@notectl/core 1.0.5 → 1.0.8

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 (250) hide show
  1. package/README.md +78 -55
  2. package/custom-elements.json +344 -0
  3. package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs → AttrRegistry-D-przlzb.mjs} +4 -4
  4. package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs.map → AttrRegistry-D-przlzb.mjs.map} +1 -1
  5. package/dist/chunks/ColorNames-iaWsSZx1.mjs +35 -0
  6. package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +1 -0
  7. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +140 -0
  8. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +1 -0
  9. package/dist/chunks/{Commands-DLP85Mp5.mjs → Commands-CSpSwGXv.mjs} +13 -13
  10. package/dist/chunks/{Commands-DLP85Mp5.mjs.map → Commands-CSpSwGXv.mjs.map} +1 -1
  11. package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs +46 -0
  12. package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs.map +1 -0
  13. package/dist/chunks/{ToolbarPlugin-D5VqeBPT.mjs → ToolbarPlugin-DY2xaJiu.mjs} +63 -93
  14. package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +1 -0
  15. package/dist/chunks/index-BAk1EG1x.mjs +541 -0
  16. package/dist/chunks/index-BAk1EG1x.mjs.map +1 -0
  17. package/dist/chunks/index-BRYzYOYC.mjs +63 -0
  18. package/dist/chunks/index-BRYzYOYC.mjs.map +1 -0
  19. package/dist/chunks/index-BSFLNveF.mjs +953 -0
  20. package/dist/chunks/index-BSFLNveF.mjs.map +1 -0
  21. package/dist/chunks/index-BYgspns5.mjs +209 -0
  22. package/dist/chunks/index-BYgspns5.mjs.map +1 -0
  23. package/dist/chunks/index-B_3qDrUN.mjs +64 -0
  24. package/dist/chunks/index-B_3qDrUN.mjs.map +1 -0
  25. package/dist/chunks/index-Bsp4LC5t.mjs +130 -0
  26. package/dist/chunks/index-Bsp4LC5t.mjs.map +1 -0
  27. package/dist/chunks/index-C-YWHOcC.mjs +100 -0
  28. package/dist/chunks/index-C-YWHOcC.mjs.map +1 -0
  29. package/dist/chunks/index-C2GQoHot.mjs +92 -0
  30. package/dist/chunks/index-C2GQoHot.mjs.map +1 -0
  31. package/dist/chunks/index-CT3HGdQt.mjs +39 -0
  32. package/dist/chunks/index-CT3HGdQt.mjs.map +1 -0
  33. package/dist/chunks/index-Ct0ivLhO.mjs +407 -0
  34. package/dist/chunks/index-Ct0ivLhO.mjs.map +1 -0
  35. package/dist/chunks/index-CxiWyUho.mjs +191 -0
  36. package/dist/chunks/index-CxiWyUho.mjs.map +1 -0
  37. package/dist/chunks/index-D3CQWJiw.mjs +200 -0
  38. package/dist/chunks/index-D3CQWJiw.mjs.map +1 -0
  39. package/dist/chunks/index-DC1EK22F.mjs +41 -0
  40. package/dist/chunks/index-DC1EK22F.mjs.map +1 -0
  41. package/dist/chunks/index-Dh76rR13.mjs +196 -0
  42. package/dist/chunks/index-Dh76rR13.mjs.map +1 -0
  43. package/dist/chunks/index-o6hDR07y.mjs +41 -0
  44. package/dist/chunks/index-o6hDR07y.mjs.map +1 -0
  45. package/dist/chunks/index-uTnc9y7M.mjs +62 -0
  46. package/dist/chunks/index-uTnc9y7M.mjs.map +1 -0
  47. package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs +34 -0
  48. package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -0
  49. package/dist/editor/EditorDOM.d.ts.map +1 -1
  50. package/dist/editor/NotectlEditor.d.ts +15 -1
  51. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  52. package/dist/editor/PaperLayoutController.d.ts +27 -0
  53. package/dist/editor/PaperLayoutController.d.ts.map +1 -0
  54. package/dist/editor/PaperSize.d.ts +35 -0
  55. package/dist/editor/PaperSize.d.ts.map +1 -0
  56. package/dist/editor/styles/color-picker.d.ts +1 -1
  57. package/dist/editor/styles/color-picker.d.ts.map +1 -1
  58. package/dist/editor/styles/paper.d.ts +3 -0
  59. package/dist/editor/styles/paper.d.ts.map +1 -0
  60. package/dist/editor/styles/table.d.ts +1 -1
  61. package/dist/editor/styles/table.d.ts.map +1 -1
  62. package/dist/editor/styles/toolbar.d.ts +1 -1
  63. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  64. package/dist/editor/styles.d.ts.map +1 -1
  65. package/dist/i18n/Locale.d.ts +17 -0
  66. package/dist/i18n/Locale.d.ts.map +1 -0
  67. package/dist/i18n/LocaleService.d.ts +8 -0
  68. package/dist/i18n/LocaleService.d.ts.map +1 -0
  69. package/dist/i18n/index.d.ts +4 -0
  70. package/dist/i18n/index.d.ts.map +1 -0
  71. package/dist/i18n/resolvePluginLocale.d.ts +3 -0
  72. package/dist/i18n/resolvePluginLocale.d.ts.map +1 -0
  73. package/dist/index.d.ts +44 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  76. package/dist/input/InputHandler.d.ts.map +1 -1
  77. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  78. package/dist/input/PasteHandler.d.ts.map +1 -1
  79. package/dist/notectl-core.mjs +1145 -837
  80. package/dist/notectl-core.mjs.map +1 -1
  81. package/dist/notectl-core.umd.js +2368 -1826
  82. package/dist/notectl-core.umd.js.map +1 -1
  83. package/dist/plugins/PluginManager.d.ts +8 -1
  84. package/dist/plugins/PluginManager.d.ts.map +1 -1
  85. package/dist/plugins/alignment/AlignmentLocale.d.ts +19 -0
  86. package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -0
  87. package/dist/plugins/alignment/AlignmentPlugin.d.ts +4 -0
  88. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
  89. package/dist/plugins/alignment.mjs +3 -89
  90. package/dist/plugins/alignment.mjs.map +1 -1
  91. package/dist/plugins/blockquote/BlockquoteLocale.d.ts +17 -0
  92. package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -0
  93. package/dist/plugins/blockquote/BlockquotePlugin.d.ts +3 -0
  94. package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
  95. package/dist/plugins/blockquote.mjs +2 -55
  96. package/dist/plugins/blockquote.mjs.map +1 -1
  97. package/dist/plugins/code-block/CodeBlockCommands.d.ts +5 -0
  98. package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -0
  99. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts +10 -0
  100. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -0
  101. package/dist/plugins/code-block/CodeBlockLocale.d.ts +17 -0
  102. package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -0
  103. package/dist/plugins/code-block/CodeBlockNodeView.d.ts +1 -1
  104. package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
  105. package/dist/plugins/code-block/CodeBlockPlugin.d.ts +4 -111
  106. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
  107. package/dist/plugins/code-block/CodeBlockService.d.ts +5 -0
  108. package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -0
  109. package/dist/plugins/code-block/CodeBlockTypes.d.ts +71 -0
  110. package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -0
  111. package/dist/plugins/code-block.mjs +3 -3
  112. package/dist/plugins/font/FontLocale.d.ts +15 -0
  113. package/dist/plugins/font/FontLocale.d.ts.map +1 -0
  114. package/dist/plugins/font/FontPlugin.d.ts +3 -0
  115. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  116. package/dist/plugins/font-size/FontSizeLocale.d.ts +17 -0
  117. package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -0
  118. package/dist/plugins/font-size/FontSizeOperations.d.ts +22 -0
  119. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -0
  120. package/dist/plugins/font-size/FontSizePlugin.d.ts +4 -10
  121. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  122. package/dist/plugins/font-size/FontSizePopup.d.ts +11 -0
  123. package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -0
  124. package/dist/plugins/font-size.mjs +2 -217
  125. package/dist/plugins/font-size.mjs.map +1 -1
  126. package/dist/plugins/font.mjs +2 -183
  127. package/dist/plugins/font.mjs.map +1 -1
  128. package/dist/plugins/hard-break.mjs +1 -1
  129. package/dist/plugins/heading/HeadingLocale.d.ts +26 -0
  130. package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -0
  131. package/dist/plugins/heading/HeadingPlugin.d.ts +4 -0
  132. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
  133. package/dist/plugins/heading.mjs +1 -184
  134. package/dist/plugins/heading.mjs.map +1 -1
  135. package/dist/plugins/highlight/HighlightLocale.d.ts +17 -0
  136. package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -0
  137. package/dist/plugins/highlight/HighlightPlugin.d.ts +3 -5
  138. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  139. package/dist/plugins/highlight.mjs +2 -123
  140. package/dist/plugins/highlight.mjs.map +1 -1
  141. package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts +15 -0
  142. package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -0
  143. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +4 -0
  144. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
  145. package/dist/plugins/horizontal-rule.mjs +2 -56
  146. package/dist/plugins/horizontal-rule.mjs.map +1 -1
  147. package/dist/plugins/image/ImageLocale.d.ts +25 -0
  148. package/dist/plugins/image/ImageLocale.d.ts.map +1 -0
  149. package/dist/plugins/image/ImageNodeView.d.ts.map +1 -1
  150. package/dist/plugins/image/ImagePlugin.d.ts +1 -0
  151. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  152. package/dist/plugins/image/ImageUpload.d.ts +3 -0
  153. package/dist/plugins/image/ImageUpload.d.ts.map +1 -1
  154. package/dist/plugins/image.mjs +4 -378
  155. package/dist/plugins/image.mjs.map +1 -1
  156. package/dist/plugins/link/LinkLocale.d.ts +23 -0
  157. package/dist/plugins/link/LinkLocale.d.ts.map +1 -0
  158. package/dist/plugins/link/LinkPlugin.d.ts +3 -0
  159. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  160. package/dist/plugins/link.mjs +2 -124
  161. package/dist/plugins/link.mjs.map +1 -1
  162. package/dist/plugins/list/ListLocale.d.ts +18 -0
  163. package/dist/plugins/list/ListLocale.d.ts.map +1 -0
  164. package/dist/plugins/list/ListPlugin.d.ts +4 -0
  165. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  166. package/dist/plugins/list.mjs +2 -190
  167. package/dist/plugins/list.mjs.map +1 -1
  168. package/dist/plugins/print/PrintContentPreparer.d.ts +12 -0
  169. package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -0
  170. package/dist/plugins/print/PrintLocale.d.ts +16 -0
  171. package/dist/plugins/print/PrintLocale.d.ts.map +1 -0
  172. package/dist/plugins/print/PrintPlugin.d.ts +13 -0
  173. package/dist/plugins/print/PrintPlugin.d.ts.map +1 -0
  174. package/dist/plugins/print/PrintServiceImpl.d.ts +7 -0
  175. package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -0
  176. package/dist/plugins/print/PrintStyleCollector.d.ts +17 -0
  177. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -0
  178. package/dist/plugins/print/PrintTypes.d.ts +61 -0
  179. package/dist/plugins/print/PrintTypes.d.ts.map +1 -0
  180. package/dist/plugins/shared/ColorMarkOperations.d.ts +28 -0
  181. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -0
  182. package/dist/plugins/shared/ColorNames.d.ts +22 -0
  183. package/dist/plugins/shared/ColorNames.d.ts.map +1 -0
  184. package/dist/plugins/shared/ColorPickerPopup.d.ts +31 -0
  185. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -0
  186. package/dist/plugins/shared/ColorValidation.d.ts +14 -0
  187. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -0
  188. package/dist/plugins/strikethrough/StrikethroughLocale.d.ts +17 -0
  189. package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -0
  190. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +3 -0
  191. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
  192. package/dist/plugins/strikethrough.mjs +2 -32
  193. package/dist/plugins/strikethrough.mjs.map +1 -1
  194. package/dist/plugins/super-sub/SuperSubLocale.d.ts +19 -0
  195. package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -0
  196. package/dist/plugins/super-sub/SuperSubPlugin.d.ts +3 -0
  197. package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
  198. package/dist/plugins/super-sub.mjs +2 -78
  199. package/dist/plugins/super-sub.mjs.map +1 -1
  200. package/dist/plugins/table/TableBorderColor.d.ts +24 -0
  201. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -0
  202. package/dist/plugins/table/TableCommands.d.ts +9 -8
  203. package/dist/plugins/table/TableCommands.d.ts.map +1 -1
  204. package/dist/plugins/table/TableContextMenu.d.ts +14 -0
  205. package/dist/plugins/table/TableContextMenu.d.ts.map +1 -0
  206. package/dist/plugins/table/TableControls.d.ts +3 -1
  207. package/dist/plugins/table/TableControls.d.ts.map +1 -1
  208. package/dist/plugins/table/TableControlsDOM.d.ts +13 -1
  209. package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
  210. package/dist/plugins/table/TableLocale.d.ts +48 -0
  211. package/dist/plugins/table/TableLocale.d.ts.map +1 -0
  212. package/dist/plugins/table/TableNavigation.d.ts +2 -1
  213. package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
  214. package/dist/plugins/table/TableNodeViews.d.ts +3 -1
  215. package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
  216. package/dist/plugins/table/TablePlugin.d.ts +7 -1
  217. package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
  218. package/dist/plugins/table/index.d.ts +3 -0
  219. package/dist/plugins/table/index.d.ts.map +1 -1
  220. package/dist/plugins/table.mjs +18 -660
  221. package/dist/plugins/table.mjs.map +1 -1
  222. package/dist/plugins/text-color/TextColorLocale.d.ts +17 -0
  223. package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -0
  224. package/dist/plugins/text-color/TextColorPlugin.d.ts +3 -5
  225. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  226. package/dist/plugins/text-color.mjs +2 -123
  227. package/dist/plugins/text-color.mjs.map +1 -1
  228. package/dist/plugins/text-formatting/TextFormattingLocale.d.ts +18 -0
  229. package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -0
  230. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +4 -0
  231. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
  232. package/dist/plugins/text-formatting.mjs +2 -49
  233. package/dist/plugins/text-formatting.mjs.map +1 -1
  234. package/dist/plugins/toolbar/ToolbarLocale.d.ts +14 -0
  235. package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -0
  236. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
  237. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  238. package/dist/plugins/toolbar.mjs +1 -1
  239. package/dist/state/EditorState.d.ts +4 -1
  240. package/dist/state/EditorState.d.ts.map +1 -1
  241. package/dist/view/EditorView.d.ts.map +1 -1
  242. package/dist/view/Reconciler.d.ts.map +1 -1
  243. package/package.json +3 -2
  244. package/dist/chunks/Plugin-B9OZ6Y4c.mjs +0 -15
  245. package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +0 -1
  246. package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs.map +0 -1
  247. package/dist/chunks/color-picker-Csf0wx5a.mjs +0 -5
  248. package/dist/chunks/color-picker-Csf0wx5a.mjs.map +0 -1
  249. package/dist/chunks/index-CPPb-Jah.mjs +0 -569
  250. package/dist/chunks/index-CPPb-Jah.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BAk1EG1x.mjs","sources":["../../src/decorations/PositionMapping.ts","../../src/decorations/Decoration.ts","../../src/plugins/code-block/CodeBlockKeyboardHandlers.ts","../../src/plugins/code-block/CodeBlockCommands.ts","../../src/plugins/code-block/CodeBlockLocale.ts","../../src/plugins/code-block/CodeBlockTypes.ts","../../src/plugins/code-block/CodeBlockService.ts","../../src/plugins/code-block/CodeBlockPlugin.ts","../../src/editor/styles/code-block.ts","../../src/plugins/code-block/CodeBlockNodeView.ts"],"sourcesContent":["/**\n * Pure functions for mapping decorations through transaction steps.\n * Handles position adjustments when the document changes — insertions,\n * deletions, splits, merges, and structural node removal.\n */\n\nimport type {\n\tDeleteTextStep,\n\tInsertTextStep,\n\tMergeBlocksStep,\n\tRemoveNodeStep,\n\tSplitBlockStep,\n\tStep,\n} from '../state/Transaction.js';\nimport type {\n\tDecoration,\n\tInlineDecoration,\n\tNodeDecoration,\n\tWidgetDecoration,\n} from './Decoration.js';\n\n/**\n * Maps a single decoration through a step.\n * Returns the mapped decoration, an array (when a split produces two),\n * or null if the decoration was deleted by the step.\n */\nexport function mapDecorationThroughStep(\n\tdeco: Decoration,\n\tstep: Step,\n): Decoration | readonly Decoration[] | null {\n\tswitch (deco.type) {\n\t\tcase 'inline':\n\t\t\treturn mapInline(deco, step);\n\t\tcase 'widget':\n\t\t\treturn mapWidget(deco, step);\n\t\tcase 'node':\n\t\t\treturn mapNode(deco, step);\n\t}\n}\n\nfunction mapInline(\n\tdeco: InlineDecoration,\n\tstep: Step,\n): InlineDecoration | readonly InlineDecoration[] | null {\n\tswitch (step.type) {\n\t\tcase 'insertText':\n\t\t\treturn mapInlineInsert(deco, step);\n\t\tcase 'deleteText':\n\t\t\treturn mapInlineDelete(deco, step);\n\t\tcase 'splitBlock':\n\t\t\treturn mapInlineSplit(deco, step);\n\t\tcase 'mergeBlocks':\n\t\t\treturn mapInlineMerge(deco, step);\n\t\tcase 'removeNode':\n\t\t\treturn removeIfBlockDeleted(deco, step);\n\t\tdefault:\n\t\t\treturn deco;\n\t}\n}\n\nfunction mapWidget(deco: WidgetDecoration, step: Step): WidgetDecoration | null {\n\tswitch (step.type) {\n\t\tcase 'insertText':\n\t\t\treturn mapWidgetInsert(deco, step);\n\t\tcase 'deleteText':\n\t\t\treturn mapWidgetDelete(deco, step);\n\t\tcase 'splitBlock':\n\t\t\treturn mapWidgetSplit(deco, step);\n\t\tcase 'mergeBlocks':\n\t\t\treturn mapWidgetMerge(deco, step);\n\t\tcase 'removeNode':\n\t\t\treturn removeIfBlockDeleted(deco, step);\n\t\tdefault:\n\t\t\treturn deco;\n\t}\n}\n\nfunction mapNode(deco: NodeDecoration, step: Step): NodeDecoration | null {\n\tswitch (step.type) {\n\t\tcase 'mergeBlocks':\n\t\t\treturn mapNodeMerge(deco, step);\n\t\tcase 'removeNode':\n\t\t\treturn removeIfBlockDeleted(deco, step);\n\t\tdefault:\n\t\t\treturn deco;\n\t}\n}\n\n// --- InsertText ---\n\nfunction mapInlineInsert(deco: InlineDecoration, step: InsertTextStep): InlineDecoration {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\tconst len: number = step.text.length;\n\t// from: assoc=-1 (stays at boundary — only shifts if insertion is strictly before)\n\tconst newFrom: number = deco.from > step.offset ? deco.from + len : deco.from;\n\t// to: assoc=1 (moves past insertion — shifts if insertion is at or before)\n\tconst newTo: number = deco.to >= step.offset ? deco.to + len : deco.to;\n\n\tif (newFrom === deco.from && newTo === deco.to) return deco;\n\treturn { ...deco, from: newFrom, to: newTo };\n}\n\nfunction mapWidgetInsert(deco: WidgetDecoration, step: InsertTextStep): WidgetDecoration {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\tconst len: number = step.text.length;\n\t// At boundary: side=-1 means \"before insertion\" (assoc=-1, stays), side=1 means \"after\" (moves)\n\tif (deco.offset > step.offset) {\n\t\treturn { ...deco, offset: deco.offset + len };\n\t}\n\tif (deco.offset === step.offset && deco.side >= 1) {\n\t\treturn { ...deco, offset: deco.offset + len };\n\t}\n\treturn deco;\n}\n\n// --- DeleteText ---\n\nfunction mapInlineDelete(deco: InlineDecoration, step: DeleteTextStep): InlineDecoration | null {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\tconst delLen: number = step.to - step.from;\n\tconst newFrom: number = clampAndShift(deco.from, step.from, step.to, delLen);\n\tconst newTo: number = clampAndShift(deco.to, step.from, step.to, delLen);\n\n\tif (newFrom >= newTo) return null;\n\tif (newFrom === deco.from && newTo === deco.to) return deco;\n\treturn { ...deco, from: newFrom, to: newTo };\n}\n\nfunction mapWidgetDelete(deco: WidgetDecoration, step: DeleteTextStep): WidgetDecoration | null {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\t// Widget strictly inside deleted range → deleted\n\tif (deco.offset > step.from && deco.offset < step.to) return null;\n\n\tconst delLen: number = step.to - step.from;\n\tif (deco.offset >= step.to) {\n\t\treturn { ...deco, offset: deco.offset - delLen };\n\t}\n\treturn deco;\n}\n\n// --- SplitBlock ---\n\nfunction mapInlineSplit(\n\tdeco: InlineDecoration,\n\tstep: SplitBlockStep,\n): InlineDecoration | readonly InlineDecoration[] {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\t// Entirely before split point → unchanged\n\tif (deco.to <= step.offset) return deco;\n\n\t// Entirely after split point → move to new block, adjust offsets\n\tif (deco.from >= step.offset) {\n\t\treturn {\n\t\t\t...deco,\n\t\t\tblockId: step.newBlockId,\n\t\t\tfrom: deco.from - step.offset,\n\t\t\tto: deco.to - step.offset,\n\t\t};\n\t}\n\n\t// Spanning the split point → split into two decorations\n\tconst left: InlineDecoration = { ...deco, to: step.offset };\n\tconst right: InlineDecoration = {\n\t\t...deco,\n\t\tblockId: step.newBlockId,\n\t\tfrom: 0,\n\t\tto: deco.to - step.offset,\n\t};\n\treturn [left, right];\n}\n\nfunction mapWidgetSplit(deco: WidgetDecoration, step: SplitBlockStep): WidgetDecoration {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\t// Before split → stays\n\tif (deco.offset < step.offset) return deco;\n\n\t// After split → new block\n\tif (deco.offset > step.offset) {\n\t\treturn {\n\t\t\t...deco,\n\t\t\tblockId: step.newBlockId,\n\t\t\toffset: deco.offset - step.offset,\n\t\t};\n\t}\n\n\t// At boundary: side determines which block\n\tif (deco.side >= 1) {\n\t\treturn {\n\t\t\t...deco,\n\t\t\tblockId: step.newBlockId,\n\t\t\toffset: 0,\n\t\t};\n\t}\n\treturn deco;\n}\n\n// --- MergeBlocks ---\n\nfunction mapInlineMerge(deco: InlineDecoration, step: MergeBlocksStep): InlineDecoration {\n\tif (deco.blockId !== step.sourceBlockId) return deco;\n\n\treturn {\n\t\t...deco,\n\t\tblockId: step.targetBlockId,\n\t\tfrom: deco.from + step.targetLengthBefore,\n\t\tto: deco.to + step.targetLengthBefore,\n\t};\n}\n\nfunction mapWidgetMerge(deco: WidgetDecoration, step: MergeBlocksStep): WidgetDecoration {\n\tif (deco.blockId !== step.sourceBlockId) return deco;\n\n\treturn {\n\t\t...deco,\n\t\tblockId: step.targetBlockId,\n\t\toffset: deco.offset + step.targetLengthBefore,\n\t};\n}\n\nfunction mapNodeMerge(deco: NodeDecoration, step: MergeBlocksStep): NodeDecoration | null {\n\t// Source block disappears → delete its node decoration\n\tif (deco.blockId === step.sourceBlockId) return null;\n\treturn deco;\n}\n\n// --- RemoveNode ---\n\nfunction removeIfBlockDeleted<T extends Decoration>(deco: T, step: RemoveNodeStep): T | null {\n\tif (deco.blockId === step.removedNode.id) return null;\n\treturn deco;\n}\n\n// --- Helpers ---\n\nfunction clampAndShift(pos: number, delFrom: number, delTo: number, delLen: number): number {\n\tif (pos <= delFrom) return pos;\n\tif (pos >= delTo) return pos - delLen;\n\treturn delFrom;\n}\n","/**\n * Decoration types and DecorationSet for transient, view-only annotations.\n * Decorations are NOT part of the document model and do NOT affect undo/redo.\n */\n\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { mapDecorationThroughStep } from './PositionMapping.js';\n\n// --- Decoration Attrs ---\n\nexport interface DecorationAttrs {\n\treadonly class?: string;\n\treadonly style?: string;\n\treadonly nodeName?: string;\n\treadonly [key: string]: string | undefined;\n}\n\n// --- Decoration Types ---\n\nexport interface InlineDecoration {\n\treadonly type: 'inline';\n\treadonly blockId: BlockId;\n\treadonly from: number;\n\treadonly to: number;\n\treadonly attrs: DecorationAttrs;\n}\n\nexport interface NodeDecoration {\n\treadonly type: 'node';\n\treadonly blockId: BlockId;\n\treadonly attrs: DecorationAttrs;\n}\n\nexport interface WidgetDecoration {\n\treadonly type: 'widget';\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n\treadonly toDOM: () => HTMLElement;\n\treadonly side: -1 | 1;\n\treadonly key?: string;\n}\n\nexport type Decoration = InlineDecoration | NodeDecoration | WidgetDecoration;\n\n// --- Factory Functions ---\n\n/** Creates an inline decoration for a text range within a block. */\nexport function inline(\n\tblockId: BlockId,\n\tfrom: number,\n\tto: number,\n\tattrs: DecorationAttrs,\n): InlineDecoration {\n\treturn { type: 'inline', blockId, from, to, attrs };\n}\n\n/** Creates a node decoration that applies to a whole block element. */\nexport function node(blockId: BlockId, attrs: DecorationAttrs): NodeDecoration {\n\treturn { type: 'node', blockId, attrs };\n}\n\n/** Creates a widget decoration that inserts a DOM element at a position. */\nexport function widget(\n\tblockId: BlockId,\n\toffset: number,\n\ttoDOM: () => HTMLElement,\n\toptions?: { readonly side?: -1 | 1; readonly key?: string },\n): WidgetDecoration {\n\treturn {\n\t\ttype: 'widget',\n\t\tblockId,\n\t\toffset,\n\t\ttoDOM,\n\t\tside: options?.side ?? -1,\n\t\tkey: options?.key,\n\t};\n}\n\n// --- DecorationSet ---\n\n/**\n * Immutable set of decorations indexed by block ID.\n * Provides efficient lookup and merging of decoration collections.\n */\nexport class DecorationSet {\n\tstatic readonly empty: DecorationSet = new DecorationSet(new Map());\n\n\tprivate constructor(private readonly byBlock: ReadonlyMap<BlockId, readonly Decoration[]>) {}\n\n\t/** Creates a DecorationSet from a flat array of decorations. */\n\tstatic create(decorations: readonly Decoration[]): DecorationSet {\n\t\tif (decorations.length === 0) return DecorationSet.empty;\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const deco of decorations) {\n\t\t\tconst existing = map.get(deco.blockId);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(deco);\n\t\t\t} else {\n\t\t\t\tmap.set(deco.blockId, [deco]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns all decorations for a given block. */\n\tfind(blockId: BlockId): readonly Decoration[] {\n\t\treturn this.byBlock.get(blockId) ?? [];\n\t}\n\n\t/** Returns only inline decorations for a given block. */\n\tfindInline(blockId: BlockId): readonly InlineDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is InlineDecoration => d.type === 'inline');\n\t}\n\n\t/** Returns only node decorations for a given block. */\n\tfindNode(blockId: BlockId): readonly NodeDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is NodeDecoration => d.type === 'node');\n\t}\n\n\t/** Returns only widget decorations for a given block. */\n\tfindWidget(blockId: BlockId): readonly WidgetDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is WidgetDecoration => d.type === 'widget');\n\t}\n\n\t/** Returns a new DecorationSet with the given decorations added. */\n\tadd(decorations: readonly Decoration[]): DecorationSet {\n\t\tif (decorations.length === 0) return this;\n\t\tif (this.isEmpty) return DecorationSet.create(decorations);\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tmap.set(bid, [...decos]);\n\t\t}\n\t\tfor (const deco of decorations) {\n\t\t\tconst existing = map.get(deco.blockId);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(deco);\n\t\t\t} else {\n\t\t\t\tmap.set(deco.blockId, [deco]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns a new DecorationSet with decorations matching the predicate removed. */\n\tremove(predicate: (d: Decoration) => boolean): DecorationSet {\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tlet changed = false;\n\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tconst filtered = decos.filter((d) => !predicate(d));\n\t\t\tif (filtered.length !== decos.length) changed = true;\n\t\t\tif (filtered.length > 0) {\n\t\t\t\tmap.set(bid, filtered);\n\t\t\t}\n\t\t}\n\n\t\tif (!changed) return this;\n\t\tif (map.size === 0) return DecorationSet.empty;\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns a new DecorationSet merging this set with another. */\n\tmerge(other: DecorationSet): DecorationSet {\n\t\tif (other.isEmpty) return this;\n\t\tif (this.isEmpty) return other;\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tmap.set(bid, [...decos]);\n\t\t}\n\t\tfor (const [bid, decos] of other.byBlock) {\n\t\t\tconst existing = map.get(bid);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(...decos);\n\t\t\t} else {\n\t\t\t\tmap.set(bid, [...decos]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Checks equality — reference first, then structural comparison. */\n\tequals(other: DecorationSet): boolean {\n\t\tif (this === other) return true;\n\t\tif (this.byBlock.size !== other.byBlock.size) return false;\n\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tconst otherDecos = other.byBlock.get(bid);\n\t\t\tif (!otherDecos) return false;\n\t\t\tif (!decorationArraysEqual(decos, otherDecos)) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** True if the set contains no decorations. */\n\tget isEmpty(): boolean {\n\t\treturn this.byBlock.size === 0;\n\t}\n\n\t/**\n\t * Maps decorations through document changes described by a transaction.\n\t * Decorations that become invalid (e.g. fully deleted range) are removed.\n\t * Decorations that span a split point are split into two.\n\t */\n\tmap(tr: Transaction): DecorationSet {\n\t\tif (this.isEmpty || tr.steps.length === 0) return this;\n\n\t\tlet mapped: Decoration[] = [];\n\t\tfor (const decos of this.byBlock.values()) {\n\t\t\tfor (const d of decos) {\n\t\t\t\tmapped.push(d);\n\t\t\t}\n\t\t}\n\n\t\tfor (const step of tr.steps) {\n\t\t\tconst next: Decoration[] = [];\n\t\t\tfor (const deco of mapped) {\n\t\t\t\tconst result = mapDecorationThroughStep(deco, step);\n\t\t\t\tif (result === null) continue;\n\t\t\t\tif (Array.isArray(result)) {\n\t\t\t\t\tfor (const r of result) {\n\t\t\t\t\t\tnext.push(r);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnext.push(result as Decoration);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapped = next;\n\t\t}\n\n\t\tif (mapped.length === 0) return DecorationSet.empty;\n\t\treturn DecorationSet.create(mapped);\n\t}\n}\n\n// --- Helpers ---\n\n/** Compares two decoration arrays for structural equality. */\nexport function decorationArraysEqual(a: readonly Decoration[], b: readonly Decoration[]): boolean {\n\tif (a === b) return true;\n\tif (a.length !== b.length) return false;\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tconst ai = a[i];\n\t\tconst bi = b[i];\n\t\tif (!ai || !bi || !decorationsEqual(ai, bi)) return false;\n\t}\n\treturn true;\n}\n\n/** Compares two individual decorations for structural equality. */\nfunction decorationsEqual(a: Decoration, b: Decoration): boolean {\n\tif (a.type !== b.type) return false;\n\tif (a.blockId !== b.blockId) return false;\n\n\tswitch (a.type) {\n\t\tcase 'inline': {\n\t\t\tconst bi = b as InlineDecoration;\n\t\t\treturn a.from === bi.from && a.to === bi.to && attrsEqual(a.attrs, bi.attrs);\n\t\t}\n\t\tcase 'node': {\n\t\t\tconst bn = b as NodeDecoration;\n\t\t\treturn attrsEqual(a.attrs, bn.attrs);\n\t\t}\n\t\tcase 'widget': {\n\t\t\tconst bw = b as WidgetDecoration;\n\t\t\treturn (\n\t\t\t\ta.offset === bw.offset && a.side === bw.side && a.key === bw.key && a.toDOM === bw.toDOM\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Compares two DecorationAttrs objects. */\nfunction attrsEqual(a: DecorationAttrs, b: DecorationAttrs): boolean {\n\tif (a === b) return true;\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\tif (aKeys.length !== bKeys.length) return false;\n\tfor (const key of aKeys) {\n\t\tif (a[key] !== b[key]) return false;\n\t}\n\treturn true;\n}\n","/**\n * Keyboard handlers for code-block navigation and editing.\n * Handles Enter, Backspace, Tab, Shift-Tab, Escape, Arrow keys,\n * and configurable shortcuts (Mod+Enter, toggle).\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockLength, getBlockText } from '../../model/Document.js';\nimport { createCollapsedSelection, isCollapsed, isNodeSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { CodeBlockConfig, CodeBlockKeymap } from './CodeBlockTypes.js';\n\n// --- Context Guard ---\n\ninterface CodeBlockContext {\n\treadonly state: EditorState;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection and non-code-block blocks.\n * Returns false (not handled) if the cursor is not inside a code block.\n */\nfunction withCodeBlockContext(\n\tcontext: PluginContext,\n\thandler: (ctx: CodeBlockContext) => boolean,\n): boolean {\n\tconst state: EditorState = context.getState();\n\tif (isNodeSelection(state.selection)) return false;\n\n\tconst sel = state.selection;\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || block.type !== 'code_block') return false;\n\n\treturn handler({\n\t\tstate,\n\t\tblock,\n\t\tblockId: sel.anchor.blockId,\n\t\toffset: sel.anchor.offset,\n\t});\n}\n\n/** Registers all code-block keyboard handlers. */\nexport function registerCodeBlockKeymaps(\n\tcontext: PluginContext,\n\tconfig: CodeBlockConfig,\n\tresolvedKeymap: Readonly<Record<keyof CodeBlockKeymap, string | null>>,\n): void {\n\tconst keymap: Record<string, () => boolean> = {\n\t\tEnter: () => handleEnter(context),\n\t\tBackspace: () => handleBackspace(context),\n\t\tTab: () => handleTab(context, config),\n\t\t'Shift-Tab': () => handleShiftTab(context, config),\n\t\tEscape: () => handleEscape(context),\n\t\tArrowDown: () => handleArrowDown(context),\n\t\tArrowUp: () => handleArrowUp(context),\n\t\tArrowRight: () => handleArrowRight(context),\n\t\tArrowLeft: () => handleArrowLeft(context),\n\t};\n\n\tconst { insertAfter, toggle } = resolvedKeymap;\n\n\tif (insertAfter) {\n\t\tkeymap[insertAfter] = () => handleModEnter(context);\n\t}\n\tif (toggle) {\n\t\tkeymap[toggle] = () => context.executeCommand('toggleCodeBlock');\n\t}\n\n\tcontext.registerKeymap(keymap);\n}\n\n// --- Handler Functions ---\n\nfunction handleBackspace(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\t\tif (offset !== 0) return false;\n\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.setBlockType(blockId, nodeType('paragraph'))\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\n\t\tif (text.endsWith('\\n') && offset === text.length) {\n\t\t\treturn exitOnDoubleEnter(context, blockId, text);\n\t\t}\n\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.insertText(blockId, offset, '\\n', [])\n\t\t\t.setSelection(createCollapsedSelection(blockId, offset + 1))\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\nfunction handleTab(context: PluginContext, config: CodeBlockConfig): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId, offset }) => {\n\t\tconst indent: string = config.useSpaces ? ' '.repeat(config.spaceCount ?? 2) : '\\t';\n\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.insertText(blockId, offset, indent, [])\n\t\t\t.setSelection(createCollapsedSelection(blockId, offset + indent.length))\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\nfunction handleShiftTab(context: PluginContext, config: CodeBlockConfig): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tconst text: string = getBlockText(block);\n\t\tconst lineStart: number = text.lastIndexOf('\\n', offset - 1) + 1;\n\n\t\tif (config.useSpaces) {\n\t\t\tconst spaceCount: number = config.spaceCount ?? 2;\n\t\t\tconst linePrefix: string = text.slice(lineStart, lineStart + spaceCount);\n\t\t\tif (linePrefix === ' '.repeat(spaceCount)) {\n\t\t\t\tconst tr: Transaction = state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(blockId, lineStart, lineStart + spaceCount)\n\t\t\t\t\t.setSelection(createCollapsedSelection(blockId, Math.max(lineStart, offset - spaceCount)))\n\t\t\t\t\t.build();\n\t\t\t\tcontext.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (text[lineStart] === '\\t') {\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('input')\n\t\t\t\t.deleteTextAt(blockId, lineStart, lineStart + 1)\n\t\t\t\t.setSelection(createCollapsedSelection(blockId, Math.max(lineStart, offset - 1)))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn true; // Consume event even if no dedent possible\n\t});\n}\n\n/**\n * Exits the code block to the next block or creates a new paragraph.\n * Exported for use by the `exitCodeBlock` command.\n */\nexport function handleEscape(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId }) => {\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx < blockOrder.length - 1) {\n\t\t\tconst nextId: BlockId = blockOrder[idx + 1] as BlockId;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(nextId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t} else {\n\t\t\tinsertParagraphAfter(context, blockId);\n\t\t}\n\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowDown(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tconst nextNewline: number = text.indexOf('\\n', offset);\n\t\tif (nextNewline !== -1) return false;\n\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx < blockOrder.length - 1) {\n\t\t\tconst nextId: BlockId = blockOrder[idx + 1] as BlockId;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(nextId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t} else {\n\t\t\tinsertParagraphAfter(context, blockId);\n\t\t}\n\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowUp(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tconst firstNewline: number = text.indexOf('\\n');\n\t\tif (firstNewline !== -1 && offset > firstNewline) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx > 0) {\n\t\t\tconst prevId: BlockId = blockOrder[idx - 1] as BlockId;\n\t\t\tconst prevBlock: BlockNode | undefined = state.getBlock(prevId);\n\t\t\tconst prevLen: number = prevBlock ? getBlockLength(prevBlock) : 0;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(prevId, prevLen))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\nfunction handleArrowRight(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tif (offset !== text.length) return false;\n\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx < blockOrder.length - 1) {\n\t\t\tconst nextId: BlockId = blockOrder[idx + 1] as BlockId;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(nextId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t} else {\n\t\t\tinsertParagraphAfter(context, blockId);\n\t\t}\n\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowLeft(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\t\tif (offset !== 0) return false;\n\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx > 0) {\n\t\t\tconst prevId: BlockId = blockOrder[idx - 1] as BlockId;\n\t\t\tconst prevBlock: BlockNode | undefined = state.getBlock(prevId);\n\t\t\tconst prevLen: number = prevBlock ? getBlockLength(prevBlock) : 0;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(prevId, prevLen))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\nfunction handleModEnter(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ blockId }) => {\n\t\tinsertParagraphAfter(context, blockId);\n\t\treturn true;\n\t});\n}\n\n// --- Shared Helpers ---\n\nfunction insertParagraphAfter(context: PluginContext, bid: BlockId): void {\n\tconst state: EditorState = context.getState();\n\tconst block: BlockNode | undefined = state.getBlock(bid);\n\tif (!block) return;\n\n\tconst blockLength: number = getBlockLength(block);\n\tconst newId: BlockId = generateBlockId();\n\n\tconst tr: Transaction = state\n\t\t.transaction('command')\n\t\t.splitBlock(bid, blockLength, newId)\n\t\t.setBlockType(newId, nodeType('paragraph'))\n\t\t.setSelection(createCollapsedSelection(newId, 0))\n\t\t.build();\n\n\tcontext.dispatch(tr);\n}\n\nfunction exitOnDoubleEnter(context: PluginContext, bid: BlockId, text: string): boolean {\n\tconst state: EditorState = context.getState();\n\tconst trimmedLen: number = text.length - 1;\n\tconst newId: BlockId = generateBlockId();\n\n\tconst tr: Transaction = state\n\t\t.transaction('input')\n\t\t.deleteTextAt(bid, trimmedLen, text.length)\n\t\t.splitBlock(bid, trimmedLen, newId)\n\t\t.setBlockType(newId, nodeType('paragraph'))\n\t\t.setSelection(createCollapsedSelection(newId, 0))\n\t\t.build();\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n","/**\n * Command registration and implementations for code blocks.\n * Handles toggle, insert, exit, and mark stripping.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockLength, getInlineChildren, isTextNode } from '../../model/Document.js';\nimport { createCollapsedSelection, isNodeSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { Transaction, TransactionBuilder } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { handleEscape } from './CodeBlockKeyboardHandlers.js';\nimport type { CodeBlockConfig } from './CodeBlockTypes.js';\n\n/** Registers all code-block commands. */\nexport function registerCodeBlockCommands(context: PluginContext, config: CodeBlockConfig): void {\n\tcontext.registerCommand('toggleCodeBlock', () => toggleCodeBlock(context, config));\n\n\tcontext.registerCommand('insertCodeBlock', () => insertCodeBlock(context, config));\n\n\tcontext.registerCommand('setCodeBlockLanguage', () => false);\n\n\tcontext.registerCommand('setCodeBlockBackground', () => false);\n\n\tcontext.registerCommand('exitCodeBlock', () => handleEscape(context));\n}\n\n// --- Command Implementations ---\n\nfunction toggleCodeBlock(context: PluginContext, config: CodeBlockConfig): boolean {\n\tconst state = context.getState();\n\tif (isNodeSelection(state.selection)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === 'code_block') {\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(state.selection.anchor.blockId, nodeType('paragraph'))\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\treturn insertCodeBlock(context, config);\n}\n\nfunction insertCodeBlock(context: PluginContext, config: CodeBlockConfig): boolean {\n\tconst state = context.getState();\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || block.type === 'code_block') return false;\n\n\tconst attrs: Record<string, string | number | boolean> = {\n\t\tlanguage: config.defaultLanguage ?? '',\n\t\tbackgroundColor: '',\n\t};\n\n\tconst builder: TransactionBuilder = state.transaction('command');\n\tstripAllMarks(builder, block);\n\tbuilder\n\t\t.setBlockType(sel.anchor.blockId, nodeType('code_block'), attrs)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0));\n\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/**\n * Strips all marks from a block's inline content.\n * Used when converting to code_block so no formatting carries over.\n */\nfunction stripAllMarks(builder: TransactionBuilder, block: BlockNode): void {\n\tconst blockLength: number = getBlockLength(block);\n\tif (blockLength === 0) return;\n\n\tconst inlineChildren = getInlineChildren(block);\n\tlet offset = 0;\n\n\tfor (const child of inlineChildren) {\n\t\tif (isTextNode(child)) {\n\t\t\tif (child.text.length > 0) {\n\t\t\t\tfor (const mark of child.marks) {\n\t\t\t\t\tbuilder.removeMark(block.id, offset, offset + child.text.length, mark);\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += child.text.length;\n\t\t} else {\n\t\t\toffset += 1;\n\t\t}\n\t}\n}\n","/** Locale interface and default English locale for the CodeBlockPlugin. */\n\n// --- Locale Interface ---\n\nexport interface CodeBlockLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut?: string) => string;\n\treadonly enteredCodeBlock: string;\n\treadonly leftCodeBlock: string;\n}\n\n// --- Default English Locale ---\n\nexport const CODE_BLOCK_LOCALE_EN: CodeBlockLocale = {\n\tlabel: 'Code Block',\n\ttooltip: (shortcut?: string) => (shortcut ? `Code Block (${shortcut})` : 'Code Block'),\n\tenteredCodeBlock: 'Entered code block. Press Escape to exit.',\n\tleftCodeBlock: 'Left code block.',\n};\n\n// --- German Locale ---\n\nexport const CODE_BLOCK_LOCALE_DE: CodeBlockLocale = {\n\tlabel: 'Codeblock',\n\ttooltip: (shortcut?: string) => (shortcut ? `Codeblock (${shortcut})` : 'Codeblock'),\n\tenteredCodeBlock: 'Codeblock betreten. Escape zum Verlassen drücken.',\n\tleftCodeBlock: 'Codeblock verlassen.',\n};\n\n// --- Spanish Locale ---\n\nexport const CODE_BLOCK_LOCALE_ES: CodeBlockLocale = {\n\tlabel: 'Bloque de código',\n\ttooltip: (shortcut?: string) =>\n\t\tshortcut ? `Bloque de código (${shortcut})` : 'Bloque de código',\n\tenteredCodeBlock: 'Bloque de código activado. Pulse Escape para salir.',\n\tleftCodeBlock: 'Bloque de código desactivado.',\n};\n\n// --- French Locale ---\n\nexport const CODE_BLOCK_LOCALE_FR: CodeBlockLocale = {\n\tlabel: 'Bloc de code',\n\ttooltip: (shortcut?: string) => (shortcut ? `Bloc de code (${shortcut})` : 'Bloc de code'),\n\tenteredCodeBlock: 'Bloc de code activé. Appuyez sur Échap pour quitter.',\n\tleftCodeBlock: 'Bloc de code quitté.',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const CODE_BLOCK_LOCALE_ZH: CodeBlockLocale = {\n\tlabel: '代码块',\n\ttooltip: (shortcut?: string) => (shortcut ? `代码块 (${shortcut})` : '代码块'),\n\tenteredCodeBlock: '已进入代码块。按 Escape 退出。',\n\tleftCodeBlock: '已离开代码块。',\n};\n\n// --- Russian Locale ---\n\nexport const CODE_BLOCK_LOCALE_RU: CodeBlockLocale = {\n\tlabel: 'Блок кода',\n\ttooltip: (shortcut?: string) => (shortcut ? `Блок кода (${shortcut})` : 'Блок кода'),\n\tenteredCodeBlock: 'Вход в блок кода. Нажмите Escape для выхода.',\n\tleftCodeBlock: 'Выход из блока кода.',\n};\n\n// --- Arabic Locale ---\n\nexport const CODE_BLOCK_LOCALE_AR: CodeBlockLocale = {\n\tlabel: 'كتلة كود',\n\ttooltip: (shortcut?: string) => (shortcut ? `كتلة كود (${shortcut})` : 'كتلة كود'),\n\tenteredCodeBlock: 'تم الدخول إلى كتلة الكود. اضغط Escape للخروج.',\n\tleftCodeBlock: 'تم الخروج من كتلة الكود.',\n};\n\n// --- Hindi Locale ---\n\nexport const CODE_BLOCK_LOCALE_HI: CodeBlockLocale = {\n\tlabel: 'कोड ब्लॉक',\n\ttooltip: (shortcut?: string) => (shortcut ? `कोड ब्लॉक (${shortcut})` : 'कोड ब्लॉक'),\n\tenteredCodeBlock: 'कोड ब्लॉक में प्रवेश किया। बाहर निकलने के लिए Escape दबाएँ।',\n\tleftCodeBlock: 'कोड ब्लॉक से बाहर।',\n};\n\n// --- Locale Map ---\n\nexport const CODE_BLOCK_LOCALES: Record<string, CodeBlockLocale> = {\n\ten: CODE_BLOCK_LOCALE_EN,\n\tde: CODE_BLOCK_LOCALE_DE,\n\tes: CODE_BLOCK_LOCALE_ES,\n\tfr: CODE_BLOCK_LOCALE_FR,\n\tzh: CODE_BLOCK_LOCALE_ZH,\n\tru: CODE_BLOCK_LOCALE_RU,\n\tar: CODE_BLOCK_LOCALE_AR,\n\thi: CODE_BLOCK_LOCALE_HI,\n};\n","/**\n * Types, interfaces, and constants for the code-block plugin.\n */\n\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { ServiceKey } from '../Plugin.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\tcode_block: {\n\t\t\tlanguage: string;\n\t\t\tbackgroundColor: string;\n\t\t};\n\t}\n}\n\n// --- Syntax Highlighting Types ---\n\nexport interface SyntaxToken {\n\treadonly from: number;\n\treadonly to: number;\n\treadonly type: string;\n}\n\nexport interface SyntaxHighlighter {\n\ttokenize(code: string, language: string): readonly SyntaxToken[];\n\tgetSupportedLanguages(): readonly string[];\n}\n\n// --- Configuration ---\n\n/**\n * Configurable keyboard bindings for CodeBlockPlugin actions.\n * Omit a slot to use the default; set to `null` to disable the binding.\n *\n * Key descriptor format: `'Mod-Enter'`, `'Mod-Shift-M'`, etc.\n * `Mod` resolves to Cmd on macOS, Ctrl on Windows/Linux.\n */\nexport interface CodeBlockKeymap {\n\t/**\n\t * Insert a new paragraph below the code block and move the cursor there.\n\t * @default 'Mod-Enter'\n\t */\n\treadonly insertAfter?: string | null;\n\n\t/**\n\t * Toggle the current block between code block and paragraph.\n\t * @default 'Mod-Shift-M'\n\t */\n\treadonly toggle?: string | null;\n}\n\nexport const DEFAULT_KEYMAP: Readonly<Record<keyof CodeBlockKeymap, string>> = {\n\tinsertAfter: 'Mod-Enter',\n\ttoggle: 'Mod-Shift-M',\n};\n\nexport interface CodeBlockConfig {\n\treadonly highlighter?: SyntaxHighlighter;\n\treadonly defaultLanguage?: string;\n\treadonly useSpaces?: boolean;\n\treadonly spaceCount?: number;\n\treadonly showCopyButton?: boolean;\n\treadonly separatorAfter?: boolean;\n\t/** Default body background color (overrides --notectl-code-block-bg). */\n\treadonly background?: string;\n\t/** Default header background color (overrides --notectl-code-block-header-bg). */\n\treadonly headerBackground?: string;\n\t/** Default text color (overrides --notectl-code-block-color). */\n\treadonly textColor?: string;\n\t/** Default header/label text color (overrides --notectl-code-block-header-color). */\n\treadonly headerColor?: string;\n\t/** Customize keyboard bindings for code block actions. */\n\treadonly keymap?: CodeBlockKeymap;\n\t/** Locale override for user-facing strings. */\n\treadonly locale?: import('./CodeBlockLocale.js').CodeBlockLocale;\n}\n\nexport const DEFAULT_CONFIG: CodeBlockConfig = {\n\tdefaultLanguage: '',\n\tuseSpaces: false,\n\tspaceCount: 2,\n\tshowCopyButton: true,\n};\n\n// --- Service Types ---\n\nexport interface CodeBlockService {\n\tsetLanguage(blockId: BlockId, language: string): void;\n\tgetLanguage(blockId: BlockId): string;\n\tsetBackground(blockId: BlockId, color: string): void;\n\tgetBackground(blockId: BlockId): string;\n\tisCodeBlock(blockId: BlockId): boolean;\n\tgetSupportedLanguages(): readonly string[];\n}\n\nexport const CODE_BLOCK_SERVICE_KEY = new ServiceKey<CodeBlockService>('codeBlock');\n\n// --- SVG Icon ---\n\nexport const CODE_BLOCK_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z\"/></svg>';\n","/**\n * Service API for code blocks.\n * Provides language/background getters and setters.\n */\n\nimport type { BlockAttrs, BlockNode } from '../../model/Document.js';\nimport { findNodePath } from '../../model/NodeResolver.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { CodeBlockConfig } from './CodeBlockTypes.js';\nimport { CODE_BLOCK_SERVICE_KEY } from './CodeBlockTypes.js';\n\n/** Registers the CodeBlockService on the given context. */\nexport function registerCodeBlockService(\n\tcontext: PluginContext,\n\tconfig: CodeBlockConfig,\n\tgetContext: () => PluginContext | null,\n): void {\n\tcontext.registerService(CODE_BLOCK_SERVICE_KEY, {\n\t\tsetLanguage(bid: BlockId, language: string): void {\n\t\t\tsetAttr(context, bid, 'language', language);\n\t\t},\n\n\t\tgetLanguage(bid: BlockId): string {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return '';\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') return '';\n\t\t\treturn (block.attrs?.language as string) ?? '';\n\t\t},\n\n\t\tsetBackground(bid: BlockId, color: string): void {\n\t\t\tsetAttr(context, bid, 'backgroundColor', color);\n\t\t},\n\n\t\tgetBackground(bid: BlockId): string {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return '';\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') return '';\n\t\t\treturn (block.attrs?.backgroundColor as string) ?? '';\n\t\t},\n\n\t\tisCodeBlock(bid: BlockId): boolean {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return false;\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\treturn block?.type === 'code_block';\n\t\t},\n\n\t\tgetSupportedLanguages(): readonly string[] {\n\t\t\tif (config.highlighter) {\n\t\t\t\treturn config.highlighter.getSupportedLanguages();\n\t\t\t}\n\t\t\treturn [];\n\t\t},\n\t});\n}\n\n// --- Helper ---\n\nfunction setAttr(context: PluginContext, bid: BlockId, key: string, value: string): void {\n\tconst state = context.getState();\n\tconst block: BlockNode | undefined = state.getBlock(bid);\n\tif (!block || block.type !== 'code_block') return;\n\n\tconst path: string[] | undefined = findNodePath(state.doc, bid);\n\tif (!path) return;\n\n\tconst newAttrs: BlockAttrs = { ...block.attrs, [key]: value };\n\tconst tr: Transaction = state\n\t\t.transaction('command')\n\t\t.setNodeAttr(path as BlockId[], newAttrs)\n\t\t.build();\n\n\tcontext.dispatch(tr);\n}\n","/**\n * CodeBlockPlugin: orchestrates code block registration by delegating to\n * focused modules for keyboard handling, commands, and service API.\n *\n * Inline responsibilities: NodeSpec, NodeView, InputRule, Toolbar,\n * Middleware, Decorations, and lifecycle hooks (focus tracking).\n */\n\nimport type { DecorationSet } from '../../decorations/Decoration.js';\nimport { inline as inlineDecoration } from '../../decorations/Decoration.js';\nimport { DecorationSet as DecorationSetClass } from '../../decorations/Decoration.js';\nimport { CODE_BLOCK_CSS } from '../../editor/styles/code-block.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockText } from '../../model/Document.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport { createBlockElement } from '../../model/NodeSpec.js';\nimport { createCollapsedSelection, isCollapsed, isNodeSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { registerCodeBlockCommands } from './CodeBlockCommands.js';\nimport { registerCodeBlockKeymaps } from './CodeBlockKeyboardHandlers.js';\nimport { CODE_BLOCK_LOCALES, type CodeBlockLocale } from './CodeBlockLocale.js';\nimport { createCodeBlockNodeViewFactory } from './CodeBlockNodeView.js';\nimport { registerCodeBlockService } from './CodeBlockService.js';\nimport type { CodeBlockConfig, CodeBlockKeymap, SyntaxToken } from './CodeBlockTypes.js';\nimport { CODE_BLOCK_ICON, DEFAULT_CONFIG, DEFAULT_KEYMAP } from './CodeBlockTypes.js';\n\n// Re-exports for backward compatibility\nexport {\n\tCODE_BLOCK_SERVICE_KEY,\n\ttype CodeBlockConfig,\n\ttype CodeBlockKeymap,\n\ttype CodeBlockService,\n\ttype SyntaxHighlighter,\n\ttype SyntaxToken,\n} from './CodeBlockTypes.js';\n\nexport class CodeBlockPlugin implements Plugin {\n\treadonly id = 'code-block';\n\treadonly name = 'Code Block';\n\treadonly priority = 36;\n\n\tprivate readonly config: CodeBlockConfig;\n\tprivate readonly resolvedKeymap: Readonly<Record<keyof CodeBlockKeymap, string | null>>;\n\tprivate context: PluginContext | null = null;\n\tprivate locale!: CodeBlockLocale;\n\n\tconstructor(config?: Partial<CodeBlockConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t\tthis.resolvedKeymap = {\n\t\t\t...DEFAULT_KEYMAP,\n\t\t\t...config?.keymap,\n\t\t};\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(CODE_BLOCK_LOCALES, context, this.config.locale);\n\t\tcontext.registerStyleSheet(CODE_BLOCK_CSS);\n\t\tthis.context = context;\n\n\t\tthis.registerNodeSpec(context);\n\t\tthis.registerNodeView(context);\n\t\tregisterCodeBlockCommands(context, this.config);\n\t\tregisterCodeBlockKeymaps(context, this.config, this.resolvedKeymap);\n\t\tthis.registerInputRule(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.registerMiddleware(context);\n\t\tregisterCodeBlockService(context, this.config, () => this.context);\n\t\tthis.patchTableCellContent(context);\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t}\n\n\tonStateChange(oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tif (!this.context) return;\n\n\t\tconst oldBlockId: BlockId | null = isNodeSelection(oldState.selection)\n\t\t\t? null\n\t\t\t: oldState.selection.anchor.blockId;\n\t\tconst newBlockId: BlockId | null = isNodeSelection(newState.selection)\n\t\t\t? null\n\t\t\t: newState.selection.anchor.blockId;\n\n\t\tconst oldBlock: BlockNode | undefined = oldBlockId ? oldState.getBlock(oldBlockId) : undefined;\n\t\tconst newBlock: BlockNode | undefined = newBlockId ? newState.getBlock(newBlockId) : undefined;\n\n\t\tconst wasInCode: boolean = oldBlock?.type === 'code_block';\n\t\tconst nowInCode: boolean = newBlock?.type === 'code_block';\n\n\t\tif (wasInCode && oldBlockId) {\n\t\t\tthis.setBlockFocused(oldBlockId, false);\n\t\t}\n\t\tif (nowInCode && newBlockId) {\n\t\t\tthis.setBlockFocused(newBlockId, true);\n\t\t}\n\n\t\tif (!wasInCode && nowInCode) {\n\t\t\tthis.context.announce(this.locale.enteredCodeBlock);\n\t\t} else if (wasInCode && !nowInCode) {\n\t\t\tthis.context.announce(this.locale.leftCodeBlock);\n\t\t}\n\t}\n\n\tdecorations(state: EditorState): DecorationSet {\n\t\tif (!this.config.highlighter) return DecorationSetClass.empty;\n\n\t\tconst decorations: ReturnType<typeof inlineDecoration>[] = [];\n\t\tconst highlighter = this.config.highlighter;\n\n\t\tfor (const bid of state.getBlockOrder()) {\n\t\t\tconst block: BlockNode | undefined = state.getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') continue;\n\n\t\t\tconst lang: string = (block.attrs?.language as string) ?? '';\n\t\t\tif (!lang) continue;\n\n\t\t\tconst text: string = getBlockText(block);\n\t\t\tif (!text) continue;\n\n\t\t\tconst tokens: readonly SyntaxToken[] = highlighter.tokenize(text, lang);\n\t\t\tfor (const token of tokens) {\n\t\t\t\tdecorations.push(\n\t\t\t\t\tinlineDecoration(bid, token.from, token.to, {\n\t\t\t\t\t\tclass: `notectl-token--${token.type}`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn DecorationSetClass.create(decorations);\n\t}\n\n\t// --- NodeSpec ---\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'code_block',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\tselectable: true,\n\t\t\tattrs: {\n\t\t\t\tlanguage: { default: '' },\n\t\t\t\tbackgroundColor: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst pre: HTMLElement = createBlockElement('pre', node.id);\n\t\t\t\tpre.className = 'notectl-code-block';\n\t\t\t\tconst code: HTMLElement = document.createElement('code');\n\t\t\t\tcode.className = 'notectl-code-block__content';\n\t\t\t\tpre.appendChild(code);\n\t\t\t\treturn pre;\n\t\t\t},\n\t\t\ttoHTML(node, content) {\n\t\t\t\tconst lang: string = escapeHTML((node.attrs?.language as string) ?? '');\n\t\t\t\tconst bg: string = escapeHTML((node.attrs?.backgroundColor as string) ?? '');\n\t\t\t\tconst langAttr: string = lang ? ` data-language=\"${lang}\"` : '';\n\t\t\t\tconst bgStyle: string = bg ? ` style=\"background-color: ${bg}\"` : '';\n\t\t\t\treturn `<pre${bgStyle}><code${langAttr}>${content || ''}</code></pre>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'pre',\n\t\t\t\t\tgetAttrs(el: HTMLElement) {\n\t\t\t\t\t\tconst code: HTMLElement | null = el.querySelector('code');\n\t\t\t\t\t\tconst langClass: string = code?.className.match(/language-(\\S+)/)?.[1] ?? '';\n\t\t\t\t\t\tconst dataLang: string = code?.getAttribute('data-language') ?? '';\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tlanguage: dataLang || langClass,\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: {\n\t\t\t\ttags: ['pre', 'code'],\n\t\t\t\tattrs: ['data-language', 'class', 'style'],\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- NodeView ---\n\n\tprivate registerNodeView(context: PluginContext): void {\n\t\tcontext.registerNodeView('code_block', createCodeBlockNodeViewFactory(this.config));\n\t}\n\n\t// --- Input Rule ---\n\n\tprivate registerInputRule(context: PluginContext): void {\n\t\tcontext.registerInputRule({\n\t\t\tpattern: /^```(\\w*) $/,\n\t\t\thandler: (state, match, start, _end) => {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (isNodeSelection(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\tconst language: string = match[1] ?? '';\n\t\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\t\tlanguage,\n\t\t\t\t\tbackgroundColor: '',\n\t\t\t\t};\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + match[0].length)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('code_block'), attrs)\n\t\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'code_block',\n\t\t\tgroup: 'block',\n\t\t\ticon: CODE_BLOCK_ICON,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip(\n\t\t\t\tthis.resolvedKeymap.toggle ? formatShortcut(this.resolvedKeymap.toggle) : undefined,\n\t\t\t),\n\t\t\tcommand: 'toggleCodeBlock',\n\t\t\tpriority: 56,\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: (state) => {\n\t\t\t\tif (isNodeSelection(state.selection)) return false;\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\t\t\t\treturn block?.type === 'code_block';\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Middleware (Mark Prevention) ---\n\n\tprivate registerMiddleware(context: PluginContext): void {\n\t\tcontext.registerMiddleware((tr, state, next) => {\n\t\t\tconst hasMarkInCodeBlock: boolean = tr.steps.some((step) => {\n\t\t\t\tif (step.type !== 'addMark') return false;\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\t\treturn block?.type === 'code_block';\n\t\t\t});\n\n\t\t\tif (!hasMarkInCodeBlock) {\n\t\t\t\tnext(tr);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst filtered = tr.steps.filter((step) => {\n\t\t\t\tif (step.type !== 'addMark') return true;\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\t\treturn block?.type !== 'code_block';\n\t\t\t});\n\n\t\t\tnext({ ...tr, steps: filtered });\n\t\t}, 50);\n\t}\n\n\t// --- Table Cell Patching ---\n\n\tprivate patchTableCellContent(context: PluginContext): void {\n\t\tconst registry = context.getSchemaRegistry();\n\t\tconst cellSpec = registry.getNodeSpec('table_cell');\n\t\tif (!cellSpec?.content) return;\n\n\t\tconst currentAllow: readonly string[] = cellSpec.content.allow ?? [];\n\t\tif (currentAllow.includes('code_block')) return;\n\n\t\tregistry.removeNodeSpec('table_cell');\n\t\tregistry.registerNodeSpec({\n\t\t\t...cellSpec,\n\t\t\tcontent: {\n\t\t\t\t...cellSpec.content,\n\t\t\t\tallow: [...currentAllow, 'code_block'],\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Helpers ---\n\n\tprivate setBlockFocused(bid: BlockId, focused: boolean): void {\n\t\tif (!this.context) return;\n\t\tconst container: HTMLElement = this.context.getContainer();\n\t\tconst el: Element | null = container.querySelector(`[data-block-id=\"${bid}\"]`);\n\t\tif (el) {\n\t\t\tel.classList.toggle('notectl-code-block--focused', focused);\n\t\t}\n\t}\n}\n","/** Code block styles — syntax highlighting container, header, copy button. */\nexport const CODE_BLOCK_CSS = `\n/* Code Block — uses theme custom properties */\n.notectl-code-block {\n\tposition: relative;\n\tmargin: 8px 0;\n\tborder-radius: 6px;\n\tbackground: var(--notectl-code-block-bg);\n\tcolor: var(--notectl-code-block-color);\n\tfont-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;\n\tfont-size: 14px;\n\tline-height: 1.5;\n\toverflow: hidden;\n}\n\n.notectl-code-block__header {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tpadding: 6px 12px;\n\tbackground: var(--notectl-code-block-header-bg);\n\tborder-bottom: 1px solid var(--notectl-code-block-header-border);\n\tfont-size: 12px;\n\tcolor: var(--notectl-code-block-header-color);\n\tuser-select: none;\n}\n\n.notectl-code-block__language {\n\tfont-weight: 500;\n\tletter-spacing: 0.02em;\n}\n\n.notectl-code-block__copy {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 24px;\n\theight: 24px;\n\tborder: none;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcolor: var(--notectl-code-block-header-color);\n\tcursor: pointer;\n\tpadding: 0;\n\ttransition: background 0.15s, color 0.15s;\n}\n\n.notectl-code-block__copy:hover {\n\tbackground: rgba(128, 128, 128, 0.15);\n\tcolor: var(--notectl-code-block-color);\n}\n\n.notectl-code-block__copy svg {\n\tfill: currentColor;\n}\n\n.notectl-code-block__content {\n\tdisplay: block;\n\tpadding: 12px 16px;\n\twhite-space: pre-wrap;\n\tword-wrap: break-word;\n\ttab-size: 4;\n\t-moz-tab-size: 4;\n\toutline: none;\n\tmin-height: 1.5em;\n}\n\n.notectl-code-block--selected {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n\n.notectl-code-block__esc-hint {\n\tdisplay: none;\n\tposition: absolute;\n\tbottom: 4px;\n\tright: 8px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-code-block-header-color);\n\topacity: 0.5;\n\tpointer-events: none;\n\tuser-select: none;\n\tfont-family: system-ui, sans-serif;\n}\n\n.notectl-code-block--focused .notectl-code-block__esc-hint {\n\tdisplay: block;\n}\n`;\n","/**\n * NodeView factory for code blocks.\n * Renders <pre> with a non-editable header (language label + copy button)\n * and a <code> content area where the Reconciler renders text.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockText } from '../../model/Document.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { NodeView, NodeViewFactory } from '../../view/NodeView.js';\nimport type { CodeBlockConfig } from './CodeBlockTypes.js';\n\nconst COPY_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"14\" height=\"14\"><path d=\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z\"/></svg>';\n\n/** Creates a NodeViewFactory for code_block nodes. */\nexport function createCodeBlockNodeViewFactory(config: CodeBlockConfig): NodeViewFactory {\n\treturn (\n\t\tnode: BlockNode,\n\t\tgetState: () => EditorState,\n\t\t_dispatch: (tr: Transaction) => void,\n\t): NodeView => {\n\t\t// --- DOM Construction ---\n\t\tconst pre: HTMLElement = document.createElement('pre');\n\t\tpre.className = 'notectl-code-block';\n\t\tpre.setAttribute('data-block-id', node.id);\n\t\tpre.setAttribute('role', 'group');\n\t\tpre.setAttribute('aria-roledescription', 'code block');\n\n\t\t// Header (non-editable)\n\t\tconst header: HTMLDivElement = document.createElement('div');\n\t\theader.className = 'notectl-code-block__header';\n\t\theader.setAttribute('contenteditable', 'false');\n\n\t\tconst langLabel: HTMLSpanElement = document.createElement('span');\n\t\tlangLabel.className = 'notectl-code-block__language';\n\n\t\tconst showCopy: boolean = config.showCopyButton !== false;\n\t\tlet copyBtn: HTMLButtonElement | null = null;\n\n\t\tif (showCopy) {\n\t\t\tcopyBtn = document.createElement('button');\n\t\t\tcopyBtn.className = 'notectl-code-block__copy';\n\t\t\tcopyBtn.setAttribute('aria-label', 'Copy code');\n\t\t\tcopyBtn.setAttribute('data-notectl-no-print', '');\n\t\t\tcopyBtn.type = 'button';\n\t\t\tcopyBtn.innerHTML = COPY_ICON;\n\t\t}\n\n\t\t// Screen reader live region for copy feedback\n\t\tconst copyAnnouncer: HTMLSpanElement = document.createElement('span');\n\t\tcopyAnnouncer.className = 'notectl-sr-only';\n\t\tcopyAnnouncer.setAttribute('aria-live', 'assertive');\n\t\tcopyAnnouncer.setAttribute('aria-atomic', 'true');\n\n\t\theader.appendChild(langLabel);\n\t\tif (copyBtn) {\n\t\t\theader.appendChild(copyBtn);\n\t\t}\n\t\theader.appendChild(copyAnnouncer);\n\n\t\t// Content area (Reconciler target)\n\t\tconst code: HTMLElement = document.createElement('code');\n\t\tcode.className = 'notectl-code-block__content';\n\n\t\t// Escape hint (visible only when focused, CSS-driven)\n\t\tconst escHint: HTMLDivElement = document.createElement('div');\n\t\tescHint.className = 'notectl-code-block__esc-hint';\n\t\tescHint.setAttribute('contenteditable', 'false');\n\t\tescHint.setAttribute('aria-hidden', 'true');\n\t\tescHint.setAttribute('data-notectl-no-print', '');\n\t\tescHint.textContent = 'Esc to exit';\n\n\t\tpre.appendChild(header);\n\t\tpre.appendChild(code);\n\t\tpre.appendChild(escHint);\n\n\t\t// Apply config-level color overrides as CSS custom properties\n\t\tif (config.background) {\n\t\t\tpre.style.setProperty('--notectl-code-block-bg', config.background);\n\t\t}\n\t\tif (config.headerBackground) {\n\t\t\tpre.style.setProperty('--notectl-code-block-header-bg', config.headerBackground);\n\t\t}\n\t\tif (config.textColor) {\n\t\t\tpre.style.setProperty('--notectl-code-block-color', config.textColor);\n\t\t}\n\t\tif (config.headerColor) {\n\t\t\tpre.style.setProperty('--notectl-code-block-header-color', config.headerColor);\n\t\t}\n\n\t\tlet currentNodeId: BlockId = node.id;\n\n\t\t// --- Attribute Application ---\n\n\t\tfunction applyAttrs(n: BlockNode): void {\n\t\t\tconst lang: string = (n.attrs?.language as string) ?? '';\n\t\t\tconst langName: string = lang || 'plain';\n\t\t\tlangLabel.textContent = langName;\n\t\t\tpre.setAttribute('aria-label', `${langName} code block. Press Escape to exit.`);\n\n\t\t\tif (lang) {\n\t\t\t\tcode.setAttribute('data-language', lang);\n\t\t\t} else {\n\t\t\t\tcode.removeAttribute('data-language');\n\t\t\t}\n\n\t\t\tconst bg: string = (n.attrs?.backgroundColor as string) ?? '';\n\t\t\tpre.style.backgroundColor = bg || '';\n\t\t}\n\n\t\tapplyAttrs(node);\n\n\t\t// --- Copy Button Handler ---\n\n\t\tif (copyBtn) {\n\t\t\tcopyBtn.addEventListener('click', (e: MouseEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tconst state: EditorState = getState();\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(currentNodeId);\n\t\t\t\tif (!block) return;\n\n\t\t\t\tconst text: string = getBlockText(block);\n\t\t\t\tnavigator.clipboard.writeText(text);\n\n\t\t\t\t// Announce to screen readers\n\t\t\t\tcopyAnnouncer.textContent = 'Copied to clipboard';\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tcopyAnnouncer.textContent = '';\n\t\t\t\t}, 1000);\n\t\t\t});\n\t\t}\n\n\t\t// --- NodeView Interface ---\n\n\t\treturn {\n\t\t\tdom: pre,\n\t\t\tcontentDOM: code,\n\n\t\t\tupdate(updatedNode: BlockNode): boolean {\n\t\t\t\tif (updatedNode.type !== 'code_block') return false;\n\t\t\t\tcurrentNodeId = updatedNode.id;\n\t\t\t\tpre.setAttribute('data-block-id', updatedNode.id);\n\t\t\t\tapplyAttrs(updatedNode);\n\t\t\t\treturn true;\n\t\t\t},\n\n\t\t\tselectNode(): void {\n\t\t\t\tpre.classList.add('notectl-code-block--selected');\n\t\t\t},\n\n\t\t\tdeselectNode(): void {\n\t\t\t\tpre.classList.remove('notectl-code-block--selected');\n\t\t\t},\n\n\t\t\tdestroy(): void {\n\t\t\t\t// No cleanup needed\n\t\t\t},\n\t\t};\n\t};\n}\n"],"names":["mapDecorationThroughStep","deco","step","type","blockId","len","text","length","newFrom","from","offset","newTo","to","delLen","clampAndShift","newBlockId","sourceBlockId","targetBlockId","targetLengthBefore","removeIfBlockDeleted","side","removedNode","id","pos","delFrom","delTo","inline","attrs","node","widget","toDOM","options","key","DecorationSet","byBlock","this","static","Map","decorations","empty","map","existing","get","push","set","decos","filter","d","isEmpty","create","bid","predicate","changed","filtered","size","other","otherDecos","decorationArraysEqual","tr","steps","mapped","values","next","result","Array","isArray","r","a","b","i","ai","bi","decorationsEqual","attrsEqual","bn","bw","aKeys","Object","keys","bKeys","withCodeBlockContext","context","handler","state","getState","isNodeSelection","selection","sel","block","getBlock","anchor","handleEscape","blockOrder","getBlockOrder","idx","indexOf","nextId","transaction","setSelection","createCollapsedSelection","build","dispatch","insertParagraphAfter","blockLength","getBlockLength","newId","generateBlockId","splitBlock","setBlockType","nodeType","insertCodeBlock","config","language","defaultLanguage","backgroundColor","builder","inlineChildren","getInlineChildren","child","isTextNode","mark","marks","removeMark","CODE_BLOCK_LOCALE_EN","label","tooltip","shortcut","enteredCodeBlock","leftCodeBlock","CODE_BLOCK_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_KEYMAP","insertAfter","toggle","DEFAULT_CONFIG","useSpaces","spaceCount","showCopyButton","CODE_BLOCK_SERVICE_KEY","ServiceKey","setAttr","value","path","findNodePath","doc","newAttrs","setNodeAttr","CodeBlockPlugin","name","priority","resolvedKeymap","locale","keymap","resolvePluginLocale","registerStyleSheet","registerNodeSpec","registerNodeView","registerCommand","Enter","isCollapsed","getBlockText","endsWith","trimmedLen","deleteTextAt","insertText","Backspace","Tab","indent","repeat","lineStart","lastIndexOf","slice","Math","max","Escape","ArrowDown","ArrowUp","firstNewline","prevId","prevBlock","prevLen","ArrowRight","ArrowLeft","executeCommand","registerKeymap","registerInputRule","registerToolbarItem","registerMiddleware","getContext","registerService","ctx","color","getSupportedLanguages","highlighter","patchTableCellContent","oldState","newState","_tr","oldBlockId","oldBlock","newBlock","wasInCode","nowInCode","setBlockFocused","announce","DecorationSetClass","lang","tokens","tokenize","token","inlineDecoration","class","group","content","allow","selectable","default","pre","createBlockElement","className","code","document","createElement","appendChild","escapeHTML","bg","parseHTML","tag","el","querySelector","langClass","match","getAttribute","sanitize","tags","_dispatch","setAttribute","header","langLabel","copyBtn","innerHTML","copyAnnouncer","escHint","textContent","background","style","setProperty","headerBackground","textColor","headerColor","currentNodeId","applyAttrs","n","langName","removeAttribute","addEventListener","e","preventDefault","stopPropagation","navigator","clipboard","writeText","setTimeout","dom","contentDOM","update","updatedNode","classList","add","deselectNode","remove","destroy","pattern","start","_end","icon","formatShortcut","command","separatorAfter","isActive","some","registry","getSchemaRegistry","cellSpec","getNodeSpec","currentAllow","includes","removeNodeSpec","focused","getContainer"],"mappings":";;;;;;;;AA0BO,SAASA,EACfC,IACAC,IAAAA;AAEA,UAAQD,GAAKE,MAAAA;AAAAA,IACZ,KAAK;AACJ,cAQH,SACCF,IACAC,IAAAA;AAEA,gBAAQA,GAAKC;UACZ,KAAK;AACJ,oBA4CH,SAAyBF,IAAwBC;AAChD,kBAAID,GAAKG,YAAYF,GAAKE,QAAS,QAAOH;AAE1C,oBAAMI,KAAcH,GAAKI,KAAKC,QAExBC,KAAkBP,GAAKQ,OAAOP,GAAKQ,SAAST,GAAKQ,OAAOJ,KAAMJ,GAAKQ,MAEnEE,KAAgBV,GAAKW,MAAMV,GAAKQ,SAAST,GAAKW,KAAKP,KAAMJ,GAAKW;AAEpE,qBAAIJ,OAAYP,GAAKQ,QAAQE,OAAUV,GAAKW,KAAWX,KAChD,EAAA,GAAKA,IAAMQ,MAAMD,IAASI,IAAID;YACtC,GAvD0BV,IAA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AA,MACHA,GAAGuC,UAAUtI,OAAO,+BAA+B2J,EAAAA;AAAAA,EAErD;AAAA;"}
