@liveblocks/react-tiptap 2.16.0-toolbars4 → 2.17.0-channels1

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.
Files changed (52) hide show
  1. package/dist/LiveblocksExtension.js.map +1 -1
  2. package/dist/LiveblocksExtension.mjs.map +1 -1
  3. package/dist/comments/CommentsExtension.js +11 -20
  4. package/dist/comments/CommentsExtension.js.map +1 -1
  5. package/dist/comments/CommentsExtension.mjs +13 -22
  6. package/dist/comments/CommentsExtension.mjs.map +1 -1
  7. package/dist/comments/FloatingComposer.js +30 -27
  8. package/dist/comments/FloatingComposer.js.map +1 -1
  9. package/dist/comments/FloatingComposer.mjs +32 -29
  10. package/dist/comments/FloatingComposer.mjs.map +1 -1
  11. package/dist/index.d.mts +10 -254
  12. package/dist/index.d.ts +10 -254
  13. package/dist/index.js +0 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +0 -2
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/types.js +3 -7
  18. package/dist/types.js.map +1 -1
  19. package/dist/types.mjs +3 -6
  20. package/dist/types.mjs.map +1 -1
  21. package/dist/utils.js +0 -17
  22. package/dist/utils.js.map +1 -1
  23. package/dist/utils.mjs +1 -16
  24. package/dist/utils.mjs.map +1 -1
  25. package/dist/version-history/HistoryVersionPreview.js +79 -79
  26. package/dist/version-history/HistoryVersionPreview.js.map +1 -1
  27. package/dist/version-history/HistoryVersionPreview.mjs +79 -79
  28. package/dist/version-history/HistoryVersionPreview.mjs.map +1 -1
  29. package/dist/version.js +1 -1
  30. package/dist/version.mjs +1 -1
  31. package/package.json +6 -8
  32. package/src/styles/constants.css +1 -2
  33. package/src/styles/index.css +6 -58
  34. package/src/styles/utils.css +0 -11
  35. package/styles.css +1 -1
  36. package/styles.css.map +1 -1
  37. package/dist/context.js +0 -24
  38. package/dist/context.js.map +0 -1
  39. package/dist/context.mjs +0 -21
  40. package/dist/context.mjs.map +0 -1
  41. package/dist/toolbar/FloatingToolbar.js +0 -321
  42. package/dist/toolbar/FloatingToolbar.js.map +0 -1
  43. package/dist/toolbar/FloatingToolbar.mjs +0 -318
  44. package/dist/toolbar/FloatingToolbar.mjs.map +0 -1
  45. package/dist/toolbar/Toolbar.js +0 -396
  46. package/dist/toolbar/Toolbar.js.map +0 -1
  47. package/dist/toolbar/Toolbar.mjs +0 -371
  48. package/dist/toolbar/Toolbar.mjs.map +0 -1
  49. package/dist/toolbar/shared.js +0 -39
  50. package/dist/toolbar/shared.js.map +0 -1
  51. package/dist/toolbar/shared.mjs +0 -36
  52. package/dist/toolbar/shared.mjs.map +0 -1
package/dist/index.d.ts CHANGED
@@ -3,20 +3,10 @@ import { BaseMetadata, DM, ThreadData, HistoryVersion } from '@liveblocks/core';
3
3
  import { ThreadProps, ComposerProps } from '@liveblocks/react-ui';
4
4
  import { Editor } from '@tiptap/react';
5
5
  import * as react from 'react';
6
- import { ComponentPropsWithoutRef, ComponentType, HTMLAttributes, ComponentProps, ReactNode } from 'react';
6
+ import { ComponentPropsWithoutRef, ComponentType, HTMLAttributes } from 'react';
7
7
  import { BaseMetadata as BaseMetadata$1 } from '@liveblocks/client';
8
8
  import { Extension, Content } from '@tiptap/core';
9
9
 
10
- type FloatingPosition = "top" | "bottom";
11
- type CommentsCommands<ReturnType> = {
12
- /**
13
- * Add a comment
14
- */
15
- addComment: (id: string) => ReturnType;
16
- selectThread: (id: string | null) => ReturnType;
17
- addPendingComment: () => ReturnType;
18
- };
19
-
20
10
  type AnchoredThreadsComponents = {
21
11
  Thread: ComponentType<ThreadProps>;
22
12
  };
@@ -36,9 +26,6 @@ interface AnchoredThreadsProps<M extends BaseMetadata = DM> extends Omit<Compone
36
26
  }
37
27
  declare function AnchoredThreads({ threads, components, className, style, editor, ...props }: AnchoredThreadsProps): react_jsx_runtime.JSX.Element | null;
38
28
 
39
- type FloatingComposerProps<M extends BaseMetadata$1 = DM> = Omit<ComposerProps<M>, "threadId" | "commentId"> & {
40
- editor: Editor | null;
41
- };
42
29
  declare const FloatingComposer: react.ForwardRefExoticComponent<Omit<ComposerProps<BaseMetadata$1>, "threadId" | "commentId"> & {
43
30
  editor: Editor | null;
44
31
  } & react.RefAttributes<HTMLFormElement>>;
