fix focusing the text editor component after adding a link, closes #523

This commit is contained in:
zadam 2019-05-13 21:13:04 +02:00
parent 75ef766649
commit 81d10fa605

View File

@ -94,15 +94,16 @@ $form.submit(() => {
$dialog.modal('hide'); $dialog.modal('hide');
const linkHref = '#' + notePath; const linkHref = '#' + notePath;
const editor = noteDetailText.getEditor();
if (hasSelection()) { if (hasSelection()) {
const editor = noteDetailText.getEditor();
editor.execute('link', linkHref); editor.execute('link', linkHref);
} }
else { else {
linkService.addLinkToEditor(linkTitle, linkHref); linkService.addLinkToEditor(linkTitle, linkHref);
} }
editor.editing.view.focus();
} }
else if (linkType === 'selected-to-active') { else if (linkType === 'selected-to-active') {
const prefix = $clonePrefix.val(); const prefix = $clonePrefix.val();
@ -145,10 +146,6 @@ function linkTypeChanged() {
$linkTypes.change(linkTypeChanged); $linkTypes.change(linkTypeChanged);
// return back focus to note text detail after quitting add link
// the problem is that cursor position is reset
$dialog.on("hidden.bs.modal", () => noteDetailText.focus());
export default { export default {
showDialog, showDialog,
showDialogForClone showDialogForClone