@@ -0,0 +1,63 @@
1
+ import { r as e } from "./resolvePluginLocale-B4w1OkPy.mjs";
2
+ import { c as t } from "./Document-CI3iCwEP.mjs";
3
+ import { c as o } from "./NodeSpec-NZVvcCuH.mjs";
4
+ import { i as r, a as i, c as l } from "./Selection-D5ZjXoB7.mjs";
5
+ import { n } from "./TypeBrands-C09nE2qO.mjs";
6
+ import { f as a } from "./ToolbarItem-ugDymuXi.mjs";
7
+ const s = { label: "Horizontal Rule", tooltip: (e2) => `Horizontal Rule (${e2})` }, c = { en: s, de: { label: "Trennlinie", tooltip: (e2) => `Trennlinie (${e2})` }, es: { label: "Línea horizontal", tooltip: (e2) => `Línea horizontal (${e2})` }, fr: { label: "Ligne horizontale", tooltip: (e2) => `Ligne horizontale (${e2})` }, zh: { label: "分隔线", tooltip: (e2) => `分隔线 (${e2})` }, ru: { label: "Горизонтальная линия", tooltip: (e2) => `Горизонтальная линия (${e2})` }, ar: { label: "خط أفقي", tooltip: (e2) => `خط أفقي (${e2})` }, hi: { label: "क्षैतिज रेखा", tooltip: (e2) => `क्षैतिज रेखा (${e2})` } }, p = {};
8
+ function u(e2) {
9
+ const t2 = e2.selection;
10
+ return r(t2) ? -1 : e2.doc.children.findIndex((e3) => e3.id === t2.anchor.blockId);
11
+ }
12
+ class h {
13
+ id = "horizontal-rule";
14
+ name = "Horizontal Rule";
15
+ priority = 40;
16
+ config;
17
+ locale;
18
+ constructor(e2) {
19
+ this.config = { ...p, ...e2 };
20
+ }
21
+ init(t2) {
22
+ this.locale = e(c, t2, this.config.locale), this.registerNodeSpec(t2), this.registerCommands(t2), this.registerKeymap(t2), this.registerInputRule(t2), this.registerToolbarItem(t2);
23
+ }
24
+ registerNodeSpec(e2) {
25
+ e2.registerNodeSpec({ type: "horizontal_rule", group: "block", isVoid: true, toDOM: (e3) => o("hr", e3.id), toHTML: () => "<hr>", parseHTML: [{ tag: "hr" }], sanitize: { tags: ["hr"] } });
26
+ }
27
+ registerCommands(e2) {
28
+ e2.registerCommand("insertHorizontalRule", () => this.insertHorizontalRule(e2));
29
+ }
30
+ registerKeymap(e2) {
31
+ e2.registerKeymap({ "Mod-Shift-H": () => e2.executeCommand("insertHorizontalRule") });
32
+ }
33
+ registerInputRule(e2) {
34
+ e2.registerInputRule({ pattern: /^-{3,} $/, handler(e3, o2, a2, s2) {
35
+ const c2 = e3.selection;
36
+ if (r(c2)) return null;
37
+ if (!i(c2)) return null;
38
+ const p2 = e3.getBlock(c2.anchor.blockId);
39
+ if (!p2 || "paragraph" !== p2.type) return null;
40
+ const h2 = u(e3);
41
+ if (-1 === h2) return null;
42
+ const m = t(n("paragraph"));
43
+ return e3.transaction("input").deleteTextAt(c2.anchor.blockId, 0, s2).setBlockType(c2.anchor.blockId, n("horizontal_rule")).insertNode([], h2 + 1, m).setSelection(l(m.id, 0)).build();
44
+ } });
45
+ }
46
+ registerToolbarItem(e2) {
47
+ e2.registerToolbarItem({ id: "horizontal-rule", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11h16v2H4z"/></svg>', label: this.locale.label, tooltip: this.locale.tooltip(a("Mod-Shift-H")), command: "insertHorizontalRule", priority: 60, separatorAfter: this.config.separatorAfter, isActive: () => false });
48
+ }
49
+ insertHorizontalRule(e2) {
50
+ const o2 = e2.getState();
51
+ if (r(o2.selection)) return false;
52
+ const i2 = u(o2);
53
+ if (-1 === i2) return false;
54
+ const a2 = t(n("horizontal_rule")), s2 = t(n("paragraph")), c2 = o2.transaction("command").insertNode([], i2 + 1, a2).insertNode([], i2 + 2, s2).setSelection(l(s2.id, 0)).build();
55
+ return e2.dispatch(c2), true;
56
+ }
57
+ }
58
+ export {
59
+ c as H,
60
+ s as a,
61
+ h as b
62
+ };
63
+ //# sourceMappingURL=index-BRYzYOYC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BRYzYOYC.mjs","sources":["../../src/plugins/horizontal-rule/HorizontalRuleLocale.ts","../../src/plugins/horizontal-rule/HorizontalRulePlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the HorizontalRulePlugin. */\n\n// --- Locale Interface ---\n\nexport interface HorizontalRuleLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_EN: HorizontalRuleLocale = {\n\tlabel: 'Horizontal Rule',\n\ttooltip: (shortcut: string) => `Horizontal Rule (${shortcut})`,\n};\n\n// --- German Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_DE: HorizontalRuleLocale = {\n\tlabel: 'Trennlinie',\n\ttooltip: (shortcut: string) => `Trennlinie (${shortcut})`,\n};\n\n// --- Spanish Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_ES: HorizontalRuleLocale = {\n\tlabel: 'Línea horizontal',\n\ttooltip: (shortcut: string) => `Línea horizontal (${shortcut})`,\n};\n\n// --- French Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_FR: HorizontalRuleLocale = {\n\tlabel: 'Ligne horizontale',\n\ttooltip: (shortcut: string) => `Ligne horizontale (${shortcut})`,\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_ZH: HorizontalRuleLocale = {\n\tlabel: '分隔线',\n\ttooltip: (shortcut: string) => `分隔线 (${shortcut})`,\n};\n\n// --- Russian Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_RU: HorizontalRuleLocale = {\n\tlabel: 'Горизонтальная линия',\n\ttooltip: (shortcut: string) => `Горизонтальная линия (${shortcut})`,\n};\n\n// --- Arabic Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_AR: HorizontalRuleLocale = {\n\tlabel: 'خط أفقي',\n\ttooltip: (shortcut: string) => `خط أفقي (${shortcut})`,\n};\n\n// --- Hindi Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_HI: HorizontalRuleLocale = {\n\tlabel: 'क्षैतिज रेखा',\n\ttooltip: (shortcut: string) => `क्षैतिज रेखा (${shortcut})`,\n};\n\n// --- Locale Map ---\n\nexport const HORIZONTAL_RULE_LOCALES: Record<string, HorizontalRuleLocale> = {\n\ten: HORIZONTAL_RULE_LOCALE_EN,\n\tde: HORIZONTAL_RULE_LOCALE_DE,\n\tes: HORIZONTAL_RULE_LOCALE_ES,\n\tfr: HORIZONTAL_RULE_LOCALE_FR,\n\tzh: HORIZONTAL_RULE_LOCALE_ZH,\n\tru: HORIZONTAL_RULE_LOCALE_RU,\n\tar: HORIZONTAL_RULE_LOCALE_AR,\n\thi: HORIZONTAL_RULE_LOCALE_HI,\n};\n","/**\n * HorizontalRulePlugin: registers a horizontal rule (divider) void block type\n * with NodeSpec, insert command, input rule, keyboard shortcut, and toolbar button.\n */\n\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { createBlockNode } from '../../model/Document.js';\nimport { createBlockElement } from '../../model/NodeSpec.js';\nimport { createCollapsedSelection, isCollapsed, isNodeSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { HORIZONTAL_RULE_LOCALES, type HorizontalRuleLocale } from './HorizontalRuleLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\thorizontal_rule: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\nexport interface HorizontalRuleConfig {\n\t/** When true, a separator is rendered after the toolbar item. */\n\treadonly separatorAfter?: boolean;\n\t/** Locale override for user-facing strings. */\n\treadonly locale?: HorizontalRuleLocale;\n}\n\nconst DEFAULT_CONFIG: HorizontalRuleConfig = {};\n\n// --- Helpers ---\n\n/** Finds the index of the cursor's block among top-level document children. */\nfunction findBlockIndexForCursor(state: EditorState): number {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return -1;\n\treturn state.doc.children.findIndex((b) => b.id === sel.anchor.blockId);\n}\n\n// --- Plugin ---\n\nexport class HorizontalRulePlugin implements Plugin {\n\treadonly id = 'horizontal-rule';\n\treadonly name = 'Horizontal Rule';\n\treadonly priority = 40;\n\n\tprivate readonly config: HorizontalRuleConfig;\n\tprivate locale!: HorizontalRuleLocale;\n\n\tconstructor(config?: Partial<HorizontalRuleConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(HORIZONTAL_RULE_LOCALES, context, this.config.locale);\n\t\tthis.registerNodeSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymap(context);\n\t\tthis.registerInputRule(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'horizontal_rule',\n\t\t\tgroup: 'block',\n\t\t\tisVoid: true,\n\t\t\ttoDOM(node) {\n\t\t\t\treturn createBlockElement('hr', node.id);\n\t\t\t},\n\t\t\ttoHTML() {\n\t\t\t\treturn '<hr>';\n\t\t\t},\n\t\t\tparseHTML: [{ tag: 'hr' }],\n\t\t\tsanitize: { tags: ['hr'] },\n\t\t});\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('insertHorizontalRule', () => {\n\t\t\treturn this.insertHorizontalRule(context);\n\t\t});\n\t}\n\n\tprivate registerKeymap(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-H': () => context.executeCommand('insertHorizontalRule'),\n\t\t});\n\t}\n\n\tprivate registerInputRule(context: PluginContext): void {\n\t\tcontext.registerInputRule({\n\t\t\tpattern: /^-{3,} $/,\n\t\t\thandler(state, _match, _start, end) {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (isNodeSelection(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\tconst blockIndex: number = findBlockIndexForCursor(state);\n\t\t\t\tif (blockIndex === -1) return null;\n\n\t\t\t\tconst newParagraph = createBlockNode(nodeType('paragraph'));\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, 0, end)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('horizontal_rule'))\n\t\t\t\t\t.insertNode([], blockIndex + 1, newParagraph)\n\t\t\t\t\t.setSelection(createCollapsedSelection(newParagraph.id, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M4 11h16v2H4z\"/></svg>';\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'horizontal-rule',\n\t\t\tgroup: 'block',\n\t\t\ticon,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip(formatShortcut('Mod-Shift-H')),\n\t\t\tcommand: 'insertHorizontalRule',\n\t\t\tpriority: 60,\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: () => false,\n\t\t});\n\t}\n\n\t/**\n\t * Inserts a horizontal rule after the current block,\n\t * followed by a new paragraph for continued editing.\n\t */\n\tprivate insertHorizontalRule(context: PluginContext): boolean {\n\t\tconst state: EditorState = context.getState();\n\t\tif (isNodeSelection(state.selection)) return false;\n\t\tconst blockIndex: number = findBlockIndexForCursor(state);\n\t\tif (blockIndex === -1) return false;\n\n\t\tconst hrBlock = createBlockNode(nodeType('horizontal_rule'));\n\t\tconst newParagraph = createBlockNode(nodeType('paragraph'));\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.insertNode([], blockIndex + 1, hrBlock)\n\t\t\t.insertNode([], blockIndex + 2, newParagraph)\n\t\t\t.setSelection(createCollapsedSelection(newParagraph.id, 0))\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n}\n"],"names":["HORIZONTAL_RULE_LOCALE_EN","label","tooltip","shortcut","HORIZONTAL_RULE_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","findBlockIndexForCursor","state","sel","selection","isNodeSelection","doc","children","findIndex","b","id","anchor","blockId","HorizontalRulePlugin","name","priority","config","locale","this","context","resolvePluginLocale","registerNodeSpec","registerCommands","registerKeymap","registerInputRule","registerToolbarItem","type","group","isVoid","toDOM","node","createBlockElement","toHTML","parseHTML","tag","sanitize","tags","registerCommand","insertHorizontalRule","executeCommand","pattern","_match","_start","end","isCollapsed","block","getBlock","blockIndex","newParagraph","createBlockNode","nodeType","transaction","deleteTextAt","setBlockType","insertNode","setSelection","createCollapsedSelection","build","icon","formatShortcut","command","separatorAfter","isActive","getState","hrBlock","tr","dispatch"],"mappings":";;;;;;AAWO,MAAMA,IAAkD,EAC9DC,OAAO,mBACPC,SAAUC,CAAAA,OAAqB,oBAAoBA,EAAAA,IAAAA,GAsDvCC,IAAgE,EAC5EC,IAAIL,GACJM,IAnD8D,EAC9DL,OAAO,cACPC,SAAUC,CAAAA,OAAqB,eAAeA,EAAAA,IAAAA,GAkD9CI,IA7C8D,EAC9DN,OAAO,oBACPC,SAAUC,CAAAA,OAAqB,qBAAqBA,EAAAA,IAAAA,GA4CpDK,IAvC8D,EAC9DP,OAAO,qBACPC,SAAUC,CAAAA,OAAqB,sBAAsBA,SAsCrDM,IAjC8D,EAC9DR,OAAO,OACPC,SAAUC,CAAAA,OAAqB,QAAQA,EAAAA,IAAAA,GAgCvCO,IA3B8D,EAC9DT,OAAO,wBACPC,SAAUC,CAAAA,OAAqB,yBAAyBA,EAAAA,IAAA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