@blocknote/core 0.29.1 → 0.30.1

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 (182) hide show
  1. package/README.md +125 -0
  2. package/dist/blocknote.cjs +9 -9
  3. package/dist/blocknote.cjs.map +1 -1
  4. package/dist/blocknote.js +1501 -1359
  5. package/dist/blocknote.js.map +1 -1
  6. package/dist/comments.cjs.map +1 -1
  7. package/dist/comments.js.map +1 -1
  8. package/dist/locales.cjs +1 -1
  9. package/dist/locales.cjs.map +1 -1
  10. package/dist/locales.js +751 -9
  11. package/dist/locales.js.map +1 -1
  12. package/dist/style.css +1 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/webpack-stats.json +1 -1
  15. package/package.json +7 -8
  16. package/src/api/README.md +1 -1
  17. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -7
  18. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
  19. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -5
  20. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -5
  21. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
  22. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +12 -12
  23. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -20
  24. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +14 -14
  25. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +16 -16
  26. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +8 -8
  27. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -12
  28. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
  29. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +7 -7
  30. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -6
  31. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +10 -10
  32. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -2
  33. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -17
  34. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -42
  35. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +18 -18
  36. package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
  37. package/src/api/blockManipulation/insertContentAt.ts +1 -1
  38. package/src/api/blockManipulation/selections/selection.ts +11 -11
  39. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +7 -7
  40. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +6 -6
  41. package/src/api/blockManipulation/tables/tables.test.ts +106 -106
  42. package/src/api/blockManipulation/tables/tables.ts +35 -35
  43. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +2 -2
  44. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +9 -9
  45. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +3 -3
  46. package/src/api/clipboard/fromClipboard/pasteExtension.ts +21 -3
  47. package/src/api/clipboard/toClipboard/copyExtension.ts +22 -22
  48. package/src/api/exporters/html/externalHTMLExporter.ts +6 -6
  49. package/src/api/exporters/html/internalHTMLSerializer.ts +3 -3
  50. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +16 -16
  51. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +14 -14
  52. package/src/api/exporters/markdown/markdownExporter.ts +3 -3
  53. package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +3 -3
  54. package/src/api/getBlockInfoFromPos.ts +6 -6
  55. package/src/api/nodeConversions/blockToNode.ts +26 -26
  56. package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
  57. package/src/api/nodeConversions/nodeToBlock.ts +37 -33
  58. package/src/api/nodeUtil.test.ts +16 -16
  59. package/src/api/nodeUtil.ts +10 -10
  60. package/src/api/parsers/html/parseHTML.ts +1 -1
  61. package/src/api/parsers/html/util/nestedLists.ts +2 -2
  62. package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
  63. package/src/api/pmUtil.ts +4 -4
  64. package/src/api/positionMapping.test.ts +3 -3
  65. package/src/api/positionMapping.ts +5 -5
  66. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +9 -4
  67. package/src/blocks/CodeBlockContent/CodeBlockContent.ts +40 -26
  68. package/src/blocks/FileBlockContent/FileBlockContent.ts +7 -2
  69. package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
  70. package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +5 -5
  71. package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +2 -2
  72. package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +1 -1
  73. package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +15 -8
  74. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +1 -1
  75. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +1 -1
  76. package/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +2 -2
  77. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +9 -6
  78. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +14 -6
  79. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +13 -29
  80. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +24 -13
  81. package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
  82. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
  83. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +13 -30
  84. package/src/blocks/ListItemBlockContent/getListItemContent.ts +115 -0
  85. package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +1 -1
  86. package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +3 -3
  87. package/src/blocks/PageBreakBlockContent/schema.ts +2 -2
  88. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +9 -5
  89. package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +10 -5
  90. package/src/blocks/README.md +1 -1
  91. package/src/blocks/TableBlockContent/TableBlockContent.ts +76 -19
  92. package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
  93. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +14 -6
  94. package/src/blocks/defaultBlockHelpers.ts +24 -8
  95. package/src/blocks/defaultBlockTypeGuards.ts +16 -16
  96. package/src/blocks/defaultBlocks.ts +3 -3
  97. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +3 -3
  98. package/src/comments/threadstore/ThreadStore.ts +1 -1
  99. package/src/comments/threadstore/TipTapThreadStore.ts +10 -10
  100. package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +4 -4
  101. package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +2 -2
  102. package/src/comments/threadstore/yjs/YjsThreadStore.ts +14 -14
  103. package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +1 -1
  104. package/src/comments/threadstore/yjs/yjsHelpers.ts +6 -6
  105. package/src/editor/Block.css +10 -1
  106. package/src/editor/BlockNoteEditor.test.ts +3 -3
  107. package/src/editor/BlockNoteEditor.ts +110 -61
  108. package/src/editor/BlockNoteExtensions.ts +24 -15
  109. package/src/editor/BlockNoteSchema.ts +4 -4
  110. package/src/editor/BlockNoteTipTapEditor.ts +10 -10
  111. package/src/editor/README.md +1 -1
  112. package/src/editor/cursorPositionTypes.ts +1 -1
  113. package/src/editor/editor.css +15 -3
  114. package/src/editor/selectionTypes.ts +1 -1
  115. package/src/editor/transformPasted.ts +2 -2
  116. package/src/exporter/Exporter.ts +5 -5
  117. package/src/exporter/mapping.ts +7 -7
  118. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
  119. package/src/extensions/Collaboration/CursorPlugin.ts +152 -0
  120. package/src/extensions/Collaboration/SyncPlugin.ts +15 -0
  121. package/src/extensions/Collaboration/UndoPlugin.ts +14 -0
  122. package/src/extensions/Comments/CommentsPlugin.ts +9 -9
  123. package/src/extensions/Comments/userstore/UserStore.ts +2 -2
  124. package/src/extensions/FilePanel/FilePanelPlugin.ts +37 -28
  125. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +6 -8
  126. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +29 -26
  127. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -11
  128. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +4 -4
  129. package/src/extensions/Placeholder/PlaceholderPlugin.ts +10 -10
  130. package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +2 -2
  131. package/src/extensions/README.md +1 -1
  132. package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
  133. package/src/extensions/SideMenu/SideMenuPlugin.ts +31 -31
  134. package/src/extensions/SideMenu/dragging.ts +8 -8
  135. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +17 -17
  136. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
  137. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +12 -12
  138. package/src/extensions/TableHandles/TableHandlesPlugin.ts +54 -53
  139. package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
  140. package/src/extensions/UniqueID/UniqueID.ts +6 -6
  141. package/src/extensions/getDraggableBlockFromElement.ts +1 -1
  142. package/src/fonts/inter.css +18 -9
  143. package/src/i18n/locales/index.ts +2 -0
  144. package/src/i18n/locales/ru.ts +2 -2
  145. package/src/i18n/locales/sk.ts +355 -0
  146. package/src/i18n/locales/zh-tw.ts +390 -0
  147. package/src/locales.ts +1 -1
  148. package/src/pm-nodes/BlockContainer.ts +7 -6
  149. package/src/pm-nodes/BlockGroup.ts +1 -1
  150. package/src/pm-nodes/Doc.ts +4 -4
  151. package/src/schema/README.md +1 -1
  152. package/src/schema/blocks/createSpec.ts +15 -15
  153. package/src/schema/blocks/internal.ts +17 -18
  154. package/src/schema/blocks/types.ts +27 -26
  155. package/src/schema/inlineContent/createSpec.ts +16 -20
  156. package/src/schema/inlineContent/internal.ts +9 -9
  157. package/src/schema/inlineContent/types.ts +26 -26
  158. package/src/schema/propTypes.ts +8 -8
  159. package/src/schema/styles/createSpec.ts +2 -2
  160. package/src/schema/styles/internal.ts +7 -7
  161. package/src/schema/styles/types.ts +2 -2
  162. package/src/util/EventEmitter.ts +4 -4
  163. package/src/util/README.md +1 -1
  164. package/src/util/combineByGroup.ts +1 -1
  165. package/src/util/table.ts +33 -30
  166. package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -4
  167. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +8 -4
  168. package/types/src/blocks/ListItemBlockContent/getListItemContent.d.ts +28 -0
  169. package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +8 -4
  170. package/types/src/blocks/defaultBlockHelpers.d.ts +1 -0
  171. package/types/src/blocks/defaultBlocks.d.ts +16 -8
  172. package/types/src/editor/BlockNoteEditor.d.ts +21 -2
  173. package/types/src/extensions/Collaboration/CursorPlugin.d.ts +31 -0
  174. package/types/src/extensions/Collaboration/SyncPlugin.d.ts +7 -0
  175. package/types/src/extensions/Collaboration/UndoPlugin.d.ts +6 -0
  176. package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +1 -1
  177. package/types/src/i18n/locales/index.d.ts +2 -0
  178. package/types/src/i18n/locales/sk.d.ts +313 -0
  179. package/types/src/i18n/locales/zh-tw.d.ts +2 -0
  180. package/types/src/schema/blocks/types.d.ts +2 -1
  181. package/src/extensions/Collaboration/createCollaborationExtensions.ts +0 -147
  182. package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +0 -17
