@ekz/lexical-react 0.40.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 (470) hide show
  1. package/@ekz/lexicalExtensionComponent.dev.js +53 -0
  2. package/@ekz/lexicalExtensionComponent.dev.mjs +51 -0
  3. package/@ekz/lexicalExtensionComponent.js +11 -0
  4. package/@ekz/lexicalExtensionComponent.mjs +12 -0
  5. package/@ekz/lexicalExtensionComponent.node.mjs +10 -0
  6. package/@ekz/lexicalExtensionComponent.prod.js +9 -0
  7. package/@ekz/lexicalExtensionComponent.prod.mjs +9 -0
  8. package/@ekz/lexicalReactExtension.dev.js +187 -0
  9. package/@ekz/lexicalReactExtension.dev.mjs +184 -0
  10. package/@ekz/lexicalReactExtension.js +11 -0
  11. package/@ekz/lexicalReactExtension.mjs +13 -0
  12. package/@ekz/lexicalReactExtension.node.mjs +11 -0
  13. package/@ekz/lexicalReactExtension.prod.js +9 -0
  14. package/@ekz/lexicalReactExtension.prod.mjs +9 -0
  15. package/@ekz/lexicalReactPluginHostExtension.dev.js +189 -0
  16. package/@ekz/lexicalReactPluginHostExtension.dev.mjs +181 -0
  17. package/@ekz/lexicalReactPluginHostExtension.js +11 -0
  18. package/@ekz/lexicalReactPluginHostExtension.mjs +18 -0
  19. package/@ekz/lexicalReactPluginHostExtension.node.mjs +16 -0
  20. package/@ekz/lexicalReactPluginHostExtension.prod.js +9 -0
  21. package/@ekz/lexicalReactPluginHostExtension.prod.mjs +9 -0
  22. package/@ekz/lexicalReactProviderExtension.dev.js +33 -0
  23. package/@ekz/lexicalReactProviderExtension.dev.mjs +31 -0
  24. package/@ekz/lexicalReactProviderExtension.js +11 -0
  25. package/@ekz/lexicalReactProviderExtension.mjs +12 -0
  26. package/@ekz/lexicalReactProviderExtension.node.mjs +10 -0
  27. package/@ekz/lexicalReactProviderExtension.prod.js +9 -0
  28. package/@ekz/lexicalReactProviderExtension.prod.mjs +9 -0
  29. package/@ekz/lexicalTreeViewExtension.dev.js +57 -0
  30. package/@ekz/lexicalTreeViewExtension.dev.mjs +54 -0
  31. package/@ekz/lexicalTreeViewExtension.js +11 -0
  32. package/@ekz/lexicalTreeViewExtension.mjs +13 -0
  33. package/@ekz/lexicalTreeViewExtension.node.mjs +11 -0
  34. package/@ekz/lexicalTreeViewExtension.prod.js +9 -0
  35. package/@ekz/lexicalTreeViewExtension.prod.mjs +9 -0
  36. package/ExtensionComponent.d.ts +42 -0
  37. package/LICENSE +21 -0
  38. package/LexicalAutoEmbedPlugin.d.ts +39 -0
  39. package/LexicalAutoEmbedPlugin.dev.js +146 -0
  40. package/LexicalAutoEmbedPlugin.dev.mjs +141 -0
  41. package/LexicalAutoEmbedPlugin.js +11 -0
  42. package/LexicalAutoEmbedPlugin.js.flow +64 -0
  43. package/LexicalAutoEmbedPlugin.mjs +15 -0
  44. package/LexicalAutoEmbedPlugin.node.mjs +13 -0
  45. package/LexicalAutoEmbedPlugin.prod.js +9 -0
  46. package/LexicalAutoEmbedPlugin.prod.mjs +9 -0
  47. package/LexicalAutoFocusPlugin.d.ts +12 -0
  48. package/LexicalAutoFocusPlugin.dev.js +47 -0
  49. package/LexicalAutoFocusPlugin.dev.mjs +45 -0
  50. package/LexicalAutoFocusPlugin.js +11 -0
  51. package/LexicalAutoFocusPlugin.js.flow +14 -0
  52. package/LexicalAutoFocusPlugin.mjs +12 -0
  53. package/LexicalAutoFocusPlugin.node.mjs +10 -0
  54. package/LexicalAutoFocusPlugin.prod.js +9 -0
  55. package/LexicalAutoFocusPlugin.prod.mjs +9 -0
  56. package/LexicalAutoLinkPlugin.d.ts +14 -0
  57. package/LexicalAutoLinkPlugin.dev.js +54 -0
  58. package/LexicalAutoLinkPlugin.dev.mjs +52 -0
  59. package/LexicalAutoLinkPlugin.js +11 -0
  60. package/LexicalAutoLinkPlugin.js.flow +18 -0
  61. package/LexicalAutoLinkPlugin.mjs +13 -0
  62. package/LexicalAutoLinkPlugin.node.mjs +11 -0
  63. package/LexicalAutoLinkPlugin.prod.js +9 -0
  64. package/LexicalAutoLinkPlugin.prod.mjs +9 -0
  65. package/LexicalBlockWithAlignableContents.d.ts +21 -0
  66. package/LexicalBlockWithAlignableContents.dev.js +81 -0
  67. package/LexicalBlockWithAlignableContents.dev.mjs +79 -0
  68. package/LexicalBlockWithAlignableContents.js +11 -0
  69. package/LexicalBlockWithAlignableContents.js.flow +28 -0
  70. package/LexicalBlockWithAlignableContents.mjs +12 -0
  71. package/LexicalBlockWithAlignableContents.node.mjs +10 -0
  72. package/LexicalBlockWithAlignableContents.prod.js +9 -0
  73. package/LexicalBlockWithAlignableContents.prod.mjs +9 -0
  74. package/LexicalCharacterLimitPlugin.d.ts +15 -0
  75. package/LexicalCharacterLimitPlugin.dev.js +292 -0
  76. package/LexicalCharacterLimitPlugin.dev.mjs +290 -0
  77. package/LexicalCharacterLimitPlugin.js +11 -0
  78. package/LexicalCharacterLimitPlugin.js.flow +12 -0
  79. package/LexicalCharacterLimitPlugin.mjs +12 -0
  80. package/LexicalCharacterLimitPlugin.node.mjs +10 -0
  81. package/LexicalCharacterLimitPlugin.prod.js +9 -0
  82. package/LexicalCharacterLimitPlugin.prod.mjs +9 -0
  83. package/LexicalCheckListPlugin.d.ts +8 -0
  84. package/LexicalCheckListPlugin.dev.js +31 -0
  85. package/LexicalCheckListPlugin.dev.mjs +29 -0
  86. package/LexicalCheckListPlugin.js +11 -0
  87. package/LexicalCheckListPlugin.js.flow +10 -0
  88. package/LexicalCheckListPlugin.mjs +12 -0
  89. package/LexicalCheckListPlugin.node.mjs +10 -0
  90. package/LexicalCheckListPlugin.prod.js +9 -0
  91. package/LexicalCheckListPlugin.prod.mjs +9 -0
  92. package/LexicalClearEditorPlugin.d.ts +13 -0
  93. package/LexicalClearEditorPlugin.dev.js +55 -0
  94. package/LexicalClearEditorPlugin.dev.mjs +53 -0
  95. package/LexicalClearEditorPlugin.js +11 -0
  96. package/LexicalClearEditorPlugin.js.flow +14 -0
  97. package/LexicalClearEditorPlugin.mjs +12 -0
  98. package/LexicalClearEditorPlugin.node.mjs +10 -0
  99. package/LexicalClearEditorPlugin.prod.js +9 -0
  100. package/LexicalClearEditorPlugin.prod.mjs +9 -0
  101. package/LexicalClickableLinkPlugin.d.ts +11 -0
  102. package/LexicalClickableLinkPlugin.dev.js +38 -0
  103. package/LexicalClickableLinkPlugin.dev.mjs +36 -0
  104. package/LexicalClickableLinkPlugin.js +11 -0
  105. package/LexicalClickableLinkPlugin.js.flow +12 -0
  106. package/LexicalClickableLinkPlugin.mjs +12 -0
  107. package/LexicalClickableLinkPlugin.node.mjs +10 -0
  108. package/LexicalClickableLinkPlugin.prod.js +9 -0
  109. package/LexicalClickableLinkPlugin.prod.mjs +9 -0
  110. package/LexicalCollaborationContext.d.ts +19 -0
  111. package/LexicalCollaborationContext.dev.js +69 -0
  112. package/LexicalCollaborationContext.dev.mjs +65 -0
  113. package/LexicalCollaborationContext.js +11 -0
  114. package/LexicalCollaborationContext.js.flow +22 -0
  115. package/LexicalCollaborationContext.mjs +14 -0
  116. package/LexicalCollaborationContext.node.mjs +12 -0
  117. package/LexicalCollaborationContext.prod.js +9 -0
  118. package/LexicalCollaborationContext.prod.mjs +9 -0
  119. package/LexicalCollaborationPlugin.d.ts +39 -0
  120. package/LexicalCollaborationPlugin.dev.js +584 -0
  121. package/LexicalCollaborationPlugin.dev.mjs +569 -0
  122. package/LexicalCollaborationPlugin.js +11 -0
  123. package/LexicalCollaborationPlugin.js.flow +50 -0
  124. package/LexicalCollaborationPlugin.mjs +13 -0
  125. package/LexicalCollaborationPlugin.node.mjs +11 -0
  126. package/LexicalCollaborationPlugin.prod.js +9 -0
  127. package/LexicalCollaborationPlugin.prod.mjs +9 -0
  128. package/LexicalComposer.d.ts +25 -0
  129. package/LexicalComposer.dev.js +134 -0
  130. package/LexicalComposer.dev.mjs +132 -0
  131. package/LexicalComposer.js +11 -0
  132. package/LexicalComposer.js.flow +40 -0
  133. package/LexicalComposer.mjs +12 -0
  134. package/LexicalComposer.node.mjs +10 -0
  135. package/LexicalComposer.prod.js +9 -0
  136. package/LexicalComposer.prod.mjs +9 -0
  137. package/LexicalComposerContext.d.ts +18 -0
  138. package/LexicalComposerContext.dev.js +55 -0
  139. package/LexicalComposerContext.dev.mjs +51 -0
  140. package/LexicalComposerContext.js +11 -0
  141. package/LexicalComposerContext.js.flow +27 -0
  142. package/LexicalComposerContext.mjs +14 -0
  143. package/LexicalComposerContext.node.mjs +12 -0
  144. package/LexicalComposerContext.prod.js +9 -0
  145. package/LexicalComposerContext.prod.mjs +9 -0
  146. package/LexicalContentEditable.d.ts +26 -0
  147. package/LexicalContentEditable.dev.js +242 -0
  148. package/LexicalContentEditable.dev.mjs +239 -0
  149. package/LexicalContentEditable.js +11 -0
  150. package/LexicalContentEditable.js.flow +80 -0
  151. package/LexicalContentEditable.mjs +13 -0
  152. package/LexicalContentEditable.node.mjs +11 -0
  153. package/LexicalContentEditable.prod.js +9 -0
  154. package/LexicalContentEditable.prod.mjs +9 -0
  155. package/LexicalContextMenuPlugin.d.ts +36 -0
  156. package/LexicalContextMenuPlugin.dev.js +524 -0
  157. package/LexicalContextMenuPlugin.dev.mjs +509 -0
  158. package/LexicalContextMenuPlugin.js +11 -0
  159. package/LexicalContextMenuPlugin.js.flow +13 -0
  160. package/LexicalContextMenuPlugin.mjs +13 -0
  161. package/LexicalContextMenuPlugin.node.mjs +11 -0
  162. package/LexicalContextMenuPlugin.prod.js +9 -0
  163. package/LexicalContextMenuPlugin.prod.mjs +9 -0
  164. package/LexicalDecoratorBlockNode.d.ts +25 -0
  165. package/LexicalDecoratorBlockNode.dev.js +59 -0
  166. package/LexicalDecoratorBlockNode.dev.mjs +56 -0
  167. package/LexicalDecoratorBlockNode.js +11 -0
  168. package/LexicalDecoratorBlockNode.js.flow +35 -0
  169. package/LexicalDecoratorBlockNode.mjs +13 -0
  170. package/LexicalDecoratorBlockNode.node.mjs +11 -0
  171. package/LexicalDecoratorBlockNode.prod.js +9 -0
  172. package/LexicalDecoratorBlockNode.prod.mjs +9 -0
  173. package/LexicalDraggableBlockPlugin.d.ts +18 -0
  174. package/LexicalDraggableBlockPlugin.dev.js +655 -0
  175. package/LexicalDraggableBlockPlugin.dev.mjs +653 -0
  176. package/LexicalDraggableBlockPlugin.js +11 -0
  177. package/LexicalDraggableBlockPlugin.js.flow +24 -0
  178. package/LexicalDraggableBlockPlugin.mjs +12 -0
  179. package/LexicalDraggableBlockPlugin.node.mjs +10 -0
  180. package/LexicalDraggableBlockPlugin.prod.js +9 -0
  181. package/LexicalDraggableBlockPlugin.prod.mjs +9 -0
  182. package/LexicalEditorRefPlugin.d.ts +20 -0
  183. package/LexicalEditorRefPlugin.dev.js +58 -0
  184. package/LexicalEditorRefPlugin.dev.mjs +43 -0
  185. package/LexicalEditorRefPlugin.js +11 -0
  186. package/LexicalEditorRefPlugin.js.flow +19 -0
  187. package/LexicalEditorRefPlugin.mjs +12 -0
  188. package/LexicalEditorRefPlugin.node.mjs +10 -0
  189. package/LexicalEditorRefPlugin.prod.js +9 -0
  190. package/LexicalEditorRefPlugin.prod.mjs +9 -0
  191. package/LexicalErrorBoundary.d.ts +13 -0
  192. package/LexicalErrorBoundary.dev.js +40 -0
  193. package/LexicalErrorBoundary.dev.mjs +38 -0
  194. package/LexicalErrorBoundary.js +11 -0
  195. package/LexicalErrorBoundary.js.flow +17 -0
  196. package/LexicalErrorBoundary.mjs +12 -0
  197. package/LexicalErrorBoundary.node.mjs +10 -0
  198. package/LexicalErrorBoundary.prod.js +9 -0
  199. package/LexicalErrorBoundary.prod.mjs +9 -0
  200. package/LexicalExtensionComponent.js.flow +12 -0
  201. package/LexicalExtensionComposer.d.ts +69 -0
  202. package/LexicalExtensionComposer.dev.js +105 -0
  203. package/LexicalExtensionComposer.dev.mjs +103 -0
  204. package/LexicalExtensionComposer.js +11 -0
  205. package/LexicalExtensionComposer.js.flow +20 -0
  206. package/LexicalExtensionComposer.mjs +12 -0
  207. package/LexicalExtensionComposer.node.mjs +10 -0
  208. package/LexicalExtensionComposer.prod.js +9 -0
  209. package/LexicalExtensionComposer.prod.mjs +9 -0
  210. package/LexicalHashtagPlugin.d.ts +9 -0
  211. package/LexicalHashtagPlugin.dev.js +34 -0
  212. package/LexicalHashtagPlugin.dev.mjs +32 -0
  213. package/LexicalHashtagPlugin.js +11 -0
  214. package/LexicalHashtagPlugin.js.flow +10 -0
  215. package/LexicalHashtagPlugin.mjs +12 -0
  216. package/LexicalHashtagPlugin.node.mjs +10 -0
  217. package/LexicalHashtagPlugin.prod.js +9 -0
  218. package/LexicalHashtagPlugin.prod.mjs +9 -0
  219. package/LexicalHistoryPlugin.d.ts +14 -0
  220. package/LexicalHistoryPlugin.dev.js +48 -0
  221. package/LexicalHistoryPlugin.dev.mjs +46 -0
  222. package/LexicalHistoryPlugin.js +11 -0
  223. package/LexicalHistoryPlugin.js.flow +28 -0
  224. package/LexicalHistoryPlugin.mjs +13 -0
  225. package/LexicalHistoryPlugin.node.mjs +11 -0
  226. package/LexicalHistoryPlugin.prod.js +9 -0
  227. package/LexicalHistoryPlugin.prod.mjs +9 -0
  228. package/LexicalHorizontalRuleNode.d.ts +25 -0
  229. package/LexicalHorizontalRuleNode.dev.js +102 -0
  230. package/LexicalHorizontalRuleNode.dev.mjs +98 -0
  231. package/LexicalHorizontalRuleNode.js +11 -0
  232. package/LexicalHorizontalRuleNode.js.flow +27 -0
  233. package/LexicalHorizontalRuleNode.mjs +15 -0
  234. package/LexicalHorizontalRuleNode.node.mjs +13 -0
  235. package/LexicalHorizontalRuleNode.prod.js +9 -0
  236. package/LexicalHorizontalRuleNode.prod.mjs +9 -0
  237. package/LexicalHorizontalRulePlugin.d.ts +8 -0
  238. package/LexicalHorizontalRulePlugin.dev.js +44 -0
  239. package/LexicalHorizontalRulePlugin.dev.mjs +42 -0
  240. package/LexicalHorizontalRulePlugin.js +11 -0
  241. package/LexicalHorizontalRulePlugin.js.flow +12 -0
  242. package/LexicalHorizontalRulePlugin.mjs +12 -0
  243. package/LexicalHorizontalRulePlugin.node.mjs +10 -0
  244. package/LexicalHorizontalRulePlugin.prod.js +9 -0
  245. package/LexicalHorizontalRulePlugin.prod.mjs +9 -0
  246. package/LexicalLinkPlugin.d.ts +14 -0
  247. package/LexicalLinkPlugin.dev.js +43 -0
  248. package/LexicalLinkPlugin.dev.mjs +41 -0
  249. package/LexicalLinkPlugin.js +11 -0
  250. package/LexicalLinkPlugin.js.flow +21 -0
  251. package/LexicalLinkPlugin.mjs +12 -0
  252. package/LexicalLinkPlugin.node.mjs +10 -0
  253. package/LexicalLinkPlugin.prod.js +9 -0
  254. package/LexicalLinkPlugin.prod.mjs +9 -0
  255. package/LexicalListPlugin.d.ts +20 -0
  256. package/LexicalListPlugin.dev.js +55 -0
  257. package/LexicalListPlugin.dev.mjs +53 -0
  258. package/LexicalListPlugin.js +11 -0
  259. package/LexicalListPlugin.js.flow +15 -0
  260. package/LexicalListPlugin.mjs +12 -0
  261. package/LexicalListPlugin.node.mjs +10 -0
  262. package/LexicalListPlugin.prod.js +9 -0
  263. package/LexicalListPlugin.prod.mjs +9 -0
  264. package/LexicalMarkdownShortcutPlugin.d.ts +12 -0
  265. package/LexicalMarkdownShortcutPlugin.dev.js +55 -0
  266. package/LexicalMarkdownShortcutPlugin.dev.mjs +52 -0
  267. package/LexicalMarkdownShortcutPlugin.js +11 -0
  268. package/LexicalMarkdownShortcutPlugin.js.flow +16 -0
  269. package/LexicalMarkdownShortcutPlugin.mjs +13 -0
  270. package/LexicalMarkdownShortcutPlugin.node.mjs +11 -0
  271. package/LexicalMarkdownShortcutPlugin.prod.js +9 -0
  272. package/LexicalMarkdownShortcutPlugin.prod.mjs +9 -0
  273. package/LexicalNestedComposer.d.ts +57 -0
  274. package/LexicalNestedComposer.dev.js +161 -0
  275. package/LexicalNestedComposer.dev.mjs +159 -0
  276. package/LexicalNestedComposer.js +11 -0
  277. package/LexicalNestedComposer.js.flow +26 -0
  278. package/LexicalNestedComposer.mjs +12 -0
  279. package/LexicalNestedComposer.node.mjs +10 -0
  280. package/LexicalNestedComposer.prod.js +9 -0
  281. package/LexicalNestedComposer.prod.mjs +9 -0
  282. package/LexicalNodeContextMenuPlugin.d.ts +46 -0
  283. package/LexicalNodeContextMenuPlugin.dev.js +257 -0
  284. package/LexicalNodeContextMenuPlugin.dev.mjs +253 -0
  285. package/LexicalNodeContextMenuPlugin.js +11 -0
  286. package/LexicalNodeContextMenuPlugin.js.flow +12 -0
  287. package/LexicalNodeContextMenuPlugin.mjs +14 -0
  288. package/LexicalNodeContextMenuPlugin.node.mjs +12 -0
  289. package/LexicalNodeContextMenuPlugin.prod.js +9 -0
  290. package/LexicalNodeContextMenuPlugin.prod.mjs +9 -0
  291. package/LexicalNodeEventPlugin.d.ts +13 -0
  292. package/LexicalNodeEventPlugin.dev.js +61 -0
  293. package/LexicalNodeEventPlugin.dev.mjs +59 -0
  294. package/LexicalNodeEventPlugin.js +11 -0
  295. package/LexicalNodeEventPlugin.js.flow +20 -0
  296. package/LexicalNodeEventPlugin.mjs +12 -0
  297. package/LexicalNodeEventPlugin.node.mjs +10 -0
  298. package/LexicalNodeEventPlugin.prod.js +9 -0
  299. package/LexicalNodeEventPlugin.prod.mjs +9 -0
  300. package/LexicalNodeMenuPlugin.d.ts +24 -0
  301. package/LexicalNodeMenuPlugin.dev.js +527 -0
  302. package/LexicalNodeMenuPlugin.dev.mjs +524 -0
  303. package/LexicalNodeMenuPlugin.js +11 -0
  304. package/LexicalNodeMenuPlugin.js.flow +64 -0
  305. package/LexicalNodeMenuPlugin.mjs +13 -0
  306. package/LexicalNodeMenuPlugin.node.mjs +11 -0
  307. package/LexicalNodeMenuPlugin.prod.js +9 -0
  308. package/LexicalNodeMenuPlugin.prod.mjs +9 -0
  309. package/LexicalOnChangePlugin.d.ts +13 -0
  310. package/LexicalOnChangePlugin.dev.js +72 -0
  311. package/LexicalOnChangePlugin.dev.mjs +70 -0
  312. package/LexicalOnChangePlugin.js +11 -0
  313. package/LexicalOnChangePlugin.js.flow +16 -0
  314. package/LexicalOnChangePlugin.mjs +12 -0
  315. package/LexicalOnChangePlugin.node.mjs +10 -0
  316. package/LexicalOnChangePlugin.prod.js +9 -0
  317. package/LexicalOnChangePlugin.prod.mjs +9 -0
  318. package/LexicalPlainTextPlugin.d.ts +14 -0
  319. package/LexicalPlainTextPlugin.dev.js +235 -0
  320. package/LexicalPlainTextPlugin.dev.mjs +233 -0
  321. package/LexicalPlainTextPlugin.js +11 -0
  322. package/LexicalPlainTextPlugin.js.flow +29 -0
  323. package/LexicalPlainTextPlugin.mjs +12 -0
  324. package/LexicalPlainTextPlugin.node.mjs +10 -0
  325. package/LexicalPlainTextPlugin.prod.js +9 -0
  326. package/LexicalPlainTextPlugin.prod.mjs +9 -0
  327. package/LexicalReactExtension.js.flow +68 -0
  328. package/LexicalReactPluginHostExtension.js.flow +84 -0
  329. package/LexicalReactProviderExtension.js.flow +12 -0
  330. package/LexicalRichTextPlugin.d.ts +14 -0
  331. package/LexicalRichTextPlugin.dev.js +235 -0
  332. package/LexicalRichTextPlugin.dev.mjs +233 -0
  333. package/LexicalRichTextPlugin.js +11 -0
  334. package/LexicalRichTextPlugin.js.flow +29 -0
  335. package/LexicalRichTextPlugin.mjs +12 -0
  336. package/LexicalRichTextPlugin.node.mjs +10 -0
  337. package/LexicalRichTextPlugin.prod.js +9 -0
  338. package/LexicalRichTextPlugin.prod.mjs +9 -0
  339. package/LexicalSelectionAlwaysOnDisplay.d.ts +12 -0
  340. package/LexicalSelectionAlwaysOnDisplay.dev.js +33 -0
  341. package/LexicalSelectionAlwaysOnDisplay.dev.mjs +31 -0
  342. package/LexicalSelectionAlwaysOnDisplay.js +11 -0
  343. package/LexicalSelectionAlwaysOnDisplay.js.flow +15 -0
  344. package/LexicalSelectionAlwaysOnDisplay.mjs +12 -0
  345. package/LexicalSelectionAlwaysOnDisplay.node.mjs +10 -0
  346. package/LexicalSelectionAlwaysOnDisplay.prod.js +9 -0
  347. package/LexicalSelectionAlwaysOnDisplay.prod.mjs +9 -0
  348. package/LexicalTabIndentationPlugin.d.ts +17 -0
  349. package/LexicalTabIndentationPlugin.dev.js +40 -0
  350. package/LexicalTabIndentationPlugin.dev.mjs +38 -0
  351. package/LexicalTabIndentationPlugin.js +11 -0
  352. package/LexicalTabIndentationPlugin.js.flow +21 -0
  353. package/LexicalTabIndentationPlugin.mjs +13 -0
  354. package/LexicalTabIndentationPlugin.node.mjs +11 -0
  355. package/LexicalTabIndentationPlugin.prod.js +9 -0
  356. package/LexicalTabIndentationPlugin.prod.mjs +9 -0
  357. package/LexicalTableOfContentsPlugin.d.ts +20 -0
  358. package/LexicalTableOfContentsPlugin.dev.js +209 -0
  359. package/LexicalTableOfContentsPlugin.dev.mjs +207 -0
  360. package/LexicalTableOfContentsPlugin.js +11 -0
  361. package/LexicalTableOfContentsPlugin.js.flow +18 -0
  362. package/LexicalTableOfContentsPlugin.mjs +12 -0
  363. package/LexicalTableOfContentsPlugin.node.mjs +10 -0
  364. package/LexicalTableOfContentsPlugin.prod.js +9 -0
  365. package/LexicalTableOfContentsPlugin.prod.mjs +9 -0
  366. package/LexicalTablePlugin.d.ts +46 -0
  367. package/LexicalTablePlugin.dev.js +81 -0
  368. package/LexicalTablePlugin.dev.mjs +79 -0
  369. package/LexicalTablePlugin.js +11 -0
  370. package/LexicalTablePlugin.js.flow +15 -0
  371. package/LexicalTablePlugin.mjs +12 -0
  372. package/LexicalTablePlugin.node.mjs +10 -0
  373. package/LexicalTablePlugin.prod.js +9 -0
  374. package/LexicalTablePlugin.prod.mjs +9 -0
  375. package/LexicalTreeView.d.ts +37 -0
  376. package/LexicalTreeView.dev.js +105 -0
  377. package/LexicalTreeView.dev.mjs +91 -0
  378. package/LexicalTreeView.js +11 -0
  379. package/LexicalTreeView.js.flow +21 -0
  380. package/LexicalTreeView.mjs +12 -0
  381. package/LexicalTreeView.node.mjs +10 -0
  382. package/LexicalTreeView.prod.js +9 -0
  383. package/LexicalTreeView.prod.mjs +9 -0
  384. package/LexicalTreeViewExtension.js.flow +12 -0
  385. package/LexicalTypeaheadMenuPlugin.d.ts +40 -0
  386. package/LexicalTypeaheadMenuPlugin.dev.js +654 -0
  387. package/LexicalTypeaheadMenuPlugin.dev.mjs +646 -0
  388. package/LexicalTypeaheadMenuPlugin.js +11 -0
  389. package/LexicalTypeaheadMenuPlugin.js.flow +83 -0
  390. package/LexicalTypeaheadMenuPlugin.mjs +18 -0
  391. package/LexicalTypeaheadMenuPlugin.node.mjs +16 -0
  392. package/LexicalTypeaheadMenuPlugin.prod.js +9 -0
  393. package/LexicalTypeaheadMenuPlugin.prod.mjs +9 -0
  394. package/README.md +90 -0
  395. package/ReactExtension.d.ts +41 -0
  396. package/ReactPluginHostExtension.d.ts +56 -0
  397. package/ReactProviderExtension.d.ts +9 -0
  398. package/TreeViewExtension.d.ts +18 -0
  399. package/package.json +1549 -0
  400. package/shared/LegacyDecorators.d.ts +23 -0
  401. package/shared/LexicalContentEditableElement.d.ts +43 -0
  402. package/shared/LexicalMenu.d.ts +52 -0
  403. package/shared/buildEditorComponent.d.ts +11 -0
  404. package/shared/mergeRefs.d.ts +9 -0
  405. package/shared/point.d.ts +21 -0
  406. package/shared/rect.d.ts +45 -0
  407. package/shared/types.d.ts +89 -0
  408. package/shared/useCanShowPlaceholder.d.ts +9 -0
  409. package/shared/useCharacterLimit.d.ts +16 -0
  410. package/shared/useDecorators.d.ts +17 -0
  411. package/shared/useHistory.d.ts +10 -0
  412. package/shared/useList.d.ts +9 -0
  413. package/shared/usePlainTextSetup.d.ts +9 -0
  414. package/shared/useReactDecorators.d.ts +12 -0
  415. package/shared/useRichTextSetup.d.ts +9 -0
  416. package/shared/useYjsCollaboration.d.ts +25 -0
  417. package/useExtensionComponent.d.ts +10 -0
  418. package/useLexicalEditable.d.ts +16 -0
  419. package/useLexicalEditable.dev.js +102 -0
  420. package/useLexicalEditable.dev.mjs +100 -0
  421. package/useLexicalEditable.js +11 -0
  422. package/useLexicalEditable.js.flow +12 -0
  423. package/useLexicalEditable.mjs +12 -0
  424. package/useLexicalEditable.node.mjs +10 -0
  425. package/useLexicalEditable.prod.js +9 -0
  426. package/useLexicalEditable.prod.mjs +9 -0
  427. package/useLexicalExtensionComponent.dev.js +37 -0
  428. package/useLexicalExtensionComponent.dev.mjs +34 -0
  429. package/useLexicalExtensionComponent.js +11 -0
  430. package/useLexicalExtensionComponent.js.flow +12 -0
  431. package/useLexicalExtensionComponent.mjs +13 -0
  432. package/useLexicalExtensionComponent.node.mjs +11 -0
  433. package/useLexicalExtensionComponent.prod.js +9 -0
  434. package/useLexicalExtensionComponent.prod.mjs +9 -0
  435. package/useLexicalIsTextContentEmpty.d.ts +9 -0
  436. package/useLexicalIsTextContentEmpty.dev.js +60 -0
  437. package/useLexicalIsTextContentEmpty.dev.mjs +58 -0
  438. package/useLexicalIsTextContentEmpty.js +11 -0
  439. package/useLexicalIsTextContentEmpty.js.flow +15 -0
  440. package/useLexicalIsTextContentEmpty.mjs +12 -0
  441. package/useLexicalIsTextContentEmpty.node.mjs +10 -0
  442. package/useLexicalIsTextContentEmpty.prod.js +9 -0
  443. package/useLexicalIsTextContentEmpty.prod.mjs +9 -0
  444. package/useLexicalNodeSelection.d.ts +24 -0
  445. package/useLexicalNodeSelection.dev.js +102 -0
  446. package/useLexicalNodeSelection.dev.mjs +100 -0
  447. package/useLexicalNodeSelection.js +11 -0
  448. package/useLexicalNodeSelection.js.flow +14 -0
  449. package/useLexicalNodeSelection.mjs +12 -0
  450. package/useLexicalNodeSelection.node.mjs +10 -0
  451. package/useLexicalNodeSelection.prod.js +9 -0
  452. package/useLexicalNodeSelection.prod.mjs +9 -0
  453. package/useLexicalSubscription.d.ts +17 -0
  454. package/useLexicalSubscription.dev.js +73 -0
  455. package/useLexicalSubscription.dev.mjs +71 -0
  456. package/useLexicalSubscription.js +11 -0
  457. package/useLexicalSubscription.js.flow +19 -0
  458. package/useLexicalSubscription.mjs +12 -0
  459. package/useLexicalSubscription.node.mjs +10 -0
  460. package/useLexicalSubscription.prod.js +9 -0
  461. package/useLexicalSubscription.prod.mjs +9 -0
  462. package/useLexicalTextEntity.d.ts +10 -0
  463. package/useLexicalTextEntity.dev.js +31 -0
  464. package/useLexicalTextEntity.dev.mjs +29 -0
  465. package/useLexicalTextEntity.js +11 -0
  466. package/useLexicalTextEntity.js.flow +18 -0
  467. package/useLexicalTextEntity.mjs +12 -0
  468. package/useLexicalTextEntity.node.mjs +10 -0
  469. package/useLexicalTextEntity.prod.js +9 -0
  470. package/useLexicalTextEntity.prod.mjs +9 -0
