@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeNode.d.ts","sourceRoot":"","sources":["../../../src/nodes/CodeNode/CodeNode.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,MAAM,EACN,OAAO,EACR,MAAM,SAAS,CAAC;AAGjB,OAAO,EAOL,WAAW,EACZ,MAAM,SAAS,CAAC;AAQjB,MAAM,MAAM,kBAAkB,GAAG,MAAM,CACrC;IACE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,EACD,qBAAqB,CACtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,sBAAsB,QAAO,MAA+B,CAAC;AAgB1E,oBAAoB;AACpB,qBAAa,QAAS,SAAQ,WAAW;IACvC,gBAAgB;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACtC,gBAAgB;IAChB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,gBAAgB;IAChB,4BAA4B,EAAE,OAAO,CAAC;IAEtC,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ;gBAI1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,CAAC,EAAE,OAAO;IAO/D,cAAc,CAAC,QAAQ,EAAE,IAAI,GAAG,IAAI;IAQpC,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAuB5C,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO;IAoD1E,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe;IAyBjD,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAmE3C,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,kBAAkB,GAAG,QAAQ;IAI/D,cAAc,CAAC,cAAc,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,GAAG,IAAI;IAO3E,UAAU,IAAI,kBAAkB;IAShC,cAAc,CACZ,SAAS,EAAE,cAAc,EACzB,gBAAgB,UAAO,GACtB,IAAI,GAAG,aAAa,GAAG,iBAAiB,GAAG,OAAO;IA4ErD,SAAS,IAAI,KAAK;IAIlB,eAAe,IAAI,OAAO;IAQ1B,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAMtD,WAAW,IAAI,MAAM,GAAG,IAAI,GAAG,SAAS;IAIxC,6BAA6B,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI;IAMzD,6BAA6B,IAAI,OAAO;IAIxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAMhD,QAAQ,IAAI,MAAM,GAAG,SAAS;CAG/B;AAED,wBAAgB,eAAe,CAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAChC,QAAQ,CAEV;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,QAAQ,CAElB"}
@@ -0,0 +1,367 @@
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 { addClassNamesToElement, isHTMLElement } from "@lexical/utils";
9
+ import { $create, $createLineBreakNode, $createParagraphNode, $createTabNode, $isTabNode, $isTextNode, ElementNode, } from "lexical";
10
+ import { $createCodeHighlightNode, $isCodeHighlightNode, } from "./CodeHighlightNode";
11
+ import { $getFirstCodeNodeOfLine } from "./FlatStructureUtils";
12
+ export const DEFAULT_CODE_LANGUAGE = "javascript";
13
+ export const getDefaultCodeLanguage = () => DEFAULT_CODE_LANGUAGE;
14
+ function hasChildDOMNodeTag(node, tagName) {
15
+ for (const child of node.childNodes) {
16
+ if (isHTMLElement(child) && child.tagName === tagName) {
17
+ return true;
18
+ }
19
+ hasChildDOMNodeTag(child, tagName);
20
+ }
21
+ return false;
22
+ }
23
+ const LANGUAGE_DATA_ATTRIBUTE = "data-language";
24
+ const HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE = "data-highlight-language";
25
+ const THEME_DATA_ATTRIBUTE = "data-theme";
26
+ /** @noInheritDoc */
27
+ export class CodeNode extends ElementNode {
28
+ static getType() {
29
+ return "code";
30
+ }
31
+ static clone(node) {
32
+ return new CodeNode(node.__language, node.__key);
33
+ }
34
+ constructor(language, key) {
35
+ super(key);
36
+ this.__language = language || undefined;
37
+ this.__isSyntaxHighlightSupported = false;
38
+ this.__theme = undefined;
39
+ }
40
+ afterCloneFrom(prevNode) {
41
+ super.afterCloneFrom(prevNode);
42
+ this.__language = prevNode.__language;
43
+ this.__theme = prevNode.__theme;
44
+ this.__isSyntaxHighlightSupported = prevNode.__isSyntaxHighlightSupported;
45
+ }
46
+ // View
47
+ createDOM(config) {
48
+ const element = document.createElement("code");
49
+ addClassNamesToElement(element, config.theme.code);
50
+ element.setAttribute("spellcheck", "false");
51
+ const language = this.getLanguage();
52
+ if (language) {
53
+ element.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language);
54
+ if (this.getIsSyntaxHighlightSupported()) {
55
+ element.setAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE, language);
56
+ }
57
+ }
58
+ const theme = this.getTheme();
59
+ if (theme) {
60
+ element.setAttribute(THEME_DATA_ATTRIBUTE, theme);
61
+ }
62
+ const style = this.getStyle();
63
+ if (style) {
64
+ element.setAttribute("style", style);
65
+ }
66
+ return element;
67
+ }
68
+ updateDOM(prevNode, dom, config) {
69
+ const language = this.__language;
70
+ const prevLanguage = prevNode.__language;
71
+ if (language) {
72
+ if (language !== prevLanguage) {
73
+ dom.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language);
74
+ }
75
+ }
76
+ else if (prevLanguage) {
77
+ dom.removeAttribute(LANGUAGE_DATA_ATTRIBUTE);
78
+ }
79
+ const isSyntaxHighlightSupported = this.__isSyntaxHighlightSupported;
80
+ const prevIsSyntaxHighlightSupported = prevNode.__isSyntaxHighlightSupported;
81
+ if (prevIsSyntaxHighlightSupported && prevLanguage) {
82
+ if (isSyntaxHighlightSupported && language) {
83
+ if (language !== prevLanguage) {
84
+ dom.setAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE, language);
85
+ }
86
+ }
87
+ else {
88
+ dom.removeAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE);
89
+ }
90
+ }
91
+ else if (isSyntaxHighlightSupported && language) {
92
+ dom.setAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE, language);
93
+ }
94
+ const theme = this.__theme;
95
+ const prevTheme = prevNode.__theme;
96
+ if (theme) {
97
+ if (theme !== prevTheme) {
98
+ dom.setAttribute(THEME_DATA_ATTRIBUTE, theme);
99
+ }
100
+ }
101
+ else if (prevTheme) {
102
+ dom.removeAttribute(THEME_DATA_ATTRIBUTE);
103
+ }
104
+ const style = this.__style;
105
+ const prevStyle = prevNode.__style;
106
+ if (style) {
107
+ if (style !== prevStyle) {
108
+ dom.setAttribute("style", style);
109
+ }
110
+ }
111
+ else if (prevStyle) {
112
+ dom.removeAttribute("style");
113
+ }
114
+ return false;
115
+ }
116
+ exportDOM(editor) {
117
+ const element = document.createElement("pre");
118
+ addClassNamesToElement(element, editor._config.theme.code);
119
+ element.setAttribute("spellcheck", "false");
120
+ const language = this.getLanguage();
121
+ if (language) {
122
+ element.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language);
123
+ if (this.getIsSyntaxHighlightSupported()) {
124
+ element.setAttribute(HIGHLIGHT_LANGUAGE_DATA_ATTRIBUTE, language);
125
+ }
126
+ }
127
+ const theme = this.getTheme();
128
+ if (theme) {
129
+ element.setAttribute(THEME_DATA_ATTRIBUTE, theme);
130
+ }
131
+ const style = this.getStyle();
132
+ if (style) {
133
+ element.setAttribute("style", style);
134
+ }
135
+ return { element };
136
+ }
137
+ static importDOM() {
138
+ return {
139
+ // Typically <pre> is used for code blocks, and <code> for inline code styles
140
+ // but if it's a multi line <code> we'll create a block. Pass through to
141
+ // inline format handled by TextNode otherwise.
142
+ code: (node) => {
143
+ const isMultiLine = node.textContent != null &&
144
+ (/\r?\n/.test(node.textContent) || hasChildDOMNodeTag(node, "BR"));
145
+ return isMultiLine
146
+ ? {
147
+ conversion: $convertPreElement,
148
+ priority: 1,
149
+ }
150
+ : null;
151
+ },
152
+ div: () => ({
153
+ conversion: $convertDivElement,
154
+ priority: 1,
155
+ }),
156
+ pre: () => ({
157
+ conversion: $convertPreElement,
158
+ priority: 0,
159
+ }),
160
+ table: (node) => {
161
+ const table = node;
162
+ // domNode is a <table> since we matched it by nodeName
163
+ if (isGitHubCodeTable(table)) {
164
+ return {
165
+ conversion: $convertTableElement,
166
+ priority: 3,
167
+ };
168
+ }
169
+ return null;
170
+ },
171
+ td: (node) => {
172
+ // element is a <td> since we matched it by nodeName
173
+ const td = node;
174
+ const table = td.closest("table");
175
+ if (isGitHubCodeCell(td) || (table && isGitHubCodeTable(table))) {
176
+ // Return a no-op if it's a table cell in a code table, but not a code line.
177
+ // Otherwise it'll fall back to the T
178
+ return {
179
+ conversion: convertCodeNoop,
180
+ priority: 3,
181
+ };
182
+ }
183
+ return null;
184
+ },
185
+ tr: (node) => {
186
+ // element is a <tr> since we matched it by nodeName
187
+ const tr = node;
188
+ const table = tr.closest("table");
189
+ if (table && isGitHubCodeTable(table)) {
190
+ return {
191
+ conversion: convertCodeNoop,
192
+ priority: 3,
193
+ };
194
+ }
195
+ return null;
196
+ },
197
+ };
198
+ }
199
+ static importJSON(serializedNode) {
200
+ return $createCodeNode().updateFromJSON(serializedNode);
201
+ }
202
+ updateFromJSON(serializedNode) {
203
+ return super
204
+ .updateFromJSON(serializedNode)
205
+ .setLanguage(serializedNode.language)
206
+ .setTheme(serializedNode.theme);
207
+ }
208
+ exportJSON() {
209
+ return Object.assign(Object.assign({}, super.exportJSON()), { language: this.getLanguage(), theme: this.getTheme() });
210
+ }
211
+ // Mutation
212
+ insertNewAfter(selection, restoreSelection = true) {
213
+ const children = this.getChildren();
214
+ const childrenLength = children.length;
215
+ if (childrenLength >= 2 &&
216
+ children[childrenLength - 1].getTextContent() === "\n" &&
217
+ children[childrenLength - 2].getTextContent() === "\n" &&
218
+ selection.isCollapsed() &&
219
+ selection.anchor.key === this.__key &&
220
+ selection.anchor.offset === childrenLength) {
221
+ children[childrenLength - 1].remove();
222
+ children[childrenLength - 2].remove();
223
+ const newElement = $createParagraphNode();
224
+ this.insertAfter(newElement, restoreSelection);
225
+ return newElement;
226
+ }
227
+ // If the selection is within the codeblock, find all leading tabs and
228
+ // spaces of the current line. Create a new line that has all those
229
+ // tabs and spaces, such that leading indentation is preserved.
230
+ const { anchor, focus } = selection;
231
+ const firstPoint = anchor.isBefore(focus) ? anchor : focus;
232
+ const firstSelectionNode = firstPoint.getNode();
233
+ if ($isTextNode(firstSelectionNode)) {
234
+ let node = $getFirstCodeNodeOfLine(firstSelectionNode);
235
+ const insertNodes = [];
236
+ // eslint-disable-next-line no-constant-condition
237
+ while (true) {
238
+ if ($isTabNode(node)) {
239
+ insertNodes.push($createTabNode());
240
+ node = node.getNextSibling();
241
+ }
242
+ else if ($isCodeHighlightNode(node)) {
243
+ let spaces = 0;
244
+ const text = node.getTextContent();
245
+ const textSize = node.getTextContentSize();
246
+ while (spaces < textSize && text[spaces] === " ") {
247
+ spaces++;
248
+ }
249
+ if (spaces !== 0) {
250
+ insertNodes.push($createCodeHighlightNode(" ".repeat(spaces)));
251
+ }
252
+ if (spaces !== textSize) {
253
+ break;
254
+ }
255
+ node = node.getNextSibling();
256
+ }
257
+ else {
258
+ break;
259
+ }
260
+ }
261
+ const split = firstSelectionNode.splitText(anchor.offset)[0];
262
+ const x = anchor.offset === 0 ? 0 : 1;
263
+ const index = split.getIndexWithinParent() + x;
264
+ const codeNode = firstSelectionNode.getParentOrThrow();
265
+ const nodesToInsert = [$createLineBreakNode(), ...insertNodes];
266
+ codeNode.splice(index, 0, nodesToInsert);
267
+ const last = insertNodes[insertNodes.length - 1];
268
+ if (last) {
269
+ last.select();
270
+ }
271
+ else if (anchor.offset === 0) {
272
+ split.selectPrevious();
273
+ }
274
+ else {
275
+ split.getNextSibling().selectNext(0, 0);
276
+ }
277
+ }
278
+ if ($isCodeNode(firstSelectionNode)) {
279
+ const { offset } = selection.anchor;
280
+ firstSelectionNode.splice(offset, 0, [$createLineBreakNode()]);
281
+ firstSelectionNode.select(offset + 1, offset + 1);
282
+ }
283
+ return null;
284
+ }
285
+ canIndent() {
286
+ return false;
287
+ }
288
+ collapseAtStart() {
289
+ const paragraph = $createParagraphNode();
290
+ const children = this.getChildren();
291
+ children.forEach((child) => paragraph.append(child));
292
+ this.replace(paragraph);
293
+ return true;
294
+ }
295
+ setLanguage(language) {
296
+ const writable = this.getWritable();
297
+ writable.__language = language || undefined;
298
+ return writable;
299
+ }
300
+ getLanguage() {
301
+ return this.getLatest().__language;
302
+ }
303
+ setIsSyntaxHighlightSupported(isSupported) {
304
+ const writable = this.getWritable();
305
+ writable.__isSyntaxHighlightSupported = isSupported;
306
+ return writable;
307
+ }
308
+ getIsSyntaxHighlightSupported() {
309
+ return this.getLatest().__isSyntaxHighlightSupported;
310
+ }
311
+ setTheme(theme) {
312
+ const writable = this.getWritable();
313
+ writable.__theme = theme || undefined;
314
+ return writable;
315
+ }
316
+ getTheme() {
317
+ return this.getLatest().__theme;
318
+ }
319
+ }
320
+ export function $createCodeNode(language, theme) {
321
+ return $create(CodeNode).setLanguage(language).setTheme(theme);
322
+ }
323
+ export function $isCodeNode(node) {
324
+ return (node === null || node === void 0 ? void 0 : node.__type) == "code";
325
+ }
326
+ function $convertPreElement(domNode) {
327
+ const language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE);
328
+ return { node: $createCodeNode(language) };
329
+ }
330
+ function $convertDivElement(domNode) {
331
+ // domNode is a <div> since we matched it by nodeName
332
+ const div = domNode;
333
+ const isCode = isCodeElement(div);
334
+ if (!isCode && !isCodeChildElement(div)) {
335
+ return {
336
+ node: null,
337
+ };
338
+ }
339
+ return {
340
+ node: isCode ? $createCodeNode() : null,
341
+ };
342
+ }
343
+ function $convertTableElement() {
344
+ return { node: $createCodeNode() };
345
+ }
346
+ function convertCodeNoop() {
347
+ return { node: null };
348
+ }
349
+ function isCodeElement(div) {
350
+ return div.style.fontFamily.match("monospace") !== null;
351
+ }
352
+ function isCodeChildElement(node) {
353
+ let parent = node.parentElement;
354
+ while (parent !== null) {
355
+ if (isCodeElement(parent)) {
356
+ return true;
357
+ }
358
+ parent = parent.parentElement;
359
+ }
360
+ return false;
361
+ }
362
+ function isGitHubCodeCell(cell) {
363
+ return cell.classList.contains("js-file-line");
364
+ }
365
+ function isGitHubCodeTable(table) {
366
+ return table.classList.contains("js-file-line-container");
367
+ }
@@ -0,0 +1,18 @@
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 type { CodeNode } from "./CodeNode";
9
+ import type { LexicalEditor, LexicalNode, NodeKey } from "lexical";
10
+ export declare function isCodeLanguageLoaded(language: string): boolean;
11
+ export declare function loadCodeLanguage(language: string, editor?: LexicalEditor, codeNodeKey?: NodeKey): Promise<void> | undefined;
12
+ export declare function isCodeThemeLoaded(theme: string): boolean;
13
+ export declare function loadCodeTheme(theme: string, editor?: LexicalEditor, codeNodeKey?: NodeKey): Promise<void> | undefined;
14
+ export declare function getCodeLanguageOptions(): [string, string][];
15
+ export declare function getCodeThemeOptions(): [string, string][];
16
+ export declare function normalizeCodeLanguage(language: string): string;
17
+ export declare function $getHighlightNodes(codeNode: CodeNode, language: string): LexicalNode[];
18
+ //# sourceMappingURL=FacadeShiki.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FacadeShiki.d.ts","sourceRoot":"","sources":["../../../src/nodes/CodeNode/FacadeShiki.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AA4BnE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,WAWpD;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,aAAa,EACtB,WAAW,CAAC,EAAE,OAAO,6BA8BtB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,WAS9C;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,aAAa,EACtB,WAAW,CAAC,EAAE,OAAO,6BAiBtB;AAED,wBAAgB,sBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAE3D;AACD,wBAAgB,mBAAmB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAExD;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU9D;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,GACf,WAAW,EAAE,CAoBf"}
@@ -0,0 +1,159 @@
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 { $isCodeNode } from "./CodeNode";
9
+ import { $createCodeHighlightNode } from "./CodeHighlightNode";
10
+ import { createHighlighterCoreSync, getTokenStyleObject, isSpecialLang, isSpecialTheme, stringifyTokenStyle, } from "@shikijs/core";
11
+ import { createJavaScriptRegexEngine } from "@shikijs/engine-javascript";
12
+ import { $createLineBreakNode, $createTabNode, $getNodeByKey } from "lexical";
13
+ import { bundledLanguagesInfo } from "shiki/langs";
14
+ import { bundledThemesInfo } from "shiki/themes";
15
+ const shiki = createHighlighterCoreSync({
16
+ engine: createJavaScriptRegexEngine(),
17
+ langs: [],
18
+ themes: [],
19
+ });
20
+ function getDiffedLanguage(language) {
21
+ const DIFF_LANGUAGE_REGEX = /^diff-([\w-]+)/i;
22
+ const diffLanguageMatch = DIFF_LANGUAGE_REGEX.exec(language);
23
+ return diffLanguageMatch ? diffLanguageMatch[1] : null;
24
+ }
25
+ export function isCodeLanguageLoaded(language) {
26
+ const diffedLanguage = getDiffedLanguage(language);
27
+ const langId = diffedLanguage || language;
28
+ // handle shiki Hard-coded languages ['ansi', '', 'plaintext', 'txt', 'text', 'plain']
29
+ if (isSpecialLang(langId)) {
30
+ return true;
31
+ }
32
+ // note: getLoadedLanguages() also returns aliases
33
+ return shiki.getLoadedLanguages().includes(langId);
34
+ }
35
+ export function loadCodeLanguage(language, editor, codeNodeKey) {
36
+ const diffedLanguage = getDiffedLanguage(language);
37
+ const langId = diffedLanguage ? diffedLanguage : language;
38
+ if (!isCodeLanguageLoaded(langId)) {
39
+ const languageInfo = bundledLanguagesInfo.find((desc) => desc.id === langId || (desc.aliases && desc.aliases.includes(langId)));
40
+ if (languageInfo) {
41
+ // in case we arrive here concurrently (not yet loaded language is loaded twice)
42
+ // shiki's synchronous checks make sure to load it only once
43
+ return shiki.loadLanguage(languageInfo.import()).then(() => {
44
+ // here we know that the language is loaded
45
+ // make sure the code is highlighed with the correct language
46
+ if (editor && codeNodeKey) {
47
+ editor.update(() => {
48
+ const codeNode = $getNodeByKey(codeNodeKey);
49
+ if ($isCodeNode(codeNode) &&
50
+ codeNode.getLanguage() === language &&
51
+ !codeNode.getIsSyntaxHighlightSupported()) {
52
+ codeNode.setIsSyntaxHighlightSupported(true);
53
+ }
54
+ });
55
+ }
56
+ });
57
+ }
58
+ }
59
+ }
60
+ export function isCodeThemeLoaded(theme) {
61
+ const themeId = theme;
62
+ // handle shiki special theme ['none']
63
+ if (isSpecialTheme(themeId)) {
64
+ return true;
65
+ }
66
+ return shiki.getLoadedThemes().includes(themeId);
67
+ }
68
+ export function loadCodeTheme(theme, editor, codeNodeKey) {
69
+ if (!isCodeThemeLoaded(theme)) {
70
+ const themeInfo = bundledThemesInfo.find((info) => info.id === theme);
71
+ if (themeInfo) {
72
+ return shiki.loadTheme(themeInfo.import()).then(() => {
73
+ if (editor && codeNodeKey) {
74
+ editor.update(() => {
75
+ const codeNode = $getNodeByKey(codeNodeKey);
76
+ if ($isCodeNode(codeNode)) {
77
+ codeNode.markDirty();
78
+ }
79
+ });
80
+ }
81
+ });
82
+ }
83
+ }
84
+ }
85
+ export function getCodeLanguageOptions() {
86
+ return bundledLanguagesInfo.map((i) => [i.id, i.name]);
87
+ }
88
+ export function getCodeThemeOptions() {
89
+ return bundledThemesInfo.map((i) => [i.id, i.displayName]);
90
+ }
91
+ export function normalizeCodeLanguage(language) {
92
+ const langId = language;
93
+ const languageInfo = bundledLanguagesInfo.find((desc) => desc.id === langId || (desc.aliases && desc.aliases.includes(langId)));
94
+ if (languageInfo) {
95
+ return languageInfo.id;
96
+ }
97
+ return language;
98
+ }
99
+ export function $getHighlightNodes(codeNode, language) {
100
+ const DIFF_LANGUAGE_REGEX = /^diff-([\w-]+)/i;
101
+ const diffLanguageMatch = DIFF_LANGUAGE_REGEX.exec(language);
102
+ const code = codeNode.getTextContent();
103
+ const tokensResult = shiki.codeToTokens(code, {
104
+ lang: diffLanguageMatch ? diffLanguageMatch[1] : language,
105
+ theme: codeNode.getTheme() || "poimandres",
106
+ });
107
+ const { tokens, bg, fg } = tokensResult;
108
+ let style = "";
109
+ if (bg) {
110
+ style += `background-color: ${bg};`;
111
+ }
112
+ if (fg) {
113
+ style += `color: ${fg};`;
114
+ }
115
+ if (codeNode.getStyle() !== style) {
116
+ codeNode.setStyle(style);
117
+ }
118
+ return mapTokensToLexicalStructure(tokens, !!diffLanguageMatch);
119
+ }
120
+ function mapTokensToLexicalStructure(tokens, diff) {
121
+ const nodes = [];
122
+ tokens.forEach((line, idx) => {
123
+ if (idx) {
124
+ nodes.push($createLineBreakNode());
125
+ }
126
+ line.forEach((token, tidx) => {
127
+ let text = token.content;
128
+ // implement diff-xxxx languages
129
+ if (diff && tidx === 0 && text.length > 0) {
130
+ const prefixes = ["+", "-", ">", "<", " "];
131
+ const prefixTypes = [
132
+ "inserted",
133
+ "deleted",
134
+ "inserted",
135
+ "deleted",
136
+ "unchanged",
137
+ ];
138
+ const prefixIndex = prefixes.indexOf(text[0]);
139
+ if (prefixIndex !== -1) {
140
+ nodes.push($createCodeHighlightNode(prefixes[prefixIndex], prefixTypes[prefixIndex]));
141
+ text = text.slice(1);
142
+ }
143
+ }
144
+ const parts = text.split("\t");
145
+ parts.forEach((part, pidx) => {
146
+ if (pidx) {
147
+ nodes.push($createTabNode());
148
+ }
149
+ if (part !== "") {
150
+ const node = $createCodeHighlightNode(part);
151
+ const style = stringifyTokenStyle(token.htmlStyle || getTokenStyleObject(token));
152
+ node.setStyle(style);
153
+ nodes.push(node);
154
+ }
155
+ });
156
+ });
157
+ });
158
+ return nodes;
159
+ }
@@ -0,0 +1,21 @@
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 type { CodeHighlightNode } from "./CodeHighlightNode";
9
+ import type { LineBreakNode, TabNode } from "lexical";
10
+ export declare function $getFirstCodeNodeOfLine(anchor: CodeHighlightNode | TabNode | LineBreakNode): CodeHighlightNode | TabNode | LineBreakNode;
11
+ export declare function $getLastCodeNodeOfLine(anchor: CodeHighlightNode | TabNode | LineBreakNode): CodeHighlightNode | TabNode | LineBreakNode;
12
+ /**
13
+ * Determines the visual writing direction of a code line.
14
+ *
15
+ * Scans the line segments (CodeHighlightNode/TabNode) from start to end
16
+ * and returns the first strong direction found ("ltr" or "rtl").
17
+ * If no strong character is found, falls back to the parent element's
18
+ * direction. Returns null if indeterminate.
19
+ */
20
+ export declare function $getCodeLineDirection(anchor: CodeHighlightNode | TabNode | LineBreakNode): "ltr" | "rtl" | null;
21
+ //# sourceMappingURL=FlatStructureUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlatStructureUtils.d.ts","sourceRoot":"","sources":["../../../src/nodes/CodeNode/FlatStructureUtils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAGV,aAAa,EAEb,OAAO,EACR,MAAM,SAAS,CAAC;AA+BjB,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,iBAAiB,GAAG,OAAO,GAAG,aAAa,GAClD,iBAAiB,GAAG,OAAO,GAAG,aAAa,CAE7C;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,GAAG,OAAO,GAAG,aAAa,GAClD,iBAAiB,GAAG,OAAO,GAAG,aAAa,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,GAAG,OAAO,GAAG,aAAa,GAClD,KAAK,GAAG,KAAK,GAAG,IAAI,CA6BtB"}
@@ -0,0 +1,85 @@
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 { $getAdjacentCaret } from "@lexical/utils";
9
+ import { $getSiblingCaret, $isElementNode, $isLineBreakNode, $isTabNode, getTextDirection, } from "lexical";
10
+ import { $isCodeHighlightNode } from "./CodeHighlightNode";
11
+ function $getLastMatchingCodeNode(anchor, direction) {
12
+ let matchingNode = anchor;
13
+ for (let caret = $getSiblingCaret(anchor, direction); caret && ($isCodeHighlightNode(caret.origin) || $isTabNode(caret.origin)); caret = $getAdjacentCaret(caret)) {
14
+ matchingNode = caret.origin;
15
+ }
16
+ return matchingNode;
17
+ }
18
+ export function $getFirstCodeNodeOfLine(anchor) {
19
+ return $getLastMatchingCodeNode(anchor, "previous");
20
+ }
21
+ export function $getLastCodeNodeOfLine(anchor) {
22
+ return $getLastMatchingCodeNode(anchor, "next");
23
+ }
24
+ /**
25
+ * Determines the visual writing direction of a code line.
26
+ *
27
+ * Scans the line segments (CodeHighlightNode/TabNode) from start to end
28
+ * and returns the first strong direction found ("ltr" or "rtl").
29
+ * If no strong character is found, falls back to the parent element's
30
+ * direction. Returns null if indeterminate.
31
+ */
32
+ export function $getCodeLineDirection(anchor) {
33
+ const start = $getFirstCodeNodeOfLine(anchor);
34
+ const end = $getLastCodeNodeOfLine(anchor);
35
+ let node = start;
36
+ while (node !== null) {
37
+ if ($isCodeHighlightNode(node)) {
38
+ const direction = getTextDirection(node.getTextContent());
39
+ if (direction !== null) {
40
+ return direction;
41
+ }
42
+ }
43
+ if (node === end) {
44
+ break;
45
+ }
46
+ node = node.getNextSibling();
47
+ }
48
+ const parent = start.getParent();
49
+ if ($isElementNode(parent)) {
50
+ const parentDirection = parent.getDirection();
51
+ if (parentDirection === "ltr" || parentDirection === "rtl") {
52
+ return parentDirection;
53
+ }
54
+ }
55
+ return null;
56
+ }
57
+ function findNextNonBlankInLine(anchor, offset) {
58
+ let node = anchor;
59
+ let nodeOffset = offset;
60
+ let nodeTextContent = anchor.getTextContent();
61
+ let nodeTextContentSize = anchor.getTextContentSize();
62
+ // eslint-disable-next-line no-constant-condition
63
+ while (true) {
64
+ if (!$isCodeHighlightNode(node) || nodeOffset === nodeTextContentSize) {
65
+ node = node.getNextSibling();
66
+ if (node === null || $isLineBreakNode(node)) {
67
+ return null;
68
+ }
69
+ if ($isCodeHighlightNode(node)) {
70
+ nodeOffset = 0;
71
+ nodeTextContent = node.getTextContent();
72
+ nodeTextContentSize = node.getTextContentSize();
73
+ }
74
+ }
75
+ if ($isCodeHighlightNode(node)) {
76
+ if (nodeTextContent[nodeOffset] !== " ") {
77
+ return {
78
+ node,
79
+ offset: nodeOffset,
80
+ };
81
+ }
82
+ nodeOffset++;
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,2 @@
1
+ export default function invariant(cond?: boolean, message?: string, ...args: string[]): asserts cond;
2
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../../src/nodes/CodeNode/invariant.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAQd"}
@@ -0,0 +1,6 @@
1
+ export default function invariant(cond, message, ...args) {
2
+ if (cond) {
3
+ return;
4
+ }
5
+ throw new Error(args.reduce((msg, arg) => msg.replace("%s", String(arg)), message || ""));
6
+ }