@@ -0,0 +1,313 @@
1
+ export declare const sk: {
2
+ slash_menu: {
3
+ heading: {
4
+ title: string;
5
+ subtext: string;
6
+ aliases: string[];
7
+ group: string;
8
+ };
9
+ heading_2: {
10
+ title: string;
11
+ subtext: string;
12
+ aliases: string[];
13
+ group: string;
14
+ };
15
+ heading_3: {
16
+ title: string;
17
+ subtext: string;
18
+ aliases: string[];
19
+ group: string;
20
+ };
21
+ quote: {
22
+ title: string;
23
+ subtext: string;
24
+ aliases: string[];
25
+ group: string;
26
+ };
27
+ numbered_list: {
28
+ title: string;
29
+ subtext: string;
30
+ aliases: string[];
31
+ group: string;
32
+ };
33
+ bullet_list: {
34
+ title: string;
35
+ subtext: string;
36
+ aliases: string[];
37
+ group: string;
38
+ };
39
+ check_list: {
40
+ title: string;
41
+ subtext: string;
42
+ aliases: string[];
43
+ group: string;
44
+ };
45
+ paragraph: {
46
+ title: string;
47
+ subtext: string;
48
+ aliases: string[];
49
+ group: string;
50
+ };
51
+ code_block: {
52
+ title: string;
53
+ subtext: string;
54
+ aliases: string[];
55
+ group: string;
56
+ };
57
+ page_break: {
58
+ title: string;
59
+ subtext: string;
60
+ aliases: string[];
61
+ group: string;
62
+ };
63
+ table: {
64
+ title: string;
65
+ subtext: string;
66
+ aliases: string[];
67
+ group: string;
68
+ };
69
+ image: {
70
+ title: string;
71
+ subtext: string;
72
+ aliases: string[];
73
+ group: string;
74
+ };
75
+ video: {
76
+ title: string;
77
+ subtext: string;
78
+ aliases: string[];
79
+ group: string;
80
+ };
81
+ audio: {
82
+ title: string;
83
+ subtext: string;
84
+ aliases: string[];
85
+ group: string;
86
+ };
87
+ file: {
88
+ title: string;
89
+ subtext: string;
90
+ aliases: string[];
91
+ group: string;
92
+ };
93
+ emoji: {
94
+ title: string;
95
+ subtext: string;
96
+ aliases: string[];
97
+ group: string;
98
+ };
99
+ };
100
+ placeholders: Record<string | "default" | "emptyDocument", string | undefined>;
101
+ file_blocks: {
102
+ image: {
103
+ add_button_text: string;
104
+ };
105
+ video: {
106
+ add_button_text: string;
107
+ };
108
+ audio: {
109
+ add_button_text: string;
110
+ };
111
+ file: {
112
+ add_button_text: string;
113
+ };
114
+ };
115
+ side_menu: {
116
+ add_block_label: string;
117
+ drag_handle_label: string;
118
+ };
119
+ drag_handle: {
120
+ delete_menuitem: string;
121
+ colors_menuitem: string;
122
+ header_row_menuitem: string;
123
+ header_column_menuitem: string;
124
+ };
125
+ table_handle: {
126
+ delete_column_menuitem: string;
127
+ delete_row_menuitem: string;
128
+ add_left_menuitem: string;
129
+ add_right_menuitem: string;
130
+ add_above_menuitem: string;
131
+ add_below_menuitem: string;
132
+ split_cell_menuitem: string;
133
+ merge_cells_menuitem: string;
134
+ background_color_menuitem: string;
135
+ };
136
+ suggestion_menu: {
137
+ no_items_title: string;
138
+ loading: string;
139
+ };
140
+ color_picker: {
141
+ text_title: string;
142
+ background_title: string;
143
+ colors: {
144
+ default: string;
145
+ gray: string;
146
+ brown: string;
147
+ red: string;
148
+ orange: string;
149
+ yellow: string;
150
+ green: string;
151
+ blue: string;
152
+ purple: string;
153
+ pink: string;
154
+ };
155
+ };
156
+ formatting_toolbar: {
157
+ bold: {
158
+ tooltip: string;
159
+ secondary_tooltip: string;
160
+ };
161
+ italic: {
162
+ tooltip: string;
163
+ secondary_tooltip: string;
164
+ };
165
+ underline: {
166
+ tooltip: string;
167
+ secondary_tooltip: string;
168
+ };
169
+ strike: {
170
+ tooltip: string;
171
+ secondary_tooltip: string;
172
+ };
173
+ code: {
174
+ tooltip: string;
175
+ secondary_tooltip: string;
176
+ };
177
+ colors: {
178
+ tooltip: string;
179
+ };
180
+ link: {
181
+ tooltip: string;
182
+ secondary_tooltip: string;
183
+ };
184
+ file_caption: {
185
+ tooltip: string;
186
+ input_placeholder: string;
187
+ };
188
+ file_replace: {
189
+ tooltip: {
190
+ image: string;
191
+ video: string;
192
+ audio: string;
193
+ file: string;
194
+ };
195
+ };
196
+ file_rename: {
197
+ tooltip: {
198
+ image: string;
199
+ video: string;
200
+ audio: string;
201
+ file: string;
202
+ };
203
+ input_placeholder: {
204
+ image: string;
205
+ video: string;
206
+ audio: string;
207
+ file: string;
208
+ };
209
+ };
210
+ file_download: {
211
+ tooltip: {
212
+ image: string;
213
+ video: string;
214
+ audio: string;
215
+ file: string;
216
+ };
217
+ };
218
+ file_delete: {
219
+ tooltip: {
220
+ image: string;
221
+ video: string;
222
+ audio: string;
223
+ file: string;
224
+ };
225
+ };
226
+ file_preview_toggle: {
227
+ tooltip: string;
228
+ };
229
+ nest: {
230
+ tooltip: string;
231
+ secondary_tooltip: string;
232
+ };
233
+ unnest: {
234
+ tooltip: string;
235
+ secondary_tooltip: string;
236
+ };
237
+ align_left: {
238
+ tooltip: string;
239
+ };
240
+ align_center: {
241
+ tooltip: string;
242
+ };
243
+ align_right: {
244
+ tooltip: string;
245
+ };
246
+ align_justify: {
247
+ tooltip: string;
248
+ };
249
+ table_cell_merge: {
250
+ tooltip: string;
251
+ };
252
+ comment: {
253
+ tooltip: string;
254
+ };
255
+ };
256
+ file_panel: {
257
+ upload: {
258
+ title: string;
259
+ file_placeholder: {
260
+ image: string;
261
+ video: string;
262
+ audio: string;
263
+ file: string;
264
+ };
265
+ upload_error: string;
266
+ };
267
+ embed: {
268
+ title: string;
269
+ embed_button: {
270
+ image: string;
271
+ video: string;
272
+ audio: string;
273
+ file: string;
274
+ };
275
+ url_placeholder: string;
276
+ };
277
+ };
278
+ link_toolbar: {
279
+ delete: {
280
+ tooltip: string;
281
+ };
282
+ edit: {
283
+ text: string;
284
+ tooltip: string;
285
+ };
286
+ open: {
287
+ tooltip: string;
288
+ };
289
+ form: {
290
+ title_placeholder: string;
291
+ url_placeholder: string;
292
+ };
293
+ };
294
+ comments: {
295
+ actions: {
296
+ add_reaction: string;
297
+ resolve: string;
298
+ edit_comment: string;
299
+ delete_comment: string;
300
+ more_actions: string;
301
+ };
302
+ reactions: {
303
+ reacted_by: string;
304
+ };
305
+ sidebar: {
306
+ marked_as_resolved: string;
307
+ more_replies: (count: number) => string;
308
+ };
309
+ };
310
+ generic: {
311
+ ctrl_shortcut: string;
312
+ };
313
+ };
@@ -0,0 +1,2 @@
1
+ import type { Dictionary } from "../dictionary.js";
2
+ export declare const zhTW: Dictionary;
@@ -24,7 +24,8 @@ export type FileBlockConfig = {
24
24
  default: boolean;
25
25
  };