@@ -0,0 +1,569 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { useCollaborationContext } from '@ekz/lexical-react/LexicalCollaborationContext';
10
+ import { useLexicalComposerContext } from '@ekz/lexical-react/LexicalComposerContext';
11
+ import { syncCursorPositions, syncLexicalUpdateToYjs, createUndoManager, setLocalStateFocus, createBindingV2__EXPERIMENTAL, CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, syncYjsStateToLexicalV2__EXPERIMENTAL, DIFF_VERSIONS_COMMAND__EXPERIMENTAL, renderSnapshot__EXPERIMENTAL, syncLexicalUpdateToYjsV2__EXPERIMENTAL, syncYjsChangesToLexical, initLocalState, TOGGLE_CONNECT_COMMAND, syncYjsChangesToLexicalV2__EXPERIMENTAL, CONNECTED_COMMAND, createBinding } from '@ekz/lexical-yjs';
12
+ import * as React from 'react';
13
+ import { useRef, useCallback, useEffect, useMemo, useState } from 'react';
14
+ import { mergeRegister } from '@ekz/lexical-utils';
15
+ import { SKIP_COLLAB_TAG, FOCUS_COMMAND, COMMAND_PRIORITY_EDITOR, BLUR_COMMAND, $getRoot, HISTORY_MERGE_TAG, $createParagraphNode, $getSelection, UNDO_COMMAND, REDO_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND } from '@ekz/lexical';
16
+ import { createPortal } from 'react-dom';
17
+ import { UndoManager } from 'yjs';
18
+ import { jsx, Fragment } from 'react/jsx-runtime';
19
+
20
+ /**
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ *
26
+ */
27
+
28
+ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBootstrap, binding, setDoc, cursorsContainerRef, initialEditorState, awarenessData, syncCursorPositionsFn = syncCursorPositions) {
29
+ const isReloadingDoc = useRef(false);
30
+ const onBootstrap = useCallback(() => {
31
+ const {
32
+ root
33
+ } = binding;
34
+ if (shouldBootstrap && root.isEmpty() && root._xmlText._length === 0) {
35
+ initializeEditor(editor, initialEditorState);
36
+ }
37
+ }, [binding, editor, initialEditorState, shouldBootstrap]);
38
+ useEffect(() => {
39
+ const {
40
+ root
41
+ } = binding;
42
+ const onYjsTreeChanges = (events, transaction) => {
43
+ const origin = transaction.origin;
44
+ if (origin !== binding) {
45
+ const isFromUndoManger = origin instanceof UndoManager;
46
+ syncYjsChangesToLexical(binding, provider, events, isFromUndoManger, syncCursorPositionsFn);
47
+ }
48
+ };
49
+
50
+ // This updates the local editor state when we receive updates from other clients
51
+ root.getSharedType().observeDeep(onYjsTreeChanges);
52
+ const removeListener = editor.registerUpdateListener(({
53
+ prevEditorState,
54
+ editorState,
55
+ dirtyLeaves,
56
+ dirtyElements,
57
+ normalizedNodes,
58
+ tags
59
+ }) => {
60
+ if (!tags.has(SKIP_COLLAB_TAG)) {
61
+ syncLexicalUpdateToYjs(binding, provider, prevEditorState, editorState, dirtyElements, dirtyLeaves, normalizedNodes, tags);
62
+ }
63
+ });
64
+ return () => {
65
+ root.getSharedType().unobserveDeep(onYjsTreeChanges);
66
+ removeListener();
67
+ };
68
+ }, [binding, provider, editor, setDoc, docMap, id, syncCursorPositionsFn]);
69
+
70
+ // Note: 'reload' is not an actual Yjs event type. Included here for legacy support (#1409).
71
+ useEffect(() => {
72
+ const onProviderDocReload = ydoc => {
73
+ clearEditorSkipCollab(editor, binding);
74
+ setDoc(ydoc);
75
+ docMap.set(id, ydoc);
76
+ isReloadingDoc.current = true;
77
+ };
78
+ const onSync = () => {
79
+ isReloadingDoc.current = false;
80
+ };
81
+ provider.on('reload', onProviderDocReload);
82
+ provider.on('sync', onSync);
83
+ return () => {
84
+ provider.off('reload', onProviderDocReload);
85
+ provider.off('sync', onSync);
86
+ };
87
+ }, [binding, provider, editor, setDoc, docMap, id]);
88
+ useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap);
89
+ useAwareness(binding, provider);
90
+ return useYjsCursors(binding, cursorsContainerRef);
91
+ }
92
+ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap, name, color, options = {}) {
93
+ const {
94
+ awarenessData,
95
+ excludedProperties,
96
+ rootName,
97
+ __shouldBootstrapUnsafe: shouldBootstrap
98
+ } = options;
99
+
100
+ // Note: v2 does not support 'reload' event, which is not an actual Yjs event type.
101
+ const isReloadingDoc = useMemo(() => ({
102
+ current: false
103
+ }), []);
104
+ const binding = useMemo(() => createBindingV2__EXPERIMENTAL(editor, id, doc, docMap, {
105
+ excludedProperties,
106
+ rootName
107
+ }), [editor, id, doc, docMap, excludedProperties, rootName]);
108
+ useEffect(() => {
109
+ docMap.set(id, doc);
110
+ return () => {
111
+ docMap.delete(id);
112
+ };
113
+ }, [doc, docMap, id]);
114
+ const onBootstrap = useCallback(() => {
115
+ const {
116
+ root
117
+ } = binding;
118
+ if (shouldBootstrap && root._length === 0) {
119
+ initializeEditor(editor);
120
+ }
121
+ }, [binding, editor, shouldBootstrap]);
122
+ const [diffSnapshots, setDiffSnapshots] = useState();
123
+ useEffect(() => {
124
+ mergeRegister(editor.registerCommand(CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, () => {
125
+ setDiffSnapshots(null);
126
+ // Ensure that any state already in Yjs is loaded into the editor (eg: after clearing diff view).
127
+ syncYjsStateToLexicalV2__EXPERIMENTAL(binding, provider);
128
+ return true;
129
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DIFF_VERSIONS_COMMAND__EXPERIMENTAL, ({
130
+ prevSnapshot,
131
+ snapshot
132
+ }) => {
133
+ setDiffSnapshots({
134
+ prevSnapshot,
135
+ snapshot
136
+ });
137
+ return true;
138
+ }, COMMAND_PRIORITY_EDITOR));
139
+ }, [editor, binding, provider]);
140
+ useEffect(() => {
141
+ const {
142
+ root
143
+ } = binding;
144
+ if (diffSnapshots) {
145
+ renderSnapshot__EXPERIMENTAL(binding, diffSnapshots.snapshot, diffSnapshots.prevSnapshot);
146
+ return;
147
+ }
148
+ const onYjsTreeChanges = (events, transaction) => {
149
+ const origin = transaction.origin;
150
+ if (origin !== binding) {
151
+ const isFromUndoManger = origin instanceof UndoManager;
152
+ syncYjsChangesToLexicalV2__EXPERIMENTAL(binding, provider, events, transaction, isFromUndoManger);
153
+ }
154
+ };
155
+
156
+ // This updates the local editor state when we receive updates from other clients
157
+ root.observeDeep(onYjsTreeChanges);
158
+ const removeListener = editor.registerUpdateListener(({
159
+ prevEditorState,
160
+ editorState,
161
+ dirtyElements,
162
+ normalizedNodes,
163
+ tags
164
+ }) => {
165
+ if (!tags.has(SKIP_COLLAB_TAG)) {
166
+ syncLexicalUpdateToYjsV2__EXPERIMENTAL(binding, provider, prevEditorState, editorState, dirtyElements, normalizedNodes, tags);
167
+ }
168
+ });
169
+ return () => {
170
+ root.unobserveDeep(onYjsTreeChanges);
171
+ removeListener();
172
+ };
173
+ }, [binding, provider, editor, diffSnapshots]);
174
+ useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap);
175
+ useAwareness(binding, provider);
176
+ return binding;
177
+ }
178
+ function useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap) {
179
+ const connect = useCallback(() => provider.connect(), [provider]);
180
+ const disconnect = useCallback(() => {
181
+ try {
182
+ provider.disconnect();
183
+ } catch (_e) {
184
+ // Do nothing
185
+ }
186
+ }, [provider]);
187
+ useEffect(() => {
188
+ const onStatus = ({
189
+ status
190
+ }) => {
191
+ editor.dispatchCommand(CONNECTED_COMMAND, status === 'connected');
192
+ };
193
+ const onSync = isSynced => {
194
+ if (isSynced && isReloadingDoc.current === false && onBootstrap) {
195
+ onBootstrap();
196
+ }
197
+ };
198
+ initLocalState(provider, name, color, document.activeElement === editor.getRootElement(), awarenessData || {});
199
+ provider.on('status', onStatus);
200
+ provider.on('sync', onSync);
201
+ const connectionPromise = connect();
202
+ return () => {
203
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- expected that isReloadingDoc.current may change
204
+ if (isReloadingDoc.current === false) {
205
+ if (connectionPromise) {
206
+ connectionPromise.then(disconnect);
207
+ } else {
208
+ // Workaround for race condition in StrictMode. It's possible there
209
+ // is a different race for the above case where connect returns a
210
+ // promise, but we don't have an example of that in-repo.
211
+ // It's possible that there is a similar issue with
212
+ // TOGGLE_CONNECT_COMMAND below when the provider connect returns a
213
+ // promise.
214
+ // https://github.com/facebook/lexical/issues/6640
215
+ disconnect();
216
+ }
217
+ }
218
+ provider.off('sync', onSync);
219
+ provider.off('status', onStatus);
220
+ };
221
+ }, [editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap, connect, disconnect]);
222
+ useEffect(() => {
223
+ return editor.registerCommand(TOGGLE_CONNECT_COMMAND, payload => {
224
+ const shouldConnect = payload;
225
+ if (shouldConnect) {
226
+ // eslint-disable-next-line no-console
227
+ console.log('Collaboration connected!');
228
+ connect();
229
+ } else {
230
+ // eslint-disable-next-line no-console
231
+ console.log('Collaboration disconnected!');
232
+ disconnect();
233
+ }
234
+ return true;
235
+ }, COMMAND_PRIORITY_EDITOR);
236
+ }, [connect, disconnect, editor]);
237
+
238
+ // Clear awareness state immediately when tab is refreshed or closed
239
+ // This prevents ghost cursors from appearing for several seconds after disconnect
240
+ // See: https://github.com/facebook/lexical/issues/8061
241
+ useEffect(() => {
242
+ const clearAwarenessState = () => {
243
+ // Immediately clear local awareness state to signal disconnection
244
+ // This broadcasts to other clients that this client has disconnected,
245
+ // causing them to remove the cursor immediately instead of waiting for timeout
246
+ try {
247
+ provider.awareness.setLocalState(null);
248
+ } catch (_e) {
249
+ // Ignore errors during cleanup (e.g., if provider is already disconnected)
250
+ }
251
+ };
252
+
253
+ // Use both beforeunload and pagehide for maximum browser compatibility
254
+ // beforeunload: fires before page unloads (may be cancelable)
255
+ // pagehide: fires when page is being unloaded (more reliable, especially on mobile)
256
+ window.addEventListener('beforeunload', clearAwarenessState);
257
+ window.addEventListener('pagehide', clearAwarenessState);
258
+ return () => {
259
+ window.removeEventListener('beforeunload', clearAwarenessState);
260
+ window.removeEventListener('pagehide', clearAwarenessState);
261
+ };
262
+ }, [provider]);
263
+ }
264
+ function useAwareness(binding, provider) {
265
+ useEffect(() => {
266
+ const {
267
+ awareness
268
+ } = provider;
269
+ const onAwarenessUpdate = () => {
270
+ syncCursorPositions(binding, provider);
271
+ };
272
+ awareness.on('update', onAwarenessUpdate);
273
+ return () => {
274
+ awareness.off('update', onAwarenessUpdate);
275
+ };
276
+ }, [binding, provider]);
277
+ }
278
+ function useYjsCursors(binding, cursorsContainerRef) {
279
+ return useMemo(() => {
280
+ const ref = element => {
281
+ binding.cursorsContainer = element;
282
+ };
283
+ return /*#__PURE__*/createPortal(/*#__PURE__*/jsx("div", {
284
+ ref: ref
285
+ }), cursorsContainerRef && cursorsContainerRef.current || document.body);
286
+ }, [binding, cursorsContainerRef]);
287
+ }
288
+ function useYjsFocusTracking(editor, provider, name, color, awarenessData) {
289
+ useEffect(() => {
290
+ return mergeRegister(editor.registerCommand(FOCUS_COMMAND, () => {
291
+ setLocalStateFocus(provider, name, color, true, awarenessData || {});
292
+ return false;
293
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(BLUR_COMMAND, () => {
294
+ setLocalStateFocus(provider, name, color, false, awarenessData || {});
295
+ return false;
296
+ }, COMMAND_PRIORITY_EDITOR));
297
+ }, [color, editor, name, provider, awarenessData]);
298
+ }
299
+ function useYjsHistory(editor, binding) {
300
+ const undoManager = useMemo(() => createUndoManager(binding, binding.root.getSharedType()), [binding]);
301
+ return useYjsUndoManager(editor, undoManager);
302
+ }
303
+ function useYjsHistoryV2(editor, binding) {
304
+ const undoManager = useMemo(() => createUndoManager(binding, binding.root), [binding]);
305
+ return useYjsUndoManager(editor, undoManager);
306
+ }
307
+ function useYjsUndoManager(editor, undoManager) {
308
+ useEffect(() => {
309
+ const undo = () => {
310
+ undoManager.undo();
311
+ };
312
+ const redo = () => {
313
+ undoManager.redo();
314
+ };
315
+ return mergeRegister(editor.registerCommand(UNDO_COMMAND, () => {
316
+ undo();
317
+ return true;
318
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(REDO_COMMAND, () => {
319
+ redo();
320
+ return true;
321
+ }, COMMAND_PRIORITY_EDITOR));
322
+ });
323
+ const clearHistory = useCallback(() => {
324
+ undoManager.clear();
325
+ }, [undoManager]);
326
+
327
+ // Exposing undo and redo states
328
+ React.useEffect(() => {
329
+ const updateUndoRedoStates = () => {
330
+ editor.dispatchCommand(CAN_UNDO_COMMAND, undoManager.undoStack.length > 0);
331
+ editor.dispatchCommand(CAN_REDO_COMMAND, undoManager.redoStack.length > 0);
332
+ };
333
+ undoManager.on('stack-item-added', updateUndoRedoStates);
334
+ undoManager.on('stack-item-popped', updateUndoRedoStates);
335
+ undoManager.on('stack-cleared', updateUndoRedoStates);
336
+ return () => {
337
+ undoManager.off('stack-item-added', updateUndoRedoStates);
338
+ undoManager.off('stack-item-popped', updateUndoRedoStates);
339
+ undoManager.off('stack-cleared', updateUndoRedoStates);
340
+ };
341
+ }, [editor, undoManager]);
342
+ return clearHistory;
343
+ }
344
+ function initializeEditor(editor, initialEditorState) {
345
+ editor.update(() => {
346
+ const root = $getRoot();
347
+ if (root.isEmpty()) {
348
+ if (initialEditorState) {
349
+ switch (typeof initialEditorState) {
350
+ case 'string':
351
+ {
352
+ const parsedEditorState = editor.parseEditorState(initialEditorState);
353
+ editor.setEditorState(parsedEditorState, {
354
+ tag: HISTORY_MERGE_TAG
355
+ });
356
+ break;
357
+ }
358
+ case 'object':
359
+ {
360
+ editor.setEditorState(initialEditorState, {
361
+ tag: HISTORY_MERGE_TAG
362
+ });
363
+ break;
364
+ }
365
+ case 'function':
366
+ {
367
+ editor.update(() => {
368
+ const root1 = $getRoot();
369
+ if (root1.isEmpty()) {
370
+ initialEditorState(editor);
371
+ }
372
+ }, {
373
+ tag: HISTORY_MERGE_TAG
374
+ });
375
+ break;
376
+ }
377
+ }
378
+ } else {
379
+ const paragraph = $createParagraphNode();
380
+ root.append(paragraph);
381
+ const {
382
+ activeElement
383
+ } = document;
384
+ if ($getSelection() !== null || activeElement !== null && activeElement === editor.getRootElement()) {
385
+ paragraph.select();
386
+ }
387
+ }
388
+ }
389
+ }, {
390
+ tag: HISTORY_MERGE_TAG
391
+ });
392
+ }
393
+ function clearEditorSkipCollab(editor, binding) {
394
+ // reset editor state
395
+ editor.update(() => {
396
+ const root = $getRoot();
397
+ root.clear();
398
+ root.select();
399
+ }, {
400
+ tag: SKIP_COLLAB_TAG
401
+ });
402
+ if (binding.cursors == null) {
403
+ return;
404
+ }
405
+ const cursors = binding.cursors;
406
+ if (cursors == null) {
407
+ return;
408
+ }
409
+ const cursorsContainer = binding.cursorsContainer;
410
+ if (cursorsContainer == null) {
411
+ return;
412
+ }
413
+
414
+ // reset cursors in dom
415
+ const cursorsArr = Array.from(cursors.values());
416
+ for (let i = 0; i < cursorsArr.length; i++) {
417
+ const cursor = cursorsArr[i];
418
+ const selection = cursor.selection;
419
+ if (selection && selection.selections != null) {
420
+ const selections = selection.selections;
421
+ for (let j = 0; j < selections.length; j++) {
422
+ cursorsContainer.removeChild(selections[i]);
423
+ }
424
+ }
425
+ }
426
+ }
427
+
428
+ /**
429
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
430
+ *
431
+ * This source code is licensed under the MIT license found in the
432
+ * LICENSE file in the root directory of this source tree.
433
+ *
434
+ */
435
+
436
+ function CollaborationPlugin({
437
+ id,
438
+ providerFactory,
439
+ shouldBootstrap,
440
+ username,
441
+ cursorColor,
442
+ cursorsContainerRef,
443
+ initialEditorState,
444
+ excludedProperties,
445
+ awarenessData,
446
+ syncCursorPositionsFn
447
+ }) {
448
+ const isBindingInitialized = useRef(false);
449
+ const isProviderInitialized = useRef(false);
450
+ const collabContext = useCollaborationContext(username, cursorColor);
451
+ const {
452
+ yjsDocMap,
453
+ name,
454
+ color
455
+ } = collabContext;
456
+ const [editor] = useLexicalComposerContext();
457
+ useCollabActive(collabContext, editor);
458
+ const [provider, setProvider] = useState();
459
+ const [doc, setDoc] = useState();
460
+ useEffect(() => {
461
+ if (isProviderInitialized.current) {
462
+ return;
463
+ }
464
+ isProviderInitialized.current = true;
465
+ const newProvider = providerFactory(id, yjsDocMap);
466
+ setProvider(newProvider);
467
+ setDoc(yjsDocMap.get(id));
468
+ return () => {
469
+ newProvider.disconnect();
470
+ };
471
+ }, [id, providerFactory, yjsDocMap]);
472
+ const [binding, setBinding] = useState();
473
+ useEffect(() => {
474
+ if (!provider) {
475
+ return;
476
+ }
477
+ if (isBindingInitialized.current) {
478
+ return;
479
+ }
480
+ isBindingInitialized.current = true;
481
+ const newBinding = createBinding(editor, provider, id, doc || yjsDocMap.get(id), yjsDocMap, excludedProperties);
482
+ setBinding(newBinding);
483
+ return () => {
484
+ newBinding.root.destroy(newBinding);
485
+ };
486
+ }, [editor, provider, id, yjsDocMap, doc, excludedProperties]);
487
+ if (!provider || !binding) {
488
+ return /*#__PURE__*/jsx(Fragment, {});
489
+ }
490
+ return /*#__PURE__*/jsx(YjsCollaborationCursors, {
491
+ awarenessData: awarenessData,
492
+ binding: binding,
493
+ collabContext: collabContext,
494
+ color: color,
495
+ cursorsContainerRef: cursorsContainerRef,
496
+ editor: editor,
497
+ id: id,
498
+ initialEditorState: initialEditorState,
499
+ name: name,
500
+ provider: provider,
501
+ setDoc: setDoc,
502
+ shouldBootstrap: shouldBootstrap,
503
+ yjsDocMap: yjsDocMap,
504
+ syncCursorPositionsFn: syncCursorPositionsFn
505
+ });
506
+ }
507
+ function YjsCollaborationCursors({
508
+ editor,
509
+ id,
510
+ provider,
511
+ yjsDocMap,
512
+ name,
513
+ color,
514
+ shouldBootstrap,
515
+ cursorsContainerRef,
516
+ initialEditorState,
517
+ awarenessData,
518
+ collabContext,
519
+ binding,
520
+ setDoc,
521
+ syncCursorPositionsFn
522
+ }) {
523
+ const cursors = useYjsCollaboration(editor, id, provider, yjsDocMap, name, color, shouldBootstrap, binding, setDoc, cursorsContainerRef, initialEditorState, awarenessData, syncCursorPositionsFn);
524
+ useYjsHistory(editor, binding);
525
+ useYjsFocusTracking(editor, provider, name, color, awarenessData);
526
+ return cursors;
527
+ }
528
+ function CollaborationPluginV2__EXPERIMENTAL({
529
+ id,
530
+ doc,
531
+ provider,
532
+ __shouldBootstrapUnsafe,
533
+ username,
534
+ cursorColor,
535
+ cursorsContainerRef,
536
+ excludedProperties,
537
+ awarenessData
538
+ }) {
539
+ const collabContext = useCollaborationContext(username, cursorColor);
540
+ const {
541
+ yjsDocMap,
542
+ name,
543
+ color
544
+ } = collabContext;
545
+ const [editor] = useLexicalComposerContext();
546
+ useCollabActive(collabContext, editor);
547
+ const binding = useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, yjsDocMap, name, color, {
548
+ __shouldBootstrapUnsafe,
549
+ awarenessData,
550
+ excludedProperties
551
+ });
552
+ useYjsHistoryV2(editor, binding);
553
+ useYjsFocusTracking(editor, provider, name, color, awarenessData);
554
+ return useYjsCursors(binding, cursorsContainerRef);
555
+ }
556
+ const useCollabActive = (collabContext, editor) => {
557
+ useEffect(() => {
558
+ collabContext.isCollabActive = true;
559
+ return () => {
560
+ // Resetting flag only when unmount top level editor collab plugin. Nested
561
+ // editors (e.g. image caption) should unmount without affecting it
562
+ if (editor._parentEditor == null) {
563
+ collabContext.isCollabActive = false;
564
+ }
565
+ };
566
+ }, [collabContext, editor]);
567
+ };
568
+
569
+ export { CollaborationPlugin, CollaborationPluginV2__EXPERIMENTAL };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ 'use strict'
10
+ const LexicalCollaborationPlugin = process.env.NODE_ENV !== 'production' ? require('./LexicalCollaborationPlugin.dev.js') : require('./LexicalCollaborationPlugin.prod.js');
11
+ module.exports = LexicalCollaborationPlugin;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type {InitialEditorStateType} from '@ekz/lexical-react/LexicalComposer';
11
+ import type {ExcludedProperties, ProviderAwareness} from '@ekz/lexical-yjs';
12
+ import type {Doc, RelativePosition} from 'yjs';
13
+
14
+ export interface Provider {
15
+ connect(): void | Promise<void>;
16
+ disconnect(): void;
17
+ awareness: ProviderAwareness;
18
+ on(type: 'sync', cb: (isSynced: boolean) => void): void;
19
+ on(type: 'status', cb: ({status: string}) => void): void;
20
+ // $FlowFixMe[unclear-type]: temp
21
+ on(type: 'update', cb: (any) => void): void;
22
+ on(type: 'reload', cb: (doc: Doc) => void): void;
23
+ off(type: 'sync', cb: (isSynced: boolean) => void): void;
24
+ // $FlowFixMe[unclear-type]: temp
25
+ off(type: 'update', cb: (any) => void): void;
26
+ off(type: 'status', cb: ({status: string}) => void): void;
27
+ off(type: 'reload', cb: (doc: Doc) => void): void;
28
+ }
29
+
30
+ export type ProviderFactory = (
31
+ id: string,
32
+ yjsDocMap: Map<string, Doc>,
33
+ ) => Provider;
34
+
35
+ export type CursorsContainerRef = {current: null | HTMLElement};
36
+
37
+ declare export function CollaborationPlugin(arg0: {
38
+ id: string,
39
+ providerFactory: (
40
+ // eslint-disable-next-line no-shadow
41
+ id: string,
42
+ yjsDocMap: Map<string, Doc>,
43
+ ) => Provider,
44
+ shouldBootstrap: boolean,
45
+ username?: string,
46
+ cursorColor?: string,
47
+ cursorsContainerRef?: CursorsContainerRef,
48
+ initialEditorState?: InitialEditorStateType,
49
+ excludedProperties?: ExcludedProperties,
50
+ }): React.Node;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import * as modDev from './LexicalCollaborationPlugin.dev.mjs';
10
+ import * as modProd from './LexicalCollaborationPlugin.prod.mjs';
11
+ const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
12
+ export const CollaborationPlugin = mod.CollaborationPlugin;
13
+ export const CollaborationPluginV2__EXPERIMENTAL = mod.CollaborationPluginV2__EXPERIMENTAL;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalCollaborationPlugin.dev.mjs') : import('./LexicalCollaborationPlugin.prod.mjs'));
10
+ export const CollaborationPlugin = mod.CollaborationPlugin;
11
+ export const CollaborationPluginV2__EXPERIMENTAL = mod.CollaborationPluginV2__EXPERIMENTAL;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ "use strict";var e=require("@ekz/lexical-react/LexicalCollaborationContext"),t=require("@ekz/lexical-react/LexicalComposerContext"),o=require("@ekz/lexical-yjs"),r=require("react"),n=require("@ekz/lexical-utils"),s=require("@ekz/lexical"),a=require("react-dom"),c=require("yjs"),i=require("react/jsx-runtime");function u(e){var t=Object.create(null);if(e)for(var o in e)t[o]=e[o];return t.default=e,t}var l=u(r);function d(e,t,n,a,i,u,l,d,p,_,g,M,R=o.syncCursorPositions){const O=r.useRef(!1),D=r.useCallback(()=>{const{root:t}=d;l&&t.isEmpty()&&0===t._xmlText._length&&m(e,g)},[d,e,g,l]);return r.useEffect(()=>{const{root:t}=d,r=(e,t)=>{const r=t.origin;if(r!==d){const t=r instanceof c.UndoManager;o.syncYjsChangesToLexical(d,n,e,t,R)}};t.getSharedType().observeDeep(r);const a=e.registerUpdateListener(({prevEditorState:e,editorState:t,dirtyLeaves:r,dirtyElements:a,normalizedNodes:c,tags:i})=>{i.has(s.SKIP_COLLAB_TAG)||o.syncLexicalUpdateToYjs(d,n,e,t,a,r,c,i)});return()=>{t.getSharedType().unobserveDeep(r),a()}},[d,n,e,p,a,t,R]),r.useEffect(()=>{const o=o=>{!function(e,t){if(e.update(()=>{const e=s.$getRoot();e.clear(),e.select()},{tag:s.SKIP_COLLAB_TAG}),null==t.cursors)return;const o=t.cursors;if(null==o)return;const r=t.cursorsContainer;if(null==r)return;const n=Array.from(o.values());for(let e=0;e<n.length;e++){const t=n[e].selection;if(t&&null!=t.selections){const o=t.selections;for(let t=0;t<o.length;t++)r.removeChild(o[e])}}}(e,d),p(o),a.set(t,o),O.current=!0},r=()=>{O.current=!1};return n.on("reload",o),n.on("sync",r),()=>{n.off("reload",o),n.off("sync",r)}},[d,n,e,p,a,t]),f(e,n,i,u,O,M,D),E(d,n),C(d,_)}function f(e,t,n,a,c,i,u){const l=r.useCallback(()=>t.connect(),[t]),d=r.useCallback(()=>{try{t.disconnect()}catch(e){}},[t]);r.useEffect(()=>{const r=({status:t})=>{e.dispatchCommand(o.CONNECTED_COMMAND,"connected"===t)},s=e=>{e&&!1===c.current&&u&&u()};o.initLocalState(t,n,a,document.activeElement===e.getRootElement(),i||{}),t.on("status",r),t.on("sync",s);const f=l();return()=>{!1===c.current&&(f?f.then(d):d()),t.off("sync",s),t.off("status",r)}},[e,t,n,a,c,i,u,l,d]),r.useEffect(()=>e.registerCommand(o.TOGGLE_CONNECT_COMMAND,e=>(e?(console.log("Collaboration connected!"),l()):(console.log("Collaboration disconnected!"),d()),!0),s.COMMAND_PRIORITY_EDITOR),[l,d,e]),r.useEffect(()=>{const e=()=>{try{t.awareness.setLocalState(null)}catch(e){}};return window.addEventListener("beforeunload",e),window.addEventListener("pagehide",e),()=>{window.removeEventListener("beforeunload",e),window.removeEventListener("pagehide",e)}},[t])}function E(e,t){r.useEffect(()=>{const{awareness:r}=t,n=()=>{o.syncCursorPositions(e,t)};return r.on("update",n),()=>{r.off("update",n)}},[e,t])}function C(e,t){return r.useMemo(()=>a.createPortal(i.jsx("div",{ref:t=>{e.cursorsContainer=t}}),t&&t.current||document.body),[e,t])}function p(e,t,a,c,i){r.useEffect(()=>n.mergeRegister(e.registerCommand(s.FOCUS_COMMAND,()=>(o.setLocalStateFocus(t,a,c,!0,i||{}),!1),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(s.BLUR_COMMAND,()=>(o.setLocalStateFocus(t,a,c,!1,i||{}),!1),s.COMMAND_PRIORITY_EDITOR)),[c,e,a,t,i])}function _(e,t){r.useEffect(()=>n.mergeRegister(e.registerCommand(s.UNDO_COMMAND,()=>(t.undo(),!0),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(s.REDO_COMMAND,()=>(t.redo(),!0),s.COMMAND_PRIORITY_EDITOR)));const o=r.useCallback(()=>{t.clear()},[t]);return l.useEffect(()=>{const o=()=>{e.dispatchCommand(s.CAN_UNDO_COMMAND,t.undoStack.length>0),e.dispatchCommand(s.CAN_REDO_COMMAND,t.redoStack.length>0)};return t.on("stack-item-added",o),t.on("stack-item-popped",o),t.on("stack-cleared",o),()=>{t.off("stack-item-added",o),t.off("stack-item-popped",o),t.off("stack-cleared",o)}},[e,t]),o}function m(e,t){e.update(()=>{const o=s.$getRoot();if(o.isEmpty())if(t)switch(typeof t){case"string":{const o=e.parseEditorState(t);e.setEditorState(o,{tag:s.HISTORY_MERGE_TAG});break}case"object":e.setEditorState(t,{tag:s.HISTORY_MERGE_TAG});break;case"function":e.update(()=>{s.$getRoot().isEmpty()&&t(e)},{tag:s.HISTORY_MERGE_TAG})}else{const t=s.$createParagraphNode();o.append(t);const{activeElement:r}=document;(null!==s.$getSelection()||null!==r&&r===e.getRootElement())&&t.select()}},{tag:s.HISTORY_MERGE_TAG})}function g({editor:e,id:t,provider:n,yjsDocMap:s,name:a,color:c,shouldBootstrap:i,cursorsContainerRef:u,initialEditorState:l,awarenessData:f,collabContext:E,binding:C,setDoc:m,syncCursorPositionsFn:g}){const M=d(e,t,n,s,a,c,i,C,m,u,l,f,g);return function(e,t){_(e,r.useMemo(()=>o.createUndoManager(t,t.root.getSharedType()),[t]))}(e,C),p(e,n,a,c,f),M}const M=(e,t)=>{r.useEffect(()=>(e.isCollabActive=!0,()=>{null==t._parentEditor&&(e.isCollabActive=!1)}),[e,t])};exports.CollaborationPlugin=function({id:n,providerFactory:s,shouldBootstrap:a,username:c,cursorColor:u,cursorsContainerRef:l,initialEditorState:d,excludedProperties:f,awarenessData:E,syncCursorPositionsFn:C}){const p=r.useRef(!1),_=r.useRef(!1),m=e.useCollaborationContext(c,u),{yjsDocMap:R,name:O,color:D}=m,[T]=t.useLexicalComposerContext();M(m,T);const[A,S]=r.useState(),[I,N]=r.useState();r.useEffect(()=>{if(_.current)return;_.current=!0;const e=s(n,R);return S(e),N(R.get(n)),()=>{e.disconnect()}},[n,s,R]);const[h,L]=r.useState();return r.useEffect(()=>{if(!A)return;if(p.current)return;p.current=!0;const e=o.createBinding(T,A,n,I||R.get(n),R,f);return L(e),()=>{e.root.destroy(e)}},[T,A,n,R,I,f]),A&&h?i.jsx(g,{awarenessData:E,binding:h,collabContext:m,color:D,cursorsContainerRef:l,editor:T,id:n,initialEditorState:d,name:O,provider:A,setDoc:N,shouldBootstrap:a,yjsDocMap:R,syncCursorPositionsFn:C}):i.jsx(i.Fragment,{})},exports.CollaborationPluginV2__EXPERIMENTAL=function({id:a,doc:i,provider:u,__shouldBootstrapUnsafe:l,username:d,cursorColor:g,cursorsContainerRef:R,excludedProperties:O,awarenessData:D}){const T=e.useCollaborationContext(d,g),{yjsDocMap:A,name:S,color:I}=T,[N]=t.useLexicalComposerContext();M(T,N);const h=function(e,t,a,i,u,l,d,C={}){const{awarenessData:p,excludedProperties:_,rootName:g,__shouldBootstrapUnsafe:M}=C,R=r.useMemo(()=>({current:!1}),[]),O=r.useMemo(()=>o.createBindingV2__EXPERIMENTAL(e,t,a,u,{excludedProperties:_,rootName:g}),[e,t,a,u,_,g]);r.useEffect(()=>(u.set(t,a),()=>{u.delete(t)}),[a,u,t]);const D=r.useCallback(()=>{const{root:t}=O;M&&0===t._length&&m(e)},[O,e,M]),[T,A]=r.useState();return r.useEffect(()=>{n.mergeRegister(e.registerCommand(o.CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL,()=>(A(null),o.syncYjsStateToLexicalV2__EXPERIMENTAL(O,i),!0),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(o.DIFF_VERSIONS_COMMAND__EXPERIMENTAL,({prevSnapshot:e,snapshot:t})=>(A({prevSnapshot:e,snapshot:t}),!0),s.COMMAND_PRIORITY_EDITOR))},[e,O,i]),r.useEffect(()=>{const{root:t}=O;if(T)return void o.renderSnapshot__EXPERIMENTAL(O,T.snapshot,T.prevSnapshot);const r=(e,t)=>{const r=t.origin;if(r!==O){const n=r instanceof c.UndoManager;o.syncYjsChangesToLexicalV2__EXPERIMENTAL(O,i,e,t,n)}};t.observeDeep(r);const n=e.registerUpdateListener(({prevEditorState:e,editorState:t,dirtyElements:r,normalizedNodes:n,tags:a})=>{a.has(s.SKIP_COLLAB_TAG)||o.syncLexicalUpdateToYjsV2__EXPERIMENTAL(O,i,e,t,r,n,a)});return()=>{t.unobserveDeep(r),n()}},[O,i,e,T]),f(e,i,l,d,R,p,D),E(O,i),O}(N,a,i,u,A,S,I,{__shouldBootstrapUnsafe:l,awarenessData:D,excludedProperties:O});return function(e,t){_(e,r.useMemo(()=>o.createUndoManager(t,t.root),[t]))}(N,h),p(N,u,S,I,D),C(h,R)};