refactored KB handling and add link dialog

This commit is contained in:
zadam
2020-02-15 22:12:05 +01:00
parent b2a48a1f3a
commit 7e41a2750c
14 changed files with 211 additions and 160 deletions

View File

@@ -9,14 +9,13 @@ const $autoComplete = $("#add-link-note-autocomplete");
const $linkTitle = $("#link-title");
const $addLinkTitleFormGroup = $("#add-link-title-form-group");
export async function showDialog() {
appContext.trigger('executeInActiveEditor', {
callback: textEditor => {
const hasSelection = !textEditor.model.document.selection.isCollapsed;
/** @var TextTypeWidget */
let textTypeWidget;
$addLinkTitleFormGroup.toggle(!hasSelection);
}
});
export async function showDialog(widget) {
textTypeWidget = widget;
$addLinkTitleFormGroup.toggle(!textTypeWidget.hasSelection());
utils.openDialog($dialog);
@@ -58,10 +57,7 @@ $form.on('submit', () => {
if (notePath) {
$dialog.modal('hide');
appContext.trigger(`addLinkToActiveEditor`, {
linkTitle: $linkTitle.val(),
linkHref: '#' + notePath
});
textTypeWidget.addLink($linkTitle.val(), '#' + notePath);
}
else {
console.error("No path to add link.");