mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	cleanup note open custom
This commit is contained in:
		
							parent
							
								
									bd8429a0ba
								
							
						
					
					
						commit
						88a961180f
					
				| @ -57,10 +57,8 @@ export default class RootCommandExecutor extends Component { | |||||||
| 
 | 
 | ||||||
|     openNoteCustomCommand() { |     openNoteCustomCommand() { | ||||||
|         const noteId = appContext.tabManager.getActiveContextNoteId(); |         const noteId = appContext.tabManager.getActiveContextNoteId(); | ||||||
|         const mime = appContext.tabManager.getActiveContextNoteMime() |  | ||||||
| 
 |  | ||||||
|         if (noteId) { |         if (noteId) { | ||||||
|             openService.openNoteCustom(noteId, mime); |             openService.openNoteCustom(noteId); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -47,14 +47,19 @@ async function openNoteExternally(noteId, mime) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function openNoteCustom(noteId, mime) { | async function openNoteCustom(noteId) { | ||||||
|     if (utils.isElectron()) { |     if (!utils.isElectron() || utils.isMac()) { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     const resp = await server.post(`notes/${noteId}/save-to-tmp-dir`); |     const resp = await server.post(`notes/${noteId}/save-to-tmp-dir`); | ||||||
|       const filePath = resp.tmpFilePath; |     let filePath = resp.tmpFilePath; | ||||||
|     const {exec} = utils.dynamicRequire('child_process'); |     const {exec} = utils.dynamicRequire('child_process'); | ||||||
|     const platform = process.platform; |     const platform = process.platform; | ||||||
|  | 
 | ||||||
|     if (platform === 'linux') { |     if (platform === 'linux') { | ||||||
|         const terminals = ['gnome-terminal', 'konsole', 'xterm', 'xfce4-terminal', 'mate-terminal', 'rxvt', 'terminator', 'terminology']; |         // we don't know which terminal is available, try in succession
 | ||||||
|  |         const terminals = ['x-terminal-emulator', 'gnome-terminal', 'konsole', 'xterm', 'xfce4-terminal', 'mate-terminal', 'rxvt', 'terminator', 'terminology']; | ||||||
|         const openFileWithTerminal = (terminal) => { |         const openFileWithTerminal = (terminal) => { | ||||||
|             const command = `${terminal} -e 'mimeopen -d "${filePath}"'`; |             const command = `${terminal} -e 'mimeopen -d "${filePath}"'`; | ||||||
|             console.log(`Open Note custom: ${command} `); |             console.log(`Open Note custom: ${command} `); | ||||||
| @ -63,10 +68,11 @@ async function openNoteCustom(noteId, mime) { | |||||||
|                     console.error(`Open Note custom: Failed to open file with ${terminal}: ${error}`); |                     console.error(`Open Note custom: Failed to open file with ${terminal}: ${error}`); | ||||||
|                     searchTerminal(terminals.indexOf(terminal) + 1); |                     searchTerminal(terminals.indexOf(terminal) + 1); | ||||||
|                 } else { |                 } else { | ||||||
|               console.log(`Open Note custom: File opened with ${terminal}. ${stdout}`); |                     console.log(`Open Note custom: File opened with ${terminal}: ${stdout}`); | ||||||
|                 } |                 } | ||||||
|             }); |             }); | ||||||
|         }; |         }; | ||||||
|  | 
 | ||||||
|         const searchTerminal = (index) => { |         const searchTerminal = (index) => { | ||||||
|             const terminal = terminals[index]; |             const terminal = terminals[index]; | ||||||
|             if (!terminal) { |             if (!terminal) { | ||||||
| @ -101,7 +107,6 @@ async function openNoteCustom(noteId, mime) { | |||||||
|         open(getFileUrl(noteId), {url: true}); |         open(getFileUrl(noteId), {url: true}); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
| function downloadNoteRevision(noteId, noteRevisionId) { | function downloadNoteRevision(noteId, noteRevisionId) { | ||||||
|     const url = getUrlForDownload(`api/notes/${noteId}/revisions/${noteRevisionId}/download`); |     const url = getUrlForDownload(`api/notes/${noteId}/revisions/${noteRevisionId}/download`); | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ const TPL = ` | |||||||
|         <a data-trigger-command="findInText" class="dropdown-item find-in-text-button">Search in note <kbd data-command="findInText"></a> |         <a data-trigger-command="findInText" class="dropdown-item find-in-text-button">Search in note <kbd data-command="findInText"></a> | ||||||
|         <a data-trigger-command="showNoteSource" class="dropdown-item show-source-button"><kbd data-command="showNoteSource"></kbd> Note source</a> |         <a data-trigger-command="showNoteSource" class="dropdown-item show-source-button"><kbd data-command="showNoteSource"></kbd> Note source</a> | ||||||
|         <a data-trigger-command="openNoteExternally" class="dropdown-item open-note-externally-button"><kbd data-command="openNoteExternally"></kbd> Open note externally</a> |         <a data-trigger-command="openNoteExternally" class="dropdown-item open-note-externally-button"><kbd data-command="openNoteExternally"></kbd> Open note externally</a> | ||||||
|         <a data-trigger-command="openNoteCustom" class="dropdown-item open-note-custom-button"><kbd data-command="openNoteCustom"></kbd> Open note custom (beta)</a> |         <a data-trigger-command="openNoteCustom" class="dropdown-item open-note-custom-button"><kbd data-command="openNoteCustom"></kbd> Open note custom</a> | ||||||
|         <a class="dropdown-item import-files-button">Import files</a> |         <a class="dropdown-item import-files-button">Import files</a> | ||||||
|         <a class="dropdown-item export-note-button">Export note</a> |         <a class="dropdown-item export-note-button">Export note</a> | ||||||
|         <a class="dropdown-item delete-note-button">Delete note</a> |         <a class="dropdown-item delete-note-button">Delete note</a> | ||||||
| @ -90,7 +90,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget { | |||||||
|         this.$renderNoteButton.toggle(note.type === 'render'); |         this.$renderNoteButton.toggle(note.type === 'render'); | ||||||
| 
 | 
 | ||||||
|         this.$openNoteExternallyButton.toggle(utils.isElectron()); |         this.$openNoteExternallyButton.toggle(utils.isElectron()); | ||||||
|         this.$openNoteCustomButton.toggle(utils.isElectron()); |         this.$openNoteCustomButton.toggle(utils.isElectron() && !utils.isMac()); // no implementation for Mac yet
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     toggleDisabled($el, enable) { |     toggleDisabled($el, enable) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam