@datalayer/lexical-loro 0.2.5 → 1.0.0

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,284 +0,0 @@
1
- import * as Y from 'yjs';
2
- import * as syncProtocol from 'y-protocols/sync';
3
- import * as awarenessProtocol from 'y-protocols/awareness';
4
- import * as encoding from 'lib0/encoding';
5
- import * as decoding from 'lib0/decoding';
6
- import * as map from 'lib0/map';
7
- import * as eventloop from 'lib0/eventloop';
8
- import * as yleveldb from 'y-leveldb';
9
- import { callbackIntegrator, isCallbackSet } from './callback';
10
- const CALLBACK_DEBOUNCE_WAIT = parseInt(process.env.CALLBACK_DEBOUNCE_WAIT || '2000');
11
- const CALLBACK_DEBOUNCE_MAXWAIT = parseInt(process.env.CALLBACK_DEBOUNCE_MAXWAIT || '10000');
12
- const debouncer = eventloop.createDebouncer(CALLBACK_DEBOUNCE_WAIT, CALLBACK_DEBOUNCE_MAXWAIT);
13
- const wsReadyStateConnecting = 0;
14
- const wsReadyStateOpen = 1;
15
- const wsReadyStateClosing = 2; // eslint-disable-line
16
- const wsReadyStateClosed = 3; // eslint-disable-line
17
- // disable gc when using snapshots!
18
- const gcEnabled = process.env.GC !== 'false' && process.env.GC !== '0';
19
- const persistenceDir = process.env.YPERSISTENCE;
20
- /**
21
- * @type {{bindState: function(string,WSSharedDoc):void, writeState:function(string,WSSharedDoc):Promise<any>, provider: any}|null}
22
- */
23
- let persistence = null;
24
- if (typeof persistenceDir === 'string') {
25
- console.info('Persisting documents to "' + persistenceDir + '"');
26
- // @ts-ignore
27
- const ldb = new yleveldb.LeveldbPersistence(persistenceDir);
28
- persistence = {
29
- provider: ldb,
30
- bindState: async (docName, ydoc) => {
31
- const persistedYdoc = await ldb.getYDoc(docName);
32
- const newUpdates = Y.encodeStateAsUpdate(ydoc);
33
- ldb.storeUpdate(docName, newUpdates);
34
- Y.applyUpdate(ydoc, Y.encodeStateAsUpdate(persistedYdoc));
35
- ydoc.on('update', update => {
36
- ldb.storeUpdate(docName, update);
37
- });
38
- },
39
- writeState: async (docName, ydoc) => { }
40
- };
41
- }
42
- /**
43
- * @param {{bindState: function(string,WSSharedDoc):void,
44
- * writeState:function(string,WSSharedDoc):Promise<any>,provider:any}|null} persistence_
45
- */
46
- export const setPersistence = persistence_ => {
47
- persistence = persistence_;
48
- };
49
- /**
50
- * @return {null|{bindState: function(string,WSSharedDoc):void,
51
- * writeState:function(string,WSSharedDoc):Promise<any>}|null} used persistence layer
52
- */
53
- export const getPersistence = () => persistence;
54
- /**
55
- * @type {Map<string,WSSharedDoc>}
56
- */
57
- export const docs = new Map();
58
- const messageSync = 0;
59
- const messageAwareness = 1;
60
- // const messageAuth = 2
61
- /**
62
- * @param {Uint8Array} update
63
- * @param {any} _origin
64
- * @param {WSSharedDoc} doc
65
- * @param {any} _tr
66
- */
67
- const updateIntegrator = (update, _origin, doc, _tr) => {
68
- const encoder = encoding.createEncoder();
69
- encoding.writeVarUint(encoder, messageSync);
70
- syncProtocol.writeUpdate(encoder, update);
71
- const message = encoding.toUint8Array(encoder);
72
- doc.conns.forEach((_, conn) => send(doc, conn, message));
73
- };
74
- /**
75
- * @type {(ydoc: Y.Doc) => Promise<void>}
76
- */
77
- let contentInitializor = _ydoc => Promise.resolve();
78
- /**
79
- * This function is called once every time a Yjs document is created. You can
80
- * use it to pull data from an external source or initialize content.
81
- *
82
- * @param {(ydoc: Y.Doc) => Promise<void>} f
83
- */
84
- export const setContentInitializor = (f) => {
85
- contentInitializor = f;
86
- };
87
- export class WSSharedDoc extends Y.Doc {
88
- name = '';
89
- conns = null;
90
- awareness = null;
91
- whenInitialized = null;
92
- /**
93
- * @param {string} name
94
- */
95
- constructor(name) {
96
- super({ gc: gcEnabled });
97
- this.name = name;
98
- /**
99
- * Maps from conn to set of controlled user ids. Delete all user ids from awareness when this conn is closed
100
- * @type {Map<Object, Set<number>>}
101
- */
102
- this.conns = new Map();
103
- /**
104
- * @type {awarenessProtocol.Awareness}
105
- */
106
- this.awareness = new awarenessProtocol.Awareness(this);
107
- this.awareness.setLocalState(null);
108
- /**
109
- * @param {{ added: Array<number>, updated: Array<number>, removed: Array<number> }} changes
110
- * @param {Object | null} conn Origin is the connection that made the change
111
- */
112
- const awarenessChangeIntegrator = ({ added, updated, removed }, conn) => {
113
- const changedClients = added.concat(updated, removed);
114
- if (conn !== null) {
115
- const connControlledIDs = /** @type {Set<number>} */ (this.conns.get(conn));
116
- if (connControlledIDs !== undefined) {
117
- added.forEach(clientID => { connControlledIDs.add(clientID); });
118
- removed.forEach(clientID => { connControlledIDs.delete(clientID); });
119
- }
120
- }
121
- // broadcast awareness update
122
- const encoder = encoding.createEncoder();
123
- encoding.writeVarUint(encoder, messageAwareness);
124
- encoding.writeVarUint8Array(encoder, awarenessProtocol.encodeAwarenessUpdate(this.awareness, changedClients));
125
- const buff = encoding.toUint8Array(encoder);
126
- this.conns.forEach((_, c) => {
127
- send(this, c, buff);
128
- });
129
- };
130
- this.awareness.on('update', awarenessChangeIntegrator);
131
- this.on('update', /** @type {any} */ (updateIntegrator));
132
- if (isCallbackSet) {
133
- this.on('update', (_update, _origin, doc) => {
134
- debouncer(() => callbackIntegrator(/** @type {WSSharedDoc} */ (doc)));
135
- });
136
- }
137
- this.whenInitialized = contentInitializor(this);
138
- }
139
- }
140
- /**
141
- * Gets a Y.Doc by name, whether in memory or on disk
142
- *
143
- * @param {string} docname - the name of the Y.Doc to find or create
144
- * @param {boolean} gc - whether to allow gc on the doc (applies only when created)
145
- * @return {WSSharedDoc}
146
- */
147
- export const getYDoc = (docname, gc = true) => map.setIfUndefined(docs, docname, () => {
148
- const doc = new WSSharedDoc(docname);
149
- doc.gc = gc;
150
- if (persistence !== null) {
151
- persistence.bindState(docname, doc);
152
- }
153
- docs.set(docname, doc);
154
- return doc;
155
- });
156
- /**
157
- * @param {any} conn
158
- * @param {WSSharedDoc} doc
159
- * @param {Uint8Array} message
160
- */
161
- const messageListener = (conn, doc, message) => {
162
- try {
163
- const encoder = encoding.createEncoder();
164
- const decoder = decoding.createDecoder(message);
165
- const messageType = decoding.readVarUint(decoder);
166
- switch (messageType) {
167
- case messageSync:
168
- encoding.writeVarUint(encoder, messageSync);
169
- syncProtocol.readSyncMessage(decoder, encoder, doc, conn);
170
- // If the `encoder` only contains the type of reply message and no
171
- // message, there is no need to send the message. When `encoder` only
172
- // contains the type of reply, its length is 1.
173
- if (encoding.length(encoder) > 1) {
174
- send(doc, conn, encoding.toUint8Array(encoder));
175
- }
176
- break;
177
- case messageAwareness: {
178
- awarenessProtocol.applyAwarenessUpdate(doc.awareness, decoding.readVarUint8Array(decoder), conn);
179
- break;
180
- }
181
- }
182
- }
183
- catch (err) {
184
- console.error(err);
185
- // @ts-ignore
186
- doc.emit('error', [err]);
187
- }
188
- };
189
- /**
190
- * @param {WSSharedDoc} doc
191
- * @param {any} conn
192
- */
193
- const closeConn = (doc, conn) => {
194
- if (doc.conns.has(conn)) {
195
- /**
196
- * @type {Set<number>}
197
- */
198
- // @ts-ignore
199
- const controlledIds = doc.conns.get(conn);
200
- doc.conns.delete(conn);
201
- awarenessProtocol.removeAwarenessStates(doc.awareness, Array.from(controlledIds), null);
202
- if (doc.conns.size === 0 && persistence !== null) {
203
- // if persisted, we store state and destroy ydocument
204
- persistence.writeState(doc.name, doc).then(() => {
205
- doc.destroy();
206
- });
207
- docs.delete(doc.name);
208
- }
209
- }
210
- conn.close();
211
- };
212
- /**
213
- * @param {WSSharedDoc} doc
214
- * @param {import('ws').WebSocket} conn
215
- * @param {Uint8Array} m
216
- */
217
- const send = (doc, conn, m) => {
218
- if (conn.readyState !== wsReadyStateConnecting && conn.readyState !== wsReadyStateOpen) {
219
- closeConn(doc, conn);
220
- }
221
- try {
222
- conn.send(m, {}, err => { err != null && closeConn(doc, conn); });
223
- }
224
- catch (e) {
225
- closeConn(doc, conn);
226
- }
227
- };
228
- const pingTimeout = 30000;
229
- /**
230
- * @param {import('ws').WebSocket} conn
231
- * @param {import('http').IncomingMessage} req
232
- * @param {any} opts
233
- */
234
- export const setupWSConnection = (conn, req, { docName = (req.url || '').slice(1).split('?')[0], gc = true } = {}) => {
235
- conn.binaryType = 'arraybuffer';
236
- // get doc, initialize if it does not exist yet
237
- const doc = getYDoc(docName, gc);
238
- doc.conns.set(conn, new Set());
239
- // listen and reply to events
240
- conn.on('message', /** @param {ArrayBuffer} message */ /** @param {ArrayBuffer} message */ message => messageListener(conn, doc, new Uint8Array(message)));
241
- // Check if connection is still alive
242
- let pongReceived = true;
243
- const pingInterval = setInterval(() => {
244
- if (!pongReceived) {
245
- if (doc.conns.has(conn)) {
246
- closeConn(doc, conn);
247
- }
248
- clearInterval(pingInterval);
249
- }
250
- else if (doc.conns.has(conn)) {
251
- pongReceived = false;
252
- try {
253
- conn.ping();
254
- }
255
- catch (e) {
256
- closeConn(doc, conn);
257
- clearInterval(pingInterval);
258
- }
259
- }
260
- }, pingTimeout);
261
- conn.on('close', () => {
262
- closeConn(doc, conn);
263
- clearInterval(pingInterval);
264
- });
265
- conn.on('pong', () => {
266
- pongReceived = true;
267
- });
268
- // put the following in a variables in a block so the interval handlers don't keep in in
269
- // scope
270
- {
271
- // send sync step 1
272
- const encoder = encoding.createEncoder();
273
- encoding.writeVarUint(encoder, messageSync);
274
- syncProtocol.writeSyncStep1(encoder, doc);
275
- send(doc, conn, encoding.toUint8Array(encoder));
276
- const awarenessStates = doc.awareness.getStates();
277
- if (awarenessStates.size > 0) {
278
- const encoder = encoding.createEncoder();
279
- encoding.writeVarUint(encoder, messageAwareness);
280
- encoding.writeVarUint8Array(encoder, awarenessProtocol.encodeAwarenessUpdate(doc.awareness, Array.from(awarenessStates.keys())));
281
- send(doc, conn, encoding.toUint8Array(encoder));
282
- }
283
- }
284
- };
@@ -1,39 +0,0 @@
1
- import type { BaseSelection, NodeKey } from 'lexical';
2
- import type { Binding } from '../Bindings';
3
- import { UserState, Provider } from '../State';
4
- import { AnyCollabNode } from '../nodes/AnyCollabNode';
5
- /*****************************************************************************/
6
- export type CursorSelection = {
7
- anchor: {
8
- key: NodeKey;
9
- offset: number;
10
- };
11
- caret: HTMLElement;
12
- color: string;
13
- focus: {
14
- key: NodeKey;
15
- offset: number;
16
- };
17
- name: HTMLSpanElement;
18
- selections: Array<HTMLElement>;
19
- };
20
- export type Cursor = {
21
- color: string;
22
- name: string;
23
- selection: null | CursorSelection;
24
- };
25
- export type SyncCursorPositionsOptions = {
26
- getAwarenessStates?: (binding: Binding, provider: Provider) => Map<number, UserState>;
27
- };
28
- export type SyncCursorPositionsFn = (binding: Binding, provider: Provider, options?: SyncCursorPositionsOptions) => void;
29
- /*****************************************************************************/
30
- export declare function $syncLocalCursorPosition(binding: Binding, provider: Provider): void;
31
- /*****************************************************************************/
32
- export declare function getAnchorAndFocusCollabNodesForUserState(binding: Binding, userState: UserState): {
33
- anchorCollabNode: AnyCollabNode;
34
- anchorOffset: number;
35
- focusCollabNode: AnyCollabNode;
36
- focusOffset: number;
37
- };
38
- export declare function syncCursorPositions(binding: Binding, provider: Provider, options?: SyncCursorPositionsOptions): void;
39
- export declare function syncLexicalSelectionToYjs(binding: Binding, provider: Provider, prevSelection: null | BaseSelection, nextSelection: null | BaseSelection): void;
@@ -1,351 +0,0 @@
1
- import { $getNodeByKey, $getSelection, $isElementNode, $isLineBreakNode, $isRangeSelection, $isTextNode, } from 'lexical';
2
- import { createDOMRange, createRectsFromDOMRange } from '@lexical/selection';
3
- import { compareRelativePositions, createAbsolutePositionFromRelativePosition, createRelativePositionFromTypeIndex, } from 'yjs';
4
- import invariant from '../../utils/invariant';
5
- import { getPositionFromElementAndOffset } from '../utils/Utils';
6
- import { CollabElementNode } from '../nodes/CollabElementNode';
7
- import { CollabTextNode } from '../nodes/CollabTextNode';
8
- /*****************************************************************************/
9
- function $setPoint(point, key, offset) {
10
- if (point.key !== key || point.offset !== offset) {
11
- let anchorNode = $getNodeByKey(key);
12
- if (anchorNode !== null &&
13
- !$isElementNode(anchorNode) &&
14
- !$isTextNode(anchorNode)) {
15
- const parent = anchorNode.getParentOrThrow();
16
- key = parent.getKey();
17
- offset = anchorNode.getIndexWithinParent();
18
- anchorNode = parent;
19
- }
20
- point.set(key, offset, $isElementNode(anchorNode) ? 'element' : 'text');
21
- }
22
- }
23
- /*****************************************************************************/
24
- export function $syncLocalCursorPosition(binding, provider) {
25
- const awareness = provider.awareness;
26
- const localState = awareness.getLocalState();
27
- if (localState === null) {
28
- return;
29
- }
30
- const { anchorCollabNode, anchorOffset, focusCollabNode, focusOffset } = getAnchorAndFocusCollabNodesForUserState(binding, localState);
31
- if (anchorCollabNode !== null && focusCollabNode !== null) {
32
- const anchorKey = anchorCollabNode.getKey();
33
- const focusKey = focusCollabNode.getKey();
34
- const selection = $getSelection();
35
- if (!$isRangeSelection(selection)) {
36
- return;
37
- }
38
- $setPoint(selection.anchor, anchorKey, anchorOffset);
39
- $setPoint(selection.focus, focusKey, focusOffset);
40
- }
41
- }
42
- /*****************************************************************************/
43
- function createRelativePosition(point, binding) {
44
- const collabNodeMap = binding.collabNodeMap;
45
- const collabNode = collabNodeMap.get(point.key);
46
- if (collabNode === undefined) {
47
- return null;
48
- }
49
- let offset = point.offset;
50
- let sharedType = collabNode.getSharedType();
51
- if (collabNode instanceof CollabTextNode) {
52
- sharedType = collabNode._parent._xmlText;
53
- const currentOffset = collabNode.getOffset();
54
- if (currentOffset === -1) {
55
- return null;
56
- }
57
- offset = currentOffset + 1 + offset;
58
- }
59
- else if (collabNode instanceof CollabElementNode &&
60
- point.type === 'element') {
61
- const parent = point.getNode();
62
- invariant($isElementNode(parent), 'Element point must be an element node');
63
- let accumulatedOffset = 0;
64
- let i = 0;
65
- let node = parent.getFirstChild();
66
- while (node !== null && i++ < offset) {
67
- if ($isTextNode(node)) {
68
- accumulatedOffset += node.getTextContentSize() + 1;
69
- }
70
- else {
71
- accumulatedOffset++;
72
- }
73
- node = node.getNextSibling();
74
- }
75
- offset = accumulatedOffset;
76
- }
77
- return createRelativePositionFromTypeIndex(sharedType, offset);
78
- }
79
- function createAbsolutePosition(relativePosition, binding) {
80
- return createAbsolutePositionFromRelativePosition(relativePosition, binding.doc);
81
- }
82
- function shouldUpdatePosition(currentPos, pos) {
83
- if (currentPos == null) {
84
- if (pos != null) {
85
- return true;
86
- }
87
- }
88
- else if (pos == null || !compareRelativePositions(currentPos, pos)) {
89
- return true;
90
- }
91
- return false;
92
- }
93
- function createCursor(name, color) {
94
- return {
95
- color: color,
96
- name: name,
97
- selection: null,
98
- };
99
- }
100
- function destroySelection(binding, selection) {
101
- const cursorsContainer = binding.cursorsContainer;
102
- if (cursorsContainer !== null) {
103
- const selections = selection.selections;
104
- const selectionsLength = selections.length;
105
- for (let i = 0; i < selectionsLength; i++) {
106
- cursorsContainer.removeChild(selections[i]);
107
- }
108
- }
109
- }
110
- function destroyCursor(binding, cursor) {
111
- const selection = cursor.selection;
112
- if (selection !== null) {
113
- destroySelection(binding, selection);
114
- }
115
- }
116
- function createCursorSelection(cursor, anchorKey, anchorOffset, focusKey, focusOffset) {
117
- const color = cursor.color;
118
- const caret = document.createElement('span');
119
- caret.style.cssText = `position:absolute;top:0;bottom:0;right:-1px;width:1px;background-color:${color};z-index:10;`;
120
- const name = document.createElement('span');
121
- name.textContent = cursor.name;
122
- name.style.cssText = `position:absolute;left:-2px;top:-16px;background-color:${color};color:#fff;line-height:12px;font-size:12px;padding:2px;font-family:Arial;font-weight:bold;white-space:nowrap;`;
123
- caret.appendChild(name);
124
- return {
125
- anchor: {
126
- key: anchorKey,
127
- offset: anchorOffset,
128
- },
129
- caret,
130
- color,
131
- focus: {
132
- key: focusKey,
133
- offset: focusOffset,
134
- },
135
- name,
136
- selections: [],
137
- };
138
- }
139
- function updateCursor(binding, cursor, nextSelection, nodeMap) {
140
- const editor = binding.editor;
141
- const rootElement = editor.getRootElement();
142
- const cursorsContainer = binding.cursorsContainer;
143
- if (cursorsContainer === null || rootElement === null) {
144
- return;
145
- }
146
- const cursorsContainerOffsetParent = cursorsContainer.offsetParent;
147
- if (cursorsContainerOffsetParent === null) {
148
- return;
149
- }
150
- const containerRect = cursorsContainerOffsetParent.getBoundingClientRect();
151
- const prevSelection = cursor.selection;
152
- if (nextSelection === null) {
153
- if (prevSelection === null) {
154
- return;
155
- }
156
- else {
157
- cursor.selection = null;
158
- destroySelection(binding, prevSelection);
159
- return;
160
- }
161
- }
162
- else {
163
- cursor.selection = nextSelection;
164
- }
165
- const caret = nextSelection.caret;
166
- const color = nextSelection.color;
167
- const selections = nextSelection.selections;
168
- const anchor = nextSelection.anchor;
169
- const focus = nextSelection.focus;
170
- const anchorKey = anchor.key;
171
- const focusKey = focus.key;
172
- const anchorNode = nodeMap.get(anchorKey);
173
- const focusNode = nodeMap.get(focusKey);
174
- if (anchorNode == null || focusNode == null) {
175
- return;
176
- }
177
- let selectionRects;
178
- // In the case of a collapsed selection on a linebreak, we need
179
- // to improvise as the browser will return nothing here as <br>
180
- // apparently take up no visual space :/
181
- // This won't work in all cases, but it's better than just showing
182
- // nothing all the time.
183
- if (anchorNode === focusNode && $isLineBreakNode(anchorNode)) {
184
- const brRect = editor.getElementByKey(anchorKey).getBoundingClientRect();
185
- selectionRects = [brRect];
186
- }
187
- else {
188
- const range = createDOMRange(editor, anchorNode, anchor.offset, focusNode, focus.offset);
189
- if (range === null) {
190
- return;
191
- }
192
- selectionRects = createRectsFromDOMRange(editor, range);
193
- }
194
- const selectionsLength = selections.length;
195
- const selectionRectsLength = selectionRects.length;
196
- for (let i = 0; i < selectionRectsLength; i++) {
197
- const selectionRect = selectionRects[i];
198
- let selection = selections[i];
199
- if (selection === undefined) {
200
- selection = document.createElement('span');
201
- selections[i] = selection;
202
- const selectionBg = document.createElement('span');
203
- selection.appendChild(selectionBg);
204
- cursorsContainer.appendChild(selection);
205
- }
206
- const top = selectionRect.top - containerRect.top;
207
- const left = selectionRect.left - containerRect.left;
208
- const style = `position:absolute;top:${top}px;left:${left}px;height:${selectionRect.height}px;width:${selectionRect.width}px;pointer-events:none;z-index:5;`;
209
- selection.style.cssText = style;
210
- selection.firstChild.style.cssText = `${style}left:0;top:0;background-color:${color};opacity:0.3;`;
211
- if (i === selectionRectsLength - 1) {
212
- if (caret.parentNode !== selection) {
213
- selection.appendChild(caret);
214
- }
215
- }
216
- }
217
- for (let i = selectionsLength - 1; i >= selectionRectsLength; i--) {
218
- const selection = selections[i];
219
- cursorsContainer.removeChild(selection);
220
- selections.pop();
221
- }
222
- }
223
- function getCollabNodeAndOffset(
224
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
225
- sharedType, offset) {
226
- const collabNode = sharedType._collabNode;
227
- if (collabNode === undefined) {
228
- return [null, 0];
229
- }
230
- if (collabNode instanceof CollabElementNode) {
231
- const { node, offset: collabNodeOffset } = getPositionFromElementAndOffset(collabNode, offset, true);
232
- if (node === null) {
233
- return [collabNode, 0];
234
- }
235
- else {
236
- return [node, collabNodeOffset];
237
- }
238
- }
239
- return [null, 0];
240
- }
241
- function getAwarenessStatesDefault(_binding, provider) {
242
- return provider.awareness.getStates();
243
- }
244
- /*****************************************************************************/
245
- export function getAnchorAndFocusCollabNodesForUserState(binding, userState) {
246
- const { anchorPos, focusPos } = userState;
247
- let anchorCollabNode = null;
248
- let anchorOffset = 0;
249
- let focusCollabNode = null;
250
- let focusOffset = 0;
251
- if (anchorPos !== null && focusPos !== null) {
252
- const anchorAbsPos = createAbsolutePosition(anchorPos, binding);
253
- const focusAbsPos = createAbsolutePosition(focusPos, binding);
254
- if (anchorAbsPos !== null && focusAbsPos !== null) {
255
- [anchorCollabNode, anchorOffset] = getCollabNodeAndOffset(anchorAbsPos.type, anchorAbsPos.index);
256
- [focusCollabNode, focusOffset] = getCollabNodeAndOffset(focusAbsPos.type, focusAbsPos.index);
257
- }
258
- }
259
- return {
260
- anchorCollabNode,
261
- anchorOffset,
262
- focusCollabNode,
263
- focusOffset,
264
- };
265
- }
266
- export function syncCursorPositions(binding, provider, options) {
267
- const { getAwarenessStates = getAwarenessStatesDefault } = options ?? {};
268
- const awarenessStates = Array.from(getAwarenessStates(binding, provider));
269
- const localClientID = binding.clientID;
270
- const cursors = binding.cursors;
271
- const editor = binding.editor;
272
- const nodeMap = editor._editorState._nodeMap;
273
- const visitedClientIDs = new Set();
274
- for (let i = 0; i < awarenessStates.length; i++) {
275
- const awarenessState = awarenessStates[i];
276
- const [clientID, awareness] = awarenessState;
277
- if (clientID !== localClientID) {
278
- visitedClientIDs.add(clientID);
279
- const { name, color, focusing } = awareness;
280
- let selection = null;
281
- let cursor = cursors.get(clientID);
282
- if (cursor === undefined) {
283
- cursor = createCursor(name, color);
284
- cursors.set(clientID, cursor);
285
- }
286
- if (focusing) {
287
- const { anchorCollabNode, anchorOffset, focusCollabNode, focusOffset } = getAnchorAndFocusCollabNodesForUserState(binding, awareness);
288
- if (anchorCollabNode !== null && focusCollabNode !== null) {
289
- const anchorKey = anchorCollabNode.getKey();
290
- const focusKey = focusCollabNode.getKey();
291
- selection = cursor.selection;
292
- if (selection === null) {
293
- selection = createCursorSelection(cursor, anchorKey, anchorOffset, focusKey, focusOffset);
294
- }
295
- else {
296
- const anchor = selection.anchor;
297
- const focus = selection.focus;
298
- anchor.key = anchorKey;
299
- anchor.offset = anchorOffset;
300
- focus.key = focusKey;
301
- focus.offset = focusOffset;
302
- }
303
- }
304
- }
305
- updateCursor(binding, cursor, selection, nodeMap);
306
- }
307
- }
308
- const allClientIDs = Array.from(cursors.keys());
309
- for (let i = 0; i < allClientIDs.length; i++) {
310
- const clientID = allClientIDs[i];
311
- if (!visitedClientIDs.has(clientID)) {
312
- const cursor = cursors.get(clientID);
313
- if (cursor !== undefined) {
314
- destroyCursor(binding, cursor);
315
- cursors.delete(clientID);
316
- }
317
- }
318
- }
319
- }
320
- export function syncLexicalSelectionToYjs(binding, provider, prevSelection, nextSelection) {
321
- const awareness = provider.awareness;
322
- const localState = awareness.getLocalState();
323
- if (localState === null) {
324
- return;
325
- }
326
- const { anchorPos: currentAnchorPos, focusPos: currentFocusPos, name, color, focusing, awarenessData, } = localState;
327
- let anchorPos = null;
328
- let focusPos = null;
329
- if (nextSelection === null ||
330
- (currentAnchorPos !== null && !nextSelection.is(prevSelection))) {
331
- if (prevSelection === null) {
332
- return;
333
- }
334
- }
335
- if ($isRangeSelection(nextSelection)) {
336
- anchorPos = createRelativePosition(nextSelection.anchor, binding);
337
- focusPos = createRelativePosition(nextSelection.focus, binding);
338
- }
339
- if (shouldUpdatePosition(currentAnchorPos, anchorPos) ||
340
- shouldUpdatePosition(currentFocusPos, focusPos)) {
341
- awareness.setLocalState({
342
- ...localState,
343
- anchorPos,
344
- awarenessData,
345
- color,
346
- focusPos,
347
- focusing,
348
- name,
349
- });
350
- }
351
- }
@@ -1,10 +0,0 @@
1
- import type { EditorState, NodeKey } from 'lexical';
2
- import { Text as YText, YEvent } from 'yjs';
3
- import { Binding } from '../Bindings';
4
- import { Provider } from '../State';
5
- import { SyncCursorPositionsFn } from './SyncCursors';
6
- /*****************************************************************************/
7
- type IntentionallyMarkedAsDirtyElement = boolean;
8
- export declare function syncYjsUpdatesToLexical(binding: Binding, provider: Provider, events: Array<YEvent<YText>>, isFromUndoManger: boolean, syncCursorPositionsFn?: SyncCursorPositionsFn): void;
9
- export declare function syncLexicalUpdatesToYjs(binding: Binding, provider: Provider, prevEditorState: EditorState, currEditorState: EditorState, dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>, dirtyLeaves: Set<NodeKey>, normalizedNodes: Set<NodeKey>, tags: Set<string>): void;
10
- export {};