mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	correctly parsing the click position
This commit is contained in:
		
							parent
							
								
									0ecb2f3662
								
							
						
					
					
						commit
						1c97310e92
					
				@ -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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user