@datalayer/jupyter-lexical 1.0.7 → 1.0.9

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 (358) hide show
  1. package/lib/autoindent/AutoIndentEngine.d.ts +111 -0
  2. package/lib/autoindent/AutoIndentEngine.js +234 -0
  3. package/lib/autoindent/AutoIndentEngine.js.map +1 -0
  4. package/lib/autoindent/LanguageIndentRegistry.d.ts +102 -0
  5. package/lib/autoindent/LanguageIndentRegistry.js +200 -0
  6. package/lib/autoindent/LanguageIndentRegistry.js.map +1 -0
  7. package/lib/autoindent/__tests__/AutoIndentEngine.test.d.ts +1 -0
  8. package/lib/autoindent/__tests__/AutoIndentEngine.test.js +422 -0
  9. package/lib/autoindent/__tests__/AutoIndentEngine.test.js.map +1 -0
  10. package/lib/autoindent/index.d.ts +13 -0
  11. package/lib/autoindent/index.js +20 -0
  12. package/lib/autoindent/index.js.map +1 -0
  13. package/lib/autoindent/languages/javascript.d.ts +30 -0
  14. package/lib/autoindent/languages/javascript.js +150 -0
  15. package/lib/autoindent/languages/javascript.js.map +1 -0
  16. package/lib/autoindent/languages/python.d.ts +30 -0
  17. package/lib/autoindent/languages/python.js +102 -0
  18. package/lib/autoindent/languages/python.js.map +1 -0
  19. package/lib/autoindent/types.d.ts +125 -0
  20. package/lib/autoindent/types.js +7 -0
  21. package/lib/autoindent/types.js.map +1 -0
  22. package/lib/components/Button.js +1 -1
  23. package/lib/components/ColorPicker.d.ts +13 -0
  24. package/lib/components/ColorPicker.js +219 -0
  25. package/lib/components/ColorPicker.js.map +1 -0
  26. package/lib/components/Commenting.d.ts +15 -11
  27. package/lib/components/Commenting.js +80 -232
  28. package/lib/components/Commenting.js.map +1 -1
  29. package/lib/components/CopyButton.js +1 -1
  30. package/lib/components/ExcalidrawComponent.d.ts +8 -0
  31. package/lib/components/ExcalidrawComponent.js +111 -0
  32. package/lib/components/ExcalidrawComponent.js.map +1 -0
  33. package/lib/components/ExcalidrawImage.d.ts +49 -0
  34. package/lib/components/ExcalidrawImage.js +118 -0
  35. package/lib/components/ExcalidrawImage.js.map +1 -0
  36. package/lib/components/ExcalidrawModal.d.ts +41 -0
  37. package/lib/components/ExcalidrawModal.js +105 -0
  38. package/lib/components/ExcalidrawModal.js.map +1 -0
  39. package/lib/components/InsertEquationDialog.js +2 -2
  40. package/lib/components/InsertImageDialog.js +4 -4
  41. package/lib/components/KatexEquationAlterer.js +2 -2
  42. package/lib/components/TableInsertModal.d.ts +6 -0
  43. package/lib/components/TableInsertModal.js +34 -0
  44. package/lib/components/TableInsertModal.js.map +1 -0
  45. package/lib/components/index.js +16 -16
  46. package/lib/context/CommentsContext.d.ts +11 -0
  47. package/lib/context/CommentsContext.js +21 -0
  48. package/lib/context/CommentsContext.js.map +1 -0
  49. package/lib/context/EmbedHandlersContext.d.ts +33 -0
  50. package/lib/context/EmbedHandlersContext.js +33 -0
  51. package/lib/context/EmbedHandlersContext.js.map +1 -0
  52. package/lib/context/LexicalConfigContext.d.ts +3 -2
  53. package/lib/context/LexicalConfigContext.js.map +1 -1
  54. package/lib/context/SettingsContext.js +2 -2
  55. package/lib/context/SettingsContext.js.map +1 -1
  56. package/lib/context/ThemeContext.d.ts +24 -0
  57. package/lib/context/ThemeContext.js +42 -0
  58. package/lib/context/ThemeContext.js.map +1 -0
  59. package/lib/context/index.d.ts +3 -0
  60. package/lib/context/index.js +7 -4
  61. package/lib/context/index.js.map +1 -1
  62. package/lib/convert/LexicalToNbformat.js +6 -6
  63. package/lib/convert/NbformatToLexical.js +3 -3
  64. package/lib/convert/index.js +2 -2
  65. package/lib/convert/markdown/MarkdownExport.js +1 -1
  66. package/lib/convert/markdown/MarkdownImport.js +2 -2
  67. package/lib/convert/markdown/MarkdownShortcuts.js +3 -3
  68. package/lib/convert/markdown/MarkdownTransformers.js +1 -1
  69. package/lib/convert/markdown/convertToMarkdown.js +1 -1
  70. package/lib/convert/markdown/index.js +4 -4
  71. package/lib/convert/markdown/utils.js +1 -1
  72. package/lib/convert/transformers/MarkdownTransformers.js +5 -4
  73. package/lib/convert/transformers/MarkdownTransformers.js.map +1 -1
  74. package/lib/editor/Editor.js +28 -14
  75. package/lib/editor/Editor.js.map +1 -1
  76. package/lib/editor/index.js +1 -1
  77. package/lib/examples/AppNbformat.js +10 -5
  78. package/lib/examples/AppNbformat.js.map +1 -1
  79. package/lib/examples/AppSimple.js +18 -9
  80. package/lib/examples/AppSimple.js.map +1 -1
  81. package/lib/examples/ManualKernelControl.js +7 -2
  82. package/lib/examples/ManualKernelControl.js.map +1 -1
  83. package/lib/examples/content/Example.lexical.json +2042 -101
  84. package/lib/examples/index.d.ts +1 -0
  85. package/lib/examples/index.js +5 -3
  86. package/lib/examples/index.js.map +1 -1
  87. package/lib/examples/setup-prism.d.ts +14 -0
  88. package/lib/examples/setup-prism.js +27 -0
  89. package/lib/examples/setup-prism.js.map +1 -0
  90. package/lib/hooks/index.js +3 -3
  91. package/lib/hooks/useLayoutEffect.js +1 -1
  92. package/lib/hooks/useModal.js +1 -1
  93. package/lib/images/icons/plus.svg +1 -0
  94. package/lib/index.d.ts +1 -0
  95. package/lib/index.js +11 -10
  96. package/lib/index.js.map +1 -1
  97. package/lib/nodes/CommentThreadNode.d.ts +35 -0
  98. package/lib/nodes/CommentThreadNode.js +86 -0
  99. package/lib/nodes/CommentThreadNode.js.map +1 -0
  100. package/lib/nodes/CounterComponent.js +1 -1
  101. package/lib/nodes/CounterNode.js +2 -2
  102. package/lib/nodes/EquationNode.js +2 -2
  103. package/lib/nodes/ExcalidrawNode.d.ts +32 -0
  104. package/lib/nodes/ExcalidrawNode.js +118 -0
  105. package/lib/nodes/ExcalidrawNode.js.map +1 -0
  106. package/lib/nodes/ImageNode.js +4 -4
  107. package/lib/nodes/InlineCompletionNode.js +0 -2
  108. package/lib/nodes/InlineCompletionNode.js.map +1 -1
  109. package/lib/nodes/JupyterInputHighlightNode.js +15 -0
  110. package/lib/nodes/JupyterInputHighlightNode.js.map +1 -1
  111. package/lib/nodes/JupyterInputHighlighter.d.ts +0 -11
  112. package/lib/nodes/JupyterInputHighlighter.js +8 -15
  113. package/lib/nodes/JupyterInputHighlighter.js.map +1 -1
  114. package/lib/nodes/JupyterInputNode.d.ts +0 -11
  115. package/lib/nodes/JupyterInputNode.js +4 -14
  116. package/lib/nodes/JupyterInputNode.js.map +1 -1
  117. package/lib/nodes/JupyterOutputNode.js +18 -12
  118. package/lib/nodes/JupyterOutputNode.js.map +1 -1
  119. package/lib/nodes/JupyterOutputNodeUtils.js +1 -1
  120. package/lib/nodes/YouTubeNode.js +65 -1
  121. package/lib/nodes/YouTubeNode.js.map +1 -1
  122. package/lib/nodes/index.d.ts +2 -0
  123. package/lib/nodes/index.js +12 -10
  124. package/lib/nodes/index.js.map +1 -1
  125. package/lib/nodes/jupyterUtils.d.ts +3 -3
  126. package/lib/nodes/jupyterUtils.js +6 -4
  127. package/lib/nodes/jupyterUtils.js.map +1 -1
  128. package/lib/plugins/AutoEmbedPlugin.js +4 -4
  129. package/lib/plugins/AutoIndentPlugin.d.ts +23 -0
  130. package/lib/plugins/AutoIndentPlugin.js +385 -0
  131. package/lib/plugins/AutoIndentPlugin.js.map +1 -0
  132. package/lib/plugins/AutoLinkPlugin.js +25 -12
  133. package/lib/plugins/AutoLinkPlugin.js.map +1 -1
  134. package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +7 -0
  135. package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +48 -0
  136. package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.js.map +1 -0
  137. package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +9 -0
  138. package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +116 -0
  139. package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js.map +1 -0
  140. package/lib/plugins/CodeActionMenuPlugin/index.d.ts +4 -0
  141. package/lib/plugins/CodeActionMenuPlugin/index.js +104 -0
  142. package/lib/plugins/CodeActionMenuPlugin/index.js.map +1 -0
  143. package/lib/plugins/CodeActionMenuPlugin/utils.d.ts +1 -0
  144. package/lib/plugins/CodeActionMenuPlugin/utils.js +24 -0
  145. package/lib/plugins/CodeActionMenuPlugin/utils.js.map +1 -0
  146. package/lib/plugins/CodeActionMenuPlugin.js +3 -3
  147. package/lib/plugins/CodeHighlightPlugin.d.ts +5 -0
  148. package/lib/plugins/CodeHighlightPlugin.js +97 -0
  149. package/lib/plugins/CodeHighlightPlugin.js.map +1 -0
  150. package/lib/plugins/CollapsiblePlugin/Collapsible.css +115 -0
  151. package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.d.ts +25 -0
  152. package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.js +137 -0
  153. package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.js.map +1 -0
  154. package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.d.ts +16 -0
  155. package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.js +85 -0
  156. package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.js.map +1 -0
  157. package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.d.ts +16 -0
  158. package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.js +87 -0
  159. package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.js.map +1 -0
  160. package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.d.ts +2 -0
  161. package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.js +14 -0
  162. package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.js.map +1 -0
  163. package/lib/plugins/CollapsiblePlugin/index.d.ts +7 -0
  164. package/lib/plugins/CollapsiblePlugin/index.js +139 -0
  165. package/lib/plugins/CollapsiblePlugin/index.js.map +1 -0
  166. package/lib/plugins/CommentPlugin.d.ts +3 -1
  167. package/lib/plugins/CommentPlugin.js +16 -20
  168. package/lib/plugins/CommentPlugin.js.map +1 -1
  169. package/lib/plugins/ComponentPickerMenuPlugin.js +41 -14
  170. package/lib/plugins/ComponentPickerMenuPlugin.js.map +1 -1
  171. package/lib/plugins/DraggableBlockPlugin.js +1 -1
  172. package/lib/plugins/EquationsPlugin.js +2 -2
  173. package/lib/plugins/ExcalidrawPlugin.d.ts +3 -0
  174. package/lib/plugins/ExcalidrawPlugin.js +45 -0
  175. package/lib/plugins/ExcalidrawPlugin.js.map +1 -0
  176. package/lib/plugins/FloatingLinkEditorPlugin/index.css +156 -0
  177. package/lib/plugins/FloatingLinkEditorPlugin/index.d.ts +15 -0
  178. package/lib/plugins/FloatingLinkEditorPlugin/index.js +317 -0
  179. package/lib/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
  180. package/lib/plugins/FloatingTextFormatToolbarPlugin.d.ts +2 -1
  181. package/lib/plugins/FloatingTextFormatToolbarPlugin.js +13 -11
  182. package/lib/plugins/FloatingTextFormatToolbarPlugin.js.map +1 -1
  183. package/lib/plugins/HorizontalRulePlugin.js.map +1 -1
  184. package/lib/plugins/ImagesPlugin.js +6 -6
  185. package/lib/plugins/InlineCompletionConfig.d.ts +135 -0
  186. package/lib/plugins/InlineCompletionConfig.js +94 -0
  187. package/lib/plugins/InlineCompletionConfig.js.map +1 -0
  188. package/lib/plugins/InlineCompletionContextExtractor.d.ts +50 -0
  189. package/lib/plugins/InlineCompletionContextExtractor.js +171 -0
  190. package/lib/plugins/InlineCompletionContextExtractor.js.map +1 -0
  191. package/lib/plugins/JupyterCellPlugin.js +1 -1
  192. package/lib/plugins/JupyterInputOutputPlugin.js +28 -22
  193. package/lib/plugins/JupyterInputOutputPlugin.js.map +1 -1
  194. package/lib/plugins/LSPCompletionMenu.d.ts +24 -0
  195. package/lib/plugins/LSPCompletionMenu.js +194 -0
  196. package/lib/plugins/LSPCompletionMenu.js.map +1 -0
  197. package/lib/plugins/LSPDocumentSyncPlugin.d.ts +37 -0
  198. package/lib/plugins/LSPDocumentSyncPlugin.js +133 -0
  199. package/lib/plugins/LSPDocumentSyncPlugin.js.map +1 -0
  200. package/lib/plugins/LSPTabCompletionPlugin.d.ts +22 -0
  201. package/lib/plugins/LSPTabCompletionPlugin.js +388 -0
  202. package/lib/plugins/LSPTabCompletionPlugin.js.map +1 -0
  203. package/lib/plugins/LSPTabCompletionProvider.d.ts +48 -0
  204. package/lib/plugins/LSPTabCompletionProvider.js +118 -0
  205. package/lib/plugins/LSPTabCompletionProvider.js.map +1 -0
  206. package/lib/plugins/LexicalInlineCompletionPlugin.d.ts +19 -2
  207. package/lib/plugins/LexicalInlineCompletionPlugin.js +374 -186
  208. package/lib/plugins/LexicalInlineCompletionPlugin.js.map +1 -1
  209. package/lib/plugins/LexicalStatePlugin.js +3 -3
  210. package/lib/plugins/MarkdownPlugin.js +1 -1
  211. package/lib/plugins/NbformatContentPlugin.js +1 -1
  212. package/lib/plugins/ShortcutsPlugin/index.js +5 -5
  213. package/lib/plugins/TableActionMenuPlugin/index.d.ts +5 -0
  214. package/lib/plugins/TableActionMenuPlugin/index.js +503 -0
  215. package/lib/plugins/TableActionMenuPlugin/index.js.map +1 -0
  216. package/lib/plugins/TableCellResizer/index.css +26 -0
  217. package/lib/plugins/TableCellResizer/index.d.ts +2 -0
  218. package/lib/plugins/TableCellResizer/index.js +298 -0
  219. package/lib/plugins/TableCellResizer/index.js.map +1 -0
  220. package/lib/plugins/TableHoverActionsPlugin/index.d.ts +4 -0
  221. package/lib/plugins/TableHoverActionsPlugin/index.js +198 -0
  222. package/lib/plugins/TableHoverActionsPlugin/index.js.map +1 -0
  223. package/lib/plugins/TableHoverActionsV2Plugin/index.css +83 -0
  224. package/lib/plugins/TableHoverActionsV2Plugin/index.d.ts +4 -0
  225. package/lib/plugins/TableHoverActionsV2Plugin/index.js +306 -0
  226. package/lib/plugins/TableHoverActionsV2Plugin/index.js.map +1 -0
  227. package/lib/plugins/TablePlugin.d.ts +4 -0
  228. package/lib/plugins/TablePlugin.js +41 -0
  229. package/lib/plugins/TablePlugin.js.map +1 -0
  230. package/lib/plugins/TableScrollShadowPlugin/index.d.ts +1 -0
  231. package/lib/plugins/TableScrollShadowPlugin/index.js +120 -0
  232. package/lib/plugins/TableScrollShadowPlugin/index.js.map +1 -0
  233. package/lib/plugins/ToolbarPlugin/fontSize.js +3 -3
  234. package/lib/plugins/ToolbarPlugin/index.js +30 -12
  235. package/lib/plugins/ToolbarPlugin/index.js.map +1 -1
  236. package/lib/plugins/ToolbarPlugin/utils.js +1 -1
  237. package/lib/plugins/YouTubePlugin.js +1 -1
  238. package/lib/plugins/index.d.ts +17 -1
  239. package/lib/plugins/index.js +38 -22
  240. package/lib/plugins/index.js.map +1 -1
  241. package/lib/plugins/lspTypes.d.ts +138 -0
  242. package/lib/plugins/lspTypes.js +38 -0
  243. package/lib/plugins/lspTypes.js.map +1 -0
  244. package/lib/state/LexicalAdapter.d.ts +73 -4
  245. package/lib/state/LexicalAdapter.js +883 -20
  246. package/lib/state/LexicalAdapter.js.map +1 -1
  247. package/lib/state/LexicalState.d.ts +20 -6
  248. package/lib/state/LexicalState.js +66 -8
  249. package/lib/state/LexicalState.js.map +1 -1
  250. package/lib/state/index.js +2 -2
  251. package/lib/themes/CommentEditorTheme.js +1 -1
  252. package/lib/themes/index.js +2 -2
  253. package/lib/tools/core/executor.js +1 -11
  254. package/lib/tools/core/executor.js.map +1 -1
  255. package/lib/tools/core/index.d.ts +2 -2
  256. package/lib/tools/core/index.js +11 -11
  257. package/lib/tools/core/index.js.map +1 -1
  258. package/lib/tools/core/interfaces.d.ts +1 -1
  259. package/lib/tools/core/types.d.ts +3 -5
  260. package/lib/tools/definitions/{deleteBlock.d.ts → deleteBlocks.d.ts} +2 -2
  261. package/lib/tools/definitions/{deleteBlock.js → deleteBlocks.js} +9 -9
  262. package/lib/tools/definitions/deleteBlocks.js.map +1 -0
  263. package/lib/tools/definitions/executeCode.js +2 -2
  264. package/lib/tools/definitions/executeCode.js.map +1 -1
  265. package/lib/tools/definitions/index.d.ts +1 -1
  266. package/lib/tools/definitions/index.js +9 -9
  267. package/lib/tools/definitions/index.js.map +1 -1
  268. package/lib/tools/definitions/insertBlock.d.ts +2 -2
  269. package/lib/tools/definitions/insertBlock.js +5 -5
  270. package/lib/tools/definitions/insertBlock.js.map +1 -1
  271. package/lib/tools/definitions/listAvailableBlocks.js +7 -7
  272. package/lib/tools/definitions/listAvailableBlocks.js.map +1 -1
  273. package/lib/tools/definitions/readAllBlocks.js +3 -3
  274. package/lib/tools/definitions/readAllBlocks.js.map +1 -1
  275. package/lib/tools/definitions/readBlock.js +3 -3
  276. package/lib/tools/definitions/readBlock.js.map +1 -1
  277. package/lib/tools/definitions/runAllBlocks.js +2 -2
  278. package/lib/tools/definitions/runAllBlocks.js.map +1 -1
  279. package/lib/tools/definitions/runBlock.js +2 -2
  280. package/lib/tools/definitions/runBlock.js.map +1 -1
  281. package/lib/tools/definitions/updateBlock.d.ts +1 -1
  282. package/lib/tools/definitions/updateBlock.js +6 -6
  283. package/lib/tools/definitions/updateBlock.js.map +1 -1
  284. package/lib/tools/index.d.ts +1 -1
  285. package/lib/tools/index.js +33 -33
  286. package/lib/tools/index.js.map +1 -1
  287. package/lib/tools/operations/deleteBlocks.d.ts +41 -0
  288. package/lib/tools/operations/deleteBlocks.js +70 -0
  289. package/lib/tools/operations/deleteBlocks.js.map +1 -0
  290. package/lib/tools/operations/executeCode.js +2 -13
  291. package/lib/tools/operations/executeCode.js.map +1 -1
  292. package/lib/tools/operations/insertBlock.d.ts +4 -2
  293. package/lib/tools/operations/insertBlock.js +8 -7
  294. package/lib/tools/operations/insertBlock.js.map +1 -1
  295. package/lib/tools/operations/listAvailableBlocks.d.ts +4 -8
  296. package/lib/tools/operations/listAvailableBlocks.js +134 -43
  297. package/lib/tools/operations/listAvailableBlocks.js.map +1 -1
  298. package/lib/tools/operations/readAllBlocks.js +3 -2
  299. package/lib/tools/operations/readAllBlocks.js.map +1 -1
  300. package/lib/tools/operations/readBlock.js +3 -3
  301. package/lib/tools/operations/readBlock.js.map +1 -1
  302. package/lib/tools/operations/runAllBlocks.js +2 -2
  303. package/lib/tools/operations/runAllBlocks.js.map +1 -1
  304. package/lib/tools/operations/runBlock.js +3 -3
  305. package/lib/tools/operations/runBlock.js.map +1 -1
  306. package/lib/tools/operations/updateBlock.d.ts +2 -2
  307. package/lib/tools/operations/updateBlock.js +9 -11
  308. package/lib/tools/operations/updateBlock.js.map +1 -1
  309. package/lib/tools/schemas/deleteBlocks.d.ts +10 -0
  310. package/lib/tools/schemas/{deleteBlock.js → deleteBlocks.js} +4 -4
  311. package/lib/tools/schemas/deleteBlocks.js.map +1 -0
  312. package/lib/tools/schemas/index.d.ts +1 -1
  313. package/lib/tools/schemas/index.js +9 -9
  314. package/lib/tools/schemas/index.js.map +1 -1
  315. package/lib/tools/schemas/insertBlock.d.ts +1 -1
  316. package/lib/tools/schemas/insertBlock.js +25 -5
  317. package/lib/tools/schemas/insertBlock.js.map +1 -1
  318. package/lib/tools/schemas/listAvailableBlocks.d.ts +1 -19
  319. package/lib/tools/schemas/listAvailableBlocks.js +6 -12
  320. package/lib/tools/schemas/listAvailableBlocks.js.map +1 -1
  321. package/lib/tools/schemas/updateBlock.d.ts +1 -1
  322. package/lib/tools/schemas/updateBlock.js +24 -4
  323. package/lib/tools/schemas/updateBlock.js.map +1 -1
  324. package/lib/tools/utils/blocks.d.ts +11 -0
  325. package/lib/tools/utils/blocks.js +394 -26
  326. package/lib/tools/utils/blocks.js.map +1 -1
  327. package/lib/tools/utils/index.js +1 -1
  328. package/lib/utils/getThemeSelector.d.ts +2 -0
  329. package/lib/utils/getThemeSelector.js +16 -0
  330. package/lib/utils/getThemeSelector.js.map +1 -0
  331. package/lib/utils/index.d.ts +2 -0
  332. package/lib/utils/index.js +12 -10
  333. package/lib/utils/index.js.map +1 -1
  334. package/lib/utils/invariant.d.ts +1 -1
  335. package/lib/utils/invariant.js +1 -1
  336. package/lib/utils/invariant.js.map +1 -1
  337. package/lib/utils/rect.js +1 -1
  338. package/lib/utils/setFloatingElemPositionForLinkEditor.d.ts +1 -0
  339. package/lib/utils/setFloatingElemPositionForLinkEditor.js +42 -0
  340. package/lib/utils/setFloatingElemPositionForLinkEditor.js.map +1 -0
  341. package/package.json +14 -4
  342. package/style/lexical/CodeActionMenuPlugin.css +15 -0
  343. package/style/lexical/ColorPicker.css +87 -0
  344. package/style/lexical/CommentPlugin.css +44 -61
  345. package/style/lexical/Editor.css +2 -122
  346. package/style/lexical/ExcalidrawModal.css +148 -0
  347. package/style/lexical/ExcalidrawNode.css +137 -0
  348. package/style/lexical/Rich.css +11 -76
  349. package/style/lexical/TableInsertModal.css +112 -0
  350. package/style/lexical/TableNode.css +287 -0
  351. package/style/lexical/images/icons/pencil-fill.svg +1 -0
  352. package/style/lexical/index.css +7 -0
  353. package/lib/tools/definitions/deleteBlock.js.map +0 -1
  354. package/lib/tools/operations/deleteBlock.d.ts +0 -52
  355. package/lib/tools/operations/deleteBlock.js +0 -110
  356. package/lib/tools/operations/deleteBlock.js.map +0 -1
  357. package/lib/tools/schemas/deleteBlock.d.ts +0 -10
  358. package/lib/tools/schemas/deleteBlock.js.map +0 -1
