el-text-editor 0.0.71 → 0.0.73

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.
@@ -646,16 +646,16 @@ class ElTextEditorComponent {
646
646
  }
647
647
  }
648
648
  // // Move caret to the end of the editor content
649
- moveCaretToEnd(editor) {
650
- const selection = window.getSelection();
651
- const range = document.createRange();
652
- if (editor.lastChild) {
653
- range.selectNodeContents(editor);
654
- range.collapse(false); // Collapse to the end
655
- selection?.removeAllRanges();
656
- selection?.addRange(range);
657
- }
658
- }
649
+ // private moveCaretToEnd(editor: HTMLElement) {
650
+ // const selection = window.getSelection();
651
+ // const range = document.createRange();
652
+ // if (editor.lastChild) {
653
+ // range.selectNodeContents(editor);
654
+ // range.collapse(false); // Collapse to the end
655
+ // selection?.removeAllRanges();
656
+ // selection?.addRange(range);
657
+ // }
658
+ // }
659
659
  init_Func(html) {
660
660
  if (html) {
661
661
  let editor = document.getElementById('editor');
@@ -695,16 +695,24 @@ class ElTextEditorComponent {
695
695
  });
696
696
  observer.observe(editor, { childList: true, subtree: true, characterData: true });
697
697
  }
698
- // private moveCaretToEnd(editor: HTMLElement) {
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
- // }
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
+ const selection = window.getSelection();
708
+ if (selection?.rangeCount) {
709
+ const range = selection.getRangeAt(0);
710
+ if (editor.contains(range.commonAncestorContainer)) {
711
+ return range.cloneRange(); // Return the current caret range
712
+ }
713
+ }
714
+ return null;
715
+ }
708
716
  // init_Func(html: any) {
709
717
  // if (html) {
710
718
  // let editor = document.getElementById('editor');