]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/services/auto-links.ts
Customization: Added parent tag classes
[bookstack] / resources / js / wysiwyg / services / auto-links.ts
index 44a78ec8577c819c021f69d1e93bf0197921127c..62cd459940c0471f03c985a7c3276a4cec1b79e0 100644 (file)
@@ -27,7 +27,7 @@ function handlePotentialLinkEvent(node: TextNode, selection: BaseSelection, edit
         return;
     }
 
-    const cursorPoint = selectionRange[0].offset - 1;
+    const cursorPoint = selectionRange[0].offset;
     const nodeText = node.getTextContent();
     const rTrimText = nodeText.slice(0, cursorPoint);
     const priorSpaceIndex = rTrimText.lastIndexOf(' ');
@@ -43,7 +43,7 @@ function handlePotentialLinkEvent(node: TextNode, selection: BaseSelection, edit
         linkNode.append(new TextNode(textSegment));
 
         const splits = node.splitText(startIndex, cursorPoint);
-        const targetIndex = splits.length === 3 ? 1 : 0;
+        const targetIndex = startIndex > 0 ? 1 : 0;
         const targetText = splits[targetIndex];
         if (targetText) {
             targetText.replace(linkNode);