fix access to editor instance if active note is not text

This commit is contained in:
zadam
2019-05-19 09:13:13 +02:00
parent 8c46e96397
commit 722380e7b8
4 changed files with 30 additions and 14 deletions

View File

@@ -73,21 +73,25 @@ function goToLink(e) {
}
function addLinkToEditor(linkTitle, linkHref) {
const editor = noteDetailService.getActiveComponent().getEditor();
const editor = noteDetailService.getActiveEditor();
editor.model.change( writer => {
const insertPosition = editor.model.document.selection.getFirstPosition();
writer.insertText(linkTitle, { linkHref: linkHref }, insertPosition);
});
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.getActiveComponent().getEditor();
const editor = noteDetailService.getActiveEditor();
editor.model.change(writer => {
const insertPosition = editor.model.document.selection.getFirstPosition();
writer.insertText(text, insertPosition);
});
if (editor) {
editor.model.change(writer => {
const insertPosition = editor.model.document.selection.getFirstPosition();
writer.insertText(text, insertPosition);
});
}
}
function init() {