@notectl/core 2.3.1 → 2.3.4

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 (392) hide show
  1. package/README.md +1 -1
  2. package/THIRD-PARTY-NOTICES.md +129 -0
  3. package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs +2 -0
  4. package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs.map +1 -0
  5. package/dist/chunks/{AttrRegistry-B3zB02z9.mjs → AttrRegistry-CtNhf2EF.mjs} +2 -2
  6. package/dist/chunks/{AttrRegistry-B3zB02z9.mjs.map → AttrRegistry-CtNhf2EF.mjs.map} +1 -1
  7. package/dist/chunks/AttributedMarkCommands-B3MQdob_.mjs +2 -0
  8. package/dist/chunks/AttributedMarkCommands-B3MQdob_.mjs.map +1 -0
  9. package/dist/chunks/{BidiIsolationPlugin-DBXyXpgm.mjs → BidiIsolationPlugin-cOLlL3Y9.mjs} +2 -2
  10. package/dist/chunks/{BidiIsolationPlugin-DBXyXpgm.mjs.map → BidiIsolationPlugin-cOLlL3Y9.mjs.map} +1 -1
  11. package/dist/chunks/BlockInsertion-O5pAFKid.mjs +2 -0
  12. package/dist/chunks/{BlockInsertion-CJusvrDL.mjs.map → BlockInsertion-O5pAFKid.mjs.map} +1 -1
  13. package/dist/chunks/BlockquotePlugin-D-jRWLQB.mjs +2 -0
  14. package/dist/chunks/{BlockquotePlugin-Bz2glHwX.mjs.map → BlockquotePlugin-D-jRWLQB.mjs.map} +1 -1
  15. package/dist/chunks/CaretNavigationPlugin-Clv8dzR5.mjs +2 -0
  16. package/dist/chunks/CaretNavigationPlugin-Clv8dzR5.mjs.map +1 -0
  17. package/dist/chunks/CodeBlockPlugin-BandNM3t.mjs +2 -0
  18. package/dist/chunks/{CodeBlockPlugin-C1hrdbSZ.mjs.map → CodeBlockPlugin-BandNM3t.mjs.map} +1 -1
  19. package/dist/chunks/ColorGrid-D0vLHsG6.mjs +2 -0
  20. package/dist/chunks/{ColorGrid-C9RQoEWF.mjs.map → ColorGrid-D0vLHsG6.mjs.map} +1 -1
  21. package/dist/chunks/ColorPickerPopup-_C5JZhki.mjs +2 -0
  22. package/dist/chunks/{ColorPickerPopup-DiA68Pzz.mjs.map → ColorPickerPopup-_C5JZhki.mjs.map} +1 -1
  23. package/dist/chunks/ColorValidation-B9d_umnf.mjs +2 -0
  24. package/dist/chunks/{ColorValidation-DAijTjG9.mjs.map → ColorValidation-B9d_umnf.mjs.map} +1 -1
  25. package/dist/chunks/Commands-D-0UXYvo.mjs +2 -0
  26. package/dist/chunks/Commands-D-0UXYvo.mjs.map +1 -0
  27. package/dist/chunks/ContentModel-Bzmzeqwg.mjs +2 -0
  28. package/dist/chunks/{ContentModel-NpAj7vGW.mjs.map → ContentModel-Bzmzeqwg.mjs.map} +1 -1
  29. package/dist/chunks/CursorMarks-dx51OGBf.mjs +2 -0
  30. package/dist/chunks/CursorMarks-dx51OGBf.mjs.map +1 -0
  31. package/dist/chunks/Decoration-BwhoA4MU.mjs +3 -0
  32. package/dist/chunks/Decoration-BwhoA4MU.mjs.map +1 -0
  33. package/dist/chunks/{DirectionDetection-CDVSEWQ6.mjs → DirectionDetection-ZrkMhyaL.mjs} +2 -2
  34. package/dist/chunks/{DirectionDetection-CDVSEWQ6.mjs.map → DirectionDetection-ZrkMhyaL.mjs.map} +1 -1
  35. package/dist/chunks/Document-D_2cIBJG.mjs +2 -0
  36. package/dist/chunks/Document-D_2cIBJG.mjs.map +1 -0
  37. package/dist/chunks/DocumentParser-i-CreJ48.mjs +2 -0
  38. package/dist/chunks/DocumentParser-i-CreJ48.mjs.map +1 -0
  39. package/dist/chunks/{FontPlugin-By-TGrQo.mjs → FontPlugin-B4Ouhmpe.mjs} +2 -2
  40. package/dist/chunks/{FontPlugin-By-TGrQo.mjs.map → FontPlugin-B4Ouhmpe.mjs.map} +1 -1
  41. package/dist/chunks/FontSizePlugin-CZB-AwZQ.mjs +2 -0
  42. package/dist/chunks/{FontSizePlugin-Dln-tYXV.mjs.map → FontSizePlugin-CZB-AwZQ.mjs.map} +1 -1
  43. package/dist/chunks/FormulaPlugin-C7N3QXDx.mjs +2 -0
  44. package/dist/chunks/FormulaPlugin-C7N3QXDx.mjs.map +1 -0
  45. package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs +2 -0
  46. package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs.map +1 -0
  47. package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs +2 -0
  48. package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs.map +1 -0
  49. package/dist/chunks/HTMLUtils-B0nGyFLb.mjs +2 -0
  50. package/dist/chunks/{HTMLUtils-Bhg3_P8B.mjs.map → HTMLUtils-B0nGyFLb.mjs.map} +1 -1
  51. package/dist/chunks/HardBreakPlugin-CC4rntSX.mjs +2 -0
  52. package/dist/chunks/{HardBreakPlugin-DlbSlrdq.mjs.map → HardBreakPlugin-CC4rntSX.mjs.map} +1 -1
  53. package/dist/chunks/HeadingPlugin-hubN_Ebt.mjs +2 -0
  54. package/dist/chunks/{HeadingPlugin-uMAjPOk5.mjs.map → HeadingPlugin-hubN_Ebt.mjs.map} +1 -1
  55. package/dist/chunks/{HighlightPlugin-Bj7FPkIQ.mjs → HighlightPlugin-CE_MgFNz.mjs} +2 -2
  56. package/dist/chunks/{HighlightPlugin-Bj7FPkIQ.mjs.map → HighlightPlugin-CE_MgFNz.mjs.map} +1 -1
  57. package/dist/chunks/{HorizontalRulePlugin-DUVmTQpX.mjs → HorizontalRulePlugin-CxmUMM34.mjs} +2 -2
  58. package/dist/chunks/{HorizontalRulePlugin-DUVmTQpX.mjs.map → HorizontalRulePlugin-CxmUMM34.mjs.map} +1 -1
  59. package/dist/chunks/{ImagePlugin-FToCOjd5.mjs → ImagePlugin-B_y4STEr.mjs} +2 -2
  60. package/dist/chunks/{ImagePlugin-FToCOjd5.mjs.map → ImagePlugin-B_y4STEr.mjs.map} +1 -1
  61. package/dist/chunks/InlineCodePlugin-C1SqGfv5.mjs +2 -0
  62. package/dist/chunks/{InlineCodePlugin-pISIoGQE.mjs.map → InlineCodePlugin-C1SqGfv5.mjs.map} +1 -1
  63. package/dist/chunks/{InlineStyleMarkSpec-CjSRj4f_.mjs → InlineStyleMarkSpec-Cx3goc3W.mjs} +2 -2
  64. package/dist/chunks/{InlineStyleMarkSpec-CjSRj4f_.mjs.map → InlineStyleMarkSpec-Cx3goc3W.mjs.map} +1 -1
  65. package/dist/chunks/{LinkPlugin-Ct5Z180S.mjs → LinkPlugin-BwXDGHPe.mjs} +2 -2
  66. package/dist/chunks/{LinkPlugin-Ct5Z180S.mjs.map → LinkPlugin-BwXDGHPe.mjs.map} +1 -1
  67. package/dist/chunks/ListPlugin-DSFPSWQC.mjs +2 -0
  68. package/dist/chunks/ListPlugin-DSFPSWQC.mjs.map +1 -0
  69. package/dist/chunks/MarkCommands-CJvLGL5G.mjs +2 -0
  70. package/dist/chunks/MarkCommands-CJvLGL5G.mjs.map +1 -0
  71. package/dist/chunks/{MarkInputRule-Bdi8KPus.mjs → MarkInputRule-DNneF2gp.mjs} +2 -2
  72. package/dist/chunks/{MarkInputRule-Bdi8KPus.mjs.map → MarkInputRule-DNneF2gp.mjs.map} +1 -1
  73. package/dist/chunks/MarkdownHTMLRegistry-CISsC0lH.mjs +2 -0
  74. package/dist/chunks/{MarkdownHTMLRegistry-CKEx7LkR.mjs.map → MarkdownHTMLRegistry-CISsC0lH.mjs.map} +1 -1
  75. package/dist/chunks/MarkdownParser-D1d9zB0R.mjs +2 -0
  76. package/dist/chunks/{MarkdownParser-CWt3M6jR.mjs.map → MarkdownParser-D1d9zB0R.mjs.map} +1 -1
  77. package/dist/chunks/MarkdownSerializer-Oex2RzNw.mjs +2 -0
  78. package/dist/chunks/{MarkdownSerializer-J-i28out.mjs.map → MarkdownSerializer-Oex2RzNw.mjs.map} +1 -1
  79. package/dist/chunks/MathFont-BS8IwYh2.mjs +2 -0
  80. package/dist/chunks/MathFont-BS8IwYh2.mjs.map +1 -0
  81. package/dist/chunks/{NodeResolver-Dleih-8R.mjs → NodeResolver-BtIknXqD.mjs} +2 -2
  82. package/dist/chunks/{NodeResolver-Dleih-8R.mjs.map → NodeResolver-BtIknXqD.mjs.map} +1 -1
  83. package/dist/chunks/NodeSelectionCommands-DK3iEh18.mjs +2 -0
  84. package/dist/chunks/{NodeSelectionCommands-1PjwUDTJ.mjs.map → NodeSelectionCommands-DK3iEh18.mjs.map} +1 -1
  85. package/dist/chunks/NodeSpecPatching-BrjPAbqe.mjs +2 -0
  86. package/dist/chunks/NodeSpecPatching-BrjPAbqe.mjs.map +1 -0
  87. package/dist/chunks/PluginHelpers-WG1Lzzh3.mjs +2 -0
  88. package/dist/chunks/{PluginHelpers-Dx_0hfDe.mjs.map → PluginHelpers-WG1Lzzh3.mjs.map} +1 -1
  89. package/dist/chunks/PopupKeyboardPatterns-BcwdDxRq.mjs +2 -0
  90. package/dist/chunks/{PopupKeyboardPatterns-tUrT9TyV.mjs.map → PopupKeyboardPatterns-BcwdDxRq.mjs.map} +1 -1
  91. package/dist/chunks/PopupManager-Jz5JrUdC.mjs +2 -0
  92. package/dist/chunks/{PopupManager-CT-fMZJn.mjs.map → PopupManager-Jz5JrUdC.mjs.map} +1 -1
  93. package/dist/chunks/{PopupPositioning-BFh6Ed1D.mjs → PopupPositioning-CIqgpqlW.mjs} +2 -2
  94. package/dist/chunks/{PopupPositioning-BFh6Ed1D.mjs.map → PopupPositioning-CIqgpqlW.mjs.map} +1 -1
  95. package/dist/chunks/PrintPlugin-1m54b2-Y.mjs +2 -0
  96. package/dist/chunks/PrintPlugin-1m54b2-Y.mjs.map +1 -0
  97. package/dist/chunks/{RangeIterator-DP7Ud3Gp.mjs → RangeIterator-DDOxTQIf.mjs} +2 -2
  98. package/dist/chunks/{RangeIterator-DP7Ud3Gp.mjs.map → RangeIterator-DDOxTQIf.mjs.map} +1 -1
  99. package/dist/chunks/SchemaRegistry-acc6q_5x.mjs +2 -0
  100. package/dist/chunks/SchemaRegistry-acc6q_5x.mjs.map +1 -0
  101. package/dist/chunks/Selection-DC6AOGgF.mjs +2 -0
  102. package/dist/chunks/Selection-DC6AOGgF.mjs.map +1 -0
  103. package/dist/chunks/{SelectionSync-BSHIw1EE.mjs → SelectionSync-CcvoRrNd.mjs} +2 -2
  104. package/dist/chunks/{SelectionSync-BSHIw1EE.mjs.map → SelectionSync-CcvoRrNd.mjs.map} +1 -1
  105. package/dist/chunks/SelectionTransactions-DNCzsl_b.mjs +2 -0
  106. package/dist/chunks/SelectionTransactions-DNCzsl_b.mjs.map +1 -0
  107. package/dist/chunks/SimpleMark-CTDtEIMV.mjs +2 -0
  108. package/dist/chunks/{SimpleMark-7CQcA4RK.mjs.map → SimpleMark-CTDtEIMV.mjs.map} +1 -1
  109. package/dist/chunks/SmartPastePlugin-CjExbE9Q.mjs +2 -0
  110. package/dist/chunks/SmartPastePlugin-CjExbE9Q.mjs.map +1 -0
  111. package/dist/chunks/StarterFonts-BDQPg-cu.mjs +2 -0
  112. package/dist/chunks/StarterFonts-BDQPg-cu.mjs.map +1 -0
  113. package/dist/chunks/{StrikethroughPlugin-C2oWvGc3.mjs → StrikethroughPlugin-d-EW2YYx.mjs} +2 -2
  114. package/dist/chunks/{StrikethroughPlugin-C2oWvGc3.mjs.map → StrikethroughPlugin-d-EW2YYx.mjs.map} +1 -1
  115. package/dist/chunks/StyleRuntime-C0RSqKzG.mjs +2 -0
  116. package/dist/chunks/{StyleRuntime-DW6omotc.mjs.map → StyleRuntime-C0RSqKzG.mjs.map} +1 -1
  117. package/dist/chunks/SuperSubPlugin-C-kvFQyx.mjs +2 -0
  118. package/dist/chunks/{SuperSubPlugin-D1xaKrSu.mjs.map → SuperSubPlugin-C-kvFQyx.mjs.map} +1 -1
  119. package/dist/chunks/TableDimensions-BcARMxQB.mjs +2 -0
  120. package/dist/chunks/TableDimensions-BcARMxQB.mjs.map +1 -0
  121. package/dist/chunks/TablePlugin-B894cIXW.mjs +2 -0
  122. package/dist/chunks/{TablePlugin-PJe3zwr-.mjs.map → TablePlugin-B894cIXW.mjs.map} +1 -1
  123. package/dist/chunks/{TextColorPlugin-CTd9tfeG.mjs → TextColorPlugin-B6YoN9mR.mjs} +2 -2
  124. package/dist/chunks/{TextColorPlugin-CTd9tfeG.mjs.map → TextColorPlugin-B6YoN9mR.mjs.map} +1 -1
  125. package/dist/chunks/TextDirectionAutoPlugin-LVDkKdDX.mjs +2 -0
  126. package/dist/chunks/{TextDirectionAutoPlugin-CPnKVVuI.mjs.map → TextDirectionAutoPlugin-LVDkKdDX.mjs.map} +1 -1
  127. package/dist/chunks/TextDirectionPlugin-CtGwof7i.mjs +2 -0
  128. package/dist/chunks/TextDirectionPlugin-CtGwof7i.mjs.map +1 -0
  129. package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +2 -0
  130. package/dist/chunks/{TextDirectionService-BcX07mw2.mjs.map → TextDirectionService-OFOU6r_s.mjs.map} +1 -1
  131. package/dist/chunks/TextFormattingPlugin-DlS0SeW7.mjs +2 -0
  132. package/dist/chunks/{TextFormattingPlugin-DBVlePqj.mjs.map → TextFormattingPlugin-DlS0SeW7.mjs.map} +1 -1
  133. package/dist/chunks/ThemeEngine-D4W6Y80e.mjs +3 -0
  134. package/dist/chunks/ThemeEngine-D4W6Y80e.mjs.map +1 -0
  135. package/dist/chunks/ToolbarPlugin-ClKY-LiT.mjs +2 -0
  136. package/dist/chunks/{ToolbarPlugin-DtfGTO_V.mjs.map → ToolbarPlugin-ClKY-LiT.mjs.map} +1 -1
  137. package/dist/chunks/VideoPlugin-C9z4JfP_.mjs +2 -0
  138. package/dist/chunks/VideoPlugin-C9z4JfP_.mjs.map +1 -0
  139. package/dist/chunks/XmlSupport-3Za6SIqF.mjs +2 -0
  140. package/dist/chunks/XmlSupport-3Za6SIqF.mjs.map +1 -0
  141. package/dist/chunks/full-CNi2CaF3.mjs +2 -0
  142. package/dist/chunks/{full-DSWM4cKQ.mjs.map → full-CNi2CaF3.mjs.map} +1 -1
  143. package/dist/chunks/minimal-Bykbo9So.mjs +2 -0
  144. package/dist/chunks/{minimal-CFkkPXef.mjs.map → minimal-Bykbo9So.mjs.map} +1 -1
  145. package/dist/chunks/register-CF80zDgl.mjs +3 -0
  146. package/dist/chunks/register-CF80zDgl.mjs.map +1 -0
  147. package/dist/chunks/src-5GKFQ2mQ.mjs +2 -0
  148. package/dist/chunks/src-5GKFQ2mQ.mjs.map +1 -0
  149. package/dist/chunks/xml-BsV44TrJ.mjs +2 -0
  150. package/dist/chunks/xml-BsV44TrJ.mjs.map +1 -0
  151. package/dist/decorations/Decoration.d.ts +9 -0
  152. package/dist/decorations/Decoration.d.ts.map +1 -1
  153. package/dist/editor/ContentSerializer.d.ts +2 -7
  154. package/dist/editor/ContentSerializer.d.ts.map +1 -1
  155. package/dist/editor/EditorEventEmitter.d.ts +10 -2
  156. package/dist/editor/EditorEventEmitter.d.ts.map +1 -1
  157. package/dist/editor/EditorInitializer.d.ts +2 -4
  158. package/dist/editor/EditorInitializer.d.ts.map +1 -1
  159. package/dist/editor/EditorLifecycleCoordinator.d.ts +16 -1
  160. package/dist/editor/EditorLifecycleCoordinator.d.ts.map +1 -1
  161. package/dist/editor/EditorStyleCoordinator.d.ts +11 -3
  162. package/dist/editor/EditorStyleCoordinator.d.ts.map +1 -1
  163. package/dist/editor/NotectlEditor.d.ts +15 -3
  164. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  165. package/dist/fonts/math.d.ts +3 -0
  166. package/dist/fonts/math.d.ts.map +1 -0
  167. package/dist/fonts/math.mjs +1 -0
  168. package/dist/fonts/starter.d.ts +3 -0
  169. package/dist/fonts/starter.d.ts.map +1 -0
  170. package/dist/fonts/starter.mjs +1 -0
  171. package/dist/fonts.d.ts +4 -4
  172. package/dist/fonts.mjs +1 -1
  173. package/dist/full.d.ts +1 -1
  174. package/dist/full.mjs +1 -1
  175. package/dist/html.mjs +1 -1
  176. package/dist/index.d.ts +5 -3
  177. package/dist/index.d.ts.map +1 -1
  178. package/dist/input/InputHandler.d.ts +4 -0
  179. package/dist/input/InputHandler.d.ts.map +1 -1
  180. package/dist/input/InputManager.d.ts +5 -0
  181. package/dist/input/InputManager.d.ts.map +1 -1
  182. package/dist/input/KeyboardHandler.d.ts +4 -0
  183. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  184. package/dist/input/PasteHTMLHandler.d.ts +7 -4
  185. package/dist/input/PasteHTMLHandler.d.ts.map +1 -1
  186. package/dist/input/PasteHandler.d.ts +33 -6
  187. package/dist/input/PasteHandler.d.ts.map +1 -1
  188. package/dist/input/PasteRichBlockHandler.d.ts +3 -2
  189. package/dist/input/PasteRichBlockHandler.d.ts.map +1 -1
  190. package/dist/markdown.mjs +1 -1
  191. package/dist/model/Document.d.ts +42 -0
  192. package/dist/model/Document.d.ts.map +1 -1
  193. package/dist/model/DocumentNormalization.d.ts +10 -0
  194. package/dist/model/DocumentNormalization.d.ts.map +1 -0
  195. package/dist/model/FileHandlerDispatcher.d.ts +27 -0
  196. package/dist/model/FileHandlerDispatcher.d.ts.map +1 -0
  197. package/dist/model/FileHandlerRegistry.d.ts +6 -1
  198. package/dist/model/FileHandlerRegistry.d.ts.map +1 -1
  199. package/dist/model/InputRuleRegistry.d.ts +9 -1
  200. package/dist/model/InputRuleRegistry.d.ts.map +1 -1
  201. package/dist/model/KeymapRegistry.d.ts +14 -1
  202. package/dist/model/KeymapRegistry.d.ts.map +1 -1
  203. package/dist/model/MarkdownSyntaxRegistry.d.ts +2 -0
  204. package/dist/model/MarkdownSyntaxRegistry.d.ts.map +1 -1
  205. package/dist/model/PluginCallbackExecutor.d.ts +44 -0
  206. package/dist/model/PluginCallbackExecutor.d.ts.map +1 -0
  207. package/dist/model/SanitizeConfig.d.ts +8 -0
  208. package/dist/model/SanitizeConfig.d.ts.map +1 -1
  209. package/dist/model/SchemaRegistry.d.ts +24 -0
  210. package/dist/model/SchemaRegistry.d.ts.map +1 -1
  211. package/dist/model/Selection.d.ts +4 -0
  212. package/dist/model/Selection.d.ts.map +1 -1
  213. package/dist/notectl-core.mjs +1 -1
  214. package/dist/notectl-core.umd.js +1 -1
  215. package/dist/notectl-core.umd.js.map +1 -1
  216. package/dist/plugins/Plugin.d.ts +3 -1
  217. package/dist/plugins/Plugin.d.ts.map +1 -1
  218. package/dist/plugins/PluginContextFactory.d.ts +9 -2
  219. package/dist/plugins/PluginContextFactory.d.ts.map +1 -1
  220. package/dist/plugins/PluginLifecycle.d.ts +6 -0
  221. package/dist/plugins/PluginLifecycle.d.ts.map +1 -1
  222. package/dist/plugins/PluginManager.d.ts +9 -2
  223. package/dist/plugins/PluginManager.d.ts.map +1 -1
  224. package/dist/plugins/RegistrationTracker.d.ts +2 -0
  225. package/dist/plugins/RegistrationTracker.d.ts.map +1 -1
  226. package/dist/plugins/alignment.mjs +1 -1
  227. package/dist/plugins/bidi-isolation.mjs +1 -1
  228. package/dist/plugins/blockquote.mjs +1 -1
  229. package/dist/plugins/caret-navigation.mjs +1 -1
  230. package/dist/plugins/code-block/CodeBlockHighlighting.d.ts.map +1 -1
  231. package/dist/plugins/code-block/CodeBlockSchema.d.ts +6 -2
  232. package/dist/plugins/code-block/CodeBlockSchema.d.ts.map +1 -1
  233. package/dist/plugins/code-block.mjs +1 -1
  234. package/dist/plugins/font-size.mjs +1 -1
  235. package/dist/plugins/font.mjs +1 -1
  236. package/dist/plugins/formula/FormulaPasteInterceptor.d.ts.map +1 -1
  237. package/dist/plugins/formula/FormulaTypes.d.ts +1 -1
  238. package/dist/plugins/formula.mjs +1 -1
  239. package/dist/plugins/gap-cursor.mjs +1 -1
  240. package/dist/plugins/hard-break.mjs +1 -1
  241. package/dist/plugins/heading.mjs +1 -1
  242. package/dist/plugins/highlight.mjs +1 -1
  243. package/dist/plugins/horizontal-rule.mjs +1 -1
  244. package/dist/plugins/image.mjs +1 -1
  245. package/dist/plugins/inline-code.mjs +1 -1
  246. package/dist/plugins/language.mjs +1 -1
  247. package/dist/plugins/link.mjs +1 -1
  248. package/dist/plugins/list/ListCommands.d.ts.map +1 -1
  249. package/dist/plugins/list/ListPlugin.d.ts +9 -0
  250. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  251. package/dist/plugins/list.mjs +1 -1
  252. package/dist/plugins/print.mjs +1 -1
  253. package/dist/plugins/shared/NodeSpecPatching.d.ts +2 -2
  254. package/dist/plugins/shared/NodeSpecPatching.d.ts.map +1 -1
  255. package/dist/plugins/shared.mjs +1 -1
  256. package/dist/plugins/smart-paste/SmartPastePlugin.d.ts.map +1 -1
  257. package/dist/plugins/smart-paste.mjs +1 -1
  258. package/dist/plugins/strikethrough.mjs +1 -1
  259. package/dist/plugins/super-sub.mjs +1 -1
  260. package/dist/plugins/table.mjs +1 -1
  261. package/dist/plugins/text-color.mjs +1 -1
  262. package/dist/plugins/text-direction-auto.mjs +1 -1
  263. package/dist/plugins/text-direction.mjs +1 -1
  264. package/dist/plugins/text-formatting.mjs +1 -1
  265. package/dist/plugins/toolbar.mjs +1 -1
  266. package/dist/plugins/video/VideoNodeSpec.d.ts.map +1 -1
  267. package/dist/plugins/video/VideoPlugin.d.ts.map +1 -1
  268. package/dist/plugins/video/VideoProviders.d.ts +3 -3
  269. package/dist/plugins/video/VideoSanitizeHook.d.ts +4 -20
  270. package/dist/plugins/video/VideoSanitizeHook.d.ts.map +1 -1
  271. package/dist/plugins/video.mjs +1 -1
  272. package/dist/presets/full.d.ts +1 -1
  273. package/dist/presets/full.mjs +1 -1
  274. package/dist/presets/minimal.d.ts +1 -1
  275. package/dist/presets/minimal.mjs +1 -1
  276. package/dist/presets.d.ts +1 -1
  277. package/dist/presets.mjs +1 -1
  278. package/dist/register.d.ts +3 -0
  279. package/dist/register.d.ts.map +1 -0
  280. package/dist/register.mjs +1 -0
  281. package/dist/serialization/DocumentParser.d.ts.map +1 -1
  282. package/dist/serialization/DocumentSerializer.d.ts.map +1 -1
  283. package/dist/serialization/HTMLSanitization.d.ts +12 -0
  284. package/dist/serialization/HTMLSanitization.d.ts.map +1 -1
  285. package/dist/state/EditorState.d.ts.map +1 -1
  286. package/dist/state/History.d.ts.map +1 -1
  287. package/dist/state/Mapping.d.ts +2 -0
  288. package/dist/state/Mapping.d.ts.map +1 -1
  289. package/dist/state/StepHandlers.d.ts.map +1 -1
  290. package/dist/state/TransactionBuilder.d.ts +2 -0
  291. package/dist/state/TransactionBuilder.d.ts.map +1 -1
  292. package/dist/state/TransactionFinalizer.d.ts +10 -0
  293. package/dist/state/TransactionFinalizer.d.ts.map +1 -0
  294. package/dist/state/TransactionSnapshot.d.ts +32 -0
  295. package/dist/state/TransactionSnapshot.d.ts.map +1 -0
  296. package/dist/test/TestUtils.d.ts.map +1 -1
  297. package/dist/view/BlockRendering.d.ts +13 -2
  298. package/dist/view/BlockRendering.d.ts.map +1 -1
  299. package/dist/view/DecorationRendering.d.ts +19 -8
  300. package/dist/view/DecorationRendering.d.ts.map +1 -1
  301. package/dist/view/EditorView.d.ts +4 -0
  302. package/dist/view/EditorView.d.ts.map +1 -1
  303. package/dist/view/EditorViewEvents.d.ts +8 -0
  304. package/dist/view/EditorViewEvents.d.ts.map +1 -1
  305. package/dist/view/NodeViewCallbackBoundary.d.ts +12 -0
  306. package/dist/view/NodeViewCallbackBoundary.d.ts.map +1 -0
  307. package/dist/view/NodeViewOwnership.d.ts +12 -0
  308. package/dist/view/NodeViewOwnership.d.ts.map +1 -0
  309. package/dist/view/NodeViewRegistry.d.ts +7 -1
  310. package/dist/view/NodeViewRegistry.d.ts.map +1 -1
  311. package/dist/view/Reconciler.d.ts +6 -0
  312. package/dist/view/Reconciler.d.ts.map +1 -1
  313. package/package.json +29 -228
  314. package/dist/chunks/AlignmentPlugin--xAFlRqE.mjs +0 -2
  315. package/dist/chunks/AlignmentPlugin--xAFlRqE.mjs.map +0 -1
  316. package/dist/chunks/AttributedMarkCommands-bagbH8Qt.mjs +0 -2
  317. package/dist/chunks/AttributedMarkCommands-bagbH8Qt.mjs.map +0 -1
  318. package/dist/chunks/BlockInsertion-CJusvrDL.mjs +0 -2
  319. package/dist/chunks/BlockquotePlugin-Bz2glHwX.mjs +0 -2
  320. package/dist/chunks/CaretNavigationPlugin-CNsT0eb4.mjs +0 -2
  321. package/dist/chunks/CaretNavigationPlugin-CNsT0eb4.mjs.map +0 -1
  322. package/dist/chunks/CodeBlockPlugin-C1hrdbSZ.mjs +0 -2
  323. package/dist/chunks/ColorGrid-C9RQoEWF.mjs +0 -2
  324. package/dist/chunks/ColorPickerPopup-DiA68Pzz.mjs +0 -2
  325. package/dist/chunks/ColorValidation-DAijTjG9.mjs +0 -2
  326. package/dist/chunks/Commands-1dFFldi7.mjs +0 -2
  327. package/dist/chunks/Commands-1dFFldi7.mjs.map +0 -1
  328. package/dist/chunks/ContentModel-NpAj7vGW.mjs +0 -2
  329. package/dist/chunks/Decoration-BpoEOANl.mjs +0 -2
  330. package/dist/chunks/Decoration-BpoEOANl.mjs.map +0 -1
  331. package/dist/chunks/Document-827l3P80.mjs +0 -2
  332. package/dist/chunks/Document-827l3P80.mjs.map +0 -1
  333. package/dist/chunks/DocumentParser-D2tr3ZKn.mjs +0 -2
  334. package/dist/chunks/DocumentParser-D2tr3ZKn.mjs.map +0 -1
  335. package/dist/chunks/FontSizePlugin-Dln-tYXV.mjs +0 -2
  336. package/dist/chunks/FormulaPlugin-By1befrR.mjs +0 -2
  337. package/dist/chunks/FormulaPlugin-By1befrR.mjs.map +0 -1
  338. package/dist/chunks/GapCursorNavigation-BuXngVu-.mjs +0 -2
  339. package/dist/chunks/GapCursorNavigation-BuXngVu-.mjs.map +0 -1
  340. package/dist/chunks/GapCursorPlugin-DAxVzXRs.mjs +0 -2
  341. package/dist/chunks/GapCursorPlugin-DAxVzXRs.mjs.map +0 -1
  342. package/dist/chunks/HTMLUtils-Bhg3_P8B.mjs +0 -2
  343. package/dist/chunks/HardBreakPlugin-DlbSlrdq.mjs +0 -2
  344. package/dist/chunks/HeadingPlugin-uMAjPOk5.mjs +0 -2
  345. package/dist/chunks/InlineCodePlugin-pISIoGQE.mjs +0 -2
  346. package/dist/chunks/ListPlugin-DAY5ezNs.mjs +0 -2
  347. package/dist/chunks/ListPlugin-DAY5ezNs.mjs.map +0 -1
  348. package/dist/chunks/MarkdownHTMLRegistry-CKEx7LkR.mjs +0 -2
  349. package/dist/chunks/MarkdownParser-CWt3M6jR.mjs +0 -2
  350. package/dist/chunks/MarkdownSerializer-J-i28out.mjs +0 -2
  351. package/dist/chunks/NodeSelectionCommands-1PjwUDTJ.mjs +0 -2
  352. package/dist/chunks/NodeSpecPatching-B_yLknTl.mjs +0 -2
  353. package/dist/chunks/NodeSpecPatching-B_yLknTl.mjs.map +0 -1
  354. package/dist/chunks/PluginHelpers-Dx_0hfDe.mjs +0 -2
  355. package/dist/chunks/PopupKeyboardPatterns-tUrT9TyV.mjs +0 -2
  356. package/dist/chunks/PopupManager-CT-fMZJn.mjs +0 -2
  357. package/dist/chunks/PrintPlugin-7zz9mhhU.mjs +0 -2
  358. package/dist/chunks/PrintPlugin-7zz9mhhU.mjs.map +0 -1
  359. package/dist/chunks/PrintTypes-CxU69qu3.mjs +0 -3
  360. package/dist/chunks/PrintTypes-CxU69qu3.mjs.map +0 -1
  361. package/dist/chunks/SchemaRegistry-CkBN-1yW.mjs +0 -2
  362. package/dist/chunks/SchemaRegistry-CkBN-1yW.mjs.map +0 -1
  363. package/dist/chunks/Selection-HYoVFpAx.mjs +0 -2
  364. package/dist/chunks/Selection-HYoVFpAx.mjs.map +0 -1
  365. package/dist/chunks/SimpleMark-7CQcA4RK.mjs +0 -2
  366. package/dist/chunks/SmartPastePlugin-CYa_nD9v.mjs +0 -2
  367. package/dist/chunks/SmartPastePlugin-CYa_nD9v.mjs.map +0 -1
  368. package/dist/chunks/StyleRuntime-DW6omotc.mjs +0 -2
  369. package/dist/chunks/SuperSubPlugin-D1xaKrSu.mjs +0 -2
  370. package/dist/chunks/TableDimensions-BBhjHNjQ.mjs +0 -2
  371. package/dist/chunks/TableDimensions-BBhjHNjQ.mjs.map +0 -1
  372. package/dist/chunks/TablePlugin-PJe3zwr-.mjs +0 -2
  373. package/dist/chunks/TextDirectionAutoPlugin-CPnKVVuI.mjs +0 -2
  374. package/dist/chunks/TextDirectionPlugin-Bns_03vL.mjs +0 -2
  375. package/dist/chunks/TextDirectionPlugin-Bns_03vL.mjs.map +0 -1
  376. package/dist/chunks/TextDirectionService-BcX07mw2.mjs +0 -2
  377. package/dist/chunks/TextFormattingPlugin-DBVlePqj.mjs +0 -2
  378. package/dist/chunks/ToolbarPlugin-DtfGTO_V.mjs +0 -2
  379. package/dist/chunks/VideoPlugin-BrR8g6Rz.mjs +0 -2
  380. package/dist/chunks/VideoPlugin-BrR8g6Rz.mjs.map +0 -1
  381. package/dist/chunks/WordBoundary-CFpIJDNP.mjs +0 -2
  382. package/dist/chunks/WordBoundary-CFpIJDNP.mjs.map +0 -1
  383. package/dist/chunks/XmlDetector-D7TQpw-e.mjs +0 -2
  384. package/dist/chunks/XmlDetector-D7TQpw-e.mjs.map +0 -1
  385. package/dist/chunks/XmlSupport-BYiRwlkK.mjs +0 -2
  386. package/dist/chunks/XmlSupport-BYiRwlkK.mjs.map +0 -1
  387. package/dist/chunks/fonts-DQC6Uj4r.mjs +0 -2
  388. package/dist/chunks/fonts-DQC6Uj4r.mjs.map +0 -1
  389. package/dist/chunks/full-DSWM4cKQ.mjs +0 -2
  390. package/dist/chunks/minimal-CFkkPXef.mjs +0 -2
  391. package/dist/chunks/src-DiAOfuOT.mjs +0 -2
  392. package/dist/chunks/src-DiAOfuOT.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableDimensions-BBhjHNjQ.mjs","names":[],"sources":["../../src/serialization/BlockIdHTML.ts","../../src/serialization/CSSClassCollector.ts","../../src/serialization/HTMLSanitization.ts","../../src/serialization/MarkSerializer.ts","../../src/serialization/DocumentSerializer.ts","../../src/model/TableDimensions.ts","../../src/serialization/TableDimensions.ts"],"sourcesContent":["/**\n * Shared rules for the `data-block-id` HTML wire format.\n *\n * Block identity round-trips through `getContentHTML` → `setContentHTML` so the\n * caret-preserving `EditorView.replaceState()` keeps the cursor on the same block\n * across content sync (Angular signal forms, RxJS pipes — see ARCHITECTURE §9.2).\n * Both serializer and parser must agree on the same shape; this module is the\n * single source of truth.\n */\n\nimport { type BlockId, blockId } from '../model/TypeBrands.js';\n\n/**\n * Conservative pattern for `data-block-id` values: alphanumeric, underscore,\n * hyphen, max 64 chars. Defense-in-depth — IDs flow in-memory only, but we keep\n * the wire shape narrow to rule out attribute-injection vectors and to allow\n * `escapeAttr` to be a no-op for valid IDs.\n */\nexport const SAFE_BLOCK_ID_PATTERN: RegExp = /^[A-Za-z0-9_-]{1,64}$/;\n\n/** True if `value` is shaped like a safe `data-block-id`. */\nexport function isSafeBlockId(value: string): boolean {\n\treturn SAFE_BLOCK_ID_PATTERN.test(value);\n}\n\n/**\n * Adopts the `data-block-id` attribute from a parsed element so that block\n * identity survives an HTML round-trip. Returns `undefined` (caller generates\n * a fresh ID) when:\n * - the attribute is missing (e.g. user-pasted external HTML),\n * - the value is malformed,\n * - or the value collides with an already-adopted ID in this parse pass\n * (e.g. concatenated HTML from two documents).\n */\nexport function adoptBlockId(el: Element, used: Set<string>): BlockId | undefined {\n\tconst raw: string | null = el.getAttribute('data-block-id');\n\tif (!raw) return undefined;\n\tif (!isSafeBlockId(raw)) return undefined;\n\tif (used.has(raw)) return undefined;\n\tused.add(raw);\n\treturn blockId(raw);\n}\n","/**\n * CSSClassCollector: maps CSS declarations to unique class names during serialization.\n * Deduplicates identical declaration sets and produces a minimal stylesheet.\n * Uses content-hash (FNV-1a) for deterministic, document-order-independent class names.\n */\n\n/** Prefix for generated style class names (avoids collisions with user classes). */\nconst CLASS_PREFIX = 'notectl-s-';\n\n/** Base for hash encoding output. */\nconst HASH_BASE = 36;\n/** Pad length for consistent 6-char hashes. */\nconst HASH_PAD_LENGTH = 6;\n\n/**\n * Normalizes a CSS declarations string by sorting individual declarations alphabetically.\n * This ensures `\"color: red; font-size: 14px\"` and `\"font-size: 14px; color: red\"` map\n * to the same class name.\n */\nfunction normalizeDeclarations(declarations: string): string {\n\treturn declarations\n\t\t.split(';')\n\t\t.map((d) => d.trim())\n\t\t.filter((d) => d.length > 0)\n\t\t.sort()\n\t\t.join('; ');\n}\n\n/** FNV-1a 32-bit offset basis. */\nconst FNV_OFFSET_BASIS = 0x811c9dc5;\n/** FNV-1a 32-bit prime. */\nconst FNV_PRIME = 0x01000193;\n\n/**\n * FNV-1a 32-bit hash function.\n * Fast, no crypto dependency, excellent distribution for short strings.\n */\nfunction fnv1aHash(input: string): string {\n\tlet hash: number = FNV_OFFSET_BASIS;\n\tfor (let i = 0; i < input.length; i++) {\n\t\thash ^= input.charCodeAt(i);\n\t\thash = Math.imul(hash, FNV_PRIME);\n\t}\n\t// Convert to unsigned 32-bit, then to base-36, padded to 6 chars\n\tconst unsigned: number = hash >>> 0;\n\treturn unsigned.toString(HASH_BASE).padStart(HASH_PAD_LENGTH, '0');\n}\n\n/**\n * Stateful collector that assigns CSS class names to unique declaration sets.\n * Used during a single serialization pass, then produces the collected stylesheet.\n *\n * Class names are deterministic: the same declarations always produce the same\n * class name, regardless of encounter order across documents.\n */\nexport class CSSClassCollector {\n\t/** Maps normalized declarations → class name. */\n\tprivate readonly classMap: Map<string, string> = new Map();\n\t/** Tracks used hashes to handle the (extremely rare) collision case. */\n\tprivate readonly usedHashes: Set<string> = new Set();\n\n\t/**\n\t * Returns the class name for the given CSS declarations.\n\t * If the same (normalized) declarations were seen before, returns the existing class.\n\t */\n\tgetClassName(declarations: string): string {\n\t\tconst normalized: string = normalizeDeclarations(declarations);\n\t\tconst existing: string | undefined = this.classMap.get(normalized);\n\t\tif (existing) return existing;\n\n\t\tlet hash: string = fnv1aHash(normalized);\n\t\tlet suffix = 0;\n\t\t// Collision handling: append suffix counter if the hash is already in use\n\t\t// for a different declarations string\n\t\twhile (this.usedHashes.has(hash)) {\n\t\t\tsuffix++;\n\t\t\thash = fnv1aHash(normalized + String(suffix));\n\t\t}\n\n\t\tconst className: string = `${CLASS_PREFIX}${hash}`;\n\t\tthis.usedHashes.add(hash);\n\t\tthis.classMap.set(normalized, className);\n\t\treturn className;\n\t}\n\n\t/**\n\t * Returns the semantic alignment class name for a given alignment value.\n\t * Unlike style classes, alignment classes use descriptive names.\n\t */\n\tgetAlignmentClassName(alignment: string): string {\n\t\t// Key by the normalized declaration so the \"one declaration → one class\"\n\t\t// invariant is shared with getClassName(); if a style class for the same\n\t\t// declaration already exists, reuse it rather than minting a second name.\n\t\tconst normalized: string = normalizeDeclarations(`text-align: ${alignment}`);\n\t\tconst existing: string | undefined = this.classMap.get(normalized);\n\t\tif (existing) return existing;\n\n\t\tconst className = `notectl-align-${alignment}`;\n\t\tthis.classMap.set(normalized, className);\n\t\treturn className;\n\t}\n\n\t/** Produces CSS rules for all collected classes. Returns empty string if none collected. */\n\ttoCSS(): string {\n\t\tif (this.classMap.size === 0) return '';\n\n\t\tconst rules: string[] = [];\n\t\tfor (const [declarations, className] of this.classMap) {\n\t\t\trules.push(`.${className} { ${declarations}; }`);\n\t\t}\n\t\treturn rules.join('\\n');\n\t}\n\n\t/**\n\t * Returns a map from class name → CSS declarations for round-trip support.\n\t * Used by `setContentHTML` to rehydrate class-based HTML.\n\t */\n\ttoStyleMap(): ReadonlyMap<string, string> {\n\t\tconst map = new Map<string, string>();\n\t\tfor (const [declarations, className] of this.classMap) {\n\t\t\tmap.set(className, declarations);\n\t\t}\n\t\treturn map;\n\t}\n}\n","/** DOMPurify options required to preserve semantic HTML IDs. */\nexport interface HTMLIdSanitizeConfig {\n\treadonly SANITIZE_DOM: false;\n\treadonly FORBID_ATTR?: string[];\n}\n\n/**\n * Builds the shared DOMPurify policy for HTML carrying document-local targets.\n *\n * DOMPurify's `SANITIZE_DOM` option removes otherwise valid IDs such as `target`\n * when their value matches a property on `document` or a form. Those removals\n * break the fragment-link contract. Callers may add attributes that a broad\n * sanitizer pass must always reject; schema-driven allowlists remain authoritative.\n */\nexport function preserveHTMLIdSanitizeConfig(\n\t...additionalForbiddenAttrs: readonly string[]\n): HTMLIdSanitizeConfig {\n\treturn additionalForbiddenAttrs.length > 0\n\t\t? { SANITIZE_DOM: false, FORBID_ATTR: [...additionalForbiddenAttrs] }\n\t\t: { SANITIZE_DOM: false };\n}\n","/**\n * MarkSerializer: shared mark serialization logic for DocumentSerializer and ClipboardHandler.\n * Separates style-based marks (merged into a single `<span style>`) from tag-based marks\n * (nested wrappers in rank order).\n */\n\nimport type { Mark } from '../model/Document.js';\nimport { escapeHTML } from '../model/HTMLUtils.js';\nimport type { MarkSpec } from '../model/MarkSpec.js';\nimport type { HTMLExportContext } from '../model/NodeSpec.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport type { CSSClassCollector } from './CSSClassCollector.js';\n\n/** Rank assigned to marks whose spec does not declare an explicit `rank`. */\nconst DEFAULT_MARK_RANK = 99;\n\n/** Builds a map of mark type name to rank from the registry (compute once per pass). */\nexport function buildMarkOrder(registry: SchemaRegistry): Map<string, number> {\n\tconst types: readonly string[] = registry.getMarkTypes();\n\tconst order = new Map<string, number>();\n\tfor (const t of types) {\n\t\tconst spec: MarkSpec | undefined = registry.getMarkSpec(t);\n\t\tif (spec) order.set(t, spec.rank ?? DEFAULT_MARK_RANK);\n\t}\n\treturn order;\n}\n\n/**\n * Wraps already-rendered inner HTML in its marks. Style-based marks\n * (`toHTMLStyle`) are merged into a single span via `wrapStyleSpan`; tag-based\n * marks (`toHTMLString`) then wrap the result in rank order. The inner HTML is\n * emitted verbatim (callers pre-escape text; rendered inline-node HTML must not\n * be re-escaped).\n */\nfunction wrapMarks(\n\tinnerHTML: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tmarkOrder: Map<string, number> | undefined,\n\texportCtx: HTMLExportContext | undefined,\n\twrapStyleSpan: (html: string, declarations: string) => string,\n): string {\n\tif (marks.length === 0) return innerHTML;\n\n\tconst order: Map<string, number> = markOrder ?? buildMarkOrder(registry);\n\tconst sortedMarks: Mark[] = [...marks].sort(\n\t\t(a, b) => (order.get(a.type) ?? DEFAULT_MARK_RANK) - (order.get(b.type) ?? DEFAULT_MARK_RANK),\n\t);\n\n\tconst styleParts: string[] = [];\n\tconst tagMarks: Mark[] = [];\n\n\tfor (const mark of sortedMarks) {\n\t\tconst markSpec: MarkSpec | undefined = registry.getMarkSpec(mark.type);\n\t\tif (markSpec?.toHTMLStyle) {\n\t\t\tconst style: string | null = markSpec.toHTMLStyle(mark);\n\t\t\tif (style) {\n\t\t\t\tstyleParts.push(style);\n\t\t\t}\n\t\t} else {\n\t\t\ttagMarks.push(mark);\n\t\t}\n\t}\n\n\t// Wrap with the merged style span first (closest to content).\n\tlet html: string = innerHTML;\n\tif (styleParts.length > 0) {\n\t\thtml = wrapStyleSpan(html, styleParts.join('; '));\n\t}\n\n\t// Then wrap with tag-based marks in rank order.\n\tfor (const mark of tagMarks) {\n\t\tconst markSpec: MarkSpec | undefined = registry.getMarkSpec(mark.type);\n\t\tif (markSpec?.toHTMLString) {\n\t\t\thtml = markSpec.toHTMLString(mark, html, exportCtx);\n\t\t}\n\t}\n\n\treturn html;\n}\n\n/**\n * Shared text mark-serialization core: escapes `text`, then delegates to\n * {@link wrapMarks}. The two public entry points differ only in how the merged\n * style declarations become a `<span>`.\n */\nfunction serializeMarks(\n\ttext: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tmarkOrder: Map<string, number> | undefined,\n\texportCtx: HTMLExportContext | undefined,\n\twrapStyleSpan: (html: string, declarations: string) => string,\n): string {\n\tif (text === '') return '';\n\treturn wrapMarks(escapeHTML(text), marks, registry, markOrder, exportCtx, wrapStyleSpan);\n}\n\n/** Builds the inline-style `<span style>` wrapper used by the style-attribute mode. */\nfunction inlineStyleSpanWrapper(\n\texportCtx: HTMLExportContext | undefined,\n): (html: string, declarations: string) => string {\n\treturn (html, declarations) => {\n\t\tconst attr: string = exportCtx ? exportCtx.styleAttr(declarations) : ` style=\"${declarations}\"`;\n\t\treturn attr ? `<span${attr}>${html}</span>` : html;\n\t};\n}\n\n/** Builds the `<span class>` wrapper used by the CSS-class mode. */\nfunction classSpanWrapper(\n\tcollector: CSSClassCollector,\n): (html: string, declarations: string) => string {\n\treturn (html, declarations) =>\n\t\t`<span class=\"${collector.getClassName(declarations)}\">${html}</span>`;\n}\n\n/**\n * Serializes text with marks to HTML.\n * Style-based marks (`toHTMLStyle`) are merged into a single `<span style=\"...\">`.\n * Tag-based marks (`toHTMLString`) wrap the content in rank order.\n */\nexport function serializeMarksToHTML(\n\ttext: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tmarkOrder?: Map<string, number>,\n\texportCtx?: HTMLExportContext,\n): string {\n\treturn serializeMarks(\n\t\ttext,\n\t\tmarks,\n\t\tregistry,\n\t\tmarkOrder,\n\t\texportCtx,\n\t\tinlineStyleSpanWrapper(exportCtx),\n\t);\n}\n\n/**\n * Wraps an already-rendered inline-node HTML fragment (e.g. `<img>`) in its marks\n * using inline-style spans, mirroring {@link serializeMarksToHTML} but without\n * escaping the fragment. Lets a linked inline image export as `<a …><img …></a>`.\n */\nexport function serializeInlineNodeMarksToHTML(\n\tinnerHTML: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tmarkOrder?: Map<string, number>,\n\texportCtx?: HTMLExportContext,\n): string {\n\treturn wrapMarks(\n\t\tinnerHTML,\n\t\tmarks,\n\t\tregistry,\n\t\tmarkOrder,\n\t\texportCtx,\n\t\tinlineStyleSpanWrapper(exportCtx),\n\t);\n}\n\n/**\n * Serializes text with marks to HTML using CSS class names instead of inline styles.\n * Style-based marks (`toHTMLStyle`) are collected into a `CSSClassCollector` and emitted\n * as `<span class=\"...\">`. Tag-based marks (`toHTMLString`) wrap identically to the inline path.\n */\nexport function serializeMarksToClassHTML(\n\ttext: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tcollector: CSSClassCollector,\n\tmarkOrder?: Map<string, number>,\n\texportCtx?: HTMLExportContext,\n): string {\n\treturn serializeMarks(text, marks, registry, markOrder, exportCtx, classSpanWrapper(collector));\n}\n\n/**\n * Wraps an already-rendered inline-node HTML fragment in its marks using\n * CSS-class spans, mirroring {@link serializeMarksToClassHTML} but without\n * escaping the fragment.\n */\nexport function serializeInlineNodeMarksToClassHTML(\n\tinnerHTML: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tcollector: CSSClassCollector,\n\tmarkOrder?: Map<string, number>,\n\texportCtx?: HTMLExportContext,\n): string {\n\treturn wrapMarks(innerHTML, marks, registry, markOrder, exportCtx, classSpanWrapper(collector));\n}\n","/**\n * DocumentSerializer: converts an immutable Document into sanitized HTML.\n * Pure functions — operates on Document/SchemaRegistry, no class state.\n */\n\nimport DOMPurify from 'dompurify';\nimport { isNodeOfType } from '../model/AttrRegistry.js';\nimport type { BlockNode, Document, InlineNode, TextNode } from '../model/Document.js';\nimport {\n\tgetBlockChildren,\n\tgetInlineChildren,\n\tisInlineNode,\n\tisLeafBlock,\n\tisTextNode,\n\tmarkSetsEqual,\n} from '../model/Document.js';\nimport { SAFE_URI_REGEXP, escapeAttr, escapeHTML, normalizeHTMLId } from '../model/HTMLUtils.js';\nimport type { HTMLExportContext } from '../model/NodeSpec.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { isSafeBlockId } from './BlockIdHTML.js';\nimport { CSSClassCollector } from './CSSClassCollector.js';\nimport type { ContentCSSResult, SerializeOptions } from './ContentHTMLTypes.js';\nimport { preserveHTMLIdSanitizeConfig } from './HTMLSanitization.js';\nimport {\n\tbuildMarkOrder,\n\tserializeInlineNodeMarksToClassHTML,\n\tserializeInlineNodeMarksToHTML,\n\tserializeMarksToClassHTML,\n\tserializeMarksToHTML,\n} from './MarkSerializer.js';\n\n/** Internal context threaded through all serialization helpers. */\ninterface SerializerContext {\n\treadonly registry?: SchemaRegistry;\n\treadonly collector?: CSSClassCollector;\n\treadonly exportCtx?: HTMLExportContext;\n\t/** Resolved from {@link SerializeOptions.includeBlockIds}; defaults to `true`. */\n\treadonly includeBlockIds: boolean;\n}\n\n/** Known-safe alignment values accepted by the serializer (defense-in-depth). */\nexport const VALID_ALIGNMENTS: ReadonlySet<string> = new Set(['start', 'center', 'end', 'justify']);\n\n/** Legacy physical → logical alignment mapping (mirrors DocumentParser). */\nconst LEGACY_ALIGNMENT_MAP: Readonly<Record<string, string>> = { left: 'start', right: 'end' };\n\n/** Known-safe direction values (defense-in-depth). `auto` is excluded — it's the default. */\nexport const VALID_DIRECTIONS: ReadonlySet<string> = new Set(['ltr', 'rtl']);\n\n/** Creates an HTMLExportContext for inline style mode. */\nfunction createInlineExportContext(): HTMLExportContext {\n\treturn {\n\t\tstyleAttr(declarations: string): string {\n\t\t\tif (!declarations) return '';\n\t\t\treturn ` style=\"${declarations}\"`;\n\t\t},\n\t};\n}\n\n/** Creates an HTMLExportContext for CSS class mode. */\nfunction createClassExportContext(collector: CSSClassCollector): HTMLExportContext {\n\treturn {\n\t\tstyleAttr(declarations: string): string {\n\t\t\tif (!declarations) return '';\n\t\t\tconst className: string = collector.getClassName(declarations);\n\t\t\treturn ` class=\"${className}\"`;\n\t\t},\n\t};\n}\n\n/**\n * Injects or merges an attribute into the first opening tag of an HTML fragment.\n * Values are expected to be pre-escaped by the caller.\n */\nfunction injectAttrIntoFirstTag(html: string, attr: string, value: string): string {\n\tconst firstTagRange: { start: number; end: number } | undefined = findFirstOpeningTagRange(html);\n\tif (!firstTagRange) return html;\n\tconst firstTag: string = html.slice(firstTagRange.start, firstTagRange.end + 1);\n\tconst pattern: RegExp = new RegExp(`\\\\s${attr}\\\\s*=\\\\s*(\\\"([^\\\"]*)\\\"|'([^']*)')`);\n\tconst existing: RegExpMatchArray | null = firstTag.match(pattern);\n\tif (existing) {\n\t\tconst existingValue: string = existing[2] ?? existing[3] ?? '';\n\t\tif (attr === 'style' && /(?:^|;)\\s*text-align\\s*:/i.test(existingValue)) {\n\t\t\treturn html;\n\t\t}\n\t\tconst sep: string = attr === 'style' ? '; ' : ' ';\n\t\tconst mergedAttr: string = ` ${attr}=\"${existingValue}${sep}${value}\"`;\n\t\tconst nextFirstTag: string = firstTag.replace(pattern, mergedAttr);\n\t\treturn `${html.slice(0, firstTagRange.start)}${nextFirstTag}${html.slice(firstTagRange.end + 1)}`;\n\t}\n\tconst isSelfClosing: boolean = firstTag.endsWith('/>');\n\tconst injectedFirstTag: string = isSelfClosing\n\t\t? `${firstTag.slice(0, -2)} ${attr}=\"${value}\"/>`\n\t\t: `${firstTag.slice(0, -1)} ${attr}=\"${value}\">`;\n\treturn `${html.slice(0, firstTagRange.start)}${injectedFirstTag}${html.slice(firstTagRange.end + 1)}`;\n}\n\n/** Replaces an attribute on the first opening tag, or adds it when absent. */\nfunction setAttrOnFirstTag(html: string, attr: string, value: string): string {\n\tconst firstTagRange: { start: number; end: number } | undefined = findFirstOpeningTagRange(html);\n\tif (!firstTagRange) return html;\n\tconst firstTag: string = html.slice(firstTagRange.start, firstTagRange.end + 1);\n\tconst replacement: string = ` ${attr}=\"${value}\"`;\n\tconst withoutExisting: string = removeAttributes(firstTag, attr);\n\tconst isSelfClosing: boolean = withoutExisting.endsWith('/>');\n\tconst nextFirstTag: string = isSelfClosing\n\t\t? `${withoutExisting.slice(0, -2)}${replacement}/>`\n\t\t: `${withoutExisting.slice(0, -1)}${replacement}>`;\n\treturn `${html.slice(0, firstTagRange.start)}${nextFirstTag}${html.slice(firstTagRange.end + 1)}`;\n}\n\n/** Removes real attributes by name without matching attribute-like text inside quoted values. */\nfunction removeAttributes(openingTag: string, attr: string): string {\n\tconst ranges: { readonly start: number; readonly end: number }[] = [];\n\tlet index = 1;\n\n\t// Skip the tag name.\n\twhile (\n\t\tindex < openingTag.length &&\n\t\t!isTagWhitespace(openingTag[index] ?? '') &&\n\t\topeningTag[index] !== '>' &&\n\t\topeningTag[index] !== '/'\n\t) {\n\t\tindex++;\n\t}\n\n\twhile (index < openingTag.length) {\n\t\twhile (isTagWhitespace(openingTag[index] ?? '')) index++;\n\t\tif (openingTag[index] === '>' || openingTag[index] === undefined) break;\n\t\tif (openingTag[index] === '/' && openingTag[index + 1] === '>') break;\n\n\t\tconst start: number = index;\n\t\twhile (\n\t\t\tindex < openingTag.length &&\n\t\t\t!isTagWhitespace(openingTag[index] ?? '') &&\n\t\t\topeningTag[index] !== '=' &&\n\t\t\topeningTag[index] !== '>' &&\n\t\t\topeningTag[index] !== '/'\n\t\t) {\n\t\t\tindex++;\n\t\t}\n\t\tconst name: string = openingTag.slice(start, index);\n\t\tif (name === '') {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\twhile (isTagWhitespace(openingTag[index] ?? '')) index++;\n\t\tif (openingTag[index] === '=') {\n\t\t\tindex++;\n\t\t\twhile (isTagWhitespace(openingTag[index] ?? '')) index++;\n\t\t\tconst quote: string | undefined = openingTag[index];\n\t\t\tif (quote === '\"' || quote === \"'\") {\n\t\t\t\tindex++;\n\t\t\t\twhile (index < openingTag.length && openingTag[index] !== quote) index++;\n\t\t\t\tif (openingTag[index] === quote) index++;\n\t\t\t} else {\n\t\t\t\twhile (\n\t\t\t\t\tindex < openingTag.length &&\n\t\t\t\t\t!isTagWhitespace(openingTag[index] ?? '') &&\n\t\t\t\t\topeningTag[index] !== '>' &&\n\t\t\t\t\t!(openingTag[index] === '/' && openingTag[index + 1] === '>')\n\t\t\t\t) {\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (name.toLowerCase() === attr.toLowerCase()) ranges.push({ start, end: index });\n\t}\n\n\tlet result: string = openingTag;\n\tfor (let rangeIndex = ranges.length - 1; rangeIndex >= 0; rangeIndex--) {\n\t\tconst range = ranges[rangeIndex];\n\t\tif (range) result = `${result.slice(0, range.start)}${result.slice(range.end)}`;\n\t}\n\treturn result;\n}\n\nfunction isTagWhitespace(character: string): boolean {\n\treturn (\n\t\tcharacter === ' ' ||\n\t\tcharacter === '\\t' ||\n\t\tcharacter === '\\n' ||\n\t\tcharacter === '\\f' ||\n\t\tcharacter === '\\r'\n\t);\n}\n\n/** Applies a validated semantic HTML ID to the first element emitted for a block. */\nexport function setHTMLIdOnFirstTag(html: string, value: unknown): string {\n\tconst htmlId: string | undefined = normalizeHTMLId(value);\n\treturn htmlId ? setAttrOnFirstTag(html, 'id', escapeAttr(htmlId)) : html;\n}\n\n/** Finds the first opening tag range, treating `>` inside quotes as attribute text. */\nfunction findFirstOpeningTagRange(html: string): { start: number; end: number } | undefined {\n\tlet start: number = html.indexOf('<');\n\twhile (start >= 0) {\n\t\tconst nextChar: string | undefined = html[start + 1];\n\t\tif (nextChar && /[A-Za-z]/.test(nextChar)) {\n\t\t\tlet quote: '\"' | \"'\" | undefined;\n\t\t\tfor (let i = start + 2; i < html.length; i++) {\n\t\t\t\tconst char: string = html[i] ?? '';\n\t\t\t\tif (quote) {\n\t\t\t\t\tif (char === quote) quote = undefined;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (char === '\"' || char === \"'\") {\n\t\t\t\t\tquote = char;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (char === '>') {\n\t\t\t\t\treturn { start, end: i };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\tstart = html.indexOf('<', start + 1);\n\t}\n\treturn undefined;\n}\n\n/** Returns the first opening tag of `html` (quote-aware), or `''` if none exists. */\nfunction firstOpeningTag(html: string): string {\n\tconst range: { start: number; end: number } | undefined = findFirstOpeningTagRange(html);\n\tif (!range) return '';\n\treturn html.slice(range.start, range.end + 1);\n}\n\n/**\n * DOMPurify config fragment that controls `data-block-id` in the output.\n *\n * `data-block-id` is a `data-*` attribute, which DOMPurify permits by default\n * (`ALLOW_DATA_ATTR`) regardless of `ALLOWED_ATTR`. Excluding it therefore\n * requires `FORBID_ATTR` — this is the load-bearing strip that guarantees clean\n * output even when a third-party `NodeSpec.toHTML` emits its own id (the central\n * injection in `serializeBlock` is merely skipped). Including it needs no special\n * config; the centrally injected attribute passes as a data-* attribute.\n */\nfunction blockIdSanitizeConfig(includeBlockIds: boolean): {\n\treadonly SANITIZE_DOM: false;\n\treadonly FORBID_ATTR?: string[];\n} {\n\treturn preserveHTMLIdSanitizeConfig(...(includeBlockIds ? [] : ['data-block-id']));\n}\n\n/** Serializes a full document to sanitized HTML, wrapping list items in `<ul>`/`<ol>`. */\nexport function serializeDocumentToHTML(\n\tdoc: Document,\n\tregistry?: SchemaRegistry,\n\toptions?: SerializeOptions,\n): string {\n\tconst includeBlockIds: boolean = options?.includeBlockIds !== false;\n\tconst exportCtx: HTMLExportContext = createInlineExportContext();\n\tconst ctx: SerializerContext = { registry, exportCtx, includeBlockIds };\n\tconst html: string = serializeBlocks(doc.children, ctx);\n\n\tconst allowedTags: string[] = registry ? registry.getAllowedTags() : ['p', 'br', 'div', 'span'];\n\tconst allowedAttrs: string[] = registry ? registry.getAllowedAttrs() : ['style', 'dir', 'id'];\n\n\treturn DOMPurify.sanitize(html, {\n\t\tALLOWED_TAGS: allowedTags,\n\t\tALLOWED_ATTR: allowedAttrs,\n\t\tALLOWED_URI_REGEXP: SAFE_URI_REGEXP,\n\t\t...blockIdSanitizeConfig(includeBlockIds),\n\t});\n}\n\n/**\n * Serializes a document to HTML with CSS class names instead of inline styles.\n * Returns the HTML and a collected stylesheet with only the rules actually used.\n */\nexport function serializeDocumentToCSS(\n\tdoc: Document,\n\tregistry?: SchemaRegistry,\n\toptions?: SerializeOptions,\n): ContentCSSResult {\n\tconst includeBlockIds: boolean = options?.includeBlockIds !== false;\n\tconst collector = new CSSClassCollector();\n\tconst exportCtx: HTMLExportContext = createClassExportContext(collector);\n\tconst ctx: SerializerContext = { registry, collector, exportCtx, includeBlockIds };\n\tconst html: string = serializeBlocks(doc.children, ctx);\n\n\tconst allowedTags: string[] = registry ? registry.getAllowedTags() : ['p', 'br', 'div', 'span'];\n\tconst baseAttrs: string[] = registry\n\t\t? registry.getAllowedAttrs()\n\t\t: ['style', 'class', 'dir', 'id'];\n\n\t// In class mode, allow `class` through DOMPurify (it is not a data-* attr, so\n\t// it must be in ALLOWED_ATTR).\n\tconst withClass: string[] = baseAttrs.includes('class')\n\t\t? [...baseAttrs]\n\t\t: [...baseAttrs, 'class'];\n\n\t// Defense-in-depth: strip `style` attribute in class mode to guarantee\n\t// zero inline styles — even from third-party plugins that forgot to use ctx.styleAttr().\n\tconst filteredAttrs: string[] = withClass.filter((attr) => attr !== 'style');\n\n\tconst sanitizedHTML: string = DOMPurify.sanitize(html, {\n\t\tALLOWED_TAGS: allowedTags,\n\t\tALLOWED_ATTR: filteredAttrs,\n\t\tALLOWED_URI_REGEXP: SAFE_URI_REGEXP,\n\t\t...blockIdSanitizeConfig(includeBlockIds),\n\t});\n\n\treturn { html: sanitizedHTML, css: collector.toCSS(), styleMap: collector.toStyleMap() };\n}\n\n/** Serializes a sequence of blocks to HTML, grouping consecutive list items into wrappers. */\nfunction serializeBlocks(blocks: readonly BlockNode[], ctx: SerializerContext): string {\n\tconst parts: string[] = [];\n\tlet i = 0;\n\n\twhile (i < blocks.length) {\n\t\tconst block: BlockNode | undefined = blocks[i];\n\t\tif (!block) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isNodeOfType(block, 'list_item')) {\n\t\t\t// Collect consecutive list items\n\t\t\tconst listItems: BlockNode[] = [];\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst item: BlockNode | undefined = blocks[i];\n\t\t\t\tif (!item || !isNodeOfType(item, 'list_item')) break;\n\t\t\t\tlistItems.push(item);\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tparts.push(serializeListGroup(listItems, ctx));\n\t\t} else {\n\t\t\tparts.push(serializeBlock(block, ctx));\n\t\t\ti++;\n\t\t}\n\t}\n\n\treturn parts.join('');\n}\n\n/**\n * Serializes a group of consecutive list items into properly nested `<ul>`/`<ol>` wrappers.\n * Uses a stack-based algorithm to handle indent-based nesting.\n * Produces valid HTML5: nested lists open *inside* the parent `<li>`.\n */\nfunction serializeListGroup(items: readonly BlockNode[], ctx: SerializerContext): string {\n\tconst parts: string[] = [];\n\tconst stack: { tag: string; indent: number }[] = [];\n\n\tfor (let idx = 0; idx < items.length; idx++) {\n\t\tconst item: BlockNode | undefined = items[idx];\n\t\tif (!item) continue;\n\n\t\tconst listType: string = (item.attrs?.listType as string) ?? 'bullet';\n\t\tconst indent: number = (item.attrs?.indent as number) ?? 0;\n\t\tconst tag: string = listType === 'ordered' ? 'ol' : 'ul';\n\t\t// Pop wrapper levels that are deeper than current indent,\n\t\t// or at the same level when the tag type changes\n\t\twhile (stack.length > 0) {\n\t\t\tconst top = stack[stack.length - 1];\n\t\t\tif (!top) break;\n\n\t\t\tif (top.indent > indent) {\n\t\t\t\tparts.push(`</${top.tag}></li>`);\n\t\t\t\tstack.pop();\n\t\t\t} else if (top.indent === indent && top.tag !== tag) {\n\t\t\t\tparts.push(`</${top.tag}></li>`);\n\t\t\t\tstack.pop();\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (stack.length === 0) {\n\t\t\tparts.push(`<${tag}>`);\n\t\t\tstack.push({ tag, indent });\n\t\t} else {\n\t\t\tconst top = stack[stack.length - 1];\n\t\t\tif (top && indent > top.indent) {\n\t\t\t\tparts.push(`<${tag}>`);\n\t\t\t\tstack.push({ tag, indent });\n\t\t\t}\n\t\t}\n\n\t\tconst content: string = serializeBlock(item, ctx);\n\n\t\t// Look ahead: if the next item is deeper, strip </li> so the nested\n\t\t// list opens inside this <li> (valid HTML5 nesting).\n\t\tconst nextItem: BlockNode | undefined = items[idx + 1];\n\t\tconst nextIndent: number | undefined = nextItem\n\t\t\t? ((nextItem.attrs?.indent as number) ?? 0)\n\t\t\t: undefined;\n\n\t\tif (nextIndent !== undefined && nextIndent > indent) {\n\t\t\tparts.push(stripTrailingLiClose(content));\n\t\t} else {\n\t\t\tparts.push(content);\n\t\t}\n\t}\n\n\t// Close all remaining open wrappers\n\twhile (stack.length > 0) {\n\t\tconst top = stack.pop();\n\t\tif (!top) break;\n\t\tparts.push(`</${top.tag}>`);\n\t\tif (stack.length > 0) {\n\t\t\tparts.push('</li>');\n\t\t}\n\t}\n\n\treturn parts.join('');\n}\n\n/** Removes the trailing `</li>` from serialized list item HTML. */\nfunction stripTrailingLiClose(html: string): string {\n\tconst suffix = '</li>';\n\tif (html.endsWith(suffix)) {\n\t\treturn html.slice(0, -suffix.length);\n\t}\n\treturn html;\n}\n\n/** Serializes a single block to HTML using its NodeSpec. */\nfunction serializeBlock(block: BlockNode, ctx: SerializerContext): string {\n\tconst content: string = isLeafBlock(block)\n\t\t? serializeInlineContent(block, ctx)\n\t\t: serializeBlocks(getBlockChildren(block), ctx);\n\tconst spec = ctx.registry?.getNodeSpec(block.type);\n\n\tlet html: string;\n\tif (spec?.toHTML) {\n\t\thtml = spec.toHTML(block, content, ctx.exportCtx);\n\t} else {\n\t\thtml = `<p>${content || '<br>'}</p>`;\n\t}\n\n\t// Centrally inject `data-block-id` so each `NodeSpec.toHTML` is relieved of\n\t// the responsibility — and the round-trip identity contract holds for every\n\t// block type, including ones added by future plugins. The serializer's\n\t// allowlist passes `data-block-id` through DOMPurify. Skip if the spec\n\t// already emits one (mirrors the existing `dir` defense-in-depth pattern).\n\t// `escapeAttr` is defense-in-depth — `isSafeBlockId` already excludes any\n\t// character that would need escaping. Skipped entirely when the caller opted\n\t// out via `includeBlockIds: false`; the allowlist strip is the guarantee.\n\tif (ctx.includeBlockIds && isSafeBlockId(block.id)) {\n\t\tif (!firstOpeningTag(html).includes(' data-block-id=')) {\n\t\t\thtml = injectAttrIntoFirstTag(html, 'data-block-id', escapeAttr(block.id));\n\t\t}\n\t}\n\n\t// HTML IDs are semantic, document-local targets and therefore independent of\n\t// the editor's internal `data-block-id` wire identity. The model value wins\n\t// over a NodeSpec-provided `id` so serialization can never emit duplicates.\n\thtml = setHTMLIdOnFirstTag(html, block.htmlId);\n\n\t// Inject alignment into the first opening tag (validated against allowlist).\n\tconst rawAlign: string | undefined = (block.attrs as Record<string, unknown>)?.align as\n\t\t| string\n\t\t| undefined;\n\tconst align: string | undefined = rawAlign\n\t\t? (LEGACY_ALIGNMENT_MAP[rawAlign] ?? rawAlign)\n\t\t: undefined;\n\tif (align && align !== 'start' && VALID_ALIGNMENTS.has(align)) {\n\t\tconst safeAlign: string = escapeAttr(align);\n\t\tif (ctx.collector) {\n\t\t\tconst className: string = ctx.collector.getAlignmentClassName(align);\n\t\t\thtml = injectAttrIntoFirstTag(html, 'class', escapeAttr(className));\n\t\t} else {\n\t\t\thtml = injectAttrIntoFirstTag(html, 'style', `text-align: ${safeAlign}`);\n\t\t}\n\t}\n\n\t// Defense-in-depth: inject dir into the first opening tag if not already present.\n\t// NodeSpec toHTML may already inject it; this ensures it survives even without a plugin.\n\tconst dir: string | undefined = (block.attrs as Record<string, unknown>)?.dir as\n\t\t| string\n\t\t| undefined;\n\tif (dir && VALID_DIRECTIONS.has(dir)) {\n\t\tif (!firstOpeningTag(html).includes(' dir=')) {\n\t\t\thtml = injectAttrIntoFirstTag(html, 'dir', escapeAttr(dir));\n\t\t}\n\t}\n\n\treturn html;\n}\n\n/** Serializes inline children (TextNode + InlineNode) of a block. */\nfunction serializeInlineContent(block: BlockNode, ctx: SerializerContext): string {\n\tconst children: readonly (TextNode | InlineNode)[] = getInlineChildren(block);\n\tconst merged: readonly (TextNode | InlineNode)[] = mergeAdjacentTextNodes(children);\n\tconst parts: string[] = [];\n\tconst markOrder: Map<string, number> | undefined = ctx.registry\n\t\t? buildMarkOrder(ctx.registry)\n\t\t: undefined;\n\n\tfor (const child of merged) {\n\t\tif (isInlineNode(child)) {\n\t\t\tconst inlineSpec = ctx.registry?.getInlineNodeSpec(child.inlineType);\n\t\t\tif (inlineSpec?.toHTMLString) {\n\t\t\t\tconst inlineHTML: string = inlineSpec.toHTMLString(child);\n\t\t\t\t// Wrap the atomic node in its marks (e.g. a linked inline image → <a><img></a>).\n\t\t\t\tif (ctx.registry && child.marks.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\tctx.collector\n\t\t\t\t\t\t\t? serializeInlineNodeMarksToClassHTML(\n\t\t\t\t\t\t\t\t\tinlineHTML,\n\t\t\t\t\t\t\t\t\tchild.marks,\n\t\t\t\t\t\t\t\t\tctx.registry,\n\t\t\t\t\t\t\t\t\tctx.collector,\n\t\t\t\t\t\t\t\t\tmarkOrder,\n\t\t\t\t\t\t\t\t\tctx.exportCtx,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: serializeInlineNodeMarksToHTML(\n\t\t\t\t\t\t\t\t\tinlineHTML,\n\t\t\t\t\t\t\t\t\tchild.marks,\n\t\t\t\t\t\t\t\t\tctx.registry,\n\t\t\t\t\t\t\t\t\tmarkOrder,\n\t\t\t\t\t\t\t\t\tctx.exportCtx,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tparts.push(inlineHTML);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (ctx.registry && ctx.collector) {\n\t\t\tparts.push(\n\t\t\t\tserializeMarksToClassHTML(\n\t\t\t\t\tchild.text,\n\t\t\t\t\tchild.marks,\n\t\t\t\t\tctx.registry,\n\t\t\t\t\tctx.collector,\n\t\t\t\t\tmarkOrder,\n\t\t\t\t\tctx.exportCtx,\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (ctx.registry) {\n\t\t\tparts.push(\n\t\t\t\tserializeMarksToHTML(child.text, child.marks, ctx.registry, markOrder, ctx.exportCtx),\n\t\t\t);\n\t\t} else if (child.text !== '') {\n\t\t\tparts.push(escapeHTML(child.text));\n\t\t}\n\t}\n\n\treturn parts.join('');\n}\n\n/**\n * Merges adjacent TextNodes that share identical mark sets.\n * InlineNodes act as merge boundaries.\n */\nfunction mergeAdjacentTextNodes(\n\tchildren: readonly (TextNode | InlineNode)[],\n): readonly (TextNode | InlineNode)[] {\n\tif (children.length <= 1) return children;\n\n\tconst result: (TextNode | InlineNode)[] = [];\n\n\tfor (const child of children) {\n\t\tif (isInlineNode(child)) {\n\t\t\tresult.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst prev: TextNode | InlineNode | undefined = result[result.length - 1];\n\t\tif (prev && isTextNode(prev) && markSetsEqual(prev.marks, child.marks)) {\n\t\t\tresult[result.length - 1] = {\n\t\t\t\ttype: 'text',\n\t\t\t\ttext: prev.text + child.text,\n\t\t\t\tmarks: prev.marks,\n\t\t\t};\n\t\t} else {\n\t\t\tresult.push(child);\n\t\t}\n\t}\n\n\treturn result;\n}\n","/** Shared, DOM-free table-dimension bounds and normalization. */\n\n/** Smallest supported table column width or row minimum height, in CSS pixels. */\nexport const MIN_TABLE_DIMENSION_PX = 1;\n\n/** Largest supported table column width or row minimum height, in CSS pixels. */\nexport const MAX_TABLE_DIMENSION_PX = 10_000;\n\n/**\n * Normalizes a finite numeric table dimension into the requested bounded range.\n * Non-numeric and non-finite input is rejected with `null`.\n */\nexport function normalizeTableDimensionPx(\n\tvalue: unknown,\n\tminimum = MIN_TABLE_DIMENSION_PX,\n\tmaximum = MAX_TABLE_DIMENSION_PX,\n): number | null {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) return null;\n\n\tconst normalizedMinimum: number = normalizeBound(minimum, MIN_TABLE_DIMENSION_PX);\n\tconst normalizedMaximum: number = Math.max(\n\t\tnormalizedMinimum,\n\t\tnormalizeBound(maximum, MAX_TABLE_DIMENSION_PX),\n\t);\n\treturn Math.min(normalizedMaximum, Math.max(normalizedMinimum, value));\n}\n\nfunction normalizeBound(value: number, fallback: number): number {\n\tif (!Number.isFinite(value)) return fallback;\n\treturn Math.min(MAX_TABLE_DIMENSION_PX, Math.max(MIN_TABLE_DIMENSION_PX, value));\n}\n","/**\n * Safe table-dimension parsing and HTML serialization helpers.\n *\n * Table dimensions are stored as finite CSS-pixel numbers. HTML import accepts\n * notectl's numeric wire attributes and a deliberately small conventional\n * subset: unitless numeric presentation attributes and exact `px` CSS values.\n * Arbitrary CSS expressions never cross into document attributes.\n */\n\nimport type { HTMLExportContext } from '../model/NodeSpec.js';\nimport {\n\tMAX_TABLE_DIMENSION_PX,\n\tMIN_TABLE_DIMENSION_PX,\n\tnormalizeTableDimensionPx,\n} from '../model/TableDimensions.js';\n\n/** Canonical HTML metadata carrying one logical column's width in CSS pixels. */\nexport const TABLE_COLUMN_WIDTH_DATA_ATTRIBUTE = 'data-notectl-width-px';\n\n/** Canonical HTML metadata carrying one logical row's minimum height in CSS pixels. */\nexport const TABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE = 'data-notectl-min-height-px';\n\n/** Defensive upper bound for a serialized `<col>` vector. */\nexport const MAX_SERIALIZED_TABLE_COLUMNS = 1_000;\n\n/** HTML's upper bound for a `<col span>` value. */\nexport const MAX_TABLE_COLUMN_SPAN = 1_000;\n\nconst DECIMAL_NUMBER_RE = /^\\d+(?:\\.\\d+)?$/;\nconst CSS_PX_RE = /^(\\d+(?:\\.\\d+)?)px$/i;\nconst POSITIVE_INTEGER_RE = /^\\d+$/;\n\n/** Returns a bounded, finite CSS-pixel value without clamping untrusted serialized input. */\nexport function normalizeSerializedTableDimensionPx(value: unknown): number | undefined {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) return undefined;\n\tif (value < MIN_TABLE_DIMENSION_PX || value > MAX_TABLE_DIMENSION_PX) return undefined;\n\treturn normalizeTableDimensionPx(value) ?? undefined;\n}\n\n/** Parses notectl's canonical numeric `data-notectl-*-px` value. */\nexport function parseTableDimensionMetadata(raw: string | null): number | undefined {\n\treturn parseDecimal(raw, false);\n}\n\n/** Parses a conventional numeric or `px` presentation attribute. */\nexport function parseConventionalTableDimension(raw: string | null): number | undefined {\n\treturn parseDecimal(raw, true);\n}\n\n/** Parses an exact CSS `<length>` in pixels. Other units and expressions are rejected. */\nexport function parseCSSTableDimension(raw: string | null): number | undefined {\n\tif (raw === null) return undefined;\n\tconst match: RegExpMatchArray | null = raw.trim().match(CSS_PX_RE);\n\treturn match?.[1] ? parseBoundedNumber(match[1]) : undefined;\n}\n\n/**\n * Reads a dimension from an element using deterministic precedence:\n * notectl metadata, exact CSS properties, then a conventional HTML attribute.\n */\nexport function readTableDimensionPx(\n\telement: HTMLElement,\n\tmetadataAttribute: string,\n\tcssProperties: readonly string[],\n\tconventionalAttribute: string,\n): number | undefined {\n\tconst metadata: number | undefined = parseTableDimensionMetadata(\n\t\telement.getAttribute(metadataAttribute),\n\t);\n\tif (metadata !== undefined) return metadata;\n\n\tfor (const property of cssProperties) {\n\t\tconst cssValue: number | undefined = parseCSSTableDimension(\n\t\t\telement.style.getPropertyValue(property),\n\t\t);\n\t\tif (cssValue !== undefined) return cssValue;\n\t}\n\n\treturn parseConventionalTableDimension(element.getAttribute(conventionalAttribute));\n}\n\n/** Parses a bounded positive integer HTML span, falling back to one when malformed. */\nexport function parseTableColumnSpan(raw: string | null): number {\n\tif (raw === null) return 1;\n\tconst normalized: string = raw.trim();\n\tif (!POSITIVE_INTEGER_RE.test(normalized)) return 1;\n\tconst value: number = Number(normalized);\n\tif (!Number.isSafeInteger(value) || value < 1 || value > MAX_TABLE_COLUMN_SPAN) return 1;\n\treturn value;\n}\n\n/**\n * Normalizes an untrusted logical column-width vector. Invalid entries become\n * automatic (`null`); a vector with no explicit width is omitted.\n */\nexport function normalizeTableColumnWidthsPx(\n\tvalue: unknown,\n): readonly (number | null)[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst widths: (number | null)[] = Array.from(\n\t\tvalue.slice(0, MAX_SERIALIZED_TABLE_COLUMNS),\n\t\t(entry: unknown): number | null => normalizeSerializedTableDimensionPx(entry) ?? null,\n\t);\n\treturn widths.some((width: number | null): boolean => width !== null) ? widths : undefined;\n}\n\n/** True when a table column-width vector contains at least one safe explicit value. */\nexport function hasExplicitTableColumnWidth(value: unknown): boolean {\n\treturn normalizeTableColumnWidthsPx(value) !== undefined;\n}\n\n/**\n * Emits canonical metadata plus mode-aware visual CSS for one safe dimension.\n * `ctx.styleAttr()` remains the sole generated-style path in class/CSP mode.\n */\nexport function serializeTableDimensionAttrs(\n\tmetadataAttribute: string,\n\tcssProperty: 'width' | 'height',\n\tvalue: unknown,\n\tctx?: HTMLExportContext,\n): string {\n\tconst dimension: number | undefined = normalizeSerializedTableDimensionPx(value);\n\tif (dimension === undefined) return '';\n\tconst declarations = `${cssProperty}: ${String(dimension)}px`;\n\tconst styleAttribute: string = ctx?.styleAttr(declarations) ?? ` style=\"${declarations}\"`;\n\treturn ` ${metadataAttribute}=\"${String(dimension)}\"${styleAttribute}`;\n}\n\nfunction parseDecimal(raw: string | null, allowPx: boolean): number | undefined {\n\tif (raw === null) return undefined;\n\tconst normalized: string = raw.trim();\n\tif (DECIMAL_NUMBER_RE.test(normalized)) return parseBoundedNumber(normalized);\n\tif (!allowPx) return undefined;\n\tconst match: RegExpMatchArray | null = normalized.match(CSS_PX_RE);\n\treturn match?.[1] ? parseBoundedNumber(match[1]) : undefined;\n}\n\nfunction parseBoundedNumber(raw: string): number | undefined {\n\tconst value: number = Number(raw);\n\treturn normalizeSerializedTableDimensionPx(value);\n}\n"],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- import{r as t}from"./HTMLUtils-Bhg3_P8B.mjs";import{E as e,_ as n,c as o,f as r,h as i,o as l,p as s,r as a,u as c}from"./Document-827l3P80.mjs";import{c as d,l as u,o as h,r as b,t as m,u as p}from"./Selection-HYoVFpAx.mjs";import{a as f}from"./TypeBrands-Ch9856Gb.mjs";import{i as g,t as w}from"./Decoration-BpoEOANl.mjs";import{_ as x,s as v}from"./BlockInsertion-CJusvrDL.mjs";import{i as C}from"./Platform-ByobkiCc.mjs";import{t as y}from"./EditorEventBoundary-zpYRxryo.mjs";import{a as S,d as R,h as z,l as I,n as k,r as A,u as E}from"./TableDimensions-BBhjHNjQ.mjs";import{c as P,o as M,s as L}from"./StyleRuntime-DW6omotc.mjs";import{n as B}from"./TypedKeys-CA4bfw9O.mjs";import{c as H,i as N,o as $}from"./PluginHelpers-Dx_0hfDe.mjs";import{t as T}from"./KeyboardNav-D0my3wuy.mjs";import{i as D,n as W}from"./PopupPositioning-BFh6Ed1D.mjs";import{i as O}from"./ColorValidation-DAijTjG9.mjs";import{n as _,t as j}from"./ColorGrid-C9RQoEWF.mjs";function F(t,e){if(0===t.rowCount||0===t.columnCount)return null;let n={fromRow:X(Math.min(e.fromRow,e.toRow),t.rowCount),fromColumn:X(Math.min(e.fromColumn,e.toColumn),t.columnCount),toRow:X(Math.max(e.fromRow,e.toRow),t.rowCount),toColumn:X(Math.max(e.fromColumn,e.toColumn),t.columnCount)};for(;;){let e=n.fromRow,o=n.fromColumn,r=n.toRow,i=n.toColumn;for(const l of t.cellsInRange(n))e=Math.min(e,l.rowStart),o=Math.min(o,l.columnStart),r=Math.max(r,l.rowEnd-1),i=Math.max(i,l.columnEnd-1);if(e===n.fromRow&&o===n.fromColumn&&r===n.toRow&&i===n.toColumn)return n;n={fromRow:e,fromColumn:o,toRow:r,toColumn:i}}}function q(t,e=1e3){return"number"==typeof t&&Number.isFinite(t)&&Number.isInteger(t)?t<=1?1:Math.min(t,e):1}function V(t){const e="table"===t.type?s(t).filter(t=>"table_row"===t.type):[],n=Array.from({length:e.length},()=>[]),o=[],r=/* @__PURE__ */new Map;let i=0;for(let l=0;l<e.length;l++){const t=e[l];if(!t)continue;const a=s(t).filter(t=>"table_cell"===t.type);let c=0;for(let s=0;s<a.length;s++){const d=a[s];if(!d)continue;const u=q(d.attrs?.colspan),h=q(d.attrs?.rowspan),b=Math.min(h,e.length-l),m=Y(n[l]??[],c,u);if(void 0===m)continue;c=m;const p=Math.min(u,1e3-c),f={cell:d,sourceRow:t,sourceRowIndex:l,sourceCellIndex:s,rowStart:l,rowEnd:l+b,columnStart:c,columnEnd:c+p,rowSpan:b,columnSpan:p};o.push(f),r.set(d.id,f);for(let t=f.rowStart;t<f.rowEnd;t++){const e=n[t];if(e)for(let t=f.columnStart;t<f.columnEnd;t++)e[t]??=f}c=f.columnEnd,i=Math.max(i,f.columnEnd)}}return{table:t,rows:e,rowCount:e.length,columnCount:i,cells:o,cellAt(t,e){if(!(!Number.isInteger(t)||!Number.isInteger(e)||t<0||e<0))return n[t]?.[e]},cellById:t=>r.get(t),cellsInRange(t){const n=Math.max(0,Math.min(t.fromRow,t.toRow)),r=Math.min(e.length-1,Math.max(t.fromRow,t.toRow)),l=Math.max(0,Math.min(t.fromColumn,t.toColumn)),s=Math.min(i-1,Math.max(t.fromColumn,t.toColumn));return r<n||s<l?[]:o.filter(t=>t.rowStart<=r&&t.rowEnd>n&&t.columnStart<=s&&t.columnEnd>l)}}}function K(t,e){const n=/* @__PURE__ */new Set,o=/* @__PURE__ */new Set;for(const b of s(e)){o.add(b.id);for(const t of s(b))n.add(t.id)}const r=V(t),i=r.cells.filter(t=>n.has(t.cell.id));if(0===i.length)return Z(e);const l=Math.min(...i.map(t=>t.columnStart)),a=Math.max(...i.map(t=>t.columnEnd))-1,c=r.rows.map((t,e)=>o.has(t.id)?e:-1).filter(t=>t>=0);if(0===c.length)return Z(e);const d=function(t,e,n,o,r,i){let l=!1;const a=s(t).map(t=>{let a=!1;const c=s(t).map(t=>{const l=e.cellById(t.id);if(!l)return t;const s=Math.min(l.rowEnd,o+1)-Math.max(l.rowStart,n),c=Math.min(l.columnEnd,i+1)-Math.max(l.columnStart,r),d=q(t.attrs?.rowspan),u=q(t.attrs?.colspan);if(s===d&&c===u)return t;a=!0;const{colspan:h,rowspan:b,...m}=t.attrs??{},p={...m,...c>1?{colspan:c}:{},...s>1?{rowspan:s}:{}},{attrs:f,...g}=t;return Object.keys(p).length>0?{...g,attrs:p}:g});return a?(l=!0,{...t,children:c}):t});return l?{...t,children:a}:t}(e,r,Math.min(...c),Math.max(...c),l,a);for(const s of c){const t=/* @__PURE__ */new Set;for(const e of i)if(!(e.rowStart>s||e.rowEnd<=s))for(let n=e.columnStart;n<e.columnEnd;n++)t.add(n);for(let e=l;e<=a;e++)if(!t.has(e))return Z(d)}const u=t.attrs?.columnWidthsPx;if(!Array.isArray(u))return d;const h=[];for(let s=l;s<=a;s++){const t=u[s];h.push("number"==typeof t&&Number.isFinite(t)?t:null)}return h.some(t=>null!==t)?{...d,attrs:{...d.attrs??{},columnWidthsPx:Object.freeze(h)}}:Z(d)}function Z(t){if(!t.attrs||!Object.hasOwn(t.attrs,"columnWidthsPx"))return t;const{columnWidthsPx:e,...n}=t.attrs,{attrs:o,...r}=t;return{...r,...Object.keys(n).length>0?{attrs:n}:{}}}function Y(t,e,n){let o=Math.max(0,e);for(;o+n<=1e3;){let e=!0;for(let r=0;r<n;r++)if(t[o+r]){e=!1,o+=r+1;break}if(e)return o}}function X(t,e){return Number.isFinite(t)?Math.min(e-1,Math.max(0,Math.trunc(t))):0}function U(){const t=l(f("paragraph"),[c("")],r());return l(f("table_cell"),[t],r())}function G(t,e){const n=t.getNodePath(e);if(!n)return null;let o=null,r=null,i=null;for(const c of n){const e=t.getBlock(c);e&&("table"===e.type?(o=c,r=e):"table_cell"===e.type&&(i=c))}if("table_cell"===t.getBlock(e)?.type&&(i=e),!o||!r||!i)return null;const l=t.doc.children.findIndex(t=>t.id===o),s=V(r),a=s.cellById(i);return a?{tableId:o,tableIndex:l,rowId:a.sourceRow.id,rowIndex:a.rowStart,rowEnd:a.rowEnd,cellId:i,colIndex:a.columnStart,colEnd:a.columnEnd,rowspan:a.rowSpan,colspan:a.columnSpan,totalRows:s.rowCount,totalCols:s.columnCount}:null}function J(t,e,n,o){const r=t.getBlock(e);return r&&"table"===r.type?V(r).cellAt(n,o)?.cell.id??null:null}function Q(t,e){const n=t.getBlock(e);if(!n)return e;const o=s(n)[0];if(!o)return e;let r=o;for(;;){const t=s(r)[0];if(!t)return r.id;r=t}}function tt(t,e){const n=t.getBlock(e);if(!n)return e;const o=s(n),r=o[o.length-1];if(!r)return e;let i=r;for(;;){const t=s(i),e=t[t.length-1];if(!e)return i.id;i=e}}function et(t,e){const n=t.getNodePath(e);if(!n)return!1;for(const o of n)if("table"===t.getBlock(o)?.type)return!0;return!1}var nt={insertRowAbove:"Insert Row Above",insertRowBelow:"Insert Row Below",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteRow:"Delete Row",deleteColumn:"Delete Column",borderColorLabel:"Border Color...",deleteTable:"Delete Table",tableActions:"Table actions",menuKeyboardHint:"↑↓ Navigate · Enter Select · Esc Close",insertRow:"Insert row",insertColumn:"Insert column",addRow:"Add row",addColumn:"Add column",tableActionsHint:"Table actions (Right-click or Shift+F10)",contextMenuHint:"Right-click or Shift+F10 for table actions",borderColor:"Border color",sizeLabel:"Size...",sizeDialogLabel:"Table size",columnWidthLabel:"Column width (px)",rowMinimumHeightLabel:"Row minimum height (px)",automatic:"Automatic",mixed:"Mixed",apply:"Apply",cancel:"Cancel",resetColumnWidth:"Reset column width",resetRowMinimumHeight:"Reset row minimum height",resetAllSizes:"Reset all sizes",invalidDimensionRange:(t,e)=>`Enter a value from ${t} to ${e} px.`,selectRowLabel:t=>`Select row ${t+1}`,selectColumnLabel:t=>`Select column ${t+1}`,resizeColumnSeparatorLabel:t=>`Resize column ${t+1}`,resizeRowSeparatorLabel:t=>`Resize row ${t+1}`,resizeKeyboardHint:(t,e)=>`Arrow keys resize by ${t} px; hold Shift for ${e} px.`,announceColumnWidthSet:(t,e)=>`Column ${t+1} width set to ${e} px.`,announceRowMinimumHeightSet:(t,e)=>`Row ${t+1} minimum height set to ${e} px.`,announceColumnWidthReset:t=>`Column ${t+1} width reset to automatic.`,announceRowMinimumHeightReset:t=>`Row ${t+1} minimum height reset to automatic.`,announceTableSizesReset:"Table column widths and row minimum heights reset to automatic.",defaultColor:"Default",noBorders:"No borders",borderColorPicker:"Border color picker",announceBorderColorSet:t=>`Table border color set to ${t}`,announceBorderReset:"Table borders reset to default",borderSwatchLabel:t=>`Border ${t}`,announceRowInsertedAbove:"Row inserted above",announceRowInsertedBelow:"Row inserted below",announceColumnInserted:t=>`Column inserted ${t}`,announceRowDeleted:"Row deleted",announceColumnDeleted:"Column deleted",announceTableDeleted:"Table deleted",insertTable:"Insert Table",tableAriaLabel:(t,e)=>`Table with ${t} rows and ${e} columns`,tableAriaDescription:"Right-click or press Shift+F10 for table actions"},ot=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-Dg9PdDet.mjs"),"./locales/de.ts":()=>import("./de-DJ5EkXQo.mjs"),"./locales/es.ts":()=>import("./es-CEAJj7aB.mjs"),"./locales/fr.ts":()=>import("./fr-DhWQzZy3.mjs"),"./locales/hi.ts":()=>import("./hi-BsZzSMfL.mjs"),"./locales/pt.ts":()=>import("./pt-BuZ7acHF.mjs"),"./locales/ru.ts":()=>import("./ru-CsP6mLxp.mjs"),"./locales/zh.ts":()=>import("./zh-CiIyOm6U.mjs")});async function rt(t){return H(ot,t,nt)}var it=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#980000","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79","#0b5394","#38761d"];function lt(t,e,n){const o=t.getBlock(e);if(!o||"table"!==o.type)return null;const r=t.getNodePath(e);if(!r)return null;if(void 0===n){const{borderColor:e,...n}=o.attrs??{},i=n;return t.transaction("command").setNodeAttr(r,i).setSelection(t.selection).build()}const i={...o.attrs,borderColor:n};return t.transaction("command").setNodeAttr(r,i).setSelection(t.selection).build()}function st(t,e,n=nt){const o=t.getState();if(!p(o.selection))return!1;const r=G(o,o.selection.anchor.blockId);if(!r)return!1;const i=lt(o,r.tableId,e);if(!i)return!1;t.dispatch(i);const l="none"===e?"none":_(e);return t.announce(n.announceBorderColorSet(l)),!0}function at(t,e=nt){const n=t.getState();if(!p(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=lt(n,o.tableId,void 0);return!!r&&(t.dispatch(r),t.announce(e.announceBorderReset),!0)}function ct(t,e){const n=t.getBlock(e);if(n)return n.attrs?.borderColor}function dt(t,e,n,o,r=nt){t.classList.add("notectl-color-picker");const i=ct(e.getState(),n),l=document.createElement("button");l.type="button",l.className="notectl-color-picker__default",l.textContent=r.defaultColor,l.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),at(e,r),o()}),l.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),o())}),t.appendChild(l);const s=document.createElement("button");s.type="button",s.className="notectl-color-picker__default",s.textContent=r.noBorders,s.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),st(e,"none",r),o()}),s.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),o())}),t.appendChild(s),j(t,{colors:it,columns:5,ariaLabel:r.borderColorPicker,ariaLabelPrefix:"",activeColor:i??null,swatchLabel:r.borderSwatchLabel,titleAsName:!0,onSelect:t=>{st(e,t,r),o()},onClose:o})}function ut(t,e,n){const o=t.clipboardData,r=n.getSelectedRange();if(!o||!r)return!1;const i=e.getState().getBlock(r.tableId);if(!i||"table"!==i.type)return!1;const l=function(t,e){const n=V(t);if(0===n.rowCount||0===n.columnCount)return null;const o=F(n,e);if(!o)return null;const{fromRow:r,fromColumn:i,toRow:l,toColumn:s}=o,a=n.cellsInRange({fromRow:r,fromColumn:i,toRow:l,toColumn:s}),c=[],d=0===i&&s===n.columnCount-1;for(let y=r;y<=l;y++){const t=n.rows[y];if(!t)continue;const e=a.filter(t=>Math.max(t.rowStart,r)===y).sort((t,e)=>Math.max(t.columnStart,i)-Math.max(e.columnStart,i)).map(t=>{const e=Math.min(t.rowEnd,l+1)-Math.max(t.rowStart,r),n=Math.min(t.columnEnd,s+1)-Math.max(t.columnStart,i),{colspan:o,rowspan:a,...c}=t.cell.attrs??{},d={...c,...n>1?{colspan:n}:{},...e>1?{rowspan:e}:{}},{attrs:u,...h}=t.cell;return Object.keys(d).length>0?{...h,attrs:d}:h}),{htmlId:o,...u}=t;c.push({...d?t:u,children:e})}const{columnWidthsPx:u,...h}=t.attrs??{},b=t.attrs?.columnWidthsPx,m=[];if(Array.isArray(b))for(let y=i;y<=s;y++){const t=b[y];m.push("number"==typeof t&&Number.isFinite(t)?t:null)}const p={...h,...m.some(t=>null!==t)?{columnWidthsPx:Object.freeze(m)}:{}},f=d&&0===r&&l===n.rowCount-1,{attrs:g,...w}=t,{htmlId:x,...v}=w,C=f?w:v;return Object.keys(p).length>0?{...C,children:c,attrs:p}:{...C,children:c}}(i,{fromRow:r.fromRow,fromColumn:r.fromCol,toRow:r.toRow,toColumn:r.toCol});return!!l&&(t.preventDefault(),t.stopImmediatePropagation(),o.setData("text/html",z({children:[l]},e.getSchemaRegistry())),o.setData("text/plain",function(t){const e=V(t);return Array.from({length:e.rowCount},(t,n)=>Array.from({length:e.columnCount},(t,o)=>{const r=e.cellAt(n,o);return r&&r.rowStart===n&&r.columnStart===o?ht(r.cell):""}).join("\t")).join("\n")}(l)),!0)}function ht(t){return e(t)?n(t):s(t).map(ht).join("\n")}var bt=new B("tableSelection");function mt(t){return JSON.stringify({rows:t.rows.map(t=>t.id),cells:t.cells.map(t=>[t.cell.id,t.rowStart,t.rowEnd,t.columnStart,t.columnEnd])})}function pt(t,e){return{tableId:t.tableId,fromRow:Math.min(t.rowStart,e.rowIndex),fromCol:Math.min(t.colStart,e.colIndex),toRow:Math.max(t.rowEnd,e.rowEnd)-1,toCol:Math.max(t.colEnd,e.colEnd)-1}}var ft=Object.freeze({minColumnWidthPx:60,minRowHeightPx:24,maxColumnWidthPx:E,maxRowHeightPx:E,keyboardResizeStepPx:8,keyboardResizeLargeStepPx:32}),gt=new B("tableSizing");function wt(t){const e=Bt(t.minColumnWidthPx,ft.minColumnWidthPx),n=Bt(t.minRowHeightPx,ft.minRowHeightPx);return{minColumnWidthPx:e,minRowHeightPx:n,maxColumnWidthPx:Bt(t.maxColumnWidthPx,ft.maxColumnWidthPx,e),maxRowHeightPx:Bt(t.maxRowHeightPx,ft.maxRowHeightPx,n),keyboardResizeStepPx:Bt(t.keyboardResizeStepPx,ft.keyboardResizeStepPx),keyboardResizeLargeStepPx:Bt(t.keyboardResizeLargeStepPx,ft.keyboardResizeLargeStepPx)}}function xt(t,e){const n=Math.max(0,Math.trunc(e)),o=t.attrs?.columnWidthsPx,r=Array.isArray(o)?o:[];return Object.freeze(Array.from({length:n},(t,e)=>{const n=r[e];return null==n?null:Lt(n)}))}function vt(t,e){const n=Object.freeze(e.map(t=>null===t?null:Lt(t))),{columnWidthsPx:o,...r}=t??{};return n.some(t=>null!==t)?{...r,columnWidthsPx:n}:r}function Ct(t){return Lt(t.attrs?.minHeightPx)}function yt(t,e){const{minHeightPx:n,...o}=t??{};if(null===e)return o;const r=Lt(e);return null===r?o:{...o,minHeightPx:r}}function St(t){const e=t.getState(),n=t.getService(bt)?.getSelectedRange()??null;if(n)return zt(e,n.tableId,n,!0);if(!p(e.selection))return null;const o=G(e,e.selection.anchor.blockId);return o?zt(e,o.tableId,{tableId:o.tableId,fromRow:o.rowIndex,fromCol:o.colIndex,toRow:o.rowEnd-1,toCol:o.colEnd-1},!0):null}function Rt(t,e){const n=t.getBlock(e.tableId);if(!n||"table"!==n.type)return null;const o=V(n);switch(e.kind){case"cell":{if(!Ht(e.row,o.rowCount))return null;if(!Ht(e.column,o.columnCount))return null;const r=o.cellAt(e.row,e.column);return r?It(t,n,o,r.rowStart,r.rowEnd-1,r.columnStart,r.columnEnd-1):null}case"range":return zt(t,e.tableId,{tableId:e.tableId,fromRow:e.fromRow,fromCol:e.fromColumn,toRow:e.toRow,toCol:e.toColumn},!0);case"column":return Ht(e.column,o.columnCount)?{state:t,table:n,grid:o,columns:[e.column],rows:[]}:null;case"row":return Ht(e.row,o.rowCount)?{state:t,table:n,grid:o,columns:[],rows:[e.row]}:null}}function zt(t,e,n,o){const r=t.getBlock(e);if(!r||"table"!==r.type)return null;const i=V(r);if(0===i.rowCount||0===i.columnCount)return null;if(![n.fromRow,n.toRow,n.fromCol,n.toCol].every(Number.isInteger))return null;if(o&&(!Ht(n.fromRow,i.rowCount)||!Ht(n.toRow,i.rowCount)||!Ht(n.fromCol,i.columnCount)||!Ht(n.toCol,i.columnCount)))return null;const l=Nt(Math.min(n.fromRow,n.toRow),i.rowCount),s=Nt(Math.max(n.fromRow,n.toRow),i.rowCount),a=F(i,{fromRow:l,fromColumn:Nt(Math.min(n.fromCol,n.toCol),i.columnCount),toRow:s,toColumn:Nt(Math.max(n.fromCol,n.toCol),i.columnCount)});return a?It(t,r,i,a.fromRow,a.toRow,a.fromColumn,a.toColumn):null}function It(t,e,n,o,r,i,l){return{state:t,table:e,grid:n,rows:$t(o,r),columns:$t(i,l)}}function kt(t){const e=xt(t.table,t.grid.columnCount),n=t.columns.map(t=>e[t]??null),o=t.rows.map(e=>{const n=t.grid.rows[e];return n?Ct(n):null});return{columnWidthPx:Mt(n),rowMinHeightPx:Mt(o)}}function At(t,e,n,o){const r=Object.prototype.hasOwnProperty.call(n,"columnWidthPx"),i=Object.prototype.hasOwnProperty.call(n,"rowMinHeightPx");if(!r&&!i)return!1;if(r&&0===e.columns.length)return!1;if(i&&0===e.rows.length)return!1;const l=r?Pt(n.columnWidthPx,o.minColumnWidthPx,o.maxColumnWidthPx):null,s=i?Pt(n.rowMinHeightPx,o.minRowHeightPx,o.maxRowHeightPx):null;if(r&&!l||i&&!s)return!1;const a=e.state.transaction("command");let c=!1;if(l){const t=[...xt(e.table,e.grid.columnCount)];for(const n of e.columns)t[n]!==l.value&&(t[n]=l.value,c=!0);if(c){const n=e.state.getNodePath(e.table.id);if(!n)return!1;a.setNodeAttr(n,vt(e.table.attrs,t))}}if(s)for(const d of e.rows){const t=e.grid.rows[d];if(!t||Ct(t)===s.value)continue;const n=e.state.getNodePath(t.id);if(!n)return!1;a.setNodeAttr(n,yt(t.attrs,s.value)),c=!0}return!!c&&(a.setSelection(e.state.selection),t.dispatch(a.build()),!0)}function Et(t,e,n,o){return At(t,e,"columnWidthPx"===n?{columnWidthPx:"auto"}:"rowMinHeightPx"===n?{rowMinHeightPx:"auto"}:{...e.columns.length>0?{columnWidthPx:"auto"}:{},...e.rows.length>0?{rowMinHeightPx:"auto"}:{}},o)}function Pt(t,e,n){if("auto"===t)return{value:null};const o=R(t,e,n);return null===o?null:{value:o}}function Mt(t){if(0===t.length)return"unavailable";const e=t[0];return t.some(t=>t!==e)?"mixed":null==e?"auto":e}function Lt(t){return"number"!=typeof t||t<1||t>1e4?null:R(t)}function Bt(t,e,n=1){return R(t??e,n,1e4)??e}function Ht(t,e){return Number.isInteger(t)&&t>=0&&t<e}function Nt(t,e){return Math.min(e-1,Math.max(0,t))}function $t(t,e){return Array.from({length:e-t+1},(e,n)=>t+n)}function Tt(t,e,n){const o=t.getBlock(e);if(!o||"table"!==o.type)return null;const r=V(o);if(!Vt(n,r.rowCount)||0===r.columnCount)return null;const i=r.cells.filter(t=>t.rowStart<n&&t.rowEnd>n),a=t.transaction("command");for(const l of i)if(!Zt(t,a,l.cell,"rowspan",l.rowSpan+1))return null;const c=[];for(let l=0;l<r.columnCount;l++)i.some(t=>t.columnStart<=l&&t.columnEnd>l)||c.push(U());const d=l(f("table_row"),c),u=function(t,e,n){if(n>=e.rowCount)return t.children.length;const o=e.rows[n];if(!o)return t.children.length;const r=t.children.findIndex(t=>"id"in t&&t.id===o.id);return-1===r?t.children.length:r}(o,r,n);a.insertNode([e],u,d);const h=s(d)[0],b=h?s(h)[0]:void 0;return b?a.setSelection(m(b.id,0)):h&&a.setSelection(m(h.id,0)),a.build()}function Dt(t,e,n){const o=t.getBlock(e);if(!o||"table"!==o.type)return null;const r=V(o);if(!Vt(n,r.columnCount)||0===r.rowCount)return null;const i=t.transaction("command");if(Yt(o)){const l=[...xt(o,r.columnCount)];l.splice(n,0,null);const s=t.getNodePath(e);if(!s)return null;i.setNodeAttr(s,vt(o.attrs,l))}const l=r.cells.filter(t=>t.columnStart<n&&t.columnEnd>n);for(const s of l)if(!Zt(t,i,s.cell,"colspan",s.columnSpan+1))return null;let a;for(let s=0;s<r.rowCount;s++){const t=r.rows[s];if(!t)continue;if(l.some(t=>t.rowStart<=s&&t.rowEnd>s))continue;const o=U();a??=o;const c=r.cells.filter(e=>e.sourceRow.id===t.id&&e.columnEnd<=n).length;i.insertNode([e,t.id],c,o)}const c=a?s(a)[0]:void 0;return i.setSelection(c?m(c.id,0):t.selection),i.build()}function Wt(t,e,n,o=0){const r=t.getBlock(e);if(!r||"table"!==r.type)return null;const i=V(r);if(!Kt(n,i.rowCount))return null;if(i.rowCount<=1)return _t(t,e);const l=t.transaction("command"),s=i.cells.filter(t=>t.rowStart<=n&&t.rowEnd>n),a=s.filter(t=>t.rowStart===n&&t.rowSpan>1).sort((t,e)=>t.columnStart-e.columnStart);for(const u of s)if(!(u.rowSpan<=1||Zt(t,l,u.cell,"rowspan",u.rowSpan-1)))return null;if(a.length>0){const t=i.rows[n+1];if(!t)return null;const o=i.cells.filter(e=>e.sourceRow.id===t.id);let r=0;for(const n of a){const i=o.filter(t=>t.columnStart<n.columnStart).length+r;l.moveNode([e,n.sourceRow.id],n.sourceCellIndex-r,[e,t.id],i),r++}}const c=function(t,e,n){const o=e.rows[n];return o?t.children.findIndex(t=>"id"in t&&t.id===o.id):-1}(r,i,n);if(c<0)return null;l.removeNode([e],c);const d=J(t,e,n>0?n-1:1,Math.min(Math.max(0,o),i.columnCount-1));if(d){const e=Q(t,d);l.setSelection(m(e,0))}return l.build()}function Ot(t,e,n,o=0){const r=t.getBlock(e);if(!r||"table"!==r.type)return null;const i=V(r);if(!Kt(n,i.columnCount))return null;if(i.columnCount<=1)return _t(t,e);const l=t.transaction("command");if(Yt(r)){const o=[...xt(r,i.columnCount)];o.splice(n,1);const s=t.getNodePath(e);if(!s)return null;l.setNodeAttr(s,vt(r.attrs,o))}const s=i.cells.filter(t=>t.columnStart<=n&&t.columnEnd>n);for(const d of s)if(!(d.columnSpan<=1||Zt(t,l,d.cell,"colspan",d.columnSpan-1)))return null;for(const d of s.filter(t=>1===t.columnSpan).sort((t,e)=>t.sourceRowIndex!==e.sourceRowIndex?e.sourceRowIndex-t.sourceRowIndex:e.sourceCellIndex-t.sourceCellIndex))l.removeNode([e,d.sourceRow.id],d.sourceCellIndex);const a=n>0?n-1:1,c=J(t,e,Math.min(Math.max(0,o),i.rowCount-1),a);if(c){const e=Q(t,c);l.setSelection(m(e,0))}return l.build()}function _t(t,e){const n=t.doc.children.findIndex(t=>t.id===e);if(-1===n)return null;if(1===t.doc.children.length){const e=o(r());return t.transaction("command").insertNode([],0,e).removeNode([],1).setSelection(m(e.id,0)).build()}const i=t.transaction("command").removeNode([],n),l=t.doc.children[n+1];if(l){const e=x(t,l.id,"start");if(e)return i.setSelection(e),i.build()}const s=t.doc.children[n-1];if(s){const e=x(t,s.id,"end");if(e)return i.setSelection(e),i.build()}return null}function jt(t,e,n){const o=t.getState(),i=N(o);if(!i)return!1;const a=function(t,e){const n=r(),o=[];for(let i=0;i<t;i++){const t=[];for(let n=0;n<e;n++)t.push(U());o.push(l(f("table_row"),t,r()))}return l(f("table"),o,n)}(e,n),c=o.transaction("command");if(!v(o,c,i,a))return!1;const d=s(a)[0],u=d?s(d)[0]:void 0,h=u?s(u)[0]:void 0;return h?c.setSelection(m(h.id,0)):u&&c.setSelection(m(u.id,0)),t.dispatch(c.build()),!0}function Ft(t,e){const n=t.getState();if(!p(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=Tt(n,o.tableId,o.rowEnd);return!!r&&(t.dispatch(r),t.announce(e.announceRowInsertedBelow),!0)}function qt(t,e,n){const o=t.getState();if(!p(o.selection))return!1;const r=G(o,o.selection.anchor.blockId);if(!r)return!1;const i="left"===e?r.colIndex:r.colEnd,l=Dt(o,r.tableId,i);return!!l&&(t.dispatch(l),t.announce(n.announceColumnInserted(e)),!0)}function Vt(t,e){return Number.isInteger(t)&&t>=0&&t<=e}function Kt(t,e){return Number.isInteger(t)&&t>=0&&t<e}function Zt(t,e,n,o,r){const i=t.getNodePath(n.id);return!!i&&(e.setNodeAttr(i,function(t,e,n){const o={...t.attrs??{}};return delete o[e],n>1&&(o[e]=n),{...t,attrs:o}}(n,o,r).attrs??{}),!0)}function Yt(t){return Object.prototype.hasOwnProperty.call(t.attrs??{},"columnWidthsPx")}function Xt(t,e){t.registerCommand("insertTable",()=>jt(t,3,3)),t.registerCommand("addRowAbove",()=>function(t,e){const n=t.getState();if(!p(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=Tt(n,o.tableId,o.rowIndex);return!!r&&(t.dispatch(r),t.announce(e.announceRowInsertedAbove),!0)}(t,e)),t.registerCommand("addRowBelow",()=>Ft(t,e)),t.registerCommand("addColumnLeft",()=>function(t,e){return qt(t,"left",e)}(t,e)),t.registerCommand("addColumnRight",()=>function(t,e){return qt(t,"right",e)}(t,e)),t.registerCommand("deleteRow",()=>function(t,e){const n=t.getState();if(!p(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=Wt(n,o.tableId,o.rowIndex,o.colIndex);return!!r&&(t.dispatch(r),t.announce(e.announceRowDeleted),!0)}(t,e)),t.registerCommand("deleteColumn",()=>function(t,e){const n=t.getState();if(!p(n.selection))return!1;const o=G(n,n.selection.anchor.blockId);if(!o)return!1;const r=Ot(n,o.tableId,o.colIndex,o.rowIndex);return!!r&&(t.dispatch(r),t.announce(e.announceColumnDeleted),!0)}(t,e)),t.registerCommand("selectTable",()=>function(t){const e=t.getState(),n=e.selection;if(u(n))return"table"===e.getBlock(n.nodeId)?.type;if(d(n))return!1;const o=G(e,n.anchor.blockId);if(!o)return!1;const r=e.getNodePath(o.tableId);if(!r)return!1;const i=e.transaction("command").setSelection(b(o.tableId,r)).build();return t.dispatch(i),!0}(t)),t.registerCommand("deleteTable",()=>function(t,e){const n=t.getState(),o=function(t){if(u(t.selection)){const e=t.getBlock(t.selection.nodeId);return"table"!==e?.type?null:{tableId:e.id}}if(d(t.selection))return null;const e=G(t,t.selection.anchor.blockId);return e?{tableId:e.tableId}:null}(n);if(!o)return!1;const r=_t(n,o.tableId);return!!r&&(t.dispatch(r),t.announce(e.announceTableDeleted),!0)}(t,e))}function Ut(t,e,n,o,r,i,l){const s=document.createElement("div");s.className="notectl-table-size-editor__field";const a=document.createElement("label");a.htmlFor=`notectl-table-size-${e}`,a.textContent=n;const c=document.createElement("div");c.className="notectl-table-size-editor__input-wrap";const d=document.createElement("input");d.id=a.htmlFor,d.type="number",d.inputMode="decimal",d.step="1",d.min=String(r),d.max=String(i),d.setAttribute("aria-describedby",`${d.id}-error`);const u=document.createElement("span");u.className="notectl-table-size-editor__unit",u.textContent="px",u.setAttribute("aria-hidden","true"),c.append(d,u);const h=document.createElement("div");h.id=`${d.id}-error`,h.className="notectl-table-size-editor__error",h.setAttribute("role","alert"),s.append(a,c,h),t.appendChild(s);const b={input:d,error:h,minimum:r,maximum:i,dirty:!1};return Gt(b,o,l),b}function Gt(t,e,n){t.input.disabled="unavailable"===e,t.input.value="number"==typeof e?String(e):"",t.input.placeholder="mixed"===e?n.mixed:n.automatic,t.dirty=!1,Qt(t)}function Jt(t,e){const n=t.input.value.trim(),o=Number(n);if(0===n.length||!Number.isFinite(o))return t.error.textContent=e.invalidDimensionRange(t.minimum,t.maximum),t.input.setAttribute("aria-invalid","true"),t.input.focus(),null;const r=Math.min(t.maximum,Math.max(t.minimum,o));return t.input.value=String(r),r}function Qt(t){t.error.textContent="",t.input.removeAttribute("aria-invalid")}function te(t,e=""){const n=document.createElement("button");return n.type="button",n.textContent=t,n.className=e,n}function ee(t,e,n){return e?t.resetSize(e,n):t.resetSelectionSize(n)}function ne(t,e,n,o){"columnWidthPx"!==n?"row"===e?.kind||"cell"===e?.kind?t.announce(o.announceRowMinimumHeightReset(e.row)):t.announce(o.resetRowMinimumHeight):"column"===e?.kind||"cell"===e?.kind?t.announce(o.announceColumnWidthReset(e.column)):t.announce(o.resetColumnWidth)}var oe=/* @__PURE__ */new WeakMap;function re(t){for(const e of[...oe.get(t)??[]])e()}function ie(t,e,n,o,r,i=nt,l,s={}){let a=!0,c=null,d=null;const u=document.createElement("div");u.className="notectl-table-context-menu",u.setAttribute("role","menu"),u.setAttribute("aria-label",i.tableActions),u.setAttribute("contenteditable","false"),u.setAttribute("data-notectl-no-print","");const h=[];let b=0;const m=function(t){return[{type:"item",label:t.insertRowAbove,command:"addRowAbove"},{type:"item",label:t.insertRowBelow,command:"addRowBelow"},{type:"separator"},{type:"item",label:t.insertColumnLeft,command:"addColumnLeft"},{type:"item",label:t.insertColumnRight,command:"addColumnRight"},{type:"separator"},{type:"item",label:t.deleteRow,command:"deleteRow"},{type:"item",label:t.deleteColumn,command:"deleteColumn"},{type:"separator"},{type:"submenu",label:t.borderColorLabel,id:"borderColor"},{type:"submenu",label:t.sizeLabel,id:"size"},{type:"separator"},{type:"item",label:t.deleteTable,command:"deleteTable"}]}(i);for(const C of m){if("separator"===C.type){const t=document.createElement("div");t.setAttribute("role","separator"),u.appendChild(t);continue}const t=document.createElement("button");t.type="button",t.setAttribute("role","menuitem"),t.textContent=C.label,"submenu"===C.type&&(t.dataset.submenu=C.id,t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded","false")),"item"===C.type&&(t.dataset.command=C.command),t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),t.addEventListener("click",n=>{n.stopPropagation(),"item"===C.type?(e.executeCommand(C.command),R()):"submenu"===C.type&&f(t)}),h.push(t),u.appendChild(t)}const p=document.createElement("div");function f(e){if(w(),e.setAttribute("aria-expanded","true"),l)d=l.open({anchor:e,position:"right",referenceNode:u,parent:{close:()=>R(),getElement:()=>u},onClose:()=>{d=null,c=null,x()},content:(t,n)=>{t.className="notectl-table-context-menu",t.setAttribute("contenteditable","false"),t.setAttribute("data-notectl-no-print",""),c=t,t.addEventListener("keydown",t=>{if(t.stopPropagation(),t.target instanceof HTMLInputElement)return;const o="rtl"===getComputedStyle(u).direction?"ArrowRight":"ArrowLeft";t.key===o&&(t.preventDefault(),n(),e.focus())}),g(t,e)}});else{c=document.createElement("div"),c.className="notectl-table-context-menu",c.setAttribute("contenteditable","false"),c.setAttribute("data-notectl-no-print",""),c.addEventListener("keydown",t=>{if(t.stopPropagation(),t.target instanceof HTMLInputElement)return;const n="rtl"===getComputedStyle(u).direction?"ArrowRight":"ArrowLeft";t.key===n&&(t.preventDefault(),w(),e.focus())}),g(c,e),t.appendChild(c);const n=u.getBoundingClientRect(),o="rtl"===getComputedStyle(u).direction;D(c,n,{position:"right",isRtl:o}),"size"!==e.dataset.submenu&&requestAnimationFrame(()=>{(c?.querySelector("button"))?.focus()})}}function g(t,o){"size"!==o.dataset.submenu?dt(t,e,n,R,i):function(t,e,n,o=nt){const r=e.getService?.(gt),i=wt(n.config??{}),l=r?function(t,e){return e?t.getSize(e):t.getSelectionSize()}(r,n.target):null;t.classList.add("notectl-table-size-editor"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",o.sizeDialogLabel);const s=document.createElement("div");s.className="notectl-table-size-editor__title",s.textContent=o.sizeDialogLabel,t.appendChild(s);const a=Ut(t,"column-width",o.columnWidthLabel,l?.columnWidthPx??"unavailable",i.minColumnWidthPx,i.maxColumnWidthPx,o),c=Ut(t,"row-min-height",o.rowMinimumHeightLabel,l?.rowMinHeightPx??"unavailable",i.minRowHeightPx,i.maxRowHeightPx,o),d=document.createElement("div");d.className="notectl-table-size-editor__resets";const u=te(o.resetColumnWidth,"notectl-table-size-editor__reset"),h=te(o.resetRowMinimumHeight,"notectl-table-size-editor__reset"),b=te(o.resetAllSizes,"notectl-table-size-editor__reset notectl-table-size-editor__reset--all");u.disabled=a.input.disabled,h.disabled=c.input.disabled,b.disabled=a.input.disabled&&c.input.disabled,d.append(u,h,b),t.appendChild(d);const m=document.createElement("div");m.className="notectl-table-size-editor__actions";const p=te(o.cancel),f=te(o.apply,"notectl-table-size-editor__apply");f.disabled=!r||!!e.isReadOnly?.(),m.append(p,f),t.appendChild(m),a.input.addEventListener("input",()=>{a.dirty=!0,Qt(a)}),c.input.addEventListener("input",()=>{c.dirty=!0,Qt(c)}),f.addEventListener("click",()=>{if(!r||e.isReadOnly?.())return;const t={};let i=!0;if(a.dirty){const e=Jt(a,o);null===e?i=!1:t.columnWidthPx=e}if(c.dirty){const e=Jt(c,o);null===e?i=!1:t.rowMinHeightPx=e}i&&(a.dirty||c.dirty?function(t,e,n){return e?t.setSize(e,n):t.setSelectionSize(n)}(r,n.target,t)&&(function(t,e,n,o){const r=[];"number"==typeof n.columnWidthPx&&("column"===e?.kind||"cell"===e?.kind?r.push(o.announceColumnWidthSet(e.column,n.columnWidthPx)):r.push(`${o.columnWidthLabel}: ${String(n.columnWidthPx)}`)),"number"==typeof n.rowMinHeightPx&&("row"===e?.kind||"cell"===e?.kind?r.push(o.announceRowMinimumHeightSet(e.row,n.rowMinHeightPx)):r.push(`${o.rowMinimumHeightLabel}: ${String(n.rowMinHeightPx)}`)),r.length>0&&t.announce(r.join(" "))}(e,n.target,t,o),n.onClose()):n.onClose())}),p.addEventListener("click",n.onClose),u.addEventListener("click",()=>{r&&ee(r,n.target,"columnWidthPx")&&(Gt(a,"auto",o),ne(e,n.target,"columnWidthPx",o))}),h.addEventListener("click",()=>{r&&ee(r,n.target,"rowMinHeightPx")&&(Gt(c,"auto",o),ne(e,n.target,"rowMinHeightPx",o))}),b.addEventListener("click",()=>{r&&ee(r,n.target)&&(a.input.disabled||Gt(a,"auto",o),c.input.disabled||Gt(c,"auto",o),e.announce(o.announceTableSizesReset))}),t.addEventListener("keydown",e=>{if("Escape"===e.key)return e.preventDefault(),e.stopPropagation(),void n.onClose();"Tab"===e.key&&function(t,e){const n=function(t){return Array.from(t.querySelectorAll("input, button")).filter(t=>!t.disabled)}(t),o=n[0],r=n[n.length-1];if(!o||!r)return;const i=function(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement:document.activeElement}(t),l=e.shiftKey&&(i===o||!t.contains(i)),s=!(e.shiftKey||i!==r&&t.contains(i));(l||s)&&(e.preventDefault(),(l?r:o).focus())}(t,e)}),requestAnimationFrame(()=>{([a.input,c.input].find(t=>!t.disabled)??p).focus()})}(t,e,{target:s.sizeTarget,config:s.sizingConfig,onClose:R},i)}function w(){d?(d.close(),d=null,c=null):c&&(c.remove(),c=null),x()}function x(){for(const t of h)t.dataset.submenu&&t.setAttribute("aria-expanded","false")}p.className="notectl-table-context-menu__hint",p.setAttribute("aria-hidden","true"),p.textContent=i.menuKeyboardHint,u.appendChild(p),T(h,b),u.addEventListener("keydown",t=>{switch(t.stopPropagation(),t.key){case"Escape":return t.preventDefault(),void R();case"ArrowDown":return t.preventDefault(),b=(b+1)%h.length,T(h,b),void h[b]?.focus();case"ArrowUp":return t.preventDefault(),b=(b-1+h.length)%h.length,T(h,b),void h[b]?.focus();case"ArrowRight":case"ArrowLeft":{t.preventDefault();const e="rtl"===getComputedStyle(u).direction?"ArrowLeft":"ArrowRight";if(t.key===e){const t=h[b];t?.dataset.submenu&&f(t)}else w(),h[b]?.focus();return}case"Enter":case" ":{t.preventDefault();const n=h[b];if(!n)return;return void(n.dataset.submenu?f(n):n.dataset.command&&(e.executeCommand(n.dataset.command),R()))}case"Home":return t.preventDefault(),b=0,T(h,b),void h[b]?.focus();case"End":return t.preventDefault(),b=h.length-1,T(h,b),void h[b]?.focus()}}),t.appendChild(u),D(u,o,{position:"below-start",isRtl:C(t)}),h[0]?.focus(),requestAnimationFrame(()=>{a&&h[0]&&h[0].focus()});const v=t=>{const e=t.composedPath();e.includes(u)||c&&e.includes(c)||R()};let y=null,S=!1;function R(){if(!a)return;a=!1,w(),u.remove(),null!==y&&(clearTimeout(y),y=null),S&&(document.removeEventListener("mousedown",v,!0),S=!1),oe.get(e)?.delete(R),r?.();const t=s.restoreFocusTo;t?.isConnected&&requestAnimationFrame(()=>t.focus({preventScroll:!0}))}y=setTimeout(()=>{y=null,document.addEventListener("mousedown",v,!0),S=!0},0);const z=oe.get(e)??/* @__PURE__ */new Set;return z.add(R),oe.set(e,z),{isOpen:()=>a,close:R,destroy:R}}var le=/* @__PURE__ */new WeakMap;function se(t,e){const n=t.getState();if(!p(n.selection))return!1;const o=n.selection,r=G(n,o.anchor.blockId);return!!r&&e(n,o,r)}function ae(t){return se(t,(e,n,o)=>{const r=o.tableIndex+1;if(r>=e.doc.children.length)return!1;const i=e.doc.children[r];if(!i)return!1;const l=e.transaction("command").setSelection(m(i.id,0)).build();return t.dispatch(l),!0})}function ce(t,e){if((t.getService?.(bt)?.getSelectedRange())?.tableId!==e.tableId)return{kind:"cell",tableId:e.tableId,row:e.rowIndex,column:e.colIndex}}function de(t,e,n,o){const r=t.getState().getBlock(e.tableId);if(!r||"table"!==r.type)return!1;const l=V(r).cells,s=l[l.findIndex(t=>t.cell.id===e.cellId)+n];return!!s&&(o?function(t,e,n,o){const r=t.getState(),l=J(r,e,n,o);if(!l)return!1;const s=tt(r,l),a=r.getBlock(s);if(!a)return!1;const c=i(a),d=r.transaction("command").setSelection(m(s,c)).build();return t.dispatch(d),!0}(t,e.tableId,s.rowStart,s.columnStart):ue(t,e.tableId,s.rowStart,s.columnStart))}function ue(t,e,n,o){const r=t.getState(),i=J(r,e,n,o);if(!i)return!1;const l=Q(r,i),s=r.transaction("command").setSelection(m(l,0)).build();return t.dispatch(s),!0}function he(t,e){const n=t.getState(),o=n.getNodePath(e);if(!o)return!1;const r=n.transaction("input").setSelection(b(e,o)).build();return t.dispatch(r),!0}var be='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 1v10M1 6h10" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';function me(t,e,n){const o=document.createElement("button");return o.className=t,o.innerHTML=e,o.title=n,o.type="button",o.setAttribute("aria-label",n),o.setAttribute("contenteditable","false"),o.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),o}function pe(t,e){const n=document.createElement("div");n.className=`ntbl-insert-line ntbl-insert-line--${t}`,n.setAttribute("contenteditable","false"),n.setAttribute("data-notectl-no-print","");const o=me("ntbl-insert-btn",be,e);return n.appendChild(o),n}function fe(t,e){const n=document.createElement("button");n.className=`ntbl-add-zone ${t}`,n.type="button",n.setAttribute("contenteditable","false"),n.setAttribute("aria-label",e),n.setAttribute("data-notectl-no-print",""),n.title=e;const o=document.createElement("span");return o.className="ntbl-add-icon",o.innerHTML=be,n.appendChild(o),n.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),n}function ge(t){const e=document.createElement("div");return e.className=t,e.setAttribute("contenteditable","false"),e.setAttribute("data-notectl-no-print",""),e}function we(t,e,n,o){const r=document.createElement("button");return r.type="button",r.className=`ntbl-resize-separator ntbl-resize-separator--${t}`,r.dataset.kind=t,r.dataset.index=String(e),r.setAttribute("role","separator"),r.setAttribute("aria-orientation","column"===t?"vertical":"horizontal"),r.setAttribute("aria-label",n),r.setAttribute("contenteditable","false"),r.setAttribute("data-notectl-no-print",""),r.title=`${n}. ${o}`,r}function xe(t,e){L(t,"none"===e?{backgroundColor:"transparent",border:"1px dashed rgba(128,128,128,0.4)"}:e?{backgroundColor:e,border:"1px solid rgba(0,0,0,0.15)"}:{backgroundColor:"var(--notectl-border)",border:"1px solid rgba(0,0,0,0.15)"})}function ve(t,e,n,o,r){const i=document.createElement("div");if(i.className=`ntbl-handle ${t}`,i.dataset.index=String(e),r){const t=me("ntbl-handle-select","",r.label);t.setAttribute("aria-pressed",r.selected?"true":"false"),t.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),r.onSelect(e)}),i.appendChild(t)}const l=me("ntbl-handle-delete",'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',n);return l.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),o(e)}),i.appendChild(l),i}function Ce(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return{top:n.top-o.top+e.scrollTop,left:n.left-o.left+e.scrollLeft}}function ye(t,e=0){const n=t.getBoundingClientRect(),o=Array.from(t.querySelectorAll(":scope > colgroup > col"));if(o.length>0){const t=o.map((t,e)=>{const o=t.getBoundingClientRect();return{index:e,position:o.left-n.left,width:o.width}});if(t.every(t=>t.width>0))return t}const r=o.length||e,i=n.width||t.offsetWidth;if(r<=0||i<=0)return[];const l=i/r;return Array.from({length:r},(t,e)=>({index:e,position:l*e,width:l}))}var Se={...ft,directResize:!0},Re=class{tableId;numRows;numCols;currentNode;readOnly=!1;activeRowIndex=-1;activeColIndex=-1;resizeSession=null;colBar;rowBar;colResizeBar;rowResizeBar;resizeIndicator;insertLineH;insertLineV;addRowZone;addColZone;deleteTableBtn;borderColorBtn;actionsBtn;contextHint;observer;wrapperEl;borderColorPopup=null;activeContextMenu=null;container;tableEl;getState;dispatchFn;pluginContext;locale;config;onWrapperScroll=()=>this.positionControls();onPointerMove=t=>this.moveResize(t);onPointerUp=t=>this.finishResize(t);onPointerCancel=t=>this.cancelResize(t);onDocumentKeyDown=t=>{"Escape"===t.key&&this.resizeSession&&(t.preventDefault(),t.stopPropagation(),this.cancelActiveResize())};onMouseMove=t=>{if(this.readOnly||this.resizeSession)return;const e=this.tableEl.getBoundingClientRect(),n=t.clientX-e.left,o=t.clientY-e.top;if(!(n>=-10&&n<=e.width+10&&o>=-10&&o<=e.height+10))return void this.hideInsertLines();const r=function(t,e,n,o){let r=Number.POSITIVE_INFINITY,i=null;for(const a of n){const t=Math.abs(e-a.position);t<r&&t<10&&(r=t,i=a)}let l=Number.POSITIVE_INFINITY,s=null;for(const a of o){const e=Math.abs(t-a.position);e<l&&e<10&&(l=e,s=a)}return i&&(!s||r<=l)?{type:"row",border:i}:s?{type:"col",border:s}:{type:"none",border:null}}(n,o,function(t){const e=t.querySelectorAll(":scope > tbody > tr"),n=t.getBoundingClientRect().top,o=[];for(let r=1;r<e.length;r++){const t=e[r];t&&o.push({position:Math.round(t.getBoundingClientRect().top-n),index:r})}return o}(this.tableEl),function(t,e=0){if("number"==typeof t){if(e<=1)return[];const n=t/e;return Array.from({length:e-1},(t,e)=>({position:Math.round(n*(e+1)),index:e+1}))}const n=ye(t,e);if(n.length<=1)return[];const o="rtl"===getComputedStyle(t).direction;return n.slice(0,-1).map((t,e)=>({position:Math.round(o?t.position:t.position+t.width),index:e+1}))}(this.tableEl,this.numCols));"row"===r.type&&r.border?(this.showHorizontalLine(r.border),this.hideVerticalLine()):"col"===r.type&&r.border?(this.showVerticalLine(r.border),this.hideHorizontalLine()):this.hideInsertLines()};onMouseLeave=()=>{this.hideInsertLines()};constructor(t,e,n,o,r,i,l=nt,s=Se){if(this.container=t,this.tableEl=e,this.getState=o,this.dispatchFn=r,this.pluginContext=i??null,this.locale=l,this.config={...wt(s),directResize:s.directResize??!0},this.wrapperEl=e.closest(".notectl-table-wrapper"),this.tableId=n.id,this.currentNode=n,this.numRows=V(n).rowCount,this.numCols=this.countCols(n),this.colBar=ge("ntbl-col-bar"),this.rowBar=ge("ntbl-row-bar"),this.colResizeBar=ge("ntbl-col-resize-bar"),this.rowResizeBar=ge("ntbl-row-resize-bar"),this.resizeIndicator=function(){const t=document.createElement("div");return t.className="ntbl-resize-indicator",t.setAttribute("aria-hidden","true"),t.setAttribute("contenteditable","false"),t.setAttribute("data-notectl-no-print",""),t}(),this.insertLineH=pe("horizontal",l.insertRow),this.insertLineV=pe("vertical",l.insertColumn),this.addRowZone=fe("ntbl-add-row",l.addRow),this.addColZone=fe("ntbl-add-col",l.addColumn),this.deleteTableBtn=me("ntbl-delete-table-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M9 3h6m-9 4h12M10 11v6m4-6v6m-9 3h14l-1-13H6L5 20z" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>',l.deleteTable),this.deleteTableBtn.setAttribute("data-notectl-no-print",""),i){const t=ct(o(),this.tableId);this.borderColorBtn=function(t,e){const n=me("ntbl-border-color-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M3 3h18v18H3V3zm0 6h18M3 15h18M9 3v18M15 3v18" stroke="currentColor" stroke-width="1.5"/></svg>',t);n.setAttribute("data-notectl-no-print","");const o=document.createElement("span");return o.className="ntbl-border-color-swatch",xe(o,e),n.appendChild(o),n}(l.borderColor,t),this.actionsBtn=function(t){const e=me("ntbl-actions-btn",'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg>',t);return e.setAttribute("data-notectl-no-print",""),e}(l.tableActionsHint)}else this.borderColorBtn=null,this.actionsBtn=null;t.append(this.colBar,this.rowBar,this.insertLineH,this.insertLineV,this.addRowZone,this.addColZone,this.deleteTableBtn),this.config.directResize&&t.append(this.colResizeBar,this.rowResizeBar,this.resizeIndicator),this.borderColorBtn&&t.appendChild(this.borderColorBtn),this.actionsBtn&&t.appendChild(this.actionsBtn),this.contextHint=function(t){const e=document.createElement("div");return e.className="ntbl-context-hint",e.setAttribute("aria-hidden","true"),e.setAttribute("contenteditable","false"),e.setAttribute("data-notectl-no-print",""),e.textContent=t,e}(l.contextMenuHint),t.appendChild(this.contextHint),this.rebuildColHandles(),this.rebuildRowHandles(),this.rebuildResizeSeparators(),this.bindEventListeners(),this.setReadOnly(i?.isReadOnly?.()??!1),this.observer=new ResizeObserver(()=>{this.positionControls()}),this.observer.observe(e),this.wrapperEl&&(this.observer.observe(this.wrapperEl),this.wrapperEl.addEventListener("scroll",this.onWrapperScroll,{passive:!0})),requestAnimationFrame(()=>this.positionControls())}update(t){this.tableId=t.id,this.currentNode=t;const e=V(t).rowCount,n=this.countCols(t);if(e===this.numRows&&n===this.numCols||(this.numRows=e,this.numCols=n,this.rebuildColHandles(),this.rebuildRowHandles(),this.rebuildResizeSeparators()),this.updateHandleSelectionState(),this.borderColorBtn){const e=this.borderColorBtn.querySelector(".ntbl-border-color-swatch");if(e){const n=t.attrs?.borderColor;xe(e,n)}}requestAnimationFrame(()=>this.positionControls())}setReadOnly(t){this.readOnly=t,this.container.toggleAttribute("data-notectl-table-readonly",t);const e=[this.colBar,this.rowBar,this.colResizeBar,this.rowResizeBar,this.addRowZone,this.addColZone,this.deleteTableBtn,this.insertLineH,this.insertLineV,...this.borderColorBtn?[this.borderColorBtn]:[],...this.actionsBtn?[this.actionsBtn]:[]];for(const n of e){n instanceof HTMLButtonElement&&(n.disabled=t);for(const e of n.querySelectorAll("button"))e.disabled=t}t&&(this.hideInsertLines(),this.cancelActiveResize(),this.activeContextMenu?.close(),this.activeContextMenu=null,this.closeBorderColorPopup())}destroy(){this.cancelActiveResize(),this.activeContextMenu?.destroy(),this.closeBorderColorPopup(),this.observer.disconnect(),this.wrapperEl?.removeEventListener("scroll",this.onWrapperScroll),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.colBar.remove(),this.rowBar.remove(),this.colResizeBar.remove(),this.rowResizeBar.remove(),this.resizeIndicator.remove(),this.insertLineH.remove(),this.insertLineV.remove(),this.addRowZone.remove(),this.addColZone.remove(),this.deleteTableBtn.remove(),this.borderColorBtn?.remove(),this.actionsBtn?.remove(),this.contextHint.remove()}bindEventListeners(){const t=this.insertLineH.querySelector(".ntbl-insert-btn"),e=this.insertLineV.querySelector(".ntbl-insert-btn");if(t.addEventListener("click",()=>{this.activeRowIndex>=0&&this.dispatchTransaction(Tt(this.getState(),this.tableId,this.activeRowIndex))}),e.addEventListener("click",()=>{this.activeColIndex>=0&&this.dispatchTransaction(Dt(this.getState(),this.tableId,this.activeColIndex))}),this.addRowZone.addEventListener("click",()=>{this.dispatchTransaction(Tt(this.getState(),this.tableId,this.numRows))}),this.addColZone.addEventListener("click",()=>{this.dispatchTransaction(Dt(this.getState(),this.tableId,this.numCols))}),this.deleteTableBtn.addEventListener("click",()=>{this.dispatchTransaction(_t(this.getState(),this.tableId))}),this.borderColorBtn&&this.pluginContext){const t=this.pluginContext;this.borderColorBtn.addEventListener("click",()=>{this.toggleBorderColorPopup(t)})}if(this.actionsBtn&&this.pluginContext){const t=this.pluginContext;this.actionsBtn.addEventListener("click",()=>{this.openActionsMenu(t)})}this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseleave",this.onMouseLeave)}openActionsMenu(t){if(this.readOnly||t.isReadOnly?.())return;if(this.activeContextMenu?.isOpen())return this.activeContextMenu.close(),void(this.activeContextMenu=null);if(!this.actionsBtn)return;const e=this.actionsBtn.getBoundingClientRect();this.activeContextMenu=ie(this.container,t,this.tableId,e,()=>{this.activeContextMenu=null},this.locale,void 0,{sizingConfig:this.config,restoreFocusTo:this.actionsBtn})}toggleBorderColorPopup(t){this.readOnly||t.isReadOnly?.()||(this.borderColorPopup?this.closeBorderColorPopup():(this.borderColorPopup=document.createElement("div"),this.borderColorPopup.className="notectl-table-context-menu",L(this.borderColorPopup,{position:"absolute",top:"24px",left:"24px",zIndex:"10000"}),this.borderColorPopup.setAttribute("contenteditable","false"),dt(this.borderColorPopup,t,this.tableId,()=>{this.closeBorderColorPopup()},this.locale),this.container.appendChild(this.borderColorPopup)))}closeBorderColorPopup(){this.borderColorPopup&&(this.borderColorPopup.remove(),this.borderColorPopup=null)}dispatchTransaction(t){!t||this.readOnly||this.pluginContext?.isReadOnly?.()||this.dispatchFn(t)}countCols(t){return V(t).columnCount}positionControls(){const t=Ce(this.tableEl,this.container),e=this.tableEl.getBoundingClientRect();L(this.colBar,{left:`${String(t.left)}px`,top:`${String(t.top-24)}px`}),P(this.rowBar,"top",`${String(t.top)}px`),function(t,e,n=0){const o=t.children;if(0===o.length)return;const r="number"==typeof e?Array.from({length:n},(t,o)=>({index:o,position:e/n*o,width:e/n})):ye(e,n);for(let l=0;l<o.length;l++){const t=o[l],e=r[l];e&&L(t,{left:`${Math.round(e.position)}px`,width:`${Math.round(e.width)}px`})}const i=r.reduce((t,e)=>Math.max(t,e.position+e.width),0);P(t,"width",`${Math.round(i)}px`)}(this.colBar,this.tableEl,this.numCols),function(t,e){const n=t.children;if(0===n.length)return;const o=e.querySelectorAll(":scope > tbody > tr"),r=e.getBoundingClientRect();let i=0;for(let l=0;l<n.length;l++){const t=n[l],e=o[l];if(e){const n=e.getBoundingClientRect(),o=n.top-r.top,l=n.height||e.offsetHeight;L(t,{top:`${o}px`,height:`${l}px`}),i=o+l}}P(t,"height",`${i}px`)}(this.rowBar,this.tableEl),function(t,e,n,o){const r=Ce(n,o),i=n.getBoundingClientRect(),l=i.height||n.offsetHeight;L(t,{width:`${i.width||n.offsetWidth}px`,left:`${r.left}px`}),L(e,{height:`${l}px`,top:`${r.top}px`})}(this.addRowZone,this.addColZone,this.tableEl,this.container),this.config.directResize&&this.positionResizeSeparators(t,e)}positionResizeSeparators(t,e){L(this.colResizeBar,{left:`${String(t.left)}px`,top:`${String(t.top)}px`,width:`${String(e.width)}px`,height:`${String(e.height)}px`}),L(this.rowResizeBar,{left:`${String(t.left)}px`,top:`${String(t.top)}px`,width:`${String(e.width)}px`,height:`${String(e.height)}px`});const n="rtl"===getComputedStyle(this.tableEl).direction,o=ye(this.tableEl,this.numCols);for(let i=0;i<this.colResizeBar.children.length;i++){const t=this.colResizeBar.children[i],r=o[i];if(!r)continue;const l=n?r.position:r.position+r.width;L(t,{left:`${String(l)}px`,top:"0px",height:`${String(e.height)}px`}),this.updateSeparatorValue(t,"column",i,r.width)}const r=Array.from(this.tableEl.querySelectorAll(":scope > tbody > tr"));for(let i=0;i<this.rowResizeBar.children.length;i++){const t=this.rowResizeBar.children[i],n=r[i];if(!n)continue;const o=n.getBoundingClientRect(),l=o.bottom-e.top;L(t,{left:"0px",top:`${String(l)}px`,width:`${String(e.width)}px`}),this.updateSeparatorValue(t,"row",i,o.height||n.offsetHeight)}}updateSeparatorValue(t,e,n,o){const r="column"===e?this.config.minColumnWidthPx:this.config.minRowHeightPx,i="column"===e?this.config.maxColumnWidthPx:this.config.maxRowHeightPx,l=Math.round(o);t.setAttribute("aria-valuemin",String(r)),t.setAttribute("aria-valuemax",String(i)),t.setAttribute("aria-valuenow",String(l)),t.setAttribute("aria-valuetext",`${String(l)} px`),t.dataset.index=String(n)}startResize(t,e,n){if(this.readOnly||this.pluginContext?.isReadOnly?.()||0!==t.button&&"touch"!==t.pointerType)return;const o=this.getRenderedDimension(e,n);null!==o&&(t.preventDefault(),t.stopPropagation(),this.cancelActiveResize(),this.resizeSession={kind:e,index:n,pointerId:t.pointerId,startCoordinate:"column"===e?t.clientX:t.clientY,startSize:o,currentSize:o},t.currentTarget?.setPointerCapture?.(t.pointerId),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("pointercancel",this.onPointerCancel),document.addEventListener("keydown",this.onDocumentKeyDown,!0),this.container.classList.add(`ntbl-container--resizing-${e}`),this.updateResizeIndicator(o,t.clientX,t.clientY))}moveResize(t){const e=this.resizeSession;if(!e||e.pointerId!==t.pointerId)return;t.preventDefault();let n=("column"===e.kind?t.clientX:t.clientY)-e.startCoordinate;"column"===e.kind&&"rtl"===getComputedStyle(this.tableEl).direction&&(n*=-1);const o=this.clampDimension(e.kind,e.startSize+n);e.currentSize=o,this.applyResizePreview(e.kind,e.index,o),this.updateResizeIndicator(o,t.clientX,t.clientY),this.positionControls()}finishResize(t){const e=this.resizeSession;if(!e||e.pointerId!==t.pointerId)return;t.currentTarget?.releasePointerCapture?.(t.pointerId),this.resizeSession=null,this.detachResizeListeners(),this.hideResizeIndicator();const n=Math.round(e.currentSize),o=this.getSizingService();("column"===e.kind?o?.setSize({kind:"column",tableId:this.tableId,column:e.index},{columnWidthPx:n}):o?.setSize({kind:"row",tableId:this.tableId,row:e.index},{rowMinHeightPx:n}))?"column"===e.kind?this.pluginContext?.announce(this.locale.announceColumnWidthSet(e.index,n)):this.pluginContext?.announce(this.locale.announceRowMinimumHeightSet(e.index,n)):this.restoreCanonicalDimensions()}cancelResize(t){this.resizeSession?.pointerId===t.pointerId&&this.cancelActiveResize()}cancelActiveResize(){this.resizeSession&&(this.resizeSession=null,this.detachResizeListeners(),this.hideResizeIndicator(),this.restoreCanonicalDimensions(),this.positionControls())}detachResizeListeners(){document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerCancel),document.removeEventListener("keydown",this.onDocumentKeyDown,!0),this.container.classList.remove("ntbl-container--resizing-column"),this.container.classList.remove("ntbl-container--resizing-row")}getRenderedDimension(t,e){if("column"===t)return ye(this.tableEl,this.numCols)[e]?.width??null;const n=Array.from(this.tableEl.querySelectorAll(":scope > tbody > tr"))[e];return n&&(n.getBoundingClientRect().height||n.offsetHeight)||null}clampDimension(t,e){const n="column"===t?this.config.minColumnWidthPx:this.config.minRowHeightPx,o="column"===t?this.config.maxColumnWidthPx:this.config.maxRowHeightPx;return Math.min(o,Math.max(n,e))}applyResizePreview(t,e,n){if("column"===t){const t=this.tableEl.querySelectorAll(":scope > colgroup > col")[e];if(!t)return;M(t,"width"),t.setAttribute("width",String(n));const o=xt(this.currentNode,this.numCols),r=o.reduce((t,o,r)=>t+(r===e?n:o??this.config.minColumnWidthPx),0);return P(this.tableEl,"minWidth",`${String(r)}px`),void(o.length>=this.numCols&&o.every((t,n)=>n===e||null!==t)?P(this.tableEl,"width",`${String(r)}px`):M(this.tableEl,"width"))}const o=this.tableEl.querySelectorAll(":scope > tbody > tr")[e];o&&(M(o,"height"),o.setAttribute("height",String(n)))}restoreCanonicalDimensions(){const t=xt(this.currentNode,this.numCols),e=Array.from(this.tableEl.querySelectorAll(":scope > colgroup > col"));let n=0;for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const r=t[i]??null;o.removeAttribute("width"),null===r?(M(o,"width"),o.removeAttribute("data-notectl-width-px")):(P(o,"width",`${String(r)}px`),o.setAttribute("data-notectl-width-px",String(r))),n+=r??this.config.minColumnWidthPx}P(this.tableEl,"minWidth",`${String(n)}px`),t.length>=this.numCols&&t.every(t=>null!==t)?P(this.tableEl,"width",`${String(n)}px`):M(this.tableEl,"width");const o=s(this.currentNode),r=Array.from(this.tableEl.querySelectorAll(":scope > tbody > tr"));for(let i=0;i<r.length;i++){const t=r[i],e=o[i];if(!t||!e)continue;t.removeAttribute("height");const n=Ct(e);null===n?(M(t,"height"),t.removeAttribute("data-notectl-min-height-px")):(P(t,"height",`${String(n)}px`),t.setAttribute("data-notectl-min-height-px",String(n)))}}updateResizeIndicator(t,e,n){const o=this.container.getBoundingClientRect();this.resizeIndicator.textContent=`${String(Math.round(t))} px`,L(this.resizeIndicator,{left:`${String(e-o.left+this.container.scrollLeft+12)}px`,top:`${String(n-o.top+this.container.scrollTop+12)}px`}),this.resizeIndicator.classList.add("ntbl-resize-indicator--visible")}hideResizeIndicator(){this.resizeIndicator.classList.remove("ntbl-resize-indicator--visible")}showHorizontalLine(t){this.activeRowIndex=t.index;const e=Ce(this.tableEl,this.container);L(this.insertLineH,{top:e.top+t.position-1+"px",left:`${e.left}px`,width:`${this.tableEl.offsetWidth}px`}),this.insertLineH.classList.add("ntbl-insert-line--visible")}showVerticalLine(t){this.activeColIndex=t.index;const e=Ce(this.tableEl,this.container);L(this.insertLineV,{left:e.left+t.position-1+"px",top:`${e.top}px`,height:`${this.tableEl.offsetHeight}px`}),this.insertLineV.classList.add("ntbl-insert-line--visible")}hideInsertLines(){this.hideHorizontalLine(),this.hideVerticalLine()}hideHorizontalLine(){this.insertLineH.classList.remove("ntbl-insert-line--visible"),this.activeRowIndex=-1}hideVerticalLine(){this.insertLineV.classList.remove("ntbl-insert-line--visible"),this.activeColIndex=-1}rebuildColHandles(){this.colBar.innerHTML="";for(let t=0;t<this.numCols;t++){const e=ve("ntbl-col-handle",t,this.locale.deleteColumn,t=>{this.dispatchTransaction(Ot(this.getState(),this.tableId,t))},{label:this.locale.selectColumnLabel(t),onSelect:t=>this.selectColumn(t)});this.colBar.appendChild(e)}}rebuildRowHandles(){this.rowBar.innerHTML="";for(let t=0;t<this.numRows;t++){const e=ve("ntbl-row-handle",t,this.locale.deleteRow,t=>{this.dispatchTransaction(Wt(this.getState(),this.tableId,t))},{label:this.locale.selectRowLabel(t),onSelect:t=>this.selectRow(t)});this.rowBar.appendChild(e)}}rebuildResizeSeparators(){if(this.colResizeBar.innerHTML="",this.rowResizeBar.innerHTML="",!this.config.directResize)return;const t=this.locale.resizeKeyboardHint(this.config.keyboardResizeStepPx,this.config.keyboardResizeLargeStepPx);for(let e=0;e<this.numCols;e++){const n=we("column",e,this.locale.resizeColumnSeparatorLabel(e),t);n.addEventListener("pointerdown",t=>this.startResize(t,"column",e)),n.addEventListener("keydown",t=>this.resizeFromKeyboard(t,"column",e)),this.colResizeBar.appendChild(n)}for(let e=0;e<this.numRows;e++){const n=we("row",e,this.locale.resizeRowSeparatorLabel(e),t);n.addEventListener("pointerdown",t=>this.startResize(t,"row",e)),n.addEventListener("keydown",t=>this.resizeFromKeyboard(t,"row",e)),this.rowResizeBar.appendChild(n)}this.setReadOnly(this.readOnly)}resizeFromKeyboard(t,e,n){if(this.readOnly||this.pluginContext?.isReadOnly?.())return;const o=this.getSizingService();if(!o)return;const r=t.currentTarget;if("Delete"===t.key||"Backspace"===t.key){t.preventDefault(),t.stopPropagation();const i="column"===e?{kind:"column",tableId:this.tableId,column:n}:{kind:"row",tableId:this.tableId,row:n},l="column"===e?"columnWidthPx":"rowMinHeightPx";return void(o.resetSize(i,l)&&(this.restoreKeyboardResizeFocus(r),this.pluginContext?.announce("column"===e?this.locale.announceColumnWidthReset(n):this.locale.announceRowMinimumHeightReset(n))))}const i="column"===e?"ArrowLeft":"ArrowUp",l="column"===e?"ArrowRight":"ArrowDown";if(t.key!==i&&t.key!==l)return;t.preventDefault(),t.stopPropagation();const s=this.getRenderedDimension(e,n);if(null===s)return;const a=t.shiftKey?this.config.keyboardResizeLargeStepPx:this.config.keyboardResizeStepPx;let c=t.key===l?1:-1;"column"===e&&"rtl"===getComputedStyle(this.tableEl).direction&&(c=1===c?-1:1);const d=Math.round(this.clampDimension(e,s+a*c));("column"===e?o.setSize({kind:"column",tableId:this.tableId,column:n},{columnWidthPx:d}):o.setSize({kind:"row",tableId:this.tableId,row:n},{rowMinHeightPx:d}))&&(this.restoreKeyboardResizeFocus(r),this.pluginContext?.announce("column"===e?this.locale.announceColumnWidthSet(n,d):this.locale.announceRowMinimumHeightSet(n,d)),this.updateSeparatorValue(r,e,n,d))}restoreKeyboardResizeFocus(t){t.isConnected&&t.focus({preventScroll:!0})}selectColumn(t){this.readOnly||0===this.numRows||(this.getSelectionService()?.setSelectedRange({tableId:this.tableId,fromRow:0,fromCol:t,toRow:this.numRows-1,toCol:t}),this.updateHandleSelectionState())}selectRow(t){this.readOnly||0===this.numCols||(this.getSelectionService()?.setSelectedRange({tableId:this.tableId,fromRow:t,fromCol:0,toRow:t,toCol:this.numCols-1}),this.updateHandleSelectionState())}updateHandleSelectionState(){const t=this.getSelectionService()?.getSelectedRange();for(let e=0;e<this.colBar.children.length;e++){const n=!!t&&t.tableId===this.tableId&&Math.min(t.fromCol,t.toCol)===e&&Math.max(t.fromCol,t.toCol)===e&&0===Math.min(t.fromRow,t.toRow)&&Math.max(t.fromRow,t.toRow)===this.numRows-1;this.colBar.children[e]?.querySelector(".ntbl-handle-select")?.setAttribute("aria-pressed",n?"true":"false")}for(let e=0;e<this.rowBar.children.length;e++){const n=!!t&&t.tableId===this.tableId&&Math.min(t.fromRow,t.toRow)===e&&Math.max(t.fromRow,t.toRow)===e&&0===Math.min(t.fromCol,t.toCol)&&Math.max(t.fromCol,t.toCol)===this.numCols-1;this.rowBar.children[e]?.querySelector(".ntbl-handle-select")?.setAttribute("aria-pressed",n?"true":"false")}}getSizingService(){return this.pluginContext?.getService?.(gt)}getSelectionService(){return this.pluginContext?.getService?.(bt)}},ze={minColumnWidthPx:60,minRowHeightPx:24,maxColumnWidthPx:1e4,maxRowHeightPx:1e4,keyboardResizeStepPx:8,keyboardResizeLargeStepPx:32,directResize:!0};function Ie(t,e){"none"===e?(P(t,"--ntbl-border-color","transparent"),t.classList.add("notectl-table--borderless")):e?(P(t,"--ntbl-border-color",e),t.classList.remove("notectl-table--borderless")):(M(t,"--ntbl-border-color"),t.classList.remove("notectl-table--borderless"))}function ke(t,e,n,o=ze){const r=V(n).columnCount;for(P(t,"--ntbl-min-column-width",`${String(o.minColumnWidthPx)}px`);e.children.length>r;)e.lastElementChild?.remove();for(;e.children.length<r;)e.appendChild(document.createElement("col"));const i=n.attrs?.columnWidthsPx,l=Array.isArray(i)?i:[];let s=0;for(let a=0;a<r;a++){const t=e.children[a];if(!t)continue;t.removeAttribute("width");const n=l[a],r="number"==typeof n&&Number.isFinite(n)&&n>0?n:void 0;void 0!==r?(P(t,"width",`${String(r)}px`),t.setAttribute("data-notectl-width-px",String(r))):(M(t,"width"),t.removeAttribute("data-notectl-width-px")),s+=r??o.minColumnWidthPx}r>0?(P(t,"minWidth",`${String(s)}px`),l.length>=r&&l.slice(0,r).every(t=>"number"==typeof t)?P(t,"width",`${String(s)}px`):M(t,"width")):(M(t,"minWidth"),M(t,"width"))}function Ae(t,e){const n=e.attrs?.minHeightPx;t.removeAttribute("height"),"number"==typeof n&&Number.isFinite(n)&&n>0?(P(t,"height",`${String(n)}px`),t.setAttribute("data-notectl-min-height-px",String(n))):(M(t,"height"),t.removeAttribute("data-notectl-min-height-px"))}function Ee(t,e){const n=Array.from(t.querySelectorAll(":scope > tr"));for(const o of s(e)){const t=n.find(t=>t.getAttribute("data-block-id")===o.id);t&&Ae(t,o)}}function Pe(t){if(!t)return;const{borderColor:e,columnWidthsPx:n,...o}=t;return Object.keys(o).length>0?o:void 0}function Me(t){if(!t)return;const{minHeightPx:e,...n}=t;return Object.keys(n).length>0?n:void 0}var Le={maxPickerRows:8,maxPickerCols:8,...ft,directResize:!0},Be="border: 1px solid var(--ntbl-bc, #d0d0d0); padding: 8px 12px; vertical-align: top",He=class{id="table";name="Table";priority=40;config;locale;selectionService=null;cleanupMouseSelection=null;cleanupClipboard=null;context=null;controls=/* @__PURE__ */new Set;constructor(t){const e=wt(t??{});this.config={...Le,...t,...e,maxPickerRows:Ne(t?.maxPickerRows,Le.maxPickerRows),maxPickerCols:Ne(t?.maxPickerCols,Le.maxPickerCols),directResize:t?.directResize??!0}}async init(t){this.locale=await $(t,this.config.locale,nt,rt),t.registerStyleSheet('\n/* Table */\n.notectl-table-wrapper {\n\tmargin: 8px 0;\n\toverflow-x: auto;\n\tposition: relative;\n}\n\n.notectl-table {\n\twidth: 100%;\n\tborder-collapse: collapse;\n\ttable-layout: fixed;\n}\n\n.notectl-table col {\n\tbox-sizing: border-box;\n}\n\n/* Border resolution order: per-table local override → theme component token → theme global token.\n * The inline --ntbl-border-color is set by the toolbar\'s "border color" action and must win\n * over the theme so per-table customizations remain visible after a theme switch.\n */\n.notectl-table td {\n\tborder: 1px solid var(--ntbl-border-color, var(--notectl-table-border, var(--notectl-border)));\n\tbackground: var(--notectl-table-cell-bg, transparent);\n\tpadding: 8px 12px;\n\tmin-width: var(--ntbl-min-column-width, 60px);\n\tvertical-align: top;\n\tmin-height: 1.6em;\n}\n\n.notectl-table th {\n\tborder: 1px solid var(--ntbl-border-color, var(--notectl-table-border, var(--notectl-border)));\n\tbackground: var(--notectl-table-header-bg, var(--notectl-surface-raised));\n\tpadding: 8px 12px;\n\tmin-width: var(--ntbl-min-column-width, 60px);\n\tvertical-align: top;\n\ttext-align: start;\n\tfont-weight: 600;\n}\n\n.notectl-table--borderless td {\n\tborder: 1px dashed rgba(128, 128, 128, 0.15);\n}\n\n@media print {\n\t.notectl-table--borderless td {\n\t\tborder: none;\n\t}\n}\n\n.notectl-table td:focus-within {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-table-cell--selected {\n\tbackground: var(--notectl-primary-muted);\n}\n\n/* Table Context Menu */\n.notectl-table-context-menu {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\tpadding: 4px 0;\n\tmin-width: 180px;\n\tz-index: 10000;\n}\n\n.notectl-table-context-menu button {\n\tdisplay: block;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: start;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tfont-family: inherit;\n}\n\n.notectl-table-context-menu button:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-table-context-menu hr {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 4px 0;\n}\n\n/* === Table Controls === */\n\n/* Outer container for table + controls */\n.ntbl-container {\n\tposition: relative;\n\tmargin: 8px 0;\n\tpadding-block-start: 24px;\n\tpadding-inline-start: 24px;\n}\n\n.ntbl-container .notectl-table-wrapper {\n\tmargin: 0;\n}\n\n.ntbl-container.notectl-table--selected .notectl-table-wrapper {\n\toutline: 2px solid var(--notectl-primary-fg);\n\toutline-offset: 2px;\n\tborder-radius: 6px;\n}\n\n/* --- Column Handle Bar --- */\n.ntbl-col-bar {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 24px;\n\theight: 20px;\n\tdisplay: flex;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tz-index: 3;\n\tpointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-col-bar,\n.ntbl-container:focus-within .ntbl-col-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-col-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n/* --- Row Handle Bar --- */\n.ntbl-row-bar {\n\tposition: absolute;\n\ttop: 24px;\n\tinset-inline-start: 0;\n\twidth: 20px;\n\tdisplay: flex;\n\tflex-direction: column;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tz-index: 3;\n\tpointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-row-bar,\n.ntbl-container:focus-within .ntbl-row-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-row-bar {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n/* --- Handle (shared base) --- */\n.ntbl-handle {\n\tposition: absolute;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\ttransition: background 0.15s ease;\n\tborder-radius: 3px;\n}\n\n.ntbl-handle-select {\n\tposition: absolute;\n\tinset: 0;\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0;\n\tborder-radius: inherit;\n\tbackground: transparent;\n\tcursor: pointer;\n}\n\n.ntbl-handle-select[aria-pressed="true"] {\n\tbackground: var(--notectl-primary-muted);\n\tbox-shadow: inset 0 0 0 1px var(--notectl-primary);\n}\n\n.ntbl-handle-select:focus-visible {\n\toutline: none;\n\tbox-shadow: inset 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-col-handle {\n\theight: 100%;\n\tbackground: var(--notectl-hover-bg);\n\tborder-radius: 4px 4px 0 0;\n}\n\n.ntbl-col-handle:hover {\n\tbackground: var(--notectl-border);\n}\n\n.ntbl-row-handle {\n\twidth: 100%;\n\tbackground: var(--notectl-hover-bg);\n\tborder-start-start-radius: 4px;\n\tborder-end-start-radius: 4px;\n}\n\n.ntbl-row-handle:hover {\n\tbackground: var(--notectl-border);\n}\n\n/* --- Handle Delete Button --- */\n.ntbl-handle-delete {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\theight: 16px;\n\tborder: none;\n\tbackground: transparent;\n\tcolor: var(--notectl-fg-muted);\n\tcursor: pointer;\n\tborder-radius: 3px;\n\tpadding: 0;\n\topacity: 0;\n\ttransform: scale(0.7);\n\ttransition: opacity 0.15s, transform 0.15s,\n\t\tbackground 0.15s, color 0.15s;\n\tz-index: 1;\n}\n\n/* --- Logical column/row resize separators --- */\n.ntbl-col-resize-bar,\n.ntbl-row-resize-bar {\n\tposition: absolute;\n\tinset: 0 auto auto 0;\n\tz-index: 8;\n\tpointer-events: none;\n}\n\n.ntbl-resize-separator {\n\tposition: absolute;\n\tdisplay: block;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tbackground: transparent;\n\topacity: 0;\n\tpointer-events: none;\n\ttouch-action: none;\n}\n\n.ntbl-resize-separator--column {\n\twidth: 12px;\n\ttransform: translateX(-6px);\n\tcursor: col-resize;\n}\n\n.ntbl-resize-separator--row {\n\theight: 12px;\n\ttransform: translateY(-6px);\n\tcursor: row-resize;\n}\n\n.ntbl-container:hover .ntbl-resize-separator,\n.ntbl-container:focus-within .ntbl-resize-separator,\n.ntbl-container.notectl-table--selected .ntbl-resize-separator,\n.ntbl-container--resizing-column .ntbl-resize-separator--column,\n.ntbl-container--resizing-row .ntbl-resize-separator--row {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-resize-separator::after {\n\tcontent: "";\n\tposition: absolute;\n\tbackground: var(--notectl-primary);\n\topacity: 0.35;\n}\n\n.ntbl-resize-separator--column::after {\n\tinset: 0 auto 0 5px;\n\twidth: 2px;\n}\n\n.ntbl-resize-separator--row::after {\n\tinset: 5px 0 auto 0;\n\theight: 2px;\n}\n\n.ntbl-resize-separator:hover::after,\n.ntbl-resize-separator:focus-visible::after {\n\topacity: 1;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-resize-separator:focus-visible {\n\toutline: none;\n}\n\n.ntbl-resize-indicator {\n\tposition: absolute;\n\tdisplay: none;\n\tz-index: 12;\n\tpadding: 3px 7px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-fg);\n\tcolor: var(--notectl-bg);\n\tfont: 12px/1.4 monospace;\n\tpointer-events: none;\n\twhite-space: nowrap;\n}\n\n.ntbl-resize-indicator--visible {\n\tdisplay: block;\n}\n\n.ntbl-container--resizing-column,\n.ntbl-container--resizing-column * {\n\tcursor: col-resize !important;\n\tuser-select: none !important;\n}\n\n.ntbl-container--resizing-row,\n.ntbl-container--resizing-row * {\n\tcursor: row-resize !important;\n\tuser-select: none !important;\n}\n\n.ntbl-handle:hover .ntbl-handle-delete,\n.ntbl-handle:focus-within .ntbl-handle-delete {\n\topacity: 1;\n\ttransform: scale(1);\n}\n\n.ntbl-handle-delete:hover,\n.ntbl-handle-delete:focus-visible {\n\tbackground: var(--notectl-danger-muted);\n\tcolor: var(--notectl-danger);\n}\n\n.ntbl-handle-delete:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Insert Lines --- */\n.ntbl-insert-line {\n\tposition: absolute;\n\tpointer-events: none;\n\topacity: 0;\n\ttransition: opacity 0.15s ease;\n\tz-index: 6;\n}\n\n.ntbl-insert-line--visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.ntbl-insert-line--horizontal {\n\theight: 2px;\n\tbackground: linear-gradient(\n\t\t90deg,\n\t\ttransparent,\n\t\tvar(--notectl-primary) 8%,\n\t\tvar(--notectl-primary) 92%,\n\t\ttransparent\n\t);\n\tbox-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--vertical {\n\twidth: 2px;\n\tbackground: linear-gradient(\n\t\t180deg,\n\t\ttransparent,\n\t\tvar(--notectl-primary) 8%,\n\t\tvar(--notectl-primary) 92%,\n\t\ttransparent\n\t);\n\tbox-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n/* --- Insert Button on Line --- */\n.ntbl-insert-btn {\n\tposition: absolute;\n\twidth: 20px;\n\theight: 20px;\n\tborder-radius: 50%;\n\tbackground: var(--notectl-surface-raised);\n\tborder: 2px solid var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n\tcursor: pointer;\n\tpointer-events: all;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: 0;\n\tbox-shadow: 0 2px 8px var(--notectl-focus-ring);\n\ttransition: background 0.15s, color 0.15s,\n\t\ttransform 0.15s, box-shadow 0.15s;\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn {\n\tleft: 50%;\n\ttop: -9px;\n\ttransform: translateX(-50%);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn {\n\ttop: 50%;\n\tinset-inline-start: -9px;\n\ttransform: translateY(-50%);\n}\n\n.ntbl-insert-btn:hover,\n.ntbl-insert-btn:focus-visible {\n\tbackground: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg);\n\tbox-shadow: 0 2px 12px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn:hover {\n\ttransform: translateX(-50%) scale(1.2);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn:hover {\n\ttransform: translateY(-50%) scale(1.2);\n}\n\n/* --- Add Row / Add Column Zones --- */\n.ntbl-add-zone {\n\tposition: absolute;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\tuser-select: none;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.2s ease,\n\t\tborder-color 0.2s ease;\n}\n\n.ntbl-container:hover .ntbl-add-zone,\n.ntbl-container:focus-within .ntbl-add-zone {\n\topacity: 1;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-add-zone {\n\topacity: 1;\n}\n\n.ntbl-delete-table-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-danger);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-danger);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n}\n\n.ntbl-container:hover .ntbl-delete-table-btn,\n.ntbl-container:focus-within .ntbl-delete-table-btn,\n.ntbl-container.notectl-table--selected .ntbl-delete-table-btn {\n\topacity: 1;\n}\n\n.ntbl-delete-table-btn:hover,\n.ntbl-delete-table-btn:focus-visible {\n\tbackground: var(--notectl-danger-muted);\n\tborder-color: var(--notectl-danger);\n}\n\n.ntbl-delete-table-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Context Menu Discovery Hint --- */\n.ntbl-context-hint {\n\tposition: absolute;\n\ttop: 4px;\n\tinset-inline-end: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tpadding: 2px 8px;\n\tborder-radius: 4px;\n\topacity: 0;\n\ttransition: opacity 0.2s ease;\n\tpointer-events: none;\n\twhite-space: nowrap;\n\tz-index: 5;\n}\n\n.ntbl-container:hover .ntbl-context-hint,\n.ntbl-container:focus-within .ntbl-context-hint,\n.ntbl-container.notectl-table--selected .ntbl-context-hint {\n\topacity: 1;\n}\n\n/* --- Table Actions Button --- */\n.ntbl-actions-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 48px;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg-muted);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n\tcursor: pointer;\n\tpadding: 0;\n}\n\n.ntbl-container:hover .ntbl-actions-btn,\n.ntbl-container:focus-within .ntbl-actions-btn,\n.ntbl-container.notectl-table--selected .ntbl-actions-btn {\n\topacity: 1;\n}\n\n.ntbl-actions-btn:hover,\n.ntbl-actions-btn:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-primary);\n}\n\n.ntbl-actions-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Border Color Button --- */\n.ntbl-border-color-btn {\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 24px;\n\twidth: 20px;\n\theight: 20px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg-muted);\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\topacity: 0;\n\ttransition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n\tz-index: 7;\n\tcursor: pointer;\n\tpadding: 0;\n}\n\n.ntbl-container:hover .ntbl-border-color-btn,\n.ntbl-container:focus-within .ntbl-border-color-btn,\n.ntbl-container.notectl-table--selected .ntbl-border-color-btn {\n\topacity: 1;\n}\n\n.ntbl-border-color-btn:hover,\n.ntbl-border-color-btn:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-primary);\n}\n\n.ntbl-border-color-btn:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-border-color-swatch {\n\twidth: 10px;\n\theight: 10px;\n\tborder-radius: 2px;\n\tborder: 1px solid rgba(0, 0, 0, 0.15);\n}\n\n/* --- Context Menu Keyboard Hint --- */\n.notectl-table-context-menu__hint {\n\tpadding: 4px 12px 6px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin-top: 4px;\n\ttext-align: center;\n\tuser-select: none;\n}\n\n/* --- Context Menu Focus --- */\n.notectl-table-context-menu button:focus-visible {\n\toutline: none;\n\tbackground: var(--notectl-primary-muted);\n\tbox-shadow: inset 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-table-context-menu [role="separator"] {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 4px 0;\n\theight: 0;\n}\n\n/* --- Precise size editor --- */\n.notectl-table-size-editor {\n\tbox-sizing: border-box;\n\twidth: 340px;\n\tmax-width: calc(100vw - 16px);\n\tmin-width: 260px;\n\tpadding: 12px;\n}\n\n.notectl-table-size-editor__title {\n\tmargin-block-end: 10px;\n\tfont-weight: 600;\n}\n\n.notectl-table-size-editor__field {\n\tdisplay: grid;\n\tgap: 4px;\n\tmargin-block-end: 10px;\n\tfont-size: 13px;\n}\n\n.notectl-table-size-editor__input-wrap {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 6px;\n}\n\n.notectl-table-size-editor input {\n\tbox-sizing: border-box;\n\tmin-width: 0;\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-bg);\n\tcolor: var(--notectl-fg);\n\tfont: inherit;\n}\n\n.notectl-table-size-editor input:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: 1px;\n}\n\n.notectl-table-size-editor input[aria-invalid="true"] {\n\tborder-color: var(--notectl-danger);\n}\n\n.notectl-table-size-editor__unit {\n\tcolor: var(--notectl-fg-muted);\n}\n\n.notectl-table-size-editor__error {\n\tmin-height: 1.2em;\n\tcolor: var(--notectl-danger);\n\tfont-size: 11px;\n}\n\n.notectl-table-size-editor__resets,\n.notectl-table-size-editor__actions {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 4px;\n}\n\n.notectl-table-size-editor__resets {\n\tpadding-block-end: 10px;\n\tborder-block-end: 1px solid var(--notectl-border);\n}\n\n.notectl-table-size-editor__actions {\n\tjustify-content: flex-end;\n\tpadding-block-start: 10px;\n}\n\n.notectl-table-size-editor button {\n\twidth: auto;\n\tpadding: 6px 8px;\n\tborder-radius: 4px;\n\tfont-size: 12px;\n}\n\n.notectl-table-context-menu .notectl-table-size-editor__apply {\n\tbackground: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-table-context-menu .notectl-table-size-editor button:disabled {\n\topacity: 0.5;\n\tcursor: not-allowed;\n}\n\n/* Read-only tables keep semantic dimensions but expose no mutation affordances. */\n.ntbl-container[data-notectl-table-readonly] {\n\tpadding-block-start: 0;\n\tpadding-inline-start: 0;\n}\n\n.ntbl-container[data-notectl-table-readonly] > :is(\n\t.ntbl-col-bar,\n\t.ntbl-row-bar,\n\t.ntbl-col-resize-bar,\n\t.ntbl-row-resize-bar,\n\t.ntbl-insert-line,\n\t.ntbl-add-zone,\n\t.ntbl-delete-table-btn,\n\t.ntbl-border-color-btn,\n\t.ntbl-actions-btn,\n\t.ntbl-context-hint,\n\t.ntbl-resize-indicator\n) {\n\tdisplay: none !important;\n}\n\n.ntbl-add-row {\n\tbottom: 0;\n\theight: 24px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-end-start-radius: 6px;\n\tborder-end-end-radius: 6px;\n\tborder-block-start: none;\n\tcolor: var(--notectl-fg-muted);\n\ttransform: translateY(100%);\n}\n\n.ntbl-add-row:hover,\n.ntbl-add-row:focus-visible {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n}\n\n.ntbl-add-row:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-col {\n\tinset-inline-end: 0;\n\ttop: 24px;\n\twidth: 24px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-start-end-radius: 6px;\n\tborder-end-end-radius: 6px;\n\tborder-inline-start: none;\n\tcolor: var(--notectl-fg-muted);\n\ttransform: translateX(100%);\n}\n\n[dir="rtl"] .ntbl-add-col {\n\ttransform: translateX(-100%);\n}\n\n.ntbl-add-col:hover,\n.ntbl-add-col:focus-visible {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary);\n}\n\n.ntbl-add-col:focus-visible {\n\toutline: none;\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-icon {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\ttransition: transform 0.2s ease;\n}\n\n.ntbl-add-zone:hover .ntbl-add-icon {\n\ttransform: scale(1.15);\n}\n\n@media print {\n\t.notectl-table-wrapper {\n\t\toverflow: visible;\n\t}\n\n\t.ntbl-container {\n\t\tpadding: 0;\n\t}\n\n\t.ntbl-container > [data-notectl-no-print] {\n\t\tdisplay: none !important;\n\t}\n}\n'),this.context=t,this.registerNodeSpecs(t),this.registerNodeViews(t),Xt(t,this.locale),t.registerCommand("resetTableBorderColor",()=>at(t,this.locale)),function(t,e,n={}){t.registerKeymap({Tab:()=>function(t,e){return se(t,(n,o,r)=>!!de(t,r,1,!1)||!t.isReadOnly?.()&&Ft(t,e))}(t,e),"Shift-Tab":()=>function(t){return se(t,(e,n,o)=>de(t,o,-1,!1)||!0)}(t),Backspace:()=>function(t){return se(t,(e,n,o)=>{if(!h(n))return!1;if(0!==n.anchor.offset)return!1;if(!function(t,e){const n=t.getBlock(e.tableId);return"table"===n?.type&&V(n).cells[0]?.cell.id===e.cellId}(e,o))return!1;const r=Q(e,o.cellId);return n.anchor.blockId===r&&he(t,o.tableId)})}(t),Delete:()=>function(t){return se(t,(e,n,o)=>{if(!h(n))return!1;const r=e.getBlock(n.anchor.blockId);if(!r)return!1;const l=i(r);if(n.anchor.offset!==l)return!1;if(!function(t,e){const n=t.getBlock(e.tableId);if(!n||"table"!==n.type)return!1;const o=V(n).cells;return o[o.length-1]?.cell.id===e.cellId}(e,o))return!1;const s=tt(e,o.cellId);return n.anchor.blockId===s&&he(t,o.tableId)})}(t),ArrowDown:()=>function(t){return se(t,(e,n,o)=>{const r=tt(e,o.cellId);return n.anchor.blockId===r&&(o.rowEnd>=o.totalRows?ae(t):ue(t,o.tableId,o.rowEnd,o.colIndex))})}(t),ArrowUp:()=>function(t){return se(t,(e,n,o)=>{const r=Q(e,o.cellId);return n.anchor.blockId===r&&!(o.rowIndex<=0)&&ue(t,o.tableId,o.rowIndex-1,o.colIndex)})}(t),ArrowRight:()=>function(t){return se(t,(e,n,o)=>{if(!h(n))return!1;const r=e.getBlock(n.anchor.blockId);if(!r)return!1;const l=i(r);if(n.anchor.offset!==l)return!1;const s=tt(e,o.cellId);return n.anchor.blockId===s&&(de(t,o,1,!1)||!0)})}(t),ArrowLeft:()=>function(t){return se(t,(e,n,o)=>{if(!h(n))return!1;if(0!==n.anchor.offset)return!1;const r=Q(e,o.cellId);return n.anchor.blockId===r&&(de(t,o,-1,!0)||!0)})}(t),Escape:()=>ae(t),"Shift-F10":()=>function(t,e,n){return!t.isReadOnly?.()&&se(t,(o,r,i)=>{const l=t.getContainer(),s=l.querySelector(`[data-block-id="${i.cellId}"]`);if(!s)return!1;const a=s.getBoundingClientRect(),c=new DOMRect(a.left+a.width/2,a.bottom,0,0),d=l.querySelector(`[data-block-id="${i.tableId}"].ntbl-container`)??l;le.get(t)?.close();const u=W(l)??s,h=ie(d,t,i.tableId,c,()=>{le.delete(t)},e,void 0,{sizeTarget:ce(t,i),sizingConfig:n,restoreFocusTo:u});return le.set(t,h),!0})}(t,e,n)},{priority:"context"})}(t,this.locale,this.config),this.registerToolbarItem(t),this.selectionService=function(t){let e=null,n=null,o=[],r=/* @__PURE__ */new Set;function i(){const t=l();if(!t)return o=[],void(r=/* @__PURE__ */new Set);const{grid:e,range:n}=t,i=e.cellsInRange({fromRow:n.fromRow,fromColumn:n.fromCol,toRow:n.toRow,toColumn:n.toCol}).map(t=>t.cell.id);o=i,r=new Set(i)}function l(){if(!e||!n)return null;const o=t.getState().getBlock(e.tableId);if(!o||"table"!==o.type)return s(),null;const r=V(o);return mt(r)!==n?(s(),null):{range:e,grid:r}}function s(){e=null,n=null,o=[],r=/* @__PURE__ */new Set}const a={getSelectedRange:()=>l()?.range??null,setSelectedRange(o){const r=t.getState();let l=null;if(o){const r=t.getState().getBlock(o.tableId),i="table"===r?.type?V(r):null,a=[o.fromRow,o.fromCol,o.toRow,o.toCol],c=i&&a.every(Number.isInteger)&&o.fromRow>=0&&o.toRow>=0&&o.fromCol>=0&&o.toCol>=0&&o.fromRow<i.rowCount&&o.toRow<i.rowCount&&o.fromCol<i.columnCount&&o.toCol<i.columnCount&&i?F(i,{fromRow:o.fromRow,fromColumn:o.fromCol,toRow:o.toRow,toColumn:o.toCol}):null;i&&c?(e={tableId:o.tableId,fromRow:c.fromRow,fromCol:c.fromColumn,toRow:c.toRow,toCol:c.toColumn},n=mt(i),l=i.cellAt(c.fromRow,c.fromColumn)?.cell.id??null):s()}else s();i();const a=p(r.selection)?G(r,r.selection.anchor.blockId):null,c=l&&a?.tableId!==o?.tableId?m(Q(r,l),0):r.selection;t.dispatch(r.transaction("api").setSelection(c).build())},clearSelectionSilent(){s()},getSelectedCellIds:()=>(i(),o),isSelected:t=>(i(),r.has(t))};return t.registerService(bt,a),a}(t),function(t,e={}){const n=wt(e),o={getSelectionSize(){const e=St(t);return e?kt(e):null},setSelectionSize(e){if(t.isReadOnly())return!1;const o=St(t);return!!o&&At(t,o,e,n)},resetSelectionSize(e){if(t.isReadOnly())return!1;const o=St(t);return!!o&&Et(t,o,e,n)},getSize(e){const n=Rt(t.getState(),e);return n?kt(n):null},setSize(e,o){if(t.isReadOnly())return!1;const r=Rt(t.getState(),e);return!!r&&At(t,r,o,n)},resetSize(e,o){if(t.isReadOnly())return!1;const r=Rt(t.getState(),e);return!!r&&Et(t,r,o,n)}};t.registerService(gt,o)}(t,this.config)}onReady(){this.context&&this.selectionService&&(this.cleanupMouseSelection=function(t,e){const n=t.getContainer();let o=null,r=!1;function i(i){if(0!==i.button||t.isReadOnly?.())return;if(!y(i,n))return;const l=i.target.closest("td[data-block-id]");if(!l)return o=null,r=!1,void e.setSelectedRange(null);if(i.shiftKey){if(o){const n=G(t.getState(),l.getAttribute("data-block-id"));if(!n||n.tableId!==o.tableId)return o=null,void e.setSelectedRange(null);i.preventDefault(),e.setSelectedRange(pt(o,n))}}else{e.setSelectedRange(null);const n=G(t.getState(),l.getAttribute("data-block-id"));if(!n)return o=null,void(r=!1);o={tableId:n.tableId,cellId:n.cellId,rowStart:n.rowIndex,rowEnd:n.rowEnd,colStart:n.colIndex,colEnd:n.colEnd},r=!0}}function l(n){if(t.isReadOnly?.()||!r||!o)return;const i=n.target.closest("td[data-block-id]");if(!i)return;const l=G(t.getState(),i.getAttribute("data-block-id"));l&&l.tableId===o.tableId&&l.cellId!==o.cellId&&(n.preventDefault(),e.setSelectedRange(pt(o,l)))}function s(){r=!1}return n.addEventListener("mousedown",i),n.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{n.removeEventListener("mousedown",i),n.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}}(this.context,this.selectionService),this.cleanupClipboard=function(t,e){const n=t.getContainer(),o=o=>{y(o,n)&&ut(o,t,e)},i=o=>{y(o,n)&&(t.isReadOnly?.()||ut(o,t,e)&&function(t,e){const n=e.getSelectedRange();if(!n)return;const o=t.getState(),i=o.getBlock(n.tableId);if(!i||"table"!==i.type)return;const a=V(i).cellsInRange({fromRow:n.fromRow,fromColumn:n.fromCol,toRow:n.toRow,toColumn:n.toCol});if(0===a.length)return;const d=o.transaction("input");let u=null;for(const h of a){const t=o.getNodePath(h.cell.id);if(!t)return;for(let o=s(h.cell).length-1;o>=0;o--)d.removeNode(t,o);const e=r(),n=l(f("paragraph"),[c("")],e);d.insertNode(t,0,n),u??=e}u&&(d.setSelection(m(u,0)),t.dispatch(d.build()),e.clearSelectionSilent())}(t,e))};return n.addEventListener("copy",o,!0),n.addEventListener("cut",i,!0),()=>{n.removeEventListener("copy",o,!0),n.removeEventListener("cut",i,!0)}}(this.context,this.selectionService))}destroy(){this.context&&re(this.context),this.cleanupMouseSelection?.(),this.cleanupMouseSelection=null,this.cleanupClipboard?.(),this.cleanupClipboard=null,this.selectionService=null,this.controls.clear(),this.context=null}onReadOnlyChange(t){for(const e of this.controls)e.setReadOnly(t);t&&this.context&&re(this.context)}decorations(t){if(!this.selectionService)return w.empty;if(!this.selectionService.getSelectedRange())return w.empty;const e=t.selection;if(!p(e)||!et(t,e.anchor.blockId))return this.selectionService.clearSelectionSilent(),w.empty;const n=this.selectionService.getSelectedCellIds();if(0===n.length)return w.empty;const o=[];for(const r of n)o.push(g(r,{class:"notectl-table-cell--selected"}));return w.create(o)}registerNodeSpecs(e){const n=this.config;e.registerNodeSpec({type:"table",attrs:{columnWidthsPx:{allowArray:!0}},group:"block",content:{allow:["table_row"],min:1},isolating:!0,selectable:!0,normalizeAttrs:t=>function(t,e){const n=De(t.attrs,["borderColor","columnWidthsPx"]),o=t.attrs?.borderColor;("none"===o||"string"==typeof o&&O(o))&&(n.borderColor=o);const r=V(t),i=t.attrs?.columnWidthsPx;if(Array.isArray(i)&&r.columnCount>0){const t=Array.from({length:r.columnCount},(t,n)=>{const o=S(i[n]);return void 0===o?null:Math.min(e.maxColumnWidthPx,Math.max(e.minColumnWidthPx,o))});t.some(t=>null!==t)&&(n.columnWidthsPx=Object.freeze(t))}return Object.keys(n).length>0?n:void 0}(t,this.config),normalizeNode:Te,transformSelectionSlice:K,toDOM(t){const e=document.createElement("div");return e.className="notectl-table-wrapper",e.setAttribute("data-block-id",t.id),e.setAttribute("part","table"),e},toHTML(e,o,r){const i=e.attrs?.borderColor,l=xt(e,V(e).columnCount),s=function(e,n,o){const r=n.reduce((t,e)=>t+(e??o),0),i=`border-collapse: collapse; table-layout: fixed; ${n.length>0&&n.every(t=>null!==t)?`width: ${String(r)}px`:"width: 100%"}; min-width: ${String(r)}px`;return e?"none"===e?`${i}; --ntbl-bc: transparent`:O(e)?`${i}; --ntbl-bc: ${t(e)}`:i:i}(i,l,n.minColumnWidthPx);return`<table${r?.styleAttr(s)??` style="${s}"`}><colgroup>${l.map(t=>null===t?"<col>":`<col${I(k,"width",t,r)}>`).join("")}</colgroup><tbody>${o}</tbody></table>`},sanitize:{tags:["table","colgroup","col","thead","tbody","tfoot"],attrs:[k,"width","span"]}}),e.registerNodeSpec({type:"table_row",group:"table_content",content:{allow:["table_cell"],min:0},normalizeAttrs:t=>function(t,e){const n=De(t.attrs,["minHeightPx"]),o=S(t.attrs?.minHeightPx);return void 0!==o&&(n.minHeightPx=Math.min(e.maxRowHeightPx,Math.max(e.minRowHeightPx,o))),Object.keys(n).length>0?n:void 0}(t,this.config),toDOM(t){const e=document.createElement("tr");return e.setAttribute("data-block-id",t.id),e.setAttribute("role","row"),e.setAttribute("part","table-row"),e},toHTML:(t,e,n)=>`<tr${I(A,"height",t.attrs?.minHeightPx,n)}>${e}</tr>`,sanitize:{tags:["tr"],attrs:[A,"height"]}}),e.registerNodeSpec({type:"table_cell",group:"table_content",content:{allow:["paragraph","list_item","heading","blockquote","image","video","horizontal_rule"],min:1},isolating:!0,normalizeAttrs:$e,toDOM(t){const e=document.createElement("td");return e.setAttribute("data-block-id",t.id),e.setAttribute("role","cell"),e.setAttribute("part","table-cell"),e},toHTML(t,e,n){const o=t.attrs?.colspan??1,r=t.attrs?.rowspan??1,i=[n?.styleAttr(Be)??` style="${Be}"`];return o>1&&i.push(` colspan="${o}"`),r>1&&i.push(` rowspan="${r}"`),`<td${i.join("")}>${e}</td>`},sanitize:{tags:["td","th"],attrs:["colspan","rowspan"]}})}registerNodeViews(t){t.getSchemaRegistry(),t.registerNodeView("table",function(t,e,n=nt,o=ze,r={}){return(t,i,l)=>{let c=t;const d=document.createElement("div");d.className="ntbl-container",d.setAttribute("data-block-id",t.id),d.setAttribute("data-selectable","true");const u=document.createElement("div");u.className="notectl-table-wrapper",u.setAttribute("part","table");const h=document.createElement("table");h.className="notectl-table",h.setAttribute("role","table");const b=document.createElement("colgroup");b.className="notectl-table-columns",h.appendChild(b);const m=s(t).length,p=V(t).columnCount;h.setAttribute("aria-label",n.tableAriaLabel(m,p)),h.setAttribute("aria-description",n.tableAriaDescription);const f=document.createElement("tbody");h.appendChild(f),u.appendChild(h),d.appendChild(u),Ie(h,t.attrs?.borderColor),ke(h,b,t,o);const g=document.createElement("div");g.className="notectl-sr-only",g.setAttribute("aria-live","polite"),g.setAttribute("aria-atomic","true"),d.appendChild(g);const w=function(t,e,n,o,r,i,l,s){return new Re(t,e,n,o,r,i,l,s)}(d,h,t,i,l,e,n,o);w.setReadOnly(e?.isReadOnly?.()??!1),r.onControlsCreated?.(w);let x=!1;const v=requestAnimationFrame(()=>{x||(Ie(h,c.attrs?.borderColor),ke(h,b,c,o),Ee(f,c))});let C=null,y=t.id;const S=t=>{if(!e||e.isReadOnly?.())return;t.preventDefault(),t.stopPropagation(),C?.close();const r=new DOMRect(t.clientX,t.clientY,0,0),i=t.target?.closest("td[data-block-id]"),l=i?.getAttribute("data-block-id"),s=l?G(e.getState(),l):null,a=!!l&&(e.getService?.(bt)?.isSelected(l)??!1),c=W(d)??(i instanceof HTMLElement?i:null);C=ie(d,e,y,r,()=>{C=null},n,void 0,{sizeTarget:s&&!a?{kind:"cell",tableId:s.tableId,row:s.rowIndex,column:s.colIndex}:void 0,sizingConfig:o,restoreFocusTo:c})};return h.addEventListener("contextmenu",S),{dom:d,contentDOM:f,update(t){if("table"!==t.type)return!1;if(!function(t,e){if(t.id!==e.id||t.htmlId!==e.htmlId)return!1;if(!a(Pe(t.attrs),Pe(e.attrs)))return!1;const n=s(t),o=s(e);return n.length===o.length&&n.every((t,e)=>{const n=o[e];return void 0!==n&&t.id===n.id&&t.htmlId===n.htmlId&&t.children===n.children&&a(Me(t.attrs),Me(n.attrs))})}(c,t))return!1;y=t.id,d.setAttribute("data-block-id",t.id),d.setAttribute("data-selectable","true");const e=s(t).length,r=V(t).columnCount;return h.setAttribute("aria-label",n.tableAriaLabel(e,r)),Ie(h,t.attrs?.borderColor),ke(h,b,t,o),Ee(f,t),w.update(t),c=t,!0},destroy(){x=!0,cancelAnimationFrame(v),C?.destroy(),h.removeEventListener("contextmenu",S),r.onControlsDestroyed?.(w),w.destroy()},selectNode(){d.classList.add("notectl-table--selected")},deselectNode(){d.classList.remove("notectl-table--selected")}}}}(0,t,this.locale,this.config,{onControlsCreated:t=>{this.controls.add(t)},onControlsDestroyed:t=>{this.controls.delete(t)}})),t.registerNodeView("table_row",(t,e,n)=>{let o=t;const r=document.createElement("tr");r.setAttribute("data-block-id",t.id),r.setAttribute("role","row"),r.setAttribute("part","table-row"),Ae(r,t);let i=!1;const l=requestAnimationFrame(()=>{i||Ae(r,o)});return{dom:r,contentDOM:r,update:t=>"table_row"===t.type&&t.children===o.children&&(r.setAttribute("data-block-id",t.id),Ae(r,t),o=t,!0),destroy(){i=!0,cancelAnimationFrame(l)}}}),t.registerNodeView("table_cell",(t,e,n)=>{const o=document.createElement("td");o.setAttribute("data-block-id",t.id),o.setAttribute("role","cell"),o.setAttribute("part","table-cell");const r=t.attrs?.colspan??1,i=t.attrs?.rowspan??1;r>1&&(o.colSpan=r),i>1&&(o.rowSpan=i);const l=t.attrs?.align;return l&&"left"!==l&&P(o,"textAlign",l),{dom:o,contentDOM:o,update(t){if("table_cell"!==t.type)return!1;o.setAttribute("data-block-id",t.id);const e=t.attrs?.colspan??1,n=t.attrs?.rowspan??1;return e>1?o.colSpan=e:o.removeAttribute("colspan"),n>1?o.rowSpan=n:o.removeAttribute("rowspan"),!1},destroy(){}}})}registerToolbarItem(t){const e=this.config.maxPickerRows??8,n=this.config.maxPickerCols??8;t.registerToolbarItem({id:"table",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 3h18v18H3V3zm2 2v4h6V5H5zm8 0v4h6V5h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6z"/></svg>',label:this.locale.insertTable,tooltip:this.locale.insertTable,command:"insertTable",popupType:"gridPicker",popupConfig:{maxRows:e,maxCols:n,onSelect:(e,n)=>{jt(t,e,n)}},isActive:t=>!!p(t.selection)&&et(t,t.selection.anchor.blockId)})}};function Ne(t,e){return"number"==typeof t&&Number.isInteger(t)&&t>0?Math.min(t,100):e}function $e(t){const e=De(t.attrs,["colspan","rowspan"]),n=q(t.attrs?.colspan),o=q(t.attrs?.rowspan);return n>1&&(e.colspan=n),o>1&&(e.rowspan=o),Object.keys(e).length>0?e:void 0}function Te(t){const e=s(t);let n=!1;const o=e.map((t,o)=>{let r=!1;const i=s(t).map(t=>{const n=q(t.attrs?.rowspan),i=Math.min(n,e.length-o);if(i===n)return t;r=!0;const{rowspan:l,...s}=t.attrs??{},a={...s,...i>1?{rowspan:i}:{}},{attrs:c,...d}=t;return Object.keys(a).length>0?{...d,attrs:a}:d});return r?(n=!0,{...t,children:i}):t});return n?{...t,children:o}:t}function De(t,e){const n={};for(const[o,r]of Object.entries(t??{})){if(e.includes(o))continue;const t=We(r);void 0!==t&&(n[o]=t)}return n}function We(t){if("string"==typeof t||"boolean"==typeof t)return t;if("number"==typeof t)return Number.isFinite(t)?t:void 0;if(!Array.isArray(t))return;const e=[];for(const n of t)if(null===n||"string"==typeof n||"boolean"==typeof n)e.push(n);else{if("number"!=typeof n||!Number.isFinite(n))return;e.push(n)}return Object.freeze(e)}export{nt as a,bt as i,ft as n,rt as o,gt as r,He as t};
2
- //# sourceMappingURL=TablePlugin-PJe3zwr-.mjs.map
@@ -1,2 +0,0 @@
1
- import{_ as t,h as e,i as r}from"./Document-827l3P80.mjs";import{t as i}from"./TextDirectionService-BcX07mw2.mjs";import{n,r as o,t as s}from"./DirectionDetection-CDVSEWQ6.mjs";function c(t,e,r){const i=t.getNodePath(e.id);if(i)return{type:"setNodeAttr",path:i,attrs:{...e.attrs,dir:r},previousAttrs:e.attrs}}function a(i,n,a,d){const u=n.getBlock(i.blockId);if(!u||!a.has(u.type))return;if("auto"!==o(u)&&e(u)>0)return;const f=t(u),p=r(u,i.offset),l=s(f.slice(0,p)+i.text+f.slice(p));if(!l)return;const h=c(n,u,l);h&&d.push(h)}function d(e,i,n,a){const d=i.getBlock(e.blockId);if(!d||!n.has(d.type))return;const u=o(d);if("auto"===u)return;const f=t(d),p=r(d,e.from),l=r(d,e.to),h=f.slice(0,p)+f.slice(l);if(0===h.length){const t=c(i,d,"auto");return void(t&&a.push(t))}const g=s(h);if(!g||g===u)return;const m=c(i,d,g);m&&a.push(m)}var u={autoDetect:!0,inherit:!0,preserve:!0},f=class{id="text-direction-auto";name="Text Direction Auto-detect";priority=93;dependencies=["text-direction"];config;constructor(t){this.config={...u,...t}}init(e){const r=e.getService(i);if(!r)throw new Error("TextDirectionAutoPlugin requires TextDirectionPlugin to be registered first.");const{directableTypes:o}=r;this.config.preserve&&function(t,e){t.registerMiddleware((t,r,i)=>{let n=!1;const o=t.steps.map(t=>{if("setBlockType"!==t.type)return t;if(!e.has(t.nodeType))return t;const r=t.previousAttrs?.dir;return r&&"auto"!==r?(n=!0,{...t,attrs:{...t.attrs,dir:r}}):t});i(n?{...t,steps:o}:t)},{name:"text-direction:preserve-dir"})}(e,o),this.config.autoDetect&&function(t,e){t.registerMiddleware((t,r,i)=>{const n=function(t){const e=/* @__PURE__ */new Set;for(const r of t)if("setBlockType"===r.type)e.add(r.blockId);else if("setNodeAttr"===r.type){const t=r.path[r.path.length-1];t&&e.add(t)}return e}(t.steps),o=[];for(const s of t.steps)if("insertText"===s.type){if(n.has(s.blockId))continue;a(s,r,e,o)}else if("deleteText"===s.type){if(n.has(s.blockId))continue;d(s,r,e,o)}i(o.length>0?{...t,steps:[...t.steps,...o]}:t)},{name:"text-direction:auto-detect"})}(e,o),this.config.inherit&&function(e,r){e.registerMiddleware((e,i,o)=>{let c=!1;const a=e.steps.map(e=>{if("insertNode"!==e.type)return e;if(!r.has(e.node.type))return e;if("auto"!==String(e.node.attrs?.dir??"auto"))return e;const o=t(e.node);if(o.length>0){const t=s(o);if(t)return c=!0,{...e,node:{...e.node,attrs:{...e.node.attrs,dir:t}}}}const a=n(i,e.parentPath,e.index);return a&&"auto"!==a?(c=!0,{...e,node:{...e.node,attrs:{...e.node.attrs,dir:a}}}):e});o(c?{...e,steps:a}:e)},{name:"text-direction:inherit-dir"})}(e,o)}};export{f as t};
2
- //# sourceMappingURL=TextDirectionAutoPlugin-CPnKVVuI.mjs.map
@@ -1,2 +0,0 @@
1
- import{r as t}from"./Platform-ByobkiCc.mjs";import{a as e,c as i,n as o,o as r,r as s}from"./PluginHelpers-Dx_0hfDe.mjs";import{t as n}from"./ShortcutFormatting-TwiufqeV.mjs";import{t as a}from"./NodeSpecPatching-B_yLknTl.mjs";import{t as c}from"./DirectionIcons-Bbawl9ei.mjs";import{t as l}from"./TextDirectionService-BcX07mw2.mjs";import{r as h}from"./DirectionDetection-CDVSEWQ6.mjs";var u=class{context;pendingDir=null;container=null;constructor(t){this.context=t}attach(t){this.container=t,t.addEventListener("keydown",this.onKeydown),t.addEventListener("keyup",this.onKeyup)}detach(){this.container&&(this.container.removeEventListener("keydown",this.onKeydown),this.container.removeEventListener("keyup",this.onKeyup),this.container=null)}onKeydown=t=>{"Shift"!==t.key||!t.ctrlKey||t.altKey||t.metaKey?this.pendingDir=null:"ShiftLeft"===t.code?this.pendingDir="ltr":"ShiftRight"===t.code&&(this.pendingDir="rtl")};onKeyup=t=>{if("Shift"!==t.key||!this.pendingDir)return;const e=this.pendingDir;this.pendingDir=null;const i="ltr"===e?"setDirectionLTR":"setDirectionRTL";this.context.executeCommand(i)}},m={ltr:"Left to Right",rtl:"Right to Left",auto:"Auto",toolbarLabel:"Text Direction",toolbarTooltip:"Text Direction",announceLTR:"Text direction set to left-to-right",announceRTL:"Text direction set to right-to-left",announceAuto:"Text direction set to automatic"},d=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BwaoCUVN.mjs"),"./locales/de.ts":()=>import("./de-BdD3DpUB.mjs"),"./locales/es.ts":()=>import("./es-kfKiqpyD.mjs"),"./locales/fr.ts":()=>import("./fr-BSUKEtTk.mjs"),"./locales/hi.ts":()=>import("./hi-Dt89SxNy.mjs"),"./locales/pt.ts":()=>import("./pt-CMrFpUWS.mjs"),"./locales/ru.ts":()=>import("./ru-C9yFslEG.mjs"),"./locales/zh.ts":()=>import("./zh-CnW44JEw.mjs")});async function p(t){return i(d,t,m)}var g={directableTypes:["paragraph","heading","title","subtitle","table_cell","blockquote","list_item"]},D=["ltr","rtl","auto"],f=class{id="text-direction";name="Text Direction";priority=91;config;locale;directableTypes;shiftDirHandler=null;constructor(t){this.config={...g,...t}}async init(e){this.locale=await r(e,this.config.locale,m,p),this.directableTypes=new Set(this.config.directableTypes),this.patchNodeSpecs(e),this.registerCommands(e),this.registerKeymaps(e),this.registerToolbarItem(e),this.registerService(e),t()||(this.shiftDirHandler=new u(e),this.shiftDirHandler.attach(e.getContainer()))}destroy(){this.shiftDirHandler?.detach(),this.shiftDirHandler=null}registerService(t){const e={directableTypes:this.directableTypes,getBlockDir:h};t.registerService(l,e)}patchNodeSpecs(t){a(t.getSchemaRegistry(),this.config.directableTypes,{attrName:"dir",getDefault:()=>"auto",applyToDOM:y})}registerCommands(t){t.registerCommand("setDirectionLTR",()=>{const e=this.setDirection(t,"ltr");return e&&t.announce(this.locale.announceLTR),e}),t.registerCommand("setDirectionRTL",()=>{const e=this.setDirection(t,"rtl");return e&&t.announce(this.locale.announceRTL),e}),t.registerCommand("setDirectionAuto",()=>{const e=this.setDirection(t,"auto");return e&&t.announce(this.locale.announceAuto),e}),t.registerCommand("toggleDirection",()=>{const e=s(t.getState());if(!e||!this.directableTypes.has(e.type))return!1;const i=h(e),o="auto"===i?"rtl":"rtl"===i?"ltr":"auto";return this.setDirection(t,o)})}registerKeymaps(t){t.registerKeymap({"Mod-Shift-D":()=>t.executeCommand("toggleDirection")})}registerToolbarItem(t){const e={ltr:"setDirectionLTR",rtl:"setDirectionRTL",auto:"setDirectionAuto"},i=D.map(t=>({label:this.getDirectionLabel(t),command:e[t],icon:c[t]}));t.registerToolbarItem({id:"text-direction",group:"block",icon:c.auto,label:this.locale.toolbarLabel,tooltip:`${this.locale.toolbarTooltip} (${n("Mod-Shift-D")})`,command:"setDirectionAuto",popupType:"dropdown",popupConfig:{items:i},isActive:t=>this.isNonDefaultDirection(t),isEnabled:t=>this.isDirectable(t),getIcon:t=>{const e=s(t);return e?c[h(e)]??c.auto:c.auto}})}getDirectionLabel(t){return"ltr"===t?this.locale.ltr:"rtl"===t?this.locale.rtl:this.locale.auto}setDirection(t,i){const r=t.getState(),s=e(r);if(0===s.length)return!1;const n=r.transaction("command");let a=!1;for(const e of s){const t=r.getBlock(e);if(!t||!this.directableTypes.has(t.type))continue;const o=r.getNodePath(e);o&&(n.setNodeAttr(o,{...t.attrs,dir:i}),a=!0)}return!!a&&o(t,n.setSelection(r.selection).build())}isNonDefaultDirection(t){const e=s(t);if(!e||!this.directableTypes.has(e.type))return!1;const i=e.attrs?.dir;return null!=i&&"auto"!==i}isDirectable(t){const e=s(t);return null!=e&&this.directableTypes.has(e.type)}};function y(t,e){const i=e.attrs?.dir;"ltr"!==i&&"rtl"!==i&&"auto"!==i||t.setAttribute("dir",i)}export{m as n,p as r,f as t};
2
- //# sourceMappingURL=TextDirectionPlugin-Bns_03vL.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextDirectionPlugin-Bns_03vL.mjs","names":[],"sources":["../../src/plugins/text-direction/ShiftDirectionHandler.ts","../../src/plugins/text-direction/TextDirectionLocale.ts","../../src/plugins/text-direction/TextDirectionPlugin.ts"],"sourcesContent":["/**\n * Handles Ctrl+Left-Shift → LTR and Ctrl+Right-Shift → RTL shortcuts.\n *\n * Uses a deferred pattern: sets a pending direction on Ctrl+Shift keydown,\n * and applies it on Shift keyup only if no other key was pressed in between.\n * This prevents conflicts with Ctrl+Shift+<key> shortcuts like Ctrl+Shift+D.\n */\n\nimport type { PluginContext } from '../Plugin.js';\n\nexport class ShiftDirectionHandler {\n\tprivate pendingDir: 'ltr' | 'rtl' | null = null;\n\tprivate container: HTMLElement | null = null;\n\n\tconstructor(private readonly context: PluginContext) {}\n\n\tattach(container: HTMLElement): void {\n\t\tthis.container = container;\n\t\tcontainer.addEventListener('keydown', this.onKeydown);\n\t\tcontainer.addEventListener('keyup', this.onKeyup);\n\t}\n\n\tdetach(): void {\n\t\tif (!this.container) return;\n\t\tthis.container.removeEventListener('keydown', this.onKeydown);\n\t\tthis.container.removeEventListener('keyup', this.onKeyup);\n\t\tthis.container = null;\n\t}\n\n\tprivate readonly onKeydown = (e: KeyboardEvent): void => {\n\t\tif (e.key === 'Shift' && e.ctrlKey && !e.altKey && !e.metaKey) {\n\t\t\tif (e.code === 'ShiftLeft') {\n\t\t\t\tthis.pendingDir = 'ltr';\n\t\t\t} else if (e.code === 'ShiftRight') {\n\t\t\t\tthis.pendingDir = 'rtl';\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// Any other keydown cancels the pending direction change\n\t\tthis.pendingDir = null;\n\t};\n\n\tprivate readonly onKeyup = (e: KeyboardEvent): void => {\n\t\tif (e.key !== 'Shift' || !this.pendingDir) return;\n\t\tconst dir: 'ltr' | 'rtl' = this.pendingDir;\n\t\tthis.pendingDir = null;\n\t\tconst command: string = dir === 'ltr' ? 'setDirectionLTR' : 'setDirectionRTL';\n\t\tthis.context.executeCommand(command);\n\t};\n}\n","/** Locale interface and default English locale for the TextDirectionPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\nexport interface TextDirectionLocale {\n\treadonly ltr: string;\n\treadonly rtl: string;\n\treadonly auto: string;\n\treadonly toolbarLabel: string;\n\treadonly toolbarTooltip: string;\n\treadonly announceLTR: string;\n\treadonly announceRTL: string;\n\treadonly announceAuto: string;\n}\n\nexport const TEXT_DIRECTION_LOCALE_EN: TextDirectionLocale = {\n\tltr: 'Left to Right',\n\trtl: 'Right to Left',\n\tauto: 'Auto',\n\ttoolbarLabel: 'Text Direction',\n\ttoolbarTooltip: 'Text Direction',\n\tannounceLTR: 'Text direction set to left-to-right',\n\tannounceRTL: 'Text direction set to right-to-left',\n\tannounceAuto: 'Text direction set to automatic',\n};\n\nconst localeModules: LocaleModuleMap<TextDirectionLocale> = import.meta.glob<{\n\tdefault: TextDirectionLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadTextDirectionLocale(lang: string): Promise<TextDirectionLocale> {\n\treturn loadLocaleModule(localeModules, lang, TEXT_DIRECTION_LOCALE_EN);\n}\n","/**\n * Block-level text direction plugin.\n *\n * Patches NodeSpecs of directable block types to add a `dir` attribute\n * (`'ltr' | 'rtl' | 'auto'`), exposes commands and a toolbar dropdown\n * for changing block direction, registers a `Mod-Shift-D` keymap, and\n * (on Windows/Linux) attaches a `Ctrl+Shift` direction handler.\n *\n * Inline `<bdi>` isolation lives in {@link BidiIsolationPlugin}; the\n * auto-detect / inherit / preserve middlewares live in\n * {@link TextDirectionAutoPlugin}. Both consume the\n * {@link TextDirectionService} that this plugin registers.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { isMac } from '../../platform/Platform.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { patchNodeSpecAttr } from '../shared/NodeSpecPatching.js';\nimport {\n\tdispatchIfPresent,\n\tgetSelectedBlock,\n\tgetSelectedBlockIds,\n\tresolveLocale,\n} from '../shared/PluginHelpers.js';\nimport { formatShortcut } from '../shared/ShortcutFormatting.js';\nimport { getBlockDir } from './DirectionDetection.js';\nimport { DIRECTION_ICONS } from './DirectionIcons.js';\nimport { ShiftDirectionHandler } from './ShiftDirectionHandler.js';\nimport {\n\tTEXT_DIRECTION_LOCALE_EN,\n\ttype TextDirectionLocale,\n\tloadTextDirectionLocale,\n} from './TextDirectionLocale.js';\nimport {\n\tTEXT_DIRECTION_SERVICE_KEY,\n\ttype TextDirection,\n\ttype TextDirectionService,\n} from './TextDirectionService.js';\n\nexport type { TextDirection };\n\nexport interface TextDirectionConfig {\n\t/** Block types that support direction. */\n\treadonly directableTypes: readonly string[];\n\treadonly locale?: TextDirectionLocale;\n}\n\nconst DEFAULT_CONFIG: TextDirectionConfig = {\n\tdirectableTypes: [\n\t\t'paragraph',\n\t\t'heading',\n\t\t'title',\n\t\t'subtitle',\n\t\t'table_cell',\n\t\t'blockquote',\n\t\t'list_item',\n\t],\n};\n\nconst ALL_DIRECTIONS: readonly TextDirection[] = ['ltr', 'rtl', 'auto'];\n\nexport class TextDirectionPlugin implements Plugin {\n\treadonly id = 'text-direction';\n\treadonly name = 'Text Direction';\n\treadonly priority = 91;\n\n\tprivate readonly config: TextDirectionConfig;\n\tprivate locale!: TextDirectionLocale;\n\tprivate directableTypes!: ReadonlySet<string>;\n\tprivate shiftDirHandler: ShiftDirectionHandler | null = null;\n\n\tconstructor(config?: Partial<TextDirectionConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tTEXT_DIRECTION_LOCALE_EN,\n\t\t\tloadTextDirectionLocale,\n\t\t);\n\n\t\tthis.directableTypes = new Set(this.config.directableTypes);\n\t\tthis.patchNodeSpecs(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.registerService(context);\n\n\t\tif (!isMac()) {\n\t\t\tthis.shiftDirHandler = new ShiftDirectionHandler(context);\n\t\t\tthis.shiftDirHandler.attach(context.getContainer());\n\t\t}\n\t}\n\n\tdestroy(): void {\n\t\tthis.shiftDirHandler?.detach();\n\t\tthis.shiftDirHandler = null;\n\t}\n\n\tprivate registerService(context: PluginContext): void {\n\t\tconst service: TextDirectionService = {\n\t\t\tdirectableTypes: this.directableTypes,\n\t\t\tgetBlockDir,\n\t\t};\n\t\tcontext.registerService(TEXT_DIRECTION_SERVICE_KEY, service);\n\t}\n\n\tprivate patchNodeSpecs(context: PluginContext): void {\n\t\tpatchNodeSpecAttr(context.getSchemaRegistry(), this.config.directableTypes, {\n\t\t\tattrName: 'dir',\n\t\t\tgetDefault: () => 'auto',\n\t\t\tapplyToDOM: applyDirection,\n\t\t});\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('setDirectionLTR', () => {\n\t\t\tconst result: boolean = this.setDirection(context, 'ltr');\n\t\t\tif (result) context.announce(this.locale.announceLTR);\n\t\t\treturn result;\n\t\t});\n\n\t\tcontext.registerCommand('setDirectionRTL', () => {\n\t\t\tconst result: boolean = this.setDirection(context, 'rtl');\n\t\t\tif (result) context.announce(this.locale.announceRTL);\n\t\t\treturn result;\n\t\t});\n\n\t\tcontext.registerCommand('setDirectionAuto', () => {\n\t\t\tconst result: boolean = this.setDirection(context, 'auto');\n\t\t\tif (result) context.announce(this.locale.announceAuto);\n\t\t\treturn result;\n\t\t});\n\n\t\tcontext.registerCommand('toggleDirection', () => {\n\t\t\tconst state = context.getState();\n\t\t\tconst block = getSelectedBlock(state);\n\t\t\tif (!block || !this.directableTypes.has(block.type)) return false;\n\n\t\t\tconst current: TextDirection = getBlockDir(block);\n\t\t\tconst next: TextDirection = current === 'auto' ? 'rtl' : current === 'rtl' ? 'ltr' : 'auto';\n\t\t\treturn this.setDirection(context, next);\n\t\t});\n\t}\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-D': () => context.executeCommand('toggleDirection'),\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst commandNames: Readonly<Record<TextDirection, string>> = {\n\t\t\tltr: 'setDirectionLTR',\n\t\t\trtl: 'setDirectionRTL',\n\t\t\tauto: 'setDirectionAuto',\n\t\t};\n\n\t\tconst dropdownItems = ALL_DIRECTIONS.map((dir) => ({\n\t\t\tlabel: this.getDirectionLabel(dir),\n\t\t\tcommand: commandNames[dir],\n\t\t\ticon: DIRECTION_ICONS[dir],\n\t\t}));\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'text-direction',\n\t\t\tgroup: 'block',\n\t\t\ticon: DIRECTION_ICONS.auto,\n\t\t\tlabel: this.locale.toolbarLabel,\n\t\t\ttooltip: `${this.locale.toolbarTooltip} (${formatShortcut('Mod-Shift-D')})`,\n\t\t\tcommand: 'setDirectionAuto',\n\t\t\tpopupType: 'dropdown',\n\t\t\tpopupConfig: { items: dropdownItems },\n\t\t\tisActive: (state) => this.isNonDefaultDirection(state),\n\t\t\tisEnabled: (state) => this.isDirectable(state),\n\t\t\tgetIcon: (state) => {\n\t\t\t\tconst block = getSelectedBlock(state);\n\t\t\t\tif (!block) return DIRECTION_ICONS.auto;\n\t\t\t\tconst dir: TextDirection = getBlockDir(block);\n\t\t\t\treturn DIRECTION_ICONS[dir] ?? DIRECTION_ICONS.auto;\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate getDirectionLabel(dir: TextDirection): string {\n\t\tif (dir === 'ltr') return this.locale.ltr;\n\t\tif (dir === 'rtl') return this.locale.rtl;\n\t\treturn this.locale.auto;\n\t}\n\n\tprivate setDirection(context: PluginContext, direction: TextDirection): boolean {\n\t\tconst state = context.getState();\n\t\tconst blockIds: BlockId[] = getSelectedBlockIds(state);\n\t\tif (blockIds.length === 0) return false;\n\n\t\tconst tb = state.transaction('command');\n\t\tlet changed = false;\n\n\t\tfor (const id of blockIds) {\n\t\t\tconst block = state.getBlock(id);\n\t\t\tif (!block || !this.directableTypes.has(block.type)) continue;\n\n\t\t\tconst path = state.getNodePath(id);\n\t\t\tif (!path) continue;\n\n\t\t\ttb.setNodeAttr(path, { ...block.attrs, dir: direction });\n\t\t\tchanged = true;\n\t\t}\n\n\t\tif (!changed) return false;\n\n\t\treturn dispatchIfPresent(context, tb.setSelection(state.selection).build());\n\t}\n\n\tprivate isNonDefaultDirection(state: EditorState): boolean {\n\t\tconst block = getSelectedBlock(state);\n\t\tif (!block || !this.directableTypes.has(block.type)) return false;\n\t\tconst dir = block.attrs?.dir;\n\t\treturn dir != null && dir !== 'auto';\n\t}\n\n\tprivate isDirectable(state: EditorState): boolean {\n\t\tconst block = getSelectedBlock(state);\n\t\treturn block != null && this.directableTypes.has(block.type);\n\t}\n}\n\nfunction applyDirection(el: HTMLElement, node: BlockNode): void {\n\tconst dir = node.attrs?.dir;\n\tif (dir === 'ltr' || dir === 'rtl' || dir === 'auto') {\n\t\tel.setAttribute('dir', dir);\n\t}\n}\n"],"mappings":"mYAUA,IAAa,EAAb,MAI8B,QAH7B,WAA2C,KAC3C,UAAwC,KAExC,WAAA,CAAY,GAAiB,KAAA,QAAA,CAAyB,CAEtD,MAAA,CAAO,GACN,KAAK,UAAY,EACjB,EAAU,iBAAiB,UAAW,KAAK,WAC3C,EAAU,iBAAiB,QAAS,KAAK,QAC1C,CAEA,MAAA,GACM,KAAK,YACV,KAAK,UAAU,oBAAoB,UAAW,KAAK,WACnD,KAAK,UAAU,oBAAoB,QAAS,KAAK,SACjD,KAAK,UAAY,KAClB,CAEA,UAA8B,IACf,UAAV,EAAE,MAAmB,EAAE,SAAY,EAAE,QAAW,EAAE,QAStD,KAAK,WAAa,KARF,cAAX,EAAE,KACL,KAAK,WAAa,MACG,eAAX,EAAE,OACZ,KAAK,WAAa,QAQrB,QAA4B,IAC3B,GAAc,UAAV,EAAE,MAAoB,KAAK,WAAY,OAC3C,MAAM,EAAqB,KAAK,WAChC,KAAK,WAAa,KAClB,MAAM,EAA0B,QAAR,EAAgB,kBAAoB,kBAC5D,KAAK,QAAQ,eAAe,KChCjB,EAAgD,CAC5D,IAAK,gBACL,IAAK,gBACL,KAAM,OACN,aAAc,iBACd,eAAgB,iBAChB,YAAa,sCACb,YAAa,sCACb,aAAc,mCAGT,iBAAsD,OAAA,OAAA,CAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,uBAI5D,eAAsB,EAAwB,GAC7C,OAAO,EAAiB,EAAe,EAAM,EAC9C,CCiBA,IAAM,EAAsC,CAC3C,gBAAiB,CAChB,YACA,UACA,QACA,WACA,aACA,aACA,cAII,EAA2C,CAAC,MAAO,MAAO,QAEnD,EAAb,MACC,GAAc,iBACd,KAAgB,iBAChB,SAAoB,GAEpB,OACA,OACA,gBACA,gBAAwD,KAExD,WAAA,CAAY,GACX,KAAK,OAAS,IAAK,KAAmB,EACvC,CAEA,UAAM,CAAK,GACV,KAAK,aAAe,EACnB,EACA,KAAK,OAAO,OACZ,EACA,GAGD,KAAK,gBAAkB,IAAI,IAAI,KAAK,OAAO,iBAC3C,KAAK,eAAe,GACpB,KAAK,iBAAiB,GACtB,KAAK,gBAAgB,GACrB,KAAK,oBAAoB,GACzB,KAAK,gBAAgB,GAEhB,MACJ,KAAK,gBAAkB,IAAI,EAAsB,GACjD,KAAK,gBAAgB,OAAO,EAAQ,gBAEtC,CAEA,OAAA,GACC,KAAK,iBAAiB,SACtB,KAAK,gBAAkB,IACxB,CAEA,eAAA,CAAwB,GACvB,MAAM,EAAgC,CACrC,gBAAiB,KAAK,gBACtB,eAED,EAAQ,gBAAgB,EAA4B,EACrD,CAEA,cAAA,CAAuB,GACtB,EAAkB,EAAQ,oBAAqB,KAAK,OAAO,gBAAiB,CAC3E,SAAU,MACV,WAAA,IAAkB,OAClB,WAAY,GAEd,CAEA,gBAAA,CAAyB,GACxB,EAAQ,gBAAgB,kBAAA,KACvB,MAAM,EAAkB,KAAK,aAAa,EAAS,OAEnD,OADI,GAAQ,EAAQ,SAAS,KAAK,OAAO,aAClC,IAGR,EAAQ,gBAAgB,kBAAA,KACvB,MAAM,EAAkB,KAAK,aAAa,EAAS,OAEnD,OADI,GAAQ,EAAQ,SAAS,KAAK,OAAO,aAClC,IAGR,EAAQ,gBAAgB,mBAAA,KACvB,MAAM,EAAkB,KAAK,aAAa,EAAS,QAEnD,OADI,GAAQ,EAAQ,SAAS,KAAK,OAAO,cAClC,IAGR,EAAQ,gBAAgB,kBAAA,KAEvB,MAAM,EAAQ,EADA,EAAQ,YAEtB,IAAK,IAAU,KAAK,gBAAgB,IAAI,EAAM,MAAO,OAAO,EAE5D,MAAM,EAAyB,EAAY,GACrC,EAAkC,SAAZ,EAAqB,MAAoB,QAAZ,EAAoB,MAAQ,OACrF,OAAO,KAAK,aAAa,EAAS,IAEpC,CAEA,eAAA,CAAwB,GACvB,EAAQ,eAAe,CACtB,cAAA,IAAqB,EAAQ,eAAe,oBAE9C,CAEA,mBAAA,CAA4B,GAC3B,MAAM,EAAwD,CAC7D,IAAK,kBACL,IAAK,kBACL,KAAM,oBAGD,EAAgB,EAAe,IAAK,IAAA,CACzC,MAAO,KAAK,kBAAkB,GAC9B,QAAS,EAAa,GACtB,KAAM,EAAgB,MAGvB,EAAQ,oBAAoB,CAC3B,GAAI,iBACJ,MAAO,QACP,KAAM,EAAgB,KACtB,MAAO,KAAK,OAAO,aACnB,QAAS,GAAG,KAAK,OAAO,mBAAmB,EAAe,kBAC1D,QAAS,mBACT,UAAW,WACX,YAAa,CAAE,MAAO,GACtB,SAAW,GAAU,KAAK,sBAAsB,GAChD,UAAY,GAAU,KAAK,aAAa,GACxC,QAAU,IACT,MAAM,EAAQ,EAAiB,GAC/B,OAAK,EAEE,EADoB,EAAY,KACR,EAAgB,KAF5B,EAAgB,OAKtC,CAEA,iBAAA,CAA0B,GACzB,MAAY,QAAR,EAAsB,KAAK,OAAO,IAC1B,QAAR,EAAsB,KAAK,OAAO,IAC/B,KAAK,OAAO,IACpB,CAEA,YAAA,CAAqB,EAAwB,GAC5C,MAAM,EAAQ,EAAQ,WAChB,EAAsB,EAAoB,GAChD,GAAwB,IAApB,EAAS,OAAc,OAAO,EAElC,MAAM,EAAK,EAAM,YAAY,WAC7B,IAAI,GAAU,EAEd,IAAK,MAAM,KAAM,EAAU,CAC1B,MAAM,EAAQ,EAAM,SAAS,GAC7B,IAAK,IAAU,KAAK,gBAAgB,IAAI,EAAM,MAAO,SAErD,MAAM,EAAO,EAAM,YAAY,GAC1B,IAEL,EAAG,YAAY,EAAM,IAAK,EAAM,MAAO,IAAK,IAC5C,GAAU,EACX,CAEA,QAAK,GAEE,EAAkB,EAAS,EAAG,aAAa,EAAM,WAAW,QACpE,CAEA,qBAAA,CAA8B,GAC7B,MAAM,EAAQ,EAAiB,GAC/B,IAAK,IAAU,KAAK,gBAAgB,IAAI,EAAM,MAAO,OAAO,EAC5D,MAAM,EAAM,EAAM,OAAO,IACzB,OAAc,MAAP,GAAuB,SAAR,CACvB,CAEA,YAAA,CAAqB,GACpB,MAAM,EAAQ,EAAiB,GAC/B,OAAgB,MAAT,GAAiB,KAAK,gBAAgB,IAAI,EAAM,KACxD,GAGD,SAAS,EAAe,EAAiB,GACxC,MAAM,EAAM,EAAK,OAAO,IACZ,QAAR,GAAyB,QAAR,GAAyB,SAAR,GACrC,EAAG,aAAa,MAAO,EAEzB"}
@@ -1,2 +0,0 @@
1
- import{n as e}from"./TypedKeys-CA4bfw9O.mjs";var r=new e("textDirection");export{r as t};
2
- //# sourceMappingURL=TextDirectionService-BcX07mw2.mjs.map
@@ -1,2 +0,0 @@
1
- import{_ as t,m as e}from"./Commands-1dFFldi7.mjs";import{i}from"./TypeBrands-Ch9856Gb.mjs";import{c as s,n as o,o as r,s as n}from"./PluginHelpers-Dx_0hfDe.mjs";import{t as a}from"./MarkInputRule-Bdi8KPus.mjs";import{t as l}from"./ShortcutFormatting-TwiufqeV.mjs";var g={boldLabel:"Bold",italicLabel:"Italic",underlineLabel:"Underline"},c=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-Dx2lO0Nm.mjs"),"./locales/de.ts":()=>import("./de-BcPntcnr.mjs"),"./locales/es.ts":()=>import("./es-nRLq7bgP.mjs"),"./locales/fr.ts":()=>import("./fr-DiDhVhyV.mjs"),"./locales/hi.ts":()=>import("./hi-BNJIGWQQ.mjs"),"./locales/pt.ts":()=>import("./pt-D__tcM2T.mjs"),"./locales/ru.ts":()=>import("./ru-CvDl-yEd.mjs"),"./locales/zh.ts":()=>import("./zh-C-wHnDo5.mjs")});async function m(t){return s(c,t,g)}var p={bold:!0,italic:!0,underline:!0},f=[{type:"bold",configKey:"bold",rank:0,tag:"strong",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:t=>`<strong>${t}</strong>`,parseHTML:[{tag:"strong"},{tag:"b",getAttrs:t=>{const e=t.style.fontWeight;return"normal"!==e&&"400"!==e&&{}}},{tag:"span",getAttrs:t=>{const e=t.style.fontWeight;if(!e)return!1;if("bold"===e)return{};const i=Number.parseInt(e,10);return!Number.isNaN(i)&&i>=700&&{}}}],sanitize:{tags:["strong","b"]}},{type:"italic",configKey:"italic",rank:1,tag:"em",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:t=>`<em>${t}</em>`,parseHTML:[{tag:"em"},{tag:"i"},{tag:"span",getAttrs:t=>"italic"===t.style.fontStyle&&{}}],sanitize:{tags:["em","i"]}},{type:"underline",configKey:"underline",rank:2,tag:"u",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:t=>`<u>${t}</u>`,parseHTML:[{tag:"u"},{tag:"span",getAttrs:t=>!!t.style.textDecoration.includes("underline")&&{}}],sanitize:{tags:["u"]}}],h=class{id="text-formatting";name="Text Formatting";priority=20;config;locale;constructor(t){this.config={...p,...t}}async init(t){this.locale=await r(t,this.config.locale,g,m);const e=f.filter(t=>this.config[t.configKey]);for(const i of e)this.registerMark(t,i);this.registerKeymaps(t,e),this.registerInputRules(t),this.registerDisabledToolbarItems(t)}registerMark(s,r){const a=n(r.type),g=this.isToolbarVisible(r.configKey);if(s.registerMarkSpec({type:r.type,rank:r.rank,toDOM:()=>document.createElement(r.tag),toHTMLString:(t,e)=>r.toHTMLString(e),parseHTML:r.parseHTML,sanitize:r.sanitize}),s.registerCommand(a,()=>o(s,t(s.getState(),i(r.type)))),g){const t=this.getMarkLabel(r.type);s.registerToolbarItem({id:r.type,group:"format",icon:r.icon,label:t,tooltip:`${t} (${l(r.keyBinding)})`,command:a,isActive:t=>e(t,i(r.type))})}}registerKeymaps(t,e){const i={};for(const s of e){const e=n(s.type);i[s.keyBinding]=()=>t.executeCommand(e)}Object.keys(i).length>0&&t.registerKeymap(i)}registerInputRules(t){!1!==this.config.inputRule&&(this.config.bold&&t.registerInputRule(a("bold","**")),this.config.italic&&t.registerInputRule(a("italic","*")))}registerDisabledToolbarItems(t){if(this.config.toolbar)for(const e of f){const i=this.config[e.configKey],s=this.config.toolbar[e.configKey]??!0;!i&&s&&t.registerToolbarItem({id:e.type,group:"format",icon:e.icon,label:this.getMarkLabel(e.type),command:n(e.type),isEnabled:()=>!1})}}getMarkLabel(t){const e=`${t}Label`;return this.locale[e]}isToolbarVisible(t){return!this.config.toolbar||(this.config.toolbar[t]??!0)}};export{g as n,m as r,h as t};
2
- //# sourceMappingURL=TextFormattingPlugin-DBVlePqj.mjs.map
@@ -1,2 +0,0 @@
1
- import{i as t}from"./Platform-ByobkiCc.mjs";import{c as e,s as o}from"./StyleRuntime-DW6omotc.mjs";import{n}from"./TypedKeys-CA4bfw9O.mjs";import{c as r,o as i}from"./PluginHelpers-Dx_0hfDe.mjs";import{n as l,r as s,t as a}from"./KeyboardNav-D0my3wuy.mjs";import{i as c,r as d,t as p}from"./PopupPositioning-BFh6Ed1D.mjs";import{n as u,t as h}from"./PopupManager-CT-fMZJn.mjs";var b=class{_toolbarItems=/* @__PURE__ */new Map;_toolbarItemPluginMap=/* @__PURE__ */new Map;registerToolbarItem(t,e){if(this._toolbarItems.has(t.id))throw new Error(`ToolbarItem with id "${t.id}" is already registered.`);if(this._toolbarItems.set(t.id,t),e){const o=this._toolbarItemPluginMap.get(e)??[];o.push(t.id),this._toolbarItemPluginMap.set(e,o)}}getToolbarItemsByPlugin(t){const e=this._toolbarItemPluginMap.get(t)??[],o=[];for(const n of e){const t=this._toolbarItems.get(n);t&&o.push(t)}return o}getToolbarItem(t){return this._toolbarItems.get(t)}getToolbarItems(){return[...this._toolbarItems.values()]}removeToolbarItem(t){this._toolbarItems.delete(t);for(const[e,o]of this._toolbarItemPluginMap){const n=o.indexOf(t);if(-1!==n){o.splice(n,1),0===o.length&&this._toolbarItemPluginMap.delete(e);break}}}clear(){this._toolbarItems.clear(),this._toolbarItemPluginMap.clear()}};function m(t){for(let e=0;e<t.length;e++)if(!t[e]?.disabled)return e;return-1}var f={formattingOptionsAria:"Formatting options",moreToolsAria:"More tools",gridPickerLabel:(t,e)=>`${t} x ${e}`},v=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-C9lO1jsY.mjs"),"./locales/de.ts":()=>import("./de-BXQBXxFJ.mjs"),"./locales/es.ts":()=>import("./es-CXuMz87y.mjs"),"./locales/fr.ts":()=>import("./fr-fshsDD66.mjs"),"./locales/hi.ts":()=>import("./hi-BOMkDPqC.mjs"),"./locales/pt.ts":()=>import("./pt-Cc4zysaT.mjs"),"./locales/ru.ts":()=>import("./ru-CwyPz2Va.mjs"),"./locales/zh.ts":()=>import("./zh-DgSmvLyw.mjs")});async function g(t){return r(v,t,f)}var w={BurgerMenu:"burger-menu",Flow:"flow",None:"none"},x="notectl-toolbar-btn--overflow-hidden",y="notectl-toolbar-separator--overflow-hidden",A="notectl-toolbar-group--overflow-hidden",E="notectl-toolbar-group",_="notectl-toolbar-separator",k=class{toolbar;context;onOverflowChange;onItemActivated;getActiveElement;ariaLabel;popupManager;entries=[];overflowButton=null;overflowDropdown=null;overflowHandle=null;overflowEntries=[];resizeObserver=null;closeHandler=null;closeHandlerTimer=null;closeHandlerAttached=!1;constructor(t){this.toolbar=t.toolbar,this.ariaLabel=t.ariaLabel,this.context=t.context,this.onOverflowChange=t.onOverflowChange,this.onItemActivated=t.onItemActivated,this.getActiveElement=t.getActiveElement,this.popupManager=t.popupManager??null,this.resizeObserver=new ResizeObserver(()=>this.recalculate()),this.resizeObserver.observe(this.toolbar)}update(t){this.entries=t.map(t=>({element:t.element,item:t.item})),this.recalculate()}recalculate(){if(0===this.entries.length)return;this.closeDropdown(),this.resetVisibility(),this.ensureOverflowButton(),this.setOverflowButtonVisible(!1);const t=this.measureAvailableWidth(),e=Array.from(this.toolbar.children),o=this.measureChildWidths(e),n=t-34-2;let r=0,i=!1;const l=[];for(const s of e){if(s===this.overflowButton)continue;if(s.classList.contains(_)){const t=(o.get(s)??0)+2;i||r+t>n?(i=!0,s.classList.add(y)):r+=t;continue}if(s.classList.contains(E)){const t=(o.get(s)??0)+2,e=this.entriesInside(s);i||r+t>n?(i=!0,this.hideGroup(s,e,l)):r+=t;continue}const t=this.entries.find(t=>t.element===s);if(!t)continue;const e=(o.get(s)??0)+2;i||r+e>n?(i=!0,t.element.classList.add(x),l.push(t)):r+=e}this.overflowEntries=l,this.hideTrailingSeparators(),this.setOverflowButtonVisible(l.length>0),this.notifyChange()}hideGroup(t,e,o){t.classList.add(A);for(const n of e)n.element.classList.add(x),o.push(n)}entriesInside(t){const e=[];for(const o of this.entries)t.contains(o.element)&&e.push(o);return e}updateItemStates(t){if(!this.overflowDropdown)return;const e=Array.from(this.overflowDropdown.querySelectorAll(".notectl-dropdown__item"));for(const o of e){const e=o.getAttribute("data-toolbar-item"),n=this.overflowEntries.find(t=>t.item.id===e);if(!n)continue;const r=n.item.isActive?.(t)??!1,i=n.item.isEnabled?.(t)??!0;if(o.classList.toggle("notectl-dropdown__item--active",r),o.disabled=!i,"combobox"===n.item.popupType){const e=o.querySelector(".notectl-dropdown__item-label");e&&(e.textContent=n.item.getLabel(t))}if(n.item.getIcon){const e=n.item.getIcon(t),r=o.querySelector(".notectl-dropdown__item-icon");r&&r.innerHTML!==e&&(r.innerHTML=e)}}}destroy(){this.resizeObserver?.disconnect(),this.resizeObserver=null,this.closeDropdown(),this.overflowButton?.remove(),this.overflowButton=null,this.entries=[],this.overflowEntries=[]}measureChildWidths(t){const e=/* @__PURE__ */new Map;for(const o of t)o!==this.overflowButton&&e.set(o,o.offsetWidth);return e}measureAvailableWidth(){const t=getComputedStyle(this.toolbar),e=Number.parseFloat(t.paddingLeft)||0,o=Number.parseFloat(t.paddingRight)||0;return this.toolbar.clientWidth-e-o}resetVisibility(){for(const o of this.entries)o.element.classList.remove(x);const t=Array.from(this.toolbar.querySelectorAll(`.${_}`));for(const o of t)o.classList.remove(y);const e=Array.from(this.toolbar.querySelectorAll(`.${E}`));for(const o of e)o.classList.remove(A)}setOverflowButtonVisible(t){this.overflowButton&&(this.overflowButton.classList.toggle("notectl-toolbar-overflow-btn--hidden",!t),t||this.overflowButton.removeAttribute("tabindex"))}ensureOverflowButton(){if(this.overflowButton)return;const t=document.createElement("button");t.type="button",t.className="notectl-toolbar-overflow-btn",t.setAttribute("aria-label",this.ariaLabel),t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded","false"),t.setAttribute("part","toolbar-button toolbar-overflow-button"),t.innerHTML='<svg viewBox="0 0 16 16" width="16" height="16"><circle cx="3" cy="8" r="1.5" fill="currentColor"/><circle cx="8" cy="8" r="1.5" fill="currentColor"/><circle cx="13" cy="8" r="1.5" fill="currentColor"/></svg>',t.addEventListener("mousedown",t=>{t.preventDefault(),this.toggleDropdown()}),this.toolbar.appendChild(t),this.overflowButton=t}toggleDropdown(){this.overflowDropdown?this.closeDropdown():this.openDropdown()}openDropdown(){if(!this.overflowButton||0===this.overflowEntries.length)return;const t=document.createElement("div");t.className="notectl-toolbar-popup notectl-dropdown",t.setAttribute("role","menu"),this.renderDropdownItems(t,this.context.getState()),this.popupManager?(this.overflowHandle=this.popupManager.open({anchor:this.overflowButton,className:"notectl-toolbar-popup notectl-dropdown",ariaRole:"menu",position:"below-end",referenceNode:this.overflowButton,restoreFocusTo:this.overflowButton,onClose:()=>{this.overflowHandle=null,this.overflowDropdown=null,this.overflowButton&&this.overflowButton.setAttribute("aria-expanded","false")},content:t=>{this.renderDropdownItems(t,this.context.getState()),this.overflowDropdown=t,t.addEventListener("keydown",t=>this.handleDropdownKeydown(t))}}),this.overflowButton.setAttribute("aria-expanded","true")):(this.positionDropdown(t),p(t,this.overflowButton),this.overflowDropdown=t,this.overflowButton.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{t.querySelector('[role="menuitem"]')?.focus()}),t.addEventListener("keydown",t=>this.handleDropdownKeydown(t)),this.registerCloseHandler())}renderDropdownItems(t,e){let o=null;for(const n of this.overflowEntries){if(null!==o&&n.item.group!==o){const e=document.createElement("div");e.className="notectl-dropdown__separator",e.setAttribute("role","separator"),t.appendChild(e)}o=n.item.group;const r=document.createElement("button");r.type="button",r.className="notectl-dropdown__item",r.setAttribute("role","menuitem"),r.setAttribute("tabindex","-1"),r.setAttribute("data-toolbar-item",n.item.id);const i=document.createElement("span");i.className="notectl-dropdown__item-icon","combobox"!==n.item.popupType&&(i.innerHTML=n.item.icon),r.appendChild(i);const l=document.createElement("span");l.className="notectl-dropdown__item-label",l.textContent="combobox"===n.item.popupType?n.item.getLabel(e):n.item.tooltip??n.item.label,r.appendChild(l),r.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),this.activateOverflowItem(n)}),t.appendChild(r)}}positionDropdown(e){if(!this.overflowButton)return;const o=this.overflowButton.getBoundingClientRect(),n=t(this.toolbar);c(e,o,{position:n?"below-start":"below-end",isRtl:n})}registerCloseHandler(){this.closeHandler=t=>{const e=t.composedPath();this.overflowDropdown&&!e.includes(this.overflowDropdown)&&this.overflowButton&&!e.includes(this.overflowButton)&&this.closeDropdown()},this.closeHandlerTimer=setTimeout(()=>{this.closeHandlerTimer=null,this.closeHandler&&this.overflowDropdown&&(document.addEventListener("mousedown",this.closeHandler),this.closeHandlerAttached=!0)},0)}closeDropdown(){if(this.overflowHandle){const t=this.overflowHandle;return this.overflowHandle=null,this.overflowDropdown=null,t.close(),void(this.overflowButton&&this.overflowButton.setAttribute("aria-expanded","false"))}this.overflowDropdown&&(this.overflowDropdown.remove(),this.overflowDropdown=null),this.overflowButton&&this.overflowButton.setAttribute("aria-expanded","false"),this.closeHandler&&(null!==this.closeHandlerTimer&&(clearTimeout(this.closeHandlerTimer),this.closeHandlerTimer=null),this.closeHandlerAttached&&(document.removeEventListener("mousedown",this.closeHandler),this.closeHandlerAttached=!1),this.closeHandler=null)}activateOverflowItem(t){this.closeDropdown(),t.item.popupType&&this.overflowButton?this.onItemActivated(this.overflowButton,t.item):this.context.executeCommand(t.item.command)}handleDropdownKeydown(t){if(!this.overflowDropdown)return;if("Escape"===t.key||"Tab"===t.key)return t.preventDefault(),t.stopPropagation(),this.closeDropdown(),void this.overflowButton?.focus();const e=Array.from(this.overflowDropdown.querySelectorAll('[role="menuitem"]')),o=e.indexOf(this.getActiveElement());switch(t.key){case"ArrowDown":t.preventDefault(),e[l(e,o,1)]?.focus();break;case"ArrowUp":t.preventDefault(),e[l(e,o,-1)]?.focus();break;case"Enter":case" ":{t.preventDefault();const n=e[o];if(!n)break;const r=n.getAttribute("data-toolbar-item"),i=this.overflowEntries.find(t=>t.item.id===r);i&&this.activateOverflowItem(i);break}}}hideTrailingSeparators(){const t=Array.from(this.toolbar.children);for(let e=t.length-1;e>=0;e--){const o=t[e];if(!o||o===this.overflowButton)continue;if(o.classList.contains(_)){o.classList.contains(y)||o.classList.add(y);continue}const n=o.classList.contains(E)&&o.classList.contains(A),r=o.classList.contains("notectl-toolbar-btn")&&o.classList.contains(x);if(!n&&!r)break}}notifyChange(){const t=this.entries.filter(t=>!t.element.classList.contains(x)).map(t=>t.element);this.onOverflowChange(t,this.overflowEntries.length>0?this.overflowButton:null)}};function C(t,e,o){const n=t.querySelectorAll(".notectl-grid-picker__cell");for(const r of n){const t=Number(r.getAttribute("data-row")),n=Number(r.getAttribute("data-col"));r.classList.toggle("notectl-grid-picker__cell--highlighted",t<=e&&n<=o)}}function B(){const t=document.createElement("span");return t.className="notectl-toolbar-separator",t.setAttribute("role","separator"),t.setAttribute("part","toolbar-divider"),t}var L=class{activePopup=null;activePopupButton=null;activeHandle=null;getActiveElement;locale;popupManager=null;constructor(t,e=f){this.getActiveElement=t,this.locale=e}setPopupManager(t){this.popupManager=t}isOpen(){return null!==this.activePopup}toggle(t,e,o){this.activePopup?this.close():this.openViaManager(t,e,o)}close(){if(this.activeHandle){const t=this.activeHandle;return this.activeHandle=null,this.clearButtonState(),void t.close()}this.clearButtonState(),this.activePopup&&(this.activePopup.remove(),this.activePopup=null)}closeAndRestoreFocus(){const t=this.activePopupButton;this.close(),t?.focus()}destroy(){this.close()}openViaManager(t,e,o){this.popupManager&&(this.activePopupButton=t,t.classList.add("notectl-toolbar-btn--popup-open"),t.setAttribute("aria-expanded","true"),this.activeHandle=this.popupManager.open({anchor:t,className:"notectl-toolbar-popup",referenceNode:t,restoreFocusTo:t,position:"below-start",onClose:()=>{this.activeHandle=null,this.clearButtonState(),this.activePopup=null},content:(t,n)=>{this.activePopup=t,this.renderPopupContent(t,e,o,n),t.addEventListener("keydown",t=>this.handlePopupKeydown(t))}}))}renderPopupContent(t,e,n,r){const i=()=>{r({restoreFocusTo:null}),n.getContainer().focus()};switch(e.popupType){case"gridPicker":!function(t,e,n,r=f){t.className+=" notectl-grid-picker";const i=document.createElement("div");i.className="notectl-grid-picker__grid",i.setAttribute("role","grid"),o(i,{display:"grid",gridTemplateColumns:`repeat(${e.maxCols}, 1fr)`,gap:"2px",padding:"8px"});const l=document.createElement("div");l.className="notectl-grid-picker__label",l.textContent=r.gridPickerLabel(1,1),o(l,{textAlign:"center",padding:"4px",fontSize:"12px"}),l.setAttribute("aria-live","polite");for(let s=1;s<=e.maxRows;s++)for(let t=1;t<=e.maxCols;t++){const a=document.createElement("div");a.className="notectl-grid-picker__cell",a.setAttribute("role","gridcell"),a.setAttribute("tabindex","-1"),a.setAttribute("aria-label",r.gridPickerLabel(s,t)),o(a,{width:"20px",height:"20px",border:"1px solid #ccc",cursor:"pointer"}),a.setAttribute("data-row",String(s)),a.setAttribute("data-col",String(t)),a.addEventListener("mouseenter",()=>{C(i,s,t),l.textContent=r.gridPickerLabel(s,t)}),a.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),a.addEventListener("click",()=>{e.onSelect(s,t),n()}),i.appendChild(a)}t.appendChild(i),t.appendChild(l)}(t,e.popupConfig,i,this.locale);break;case"dropdown":!function(t,e,o,r){t.classList.add("notectl-dropdown"),t.setAttribute("role","menu");for(const i of e.items){const e=document.createElement("button");if(e.type="button",e.className="notectl-dropdown__item",e.setAttribute("role","menuitem"),e.setAttribute("tabindex","-1"),i.icon){const t=document.createElement("span");t.className="notectl-dropdown__item-icon",t.innerHTML=i.icon,e.appendChild(t)}const o=document.createElement("span");o.className="notectl-dropdown__item-label",o.textContent=i.label,e.appendChild(o),e.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),e.addEventListener("click",()=>{var t;t=i.command,n.executeCommand(t),r()}),t.appendChild(e)}}(t,e.popupConfig,0,i);break;case"custom":case"combobox":e.renderPopup(t,n,r)}}clearButtonState(){this.activePopupButton&&(this.activePopupButton.classList.remove("notectl-toolbar-btn--popup-open"),this.activePopupButton.setAttribute("aria-expanded","false"),this.activePopupButton=null)}handlePopupKeydown(t){if(!this.activePopup)return;if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void this.closeAndRestoreFocus();if("Tab"===t.key)return t.preventDefault(),void this.closeAndRestoreFocus();const e=this.activePopup.querySelectorAll('[role="menuitem"]');e.length>0?this.handleDropdownKeydown(t,e):null===this.activePopup.querySelector(".notectl-grid-picker__cell")?this.handleCustomPopupKeydown(t):this.handleGridKeydown(t)}handleDropdownKeydown(t,e){const o=Array.from(e),n=o.indexOf(this.getActiveElement());switch(t.key){case"ArrowDown":t.preventDefault(),o[l(o,n,1)]?.focus();break;case"ArrowUp":t.preventDefault(),o[l(o,n,-1)]?.focus();break;case"Enter":case" ":{t.preventDefault();const e=o[n];e&&e.click();break}}}handleGridKeydown(e){const o=this.getActiveElement(),n=Number(o?.getAttribute("data-row")??1),r=Number(o?.getAttribute("data-col")??1),i=this.activePopup?.querySelector(".notectl-grid-picker__grid")??null;if(!i)return;const l=i.querySelector(".notectl-grid-picker__cell:last-child"),a=Number(l?.getAttribute("data-col")??1),c=Number(l?.getAttribute("data-row")??1);if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)){e.preventDefault();const[o,l]=s(n,r,c,a,e.key,!!this.activePopup&&t(this.activePopup));i.querySelector(`.notectl-grid-picker__cell[data-row="${o}"][data-col="${l}"]`)?.focus(),C(i,o,l);const d=this.activePopup?.querySelector(".notectl-grid-picker__label")??null;d&&(d.textContent=this.locale.gridPickerLabel(o,l))}"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o?.click())}handleCustomPopupKeydown(t){if(!this.activePopup)return;const e=Array.from(this.activePopup.querySelectorAll("button"));if(0===e.length)return;const o=this.getActiveElement(),n=e.indexOf(o);switch(t.key){case"ArrowDown":t.preventDefault(),e[l(e,n,1)]?.focus();break;case"ArrowUp":t.preventDefault(),e[l(e,n,-1)]?.focus();break;case"Enter":case" ":t.preventDefault(),o&&((r=o).dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),r.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),r.click())}var r}},I=class t{element;timer=null;target=null;isPopupActive;static TOOLTIP_ID="notectl-toolbar-tooltip";constructor(o){this.isPopupActive=o,this.element=document.createElement("div"),this.element.className="notectl-toolbar-tooltip",this.element.id=t.TOOLTIP_ID,this.element.setAttribute("role","tooltip"),e(this.element,"display","none")}show(n){if(this.hide(),this.isPopupActive()||n.disabled)return;const r=n.getAttribute("data-tooltip");r&&(this.target=n,this.timer=setTimeout(()=>{if(this.isPopupActive())return;this.element.textContent=r,e(this.element,"display","");const i=n.getRootNode();i instanceof ShadowRoot&&!this.element.parentNode?i.appendChild(this.element):i instanceof ShadowRoot||this.element.parentNode||document.body.appendChild(this.element),n.setAttribute("aria-describedby",t.TOOLTIP_ID);const l=n.getBoundingClientRect();e(this.element,"position","fixed");const s=d(this.element);o(this.element,{top:l.bottom+6-s.y+"px",left:l.left+l.width/2-s.x+"px",transform:"translateX(-50%)"})},500))}hide(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.target&&(this.target.removeAttribute("aria-describedby"),this.target=null),e(this.element,"display","none")}destroy(){this.hide(),this.element.remove()}};function P(t){if(Array.isArray(t))return{plugins:t,label:void 0};const e=t;return{plugins:e.plugins,label:e.label}}var D=new n("toolbar"),T=class{id="toolbar";name="Toolbar";priority=10;context=null;toolbarElement=null;buttons=[];hiddenItems=/* @__PURE__ */new Set;layoutConfig;overflowBehavior;focusedIndex=0;tooltip=null;popupController=null;popupManager=null;overflowController=null;visibleElements=[];locale;constructor(t){this.layoutConfig=t??null,this.overflowBehavior=t?.overflow??w.BurgerMenu}async init(t){this.locale=await i(t,void 0,f,g),t.registerStyleSheet('\n/* Toolbar */\n.notectl-plugin-container--top {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\tborder-bottom: 1px solid var(--notectl-border);\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n\tmin-height: 40px;\n\tflex-shrink: 0;\n}\n\n.notectl-toolbar {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n\tflex: 1;\n\tmin-width: 0;\n\tgap: 2px;\n\tpadding: 4px 8px;\n}\n\n.notectl-toolbar[hidden] {\n\tdisplay: none;\n}\n\n/* Group wrapper — real flex container so consumers can style it via ::part(toolbar-group)\n with padding/background/border directly. Group gap mirrors the toolbar gap so the\n visual rhythm between buttons stays uniform whether or not a group boundary lies between them. */\n.notectl-toolbar-group {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 2px;\n}\n\n.notectl-toolbar-group--overflow-hidden {\n\tdisplay: none;\n}\n\n.notectl-toolbar-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-toolbar-button-bg, transparent);\n\tcursor: pointer;\n\tcolor: var(--notectl-toolbar-button-fg, var(--notectl-fg));\n\tfont-size: 14px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn:hover {\n\t\tbackground: var(--notectl-toolbar-button-hover-bg, var(--notectl-hover-bg));\n\t\tborder-color: var(--notectl-border);\n\t}\n}\n\n.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-toolbar-button-active-bg, var(--notectl-active-bg));\n\tborder-color: var(--notectl-primary-muted);\n\tcolor: var(--notectl-toolbar-button-active-fg, var(--notectl-primary-fg));\n}\n\n.notectl-toolbar-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn:disabled:hover {\n\t\tbackground: transparent;\n\t\tborder-color: transparent;\n\t}\n}\n\n.notectl-toolbar-btn__icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n\tdisplay: block;\n\twidth: 18px;\n\theight: 18px;\n\tfill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n\tpadding: 4px 8px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 10001;\n\tline-height: 1.4;\n\tletter-spacing: 0.01em;\n\tfont-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n\tdisplay: inline-block;\n\twidth: 1px;\n\theight: 20px;\n\tbackground: var(--notectl-border);\n\tmargin: 0 4px;\n\tvertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\toverflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-grid-picker__cell--highlighted {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n}\n\n/* Dropdown */\n.notectl-dropdown {\n\tmin-width: 160px;\n\tpadding: 4px 0;\n}\n\n.notectl-dropdown__item {\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: start;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\tfont-family: inherit;\n\twhite-space: nowrap;\n}\n\n@media (hover: hover) {\n\t.notectl-dropdown__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-dropdown__item:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\toutline: none;\n}\n\n.notectl-dropdown__item-icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-fg-muted);\n\tflex-shrink: 0;\n}\n\n.notectl-dropdown__item-label {\n\tflex: 1;\n}\n\n/* Overflow behavior: flow mode — toolbar wraps to additional rows */\n.notectl-toolbar[data-overflow="flow"] {\n\tflex-wrap: wrap;\n\toverflow: visible;\n}\n\n/* Overflow behavior: none — toolbar clips without any responsive behavior */\n.notectl-toolbar[data-overflow="none"] {\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n}\n\n/* Overflow: hidden items (burger-menu mode) */\n.notectl-toolbar-btn--overflow-hidden,\n.notectl-toolbar-separator--overflow-hidden {\n\tdisplay: none;\n}\n\n/* Overflow "more" button */\n.notectl-toolbar-overflow-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 16px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\tmargin-inline-start: auto;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-overflow-btn:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t\tborder-color: var(--notectl-border);\n\t}\n}\n\n.notectl-toolbar-overflow-btn--hidden {\n\tdisplay: none;\n}\n\n.notectl-toolbar-overflow-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n/* Dropdown item states shared by all dropdown menus (including overflow) */\n.notectl-dropdown__item:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n@media (hover: hover) {\n\t.notectl-dropdown__item:disabled:hover {\n\t\tbackground: none;\n\t}\n}\n\n.notectl-dropdown__item--active {\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-dropdown__item-icon svg {\n\tdisplay: block;\n\twidth: 16px;\n\theight: 16px;\n\tfill: currentColor;\n}\n\n.notectl-dropdown__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 0;\n}\n\n/* Combobox-style toolbar buttons (shared base for font, fontSize, heading, etc.) */\n.notectl-toolbar-btn[role="combobox"] {\n\twidth: auto;\n\tpadding: 0 8px;\n\tgap: 4px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn[role="combobox"]:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t\tborder-color: var(--notectl-fg-muted);\n\t}\n}\n\n.notectl-toolbar-btn[role="combobox"].notectl-toolbar-btn--active {\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n\tborder-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-combobox__label {\n\tflex: 1;\n\tfont-size: 13px;\n\tfont-weight: 500;\n\tcolor: var(--notectl-fg);\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\ttext-align: start;\n\tline-height: 30px;\n}\n\n.notectl-toolbar-combobox__arrow {\n\tflex-shrink: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tline-height: 30px;\n}\n\n/* Link Popup */\n.notectl-link-popup {\n\tpadding: 8px;\n\tmin-width: 200px;\n}\n\n.notectl-link-popup__input {\n\twidth: 100%;\n\tpadding: 4px;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n}\n\n.notectl-link-popup__input:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-link-popup__button {\n\twidth: 100%;\n\tpadding: 6px 12px;\n\tcursor: pointer;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-overlay);\n\tcolor: var(--notectl-fg);\n\tfont-size: 13px;\n}\n\n.notectl-link-popup__button--apply {\n\tmargin-top: 4px;\n}\n\n@media (hover: hover) {\n\t.notectl-link-popup__button:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-link-popup__button:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n'),this.context=t,this.popupManager=new h(t.getContainer()),t.registerService(u,this.popupManager),this.popupController=new L(()=>this.getActiveElement(),this.locale),this.popupController.setPopupManager(this.popupManager),this.tooltip=new I(()=>this.popupController?.isOpen()??!1),t.registerService(D,{refresh:()=>this.updateButtonStates(t.getState()),closePopup:()=>this.popupController?.close()}),this.createToolbarElement()}getOverflowBehavior(){return this.overflowBehavior}setOverflowBehavior(t){t!==this.overflowBehavior&&(this.overflowBehavior=t,this.applyOverflowBehavior(),this.renderItems())}onReady(){this.renderItems()}destroy(){this.overflowController?.destroy(),this.overflowController=null,this.popupController?.destroy(),this.popupController=null,this.popupManager?.destroy(),this.popupManager=null,this.tooltip?.destroy(),this.tooltip=null,this.toolbarElement&&(this.toolbarElement.remove(),this.toolbarElement=null),this.buttons=[],this.visibleElements=[],this.context=null}onStateChange(t,e,o){this.updateButtonStates(e)}onReadOnlyChange(t){this.toolbarElement&&(this.toolbarElement.hidden=t)}onConfigure(t){for(const[e,o]of Object.entries(t))!1===o?this.hiddenItems.add(e):this.hiddenItems.delete(e);this.renderItems()}createToolbarElement(){if(!this.context)return;this.toolbarElement&&this.toolbarElement.remove(),this.buttons=[];const t=this.context.getPluginContainer("top");this.toolbarElement=document.createElement("div"),this.toolbarElement.setAttribute("role","toolbar"),this.toolbarElement.setAttribute("aria-label",this.locale.formattingOptionsAria),this.toolbarElement.setAttribute("data-notectl-no-print",""),this.toolbarElement.setAttribute("part","toolbar"),this.toolbarElement.className="notectl-toolbar",this.toolbarElement.addEventListener("keydown",t=>this.handleToolbarKeydown(t)),this.applyOverflowBehavior(),t.appendChild(this.toolbarElement)}applyOverflowBehavior(){this.toolbarElement&&this.context&&(this.overflowController?.destroy(),this.overflowController=null,this.toolbarElement.setAttribute("data-overflow",this.overflowBehavior),this.overflowBehavior===w.BurgerMenu?this.overflowController=new k({toolbar:this.toolbarElement,ariaLabel:this.locale.moreToolsAria,context:this.context,popupManager:this.popupManager??void 0,onOverflowChange:(t,e)=>{this.visibleElements=e?[...t,e]:[...t],this.initRovingTabindex()},onItemActivated:(t,e)=>{this.activateButton(t,e)},getActiveElement:()=>this.getActiveElement()}):this.visibleElements=[])}renderItems(){if(this.context&&this.toolbarElement){for(const t of this.buttons)t.element.remove();this.buttons=[];for(const t of this.toolbarElement.querySelectorAll(".notectl-toolbar-separator"))t.remove();for(const t of this.toolbarElement.querySelectorAll(".notectl-toolbar-group"))t.remove();this.layoutConfig?this.renderItemsByLayout():this.renderItemsByGroup(),this.buttons.length>0&&!this.toolbarElement.parentElement&&this.context.getPluginContainer("top").appendChild(this.toolbarElement),this.overflowController?.update(this.buttons),this.initRovingTabindex(),this.updateButtonStates(this.context.getState())}}createGroupWrapper(t){const e=document.createElement("div");return e.className="notectl-toolbar-group",e.setAttribute("part","toolbar-group"),void 0!==t&&(e.setAttribute("role","group"),e.setAttribute("aria-label",t)),e}getTabElements(){return this.visibleElements.length>0?this.visibleElements:this.buttons.map(t=>t.element)}initRovingTabindex(){const t=this.getTabElements(),e=m(t);this.focusedIndex=e>=0?e:0,a(t,this.focusedIndex)}setRovingFocus(t){const e=this.getTabElements();t<0||t>=e.length||(this.focusedIndex=t,a(e,t),e[t]?.focus())}getActiveElement(){const t=this.toolbarElement?.getRootNode();return t instanceof ShadowRoot?t.activeElement:document.activeElement}syncFocusedIndex(){const t=this.getActiveElement(),e=this.getTabElements().findIndex(e=>e===t);e>=0&&(this.focusedIndex=e)}handleToolbarKeydown(e){const o=this.getTabElements();var n;if(0!==o.length)switch(this.syncFocusedIndex(),e.key){case"ArrowRight":case"ArrowLeft":{e.preventDefault();const r=(n=!!this.toolbarElement&&t(this.toolbarElement),"ArrowRight"===e.key?n?-1:1:n?1:-1),i=function(t,e,o){const n=t.length;if(0===n)return-1;let r=e;for(let i=0;i<n;i++)if(r=(r+o+n)%n,!t[r]?.disabled)return r;return e}(o,this.focusedIndex,r);this.setRovingFocus(i);break}case"Home":{e.preventDefault();const t=m(o);t>=0&&this.setRovingFocus(t);break}case"End":{e.preventDefault();const t=function(t){for(let e=t.length-1;e>=0;e--)if(!t[e]?.disabled)return e;return-1}(o);t>=0&&this.setRovingFocus(t);break}case"Enter":case" ":{e.preventDefault();const t=o[this.focusedIndex],n=this.buttons.find(e=>e.element===t);n&&this.activateButton(n.element,n.item);break}}}activateButton(t,e){this.tooltip?.hide(),e.popupType&&this.context?this.popupController?.toggle(t,e,this.context):this.context?.executeCommand(e.command)}renderItemsByLayout(){if(!this.context||!this.toolbarElement||!this.layoutConfig)return;const t=this.context.getToolbarRegistry();let e=!0;for(const o of this.layoutConfig.groups){const{plugins:n,label:r}=P(o),i=[];for(const e of n){const o=t.getToolbarItemsByPlugin(e).filter(t=>!this.hiddenItems.has(t.id));i.push(...o)}if(0===i.length)continue;e||this.toolbarElement.appendChild(B()),e=!1;const l=this.createGroupWrapper(r);for(const t of i){const e=this.createButton(t);l.appendChild(e.element),this.buttons.push(e)}this.toolbarElement.appendChild(l)}0===this.buttons.length&&this.toolbarElement.remove()}renderItemsByGroup(){if(!this.context||!this.toolbarElement)return;const t=this.context.getToolbarRegistry().getToolbarItems().filter(t=>!this.hiddenItems.has(t.id));if(0===t.length)return void this.toolbarElement.remove();const e=/* @__PURE__ */new Map;for(const n of t){const t=e.get(n.group)??[];t.push(n),e.set(n.group,t)}let o=!0;for(const[,n]of e){o||this.toolbarElement.appendChild(B()),o=!1;const t=this.createGroupWrapper(void 0);for(const e of n){const o=this.createButton(e);t.appendChild(o.element),this.buttons.push(o)}this.toolbarElement.appendChild(t)}}createButton(t){const e=document.createElement("button");e.type="button",e.className=`notectl-toolbar-btn notectl-toolbar-btn--${t.id}`,e.setAttribute("aria-pressed","false"),e.setAttribute("aria-label",t.label),e.setAttribute("data-toolbar-item",t.id),e.setAttribute("data-tooltip",t.tooltip??t.label),e.setAttribute("part","toolbar-button");let o=null;if("combobox"===t.popupType){e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-expanded","false");const n=document.createElement("span");n.className="notectl-toolbar-combobox__label";const r=this.context?.getState();r&&(n.textContent=t.getLabel(r)),e.appendChild(n),o=n;const i=document.createElement("span");i.className="notectl-toolbar-combobox__arrow",i.setAttribute("aria-hidden","true"),i.textContent="▾",e.appendChild(i)}else{t.popupType&&(e.setAttribute("aria-haspopup","true"),e.setAttribute("aria-expanded","false"));const o=document.createElement("span");o.className="notectl-toolbar-btn__icon",o.innerHTML=t.icon,e.appendChild(o)}return e.addEventListener("mousedown",o=>{o.preventDefault(),this.activateButton(e,t)}),e.addEventListener("mouseenter",()=>this.tooltip?.show(e)),e.addEventListener("mouseleave",()=>this.tooltip?.hide()),e.addEventListener("focus",()=>this.tooltip?.show(e)),e.addEventListener("blur",()=>this.tooltip?.hide()),{element:e,item:t,comboLabelEl:o}}updateButtonStates(t){for(const e of this.buttons){const o=e.item.isActive?.(t)??!1,n=e.item.isEnabled?.(t)??!0;if(e.element.setAttribute("aria-pressed",String(o)),e.element.classList.toggle("notectl-toolbar-btn--active",o),e.element.setAttribute("part",o?"toolbar-button toolbar-button-active":"toolbar-button"),e.element.disabled=!n,n?e.element.removeAttribute("aria-disabled"):e.element.setAttribute("aria-disabled","true"),e.comboLabelEl&&"combobox"===e.item.popupType&&(e.comboLabelEl.textContent=e.item.getLabel(t)),e.item.getIcon){const o=e.item.getIcon(t),n=e.element.querySelector(".notectl-toolbar-btn__icon");n&&n.innerHTML!==o&&(n.innerHTML=o)}}this.overflowController?.updateItemStates(t)}};export{g as a,f as i,D as n,b as o,w as r,T as t};
2
- //# sourceMappingURL=ToolbarPlugin-DtfGTO_V.mjs.map