@bobfrankston/rmfmail 1.1.151 → 1.1.152
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.
|
@@ -777,30 +777,47 @@ async function createTinyMceEditor(container2, opts = {}) {
|
|
|
777
777
|
applyZoom();
|
|
778
778
|
}
|
|
779
779
|
});
|
|
780
|
-
|
|
781
|
-
|
|
780
|
+
const installLinkEscape = () => {
|
|
781
|
+
const doc = ed.getDoc();
|
|
782
|
+
if (!doc || doc.__rmfLinkEscapeInstalled)
|
|
782
783
|
return;
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
784
|
+
doc.__rmfLinkEscapeInstalled = true;
|
|
785
|
+
doc.addEventListener("beforeinput", (e) => {
|
|
786
|
+
const kind = e.inputType || "";
|
|
787
|
+
const isInsert = kind === "insertText" || kind === "insertCompositionText" || kind === "insertFromPaste" || kind === "insertFromDrop" || kind === "insertFromComposition";
|
|
788
|
+
if (!isInsert)
|
|
789
|
+
return;
|
|
790
|
+
const sel = doc.getSelection();
|
|
791
|
+
if (!sel || sel.rangeCount === 0)
|
|
792
|
+
return;
|
|
793
|
+
const rng = sel.getRangeAt(0);
|
|
794
|
+
if (!rng.collapsed)
|
|
795
|
+
return;
|
|
796
|
+
const node = rng.startContainer;
|
|
797
|
+
const a = node.nodeType === Node.ELEMENT_NODE ? node : node.parentNode;
|
|
798
|
+
if (!a)
|
|
799
|
+
return;
|
|
800
|
+
const link = a.closest?.("a");
|
|
801
|
+
if (!link)
|
|
802
|
+
return;
|
|
803
|
+
let tail;
|
|
804
|
+
try {
|
|
805
|
+
tail = rng.cloneRange();
|
|
806
|
+
tail.setEndAfter(link);
|
|
807
|
+
} catch {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
if (tail.toString().length > 0)
|
|
811
|
+
return;
|
|
812
|
+
const after = doc.createRange();
|
|
813
|
+
after.setStartAfter(link);
|
|
814
|
+
after.collapse(true);
|
|
815
|
+
sel.removeAllRanges();
|
|
816
|
+
sel.addRange(after);
|
|
817
|
+
}, true);
|
|
818
|
+
};
|
|
819
|
+
ed.on("init", installLinkEscape);
|
|
820
|
+
ed.on("SetContent", installLinkEscape);
|
|
804
821
|
ed.on("init", () => {
|
|
805
822
|
try {
|
|
806
823
|
const body = ed.getBody();
|