mirror of
https://github.com/zadam/trilium.git
synced 2025-03-02 01:53:11 +08:00
ability to define a keyboard shortcut for paste markdown, closes #761
This commit is contained in:
parent
45c5287d53
commit
a82066d899
8 changed files with 112 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -384,6 +384,12 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
|
|||
this.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;
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue