@notectl/core 1.0.3 → 1.0.5

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 (312) hide show
  1. package/README.md +51 -148
  2. package/dist/chunks/AttrRegistry-DTsHyDVA.mjs +16 -0
  3. package/dist/chunks/AttrRegistry-DTsHyDVA.mjs.map +1 -0
  4. package/dist/chunks/Commands-DLP85Mp5.mjs +461 -0
  5. package/dist/chunks/Commands-DLP85Mp5.mjs.map +1 -0
  6. package/dist/chunks/Document-CI3iCwEP.mjs +177 -0
  7. package/dist/chunks/Document-CI3iCwEP.mjs.map +1 -0
  8. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +7 -0
  9. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +1 -0
  10. package/dist/chunks/NodeResolver-D68ZLXti.mjs +81 -0
  11. package/dist/chunks/NodeResolver-D68ZLXti.mjs.map +1 -0
  12. package/dist/chunks/NodeSpec-NZVvcCuH.mjs +8 -0
  13. package/dist/chunks/NodeSpec-NZVvcCuH.mjs.map +1 -0
  14. package/dist/chunks/Plugin-B9OZ6Y4c.mjs +15 -0
  15. package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +1 -0
  16. package/dist/chunks/Selection-D5ZjXoB7.mjs +44 -0
  17. package/dist/chunks/Selection-D5ZjXoB7.mjs.map +1 -0
  18. package/dist/chunks/ToolbarItem-ugDymuXi.mjs +7 -0
  19. package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +1 -0
  20. package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs +398 -0
  21. package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs.map +1 -0
  22. package/dist/chunks/TypeBrands-C09nE2qO.mjs +27 -0
  23. package/dist/chunks/TypeBrands-C09nE2qO.mjs.map +1 -0
  24. package/dist/chunks/color-picker-Csf0wx5a.mjs +5 -0
  25. package/dist/chunks/color-picker-Csf0wx5a.mjs.map +1 -0
  26. package/dist/chunks/index-CPPb-Jah.mjs +569 -0
  27. package/dist/chunks/index-CPPb-Jah.mjs.map +1 -0
  28. package/dist/commands/Commands.d.ts +71 -0
  29. package/dist/commands/Commands.d.ts.map +1 -0
  30. package/dist/commands/PasteCommand.d.ts +9 -0
  31. package/dist/commands/PasteCommand.d.ts.map +1 -0
  32. package/dist/decorations/Decoration.d.ts +76 -0
  33. package/dist/decorations/Decoration.d.ts.map +1 -0
  34. package/dist/decorations/PositionMapping.d.ts +9 -0
  35. package/dist/decorations/PositionMapping.d.ts.map +1 -0
  36. package/dist/editor/Announcer.d.ts +12 -0
  37. package/dist/editor/Announcer.d.ts.map +1 -0
  38. package/dist/editor/DocumentParser.d.ts +5 -0
  39. package/dist/editor/DocumentParser.d.ts.map +1 -0
  40. package/dist/editor/DocumentSerializer.d.ts +5 -0
  41. package/dist/editor/DocumentSerializer.d.ts.map +1 -0
  42. package/dist/editor/EditorDOM.d.ts +18 -0
  43. package/dist/editor/EditorDOM.d.ts.map +1 -0
  44. package/dist/editor/EditorThemeController.d.ts +21 -0
  45. package/dist/editor/EditorThemeController.d.ts.map +1 -0
  46. package/dist/editor/NotectlEditor.d.ts +131 -0
  47. package/dist/editor/NotectlEditor.d.ts.map +1 -0
  48. package/dist/editor/styles/base.d.ts +3 -0
  49. package/dist/editor/styles/base.d.ts.map +1 -0
  50. package/dist/editor/styles/code-block.d.ts +3 -0
  51. package/dist/editor/styles/code-block.d.ts.map +1 -0
  52. package/dist/editor/styles/color-picker.d.ts +3 -0
  53. package/dist/editor/styles/color-picker.d.ts.map +1 -0
  54. package/dist/editor/styles/font-select.d.ts +3 -0
  55. package/dist/editor/styles/font-select.d.ts.map +1 -0
  56. package/dist/editor/styles/font-size-select.d.ts +3 -0
  57. package/dist/editor/styles/font-size-select.d.ts.map +1 -0
  58. package/dist/editor/styles/heading-select.d.ts +3 -0
  59. package/dist/editor/styles/heading-select.d.ts.map +1 -0
  60. package/dist/editor/styles/image.d.ts +3 -0
  61. package/dist/editor/styles/image.d.ts.map +1 -0
  62. package/dist/editor/styles/list.d.ts +3 -0
  63. package/dist/editor/styles/list.d.ts.map +1 -0
  64. package/dist/editor/styles/reduced-motion.d.ts +3 -0
  65. package/dist/editor/styles/reduced-motion.d.ts.map +1 -0
  66. package/dist/editor/styles/table.d.ts +3 -0
  67. package/dist/editor/styles/table.d.ts.map +1 -0
  68. package/dist/editor/styles/toolbar.d.ts +3 -0
  69. package/dist/editor/styles/toolbar.d.ts.map +1 -0
  70. package/dist/editor/styles.d.ts +12 -0
  71. package/dist/editor/styles.d.ts.map +1 -0
  72. package/dist/editor/theme/ThemeEngine.d.ts +6 -0
  73. package/dist/editor/theme/ThemeEngine.d.ts.map +1 -0
  74. package/dist/editor/theme/ThemeTokens.d.ts +73 -0
  75. package/dist/editor/theme/ThemeTokens.d.ts.map +1 -0
  76. package/dist/fonts.d.ts +17 -0
  77. package/dist/fonts.d.ts.map +1 -0
  78. package/dist/fonts.mjs +7 -0
  79. package/dist/fonts.mjs.map +1 -0
  80. package/dist/index.d.ts +81 -2360
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/input/ClipboardHandler.d.ts +29 -0
  83. package/dist/input/ClipboardHandler.d.ts.map +1 -0
  84. package/dist/input/InputHandler.d.ts +32 -0
  85. package/dist/input/InputHandler.d.ts.map +1 -0
  86. package/dist/input/InputRule.d.ts +9 -0
  87. package/dist/input/InputRule.d.ts.map +1 -0
  88. package/dist/input/InternalClipboard.d.ts +23 -0
  89. package/dist/input/InternalClipboard.d.ts.map +1 -0
  90. package/dist/input/KeyboardHandler.d.ts +42 -0
  91. package/dist/input/KeyboardHandler.d.ts.map +1 -0
  92. package/dist/input/Keymap.d.ts +11 -0
  93. package/dist/input/Keymap.d.ts.map +1 -0
  94. package/dist/input/PasteHandler.d.ts +38 -0
  95. package/dist/input/PasteHandler.d.ts.map +1 -0
  96. package/dist/input/SourceNormalizer.d.ts +7 -0
  97. package/dist/input/SourceNormalizer.d.ts.map +1 -0
  98. package/dist/model/AttrRegistry.d.ts +39 -0
  99. package/dist/model/AttrRegistry.d.ts.map +1 -0
  100. package/dist/model/BuiltinSpecs.d.ts +4 -0
  101. package/dist/model/BuiltinSpecs.d.ts.map +1 -0
  102. package/dist/model/ContentModel.d.ts +12 -0
  103. package/dist/model/ContentModel.d.ts.map +1 -0
  104. package/dist/model/ContentSlice.d.ts +17 -0
  105. package/dist/model/ContentSlice.d.ts.map +1 -0
  106. package/dist/model/Document.d.ts +127 -0
  107. package/dist/model/Document.d.ts.map +1 -0
  108. package/dist/model/HTMLParser.d.ts +36 -0
  109. package/dist/model/HTMLParser.d.ts.map +1 -0
  110. package/dist/model/HTMLUtils.d.ts +6 -0
  111. package/dist/model/HTMLUtils.d.ts.map +1 -0
  112. package/dist/model/InlineNodeSpec.d.ts +20 -0
  113. package/dist/model/InlineNodeSpec.d.ts.map +1 -0
  114. package/dist/model/MarkSpec.d.ts +22 -0
  115. package/dist/model/MarkSpec.d.ts.map +1 -0
  116. package/dist/model/NodeResolver.d.ts +36 -0
  117. package/dist/model/NodeResolver.d.ts.map +1 -0
  118. package/dist/model/NodeSpec.d.ts +67 -0
  119. package/dist/model/NodeSpec.d.ts.map +1 -0
  120. package/dist/model/ParseRule.d.ts +11 -0
  121. package/dist/model/ParseRule.d.ts.map +1 -0
  122. package/dist/model/SanitizeConfig.d.ts +9 -0
  123. package/dist/model/SanitizeConfig.d.ts.map +1 -0
  124. package/dist/model/Schema.d.ts +17 -0
  125. package/dist/model/Schema.d.ts.map +1 -0
  126. package/dist/model/SchemaRegistry.d.ts +81 -0
  127. package/dist/model/SchemaRegistry.d.ts.map +1 -0
  128. package/dist/model/Selection.d.ts +52 -0
  129. package/dist/model/Selection.d.ts.map +1 -0
  130. package/dist/model/TypeBrands.d.ts +28 -0
  131. package/dist/model/TypeBrands.d.ts.map +1 -0
  132. package/dist/notectl-core.mjs +2576 -11104
  133. package/dist/notectl-core.mjs.map +1 -1
  134. package/dist/notectl-core.umd.js +6810 -0
  135. package/dist/notectl-core.umd.js.map +1 -0
  136. package/dist/plugins/EventBus.d.ts +13 -0
  137. package/dist/plugins/EventBus.d.ts.map +1 -0
  138. package/dist/plugins/Plugin.d.ts +85 -0
  139. package/dist/plugins/Plugin.d.ts.map +1 -0
  140. package/dist/plugins/PluginManager.d.ts +66 -0
  141. package/dist/plugins/PluginManager.d.ts.map +1 -0
  142. package/dist/plugins/alignment/AlignmentPlugin.d.ts +48 -0
  143. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -0
  144. package/dist/plugins/alignment/index.d.ts +2 -0
  145. package/dist/plugins/alignment/index.d.ts.map +1 -0
  146. package/dist/plugins/alignment.mjs +92 -0
  147. package/dist/plugins/alignment.mjs.map +1 -0
  148. package/dist/plugins/blockquote/BlockquotePlugin.d.ts +30 -0
  149. package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -0
  150. package/dist/plugins/blockquote/index.d.ts +2 -0
  151. package/dist/plugins/blockquote/index.d.ts.map +1 -0
  152. package/dist/plugins/blockquote.mjs +58 -0
  153. package/dist/plugins/blockquote.mjs.map +1 -0
  154. package/dist/plugins/code-block/CodeBlockNodeView.d.ts +5 -0
  155. package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -0
  156. package/dist/plugins/code-block/CodeBlockPlugin.d.ts +135 -0
  157. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -0
  158. package/dist/plugins/code-block/index.d.ts +2 -0
  159. package/dist/plugins/code-block/index.d.ts.map +1 -0
  160. package/dist/plugins/code-block.mjs +6 -0
  161. package/dist/plugins/code-block.mjs.map +1 -0
  162. package/dist/plugins/font/FontPlugin.d.ts +85 -0
  163. package/dist/plugins/font/FontPlugin.d.ts.map +1 -0
  164. package/dist/plugins/font/StarterFonts.d.ts +10 -0
  165. package/dist/plugins/font/StarterFonts.d.ts.map +1 -0
  166. package/dist/plugins/font/index.d.ts +2 -0
  167. package/dist/plugins/font/index.d.ts.map +1 -0
  168. package/dist/plugins/font-size/FontSizePlugin.d.ts +65 -0
  169. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -0
  170. package/dist/plugins/font-size/index.d.ts +2 -0
  171. package/dist/plugins/font-size/index.d.ts.map +1 -0
  172. package/dist/plugins/font-size.mjs +220 -0
  173. package/dist/plugins/font-size.mjs.map +1 -0
  174. package/dist/plugins/font.mjs +186 -0
  175. package/dist/plugins/font.mjs.map +1 -0
  176. package/dist/plugins/hard-break/HardBreakPlugin.d.ts +16 -0
  177. package/dist/plugins/hard-break/HardBreakPlugin.d.ts.map +1 -0
  178. package/dist/plugins/hard-break/index.d.ts +2 -0
  179. package/dist/plugins/hard-break/index.d.ts.map +1 -0
  180. package/dist/plugins/hard-break.mjs +28 -0
  181. package/dist/plugins/hard-break.mjs.map +1 -0
  182. package/dist/plugins/heading/BlockTypePickerEntry.d.ts +20 -0
  183. package/dist/plugins/heading/BlockTypePickerEntry.d.ts.map +1 -0
  184. package/dist/plugins/heading/HeadingPlugin.d.ts +78 -0
  185. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -0
  186. package/dist/plugins/heading/index.d.ts +3 -0
  187. package/dist/plugins/heading/index.d.ts.map +1 -0
  188. package/dist/plugins/heading.mjs +188 -0
  189. package/dist/plugins/heading.mjs.map +1 -0
  190. package/dist/plugins/highlight/HighlightPlugin.d.ts +37 -0
  191. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -0
  192. package/dist/plugins/highlight/index.d.ts +2 -0
  193. package/dist/plugins/highlight/index.d.ts.map +1 -0
  194. package/dist/plugins/highlight.mjs +126 -0
  195. package/dist/plugins/highlight.mjs.map +1 -0
  196. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +29 -0
  197. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -0
  198. package/dist/plugins/horizontal-rule/index.d.ts +2 -0
  199. package/dist/plugins/horizontal-rule/index.d.ts.map +1 -0
  200. package/dist/plugins/horizontal-rule.mjs +59 -0
  201. package/dist/plugins/horizontal-rule.mjs.map +1 -0
  202. package/dist/plugins/image/ImageCommands.d.ts +26 -0
  203. package/dist/plugins/image/ImageCommands.d.ts.map +1 -0
  204. package/dist/plugins/image/ImageNodeView.d.ts +6 -0
  205. package/dist/plugins/image/ImageNodeView.d.ts.map +1 -0
  206. package/dist/plugins/image/ImagePlugin.d.ts +43 -0
  207. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -0
  208. package/dist/plugins/image/ImageUpload.d.ts +48 -0
  209. package/dist/plugins/image/ImageUpload.d.ts.map +1 -0
  210. package/dist/plugins/image/index.d.ts +3 -0
  211. package/dist/plugins/image/index.d.ts.map +1 -0
  212. package/dist/plugins/image.mjs +381 -0
  213. package/dist/plugins/image.mjs.map +1 -0
  214. package/dist/plugins/link/LinkPlugin.d.ts +32 -0
  215. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -0
  216. package/dist/plugins/link/index.d.ts +2 -0
  217. package/dist/plugins/link/index.d.ts.map +1 -0
  218. package/dist/plugins/link.mjs +127 -0
  219. package/dist/plugins/link.mjs.map +1 -0
  220. package/dist/plugins/list/ListPlugin.d.ts +51 -0
  221. package/dist/plugins/list/ListPlugin.d.ts.map +1 -0
  222. package/dist/plugins/list/index.d.ts +2 -0
  223. package/dist/plugins/list/index.d.ts.map +1 -0
  224. package/dist/plugins/list.mjs +193 -0
  225. package/dist/plugins/list.mjs.map +1 -0
  226. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +23 -0
  227. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -0
  228. package/dist/plugins/strikethrough/index.d.ts +2 -0
  229. package/dist/plugins/strikethrough/index.d.ts.map +1 -0
  230. package/dist/plugins/strikethrough.mjs +35 -0
  231. package/dist/plugins/strikethrough.mjs.map +1 -0
  232. package/dist/plugins/super-sub/SuperSubPlugin.d.ts +44 -0
  233. package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -0
  234. package/dist/plugins/super-sub/index.d.ts +2 -0
  235. package/dist/plugins/super-sub/index.d.ts.map +1 -0
  236. package/dist/plugins/super-sub.mjs +81 -0
  237. package/dist/plugins/super-sub.mjs.map +1 -0
  238. package/dist/plugins/table/TableCommands.d.ts +50 -0
  239. package/dist/plugins/table/TableCommands.d.ts.map +1 -0
  240. package/dist/plugins/table/TableControls.d.ts +10 -0
  241. package/dist/plugins/table/TableControls.d.ts.map +1 -0
  242. package/dist/plugins/table/TableControlsDOM.d.ts +18 -0
  243. package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -0
  244. package/dist/plugins/table/TableControlsLayout.d.ts +34 -0
  245. package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -0
  246. package/dist/plugins/table/TableHelpers.d.ts +39 -0
  247. package/dist/plugins/table/TableHelpers.d.ts.map +1 -0
  248. package/dist/plugins/table/TableNavigation.d.ts +4 -0
  249. package/dist/plugins/table/TableNavigation.d.ts.map +1 -0
  250. package/dist/plugins/table/TableNodeViews.d.ts +18 -0
  251. package/dist/plugins/table/TableNodeViews.d.ts.map +1 -0
  252. package/dist/plugins/table/TablePlugin.d.ts +39 -0
  253. package/dist/plugins/table/TablePlugin.d.ts.map +1 -0
  254. package/dist/plugins/table/TableSelection.d.ts +26 -0
  255. package/dist/plugins/table/TableSelection.d.ts.map +1 -0
  256. package/dist/plugins/table/TableTestUtils.d.ts +45 -0
  257. package/dist/plugins/table/TableTestUtils.d.ts.map +1 -0
  258. package/dist/plugins/table/index.d.ts +4 -0
  259. package/dist/plugins/table/index.d.ts.map +1 -0
  260. package/dist/plugins/table.mjs +663 -0
  261. package/dist/plugins/table.mjs.map +1 -0
  262. package/dist/plugins/text-color/TextColorPlugin.d.ts +37 -0
  263. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -0
  264. package/dist/plugins/text-color/index.d.ts +2 -0
  265. package/dist/plugins/text-color/index.d.ts.map +1 -0
  266. package/dist/plugins/text-color.mjs +126 -0
  267. package/dist/plugins/text-color.mjs.map +1 -0
  268. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +34 -0
  269. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -0
  270. package/dist/plugins/text-formatting/index.d.ts +2 -0
  271. package/dist/plugins/text-formatting/index.d.ts.map +1 -0
  272. package/dist/plugins/text-formatting.mjs +52 -0
  273. package/dist/plugins/text-formatting.mjs.map +1 -0
  274. package/dist/plugins/toolbar/ToolbarItem.d.ts +66 -0
  275. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -0
  276. package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts +25 -0
  277. package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts.map +1 -0
  278. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +47 -0
  279. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -0
  280. package/dist/plugins/toolbar/ToolbarPopupController.d.ts +25 -0
  281. package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -0
  282. package/dist/plugins/toolbar/ToolbarRenderers.d.ts +19 -0
  283. package/dist/plugins/toolbar/ToolbarRenderers.d.ts.map +1 -0
  284. package/dist/plugins/toolbar/ToolbarTooltip.d.ts +17 -0
  285. package/dist/plugins/toolbar/ToolbarTooltip.d.ts.map +1 -0
  286. package/dist/plugins/toolbar/index.d.ts +4 -0
  287. package/dist/plugins/toolbar/index.d.ts.map +1 -0
  288. package/dist/plugins/toolbar.mjs +8 -0
  289. package/dist/plugins/toolbar.mjs.map +1 -0
  290. package/dist/state/EditorState.d.ts +40 -0
  291. package/dist/state/EditorState.d.ts.map +1 -0
  292. package/dist/state/History.d.ts +38 -0
  293. package/dist/state/History.d.ts.map +1 -0
  294. package/dist/state/StepApplication.d.ts +5 -0
  295. package/dist/state/StepApplication.d.ts.map +1 -0
  296. package/dist/state/Transaction.d.ts +185 -0
  297. package/dist/state/Transaction.d.ts.map +1 -0
  298. package/dist/test/PluginTestUtils.d.ts +127 -0
  299. package/dist/test/PluginTestUtils.d.ts.map +1 -0
  300. package/dist/test/TestUtils.d.ts +153 -0
  301. package/dist/test/TestUtils.d.ts.map +1 -0
  302. package/dist/view/EditorView.d.ts +74 -0
  303. package/dist/view/EditorView.d.ts.map +1 -0
  304. package/dist/view/NodeView.d.ts +18 -0
  305. package/dist/view/NodeView.d.ts.map +1 -0
  306. package/dist/view/Reconciler.d.ts +23 -0
  307. package/dist/view/Reconciler.d.ts.map +1 -0
  308. package/dist/view/SelectionSync.d.ts +8 -0
  309. package/dist/view/SelectionSync.d.ts.map +1 -0
  310. package/package.json +112 -11
  311. package/dist/notectl-core.js +0 -1463
  312. package/dist/notectl-core.js.map +0 -1
