el-text-editor 0.0.74 → 0.0.76
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.
@@ -689,29 +689,21 @@ class ElTextEditorComponent {
|
|
689
689
|
setupMutationObserver(editor) {
|
690
690
|
const observer = new MutationObserver(() => {
|
691
691
|
// Move the caret to the end after content changes
|
692
|
-
this.moveCaretToEnd(editor);
|
692
|
+
// this.moveCaretToEnd(editor);
|
693
693
|
// Update model with the current content
|
694
694
|
this.onModelChange(editor.innerHTML);
|
695
695
|
});
|
696
696
|
observer.observe(editor, { childList: true, subtree: true, characterData: true });
|
697
697
|
}
|
698
698
|
moveCaretToEnd(editor) {
|
699
|
-
// const selection = window.getSelection();
|
700
|
-
// const range = document.createRange();
|
701
|
-
// if (editor.lastChild) {
|
702
|
-
// range.selectNodeContents(editor);
|
703
|
-
// range.collapse(false); // Collapse to the end
|
704
|
-
// selection?.removeAllRanges();
|
705
|
-
// selection?.addRange(range);
|
706
|
-
// }
|
707
699
|
const selection = window.getSelection();
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
700
|
+
const range = document.createRange();
|
701
|
+
if (editor.lastChild) {
|
702
|
+
range.selectNodeContents(editor);
|
703
|
+
range.collapse(false); // Collapse to the end
|
704
|
+
selection?.removeAllRanges();
|
705
|
+
selection?.addRange(range);
|
713
706
|
}
|
714
|
-
return null;
|
715
707
|
}
|
716
708
|
// init_Func(html: any) {
|
717
709
|
// if (html) {
|
@@ -909,7 +901,7 @@ class ElTextEditorComponent {
|
|
909
901
|
const imgWidth = img.width;
|
910
902
|
// If the image width exceeds the editor's width, fit it to the editor
|
911
903
|
const imgHTML = imgWidth > editorWidth
|
912
|
-
? `<img src="${img.src}" style="width: 100%; max-width: ${
|
904
|
+
? `<img src="${img.src}" style="width: 100%; max-width: ${700}px; height: auto;">`
|
913
905
|
: `<img src="${img.src}" style="width: ${imgWidth}px; height: auto;">`;
|
914
906
|
this.newImageAdded.emit();
|
915
907
|
// Insert the image into the editor
|