@@ -0,0 +1,111 @@
1
+ /**
2
+ * AutoIndent Engine
3
+ *
4
+ * Core logic for calculating language-aware code indentation.
5
+ * Processes indent/dedent rules and applies them based on line content.
6
+ *
7
+ * @module autoindent/AutoIndentEngine
8
+ */
9
+ import type { IndentContext, IndentResult } from './types';
10
+ import { LanguageIndentRegistry } from './LanguageIndentRegistry';
11
+ /**
12
+ * Engine for calculating intelligent code indentation
13
+ *
14
+ * Uses language-specific rules to determine appropriate indentation
15
+ * based on line content and context.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const registry = new LanguageIndentRegistry();
20
+ * const engine = new AutoIndentEngine(registry);
21
+ *
22
+ * const result = engine.calculateIndent({
23
+ * currentLine: 'if x > 0:',
24
+ * language: 'python',
25
+ * currentIndent: 0,
26
+ * });
27
+ *
28
+ * console.log(result.spaces); // 4
29
+ * console.log(result.shouldIndent); // true
30
+ * ```
31
+ */
32
+ export declare class AutoIndentEngine {
33
+ private registry;
34
+ private _debug;
35
+ /**
36
+ * Create a new autoindent engine
37
+ *
38
+ * @param registry - Language configuration registry
39
+ * @param debug - Enable debug logging (currently unused - logging disabled)
40
+ */
41
+ constructor(registry: LanguageIndentRegistry, debug?: boolean);
42
+ /**
43
+ * Calculate indentation for a new line based on current line context
44
+ *
45
+ * @param context - Indentation context
46
+ * @returns Indent result with spaces and indent/dedent flags
47
+ */
48
+ calculateIndent(context: IndentContext): IndentResult;
49
+ /**
50
+ * Get tab string for a language (either spaces or actual tab character)
51
+ *
52
+ * @param language - Language identifier
53
+ * @returns String to insert for one tab press
54
+ */
55
+ getTabString(language: string | null | undefined): string;
56
+ /**
57
+ * Get tab size (number of spaces) for a language
58
+ *
59
+ * @param language - Language identifier
60
+ * @returns Number of spaces per indentation level
61
+ */
62
+ getTabSize(language: string | null | undefined): number;
63
+ /**
64
+ * Calculate indentation for outdenting (Shift+Tab or dedent)
65
+ *
66
+ * @param currentIndent - Current indentation in spaces
67
+ * @param language - Language identifier
68
+ * @returns New indentation level after outdent
69
+ */
70
+ calculateOutdent(currentIndent: number, language: string | null | undefined): number;
71
+ /**
72
+ * Get leading whitespace count from a line
73
+ *
74
+ * @param line - Line of text
75
+ * @returns Number of leading whitespace characters (spaces and tabs)
76
+ */
77
+ private getLeadingWhitespaceCount;
78
+ /**
79
+ * Get leading whitespace string from a line
80
+ *
81
+ * @param line - Line of text
82
+ * @returns Leading whitespace characters
83
+ */
84
+ getLeadingWhitespace(line: string): string;
85
+ /**
86
+ * Check if a line matches an indent rule
87
+ *
88
+ * @param line - Line of text
89
+ * @param rule - Indent rule to check
90
+ * @returns True if line matches the rule
91
+ */
92
+ private matchesIndentRule;
93
+ /**
94
+ * Check if a line matches a dedent rule
95
+ *
96
+ * @param line - Line of text
97
+ * @param rule - Dedent rule to check
98
+ * @returns True if line matches the rule
99
+ */
100
+ private matchesDedentRule;
101
+ /**
102
+ * Normalize indentation to use consistent spacing
103
+ * Converts tabs to spaces based on language config
104
+ *
105
+ * @param line - Line of text
106
+ * @param language - Language identifier
107
+ * @returns Line with normalized indentation
108
+ */
109
+ normalizeIndentation(line: string, language: string | null | undefined): string;
110
+ }
111
+ export default AutoIndentEngine;
@@ -0,0 +1,234 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Engine for calculating intelligent code indentation
8
+ *
9
+ * Uses language-specific rules to determine appropriate indentation
10
+ * based on line content and context.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const registry = new LanguageIndentRegistry();
15
+ * const engine = new AutoIndentEngine(registry);
16
+ *
17
+ * const result = engine.calculateIndent({
18
+ * currentLine: 'if x > 0:',
19
+ * language: 'python',
20
+ * currentIndent: 0,
21
+ * });
22
+ *
23
+ * console.log(result.spaces); // 4
24
+ * console.log(result.shouldIndent); // true
25
+ * ```
26
+ */
27
+ export class AutoIndentEngine {
28
+ registry;
29
+ // @ts-expect-error - Debug field preserved for future use, logging currently disabled
30
+ _debug;
31
+ /**
32
+ * Create a new autoindent engine
33
+ *
34
+ * @param registry - Language configuration registry
35
+ * @param debug - Enable debug logging (currently unused - logging disabled)
36
+ */
37
+ constructor(registry, debug = false) {
38
+ this.registry = registry;
39
+ this._debug = debug;
40
+ }
41
+ /**
42
+ * Calculate indentation for a new line based on current line context
43
+ *
44
+ * @param context - Indentation context
45
+ * @returns Indent result with spaces and indent/dedent flags
46
+ */
47
+ calculateIndent(context) {
48
+ const config = this.registry.getConfigOrDefault(context.language);
49
+ // Get base indentation from current line
50
+ const currentLineIndent = this.getLeadingWhitespaceCount(context.currentLine);
51
+ // Start with current indentation
52
+ let resultSpaces = currentLineIndent;
53
+ let shouldIndent = false;
54
+ let shouldDedent = false;
55
+ let triggeredRule;
56
+ // Check indent triggers
57
+ for (const rule of config.indentTriggers) {
58
+ if (this.matchesIndentRule(context.currentLine, rule)) {
59
+ resultSpaces = currentLineIndent + rule.indentAmount;
60
+ shouldIndent = true;
61
+ triggeredRule = rule.name;
62
+ break; // Use first matching rule
63
+ }
64
+ }
65
+ // Check dedent triggers (only if no indent trigger matched)
66
+ if (!shouldIndent) {
67
+ for (const rule of config.dedentTriggers) {
68
+ if (this.matchesDedentRule(context.currentLine, rule)) {
69
+ // Note: Dedent triggers indicate that the NEXT line after the current
70
+ // line should be dedented. The current line maintains its indent.
71
+ shouldDedent = true;
72
+ triggeredRule = rule.name;
73
+ break;
74
+ }
75
+ }
76
+ }
77
+ // Apply custom rules
78
+ if (config.customRules) {
79
+ for (const customRule of config.customRules) {
80
+ if (customRule.condition(context.currentLine, context)) {
81
+ resultSpaces = customRule.apply(resultSpaces, context);
82
+ break; // Use first matching custom rule
83
+ }
84
+ }
85
+ }
86
+ // Ensure we never go negative
87
+ resultSpaces = Math.max(0, resultSpaces);
88
+ const result = {
89
+ spaces: resultSpaces,
90
+ shouldIndent,
91
+ shouldDedent,
92
+ triggeredRule,
93
+ };
94
+ return result;
95
+ }
96
+ /**
97
+ * Get tab string for a language (either spaces or actual tab character)
98
+ *
99
+ * @param language - Language identifier
100
+ * @returns String to insert for one tab press
101
+ */
102
+ getTabString(language) {
103
+ const config = this.registry.getConfigOrDefault(language);
104
+ if (config.useTabs) {
105
+ return '\t';
106
+ }
107
+ return ' '.repeat(config.tabSize);
108
+ }
109
+ /**
110
+ * Get tab size (number of spaces) for a language
111
+ *
112
+ * @param language - Language identifier
113
+ * @returns Number of spaces per indentation level
114
+ */
115
+ getTabSize(language) {
116
+ const config = this.registry.getConfigOrDefault(language);
117
+ return config.tabSize;
118
+ }
119
+ /**
120
+ * Calculate indentation for outdenting (Shift+Tab or dedent)
121
+ *
122
+ * @param currentIndent - Current indentation in spaces
123
+ * @param language - Language identifier
124
+ * @returns New indentation level after outdent
125
+ */
126
+ calculateOutdent(currentIndent, language) {
127
+ const config = this.registry.getConfigOrDefault(language);
128
+ const newIndent = currentIndent - config.tabSize;
129
+ return Math.max(0, newIndent);
130
+ }
131
+ /**
132
+ * Get leading whitespace count from a line
133
+ *
134
+ * @param line - Line of text
135
+ * @returns Number of leading whitespace characters (spaces and tabs)
136
+ */
137
+ getLeadingWhitespaceCount(line) {
138
+ const match = line.match(/^[\t ]*/);
139
+ if (!match) {
140
+ return 0;
141
+ }
142
+ const whitespace = match[0];
143
+ let count = 0;
144
+ for (const char of whitespace) {
145
+ if (char === '\t') {
146
+ // Count tab as 4 spaces (or configured tab size)
147
+ // Note: This is a simplification; actual tab width depends on config
148
+ count += 4;
149
+ }
150
+ else {
151
+ count += 1;
152
+ }
153
+ }
154
+ return count;
155
+ }
156
+ /**
157
+ * Get leading whitespace string from a line
158
+ *
159
+ * @param line - Line of text
160
+ * @returns Leading whitespace characters
161
+ */
162
+ getLeadingWhitespace(line) {
163
+ const match = line.match(/^[\t ]*/);
164
+ return match ? match[0] : '';
165
+ }
166
+ /**
167
+ * Check if a line matches an indent rule
168
+ *
169
+ * @param line - Line of text
170
+ * @param rule - Indent rule to check
171
+ * @returns True if line matches the rule
172
+ */
173
+ matchesIndentRule(line, rule) {
174
+ switch (rule.context) {
175
+ case 'line-end':
176
+ return rule.pattern.test(line);
177
+ case 'line-start':
178
+ return rule.pattern.test(line);
179
+ case 'anywhere':
180
+ return rule.pattern.test(line);
181
+ default:
182
+ return false;
183
+ }
184
+ }
185
+ /**
186
+ * Check if a line matches a dedent rule
187
+ *
188
+ * @param line - Line of text
189
+ * @param rule - Dedent rule to check
190
+ * @returns True if line matches the rule
191
+ */
192
+ matchesDedentRule(line, rule) {
193
+ switch (rule.context) {
194
+ case 'line-start':
195
+ return rule.pattern.test(line);
196
+ case 'anywhere':
197
+ return rule.pattern.test(line);
198
+ default:
199
+ return false;
200
+ }
201
+ }
202
+ /**
203
+ * Normalize indentation to use consistent spacing
204
+ * Converts tabs to spaces based on language config
205
+ *
206
+ * @param line - Line of text
207
+ * @param language - Language identifier
208
+ * @returns Line with normalized indentation
209
+ */
210
+ normalizeIndentation(line, language) {
211
+ const config = this.registry.getConfigOrDefault(language);
212
+ if (config.useTabs) {
213
+ // Convert spaces to tabs
214
+ const leadingSpaces = this.getLeadingWhitespace(line);
215
+ const spaceCount = leadingSpaces.length;
216
+ const tabCount = Math.floor(spaceCount / config.tabSize);
217
+ const remainingSpaces = spaceCount % config.tabSize;
218
+ const normalized = '\t'.repeat(tabCount) +
219
+ ' '.repeat(remainingSpaces) +
220
+ line.substring(leadingSpaces.length);
221
+ return normalized;
222
+ }
223
+ else {
224
+ // Convert tabs to spaces
225
+ const leadingWhitespace = this.getLeadingWhitespace(line);
226
+ const normalized = leadingWhitespace
227
+ .replace(/\t/g, ' '.repeat(config.tabSize))
228
+ .concat(line.substring(leadingWhitespace.length));
229
+ return normalized;
230
+ }
231
+ }
232
+ }
233
+ export default AutoIndentEngine;
234
+ //# sourceMappingURL=AutoIndentEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoIndentEngine.js","sourceRoot":"","sources":["../../src/autoindent/AutoIndentEngine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,gBAAgB;IACnB,QAAQ,CAAyB;IACzC,sFAAsF;IAC9E,MAAM,CAAU;IAExB;;;;;OAKG;IACH,YAAY,QAAgC,EAAE,KAAK,GAAG,KAAK;QACzD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,OAAsB;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAElE,yCAAyC;QACzC,MAAM,iBAAiB,GAAG,IAAI,CAAC,yBAAyB,CACtD,OAAO,CAAC,WAAW,CACpB,CAAC;QAEF,iCAAiC;QACjC,IAAI,YAAY,GAAG,iBAAiB,CAAC;QACrC,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C;QAE1D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,yBAAyB;YACzB,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YACtD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;YACzD,MAAM,eAAe,GAAG,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;YAEpD,MAAM,UAAU,GACd,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC;gBAC3B,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAEvC,OAAO,UAAU,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,yBAAyB;YACzB,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAC1D,MAAM,UAAU,GAAG,iBAAiB;iBACjC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;iBAC1C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;YAEpD,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Language Indentation Registry
3
+ *
4
+ * Central registry for managing language-specific indentation configurations.
5
+ * Supports registration, retrieval, and updating of language configs.
6
+ *
7
+ * @module autoindent/LanguageIndentRegistry
8
+ */
9
+ import type { LanguageIndentConfig, AutoIndentOptions } from './types';
10
+ /**
11
+ * Registry for language indentation configurations
12
+ *
13
+ * Manages a collection of language-specific indent rules and provides
14
+ * methods to register, retrieve, and update configurations.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const registry = new LanguageIndentRegistry();
19
+ * const config = registry.getConfig('python');
20
+ * console.log(config.tabSize); // 4
21
+ * ```
22
+ */
23
+ export declare class LanguageIndentRegistry {
24
+ private configs;
25
+ private options;
26
+ /**
27
+ * Create a new language indent registry
28
+ *
29
+ * @param options - Configuration options
30
+ */
31
+ constructor(options?: AutoIndentOptions);
32
+ /**
33
+ * Register default language configurations
34
+ * Currently supports: Python, JavaScript, TypeScript
35
+ */
36
+ private registerDefaultLanguages;
37
+ /**
38
+ * Register a language configuration
39
+ *
40
+ * @param config - Language indent configuration
41
+ * @throws Error if language already registered (use updateConfig to modify)
42
+ */
43
+ registerLanguage(config: LanguageIndentConfig): void;
44
+ /**
45
+ * Register a language alias
46
+ * Example: 'py' -> 'python', 'js' -> 'javascript'
47
+ *
48
+ * @param alias - Short alias name
49
+ * @param targetLanguage - Full language name
50
+ */
51
+ registerAlias(alias: string, targetLanguage: string): void;
52
+ /**
53
+ * Get configuration for a language
54
+ *
55
+ * @param language - Language identifier
56
+ * @returns Language config or undefined if not found
57
+ */
58
+ getConfig(language: string | null | undefined): LanguageIndentConfig | undefined;
59
+ /**
60
+ * Get configuration for a language with fallback to default
61
+ *
62
+ * @param language - Language identifier
63
+ * @returns Language config (never undefined - returns default if not found)
64
+ */
65
+ getConfigOrDefault(language: string | null | undefined): LanguageIndentConfig;
66
+ /**
67
+ * Create a minimal fallback configuration
68
+ */
69
+ private createFallbackConfig;
70
+ /**
71
+ * Check if a language is registered
72
+ *
73
+ * @param language - Language identifier
74
+ * @returns True if language has a configuration
75
+ */
76
+ hasLanguage(language: string | null | undefined): boolean;
77
+ /**
78
+ * Update an existing language configuration
79
+ *
80
+ * @param language - Language identifier
81
+ * @param updates - Partial configuration to merge
82
+ * @returns True if update successful, false if language not found
83
+ */
84
+ updateConfig(language: string, updates: Partial<LanguageIndentConfig>): boolean;
85
+ /**
86
+ * Get list of all registered languages
87
+ *
88
+ * @returns Array of language identifiers
89
+ */
90
+ getRegisteredLanguages(): string[];
91
+ /**
92
+ * Clear all registered configurations
93
+ * Useful for testing
94
+ */
95
+ clear(): void;
96
+ /**
97
+ * Reset to default configurations
98
+ * Removes custom configs but keeps built-in languages
99
+ */
100
+ reset(): void;
101
+ }
102
+ export default LanguageIndentRegistry;
@@ -0,0 +1,200 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { pythonIndentConfig } from './languages/python.js';
7
+ import { javascriptIndentConfig, typescriptIndentConfig, } from './languages/javascript.js';
8
+ /**
9
+ * Registry for language indentation configurations
10
+ *
11
+ * Manages a collection of language-specific indent rules and provides
12
+ * methods to register, retrieve, and update configurations.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const registry = new LanguageIndentRegistry();
17
+ * const config = registry.getConfig('python');
18
+ * console.log(config.tabSize); // 4
19
+ * ```
20
+ */
21
+ export class LanguageIndentRegistry {
22
+ configs;
23
+ options;
24
+ /**
25
+ * Create a new language indent registry
26
+ *
27
+ * @param options - Configuration options
28
+ */
29
+ constructor(options = {}) {
30
+ this.configs = new Map();
31
+ this.options = {
32
+ defaultLanguage: 'python',
33
+ fallbackTabSize: 4,
34
+ debug: false,
35
+ ...options,
36
+ };
37
+ // Register default languages
38
+ this.registerDefaultLanguages();
39
+ // Register any custom configs provided
40
+ if (options.customConfigs) {
41
+ options.customConfigs.forEach(config => this.registerLanguage(config));
42
+ }
43
+ }
44
+ /**
45
+ * Register default language configurations
46
+ * Currently supports: Python, JavaScript, TypeScript
47
+ */
48
+ registerDefaultLanguages() {
49
+ this.registerLanguage(pythonIndentConfig);
50
+ this.registerLanguage(javascriptIndentConfig);
51
+ this.registerLanguage(typescriptIndentConfig);
52
+ // Add common language aliases
53
+ this.registerAlias('py', 'python');
54
+ this.registerAlias('js', 'javascript');
55
+ this.registerAlias('ts', 'typescript');
56
+ this.registerAlias('jsx', 'javascript');
57
+ this.registerAlias('tsx', 'typescript');
58
+ }
59
+ /**
60
+ * Register a language configuration
61
+ *
62
+ * @param config - Language indent configuration
63
+ * @throws Error if language already registered (use updateConfig to modify)
64
+ */
65
+ registerLanguage(config) {
66
+ if (this.configs.has(config.language)) {
67
+ if (this.options.debug) {
68
+ console.warn(`[LanguageIndentRegistry] Language '${config.language}' already registered. Use updateConfig() to modify.`);
69
+ }
70
+ return;
71
+ }
72
+ this.configs.set(config.language, config);
73
+ }
74
+ /**
75
+ * Register a language alias
76
+ * Example: 'py' -> 'python', 'js' -> 'javascript'
77
+ *
78
+ * @param alias - Short alias name
79
+ * @param targetLanguage - Full language name
80
+ */
81
+ registerAlias(alias, targetLanguage) {
82
+ const config = this.configs.get(targetLanguage);
83
+ if (config) {
84
+ this.configs.set(alias, config);
85
+ }
86
+ }
87
+ /**
88
+ * Get configuration for a language
89
+ *
90
+ * @param language - Language identifier
91
+ * @returns Language config or undefined if not found
92
+ */
93
+ getConfig(language) {
94
+ if (!language) {
95
+ return this.getConfig(this.options.defaultLanguage);
96
+ }
97
+ // Normalize language name (lowercase, trim)
98
+ const normalized = language.toLowerCase().trim();
99
+ return this.configs.get(normalized);
100
+ }
101
+ /**
102
+ * Get configuration for a language with fallback to default
103
+ *
104
+ * @param language - Language identifier
105
+ * @returns Language config (never undefined - returns default if not found)
106
+ */
107
+ getConfigOrDefault(language) {
108
+ const config = this.getConfig(language);
109
+ if (config) {
110
+ return config;
111
+ }
112
+ // Fallback to default language
113
+ const defaultConfig = this.getConfig(this.options.defaultLanguage);
114
+ if (defaultConfig) {
115
+ if (this.options.debug) {
116
+ console.warn(`[LanguageIndentRegistry] Language '${language}' not found, using default: ${this.options.defaultLanguage}`);
117
+ }
118
+ return defaultConfig;
119
+ }
120
+ // Ultimate fallback: create minimal config
121
+ if (this.options.debug) {
122
+ console.error(`[LanguageIndentRegistry] No config found for '${language}' and default '${this.options.defaultLanguage}' missing!`);
123
+ }
124
+ return this.createFallbackConfig(language || 'unknown');
125
+ }
126
+ /**
127
+ * Create a minimal fallback configuration
128
+ */
129
+ createFallbackConfig(language) {
130
+ return {
131
+ language,
132
+ tabSize: this.options.fallbackTabSize || 4,
133
+ useTabs: this.options.preserveTabs || false,
134
+ indentTriggers: [],
135
+ dedentTriggers: [],
136
+ };
137
+ }
138
+ /**
139
+ * Check if a language is registered
140
+ *
141
+ * @param language - Language identifier
142
+ * @returns True if language has a configuration
143
+ */
144
+ hasLanguage(language) {
145
+ if (!language) {
146
+ return false;
147
+ }
148
+ const normalized = language.toLowerCase().trim();
149
+ return this.configs.has(normalized);
150
+ }
151
+ /**
152
+ * Update an existing language configuration
153
+ *
154
+ * @param language - Language identifier
155
+ * @param updates - Partial configuration to merge
156
+ * @returns True if update successful, false if language not found
157
+ */
158
+ updateConfig(language, updates) {
159
+ const normalized = language.toLowerCase().trim();
160
+ const existing = this.configs.get(normalized);
161
+ if (!existing) {
162
+ if (this.options.debug) {
163
+ console.warn(`[LanguageIndentRegistry] Cannot update '${language}' - not registered`);
164
+ }
165
+ return false;
166
+ }
167
+ const updated = {
168
+ ...existing,
169
+ ...updates,
170
+ language: existing.language, // Preserve original language name
171
+ };
172
+ this.configs.set(normalized, updated);
173
+ return true;
174
+ }
175
+ /**
176
+ * Get list of all registered languages
177
+ *
178
+ * @returns Array of language identifiers
179
+ */
180
+ getRegisteredLanguages() {
181
+ return Array.from(this.configs.keys());
182
+ }
183
+ /**
184
+ * Clear all registered configurations
185
+ * Useful for testing
186
+ */
187
+ clear() {
188
+ this.configs.clear();
189
+ }
190
+ /**
191
+ * Reset to default configurations
192
+ * Removes custom configs but keeps built-in languages
193
+ */
194
+ reset() {
195
+ this.clear();
196
+ this.registerDefaultLanguages();
197
+ }
198
+ }
199
+ export default LanguageIndentRegistry;
200
+ //# sourceMappingURL=LanguageIndentRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LanguageIndentRegistry.js","sourceRoot":"","sources":["../../src/autoindent/LanguageIndentRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,EAAE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