@flexiui/svelte-rich-text 0.0.75 → 0.0.77

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.
@@ -127,6 +127,13 @@
127
127
  type ToolbarConfig = ToolbarItem[] | ToolbarItem[][];
128
128
  type BubbleMenuConfig = ToolbarItem[] | ToolbarItem[][];
129
129
 
130
+ type BubbleMenuOptions = {
131
+ placement?: "top" | "right" | "bottom" | "left";
132
+ strategy?: "absolute" | "fixed";
133
+ offset?: number;
134
+ flip?: boolean;
135
+ };
136
+
130
137
  let {
131
138
  id = "fl-rich-text-editor",
132
139
  className,
@@ -142,6 +149,7 @@
142
149
  uniqueH1 = false,
143
150
  toolbarConfig = undefined,
144
151
  bubbleMenuConfig = undefined,
152
+ bubbleMenuOptions = {},
145
153
  customExtensions = [],
146
154
  editorEvents = {
147
155
  onTransaction: () => {},
@@ -233,6 +241,18 @@
233
241
  let bubbleOffset =
234
242
  $editor?.storage.tableCell.customTableSelection === "column" ? 18 : 8;
235
243
 
244
+ const defaultBubbleMenuOptions = {
245
+ placement: "bottom" as const,
246
+ strategy: "absolute" as const,
247
+ offset: bubbleOffset,
248
+ flip: true,
249
+ };
250
+
251
+ let mergedBubbleMenuOptions = $derived({
252
+ ...defaultBubbleMenuOptions,
253
+ ...bubbleMenuOptions,
254
+ });
255
+
236
256
  let tooltipVisible = $state(false);
237
257
  let tooltipX = $state(0);
238
258
  let tooltipY = $state(0);
@@ -578,6 +598,14 @@
578
598
  editorEvents.onFocus({ editor, event });
579
599
  },
580
600
  onBlur({ editor, event }) {
601
+ const relatedTarget = event.relatedTarget as HTMLElement;
602
+
603
+ const isFontSizeEditor = relatedTarget && relatedTarget.closest(".fl-font-size-editor");
604
+
605
+ if((relatedTarget && relatedTarget.classList.contains("fl-bubble-menu-mark-button")) || isFontSizeEditor) {
606
+ return;
607
+ }
608
+
581
609
  focused = false;
582
610
 
583
611
  const { state, view } = editor;
@@ -957,6 +985,9 @@
957
985
  </div>
958
986
  {/if}
959
987
 
988
+ <pre>
989
+ Focused: {focused}
990
+ </pre>
960
991
  <div
961
992
  class="fl-toolbar-dropdown-panel"
962
993
  bind:this={tooltip}
@@ -1277,15 +1308,10 @@
1277
1308
  {/if}
1278
1309
  </div>
1279
1310
 
1280
- {#if editor && focused}
1311
+ {#if editor && focused}
1281
1312
  <div class="hidden">
1282
1313
  <BubbleMenu
1283
- options={{
1284
- placement: "top",
1285
- strategy: "absolute",
1286
- offset: bubbleOffset,
1287
- flip: false,
1288
- }}
1314
+ options={mergedBubbleMenuOptions}
1289
1315
  editor={$editor}
1290
1316
  shouldShow={() => {
1291
1317
  const emptySelection = $editor.state.selection.empty;
@@ -14,5 +14,7 @@
14
14
  onclick={handleClick}
15
15
  >
16
16
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-line-height"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3 8l3 -3l3 3"/><path d="M3 16l3 3l3 -3"/><path d="M6 5l0 14"/><path d="M13 6l7 0"/><path d="M13 12l7 0"/><path d="M13 18l7 0"/></svg>
17
- <svg class="toogle-dropdown-button-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6"><use href="#dropdown-arrow"></use></svg>
17
+ <svg class="toogle-dropdown-button-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
18
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"></path>
19
+ </svg>
18
20
  </button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexiui/svelte-rich-text",
3
- "version": "0.0.75",
3
+ "version": "0.0.77",
4
4
  "description": "A lightweight and flexible rich text editor component for Svelte",
5
5
  "keywords": [
6
6
  "svelte",