mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
some fixes for CKEditor
This commit is contained in:
parent
a85bb649cb
commit
7b6ccab894
@ -10,8 +10,6 @@ const addLink = (function() {
|
|||||||
function showDialog() {
|
function showDialog() {
|
||||||
glob.activeDialog = dialogEl;
|
glob.activeDialog = dialogEl;
|
||||||
|
|
||||||
noteDetailEl.summernote('editor.saveRange');
|
|
||||||
|
|
||||||
dialogEl.dialog({
|
dialogEl.dialog({
|
||||||
modal: true,
|
modal: true,
|
||||||
width: 500
|
width: 500
|
||||||
@ -21,7 +19,7 @@ const addLink = (function() {
|
|||||||
linkTitleEl.val('');
|
linkTitleEl.val('');
|
||||||
|
|
||||||
function setDefaultLinkTitle(noteId) {
|
function setDefaultLinkTitle(noteId) {
|
||||||
const noteTitle = treeUtils.getNoteTitle(noteId);
|
const noteTitle = noteTree.getNoteTitle(noteId);
|
||||||
|
|
||||||
linkTitleEl.val(noteTitle);
|
linkTitleEl.val(noteTitle);
|
||||||
}
|
}
|
||||||
@ -31,7 +29,8 @@ const addLink = (function() {
|
|||||||
minLength: 0,
|
minLength: 0,
|
||||||
change: () => {
|
change: () => {
|
||||||
const val = autoCompleteEl.val();
|
const val = autoCompleteEl.val();
|
||||||
const noteId = link.getNodePathFromLabel(val);
|
const notePath = link.getNodePathFromLabel(val);
|
||||||
|
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
|
||||||
|
|
||||||
if (noteId) {
|
if (noteId) {
|
||||||
setDefaultLinkTitle(noteId);
|
setDefaultLinkTitle(noteId);
|
||||||
@ -40,7 +39,8 @@ const addLink = (function() {
|
|||||||
// this is called when user goes through autocomplete list with keyboard
|
// this is called when user goes through autocomplete list with keyboard
|
||||||
// at this point the item isn't selected yet so we use supplied ui.item to see WHERE the cursor is
|
// at this point the item isn't selected yet so we use supplied ui.item to see WHERE the cursor is
|
||||||
focus: (event, ui) => {
|
focus: (event, ui) => {
|
||||||
const noteId = link.getNodePathFromLabel(ui.item.value);
|
const notePath = link.getNodePathFromLabel(ui.item.value);
|
||||||
|
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
|
||||||
|
|
||||||
setDefaultLinkTitle(noteId);
|
setDefaultLinkTitle(noteId);
|
||||||
}
|
}
|
||||||
@ -57,13 +57,22 @@ const addLink = (function() {
|
|||||||
|
|
||||||
dialogEl.dialog("close");
|
dialogEl.dialog("close");
|
||||||
|
|
||||||
noteDetailEl.summernote('editor.restoreRange');
|
const editor = noteEditor.getEditor();
|
||||||
|
const doc = editor.document;
|
||||||
|
|
||||||
noteDetailEl.summernote('createLink', {
|
// doc.enqueueChanges( () => {
|
||||||
text: linkTitle,
|
// // const link = '<a href="#' + notePath + '" target="_blank">' + linkTitle + '</a>';
|
||||||
url: 'app#' + notePath,
|
//
|
||||||
isNewWindow: true
|
// editor.data.insertContent({
|
||||||
});
|
// linkHref: '#' + notePath
|
||||||
|
// }, doc.selection);
|
||||||
|
// } );
|
||||||
|
|
||||||
|
// noteDetailEl.summernote('createLink', {
|
||||||
|
// text: linkTitle,
|
||||||
|
// url: 'app#' + notePath,
|
||||||
|
// isNewWindow: true
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -82,7 +82,7 @@ $.ui.autocomplete.filter = (array, terms) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$(document).tooltip({
|
$(document).tooltip({
|
||||||
items: ".note-editable a",
|
items: "#note-detail a",
|
||||||
content: function(callback) {
|
content: function(callback) {
|
||||||
const noteId = link.getNotePathFromLink($(this).attr("href"));
|
const noteId = link.getNotePathFromLink($(this).attr("href"));
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ const link = (function() {
|
|||||||
// 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);
|
||||||
$(document).on('click', 'div.popover-content a, div.ui-tooltip-content', goToInternalNote);
|
$(document).on('click', 'div.popover-content a, div.ui-tooltip-content', goToInternalNote);
|
||||||
$(document).on('dblclick', '.note-editable a, div.ui-tooltip-content', goToInternalNote);
|
$(document).on('dblclick', '#note-detail a, div.ui-tooltip-content', goToInternalNote);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getNodePathFromLabel,
|
getNodePathFromLabel,
|
||||||
|
@ -82,12 +82,12 @@ const noteEditor = (function() {
|
|||||||
|
|
||||||
function setNoteBackgroundIfProtected(note) {
|
function setNoteBackgroundIfProtected(note) {
|
||||||
if (note.detail.is_protected) {
|
if (note.detail.is_protected) {
|
||||||
$(".note-editable").addClass("protected");
|
$("#note-detail").addClass("protected");
|
||||||
protectButton.hide();
|
protectButton.hide();
|
||||||
unprotectButton.show();
|
unprotectButton.show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(".note-editable").removeClass("protected");
|
$("#note-detail").removeClass("protected");
|
||||||
protectButton.show();
|
protectButton.show();
|
||||||
unprotectButton.hide();
|
unprotectButton.hide();
|
||||||
}
|
}
|
||||||
@ -126,9 +126,6 @@ const noteEditor = (function() {
|
|||||||
|
|
||||||
noteTitleEl.val(currentNote.detail.note_title);
|
noteTitleEl.val(currentNote.detail.note_title);
|
||||||
|
|
||||||
// Clear contents and remove all stored history. This is to prevent undo from going across notes
|
|
||||||
//noteDetailEl.summernote('reset');
|
|
||||||
|
|
||||||
editor.setData(currentNote.detail.note_text);
|
editor.setData(currentNote.detail.note_text);
|
||||||
|
|
||||||
noteChangeDisabled = false;
|
noteChangeDisabled = false;
|
||||||
@ -142,6 +139,10 @@ const noteEditor = (function() {
|
|||||||
return await server.get('notes/' + noteId);
|
return await server.get('notes/' + noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getEditor() {
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
noteTitleEl.on('input', () => {
|
noteTitleEl.on('input', () => {
|
||||||
noteChanged();
|
noteChanged();
|
||||||
@ -179,6 +180,7 @@ const noteEditor = (function() {
|
|||||||
loadNote,
|
loadNote,
|
||||||
getCurrentNote,
|
getCurrentNote,
|
||||||
getCurrentNoteId,
|
getCurrentNoteId,
|
||||||
newNoteCreated
|
newNoteCreated,
|
||||||
|
getEditor
|
||||||
};
|
};
|
||||||
})();
|
})();
|
Loading…
x
Reference in New Issue
Block a user