converted more keyboard actions

This commit is contained in:
zadam
2020-01-21 22:54:16 +01:00
parent af5c623671
commit c63bb7ce8a
9 changed files with 136 additions and 156 deletions

View File

@@ -2,6 +2,7 @@ import treeService from './tree.js';
import treeUtils from './tree_utils.js';
import contextMenuService from "./context_menu.js";
import noteDetailService from "./note_detail.js";
import appContext from "./app_context.js";
function getNotePathFromUrl(url) {
const notePathMatch = /#(root[A-Za-z0-9/]*)$/.exec(url);
@@ -98,28 +99,6 @@ function goToLink(e) {
return true;
}
function addLinkToEditor(linkTitle, linkHref) {
const editor = noteDetailService.getActiveEditor();
if (editor) {
editor.model.change(writer => {
const insertPosition = editor.model.document.selection.getFirstPosition();
writer.insertText(linkTitle, {linkHref: linkHref}, insertPosition);
});
}
}
function addTextToEditor(text) {
const editor = noteDetailService.getActiveEditor();
if (editor) {
editor.model.change(writer => {
const insertPosition = editor.model.document.selection.getFirstPosition();
writer.insertText(text, insertPosition);
});
}
}
function newTabContextMenu(e) {
const $link = $(e.target).closest("a");
@@ -188,7 +167,5 @@ $(document).on('contextmenu', ".note-detail-render a", newTabContextMenu);
export default {
getNotePathFromUrl,
createNoteLink,
addLinkToEditor,
addTextToEditor,
goToLink
};