@cqa-lib/cqa-ui 1.1.495 → 1.1.496
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19957,15 +19957,26 @@ class MixedVariableInputComponent {
|
|
|
19957
19957
|
this.placeCaretAfter(chip);
|
|
19958
19958
|
return;
|
|
19959
19959
|
}
|
|
19960
|
-
|
|
19960
|
+
let node = range.startContainer;
|
|
19961
|
+
let offset = range.startOffset;
|
|
19962
|
+
// Caret may sit on the editor element (e.g. right after a pasted text node).
|
|
19963
|
+
// Walk into the previous text node so we replace the trailing word instead
|
|
19964
|
+
// of just inserting the chip alongside it.
|
|
19961
19965
|
if (node.nodeType !== Node.TEXT_NODE) {
|
|
19962
|
-
|
|
19963
|
-
|
|
19964
|
-
|
|
19966
|
+
const prev = node.childNodes[offset - 1];
|
|
19967
|
+
if (prev && prev.nodeType === Node.TEXT_NODE) {
|
|
19968
|
+
node = prev;
|
|
19969
|
+
offset = (prev.nodeValue || '').length;
|
|
19970
|
+
}
|
|
19971
|
+
else {
|
|
19972
|
+
range.insertNode(chip);
|
|
19973
|
+
this.placeCaretAfter(chip);
|
|
19974
|
+
return;
|
|
19975
|
+
}
|
|
19965
19976
|
}
|
|
19966
19977
|
const text = node.nodeValue || '';
|
|
19967
|
-
const before = text.slice(0,
|
|
19968
|
-
const after = text.slice(
|
|
19978
|
+
const before = text.slice(0, offset);
|
|
19979
|
+
const after = text.slice(offset);
|
|
19969
19980
|
const wordMatch = before.match(VAR_PATH_TAIL_REGEX);
|
|
19970
19981
|
let beforeKept = wordMatch ? before.slice(0, before.length - wordMatch[1].length) : before;
|
|
19971
19982
|
let afterKept = after;
|