Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
ability to define a keyboard shortcut for paste markdown, closes #761
zadama82066d8998b
diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.htmlindex cbe5cd3ef1..9b6acb3a06 100644--- a/docs/backend_api/entities_note.js.html+++ b/docs/backend_api/entities_note.js.html@@ -959,6 +959,7 @@ class Note extends Entity {delete pojo.isContentAvailable;delete pojo.__attributeCache;+ delete pojo.__ownedAttributeCache;delete pojo.content;/** zero references to contentHash, probably can be removed */delete pojo.contentHash;diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.htmlindex dc8fc5a64b..e71c0b4079 100644--- a/docs/frontend_api/FrontendScriptApi.html+++ b/docs/frontend_api/FrontendScriptApi.html@@ -4975,6 +4975,90 @@ Internally this serializes the anonymous function into string and sends it to ba+++++++ <h4 class="name" id="waitUntilSynced"><span class="type-signature"></span>waitUntilSynced<span class="signature">()</span><span class="type-signature"></span></h4>+++++++++++++++++++<dl class="details">+++++++++++++++++++++++++++ <dt class="tag-source">Source:</dt>+ <dd class="tag-source"><ul class="dummy"><li>+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line389">line 389</a>+ </li></ul></dd>++++++++</dl>++++++++++++++++++++diff --git a/docs/frontend_api/entities_branch.js.html b/docs/frontend_api/entities_branch.js.htmlindex bf5d068793..27e633a2b0 100644--- a/docs/frontend_api/entities_branch.js.html+++ b/docs/frontend_api/entities_branch.js.html@@ -47,7 +47,7 @@ class Branch {/** @returns {NoteShort} */async getNote() {- return await this.treeCache.getNote(this.noteId);+ return this.treeCache.getNote(this.noteId);}/** @returns {boolean} true if it's top level, meaning its parent is root note */diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.htmlindex e763257203..6d22768bbf 100644--- a/docs/frontend_api/services_frontend_script_api.js.html+++ b/docs/frontend_api/services_frontend_script_api.js.html@@ -410,6 +410,11 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte* @param {function} handler*/this.bindGlobalShortcut = utils.bindGlobalShortcut;++ /**+ * @method+ */+ this.waitUntilSynced = ws.waitForMaxKnownSyncId;}export default FrontendScriptApi;</code></pre>diff --git a/src/public/javascripts/dialogs/markdown_import.js b/src/public/javascripts/dialogs/markdown_import.jsindex 56c78d8799..02465e34ab 100644--- a/src/public/javascripts/dialogs/markdown_import.js+++ b/src/public/javascripts/dialogs/markdown_import.js@@ -26,6 +26,10 @@ async function convertMarkdownToHtml(text) {}export async function importMarkdownInline() {+ if (noteDetailService.getActiveTabNoteType() !== 'text') {+ return;+ }+if (utils.isElectron()) {const {clipboard} = require('electron');const text = clipboard.readText();diff --git a/src/public/javascripts/services/entrypoints.js b/src/public/javascripts/services/entrypoints.jsindex d3d0604b22..b8f4aa1bf5 100644--- a/src/public/javascripts/services/entrypoints.js+++ b/src/public/javascripts/services/entrypoints.js@@ -132,6 +132,12 @@ function registerEntrypoints() {$("#open-dev-tools-button").toggle(utils.isElectron());+ keyboardActionService.setGlobalActionHandler("PasteMarkdownIntoText", async () => {+ const dialog = await import("../dialogs/markdown_import.js");++ dialog.importMarkdownInline();+ });+if (utils.isElectron()) {const openDevTools = () => {require('electron').remote.getCurrentWindow().toggleDevTools();diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.jsindex 7d1711bda1..d17ad38d3b 100644--- a/src/public/javascripts/services/frontend_script_api.js+++ b/src/public/javascripts/services/frontend_script_api.js@@ -384,6 +384,12 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabContethis.bindGlobalShortcut = utils.bindGlobalShortcut;/**+ * Trilium runs in backend and frontend process, when something is changed on the backend from script,+ * frontend will get asynchronously synchronized.+ *+ * This method returns a promise which resolves once all the backend -> frontend synchronization is finished.+ * Typical use case is when new note has been created, we should wait until it is synced into frontend and only then activate it.+ ** @method*/this.waitUntilSynced = ws.waitForMaxKnownSyncId;diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.jsindex 862e825893..31d7e9dee2 100644--- a/src/services/keyboard_actions.js+++ b/src/services/keyboard_actions.js@@ -250,6 +250,11 @@ const DEFAULT_KEYBOARD_ACTIONS = [actionName: "InsertDateTimeToText",defaultShortcuts: ["Alt+T"]},+ {+ actionName: "PasteMarkdownIntoText",+ defaultShortcuts: [],+ description: "Pastes Markdown from clipboard into text note"+ },{separator: "Other"