@flexiui/svelte-rich-text 0.0.79 → 0.0.80
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.
- package/dist/RichText.svelte +35 -13
- package/package.json +1 -1
package/dist/RichText.svelte
CHANGED
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
let {
|
|
138
|
-
id =
|
|
138
|
+
id = `fl-r-text-${crypto.randomUUID().slice(0, 8)}`,
|
|
139
139
|
className,
|
|
140
140
|
editable,
|
|
141
141
|
content,
|
|
@@ -237,6 +237,7 @@
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
let focused = $state(false);
|
|
240
|
+
let shouldClearSelectionOnFocus = false;
|
|
240
241
|
|
|
241
242
|
let bubbleOffset =
|
|
242
243
|
$editor?.storage.tableCell.customTableSelection === "column" ? 18 : 8;
|
|
@@ -593,29 +594,36 @@
|
|
|
593
594
|
editorEvents.onSelectionUpdate({ editor });
|
|
594
595
|
},
|
|
595
596
|
|
|
596
|
-
onFocus({ editor
|
|
597
|
+
onFocus({ editor }) {
|
|
597
598
|
focused = true;
|
|
598
|
-
|
|
599
|
+
|
|
600
|
+
editorEvents.onFocus({ editor });
|
|
599
601
|
},
|
|
600
602
|
onBlur({ editor, event }) {
|
|
601
603
|
const relatedTarget = event.relatedTarget as HTMLElement;
|
|
602
604
|
|
|
603
|
-
const
|
|
605
|
+
const isSameEditor = relatedTarget?.closest(`#${id}`); // usa el id del editor actual
|
|
604
606
|
|
|
605
|
-
|
|
607
|
+
const isBubbleMenu = relatedTarget?.closest(".fl-bubble-menu");
|
|
608
|
+
const isToolbarDropdown = relatedTarget?.closest(".fl-toolbar-dropdown-panel");
|
|
609
|
+
const isFontSizeEditor = relatedTarget?.closest(".fl-font-size-editor");
|
|
610
|
+
|
|
611
|
+
if (relatedTarget?.classList.contains("fl-bubble-menu-mark-button") || isFontSizeEditor) {
|
|
606
612
|
return;
|
|
607
613
|
}
|
|
608
614
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
// const tr = state.tr.setSelection(TextSelection.create(state.doc, pos));
|
|
615
|
+
// Solo saltar la limpieza si el foco va al MISMO editor
|
|
616
|
+
if (isSameEditor || isBubbleMenu || isToolbarDropdown) {
|
|
617
|
+
focused = false;
|
|
618
|
+
editorEvents.onBlur({ editor, event });
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
616
621
|
|
|
617
|
-
//
|
|
622
|
+
// Foco fue fuera o a OTRO editor → limpiar
|
|
623
|
+
shouldClearSelectionOnFocus = true;
|
|
624
|
+
clearSelection(editor);
|
|
618
625
|
|
|
626
|
+
focused = false;
|
|
619
627
|
editorEvents.onBlur({ editor, event });
|
|
620
628
|
},
|
|
621
629
|
onDestroy() {
|
|
@@ -813,6 +821,19 @@
|
|
|
813
821
|
}
|
|
814
822
|
}
|
|
815
823
|
}
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
function clearSelection(editor) {
|
|
827
|
+
const { state, view } = editor;
|
|
828
|
+
|
|
829
|
+
const pos = state.selection.to;
|
|
830
|
+
|
|
831
|
+
const tr = state.tr.setSelection(
|
|
832
|
+
TextSelection.create(state.doc, pos)
|
|
833
|
+
);
|
|
834
|
+
|
|
835
|
+
view.dispatch(tr);
|
|
836
|
+
}
|
|
816
837
|
</script>
|
|
817
838
|
|
|
818
839
|
{#if cleanMode}
|
|
@@ -832,6 +853,7 @@
|
|
|
832
853
|
{/if}
|
|
833
854
|
{:else}
|
|
834
855
|
<div
|
|
856
|
+
id={id}
|
|
835
857
|
class="fl-rich-text {className}"
|
|
836
858
|
class:editable
|
|
837
859
|
style="
|