From 7cf47520d42588d99be96a3c05f8d2e2a451834a Mon Sep 17 00:00:00 2001 From: baiyongjie <407221377@qq.com> Date: Thu, 11 May 2023 10:54:20 +0800 Subject: [PATCH 1/8] fix included note display --- src/public/app/widgets/type_widgets/editable_text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.js index 826a9eab3..10004e736 100644 --- a/src/public/app/widgets/type_widgets/editable_text.js +++ b/src/public/app/widgets/type_widgets/editable_text.js @@ -51,7 +51,7 @@ const TPL = ` 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; } From cf4201b084932d4d55a1b54158ebc9f20273af00 Mon Sep 17 00:00:00 2001 From: MeIchthys <10717998+meichthys@users.noreply.github.com> Date: Mon, 15 May 2023 10:11:07 -0400 Subject: [PATCH 2/8] update keyboardlauncher to keyboardShortcut --- src/public/app/doc_notes/launchbar_note_launcher.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/doc_notes/launchbar_note_launcher.html b/src/public/app/doc_notes/launchbar_note_launcher.html index 74b28296a..7e61eee0a 100644 --- a/src/public/app/doc_notes/launchbar_note_launcher.html +++ b/src/public/app/doc_notes/launchbar_note_launcher.html @@ -3,7 +3,7 @@
  1. target - note which should be opened upon activating the launcher
  2. hoistedNote - optional, will change the hoisted note before opening the target note
  3. -
  4. keyboardLauncher - optional, pressing the keyboard launcher will open the note
  5. +
  6. keyboardShortcut - optional, pressing the keyboard shortcut will open the note

Launchbar displays the title / icon from the launcher which does not necessarily mirrors those of the target note.

From aee520a2094f55b208842b082606a44a2bfbfaa4 Mon Sep 17 00:00:00 2001 From: MeIchthys <10717998+meichthys@users.noreply.github.com> Date: Mon, 15 May 2023 10:12:43 -0400 Subject: [PATCH 3/8] Change keyboardLauncher to keyboardShortcut --- src/public/app/doc_notes/launchbar_script_launcher.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/doc_notes/launchbar_script_launcher.html b/src/public/app/doc_notes/launchbar_script_launcher.html index 0a17bf523..49e315487 100644 --- a/src/public/app/doc_notes/launchbar_script_launcher.html +++ b/src/public/app/doc_notes/launchbar_script_launcher.html @@ -2,7 +2,7 @@
  1. script - relation to the script note which should be executed upon launcher activation
  2. -
  3. keyboardLauncher - optional, pressing the keyboard launcher will activate the launcher
  4. +
  5. keyboardShortcut - optional, pressing the keyboard shortcut will activate the launcher

Example script

From 9968cba3482b9043690e5a56baea9e4ea4942b31 Mon Sep 17 00:00:00 2001 From: MeIchthys <10717998+meichthys@users.noreply.github.com> Date: Mon, 15 May 2023 10:15:14 -0400 Subject: [PATCH 4/8] singluarify 'mirrors' --- src/public/app/doc_notes/launchbar_note_launcher.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/doc_notes/launchbar_note_launcher.html b/src/public/app/doc_notes/launchbar_note_launcher.html index 7e61eee0a..403c6e2b4 100644 --- a/src/public/app/doc_notes/launchbar_note_launcher.html +++ b/src/public/app/doc_notes/launchbar_note_launcher.html @@ -6,4 +6,4 @@
  • keyboardShortcut - optional, pressing the keyboard shortcut will open the note
  • -

    Launchbar displays the title / icon from the launcher which does not necessarily mirrors those of the target note.

    +

    Launchbar displays the title / icon from the launcher which does not necessarily mirror those of the target note.

    From 470a0c7b21247a7617ad69138d8eedfa82a403eb Mon Sep 17 00:00:00 2001 From: MeIchthys <10717998+meichthys@users.noreply.github.com> Date: Mon, 15 May 2023 10:21:40 -0400 Subject: [PATCH 5/8] Update launchbar_command_launcher.html to refer to shortcuts --- src/public/app/doc_notes/launchbar_command_launcher.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/doc_notes/launchbar_command_launcher.html b/src/public/app/doc_notes/launchbar_command_launcher.html index eb228f06a..68eb051a2 100644 --- a/src/public/app/doc_notes/launchbar_command_launcher.html +++ b/src/public/app/doc_notes/launchbar_command_launcher.html @@ -1 +1 @@ -

    Keyboard launcher for this launcher action can be configured in Options -> Launchers.

    +

    Keyboard shortcut for this launcher action can be configured in Options -> Shortcuts.

    From 412fd105c9ed336a941d811fabe8962b552666d7 Mon Sep 17 00:00:00 2001 From: SnnBcd xt <1160925501@qq.com> Date: Tue, 16 May 2023 06:22:15 +0000 Subject: [PATCH 6/8] open-note-custom-test --- src/public/app/widgets/buttons/note_actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/widgets/buttons/note_actions.js b/src/public/app/widgets/buttons/note_actions.js index fb2c19918..68406eb08 100644 --- a/src/public/app/widgets/buttons/note_actions.js +++ b/src/public/app/widgets/buttons/note_actions.js @@ -28,7 +28,7 @@ const TPL = ` Re-render note Search in note Note source - Open note externally + Open note externally11 Import files Export note Delete note From 9fc474504b87ffbfe0fda6ca639f268d3f8ebe9b Mon Sep 17 00:00:00 2001 From: SnnBcd xt <1160925501@qq.com> Date: Tue, 16 May 2023 11:57:28 +0000 Subject: [PATCH 7/8] Open notes with custom software --- .../app/components/root_command_executor.js | 9 +++ src/public/app/services/open.js | 73 +++++++++++++++++++ .../app/widgets/buttons/note_actions.js | 5 +- 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/src/public/app/components/root_command_executor.js b/src/public/app/components/root_command_executor.js index bac07af70..63d86ae46 100644 --- a/src/public/app/components/root_command_executor.js +++ b/src/public/app/components/root_command_executor.js @@ -54,6 +54,15 @@ export default class RootCommandExecutor extends Component { openService.openNoteExternally(noteId, mime); } } + + openNoteCustomCommand() { + const noteId = appContext.tabManager.getActiveContextNoteId(); + const mime = appContext.tabManager.getActiveContextNoteMime() + + if (noteId) { + openService.openNoteCustom(noteId, mime); + } + } enterProtectedSessionCommand() { protectedSessionService.enterProtectedSession(); diff --git a/src/public/app/services/open.js b/src/public/app/services/open.js index 2d0ef6091..fa5959642 100644 --- a/src/public/app/services/open.js +++ b/src/public/app/services/open.js @@ -47,6 +47,78 @@ async function openNoteExternally(noteId, mime) { } } +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']; + let foundTerminal = false; + let availableTerminal = null; + 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}. `); + console.log(`Open Note custom: ${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()) { + foundTerminal = true; + availableTerminal = terminal; + } + if (foundTerminal) { + openFileWithTerminal(availableTerminal); + } 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 }); + } + } + else { + // allow browser to handle opening common file + if (mime === "application/pdf" || mime.startsWith("image") || mime.startsWith("audio") || mime.startsWith("video")) { + window.open(getOpenFileUrl(noteId)); + } + else { + window.location.href = getFileUrl(noteId); + } + } + } + function downloadNoteRevision(noteId, noteRevisionId) { const url = getUrlForDownload(`api/notes/${noteId}/revisions/${noteRevisionId}/download`); @@ -76,6 +148,7 @@ export default { download, downloadFileNote, openNoteExternally, + openNoteCustom, downloadNoteRevision, getUrlForDownload } diff --git a/src/public/app/widgets/buttons/note_actions.js b/src/public/app/widgets/buttons/note_actions.js index 68406eb08..de2ad33f9 100644 --- a/src/public/app/widgets/buttons/note_actions.js +++ b/src/public/app/widgets/buttons/note_actions.js @@ -28,7 +28,8 @@ const TPL = ` Re-render note Search in note Note source - Open note externally11 + Open note externally + Open note custom (beta) Import files Export note Delete note @@ -67,6 +68,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget { this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle')); 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.on("click", () => { @@ -88,6 +90,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget { this.$renderNoteButton.toggle(note.type === 'render'); this.$openNoteExternallyButton.toggle(utils.isElectron()); + this.$openNoteCustomButton.toggle(utils.isElectron()); } toggleDisabled($el, enable) { From 7c7bea5e3a0a1c98241e379c6a23c18871a0c843 Mon Sep 17 00:00:00 2001 From: SnnBcd xt <1160925501@qq.com> Date: Tue, 16 May 2023 14:01:55 +0000 Subject: [PATCH 8/8] Open notes with custom software. --- src/public/app/services/open.js | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/public/app/services/open.js b/src/public/app/services/open.js index fa5959642..9d6f3c931 100644 --- a/src/public/app/services/open.js +++ b/src/public/app/services/open.js @@ -55,18 +55,15 @@ async function openNoteCustom(noteId, mime) { const platform = process.platform; if (platform === 'linux') { const terminals = ['gnome-terminal', 'konsole', 'xterm', 'xfce4-terminal', 'mate-terminal', 'rxvt', 'terminator', 'terminology']; - let foundTerminal = false; - let availableTerminal = null; const openFileWithTerminal = (terminal) => { const command = `${terminal} -e 'mimeopen -d "${filePath}"'`; - console.log(`Open Note custom: ${command}. `); + 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}. `); - console.log(`Open Note custom: ${stdout}. `); + console.log(`Open Note custom: File opened with ${terminal}. ${stdout}`); } }); }; @@ -79,11 +76,7 @@ async function openNoteCustom(noteId, mime) { } exec(`which ${terminal}`, (error, stdout, stderr) => { if (stdout.trim()) { - foundTerminal = true; - availableTerminal = terminal; - } - if (foundTerminal) { - openFileWithTerminal(availableTerminal); + openFileWithTerminal(terminal); } else { searchTerminal(index + 1); } @@ -108,15 +101,6 @@ async function openNoteCustom(noteId, mime) { open(getFileUrl(noteId), { url: true }); } } - else { - // allow browser to handle opening common file - if (mime === "application/pdf" || mime.startsWith("image") || mime.startsWith("audio") || mime.startsWith("video")) { - window.open(getOpenFileUrl(noteId)); - } - else { - window.location.href = getFileUrl(noteId); - } - } } function downloadNoteRevision(noteId, noteRevisionId) {