@datalayer/lexical-loro 0.2.5 → 1.0.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 (399) hide show
  1. package/package.json +1 -1
  2. package/lib/App.d.ts +0 -2
  3. package/lib/App.js +0 -141
  4. package/lib/Editor.d.ts +0 -2
  5. package/lib/Editor.js +0 -115
  6. package/lib/Settings.d.ts +0 -2
  7. package/lib/Settings.js +0 -57
  8. package/lib/appSettings.d.ts +0 -36
  9. package/lib/appSettings.js +0 -48
  10. package/lib/collab/loro/Bindings.d.ts +0 -41
  11. package/lib/collab/loro/Bindings.js +0 -99
  12. package/lib/collab/loro/Debug.d.ts +0 -33
  13. package/lib/collab/loro/Debug.js +0 -452
  14. package/lib/collab/loro/LexicalCollaborationContext.d.ts +0 -19
  15. package/lib/collab/loro/LexicalCollaborationContext.js +0 -52
  16. package/lib/collab/loro/LexicalCollaborationPlugin.d.ts +0 -24
  17. package/lib/collab/loro/LexicalCollaborationPlugin.js +0 -83
  18. package/lib/collab/loro/State.d.ts +0 -53
  19. package/lib/collab/loro/State.js +0 -94
  20. package/lib/collab/loro/components/LoroCollaborationUI.d.ts +0 -13
  21. package/lib/collab/loro/components/LoroCollaborationUI.js +0 -9
  22. package/lib/collab/loro/components/LoroCollaborators.d.ts +0 -8
  23. package/lib/collab/loro/components/LoroCollaborators.js +0 -102
  24. package/lib/collab/loro/components/index.d.ts +0 -2
  25. package/lib/collab/loro/components/index.js +0 -6
  26. package/lib/collab/loro/index.d.ts +0 -6
  27. package/lib/collab/loro/index.js +0 -10
  28. package/lib/collab/loro/integrators/BaseIntegrator.d.ts +0 -14
  29. package/lib/collab/loro/integrators/BaseIntegrator.js +0 -5
  30. package/lib/collab/loro/integrators/CounterIntegrator.d.ts +0 -23
  31. package/lib/collab/loro/integrators/CounterIntegrator.js +0 -44
  32. package/lib/collab/loro/integrators/ListIntegrator.d.ts +0 -23
  33. package/lib/collab/loro/integrators/ListIntegrator.js +0 -53
  34. package/lib/collab/loro/integrators/MapIntegrator.d.ts +0 -24
  35. package/lib/collab/loro/integrators/MapIntegrator.js +0 -235
  36. package/lib/collab/loro/integrators/TextIntegrator.d.ts +0 -25
  37. package/lib/collab/loro/integrators/TextIntegrator.js +0 -55
  38. package/lib/collab/loro/integrators/TreeIntegrator.d.ts +0 -36
  39. package/lib/collab/loro/integrators/TreeIntegrator.js +0 -251
  40. package/lib/collab/loro/nodes/NodeFactory.d.ts +0 -15
  41. package/lib/collab/loro/nodes/NodeFactory.js +0 -101
  42. package/lib/collab/loro/nodes/NodesMapper.d.ts +0 -120
  43. package/lib/collab/loro/nodes/NodesMapper.js +0 -277
  44. package/lib/collab/loro/propagators/DecoratorNodePropagator.d.ts +0 -60
  45. package/lib/collab/loro/propagators/DecoratorNodePropagator.js +0 -306
  46. package/lib/collab/loro/propagators/ElementNodePropagator.d.ts +0 -62
  47. package/lib/collab/loro/propagators/ElementNodePropagator.js +0 -326
  48. package/lib/collab/loro/propagators/LineBreakNodePropagator.d.ts +0 -57
  49. package/lib/collab/loro/propagators/LineBreakNodePropagator.js +0 -200
  50. package/lib/collab/loro/propagators/RootNodePropagator.d.ts +0 -55
  51. package/lib/collab/loro/propagators/RootNodePropagator.js +0 -174
  52. package/lib/collab/loro/propagators/TextNodePropagator.d.ts +0 -60
  53. package/lib/collab/loro/propagators/TextNodePropagator.js +0 -440
  54. package/lib/collab/loro/propagators/index.d.ts +0 -49
  55. package/lib/collab/loro/propagators/index.js +0 -30
  56. package/lib/collab/loro/provider/websocket.d.ts +0 -116
  57. package/lib/collab/loro/provider/websocket.js +0 -911
  58. package/lib/collab/loro/servers/index.d.ts +0 -0
  59. package/lib/collab/loro/servers/index.js +0 -4
  60. package/lib/collab/loro/servers/ws/callback.d.ts +0 -5
  61. package/lib/collab/loro/servers/ws/callback.js +0 -89
  62. package/lib/collab/loro/servers/ws/server.d.ts +0 -2
  63. package/lib/collab/loro/servers/ws/server.js +0 -29
  64. package/lib/collab/loro/servers/ws/utils.d.ts +0 -40
  65. package/lib/collab/loro/servers/ws/utils.js +0 -517
  66. package/lib/collab/loro/sync/SyncCursors.d.ts +0 -32
  67. package/lib/collab/loro/sync/SyncCursors.js +0 -475
  68. package/lib/collab/loro/sync/SyncLexicalToLoro.d.ts +0 -4
  69. package/lib/collab/loro/sync/SyncLexicalToLoro.js +0 -113
  70. package/lib/collab/loro/sync/SyncLoroToLexical.d.ts +0 -5
  71. package/lib/collab/loro/sync/SyncLoroToLexical.js +0 -100
  72. package/lib/collab/loro/types/LexicalNodeData.d.ts +0 -32
  73. package/lib/collab/loro/types/LexicalNodeData.js +0 -75
  74. package/lib/collab/loro/useCollaboration.d.ts +0 -12
  75. package/lib/collab/loro/useCollaboration.js +0 -260
  76. package/lib/collab/loro/utils/InitialContent.d.ts +0 -64
  77. package/lib/collab/loro/utils/InitialContent.js +0 -113
  78. package/lib/collab/loro/utils/LexicalToLoro.d.ts +0 -18
  79. package/lib/collab/loro/utils/LexicalToLoro.js +0 -100
  80. package/lib/collab/loro/utils/Utils.d.ts +0 -44
  81. package/lib/collab/loro/utils/Utils.js +0 -157
  82. package/lib/collab/loro/wsProvider.d.ts +0 -8
  83. package/lib/collab/loro/wsProvider.js +0 -35
  84. package/lib/collab/utils/invariant.d.ts +0 -1
  85. package/lib/collab/utils/invariant.js +0 -15
  86. package/lib/collab/utils/simpleDiffWithCursor.d.ts +0 -5
  87. package/lib/collab/utils/simpleDiffWithCursor.js +0 -35
  88. package/lib/collab/yjs/Bindings.d.ts +0 -23
  89. package/lib/collab/yjs/Bindings.js +0 -26
  90. package/lib/collab/yjs/Debug.d.ts +0 -23
  91. package/lib/collab/yjs/Debug.js +0 -213
  92. package/lib/collab/yjs/LexicalCollaborationContext.d.ts +0 -10
  93. package/lib/collab/yjs/LexicalCollaborationContext.js +0 -37
  94. package/lib/collab/yjs/LexicalCollaborationPlugin.d.ts +0 -21
  95. package/lib/collab/yjs/LexicalCollaborationPlugin.js +0 -63
  96. package/lib/collab/yjs/State.d.ts +0 -51
  97. package/lib/collab/yjs/State.js +0 -35
  98. package/lib/collab/yjs/nodes/AnyCollabNode.d.ts +0 -5
  99. package/lib/collab/yjs/nodes/AnyCollabNode.js +0 -1
  100. package/lib/collab/yjs/nodes/CollabDecoratorNode.d.ts +0 -22
  101. package/lib/collab/yjs/nodes/CollabDecoratorNode.js +0 -64
  102. package/lib/collab/yjs/nodes/CollabElementNode.d.ts +0 -40
  103. package/lib/collab/yjs/nodes/CollabElementNode.js +0 -462
  104. package/lib/collab/yjs/nodes/CollabLineBreakNode.d.ts +0 -19
  105. package/lib/collab/yjs/nodes/CollabLineBreakNode.js +0 -44
  106. package/lib/collab/yjs/nodes/CollabTextNode.d.ts +0 -25
  107. package/lib/collab/yjs/nodes/CollabTextNode.js +0 -103
  108. package/lib/collab/yjs/provider/websocket.d.ts +0 -88
  109. package/lib/collab/yjs/provider/websocket.js +0 -415
  110. package/lib/collab/yjs/servers/index.d.ts +0 -0
  111. package/lib/collab/yjs/servers/index.js +0 -0
  112. package/lib/collab/yjs/servers/ws/callback.d.ts +0 -5
  113. package/lib/collab/yjs/servers/ws/callback.js +0 -72
  114. package/lib/collab/yjs/servers/ws/server.d.ts +0 -2
  115. package/lib/collab/yjs/servers/ws/server.js +0 -25
  116. package/lib/collab/yjs/servers/ws/utils.d.ts +0 -49
  117. package/lib/collab/yjs/servers/ws/utils.js +0 -284
  118. package/lib/collab/yjs/sync/SyncCursors.d.ts +0 -39
  119. package/lib/collab/yjs/sync/SyncCursors.js +0 -351
  120. package/lib/collab/yjs/sync/SyncEditorStates.d.ts +0 -10
  121. package/lib/collab/yjs/sync/SyncEditorStates.js +0 -200
  122. package/lib/collab/yjs/useCollaboration.d.ts +0 -12
  123. package/lib/collab/yjs/useCollaboration.js +0 -255
  124. package/lib/collab/yjs/utils/Utils.d.ts +0 -25
  125. package/lib/collab/yjs/utils/Utils.js +0 -402
  126. package/lib/collab/yjs/wsProvider.d.ts +0 -3
  127. package/lib/collab/yjs/wsProvider.js +0 -21
  128. package/lib/commenting/index.d.ts +0 -41
  129. package/lib/commenting/index.js +0 -328
  130. package/lib/context/FlashMessageContext.d.ts +0 -7
  131. package/lib/context/FlashMessageContext.js +0 -24
  132. package/lib/context/SettingsContext.d.ts +0 -12
  133. package/lib/context/SettingsContext.js +0 -38
  134. package/lib/context/SharedHistoryContext.d.ts +0 -11
  135. package/lib/context/SharedHistoryContext.js +0 -11
  136. package/lib/context/ToolbarContext.d.ts +0 -65
  137. package/lib/context/ToolbarContext.js +0 -84
  138. package/lib/demo.d.ts +0 -12
  139. package/lib/demo.js +0 -45
  140. package/lib/hooks/useFlashMessage.d.ts +0 -2
  141. package/lib/hooks/useFlashMessage.js +0 -8
  142. package/lib/hooks/useModal.d.ts +0 -5
  143. package/lib/hooks/useModal.js +0 -26
  144. package/lib/hooks/useReport.d.ts +0 -1
  145. package/lib/hooks/useReport.js +0 -50
  146. package/lib/index.d.ts +0 -1
  147. package/lib/index.js +0 -5
  148. package/lib/nodes/AutocompleteNode.d.ts +0 -27
  149. package/lib/nodes/AutocompleteNode.js +0 -60
  150. package/lib/nodes/CounterComponent.d.ts +0 -6
  151. package/lib/nodes/CounterComponent.js +0 -137
  152. package/lib/nodes/CounterNode.d.ts +0 -23
  153. package/lib/nodes/CounterNode.js +0 -47
  154. package/lib/nodes/DateTimeNode/DateTimeComponent.d.ts +0 -8
  155. package/lib/nodes/DateTimeNode/DateTimeComponent.js +0 -119
  156. package/lib/nodes/DateTimeNode/DateTimeNode.d.ts +0 -27
  157. package/lib/nodes/DateTimeNode/DateTimeNode.js +0 -82
  158. package/lib/nodes/EmojiNode.d.ts +0 -18
  159. package/lib/nodes/EmojiNode.js +0 -54
  160. package/lib/nodes/EquationComponent.d.ts +0 -9
  161. package/lib/nodes/EquationComponent.js +0 -75
  162. package/lib/nodes/EquationNode.d.ts +0 -26
  163. package/lib/nodes/EquationNode.js +0 -109
  164. package/lib/nodes/ExcalidrawNode/ExcalidrawComponent.d.ts +0 -8
  165. package/lib/nodes/ExcalidrawNode/ExcalidrawComponent.js +0 -110
  166. package/lib/nodes/ExcalidrawNode/ExcalidrawImage.d.ts +0 -50
  167. package/lib/nodes/ExcalidrawNode/ExcalidrawImage.js +0 -55
  168. package/lib/nodes/ExcalidrawNode/index.d.ts +0 -32
  169. package/lib/nodes/ExcalidrawNode/index.js +0 -117
  170. package/lib/nodes/FigmaNode.d.ts +0 -20
  171. package/lib/nodes/FigmaNode.js +0 -52
  172. package/lib/nodes/ImageComponent.d.ts +0 -16
  173. package/lib/nodes/ImageComponent.js +0 -272
  174. package/lib/nodes/ImageNode.d.ts +0 -50
  175. package/lib/nodes/ImageNode.js +0 -151
  176. package/lib/nodes/InlineImageNode/InlineImageComponent.d.ts +0 -26
  177. package/lib/nodes/InlineImageNode/InlineImageComponent.js +0 -161
  178. package/lib/nodes/InlineImageNode/InlineImageNode.d.ts +0 -59
  179. package/lib/nodes/InlineImageNode/InlineImageNode.js +0 -162
  180. package/lib/nodes/KeywordNode.d.ts +0 -14
  181. package/lib/nodes/KeywordNode.js +0 -37
  182. package/lib/nodes/LayoutContainerNode.d.ts +0 -24
  183. package/lib/nodes/LayoutContainerNode.js +0 -95
  184. package/lib/nodes/LayoutItemNode.d.ts +0 -16
  185. package/lib/nodes/LayoutItemNode.js +0 -69
  186. package/lib/nodes/MentionNode.d.ts +0 -20
  187. package/lib/nodes/MentionNode.js +0 -85
  188. package/lib/nodes/PageBreakNode/index.d.ts +0 -17
  189. package/lib/nodes/PageBreakNode/index.js +0 -83
  190. package/lib/nodes/PlaygroundNodes.d.ts +0 -3
  191. package/lib/nodes/PlaygroundNodes.js +0 -75
  192. package/lib/nodes/PollComponent.d.ts +0 -9
  193. package/lib/nodes/PollComponent.js +0 -85
  194. package/lib/nodes/PollNode.d.ts +0 -43
  195. package/lib/nodes/PollNode.js +0 -153
  196. package/lib/nodes/SpecialTextNode.d.ts +0 -24
  197. package/lib/nodes/SpecialTextNode.js +0 -54
  198. package/lib/nodes/StickyComponent.d.ts +0 -10
  199. package/lib/nodes/StickyComponent.js +0 -162
  200. package/lib/nodes/StickyNode.d.ts +0 -31
  201. package/lib/nodes/StickyNode.js +0 -76
  202. package/lib/nodes/TweetNode.d.ts +0 -21
  203. package/lib/nodes/TweetNode.js +0 -119
  204. package/lib/nodes/YouTubeNode.d.ts +0 -22
  205. package/lib/nodes/YouTubeNode.js +0 -84
  206. package/lib/plugins/ActionsPlugin/index.d.ts +0 -5
  207. package/lib/plugins/ActionsPlugin/index.js +0 -168
  208. package/lib/plugins/AutoEmbedPlugin/index.d.ts +0 -19
  209. package/lib/plugins/AutoEmbedPlugin/index.js +0 -158
  210. package/lib/plugins/AutoLinkPlugin/index.d.ts +0 -2
  211. package/lib/plugins/AutoLinkPlugin/index.js +0 -15
  212. package/lib/plugins/AutocompletePlugin/index.d.ts +0 -10
  213. package/lib/plugins/AutocompletePlugin/index.js +0 -2477
  214. package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +0 -7
  215. package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +0 -46
  216. package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +0 -17
  217. package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +0 -115
  218. package/lib/plugins/CodeActionMenuPlugin/index.d.ts +0 -5
  219. package/lib/plugins/CodeActionMenuPlugin/index.js +0 -104
  220. package/lib/plugins/CodeActionMenuPlugin/utils.d.ts +0 -1
  221. package/lib/plugins/CodeActionMenuPlugin/utils.js +0 -22
  222. package/lib/plugins/CodeHighlightPrismPlugin/index.d.ts +0 -2
  223. package/lib/plugins/CodeHighlightPrismPlugin/index.js +0 -14
  224. package/lib/plugins/CodeHighlightShikiPlugin/index.d.ts +0 -2
  225. package/lib/plugins/CodeHighlightShikiPlugin/index.js +0 -14
  226. package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.d.ts +0 -25
  227. package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.js +0 -135
  228. package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.d.ts +0 -16
  229. package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.js +0 -83
  230. package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.d.ts +0 -16
  231. package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.js +0 -85
  232. package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.d.ts +0 -2
  233. package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.js +0 -12
  234. package/lib/plugins/CollapsiblePlugin/index.d.ts +0 -3
  235. package/lib/plugins/CollapsiblePlugin/index.js +0 -132
  236. package/lib/plugins/CommentPlugin/index.d.ts +0 -9
  237. package/lib/plugins/CommentPlugin/index.js +0 -460
  238. package/lib/plugins/ComponentPickerPlugin/index.d.ts +0 -2
  239. package/lib/plugins/ComponentPickerPlugin/index.js +0 -276
  240. package/lib/plugins/ContextMenuPlugin/index.d.ts +0 -2
  241. package/lib/plugins/ContextMenuPlugin/index.js +0 -112
  242. package/lib/plugins/CounterPlugin/index.d.ts +0 -3
  243. package/lib/plugins/CounterPlugin/index.js +0 -24
  244. package/lib/plugins/DateTimePlugin/index.d.ts +0 -8
  245. package/lib/plugins/DateTimePlugin/index.js +0 -28
  246. package/lib/plugins/DebugPlugin/index.d.ts +0 -3
  247. package/lib/plugins/DebugPlugin/index.js +0 -219
  248. package/lib/plugins/DocsPlugin/index.d.ts +0 -2
  249. package/lib/plugins/DocsPlugin/index.js +0 -4
  250. package/lib/plugins/DragDropPastePlugin/index.d.ts +0 -1
  251. package/lib/plugins/DragDropPastePlugin/index.js +0 -37
  252. package/lib/plugins/DraggableBlockPlugin/index.d.ts +0 -12
  253. package/lib/plugins/DraggableBlockPlugin/index.js +0 -36
  254. package/lib/plugins/EmojiPickerPlugin/index.d.ts +0 -1
  255. package/lib/plugins/EmojiPickerPlugin/index.js +0 -84
  256. package/lib/plugins/EmojisPlugin/index.d.ts +0 -2
  257. package/lib/plugins/EmojisPlugin/index.js +0 -56
  258. package/lib/plugins/EquationsPlugin/index.d.ts +0 -14
  259. package/lib/plugins/EquationsPlugin/index.js +0 -34
  260. package/lib/plugins/ExcalidrawPlugin/index.d.ts +0 -5
  261. package/lib/plugins/ExcalidrawPlugin/index.js +0 -44
  262. package/lib/plugins/FigmaPlugin/index.d.ts +0 -4
  263. package/lib/plugins/FigmaPlugin/index.js +0 -24
  264. package/lib/plugins/FloatingLinkEditorPlugin/index.d.ts +0 -15
  265. package/lib/plugins/FloatingLinkEditorPlugin/index.js +0 -280
  266. package/lib/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +0 -7
  267. package/lib/plugins/FloatingTextFormatToolbarPlugin/index.js +0 -219
  268. package/lib/plugins/ImagesPlugin/index.d.ts +0 -24
  269. package/lib/plugins/ImagesPlugin/index.js +0 -195
  270. package/lib/plugins/InlineImagePlugin/index.d.ts +0 -17
  271. package/lib/plugins/InlineImagePlugin/index.js +0 -180
  272. package/lib/plugins/KeywordsPlugin/index.d.ts +0 -2
  273. package/lib/plugins/KeywordsPlugin/index.js +0 -35
  274. package/lib/plugins/LayoutPlugin/InsertLayoutDialog.d.ts +0 -6
  275. package/lib/plugins/LayoutPlugin/InsertLayoutDialog.js +0 -21
  276. package/lib/plugins/LayoutPlugin/LayoutPlugin.d.ts +0 -7
  277. package/lib/plugins/LayoutPlugin/LayoutPlugin.js +0 -135
  278. package/lib/plugins/LinkPlugin/index.d.ts +0 -6
  279. package/lib/plugins/LinkPlugin/index.js +0 -11
  280. package/lib/plugins/MarkdownShortcutPlugin/index.d.ts +0 -2
  281. package/lib/plugins/MarkdownShortcutPlugin/index.js +0 -6
  282. package/lib/plugins/MarkdownTransformers/index.d.ts +0 -8
  283. package/lib/plugins/MarkdownTransformers/index.js +0 -238
  284. package/lib/plugins/MaxLengthPlugin/index.d.ts +0 -3
  285. package/lib/plugins/MaxLengthPlugin/index.js +0 -41
  286. package/lib/plugins/MentionsPlugin/index.d.ts +0 -2
  287. package/lib/plugins/MentionsPlugin/index.js +0 -564
  288. package/lib/plugins/PageBreakPlugin/index.d.ts +0 -4
  289. package/lib/plugins/PageBreakPlugin/index.js +0 -31
  290. package/lib/plugins/PasteLogPlugin/index.d.ts +0 -2
  291. package/lib/plugins/PasteLogPlugin/index.js +0 -27
  292. package/lib/plugins/PollPlugin/index.d.ts +0 -8
  293. package/lib/plugins/PollPlugin/index.js +0 -38
  294. package/lib/plugins/ShortcutsPlugin/index.d.ts +0 -6
  295. package/lib/plugins/ShortcutsPlugin/index.js +0 -116
  296. package/lib/plugins/ShortcutsPlugin/shortcuts.d.ts +0 -59
  297. package/lib/plugins/ShortcutsPlugin/shortcuts.js +0 -173
  298. package/lib/plugins/SpecialTextPlugin/index.d.ts +0 -2
  299. package/lib/plugins/SpecialTextPlugin/index.js +0 -50
  300. package/lib/plugins/SpeechToTextPlugin/index.d.ts +0 -5
  301. package/lib/plugins/SpeechToTextPlugin/index.js +0 -86
  302. package/lib/plugins/StickyPlugin/index.d.ts +0 -2
  303. package/lib/plugins/StickyPlugin/index.js +0 -16
  304. package/lib/plugins/TabFocusPlugin/index.d.ts +0 -1
  305. package/lib/plugins/TabFocusPlugin/index.js +0 -38
  306. package/lib/plugins/TableActionMenuPlugin/index.d.ts +0 -5
  307. package/lib/plugins/TableActionMenuPlugin/index.js +0 -492
  308. package/lib/plugins/TableCellResizer/index.d.ts +0 -3
  309. package/lib/plugins/TableCellResizer/index.js +0 -297
  310. package/lib/plugins/TableHoverActionsPlugin/index.d.ts +0 -4
  311. package/lib/plugins/TableHoverActionsPlugin/index.js +0 -188
  312. package/lib/plugins/TableOfContentsPlugin/index.d.ts +0 -2
  313. package/lib/plugins/TableOfContentsPlugin/index.js +0 -116
  314. package/lib/plugins/TablePlugin.d.ts +0 -31
  315. package/lib/plugins/TablePlugin.js +0 -63
  316. package/lib/plugins/TestRecorderPlugin/index.d.ts +0 -3
  317. package/lib/plugins/TestRecorderPlugin/index.js +0 -346
  318. package/lib/plugins/ToolbarPlugin/fontSize.d.ts +0 -9
  319. package/lib/plugins/ToolbarPlugin/fontSize.js +0 -84
  320. package/lib/plugins/ToolbarPlugin/index.d.ts +0 -9
  321. package/lib/plugins/ToolbarPlugin/index.js +0 -500
  322. package/lib/plugins/ToolbarPlugin/utils.d.ts +0 -26
  323. package/lib/plugins/ToolbarPlugin/utils.js +0 -247
  324. package/lib/plugins/TreeViewPlugin/index.d.ts +0 -2
  325. package/lib/plugins/TreeViewPlugin/index.js +0 -7
  326. package/lib/plugins/TwitterPlugin/index.d.ts +0 -4
  327. package/lib/plugins/TwitterPlugin/index.js +0 -24
  328. package/lib/plugins/TypingPerfPlugin/index.d.ts +0 -2
  329. package/lib/plugins/TypingPerfPlugin/index.js +0 -97
  330. package/lib/plugins/YouTubePlugin/index.d.ts +0 -4
  331. package/lib/plugins/YouTubePlugin/index.js +0 -24
  332. package/lib/server/validation.d.ts +0 -1
  333. package/lib/server/validation.js +0 -115
  334. package/lib/setupEnv.d.ts +0 -2
  335. package/lib/setupEnv.js +0 -29
  336. package/lib/themes/CommentEditorTheme.d.ts +0 -4
  337. package/lib/themes/CommentEditorTheme.js +0 -11
  338. package/lib/themes/PlaygroundEditorTheme.d.ts +0 -4
  339. package/lib/themes/PlaygroundEditorTheme.js +0 -124
  340. package/lib/themes/StickyEditorTheme.d.ts +0 -4
  341. package/lib/themes/StickyEditorTheme.js +0 -11
  342. package/lib/tyes.dt.d.ts +0 -12
  343. package/lib/tyes.dt.js +0 -4
  344. package/lib/ui/Button.d.ts +0 -12
  345. package/lib/ui/Button.js +0 -6
  346. package/lib/ui/ColorPicker.d.ts +0 -14
  347. package/lib/ui/ColorPicker.js +0 -219
  348. package/lib/ui/ContentEditable.d.ts +0 -9
  349. package/lib/ui/ContentEditable.js +0 -6
  350. package/lib/ui/Dialog.d.ts +0 -10
  351. package/lib/ui/Dialog.js +0 -8
  352. package/lib/ui/DropDown.d.ts +0 -18
  353. package/lib/ui/DropDown.js +0 -133
  354. package/lib/ui/DropdownColorPicker.d.ts +0 -13
  355. package/lib/ui/DropdownColorPicker.js +0 -6
  356. package/lib/ui/EquationEditor.d.ts +0 -8
  357. package/lib/ui/EquationEditor.js +0 -11
  358. package/lib/ui/ExcalidrawModal.d.ts +0 -42
  359. package/lib/ui/ExcalidrawModal.js +0 -103
  360. package/lib/ui/FileInput.d.ts +0 -10
  361. package/lib/ui/FileInput.js +0 -5
  362. package/lib/ui/FlashMessage.d.ts +0 -7
  363. package/lib/ui/FlashMessage.js +0 -6
  364. package/lib/ui/ImageResizer.d.ts +0 -17
  365. package/lib/ui/ImageResizer.js +0 -171
  366. package/lib/ui/KatexEquationAlterer.d.ts +0 -8
  367. package/lib/ui/KatexEquationAlterer.js +0 -23
  368. package/lib/ui/KatexRenderer.d.ts +0 -6
  369. package/lib/ui/KatexRenderer.js +0 -24
  370. package/lib/ui/Modal.d.ts +0 -9
  371. package/lib/ui/Modal.js +0 -48
  372. package/lib/ui/Select.d.ts +0 -8
  373. package/lib/ui/Select.js +0 -5
  374. package/lib/ui/Switch.d.ts +0 -8
  375. package/lib/ui/Switch.js +0 -6
  376. package/lib/ui/TextInput.d.ts +0 -13
  377. package/lib/ui/TextInput.js +0 -7
  378. package/lib/utils/docSerialization.d.ts +0 -3
  379. package/lib/utils/docSerialization.js +0 -60
  380. package/lib/utils/emoji-list.d.ts +0 -20
  381. package/lib/utils/emoji-list.js +0 -16609
  382. package/lib/utils/getDOMRangeRect.d.ts +0 -8
  383. package/lib/utils/getDOMRangeRect.js +0 -26
  384. package/lib/utils/getSelectedNode.d.ts +0 -2
  385. package/lib/utils/getSelectedNode.js +0 -28
  386. package/lib/utils/getThemeSelector.d.ts +0 -2
  387. package/lib/utils/getThemeSelector.js +0 -14
  388. package/lib/utils/isMobileWidth.d.ts +0 -7
  389. package/lib/utils/isMobileWidth.js +0 -11
  390. package/lib/utils/joinClasses.d.ts +0 -1
  391. package/lib/utils/joinClasses.js +0 -7
  392. package/lib/utils/setFloatingElemPosition.d.ts +0 -1
  393. package/lib/utils/setFloatingElemPosition.js +0 -59
  394. package/lib/utils/setFloatingElemPositionForLinkEditor.d.ts +0 -1
  395. package/lib/utils/setFloatingElemPositionForLinkEditor.js +0 -36
  396. package/lib/utils/swipe.d.ts +0 -4
  397. package/lib/utils/swipe.js +0 -94
  398. package/lib/utils/url.d.ts +0 -2
  399. package/lib/utils/url.js +0 -31
