@flexiui/svelte-rich-text 0.0.79 → 0.0.81
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 +48 -13
- package/dist/getExtensions.js +1 -1
- 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;
|
|
@@ -507,6 +508,19 @@
|
|
|
507
508
|
}, 200);
|
|
508
509
|
}
|
|
509
510
|
},
|
|
511
|
+
transformPastedText(text) {
|
|
512
|
+
return text
|
|
513
|
+
},
|
|
514
|
+
transformPastedHTML(html: string) {
|
|
515
|
+
// Crear un div temporal para parsear el HTML
|
|
516
|
+
const div = document.createElement('div')
|
|
517
|
+
div.innerHTML = html
|
|
518
|
+
|
|
519
|
+
// Obtener solo el texto con saltos de línea
|
|
520
|
+
const text = div.innerText || div.textContent || ''
|
|
521
|
+
|
|
522
|
+
return text
|
|
523
|
+
},
|
|
510
524
|
},
|
|
511
525
|
onTransaction: ({ editor, transaction }) => {
|
|
512
526
|
// Actualizar contador de nodos
|
|
@@ -593,29 +607,36 @@
|
|
|
593
607
|
editorEvents.onSelectionUpdate({ editor });
|
|
594
608
|
},
|
|
595
609
|
|
|
596
|
-
onFocus({ editor
|
|
610
|
+
onFocus({ editor }) {
|
|
597
611
|
focused = true;
|
|
598
|
-
|
|
612
|
+
|
|
613
|
+
editorEvents.onFocus({ editor });
|
|
599
614
|
},
|
|
600
615
|
onBlur({ editor, event }) {
|
|
601
616
|
const relatedTarget = event.relatedTarget as HTMLElement;
|
|
602
617
|
|
|
603
|
-
const
|
|
618
|
+
const isSameEditor = relatedTarget?.closest(`#${id}`); // usa el id del editor actual
|
|
604
619
|
|
|
605
|
-
|
|
620
|
+
const isBubbleMenu = relatedTarget?.closest(".fl-bubble-menu");
|
|
621
|
+
const isToolbarDropdown = relatedTarget?.closest(".fl-toolbar-dropdown-panel");
|
|
622
|
+
const isFontSizeEditor = relatedTarget?.closest(".fl-font-size-editor");
|
|
623
|
+
|
|
624
|
+
if (relatedTarget?.classList.contains("fl-bubble-menu-mark-button") || isFontSizeEditor) {
|
|
606
625
|
return;
|
|
607
626
|
}
|
|
608
627
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
// const tr = state.tr.setSelection(TextSelection.create(state.doc, pos));
|
|
628
|
+
// Solo saltar la limpieza si el foco va al MISMO editor
|
|
629
|
+
if (isSameEditor || isBubbleMenu || isToolbarDropdown) {
|
|
630
|
+
focused = false;
|
|
631
|
+
editorEvents.onBlur({ editor, event });
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
616
634
|
|
|
617
|
-
//
|
|
635
|
+
// Foco fue fuera o a OTRO editor → limpiar
|
|
636
|
+
shouldClearSelectionOnFocus = true;
|
|
637
|
+
clearSelection(editor);
|
|
618
638
|
|
|
639
|
+
focused = false;
|
|
619
640
|
editorEvents.onBlur({ editor, event });
|
|
620
641
|
},
|
|
621
642
|
onDestroy() {
|
|
@@ -813,6 +834,19 @@
|
|
|
813
834
|
}
|
|
814
835
|
}
|
|
815
836
|
}
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
function clearSelection(editor) {
|
|
840
|
+
const { state, view } = editor;
|
|
841
|
+
|
|
842
|
+
const pos = state.selection.to;
|
|
843
|
+
|
|
844
|
+
const tr = state.tr.setSelection(
|
|
845
|
+
TextSelection.create(state.doc, pos)
|
|
846
|
+
);
|
|
847
|
+
|
|
848
|
+
view.dispatch(tr);
|
|
849
|
+
}
|
|
816
850
|
</script>
|
|
817
851
|
|
|
818
852
|
{#if cleanMode}
|
|
@@ -832,6 +866,7 @@
|
|
|
832
866
|
{/if}
|
|
833
867
|
{:else}
|
|
834
868
|
<div
|
|
869
|
+
id={id}
|
|
835
870
|
class="fl-rich-text {className}"
|
|
836
871
|
class:editable
|
|
837
872
|
style="
|
package/dist/getExtensions.js
CHANGED
|
@@ -100,7 +100,7 @@ export function getRichTextExtensions(options) {
|
|
|
100
100
|
listKeymap: false,
|
|
101
101
|
}),
|
|
102
102
|
EnhancedLink,
|
|
103
|
-
Image.configure({ inline:
|
|
103
|
+
Image.configure({ inline: false }),
|
|
104
104
|
Audio.configure({
|
|
105
105
|
HTMLAttributes: { class: "audio-player" },
|
|
106
106
|
}),
|