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