@@ -0,0 +1,52 @@
1
+ import { A as t, r as e } from "../chunks/Commands-DLP85Mp5.mjs";
2
+ import { m as i } from "../chunks/TypeBrands-C09nE2qO.mjs";
3
+ import { f as o } from "../chunks/ToolbarItem-ugDymuXi.mjs";
4
+ const r = { bold: true, italic: true, underline: true }, s = [{ type: "bold", configKey: "bold", rank: 0, tag: "strong", label: "Bold", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/></svg>', keyBinding: "Mod-B", toHTMLString: (t2) => `<strong>${t2}</strong>`, parseHTML: [{ tag: "strong" }, { tag: "b" }], sanitize: { tags: ["strong", "b"] } }, { type: "italic", configKey: "italic", rank: 1, tag: "em", label: "Italic", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/></svg>', keyBinding: "Mod-I", toHTMLString: (t2) => `<em>${t2}</em>`, parseHTML: [{ tag: "em" }, { tag: "i" }], sanitize: { tags: ["em", "i"] } }, { type: "underline", configKey: "underline", rank: 2, tag: "u", label: "Underline", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/></svg>', keyBinding: "Mod-U", toHTMLString: (t2) => `<u>${t2}</u>`, parseHTML: [{ tag: "u" }], sanitize: { tags: ["u"] } }];
5
+ class n {
6
+ id = "text-formatting";
7
+ name = "Text Formatting";
8
+ priority = 20;
9
+ config;
10
+ constructor(t2) {
11
+ this.config = { ...r, ...t2 };
12
+ }
13
+ init(t2) {
14
+ const e2 = s.filter((t3) => this.config[t3.configKey]), i2 = e2.filter((t3) => this.isToolbarVisible(t3.configKey)).at(-1);
15
+ for (const o2 of e2) {
16
+ const e3 = this.config.separatorAfter && o2 === i2;
17
+ this.registerMark(t2, o2, e3);
18
+ }
19
+ this.registerKeymaps(t2, e2), this.registerDisabledToolbarItems(t2);
20
+ }
21
+ registerMark(r2, s2, n2) {
22
+ const g = a(s2.type), c = this.isToolbarVisible(s2.configKey);
23
+ r2.registerMarkSpec({ type: s2.type, rank: s2.rank, toDOM: () => document.createElement(s2.tag), toHTMLString: (t2, e2) => s2.toHTMLString(e2), parseHTML: s2.parseHTML, sanitize: s2.sanitize }), r2.registerCommand(g, () => {
24
+ const e2 = t(r2.getState(), i(s2.type));
25
+ return !!e2 && (r2.dispatch(e2), true);
26
+ }), c && r2.registerToolbarItem({ id: s2.type, group: "format", icon: s2.icon, label: s2.label, tooltip: `${s2.label} (${o(s2.keyBinding)})`, command: g, priority: 10 * s2.rank + 10, separatorAfter: n2, isActive: (t2) => e(t2, i(s2.type)) });
27
+ }
28
+ registerKeymaps(t2, e2) {
29
+ const i2 = {};
30
+ for (const o2 of e2) {
31
+ const e3 = a(o2.type);
32
+ i2[o2.keyBinding] = () => t2.executeCommand(e3);
33
+ }
34
+ Object.keys(i2).length > 0 && t2.registerKeymap(i2);
35
+ }
36
+ registerDisabledToolbarItems(t2) {
37
+ if (this.config.toolbar) for (const e2 of s) {
38
+ const i2 = this.config[e2.configKey], o2 = this.config.toolbar[e2.configKey] ?? true;
39
+ !i2 && o2 && t2.registerToolbarItem({ id: e2.type, group: "format", icon: e2.icon, label: e2.label, command: a(e2.type), priority: 10 * e2.rank + 10, isEnabled: () => false });
40
+ }
41
+ }
42
+ isToolbarVisible(t2) {
43
+ return !this.config.toolbar || (this.config.toolbar[t2] ?? true);
44
+ }
45
+ }
46
+ function a(t2) {
47
+ return `toggle${t2.charAt(0).toUpperCase()}${t2.slice(1)}`;
48
+ }
49
+ export {
50
+ n as TextFormattingPlugin
51
+ };
52
+ //# sourceMappingURL=text-formatting.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-formatting.mjs","sources":["../../src/plugins/text-formatting/TextFormattingPlugin.ts"],"sourcesContent":["/**\n * TextFormattingPlugin: registers inline marks (bold, italic, underline)\n * with their MarkSpecs, toggle commands, keyboard shortcuts, and toolbar items.\n *\n * This plugin is data-driven — each mark type is defined declaratively and\n * all registrations (MarkSpec, command, keymap, toolbar item) are derived\n * from the same definition.\n *\n * Supports two separate config dimensions:\n * - Feature config (bold/italic/underline): controls whether the mark is\n * registered in the schema. When disabled, the keyboard shortcut does nothing.\n * - Toolbar config: controls whether the toolbar button is visible.\n * When a feature is disabled but toolbar is enabled, the button renders as disabled.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport type { ParseRule } from '../../model/ParseRule.js';\nimport type { SanitizeConfig } from '../../model/SanitizeConfig.js';\nimport { markType as mkType } from '../../model/TypeBrands.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\n\n// --- Configuration ---\n\n/** Controls toolbar button visibility per mark. */\nexport interface TextFormattingToolbarConfig {\n\treadonly bold?: boolean;\n\treadonly italic?: boolean;\n\treadonly underline?: boolean;\n}\n\n/** Controls which inline marks are enabled and which toolbar buttons are shown. */\nexport interface TextFormattingConfig {\n\treadonly bold: boolean;\n\treadonly italic: boolean;\n\treadonly underline: boolean;\n\treadonly toolbar?: TextFormattingToolbarConfig;\n\t/** When true, a separator is rendered after the last text-formatting toolbar item. */\n\treadonly separatorAfter?: boolean;\n}\n\nconst DEFAULT_CONFIG: TextFormattingConfig = {\n\tbold: true,\n\titalic: true,\n\tunderline: true,\n};\n\n// --- Mark Definitions ---\n\ninterface MarkDefinition {\n\treadonly type: string;\n\treadonly configKey: keyof Omit<TextFormattingConfig, 'toolbar' | 'separatorAfter'>;\n\treadonly rank: number;\n\treadonly tag: string;\n\treadonly label: string;\n\treadonly icon: string;\n\treadonly keyBinding: string;\n\treadonly toHTMLString: (content: string) => string;\n\treadonly parseHTML: readonly ParseRule[];\n\treadonly sanitize: SanitizeConfig;\n}\n\nconst BOLD_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\"/></svg>';\nconst ITALIC_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z\"/></svg>';\nconst UNDERLINE_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z\"/></svg>';\n\nconst MARK_DEFINITIONS: readonly MarkDefinition[] = [\n\t{\n\t\ttype: 'bold',\n\t\tconfigKey: 'bold',\n\t\trank: 0,\n\t\ttag: 'strong',\n\t\tlabel: 'Bold',\n\t\ticon: BOLD_ICON,\n\t\tkeyBinding: 'Mod-B',\n\t\ttoHTMLString: (content) => `<strong>${content}</strong>`,\n\t\tparseHTML: [{ tag: 'strong' }, { tag: 'b' }],\n\t\tsanitize: { tags: ['strong', 'b'] },\n\t},\n\t{\n\t\ttype: 'italic',\n\t\tconfigKey: 'italic',\n\t\trank: 1,\n\t\ttag: 'em',\n\t\tlabel: 'Italic',\n\t\ticon: ITALIC_ICON,\n\t\tkeyBinding: 'Mod-I',\n\t\ttoHTMLString: (content) => `<em>${content}</em>`,\n\t\tparseHTML: [{ tag: 'em' }, { tag: 'i' }],\n\t\tsanitize: { tags: ['em', 'i'] },\n\t},\n\t{\n\t\ttype: 'underline',\n\t\tconfigKey: 'underline',\n\t\trank: 2,\n\t\ttag: 'u',\n\t\tlabel: 'Underline',\n\t\ticon: UNDERLINE_ICON,\n\t\tkeyBinding: 'Mod-U',\n\t\ttoHTMLString: (content) => `<u>${content}</u>`,\n\t\tparseHTML: [{ tag: 'u' }],\n\t\tsanitize: { tags: ['u'] },\n\t},\n];\n\n// --- Plugin ---\n\nexport class TextFormattingPlugin implements Plugin {\n\treadonly id = 'text-formatting';\n\treadonly name = 'Text Formatting';\n\treadonly priority = 20;\n\n\tprivate readonly config: TextFormattingConfig;\n\n\tconstructor(config?: Partial<TextFormattingConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tconst enabledMarks = MARK_DEFINITIONS.filter((def) => this.config[def.configKey]);\n\n\t\t// Determine which marks will have visible toolbar items\n\t\tconst visibleToolbarMarks = enabledMarks.filter((def) => this.isToolbarVisible(def.configKey));\n\t\tconst lastVisibleMark = visibleToolbarMarks.at(-1);\n\n\t\tfor (const def of enabledMarks) {\n\t\t\tconst isSeparatorTarget = this.config.separatorAfter && def === lastVisibleMark;\n\t\t\tthis.registerMark(context, def, isSeparatorTarget);\n\t\t}\n\n\t\tthis.registerKeymaps(context, enabledMarks);\n\n\t\t// Register disabled placeholder buttons for marks that are disabled\n\t\t// as features but explicitly requested in the toolbar config\n\t\tthis.registerDisabledToolbarItems(context);\n\t}\n\n\tprivate registerMark(\n\t\tcontext: PluginContext,\n\t\tdef: MarkDefinition,\n\t\tseparatorAfter?: boolean,\n\t): void {\n\t\tconst commandName = toCommandName(def.type);\n\t\tconst toolbarVisible = this.isToolbarVisible(def.configKey);\n\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: def.type,\n\t\t\trank: def.rank,\n\t\t\ttoDOM() {\n\t\t\t\treturn document.createElement(def.tag);\n\t\t\t},\n\t\t\ttoHTMLString: (_mark, content) => def.toHTMLString(content),\n\t\t\tparseHTML: def.parseHTML,\n\t\t\tsanitize: def.sanitize,\n\t\t});\n\n\t\tcontext.registerCommand(commandName, () => {\n\t\t\tconst tr = toggleMark(context.getState(), mkType(def.type));\n\t\t\tif (tr) {\n\t\t\t\tcontext.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\n\t\tif (toolbarVisible) {\n\t\t\tcontext.registerToolbarItem({\n\t\t\t\tid: def.type,\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon: def.icon,\n\t\t\t\tlabel: def.label,\n\t\t\t\ttooltip: `${def.label} (${formatShortcut(def.keyBinding)})`,\n\t\t\t\tcommand: commandName,\n\t\t\t\tpriority: def.rank * 10 + 10,\n\t\t\t\tseparatorAfter,\n\t\t\t\tisActive: (state) => isMarkActive(state, mkType(def.type)),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate registerKeymaps(context: PluginContext, marks: readonly MarkDefinition[]): void {\n\t\tconst keymap: Record<string, () => boolean> = {};\n\t\tfor (const def of marks) {\n\t\t\tconst commandName = toCommandName(def.type);\n\t\t\tkeymap[def.keyBinding] = () => context.executeCommand(commandName);\n\t\t}\n\t\tif (Object.keys(keymap).length > 0) {\n\t\t\tcontext.registerKeymap(keymap);\n\t\t}\n\t}\n\n\t/**\n\t * Registers disabled toolbar buttons for marks whose feature is disabled\n\t * but whose toolbar button is explicitly requested.\n\t */\n\tprivate registerDisabledToolbarItems(context: PluginContext): void {\n\t\tif (!this.config.toolbar) return;\n\n\t\tfor (const def of MARK_DEFINITIONS) {\n\t\t\tconst featureEnabled = this.config[def.configKey];\n\t\t\tconst toolbarVisible = this.config.toolbar[def.configKey] ?? true;\n\n\t\t\tif (!featureEnabled && toolbarVisible) {\n\t\t\t\tcontext.registerToolbarItem({\n\t\t\t\t\tid: def.type,\n\t\t\t\t\tgroup: 'format',\n\t\t\t\t\ticon: def.icon,\n\t\t\t\t\tlabel: def.label,\n\t\t\t\t\tcommand: toCommandName(def.type),\n\t\t\t\t\tpriority: def.rank * 10 + 10,\n\t\t\t\t\tisEnabled: () => false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Checks if a toolbar button should be visible for a given mark. */\n\tprivate isToolbarVisible(\n\t\tconfigKey: keyof Omit<TextFormattingConfig, 'toolbar' | 'separatorAfter'>,\n\t): boolean {\n\t\tif (!this.config.toolbar) return true;\n\t\treturn this.config.toolbar[configKey] ?? true;\n\t}\n}\n\n/** Converts a mark type to its toggle command name (e.g. 'bold' → 'toggleBold'). */\nfunction toCommandName(markType: string): string {\n\treturn `toggle${markType.charAt(0).toUpperCase()}${markType.slice(1)}`;\n}\n"],"names":["DEFAULT_CONFIG","bold","italic","underline","MARK_DEFINITIONS","type","configKey","rank","tag","label","icon","keyBinding","toHTMLString","content","parseHTML","sanitize","tags","TextFormattingPlugin","id","name","priority","config","this","context","enabledMarks","filter","def","lastVisibleMark","isToolbarVisible","at","isSeparatorTarget","separatorAfter","registerMark","registerKeymaps","registerDisabledToolbarItems","commandName","toCommandName","toolbarVisible","registerMarkSpec","toDOM","document","createElement","_mark","registerCommand","tr","toggleMark","getState","mkType","dispatch","registerToolbarItem","group","tooltip","formatShortcut","command","isActive","state","isMarkActive","marks","keymap","executeCommand","Object","keys","length","registerKeymap","toolbar","featureEnabled","isEnabled","markType","charAt","toUpperCase","slice"],"mappings":"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"}
@@ -0,0 +1,66 @@
1
+ import { EditorState } from '../../state/EditorState.js';
2
+ import { PluginContext } from '../Plugin.js';
3
+ export interface GridPickerConfig {
4
+ readonly maxRows: number;
5
+ readonly maxCols: number;
6
+ onSelect(rows: number, cols: number): void;
7
+ }
8
+ export interface DropdownConfig {
9
+ readonly items: readonly {
10
+ label: string;
11
+ command: string;
12
+ icon?: string;
13
+ }[];
14
+ }
15
+ export type ToolbarGroup = 'format' | 'block' | 'insert' | (string & {});
16
+ export type PopupType = 'gridPicker' | 'dropdown' | 'custom';
17
+ interface ToolbarItemBase {
18
+ readonly id: string;
19
+ /** Grouping key: 'format' | 'insert' | 'block' or custom. */
20
+ readonly group: ToolbarGroup;
21
+ /** Icon content: inline SVG markup or plain text. Rendered via innerHTML. */
22
+ readonly icon: string;
23
+ readonly label: string;
24
+ /** Tooltip shown on hover, e.g. "Bold (Ctrl+B)". Falls back to label. */
25
+ readonly tooltip?: string;
26
+ /** Command name to execute on click. */
27
+ readonly command: string;
28
+ /**
29
+ * Lower priority renders further left.
30
+ * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.
31
+ */
32
+ readonly priority?: number;
33
+ /**
34
+ * When true, a visual separator is rendered after this item.
35
+ * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.
36
+ */
37
+ readonly separatorAfter?: boolean;
38
+ isActive?(state: EditorState): boolean;
39
+ isEnabled?(state: EditorState): boolean;
40
+ }
41
+ interface ToolbarItemNoPopup extends ToolbarItemBase {
42
+ readonly popupType?: undefined;
43
+ }
44
+ interface ToolbarItemGridPicker extends ToolbarItemBase {
45
+ readonly popupType: 'gridPicker';
46
+ readonly popupConfig: GridPickerConfig;
47
+ }
48
+ interface ToolbarItemDropdown extends ToolbarItemBase {
49
+ readonly popupType: 'dropdown';
50
+ readonly popupConfig: DropdownConfig;
51
+ }
52
+ interface ToolbarItemCustomPopup extends ToolbarItemBase {
53
+ readonly popupType: 'custom';
54
+ renderPopup(container: HTMLElement, context: PluginContext, onClose: () => void): void;
55
+ }
56
+ export type ToolbarItem = ToolbarItemNoPopup | ToolbarItemGridPicker | ToolbarItemDropdown | ToolbarItemCustomPopup;
57
+ /**
58
+ * Formats a keymap binding string into a human-readable shortcut,
59
+ * using platform-appropriate modifier symbols (⌘ on Mac, Ctrl on others).
60
+ *
61
+ * @example formatShortcut('Mod-B') → "Ctrl+B" or "⌘B"
62
+ * @example formatShortcut('Mod-Shift-X') → "Ctrl+Shift+X" or "⌘⇧X"
63
+ */
64
+ export declare function formatShortcut(binding: string): string;
65
+ export {};
66
+ //# sourceMappingURL=ToolbarItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarItem.d.ts","sourceRoot":"","sources":["../../../src/plugins/toolbar/ToolbarItem.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC7E;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AACzE,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE7D,UAAU,eAAe;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC;IACvC,SAAS,CAAC,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC;CACxC;AAED,UAAU,kBAAmB,SAAQ,eAAe;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAC/B;AAED,UAAU,qBAAsB,SAAQ,eAAe;IACtD,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;CACvC;AAED,UAAU,mBAAoB,SAAQ,eAAe;IACpD,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;CACrC;AAED,UAAU,sBAAuB,SAAQ,eAAe;IACvD,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC7B,WAAW,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACvF;AAED,MAAM,MAAM,WAAW,GACpB,kBAAkB,GAClB,qBAAqB,GACrB,mBAAmB,GACnB,sBAAsB,CAAC;AAE1B;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUtD"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Keyboard navigation helpers for the toolbar (WAI-ARIA Toolbar pattern).
3
+ * Pure functions that operate on arrays of buttons and DOM elements.
4
+ */
5
+ /** Returns indices of all enabled buttons. */
6
+ export declare function getEnabledIndices(buttons: readonly HTMLButtonElement[]): number[];
7
+ /** Finds the next enabled button index in the given direction (wraps around). */
8
+ export declare function findNextEnabled(buttons: readonly HTMLButtonElement[], current: number, direction: 1 | -1): number;
9
+ /** Finds the first enabled button index. */
10
+ export declare function findFirstEnabled(buttons: readonly HTMLButtonElement[]): number;
11
+ /** Finds the last enabled button index. */
12
+ export declare function findLastEnabled(buttons: readonly HTMLButtonElement[]): number;
13
+ /**
14
+ * Applies roving tabindex: sets tabindex="0" on the focused button,
15
+ * tabindex="-1" on all others.
16
+ */
17
+ export declare function applyRovingTabindex(buttons: readonly HTMLButtonElement[], focusedIndex: number): void;
18
+ /** Navigates dropdown items with arrow keys (wraps around). */
19
+ export declare function findNextDropdownItem(items: readonly HTMLElement[], current: number, direction: 1 | -1): number;
20
+ /**
21
+ * Navigates a grid of cells with arrow keys.
22
+ * Returns the new [row, col] position.
23
+ */
24
+ export declare function navigateGrid(row: number, col: number, maxRows: number, maxCols: number, key: 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight'): [number, number];
25
+ //# sourceMappingURL=ToolbarKeyboardNav.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarKeyboardNav.d.ts","sourceRoot":"","sources":["../../../src/plugins/toolbar/ToolbarKeyboardNav.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8CAA8C;AAC9C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAQjF;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAC9B,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,GACf,MAAM,CAYR;AAED,4CAA4C;AAC5C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,CAK9E;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,CAK7E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,YAAY,EAAE,MAAM,GAClB,IAAI,CAON;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,GACf,MAAM,CAIR;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,GACvD,CAAC,MAAM,EAAE,MAAM,CAAC,CAWlB"}
@@ -0,0 +1,47 @@
1
+ import { EditorState } from '../../state/EditorState.js';
2
+ import { Transaction } from '../../state/Transaction.js';
3
+ import { ServiceKey, Plugin, PluginConfig, PluginContext } from '../Plugin.js';
4
+ export interface ToolbarLayoutConfig {
5
+ readonly groups: ReadonlyArray<ReadonlyArray<string>>;
6
+ }
7
+ export interface ToolbarServiceAPI {
8
+ /** Re-reads isActive/isEnabled from state and updates all buttons. */
9
+ refresh(): void;
10
+ /** Closes the currently open popup, if any. */
11
+ closePopup(): void;
12
+ }
13
+ export declare const ToolbarServiceKey: ServiceKey<ToolbarServiceAPI>;
14
+ export declare class ToolbarPlugin implements Plugin {
15
+ readonly id = "toolbar";
16
+ readonly name = "Toolbar";
17
+ readonly priority = 10;
18
+ private context;
19
+ private toolbarElement;
20
+ private buttons;
21
+ private readonly hiddenItems;
22
+ private readonly layoutConfig;
23
+ private focusedIndex;
24
+ private tooltip;
25
+ private popupController;
26
+ constructor(layoutConfig?: ToolbarLayoutConfig);
27
+ init(context: PluginContext): void;
28
+ onReady(): void;
29
+ destroy(): void;
30
+ onStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void;
31
+ onConfigure(config: PluginConfig): void;
32
+ private createToolbarElement;
33
+ private renderItems;
34
+ private initRovingTabindex;
35
+ private setRovingFocus;
36
+ /** Returns the active element, respecting shadow DOM boundaries. */
37
+ private getActiveElement;
38
+ private syncFocusedIndex;
39
+ private handleToolbarKeydown;
40
+ /** Activates a toolbar button (shared between mouse click and keyboard). */
41
+ private activateButton;
42
+ private renderItemsByLayout;
43
+ private renderItemsByPriority;
44
+ private createButton;
45
+ private updateButtonStates;
46
+ }
47
+ //# sourceMappingURL=ToolbarPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/toolbar/ToolbarPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAcxE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;CACtD;AAID,MAAM,WAAW,iBAAiB;IACjC,sEAAsE;IACtE,OAAO,IAAI,IAAI,CAAC;IAChB,+CAA+C;IAC/C,UAAU,IAAI,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,iBAAiB,+BAA+C,CAAC;AAS9E,qBAAa,aAAc,YAAW,MAAM;IAC3C,QAAQ,CAAC,EAAE,aAAa;IACxB,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,QAAQ,MAAM;IAEvB,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAC1D,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,eAAe,CAAuC;gBAElD,YAAY,CAAC,EAAE,mBAAmB;IAI9C,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAelC,OAAO,IAAI,IAAI;IAIf,OAAO,IAAI,IAAI;IAaf,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI;IAIpF,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAavC,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,WAAW;IA6BnB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,cAAc;IAQtB,oEAAoE;IACpE,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,oBAAoB;IAyC5B,4EAA4E;IAC5E,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,mBAAmB;IAmC3B,OAAO,CAAC,qBAAqB;IAwD7B,OAAO,CAAC,YAAY;IAkCpB,OAAO,CAAC,kBAAkB;CAc1B"}
@@ -0,0 +1,25 @@
1
+ import { PluginContext } from '../Plugin.js';
2
+ import { ToolbarItem } from './ToolbarItem.js';
3
+ export declare class ToolbarPopupController {
4
+ private activePopup;
5
+ private activePopupButton;
6
+ private closePopupHandler;
7
+ private readonly getActiveElement;
8
+ constructor(getActiveElement: () => Element | null);
9
+ /** Whether a popup is currently open. */
10
+ isOpen(): boolean;
11
+ /** Toggles a popup for the given toolbar button. */
12
+ toggle(button: HTMLButtonElement, item: ToolbarItem, context: PluginContext): void;
13
+ /** Closes the active popup and cleans up event listeners. */
14
+ close(): void;
15
+ /** Closes popup and restores focus to the trigger button. */
16
+ closeAndRestoreFocus(): void;
17
+ destroy(): void;
18
+ private positionAndAppend;
19
+ private focusFirstItem;
20
+ private handlePopupKeydown;
21
+ private handleDropdownKeydown;
22
+ private handleGridKeydown;
23
+ private handleCustomPopupKeydown;
24
+ }
25
+ //# sourceMappingURL=ToolbarPopupController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarPopupController.d.ts","sourceRoot":"","sources":["../../../src/plugins/toolbar/ToolbarPopupController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,qBAAa,sBAAsB;IAClC,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,iBAAiB,CAA0C;IACnE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;gBAE5C,gBAAgB,EAAE,MAAM,OAAO,GAAG,IAAI;IAIlD,yCAAyC;IACzC,MAAM,IAAI,OAAO;IAIjB,oDAAoD;IACpD,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI;IAkDlF,6DAA6D;IAC7D,KAAK,IAAI,IAAI;IAgBb,6DAA6D;IAC7D,oBAAoB,IAAI,IAAI;IAM5B,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,kBAAkB;IA+B1B,OAAO,CAAC,qBAAqB;IA2B7B,OAAO,CAAC,iBAAiB;IAuCzB,OAAO,CAAC,wBAAwB;CA8BhC"}
@@ -0,0 +1,19 @@
1
+ import { DropdownConfig, GridPickerConfig } from './ToolbarItem.js';
2
+ /**
3
+ * Renders a grid picker into the given container.
4
+ * Calls `onClose` after a cell is selected so the popup can be dismissed.
5
+ */
6
+ export declare function renderGridPicker(container: HTMLElement, config: GridPickerConfig, onClose: () => void): void;
7
+ /**
8
+ * Highlights grid cells up to the given row/col and updates the label.
9
+ * Used by both mouse hover and keyboard navigation.
10
+ */
11
+ export declare function highlightCells(grid: HTMLElement, targetRow: number, targetCol: number): void;
12
+ /**
13
+ * Renders a dropdown menu into the given container.
14
+ * Calls `onClose` after an item is activated so the popup can be dismissed.
15
+ */
16
+ export declare function renderDropdown(container: HTMLElement, config: DropdownConfig, executeCommand: (command: string) => void, onClose: () => void): void;
17
+ /** Creates a toolbar group separator element. */
18
+ export declare function createSeparator(): HTMLSpanElement;
19
+ //# sourceMappingURL=ToolbarRenderers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarRenderers.d.ts","sourceRoot":"","sources":["../../../src/plugins/toolbar/ToolbarRenderers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIzE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,MAAM,IAAI,GACjB,IAAI,CAwDN;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAO5F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC7B,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,cAAc,EACtB,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EACzC,OAAO,EAAE,MAAM,IAAI,GACjB,IAAI,CAqCN;AAED,iDAAiD;AACjD,wBAAgB,eAAe,IAAI,eAAe,CAKjD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ToolbarTooltip: manages the tooltip lifecycle for toolbar buttons.
3
+ * Shows a tooltip after a short delay when hovering or focusing a button,
4
+ * hides it when the cursor leaves or focus moves away.
5
+ */
6
+ export declare class ToolbarTooltip {
7
+ private readonly element;
8
+ private timer;
9
+ private target;
10
+ private readonly isPopupActive;
11
+ static readonly TOOLTIP_ID = "notectl-toolbar-tooltip";
12
+ constructor(isPopupActive: () => boolean);
13
+ show(button: HTMLButtonElement): void;
14
+ hide(): void;
15
+ destroy(): void;
16
+ }
17
+ //# sourceMappingURL=ToolbarTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarTooltip.d.ts","sourceRoot":"","sources":["../../../src/plugins/toolbar/ToolbarTooltip.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,qBAAa,cAAc;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,KAAK,CAA8C;IAC3D,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAE9C,MAAM,CAAC,QAAQ,CAAC,UAAU,6BAA6B;gBAE3C,aAAa,EAAE,MAAM,OAAO;IASxC,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAiCrC,IAAI,IAAI,IAAI;IAYZ,OAAO,IAAI,IAAI;CAIf"}
@@ -0,0 +1,4 @@
1
+ export { ToolbarPlugin, ToolbarServiceKey, type ToolbarServiceAPI, type ToolbarLayoutConfig, } from './ToolbarPlugin.js';
2
+ export type { ToolbarItem, ToolbarGroup, PopupType, GridPickerConfig, DropdownConfig, } from './ToolbarItem.js';
3
+ export { formatShortcut } from './ToolbarItem.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/toolbar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACxB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,cAAc,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { T, a } from "../chunks/ToolbarPlugin-D5VqeBPT.mjs";
2
+ import { f } from "../chunks/ToolbarItem-ugDymuXi.mjs";
3
+ export {
4
+ T as ToolbarPlugin,
5
+ a as ToolbarServiceKey,
6
+ f as formatShortcut
7
+ };
8
+ //# sourceMappingURL=toolbar.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbar.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,40 @@
1
+ import { BlockNode, Document, Mark } from '../model/Document.js';
2
+ import { Schema } from '../model/Schema.js';
3
+ import { EditorSelection } from '../model/Selection.js';
4
+ import { BlockId } from '../model/TypeBrands.js';
5
+ import { Transaction, TransactionBuilder } from './Transaction.js';
6
+ export declare class EditorState {
7
+ readonly doc: Document;
8
+ readonly selection: EditorSelection;
9
+ readonly storedMarks: readonly Mark[] | null;
10
+ readonly schema: Schema;
11
+ private _blockMap;
12
+ private _blockOrder;
13
+ private constructor();
14
+ /** Creates a new EditorState with default document. */
15
+ static create(options?: {
16
+ doc?: Document;
17
+ selection?: EditorSelection;
18
+ schema?: Schema;
19
+ }): EditorState;
20
+ /** Creates a TransactionBuilder from this state. */
21
+ transaction(origin?: 'input' | 'paste' | 'command' | 'history' | 'api'): TransactionBuilder;
22
+ /** Applies a transaction and returns a new EditorState. */
23
+ apply(tr: Transaction): EditorState;
24
+ /** Finds a block by its ID anywhere in the tree. Uses a lazy-built Map for O(1) lookup. */
25
+ getBlock(blockId: BlockId): BlockNode | undefined;
26
+ /** Returns leaf-block IDs in depth-first order. Cached after first call. */
27
+ getBlockOrder(): readonly BlockId[];
28
+ /** Returns the path (array of block IDs) to a node. */
29
+ getNodePath(nodeId: BlockId): BlockId[] | undefined;
30
+ /** Returns the parent BlockNode of a node, or undefined for top-level blocks. */
31
+ getParent(nodeId: BlockId): BlockNode | undefined;
32
+ /** Serializes the state to JSON. */
33
+ toJSON(): object;
34
+ /** Deserializes a state from JSON. */
35
+ static fromJSON(json: {
36
+ doc: Document;
37
+ selection: EditorSelection;
38
+ }, schema?: Schema): EditorState;
39
+ }
40
+ //# sourceMappingURL=EditorState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorState.d.ts","sourceRoot":"","sources":["../../src/state/EditorState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,IAAI,EAKT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAY,MAAM,uBAAuB,CAAC;AAOvE,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qBAAa,WAAW;IACvB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,SAAS,CAAwC;IACzD,OAAO,CAAC,WAAW,CAAmC;IAEtD,OAAO;IAYP,uDAAuD;IACvD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QACvB,GAAG,CAAC,EAAE,QAAQ,CAAC;QACf,SAAS,CAAC,EAAE,eAAe,CAAC;QAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,WAAW;IAUf,oDAAoD;IACpD,WAAW,CACV,MAAM,GAAE,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,KAAa,GAC/D,kBAAkB;IAIrB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,EAAE,WAAW,GAAG,WAAW;IAWnC,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS;IAKjD,4EAA4E;IAC5E,aAAa,IAAI,SAAS,OAAO,EAAE;IAKnC,uDAAuD;IACvD,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,SAAS;IAInD,iFAAiF;IACjF,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS;IAQjD,oCAAoC;IACpC,MAAM,IAAI,MAAM;IAOhB,sCAAsC;IACtC,MAAM,CAAC,QAAQ,CACd,IAAI,EAAE;QAAE,GAAG,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,eAAe,CAAA;KAAE,EACnD,MAAM,CAAC,EAAE,MAAM,GACb,WAAW;CAGd"}
@@ -0,0 +1,38 @@
1
+ import { EditorState } from './EditorState.js';
2
+ import { Transaction } from './Transaction.js';
3
+ export interface HistoryResult {
4
+ readonly state: EditorState;
5
+ readonly transaction: Transaction;
6
+ }
7
+ export declare class HistoryManager {
8
+ private undoStack;
9
+ private redoStack;
10
+ private readonly groupTimeoutMs;
11
+ private readonly maxDepth;
12
+ private lastOrigin;
13
+ constructor(options?: {
14
+ groupTimeoutMs?: number;
15
+ maxDepth?: number;
16
+ });
17
+ /**
18
+ * Pushes a transaction onto the undo stack.
19
+ * Groups consecutive input transactions within the timeout window.
20
+ */
21
+ push(tr: Transaction): void;
22
+ /** Undoes the last group and returns the new state with transaction, or null if nothing to undo. */
23
+ undo(state: EditorState): HistoryResult | null;
24
+ /** Redoes the last undone group and returns the new state with transaction, or null if nothing to redo. */
25
+ redo(state: EditorState): HistoryResult | null;
26
+ /** Returns true if there are entries to undo. */
27
+ canUndo(): boolean;
28
+ /** Returns true if there are entries to redo. */
29
+ canRedo(): boolean;
30
+ /** Clears all history. */
31
+ clear(): void;
32
+ /**
33
+ * Checks if consecutive transactions are of the same "type" for grouping.
34
+ * Groups text insertion together, deletion together, but not mixed.
35
+ */
36
+ private isSameInputType;
37
+ }
38
+ //# sourceMappingURL=History.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../src/state/History.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAQ,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG1D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CAClC;AAUD,qBAAa,cAAc;IAC1B,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,UAAU,CAAuB;gBAE7B,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;IAKpE;;;OAGG;IACH,IAAI,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI;IAsC3B,oGAAoG;IACpG,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,GAAG,IAAI;IAmC9C,2GAA2G;IAC3G,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,GAAG,IAAI;IAgC9C,iDAAiD;IACjD,OAAO,IAAI,OAAO;IAIlB,iDAAiD;IACjD,OAAO,IAAI,OAAO;IAIlB,0BAA0B;IAC1B,KAAK,IAAI,IAAI;IAMb;;;OAGG;IACH,OAAO,CAAC,eAAe;CAUvB"}
@@ -0,0 +1,5 @@
1
+ import { Document } from '../model/Document.js';
2
+ import { Step } from './Transaction.js';
3
+ /** Applies a single step to a document and returns the new document. */
4
+ export declare function applyStep(doc: Document, step: Step): Document;
5
+ //# sourceMappingURL=StepApplication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepApplication.d.ts","sourceRoot":"","sources":["../../src/state/StepApplication.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGN,KAAK,QAAQ,EAeb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAcX,IAAI,EACJ,MAAM,kBAAkB,CAAC;AAE1B,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,CA+B7D"}
@@ -0,0 +1,185 @@
1
+ import { BlockAttrs, BlockNode, Document, InlineNode, Mark, TextSegment } from '../model/Document.js';
2
+ import { EditorSelection } from '../model/Selection.js';
3
+ import { BlockId, NodeTypeName } from '../model/TypeBrands.js';
4
+ export interface InsertTextStep {
5
+ readonly type: 'insertText';
6
+ readonly blockId: BlockId;
7
+ readonly offset: number;
8
+ readonly text: string;
9
+ readonly marks: readonly Mark[];
10
+ readonly segments?: readonly TextSegment[];
11
+ readonly path?: readonly BlockId[];
12
+ }
13
+ export interface DeleteTextStep {
14
+ readonly type: 'deleteText';
15
+ readonly blockId: BlockId;
16
+ readonly from: number;
17
+ readonly to: number;
18
+ readonly deletedText: string;
19
+ readonly deletedMarks: readonly Mark[];
20
+ readonly deletedSegments: readonly TextSegment[];
21
+ readonly path?: readonly BlockId[];
22
+ }
23
+ export interface SplitBlockStep {
24
+ readonly type: 'splitBlock';
25
+ readonly blockId: BlockId;
26
+ readonly offset: number;
27
+ readonly newBlockId: BlockId;
28
+ readonly path?: readonly BlockId[];
29
+ }
30
+ export interface MergeBlocksStep {
31
+ readonly type: 'mergeBlocks';
32
+ readonly targetBlockId: BlockId;
33
+ readonly sourceBlockId: BlockId;
34
+ readonly targetLengthBefore: number;
35
+ readonly path?: readonly BlockId[];
36
+ }
37
+ export interface AddMarkStep {
38
+ readonly type: 'addMark';
39
+ readonly blockId: BlockId;
40
+ readonly from: number;
41
+ readonly to: number;
42
+ readonly mark: Mark;
43
+ readonly path?: readonly BlockId[];
44
+ }
45
+ export interface RemoveMarkStep {
46
+ readonly type: 'removeMark';
47
+ readonly blockId: BlockId;
48
+ readonly from: number;
49
+ readonly to: number;
50
+ readonly mark: Mark;
51
+ readonly path?: readonly BlockId[];
52
+ }
53
+ export interface SetStoredMarksStep {
54
+ readonly type: 'setStoredMarks';
55
+ readonly marks: readonly Mark[] | null;
56
+ readonly previousMarks: readonly Mark[] | null;
57
+ }
58
+ export interface SetBlockTypeStep {
59
+ readonly type: 'setBlockType';
60
+ readonly blockId: BlockId;
61
+ readonly nodeType: NodeTypeName;
62
+ readonly attrs?: BlockAttrs;
63
+ readonly previousNodeType: NodeTypeName;
64
+ readonly previousAttrs?: BlockAttrs;
65
+ readonly path?: readonly BlockId[];
66
+ }
67
+ export interface InsertNodeStep {
68
+ readonly type: 'insertNode';
69
+ readonly parentPath: readonly BlockId[];
70
+ readonly index: number;
71
+ readonly node: BlockNode;
72
+ }
73
+ export interface RemoveNodeStep {
74
+ readonly type: 'removeNode';
75
+ readonly parentPath: readonly BlockId[];
76
+ readonly index: number;
77
+ readonly removedNode: BlockNode;
78
+ }
79
+ export interface SetNodeAttrStep {
80
+ readonly type: 'setNodeAttr';
81
+ readonly path: readonly BlockId[];
82
+ readonly attrs: BlockAttrs | undefined;
83
+ readonly previousAttrs?: BlockAttrs;
84
+ }
85
+ export interface InsertInlineNodeStep {
86
+ readonly type: 'insertInlineNode';
87
+ readonly blockId: BlockId;
88
+ readonly offset: number;
89
+ readonly node: InlineNode;
90
+ readonly path?: readonly BlockId[];
91
+ }
92
+ export interface RemoveInlineNodeStep {
93
+ readonly type: 'removeInlineNode';
94
+ readonly blockId: BlockId;
95
+ readonly offset: number;
96
+ readonly removedNode: InlineNode;
97
+ readonly path?: readonly BlockId[];
98
+ }
99
+ export interface SetInlineNodeAttrStep {
100
+ readonly type: 'setInlineNodeAttr';
101
+ readonly blockId: BlockId;
102
+ readonly offset: number;
103
+ readonly attrs: Readonly<Record<string, string | number | boolean>>;
104
+ readonly previousAttrs: Readonly<Record<string, string | number | boolean>>;
105
+ readonly path?: readonly BlockId[];
106
+ }
107
+ export type Step = InsertTextStep | DeleteTextStep | SplitBlockStep | MergeBlocksStep | AddMarkStep | RemoveMarkStep | SetStoredMarksStep | SetBlockTypeStep | InsertNodeStep | RemoveNodeStep | SetNodeAttrStep | InsertInlineNodeStep | RemoveInlineNodeStep | SetInlineNodeAttrStep;
108
+ export type TransactionOrigin = 'input' | 'paste' | 'command' | 'history' | 'api';
109
+ export interface TransactionMetadata {
110
+ readonly origin: TransactionOrigin;
111
+ readonly timestamp: number;
112
+ readonly historyDirection?: 'undo' | 'redo';
113
+ }
114
+ export interface Transaction {
115
+ readonly steps: readonly Step[];
116
+ readonly selectionBefore: EditorSelection;
117
+ readonly selectionAfter: EditorSelection;
118
+ readonly storedMarksAfter: readonly Mark[] | null;
119
+ readonly metadata: TransactionMetadata;
120
+ }
121
+ /** Inverts a single step for undo. */
122
+ export declare function invertStep(step: Step): Step;
123
+ /** Inverts an entire transaction (reverses step order and swaps selections). */
124
+ export declare function invertTransaction(tr: Transaction): Transaction;
125
+ /** Fluent API for building transactions. */
126
+ export declare class TransactionBuilder {
127
+ private readonly steps;
128
+ private selection;
129
+ private storedMarks;
130
+ private readonly selectionBefore;
131
+ private readonly origin;
132
+ private workingDoc;
133
+ constructor(currentSelection: EditorSelection, currentStoredMarks: readonly Mark[] | null, origin?: TransactionOrigin, doc?: Document);
134
+ /** Adds an insert-text step. Updates workingDoc if available. */
135
+ insertText(blockId: BlockId, offset: number, text: string, marks: readonly Mark[], segments?: readonly TextSegment[]): this;
136
+ /** Adds a delete-text step with explicit data. Updates workingDoc if available. */
137
+ deleteText(blockId: BlockId, from: number, to: number, deletedText: string, deletedMarks: readonly Mark[], deletedSegments?: readonly TextSegment[]): this;
138
+ /**
139
+ * Deletes text at the given range, auto-deriving deletedText, deletedMarks, and deletedSegments
140
+ * from the working document. Requires a document to be provided at construction.
141
+ */
142
+ deleteTextAt(blockId: BlockId, from: number, to: number): this;
143
+ /** Adds a split-block step. Updates workingDoc if available. */
144
+ splitBlock(blockId: BlockId, offset: number, newBlockId: BlockId): this;
145
+ /** Adds a merge-blocks step with explicit targetLengthBefore. Updates workingDoc if available. */
146
+ mergeBlocks(targetBlockId: BlockId, sourceBlockId: BlockId, targetLengthBefore: number): this;
147
+ /**
148
+ * Merges two blocks, auto-deriving targetLengthBefore from the working document.
149
+ * Requires a document to be provided at construction.
150
+ */
151
+ mergeBlocksAt(targetBlockId: BlockId, sourceBlockId: BlockId): this;
152
+ /** Adds an add-mark step. Updates workingDoc if available. */
153
+ addMark(blockId: BlockId, from: number, to: number, mark: Mark): this;
154
+ /** Adds a remove-mark step. Updates workingDoc if available. */
155
+ removeMark(blockId: BlockId, from: number, to: number, mark: Mark): this;
156
+ /** Adds a set-block-type step, changing a block's node type and optionally its attrs. */
157
+ setBlockType(blockId: BlockId, nodeType: NodeTypeName, attrs?: BlockAttrs): this;
158
+ /** Inserts a node as a child of the parent at the given path and index. */
159
+ insertNode(parentPath: readonly BlockId[], index: number, node: BlockNode): this;
160
+ /** Removes a node at the given index from the parent at the given path. */
161
+ removeNode(parentPath: readonly BlockId[], index: number): this;
162
+ /** Sets attributes on a node at the given path. */
163
+ setNodeAttr(path: readonly BlockId[], attrs: BlockAttrs): this;
164
+ /** Inserts an InlineNode at the given offset within a block. */
165
+ insertInlineNode(blockId: BlockId, offset: number, node: InlineNode): this;
166
+ /** Removes an InlineNode at the given offset, deriving removedNode from workingDoc. */
167
+ removeInlineNode(blockId: BlockId, offset: number): this;
168
+ /** Sets attributes on an InlineNode at the given offset. */
169
+ setInlineNodeAttr(blockId: BlockId, offset: number, attrs: Readonly<Record<string, string | number | boolean>>): this;
170
+ /** Sets the selection for the resulting state. */
171
+ setSelection(selection: EditorSelection): this;
172
+ /** Sets a NodeSelection for the resulting state. */
173
+ setNodeSelection(nodeId: BlockId, path: readonly BlockId[]): this;
174
+ /** Sets stored marks for the resulting state. */
175
+ setStoredMarks(marks: readonly Mark[] | null, previousMarks: readonly Mark[] | null): this;
176
+ /** Builds the final transaction. */
177
+ build(): Transaction;
178
+ /** Advances the working document by applying a step. */
179
+ private advanceDoc;
180
+ }
181
+ /** Helper to create a TransactionBuilder with input origin. */
182
+ export declare function inputTransaction(selection: EditorSelection, storedMarks: readonly Mark[] | null): TransactionBuilder;
183
+ /** Helper to create a TransactionBuilder with command origin. */
184
+ export declare function commandTransaction(selection: EditorSelection, storedMarks: readonly Mark[] | null): TransactionBuilder;
185
+ //# sourceMappingURL=Transaction.d.ts.map