Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
correctly parsing the click position
zadam1c97310e92aa
diff --git a/src/public/app/widgets/note_attributes.js b/src/public/app/widgets/note_attributes.jsindex 5b2ab5478f..1c32143f56 100644--- a/src/public/app/widgets/note_attributes.js+++ b/src/public/app/widgets/note_attributes.js@@ -392,10 +392,9 @@ export default class NoteAttributesWidget extends TabAwareWidget {const pos = this.textEditor.model.document.selection.getFirstPosition();if (pos && pos.textNode && pos.textNode.data) {- const attrText = pos.textNode.data;- const clickIndex = pos.offset - pos.textNode.startOffset;+ const clickIndex = this.getClickIndex(pos);- const parsedAttrs = attributesParser.lexAndParse(attrText, true);+ const parsedAttrs = attributesParser.lexAndParse(this.textEditor.getData(), true);let matchedAttr = null;@@ -416,6 +415,24 @@ export default class NoteAttributesWidget extends TabAwareWidget {}}+ getClickIndex(pos) {+ let clickIndex = pos.offset - pos.textNode.startOffset;++ let curNode = pos.textNode;++ while (curNode.previousSibling) {+ curNode = curNode.previousSibling;++ if (curNode.name === 'reference') {+ clickIndex += curNode._attrs.get('notePath').length + 1;+ } else {+ clickIndex += curNode.data.length;+ }+ }++ return clickIndex;+ }+async loadReferenceLinkTitle(noteId, $el) {const note = await treeCache.getNote(noteId, true);