mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 02:05:53 +01:00
removed note detail service
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user