mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
add links in ckeditor
This commit is contained in:
parent
7ca043ebc6
commit
d2a5921489
@ -57,22 +57,7 @@ const addLink = (function() {
|
|||||||
|
|
||||||
dialogEl.dialog("close");
|
dialogEl.dialog("close");
|
||||||
|
|
||||||
const editor = noteEditor.getEditor();
|
link.addLinkToEditor(linkTitle, '#' + notePath);
|
||||||
const doc = editor.document;
|
|
||||||
|
|
||||||
// doc.enqueueChanges( () => {
|
|
||||||
// // const link = '<a href="#' + notePath + '" target="_blank">' + linkTitle + '</a>';
|
|
||||||
//
|
|
||||||
// editor.data.insertContent({
|
|
||||||
// linkHref: '#' + notePath
|
|
||||||
// }, doc.selection);
|
|
||||||
// } );
|
|
||||||
|
|
||||||
// noteDetailEl.summernote('createLink', {
|
|
||||||
// text: linkTitle,
|
|
||||||
// url: 'app#' + notePath,
|
|
||||||
// isNewWindow: true
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,8 +7,6 @@ const jumpToNote = (function() {
|
|||||||
const noteDetailEl = $('#note-detail');
|
const noteDetailEl = $('#note-detail');
|
||||||
|
|
||||||
async function showDialog() {
|
async function showDialog() {
|
||||||
noteDetailEl.summernote('editor.saveRange');
|
|
||||||
|
|
||||||
glob.activeDialog = dialogEl;
|
glob.activeDialog = dialogEl;
|
||||||
|
|
||||||
autoCompleteEl.val('');
|
autoCompleteEl.val('');
|
||||||
@ -58,15 +56,9 @@ const jumpToNote = (function() {
|
|||||||
if (notePath) {
|
if (notePath) {
|
||||||
dialogEl.dialog("close");
|
dialogEl.dialog("close");
|
||||||
|
|
||||||
noteDetailEl.summernote('editor.restoreRange');
|
|
||||||
|
|
||||||
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
|
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
|
||||||
|
|
||||||
noteDetailEl.summernote('createLink', {
|
link.addLinkToEditor(noteTree.getNoteTitle(noteId), '#' + notePath);
|
||||||
text: noteTree.getNoteTitle(noteId),
|
|
||||||
url: 'app#' + notePath,
|
|
||||||
isNewWindow: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (action === 'add-current-as-child') {
|
else if (action === 'add-current-as-child') {
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
const recentNotes = (function() {
|
const recentNotes = (function() {
|
||||||
const dialogEl = $("#recent-notes-dialog");
|
const dialogEl = $("#recent-notes-dialog");
|
||||||
const selectBoxEl = $('#recent-notes-select-box');
|
const selectBoxEl = $('#recent-notes-select-box');
|
||||||
const jumpToButtonEl = $('#recentNotesJumpTo');
|
const jumpToButtonEl = $('#recent-notes-jump-to');
|
||||||
const addLinkButtonEl = $('#recentNotesAddLink');
|
const addLinkButtonEl = $('#recent-notes-add-link');
|
||||||
const addCurrentAsChildEl = $("#recent-notes-add-current-as-child");
|
const addCurrentAsChildEl = $("#recent-notes-add-current-as-child");
|
||||||
const addRecentAsChildEl = $("#recent-notes-add-recent-as-child");
|
const addRecentAsChildEl = $("#recent-notes-add-recent-as-child");
|
||||||
const noteDetailEl = $('#note-detail');
|
const noteDetailEl = $('#note-detail');
|
||||||
@ -31,8 +31,6 @@ const recentNotes = (function() {
|
|||||||
function showDialog() {
|
function showDialog() {
|
||||||
glob.activeDialog = dialogEl;
|
glob.activeDialog = dialogEl;
|
||||||
|
|
||||||
noteDetailEl.summernote('editor.saveRange');
|
|
||||||
|
|
||||||
dialogEl.dialog({
|
dialogEl.dialog({
|
||||||
modal: true,
|
modal: true,
|
||||||
width: 800
|
width: 800
|
||||||
@ -84,13 +82,7 @@ const recentNotes = (function() {
|
|||||||
|
|
||||||
dialogEl.dialog("close");
|
dialogEl.dialog("close");
|
||||||
|
|
||||||
noteDetailEl.summernote('editor.restoreRange');
|
link.addLinkToEditor(linkTitle, '#' + notePath);
|
||||||
|
|
||||||
noteDetailEl.summernote('createLink', {
|
|
||||||
text: linkTitle,
|
|
||||||
url: 'app#' + notePath,
|
|
||||||
isNewWindow: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addCurrentAsChild() {
|
async function addCurrentAsChild() {
|
||||||
|
@ -63,6 +63,13 @@ const link = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addLinkToEditor(linkTitle, linkHref) {
|
||||||
|
const editor = noteEditor.getEditor();
|
||||||
|
const doc = editor.document;
|
||||||
|
|
||||||
|
doc.enqueueChanges(() => editor.data.insertLink(linkTitle, linkHref), doc.selection);
|
||||||
|
}
|
||||||
|
|
||||||
// when click on link popup, in case of internal link, just go the the referenced note instead of default behavior
|
// when click on link popup, in case of internal link, just go the the referenced note instead of default behavior
|
||||||
// of opening the link in new window/tab
|
// of opening the link in new window/tab
|
||||||
$(document).on('click', "a[action='note']", goToInternalNote);
|
$(document).on('click', "a[action='note']", goToInternalNote);
|
||||||
@ -72,6 +79,7 @@ const link = (function() {
|
|||||||
return {
|
return {
|
||||||
getNodePathFromLabel,
|
getNodePathFromLabel,
|
||||||
getNotePathFromLink,
|
getNotePathFromLink,
|
||||||
createNoteLink
|
createNoteLink,
|
||||||
|
addLinkToEditor
|
||||||
};
|
};
|
||||||
})();
|
})();
|
@ -23,8 +23,6 @@ const noteEditor = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function noteChanged() {
|
function noteChanged() {
|
||||||
console.log("CHANGED!!!");
|
|
||||||
|
|
||||||
if (noteChangeDisabled) {
|
if (noteChangeDisabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -158,7 +156,7 @@ const noteEditor = (function() {
|
|||||||
.then(edit => {
|
.then(edit => {
|
||||||
editor = edit;
|
editor = edit;
|
||||||
|
|
||||||
editor.document.on('change', () => noteChanged);
|
editor.document.on('changesDone', noteChanged);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -305,8 +305,6 @@ const noteTree = (function() {
|
|||||||
let parentNoteId = 'root';
|
let parentNoteId = 'root';
|
||||||
|
|
||||||
for (const noteId of notePath.split('/')) {
|
for (const noteId of notePath.split('/')) {
|
||||||
console.log('noteId: ' + noteId);
|
|
||||||
|
|
||||||
titlePath.push(getNoteTitle(noteId, parentNoteId));
|
titlePath.push(getNoteTitle(noteId, parentNoteId));
|
||||||
|
|
||||||
parentNoteId = noteId;
|
parentNoteId = noteId;
|
||||||
|
2
public/libraries/ckeditor/ckeditor.js
vendored
2
public/libraries/ckeditor/ckeditor.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -14,7 +14,7 @@ async function verifyPassword(password) {
|
|||||||
async function setDataKey(password, plainTextDataKey) {
|
async function setDataKey(password, plainTextDataKey) {
|
||||||
const passwordDerivedKey = await my_scrypt.getPasswordDerivedKey(password);
|
const passwordDerivedKey = await my_scrypt.getPasswordDerivedKey(password);
|
||||||
|
|
||||||
const encryptedDataKeyIv = utils.randomSecureToken(16).slice(0, 16);
|
const encryptedDataKeyIv = utils.randomString(16);
|
||||||
|
|
||||||
await options.setOption('encrypted_data_key_iv', encryptedDataKeyIv);
|
await options.setOption('encrypted_data_key_iv', encryptedDataKeyIv);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user