@@ -77,244 +64,6 @@ type LiveblocksExtensionOptions = {
77
64
  declare function useIsEditorReady(): boolean;
78
65
  declare const useLiveblocksExtension: (opts?: LiveblocksExtensionOptions) => Extension;
79
66
 
80
- interface ToolbarSlotProps {
81
- editor: Editor;
82
- }
83
- type ToolbarSlot = ReactNode | ComponentType<ToolbarSlotProps>;
84
- interface ToolbarProps extends Omit<ComponentProps<"div">, "children"> {
85
- /**
86
- * The Tiptap editor.
87
- */
88
- editor: Editor | null;
89
- /**
90
- * The content of the toolbar, overriding the default content.
91
- * Use the `before` and `after` props if you want to keep and extend the default content.
92
- */
93
- children?: ToolbarSlot;
94
- /**
95
- * The content to display at the start of the toolbar.
96
- */
97
- before?: ToolbarSlot;
98
- /**
99
- * The content to display at the end of the toolbar.
100
- */
101
- after?: ToolbarSlot;
102
- }
103
- interface ToolbarButtonProps extends ComponentProps<"button"> {
104
- /**
105
- * The name of this button displayed in its tooltip.
106
- */
107
- name: string;
108
- /**
109
- * An optional icon displayed in this button.
110
- */
111
- icon?: ReactNode;
112
- /**
113
- * An optional keyboard shortcut displayed in this button's tooltip.
114
- *
115
- * @example
116
- * "Mod-Alt-B" → "⌘⌥B" in Apple environments, "⌃⌥B" otherwise
117
- * "Ctrl-Shift-Escape" → "⌃⇧⎋"
118
- * "Space" → "␣"
119
- */
120
- shortcut?: string;
121
- }
122
- interface ToolbarToggleProps extends ToolbarButtonProps {
123
- /**
124
- * Whether the button is toggled.
125
- */
126
- active: boolean;
127
- }
128
- interface ToolbarBlockSelectorItem {
129
- /**
130
- * The name of this block element, displayed as the label of this item.
131
- */
132
- name: string;
133
- /**
134
- * Optionally replace the name used as the label of this item by any content.
135
- */
136
- label?: ReactNode;
137
- /**
138
- * An optional icon displayed in this item.
139
- */
140
- icon?: ReactNode;
141
- /**
142
- * Whether this block element is currently active.
143
- * Set to `"default"` to display this item when no other item is active.
144
- */
145
- isActive: ((editor: Editor) => boolean) | "default";
146
- /**
147
- * A callback invoked when this item is selected.
148
- */
149
- setActive: (editor: Editor) => void;
150
- }
151
- interface ToolbarBlockSelectorProps extends ComponentProps<"button"> {
152
- /**
153
- * The items displayed in this block selector.
154
- * When provided as an array, the default items are overridden. To avoid this,
155
- * a function can be provided instead and it will receive the default items.
156
- *
157
- * @example
158
- * <Toolbar.BlockSelector
159
- * items={[
160
- * {
161
- * name: "Text",
162
- * isActive: "default",
163
- * setActive: () => { ... },
164
- * },
165
- * {
166
- * name: "Heading 1",
167
- * isActive: () => { ... },
168
- * setActive: () => { ... },
169
- * },
170
- * ]}
171
- * />
172
- *
173
- * @example
174
- * <Toolbar.BlockSelector
175
- * items={(defaultItems) => [
176
- * ...defaultItems,
177
- * {
178
- * name: "Custom block",
179
- * isActive: () => { ... },
180
- * setActive: () => { ... },
181
- * },
182
- * ]}
183
- * />
184
- */
185
- items?: ToolbarBlockSelectorItem[] | ((defaultItems: ToolbarBlockSelectorItem[]) => ToolbarBlockSelectorItem[]);
186
- }
187
- type ToolbarSeparatorProps = ComponentProps<"div">;
188
- declare function ToolbarSectionHistory(): react_jsx_runtime.JSX.Element;
189
- declare function ToolbarSectionInline(): react_jsx_runtime.JSX.Element;
190
- declare function ToolbarSectionCollaboration(): react_jsx_runtime.JSX.Element;
191
- /**
192
- * A static toolbar containing actions and values related to the editor.
193
- *
194
- * @example
195
- * <Toolbar editor={editor} />
196
- *
197
- * @example
198
- * <Toolbar editor={editor}>
199
- * <Toolbar.BlockSelector />
200
- * <Toolbar.Separator />
201
- * <Toolbar.SectionInline />
202
- * <Toolbar.Separator />
203
- * <Toolbar.Button name="Custom action" onClick={() => { ... }} icon={<Icon.QuestionMark />} />
204
- * </Toolbar>
205
- */
206
- declare const Toolbar: react.ForwardRefExoticComponent<Omit<ToolbarProps, "ref"> & react.RefAttributes<HTMLDivElement>> & {
207
- /**
208
- * A button for triggering actions.
209
- *
210
- * @example
211
- * <Toolbar.Button name="Comment" shortcut="Mod-Shift-E" onClick={() => { ... }}>Comment</Toolbar.Button>
212
- *
213
- * @example
214
- * <Toolbar.Button name="Mention someone" icon={<Icon.Mention />} onClick={() => { ... }} />
215
- */
216
- Button: react.ForwardRefExoticComponent<Omit<ToolbarButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
217
- /**
218
- * A toggle button for values that can be active or inactive.
219
- *
220
- * @example
221
- * <Toolbar.Toggle name="Bold" active={isBold}>Bold</Toolbar.Toggle>
222
- *
223
- * @example
224
- * <Toolbar.Toggle name="Italic" icon={<Icon.Italic />} shortcut="Mod-I" active={isItalic} onClick={() => { ... }} />
225
- */
226
- Toggle: react.ForwardRefExoticComponent<Omit<ToolbarToggleProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
227
- /**
228
- * A dropdown selector to switch between different block types.
229
- *
230
- * @example
231
- * <Toolbar.BlockSelector />
232
- */
233
- BlockSelector: react.ForwardRefExoticComponent<Omit<ToolbarBlockSelectorProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
234
- /**
235
- * A visual (and accessible) separator to separate sections in a toolbar.
236
- */
237
- Separator: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
238
- /**
239
- * A section containing history actions. (e.g. undo, redo)
240
- */
241
- SectionHistory: typeof ToolbarSectionHistory;
242
- /**
243
- * A section containing inline formatting actions. (e.g. bold, italic, underline, ...)
244
- */
245
- SectionInline: typeof ToolbarSectionInline;
246
- /**
247
- * A section containing collaborative actions. (e.g. adding a comment)
248
- */
249
- SectionCollaboration: typeof ToolbarSectionCollaboration;
250
- };
251
-
252
- interface FloatingToolbarProps extends Omit<ComponentProps<"div">, "children"> {
253
- /**
254
- * The Tiptap editor.
255
- */
256
- editor: Editor | null;
257
- /**
258
- * The vertical position of the floating toolbar.
259
- */
260
- position?: FloatingPosition;
261
- /**
262
- * The vertical offset of the floating toolbar from the selection.
263
- */
264
- offset?: number;
265
- /**
266
- * The content of the floating toolbar, overriding the default content.
267
- * Use the `before` and `after` props if you want to keep and extend the default content.
268
- */
269
- children?: ToolbarSlot;
270
- /**
271
- * The content to display at the start of the floating toolbar.
272
- */
273
- before?: ToolbarSlot;
274
- /**
275
- * The content to display at the end of the floating toolbar.
276
- */
277
- after?: ToolbarSlot;
278
- }
279
- /**
280
- * A floating toolbar attached to the selection and containing actions and values related to the editor.
281
- *
282
- * @example
283
- * <FloatingToolbar editor={editor} />
284
- *
285
- * @example
286
- * <FloatingToolbar editor={editor}>
287
- * <Toolbar.BlockSelector />
288
- * <Toolbar.Separator />
289
- * <Toolbar.SectionInline />
290
- * <Toolbar.Separator />
291
- * <Toolbar.Button name="Custom action" onClick={() => { ... }} icon={<Icon.QuestionMark />} />
292
- * </FloatingToolbar>
293
- */
294
- declare const FloatingToolbar: react.ForwardRefExoticComponent<Omit<FloatingToolbarProps, "ref"> & react.RefAttributes<HTMLDivElement>> & {
295
- /**
296
- * A component that can be wrapped around elements which are rendered outside of the floating
297
- * toolbar (e.g. portals) to prevent the toolbar from closing when clicking/focusing within them.
298
- *
299
- * @example
300
- * <FloatingToolbar editor={editor}>
301
- * <Popover.Root>
302
- * <Popover.Trigger asChild>
303
- * <Toolbar.Button>Open popover</Toolbar.Button>
304
- * </Popover.Trigger>
305
- * <Popover.Portal>
306
- * <FloatingToolbar.External>
307
- * <Popover.Content>
308
- * This popover is rendered outside of the floating toolbar, but the toolbar will not close when clicking/focusing within it.
309
- * </Popover.Content>
310
- * </FloatingToolbar.External>
311
- * </Popover.Portal>
312
- * </Popover.Root>
313
- * </FloatingToolbar>
314
- */
315
- External: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
316
- };
317
-
318
67
  interface HistoryVersionPreviewProps extends ComponentPropsWithoutRef<"div"> {
319
68
  version: HistoryVersion;
320
69
  editor: Editor;
@@ -330,8 +79,15 @@ declare const HistoryVersionPreview: react.ForwardRefExoticComponent<HistoryVers
330
79
 
331
80
  declare module "@tiptap/core" {
332
81
  interface Commands<ReturnType> {
333
- comments: CommentsCommands<ReturnType>;
82
+ comments: {
83
+ /**
84
+ * Add a comment
85
+ */
86
+ addComment: (id: string) => ReturnType;
87
+ selectThread: (id: string | null) => ReturnType;
88
+ addPendingComment: () => ReturnType;
89
+ };
334
90
  }
335
91
  }
336
92
 
337
- export { AnchoredThreads, AnchoredThreadsProps, FloatingComposer, FloatingComposerProps, FloatingThreads, FloatingThreadsProps, FloatingToolbar, FloatingToolbarProps, HistoryVersionPreview, HistoryVersionPreviewProps, Toolbar, ToolbarBlockSelectorItem, ToolbarBlockSelectorProps, ToolbarButtonProps, ToolbarProps, ToolbarSeparatorProps, ToolbarToggleProps, useIsEditorReady, useLiveblocksExtension };
93
+ export { AnchoredThreads, FloatingComposer, FloatingThreads, HistoryVersionPreview, useIsEditorReady, useLiveblocksExtension };
package/dist/index.js CHANGED
@@ -6,8 +6,6 @@ var AnchoredThreads = require('./comments/AnchoredThreads.js');
6
6
  var FloatingComposer = require('./comments/FloatingComposer.js');
7
7
  var FloatingThreads = require('./comments/FloatingThreads.js');
8
8
  var LiveblocksExtension = require('./LiveblocksExtension.js');
9
- var FloatingToolbar = require('./toolbar/FloatingToolbar.js');
10
- var Toolbar = require('./toolbar/Toolbar.js');
11
9
  var HistoryVersionPreview = require('./version-history/HistoryVersionPreview.js');
12
10
 
13
11
  core.detectDupes(version.PKG_NAME, version.PKG_VERSION, version.PKG_FORMAT);
@@ -17,7 +15,5 @@ exports.FloatingComposer = FloatingComposer.FloatingComposer;
17
15
  exports.FloatingThreads = FloatingThreads.FloatingThreads;
18
16
  exports.useIsEditorReady = LiveblocksExtension.useIsEditorReady;
19
17
  exports.useLiveblocksExtension = LiveblocksExtension.useLiveblocksExtension;
20
- exports.FloatingToolbar = FloatingToolbar.FloatingToolbar;
21
- exports.Toolbar = Toolbar.Toolbar;
22
18
  exports.HistoryVersionPreview = HistoryVersionPreview.HistoryVersionPreview;
23
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport type { CommentsCommands } from \"./types\";\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { AnchoredThreadsProps } from \"./comments/AnchoredThreads\";\nexport { AnchoredThreads } from \"./comments/AnchoredThreads\";\nexport type { FloatingComposerProps } from \"./comments/FloatingComposer\";\nexport { FloatingComposer } from \"./comments/FloatingComposer\";\nexport type { FloatingThreadsProps } from \"./comments/FloatingThreads\";\nexport { FloatingThreads } from \"./comments/FloatingThreads\";\nexport { useLiveblocksExtension } from \"./LiveblocksExtension\";\nexport { useIsEditorReady } from \"./LiveblocksExtension\";\nexport type { FloatingToolbarProps } from \"./toolbar/FloatingToolbar\";\nexport { FloatingToolbar } from \"./toolbar/FloatingToolbar\";\nexport type {\n ToolbarBlockSelectorItem,\n ToolbarBlockSelectorProps,\n ToolbarButtonProps,\n ToolbarProps,\n ToolbarSeparatorProps,\n ToolbarToggleProps,\n} from \"./toolbar/Toolbar\";\nexport { Toolbar } from \"./toolbar/Toolbar\";\nexport type { HistoryVersionPreviewProps } from \"./version-history/HistoryVersionPreview\";\nexport { HistoryVersionPreview } from \"./version-history/HistoryVersionPreview\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n comments: CommentsCommands<ReturnType>;\n }\n}\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;;;AAKAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport { AnchoredThreads } from \"./comments/AnchoredThreads\";\nexport { FloatingComposer } from \"./comments/FloatingComposer\";\nexport { FloatingThreads } from \"./comments/FloatingThreads\";\nexport { useLiveblocksExtension } from \"./LiveblocksExtension\";\nexport { useIsEditorReady } from \"./LiveblocksExtension\";\nexport { HistoryVersionPreview } from \"./version-history/HistoryVersionPreview\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n comments: {\n /**\n * Add a comment\n */\n addComment: (id: string) => ReturnType;\n selectThread: (id: string | null) => ReturnType;\n addPendingComment: () => ReturnType;\n };\n }\n}\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;AAIAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -4,8 +4,6 @@ export { AnchoredThreads } from './comments/AnchoredThreads.mjs';
4
4
  export { FloatingComposer } from './comments/FloatingComposer.mjs';
5
5
  export { FloatingThreads } from './comments/FloatingThreads.mjs';
6
6
  export { useIsEditorReady, useLiveblocksExtension } from './LiveblocksExtension.mjs';
7
- export { FloatingToolbar } from './toolbar/FloatingToolbar.mjs';
8
- export { Toolbar } from './toolbar/Toolbar.mjs';
9
7
  export { HistoryVersionPreview } from './version-history/HistoryVersionPreview.mjs';
10
8
 
11
9
  detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport type { CommentsCommands } from \"./types\";\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { AnchoredThreadsProps } from \"./comments/AnchoredThreads\";\nexport { AnchoredThreads } from \"./comments/AnchoredThreads\";\nexport type { FloatingComposerProps } from \"./comments/FloatingComposer\";\nexport { FloatingComposer } from \"./comments/FloatingComposer\";\nexport type { FloatingThreadsProps } from \"./comments/FloatingThreads\";\nexport { FloatingThreads } from \"./comments/FloatingThreads\";\nexport { useLiveblocksExtension } from \"./LiveblocksExtension\";\nexport { useIsEditorReady } from \"./LiveblocksExtension\";\nexport type { FloatingToolbarProps } from \"./toolbar/FloatingToolbar\";\nexport { FloatingToolbar } from \"./toolbar/FloatingToolbar\";\nexport type {\n ToolbarBlockSelectorItem,\n ToolbarBlockSelectorProps,\n ToolbarButtonProps,\n ToolbarProps,\n ToolbarSeparatorProps,\n ToolbarToggleProps,\n} from \"./toolbar/Toolbar\";\nexport { Toolbar } from \"./toolbar/Toolbar\";\nexport type { HistoryVersionPreviewProps } from \"./version-history/HistoryVersionPreview\";\nexport { HistoryVersionPreview } from \"./version-history/HistoryVersionPreview\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n comments: CommentsCommands<ReturnType>;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAKA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport { AnchoredThreads } from \"./comments/AnchoredThreads\";\nexport { FloatingComposer } from \"./comments/FloatingComposer\";\nexport { FloatingThreads } from \"./comments/FloatingThreads\";\nexport { useLiveblocksExtension } from \"./LiveblocksExtension\";\nexport { useIsEditorReady } from \"./LiveblocksExtension\";\nexport { HistoryVersionPreview } from \"./version-history/HistoryVersionPreview\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n comments: {\n /**\n * Add a comment\n */\n addComment: (id: string) => ReturnType;\n selectThread: (id: string | null) => ReturnType;\n addPendingComment: () => ReturnType;\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
package/dist/types.js CHANGED
@@ -10,28 +10,24 @@ const LIVEBLOCKS_MENTION_NOTIFIER_KEY = new state.PluginKey(
10
10
  "lb-plugin-mention-notify"
11
11
  );
12
12
  const LIVEBLOCKS_MENTION_TYPE = "liveblocksMention";
13
- const THREADS_ACTIVE_SELECTION_PLUGIN = new state.PluginKey(
14
- "lb-threads-active-selection-plugin"
13
+ const ACTIVE_SELECTION_PLUGIN = new state.PluginKey(
14
+ "lb-active-selection-plugin"
15
15
  );
16
16
  const THREADS_PLUGIN_KEY = new state.PluginKey(
17
17
  "lb-threads-plugin"
18
18
  );
19
- const AI_TOOLBAR_SELECTION_PLUGIN = new state.PluginKey(
20
- "lb-ai-toolbar-selection-plugin"
21
- );
22
19
  const LIVEBLOCKS_COMMENT_MARK_TYPE = "liveblocksCommentMark";
23
20
  var ThreadPluginActions = /* @__PURE__ */ ((ThreadPluginActions2) => {
24
21
  ThreadPluginActions2["SET_SELECTED_THREAD_ID"] = "SET_SELECTED_THREAD_ID";
25
22
  return ThreadPluginActions2;
26
23
  })(ThreadPluginActions || {});
27
24
 
28
- exports.AI_TOOLBAR_SELECTION_PLUGIN = AI_TOOLBAR_SELECTION_PLUGIN;
25
+ exports.ACTIVE_SELECTION_PLUGIN = ACTIVE_SELECTION_PLUGIN;
29
26
  exports.LIVEBLOCKS_COMMENT_MARK_TYPE = LIVEBLOCKS_COMMENT_MARK_TYPE;
30
27
  exports.LIVEBLOCKS_MENTION_KEY = LIVEBLOCKS_MENTION_KEY;
31
28
  exports.LIVEBLOCKS_MENTION_NOTIFIER_KEY = LIVEBLOCKS_MENTION_NOTIFIER_KEY;
32
29
  exports.LIVEBLOCKS_MENTION_PASTE_KEY = LIVEBLOCKS_MENTION_PASTE_KEY;
33
30
  exports.LIVEBLOCKS_MENTION_TYPE = LIVEBLOCKS_MENTION_TYPE;
34
- exports.THREADS_ACTIVE_SELECTION_PLUGIN = THREADS_ACTIVE_SELECTION_PLUGIN;
35
31
  exports.THREADS_PLUGIN_KEY = THREADS_PLUGIN_KEY;
36
32
  exports.ThreadPluginActions = ThreadPluginActions;
37
33
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { TextSelection } from \"@tiptap/pm/state\";\nimport { PluginKey } from \"@tiptap/pm/state\";\nimport type { DecorationSet } from \"@tiptap/pm/view\";\nimport type { ChainedCommands, SingleCommands } from \"@tiptap/react\";\n\nexport const LIVEBLOCKS_MENTION_KEY = new PluginKey(\"lb-plugin-mention\");\nexport const LIVEBLOCKS_MENTION_PASTE_KEY = new PluginKey(\n \"lb-plugin-mention-paste\"\n);\nexport const LIVEBLOCKS_MENTION_NOTIFIER_KEY = new PluginKey(\n \"lb-plugin-mention-notify\"\n);\nexport const LIVEBLOCKS_MENTION_TYPE = \"liveblocksMention\";\n\nexport const THREADS_ACTIVE_SELECTION_PLUGIN = new PluginKey(\n \"lb-threads-active-selection-plugin\"\n);\nexport const THREADS_PLUGIN_KEY = new PluginKey<ThreadPluginState>(\n \"lb-threads-plugin\"\n);\nexport const AI_TOOLBAR_SELECTION_PLUGIN = new PluginKey(\n \"lb-ai-toolbar-selection-plugin\"\n);\n\nexport const LIVEBLOCKS_COMMENT_MARK_TYPE = \"liveblocksCommentMark\";\n\nexport type CommentsExtensionStorage = {\n pendingCommentSelection: TextSelection | null;\n};\n\nexport const enum ThreadPluginActions {\n SET_SELECTED_THREAD_ID = \"SET_SELECTED_THREAD_ID\",\n}\n\nexport type LiveblocksExtensionStorage = CommentsExtensionStorage;\n\nexport type ThreadPluginState = {\n threadPositions: Map<string, { from: number; to: number }>;\n selectedThreadId: string | null;\n selectedThreadPos: number | null;\n decorations: DecorationSet;\n};\n\nexport type FloatingPosition = \"top\" | \"bottom\";\n\nexport type ExtendedCommands<\n T extends string,\n A extends any[] = [],\n> = SingleCommands & Record<T, (...args: A) => boolean>;\n\nexport type ExtendedChainedCommands<\n T extends string,\n A extends any[] = [],\n> = ChainedCommands & Record<T, (...args: A) => ChainedCommands>;\n\nexport type CommentsCommands<ReturnType> = {\n /**\n * Add a comment\n */\n addComment: (id: string) => ReturnType;\n selectThread: (id: string | null) => ReturnType;\n addPendingComment: () => ReturnType;\n /** @internal */\n closePendingComment: () => ReturnType;\n};\n"],"names":["PluginKey","ThreadPluginActions"],"mappings":";;;;AAKa,MAAA,sBAAA,GAAyB,IAAIA,eAAA,CAAU,mBAAmB,EAAA;AAChE,MAAM,+BAA+B,IAAIA,eAAA;AAAA,EAC9C,yBAAA;AACF,EAAA;AACO,MAAM,kCAAkC,IAAIA,eAAA;AAAA,EACjD,0BAAA;AACF,EAAA;AACO,MAAM,uBAA0B,GAAA,oBAAA;AAEhC,MAAM,kCAAkC,IAAIA,eAAA;AAAA,EACjD,oCAAA;AACF,EAAA;AACO,MAAM,qBAAqB,IAAIA,eAAA;AAAA,EACpC,mBAAA;AACF,EAAA;AACO,MAAM,8BAA8B,IAAIA,eAAA;AAAA,EAC7C,gCAAA;AACF,EAAA;AAEO,MAAM,4BAA+B,GAAA,wBAAA;AAM1B,IAAA,mBAAA,qBAAAC,oBAAX,KAAA;AACL,EAAAA,qBAAA,wBAAyB,CAAA,GAAA,wBAAA,CAAA;AADT,EAAAA,OAAAA,oBAAAA,CAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA;;;;;;;;;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { TextSelection } from \"@tiptap/pm/state\";\nimport { PluginKey } from \"@tiptap/pm/state\";\nimport type { DecorationSet } from \"@tiptap/pm/view\";\n\nexport const LIVEBLOCKS_MENTION_KEY = new PluginKey(\"lb-plugin-mention\");\nexport const LIVEBLOCKS_MENTION_PASTE_KEY = new PluginKey(\n \"lb-plugin-mention-paste\"\n);\nexport const LIVEBLOCKS_MENTION_NOTIFIER_KEY = new PluginKey(\n \"lb-plugin-mention-notify\"\n);\nexport const LIVEBLOCKS_MENTION_TYPE = \"liveblocksMention\";\n\nexport const ACTIVE_SELECTION_PLUGIN = new PluginKey(\n \"lb-active-selection-plugin\"\n);\nexport const THREADS_PLUGIN_KEY = new PluginKey<ThreadPluginState>(\n \"lb-threads-plugin\"\n);\n\nexport const LIVEBLOCKS_COMMENT_MARK_TYPE = \"liveblocksCommentMark\";\n\nexport type CommentsExtensionStorage = {\n pendingComment: boolean;\n};\n\nexport const enum ThreadPluginActions {\n SET_SELECTED_THREAD_ID = \"SET_SELECTED_THREAD_ID\",\n}\n\nexport type ThreadPluginState = {\n threadPositions: Map<string, { from: number; to: number }>;\n selectedThreadId: string | null;\n selectedThreadPos: number | null;\n decorations: DecorationSet;\n};\n"],"names":["PluginKey","ThreadPluginActions"],"mappings":";;;;AAIa,MAAA,sBAAA,GAAyB,IAAIA,eAAA,CAAU,mBAAmB,EAAA;AAChE,MAAM,+BAA+B,IAAIA,eAAA;AAAA,EAC9C,yBAAA;AACF,EAAA;AACO,MAAM,kCAAkC,IAAIA,eAAA;AAAA,EACjD,0BAAA;AACF,EAAA;AACO,MAAM,uBAA0B,GAAA,oBAAA;AAEhC,MAAM,0BAA0B,IAAIA,eAAA;AAAA,EACzC,4BAAA;AACF,EAAA;AACO,MAAM,qBAAqB,IAAIA,eAAA;AAAA,EACpC,mBAAA;AACF,EAAA;AAEO,MAAM,4BAA+B,GAAA,wBAAA;AAM1B,IAAA,mBAAA,qBAAAC,oBAAX,KAAA;AACL,EAAAA,qBAAA,wBAAyB,CAAA,GAAA,wBAAA,CAAA;AADT,EAAAA,OAAAA,oBAAAA,CAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA;;;;;;;;;;;"}
package/dist/types.mjs CHANGED
@@ -8,20 +8,17 @@ const LIVEBLOCKS_MENTION_NOTIFIER_KEY = new PluginKey(
8
8
  "lb-plugin-mention-notify"
9
9
  );
