@scottjgilbert/lexical-blog-editor 0.1.4 → 1.0.0-beta.2

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 (313) hide show
  1. package/README.md +73 -67
  2. package/build/Editor.d.ts +8 -3
  3. package/build/Editor.d.ts.map +1 -1
  4. package/build/Editor.js +13 -8
  5. package/build/EditorExport.d.ts +4 -0
  6. package/build/EditorExport.d.ts.map +1 -0
  7. package/build/EditorExport.js +13 -0
  8. package/build/appSettings.d.ts +1 -1
  9. package/build/appSettings.js +1 -1
  10. package/build/buildHTMLConfig.d.ts +1 -1
  11. package/build/buildHTMLConfig.d.ts.map +1 -1
  12. package/build/buildHTMLConfig.js +35 -11
  13. package/build/context/FlashMessageContext.d.ts +2 -2
  14. package/build/context/FlashMessageContext.d.ts.map +1 -1
  15. package/build/context/FlashMessageContext.js +4 -3
  16. package/build/context/SharedHistoryContext.d.ts +3 -3
  17. package/build/context/SharedHistoryContext.d.ts.map +1 -1
  18. package/build/context/SharedHistoryContext.js +3 -2
  19. package/build/context/ToolbarContext.d.ts +1 -0
  20. package/build/context/ToolbarContext.d.ts.map +1 -1
  21. package/build/context/ToolbarContext.js +2 -0
  22. package/build/hooks/useModal.d.ts.map +1 -1
  23. package/build/hooks/useModal.js +1 -0
  24. package/build/hooks/useReport.d.ts +0 -7
  25. package/build/hooks/useReport.d.ts.map +1 -1
  26. package/build/hooks/useReport.js +1 -0
  27. package/build/index.css +283 -246
  28. package/build/index.d.ts +3 -3
  29. package/build/index.d.ts.map +1 -1
  30. package/build/index.js +2 -2
  31. package/build/nodes/CodeNode/CodeHighlightNode.d.ts +35 -0
  32. package/build/nodes/CodeNode/CodeHighlightNode.d.ts.map +1 -0
  33. package/build/nodes/CodeNode/CodeHighlightNode.js +88 -0
  34. package/build/nodes/CodeNode/CodeHighlighterShiki.d.ts +22 -0
  35. package/build/nodes/CodeNode/CodeHighlighterShiki.d.ts.map +1 -0
  36. package/build/nodes/CodeNode/CodeHighlighterShiki.js +644 -0
  37. package/build/nodes/CodeNode/CodeNode.d.ts +48 -0
  38. package/build/nodes/CodeNode/CodeNode.d.ts.map +1 -0
  39. package/build/nodes/CodeNode/CodeNode.js +367 -0
  40. package/build/nodes/CodeNode/FacadeShiki.d.ts +18 -0
  41. package/build/nodes/CodeNode/FacadeShiki.d.ts.map +1 -0
  42. package/build/nodes/CodeNode/FacadeShiki.js +159 -0
  43. package/build/nodes/CodeNode/FlatStructureUtils.d.ts +21 -0
  44. package/build/nodes/CodeNode/FlatStructureUtils.d.ts.map +1 -0
  45. package/build/nodes/CodeNode/FlatStructureUtils.js +85 -0
  46. package/build/nodes/CodeNode/invariant.d.ts +2 -0
  47. package/build/nodes/CodeNode/invariant.d.ts.map +1 -0
  48. package/build/nodes/CodeNode/invariant.js +6 -0
  49. package/build/nodes/DateTimeNode/DateTimeComponent.d.ts.map +1 -1
  50. package/build/nodes/DateTimeNode/DateTimeComponent.js +1 -0
  51. package/build/nodes/DateTimeNode/DateTimeNode.css +21 -0
  52. package/build/nodes/FigmaNode/FigmaNode.d.ts.map +1 -0
  53. package/build/nodes/FigmaNode/ServerFigmaNode.d.ts +21 -0
  54. package/build/nodes/FigmaNode/ServerFigmaNode.d.ts.map +1 -0
  55. package/build/nodes/FigmaNode/ServerFigmaNode.js +48 -0
  56. package/build/nodes/ImageComponent.d.ts.map +1 -1
  57. package/build/nodes/ImageComponent.js +1 -2
  58. package/build/nodes/ImageNode.d.ts +7 -7
  59. package/build/nodes/ImageNode.d.ts.map +1 -1
  60. package/build/nodes/ImageNode.js +30 -30
  61. package/build/nodes/LayoutContainerNode.d.ts +2 -2
  62. package/build/nodes/LayoutContainerNode.d.ts.map +1 -1
  63. package/build/nodes/LayoutContainerNode.js +10 -10
  64. package/build/nodes/PlaygroundNodes/PlaygroundNodes.d.ts.map +1 -0
  65. package/build/nodes/{PlaygroundNodes.js → PlaygroundNodes/PlaygroundNodes.js} +19 -21
  66. package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.d.ts +11 -0
  67. package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.d.ts.map +1 -0
  68. package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.js +65 -0
  69. package/build/nodes/TweetNode/ServerTweetNode.d.ts +20 -0
  70. package/build/nodes/TweetNode/ServerTweetNode.d.ts.map +1 -0
  71. package/build/nodes/TweetNode/ServerTweetNode.js +59 -0
  72. package/build/nodes/TweetNode/TweetNode.d.ts.map +1 -0
  73. package/build/nodes/YouTubeNode/ServerYouTubeNode.d.ts +21 -0
  74. package/build/nodes/YouTubeNode/ServerYouTubeNode.d.ts.map +1 -0
  75. package/build/nodes/YouTubeNode/ServerYouTubeNode.js +67 -0
  76. package/build/nodes/YouTubeNode/YouTubeNode.d.ts.map +1 -0
  77. package/build/plugins/ActionsPlugin/index.d.ts +0 -7
  78. package/build/plugins/ActionsPlugin/index.d.ts.map +1 -1
  79. package/build/plugins/ActionsPlugin/index.js +2 -1
  80. package/build/plugins/AutoEmbedPlugin/index.d.ts +2 -9
  81. package/build/plugins/AutoEmbedPlugin/index.d.ts.map +1 -1
  82. package/build/plugins/AutoEmbedPlugin/index.js +30 -29
  83. package/build/plugins/AutoLinkPlugin/index.d.ts +1 -1
  84. package/build/plugins/AutoLinkPlugin/index.d.ts.map +1 -1
  85. package/build/plugins/AutoLinkPlugin/index.js +3 -2
  86. package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +1 -1
  87. package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts.map +1 -1
  88. package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +7 -6
  89. package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +2 -2
  90. package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts.map +1 -1
  91. package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +25 -24
  92. package/build/plugins/CodeActionMenuPlugin/index.d.ts +2 -9
  93. package/build/plugins/CodeActionMenuPlugin/index.d.ts.map +1 -1
  94. package/build/plugins/CodeActionMenuPlugin/index.js +22 -20
  95. package/build/plugins/CodeActionMenuPlugin/utils.d.ts.map +1 -1
  96. package/build/plugins/CodeActionMenuPlugin/utils.js +3 -2
  97. package/build/plugins/CodeHighlightPrismPlugin/index.d.ts +1 -1
  98. package/build/plugins/CodeHighlightPrismPlugin/index.d.ts.map +1 -1
  99. package/build/plugins/CodeHighlightPrismPlugin/index.js +4 -10
  100. package/build/plugins/CodeHighlightShikiPlugin/index.d.ts +1 -1
  101. package/build/plugins/CodeHighlightShikiPlugin/index.d.ts.map +1 -1
  102. package/build/plugins/CodeHighlightShikiPlugin/index.js +3 -3
  103. package/build/plugins/CollapsiblePlugin/Collapsible.css +17 -1
  104. package/build/plugins/CollapsiblePlugin/index.d.ts +1 -1
  105. package/build/plugins/CollapsiblePlugin/index.d.ts.map +1 -1
  106. package/build/plugins/CollapsiblePlugin/index.js +11 -10
  107. package/build/plugins/ComponentPickerPlugin/index.d.ts.map +1 -1
  108. package/build/plugins/ComponentPickerPlugin/index.js +3 -8
  109. package/build/plugins/ContextMenuPlugin/index.d.ts +1 -1
  110. package/build/plugins/ContextMenuPlugin/index.d.ts.map +1 -1
  111. package/build/plugins/ContextMenuPlugin/index.js +15 -14
  112. package/build/plugins/DateTimePlugin/index.d.ts +2 -2
  113. package/build/plugins/DateTimePlugin/index.d.ts.map +1 -1
  114. package/build/plugins/DateTimePlugin/index.js +8 -14
  115. package/build/plugins/DragDropPastePlugin/index.d.ts +0 -7
  116. package/build/plugins/DragDropPastePlugin/index.d.ts.map +1 -1
  117. package/build/plugins/DragDropPastePlugin/index.js +12 -11
  118. package/build/plugins/DraggableBlockPlugin/index.css +6 -0
  119. package/build/plugins/DraggableBlockPlugin/index.d.ts +2 -2
  120. package/build/plugins/DraggableBlockPlugin/index.d.ts.map +1 -1
  121. package/build/plugins/DraggableBlockPlugin/index.js +23 -22
  122. package/build/plugins/EmojiPickerPlugin/index.d.ts +0 -7
  123. package/build/plugins/EmojiPickerPlugin/index.d.ts.map +1 -1
  124. package/build/plugins/EmojiPickerPlugin/index.js +1 -0
  125. package/build/plugins/EmojisPlugin/index.d.ts +1 -8
  126. package/build/plugins/EmojisPlugin/index.d.ts.map +1 -1
  127. package/build/plugins/EmojisPlugin/index.js +10 -16
  128. package/build/plugins/EquationsPlugin/index.d.ts +3 -3
  129. package/build/plugins/EquationsPlugin/index.d.ts.map +1 -1
  130. package/build/plugins/EquationsPlugin/index.js +14 -10
  131. package/build/plugins/FigmaPlugin/index.d.ts +2 -2
  132. package/build/plugins/FigmaPlugin/index.d.ts.map +1 -1
  133. package/build/plugins/FigmaPlugin/index.js +8 -14
  134. package/build/plugins/FloatingLinkEditorPlugin/index.css +11 -0
  135. package/build/plugins/FloatingLinkEditorPlugin/index.d.ts +3 -3
  136. package/build/plugins/FloatingLinkEditorPlugin/index.d.ts.map +1 -1
  137. package/build/plugins/FloatingLinkEditorPlugin/index.js +28 -27
  138. package/build/plugins/FloatingTextFormatToolbarPlugin/index.css +15 -0
  139. package/build/plugins/FloatingTextFormatToolbarPlugin/index.d.ts.map +1 -1
  140. package/build/plugins/FloatingTextFormatToolbarPlugin/index.js +2 -1
  141. package/build/plugins/ImagesPlugin/index.d.ts +3 -3
  142. package/build/plugins/ImagesPlugin/index.d.ts.map +1 -1
  143. package/build/plugins/ImagesPlugin/index.js +38 -37
  144. package/build/plugins/KeywordsPlugin/index.d.ts +1 -8
  145. package/build/plugins/KeywordsPlugin/index.d.ts.map +1 -1
  146. package/build/plugins/KeywordsPlugin/index.js +6 -12
  147. package/build/plugins/LayoutPlugin/InsertLayoutDialog.d.ts +2 -2
  148. package/build/plugins/LayoutPlugin/InsertLayoutDialog.d.ts.map +1 -1
  149. package/build/plugins/LayoutPlugin/InsertLayoutDialog.js +10 -9
  150. package/build/plugins/LayoutPlugin/LayoutPlugin.d.ts +1 -1
  151. package/build/plugins/LayoutPlugin/LayoutPlugin.d.ts.map +1 -1
  152. package/build/plugins/LayoutPlugin/LayoutPlugin.js +8 -14
  153. package/build/plugins/LinkPlugin/index.d.ts.map +1 -1
  154. package/build/plugins/LinkPlugin/index.js +1 -0
  155. package/build/plugins/MarkdownShortcutPlugin/index.d.ts.map +1 -1
  156. package/build/plugins/MarkdownShortcutPlugin/index.js +1 -0
  157. package/build/plugins/MarkdownTransformers/index.d.ts +1 -1
  158. package/build/plugins/MarkdownTransformers/index.d.ts.map +1 -1
  159. package/build/plugins/MarkdownTransformers/index.js +25 -25
  160. package/build/plugins/PasteLogPlugin/index.d.ts.map +1 -1
  161. package/build/plugins/PasteLogPlugin/index.js +1 -0
  162. package/build/plugins/ShortcutsPlugin/index.d.ts +0 -7
  163. package/build/plugins/ShortcutsPlugin/index.d.ts.map +1 -1
  164. package/build/plugins/ShortcutsPlugin/index.js +1 -0
  165. package/build/plugins/SpeechToTextPlugin/index.d.ts +2 -2
  166. package/build/plugins/SpeechToTextPlugin/index.d.ts.map +1 -1
  167. package/build/plugins/SpeechToTextPlugin/index.js +7 -11
  168. package/build/plugins/TabFocusPlugin/index.d.ts +0 -7
  169. package/build/plugins/TabFocusPlugin/index.d.ts.map +1 -1
  170. package/build/plugins/TabFocusPlugin/index.js +6 -5
  171. package/build/plugins/TableActionMenuPlugin/index.d.ts +1 -8
  172. package/build/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
  173. package/build/plugins/TableActionMenuPlugin/index.js +41 -40
  174. package/build/plugins/TableCellResizer/index.d.ts +2 -2
  175. package/build/plugins/TableCellResizer/index.d.ts.map +1 -1
  176. package/build/plugins/TableCellResizer/index.js +43 -42
  177. package/build/plugins/TableHoverActionsPlugin/index.d.ts +1 -8
  178. package/build/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  179. package/build/plugins/TableHoverActionsPlugin/index.js +19 -18
  180. package/build/plugins/TableHoverActionsV2Plugin/index.d.ts.map +1 -1
  181. package/build/plugins/TableHoverActionsV2Plugin/index.js +1 -0
  182. package/build/plugins/TablePlugin.d.ts +2 -2
  183. package/build/plugins/TablePlugin.d.ts.map +1 -1
  184. package/build/plugins/TablePlugin.js +11 -10
  185. package/build/plugins/TableScrollShadowPlugin/index.d.ts +0 -7
  186. package/build/plugins/TableScrollShadowPlugin/index.d.ts.map +1 -1
  187. package/build/plugins/TableScrollShadowPlugin/index.js +9 -8
  188. package/build/plugins/TestRecorderPlugin/index.d.ts +1 -8
  189. package/build/plugins/TestRecorderPlugin/index.d.ts.map +1 -1
  190. package/build/plugins/TestRecorderPlugin/index.js +45 -44
  191. package/build/plugins/ToolbarPlugin/fontSize.d.ts +2 -2
  192. package/build/plugins/ToolbarPlugin/fontSize.d.ts.map +1 -1
  193. package/build/plugins/ToolbarPlugin/fontSize.js +19 -18
  194. package/build/plugins/ToolbarPlugin/index.d.ts.map +1 -1
  195. package/build/plugins/ToolbarPlugin/index.js +68 -60
  196. package/build/plugins/ToolbarPlugin/languages.d.ts +14 -0
  197. package/build/plugins/ToolbarPlugin/languages.d.ts.map +1 -0
  198. package/build/plugins/ToolbarPlugin/languages.js +185 -0
  199. package/build/plugins/ToolbarPlugin/utils.d.ts +2 -2
  200. package/build/plugins/ToolbarPlugin/utils.js +21 -21
  201. package/build/plugins/TwitterPlugin/index.d.ts +2 -2
  202. package/build/plugins/TwitterPlugin/index.d.ts.map +1 -1
  203. package/build/plugins/TwitterPlugin/index.js +8 -14
  204. package/build/plugins/YouTubePlugin/index.d.ts +2 -2
  205. package/build/plugins/YouTubePlugin/index.d.ts.map +1 -1
  206. package/build/plugins/YouTubePlugin/index.js +8 -14
  207. package/build/themes/PlaygroundEditorTheme.css +301 -33
  208. package/build/themes/ViewerTheme.css +899 -0
  209. package/build/{plugins/MentionsPlugin/index.d.ts → themes/ViewerTheme.d.ts} +5 -3
  210. package/build/themes/ViewerTheme.d.ts.map +1 -0
  211. package/build/themes/ViewerTheme.js +124 -0
  212. package/build/themes/ViewerThemeComplete.css +1043 -0
  213. package/build/ui/ColorPicker.d.ts +2 -2
  214. package/build/ui/ColorPicker.d.ts.map +1 -1
  215. package/build/ui/ColorPicker.js +47 -46
  216. package/build/ui/DropDown.d.ts.map +1 -1
  217. package/build/ui/DropDown.js +1 -0
  218. package/build/ui/FlashMessage.d.ts +3 -3
  219. package/build/ui/FlashMessage.d.ts.map +1 -1
  220. package/build/ui/FlashMessage.js +3 -2
  221. package/build/ui/ImageResizer.d.ts +3 -3
  222. package/build/ui/ImageResizer.d.ts.map +1 -1
  223. package/build/ui/ImageResizer.js +20 -19
  224. package/build/ui/KatexEquationAlterer.css +3 -1
  225. package/build/ui/KatexEquationAlterer.d.ts.map +1 -1
  226. package/build/ui/KatexEquationAlterer.js +1 -0
  227. package/build/ui/KatexRenderer.d.ts.map +1 -1
  228. package/build/ui/KatexRenderer.js +1 -0
  229. package/build/ui/Modal.d.ts.map +1 -1
  230. package/build/ui/Modal.js +1 -0
  231. package/build/ui/Switch.d.ts +2 -2
  232. package/build/ui/Switch.d.ts.map +1 -1
  233. package/build/ui/Switch.js +3 -2
  234. package/build/ui/TextInput.d.ts.map +1 -1
  235. package/build/ui/TextInput.js +1 -0
  236. package/build/utils/ServerBlockWithAlignableContents.d.ts +22 -0
  237. package/build/utils/ServerBlockWithAlignableContents.d.ts.map +1 -0
  238. package/build/utils/ServerBlockWithAlignableContents.js +6 -0
  239. package/build/utils/focusUtils.d.ts.map +1 -1
  240. package/build/utils/focusUtils.js +4 -3
  241. package/build/utils/getDOMRangeRect.d.ts.map +1 -1
  242. package/build/utils/getDOMRangeRect.js +1 -0
  243. package/build/utils/setFloatingElemPosition.d.ts.map +1 -1
  244. package/build/utils/setFloatingElemPosition.js +5 -4
  245. package/build/utils/swipe.d.ts +0 -7
  246. package/build/utils/swipe.d.ts.map +1 -1
  247. package/build/utils/swipe.js +5 -11
  248. package/build/viewer/Viewer.d.ts +18 -0
  249. package/build/viewer/Viewer.d.ts.map +1 -0
  250. package/build/viewer/Viewer.js +105 -0
  251. package/build/viewer/client.d.ts +18 -0
  252. package/build/viewer/client.d.ts.map +1 -0
  253. package/build/viewer/client.js +97 -0
  254. package/build/viewer/index.d.ts +4 -0
  255. package/build/viewer/index.d.ts.map +1 -0
  256. package/build/viewer/index.js +2 -0
  257. package/package.json +58 -36
  258. package/build/collaboration.d.ts +0 -12
  259. package/build/collaboration.d.ts.map +0 -1
  260. package/build/collaboration.js +0 -32
  261. package/build/nodes/FigmaNode.d.ts.map +0 -1
  262. package/build/nodes/PageBreakNode/index.css +0 -64
  263. package/build/nodes/PageBreakNode/index.d.ts +0 -25
  264. package/build/nodes/PageBreakNode/index.d.ts.map +0 -1
  265. package/build/nodes/PageBreakNode/index.js +0 -83
  266. package/build/nodes/PlaygroundNodes.d.ts.map +0 -1
  267. package/build/nodes/PollComponent.d.ts +0 -17
  268. package/build/nodes/PollComponent.d.ts.map +0 -1
  269. package/build/nodes/PollComponent.js +0 -85
  270. package/build/nodes/PollNode.css +0 -165
  271. package/build/nodes/PollNode.d.ts +0 -51
  272. package/build/nodes/PollNode.d.ts.map +0 -1
  273. package/build/nodes/PollNode.js +0 -153
  274. package/build/nodes/StickyComponent.d.ts +0 -18
  275. package/build/nodes/StickyComponent.d.ts.map +0 -1
  276. package/build/nodes/StickyComponent.js +0 -155
  277. package/build/nodes/StickyNode.css +0 -37
  278. package/build/nodes/StickyNode.d.ts +0 -39
  279. package/build/nodes/StickyNode.d.ts.map +0 -1
  280. package/build/nodes/StickyNode.js +0 -66
  281. package/build/nodes/TweetNode.d.ts.map +0 -1
  282. package/build/nodes/YouTubeNode.d.ts.map +0 -1
  283. package/build/plugins/DocsPlugin/index.d.ts +0 -10
  284. package/build/plugins/DocsPlugin/index.d.ts.map +0 -1
  285. package/build/plugins/DocsPlugin/index.js +0 -4
  286. package/build/plugins/MaxLengthPlugin/index.d.ts +0 -11
  287. package/build/plugins/MaxLengthPlugin/index.d.ts.map +0 -1
  288. package/build/plugins/MaxLengthPlugin/index.js +0 -44
  289. package/build/plugins/MentionsPlugin/index.d.ts.map +0 -1
  290. package/build/plugins/MentionsPlugin/index.js +0 -562
  291. package/build/plugins/PageBreakPlugin/index.d.ts +0 -12
  292. package/build/plugins/PageBreakPlugin/index.d.ts.map +0 -1
  293. package/build/plugins/PageBreakPlugin/index.js +0 -34
  294. package/build/plugins/StickyPlugin/index.d.ts +0 -10
  295. package/build/plugins/StickyPlugin/index.d.ts.map +0 -1
  296. package/build/plugins/StickyPlugin/index.js +0 -19
  297. package/build/plugins/TreeViewPlugin/index.d.ts +0 -10
  298. package/build/plugins/TreeViewPlugin/index.d.ts.map +0 -1
  299. package/build/plugins/TreeViewPlugin/index.js +0 -7
  300. package/build/plugins/TypingPerfPlugin/index.d.ts +0 -10
  301. package/build/plugins/TypingPerfPlugin/index.d.ts.map +0 -1
  302. package/build/plugins/TypingPerfPlugin/index.js +0 -100
  303. package/build/plugins/VersionsPlugin/index.css +0 -57
  304. package/build/plugins/VersionsPlugin/index.d.ts +0 -14
  305. package/build/plugins/VersionsPlugin/index.d.ts.map +0 -1
  306. package/build/plugins/VersionsPlugin/index.js +0 -147
  307. /package/build/nodes/{FigmaNode.d.ts → FigmaNode/FigmaNode.d.ts} +0 -0
  308. /package/build/nodes/{FigmaNode.js → FigmaNode/FigmaNode.js} +0 -0
  309. /package/build/nodes/{PlaygroundNodes.d.ts → PlaygroundNodes/PlaygroundNodes.d.ts} +0 -0
  310. /package/build/nodes/{TweetNode.d.ts → TweetNode/TweetNode.d.ts} +0 -0
  311. /package/build/nodes/{TweetNode.js → TweetNode/TweetNode.js} +0 -0
  312. /package/build/nodes/{YouTubeNode.d.ts → YouTubeNode/YouTubeNode.d.ts} +0 -0
  313. /package/build/nodes/{YouTubeNode.js → YouTubeNode/YouTubeNode.js} +0 -0
