el-text-editor 0.0.73 → 0.0.75

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.
@@ -91,6 +91,16 @@ class ElTextEditorComponent {
91
91
  this.isOpen.emit(this.IsOpen);
92
92
  }
93
93
  };
94
+ // private setCaretToEnd(element: HTMLElement) {
95
+ // const range = document.createRange();
96
+ // const sel = window.getSelection();
97
+ // if (sel) {
98
+ // range.selectNodeContents(element);
99
+ // range.collapse(false);
100
+ // sel.removeAllRanges();
101
+ // sel.addRange(range);
102
+ // }
103
+ // }
94
104
  // openColorPicker(inputId: string) {
95
105
  // const inputElement = document.getElementById(inputId);
96
106
  // if (inputElement) {
@@ -624,20 +634,20 @@ class ElTextEditorComponent {
624
634
  const tempDiv = document.createElement('div');
625
635
  tempDiv.innerHTML = newData;
626
636
  // Append the new data to the fragment (supports HTML insertion)
627
- while (tempDiv.firstChild) {
628
- fragment.appendChild(tempDiv.firstChild);
629
- }
630
- // Insert the fragment at the caret position
631
- range.deleteContents(); // Remove any selected content if applicable
632
- range.insertNode(fragment);
633
- // Move the caret after the inserted content
634
- const lastChild = fragment.lastChild;
635
- if (lastChild) {
636
- range.setStartAfter(lastChild);
637
- range.setEndAfter(lastChild);
638
- selection.removeAllRanges();
639
- selection.addRange(range);
640
- }
637
+ // while (tempDiv.firstChild) {
638
+ // fragment.appendChild(tempDiv.firstChild);
639
+ // }
640
+ // // Insert the fragment at the caret position
641
+ // range.deleteContents(); // Remove any selected content if applicable
642
+ // range.insertNode(fragment);
643
+ // // Move the caret after the inserted content
644
+ // const lastChild = fragment.lastChild;
645
+ // if (lastChild) {
646
+ // range.setStartAfter(lastChild);
647
+ // range.setEndAfter(lastChild);
648
+ // selection.removeAllRanges();
649
+ // selection.addRange(range);
650
+ // }
641
651
  let editor = document.getElementById('editor');
642
652
  if (editor) {
643
653
  this.moveCaretToEnd(editor);
@@ -689,7 +699,7 @@ class ElTextEditorComponent {
689
699
  setupMutationObserver(editor) {
690
700
  const observer = new MutationObserver(() => {
691
701
  // Move the caret to the end after content changes
692
- // this.moveCaretToEnd(editor);
702
+ this.moveCaretToEnd(editor);
693
703
  // Update model with the current content
694
704
  this.onModelChange(editor.innerHTML);
695
705
  });
@@ -1155,16 +1165,6 @@ class ElTextEditorComponent {
1155
1165
  }
1156
1166
  }
1157
1167
  }
1158
- setCaretToEnd(element) {
1159
- const range = document.createRange();
1160
- const sel = window.getSelection();
1161
- if (sel) {
1162
- range.selectNodeContents(element);
1163
- range.collapse(false);
1164
- sel.removeAllRanges();
1165
- sel.addRange(range);
1166
- }
1167
- }
1168
1168
  openColorPicker(inputId) {
1169
1169
  const inputElement = document.getElementById(inputId);
1170
1170
  if (inputElement) {