10
10
  const LIVEBLOCKS_MENTION_TYPE = "liveblocksMention";
11
- const THREADS_ACTIVE_SELECTION_PLUGIN = new PluginKey(
12
- "lb-threads-active-selection-plugin"
11
+ const ACTIVE_SELECTION_PLUGIN = new PluginKey(
12
+ "lb-active-selection-plugin"
13
13
  );
14
14
  const THREADS_PLUGIN_KEY = new PluginKey(
15
15
  "lb-threads-plugin"
16
16
  );
17
- const AI_TOOLBAR_SELECTION_PLUGIN = new PluginKey(
18
- "lb-ai-toolbar-selection-plugin"
19
- );
20
17
  const LIVEBLOCKS_COMMENT_MARK_TYPE = "liveblocksCommentMark";
21
18
  var ThreadPluginActions = /* @__PURE__ */ ((ThreadPluginActions2) => {
22
19
  ThreadPluginActions2["SET_SELECTED_THREAD_ID"] = "SET_SELECTED_THREAD_ID";
23
20
  return ThreadPluginActions2;
24
21
  })(ThreadPluginActions || {});
25
22
 
26
- export { AI_TOOLBAR_SELECTION_PLUGIN, LIVEBLOCKS_COMMENT_MARK_TYPE, LIVEBLOCKS_MENTION_KEY, LIVEBLOCKS_MENTION_NOTIFIER_KEY, LIVEBLOCKS_MENTION_PASTE_KEY, LIVEBLOCKS_MENTION_TYPE, THREADS_ACTIVE_SELECTION_PLUGIN, THREADS_PLUGIN_KEY, ThreadPluginActions };
23
+ export { ACTIVE_SELECTION_PLUGIN, LIVEBLOCKS_COMMENT_MARK_TYPE, LIVEBLOCKS_MENTION_KEY, LIVEBLOCKS_MENTION_NOTIFIER_KEY, LIVEBLOCKS_MENTION_PASTE_KEY, LIVEBLOCKS_MENTION_TYPE, THREADS_PLUGIN_KEY, ThreadPluginActions };
27
24
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sources":["../src/types.ts"],"sourcesContent":["import type { TextSelection } from \"@tiptap/pm/state\";\nimport { PluginKey } from \"@tiptap/pm/state\";\nimport type { DecorationSet } from \"@tiptap/pm/view\";\nimport type { ChainedCommands, SingleCommands } from \"@tiptap/react\";\n\nexport const LIVEBLOCKS_MENTION_KEY = new PluginKey(\"lb-plugin-mention\");\nexport const LIVEBLOCKS_MENTION_PASTE_KEY = new PluginKey(\n \"lb-plugin-mention-paste\"\n);\nexport const LIVEBLOCKS_MENTION_NOTIFIER_KEY = new PluginKey(\n \"lb-plugin-mention-notify\"\n);\nexport const LIVEBLOCKS_MENTION_TYPE = \"liveblocksMention\";\n\nexport const THREADS_ACTIVE_SELECTION_PLUGIN = new PluginKey(\n \"lb-threads-active-selection-plugin\"\n);\nexport const THREADS_PLUGIN_KEY = new PluginKey<ThreadPluginState>(\n \"lb-threads-plugin\"\n);\nexport const AI_TOOLBAR_SELECTION_PLUGIN = new PluginKey(\n \"lb-ai-toolbar-selection-plugin\"\n);\n\nexport const LIVEBLOCKS_COMMENT_MARK_TYPE = \"liveblocksCommentMark\";\n\nexport type CommentsExtensionStorage = {\n pendingCommentSelection: TextSelection | null;\n};\n\nexport const enum ThreadPluginActions {\n SET_SELECTED_THREAD_ID = \"SET_SELECTED_THREAD_ID\",\n}\n\nexport type LiveblocksExtensionStorage = CommentsExtensionStorage;\n\nexport type ThreadPluginState = {\n threadPositions: Map<string, { from: number; to: number }>;\n selectedThreadId: string | null;\n selectedThreadPos: number | null;\n decorations: DecorationSet;\n};\n\nexport type FloatingPosition = \"top\" | \"bottom\";\n\nexport type ExtendedCommands<\n T extends string,\n A extends any[] = [],\n> = SingleCommands & Record<T, (...args: A) => boolean>;\n\nexport type ExtendedChainedCommands<\n T extends string,\n A extends any[] = [],\n> = ChainedCommands & Record<T, (...args: A) => ChainedCommands>;\n\nexport type CommentsCommands<ReturnType> = {\n /**\n * Add a comment\n */\n addComment: (id: string) => ReturnType;\n selectThread: (id: string | null) => ReturnType;\n addPendingComment: () => ReturnType;\n /** @internal */\n closePendingComment: () => ReturnType;\n};\n"],"names":["ThreadPluginActions"],"mappings":";;AAKa,MAAA,sBAAA,GAAyB,IAAI,SAAA,CAAU,mBAAmB,EAAA;AAChE,MAAM,+BAA+B,IAAI,SAAA;AAAA,EAC9C,yBAAA;AACF,EAAA;AACO,MAAM,kCAAkC,IAAI,SAAA;AAAA,EACjD,0BAAA;AACF,EAAA;AACO,MAAM,uBAA0B,GAAA,oBAAA;AAEhC,MAAM,kCAAkC,IAAI,SAAA;AAAA,EACjD,oCAAA;AACF,EAAA;AACO,MAAM,qBAAqB,IAAI,SAAA;AAAA,EACpC,mBAAA;AACF,EAAA;AACO,MAAM,8BAA8B,IAAI,SAAA;AAAA,EAC7C,gCAAA;AACF,EAAA;AAEO,MAAM,4BAA+B,GAAA,wBAAA;AAM1B,IAAA,mBAAA,qBAAAA,oBAAX,KAAA;AACL,EAAAA,qBAAA,wBAAyB,CAAA,GAAA,wBAAA,CAAA;AADT,EAAAA,OAAAA,oBAAAA,CAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA;;;;"}
1
+ {"version":3,"file":"types.mjs","sources":["../src/types.ts"],"sourcesContent":["import type { TextSelection } from \"@tiptap/pm/state\";\nimport { PluginKey } from \"@tiptap/pm/state\";\nimport type { DecorationSet } from \"@tiptap/pm/view\";\n\nexport const LIVEBLOCKS_MENTION_KEY = new PluginKey(\"lb-plugin-mention\");\nexport const LIVEBLOCKS_MENTION_PASTE_KEY = new PluginKey(\n \"lb-plugin-mention-paste\"\n);\nexport const LIVEBLOCKS_MENTION_NOTIFIER_KEY = new PluginKey(\n \"lb-plugin-mention-notify\"\n);\nexport const LIVEBLOCKS_MENTION_TYPE = \"liveblocksMention\";\n\nexport const ACTIVE_SELECTION_PLUGIN = new PluginKey(\n \"lb-active-selection-plugin\"\n);\nexport const THREADS_PLUGIN_KEY = new PluginKey<ThreadPluginState>(\n \"lb-threads-plugin\"\n);\n\nexport const LIVEBLOCKS_COMMENT_MARK_TYPE = \"liveblocksCommentMark\";\n\nexport type CommentsExtensionStorage = {\n pendingComment: boolean;\n};\n\nexport const enum ThreadPluginActions {\n SET_SELECTED_THREAD_ID = \"SET_SELECTED_THREAD_ID\",\n}\n\nexport type ThreadPluginState = {\n threadPositions: Map<string, { from: number; to: number }>;\n selectedThreadId: string | null;\n selectedThreadPos: number | null;\n decorations: DecorationSet;\n};\n"],"names":["ThreadPluginActions"],"mappings":";;AAIa,MAAA,sBAAA,GAAyB,IAAI,SAAA,CAAU,mBAAmB,EAAA;AAChE,MAAM,+BAA+B,IAAI,SAAA;AAAA,EAC9C,yBAAA;AACF,EAAA;AACO,MAAM,kCAAkC,IAAI,SAAA;AAAA,EACjD,0BAAA;AACF,EAAA;AACO,MAAM,uBAA0B,GAAA,oBAAA;AAEhC,MAAM,0BAA0B,IAAI,SAAA;AAAA,EACzC,4BAAA;AACF,EAAA;AACO,MAAM,qBAAqB,IAAI,SAAA;AAAA,EACpC,mBAAA;AACF,EAAA;AAEO,MAAM,4BAA+B,GAAA,wBAAA;AAM1B,IAAA,mBAAA,qBAAAA,oBAAX,KAAA;AACL,EAAAA,qBAAA,wBAAyB,CAAA,GAAA,wBAAA,CAAA;AADT,EAAAA,OAAAA,oBAAAA,CAAAA;AAAA,CAAA,EAAA,mBAAA,IAAA,EAAA;;;;"}
package/dist/utils.js CHANGED
@@ -40,24 +40,7 @@ const mapFragment = (fragment, callback) => {
40
40
  });
