removed note detail service

This commit is contained in:
zadam
2020-02-02 10:41:43 +01:00
parent 96e2b9bc18
commit 3cd4be4e48
23 changed files with 100 additions and 97 deletions

View File

@@ -1,5 +1,3 @@
import linkService from '../services/link.js';
import noteDetailService from '../services/note_detail.js';
import treeService from '../services/tree.js';
import noteAutocompleteService from "../services/note_autocomplete.js";
import utils from "../services/utils.js";
@@ -55,33 +53,16 @@ $form.on('submit', () => {
const notePath = $autoComplete.getSelectedPath();
if (notePath) {
const linkTitle = $linkTitle.val();
$dialog.modal('hide');
const linkHref = '#' + notePath;
const editor = noteDetailService.getActiveEditor();
if (hasSelection()) {
editor.execute('link', linkHref);
}
else {
linkService.addLinkToEditor(linkTitle, linkHref);
}
editor.editing.view.focus();
appContext.trigger(`addLinkToActiveEditor`, {
linkTitle: $linkTitle.val(),
linkHref: '#' + notePath
});
}
else {
console.error("No path to add link.");
}
return false;
});
// returns true if user selected some text, false if there's no selection
function hasSelection() {
const model = noteDetailService.getActiveEditor().model;
const selection = model.document.selection;
return !selection.isCollapsed;
}
});

View File

@@ -1,7 +1,6 @@
import libraryLoader from "../services/library_loader.js";
import toastService from "../services/toast.js";
import utils from "../services/utils.js";
import noteDetailService from "../services/note_detail.js";
import appContext from "../services/app_context.js";
const $dialog = $('#markdown-import-dialog');
@@ -17,13 +16,16 @@ async function convertMarkdownToHtml(text) {
const result = writer.render(parsed);
const textEditor = noteDetailService.getActiveEditor();
const viewFragment = textEditor.data.processor.toView(result);
const modelFragment = textEditor.data.toModel(viewFragment);
appContext.trigger('executeInActiveEditor', {
callback: textEditor => {
const viewFragment = textEditor.data.processor.toView(result);
const modelFragment = textEditor.data.toModel(viewFragment);
textEditor.model.insertContent(modelFragment, textEditor.model.document.selection);
textEditor.model.insertContent(modelFragment, textEditor.model.document.selection);
toastService.showMessage("Markdown content has been imported into the document.");
toastService.showMessage("Markdown content has been imported into the document.");
}
});
}
export async function importMarkdownInline() {