26
26
  previewWidth?: {
27
- default: number;
27
+ default: undefined;
28
+ type: "number";
28
29
  };
29
30
  };
30
31
  content: "none";
@@ -1,147 +0,0 @@
1
- import Collaboration from "@tiptap/extension-collaboration";
2
- import CollaborationCursor from "@tiptap/extension-collaboration-cursor";
3
- import { Awareness } from "y-protocols/awareness";
4
- import * as Y from "yjs";
5
-
6
- export const createCollaborationExtensions = (collaboration: {
7
- fragment: Y.XmlFragment;
8
- user: {
9
- name: string;
10
- color: string;
11
- [key: string]: string;
12
- };
13
- provider: any;
14
- renderCursor?: (user: any) => HTMLElement;
15
- showCursorLabels?: "always" | "activity";
16
- }) => {
17
- const tiptapExtensions = [];
18
-
19
- tiptapExtensions.push(
20
- Collaboration.configure({
21
- fragment: collaboration.fragment,
22
- })
23
- );
24
-
25
- const awareness = collaboration.provider?.awareness as Awareness | undefined;
26
-
27
- if (awareness) {
28
- const cursors = new Map<
29
- number,
30
- { element: HTMLElement; hideTimeout: NodeJS.Timeout | undefined }
31
- >();
32
-
33
- if (collaboration.showCursorLabels !== "always") {
34
- awareness.on(
35
- "change",
36
- ({
37
- updated,
38
- }: {
39
- added: Array<number>;
40
- updated: Array<number>;
41
- removed: Array<number>;
42
- }) => {
43
- for (const clientID of updated) {
44
- const cursor = cursors.get(clientID);
45
-
46
- if (cursor) {
47
- cursor.element.setAttribute("data-active", "");
48
-
49
- if (cursor.hideTimeout) {
50
- clearTimeout(cursor.hideTimeout);
51
- }
52
-
53
- cursors.set(clientID, {
54
- element: cursor.element,
55
- hideTimeout: setTimeout(() => {
56
- cursor.element.removeAttribute("data-active");
57
- }, 2000),
58
- });
59
- }
60
- }
61
- }
62
- );
63
- }
64
-
65
- const renderCursor = (user: { name: string; color: string }) => {
66
- const cursorElement = document.createElement("span");
67
-
68
- cursorElement.classList.add("bn-collaboration-cursor__base");
69
-
70
- const caretElement = document.createElement("span");
71
- caretElement.setAttribute("contentedEditable", "false");
72
- caretElement.classList.add("bn-collaboration-cursor__caret");
73
- caretElement.setAttribute("style", `background-color: ${user.color}`);
74
-
75
- const labelElement = document.createElement("span");
76
-
77
- labelElement.classList.add("bn-collaboration-cursor__label");
78
- labelElement.setAttribute("style", `background-color: ${user.color}`);
79
- labelElement.insertBefore(document.createTextNode(user.name), null);
80
-
81
- caretElement.insertBefore(labelElement, null);
82
-
83
- cursorElement.insertBefore(document.createTextNode("\u2060"), null); // Non-breaking space
84
- cursorElement.insertBefore(caretElement, null);
85
- cursorElement.insertBefore(document.createTextNode("\u2060"), null); // Non-breaking space
86
-
87
- return cursorElement;
88
- };
89
-
90
- const render = (
91
- user: { color: string; name: string },
92
- clientID: number
93
- ) => {
94
- let cursorData = cursors.get(clientID);
95
-
96
- if (!cursorData) {
97
- const cursorElement =
98
- collaboration?.renderCursor?.(user) || renderCursor(user);
99
-
100
- if (collaboration?.showCursorLabels !== "always") {
101
- cursorElement.addEventListener("mouseenter", () => {
102
- const cursor = cursors.get(clientID)!;
103
- cursor.element.setAttribute("data-active", "");
104
-
105
- if (cursor.hideTimeout) {
106
- clearTimeout(cursor.hideTimeout);
107
- cursors.set(clientID, {
108
- element: cursor.element,
109
- hideTimeout: undefined,
110
- });
111
- }
112
- });
113
-
114
- cursorElement.addEventListener("mouseleave", () => {
115
- const cursor = cursors.get(clientID)!;
116
-
117
- cursors.set(clientID, {
118
- element: cursor.element,
119
- hideTimeout: setTimeout(() => {
120
- cursor.element.removeAttribute("data-active");
121
- }, 2000),
122
- });
123
- });
124
- }
125
-
126
- cursorData = {
127
- element: cursorElement,
128
- hideTimeout: undefined,
129
- };
130
-
131
- cursors.set(clientID, cursorData);
132
- }
133
-
134
- return cursorData.element;
135
- };
136
-
137
- tiptapExtensions.push(
138
- CollaborationCursor.configure({
139
- user: collaboration.user,
140
- render: render as any, // tiptap type not compatible with latest y-prosemirror
141
- provider: collaboration.provider,
142
- })
143
- );
144
- }
145
-
146
- return tiptapExtensions;
147
- };
@@ -1,17 +0,0 @@
1
- import * as Y from "yjs";
2
- export declare const createCollaborationExtensions: (collaboration: {
3
- fragment: Y.XmlFragment;
4
- user: {
5
- name: string;
6
- color: string;
7
- [key: string]: string;
8
- };
9
- provider: any;
10
- renderCursor?: (user: any) => HTMLElement;
11
- showCursorLabels?: "always" | "activity";
12
- }) => (import("@tiptap/core").Extension<import("@tiptap/extension-collaboration").CollaborationOptions, import("@tiptap/extension-collaboration").CollaborationStorage> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration-cursor").CollaborationCursorOptions, {
13
- users: {
14
- clientId: number;
15
- [key: string]: any;
16
- }[];
17
- }>)[];