@notectl/core 1.0.9 → 1.6.1

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 (227) hide show
  1. package/dist/chunks/{AttrRegistry-D-przlzb.mjs → AttrRegistry-I-VdmRnN.mjs} +2 -2
  2. package/dist/chunks/{AttrRegistry-D-przlzb.mjs.map → AttrRegistry-I-VdmRnN.mjs.map} +1 -1
  3. package/dist/chunks/CaretNavigation-CAJXoaae.mjs +311 -0
  4. package/dist/chunks/CaretNavigation-CAJXoaae.mjs.map +1 -0
  5. package/dist/chunks/ColorNames-BdsHwA2f.mjs +59 -0
  6. package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +1 -0
  7. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +125 -0
  8. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +1 -0
  9. package/dist/chunks/Commands-CicwYoTQ.mjs +286 -0
  10. package/dist/chunks/Commands-CicwYoTQ.mjs.map +1 -0
  11. package/dist/chunks/{Document-CI3iCwEP.mjs → Document-CuwE73FF.mjs} +35 -22
  12. package/dist/chunks/{Document-CI3iCwEP.mjs.map → Document-CuwE73FF.mjs.map} +1 -1
  13. package/dist/chunks/HTMLUtils-DTqQzcKR.mjs +35 -0
  14. package/dist/chunks/HTMLUtils-DTqQzcKR.mjs.map +1 -0
  15. package/dist/chunks/MarkCommands-CC37WA7Z.mjs +94 -0
  16. package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +1 -0
  17. package/dist/chunks/NavigationUtils-CyW0Vo8A.mjs +47 -0
  18. package/dist/chunks/NavigationUtils-CyW0Vo8A.mjs.map +1 -0
  19. package/dist/chunks/{NodeResolver-D68ZLXti.mjs → NodeResolver-B-wzthAQ.mjs} +2 -2
  20. package/dist/chunks/{NodeResolver-D68ZLXti.mjs.map → NodeResolver-B-wzthAQ.mjs.map} +1 -1
  21. package/dist/chunks/Platform-S_xqIqcM.mjs +26 -0
  22. package/dist/chunks/Platform-S_xqIqcM.mjs.map +1 -0
  23. package/dist/chunks/Selection-DmFDwiPJ.mjs +52 -0
  24. package/dist/chunks/Selection-DmFDwiPJ.mjs.map +1 -0
  25. package/dist/chunks/ToolbarItem-BpZggUGo.mjs +8 -0
  26. package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -0
  27. package/dist/chunks/{ToolbarPlugin-DFkl1uYO.mjs → ToolbarPlugin-B6JETWaw.mjs} +3 -3
  28. package/dist/chunks/{ToolbarPlugin-DFkl1uYO.mjs.map → ToolbarPlugin-B6JETWaw.mjs.map} +1 -1
  29. package/dist/chunks/index--z_Txzej.mjs +467 -0
  30. package/dist/chunks/index--z_Txzej.mjs.map +1 -0
  31. package/dist/chunks/{index-o6hDR07y.mjs → index-83QoUENW.mjs} +25 -20
  32. package/dist/chunks/index-83QoUENW.mjs.map +1 -0
  33. package/dist/chunks/{index-DfO_fKw6.mjs → index-B0UFAfyb.mjs} +15 -15
  34. package/dist/chunks/{index-DfO_fKw6.mjs.map → index-B0UFAfyb.mjs.map} +1 -1
  35. package/dist/chunks/{index-BFsYGsBR.mjs → index-BDMP86F4.mjs} +39 -39
  36. package/dist/chunks/{index-BFsYGsBR.mjs.map → index-BDMP86F4.mjs.map} +1 -1
  37. package/dist/chunks/{index-Bsp4LC5t.mjs → index-BWXkaC2Z.mjs} +36 -36
  38. package/dist/chunks/index-BWXkaC2Z.mjs.map +1 -0
  39. package/dist/chunks/{index-DAFCISBN.mjs → index-BigJ0z6n.mjs} +3 -3
  40. package/dist/chunks/{index-DAFCISBN.mjs.map → index-BigJ0z6n.mjs.map} +1 -1
  41. package/dist/chunks/{index-uTnc9y7M.mjs → index-CPjf45-o.mjs} +28 -28
  42. package/dist/chunks/index-CPjf45-o.mjs.map +1 -0
  43. package/dist/chunks/{index-DGrRWMlW.mjs → index-CPyHuEzh.mjs} +105 -105
  44. package/dist/chunks/index-CPyHuEzh.mjs.map +1 -0
  45. package/dist/chunks/{index-BL56fbXt.mjs → index-D4GKlc-A.mjs} +89 -87
  46. package/dist/chunks/index-D4GKlc-A.mjs.map +1 -0
  47. package/dist/chunks/{index-BRYzYOYC.mjs → index-D67mP19g.mjs} +29 -29
  48. package/dist/chunks/index-D67mP19g.mjs.map +1 -0
  49. package/dist/chunks/{index-BIL37LSL.mjs → index-D8tbbW97.mjs} +18 -18
  50. package/dist/chunks/{index-BIL37LSL.mjs.map → index-D8tbbW97.mjs.map} +1 -1
  51. package/dist/chunks/{index-DC1EK22F.mjs → index-DIAXWwgJ.mjs} +24 -19
  52. package/dist/chunks/index-DIAXWwgJ.mjs.map +1 -0
  53. package/dist/chunks/{index-BSFLNveF.mjs → index-DQryjfJs.mjs} +352 -341
  54. package/dist/chunks/index-DQryjfJs.mjs.map +1 -0
  55. package/dist/chunks/{index-BTJfyJlJ.mjs → index-DRZwd-1W.mjs} +104 -104
  56. package/dist/chunks/index-DRZwd-1W.mjs.map +1 -0
  57. package/dist/chunks/{index-BQ8iIYLn.mjs → index-DUC1X43Z.mjs} +54 -54
  58. package/dist/chunks/index-DUC1X43Z.mjs.map +1 -0
  59. package/dist/chunks/{index-BCvuDpVr.mjs → index-DipAT_Q9.mjs} +31 -31
  60. package/dist/chunks/index-DipAT_Q9.mjs.map +1 -0
  61. package/dist/chunks/{index-DA8TG2S8.mjs → index-tBDVaSjG.mjs} +56 -56
  62. package/dist/chunks/index-tBDVaSjG.mjs.map +1 -0
  63. package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -1
  64. package/dist/commands/Commands.d.ts +13 -45
  65. package/dist/commands/Commands.d.ts.map +1 -1
  66. package/dist/commands/DeleteCommands.d.ts +15 -0
  67. package/dist/commands/DeleteCommands.d.ts.map +1 -0
  68. package/dist/commands/GapCursorCommands.d.ts +24 -0
  69. package/dist/commands/GapCursorCommands.d.ts.map +1 -0
  70. package/dist/commands/MarkCommands.d.ts +19 -0
  71. package/dist/commands/MarkCommands.d.ts.map +1 -0
  72. package/dist/commands/MovementCommands.d.ts +27 -0
  73. package/dist/commands/MovementCommands.d.ts.map +1 -0
  74. package/dist/commands/NodeSelectionCommands.d.ts +24 -0
  75. package/dist/commands/NodeSelectionCommands.d.ts.map +1 -0
  76. package/dist/commands/PasteCommand.d.ts.map +1 -1
  77. package/dist/commands/WordBoundary.d.ts +12 -0
  78. package/dist/commands/WordBoundary.d.ts.map +1 -0
  79. package/dist/editor/DocumentSerializer.d.ts.map +1 -1
  80. package/dist/editor/NotectlEditor.d.ts +7 -1
  81. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  82. package/dist/index.d.ts +25 -7
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  85. package/dist/input/CompositionTracker.d.ts +14 -0
  86. package/dist/input/CompositionTracker.d.ts.map +1 -0
  87. package/dist/input/FileHandlerRegistry.d.ts +16 -0
  88. package/dist/input/FileHandlerRegistry.d.ts.map +1 -0
  89. package/dist/input/InputHandler.d.ts +6 -4
  90. package/dist/input/InputHandler.d.ts.map +1 -1
  91. package/dist/input/InputRuleRegistry.d.ts +9 -0
  92. package/dist/input/InputRuleRegistry.d.ts.map +1 -0
  93. package/dist/input/KeyboardHandler.d.ts +20 -5
  94. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  95. package/dist/input/Keymap.d.ts +11 -0
  96. package/dist/input/Keymap.d.ts.map +1 -1
  97. package/dist/input/KeymapRegistry.d.ts +19 -0
  98. package/dist/input/KeymapRegistry.d.ts.map +1 -0
  99. package/dist/input/PasteHandler.d.ts +3 -0
  100. package/dist/input/PasteHandler.d.ts.map +1 -1
  101. package/dist/model/Document.d.ts +8 -0
  102. package/dist/model/Document.d.ts.map +1 -1
  103. package/dist/model/GraphemeUtils.d.ts +20 -0
  104. package/dist/model/GraphemeUtils.d.ts.map +1 -0
  105. package/dist/model/HTMLUtils.d.ts +6 -1
  106. package/dist/model/HTMLUtils.d.ts.map +1 -1
  107. package/dist/model/NavigationUtils.d.ts +16 -0
  108. package/dist/model/NavigationUtils.d.ts.map +1 -0
  109. package/dist/model/SchemaRegistry.d.ts +0 -39
  110. package/dist/model/SchemaRegistry.d.ts.map +1 -1
  111. package/dist/model/Selection.d.ts +14 -3
  112. package/dist/model/Selection.d.ts.map +1 -1
  113. package/dist/notectl-core.mjs +2755 -2496
  114. package/dist/notectl-core.mjs.map +1 -1
  115. package/dist/notectl-core.umd.js +2672 -1680
  116. package/dist/notectl-core.umd.js.map +1 -1
  117. package/dist/plugins/Plugin.d.ts +17 -3
  118. package/dist/plugins/Plugin.d.ts.map +1 -1
  119. package/dist/plugins/PluginManager.d.ts +14 -0
  120. package/dist/plugins/PluginManager.d.ts.map +1 -1
  121. package/dist/plugins/alignment.mjs +1 -1
  122. package/dist/plugins/blockquote.mjs +1 -1
  123. package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts +35 -0
  124. package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts.map +1 -0
  125. package/dist/plugins/caret-navigation/index.d.ts +2 -0
  126. package/dist/plugins/caret-navigation/index.d.ts.map +1 -0
  127. package/dist/plugins/caret-navigation.mjs +5 -0
  128. package/dist/plugins/caret-navigation.mjs.map +1 -0
  129. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -1
  130. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
  131. package/dist/plugins/code-block.mjs +1 -1
  132. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  133. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
  134. package/dist/plugins/font-size.mjs +1 -1
  135. package/dist/plugins/font.mjs +1 -1
  136. package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts +15 -0
  137. package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -0
  138. package/dist/plugins/gap-cursor/index.d.ts +2 -0
  139. package/dist/plugins/gap-cursor/index.d.ts.map +1 -0
  140. package/dist/plugins/gap-cursor.mjs +65 -0
  141. package/dist/plugins/gap-cursor.mjs.map +1 -0
  142. package/dist/plugins/hard-break.mjs +1 -1
  143. package/dist/plugins/heading/BlockTypePickerRegistry.d.ts +9 -0
  144. package/dist/plugins/heading/BlockTypePickerRegistry.d.ts.map +1 -0
  145. package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -1
  146. package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -1
  147. package/dist/plugins/heading.mjs +1 -1
  148. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  149. package/dist/plugins/highlight.mjs +1 -1
  150. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
  151. package/dist/plugins/horizontal-rule.mjs +1 -1
  152. package/dist/plugins/image/ImageCommands.d.ts.map +1 -1
  153. package/dist/plugins/image.mjs +1 -1
  154. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  155. package/dist/plugins/link.mjs +1 -1
  156. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  157. package/dist/plugins/list.mjs +1 -1
  158. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
  159. package/dist/plugins/print/PrintTypes.d.ts +5 -1
  160. package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
  161. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
  162. package/dist/plugins/shared/ColorValidation.d.ts +7 -0
  163. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
  164. package/dist/plugins/strikethrough.mjs +1 -1
  165. package/dist/plugins/super-sub.mjs +1 -1
  166. package/dist/plugins/table/TableCommands.d.ts.map +1 -1
  167. package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
  168. package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
  169. package/dist/plugins/table.mjs +1 -1
  170. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  171. package/dist/plugins/text-color.mjs +1 -1
  172. package/dist/plugins/text-formatting.mjs +1 -1
  173. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
  174. package/dist/plugins/toolbar/ToolbarRegistry.d.ts +12 -0
  175. package/dist/plugins/toolbar/ToolbarRegistry.d.ts.map +1 -0
  176. package/dist/plugins/toolbar.mjs +2 -2
  177. package/dist/state/EditorState.d.ts.map +1 -1
  178. package/dist/state/History.d.ts.map +1 -1
  179. package/dist/state/SelectionTransactions.d.ts +10 -0
  180. package/dist/state/SelectionTransactions.d.ts.map +1 -0
  181. package/dist/test/TestUtils.d.ts +23 -0
  182. package/dist/test/TestUtils.d.ts.map +1 -1
  183. package/dist/view/CaretNavigation.d.ts +48 -0
  184. package/dist/view/CaretNavigation.d.ts.map +1 -0
  185. package/dist/view/CursorWrapper.d.ts +19 -0
  186. package/dist/view/CursorWrapper.d.ts.map +1 -0
  187. package/dist/view/DomPointUtils.d.ts +20 -0
  188. package/dist/view/DomPointUtils.d.ts.map +1 -0
  189. package/dist/view/EditorView.d.ts +43 -0
  190. package/dist/view/EditorView.d.ts.map +1 -1
  191. package/dist/view/MarkRendering.d.ts +7 -0
  192. package/dist/view/MarkRendering.d.ts.map +1 -0
  193. package/dist/view/NodeViewRegistry.d.ts +9 -0
  194. package/dist/view/NodeViewRegistry.d.ts.map +1 -0
  195. package/dist/view/Platform.d.ts +29 -0
  196. package/dist/view/Platform.d.ts.map +1 -0
  197. package/dist/view/Reconciler.d.ts +4 -0
  198. package/dist/view/Reconciler.d.ts.map +1 -1
  199. package/dist/view/SelectionSync.d.ts +2 -0
  200. package/dist/view/SelectionSync.d.ts.map +1 -1
  201. package/dist/view/ViewMovementCommands.d.ts +40 -0
  202. package/dist/view/ViewMovementCommands.d.ts.map +1 -0
  203. package/package.json +10 -2
  204. package/dist/chunks/ColorNames-iaWsSZx1.mjs +0 -35
  205. package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +0 -1
  206. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +0 -140
  207. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +0 -1
  208. package/dist/chunks/Commands-CSpSwGXv.mjs +0 -461
  209. package/dist/chunks/Commands-CSpSwGXv.mjs.map +0 -1
  210. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +0 -7
  211. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +0 -1
  212. package/dist/chunks/Selection-D5ZjXoB7.mjs +0 -44
  213. package/dist/chunks/Selection-D5ZjXoB7.mjs.map +0 -1
  214. package/dist/chunks/ToolbarItem-ugDymuXi.mjs +0 -7
  215. package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +0 -1
  216. package/dist/chunks/index-BCvuDpVr.mjs.map +0 -1
  217. package/dist/chunks/index-BL56fbXt.mjs.map +0 -1
  218. package/dist/chunks/index-BQ8iIYLn.mjs.map +0 -1
  219. package/dist/chunks/index-BRYzYOYC.mjs.map +0 -1
  220. package/dist/chunks/index-BSFLNveF.mjs.map +0 -1
  221. package/dist/chunks/index-BTJfyJlJ.mjs.map +0 -1
  222. package/dist/chunks/index-Bsp4LC5t.mjs.map +0 -1
  223. package/dist/chunks/index-DA8TG2S8.mjs.map +0 -1
  224. package/dist/chunks/index-DC1EK22F.mjs.map +0 -1
  225. package/dist/chunks/index-DGrRWMlW.mjs.map +0 -1
  226. package/dist/chunks/index-o6hDR07y.mjs.map +0 -1
  227. package/dist/chunks/index-uTnc9y7M.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CPyHuEzh.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 {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} 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) || isGapCursor(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, { priority: 'context' });\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, isGapCursor, 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) || isGapCursor(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) || isGapCursor(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 {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} 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 =\n\t\t\tisNodeSelection(oldState.selection) || isGapCursor(oldState.selection)\n\t\t\t\t? null\n\t\t\t\t: oldState.selection.anchor.blockId;\n\t\tconst newBlockId: BlockId | null =\n\t\t\tisNodeSelection(newState.selection) || isGapCursor(newState.selection)\n\t\t\t\t? null\n\t\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) || isGapCursor(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) || isGapCursor(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(\n\t\t\t(tr, state, next) => {\n\t\t\t\tconst hasMarkInCodeBlock: boolean = tr.steps.some((step) => {\n\t\t\t\t\tif (step.type !== 'addMark') return false;\n\t\t\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\t\t\treturn block?.type === 'code_block';\n\t\t\t\t});\n\n\t\t\t\tif (!hasMarkInCodeBlock) {\n\t\t\t\t\tnext(tr);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst filtered = tr.steps.filter((step) => {\n\t\t\t\t\tif (step.type !== 'addMark') return true;\n\t\t\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\t\t\treturn block?.type !== 'code_block';\n\t\t\t\t});\n\n\t\t\t\tnext({ ...tr, steps: filtered });\n\t\t\t},\n\t\t\t{ name: 'code-block:mark-guard', priority: 50 },\n\t\t);\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","isGapCursor","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","destroy","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","remove","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,MAAAA;AAAAA,UACZ,KAAK;AACJ,oBA4CH,SAAyBF,IAAwBC,IAAAA;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,GAAAA;AAAAA,YACtC,GAvD0BV,IAAMC,EAAAA;AAAAA,UAC9B,KAAK;AACJ,oBAuEH,SAAyBD,IAAwBC,IAAAA;AAChD,kBAAID,GAAKG,YAAYF,GAAKE,QAAS,QAAOH;AAE1C,oBAAMY,KAAiBX,GAAKU,KAAKV,GAAKO,MAChCD,KAAkBM,EAAcb,GAAKQ,MAAMP,GAAKO,MAAMP,GA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;EAG5B;AAAA,EAIQ,gBAAgBlP,IAAcqP,IAAAA;AACrC,QAAA,CAAKpQ,KAAK8C,QAAS;AACnB,UACM4J,KADyB1M,KAAK8C,QAAQuN,aAAAA,EACP1D,cAAc,mBAAmB5L,EAAAA,IAAAA;AAClE2L,IAAAA,MACHA,GAAGuC,UAAUvI,OAAO,+BAA+B0J,EAAAA;AAAAA,EAErD;AAAA;"}
@@ -1,12 +1,14 @@
1
1
  import { S as e, r as t } from "./resolvePluginLocale-B4w1OkPy.mjs";
2
- import { e as n } from "./HTMLUtils-0wvCRvJc.mjs";
2
+ import { e as n } from "./HTMLUtils-DTqQzcKR.mjs";
3
3
  import { c as i } from "./NodeSpec-NZVvcCuH.mjs";
4
- import { i as r, c as o, b as a } from "./Selection-D5ZjXoB7.mjs";
5
- import { f as s } from "./ToolbarItem-ugDymuXi.mjs";
6
- import { a as l, c, u as d } from "./Document-CI3iCwEP.mjs";
7
- import { n as g } from "./TypeBrands-C09nE2qO.mjs";
8
- function u(e2, t2) {
9
- const n2 = e2.getState(), i2 = n2.selection, o2 = { src: t2.src, alt: t2.alt ?? "", align: t2.align ?? "center", ...void 0 !== t2.width ? { width: t2.width } : {}, ...void 0 !== t2.height ? { height: t2.height } : {} }, s2 = r(i2) ? i2.nodeId : i2.anchor.blockId, u2 = (function(e3, t3) {
4
+ import { i as r, a as o, c as a, e as s } from "./Selection-DmFDwiPJ.mjs";
5
+ import { f as l } from "./ToolbarItem-BpZggUGo.mjs";
6
+ import { a as c, f as d, u as g } from "./Document-CuwE73FF.mjs";
7
+ import { n as u } from "./TypeBrands-C09nE2qO.mjs";
8
+ function m(e2, t2) {
9
+ const n2 = e2.getState(), i2 = n2.selection, a2 = { src: t2.src, alt: t2.alt ?? "", align: t2.align ?? "center", ...void 0 !== t2.width ? { width: t2.width } : {}, ...void 0 !== t2.height ? { height: t2.height } : {} };
10
+ if (o(i2)) return false;
11
+ const l2 = r(i2) ? i2.nodeId : i2.anchor.blockId, m2 = (function(e3, t3) {
10
12
  const n3 = e3.getBlock(t3);
11
13
  if ("table_cell" === n3?.type) return t3;
12
14
  const i3 = e3.getNodePath(t3);
@@ -14,26 +16,26 @@ function u(e2, t2) {
14
16
  const n4 = e3.getBlock(t4);
15
17
  if ("table_cell" === n4?.type) return t4;
16
18
  }
17
- })(n2, s2);
18
- return u2 ? (function(e3, t3, n3, i3) {
19
+ })(n2, l2);
20
+ return m2 ? (function(e3, t3, n3, i3) {
19
21
  const r2 = e3.getNodePath(n3);
20
22
  if (!r2) return false;
21
- const o3 = c(g("image"), [], void 0, i3), s3 = e3.getBlock(n3);
22
- if (!s3) return false;
23
- const u3 = e3.transaction("command"), m2 = d(s3);
24
- for (let e4 = m2.length - 1; e4 >= 0; e4--) {
25
- const t4 = s3.children.findIndex((t5) => l(t5) && t5.id === m2[e4]?.id);
26
- -1 !== t4 && u3.removeNode(r2, t4);
23
+ const o2 = d(u("image"), [], void 0, i3), a3 = e3.getBlock(n3);
24
+ if (!a3) return false;
25
+ const l3 = e3.transaction("command"), m3 = g(a3);
26
+ for (let e4 = m3.length - 1; e4 >= 0; e4--) {
27
+ const t4 = a3.children.findIndex((t5) => c(t5) && t5.id === m3[e4]?.id);
28
+ -1 !== t4 && l3.removeNode(r2, t4);
27
29
  }
28
- return u3.insertNode(r2, 0, o3), u3.setSelection(a(o3.id, [...r2, o3.id])), t3.dispatch(u3.build()), true;
29
- })(n2, e2, u2, o2) : (function(e3, t3, n3, i3) {
30
+ return l3.insertNode(r2, 0, o2), l3.setSelection(s(o2.id, [...r2, o2.id])), t3.dispatch(l3.build()), true;
31
+ })(n2, e2, m2, a2) : (function(e3, t3, n3, i3) {
30
32
  const r2 = e3.doc.children.findIndex((e4) => e4.id === n3);
31
33
  if (-1 === r2) return false;
32
- const o3 = c(g("image"), [], void 0, i3), s3 = c(g("paragraph")), l2 = e3.transaction("command").insertNode([], r2 + 1, o3).insertNode([], r2 + 2, s3).setSelection(a(o3.id, [])).build();
33
- return t3.dispatch(l2), true;
34
- })(n2, e2, s2, o2);
34
+ const o2 = d(u("image"), [], void 0, i3), a3 = d(u("paragraph")), l3 = e3.transaction("command").insertNode([], r2 + 1, o2).insertNode([], r2 + 2, a3).setSelection(s(o2.id, [])).build();
35
+ return t3.dispatch(l3), true;
36
+ })(n2, e2, l2, a2);
35
37
  }
36
- function m(e2, t2, n2) {
38
+ function p(e2, t2, n2) {
37
39
  const i2 = e2.getState(), o2 = i2.selection;
38
40
  if (!r(o2)) return false;
39
41
  const a2 = i2.getBlock(o2.nodeId);
@@ -52,10 +54,10 @@ function m(e2, t2, n2) {
52
54
  return e3.dispatch(l3), true;
53
55
  })(e2, { width: d2, height: g2 });
54
56
  }
55
- const p = { insertImage: "Insert Image", insertImageTooltip: "Insert Image", uploadFromComputer: "Upload from computer", uploadAria: "Upload image from computer", separator: "or", urlPlaceholder: "https://...", urlAria: "Image URL", insertButton: "Insert", insertAria: "Insert image", imageAria: (e2, t2, n2) => {
57
+ const h = { insertImage: "Insert Image", insertImageTooltip: "Insert Image", uploadFromComputer: "Upload from computer", uploadAria: "Upload image from computer", separator: "or", urlPlaceholder: "https://...", urlAria: "Image URL", insertButton: "Insert", insertAria: "Insert image", imageAria: (e2, t2, n2) => {
56
58
  const i2 = [e2 || "Image"];
57
59
  return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} by ${n2} pixels`), i2.join(", ");
58
- }, resetToNaturalSize: "Image reset to natural size.", uploadFailed: "Image upload failed." }, h = { en: p, de: { insertImage: "Bild einfügen", insertImageTooltip: "Bild einfügen", uploadFromComputer: "Vom Computer hochladen", uploadAria: "Bild vom Computer hochladen", separator: "oder", urlPlaceholder: "https://...", urlAria: "Bild-URL", insertButton: "Einfügen", insertAria: "Bild einfügen", imageAria: (e2, t2, n2) => {
60
+ }, resetToNaturalSize: "Image reset to natural size.", uploadFailed: "Image upload failed." }, f = { en: h, de: { insertImage: "Bild einfügen", insertImageTooltip: "Bild einfügen", uploadFromComputer: "Vom Computer hochladen", uploadAria: "Bild vom Computer hochladen", separator: "oder", urlPlaceholder: "https://...", urlAria: "Bild-URL", insertButton: "Einfügen", insertAria: "Bild einfügen", imageAria: (e2, t2, n2) => {
59
61
  const i2 = [e2 || "Bild"];
60
62
  return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} mal ${n2} Pixel`), i2.join(", ");
61
63
  }, resetToNaturalSize: "Bild auf Originalgröße zurückgesetzt.", uploadFailed: "Bild-Upload fehlgeschlagen." }, es: { insertImage: "Insertar imagen", insertImageTooltip: "Insertar imagen", uploadFromComputer: "Subir desde el ordenador", uploadAria: "Subir imagen desde el ordenador", separator: "o", urlPlaceholder: "https://...", urlAria: "URL de la imagen", insertButton: "Insertar", insertAria: "Insertar imagen", imageAria: (e2, t2, n2) => {
@@ -76,28 +78,28 @@ const p = { insertImage: "Insert Image", insertImageTooltip: "Insert Image", upl
76
78
  }, resetToNaturalSize: "تمت إعادة الصورة إلى حجمها الطبيعي.", uploadFailed: "فشل رفع الصورة." }, hi: { insertImage: "चित्र डालें", insertImageTooltip: "चित्र डालें", uploadFromComputer: "कंप्यूटर से अपलोड करें", uploadAria: "कंप्यूटर से चित्र अपलोड करें", separator: "या", urlPlaceholder: "https://...", urlAria: "चित्र URL", insertButton: "डालें", insertAria: "चित्र डालें", imageAria: (e2, t2, n2) => {
77
79
  const i2 = [e2 || "चित्र"];
78
80
  return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} x ${n2} पिक्सेल`), i2.join(", ");
79
- }, resetToNaturalSize: "चित्र मूल आकार में पुनर्स्थापित।", uploadFailed: "चित्र अपलोड विफल।" } }, f = { left: "notectl-image--left", center: "notectl-image--center", right: "notectl-image--right" }, b = { nw: "nwse-resize", ne: "nesw-resize", sw: "nesw-resize", se: "nwse-resize" }, v = { nw: -1, ne: 1, sw: -1, se: 1 }, x = { nw: "Resize top-left", ne: "Resize top-right", sw: "Resize bottom-left", se: "Resize bottom-right" };
80
- let y = null;
81
- function I() {
82
- y && (y.remove(), y = null);
81
+ }, resetToNaturalSize: "चित्र मूल आकार में पुनर्स्थापित।", uploadFailed: "चित्र अपलोड विफल।" } }, b = { left: "notectl-image--left", center: "notectl-image--center", right: "notectl-image--right" }, v = { nw: "nwse-resize", ne: "nesw-resize", sw: "nesw-resize", se: "nwse-resize" }, x = { nw: -1, ne: 1, sw: -1, se: 1 }, y = { nw: "Resize top-left", ne: "Resize top-right", sw: "Resize bottom-left", se: "Resize bottom-right" };
82
+ let I = null;
83
+ function z() {
84
+ I && (I.remove(), I = null);
83
85
  }
84
- function z(e2, t2, n2) {
86
+ function w(e2, t2, n2) {
85
87
  return (i2, r2, o2) => {
86
88
  const a2 = document.createElement("figure");
87
89
  a2.className = "notectl-image", a2.setAttribute("data-block-id", i2.id), a2.setAttribute("data-void", "true"), a2.setAttribute("data-selectable", "true");
88
- const l2 = document.createElement("div");
89
- l2.className = "notectl-image__container";
90
+ const s2 = document.createElement("div");
91
+ s2.className = "notectl-image__container";
90
92
  const c2 = document.createElement("img");
91
93
  c2.className = "notectl-image__img", c2.draggable = false;
92
94
  const d2 = document.createElement("div");
93
- d2.className = "notectl-image__overlay", l2.appendChild(c2), l2.appendChild(d2), a2.appendChild(l2);
95
+ d2.className = "notectl-image__overlay", s2.appendChild(c2), s2.appendChild(d2), a2.appendChild(s2);
94
96
  let g2 = i2.id, u2 = null;
95
97
  function m2(e3) {
96
- const n3 = e3.attrs?.src ?? "", i3 = e3.attrs?.alt ?? "", r3 = e3.attrs?.width, o3 = e3.attrs?.height, s2 = e3.attrs?.align ?? "center";
98
+ const n3 = e3.attrs?.src ?? "", i3 = e3.attrs?.alt ?? "", r3 = e3.attrs?.width, o3 = e3.attrs?.height, s3 = e3.attrs?.align ?? "center";
97
99
  c2.src !== n3 && (c2.src = n3), c2.alt = i3, c2.style.width = void 0 !== r3 ? `${r3}px` : "", c2.style.height = void 0 !== o3 ? `${o3}px` : "";
98
- for (const e4 of Object.values(f)) a2.classList.remove(e4);
99
- const l3 = f[s2];
100
- l3 && a2.classList.add(l3);
100
+ for (const e4 of Object.values(b)) a2.classList.remove(e4);
101
+ const l2 = b[s3];
102
+ l2 && a2.classList.add(l2);
101
103
  const g3 = t2.get(e3.id) ?? "idle", u3 = "uploading" === g3;
102
104
  d2.classList.toggle("notectl-image__overlay--uploading", u3), d2.classList.toggle("notectl-image__overlay--error", "error" === g3), d2.textContent = u3 ? "Uploading..." : "error" === g3 ? "Upload failed" : "", u3 ? a2.setAttribute("aria-busy", "true") : a2.removeAttribute("aria-busy"), (function(e4) {
103
105
  const t3 = e4.attrs?.alt ?? "", n4 = e4.attrs?.width, i4 = e4.attrs?.height, r4 = [];
@@ -106,21 +108,21 @@ function z(e2, t2, n2) {
106
108
  }
107
109
  m2(i2);
108
110
  let p2 = false;
109
- function h2(t3, n3, i3, s2) {
110
- let l3 = 0, d3 = 0, g3 = 1;
111
+ function h2(t3, n3, i3, s3) {
112
+ let l2 = 0, d3 = 0, g3 = 1;
111
113
  const u3 = (t4) => {
112
- const i4 = t4.clientX - l3, r3 = (o3 = d3 + i4 * v[n3], Math.max(50, Math.min(e2.maxWidth, o3)));
114
+ const i4 = t4.clientX - l2, r3 = (o3 = d3 + i4 * x[n3], Math.max(50, Math.min(e2.maxWidth, o3)));
113
115
  var o3;
114
116
  const a3 = Math.round(r3 / g3);
115
- c2.style.width = `${r3}px`, c2.style.height = `${a3}px`, s2.textContent = `${Math.round(r3)} × ${a3}`;
117
+ c2.style.width = `${r3}px`, c2.style.height = `${a3}px`, s3.textContent = `${Math.round(r3)} × ${a3}`;
116
118
  }, m3 = (e3) => {
117
- document.removeEventListener("pointermove", u3), document.removeEventListener("pointerup", m3), a2.classList.remove("notectl-image--resizing"), s2.classList.remove("notectl-image__size-indicator--visible"), I();
119
+ document.removeEventListener("pointermove", u3), document.removeEventListener("pointerup", m3), a2.classList.remove("notectl-image--resizing"), s3.classList.remove("notectl-image__size-indicator--visible"), z();
118
120
  const t4 = Math.round(c2.getBoundingClientRect().width), n4 = Math.round(t4 / g3);
119
121
  !(function(e4, t5, n5) {
120
122
  const i4 = r2(), a3 = i4.getBlock(e4);
121
123
  if (!a3) return;
122
- const s3 = a3.attrs?.width, l4 = a3.attrs?.height;
123
- if (s3 === t5 && l4 === n5) return;
124
+ const s4 = a3.attrs?.width, l3 = a3.attrs?.height;
125
+ if (s4 === t5 && l3 === n5) return;
124
126
  const c3 = i4.getNodePath(e4);
125
127
  if (!c3) return;
126
128
  const d4 = { ...a3.attrs ?? {}, width: t5, height: n5 }, g4 = i4.transaction("command").setNodeAttr(c3, d4).build();
@@ -128,14 +130,14 @@ function z(e2, t2, n2) {
128
130
  })(i3, t4, n4), e3.target?.releasePointerCapture?.(e3.pointerId);
129
131
  };
130
132
  t3.addEventListener("pointerdown", (e3) => {
131
- e3.preventDefault(), e3.stopPropagation(), l3 = e3.clientX, d3 = c2.getBoundingClientRect().width;
133
+ e3.preventDefault(), e3.stopPropagation(), l2 = e3.clientX, d3 = c2.getBoundingClientRect().width;
132
134
  const t4 = c2.getBoundingClientRect().height;
133
135
  var i4;
134
- g3 = t4 > 0 ? d3 / t4 : 1, a2.classList.add("notectl-image--resizing"), s2.textContent = `${Math.round(d3)} × ${Math.round(t4)}`, s2.classList.add("notectl-image__size-indicator--visible"), i4 = b[n3], I(), y = document.createElement("style"), y.textContent = `*{cursor:${i4}!important;user-select:none!important}`, document.head.appendChild(y), e3.target.setPointerCapture(e3.pointerId), document.addEventListener("pointermove", u3), document.addEventListener("pointerup", m3);
136
+ g3 = t4 > 0 ? d3 / t4 : 1, a2.classList.add("notectl-image--resizing"), s3.textContent = `${Math.round(d3)} × ${Math.round(t4)}`, s3.classList.add("notectl-image__size-indicator--visible"), i4 = v[n3], z(), I = document.createElement("style"), I.textContent = `*{cursor:${i4}!important;user-select:none!important}`, document.head.appendChild(I), e3.target.setPointerCapture(e3.pointerId), document.addEventListener("pointermove", u3), document.addEventListener("pointerup", m3);
135
137
  });
136
138
  }
137
- function z2() {
138
- I(), u2 && (u2.remove(), u2 = null);
139
+ function f2() {
140
+ z(), u2 && (u2.remove(), u2 = null);
139
141
  }
140
142
  return c2.addEventListener("load", () => {
141
143
  if (p2) return;
@@ -143,11 +145,11 @@ function z(e2, t2, n2) {
143
145
  if (!n3 || "image" !== n3.type) return;
144
146
  const i3 = void 0 !== n3.attrs?.width, a3 = void 0 !== n3.attrs?.height;
145
147
  if (i3 && a3) return void (p2 = true);
146
- const s2 = c2.naturalWidth, l3 = c2.naturalHeight;
147
- if (0 === s2 || 0 === l3) return;
148
- const d3 = Math.min(s2, e2.maxWidth), u3 = s2 > 0 ? l3 / s2 : 1, m3 = Math.round(d3 * u3), h3 = t3.getNodePath(g2);
148
+ const s3 = c2.naturalWidth, l2 = c2.naturalHeight;
149
+ if (0 === s3 || 0 === l2) return;
150
+ const d3 = Math.min(s3, e2.maxWidth), u3 = s3 > 0 ? l2 / s3 : 1, m3 = Math.round(d3 * u3), h3 = t3.getNodePath(g2);
149
151
  if (!h3) return;
150
- const f2 = { ...n3.attrs ?? {}, width: d3, height: m3 }, b2 = t3.transaction("command").setNodeAttr(h3, f2).build();
152
+ const f3 = { ...n3.attrs ?? {}, width: d3, height: m3 }, b2 = t3.transaction("command").setNodeAttr(h3, f3).build();
151
153
  o2(b2), p2 = true;
152
154
  }), { dom: a2, contentDOM: null, update: (e3) => "image" === e3.type && (g2 = e3.id, a2.setAttribute("data-block-id", e3.id), m2(e3), true), selectNode() {
153
155
  a2.classList.add("notectl-image--selected"), (function(t3) {
@@ -158,29 +160,29 @@ function z(e2, t2, n2) {
158
160
  const r3 = ["nw", "ne", "sw", "se"];
159
161
  for (const e3 of r3) {
160
162
  const n3 = document.createElement("div");
161
- n3.className = `notectl-image__resize-handle notectl-image__resize-handle--${e3}`, n3.setAttribute("role", "separator"), n3.setAttribute("aria-label", x[e3]), h2(n3, e3, t3, i3), u2.appendChild(n3);
163
+ n3.className = `notectl-image__resize-handle notectl-image__resize-handle--${e3}`, n3.setAttribute("role", "separator"), n3.setAttribute("aria-label", y[e3]), h2(n3, e3, t3, i3), u2.appendChild(n3);
162
164
  }
163
165
  if (n2) {
164
166
  const e3 = (function(e4) {
165
167
  const t4 = e4.shrinkWidth ?? null, n3 = e4.growWidth ?? null;
166
- return t4 && n3 ? `${s(t4)} / ${s(n3)} to resize` : "";
168
+ return t4 && n3 ? `${l(t4)} / ${l(n3)} to resize` : "";
167
169
  })(n2);
168
170
  if (e3) {
169
171
  const t4 = document.createElement("div");
170
172
  t4.className = "notectl-image__keyboard-hint", t4.setAttribute("aria-hidden", "true"), t4.textContent = e3, u2.appendChild(t4);
171
173
  }
172
174
  }
173
- l2.appendChild(u2);
175
+ s2.appendChild(u2);
174
176
  })(g2);
175
177
  }, deselectNode() {
176
- a2.classList.remove("notectl-image--selected"), z2();
178
+ a2.classList.remove("notectl-image--selected"), f2();
177
179
  }, destroy() {
178
- z2();
180
+ f2();
179
181
  } };
180
182
  };
181
183
  }
182
- const w = new e("image:upload"), A = { growWidth: "Mod-Shift-ArrowRight", shrinkWidth: "Mod-Shift-ArrowLeft", growWidthLarge: "Mod-Shift-Alt-ArrowRight", shrinkWidthLarge: "Mod-Shift-Alt-ArrowLeft", resetSize: "Mod-Shift-0" }, _ = { maxWidth: 800, maxFileSize: 10485760, acceptedTypes: ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"], resizable: true, resizeStep: 10, resizeStepLarge: 50 };
183
- class S {
184
+ const A = new e("image:upload"), _ = { growWidth: "Mod-Shift-ArrowRight", shrinkWidth: "Mod-Shift-ArrowLeft", growWidthLarge: "Mod-Shift-Alt-ArrowRight", shrinkWidthLarge: "Mod-Shift-Alt-ArrowLeft", resetSize: "Mod-Shift-0" }, S = { maxWidth: 800, maxFileSize: 10485760, acceptedTypes: ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"], resizable: true, resizeStep: 10, resizeStepLarge: 50 };
185
+ class k {
184
186
  id = "image";
185
187
  name = "Image";
186
188
  priority = 45;
@@ -191,26 +193,26 @@ class S {
191
193
  context = null;
192
194
  locale;
193
195
  constructor(e2) {
194
- this.config = { ..._, ...e2 }, this.resolvedKeymap = { ...A, ...e2?.keymap };
196
+ this.config = { ...S, ...e2 }, this.resolvedKeymap = { ..._, ...e2?.keymap };
195
197
  }
196
198
  init(e2) {
197
- this.locale = t(h, e2, this.config.locale), e2.registerStyleSheet("\n/* Image */\n.notectl-image {\n margin: 8px 0;\n user-select: none;\n line-height: 0;\n}\n\n.notectl-image--center {\n text-align: center;\n}\n\n.notectl-image--left {\n text-align: left;\n}\n\n.notectl-image--right {\n text-align: right;\n}\n\n.notectl-image__container {\n display: inline-block;\n position: relative;\n line-height: 0;\n}\n\n.notectl-image__img {\n display: block;\n max-width: 100%;\n border-radius: 4px;\n}\n\n.notectl-image--selected .notectl-image__container {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n border-radius: 6px;\n}\n\n/* Alignment toolbar (appears on image selection) */\n.notectl-image__align-toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n top: -36px;\n left: 50%;\n transform: translateX(-50%);\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n padding: 2px;\n box-shadow: 0 2px 8px var(--notectl-shadow);\n z-index: 10;\n}\n\n.notectl-image__align-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: none;\n background: transparent;\n border-radius: 4px;\n cursor: pointer;\n color: var(--notectl-fg);\n}\n\n.notectl-image__align-btn:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-image__align-btn--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-image__align-btn svg {\n width: 16px;\n height: 16px;\n fill: currentColor;\n}\n\n/* Upload overlay */\n.notectl-image__overlay {\n position: absolute;\n inset: 0;\n display: none;\n align-items: center;\n justify-content: center;\n background: rgba(255, 255, 255, 0.8);\n border-radius: 4px;\n font-size: 13px;\n color: var(--notectl-fg-muted);\n}\n\n.notectl-image__overlay--uploading {\n display: flex;\n}\n\n.notectl-image__overlay--error {\n display: flex;\n background: var(--notectl-danger-muted);\n color: var(--notectl-danger);\n}\n\n/* Resize overlay + handles */\n.notectl-image__resize-overlay {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n.notectl-image__resize-handle {\n position: absolute;\n width: 10px;\n height: 10px;\n background: var(--notectl-bg);\n border: 2px solid var(--notectl-primary);\n border-radius: 50%;\n pointer-events: all;\n z-index: 2;\n transition: transform 0.1s, background 0.1s;\n}\n\n.notectl-image__resize-handle:hover {\n background: var(--notectl-primary);\n transform: scale(1.3);\n}\n\n.notectl-image--resizing .notectl-image__resize-handle {\n background: var(--notectl-primary);\n}\n\n.notectl-image__resize-handle--nw {\n top: -5px;\n left: -5px;\n cursor: nwse-resize;\n}\n\n.notectl-image__resize-handle--ne {\n top: -5px;\n right: -5px;\n cursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--sw {\n bottom: -5px;\n left: -5px;\n cursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--se {\n bottom: -5px;\n right: -5px;\n cursor: nwse-resize;\n}\n\n/* Size indicator tooltip */\n.notectl-image__size-indicator {\n position: absolute;\n bottom: -28px;\n left: 50%;\n transform: translateX(-50%);\n padding: 2px 8px;\n background: var(--notectl-tooltip-bg);\n color: var(--notectl-tooltip-fg);\n font-size: 11px;\n font-weight: 500;\n border-radius: 4px;\n white-space: nowrap;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s;\n z-index: 3;\n}\n\n.notectl-image__size-indicator--visible {\n opacity: 1;\n}\n\n/* Keyboard resize hint (shown on selection, hidden during drag) */\n.notectl-image__keyboard-hint {\n display: none;\n position: absolute;\n bottom: -28px;\n left: 50%;\n transform: translateX(-50%);\n padding: 2px 8px;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n white-space: nowrap;\n pointer-events: none;\n z-index: 3;\n}\n\n.notectl-image--selected .notectl-image__keyboard-hint {\n display: block;\n}\n\n.notectl-image--resizing .notectl-image__keyboard-hint {\n display: none;\n}\n\n/* Resizing feedback */\n.notectl-image--resizing .notectl-image__img {\n opacity: 0.85;\n}\n"), this.context = e2, this.registerNodeSpec(e2), this.registerNodeView(e2), (function(e3) {
198
- e3.registerCommand("insertImage", () => u(e3, { src: "" })), e3.registerCommand("removeImage", () => (function(e4) {
199
+ this.locale = t(f, e2, this.config.locale), e2.registerStyleSheet("\n/* Image */\n.notectl-image {\n margin: 8px 0;\n user-select: none;\n line-height: 0;\n}\n\n.notectl-image--center {\n text-align: center;\n}\n\n.notectl-image--left {\n text-align: left;\n}\n\n.notectl-image--right {\n text-align: right;\n}\n\n.notectl-image__container {\n display: inline-block;\n position: relative;\n line-height: 0;\n}\n\n.notectl-image__img {\n display: block;\n max-width: 100%;\n border-radius: 4px;\n}\n\n.notectl-image--selected .notectl-image__container {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n border-radius: 6px;\n}\n\n/* Alignment toolbar (appears on image selection) */\n.notectl-image__align-toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n top: -36px;\n left: 50%;\n transform: translateX(-50%);\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n padding: 2px;\n box-shadow: 0 2px 8px var(--notectl-shadow);\n z-index: 10;\n}\n\n.notectl-image__align-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: none;\n background: transparent;\n border-radius: 4px;\n cursor: pointer;\n color: var(--notectl-fg);\n}\n\n.notectl-image__align-btn:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-image__align-btn--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-image__align-btn svg {\n width: 16px;\n height: 16px;\n fill: currentColor;\n}\n\n/* Upload overlay */\n.notectl-image__overlay {\n position: absolute;\n inset: 0;\n display: none;\n align-items: center;\n justify-content: center;\n background: rgba(255, 255, 255, 0.8);\n border-radius: 4px;\n font-size: 13px;\n color: var(--notectl-fg-muted);\n}\n\n.notectl-image__overlay--uploading {\n display: flex;\n}\n\n.notectl-image__overlay--error {\n display: flex;\n background: var(--notectl-danger-muted);\n color: var(--notectl-danger);\n}\n\n/* Resize overlay + handles */\n.notectl-image__resize-overlay {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n.notectl-image__resize-handle {\n position: absolute;\n width: 10px;\n height: 10px;\n background: var(--notectl-bg);\n border: 2px solid var(--notectl-primary);\n border-radius: 50%;\n pointer-events: all;\n z-index: 2;\n transition: transform 0.1s, background 0.1s;\n}\n\n.notectl-image__resize-handle:hover {\n background: var(--notectl-primary);\n transform: scale(1.3);\n}\n\n.notectl-image--resizing .notectl-image__resize-handle {\n background: var(--notectl-primary);\n}\n\n.notectl-image__resize-handle--nw {\n top: -5px;\n left: -5px;\n cursor: nwse-resize;\n}\n\n.notectl-image__resize-handle--ne {\n top: -5px;\n right: -5px;\n cursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--sw {\n bottom: -5px;\n left: -5px;\n cursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--se {\n bottom: -5px;\n right: -5px;\n cursor: nwse-resize;\n}\n\n/* Size indicator tooltip */\n.notectl-image__size-indicator {\n position: absolute;\n bottom: -28px;\n left: 50%;\n transform: translateX(-50%);\n padding: 2px 8px;\n background: var(--notectl-tooltip-bg);\n color: var(--notectl-tooltip-fg);\n font-size: 11px;\n font-weight: 500;\n border-radius: 4px;\n white-space: nowrap;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s;\n z-index: 3;\n}\n\n.notectl-image__size-indicator--visible {\n opacity: 1;\n}\n\n/* Keyboard resize hint (shown on selection, hidden during drag) */\n.notectl-image__keyboard-hint {\n display: none;\n position: absolute;\n bottom: -28px;\n left: 50%;\n transform: translateX(-50%);\n padding: 2px 8px;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n white-space: nowrap;\n pointer-events: none;\n z-index: 3;\n}\n\n.notectl-image--selected .notectl-image__keyboard-hint {\n display: block;\n}\n\n.notectl-image--resizing .notectl-image__keyboard-hint {\n display: none;\n}\n\n/* Resizing feedback */\n.notectl-image--resizing .notectl-image__img {\n opacity: 0.85;\n}\n"), this.context = e2, this.registerNodeSpec(e2), this.registerNodeView(e2), (function(e3) {
200
+ e3.registerCommand("insertImage", () => m(e3, { src: "" })), e3.registerCommand("removeImage", () => (function(e4) {
199
201
  const t2 = e4.getState(), n2 = t2.selection;
200
202
  if (!r(n2)) return false;
201
203
  const i2 = t2.getBlock(n2.nodeId);
202
204
  if (!i2 || "image" !== i2.type) return false;
203
- const a2 = t2.getNodePath(n2.nodeId);
204
- if (!a2 || 0 === a2.length) return false;
205
- const s2 = a2.slice(0, -1);
206
- let c2;
207
- if (0 === s2.length) c2 = t2.doc;
205
+ const o2 = t2.getNodePath(n2.nodeId);
206
+ if (!o2 || 0 === o2.length) return false;
207
+ const s2 = o2.slice(0, -1);
208
+ let l2;
209
+ if (0 === s2.length) l2 = t2.doc;
208
210
  else {
209
211
  const e5 = s2[s2.length - 1];
210
- c2 = e5 ? t2.getBlock(e5) : void 0;
212
+ l2 = e5 ? t2.getBlock(e5) : void 0;
211
213
  }
212
- if (!c2) return false;
213
- const d2 = c2.children.findIndex((e5) => l(e5) && e5.id === n2.nodeId);
214
+ if (!l2) return false;
215
+ const d2 = l2.children.findIndex((e5) => c(e5) && e5.id === n2.nodeId);
214
216
  if (-1 === d2) return false;
215
217
  const g2 = (function(e5, t3, n3) {
216
218
  if (0 === t3.length) {
@@ -220,7 +222,7 @@ class S {
220
222
  return t3[t3.length - 1];
221
223
  })(t2, s2, n2.nodeId);
222
224
  if (!g2) return false;
223
- const u2 = t2.transaction("command").removeNode(s2, d2).setSelection(o(g2, 0)).build();
225
+ const u2 = t2.transaction("command").removeNode(s2, d2).setSelection(a(g2, 0)).build();
224
226
  return e4.dispatch(u2), true;
225
227
  })(e3));
226
228
  })(e2), this.registerResizeCommands(e2), this.registerResizeKeymaps(e2), this.registerFileHandler(e2), this.registerToolbarItem(e2);
@@ -260,21 +262,21 @@ class S {
260
262
  } }], sanitize: { tags: ["figure", "img"], attrs: ["src", "alt", "width", "height", "class"] } });
261
263
  }
262
264
  registerNodeView(e2) {
263
- e2.registerNodeView("image", z(this.config, this.uploadStates, this.resolvedKeymap));
265
+ e2.registerNodeView("image", w(this.config, this.uploadStates, this.resolvedKeymap));
264
266
  }
265
267
  registerResizeCommands(e2) {
266
268
  const t2 = this.config.resizeStep ?? 10, n2 = this.config.resizeStepLarge ?? 50, i2 = this.config.maxWidth;
267
269
  e2.registerCommand("resizeImageGrow", () => {
268
- const n3 = m(e2, t2, i2);
270
+ const n3 = p(e2, t2, i2);
269
271
  return n3 && this.announceCurrentSize(e2), n3;
270
272
  }), e2.registerCommand("resizeImageShrink", () => {
271
- const n3 = m(e2, -t2, i2);
273
+ const n3 = p(e2, -t2, i2);
272
274
  return n3 && this.announceCurrentSize(e2), n3;
273
275
  }), e2.registerCommand("resizeImageGrowLarge", () => {
274
- const t3 = m(e2, n2, i2);
276
+ const t3 = p(e2, n2, i2);
275
277
  return t3 && this.announceCurrentSize(e2), t3;
276
278
  }), e2.registerCommand("resizeImageShrinkLarge", () => {
277
- const t3 = m(e2, -n2, i2);
279
+ const t3 = p(e2, -n2, i2);
278
280
  return t3 && this.announceCurrentSize(e2), t3;
279
281
  }), e2.registerCommand("resetImageSize", () => {
280
282
  const t3 = (function(e3) {
@@ -304,14 +306,14 @@ class S {
304
306
  handleFileInsert(e2, t2) {
305
307
  if (t2.size > this.config.maxFileSize) return;
306
308
  const n2 = URL.createObjectURL(t2);
307
- if (this.blobUrls.add(n2), !u(e2, { src: n2 })) return URL.revokeObjectURL(n2), void this.blobUrls.delete(n2);
309
+ if (this.blobUrls.add(n2), !m(e2, { src: n2 })) return URL.revokeObjectURL(n2), void this.blobUrls.delete(n2);
308
310
  const i2 = e2.getState().selection;
309
311
  if (!r(i2)) return;
310
312
  const o2 = i2.nodeId;
311
- this.uploadStates.set(o2, "uploading"), e2.getService(w) ? this.uploadFile(e2, t2, o2, n2) : this.uploadStates.set(o2, "complete");
313
+ this.uploadStates.set(o2, "uploading"), e2.getService(A) ? this.uploadFile(e2, t2, o2, n2) : this.uploadStates.set(o2, "complete");
312
314
  }
313
315
  async uploadFile(e2, t2, n2, i2) {
314
- const r2 = e2.getService(w);
316
+ const r2 = e2.getService(A);
315
317
  if (r2) try {
316
318
  const o2 = await r2.upload(t2);
317
319
  this.uploadStates.set(n2, "complete");
@@ -355,7 +357,7 @@ class S {
355
357
  d2.type = "button", d2.textContent = this.locale.insertButton, d2.setAttribute("aria-label", this.locale.insertAria), d2.style.cssText = "width:100%;padding:8px 12px;margin-top:4px;cursor:pointer;border:1px solid var(--notectl-border);border-radius:4px;background:var(--notectl-surface-raised);color:var(--notectl-fg);";
356
358
  const g2 = () => {
357
359
  const e3 = c2.value.trim();
358
- e3 && (u(t2, { src: e3 }), n2(), t2.getContainer().focus());
360
+ e3 && (m(t2, { src: e3 }), n2(), t2.getContainer().focus());
359
361
  };
360
362
  d2.addEventListener("mousedown", (e3) => {
361
363
  e3.preventDefault(), e3.stopPropagation(), g2();
@@ -378,10 +380,10 @@ class S {
378
380
  if (!r(t2)) return;
379
381
  const n2 = e2.getBlock(t2.nodeId);
380
382
  if (!n2 || "image" !== n2.type) return;
381
- const i2 = n2.attrs?.alt ?? "", o2 = n2.attrs?.width, a2 = n2.attrs?.height, l2 = ["Image selected."];
382
- i2 && l2.push(`Alt text: ${i2}.`), void 0 !== o2 && void 0 !== a2 && l2.push(`Size: ${o2} by ${a2} pixels.`);
383
+ const i2 = n2.attrs?.alt ?? "", o2 = n2.attrs?.width, a2 = n2.attrs?.height, s2 = ["Image selected."];
384
+ i2 && s2.push(`Alt text: ${i2}.`), void 0 !== o2 && void 0 !== a2 && s2.push(`Size: ${o2} by ${a2} pixels.`);
383
385
  const c2 = this.resolvedKeymap.shrinkWidth ?? null, d2 = this.resolvedKeymap.growWidth ?? null;
384
- c2 && d2 && l2.push(`${s(c2)} / ${s(d2)} to resize.`), this.context.announce(l2.join(" "));
386
+ c2 && d2 && s2.push(`${l(c2)} / ${l(d2)} to resize.`), this.context.announce(s2.join(" "));
385
387
  }
386
388
  announceCurrentSize(e2) {
387
389
  const t2 = e2.getState(), n2 = t2.selection;
@@ -393,10 +395,10 @@ class S {
393
395
  }
394
396
  }
395
397
  export {
396
- A as D,
397
- h as I,
398
- p as a,
399
- w as b,
400
- S as c
398
+ _ as D,
399
+ f as I,
400
+ h as a,
401
+ A as b,
402
+ k as c
401
403
  };
402
- //# sourceMappingURL=index-BL56fbXt.mjs.map
404
+ //# sourceMappingURL=index-D4GKlc-A.mjs.map