@flexiui/svelte-rich-text 0.0.71 → 0.0.73

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.
@@ -21,10 +21,11 @@
21
21
  createEditor,
22
22
  Editor,
23
23
  // EditorContent,
24
- BubbleMenu,
24
+ // BubbleMenu,
25
25
  } from "svelte-tiptap";
26
26
 
27
27
  import EditorContent from "./svelte-tiptap-extends/EditorContent.svelte";
28
+ import BubbleMenu from "./svelte-tiptap-extends/BubbleMenu.svelte";
28
29
  import { getRichTextExtensions } from "./getExtensions";
29
30
  import { rgbToHex } from "./utils";
30
31
 
@@ -953,6 +954,7 @@ function onOpenChangeHighlight(open: boolean) {
953
954
  {/if}
954
955
  </div>
955
956
  {/if}
957
+
956
958
  <div
957
959
  class="fl-toolbar-dropdown-panel"
958
960
  bind:this={tooltip}
@@ -1308,7 +1310,13 @@ function onOpenChangeHighlight(open: boolean) {
1308
1310
  }}
1309
1311
  appendTo={document.body}
1310
1312
  >
1311
- <div data-test-id="bubble-menu" class="fl-bubble-menu flex">
1313
+ <div
1314
+ data-test-id="bubble-menu"
1315
+ class="fl-bubble-menu flex"
1316
+ style="
1317
+ --fl-editor-accent-color: {editorConfig.editorAccentColor};
1318
+ "
1319
+ >
1312
1320
  {#each bubbleMenuGroups as bubbleMenuGroup}
1313
1321
  {#if bubbleMenuGroup.length > 0}
1314
1322
  <div role="group" class="fl-rich-text-toolbar-group">
package/dist/styles.css CHANGED
@@ -123,66 +123,66 @@
123
123
  background: transparent;
124
124
  line-height: 1.6;
125
125
  }
126
+ }
126
127
 