@@ -1,452 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the MIT License.
4
- */
5
- /**
6
- * Sets up global debugging utilities for Loro collaboration.
7
- * Attaches comprehensive debugging tools to window.debugLoro for development use.
8
- */
9
- export function setupLoroDebugging(binding) {
10
- // Setup global debugging for Loro
11
- window.debugLoro = {
12
- binding: null, // Will be set after binding is created
13
- logStructure: () => {
14
- const binding = window.debugLoro.binding;
15
- if (binding) {
16
- console.log('=== LORO TREE STRUCTURE DEBUG ===');
17
- const tree = binding.tree;
18
- const nodes = tree.nodes();
19
- console.log(`Total nodes in tree: ${nodes.length}`);
20
- // Helper function to recursively log tree structure
21
- const logTreeStructure = (node, prefix = '', isLast = true, depth = 0) => {
22
- const data = Object.fromEntries(node.data.entries());
23
- const treeId = node.id;
24
- // Get lexical key from mapper instead of node data
25
- const lexicalKey = binding.nodeMapper?.getLexicalKeyByLoroId(treeId) || 'no-key';
26
- const elementType = data.elementType || 'no-type';
27
- const connector = depth === 0 ? '' : (isLast ? '└── ' : '├── ');
28
- const nodeInfo = `TreeID(${treeId.slice(0, 8)}...) → ${lexicalKey} [${elementType}]`;
29
- console.log(`${prefix}${connector}${nodeInfo}`);
30
- const children = node.children();
31
- if (children && children.length > 0) {
32
- children.forEach((child, index) => {
33
- const isLastChild = index === children.length - 1;
34
- const childPrefix = prefix + (depth === 0 ? '' : (isLast ? ' ' : '│ '));
35
- logTreeStructure(child, childPrefix, isLastChild, depth + 1);
36
- });
37
- }
38
- };
39
- // Find and display all root nodes
40
- const rootNodes = nodes.filter((node) => {
41
- const parent = node.parent();
42
- const data = Object.fromEntries(node.data.entries());
43
- return !parent || data.isRoot;
44
- });
45
- console.log(`Root nodes: ${rootNodes.length}`);
46
- console.log('');
47
- if (rootNodes.length === 0) {
48
- console.log('⚠️ No root nodes found!');
49
- }
50
- else {
51
- rootNodes.forEach((root, index) => {
52
- const isLastRoot = index === rootNodes.length - 1;
53
- logTreeStructure(root, '', isLastRoot, 0);
54
- });
55
- }
56
- console.log('=== END LORO DEBUG ===');
57
- }
58
- else {
59
- console.log('Loro binding not available yet');
60
- }
61
- },
62
- verifyStructure: () => {
63
- const binding = window.debugLoro.binding;
64
- if (!binding)
65
- return console.log('❌ Loro Binding not available');
66
- console.log('🔍 LORO TREE VERIFICATION:');
67
- const tree = binding.tree;
68
- const nodes = tree.nodes();
69
- console.log('Total nodes:', nodes.length);
70
- console.log('Peer ID:', binding.doc.peerIdStr);
71
- console.log('Client ID:', binding.clientID);
72
- // Check mapping consistency
73
- const mapper = binding.nodeMapper;
74
- console.log('\n📍 Node Mappings:');
75
- nodes.forEach((node, index) => {
76
- const data = Object.fromEntries(node.data.entries());
77
- const treeId = node.id;
78
- // Get lexical key from mapper instead of node data
79
- const lexicalKey = binding.nodeMapper?.getLexicalKeyByLoroId(treeId) || 'no-key';
80
- console.log(`\n📍 Node ${index}:`);
81
- console.log(' TreeID:', treeId);
82
- console.log(' Lexical Key:', lexicalKey);
83
- console.log(' Element Type:', data.elementType || 'N/A');
84
- console.log(' Created At:', data.createdAt && typeof data.createdAt === 'number' ? new Date(data.createdAt).toLocaleTimeString() : 'N/A');
85
- console.log(' Has Lexical Data:', data.lexical ? 'Yes' : 'No');
86
- const parent = node.parent();
87
- console.log(' Parent:', parent ? parent.id : 'None (Root)');
88
- const children = node.children();
89
- console.log(' Children Count:', children ? children.length : 0);
90
- if (data.lexical && typeof data.lexical === 'string') {
91
- try {
92
- const parsed = JSON.parse(data.lexical);
93
- console.log(' Lexical Type:', parsed.lexicalNode?.type || 'Unknown');
94
- }
95
- catch (e) {
96
- console.log(' Lexical Data: Invalid JSON');
97
- }
98
- }
99
- });
100
- // Check for orphaned nodes
101
- const orphanedNodes = nodes.filter(node => {
102
- const parent = node.parent();
103
- const data = Object.fromEntries(node.data.entries());
104
- return !parent && !data.isRoot;
105
- });
106
- if (orphanedNodes.length > 0) {
107
- console.log('\n⚠️ WARNING: Found orphaned nodes (no parent, not root):');
108
- orphanedNodes.forEach(node => {
109
- const data = Object.fromEntries(node.data.entries());
110
- const lexicalKey = binding.nodeMapper?.getLexicalKeyByLoroId(node.id) || 'no-key';
111
- console.log(` - ${node.id} (${lexicalKey}, ${data.elementType})`);
112
- });
113
- }
114
- // Show parent-child relationships
115
- console.log('\n🌳 Parent-Child Relationships:');
116
- nodes.forEach(node => {
117
- const data = Object.fromEntries(node.data.entries());
118
- const parent = node.parent();
119
- const children = node.children();
120
- const lexicalKey = binding.nodeMapper?.getLexicalKeyByLoroId(node.id) || 'no-key';
121
- console.log(`${node.id} (${lexicalKey}, ${data.elementType || 'no-type'})`);
122
- console.log(` Parent: ${parent ? parent.id : 'None'}`);
123
- console.log(` Children: ${children ? children.map(child => child.id).join(', ') : 'None'}`);
124
- });
125
- },
126
- inspectNode: (treeId) => {
127
- const binding = window.debugLoro.binding;
128
- if (!binding)
129
- return console.log('Loro binding not available');
130
- const tree = binding.tree;
131
- // Cast treeId to TreeID type - in practice this should work if it's a valid ID
132
- const node = tree.getNodeByID(treeId);
133
- if (node) {
134
- const data = Object.fromEntries(node.data.entries());
135
- const parent = node.parent();
136
- const children = node.children();
137
- // Collect lexical properties (new individual property format)
138
- const lexicalProps = {};
139
- Object.entries(data).forEach(([key, value]) => {
140
- if (key.startsWith('lexical_')) {
141
- lexicalProps[key.substring(8)] = value; // Remove 'lexical_' prefix
142
- }
143
- });
144
- // Get lexical key from mapper instead of node data
145
- const lexicalKey = binding.nodeMapper?.getLexicalKeyByLoroId(node.id) || 'no-key';
146
- console.log('🔍 Loro Node Details:', {
147
- treeId: node.id,
148
- lexicalKey: lexicalKey,
149
- elementType: data.elementType,
150
- createdAt: data.createdAt && typeof data.createdAt === 'number' ? new Date(data.createdAt).toLocaleString() : 'N/A',
151
- hasLexicalData: Object.keys(lexicalProps).length > 0 || !!data.lexical,
152
- parent: parent ? parent.id : 'None (Root)',
153
- childrenCount: children ? children.length : 0,
154
- isRoot: data.isRoot || false
155
- });
156
- // Handle different lexical data formats
157
- if (Object.keys(lexicalProps).length > 0) {
158
- console.log('📄 Lexical Data (Individual Properties):', lexicalProps);
159
- }
160
- else if (data.lexical) {
161
- if (typeof data.lexical === 'object') {
162
- console.log('📄 Lexical Data (Current JSON Object):', data.lexical);
163
- }
164
- else if (typeof data.lexical === 'string') {
165
- try {
166
- const lexicalData = JSON.parse(data.lexical);
167
- console.log('📄 Lexical Data (Legacy JSON String):', lexicalData);
168
- }
169
- catch (e) {
170
- console.log('❌ Failed to parse lexical data:', e);
171
- }
172
- }
173
- }
174
- else {
175
- console.log('⚠️ No lexical data found for this node');
176
- }
177
- // Fetch and log the corresponding lexical node
178
- if (lexicalKey && lexicalKey !== 'no-key' && typeof lexicalKey === 'string') {
179
- try {
180
- const editorState = binding.editor.getEditorState();
181
- const nodeInfo = editorState.read(() => {
182
- const lexicalNode = editorState._nodeMap.get(lexicalKey);
183
- if (!lexicalNode) {
184
- return null;
185
- }
186
- const info = {
187
- key: lexicalNode.getKey(),
188
- type: lexicalNode.getType(),
189
- parent: lexicalNode.getParent()?.getKey() || 'None (Root)',
190
- textContent: lexicalNode.getTextContent ? lexicalNode.getTextContent() : 'N/A',
191
- serialized: lexicalNode.exportJSON()
192
- };
193
- // Add children info if it's an ElementNode
194
- if ('getChildren' in lexicalNode && typeof lexicalNode.getChildren === 'function') {
195
- info.children = lexicalNode.getChildren().map((child) => child.getKey());
196
- }
197
- else {
198
- info.children = 'N/A (Not an ElementNode)';
199
- }
200
- return info;
201
- });
202
- if (nodeInfo) {
203
- console.log('🔗 Linked Lexical Node:', nodeInfo);
204
- }
205
- else {
206
- console.log('⚠️ No lexical node found in editor state for key:', lexicalKey, '(node may have been deleted or not yet created)');
207
- }
208
- }
209
- catch (e) {
210
- console.log('❌ Failed to fetch lexical node:', e);
211
- }
212
- }
213
- else {
214
- console.log('⚠️ No valid lexical key found for this Loro node (key:', lexicalKey, ')');
215
- }
216
- }
217
- else {
218
- console.warn(`Node with TreeID "${treeId}" not found`);
219
- }
220
- },
221
- generateTreeHTML: (nodes, rootNode, prefix = '', isLast = true, depth = 0) => {
222
- if (!rootNode) {
223
- // Find root nodes
224
- const rootNodes = nodes.filter(node => {
225
- const parent = node.parent();
226
- const data = Object.fromEntries(node.data.entries());
227
- return !parent || data.isRoot;
228
- });
229
- if (rootNodes.length === 0)
230
- return '<div style="color: #ffaa00;">No root nodes found</div>';
231
- // Display all root nodes
232
- let result = '';
233
- rootNodes.forEach((root, index) => {
234
- const isLastRoot = index === rootNodes.length - 1;
235
- result += window.debugLoro.generateTreeHTML(nodes, root, '', isLastRoot, 0);
236
- });
237
- return result;
238
- }
239
- const data = Object.fromEntries(rootNode.data.entries());
240
- const treeId = rootNode.id;
241
- // Get lexical key from mapper instead of node data
242
- const binding = window.debugLoro.binding;
243
- const lexicalKey = binding?.nodeMapper?.getLexicalKeyByLoroId(treeId) || 'no-key';
244
- const elementType = data.elementType || 'no-type';
245
- const nodeInfo = `TreeID(${treeId.slice(0, 8)}...) → ${lexicalKey} [${elementType}]`;
246
- const clickIntegrator = `onclick="window.debugLoro.inspectNode('${treeId}')"`;
247
- const nodeColor = data.isRoot ? '#00ff88' : '#00ffaa';
248
- const cursor = 'cursor: pointer; text-decoration: underline;';
249
- // Create proper tree structure with indentation
250
- const connector = depth === 0 ? '' : (isLast ? '└── ' : '├── ');
251
- let result = `<div style="color: ${nodeColor}; ${cursor}" ${clickIntegrator}>${prefix}${connector}${nodeInfo}</div>`;
252
- const children = rootNode.children();
253
- if (children && children.length > 0) {
254
- children.forEach((child, index) => {
255
- const isLastChild = index === children.length - 1;
256
- // Calculate prefix for children - if current node is last, use spaces, otherwise use vertical line
257
- // Use &nbsp; for HTML spaces to ensure proper rendering
258
- const childPrefix = prefix + (depth === 0 ? '' : (isLast ? '&nbsp;&nbsp;&nbsp;&nbsp;' : '│&nbsp;&nbsp;&nbsp;'));
259
- result += window.debugLoro.generateTreeHTML(nodes, child, childPrefix, isLastChild, depth + 1);
260
- });
261
- }
262
- return result;
263
- },
264
- addDebugToPage: () => {
265
- const binding = window.debugLoro.binding;
266
- if (!binding)
267
- return;
268
- const tree = binding.tree;
269
- const nodes = tree.nodes();
270
- // Debug: log the actual structure to console as a tree
271
- console.log('🟢 LORO Tree structure:');
272
- console.log(` Total nodes: ${nodes.length}`);
273
- console.log(` Peer ID: ${binding.doc.peerIdStr}`);
274
- console.log(` Client ID: ${binding.clientID}`);
275
- console.log('');
276
- // Helper function to recursively log tree structure
277
- const logTreeStructure = (node, prefix = '', isLast = true, depth = 0) => {
278
- const data = Object.fromEntries(node.data.entries());
279
- const treeId = node.id;
280
- // Get lexical key from mapper instead of node data
281
- const lexicalKey = binding.nodeMapper?.getLexicalKeyByLoroId(treeId) || 'no-key';
282
- const elementType = data.elementType || 'no-type';
283
- const connector = depth === 0 ? '' : (isLast ? '└── ' : '├── ');
284
- const nodeInfo = `TreeID(${treeId.slice(0, 8)}...) → ${lexicalKey} [${elementType}]`;
285
- console.log(`${prefix}${connector}${nodeInfo}`);
286
- const children = node.children();
287
- if (children && children.length > 0) {
288
- children.forEach((child, index) => {
289
- const isLastChild = index === children.length - 1;
290
- const childPrefix = prefix + (depth === 0 ? '' : (isLast ? ' ' : '│ '));
291
- logTreeStructure(child, childPrefix, isLastChild, depth + 1);
292
- });
293
- }
294
- };
295
- // Find and display all root nodes
296
- const rootNodes = nodes.filter((node) => {
297
- const parent = node.parent();
298
- const data = Object.fromEntries(node.data.entries());
299
- return !parent || data.isRoot;
300
- });
301
- if (rootNodes.length === 0) {
302
- console.log(' ⚠️ No root nodes found!');
303
- }
304
- else {
305
- rootNodes.forEach((root, index) => {
306
- const isLastRoot = index === rootNodes.length - 1;
307
- logTreeStructure(root, '', isLastRoot, 0);
308
- });
309
- }
310
- console.log('🟢 Loro Tree:', tree.toJSON());
311
- console.log('🟢 Lexical State:', binding.editor.getEditorState().toJSON());
312
- const treeHTML = window.debugLoro.generateTreeHTML(nodes);
313
- const debugDiv = document.getElementById('debug-loro') || document.createElement('div');
314
- const existingDiv = document.getElementById('debug-loro');
315
- // Preserve current position if panel already exists
316
- let currentLeft = '10px';
317
- let currentTop = '700px';
318
- if (existingDiv) {
319
- currentLeft = existingDiv.style.left || '10px';
320
- currentTop = existingDiv.style.top || '10px';
321
- }
322
- debugDiv.id = 'debug-loro';
323
- debugDiv.style.cssText = `position: fixed; top: ${currentTop}; left: ${currentLeft}; background: rgba(0,0,0,0.95); color: #00ff00; padding: 0; border-radius: 8px; font-family: "Courier New", monospace; font-size: 11px; z-index: 9999; max-width: 500px; max-height: 80vh; box-shadow: 0 4px 8px rgba(0,0,0,0.5); border: 1px solid #00ff00; user-select: none;`;
324
- // Add drag functionality if not already added
325
- if (!debugDiv.classList.contains('draggable-initialized')) {
326
- debugDiv.classList.add('draggable-initialized');
327
- let isDragging = false;
328
- let startX = 0;
329
- let startY = 0;
330
- let startLeft = 0;
331
- let startTop = 0;
332
- debugDiv.addEventListener('mousedown', (e) => {
333
- // Only start drag if clicking on the header area
334
- const target = e.target;
335
- const dragHandle = debugDiv.querySelector('.debug-drag-integrate');
336
- if (!dragHandle || !dragHandle.contains(target))
337
- return;
338
- isDragging = true;
339
- startX = e.clientX;
340
- startY = e.clientY;
341
- const rect = debugDiv.getBoundingClientRect();
342
- startLeft = rect.left;
343
- startTop = rect.top;
344
- document.addEventListener('mousemove', onMouseMove);
345
- document.addEventListener('mouseup', onMouseUp);
346
- e.preventDefault();
347
- });
348
- function onMouseMove(e) {
349
- if (!isDragging)
350
- return;
351
- const deltaX = e.clientX - startX;
352
- const deltaY = e.clientY - startY;
353
- const newLeft = Math.max(0, Math.min(window.innerWidth - debugDiv.offsetWidth, startLeft + deltaX));
354
- const newTop = Math.max(0, Math.min(window.innerHeight - debugDiv.offsetHeight, startTop + deltaY));
355
- debugDiv.style.left = newLeft + 'px';
356
- debugDiv.style.top = newTop + 'px';
357
- }
358
- function onMouseUp() {
359
- isDragging = false;
360
- document.removeEventListener('mousemove', onMouseMove);
361
- document.removeEventListener('mouseup', onMouseUp);
362
- }
363
- }
364
- debugDiv.innerHTML = `
365
- <div class="debug-drag-integrate" style="color: #00ff88; font-weight: bold; margin-bottom: 10px; border-bottom: 1px solid #00ff00; padding: 15px 15px 5px 15px; cursor: move; background: linear-gradient(90deg, rgba(0,255,136,0.1), transparent);">
366
- 🟢 LORO TREE <span style="float: right; font-size: 9px; color: #666;">⋮⋮ drag</span>
367
- </div>
368
- <div style="padding: 0 15px 15px 15px; overflow-y: auto; max-height: calc(80vh - 50px);">
369
- <div style="color: #00ffaa; margin-bottom: 8px;">Total nodes: ${nodes.length}</div>
370
- <div style="color: #00ff66; margin-bottom: 8px;">Peer ID: ${binding.doc.peerIdStr.slice(0, 8)}...</div>
371
- <div style="color: #00ffdd; margin-bottom: 10px;">Time: ${new Date().toLocaleTimeString()}</div>
372
- <div style="border-top: 1px solid #444; padding-top: 8px; line-height: 1.4; font-family: 'Courier New', monospace;">
373
- ${treeHTML}
374
- </div>
375
- <div style="margin-top: 10px; font-size: 10px; color: #666;">
376
- <span onclick="window.debugLoro.addDebugToPage()" style="color: #00ffaa; cursor: pointer; text-decoration: underline;">🔄 Refresh</span> |
377
- <span onclick="window.debugLoro.verifyStructure()" style="color: #00ff66; cursor: pointer; text-decoration: underline;">✅ Verify</span> |
378
- <span onclick="window.debugLoro.logStructure()" style="color: #00ffdd; cursor: pointer; text-decoration: underline;">📝 Log</span> |
379
- <span onclick="window.debugLoro.cleanupEphemeralStore()" style="color: #ffaa00; cursor: pointer; text-decoration: underline;">🧹 Cleanup</span> |
380
- <span onclick="window.debugLoro.resetGlobalEphemeralStore()" style="color: #ff6600; cursor: pointer; text-decoration: underline;">🔄 Reset</span> |
381
- <span onclick="document.getElementById('debug-loro').remove()" style="color: #ff0066; cursor: pointer; text-decoration: underline;">❌ Close</span>
382
- </div>
383
- </div>
384
- `;
385
- document.body.appendChild(debugDiv);
386
- },
387
- cleanupEphemeralStore: (provider) => {
388
- if (!provider) {
389
- console.log('⚠️ No provider passed. Usage: window.debugLoro.cleanupEphemeralStore(provider)');
390
- console.log('You can get the provider from your useCollaboration hook');
391
- return;
392
- }
393
- if (typeof provider.cleanupStaleStates !== 'function') {
394
- console.log('❌ Provider does not have cleanupStaleStates method');
395
- return;
396
- }
397
- console.log('🧹 Cleaning up stale ephemeral states...');
398
- provider.cleanupStaleStates();
399
- },
400
- resetGlobalEphemeralStore: () => {
401
- try {
402
- // We need to access the WebsocketProvider class which may not be globally available
403
- console.log('🔄 Attempting to reset global EphemeralStore...');
404
- console.log('💡 You can also refresh the browser to clear the global store');
405
- // For now, instruct user to refresh
406
- alert('To reset the global ephemeral store and clear all collaborators, please refresh the browser page.');
407
- }
408
- catch (error) {
409
- console.warn('❌ Reset failed:', error.message);
410
- }
411
- }
412
- };
413
- // Expose binding for debugging
414
- window.debugLoro.binding = binding;
415
- // Auto-initialize debug window after a short delay
416
- setTimeout(() => {
417
- window.debugLoro.addDebugToPage();
418
- }, 2000); // Slightly later than Y.js to avoid overlap
419
- }
420
- /**
421
- * Quick access function to add debug panel to page
422
- */
423
- export function addDebugPanel() {
424
- if (window.debugLoro?.addDebugToPage) {
425
- window.debugLoro.addDebugToPage();
426
- }
427
- else {
428
- console.warn('Debug utilities not initialized. Call setupLoroDebugging first.');
429
- }
430
- }
431
- /**
432
- * Quick access function to log tree structure
433
- */
434
- export function logTreeStructure() {
435
- if (window.debugLoro?.logStructure) {
436
- window.debugLoro.logStructure();
437
- }
438
- else {
439
- console.warn('Debug utilities not initialized. Call setupLoroDebugging first.');
440
- }
441
- }
442
- /**
443
- * Quick access function to verify tree structure
444
- */
445
- export function verifyTreeStructure() {
446
- if (window.debugLoro?.verifyStructure) {
447
- window.debugLoro.verifyStructure();
448
- }
449
- else {
450
- console.warn('Debug utilities not initialized. Call setupLoroDebugging first.');
451
- }
452
- }
@@ -1,19 +0,0 @@
1
- import type { LoroDoc } from 'loro-crdt';
2
- export type CollaborationContextType = {
3
- clientID: number;
4
- color: string;
5
- isCollabActive: boolean;
6
- name: string;
7
- docMap: Map<string, LoroDoc>;
8
- };
9
- /**
10
- * Generate a deterministic name and color based on a client ID
11
- * This ensures the same client ID always gets the same name across browser sessions
12
- */
13
- declare function generateDeterministicUserData(clientId: number): {
14
- name: string;
15
- color: string;
16
- };
17
- export declare const CollaborationContext: import("react").Context<CollaborationContextType>;
18
- export { generateDeterministicUserData };
19
- export declare function useCollaborationContext(username?: string, color?: string): CollaborationContextType;
@@ -1,52 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the MIT License.
4
- */
5
- import { createContext, useContext } from 'react';
6
- const ANIMAL_NAMES = [
7
- 'Cat', 'Dog', 'Rabbit', 'Frog', 'Fox', 'Hedgehog', 'Pigeon', 'Squirrel',
8
- 'Bear', 'Tiger', 'Leopard', 'Zebra', 'Wolf', 'Owl', 'Gull', 'Squid',
9
- 'Panda', 'Lion', 'Eagle', 'Shark', 'Dolphin', 'Penguin', 'Koala', 'Kangaroo'
10
- ];
11
- const COLORS = [
12
- 'rgb(125, 50, 0)', 'rgb(100, 0, 0)', 'rgb(150, 0, 0)', 'rgb(200, 0, 0)',
13
- 'rgb(200, 75, 0)', 'rgb(0, 75, 0)', 'rgb(0, 125, 0)', 'rgb(75, 100, 0)',
14
- 'rgb(125, 100, 0)', 'rgb(0, 0, 150)', 'rgb(0, 0, 200)', 'rgb(0, 0, 250)',
15
- 'rgb(0, 100, 150)', 'rgb(0, 100, 100)', 'rgb(100, 0, 100)', 'rgb(150, 0, 150)',
16
- 'rgb(255, 99, 71)', 'rgb(60, 179, 113)', 'rgb(30, 144, 255)', 'rgb(255, 165, 0)',
17
- 'rgb(138, 43, 226)', 'rgb(255, 20, 147)', 'rgb(0, 191, 255)', 'rgb(50, 205, 50)'
18
- ];
19
- /**
20
- * Generate a deterministic name and color based on a client ID
21
- * This ensures the same client ID always gets the same name across browser sessions
22
- */
23
- function generateDeterministicUserData(clientId) {
24
- // Use clientId as seed for deterministic selection
25
- const nameIndex = Math.abs(clientId) % ANIMAL_NAMES.length;
26
- const colorIndex = Math.abs(clientId) % COLORS.length;
27
- // Add a short ID suffix for uniqueness in case of collisions
28
- const shortId = Math.abs(clientId).toString().slice(-4);
29
- const name = `${ANIMAL_NAMES[nameIndex]}-${shortId}`;
30
- const color = COLORS[colorIndex];
31
- return { name, color };
32
- }
33
- // Use a temporary fallback for initial context (will be updated when client connects)
34
- const fallbackUserData = generateDeterministicUserData(Math.floor(Math.random() * 100000));
35
- export const CollaborationContext = createContext({
36
- clientID: 0,
37
- color: fallbackUserData.color,
38
- isCollabActive: false,
39
- name: fallbackUserData.name,
40
- docMap: new Map(),
41
- });
42
- export { generateDeterministicUserData };
43
- export function useCollaborationContext(username, color) {
44
- const collabContext = useContext(CollaborationContext);
45
- if (username != null) {
46
- collabContext.name = username;
47
- }
48
- if (color != null) {
49
- collabContext.color = color;
50
- }
51
- return collabContext;
52
- }
@@ -1,24 +0,0 @@
1
- import type { JSX } from 'react';
2
- import { InitialEditorStateType } from '@lexical/react/LexicalComposer';
3
- import type { LoroDoc } from 'loro-crdt';
4
- import { Provider } from './State';
5
- import { CursorsContainerRef } from './useCollaboration';
6
- import { SyncCursorPositionsFn } from './sync/SyncCursors';
7
- import { ExcludedProperties } from './Bindings';
8
- type Props = {
9
- id: string;
10
- providerFactory: (id: string, docMap: Map<string, LoroDoc>, websocketUrl?: string) => Provider;
11
- shouldBootstrap: boolean;
12
- username?: string;
13
- cursorColor?: string;
14
- cursorsContainerRef?: CursorsContainerRef;
15
- initialEditorState?: InitialEditorStateType;
16
- excludedProperties?: ExcludedProperties;
17
- awarenessData?: object;
18
- syncCursorPositionsFn?: SyncCursorPositionsFn;
19
- showCollaborators?: boolean;
20
- websocketUrl?: string;
21
- onInitialization?: (isInitialized: boolean) => void;
22
- };
23
- export declare function LoroCollaborationPlugin({ id, providerFactory, shouldBootstrap, username, cursorColor, cursorsContainerRef, initialEditorState, excludedProperties, awarenessData, syncCursorPositionsFn, showCollaborators, websocketUrl, onInitialization, }: Props): JSX.Element;
24
- export {};
@@ -1,83 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from 'react';
3
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
- import { useCollaborationContext, generateDeterministicUserData, } from './LexicalCollaborationContext';
5
- import { updateLocalStateName } from './State';
6
- import { useCollaboration, useFocusTracking, useHistory, } from './useCollaboration';
7
- import { createBinding, LoroCollaborationUI } from './Bindings';
8
- export function LoroCollaborationPlugin({ id, providerFactory, shouldBootstrap, username, cursorColor, cursorsContainerRef, initialEditorState, excludedProperties, awarenessData, syncCursorPositionsFn, showCollaborators = true, websocketUrl = 'ws://localhost:3002', onInitialization, }) {
9
- const isBindingInitialized = useRef(false);
10
- const isProviderInitialized = useRef(false);
11
- const collabContext = useCollaborationContext(username, cursorColor);
12
- const { docMap, name, color } = collabContext;
13
- const [editor] = useLexicalComposerContext();
14
- useEffect(() => {
15
- collabContext.isCollabActive = true;
16
- return () => {
17
- // Resetting flag only when unmount top level editor collab plugin. Nested
18
- // editors (e.g. image caption) should unmount without affecting it
19
- if (editor._parentEditor == null) {
20
- collabContext.isCollabActive = false;
21
- }
22
- };
23
- }, [collabContext, editor]);
24
- const [provider, setProvider] = useState();
25
- const [doc, setDoc] = useState();
26
- useEffect(() => {
27
- if (isProviderInitialized.current) {
28
- return;
29
- }
30
- isProviderInitialized.current = true;
31
- const provider = providerFactory(id, docMap, websocketUrl);
32
- setProvider(provider);
33
- setDoc(docMap.get(id));
34
- return () => {
35
- provider.disconnect();
36
- };
37
- }, [id, providerFactory, docMap, websocketUrl]);
38
- const [binding, setBinding] = useState();
39
- useEffect(() => {
40
- if (!provider) {
41
- return;
42
- }
43
- if (isBindingInitialized.current) {
44
- return;
45
- }
46
- isBindingInitialized.current = true;
47
- const binding = createBinding(editor, provider, id, doc || docMap.get(id), docMap, excludedProperties);
48
- // Update collaboration context with deterministic name based on client ID
49
- // This ensures consistent names across browser sessions
50
- const deterministicUserData = generateDeterministicUserData(binding.clientID);
51
- console.log('Setting deterministic user data based on client ID:', {
52
- clientId: binding.clientID,
53
- name: deterministicUserData.name,
54
- color: deterministicUserData.color
55
- });
56
- // Update the collaboration context with stable name and color
57
- const finalName = username || deterministicUserData.name;
58
- const finalColor = cursorColor || deterministicUserData.color;
59
- collabContext.name = finalName;
60
- collabContext.color = finalColor;
61
- collabContext.clientID = binding.clientID;
62
- // Update the awareness state immediately with the deterministic name
63
- updateLocalStateName(provider, finalName, finalColor);
64
- setBinding(binding);
65
- return () => {
66
- // Clean up binding resources if needed
67
- };
68
- }, [editor, provider, id, docMap, doc, excludedProperties, collabContext, username, cursorColor]);
69
- if (!provider || !binding) {
70
- return _jsx(_Fragment, {});
71
- }
72
- return (_jsx(LoroCollaborationCursors, { awarenessData: awarenessData, binding: binding, collabContext: collabContext, color: color, cursorsContainerRef: cursorsContainerRef, editor: editor, id: id, initialEditorState: initialEditorState, name: name, provider: provider, setDoc: setDoc, shouldBootstrap: shouldBootstrap, docMap: docMap, syncCursorPositionsFn: syncCursorPositionsFn, showCollaborators: showCollaborators, onInitialization: onInitialization }));
73
- }
74
- function LoroCollaborationCursors({ editor, id, provider, docMap, name, color, shouldBootstrap, cursorsContainerRef, initialEditorState, awarenessData, collabContext, binding, setDoc, syncCursorPositionsFn, showCollaborators = false, onInitialization, }) {
75
- const cursorsElement = useCollaboration(editor, id, provider, docMap, name, color, shouldBootstrap, binding, setDoc, cursorsContainerRef, initialEditorState, awarenessData, syncCursorPositionsFn, onInitialization);
76
- collabContext.clientID = binding.clientID;
77
- useHistory(editor, binding);
78
- useFocusTracking(editor, provider, name, color, awarenessData);
79
- if (showCollaborators) {
80
- return (_jsx(LoroCollaborationUI, { binding: binding, cursorsContainer: cursorsElement, currentUserName: name, currentUserColor: color, showCollaborators: true }));
81
- }
82
- return cursorsElement;
83
- }