mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
ability to define a keyboard shortcut for paste markdown, closes #761
This commit is contained in:
parent
45c5287d53
commit
a82066d899
@ -959,6 +959,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
delete pojo.isContentAvailable;
|
delete pojo.isContentAvailable;
|
||||||
delete pojo.__attributeCache;
|
delete pojo.__attributeCache;
|
||||||
|
delete pojo.__ownedAttributeCache;
|
||||||
delete pojo.content;
|
delete pojo.content;
|
||||||
/** zero references to contentHash, probably can be removed */
|
/** zero references to contentHash, probably can be removed */
|
||||||
delete pojo.contentHash;
|
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} */
|
/** @returns {NoteShort} */
|
||||||
async getNote() {
|
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 */
|
/** @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
|
* @param {function} handler
|
||||||
*/
|
*/
|
||||||
this.bindGlobalShortcut = utils.bindGlobalShortcut;
|
this.bindGlobalShortcut = utils.bindGlobalShortcut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method
|
||||||
|
*/
|
||||||
|
this.waitUntilSynced = ws.waitForMaxKnownSyncId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FrontendScriptApi;</code></pre>
|
export default FrontendScriptApi;</code></pre>
|
||||||
|
@ -26,6 +26,10 @@ async function convertMarkdownToHtml(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function importMarkdownInline() {
|
export async function importMarkdownInline() {
|
||||||
|
if (noteDetailService.getActiveTabNoteType() !== 'text') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
const {clipboard} = require('electron');
|
const {clipboard} = require('electron');
|
||||||
const text = clipboard.readText();
|
const text = clipboard.readText();
|
||||||
|
@ -132,6 +132,12 @@ function registerEntrypoints() {
|
|||||||
|
|
||||||
$("#open-dev-tools-button").toggle(utils.isElectron());
|
$("#open-dev-tools-button").toggle(utils.isElectron());
|
||||||
|
|
||||||
|
keyboardActionService.setGlobalActionHandler("PasteMarkdownIntoText", async () => {
|
||||||
|
const dialog = await import("../dialogs/markdown_import.js");
|
||||||
|
|
||||||
|
dialog.importMarkdownInline();
|
||||||
|
});
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
const openDevTools = () => {
|
const openDevTools = () => {
|
||||||
require('electron').remote.getCurrentWindow().toggleDevTools();
|
require('electron').remote.getCurrentWindow().toggleDevTools();
|
||||||
|
@ -384,6 +384,12 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
|
|||||||
this.bindGlobalShortcut = utils.bindGlobalShortcut;
|
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
|
* @method
|
||||||
*/
|
*/
|
||||||
this.waitUntilSynced = ws.waitForMaxKnownSyncId;
|
this.waitUntilSynced = ws.waitForMaxKnownSyncId;
|
||||||
|
@ -250,6 +250,11 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
|||||||
actionName: "InsertDateTimeToText",
|
actionName: "InsertDateTimeToText",
|
||||||
defaultShortcuts: ["Alt+T"]
|
defaultShortcuts: ["Alt+T"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
actionName: "PasteMarkdownIntoText",
|
||||||
|
defaultShortcuts: [],
|
||||||
|
description: "Pastes Markdown from clipboard into text note"
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
separator: "Other"
|
separator: "Other"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user