el-text-editor 0.0.70 → 0.0.71

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.
@@ -641,23 +641,21 @@ class ElTextEditorComponent {
641
641
  let editor = document.getElementById('editor');
642
642
  if (editor) {
643
643
  this.moveCaretToEnd(editor);
644
- this.onEditorClick(editor);
645
- this.onKeyboardMove(editor);
646
644
  }
647
645
  this.placeHolderRemove.emit();
648
646
  }
649
647
  }
650
648
  // // Move caret to the end of the editor content
651
- // private moveCaretToEnd(editor: HTMLElement) {
652
- // const selection = window.getSelection();
653
- // const range = document.createRange();
654
- // if (editor.lastChild) {
655
- // range.selectNodeContents(editor);
656
- // range.collapse(false); // Collapse to the end
657
- // selection?.removeAllRanges();
658
- // selection?.addRange(range);
659
- // }
660
- // }
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
+ }
661
659
  init_Func(html) {
662
660
  if (html) {
663
661
  let editor = document.getElementById('editor');
@@ -668,8 +666,6 @@ class ElTextEditorComponent {
668
666
  this.setupMutationObserver(editor);
669
667
  // Move the caret to the end after initial content setup
670
668
  this.moveCaretToEnd(editor);
671
- this.onEditorClick(editor);
672
- this.onKeyboardMove(editor);
673
669
  // Track caret position on mouse click
674
670
  editor.addEventListener('click', () => {
675
671
  if (editor) { // Ensure editor is not null
@@ -709,49 +705,6 @@ class ElTextEditorComponent {
709
705
  // selection?.addRange(range);
710
706
  // }
711
707
  // }
712
- moveCaretToEnd(editor) {
713
- const selection = window.getSelection();
714
- const range = document.createRange();
715
- if (editor.lastChild) {
716
- range.selectNodeContents(editor);
717
- range.collapse(false); // Collapse to the end
718
- selection?.removeAllRanges();
719
- selection?.addRange(range);
720
- }
721
- }
722
- onKeyboardMove(editor) {
723
- editor.addEventListener('keydown', (event) => {
724
- const selection = window.getSelection();
725
- const range = document.createRange();
726
- if (selection && selection.rangeCount > 0) {
727
- const currentRange = selection.getRangeAt(0);
728
- const currentCaretPosition = currentRange.startContainer;
729
- if (event.key === 'ArrowRight' || event.key === 'ArrowLeft' || event.key === 'ArrowUp' || event.key === 'ArrowDown') {
730
- // You can handle specific behavior for different arrow keys here
731
- // For example, move caret within a specific node or across nodes
732
- }
733
- }
734
- });
735
- }
736
- onEditorClick(editor) {
737
- editor.addEventListener('click', (event) => {
738
- const selection = window.getSelection();
739
- const range = document.createRange();
740
- const clickedNode = event.target;
741
- if (clickedNode && clickedNode !== editor) {
742
- // Place the caret at the clicked position
743
- range.setStart(clickedNode, 0);
744
- range.setEnd(clickedNode, clickedNode?.length);
745
- }
746
- else {
747
- // Move caret to the end if clicked inside the editor but not on text node
748
- range.selectNodeContents(editor);
749
- range.collapse(false);
750
- }
751
- selection?.removeAllRanges();
752
- selection?.addRange(range);
753
- });
754
- }
755
708
  // init_Func(html: any) {
756
709
  // if (html) {
757
710
  // let editor = document.getElementById('editor');