41
41
  return model.Fragment.from(content);
42
42
  };
43
- function getDomRangeFromTextSelection(selection, editor) {
44
- const { from, to } = selection;
45
- const fromPos = editor.view.domAtPos(from);
46
- const endPos = editor.view.domAtPos(to);
47
- const domRange = document.createRange();
48
- domRange.setStart(fromPos.node, fromPos.offset);
49
- domRange.setEnd(endPos.node, endPos.offset);
50
- return domRange;
51
- }
52
- function compareTextSelections(a, b) {
53
- if (!a || !b) {
54
- return false;
55
- }
56
- return a.eq(b);
57
- }
58
43
 
59
- exports.compareTextSelections = compareTextSelections;
60
- exports.getDomRangeFromTextSelection = getDomRangeFromTextSelection;
61
44
  exports.getMentionsFromNode = getMentionsFromNode;
62
45
  exports.getRectFromCoords = getRectFromCoords;
63
46
  exports.mapFragment = mapFragment;
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import type { ClientRectObject } from \"@floating-ui/react-dom\";\nimport type { Editor, Range } from \"@tiptap/core\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\nimport { Fragment } from \"@tiptap/pm/model\";\nimport type { TextSelection } from \"@tiptap/pm/state\";\n\nimport { LIVEBLOCKS_MENTION_TYPE } from \"./types\";\n\nexport const getRectFromCoords = (coords: {\n top: number;\n left: number;\n right: number;\n bottom: number;\n}): ClientRectObject => {\n return {\n ...coords,\n x: coords.left,\n y: coords.top,\n width: coords.right - coords.left,\n height: coords.bottom - coords.top,\n };\n};\n\nexport const getMentionsFromNode = (\n node: ProseMirrorNode,\n range: Range\n): { notificationId: string; userId: string }[] => {\n const result: { notificationId: string; userId: string }[] = [];\n node.nodesBetween(range.from, range.to, (child) => {\n if (child.type.name === LIVEBLOCKS_MENTION_TYPE) {\n const mention = child.attrs as { id?: string; notificationId?: string };\n if (mention.id && mention.notificationId) {\n result.push({\n notificationId: mention.notificationId,\n userId: mention.id,\n });\n }\n }\n });\n return result;\n};\n\n// How to modify data in transformPasted, inspired by: https://discuss.prosemirror.net/t/modify-specific-node-on-copy-and-paste-in-clipboard/4901/4\nexport const mapFragment = (\n fragment: Fragment,\n callback: (\n node: ProseMirrorNode\n ) => ProseMirrorNode | ProseMirrorNode[] | Fragment | null\n): Fragment => {\n const content: ProseMirrorNode[] = [];\n fragment.forEach((node) => {\n if (node.content.childCount > 0) {\n content.push(\n node.type.create(node.attrs, mapFragment(node.content, callback))\n );\n return;\n }\n content.push(callback(node) as ProseMirrorNode);\n });\n\n return Fragment.from(content);\n};\n\nexport function getDomRangeFromTextSelection(\n selection: TextSelection,\n editor: Editor\n) {\n const { from, to } = selection;\n const fromPos = editor.view.domAtPos(from);\n const endPos = editor.view.domAtPos(to);\n\n const domRange = document.createRange();\n domRange.setStart(fromPos.node, fromPos.offset);\n domRange.setEnd(endPos.node, endPos.offset);\n\n return domRange;\n}\n\nexport function compareTextSelections(\n a: TextSelection | null | undefined,\n b: TextSelection | null | undefined\n) {\n if (!a || !b) {\n return false;\n }\n\n return a.eq(b);\n}\n"],"names":["LIVEBLOCKS_MENTION_TYPE","Fragment"],"mappings":";;;;;AAQa,MAAA,iBAAA,GAAoB,CAAC,MAKV,KAAA;AACtB,EAAO,OAAA;AAAA,IACL,GAAG,MAAA;AAAA,IACH,GAAG,MAAO,CAAA,IAAA;AAAA,IACV,GAAG,MAAO,CAAA,GAAA;AAAA,IACV,KAAA,EAAO,MAAO,CAAA,KAAA,GAAQ,MAAO,CAAA,IAAA;AAAA,IAC7B,MAAA,EAAQ,MAAO,CAAA,MAAA,GAAS,MAAO,CAAA,GAAA;AAAA,GACjC,CAAA;AACF,EAAA;AAEa,MAAA,mBAAA,GAAsB,CACjC,IAAA,EACA,KACiD,KAAA;AACjD,EAAA,MAAM,SAAuD,EAAC,CAAA;AAC9D,EAAA,IAAA,CAAK,aAAa,KAAM,CAAA,IAAA,EAAM,KAAM,CAAA,EAAA,EAAI,CAAC,KAAU,KAAA;AACjD,IAAI,IAAA,KAAA,CAAM,IAAK,CAAA,IAAA,KAASA,6BAAyB,EAAA;AAC/C,MAAA,MAAM,UAAU,KAAM,CAAA,KAAA,CAAA;AACtB,MAAI,IAAA,OAAA,CAAQ,EAAM,IAAA,OAAA,CAAQ,cAAgB,EAAA;AACxC,QAAA,MAAA,CAAO,IAAK,CAAA;AAAA,UACV,gBAAgB,OAAQ,CAAA,cAAA;AAAA,UACxB,QAAQ,OAAQ,CAAA,EAAA;AAAA,SACjB,CAAA,CAAA;AAAA,OACH;AAAA,KACF;AAAA,GACD,CAAA,CA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,CAAK,IAAA,CAAC,CAAG,EAAA;AACZ,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,CAAA,CAAE,GAAG,CAAC,CAAA,CAAA;AACf;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import type { ClientRectObject } from \"@floating-ui/react-dom\";\nimport type { Range } from \"@tiptap/core\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\nimport { Fragment } from \"@tiptap/pm/model\";\n\nimport { LIVEBLOCKS_MENTION_TYPE } from \"./types\";\n\nexport const getRectFromCoords = (coords: {\n top: number;\n left: number;\n right: number;\n bottom: number;\n}): ClientRectObject => {\n return {\n ...coords,\n x: coords.left,\n y: coords.top,\n width: coords.right - coords.left,\n height: coords.bottom - coords.top,\n };\n};\n\nexport const getMentionsFromNode = (\n node: ProseMirrorNode,\n range: Range\n): { notificationId: string; userId: string }[] => {\n const result: { notificationId: string; userId: string }[] = [];\n node.nodesBetween(range.from, range.to, (child) => {\n if (child.type.name === LIVEBLOCKS_MENTION_TYPE) {\n const mention = child.attrs as { id?: string; notificationId?: string };\n if (mention.id && mention.notificationId) {\n result.push({\n notificationId: mention.notificationId,\n userId: mention.id,\n });\n }\n }\n });\n return result;\n};\n\n// How to modify data in transformPasted, inspired by: https://discuss.prosemirror.net/t/modify-specific-node-on-copy-and-paste-in-clipboard/4901/4\nexport const mapFragment = (\n fragment: Fragment,\n callback: (\n node: ProseMirrorNode\n ) => ProseMirrorNode | ProseMirrorNode[] | Fragment | null\n): Fragment => {\n const content: ProseMirrorNode[] = [];\n fragment.forEach((node) => {\n if (node.content.childCount > 0) {\n content.push(\n node.type.create(node.attrs, mapFragment(node.content, callback))\n );\n return;\n }\n content.push(callback(node) as ProseMirrorNode);\n });\n\n return Fragment.from(content);\n};\n"],"names":["LIVEBLOCKS_MENTION_TYPE","Fragment"],"mappings":";;;;;AAOa,MAAA,iBAAA,GAAoB,CAAC,MAKV,KA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AA;AAAA,OAClE,CAAA;AACA,MAAA,OAAA;AAAA,KACF;AACA,IAAQ,OAAA,CAAA,IAAA,CAAK,QAAS,CAAA,IAAI,CAAoB,CAAA,CAAA;AAAA,GAC/C,CAAA,CAAA;AAED,EAAO,OAAAC,cAAA,CAAS,KAAK,OAAO,CAAA,CAAA;AAC9B;;;;;;"}
package/dist/utils.mjs CHANGED
@@ -38,21 +38,6 @@ const mapFragment = (fragment, callback) => {
38
38
  });
