mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
basic implementation of reference link functionality
This commit is contained in:
parent
d927865cbd
commit
9b17e9976e
@ -56,7 +56,7 @@ $form.on('submit', () => {
|
||||
if (notePath) {
|
||||
$dialog.modal('hide');
|
||||
|
||||
textTypeWidget.addLink($linkTitle.val(), '#' + notePath);
|
||||
textTypeWidget.addLink(notePath, $linkTitle.val());
|
||||
}
|
||||
else {
|
||||
console.error("No path to add link.");
|
||||
|
@ -117,6 +117,11 @@ $(window).on('hashchange', function() {
|
||||
if (isNotePathInAddress()) {
|
||||
const [notePath, tabId] = treeService.getHashValueFromAddress();
|
||||
|
||||
if (!notePath) {
|
||||
console.log(`Invalid hash value "${document.location.hash}", ignoring.`);
|
||||
return;
|
||||
}
|
||||
|
||||
appContext.tabManager.switchToTab(tabId, notePath);
|
||||
}
|
||||
});
|
||||
|
@ -4,6 +4,7 @@ import server from "./server.js";
|
||||
import libraryLoader from "./library_loader.js";
|
||||
import ws from "./ws.js";
|
||||
import protectedSessionHolder from "./protected_session_holder.js";
|
||||
import treeCache from "./tree_cache.js";
|
||||
|
||||
window.glob.PROFILING_LOG = false;
|
||||
|
||||
@ -18,6 +19,7 @@ window.glob.getActiveTabNote = () => appContext.tabManager.getActiveTabNote();
|
||||
window.glob.requireLibrary = libraryLoader.requireLibrary;
|
||||
window.glob.ESLINT = libraryLoader.ESLINT;
|
||||
window.glob.appContext = appContext; // for debugging
|
||||
window.glob.treeCache = treeCache;
|
||||
|
||||
// for CKEditor integration (button on block toolbar)
|
||||
window.glob.importMarkdownInline = async () => {
|
||||
|
@ -9,7 +9,7 @@ import treeCache from "../../services/tree_cache.js";
|
||||
import linkService from "../../services/link.js";
|
||||
import noteContentRenderer from "../../services/note_content_renderer.js";
|
||||
|
||||
const ENABLE_INSPECTOR = false;
|
||||
const ENABLE_INSPECTOR = true;
|
||||
|
||||
const mentionSetup = {
|
||||
feeds: [
|
||||
@ -135,7 +135,7 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
this.textEditor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
|
||||
|
||||
if (glob.isDev && ENABLE_INSPECTOR) {
|
||||
await import('../../libraries/ckeditor/inspector.js');
|
||||
await import('../../../libraries/ckeditor/inspector.js');
|
||||
CKEditorInspector.attach(this.textEditor);
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
this.addTextToEditor(dateString);
|
||||
}
|
||||
|
||||
async addLinkToEditor(linkTitle, linkHref) {
|
||||
async addLinkToEditor(linkHref, linkTitle) {
|
||||
await this.initialized;
|
||||
|
||||
this.textEditor.model.change(writer => {
|
||||
@ -217,14 +217,18 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
this.addTextToEditor(text);
|
||||
}
|
||||
|
||||
async addLink(linkTitle, linkHref) {
|
||||
async addLink(notePath, linkTitle) {
|
||||
await this.initialized;
|
||||
|
||||
if (linkTitle && false) {
|
||||
if (this.hasSelection()) {
|
||||
this.textEditor.execute('link', linkHref);
|
||||
this.textEditor.execute('link', '#' + notePath);
|
||||
} else {
|
||||
await this.addLinkToEditor('#' + notePath, linkTitle);
|
||||
}
|
||||
}
|
||||
else {
|
||||
await this.addLinkToEditor(linkTitle, linkHref);
|
||||
this.textEditor.execute('referenceLink', { notePath: notePath });
|
||||
}
|
||||
|
||||
this.textEditor.editing.view.focus();
|
||||
|
Loading…
x
Reference in New Issue
Block a user