@notectl/core 1.0.8 → 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 (269) 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-B6JETWaw.mjs +818 -0
  28. package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +1 -0
  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-CT3HGdQt.mjs → index-B0UFAfyb.mjs} +13 -13
  34. package/dist/chunks/{index-CT3HGdQt.mjs.map → index-B0UFAfyb.mjs.map} +1 -1
  35. package/dist/chunks/{index-C2GQoHot.mjs → index-BDMP86F4.mjs} +40 -40
  36. package/dist/chunks/{index-C2GQoHot.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-C-YWHOcC.mjs → index-BigJ0z6n.mjs} +22 -22
  40. package/dist/chunks/{index-C-YWHOcC.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-BAk1EG1x.mjs → index-CPyHuEzh.mjs} +106 -106
  44. package/dist/chunks/index-CPyHuEzh.mjs.map +1 -0
  45. package/dist/chunks/{index-Ct0ivLhO.mjs → index-D4GKlc-A.mjs} +256 -259
  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-D8tbbW97.mjs +73 -0
  50. package/dist/chunks/index-D8tbbW97.mjs.map +1 -0
  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-DRZwd-1W.mjs +187 -0
  56. package/dist/chunks/index-DRZwd-1W.mjs.map +1 -0
  57. package/dist/chunks/{index-BYgspns5.mjs → index-DUC1X43Z.mjs} +54 -54
  58. package/dist/chunks/index-DUC1X43Z.mjs.map +1 -0
  59. package/dist/chunks/{index-CxiWyUho.mjs → index-DipAT_Q9.mjs} +31 -31
  60. package/dist/chunks/index-DipAT_Q9.mjs.map +1 -0
  61. package/dist/chunks/{index-D3CQWJiw.mjs → index-tBDVaSjG.mjs} +81 -61
  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 +34 -6
  81. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  82. package/dist/editor/styles/list.d.ts +2 -0
  83. package/dist/editor/styles/list.d.ts.map +1 -1
  84. package/dist/editor/styles/toolbar.d.ts +1 -1
  85. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  86. package/dist/index.d.ts +31 -10
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/input/ClipboardHandler.d.ts +2 -0
  89. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  90. package/dist/input/CompositionTracker.d.ts +14 -0
  91. package/dist/input/CompositionTracker.d.ts.map +1 -0
  92. package/dist/input/FileHandlerRegistry.d.ts +16 -0
  93. package/dist/input/FileHandlerRegistry.d.ts.map +1 -0
  94. package/dist/input/InputHandler.d.ts +8 -4
  95. package/dist/input/InputHandler.d.ts.map +1 -1
  96. package/dist/input/InputRuleRegistry.d.ts +9 -0
  97. package/dist/input/InputRuleRegistry.d.ts.map +1 -0
  98. package/dist/input/KeyboardHandler.d.ts +22 -5
  99. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  100. package/dist/input/Keymap.d.ts +11 -0
  101. package/dist/input/Keymap.d.ts.map +1 -1
  102. package/dist/input/KeymapRegistry.d.ts +19 -0
  103. package/dist/input/KeymapRegistry.d.ts.map +1 -0
  104. package/dist/input/LegacyHTMLNormalizer.d.ts +18 -0
  105. package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -0
  106. package/dist/input/PasteHandler.d.ts +7 -0
  107. package/dist/input/PasteHandler.d.ts.map +1 -1
  108. package/dist/model/Document.d.ts +8 -0
  109. package/dist/model/Document.d.ts.map +1 -1
  110. package/dist/model/GraphemeUtils.d.ts +20 -0
  111. package/dist/model/GraphemeUtils.d.ts.map +1 -0
  112. package/dist/model/HTMLParser.d.ts +13 -0
  113. package/dist/model/HTMLParser.d.ts.map +1 -1
  114. package/dist/model/HTMLUtils.d.ts +6 -1
  115. package/dist/model/HTMLUtils.d.ts.map +1 -1
  116. package/dist/model/NavigationUtils.d.ts +16 -0
  117. package/dist/model/NavigationUtils.d.ts.map +1 -0
  118. package/dist/model/SchemaRegistry.d.ts +0 -39
  119. package/dist/model/SchemaRegistry.d.ts.map +1 -1
  120. package/dist/model/Selection.d.ts +14 -3
  121. package/dist/model/Selection.d.ts.map +1 -1
  122. package/dist/notectl-core.mjs +2831 -2420
  123. package/dist/notectl-core.mjs.map +1 -1
  124. package/dist/notectl-core.umd.js +3616 -2013
  125. package/dist/notectl-core.umd.js.map +1 -1
  126. package/dist/plugins/Plugin.d.ts +34 -5
  127. package/dist/plugins/Plugin.d.ts.map +1 -1
  128. package/dist/plugins/PluginManager.d.ts +31 -1
  129. package/dist/plugins/PluginManager.d.ts.map +1 -1
  130. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
  131. package/dist/plugins/alignment.mjs +1 -1
  132. package/dist/plugins/blockquote.mjs +1 -1
  133. package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts +35 -0
  134. package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts.map +1 -0
  135. package/dist/plugins/caret-navigation/index.d.ts +2 -0
  136. package/dist/plugins/caret-navigation/index.d.ts.map +1 -0
  137. package/dist/plugins/caret-navigation.mjs +5 -0
  138. package/dist/plugins/caret-navigation.mjs.map +1 -0
  139. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -1
  140. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
  141. package/dist/plugins/code-block.mjs +1 -1
  142. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  143. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
  144. package/dist/plugins/font-size.mjs +1 -1
  145. package/dist/plugins/font.mjs +1 -1
  146. package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts +15 -0
  147. package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -0
  148. package/dist/plugins/gap-cursor/index.d.ts +2 -0
  149. package/dist/plugins/gap-cursor/index.d.ts.map +1 -0
  150. package/dist/plugins/gap-cursor.mjs +65 -0
  151. package/dist/plugins/gap-cursor.mjs.map +1 -0
  152. package/dist/plugins/hard-break.mjs +1 -1
  153. package/dist/plugins/heading/BlockTypePickerRegistry.d.ts +9 -0
  154. package/dist/plugins/heading/BlockTypePickerRegistry.d.ts.map +1 -0
  155. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +14 -0
  156. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -0
  157. package/dist/plugins/heading/HeadingCommands.d.ts +5 -0
  158. package/dist/plugins/heading/HeadingCommands.d.ts.map +1 -0
  159. package/dist/plugins/heading/HeadingInputRules.d.ts +5 -0
  160. package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -0
  161. package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts +5 -0
  162. package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -0
  163. package/dist/plugins/heading/HeadingPlugin.d.ts +1 -41
  164. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
  165. package/dist/plugins/heading.mjs +1 -1
  166. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  167. package/dist/plugins/highlight.mjs +1 -1
  168. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
  169. package/dist/plugins/horizontal-rule.mjs +1 -1
  170. package/dist/plugins/image/ImageCommands.d.ts.map +1 -1
  171. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  172. package/dist/plugins/image.mjs +1 -1
  173. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  174. package/dist/plugins/link.mjs +1 -1
  175. package/dist/plugins/list/ListPlugin.d.ts +9 -0
  176. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  177. package/dist/plugins/list.mjs +1 -1
  178. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
  179. package/dist/plugins/print/PrintTypes.d.ts +5 -1
  180. package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
  181. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
  182. package/dist/plugins/shared/ColorValidation.d.ts +7 -0
  183. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
  184. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
  185. package/dist/plugins/strikethrough.mjs +1 -1
  186. package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
  187. package/dist/plugins/super-sub.mjs +1 -1
  188. package/dist/plugins/table/TableCommands.d.ts.map +1 -1
  189. package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
  190. package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
  191. package/dist/plugins/table.mjs +1 -1
  192. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  193. package/dist/plugins/text-color.mjs +1 -1
  194. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
  195. package/dist/plugins/text-formatting.mjs +1 -1
  196. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
  197. package/dist/plugins/toolbar/ToolbarLocale.d.ts +1 -0
  198. package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -1
  199. package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts +23 -0
  200. package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts.map +1 -0
  201. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +56 -0
  202. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -0
  203. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +17 -0
  204. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  205. package/dist/plugins/toolbar/ToolbarRegistry.d.ts +12 -0
  206. package/dist/plugins/toolbar/ToolbarRegistry.d.ts.map +1 -0
  207. package/dist/plugins/toolbar.mjs +2 -2
  208. package/dist/state/EditorState.d.ts.map +1 -1
  209. package/dist/state/History.d.ts.map +1 -1
  210. package/dist/state/ReadonlyGuard.d.ts +6 -0
  211. package/dist/state/ReadonlyGuard.d.ts.map +1 -0
  212. package/dist/state/SelectionTransactions.d.ts +10 -0
  213. package/dist/state/SelectionTransactions.d.ts.map +1 -0
  214. package/dist/state/Transaction.d.ts +4 -0
  215. package/dist/state/Transaction.d.ts.map +1 -1
  216. package/dist/test/TestUtils.d.ts +23 -0
  217. package/dist/test/TestUtils.d.ts.map +1 -1
  218. package/dist/view/CaretNavigation.d.ts +48 -0
  219. package/dist/view/CaretNavigation.d.ts.map +1 -0
  220. package/dist/view/CursorWrapper.d.ts +19 -0
  221. package/dist/view/CursorWrapper.d.ts.map +1 -0
  222. package/dist/view/DomPointUtils.d.ts +20 -0
  223. package/dist/view/DomPointUtils.d.ts.map +1 -0
  224. package/dist/view/EditorView.d.ts +45 -0
  225. package/dist/view/EditorView.d.ts.map +1 -1
  226. package/dist/view/MarkRendering.d.ts +7 -0
  227. package/dist/view/MarkRendering.d.ts.map +1 -0
  228. package/dist/view/NodeViewRegistry.d.ts +9 -0
  229. package/dist/view/NodeViewRegistry.d.ts.map +1 -0
  230. package/dist/view/Platform.d.ts +29 -0
  231. package/dist/view/Platform.d.ts.map +1 -0
  232. package/dist/view/Reconciler.d.ts +4 -0
  233. package/dist/view/Reconciler.d.ts.map +1 -1
  234. package/dist/view/SelectionSync.d.ts +2 -0
  235. package/dist/view/SelectionSync.d.ts.map +1 -1
  236. package/dist/view/ViewMovementCommands.d.ts +40 -0
  237. package/dist/view/ViewMovementCommands.d.ts.map +1 -0
  238. package/package.json +10 -2
  239. package/dist/chunks/ColorNames-iaWsSZx1.mjs +0 -35
  240. package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +0 -1
  241. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +0 -140
  242. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +0 -1
  243. package/dist/chunks/Commands-CSpSwGXv.mjs +0 -461
  244. package/dist/chunks/Commands-CSpSwGXv.mjs.map +0 -1
  245. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +0 -7
  246. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +0 -1
  247. package/dist/chunks/Selection-D5ZjXoB7.mjs +0 -44
  248. package/dist/chunks/Selection-D5ZjXoB7.mjs.map +0 -1
  249. package/dist/chunks/ToolbarItem-ugDymuXi.mjs +0 -7
  250. package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +0 -1
  251. package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs +0 -368
  252. package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +0 -1
  253. package/dist/chunks/index-BAk1EG1x.mjs.map +0 -1
  254. package/dist/chunks/index-BRYzYOYC.mjs.map +0 -1
  255. package/dist/chunks/index-BSFLNveF.mjs.map +0 -1
  256. package/dist/chunks/index-BYgspns5.mjs.map +0 -1
  257. package/dist/chunks/index-B_3qDrUN.mjs +0 -64
  258. package/dist/chunks/index-B_3qDrUN.mjs.map +0 -1
  259. package/dist/chunks/index-Bsp4LC5t.mjs.map +0 -1
  260. package/dist/chunks/index-Ct0ivLhO.mjs.map +0 -1
  261. package/dist/chunks/index-CxiWyUho.mjs.map +0 -1
  262. package/dist/chunks/index-D3CQWJiw.mjs.map +0 -1
  263. package/dist/chunks/index-DC1EK22F.mjs.map +0 -1
  264. package/dist/chunks/index-Dh76rR13.mjs +0 -196
  265. package/dist/chunks/index-Dh76rR13.mjs.map +0 -1
  266. package/dist/chunks/index-o6hDR07y.mjs.map +0 -1
  267. package/dist/chunks/index-uTnc9y7M.mjs.map +0 -1
  268. package/dist/input/SourceNormalizer.d.ts +0 -7
  269. package/dist/input/SourceNormalizer.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-D4GKlc-A.mjs","sources":["../../src/plugins/image/ImageCommands.ts","../../src/plugins/image/ImageLocale.ts","../../src/plugins/image/ImageNodeView.ts","../../src/plugins/image/ImageUpload.ts","../../src/plugins/image/ImagePlugin.ts","../../src/editor/styles/image.ts"],"sourcesContent":["/**\n * Image plugin commands: insert, remove, and attribute updates.\n * Supports both root-level and nested contexts (e.g. images inside table cells).\n */\n\nimport type { BlockAttrs, BlockNode } from '../../model/Document.js';\nimport { createBlockNode, getBlockChildren, isBlockNode } from '../../model/Document.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\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 { PluginContext } from '../Plugin.js';\nimport type { ImageAttrs } from './ImageUpload.js';\n\n/**\n * Inserts an image block. When the cursor is inside a table cell,\n * the image is inserted as a child of the cell. Otherwise it is\n * inserted after the current block at document root.\n */\nexport function insertImage(\n\tcontext: PluginContext,\n\tattrs: Partial<ImageAttrs> & { readonly src: string },\n): boolean {\n\tconst state = context.getState();\n\tconst sel = state.selection;\n\n\tconst imageAttrs: BlockAttrs = {\n\t\tsrc: attrs.src,\n\t\talt: attrs.alt ?? '',\n\t\talign: attrs.align ?? 'center',\n\t\t...(attrs.width !== undefined ? { width: attrs.width } : {}),\n\t\t...(attrs.height !== undefined ? { height: attrs.height } : {}),\n\t};\n\n\tif (isGapCursor(sel)) return false;\n\n\tconst anchorBlockId: BlockId = isNodeSelection(sel) ? sel.nodeId : sel.anchor.blockId;\n\n\t// Check if we're inside a table cell\n\tconst cellId: BlockId | undefined = findTableCellAncestor(state, anchorBlockId);\n\tif (cellId) {\n\t\treturn insertImageIntoCell(state, context, cellId, imageAttrs);\n\t}\n\n\treturn insertImageAtRoot(state, context, anchorBlockId, imageAttrs);\n}\n\n/** Finds a table_cell ancestor for the given block (or the block itself). */\nfunction findTableCellAncestor(state: EditorState, bid: BlockId): BlockId | undefined {\n\tconst block: BlockNode | undefined = state.getBlock(bid);\n\tif (block?.type === 'table_cell') return bid;\n\n\tconst path: BlockId[] | undefined = state.getNodePath(bid);\n\tif (!path) return undefined;\n\n\tfor (const id of path) {\n\t\tconst node: BlockNode | undefined = state.getBlock(id);\n\t\tif (node?.type === 'table_cell') return id;\n\t}\n\treturn undefined;\n}\n\n/** Inserts an image at document root after the anchor block. */\nfunction insertImageAtRoot(\n\tstate: EditorState,\n\tcontext: PluginContext,\n\tanchorBlockId: BlockId,\n\timageAttrs: BlockAttrs,\n): boolean {\n\tconst blockIndex: number = state.doc.children.findIndex((b) => b.id === anchorBlockId);\n\tif (blockIndex === -1) return false;\n\n\tconst imageBlock: BlockNode = createBlockNode(nodeType('image'), [], undefined, imageAttrs);\n\tconst newParagraph: BlockNode = createBlockNode(nodeType('paragraph'));\n\n\tconst tr = state\n\t\t.transaction('command')\n\t\t.insertNode([], blockIndex + 1, imageBlock)\n\t\t.insertNode([], blockIndex + 2, newParagraph)\n\t\t.setSelection(createNodeSelection(imageBlock.id, []))\n\t\t.build();\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n/** Inserts an image as a child of a table cell. */\nfunction insertImageIntoCell(\n\tstate: EditorState,\n\tcontext: PluginContext,\n\tcellId: BlockId,\n\timageAttrs: BlockAttrs,\n): boolean {\n\tconst cellPath: BlockId[] | undefined = state.getNodePath(cellId);\n\tif (!cellPath) return false;\n\n\tconst imageBlock: BlockNode = createBlockNode(nodeType('image'), [], undefined, imageAttrs);\n\n\t// Remove existing block children first (if any)\n\tconst cell: BlockNode | undefined = state.getBlock(cellId);\n\tif (!cell) return false;\n\n\tconst builder = state.transaction('command');\n\tconst blockChildren: readonly BlockNode[] = getBlockChildren(cell);\n\tfor (let i = blockChildren.length - 1; i >= 0; i--) {\n\t\t// Find the raw index in children array\n\t\tconst rawIndex: number = cell.children.findIndex(\n\t\t\t(c) => isBlockNode(c) && c.id === blockChildren[i]?.id,\n\t\t);\n\t\tif (rawIndex !== -1) {\n\t\t\tbuilder.removeNode(cellPath, rawIndex);\n\t\t}\n\t}\n\n\t// Insert image at index 0 (before any text nodes)\n\tbuilder.insertNode(cellPath, 0, imageBlock);\n\tbuilder.setSelection(createNodeSelection(imageBlock.id, [...cellPath, imageBlock.id]));\n\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** Removes the currently selected image block (works for nested images too). */\nexport function removeImage(context: PluginContext): boolean {\n\tconst state = context.getState();\n\tconst sel = state.selection;\n\tif (!isNodeSelection(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.nodeId);\n\tif (!block || block.type !== 'image') return false;\n\n\tconst nodePath: BlockId[] | undefined = state.getNodePath(sel.nodeId);\n\tif (!nodePath || nodePath.length === 0) return false;\n\n\t// parentPath = all IDs except the last (the image itself)\n\tconst parentPath: BlockId[] = nodePath.slice(0, -1);\n\n\t// Find the index of the image in its parent's children\n\tlet parent: BlockNode | { readonly children: readonly BlockNode[] } | undefined;\n\tif (parentPath.length === 0) {\n\t\tparent = state.doc;\n\t} else {\n\t\tconst parentId: BlockId | undefined = parentPath[parentPath.length - 1];\n\t\tparent = parentId ? state.getBlock(parentId) : undefined;\n\t}\n\tif (!parent) return false;\n\n\tconst imageIndex: number = parent.children.findIndex(\n\t\t(c) => isBlockNode(c) && c.id === sel.nodeId,\n\t);\n\tif (imageIndex === -1) return false;\n\n\t// Determine where to place the cursor after removal\n\tconst selectionTarget: BlockId | undefined = findSelectionTargetAfterRemoval(\n\t\tstate,\n\t\tparentPath,\n\t\tsel.nodeId,\n\t);\n\tif (!selectionTarget) return false;\n\n\tconst tr = state\n\t\t.transaction('command')\n\t\t.removeNode(parentPath, imageIndex)\n\t\t.setSelection(createCollapsedSelection(selectionTarget, 0))\n\t\t.build();\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n/** Finds a suitable block to select after removing an image. */\nfunction findSelectionTargetAfterRemoval(\n\tstate: EditorState,\n\tparentPath: readonly BlockId[],\n\tremovedId: BlockId,\n): BlockId | undefined {\n\tif (parentPath.length === 0) {\n\t\t// Root level: select adjacent block\n\t\tconst rootChildren: readonly BlockNode[] = state.doc.children;\n\t\tconst idx: number = rootChildren.findIndex((b) => b.id === removedId);\n\t\tconst adjacent: BlockNode | undefined = rootChildren[idx + 1] ?? rootChildren[idx - 1];\n\t\treturn adjacent?.id;\n\t}\n\n\t// Nested (e.g. inside table cell): select the cell itself\n\tconst cellId: BlockId | undefined = parentPath[parentPath.length - 1];\n\treturn cellId;\n}\n\n/** Updates attributes on the currently selected image block. */\nexport function setImageAttr(context: PluginContext, attrs: Partial<ImageAttrs>): boolean {\n\tconst state = context.getState();\n\tconst sel = state.selection;\n\tif (!isNodeSelection(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.nodeId);\n\tif (!block || block.type !== 'image') return false;\n\n\tconst path: BlockId[] | undefined = state.getNodePath(sel.nodeId);\n\tif (!path) return false;\n\n\tconst merged: BlockAttrs = { ...(block.attrs ?? {}), ...attrs };\n\tconst tr = state.transaction('command').setNodeAttr(path, merged).build();\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n/** Minimum image width in pixels (shared with NodeView). */\nexport const MIN_IMAGE_WIDTH = 50;\n\n/**\n * Resizes the currently selected image by a pixel delta, preserving aspect ratio.\n * Returns false if no image is selected or the image has no width/height attributes.\n */\nexport function resizeImageByDelta(\n\tcontext: PluginContext,\n\tdelta: number,\n\tmaxWidth: number,\n): boolean {\n\tconst state = context.getState();\n\tconst sel = state.selection;\n\tif (!isNodeSelection(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.nodeId);\n\tif (!block || block.type !== 'image') return false;\n\n\tconst currentWidth: number | undefined = block.attrs?.width as number | undefined;\n\tconst currentHeight: number | undefined = block.attrs?.height as number | undefined;\n\tif (currentWidth === undefined || currentHeight === undefined) return false;\n\n\tconst aspectRatio: number = currentHeight > 0 ? currentWidth / currentHeight : 1;\n\tconst clampedWidth: number = Math.max(MIN_IMAGE_WIDTH, Math.min(maxWidth, currentWidth + delta));\n\tconst newHeight: number = Math.round(clampedWidth / aspectRatio);\n\n\tif (clampedWidth === currentWidth && newHeight === currentHeight) return false;\n\n\treturn setImageAttr(context, { width: clampedWidth, height: newHeight });\n}\n\n/** Resets the currently selected image to its natural size by removing width/height. */\nexport function resetImageSize(context: PluginContext): boolean {\n\tconst state = context.getState();\n\tconst sel = state.selection;\n\tif (!isNodeSelection(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.nodeId);\n\tif (!block || block.type !== 'image') return false;\n\n\tconst path: BlockId[] | undefined = state.getNodePath(sel.nodeId);\n\tif (!path) return false;\n\n\tconst attrs: BlockAttrs = { ...(block.attrs ?? {}) };\n\tconst cleaned: BlockAttrs = Object.fromEntries(\n\t\tObject.entries(attrs).filter(([k]) => k !== 'width' && k !== 'height'),\n\t);\n\n\tconst tr = state.transaction('command').setNodeAttr(path, cleaned).build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n/** Registers all image commands on the plugin context. */\nexport function registerImageCommands(context: PluginContext): void {\n\tcontext.registerCommand('insertImage', () => {\n\t\treturn insertImage(context, { src: '' });\n\t});\n\n\tcontext.registerCommand('removeImage', () => {\n\t\treturn removeImage(context);\n\t});\n}\n","/** Locale interface and default English locale for the ImagePlugin. */\n\n// --- Locale Interface ---\n\nexport interface ImageLocale {\n\treadonly insertImage: string;\n\treadonly insertImageTooltip: string;\n\treadonly uploadFromComputer: string;\n\treadonly uploadAria: string;\n\treadonly separator: string;\n\treadonly urlPlaceholder: string;\n\treadonly urlAria: string;\n\treadonly insertButton: string;\n\treadonly insertAria: string;\n\treadonly imageAria: (alt: string, width?: number, height?: number) => string;\n\treadonly resetToNaturalSize: string;\n\treadonly uploadFailed: string;\n}\n\n// --- Default English Locale ---\n\nexport const IMAGE_LOCALE_EN: ImageLocale = {\n\tinsertImage: 'Insert Image',\n\tinsertImageTooltip: 'Insert Image',\n\tuploadFromComputer: 'Upload from computer',\n\tuploadAria: 'Upload image from computer',\n\tseparator: 'or',\n\turlPlaceholder: 'https://...',\n\turlAria: 'Image URL',\n\tinsertButton: 'Insert',\n\tinsertAria: 'Insert image',\n\timageAria: (alt: string, width?: number, height?: number) => {\n\t\tconst parts: string[] = [alt || 'Image'];\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`${width} by ${height} pixels`);\n\t\t}\n\t\treturn parts.join(', ');\n\t},\n\tresetToNaturalSize: 'Image reset to natural size.',\n\tuploadFailed: 'Image upload failed.',\n};\n\n// --- German Locale ---\n\nexport const IMAGE_LOCALE_DE: ImageLocale = {\n\tinsertImage: 'Bild einfügen',\n\tinsertImageTooltip: 'Bild einfügen',\n\tuploadFromComputer: 'Vom Computer hochladen',\n\tuploadAria: 'Bild vom Computer hochladen',\n\tseparator: 'oder',\n\turlPlaceholder: 'https://...',\n\turlAria: 'Bild-URL',\n\tinsertButton: 'Einfügen',\n\tinsertAria: 'Bild einfügen',\n\timageAria: (alt: string, width?: number, height?: number) => {\n\t\tconst parts: string[] = [alt || 'Bild'];\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`${width} mal ${height} Pixel`);\n\t\t}\n\t\treturn parts.join(', ');\n\t},\n\tresetToNaturalSize: 'Bild auf Originalgröße zurückgesetzt.',\n\tuploadFailed: 'Bild-Upload fehlgeschlagen.',\n};\n\n// --- Spanish Locale ---\n\nexport const IMAGE_LOCALE_ES: ImageLocale = {\n\tinsertImage: 'Insertar imagen',\n\tinsertImageTooltip: 'Insertar imagen',\n\tuploadFromComputer: 'Subir desde el ordenador',\n\tuploadAria: 'Subir imagen desde el ordenador',\n\tseparator: 'o',\n\turlPlaceholder: 'https://...',\n\turlAria: 'URL de la imagen',\n\tinsertButton: 'Insertar',\n\tinsertAria: 'Insertar imagen',\n\timageAria: (alt: string, width?: number, height?: number) => {\n\t\tconst parts: string[] = [alt || 'Imagen'];\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`${width} por ${height} píxeles`);\n\t\t}\n\t\treturn parts.join(', ');\n\t},\n\tresetToNaturalSize: 'Imagen restablecida a tamaño natural.',\n\tuploadFailed: 'Error al subir la imagen.',\n};\n\n// --- French Locale ---\n\nexport const IMAGE_LOCALE_FR: ImageLocale = {\n\tinsertImage: 'Insérer une image',\n\tinsertImageTooltip: 'Insérer une image',\n\tuploadFromComputer: 'Télécharger depuis l\\u2019ordinateur',\n\tuploadAria: 'Télécharger une image depuis l\\u2019ordinateur',\n\tseparator: 'ou',\n\turlPlaceholder: 'https://...',\n\turlAria: 'URL de l\\u2019image',\n\tinsertButton: 'Insérer',\n\tinsertAria: 'Insérer une image',\n\timageAria: (alt: string, width?: number, height?: number) => {\n\t\tconst parts: string[] = [alt || 'Image'];\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`${width} par ${height} pixels`);\n\t\t}\n\t\treturn parts.join(', ');\n\t},\n\tresetToNaturalSize: 'Image rétablie à sa taille d\\u2019origine.',\n\tuploadFailed: 'Échec du téléchargement de l\\u2019image.',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const IMAGE_LOCALE_ZH: ImageLocale = {\n\tinsertImage: '插入图片',\n\tinsertImageTooltip: '插入图片',\n\tuploadFromComputer: '从电脑上传',\n\tuploadAria: '从电脑上传图片',\n\tseparator: '或',\n\turlPlaceholder: 'https://...',\n\turlAria: '图片链接',\n\tinsertButton: '插入',\n\tinsertAria: '插入图片',\n\timageAria: (alt: string, width?: number, height?: number) => {\n\t\tconst parts: string[] = [alt || '图片'];\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`${width} x ${height} 像素`);\n\t\t}\n\t\treturn parts.join(',');\n\t},\n\tresetToNaturalSize: '图片已恢复原始大小。',\n\tuploadFailed: '图片上传失败。',\n};\n\n// --- Russian Locale ---\n\nexport const IMAGE_LOCALE_RU: ImageLocale = {\n\tinsertImage: 'Вставить изображение',\n\tinsertImageTooltip: 'Вставить изображение',\n\tuploadFromComputer: 'Загрузить с компьютера',\n\tuploadAria: 'Загрузить изображение с компьютера',\n\tseparator: 'или',\n\turlPlaceholder: 'https://...',\n\turlAria: 'URL изображения',\n\tinsertButton: 'Вставить',\n\tinsertAria: 'Вставить изображение',\n\timageAria: (alt: string, width?: number, height?: number) => {\n\t\tconst parts: string[] = [alt || 'Изображение'];\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`${width} на ${height} пикселей`);\n\t\t}\n\t\treturn parts.join(', ');\n\t},\n\tresetToNaturalSize: 'Изображение сброшено до исходного размера.',\n\tuploadFailed: 'Ошибка загрузки изображения.',\n};\n\n// --- Arabic Locale ---\n\nexport const IMAGE_LOCALE_AR: ImageLocale = {\n\tinsertImage: 'إدراج صورة',\n\tinsertImageTooltip: 'إدراج صورة',\n\tuploadFromComputer: 'رفع من الحاسوب',\n\tuploadAria: 'رفع صورة من الحاسوب',\n\tseparator: 'أو',\n\turlPlaceholder: 'https://...',\n\turlAria: 'رابط الصورة',\n\tinsertButton: 'إدراج',\n\tinsertAria: 'إدراج صورة',\n\timageAria: (alt: string, width?: number, height?: number) => {\n\t\tconst parts: string[] = [alt || 'صورة'];\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`${width} × ${height} بكسل`);\n\t\t}\n\t\treturn parts.join('، ');\n\t},\n\tresetToNaturalSize: 'تمت إعادة الصورة إلى حجمها الطبيعي.',\n\tuploadFailed: 'فشل رفع الصورة.',\n};\n\n// --- Hindi Locale ---\n\nexport const IMAGE_LOCALE_HI: ImageLocale = {\n\tinsertImage: 'चित्र डालें',\n\tinsertImageTooltip: 'चित्र डालें',\n\tuploadFromComputer: 'कंप्यूटर से अपलोड करें',\n\tuploadAria: 'कंप्यूटर से चित्र अपलोड करें',\n\tseparator: 'या',\n\turlPlaceholder: 'https://...',\n\turlAria: 'चित्र URL',\n\tinsertButton: 'डालें',\n\tinsertAria: 'चित्र डालें',\n\timageAria: (alt: string, width?: number, height?: number) => {\n\t\tconst parts: string[] = [alt || 'चित्र'];\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`${width} x ${height} पिक्सेल`);\n\t\t}\n\t\treturn parts.join(', ');\n\t},\n\tresetToNaturalSize: 'चित्र मूल आकार में पुनर्स्थापित।',\n\tuploadFailed: 'चित्र अपलोड विफल।',\n};\n\n// --- Locale Map ---\n\nexport const IMAGE_LOCALES: Record<string, ImageLocale> = {\n\ten: IMAGE_LOCALE_EN,\n\tde: IMAGE_LOCALE_DE,\n\tes: IMAGE_LOCALE_ES,\n\tfr: IMAGE_LOCALE_FR,\n\tzh: IMAGE_LOCALE_ZH,\n\tru: IMAGE_LOCALE_RU,\n\tar: IMAGE_LOCALE_AR,\n\thi: IMAGE_LOCALE_HI,\n};\n","/**\n * NodeView factory for image blocks.\n * Renders <figure> with <img>, handles selection state, upload overlay,\n * resize with 4 corner handles + live size indicator, and a keyboard-hint\n * showing resize shortcuts when the image is selected.\n */\n\nimport type { BlockAttrs, BlockNode } 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 { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport type { ImageKeymap, ImagePluginConfig, UploadState } from './ImageUpload.js';\n\nconst ALIGNMENT_CLASSES: Record<string, string> = {\n\tleft: 'notectl-image--left',\n\tcenter: 'notectl-image--center',\n\tright: 'notectl-image--right',\n};\n\nconst MIN_IMAGE_WIDTH = 50;\n\ntype HandlePosition = 'nw' | 'ne' | 'sw' | 'se';\n\nconst HANDLE_CURSORS: Readonly<Record<HandlePosition, string>> = {\n\tnw: 'nwse-resize',\n\tne: 'nesw-resize',\n\tsw: 'nesw-resize',\n\tse: 'nwse-resize',\n};\n\n/** +1 means dragging right increases width; -1 means dragging left does. */\nconst HANDLE_X_SIGN: Readonly<Record<HandlePosition, 1 | -1>> = {\n\tnw: -1,\n\tne: 1,\n\tsw: -1,\n\tse: 1,\n};\n\nconst HANDLE_LABELS: Readonly<Record<HandlePosition, string>> = {\n\tnw: 'Resize top-left',\n\tne: 'Resize top-right',\n\tsw: 'Resize bottom-left',\n\tse: 'Resize bottom-right',\n};\n\n// --- Global cursor override during resize ---\n\nlet activeCursorStyle: HTMLStyleElement | null = null;\n\nfunction setGlobalResizeCursor(cursor: string): void {\n\tclearGlobalResizeCursor();\n\tactiveCursorStyle = document.createElement('style');\n\tactiveCursorStyle.textContent = `*{cursor:${cursor}!important;user-select:none!important}`;\n\tdocument.head.appendChild(activeCursorStyle);\n}\n\nfunction clearGlobalResizeCursor(): void {\n\tif (activeCursorStyle) {\n\t\tactiveCursorStyle.remove();\n\t\tactiveCursorStyle = null;\n\t}\n}\n\n/** Builds the keyboard-hint text from the resolved keymap. */\nfunction buildKeyboardHintText(\n\tresolvedKeymap: Readonly<Record<keyof ImageKeymap, string | null>>,\n): string {\n\tconst shrink: string | null = resolvedKeymap.shrinkWidth ?? null;\n\tconst grow: string | null = resolvedKeymap.growWidth ?? null;\n\tif (!shrink || !grow) return '';\n\treturn `${formatShortcut(shrink)} / ${formatShortcut(grow)} to resize`;\n}\n\n/** Creates a NodeViewFactory for image blocks. */\nexport function createImageNodeViewFactory(\n\tconfig: ImagePluginConfig,\n\tuploadStates: Map<BlockId, UploadState>,\n\tresolvedKeymap?: Readonly<Record<keyof ImageKeymap, string | null>>,\n): NodeViewFactory {\n\treturn (\n\t\tnode: BlockNode,\n\t\tgetState: () => EditorState,\n\t\tdispatch: (tr: Transaction) => void,\n\t): NodeView => {\n\t\t// --- DOM Construction ---\n\t\tconst figure: HTMLElement = document.createElement('figure');\n\t\tfigure.className = 'notectl-image';\n\t\tfigure.setAttribute('data-block-id', node.id);\n\t\tfigure.setAttribute('data-void', 'true');\n\t\tfigure.setAttribute('data-selectable', 'true');\n\n\t\tconst container: HTMLDivElement = document.createElement('div');\n\t\tcontainer.className = 'notectl-image__container';\n\n\t\tconst img: HTMLImageElement = document.createElement('img');\n\t\timg.className = 'notectl-image__img';\n\t\timg.draggable = false;\n\n\t\tconst overlay: HTMLDivElement = document.createElement('div');\n\t\toverlay.className = 'notectl-image__overlay';\n\n\t\tcontainer.appendChild(img);\n\t\tcontainer.appendChild(overlay);\n\t\tfigure.appendChild(container);\n\n\t\tlet currentNodeId: BlockId = node.id;\n\t\tlet resizeOverlay: HTMLDivElement | null = null;\n\n\t\t// --- ARIA Label ---\n\n\t\tfunction updateAriaLabel(n: BlockNode): void {\n\t\t\tconst alt: string = (n.attrs?.alt as string | undefined) ?? '';\n\t\t\tconst width: number | undefined = n.attrs?.width as number | undefined;\n\t\t\tconst height: number | undefined = n.attrs?.height as number | undefined;\n\n\t\t\tconst parts: string[] = [];\n\t\t\tif (alt) {\n\t\t\t\tparts.push(alt);\n\t\t\t} else {\n\t\t\t\tparts.push('Image');\n\t\t\t}\n\t\t\tif (width !== undefined && height !== undefined) {\n\t\t\t\tparts.push(`${width} by ${height} pixels`);\n\t\t\t}\n\t\t\tfigure.setAttribute('aria-label', parts.join(', '));\n\t\t}\n\n\t\t// --- Attribute Application ---\n\n\t\tfunction applyAttrs(n: BlockNode): void {\n\t\t\tconst src: string = (n.attrs?.src as string | undefined) ?? '';\n\t\t\tconst alt: string = (n.attrs?.alt as string | undefined) ?? '';\n\t\t\tconst width: number | undefined = n.attrs?.width as number | undefined;\n\t\t\tconst height: number | undefined = n.attrs?.height as number | undefined;\n\t\t\tconst align: string = (n.attrs?.align as string | undefined) ?? 'center';\n\n\t\t\t// Only update src when it changes to avoid re-triggering load events\n\t\t\tif (img.src !== src) img.src = src;\n\t\t\timg.alt = alt;\n\n\t\t\tif (width !== undefined) {\n\t\t\t\timg.style.width = `${width}px`;\n\t\t\t} else {\n\t\t\t\timg.style.width = '';\n\t\t\t}\n\t\t\tif (height !== undefined) {\n\t\t\t\timg.style.height = `${height}px`;\n\t\t\t} else {\n\t\t\t\timg.style.height = '';\n\t\t\t}\n\n\t\t\tfor (const cls of Object.values(ALIGNMENT_CLASSES)) {\n\t\t\t\tfigure.classList.remove(cls);\n\t\t\t}\n\t\t\tconst alignClass: string | undefined = ALIGNMENT_CLASSES[align];\n\t\t\tif (alignClass) {\n\t\t\t\tfigure.classList.add(alignClass);\n\t\t\t}\n\n\t\t\tconst uploadState: UploadState = uploadStates.get(n.id) ?? 'idle';\n\t\t\tconst isUploading: boolean = uploadState === 'uploading';\n\t\t\toverlay.classList.toggle('notectl-image__overlay--uploading', isUploading);\n\t\t\toverlay.classList.toggle('notectl-image__overlay--error', uploadState === 'error');\n\n\t\t\tif (isUploading) {\n\t\t\t\toverlay.textContent = 'Uploading...';\n\t\t\t} else if (uploadState === 'error') {\n\t\t\t\toverlay.textContent = 'Upload failed';\n\t\t\t} else {\n\t\t\t\toverlay.textContent = '';\n\t\t\t}\n\n\t\t\tif (isUploading) {\n\t\t\t\tfigure.setAttribute('aria-busy', 'true');\n\t\t\t} else {\n\t\t\t\tfigure.removeAttribute('aria-busy');\n\t\t\t}\n\n\t\t\tupdateAriaLabel(n);\n\t\t}\n\n\t\tapplyAttrs(node);\n\n\t\t// --- Commit natural dimensions on first load ---\n\n\t\tlet dimensionsCommitted = false;\n\n\t\timg.addEventListener('load', () => {\n\t\t\tif (dimensionsCommitted) return;\n\n\t\t\tconst state: EditorState = getState();\n\t\t\tconst block: BlockNode | undefined = state.getBlock(currentNodeId);\n\t\t\tif (!block || block.type !== 'image') return;\n\n\t\t\tconst hasWidth: boolean = block.attrs?.width !== undefined;\n\t\t\tconst hasHeight: boolean = block.attrs?.height !== undefined;\n\t\t\tif (hasWidth && hasHeight) {\n\t\t\t\tdimensionsCommitted = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst naturalW: number = img.naturalWidth;\n\t\t\tconst naturalH: number = img.naturalHeight;\n\t\t\tif (naturalW === 0 || naturalH === 0) return;\n\n\t\t\tconst clampedW: number = Math.min(naturalW, config.maxWidth);\n\t\t\tconst ratio: number = naturalW > 0 ? naturalH / naturalW : 1;\n\t\t\tconst clampedH: number = Math.round(clampedW * ratio);\n\n\t\t\tconst path: BlockId[] | undefined = state.getNodePath(currentNodeId);\n\t\t\tif (!path) return;\n\n\t\t\tconst merged: BlockAttrs = {\n\t\t\t\t...(block.attrs ?? {}),\n\t\t\t\twidth: clampedW,\n\t\t\t\theight: clampedH,\n\t\t\t};\n\n\t\t\tconst tr: Transaction = state.transaction('command').setNodeAttr(path, merged).build();\n\t\t\tdispatch(tr);\n\t\t\tdimensionsCommitted = true;\n\t\t});\n\n\t\t// --- Resize Logic ---\n\n\t\tfunction clampWidth(width: number): number {\n\t\t\treturn Math.max(MIN_IMAGE_WIDTH, Math.min(config.maxWidth, width));\n\t\t}\n\n\t\tfunction commitResize(nodeId: BlockId, width: number, height: number): void {\n\t\t\tconst state: EditorState = getState();\n\t\t\tconst block: BlockNode | undefined = state.getBlock(nodeId);\n\t\t\tif (!block) return;\n\n\t\t\tconst prevWidth: number | undefined = block.attrs?.width as number | undefined;\n\t\t\tconst prevHeight: number | undefined = block.attrs?.height as number | undefined;\n\t\t\tif (prevWidth === width && prevHeight === height) return;\n\n\t\t\tconst path: BlockId[] | undefined = state.getNodePath(nodeId);\n\t\t\tif (!path) return;\n\n\t\t\tconst merged: BlockAttrs = {\n\t\t\t\t...(block.attrs ?? {}),\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t};\n\n\t\t\tconst tr: Transaction = state.transaction('command').setNodeAttr(path, merged).build();\n\t\t\tdispatch(tr);\n\t\t}\n\n\t\tfunction attachHandleListeners(\n\t\t\thandle: HTMLDivElement,\n\t\t\tposition: HandlePosition,\n\t\t\tnodeId: BlockId,\n\t\t\tsizeIndicator: HTMLDivElement,\n\t\t): void {\n\t\t\tlet startX = 0;\n\t\t\tlet startWidth = 0;\n\t\t\tlet aspectRatio = 1;\n\n\t\t\tconst onPointerMove = (e: PointerEvent): void => {\n\t\t\t\tconst deltaX: number = e.clientX - startX;\n\t\t\t\tconst newWidth: number = clampWidth(startWidth + deltaX * HANDLE_X_SIGN[position]);\n\t\t\t\tconst newHeight: number = Math.round(newWidth / aspectRatio);\n\n\t\t\t\timg.style.width = `${newWidth}px`;\n\t\t\t\timg.style.height = `${newHeight}px`;\n\n\t\t\t\tsizeIndicator.textContent = `${Math.round(newWidth)} \\u00D7 ${newHeight}`;\n\t\t\t};\n\n\t\t\tconst onPointerUp = (e: PointerEvent): void => {\n\t\t\t\tdocument.removeEventListener('pointermove', onPointerMove);\n\t\t\t\tdocument.removeEventListener('pointerup', onPointerUp);\n\n\t\t\t\tfigure.classList.remove('notectl-image--resizing');\n\t\t\t\tsizeIndicator.classList.remove('notectl-image__size-indicator--visible');\n\t\t\t\tclearGlobalResizeCursor();\n\n\t\t\t\tconst finalWidth: number = Math.round(img.getBoundingClientRect().width);\n\t\t\t\tconst finalHeight: number = Math.round(finalWidth / aspectRatio);\n\n\t\t\t\tcommitResize(nodeId, finalWidth, finalHeight);\n\n\t\t\t\t(e.target as HTMLElement | null)?.releasePointerCapture?.(e.pointerId);\n\t\t\t};\n\n\t\t\thandle.addEventListener('pointerdown', (e: PointerEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tstartX = e.clientX;\n\t\t\t\tstartWidth = img.getBoundingClientRect().width;\n\t\t\t\tconst imgHeight: number = img.getBoundingClientRect().height;\n\t\t\t\taspectRatio = imgHeight > 0 ? startWidth / imgHeight : 1;\n\n\t\t\t\tfigure.classList.add('notectl-image--resizing');\n\t\t\t\tsizeIndicator.textContent = `${Math.round(startWidth)} \\u00D7 ${Math.round(imgHeight)}`;\n\t\t\t\tsizeIndicator.classList.add('notectl-image__size-indicator--visible');\n\t\t\t\tsetGlobalResizeCursor(HANDLE_CURSORS[position]);\n\n\t\t\t\t(e.target as HTMLElement).setPointerCapture(e.pointerId);\n\t\t\t\tdocument.addEventListener('pointermove', onPointerMove);\n\t\t\t\tdocument.addEventListener('pointerup', onPointerUp);\n\t\t\t});\n\t\t}\n\n\t\tfunction createResizeOverlay(nodeId: BlockId): void {\n\t\t\tif (!config.resizable || resizeOverlay) return;\n\n\t\t\tresizeOverlay = document.createElement('div');\n\t\t\tresizeOverlay.className = 'notectl-image__resize-overlay';\n\t\t\tresizeOverlay.setAttribute('data-notectl-no-print', '');\n\n\t\t\tconst sizeIndicator: HTMLDivElement = document.createElement('div');\n\t\t\tsizeIndicator.className = 'notectl-image__size-indicator';\n\t\t\tresizeOverlay.appendChild(sizeIndicator);\n\n\t\t\tconst positions: readonly HandlePosition[] = ['nw', 'ne', 'sw', 'se'];\n\t\t\tfor (const pos of positions) {\n\t\t\t\tconst handle: HTMLDivElement = document.createElement('div');\n\t\t\t\thandle.className = `notectl-image__resize-handle notectl-image__resize-handle--${pos}`;\n\t\t\t\thandle.setAttribute('role', 'separator');\n\t\t\t\thandle.setAttribute('aria-label', HANDLE_LABELS[pos]);\n\t\t\t\tattachHandleListeners(handle, pos, nodeId, sizeIndicator);\n\t\t\t\tresizeOverlay.appendChild(handle);\n\t\t\t}\n\n\t\t\t// Keyboard hint (hidden from screenreaders, visual only)\n\t\t\tif (resolvedKeymap) {\n\t\t\t\tconst hintText: string = buildKeyboardHintText(resolvedKeymap);\n\t\t\t\tif (hintText) {\n\t\t\t\t\tconst hint: HTMLDivElement = document.createElement('div');\n\t\t\t\t\thint.className = 'notectl-image__keyboard-hint';\n\t\t\t\t\thint.setAttribute('aria-hidden', 'true');\n\t\t\t\t\thint.textContent = hintText;\n\t\t\t\t\tresizeOverlay.appendChild(hint);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontainer.appendChild(resizeOverlay);\n\t\t}\n\n\t\tfunction removeResizeOverlay(): void {\n\t\t\tclearGlobalResizeCursor();\n\t\t\tif (resizeOverlay) {\n\t\t\t\tresizeOverlay.remove();\n\t\t\t\tresizeOverlay = null;\n\t\t\t}\n\t\t}\n\n\t\t// --- NodeView Interface ---\n\n\t\treturn {\n\t\t\tdom: figure,\n\t\t\tcontentDOM: null,\n\n\t\t\tupdate(updatedNode: BlockNode): boolean {\n\t\t\t\tif (updatedNode.type !== 'image') return false;\n\t\t\t\tcurrentNodeId = updatedNode.id;\n\t\t\t\tfigure.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\tfigure.classList.add('notectl-image--selected');\n\t\t\t\tcreateResizeOverlay(currentNodeId);\n\t\t\t},\n\n\t\t\tdeselectNode(): void {\n\t\t\t\tfigure.classList.remove('notectl-image--selected');\n\t\t\t\tremoveResizeOverlay();\n\t\t\t},\n\n\t\t\tdestroy(): void {\n\t\t\t\tremoveResizeOverlay();\n\t\t\t\t// Do NOT revoke blob URLs here — the URL may still be referenced\n\t\t\t\t// by the clipboard (cut/paste) or undo history. Blob URLs are\n\t\t\t\t// automatically released when the document is unloaded.\n\t\t\t},\n\t\t};\n\t};\n}\n","/**\n * Image plugin types, configuration, and service key.\n */\n\nimport { ServiceKey } from '../Plugin.js';\nimport type { ImageLocale } from './ImageLocale.js';\n\n// --- Image Attributes ---\n\nexport interface ImageAttrs {\n\treadonly src: string;\n\treadonly alt: string;\n\treadonly width?: number;\n\treadonly height?: number;\n\treadonly align: 'left' | 'center' | 'right';\n}\n\n// --- Upload Types ---\n\nexport interface ImageUploadResult {\n\treadonly url: string;\n\treadonly width?: number;\n\treadonly height?: number;\n}\n\nexport interface ImageUploadService {\n\tupload(file: File): Promise<ImageUploadResult>;\n}\n\nexport const IMAGE_UPLOAD_SERVICE = new ServiceKey<ImageUploadService>('image:upload');\n\nexport type UploadState = 'idle' | 'uploading' | 'complete' | 'error';\n\n// --- Keyboard Bindings ---\n\n/**\n * Configurable keyboard bindings for image resize actions.\n * Omit a slot to use the default; set to `null` to disable the binding.\n *\n * Key descriptor format: `'Mod-Shift-ArrowRight'`, etc.\n * `Mod` resolves to Cmd on macOS, Ctrl on Windows/Linux.\n */\nexport interface ImageKeymap {\n\treadonly growWidth?: string | null;\n\treadonly shrinkWidth?: string | null;\n\treadonly growWidthLarge?: string | null;\n\treadonly shrinkWidthLarge?: string | null;\n\treadonly resetSize?: string | null;\n}\n\nexport const DEFAULT_IMAGE_KEYMAP: Readonly<Record<keyof ImageKeymap, string>> = {\n\tgrowWidth: 'Mod-Shift-ArrowRight',\n\tshrinkWidth: 'Mod-Shift-ArrowLeft',\n\tgrowWidthLarge: 'Mod-Shift-Alt-ArrowRight',\n\tshrinkWidthLarge: 'Mod-Shift-Alt-ArrowLeft',\n\tresetSize: 'Mod-Shift-0',\n};\n\n// --- Configuration ---\n\nexport interface ImagePluginConfig {\n\treadonly maxWidth: number;\n\treadonly maxFileSize: number;\n\treadonly acceptedTypes: readonly string[];\n\treadonly resizable: boolean;\n\treadonly separatorAfter?: boolean;\n\t/** Pixels to grow/shrink per small resize step. @default 10 */\n\treadonly resizeStep?: number;\n\t/** Pixels to grow/shrink per large resize step. @default 50 */\n\treadonly resizeStepLarge?: number;\n\t/** Customize keyboard bindings for image resize actions. */\n\treadonly keymap?: ImageKeymap;\n\t/** Locale override for user-facing strings. */\n\treadonly locale?: ImageLocale;\n}\n\nexport const DEFAULT_IMAGE_CONFIG: ImagePluginConfig = {\n\tmaxWidth: 800,\n\tmaxFileSize: 10 * 1024 * 1024,\n\tacceptedTypes: ['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/svg+xml'],\n\tresizable: true,\n\tresizeStep: 10,\n\tresizeStepLarge: 50,\n};\n","/**\n * ImagePlugin: registers an image void block type with NodeSpec,\n * NodeView, commands, file handler, toolbar button, and accessible\n * keyboard resize with screenreader announcements.\n */\n\nimport { IMAGE_CSS } from '../../editor/styles/image.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { BlockAttrs, BlockNode } from '../../model/Document.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport { createBlockElement } from '../../model/NodeSpec.js';\nimport { isNodeSelection } from '../../model/Selection.js';\nimport type { BlockId } 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 {\n\tinsertImage,\n\tregisterImageCommands,\n\tresetImageSize,\n\tresizeImageByDelta,\n} from './ImageCommands.js';\nimport { IMAGE_LOCALES, type ImageLocale } from './ImageLocale.js';\nimport { createImageNodeViewFactory } from './ImageNodeView.js';\nimport {\n\tDEFAULT_IMAGE_CONFIG,\n\tDEFAULT_IMAGE_KEYMAP,\n\tIMAGE_UPLOAD_SERVICE,\n\ttype ImageKeymap,\n\ttype ImagePluginConfig,\n\ttype UploadState,\n} from './ImageUpload.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\timage: {\n\t\t\tsrc: string;\n\t\t\talt: string;\n\t\t\twidth?: number;\n\t\t\theight?: number;\n\t\t\talign: 'left' | 'center' | 'right';\n\t\t};\n\t}\n}\n\n// --- Plugin ---\n\nexport class ImagePlugin implements Plugin {\n\treadonly id = 'image';\n\treadonly name = 'Image';\n\treadonly priority = 45;\n\n\tprivate readonly config: ImagePluginConfig;\n\tprivate readonly resolvedKeymap: Readonly<Record<keyof ImageKeymap, string | null>>;\n\tprivate readonly uploadStates = new Map<BlockId, UploadState>();\n\tprivate readonly blobUrls = new Set<string>();\n\tprivate context: PluginContext | null = null;\n\tprivate locale!: ImageLocale;\n\n\tconstructor(config?: Partial<ImagePluginConfig>) {\n\t\tthis.config = { ...DEFAULT_IMAGE_CONFIG, ...config };\n\t\tthis.resolvedKeymap = { ...DEFAULT_IMAGE_KEYMAP, ...config?.keymap };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(IMAGE_LOCALES, context, this.config.locale);\n\t\tcontext.registerStyleSheet(IMAGE_CSS);\n\t\tthis.context = context;\n\t\tthis.registerNodeSpec(context);\n\t\tthis.registerNodeView(context);\n\t\tregisterImageCommands(context);\n\t\tthis.registerResizeCommands(context);\n\t\tthis.registerResizeKeymaps(context);\n\t\tthis.registerFileHandler(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tdestroy(): void {\n\t\tfor (const url of this.blobUrls) {\n\t\t\tURL.revokeObjectURL(url);\n\t\t}\n\t\tthis.blobUrls.clear();\n\t\tthis.uploadStates.clear();\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\t// Clean up upload states for removed blocks (searches full tree)\n\t\tfor (const id of this.uploadStates.keys()) {\n\t\t\tif (!newState.getBlock(id)) {\n\t\t\t\tthis.uploadStates.delete(id);\n\t\t\t}\n\t\t}\n\n\t\t// Announce image selection for screenreaders\n\t\tconst oldIsImage: boolean = this.isImageSelected(oldState);\n\t\tconst nowIsImage: boolean = this.isImageSelected(newState);\n\n\t\tif (!oldIsImage && nowIsImage) {\n\t\t\tthis.announceImageSelection(newState);\n\t\t}\n\t}\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tconst locale = this.locale;\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'image',\n\t\t\tgroup: 'block',\n\t\t\tisVoid: true,\n\t\t\tselectable: true,\n\t\t\tattrs: {\n\t\t\t\tsrc: { default: '' },\n\t\t\t\talt: { default: '' },\n\t\t\t\talign: { default: 'center' },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst figure = createBlockElement('figure', node.id);\n\t\t\t\tfigure.className = 'notectl-image';\n\t\t\t\tfigure.setAttribute('data-void', 'true');\n\t\t\t\tfigure.setAttribute('data-selectable', 'true');\n\n\t\t\t\tconst imgContainer: HTMLDivElement = document.createElement('div');\n\t\t\t\timgContainer.className = 'notectl-image__container';\n\n\t\t\t\tconst alt: string = (node.attrs?.alt as string | undefined) ?? '';\n\t\t\t\tconst width: number | undefined = node.attrs?.width as number | undefined;\n\t\t\t\tconst height: number | undefined = node.attrs?.height as number | undefined;\n\n\t\t\t\tconst img: HTMLImageElement = document.createElement('img');\n\t\t\t\timg.className = 'notectl-image__img';\n\t\t\t\timg.src = (node.attrs?.src as string | undefined) ?? '';\n\t\t\t\timg.alt = alt;\n\t\t\t\timg.draggable = false;\n\n\t\t\t\tif (width !== undefined) img.style.width = `${width}px`;\n\t\t\t\tif (height !== undefined) img.style.height = `${height}px`;\n\n\t\t\t\tconst align: string = (node.attrs?.align as string | undefined) ?? 'center';\n\t\t\t\tconst alignClass: string | undefined = {\n\t\t\t\t\tleft: 'notectl-image--left',\n\t\t\t\t\tcenter: 'notectl-image--center',\n\t\t\t\t\tright: 'notectl-image--right',\n\t\t\t\t}[align];\n\t\t\t\tif (alignClass) figure.classList.add(alignClass);\n\n\t\t\t\tfigure.setAttribute('aria-label', locale.imageAria(alt, width, height));\n\n\t\t\t\timgContainer.appendChild(img);\n\t\t\t\tfigure.appendChild(imgContainer);\n\t\t\t\treturn figure;\n\t\t\t},\n\t\t\ttoHTML(node) {\n\t\t\t\tconst src: string = escapeHTML((node.attrs?.src as string | undefined) ?? '');\n\t\t\t\tconst alt: string = escapeHTML((node.attrs?.alt as string | undefined) ?? '');\n\t\t\t\tconst width: number | undefined = node.attrs?.width as number | undefined;\n\t\t\t\tconst height: number | undefined = node.attrs?.height as number | undefined;\n\t\t\t\tconst align: string = (node.attrs?.align as string | undefined) ?? 'center';\n\n\t\t\t\tconst sizeAttrs: string =\n\t\t\t\t\t(width !== undefined ? ` width=\"${width}\"` : '') +\n\t\t\t\t\t(height !== undefined ? ` height=\"${height}\"` : '');\n\n\t\t\t\treturn `<figure class=\"notectl-image notectl-image--${escapeHTML(align)}\"><img src=\"${src}\" alt=\"${alt}\"${sizeAttrs}></figure>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'figure',\n\t\t\t\t\tgetAttrs(el) {\n\t\t\t\t\t\tconst img: HTMLImageElement | null = el.querySelector('img');\n\t\t\t\t\t\tif (!img) return false;\n\t\t\t\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\t\t\t\tsrc: img.getAttribute('src') ?? '',\n\t\t\t\t\t\t\talt: img.getAttribute('alt') ?? '',\n\t\t\t\t\t\t\talign: 'center',\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst width: string | null = img.getAttribute('width');\n\t\t\t\t\t\tconst height: string | null = img.getAttribute('height');\n\t\t\t\t\t\tif (width) attrs.width = Number.parseInt(width, 10);\n\t\t\t\t\t\tif (height) attrs.height = Number.parseInt(height, 10);\n\n\t\t\t\t\t\tif (el.classList.contains('notectl-image--left')) attrs.align = 'left';\n\t\t\t\t\t\tif (el.classList.contains('notectl-image--right')) attrs.align = 'right';\n\t\t\t\t\t\treturn attrs;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttag: 'img',\n\t\t\t\t\tgetAttrs(el) {\n\t\t\t\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\t\t\t\tsrc: el.getAttribute('src') ?? '',\n\t\t\t\t\t\t\talt: el.getAttribute('alt') ?? '',\n\t\t\t\t\t\t\talign: 'center',\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst width: string | null = el.getAttribute('width');\n\t\t\t\t\t\tconst height: string | null = el.getAttribute('height');\n\t\t\t\t\t\tif (width) attrs.width = Number.parseInt(width, 10);\n\t\t\t\t\t\tif (height) attrs.height = Number.parseInt(height, 10);\n\t\t\t\t\t\treturn attrs;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: {\n\t\t\t\ttags: ['figure', 'img'],\n\t\t\t\tattrs: ['src', 'alt', 'width', 'height', 'class'],\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate registerNodeView(context: PluginContext): void {\n\t\tcontext.registerNodeView(\n\t\t\t'image',\n\t\t\tcreateImageNodeViewFactory(this.config, this.uploadStates, this.resolvedKeymap),\n\t\t);\n\t}\n\n\tprivate registerResizeCommands(context: PluginContext): void {\n\t\tconst step: number = this.config.resizeStep ?? 10;\n\t\tconst stepLarge: number = this.config.resizeStepLarge ?? 50;\n\t\tconst maxWidth: number = this.config.maxWidth;\n\n\t\tcontext.registerCommand('resizeImageGrow', () => {\n\t\t\tconst result: boolean = resizeImageByDelta(context, step, maxWidth);\n\t\t\tif (result) this.announceCurrentSize(context);\n\t\t\treturn result;\n\t\t});\n\n\t\tcontext.registerCommand('resizeImageShrink', () => {\n\t\t\tconst result: boolean = resizeImageByDelta(context, -step, maxWidth);\n\t\t\tif (result) this.announceCurrentSize(context);\n\t\t\treturn result;\n\t\t});\n\n\t\tcontext.registerCommand('resizeImageGrowLarge', () => {\n\t\t\tconst result: boolean = resizeImageByDelta(context, stepLarge, maxWidth);\n\t\t\tif (result) this.announceCurrentSize(context);\n\t\t\treturn result;\n\t\t});\n\n\t\tcontext.registerCommand('resizeImageShrinkLarge', () => {\n\t\t\tconst result: boolean = resizeImageByDelta(context, -stepLarge, maxWidth);\n\t\t\tif (result) this.announceCurrentSize(context);\n\t\t\treturn result;\n\t\t});\n\n\t\tcontext.registerCommand('resetImageSize', () => {\n\t\t\tconst result: boolean = resetImageSize(context);\n\t\t\tif (result) context.announce(this.locale.resetToNaturalSize);\n\t\t\treturn result;\n\t\t});\n\t}\n\n\tprivate registerResizeKeymaps(context: PluginContext): void {\n\t\tconst bindings: Record<string, () => boolean> = {};\n\t\tconst commands: Record<keyof ImageKeymap, string> = {\n\t\t\tgrowWidth: 'resizeImageGrow',\n\t\t\tshrinkWidth: 'resizeImageShrink',\n\t\t\tgrowWidthLarge: 'resizeImageGrowLarge',\n\t\t\tshrinkWidthLarge: 'resizeImageShrinkLarge',\n\t\t\tresetSize: 'resetImageSize',\n\t\t};\n\n\t\tfor (const [slot, commandName] of Object.entries(commands)) {\n\t\t\tconst binding: string | null = this.resolvedKeymap[slot as keyof ImageKeymap] ?? null;\n\t\t\tif (binding) {\n\t\t\t\tbindings[binding] = () => context.executeCommand(commandName);\n\t\t\t}\n\t\t}\n\n\t\tif (Object.keys(bindings).length > 0) {\n\t\t\tcontext.registerKeymap(bindings);\n\t\t}\n\t}\n\n\tprivate registerFileHandler(context: PluginContext): void {\n\t\tcontext.registerFileHandler('image/*', async (file, _position) => {\n\t\t\tif (!this.isAcceptedType(file.type)) return false;\n\t\t\tthis.handleFileInsert(context, file);\n\t\t\treturn true;\n\t\t});\n\t}\n\n\tprivate handleFileInsert(context: PluginContext, file: File): void {\n\t\tif (file.size > this.config.maxFileSize) return;\n\n\t\tconst blobUrl: string = URL.createObjectURL(file);\n\t\tthis.blobUrls.add(blobUrl);\n\n\t\tconst inserted: boolean = insertImage(context, { src: blobUrl });\n\t\tif (!inserted) {\n\t\t\tURL.revokeObjectURL(blobUrl);\n\t\t\tthis.blobUrls.delete(blobUrl);\n\t\t\treturn;\n\t\t}\n\n\t\t// Find the newly inserted image block\n\t\tconst state: EditorState = context.getState();\n\t\tconst sel = state.selection;\n\t\tif (!isNodeSelection(sel)) return;\n\t\tconst imageBlockId: BlockId = sel.nodeId;\n\n\t\tthis.uploadStates.set(imageBlockId, 'uploading');\n\n\t\t// Upload if service is registered\n\t\tconst uploadService = context.getService(IMAGE_UPLOAD_SERVICE);\n\t\tif (uploadService) {\n\t\t\tthis.uploadFile(context, file, imageBlockId, blobUrl);\n\t\t} else {\n\t\t\tthis.uploadStates.set(imageBlockId, 'complete');\n\t\t}\n\t}\n\n\tprivate async uploadFile(\n\t\tcontext: PluginContext,\n\t\tfile: File,\n\t\timageBlockId: BlockId,\n\t\tblobUrl: string,\n\t): Promise<void> {\n\t\tconst uploadService = context.getService(IMAGE_UPLOAD_SERVICE);\n\t\tif (!uploadService) return;\n\n\t\ttry {\n\t\t\tconst result = await uploadService.upload(file);\n\t\t\tthis.uploadStates.set(imageBlockId, 'complete');\n\n\t\t\t// Replace blob URL with uploaded URL\n\t\t\tconst state: EditorState = context.getState();\n\t\t\tconst block: BlockNode | undefined = state.getBlock(imageBlockId);\n\t\t\tif (!block) return;\n\n\t\t\tconst path: BlockId[] | undefined = state.getNodePath(imageBlockId);\n\t\t\tif (!path) return;\n\n\t\t\tconst merged: BlockAttrs = {\n\t\t\t\t...(block.attrs ?? {}),\n\t\t\t\tsrc: result.url,\n\t\t\t\t...(result.width !== undefined ? { width: result.width } : {}),\n\t\t\t\t...(result.height !== undefined ? { height: result.height } : {}),\n\t\t\t};\n\n\t\t\tconst tr: Transaction = state.transaction('command').setNodeAttr(path, merged).build();\n\t\t\tcontext.dispatch(tr);\n\n\t\t\t// Clean up blob URL\n\t\t\tURL.revokeObjectURL(blobUrl);\n\t\t\tthis.blobUrls.delete(blobUrl);\n\t\t} catch {\n\t\t\tthis.uploadStates.set(imageBlockId, 'error');\n\t\t\tcontext.announce(this.locale.uploadFailed);\n\t\t}\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z\"/></svg>';\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'image',\n\t\t\tgroup: 'insert',\n\t\t\ticon,\n\t\t\tlabel: this.locale.insertImage,\n\t\t\ttooltip: this.locale.insertImageTooltip,\n\t\t\tcommand: 'insertImage',\n\t\t\tpriority: 50,\n\t\t\tpopupType: 'custom',\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\tthis.renderImagePopup(container, ctx, onClose);\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate renderImagePopup(\n\t\tcontainer: HTMLElement,\n\t\tcontext: PluginContext,\n\t\tonClose: () => void,\n\t): void {\n\t\tcontainer.style.padding = '8px';\n\t\tcontainer.style.minWidth = '240px';\n\n\t\t// --- File upload ---\n\t\tconst fileInput: HTMLInputElement = document.createElement('input');\n\t\tfileInput.type = 'file';\n\t\tfileInput.accept = this.config.acceptedTypes.join(',');\n\t\tfileInput.style.cssText = 'position:absolute;width:0;height:0;overflow:hidden;opacity:0;';\n\n\t\tconst uploadBtn: HTMLButtonElement = document.createElement('button');\n\t\tuploadBtn.type = 'button';\n\t\tuploadBtn.textContent = this.locale.uploadFromComputer;\n\t\tuploadBtn.setAttribute('aria-label', this.locale.uploadAria);\n\t\tuploadBtn.style.cssText =\n\t\t\t'display:block;width:100%;padding:8px 12px;cursor:pointer;' +\n\t\t\t'text-align:center;box-sizing:border-box;' +\n\t\t\t'border:1px solid var(--notectl-border);border-radius:4px;' +\n\t\t\t'background:var(--notectl-surface-raised);color:var(--notectl-fg);';\n\n\t\tuploadBtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tfileInput.click();\n\t\t});\n\n\t\tfileInput.addEventListener('change', () => {\n\t\t\tconst file: File | undefined = fileInput.files?.[0];\n\t\t\tif (file) {\n\t\t\t\tthis.handleFileInsert(context, file);\n\t\t\t\tonClose();\n\t\t\t\tcontext.getContainer().focus();\n\t\t\t}\n\t\t});\n\n\t\tcontainer.appendChild(fileInput);\n\t\tcontainer.appendChild(uploadBtn);\n\n\t\t// --- Separator ---\n\t\tconst separator: HTMLDivElement = document.createElement('div');\n\t\tseparator.style.cssText =\n\t\t\t'display:flex;align-items:center;margin:8px 0;' +\n\t\t\t'color:var(--notectl-fg-muted);font-size:12px;';\n\t\tconst line1: HTMLSpanElement = document.createElement('span');\n\t\tline1.style.cssText = 'flex:1;height:1px;background:var(--notectl-border);';\n\t\tconst orText: HTMLSpanElement = document.createElement('span');\n\t\torText.textContent = this.locale.separator;\n\t\torText.style.cssText = 'padding:0 8px;';\n\t\tconst line2: HTMLSpanElement = document.createElement('span');\n\t\tline2.style.cssText = 'flex:1;height:1px;background:var(--notectl-border);';\n\t\tseparator.appendChild(line1);\n\t\tseparator.appendChild(orText);\n\t\tseparator.appendChild(line2);\n\t\tcontainer.appendChild(separator);\n\n\t\t// --- URL input ---\n\t\tconst urlInput: HTMLInputElement = document.createElement('input');\n\t\turlInput.type = 'url';\n\t\turlInput.placeholder = this.locale.urlPlaceholder;\n\t\turlInput.setAttribute('aria-label', this.locale.urlAria);\n\t\turlInput.style.cssText =\n\t\t\t'width:100%;padding:6px 8px;box-sizing:border-box;' +\n\t\t\t'border:1px solid var(--notectl-border);border-radius:4px;' +\n\t\t\t'background:var(--notectl-bg);color:var(--notectl-fg);';\n\n\t\tconst insertBtn: HTMLButtonElement = document.createElement('button');\n\t\tinsertBtn.type = 'button';\n\t\tinsertBtn.textContent = this.locale.insertButton;\n\t\tinsertBtn.setAttribute('aria-label', this.locale.insertAria);\n\t\tinsertBtn.style.cssText =\n\t\t\t'width:100%;padding:8px 12px;margin-top:4px;cursor:pointer;' +\n\t\t\t'border:1px solid var(--notectl-border);border-radius:4px;' +\n\t\t\t'background:var(--notectl-surface-raised);color:var(--notectl-fg);';\n\n\t\tconst applyUrl = (): void => {\n\t\t\tconst src: string = urlInput.value.trim();\n\t\t\tif (src) {\n\t\t\t\tinsertImage(context, { src });\n\t\t\t\tonClose();\n\t\t\t\tcontext.getContainer().focus();\n\t\t\t}\n\t\t};\n\n\t\tinsertBtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tapplyUrl();\n\t\t});\n\n\t\turlInput.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Enter') {\n\t\t\t\te.preventDefault();\n\t\t\t\tapplyUrl();\n\t\t\t}\n\t\t});\n\n\t\tcontainer.appendChild(urlInput);\n\t\tcontainer.appendChild(insertBtn);\n\n\t\trequestAnimationFrame(() => urlInput.focus());\n\t}\n\n\tprivate isAcceptedType(mimeType: string): boolean {\n\t\treturn this.config.acceptedTypes.some(\n\t\t\t(accepted) =>\n\t\t\t\taccepted === mimeType ||\n\t\t\t\t(accepted.endsWith('/*') && mimeType.startsWith(accepted.slice(0, -1))),\n\t\t);\n\t}\n\n\tprivate isImageSelected(state: EditorState): boolean {\n\t\tconst sel = state.selection;\n\t\tif (!isNodeSelection(sel)) return false;\n\t\tconst block: BlockNode | undefined = state.getBlock(sel.nodeId);\n\t\treturn block?.type === 'image';\n\t}\n\n\tprivate announceImageSelection(state: EditorState): void {\n\t\tif (!this.context) return;\n\t\tconst sel = state.selection;\n\t\tif (!isNodeSelection(sel)) return;\n\n\t\tconst block: BlockNode | undefined = state.getBlock(sel.nodeId);\n\t\tif (!block || block.type !== 'image') return;\n\n\t\tconst alt: string = (block.attrs?.alt as string | undefined) ?? '';\n\t\tconst width: number | undefined = block.attrs?.width as number | undefined;\n\t\tconst height: number | undefined = block.attrs?.height as number | undefined;\n\n\t\tconst parts: string[] = ['Image selected.'];\n\t\tif (alt) parts.push(`Alt text: ${alt}.`);\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tparts.push(`Size: ${width} by ${height} pixels.`);\n\t\t}\n\n\t\tconst shrinkKey: string | null = this.resolvedKeymap.shrinkWidth ?? null;\n\t\tconst growKey: string | null = this.resolvedKeymap.growWidth ?? null;\n\t\tif (shrinkKey && growKey) {\n\t\t\tparts.push(`${formatShortcut(shrinkKey)} / ${formatShortcut(growKey)} to resize.`);\n\t\t}\n\n\t\tthis.context.announce(parts.join(' '));\n\t}\n\n\tprivate announceCurrentSize(context: PluginContext): void {\n\t\tconst state = context.getState();\n\t\tconst sel = state.selection;\n\t\tif (!isNodeSelection(sel)) return;\n\n\t\tconst block: BlockNode | undefined = state.getBlock(sel.nodeId);\n\t\tif (!block || block.type !== 'image') return;\n\n\t\tconst width: number | undefined = block.attrs?.width as number | undefined;\n\t\tconst height: number | undefined = block.attrs?.height as number | undefined;\n\t\tif (width !== undefined && height !== undefined) {\n\t\t\tcontext.announce(`Image resized to ${width} by ${height} pixels.`);\n\t\t}\n\t}\n}\n","/** Image styles — display, alignment, resize handles, upload overlay. */\nexport const IMAGE_CSS = `\n/* Image */\n.notectl-image {\n\tmargin: 8px 0;\n\tuser-select: none;\n\tline-height: 0;\n}\n\n.notectl-image--center {\n\ttext-align: center;\n}\n\n.notectl-image--left {\n\ttext-align: left;\n}\n\n.notectl-image--right {\n\ttext-align: right;\n}\n\n.notectl-image__container {\n\tdisplay: inline-block;\n\tposition: relative;\n\tline-height: 0;\n}\n\n.notectl-image__img {\n\tdisplay: block;\n\tmax-width: 100%;\n\tborder-radius: 4px;\n}\n\n.notectl-image--selected .notectl-image__container {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n\tborder-radius: 6px;\n}\n\n/* Alignment toolbar (appears on image selection) */\n.notectl-image__align-toolbar {\n\tdisplay: flex;\n\tgap: 2px;\n\tposition: absolute;\n\ttop: -36px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tpadding: 2px;\n\tbox-shadow: 0 2px 8px var(--notectl-shadow);\n\tz-index: 10;\n}\n\n.notectl-image__align-btn {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\theight: 28px;\n\tborder: none;\n\tbackground: transparent;\n\tborder-radius: 4px;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-image__align-btn:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-image__align-btn--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-image__align-btn svg {\n\twidth: 16px;\n\theight: 16px;\n\tfill: currentColor;\n}\n\n/* Upload overlay */\n.notectl-image__overlay {\n\tposition: absolute;\n\tinset: 0;\n\tdisplay: none;\n\talign-items: center;\n\tjustify-content: center;\n\tbackground: rgba(255, 255, 255, 0.8);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg-muted);\n}\n\n.notectl-image__overlay--uploading {\n\tdisplay: flex;\n}\n\n.notectl-image__overlay--error {\n\tdisplay: flex;\n\tbackground: var(--notectl-danger-muted);\n\tcolor: var(--notectl-danger);\n}\n\n/* Resize overlay + handles */\n.notectl-image__resize-overlay {\n\tposition: absolute;\n\tinset: 0;\n\tpointer-events: none;\n}\n\n.notectl-image__resize-handle {\n\tposition: absolute;\n\twidth: 10px;\n\theight: 10px;\n\tbackground: var(--notectl-bg);\n\tborder: 2px solid var(--notectl-primary);\n\tborder-radius: 50%;\n\tpointer-events: all;\n\tz-index: 2;\n\ttransition: transform 0.1s, background 0.1s;\n}\n\n.notectl-image__resize-handle:hover {\n\tbackground: var(--notectl-primary);\n\ttransform: scale(1.3);\n}\n\n.notectl-image--resizing .notectl-image__resize-handle {\n\tbackground: var(--notectl-primary);\n}\n\n.notectl-image__resize-handle--nw {\n\ttop: -5px;\n\tleft: -5px;\n\tcursor: nwse-resize;\n}\n\n.notectl-image__resize-handle--ne {\n\ttop: -5px;\n\tright: -5px;\n\tcursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--sw {\n\tbottom: -5px;\n\tleft: -5px;\n\tcursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--se {\n\tbottom: -5px;\n\tright: -5px;\n\tcursor: nwse-resize;\n}\n\n/* Size indicator tooltip */\n.notectl-image__size-indicator {\n\tposition: absolute;\n\tbottom: -28px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tpadding: 2px 8px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\tborder-radius: 4px;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\topacity: 0;\n\ttransition: opacity 0.15s;\n\tz-index: 3;\n}\n\n.notectl-image__size-indicator--visible {\n\topacity: 1;\n}\n\n/* Keyboard resize hint (shown on selection, hidden during drag) */\n.notectl-image__keyboard-hint {\n\tdisplay: none;\n\tposition: absolute;\n\tbottom: -28px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tpadding: 2px 8px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 3;\n}\n\n.notectl-image--selected .notectl-image__keyboard-hint {\n\tdisplay: block;\n}\n\n.notectl-image--resizing .notectl-image__keyboard-hint {\n\tdisplay: none;\n}\n\n/* Resizing feedback */\n.notectl-image--resizing .notectl-image__img {\n\topacity: 0.85;\n}\n`;\n"],"names":["insertImage","context","attrs","state","getState","sel","selection","imageAttrs","src","alt","align","width","height","isGapCursor","anchorBlockId","isNodeSelection","nodeId","anchor","blockId","cellId","bid","block","getBlock","type","path","getNodePath","id","node","cellPath","imageBlock","createBlockNode","nodeType","cell","builder","transaction","blockChildren","getBlockChildren","i","length","rawIndex","children","findIndex","c","isBlockNode","removeNode","insertNode","setSelection","createNodeSelection","dispatch","build","blockIndex","doc","b","newParagraph","tr","resizeImageByDelta","delta","maxWidth","currentWidth","currentHeight","aspectRatio","clampedWidth","Math","max","min","newHeight","round","merged","setNodeAttr","IMAGE_LOCALE_EN","insertImageTooltip","uploadFromComputer","uploadAria","separator","urlPlaceholder","urlAria","insertButton","insertAria","imageAria","parts","push","join","resetToNaturalSize","uploadFailed","IMAGE_LOCALES","en","de","es","fr","zh","ru","ar","hi","ALIGNMENT_CLASSES","left","center","right","HANDLE_CURSORS","nw","ne","sw","se","HANDLE_X_SIGN","HANDLE_LABELS","activeCursorStyle","clearGlobalResizeCursor","remove","createImageNodeViewFactory","config","uploadStates","resolvedKeymap","figure","document","createElement","className","setAttribute","container","img","draggable","overlay","appendChild","currentNodeId","resizeOverlay","applyAttrs","n","style","cls","Object","values","classList","alignClass","add","uploadState","get","isUploading","toggle","textContent","removeAttribute","dimensionsCommitted","attachHandleListeners","handle","position","sizeIndicator","startX","startWidth","onPointerMove","e","deltaX","clientX","newWidth","onPointerUp","removeEventListener","finalWidth","getBoundingClientRect","finalHeight","prevWidth","prevHeight","target","releasePointerCapture","pointerId","addEventListener","preventDefault","stopPropagation","imgHeight","cursor","head","setPointerCapture","removeResizeOverlay","hasWidth","hasHeight","naturalW","naturalWidth","naturalH","naturalHeight","clampedW","ratio","clampedH","dom","contentDOM","update","updatedNode","selectNode","resizable","positions","pos","hintText","shrink","shrinkWidth","grow","growWidth","formatShortcut","hint","deselectNode","destroy","IMAGE_UPLOAD_SERVICE","ServiceKey","DEFAULT_IMAGE_KEYMAP","growWidthLarge","shrinkWidthLarge","resetSize","DEFAULT_IMAGE_CONFIG","maxFileSize","acceptedTypes","resizeStep","resizeStepLarge","ImagePlugin","name","priority","Map","blobUrls","Set","locale","this","keymap","resolvePluginLocale","registerStyleSheet","registerNodeSpec","registerNodeView","registerCommand","nodePath","parentPath","slice","parent","parentId","imageIndex","selectionTarget","removedId","rootChildren","idx","adjacent","createCollapsedSelection","registerResizeCommands","registerResizeKeymaps","registerFileHandler","registerToolbarItem","url","URL","revokeObjectURL","clear","oldState","newState","_tr","keys","delete","oldIsImage","isImageSelected","nowIsImage","announceImageSelection","group","isVoid","selectable","default","createBlockElement","imgContainer","escapeHTML","sizeAttrs","parseHTML","tag","el","querySelector","getAttribute","Number","parseInt","contains","sanitize","tags","step","stepLarge","result","announceCurrentSize","cleaned","fromEntries","entries","filter","k","announce","bindings","commands","slot","commandName","binding","executeCommand","registerKeymap","async","file","_position","isAcceptedType","handleFileInsert","size","blobUrl","createObjectURL","imageBlockId","set","getService","uploadFile","uploadService","upload","icon","label","tooltip","command","popupType","separatorAfter","renderPopup","ctx","onClose","renderImagePopup","padding","minWidth","fileInput","accept","cssText","uploadBtn","click","files","getContainer","focus","line1","orText","line2","urlInput","placeholder","insertBtn","applyUrl","value","trim","key","requestAnimationFrame","mimeType","some","accepted","endsWith","startsWith","shr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
  import { r as e } from "./resolvePluginLocale-B4w1OkPy.mjs";
2
- import { c as t } from "./Document-CI3iCwEP.mjs";
2
+ import { f as t } from "./Document-CuwE73FF.mjs";
3
3
  import { c as o } from "./NodeSpec-NZVvcCuH.mjs";
4
- import { i as r, a as i, c as l } from "./Selection-D5ZjXoB7.mjs";
5
- import { n } from "./TypeBrands-C09nE2qO.mjs";
6
- import { f as a } from "./ToolbarItem-ugDymuXi.mjs";
7
- const s = { label: "Horizontal Rule", tooltip: (e2) => `Horizontal Rule (${e2})` }, c = { en: s, de: { label: "Trennlinie", tooltip: (e2) => `Trennlinie (${e2})` }, es: { label: "Línea horizontal", tooltip: (e2) => `Línea horizontal (${e2})` }, fr: { label: "Ligne horizontale", tooltip: (e2) => `Ligne horizontale (${e2})` }, zh: { label: "分隔线", tooltip: (e2) => `分隔线 (${e2})` }, ru: { label: "Горизонтальная линия", tooltip: (e2) => `Горизонтальная линия (${e2})` }, ar: { label: "خط أفقي", tooltip: (e2) => `خط أفقي (${e2})` }, hi: { label: "क्षैतिज रेखा", tooltip: (e2) => `क्षैतिज रेखा (${e2})` } }, p = {};
4
+ import { i as r, a as i, b as l, c as n } from "./Selection-DmFDwiPJ.mjs";
5
+ import { n as a } from "./TypeBrands-C09nE2qO.mjs";
6
+ import { f as s } from "./ToolbarItem-BpZggUGo.mjs";
7
+ const c = { label: "Horizontal Rule", tooltip: (e2) => `Horizontal Rule (${e2})` }, p = { en: c, de: { label: "Trennlinie", tooltip: (e2) => `Trennlinie (${e2})` }, es: { label: "Línea horizontal", tooltip: (e2) => `Línea horizontal (${e2})` }, fr: { label: "Ligne horizontale", tooltip: (e2) => `Ligne horizontale (${e2})` }, zh: { label: "分隔线", tooltip: (e2) => `分隔线 (${e2})` }, ru: { label: "Горизонтальная линия", tooltip: (e2) => `Горизонтальная линия (${e2})` }, ar: { label: "خط أفقي", tooltip: (e2) => `خط أفقي (${e2})` }, hi: { label: "क्षैतिज रेखा", tooltip: (e2) => `क्षैतिज रेखा (${e2})` } }, h = {};
8
8
  function u(e2) {
9
9
  const t2 = e2.selection;
10
- return r(t2) ? -1 : e2.doc.children.findIndex((e3) => e3.id === t2.anchor.blockId);
10
+ return r(t2) || i(t2) ? -1 : e2.doc.children.findIndex((e3) => e3.id === t2.anchor.blockId);
11
11
  }
12
- class h {
12
+ class m {
13
13
  id = "horizontal-rule";
14
14
  name = "Horizontal Rule";
15
15
  priority = 40;
16
16
  config;
17
17
  locale;
18
18
  constructor(e2) {
19
- this.config = { ...p, ...e2 };
19
+ this.config = { ...h, ...e2 };
20
20
  }
21
21
  init(t2) {
22
- this.locale = e(c, t2, this.config.locale), this.registerNodeSpec(t2), this.registerCommands(t2), this.registerKeymap(t2), this.registerInputRule(t2), this.registerToolbarItem(t2);
22
+ this.locale = e(p, t2, this.config.locale), this.registerNodeSpec(t2), this.registerCommands(t2), this.registerKeymap(t2), this.registerInputRule(t2), this.registerToolbarItem(t2);
23
23
  }
24
24
  registerNodeSpec(e2) {
25
25
  e2.registerNodeSpec({ type: "horizontal_rule", group: "block", isVoid: true, toDOM: (e3) => o("hr", e3.id), toHTML: () => "<hr>", parseHTML: [{ tag: "hr" }], sanitize: { tags: ["hr"] } });
@@ -31,33 +31,33 @@ class h {
31
31
  e2.registerKeymap({ "Mod-Shift-H": () => e2.executeCommand("insertHorizontalRule") });
32
32
  }
33
33
  registerInputRule(e2) {
34
- e2.registerInputRule({ pattern: /^-{3,} $/, handler(e3, o2, a2, s2) {
35
- const c2 = e3.selection;
36
- if (r(c2)) return null;
37
- if (!i(c2)) return null;
38
- const p2 = e3.getBlock(c2.anchor.blockId);
39
- if (!p2 || "paragraph" !== p2.type) return null;
40
- const h2 = u(e3);
41
- if (-1 === h2) return null;
42
- const m = t(n("paragraph"));
43
- return e3.transaction("input").deleteTextAt(c2.anchor.blockId, 0, s2).setBlockType(c2.anchor.blockId, n("horizontal_rule")).insertNode([], h2 + 1, m).setSelection(l(m.id, 0)).build();
34
+ e2.registerInputRule({ pattern: /^-{3,} $/, handler(e3, o2, s2, c2) {
35
+ const p2 = e3.selection;
36
+ if (r(p2) || i(p2)) return null;
37
+ if (!l(p2)) return null;
38
+ const h2 = e3.getBlock(p2.anchor.blockId);
39
+ if (!h2 || "paragraph" !== h2.type) return null;
40
+ const m2 = u(e3);
41
+ if (-1 === m2) return null;
42
+ const d = t(a("paragraph"));
43
+ return e3.transaction("input").deleteTextAt(p2.anchor.blockId, 0, c2).setBlockType(p2.anchor.blockId, a("horizontal_rule")).insertNode([], m2 + 1, d).setSelection(n(d.id, 0)).build();
44
44
  } });
45
45
  }
46
46
  registerToolbarItem(e2) {
47
- e2.registerToolbarItem({ id: "horizontal-rule", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11h16v2H4z"/></svg>', label: this.locale.label, tooltip: this.locale.tooltip(a("Mod-Shift-H")), command: "insertHorizontalRule", priority: 60, separatorAfter: this.config.separatorAfter, isActive: () => false });
47
+ e2.registerToolbarItem({ id: "horizontal-rule", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11h16v2H4z"/></svg>', label: this.locale.label, tooltip: this.locale.tooltip(s("Mod-Shift-H")), command: "insertHorizontalRule", priority: 60, separatorAfter: this.config.separatorAfter, isActive: () => false });
48
48
  }
49
49
  insertHorizontalRule(e2) {
50
50
  const o2 = e2.getState();
51
- if (r(o2.selection)) return false;
52
- const i2 = u(o2);
53
- if (-1 === i2) return false;
54
- const a2 = t(n("horizontal_rule")), s2 = t(n("paragraph")), c2 = o2.transaction("command").insertNode([], i2 + 1, a2).insertNode([], i2 + 2, s2).setSelection(l(s2.id, 0)).build();
55
- return e2.dispatch(c2), true;
51
+ if (r(o2.selection) || i(o2.selection)) return false;
52
+ const l2 = u(o2);
53
+ if (-1 === l2) return false;
54
+ const s2 = t(a("horizontal_rule")), c2 = t(a("paragraph")), p2 = o2.transaction("command").insertNode([], l2 + 1, s2).insertNode([], l2 + 2, c2).setSelection(n(c2.id, 0)).build();
55
+ return e2.dispatch(p2), true;
56
56
  }
57
57
  }
58
58
  export {
59
- c as H,
60
- s as a,
61
- h as b
59
+ p as H,
60
+ c as a,
61
+ m as b
62
62
  };
63
- //# sourceMappingURL=index-BRYzYOYC.mjs.map
63
+ //# sourceMappingURL=index-D67mP19g.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-D67mP19g.mjs","sources":["../../src/plugins/horizontal-rule/HorizontalRuleLocale.ts","../../src/plugins/horizontal-rule/HorizontalRulePlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the HorizontalRulePlugin. */\n\n// --- Locale Interface ---\n\nexport interface HorizontalRuleLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_EN: HorizontalRuleLocale = {\n\tlabel: 'Horizontal Rule',\n\ttooltip: (shortcut: string) => `Horizontal Rule (${shortcut})`,\n};\n\n// --- German Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_DE: HorizontalRuleLocale = {\n\tlabel: 'Trennlinie',\n\ttooltip: (shortcut: string) => `Trennlinie (${shortcut})`,\n};\n\n// --- Spanish Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_ES: HorizontalRuleLocale = {\n\tlabel: 'Línea horizontal',\n\ttooltip: (shortcut: string) => `Línea horizontal (${shortcut})`,\n};\n\n// --- French Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_FR: HorizontalRuleLocale = {\n\tlabel: 'Ligne horizontale',\n\ttooltip: (shortcut: string) => `Ligne horizontale (${shortcut})`,\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_ZH: HorizontalRuleLocale = {\n\tlabel: '分隔线',\n\ttooltip: (shortcut: string) => `分隔线 (${shortcut})`,\n};\n\n// --- Russian Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_RU: HorizontalRuleLocale = {\n\tlabel: 'Горизонтальная линия',\n\ttooltip: (shortcut: string) => `Горизонтальная линия (${shortcut})`,\n};\n\n// --- Arabic Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_AR: HorizontalRuleLocale = {\n\tlabel: 'خط أفقي',\n\ttooltip: (shortcut: string) => `خط أفقي (${shortcut})`,\n};\n\n// --- Hindi Locale ---\n\nexport const HORIZONTAL_RULE_LOCALE_HI: HorizontalRuleLocale = {\n\tlabel: 'क्षैतिज रेखा',\n\ttooltip: (shortcut: string) => `क्षैतिज रेखा (${shortcut})`,\n};\n\n// --- Locale Map ---\n\nexport const HORIZONTAL_RULE_LOCALES: Record<string, HorizontalRuleLocale> = {\n\ten: HORIZONTAL_RULE_LOCALE_EN,\n\tde: HORIZONTAL_RULE_LOCALE_DE,\n\tes: HORIZONTAL_RULE_LOCALE_ES,\n\tfr: HORIZONTAL_RULE_LOCALE_FR,\n\tzh: HORIZONTAL_RULE_LOCALE_ZH,\n\tru: HORIZONTAL_RULE_LOCALE_RU,\n\tar: HORIZONTAL_RULE_LOCALE_AR,\n\thi: HORIZONTAL_RULE_LOCALE_HI,\n};\n","/**\n * HorizontalRulePlugin: registers a horizontal rule (divider) void block type\n * with NodeSpec, insert command, input rule, keyboard shortcut, and toolbar button.\n */\n\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { createBlockNode } from '../../model/Document.js';\nimport { createBlockElement } from '../../model/NodeSpec.js';\nimport {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { HORIZONTAL_RULE_LOCALES, type HorizontalRuleLocale } from './HorizontalRuleLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\thorizontal_rule: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\nexport interface HorizontalRuleConfig {\n\t/** When true, a separator is rendered after the toolbar item. */\n\treadonly separatorAfter?: boolean;\n\t/** Locale override for user-facing strings. */\n\treadonly locale?: HorizontalRuleLocale;\n}\n\nconst DEFAULT_CONFIG: HorizontalRuleConfig = {};\n\n// --- Helpers ---\n\n/** Finds the index of the cursor's block among top-level document children. */\nfunction findBlockIndexForCursor(state: EditorState): number {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return -1;\n\treturn state.doc.children.findIndex((b) => b.id === sel.anchor.blockId);\n}\n\n// --- Plugin ---\n\nexport class HorizontalRulePlugin implements Plugin {\n\treadonly id = 'horizontal-rule';\n\treadonly name = 'Horizontal Rule';\n\treadonly priority = 40;\n\n\tprivate readonly config: HorizontalRuleConfig;\n\tprivate locale!: HorizontalRuleLocale;\n\n\tconstructor(config?: Partial<HorizontalRuleConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(HORIZONTAL_RULE_LOCALES, context, this.config.locale);\n\t\tthis.registerNodeSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymap(context);\n\t\tthis.registerInputRule(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'horizontal_rule',\n\t\t\tgroup: 'block',\n\t\t\tisVoid: true,\n\t\t\ttoDOM(node) {\n\t\t\t\treturn createBlockElement('hr', node.id);\n\t\t\t},\n\t\t\ttoHTML() {\n\t\t\t\treturn '<hr>';\n\t\t\t},\n\t\t\tparseHTML: [{ tag: 'hr' }],\n\t\t\tsanitize: { tags: ['hr'] },\n\t\t});\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('insertHorizontalRule', () => {\n\t\t\treturn this.insertHorizontalRule(context);\n\t\t});\n\t}\n\n\tprivate registerKeymap(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-H': () => context.executeCommand('insertHorizontalRule'),\n\t\t});\n\t}\n\n\tprivate registerInputRule(context: PluginContext): void {\n\t\tcontext.registerInputRule({\n\t\t\tpattern: /^-{3,} $/,\n\t\t\thandler(state, _match, _start, end) {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\tconst blockIndex: number = findBlockIndexForCursor(state);\n\t\t\t\tif (blockIndex === -1) return null;\n\n\t\t\t\tconst newParagraph = createBlockNode(nodeType('paragraph'));\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, 0, end)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('horizontal_rule'))\n\t\t\t\t\t.insertNode([], blockIndex + 1, newParagraph)\n\t\t\t\t\t.setSelection(createCollapsedSelection(newParagraph.id, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M4 11h16v2H4z\"/></svg>';\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'horizontal-rule',\n\t\t\tgroup: 'block',\n\t\t\ticon,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip(formatShortcut('Mod-Shift-H')),\n\t\t\tcommand: 'insertHorizontalRule',\n\t\t\tpriority: 60,\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: () => false,\n\t\t});\n\t}\n\n\t/**\n\t * Inserts a horizontal rule after the current block,\n\t * followed by a new paragraph for continued editing.\n\t */\n\tprivate insertHorizontalRule(context: PluginContext): boolean {\n\t\tconst state: EditorState = context.getState();\n\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\tconst blockIndex: number = findBlockIndexForCursor(state);\n\t\tif (blockIndex === -1) return false;\n\n\t\tconst hrBlock = createBlockNode(nodeType('horizontal_rule'));\n\t\tconst newParagraph = createBlockNode(nodeType('paragraph'));\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.insertNode([], blockIndex + 1, hrBlock)\n\t\t\t.insertNode([], blockIndex + 2, newParagraph)\n\t\t\t.setSelection(createCollapsedSelection(newParagraph.id, 0))\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n}\n"],"names":["HORIZONTAL_RULE_LOCALE_EN","label","tooltip","shortcut","HORIZONTAL_RULE_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","findBlockIndexForCursor","state","sel","selection","isNodeSelection","isGapCursor","doc","children","findIndex","b","id","anchor","blockId","HorizontalRulePlugin","name","priority","config","locale","this","context","resolvePluginLocale","registerNodeSpec","registerCommands","registerKeymap","registerInputRule","registerToolbarItem","type","group","isVoid","toDOM","node","createBlockElement","toHTML","parseHTML","tag","sanitize","tags","registerCommand","insertHorizontalRule","executeCommand","pattern","_match","_start","end","isCollapsed","block","getBlock","blockIndex","newParagraph","createBlockNode","nodeType","transaction","deleteTextAt","setBlockType","insertNode","setSelection","createCollapsedSelection","build","icon","formatShortcut","command","separatorAfter","isActive","getState","hrBlock","tr","dispatch"],"mappings":";;;;;;AAWO,MAAMA,IAAkD,EAC9DC,OAAO,mBACPC,SAAUC,CAAAA,OAAqB,oBAAoBA,SAsDvCC,IAAgE,EAC5EC,IAAIL,GACJM,IAnD8D,EAC9DL,OAAO,cACPC,SAAUC,CAAAA,OAAqB,eAAeA,SAkD9CI,I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AoB,EAC3Bf,IAAI,mBACJiB,OAAO,SACP+B,MALA,+FAMAvE,OAAO+B,KAAKD,OAAO9B,OACnBC,SAAS8B,KAAKD,OAAO7B,QAAQuE,EAAe,aAAA,CAAA,GAC5CC,SAAS,wBACT7C,UAAU,IACV8C,gBAAgB3C,KAAKF,OAAO6C,gBAC5BC,UAAU,YAAM,CAAA;AAAA,EAElB;AAAA,EAMQ,qBAAqB3C,IAAAA;AAC5B,UAAMlB,KAAqBkB,GAAQ4C;AACnC,QAAI3D,EAAgBH,GAAME,SAAAA,KAAcE,EAAYJ,GAAME,WAAY,QAAA;AACtE,UAAM4C,KAAqB/C,EAAwBC;AACnD,QAAA,OAAI8C,GAAmB,QAAA;AAEvB,UAAMiB,KAAUf,EAAgBC,EAAS,iBAAA,CAAA,GACnCF,KAAeC,EAAgBC,EAAS,WAAA,CAAA,GAExCe,KAAKhE,GACTkD,YAAY,SAAA,EACZG,WAAW,CAAA,GAAIP,KAAa,GAAGiB,EAAAA,EAC/BV,WAAW,IAAIP,KAAa,GAAGC,IAC/BO,aAAaC,EAAyBR,GAAatC,IAAI,CAAA,CAAA,EACvD+C;AAGF,WADAtC,GAAQ+C,SAASD,EAAAA,GAAAA;AAAAA,EAElB;AAAA;"}
@@ -0,0 +1,73 @@
1
+ import { r as e } from "./resolvePluginLocale-B4w1OkPy.mjs";
2
+ import { m as t } from "./TypeBrands-C09nE2qO.mjs";
3
+ import { f as i } from "./ToolbarItem-BpZggUGo.mjs";
4
+ import { e as a, b as r } from "./MarkCommands-CC37WA7Z.mjs";
5
+ const o = { boldLabel: "Bold", italicLabel: "Italic", underlineLabel: "Underline" }, n = { en: o, de: { boldLabel: "Fett", italicLabel: "Kursiv", underlineLabel: "Unterstrichen" }, es: { boldLabel: "Negrita", italicLabel: "Cursiva", underlineLabel: "Subrayado" }, fr: { boldLabel: "Gras", italicLabel: "Italique", underlineLabel: "Souligné" }, zh: { boldLabel: "粗体", italicLabel: "斜体", underlineLabel: "下划线" }, ru: { boldLabel: "Жирный", italicLabel: "Курсив", underlineLabel: "Подчёркнутый" }, ar: { boldLabel: "غامق", italicLabel: "مائل", underlineLabel: "تحته خط" }, hi: { boldLabel: "बोल्ड", italicLabel: "इटैलिक", underlineLabel: "अंडरलाइन" } }, s = { bold: true, italic: true, underline: true }, l = [{ type: "bold", configKey: "bold", rank: 0, tag: "strong", label: "Bold", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/></svg>', keyBinding: "Mod-B", toHTMLString: (e2) => `<strong>${e2}</strong>`, parseHTML: [{ tag: "strong" }, { tag: "b", getAttrs: (e2) => {
6
+ const t2 = e2.style.fontWeight;
7
+ return "normal" !== t2 && "400" !== t2 && {};
8
+ } }, { tag: "span", getAttrs: (e2) => {
9
+ const t2 = e2.style.fontWeight;
10
+ if (!t2) return false;
11
+ if ("bold" === t2) return {};
12
+ const i2 = Number.parseInt(t2, 10);
13
+ return !Number.isNaN(i2) && i2 >= 700 && {};
14
+ } }], sanitize: { tags: ["strong", "b"] } }, { type: "italic", configKey: "italic", rank: 1, tag: "em", label: "Italic", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/></svg>', keyBinding: "Mod-I", toHTMLString: (e2) => `<em>${e2}</em>`, parseHTML: [{ tag: "em" }, { tag: "i" }, { tag: "span", getAttrs: (e2) => "italic" === e2.style.fontStyle && {} }], sanitize: { tags: ["em", "i"] } }, { type: "underline", configKey: "underline", rank: 2, tag: "u", label: "Underline", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/></svg>', keyBinding: "Mod-U", toHTMLString: (e2) => `<u>${e2}</u>`, parseHTML: [{ tag: "u" }, { tag: "span", getAttrs: (e2) => !!e2.style.textDecoration.includes("underline") && {} }], sanitize: { tags: ["u"] } }];
15
+ class g {
16
+ id = "text-formatting";
17
+ name = "Text Formatting";
18
+ priority = 20;
19
+ config;
20
+ locale;
21
+ constructor(e2) {
22
+ this.config = { ...s, ...e2 };
23
+ }
24
+ init(t2) {
25
+ this.locale = e(n, t2, this.config.locale);
26
+ const i2 = l.filter((e2) => this.config[e2.configKey]), a2 = i2.filter((e2) => this.isToolbarVisible(e2.configKey)).at(-1);
27
+ for (const e2 of i2) {
28
+ const i3 = this.config.separatorAfter && e2 === a2;
29
+ this.registerMark(t2, e2, i3);
30
+ }
31
+ this.registerKeymaps(t2, i2), this.registerDisabledToolbarItems(t2);
32
+ }
33
+ registerMark(e2, o2, n2) {
34
+ const s2 = c(o2.type), l2 = this.isToolbarVisible(o2.configKey);
35
+ if (e2.registerMarkSpec({ type: o2.type, rank: o2.rank, toDOM: () => document.createElement(o2.tag), toHTMLString: (e3, t2) => o2.toHTMLString(t2), parseHTML: o2.parseHTML, sanitize: o2.sanitize }), e2.registerCommand(s2, () => {
36
+ const i2 = a(e2.getState(), t(o2.type));
37
+ return !!i2 && (e2.dispatch(i2), true);
38
+ }), l2) {
39
+ const a2 = this.getMarkLabel(o2.type);
40
+ e2.registerToolbarItem({ id: o2.type, group: "format", icon: o2.icon, label: a2, tooltip: `${a2} (${i(o2.keyBinding)})`, command: s2, priority: 10 * o2.rank + 10, separatorAfter: n2, isActive: (e3) => r(e3, t(o2.type)) });
41
+ }
42
+ }
43
+ registerKeymaps(e2, t2) {
44
+ const i2 = {};
45
+ for (const a2 of t2) {
46
+ const t3 = c(a2.type);
47
+ i2[a2.keyBinding] = () => e2.executeCommand(t3);
48
+ }
49
+ Object.keys(i2).length > 0 && e2.registerKeymap(i2);
50
+ }
51
+ registerDisabledToolbarItems(e2) {
52
+ if (this.config.toolbar) for (const t2 of l) {
53
+ const i2 = this.config[t2.configKey], a2 = this.config.toolbar[t2.configKey] ?? true;
54
+ !i2 && a2 && e2.registerToolbarItem({ id: t2.type, group: "format", icon: t2.icon, label: this.getMarkLabel(t2.type), command: c(t2.type), priority: 10 * t2.rank + 10, isEnabled: () => false });
55
+ }
56
+ }
57
+ getMarkLabel(e2) {
58
+ const t2 = `${e2}Label`;
59
+ return this.locale[t2];
60
+ }
61
+ isToolbarVisible(e2) {
62
+ return !this.config.toolbar || (this.config.toolbar[e2] ?? true);
63
+ }
64
+ }
65
+ function c(e2) {
66
+ return `toggle${e2.charAt(0).toUpperCase()}${e2.slice(1)}`;
67
+ }
68
+ export {
69
+ g as T,
70
+ n as a,
71
+ o as b
72
+ };
73
+ //# sourceMappingURL=index-D8tbbW97.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-D8tbbW97.mjs","sources":["../../src/plugins/text-formatting/TextFormattingLocale.ts","../../src/plugins/text-formatting/TextFormattingPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the TextFormattingPlugin.\n */\n\n// --- Locale Interface ---\n\nexport interface TextFormattingLocale {\n\treadonly boldLabel: string;\n\treadonly italicLabel: string;\n\treadonly underlineLabel: string;\n}\n\n// --- Default English Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_EN: TextFormattingLocale = {\n\tboldLabel: 'Bold',\n\titalicLabel: 'Italic',\n\tunderlineLabel: 'Underline',\n};\n\n// --- German Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_DE: TextFormattingLocale = {\n\tboldLabel: 'Fett',\n\titalicLabel: 'Kursiv',\n\tunderlineLabel: 'Unterstrichen',\n};\n\n// --- Spanish Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_ES: TextFormattingLocale = {\n\tboldLabel: 'Negrita',\n\titalicLabel: 'Cursiva',\n\tunderlineLabel: 'Subrayado',\n};\n\n// --- French Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_FR: TextFormattingLocale = {\n\tboldLabel: 'Gras',\n\titalicLabel: 'Italique',\n\tunderlineLabel: 'Souligné',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_ZH: TextFormattingLocale = {\n\tboldLabel: '粗体',\n\titalicLabel: '斜体',\n\tunderlineLabel: '下划线',\n};\n\n// --- Russian Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_RU: TextFormattingLocale = {\n\tboldLabel: 'Жирный',\n\titalicLabel: 'Курсив',\n\tunderlineLabel: 'Подчёркнутый',\n};\n\n// --- Arabic Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_AR: TextFormattingLocale = {\n\tboldLabel: 'غامق',\n\titalicLabel: 'مائل',\n\tunderlineLabel: 'تحته خط',\n};\n\n// --- Hindi Locale ---\n\nexport const TEXT_FORMATTING_LOCALE_HI: TextFormattingLocale = {\n\tboldLabel: 'बोल्ड',\n\titalicLabel: 'इटैलिक',\n\tunderlineLabel: 'अंडरलाइन',\n};\n\n// --- Locale Map ---\n\nexport const TEXT_FORMATTING_LOCALES: Record<string, TextFormattingLocale> = {\n\ten: TEXT_FORMATTING_LOCALE_EN,\n\tde: TEXT_FORMATTING_LOCALE_DE,\n\tes: TEXT_FORMATTING_LOCALE_ES,\n\tfr: TEXT_FORMATTING_LOCALE_FR,\n\tzh: TEXT_FORMATTING_LOCALE_ZH,\n\tru: TEXT_FORMATTING_LOCALE_RU,\n\tar: TEXT_FORMATTING_LOCALE_AR,\n\thi: TEXT_FORMATTING_LOCALE_HI,\n};\n","/**\n * TextFormattingPlugin: registers inline marks (bold, italic, underline)\n * with their MarkSpecs, toggle commands, keyboard shortcuts, and toolbar items.\n *\n * This plugin is data-driven — each mark type is defined declaratively and\n * all registrations (MarkSpec, command, keymap, toolbar item) are derived\n * from the same definition.\n *\n * Supports two separate config dimensions:\n * - Feature config (bold/italic/underline): controls whether the mark is\n * registered in the schema. When disabled, the keyboard shortcut does nothing.\n * - Toolbar config: controls whether the toolbar button is visible.\n * When a feature is disabled but toolbar is enabled, the button renders as disabled.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { ParseRule } from '../../model/ParseRule.js';\nimport type { SanitizeConfig } from '../../model/SanitizeConfig.js';\nimport { markType as mkType } from '../../model/TypeBrands.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { TEXT_FORMATTING_LOCALES, type TextFormattingLocale } from './TextFormattingLocale.js';\n\n// --- Configuration ---\n\n/** Controls toolbar button visibility per mark. */\nexport interface TextFormattingToolbarConfig {\n\treadonly bold?: boolean;\n\treadonly italic?: boolean;\n\treadonly underline?: boolean;\n}\n\n/** Controls which inline marks are enabled and which toolbar buttons are shown. */\nexport interface TextFormattingConfig {\n\treadonly bold: boolean;\n\treadonly italic: boolean;\n\treadonly underline: boolean;\n\treadonly toolbar?: TextFormattingToolbarConfig;\n\t/** When true, a separator is rendered after the last text-formatting toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: TextFormattingLocale;\n}\n\nconst DEFAULT_CONFIG: TextFormattingConfig = {\n\tbold: true,\n\titalic: true,\n\tunderline: true,\n};\n\n// --- Mark Definitions ---\n\ninterface MarkDefinition {\n\treadonly type: string;\n\treadonly configKey: keyof Omit<TextFormattingConfig, 'toolbar' | 'separatorAfter' | 'locale'>;\n\treadonly rank: number;\n\treadonly tag: string;\n\treadonly label: string;\n\treadonly icon: string;\n\treadonly keyBinding: string;\n\treadonly toHTMLString: (content: string) => string;\n\treadonly parseHTML: readonly ParseRule[];\n\treadonly sanitize: SanitizeConfig;\n}\n\nconst BOLD_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\"/></svg>';\nconst ITALIC_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z\"/></svg>';\nconst UNDERLINE_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z\"/></svg>';\n\nconst MARK_DEFINITIONS: readonly MarkDefinition[] = [\n\t{\n\t\ttype: 'bold',\n\t\tconfigKey: 'bold',\n\t\trank: 0,\n\t\ttag: 'strong',\n\t\tlabel: 'Bold',\n\t\ticon: BOLD_ICON,\n\t\tkeyBinding: 'Mod-B',\n\t\ttoHTMLString: (content) => `<strong>${content}</strong>`,\n\t\tparseHTML: [\n\t\t\t{ tag: 'strong' },\n\t\t\t{\n\t\t\t\ttag: 'b',\n\t\t\t\tgetAttrs: (el: HTMLElement) => {\n\t\t\t\t\tconst fw: string = el.style.fontWeight;\n\t\t\t\t\treturn fw === 'normal' || fw === '400' ? false : {};\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: 'span',\n\t\t\t\tgetAttrs: (el: HTMLElement) => {\n\t\t\t\t\tconst fw: string = el.style.fontWeight;\n\t\t\t\t\tif (!fw) return false;\n\t\t\t\t\tif (fw === 'bold') return {};\n\t\t\t\t\tconst numeric: number = Number.parseInt(fw, 10);\n\t\t\t\t\treturn !Number.isNaN(numeric) && numeric >= 700 ? {} : false;\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tsanitize: { tags: ['strong', 'b'] },\n\t},\n\t{\n\t\ttype: 'italic',\n\t\tconfigKey: 'italic',\n\t\trank: 1,\n\t\ttag: 'em',\n\t\tlabel: 'Italic',\n\t\ticon: ITALIC_ICON,\n\t\tkeyBinding: 'Mod-I',\n\t\ttoHTMLString: (content) => `<em>${content}</em>`,\n\t\tparseHTML: [\n\t\t\t{ tag: 'em' },\n\t\t\t{ tag: 'i' },\n\t\t\t{\n\t\t\t\ttag: 'span',\n\t\t\t\tgetAttrs: (el: HTMLElement) => {\n\t\t\t\t\treturn el.style.fontStyle === 'italic' ? {} : false;\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tsanitize: { tags: ['em', 'i'] },\n\t},\n\t{\n\t\ttype: 'underline',\n\t\tconfigKey: 'underline',\n\t\trank: 2,\n\t\ttag: 'u',\n\t\tlabel: 'Underline',\n\t\ticon: UNDERLINE_ICON,\n\t\tkeyBinding: 'Mod-U',\n\t\ttoHTMLString: (content) => `<u>${content}</u>`,\n\t\tparseHTML: [\n\t\t\t{ tag: 'u' },\n\t\t\t{\n\t\t\t\ttag: 'span',\n\t\t\t\tgetAttrs: (el: HTMLElement) => {\n\t\t\t\t\treturn el.style.textDecoration.includes('underline') ? {} : false;\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tsanitize: { tags: ['u'] },\n\t},\n];\n\n// --- Plugin ---\n\nexport class TextFormattingPlugin implements Plugin {\n\treadonly id = 'text-formatting';\n\treadonly name = 'Text Formatting';\n\treadonly priority = 20;\n\n\tprivate readonly config: TextFormattingConfig;\n\tprivate locale!: TextFormattingLocale;\n\n\tconstructor(config?: Partial<TextFormattingConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(TEXT_FORMATTING_LOCALES, context, this.config.locale);\n\n\t\tconst enabledMarks = MARK_DEFINITIONS.filter((def) => this.config[def.configKey]);\n\n\t\t// Determine which marks will have visible toolbar items\n\t\tconst visibleToolbarMarks = enabledMarks.filter((def) => this.isToolbarVisible(def.configKey));\n\t\tconst lastVisibleMark = visibleToolbarMarks.at(-1);\n\n\t\tfor (const def of enabledMarks) {\n\t\t\tconst isSeparatorTarget = this.config.separatorAfter && def === lastVisibleMark;\n\t\t\tthis.registerMark(context, def, isSeparatorTarget);\n\t\t}\n\n\t\tthis.registerKeymaps(context, enabledMarks);\n\n\t\t// Register disabled placeholder buttons for marks that are disabled\n\t\t// as features but explicitly requested in the toolbar config\n\t\tthis.registerDisabledToolbarItems(context);\n\t}\n\n\tprivate registerMark(\n\t\tcontext: PluginContext,\n\t\tdef: MarkDefinition,\n\t\tseparatorAfter?: boolean,\n\t): void {\n\t\tconst commandName = toCommandName(def.type);\n\t\tconst toolbarVisible = this.isToolbarVisible(def.configKey);\n\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: def.type,\n\t\t\trank: def.rank,\n\t\t\ttoDOM() {\n\t\t\t\treturn document.createElement(def.tag);\n\t\t\t},\n\t\t\ttoHTMLString: (_mark, content) => def.toHTMLString(content),\n\t\t\tparseHTML: def.parseHTML,\n\t\t\tsanitize: def.sanitize,\n\t\t});\n\n\t\tcontext.registerCommand(commandName, () => {\n\t\t\tconst tr = toggleMark(context.getState(), mkType(def.type));\n\t\t\tif (tr) {\n\t\t\t\tcontext.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\n\t\tif (toolbarVisible) {\n\t\t\tconst label: string = this.getMarkLabel(def.type);\n\t\t\tcontext.registerToolbarItem({\n\t\t\t\tid: def.type,\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon: def.icon,\n\t\t\t\tlabel,\n\t\t\t\ttooltip: `${label} (${formatShortcut(def.keyBinding)})`,\n\t\t\t\tcommand: commandName,\n\t\t\t\tpriority: def.rank * 10 + 10,\n\t\t\t\tseparatorAfter,\n\t\t\t\tisActive: (state) => isMarkActive(state, mkType(def.type)),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate registerKeymaps(context: PluginContext, marks: readonly MarkDefinition[]): void {\n\t\tconst keymap: Record<string, () => boolean> = {};\n\t\tfor (const def of marks) {\n\t\t\tconst commandName = toCommandName(def.type);\n\t\t\tkeymap[def.keyBinding] = () => context.executeCommand(commandName);\n\t\t}\n\t\tif (Object.keys(keymap).length > 0) {\n\t\t\tcontext.registerKeymap(keymap);\n\t\t}\n\t}\n\n\t/**\n\t * Registers disabled toolbar buttons for marks whose feature is disabled\n\t * but whose toolbar button is explicitly requested.\n\t */\n\tprivate registerDisabledToolbarItems(context: PluginContext): void {\n\t\tif (!this.config.toolbar) return;\n\n\t\tfor (const def of MARK_DEFINITIONS) {\n\t\t\tconst featureEnabled = this.config[def.configKey];\n\t\t\tconst toolbarVisible = this.config.toolbar[def.configKey] ?? true;\n\n\t\t\tif (!featureEnabled && toolbarVisible) {\n\t\t\t\tcontext.registerToolbarItem({\n\t\t\t\t\tid: def.type,\n\t\t\t\t\tgroup: 'format',\n\t\t\t\t\ticon: def.icon,\n\t\t\t\t\tlabel: this.getMarkLabel(def.type),\n\t\t\t\t\tcommand: toCommandName(def.type),\n\t\t\t\t\tpriority: def.rank * 10 + 10,\n\t\t\t\t\tisEnabled: () => false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getMarkLabel(type: string): string {\n\t\tconst key = `${type}Label` as keyof TextFormattingLocale;\n\t\treturn this.locale[key] as string;\n\t}\n\n\t/** Checks if a toolbar button should be visible for a given mark. */\n\tprivate isToolbarVisible(\n\t\tconfigKey: keyof Omit<TextFormattingConfig, 'toolbar' | 'separatorAfter' | 'locale'>,\n\t): boolean {\n\t\tif (!this.config.toolbar) return true;\n\t\treturn this.config.toolbar[configKey] ?? true;\n\t}\n}\n\n/** Converts a mark type to its toggle command name (e.g. 'bold' → 'toggleBold'). */\nfunction toCommandName(markType: string): string {\n\treturn `toggle${markType.charAt(0).toUpperCase()}${markType.slice(1)}`;\n}\n"],"names":["TEXT_FORMATTING_LOCALE_EN","boldLabel","italicLabel","underlineLabel","TEXT_FORMATTING_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","bold","italic","underline","MARK_DEFINITIONS","type","configKey","rank","tag","label","icon","keyBinding","toHTMLString","content","parseHTML","getAttrs","el","fw","style","fontWeight","numeric","Number","parseInt","isNaN","sanitize","tags","fontStyle","textDecoration","includes","TextFormattingPlugin","id","name","priority","config","locale","this","context","resolvePluginLocale","enabledMarks","filter","def","lastVisibleMark","isToolbarVisible","at","isSeparatorTarget","separatorAfter","registerMark","registerKeymaps","registerDisabledToolbarItems","commandName","toCommandName","toolbarVisible","registerMarkSpec","toDOM","document","createElement","_mark","registerCommand","tr","toggleMark","getState","mkType","dispatch","getMarkLabel","registerToolbarItem","group","tooltip","formatShortcut","command","isActive","state","isMarkActive","marks","keymap","executeCommand","Object","keys","length","registerKeymap","toolbar","featureEnabled","isEnabled","key","markType","charAt","toUpperCase","slice"],"mappings":";;;;AAcO,MAAMA,IAAkD,EAC9DC,WAAW,QACXC,aAAa,UACbC,gBAAgB,YAAA,GA6DJC,IAAgE,EAC5EC,IAAIL,GACJM,IA1D8D,EAC9DL,WAAW,QACXC,aAAa,UACbC,gBAAgB,gBAAA,GAwDhBI,IAnD8D,EAC9DN,WAAW,WACXC,aAAa,WACbC,gBAAgB,YAAA,GAiDhBK,IA5C8D,EAC9DP,WAAW,QACXC,aAAa,YACbC,gBAAgB,WAAA,GA0ChBM,IArC8D,EAC9DR,WAAW,MACXC,aAAa,MACbC,gBAAgB,MAAA,GAmChBO,IA9B8D,EAC9DT,WAAW,UACXC,aAAa,UACbC,gBAAgB,eAAA,GA4BhBQ,IAvB8D,EAC9DV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IlC,SAAAA,KAAAA;OAE1C0E,MAAkB7B,MACtBf,GAAQ4B,oBAAoB,EAC3BlC,IAAIU,GAAInC,MACR4D,OAAO,UACPvD,MAAM8B,GAAI9B,MACVD,OAAO0B,KAAK4B,aAAavB,GAAInC,IAAAA,GAC7B+D,SAASlB,EAAcV,GAAInC,IAAAA,GAC3B2B,UAAqB,KAAXQ,GAAIjC,OAAY,IAC1B0E,WAAW,MAAA,MAAM,CAAA;AAAA,IAGpB;AAAA,EACD;AAAA,EAEQ,aAAa5E;AACpB,UAAM6E,KAAM,GAAG7E,EAAAA;AACf,WAAO8B,KAAKD,OAAOgD,EAAAA;AAAAA,EACpB;AAAA,EAGQ,iBACP5E,IAAAA;AAEA,WAAA,CAAK6B,KAAKF,OAAO8C,YACV5C,KAAKF,OAAO8C,QAAQzE,EAAAA,KAAAA;AAAAA,EAC5B;AAAA;AAID,SAAS4C,EAAciC,IAAAA;AACtB,SAAO,SAASA,GAASC,OAAO,CAAA,EAAGC,YAAAA,CAAAA,GAAgBF,GAASG,MAAM,CAAA,CAAA;AACnE;"}
@@ -1,41 +1,46 @@
1
- import { r as e, C as t, a as o, i as r, b as a } from "./ColorValidation-Dyy4Bye8.mjs";
2
- import { r as l } from "./resolvePluginLocale-B4w1OkPy.mjs";
3
- const i = { label: "Text Color", tooltip: "Text Color", resetLabel: "Default", ariaLabelPrefix: "Text color" }, s = { en: i, de: { label: "Textfarbe", tooltip: "Textfarbe", resetLabel: "Standard", ariaLabelPrefix: "Textfarbe" }, es: { label: "Color de texto", tooltip: "Color de texto", resetLabel: "Predeterminado", ariaLabelPrefix: "Color de texto" }, fr: { label: "Couleur du texte", tooltip: "Couleur du texte", resetLabel: "Par défaut", ariaLabelPrefix: "Couleur du texte" }, zh: { label: "文字颜色", tooltip: "文字颜色", resetLabel: "默认", ariaLabelPrefix: "文字颜色" }, ru: { label: "Цвет текста", tooltip: "Цвет текста", resetLabel: "По умолчанию", ariaLabelPrefix: "Цвет текста" }, ar: { label: "لون النص", tooltip: "لون النص", resetLabel: "افتراضي", ariaLabelPrefix: "لون النص" }, hi: { label: "टेक्स्ट रंग", tooltip: "टेक्स्ट रंग", resetLabel: "डिफ़ॉल्ट", ariaLabelPrefix: "टेक्स्ट रंग" } }, f = ["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc", "#d9d9d9", "#efefef", "#f3f3f3", "#ffffff", "#980000", "#ff0000", "#ff9900", "#ffff00", "#00ff00", "#00ffff", "#4a86e8", "#0000ff", "#9900ff", "#ff00ff", "#e6b8af", "#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#c9daf8", "#cfe2f3", "#d9d2e9", "#ead1dc", "#dd7e6b", "#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#a4c2f4", "#9fc5e8", "#b4a7d6", "#d5a6bd", "#cc4125", "#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6d9eeb", "#6fa8dc", "#8e7cc3", "#c27ba0", "#a61c00", "#cc0000", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3c78d8", "#3d85c6", "#674ea7", "#a64d79", "#85200c", "#990000", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#1155cc", "#0b5394", "#351c75", "#741b47"];
4
- class c {
1
+ import { C as e, r as t, i as r, a as o } from "./ColorPickerPopup-xL8ZUfpB.mjs";
2
+ import { r as a } from "./resolvePluginLocale-B4w1OkPy.mjs";
3
+ import { e as l } from "./HTMLUtils-DTqQzcKR.mjs";
4
+ import { r as s, i } from "./ColorNames-BdsHwA2f.mjs";
5
+ const f = { label: "Text Color", tooltip: "Text Color", resetLabel: "Default", ariaLabelPrefix: "Text color" }, c = { en: f, de: { label: "Textfarbe", tooltip: "Textfarbe", resetLabel: "Standard", ariaLabelPrefix: "Textfarbe" }, es: { label: "Color de texto", tooltip: "Color de texto", resetLabel: "Predeterminado", ariaLabelPrefix: "Color de texto" }, fr: { label: "Couleur du texte", tooltip: "Couleur du texte", resetLabel: "Par défaut", ariaLabelPrefix: "Couleur du texte" }, zh: { label: "文字颜色", tooltip: "文字颜色", resetLabel: "默认", ariaLabelPrefix: "文字颜色" }, ru: { label: "Цвет текста", tooltip: "Цвет текста", resetLabel: "По умолчанию", ariaLabelPrefix: "Цвет текста" }, ar: { label: "لون النص", tooltip: "لون النص", resetLabel: "افتراضي", ariaLabelPrefix: "لون النص" }, hi: { label: "टेक्स्ट रंग", tooltip: "टेक्स्ट रंग", resetLabel: "डिफ़ॉल्ट", ariaLabelPrefix: "टेक्स्ट रंग" } }, b = ["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc", "#d9d9d9", "#efefef", "#f3f3f3", "#ffffff", "#980000", "#ff0000", "#ff9900", "#ffff00", "#00ff00", "#00ffff", "#4a86e8", "#0000ff", "#9900ff", "#ff00ff", "#e6b8af", "#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#c9daf8", "#cfe2f3", "#d9d2e9", "#ead1dc", "#dd7e6b", "#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#a4c2f4", "#9fc5e8", "#b4a7d6", "#d5a6bd", "#cc4125", "#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6d9eeb", "#6fa8dc", "#8e7cc3", "#c27ba0", "#a61c00", "#cc0000", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3c78d8", "#3d85c6", "#674ea7", "#a64d79", "#85200c", "#990000", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#1155cc", "#0b5394", "#351c75", "#741b47"];
6
+ class d {
5
7
  id = "textColor";
6
8
  name = "Text Color";
7
9
  priority = 23;
8
10
  config;
9
11
  colors;
10
12
  locale;
11
- constructor(t2) {
12
- this.config = { ...t2 }, this.colors = e(t2?.colors, f, "TextColorPlugin");
13
+ constructor(e2) {
14
+ this.config = { ...e2 }, this.colors = s(e2?.colors, b, "TextColorPlugin");
13
15
  }
14
- init(e2) {
15
- this.locale = l(s, e2, this.config.locale), e2.registerStyleSheet(t), this.registerMarkSpec(e2), this.registerCommands(e2), this.registerToolbarItem(e2);
16
+ init(t2) {
17
+ this.locale = a(c, t2, this.config.locale), t2.registerStyleSheet(e), this.registerMarkSpec(t2), this.registerCommands(t2), this.registerToolbarItem(t2);
16
18
  }
17
19
  registerMarkSpec(e2) {
18
20
  e2.registerMarkSpec({ type: "textColor", rank: 5, attrs: { color: { default: "" } }, toDOM(e3) {
19
- const t2 = document.createElement("span"), o2 = e3.attrs?.color ?? "";
20
- return t2.style.color = o2, t2;
21
- }, toHTMLString: (e3, t2) => `<span style="color: ${String(e3.attrs?.color ?? "")}">${t2}</span>`, parseHTML: [{ tag: "span", getAttrs: (e3) => {
21
+ const t2 = document.createElement("span"), r2 = e3.attrs?.color ?? "";
22
+ return t2.style.color = r2, t2;
23
+ }, toHTMLString: (e3, t2) => {
24
+ const r2 = String(e3.attrs?.color ?? "");
25
+ return r2 && i(r2) ? `<span style="color: ${l(r2)}">${t2}</span>` : t2;
26
+ }, parseHTML: [{ tag: "span", getAttrs: (e3) => {
22
27
  const t2 = e3.style.color;
23
- return !!t2 && { color: t2 };
28
+ return !(!t2 || !i(t2)) && { color: t2 };
24
29
  } }], sanitize: { tags: ["span"] } });
25
30
  }
26
31
  registerCommands(e2) {
27
- e2.registerCommand("removeTextColor", () => o(e2, e2.getState(), "textColor"));
32
+ e2.registerCommand("removeTextColor", () => t(e2, e2.getState(), "textColor"));
28
33
  }
29
34
  registerToolbarItem(e2) {
30
35
  const t2 = ['<svg xmlns="http://www.w3.org/2000/svg"', ' viewBox="0 0 24 24">', '<path d="M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z"/>', '<rect x="3" y="19.5" width="18" height="3"', ' rx="0.5" fill="#e53935"/>', "</svg>"].join("");
31
- e2.registerToolbarItem({ id: "textColor", group: "format", icon: t2, label: this.locale.label, tooltip: this.locale.tooltip, command: "removeTextColor", priority: 45, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (e3, t3, o2) => {
32
- a(e3, t3, { markType: "textColor", colors: this.colors, columns: 10, resetLabel: this.locale.resetLabel, resetCommand: "removeTextColor", ariaLabelPrefix: this.locale.ariaLabelPrefix, onClose: o2 });
36
+ e2.registerToolbarItem({ id: "textColor", group: "format", icon: t2, label: this.locale.label, tooltip: this.locale.tooltip, command: "removeTextColor", priority: 45, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (e3, t3, r2) => {
37
+ o(e3, t3, { markType: "textColor", colors: this.colors, columns: 10, resetLabel: this.locale.resetLabel, resetCommand: "removeTextColor", ariaLabelPrefix: this.locale.ariaLabelPrefix, onClose: r2 });
33
38
  }, isActive: (e3) => r(e3, "textColor") });
34
39
  }
35
40
  }
36
41
  export {
37
- s as T,
38
- i as a,
39
- c as b
42
+ c as T,
43
+ f as a,
44
+ d as b
40
45
  };
41
- //# sourceMappingURL=index-DC1EK22F.mjs.map
46
+ //# sourceMappingURL=index-DIAXWwgJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DIAXWwgJ.mjs","sources":["../../src/plugins/text-color/TextColorLocale.ts","../../src/plugins/text-color/TextColorPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the TextColorPlugin. */\n\n// --- Locale Interface ---\n\nexport interface TextColorLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly resetLabel: string;\n\treadonly ariaLabelPrefix: string;\n}\n\n// --- Default English Locale ---\n\nexport const TEXT_COLOR_LOCALE_EN: TextColorLocale = {\n\tlabel: 'Text Color',\n\ttooltip: 'Text Color',\n\tresetLabel: 'Default',\n\tariaLabelPrefix: 'Text color',\n};\n\n// --- German Locale ---\n\nexport const TEXT_COLOR_LOCALE_DE: TextColorLocale = {\n\tlabel: 'Textfarbe',\n\ttooltip: 'Textfarbe',\n\tresetLabel: 'Standard',\n\tariaLabelPrefix: 'Textfarbe',\n};\n\n// --- Spanish Locale ---\n\nexport const TEXT_COLOR_LOCALE_ES: TextColorLocale = {\n\tlabel: 'Color de texto',\n\ttooltip: 'Color de texto',\n\tresetLabel: 'Predeterminado',\n\tariaLabelPrefix: 'Color de texto',\n};\n\n// --- French Locale ---\n\nexport const TEXT_COLOR_LOCALE_FR: TextColorLocale = {\n\tlabel: 'Couleur du texte',\n\ttooltip: 'Couleur du texte',\n\tresetLabel: 'Par défaut',\n\tariaLabelPrefix: 'Couleur du texte',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const TEXT_COLOR_LOCALE_ZH: TextColorLocale = {\n\tlabel: '文字颜色',\n\ttooltip: '文字颜色',\n\tresetLabel: '默认',\n\tariaLabelPrefix: '文字颜色',\n};\n\n// --- Russian Locale ---\n\nexport const TEXT_COLOR_LOCALE_RU: TextColorLocale = {\n\tlabel: 'Цвет текста',\n\ttooltip: 'Цвет текста',\n\tresetLabel: 'По умолчанию',\n\tariaLabelPrefix: 'Цвет текста',\n};\n\n// --- Arabic Locale ---\n\nexport const TEXT_COLOR_LOCALE_AR: TextColorLocale = {\n\tlabel: 'لون النص',\n\ttooltip: 'لون النص',\n\tresetLabel: 'افتراضي',\n\tariaLabelPrefix: 'لون النص',\n};\n\n// --- Hindi Locale ---\n\nexport const TEXT_COLOR_LOCALE_HI: TextColorLocale = {\n\tlabel: 'टेक्स्ट रंग',\n\ttooltip: 'टेक्स्ट रंग',\n\tresetLabel: 'डिफ़ॉल्ट',\n\tariaLabelPrefix: 'टेक्स्ट रंग',\n};\n\n// --- Locale Map ---\n\nexport const TEXT_COLOR_LOCALES: Record<string, TextColorLocale> = {\n\ten: TEXT_COLOR_LOCALE_EN,\n\tde: TEXT_COLOR_LOCALE_DE,\n\tes: TEXT_COLOR_LOCALE_ES,\n\tfr: TEXT_COLOR_LOCALE_FR,\n\tzh: TEXT_COLOR_LOCALE_ZH,\n\tru: TEXT_COLOR_LOCALE_RU,\n\tar: TEXT_COLOR_LOCALE_AR,\n\thi: TEXT_COLOR_LOCALE_HI,\n};\n","/**\n * TextColorPlugin: registers a text color mark with attrs,\n * toolbar button with a color picker popup, and removeTextColor command.\n */\n\nimport { COLOR_PICKER_CSS } from '../../editor/styles/color-picker.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isColorMarkActive, removeColorMark } from '../shared/ColorMarkOperations.js';\nimport { renderColorPickerPopup } from '../shared/ColorPickerPopup.js';\nimport { isValidCSSColor, resolveColors } from '../shared/ColorValidation.js';\nimport { TEXT_COLOR_LOCALES, type TextColorLocale } from './TextColorLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\ttextColor: { color: string };\n\t}\n}\n\n// --- Configuration ---\n\nexport interface TextColorConfig {\n\t/**\n\t * Restricts the color picker to a specific set of hex colors.\n\t * Each value must be a valid hex color code (`#RGB` or `#RRGGBB`).\n\t * Duplicates are removed automatically (case-insensitive).\n\t * When omitted, the full default palette is shown.\n\t */\n\treadonly colors?: readonly string[];\n\t/** When true, a separator is rendered after the textColor toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: TextColorLocale;\n}\n\n// --- Color Palette (Google Docs style: 10 columns x 7 rows) ---\n\nconst COLOR_PALETTE: readonly string[] = [\n\t// Row 1 — dark\n\t'#000000',\n\t'#434343',\n\t'#666666',\n\t'#999999',\n\t'#b7b7b7',\n\t'#cccccc',\n\t'#d9d9d9',\n\t'#efefef',\n\t'#f3f3f3',\n\t'#ffffff',\n\t// Row 2 — vivid\n\t'#980000',\n\t'#ff0000',\n\t'#ff9900',\n\t'#ffff00',\n\t'#00ff00',\n\t'#00ffff',\n\t'#4a86e8',\n\t'#0000ff',\n\t'#9900ff',\n\t'#ff00ff',\n\t// Row 3 — light 3\n\t'#e6b8af',\n\t'#f4cccc',\n\t'#fce5cd',\n\t'#fff2cc',\n\t'#d9ead3',\n\t'#d0e0e3',\n\t'#c9daf8',\n\t'#cfe2f3',\n\t'#d9d2e9',\n\t'#ead1dc',\n\t// Row 4 — light 2\n\t'#dd7e6b',\n\t'#ea9999',\n\t'#f9cb9c',\n\t'#ffe599',\n\t'#b6d7a8',\n\t'#a2c4c9',\n\t'#a4c2f4',\n\t'#9fc5e8',\n\t'#b4a7d6',\n\t'#d5a6bd',\n\t// Row 5 — light 1\n\t'#cc4125',\n\t'#e06666',\n\t'#f6b26b',\n\t'#ffd966',\n\t'#93c47d',\n\t'#76a5af',\n\t'#6d9eeb',\n\t'#6fa8dc',\n\t'#8e7cc3',\n\t'#c27ba0',\n\t// Row 6 — dark 1\n\t'#a61c00',\n\t'#cc0000',\n\t'#e69138',\n\t'#f1c232',\n\t'#6aa84f',\n\t'#45818e',\n\t'#3c78d8',\n\t'#3d85c6',\n\t'#674ea7',\n\t'#a64d79',\n\t// Row 7 — dark 2\n\t'#85200c',\n\t'#990000',\n\t'#b45f06',\n\t'#bf9000',\n\t'#38761d',\n\t'#134f5c',\n\t'#1155cc',\n\t'#0b5394',\n\t'#351c75',\n\t'#741b47',\n];\n\n// --- Plugin ---\n\nexport class TextColorPlugin implements Plugin {\n\treadonly id = 'textColor';\n\treadonly name = 'Text Color';\n\treadonly priority = 23;\n\n\tprivate readonly config: TextColorConfig;\n\tprivate readonly colors: readonly string[];\n\tprivate locale!: TextColorLocale;\n\n\tconstructor(config?: Partial<TextColorConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.colors = resolveColors(config?.colors, COLOR_PALETTE, 'TextColorPlugin');\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(TEXT_COLOR_LOCALES, context, this.config.locale);\n\n\t\tcontext.registerStyleSheet(COLOR_PICKER_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: 'textColor',\n\t\t\trank: 5,\n\t\t\tattrs: {\n\t\t\t\tcolor: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(mark) {\n\t\t\t\tconst span = document.createElement('span');\n\t\t\t\tconst color = mark.attrs?.color ?? '';\n\t\t\t\tspan.style.color = color;\n\t\t\t\treturn span;\n\t\t\t},\n\t\t\ttoHTMLString: (mark, content) => {\n\t\t\t\tconst color: string = String(mark.attrs?.color ?? '');\n\t\t\t\tif (!color || !isValidCSSColor(color)) return content;\n\t\t\t\treturn `<span style=\"color: ${escapeHTML(color)}\">${content}</span>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'span',\n\t\t\t\t\tgetAttrs: (el) => {\n\t\t\t\t\t\tconst color: string = el.style.color;\n\t\t\t\t\t\tif (!color || !isValidCSSColor(color)) return false;\n\t\t\t\t\t\treturn { color };\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['span'] },\n\t\t});\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeTextColor', () => {\n\t\t\treturn removeColorMark(context, context.getState(), 'textColor');\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst pathD =\n\t\t\t'M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2z' + 'm-1.38 9L12 5.67 14.38 12H9.62z';\n\t\tconst icon: string = [\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\"',\n\t\t\t' viewBox=\"0 0 24 24\">',\n\t\t\t`<path d=\"${pathD}\"/>`,\n\t\t\t'<rect x=\"3\" y=\"19.5\" width=\"18\" height=\"3\"',\n\t\t\t' rx=\"0.5\" fill=\"#e53935\"/>',\n\t\t\t'</svg>',\n\t\t].join('');\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'textColor',\n\t\t\tgroup: 'format',\n\t\t\ticon,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeTextColor',\n\t\t\tpriority: 45,\n\t\t\tpopupType: 'custom',\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderColorPickerPopup(container, ctx, {\n\t\t\t\t\tmarkType: 'textColor',\n\t\t\t\t\tcolors: this.colors,\n\t\t\t\t\tcolumns: 10,\n\t\t\t\t\tresetLabel: this.locale.resetLabel,\n\t\t\t\t\tresetCommand: 'removeTextColor',\n\t\t\t\t\tariaLabelPrefix: this.locale.ariaLabelPrefix,\n\t\t\t\t\tonClose,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state: EditorState) => isColorMarkActive(state, 'textColor'),\n\t\t});\n\t}\n}\n"],"names":["TEXT_COLOR_LOCALE_EN","label","tooltip","resetLabel","ariaLabelPrefix","TEXT_COLOR_LOCALES","en","de","es","fr","zh","ru","ar","hi","COLOR_PALETTE","TextColorPlugin","id","name","priority","config","colors","locale","this","resolveColors","context","resolvePluginLocale","registerStyleSheet","COLOR_PICKER_CSS","registerMarkSpec","registerCommands","registerToolbarItem","type","rank","attrs","color","default","mark","span","document","createElement","style","toHTMLString","content","String","isValidCSSColor","escapeHTML","parseHTML","tag","getAttrs","el","sanitize","tags","registerCommand","removeColorMark","getState","icon","join","group","command","popupType","separatorAfter","renderPopup","container","ctx","onClose","renderColorPickerPopup","markType","columns","resetCommand","isActive","state","isColorMarkActive"],"mappings":";;;;AAaO,MAAMA,IAAwC,EACpDC,OAAO,cACPC,SAAS,cACTC,YAAY,WACZC,iBAAiB,aAAA,GAoELC,IAAsD,EAClEC,IAAIN,GACJO,IAjEoD,EACpDN,OAAO,aACPC,SAAS,aACTC,YAAY,YACZC,iBAAiB,YAAA,GA8DjBI,IAzDoD,EACpDP,OAAO,kBACPC,SAAS,kBACT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