upgrade CKEditor to 1.0 beta.2, fixes #93

This commit is contained in:
azivner 2018-04-12 20:03:23 -04:00
parent 7a94e21c54
commit cdad18551a
5 changed files with 14 additions and 13 deletions

View File

@ -45,8 +45,8 @@ async function showDialog() {
$clonePrefix.val(''); $clonePrefix.val('');
$linkTitle.val(''); $linkTitle.val('');
function setDefaultLinkTitle(noteId) { async function setDefaultLinkTitle(noteId) {
const noteTitle = treeUtils.getNoteTitle(noteId); const noteTitle = await treeUtils.getNoteTitle(noteId);
$linkTitle.val(noteTitle); $linkTitle.val(noteTitle);
} }
@ -54,7 +54,7 @@ async function showDialog() {
$autoComplete.autocomplete({ $autoComplete.autocomplete({
source: await autocompleteService.getAutocompleteItems(), source: await autocompleteService.getAutocompleteItems(),
minLength: 0, minLength: 0,
change: () => { change: async () => {
const val = $autoComplete.val(); const val = $autoComplete.val();
const notePath = linkService.getNodePathFromLabel(val); const notePath = linkService.getNodePathFromLabel(val);
if (!notePath) { if (!notePath) {
@ -64,16 +64,16 @@ async function showDialog() {
const noteId = treeUtils.getNoteIdFromNotePath(notePath); const noteId = treeUtils.getNoteIdFromNotePath(notePath);
if (noteId) { if (noteId) {
setDefaultLinkTitle(noteId); await setDefaultLinkTitle(noteId);
} }
}, },
// 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: async (event, ui) => {
const notePath = linkService.getNodePathFromLabel(ui.item.value); const notePath = linkService.getNodePathFromLabel(ui.item.value);
const noteId = treeUtils.getNoteIdFromNotePath(notePath); const noteId = treeUtils.getNoteIdFromNotePath(notePath);
setDefaultLinkTitle(noteId); await setDefaultLinkTitle(noteId);
} }
}); });
} }

View File

@ -76,9 +76,11 @@ function goToLink(e) {
function addLinkToEditor(linkTitle, linkHref) { function addLinkToEditor(linkTitle, linkHref) {
const editor = noteDetailText.getEditor(); const editor = noteDetailText.getEditor();
const doc = editor.document;
doc.enqueueChanges(() => editor.data.insertLink(linkTitle, linkHref), doc.selection); editor.model.change( writer => {
const insertPosition = editor.model.document.selection.getFirstPosition();
writer.insertText(linkTitle, { linkHref: linkHref }, insertPosition);
});
} }
function addTextToEditor(text) { function addTextToEditor(text) {

View File

@ -11,11 +11,10 @@ async function show() {
textEditor = await BalloonEditor.create($noteDetailText[0], {}); textEditor = await BalloonEditor.create($noteDetailText[0], {});
textEditor.document.on('change', noteDetailService.noteChanged); textEditor.model.document.on('change', noteDetailService.noteChanged);
} }
// temporary workaround for https://github.com/ckeditor/ckeditor5-enter/issues/49 textEditor.setData(noteDetailService.getCurrentNote().content);
textEditor.setData(noteDetailService.getCurrentNote().content || "<p></p>");
$noteDetailText.show(); $noteDetailText.show();
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long