39
39
  return Fragment.from(content);
40
40
  };
41
- function getDomRangeFromTextSelection(selection, editor) {
42
- const { from, to } = selection;
43
- const fromPos = editor.view.domAtPos(from);
44
- const endPos = editor.view.domAtPos(to);
45
- const domRange = document.createRange();
46
- domRange.setStart(fromPos.node, fromPos.offset);
47
- domRange.setEnd(endPos.node, endPos.offset);
48
- return domRange;
49
- }
50
- function compareTextSelections(a, b) {
51
- if (!a || !b) {
52
- return false;
53
- }
54
- return a.eq(b);
55
- }
56
41
 
57
- export { compareTextSelections, getDomRangeFromTextSelection, getMentionsFromNode, getRectFromCoords, mapFragment };
42
+ export { getMentionsFromNode, getRectFromCoords, mapFragment };
58
43
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { ClientRectObject } from \"@floating-ui/react-dom\";\nimport type { Editor, Range } from \"@tiptap/core\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\nimport { Fragment } from \"@tiptap/pm/model\";\nimport type { TextSelection } from \"@tiptap/pm/state\";\n\nimport { LIVEBLOCKS_MENTION_TYPE } from \"./types\";\n\nexport const getRectFromCoords = (coords: {\n top: number;\n left: number;\n right: number;\n bottom: number;\n}): ClientRectObject => {\n return {\n ...coords,\n x: coords.left,\n y: coords.top,\n width: coords.right - coords.left,\n height: coords.bottom - coords.top,\n };\n};\n\nexport const getMentionsFromNode = (\n node: ProseMirrorNode,\n range: Range\n): { notificationId: string; userId: string }[] => {\n const result: { notificationId: string; userId: string }[] = [];\n node.nodesBetween(range.from, range.to, (child) => {\n if (child.type.name === LIVEBLOCKS_MENTION_TYPE) {\n const mention = child.attrs as { id?: string; notificationId?: string };\n if (mention.id && mention.notificationId) {\n result.push({\n notificationId: mention.notificationId,\n userId: mention.id,\n });\n }\n }\n });\n return result;\n};\n\n// How to modify data in transformPasted, inspired by: https://discuss.prosemirror.net/t/modify-specific-node-on-copy-and-paste-in-clipboard/4901/4\nexport const mapFragment = (\n fragment: Fragment,\n callback: (\n node: ProseMirrorNode\n ) => ProseMirrorNode | ProseMirrorNode[] | Fragment | null\n): Fragment => {\n const content: ProseMirrorNode[] = [];\n fragment.forEach((node) => {\n if (node.content.childCount > 0) {\n content.push(\n node.type.create(node.attrs, mapFragment(node.content, callback))\n );\n return;\n }\n content.push(callback(node) as ProseMirrorNode);\n });\n\n return Fragment.from(content);\n};\n\nexport function getDomRangeFromTextSelection(\n selection: TextSelection,\n editor: Editor\n) {\n const { from, to } = selection;\n const fromPos = editor.view.domAtPos(from);\n const endPos = editor.view.domAtPos(to);\n\n const domRange = document.createRange();\n domRange.setStart(fromPos.node, fromPos.offset);\n domRange.setEnd(endPos.node, endPos.offset);\n\n return domRange;\n}\n\nexport function compareTextSelections(\n a: TextSelection | null | undefined,\n b: TextSelection | null | undefined\n) {\n if (!a || !b) {\n return false;\n }\n\n return a.eq(b);\n}\n"],"names":[],"mappings":";;;AAQa,MAAA,iBAAA,GAAoB,CAAC,MAKV,KAAA;AACtB,EAAO,OAAA;AAAA,IACL,GAAG,MAAA;AAAA,IACH,GAAG,MAAO,CAAA,IAAA;AAAA,IACV,GAAG,MAAO,CAAA,GAAA;AAAA,IACV,KAAA,EAAO,MAAO,CAAA,KAAA,GAAQ,MAAO,CAAA,IAAA;AAAA,IAC7B,MAAA,EAAQ,MAAO,CAAA,MAAA,GAAS,MAAO,CAAA,GAAA;AAAA,GACjC,CAAA;AACF,EAAA;AAEa,MAAA,mBAAA,GAAsB,CACjC,IAAA,E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A;AACrB,EAAA,MAAM,OAAU,GAAA,MAAA,CAAO,IAAK,CAAA,QAAA,CAAS,IAAI,CAAA,CAAA;AACzC,EAAA,MAAM,MAAS,GAAA,MAAA,CAAO,IAAK,CAAA,QAAA,CAAS,EAAE,CAAA,CAAA;AAEtC,EAAM,MAAA,QAAA,GAAW,SAAS,WAAY,EAAA,CAAA;AACtC,EAAA,QAAA,CAAS,QAAS,CAAA,OAAA,CAAQ,IAAM,EAAA,OAAA,CAAQ,MAAM,CAAA,CAAA;AAC9C,EAAA,QAAA,CAAS,MAAO,CAAA,MAAA,CAAO,IAAM,EAAA,MAAA,CAAO,MAAM,CAAA,CAAA;AAE1C,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAEgB,SAAA,qBAAA,CACd,GACA,CACA,EAAA;AACA,EAAI,IAAA,CAAC,CAAK,IAAA,CAAC,CAAG,EAAA;AACZ,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,CAAA,CAAE,GAAG,CAAC,CAAA,CAAA;AACf;;;;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { ClientRectObject } from \"@floating-ui/react-dom\";\nimport type { Range } from \"@tiptap/core\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\nimport { Fragment } from \"@tiptap/pm/model\";\n\nimport { LIVEBLOCKS_MENTION_TYPE } from \"./types\";\n\nexport const getRectFromCoords = (coords: {\n top: number;\n left: number;\n right: number;\n bottom: number;\n}): ClientRectObject => {\n return {\n ...coords,\n x: coords.left,\n y: coords.top,\n width: coords.right - coords.left,\n height: coords.bottom - coords.top,\n };\n};\n\nexport const getMentionsFromNode = (\n node: ProseMirrorNode,\n range: Range\n): { notificationId: string; userId: string }[] => {\n const result: { notificationId: string; userId: string }[] = [];\n node.nodesBetween(range.from, range.to, (child) => {\n if (child.type.name === LIVEBLOCKS_MENTION_TYPE) {\n const mention = child.attrs as { id?: string; notificationId?: string };\n if (mention.id && mention.notificationId) {\n result.push({\n notificationId: mention.notificationId,\n userId: mention.id,\n });\n }\n }\n });\n return result;\n};\n\n// How to modify data in transformPasted, inspired by: https://discuss.prosemirror.net/t/modify-specific-node-on-copy-and-paste-in-clipboard/4901/4\nexport const mapFragment = (\n fragment: Fragment,\n callback: (\n node: ProseMirrorNode\n ) => ProseMirrorNode | ProseMirrorNode[] | Fragment | null\n): Fragment => {\n const content: ProseMirrorNode[] = [];\n fragment.forEach((node) => {\n if (node.content.childCount > 0) {\n content.push(\n node.type.create(node.attrs, mapFragment(node.content, callback))\n );\n return;\n }\n content.push(callback(node) as ProseMirrorNode);\n });\n\n return Fragment.from(content);\n};\n"],"names":[],"mappings":";;;AAOa,MAAA,iBAAA,GAAoB,CAAC,MAKV,KAAA;AACtB,EAAO,OAAA;AAAA,IACL,GAAG,MAAA;AAAA,IACH,GAAG,MAAO,CAAA,IAAA;AAAA,IACV,GAAG,MAAO,CAAA,GAAA;AAAA,IACV,KAAA,EAAO,MAAO,CAAA,KAAA,GAAQ,MAAO,CAAA,IAAA;AAAA,IAC7B,MAAA,EAAQ,MAAO,CAAA,MAAA,GAAS,MAAO,CAAA,GAAA;AAAA,GACjC,CAAA;AACF,EAAA;AAEa,MAAA,mBAAA,GAAsB,CACjC,IAAA,EACA,KACiD,KAAA;AACjD,EAAA,MAAM,SAAuD,EAAC,CAAA;AAC9D,EAAA,IAAA,CAAK,aAAa,KAAM,CAAA,IAAA,EAAM,KAAM,CAAA,EAAA,EAAI,CAAC,KAAU,KAAA;AACjD,IAAI,IAAA,KAAA,CAAM,IAAK,CAAA,IAAA,KAAS,uBAAyB,EAAA;AAC/C,MAAA,MAAM,UAAU,KAAM,CAAA,KAAA,CAAA;AACtB,MAAI,IAAA,OAAA,CAAQ,EAAM,IAAA,OAAA,CAAQ,cAAgB,EAAA;AACxC,QAAA,MAAA,CAAO,IAAK,CAAA;AAAA,UACV,gBAAgB,OAAQ,CAAA,cAAA;AAAA,UACxB,QAAQ,OAA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