mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	Merge remote-tracking branch 'origin/master' into next60
# Conflicts: # src/public/app/services/open.js # src/public/app/widgets/buttons/note_actions.js
This commit is contained in:
		
						commit
						af95d387b9
					
				@ -55,6 +55,15 @@ export default class RootCommandExecutor extends Component {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    openNoteCustomCommand() {
 | 
				
			||||||
 | 
					        const noteId = appContext.tabManager.getActiveContextNoteId();
 | 
				
			||||||
 | 
					        const mime = appContext.tabManager.getActiveContextNoteMime()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (noteId) {
 | 
				
			||||||
 | 
					            openService.openNoteCustom(noteId, mime);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    enterProtectedSessionCommand() {
 | 
					    enterProtectedSessionCommand() {
 | 
				
			||||||
        protectedSessionService.enterProtectedSession();
 | 
					        protectedSessionService.enterProtectedSession();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -1 +1 @@
 | 
				
			|||||||
<p>Keyboard launcher for this launcher action can be configured in Options -> Launchers.</p>
 | 
					<p>Keyboard shortcut for this launcher action can be configured in Options -> Shortcuts.</p>
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@
 | 
				
			|||||||
<ol>
 | 
					<ol>
 | 
				
			||||||
    <li><code>target</code> - note which should be opened upon activating the launcher</li>
 | 
					    <li><code>target</code> - note which should be opened upon activating the launcher</li>
 | 
				
			||||||
    <li><code>hoistedNote</code> - optional, will change the hoisted note before opening the target note</li>
 | 
					    <li><code>hoistedNote</code> - optional, will change the hoisted note before opening the target note</li>
 | 
				
			||||||
    <li><code>keyboardLauncher</code> - optional, pressing the keyboard launcher will open the note</li>
 | 
					    <li><code>keyboardShortcut</code> - optional, pressing the keyboard shortcut will open the note</li>
 | 
				
			||||||
</ol>
 | 
					</ol>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p>Launchbar displays the title / icon from the launcher which does not necessarily mirror those of the target note.</p>
 | 
					<p>Launchbar displays the title / icon from the launcher which does not necessarily mirror those of the target note.</p>
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<ol>
 | 
					<ol>
 | 
				
			||||||
    <li><code>script</code> - relation to the script note which should be executed upon launcher activation</li>
 | 
					    <li><code>script</code> - relation to the script note which should be executed upon launcher activation</li>
 | 
				
			||||||
    <li><code>keyboardLauncher</code> - optional, pressing the keyboard launcher will activate the launcher</li>
 | 
					    <li><code>keyboardShortcut</code> - optional, pressing the keyboard shortcut will activate the launcher</li>
 | 
				
			||||||
</ol>
 | 
					</ol>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<h4>Example script</h4>
 | 
					<h4>Example script</h4>
 | 
				
			||||||
 | 
				
			|||||||
@ -41,6 +41,62 @@ function downloadAttachment(attachmentId) {
 | 
				
			|||||||
    download(url);
 | 
					    download(url);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function openNoteCustom(noteId, mime) {
 | 
				
			||||||
 | 
					    if (utils.isElectron()) {
 | 
				
			||||||
 | 
					      const resp = await server.post(`notes/${noteId}/save-to-tmp-dir`);
 | 
				
			||||||
 | 
					      const filePath = resp.tmpFilePath;
 | 
				
			||||||
 | 
					      const { exec } = utils.dynamicRequire('child_process');
 | 
				
			||||||
 | 
					      const platform = process.platform;
 | 
				
			||||||
 | 
					      if (platform === 'linux') {
 | 
				
			||||||
 | 
					        const terminals = ['gnome-terminal', 'konsole', 'xterm', 'xfce4-terminal', 'mate-terminal', 'rxvt', 'terminator', 'terminology'];
 | 
				
			||||||
 | 
					        const openFileWithTerminal = (terminal) => {
 | 
				
			||||||
 | 
					          const command = `${terminal} -e 'mimeopen -d "${filePath}"'`;
 | 
				
			||||||
 | 
					          console.log(`Open Note custom: ${command} `);
 | 
				
			||||||
 | 
					          exec(command, (error, stdout, stderr) => {
 | 
				
			||||||
 | 
					            if (error) {
 | 
				
			||||||
 | 
					              console.error(`Open Note custom: Failed to open file with ${terminal}: ${error}`);
 | 
				
			||||||
 | 
					              searchTerminal(terminals.indexOf(terminal) + 1);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					              console.log(`Open Note custom: File opened with ${terminal}. ${stdout}`);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        const searchTerminal = (index) => {
 | 
				
			||||||
 | 
					          const terminal = terminals[index];
 | 
				
			||||||
 | 
					          if (!terminal) {
 | 
				
			||||||
 | 
					            console.error('Open Note custom: No terminal found!');
 | 
				
			||||||
 | 
					            open(getFileUrl(noteId), { url: true });
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          exec(`which ${terminal}`, (error, stdout, stderr) => {
 | 
				
			||||||
 | 
					            if (stdout.trim()) {
 | 
				
			||||||
 | 
					              openFileWithTerminal(terminal);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					              searchTerminal(index + 1);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        searchTerminal(0);
 | 
				
			||||||
 | 
					      } else if (platform === 'win32') {
 | 
				
			||||||
 | 
					        if (filePath.indexOf("/") !== -1) {
 | 
				
			||||||
 | 
					          //Note that the path separator must be \ instead of /
 | 
				
			||||||
 | 
					          filePath = filePath.replace(/\//g, "\\");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        const command = `rundll32.exe shell32.dll,OpenAs_RunDLL ` + filePath;
 | 
				
			||||||
 | 
					        exec(command, (err, stdout, stderr) => {
 | 
				
			||||||
 | 
					          if (err) {
 | 
				
			||||||
 | 
					            console.error("Open Note custom: ", err);
 | 
				
			||||||
 | 
					            open(getFileUrl(noteId), { url: true });
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        console.log('Currently "Open Note custom" only supports linux and windows systems');
 | 
				
			||||||
 | 
					        open(getFileUrl(noteId), { url: true });
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function downloadNoteRevision(noteId, noteRevisionId) {
 | 
					function downloadNoteRevision(noteId, noteRevisionId) {
 | 
				
			||||||
    const url = getUrlForDownload(`api/revisions/${noteRevisionId}/download`);
 | 
					    const url = getUrlForDownload(`api/revisions/${noteRevisionId}/download`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -108,4 +164,5 @@ export default {
 | 
				
			|||||||
    getUrlForDownload,
 | 
					    getUrlForDownload,
 | 
				
			||||||
    openNoteExternally,
 | 
					    openNoteExternally,
 | 
				
			||||||
    openAttachmentExternally,
 | 
					    openAttachmentExternally,
 | 
				
			||||||
 | 
					    openNoteCustom,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,7 @@ const TPL = `
 | 
				
			|||||||
            <kbd data-command="openNoteExternally"></kbd> 
 | 
					            <kbd data-command="openNoteExternally"></kbd> 
 | 
				
			||||||
            Open note externally
 | 
					            Open note externally
 | 
				
			||||||
        </a>
 | 
					        </a>
 | 
				
			||||||
 | 
					        <a data-trigger-command="openNoteCustom" class="dropdown-item open-note-custom-button"><kbd data-command="openNoteCustom"></kbd> Open note custom (beta)</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>
 | 
				
			||||||
@ -79,6 +80,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
        this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle'));
 | 
					        this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$openNoteExternallyButton = this.$widget.find(".open-note-externally-button");
 | 
					        this.$openNoteExternallyButton = this.$widget.find(".open-note-externally-button");
 | 
				
			||||||
 | 
					        this.$openNoteCustomButton = this.$widget.find(".open-note-custom-button");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$deleteNoteButton = this.$widget.find(".delete-note-button");
 | 
					        this.$deleteNoteButton = this.$widget.find(".delete-note-button");
 | 
				
			||||||
        this.$deleteNoteButton.on("click", () => {
 | 
					        this.$deleteNoteButton.on("click", () => {
 | 
				
			||||||
@ -102,6 +104,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());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async convertNoteIntoAttachmentCommand() {
 | 
					    async convertNoteIntoAttachmentCommand() {
 | 
				
			||||||
 | 
				
			|||||||
@ -51,7 +51,7 @@ const TPL = `
 | 
				
			|||||||
        cursor: text !important;
 | 
					        cursor: text !important;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    .note-detail-editable-text *:not(figure):first-child {
 | 
					    .note-detail-editable-text *:not(figure,.include-note):first-child {
 | 
				
			||||||
        margin-top: 0 !important;
 | 
					        margin-top: 0 !important;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
         
 | 
					         
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user