127
- .fl-bubble-menu {
128
- padding: 6px;
129
- background: #242424b0;
130
- border: 1px solid #ffffff12;
131
- backdrop-filter: blur(16px);
132
- border-radius: 14px;
128
+ .fl-bubble-menu {
129
+ padding: 6px;
130
+ background: #242424b0;
131
+ border: 1px solid #ffffff12;
132
+ backdrop-filter: blur(16px);
133
+ border-radius: 14px;
134
+ display: flex;
135
+ gap: 5px;
136
+ position: relative;
137
+ z-index: var(--fl-toolbar-z-index, 10);
138
+
139
+
140
+ .fl-bubble-menu-mark-button {
141
+ border-radius: 9px;
142
+ border: none;
133
143
  display: flex;
134
- gap: 5px;
135
- position: relative;
136
- z-index: var(--fl-toolbar-z-index, 10);
137
-
138
-
139
- .fl-bubble-menu-mark-button {
140
- border-radius: 9px;
141
- border: none;
142
- display: flex;
143
- align-items: center;
144
- justify-content: center;
145
- padding: 6px 11px;
146
- min-width: 30px;
147
- min-height: 30px;
148
- background: rgba(255, 255, 255, 0.1);
149
- transition: background 0.3s ease;
150
- cursor: pointer;
151
-
152
- &.fl-bubble-menu-mark-button {
153
- padding-inline: 6px;
154
-
155
- svg {
156
- width: 16px;
157
- height: 16px;
158
-
159
- &.toogle-dropdown-button-icon {
160
- width: 8px;
161
- margin: 0 2px 0 6px;
162
- }
144
+ align-items: center;
145
+ justify-content: center;
146
+ padding: 6px 11px;
147
+ min-width: 30px;
148
+ min-height: 30px;
149
+ background: rgba(255, 255, 255, 0.1);
150
+ transition: background 0.3s ease;
151
+ cursor: pointer;
152
+
153
+ &.fl-bubble-menu-mark-button {
154
+ padding-inline: 6px;
155
+
156
+ svg {
157
+ width: 16px;
158
+ height: 16px;
159
+
160
+ &.toogle-dropdown-button-icon {
161
+ width: 8px;
162
+ margin: 0 2px 0 6px;
163
163
  }
164
164
  }
165
+ }
165
166
 
166
- &.is-active {
167
- background: var(--fl-editor-accent-color);
168
- color: white;
169
-
170
- &.accent-soft {
171
- background: transparent;
172
- color: var(--fl-editor-accent-color);
173
- position: relative;
174
-
175
- &::after {
176
- content: "";
177
- position: absolute;
178
- width: 100%;
179
- height: 100%;
180
- left: 0;
181
- top: 0;
182
- background: var(--fl-editor-accent-color);
183
- opacity: 0.15;
184
- border-radius: inherit;
185
- }
167
+ &.is-active {
168
+ background: var(--fl-editor-accent-color);
169
+ color: white;
170
+
171
+ &.accent-soft {
172
+ background: transparent;
173
+ color: var(--fl-editor-accent-color);
174
+ position: relative;
175
+
176
+ &::after {
177
+ content: "";
178
+ position: absolute;
179
+ width: 100%;
180
+ height: 100%;
181
+ left: 0;
182
+ top: 0;
183
+ background: var(--fl-editor-accent-color);
184
+ opacity: 0.15;
185
+ border-radius: inherit;
186
186
  }
187
187
  }
188
188
  }
@@ -0,0 +1,56 @@
1
+ <script lang="ts">
2
+ import { onMount } from 'svelte';
3
+ import { BubbleMenuPlugin, type BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
4
+
5
+ import type { ComponentInputProps } from './types';
6
+ import { invariant } from './utils';
7
+
8
+ type Props = ComponentInputProps<BubbleMenuPluginProps>;
9
+
10
+ const {
11
+ editor,
12
+ options = {},
13
+ pluginKey = 'SvelteTiptapBubbleMenu',
14
+ shouldShow = null,
15
+ updateDelay = 250,
16
+ appendTo = null,
17
+ children,
18
+ class: className,
19
+ }: Props = $props();
20
+
21
+ invariant(editor, 'Missing editor instance.');
22
+
23
+ let element: HTMLElement;
24
+
25
+ onMount(() => {
26
+ element.style.visibility = 'hidden';
27
+ element.style.position = 'absolute';
28
+
29
+ const plugin = BubbleMenuPlugin({
30
+ pluginKey,
31
+ editor,
32
+ element,
33
+ options,
34
+ shouldShow,
35
+ updateDelay,
36
+ appendTo,
37
+ });
38
+
39
+ editor.registerPlugin(plugin);
40
+
41
+ return () => {
42
+ editor?.unregisterPlugin(pluginKey);
43
+ window.requestAnimationFrame(() => {
44
+ if (element && element.parentNode) {
45
+ element.parentNode.removeChild(element);
46
+ }
47
+ });
48
+ };
49
+ });
50
+ </script>
51
+
52
+ <div bind:this={element} class={className} style="visibility: hidden;">
53
+ {#if children}
54
+ {@render children()}
55
+ {/if}
56
+ </div>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export type BubbleMenuProps = typeof __propDef.props;
10
+ export type BubbleMenuEvents = typeof __propDef.events;
11
+ export type BubbleMenuSlots = typeof __propDef.slots;
12
+ export default class BubbleMenu extends SvelteComponentTyped<BubbleMenuProps, BubbleMenuEvents, BubbleMenuSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,4 @@
1
+ type Invariant = (condition: unknown, message?: string) => asserts condition;
2
+ export declare const invariant: Invariant;
3
+ export declare const runIfFn: <T>(value: T | ((...args: unknown[]) => T), ...args: unknown[]) => T;
4
+ export {};
@@ -0,0 +1,8 @@
1
+ export const invariant = (condition, msg) => {
2
+ if (!condition) {
3
+ throw new Error(msg);
4
+ }
5
+ };
6
+ export const runIfFn = (value, ...args) => {
7
+ return typeof value === 'function' ? value(...args) : value;
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexiui/svelte-rich-text",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "description": "A lightweight and flexible rich text editor component for Svelte",
5
5
  "keywords": [
6
6
  "svelte",