add links in ckeditor

This commit is contained in:
azivner 2017-12-09 14:11:35 -05:00
parent 7ca043ebc6
commit d2a5921489
9 changed files with 18 additions and 45 deletions

View File

@ -57,22 +57,7 @@ const addLink = (function() {
dialogEl.dialog("close");
const editor = noteEditor.getEditor();
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
// });
link.addLinkToEditor(linkTitle, '#' + notePath);
}
return false;

View File

@ -7,8 +7,6 @@ const jumpToNote = (function() {
const noteDetailEl = $('#note-detail');
async function showDialog() {
noteDetailEl.summernote('editor.saveRange');
glob.activeDialog = dialogEl;
autoCompleteEl.val('');
@ -58,15 +56,9 @@ const jumpToNote = (function() {
if (notePath) {
dialogEl.dialog("close");
noteDetailEl.summernote('editor.restoreRange');
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
noteDetailEl.summernote('createLink', {
text: noteTree.getNoteTitle(noteId),
url: 'app#' + notePath,
isNewWindow: true
});
link.addLinkToEditor(noteTree.getNoteTitle(noteId), '#' + notePath);
}
}
else if (action === 'add-current-as-child') {

View File

@ -3,8 +3,8 @@
const recentNotes = (function() {
const dialogEl = $("#recent-notes-dialog");
const selectBoxEl = $('#recent-notes-select-box');
const jumpToButtonEl = $('#recentNotesJumpTo');
const addLinkButtonEl = $('#recentNotesAddLink');
const jumpToButtonEl = $('#recent-notes-jump-to');
const addLinkButtonEl = $('#recent-notes-add-link');
const addCurrentAsChildEl = $("#recent-notes-add-current-as-child");
const addRecentAsChildEl = $("#recent-notes-add-recent-as-child");
const noteDetailEl = $('#note-detail');
@ -31,8 +31,6 @@ const recentNotes = (function() {
function showDialog() {
glob.activeDialog = dialogEl;
noteDetailEl.summernote('editor.saveRange');
dialogEl.dialog({
modal: true,
width: 800
@ -84,13 +82,7 @@ const recentNotes = (function() {
dialogEl.dialog("close");
noteDetailEl.summernote('editor.restoreRange');
noteDetailEl.summernote('createLink', {
text: linkTitle,
url: 'app#' + notePath,
isNewWindow: true
});
link.addLinkToEditor(linkTitle, '#' + notePath);
}
async function addCurrentAsChild() {

View File

@ -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
// of opening the link in new window/tab
$(document).on('click', "a[action='note']", goToInternalNote);
@ -72,6 +79,7 @@ const link = (function() {
return {
getNodePathFromLabel,
getNotePathFromLink,
createNoteLink
createNoteLink,
addLinkToEditor
};
})();

View File

@ -23,8 +23,6 @@ const noteEditor = (function() {
}
function noteChanged() {
console.log("CHANGED!!!");
if (noteChangeDisabled) {
return;
}
@ -158,7 +156,7 @@ const noteEditor = (function() {
.then(edit => {
editor = edit;
editor.document.on('change', () => noteChanged);
editor.document.on('changesDone', noteChanged);
})
.catch(error => {
console.error(error);

View File

@ -305,8 +305,6 @@ const noteTree = (function() {
let parentNoteId = 'root';
for (const noteId of notePath.split('/')) {
console.log('noteId: ' + noteId);
titlePath.push(getNoteTitle(noteId, parentNoteId));
parentNoteId = noteId;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@ async function verifyPassword(password) {
async function setDataKey(password, plainTextDataKey) {
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);