@@ -1,100 +0,0 @@
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
- import { useEffect } from 'react';
9
- import useReport from '../../hooks/useReport';
10
- const validInputTypes = new Set([
11
- 'insertText',
12
- 'insertCompositionText',
13
- 'insertFromComposition',
14
- 'insertLineBreak',
15
- 'insertParagraph',
16
- 'deleteCompositionText',
17
- 'deleteContentBackward',
18
- 'deleteByComposition',
19
- 'deleteContent',
20
- 'deleteContentForward',
21
- 'deleteWordBackward',
22
- 'deleteWordForward',
23
- 'deleteHardLineBackward',
24
- 'deleteSoftLineBackward',
25
- 'deleteHardLineForward',
26
- 'deleteSoftLineForward',
27
- ]);
28
- export default function TypingPerfPlugin() {
29
- const report = useReport();
30
- useEffect(() => {
31
- let start = 0;
32
- let timerId;
33
- let keyPressTimerId;
34
- let log = [];
35
- let invalidatingEvent = false;
36
- const measureEventEnd = function logKeyPress() {
37
- if (keyPressTimerId != null) {
38
- if (invalidatingEvent) {
39
- invalidatingEvent = false;
40
- }
41
- else {
42
- log.push(performance.now() - start);
43
- }
44
- clearTimeout(keyPressTimerId);
45
- keyPressTimerId = null;
46
- }
47
- };
48
- const measureEventStart = function measureEvent() {
49
- if (timerId != null) {
50
- clearTimeout(timerId);
51
- timerId = null;
52
- }
53
- // We use a setTimeout(0) instead of requestAnimationFrame, due to
54
- // inconsistencies between the sequencing of rAF in different browsers.
55
- keyPressTimerId = setTimeout(measureEventEnd, 0);
56
- // Schedule a timer to report the results.
57
- timerId = setTimeout(() => {
58
- const total = log.reduce((a, b) => a + b, 0);
59
- const reportedText = 'Typing Perf: ' + Math.round((total / log.length) * 100) / 100 + 'ms';
60
- report(reportedText);
61
- log = [];
62
- }, 2000);
63
- // Make the time after we do the previous logic, so we don't measure the overhead
64
- // for it all.
65
- start = performance.now();
66
- };
67
- const beforeInputHandler = function beforeInputHandler(event) {
68
- if (!validInputTypes.has(event.inputType) || invalidatingEvent) {
69
- invalidatingEvent = false;
70
- return;
71
- }
72
- measureEventStart();
73
- };
74
- const keyDownHandler = function keyDownHandler(event) {
75
- const key = event.key;
76
- if (key === 'Backspace' || key === 'Enter') {
77
- measureEventStart();
78
- }
79
- };
80
- const pasteHandler = function pasteHandler() {
81
- invalidatingEvent = true;
82
- };
83
- const cutHandler = function cutHandler() {
84
- invalidatingEvent = true;
85
- };
86
- window.addEventListener('keydown', keyDownHandler, true);
87
- window.addEventListener('selectionchange', measureEventEnd, true);
88
- window.addEventListener('beforeinput', beforeInputHandler, true);
89
- window.addEventListener('paste', pasteHandler, true);
90
- window.addEventListener('cut', cutHandler, true);
91
- return () => {
92
- window.removeEventListener('keydown', keyDownHandler, true);
93
- window.removeEventListener('selectionchange', measureEventEnd, true);
94
- window.removeEventListener('beforeinput', beforeInputHandler, true);
95
- window.removeEventListener('paste', pasteHandler, true);
96
- window.removeEventListener('cut', cutHandler, true);
97
- };
98
- }, [report]);
99
- return null;
100
- }
@@ -1,57 +0,0 @@
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
- .VersionsPlugin_Container {
10
- display: flex;
11
- flex-direction: column;
12
- gap: 16px;
13
- min-width: 320px;
14
- }
15
-
16
- .VersionsPlugin_Header {
17
- align-items: center;
18
- display: flex;
19
- justify-content: space-between;
20
- }
21
-
22
- .VersionsPlugin_VersionList {
23
- border: 1px solid #ddd;
24
- border-radius: 4px;
25
- max-height: 300px;
26
- overflow-y: auto;
27
- }
28
-
29
- .VersionsPlugin_VersionItem {
30
- align-items: center;
31
- background-color: white;
32
- border: none;
33
- border-bottom: 1px solid #eee;
34
- cursor: pointer;
35
- display: flex;
36
- justify-content: space-between;
37
- padding: 12px 16px;
38
- width: 100%;
39
-
40
- &:disabled {
41
- color: #777;
42
- font-style: italic;
43
- cursor: default;
44
- }
45
- }
46
-
47
- .VersionsPlugin_VersionItem:hover:not(:disabled) {
48
- background-color: #f5f5f5;
49
- }
50
-
51
- .VersionsPlugin_VersionItem--selected {
52
- background-color: #e3f2fd;
53
- }
54
-
55
- .VersionsPlugin_CompareButton {
56
- align-self: center;
57
- }
@@ -1,14 +0,0 @@
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
- import './index.css';
9
- import { LexicalCommand } from 'lexical';
10
- export declare const SHOW_VERSIONS_COMMAND: LexicalCommand<void>;
11
- export declare function VersionsPlugin({ id }: {
12
- id: string;
13
- }): import("react/jsx-runtime").JSX.Element | null;
14
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/VersionsPlugin/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,aAAa,CAAC;AAUrB,OAAO,EAKL,cAAc,EAEf,MAAM,SAAS,CAAC;AA8BjB,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,IAAI,CAEtD,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAAC,EAAE,EAAC,EAAE;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,kDAwJhD"}
@@ -1,147 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- */
9
- import './index.css';
10
- import { useCollaborationContext } from '@lexical/react/LexicalCollaborationContext';
11
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
12
- import { mergeRegister } from '@lexical/utils';
13
- import { $getYChangeState, CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, DIFF_VERSIONS_COMMAND__EXPERIMENTAL, } from '@lexical/yjs';
14
- import { $getNodeByKeyOrThrow, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, createCommand, TextNode, } from 'lexical';
15
- import { useCallback, useEffect, useState } from 'react';
16
- import { PermanentUserData, snapshot as createSnapshot, XmlElement, } from 'yjs';
17
- import Button from '../../ui/Button';
18
- import Modal from '../../ui/Modal';
19
- const COLORS = [
20
- '#4a90e288',
21
- '#bd10e088',
22
- '#d0021b88',
23
- '#8b572a88',
24
- '#41750588',
25
- '#f5a62388',
26
- ];
27
- export const SHOW_VERSIONS_COMMAND = createCommand('SHOW_VERSIONS_COMMAND');
28
- export function VersionsPlugin({ id }) {
29
- const [editor] = useLexicalComposerContext();
30
- const { name: username, yjsDocMap } = useCollaborationContext();
31
- const yDoc = yjsDocMap.get(id);
32
- const [isDiffMode, setIsDiffMode] = useState(false);
33
- const [showModal, setShowModal] = useState(false);
34
- const [versions, setVersions] = useState([]);
35
- const [pudInitialised, setPudInitialised] = useState(false);
36
- useEffect(() => mergeRegister(editor.registerCommand(SHOW_VERSIONS_COMMAND, () => {
37
- setShowModal(true);
38
- return false;
39
- }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DIFF_VERSIONS_COMMAND__EXPERIMENTAL, () => {
40
- editor.setEditable(false);
41
- setIsDiffMode(true);
42
- return false;
43
- }, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, () => {
44
- editor.setEditable(true);
45
- setIsDiffMode(false);
46
- return false;
47
- }, COMMAND_PRIORITY_CRITICAL), editor.registerEditableListener((isEditable) => {
48
- if (isEditable && isDiffMode) {
49
- editor.dispatchCommand(CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, undefined);
50
- }
51
- })), [editor, isDiffMode]);
52
- useEffect(() => {
53
- if (pudInitialised || !yDoc) {
54
- return;
55
- }
56
- const root = yDoc.get('root-v2', XmlElement);
57
- const handleChange = (_events, transaction) => {
58
- if (transaction.local) {
59
- // User's made a local change. Register PUD mapping.
60
- const permanentUserData = new PermanentUserData(yDoc);
61
- permanentUserData.setUserMapping(yDoc, yDoc.clientID, username);
62
- setPudInitialised(true);
63
- }
64
- };
65
- root.observeDeep(handleChange);
66
- return () => root.unobserveDeep(handleChange);
67
- }, [yDoc, username, pudInitialised]);
68
- useEffect(() => {
69
- if (!isDiffMode) {
70
- return;
71
- }
72
- return editor.registerMutationListener(TextNode, (nodes) => {
73
- const userToColor = new Map();
74
- const getUserColor = (user) => {
75
- if (userToColor.has(user)) {
76
- return userToColor.get(user);
77
- }
78
- const color = COLORS[userToColor.size % COLORS.length];
79
- userToColor.set(user, color);
80
- return color;
81
- };
82
- editor.getEditorState().read(() => {
83
- for (const [nodeKey, mutation] of nodes.entries()) {
84
- if (mutation === 'destroyed') {
85
- continue;
86
- }
87
- const node = $getNodeByKeyOrThrow(nodeKey);
88
- const ychange = $getYChangeState(node);
89
- const element = editor.getElementByKey(nodeKey);
90
- if (!ychange || !element) {
91
- continue;
92
- }
93
- const { type, user: changeUser } = ychange;
94
- if (!changeUser) {
95
- continue;
96
- }
97
- const color = getUserColor(changeUser);
98
- switch (type) {
99
- case 'removed':
100
- element.style.color = color;
101
- element.style.textDecoration = 'line-through';
102
- break;
103
- case 'added':
104
- element.style.backgroundColor = color;
105
- break;
106
- default:
107
- // no change
108
- }
109
- }
110
- });
111
- }, { skipInitialization: true });
112
- }, [editor, isDiffMode]);
113
- const handleAddVersion = useCallback(() => {
114
- if (!yDoc) {
115
- return;
116
- }
117
- const now = Date.now();
118
- setVersions((prevVersions) => [
119
- ...prevVersions,
120
- {
121
- name: `Snapshot ${new Date(now).toLocaleString()}`,
122
- snapshot: createSnapshot(yDoc),
123
- timestamp: now,
124
- },
125
- ]);
126
- }, [setVersions, yDoc]);
127
- if (!showModal) {
128
- return null;
129
- }
130
- return (_jsx(VersionsModal, { versions: versions, isDiffMode: isDiffMode, onAddVersion: handleAddVersion, onClose: () => setShowModal(false) }));
131
- }
132
- function VersionsModal({ versions, isDiffMode, onAddVersion, onClose, }) {
133
- const [editor] = useLexicalComposerContext();
134
- const [selectedVersion, setSelectedVersion] = useState(null);
135
- return (_jsx(Modal, { onClose: onClose, title: "Version History", children: _jsxs("div", { className: "VersionsPlugin_Container", children: [_jsxs("div", { className: "VersionsPlugin_Header", children: [_jsx(Button, { onClick: onAddVersion, children: "+ Add snapshot" }), isDiffMode && (_jsx(Button, { onClick: () => {
136
- editor.dispatchCommand(CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, undefined);
137
- onClose();
138
- }, children: "Exit compare view" }))] }), _jsx("div", { className: "VersionsPlugin_VersionList", children: versions.length === 0 ? (_jsx("button", { className: "VersionsPlugin_VersionItem", disabled: true, children: "Add a snapshot to get started" })) : (versions.map((version, idx) => {
139
- const isSelected = selectedVersion === idx;
140
- return (_jsxs("button", { onClick: () => setSelectedVersion(idx), className: `VersionsPlugin_VersionItem ${isSelected ? 'VersionsPlugin_VersionItem--selected' : ''}`, children: ["Snapshot at ", new Date(version.timestamp).toLocaleString()] }, version.name));
141
- })) }), _jsx(Button, { onClick: () => {
142
- editor.dispatchCommand(DIFF_VERSIONS_COMMAND__EXPERIMENTAL, {
143
- prevSnapshot: versions[selectedVersion].snapshot,
144
- });
145
- onClose();
146
- }, disabled: selectedVersion === null, className: "VersionsPlugin_CompareButton", children: "Show changes since selected version" })] }) }));
147
- }