@notectl/core 2.3.3 → 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 (352) hide show
  1. package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs +2 -0
  2. package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs.map +1 -0
  3. package/dist/chunks/{AttrRegistry-B3zB02z9.mjs → AttrRegistry-CtNhf2EF.mjs} +2 -2
  4. package/dist/chunks/{AttrRegistry-B3zB02z9.mjs.map → AttrRegistry-CtNhf2EF.mjs.map} +1 -1
  5. package/dist/chunks/AttributedMarkCommands-B3MQdob_.mjs +2 -0
  6. package/dist/chunks/AttributedMarkCommands-B3MQdob_.mjs.map +1 -0
  7. package/dist/chunks/{BidiIsolationPlugin-Cw2KMk-H.mjs → BidiIsolationPlugin-cOLlL3Y9.mjs} +2 -2
  8. package/dist/chunks/{BidiIsolationPlugin-Cw2KMk-H.mjs.map → BidiIsolationPlugin-cOLlL3Y9.mjs.map} +1 -1
  9. package/dist/chunks/BlockInsertion-O5pAFKid.mjs +2 -0
  10. package/dist/chunks/{BlockInsertion-CYH2gRkY.mjs.map → BlockInsertion-O5pAFKid.mjs.map} +1 -1
  11. package/dist/chunks/BlockquotePlugin-D-jRWLQB.mjs +2 -0
  12. package/dist/chunks/{BlockquotePlugin-0bZSbkyo.mjs.map → BlockquotePlugin-D-jRWLQB.mjs.map} +1 -1
  13. package/dist/chunks/CaretNavigationPlugin-Clv8dzR5.mjs +2 -0
  14. package/dist/chunks/CaretNavigationPlugin-Clv8dzR5.mjs.map +1 -0
  15. package/dist/chunks/CodeBlockPlugin-BandNM3t.mjs +2 -0
  16. package/dist/chunks/{CodeBlockPlugin-BCJ3faXx.mjs.map → CodeBlockPlugin-BandNM3t.mjs.map} +1 -1
  17. package/dist/chunks/ColorGrid-D0vLHsG6.mjs +2 -0
  18. package/dist/chunks/{ColorGrid-DQEkJ-0y.mjs.map → ColorGrid-D0vLHsG6.mjs.map} +1 -1
  19. package/dist/chunks/ColorPickerPopup-_C5JZhki.mjs +2 -0
  20. package/dist/chunks/{ColorPickerPopup-CyF26zIU.mjs.map → ColorPickerPopup-_C5JZhki.mjs.map} +1 -1
  21. package/dist/chunks/ColorValidation-B9d_umnf.mjs +2 -0
  22. package/dist/chunks/{ColorValidation-DAijTjG9.mjs.map → ColorValidation-B9d_umnf.mjs.map} +1 -1
  23. package/dist/chunks/Commands-D-0UXYvo.mjs +2 -0
  24. package/dist/chunks/Commands-D-0UXYvo.mjs.map +1 -0
  25. package/dist/chunks/ContentModel-Bzmzeqwg.mjs +2 -0
  26. package/dist/chunks/{ContentModel-NpAj7vGW.mjs.map → ContentModel-Bzmzeqwg.mjs.map} +1 -1
  27. package/dist/chunks/CursorMarks-dx51OGBf.mjs +2 -0
  28. package/dist/chunks/CursorMarks-dx51OGBf.mjs.map +1 -0
  29. package/dist/chunks/Decoration-BwhoA4MU.mjs +3 -0
  30. package/dist/chunks/Decoration-BwhoA4MU.mjs.map +1 -0
  31. package/dist/chunks/{DirectionDetection-CDVSEWQ6.mjs → DirectionDetection-ZrkMhyaL.mjs} +2 -2
  32. package/dist/chunks/{DirectionDetection-CDVSEWQ6.mjs.map → DirectionDetection-ZrkMhyaL.mjs.map} +1 -1
  33. package/dist/chunks/Document-D_2cIBJG.mjs +2 -0
  34. package/dist/chunks/Document-D_2cIBJG.mjs.map +1 -0
  35. package/dist/chunks/DocumentParser-i-CreJ48.mjs +2 -0
  36. package/dist/chunks/DocumentParser-i-CreJ48.mjs.map +1 -0
  37. package/dist/chunks/{FontPlugin-D041tiLe.mjs → FontPlugin-B4Ouhmpe.mjs} +2 -2
  38. package/dist/chunks/{FontPlugin-D041tiLe.mjs.map → FontPlugin-B4Ouhmpe.mjs.map} +1 -1
  39. package/dist/chunks/FontSizePlugin-CZB-AwZQ.mjs +2 -0
  40. package/dist/chunks/{FontSizePlugin-8CAvj1RD.mjs.map → FontSizePlugin-CZB-AwZQ.mjs.map} +1 -1
  41. package/dist/chunks/FormulaPlugin-C7N3QXDx.mjs +2 -0
  42. package/dist/chunks/{FormulaPlugin-DJ39BtqV.mjs.map → FormulaPlugin-C7N3QXDx.mjs.map} +1 -1
  43. package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs +2 -0
  44. package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs.map +1 -0
  45. package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs +2 -0
  46. package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs.map +1 -0
  47. package/dist/chunks/HTMLUtils-B0nGyFLb.mjs +2 -0
  48. package/dist/chunks/{HTMLUtils-Bhg3_P8B.mjs.map → HTMLUtils-B0nGyFLb.mjs.map} +1 -1
  49. package/dist/chunks/HardBreakPlugin-CC4rntSX.mjs +2 -0
  50. package/dist/chunks/{HardBreakPlugin-vniSvTgq.mjs.map → HardBreakPlugin-CC4rntSX.mjs.map} +1 -1
  51. package/dist/chunks/HeadingPlugin-hubN_Ebt.mjs +2 -0
  52. package/dist/chunks/{HeadingPlugin-DUKsLuMd.mjs.map → HeadingPlugin-hubN_Ebt.mjs.map} +1 -1
  53. package/dist/chunks/{HighlightPlugin-DRTAE1N5.mjs → HighlightPlugin-CE_MgFNz.mjs} +2 -2
  54. package/dist/chunks/{HighlightPlugin-DRTAE1N5.mjs.map → HighlightPlugin-CE_MgFNz.mjs.map} +1 -1
  55. package/dist/chunks/HorizontalRulePlugin-CxmUMM34.mjs +2 -0
  56. package/dist/chunks/{HorizontalRulePlugin-B9OvwrKB.mjs.map → HorizontalRulePlugin-CxmUMM34.mjs.map} +1 -1
  57. package/dist/chunks/{ImagePlugin-CwxTRr6d.mjs → ImagePlugin-B_y4STEr.mjs} +2 -2
  58. package/dist/chunks/{ImagePlugin-CwxTRr6d.mjs.map → ImagePlugin-B_y4STEr.mjs.map} +1 -1
  59. package/dist/chunks/InlineCodePlugin-C1SqGfv5.mjs +2 -0
  60. package/dist/chunks/{InlineCodePlugin-uxgMUX_E.mjs.map → InlineCodePlugin-C1SqGfv5.mjs.map} +1 -1
  61. package/dist/chunks/{InlineStyleMarkSpec-CjSRj4f_.mjs → InlineStyleMarkSpec-Cx3goc3W.mjs} +2 -2
  62. package/dist/chunks/{InlineStyleMarkSpec-CjSRj4f_.mjs.map → InlineStyleMarkSpec-Cx3goc3W.mjs.map} +1 -1
  63. package/dist/chunks/{LinkPlugin-CvWHbSkb.mjs → LinkPlugin-BwXDGHPe.mjs} +2 -2
  64. package/dist/chunks/{LinkPlugin-CvWHbSkb.mjs.map → LinkPlugin-BwXDGHPe.mjs.map} +1 -1
  65. package/dist/chunks/ListPlugin-DSFPSWQC.mjs +2 -0
  66. package/dist/chunks/ListPlugin-DSFPSWQC.mjs.map +1 -0
  67. package/dist/chunks/MarkCommands-CJvLGL5G.mjs +2 -0
  68. package/dist/chunks/MarkCommands-CJvLGL5G.mjs.map +1 -0
  69. package/dist/chunks/{MarkInputRule-Bdi8KPus.mjs → MarkInputRule-DNneF2gp.mjs} +2 -2
  70. package/dist/chunks/{MarkInputRule-Bdi8KPus.mjs.map → MarkInputRule-DNneF2gp.mjs.map} +1 -1
  71. package/dist/chunks/MarkdownHTMLRegistry-CISsC0lH.mjs +2 -0
  72. package/dist/chunks/{MarkdownHTMLRegistry-Q7l0d6Ma.mjs.map → MarkdownHTMLRegistry-CISsC0lH.mjs.map} +1 -1
  73. package/dist/chunks/MarkdownParser-D1d9zB0R.mjs +2 -0
  74. package/dist/chunks/{MarkdownParser-Dp62mfUq.mjs.map → MarkdownParser-D1d9zB0R.mjs.map} +1 -1
  75. package/dist/chunks/MarkdownSerializer-Oex2RzNw.mjs +2 -0
  76. package/dist/chunks/{MarkdownSerializer-DBELFAeo.mjs.map → MarkdownSerializer-Oex2RzNw.mjs.map} +1 -1
  77. package/dist/chunks/{NodeResolver-Dleih-8R.mjs → NodeResolver-BtIknXqD.mjs} +2 -2
  78. package/dist/chunks/{NodeResolver-Dleih-8R.mjs.map → NodeResolver-BtIknXqD.mjs.map} +1 -1
  79. package/dist/chunks/NodeSelectionCommands-DK3iEh18.mjs +2 -0
  80. package/dist/chunks/{NodeSelectionCommands-WH5snxr_.mjs.map → NodeSelectionCommands-DK3iEh18.mjs.map} +1 -1
  81. package/dist/chunks/NodeSpecPatching-BrjPAbqe.mjs +2 -0
  82. package/dist/chunks/NodeSpecPatching-BrjPAbqe.mjs.map +1 -0
  83. package/dist/chunks/{PluginHelpers-KDuTlmXm.mjs → PluginHelpers-WG1Lzzh3.mjs} +2 -2
  84. package/dist/chunks/{PluginHelpers-KDuTlmXm.mjs.map → PluginHelpers-WG1Lzzh3.mjs.map} +1 -1
  85. package/dist/chunks/PopupKeyboardPatterns-BcwdDxRq.mjs +2 -0
  86. package/dist/chunks/{PopupKeyboardPatterns-tUrT9TyV.mjs.map → PopupKeyboardPatterns-BcwdDxRq.mjs.map} +1 -1
  87. package/dist/chunks/PopupManager-Jz5JrUdC.mjs +2 -0
  88. package/dist/chunks/{PopupManager-Cj86uDEB.mjs.map → PopupManager-Jz5JrUdC.mjs.map} +1 -1
  89. package/dist/chunks/{PopupPositioning-BFh6Ed1D.mjs → PopupPositioning-CIqgpqlW.mjs} +2 -2
  90. package/dist/chunks/{PopupPositioning-BFh6Ed1D.mjs.map → PopupPositioning-CIqgpqlW.mjs.map} +1 -1
  91. package/dist/chunks/PrintPlugin-1m54b2-Y.mjs +2 -0
  92. package/dist/chunks/PrintPlugin-1m54b2-Y.mjs.map +1 -0
  93. package/dist/chunks/{RangeIterator-DP7Ud3Gp.mjs → RangeIterator-DDOxTQIf.mjs} +2 -2
  94. package/dist/chunks/{RangeIterator-DP7Ud3Gp.mjs.map → RangeIterator-DDOxTQIf.mjs.map} +1 -1
  95. package/dist/chunks/SchemaRegistry-acc6q_5x.mjs +2 -0
  96. package/dist/chunks/SchemaRegistry-acc6q_5x.mjs.map +1 -0
  97. package/dist/chunks/Selection-DC6AOGgF.mjs +2 -0
  98. package/dist/chunks/Selection-DC6AOGgF.mjs.map +1 -0
  99. package/dist/chunks/{SelectionSync-BSHIw1EE.mjs → SelectionSync-CcvoRrNd.mjs} +2 -2
  100. package/dist/chunks/{SelectionSync-BSHIw1EE.mjs.map → SelectionSync-CcvoRrNd.mjs.map} +1 -1
  101. package/dist/chunks/SelectionTransactions-DNCzsl_b.mjs +2 -0
  102. package/dist/chunks/SelectionTransactions-DNCzsl_b.mjs.map +1 -0
  103. package/dist/chunks/SimpleMark-CTDtEIMV.mjs +2 -0
  104. package/dist/chunks/{SimpleMark-gTQaSJcO.mjs.map → SimpleMark-CTDtEIMV.mjs.map} +1 -1
  105. package/dist/chunks/SmartPastePlugin-CjExbE9Q.mjs +2 -0
  106. package/dist/chunks/{SmartPastePlugin-BvJQ-fOz.mjs.map → SmartPastePlugin-CjExbE9Q.mjs.map} +1 -1
  107. package/dist/chunks/{StrikethroughPlugin-BdrG1TTY.mjs → StrikethroughPlugin-d-EW2YYx.mjs} +2 -2
  108. package/dist/chunks/{StrikethroughPlugin-BdrG1TTY.mjs.map → StrikethroughPlugin-d-EW2YYx.mjs.map} +1 -1
  109. package/dist/chunks/StyleRuntime-C0RSqKzG.mjs +2 -0
  110. package/dist/chunks/{StyleRuntime-DW6omotc.mjs.map → StyleRuntime-C0RSqKzG.mjs.map} +1 -1
  111. package/dist/chunks/SuperSubPlugin-C-kvFQyx.mjs +2 -0
  112. package/dist/chunks/{SuperSubPlugin-DTZB0Y3D.mjs.map → SuperSubPlugin-C-kvFQyx.mjs.map} +1 -1
  113. package/dist/chunks/TableDimensions-BcARMxQB.mjs +2 -0
  114. package/dist/chunks/TableDimensions-BcARMxQB.mjs.map +1 -0
  115. package/dist/chunks/TablePlugin-B894cIXW.mjs +2 -0
  116. package/dist/chunks/{TablePlugin-CPvg9YZS.mjs.map → TablePlugin-B894cIXW.mjs.map} +1 -1
  117. package/dist/chunks/{TextColorPlugin-Ckg3KWvb.mjs → TextColorPlugin-B6YoN9mR.mjs} +2 -2
  118. package/dist/chunks/{TextColorPlugin-Ckg3KWvb.mjs.map → TextColorPlugin-B6YoN9mR.mjs.map} +1 -1
  119. package/dist/chunks/TextDirectionAutoPlugin-LVDkKdDX.mjs +2 -0
  120. package/dist/chunks/{TextDirectionAutoPlugin-DRGbgTlx.mjs.map → TextDirectionAutoPlugin-LVDkKdDX.mjs.map} +1 -1
  121. package/dist/chunks/TextDirectionPlugin-CtGwof7i.mjs +2 -0
  122. package/dist/chunks/TextDirectionPlugin-CtGwof7i.mjs.map +1 -0
  123. package/dist/chunks/TextFormattingPlugin-DlS0SeW7.mjs +2 -0
  124. package/dist/chunks/{TextFormattingPlugin-BhRxSC8q.mjs.map → TextFormattingPlugin-DlS0SeW7.mjs.map} +1 -1
  125. package/dist/chunks/ThemeEngine-D4W6Y80e.mjs +3 -0
  126. package/dist/chunks/{ThemeEngine-BUVo_zaT.mjs.map → ThemeEngine-D4W6Y80e.mjs.map} +1 -1
  127. package/dist/chunks/{ToolbarPlugin-dmTj1jIz.mjs → ToolbarPlugin-ClKY-LiT.mjs} +2 -2
  128. package/dist/chunks/{ToolbarPlugin-dmTj1jIz.mjs.map → ToolbarPlugin-ClKY-LiT.mjs.map} +1 -1
  129. package/dist/chunks/VideoPlugin-C9z4JfP_.mjs +2 -0
  130. package/dist/chunks/VideoPlugin-C9z4JfP_.mjs.map +1 -0
  131. package/dist/chunks/{XmlSupport-DIXH5on9.mjs → XmlSupport-3Za6SIqF.mjs} +2 -2
  132. package/dist/chunks/{XmlSupport-DIXH5on9.mjs.map → XmlSupport-3Za6SIqF.mjs.map} +1 -1
  133. package/dist/chunks/full-CNi2CaF3.mjs +2 -0
  134. package/dist/chunks/{full-JM0-SwWy.mjs.map → full-CNi2CaF3.mjs.map} +1 -1
  135. package/dist/chunks/minimal-Bykbo9So.mjs +2 -0
  136. package/dist/chunks/{minimal-DSlR2A27.mjs.map → minimal-Bykbo9So.mjs.map} +1 -1
  137. package/dist/chunks/register-CF80zDgl.mjs +3 -0
  138. package/dist/chunks/register-CF80zDgl.mjs.map +1 -0
  139. package/dist/decorations/Decoration.d.ts +9 -0
  140. package/dist/decorations/Decoration.d.ts.map +1 -1
  141. package/dist/editor/ContentSerializer.d.ts +2 -7
  142. package/dist/editor/ContentSerializer.d.ts.map +1 -1
  143. package/dist/editor/EditorEventEmitter.d.ts +10 -2
  144. package/dist/editor/EditorEventEmitter.d.ts.map +1 -1
  145. package/dist/editor/EditorInitializer.d.ts +2 -4
  146. package/dist/editor/EditorInitializer.d.ts.map +1 -1
  147. package/dist/editor/EditorLifecycleCoordinator.d.ts +16 -1
  148. package/dist/editor/EditorLifecycleCoordinator.d.ts.map +1 -1
  149. package/dist/editor/EditorStyleCoordinator.d.ts +11 -3
  150. package/dist/editor/EditorStyleCoordinator.d.ts.map +1 -1
  151. package/dist/editor/NotectlEditor.d.ts +15 -3
  152. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  153. package/dist/full.mjs +1 -1
  154. package/dist/html.mjs +1 -1
  155. package/dist/index.d.ts +3 -2
  156. package/dist/index.d.ts.map +1 -1
  157. package/dist/input/InputHandler.d.ts +4 -0
  158. package/dist/input/InputHandler.d.ts.map +1 -1
  159. package/dist/input/InputManager.d.ts +5 -0
  160. package/dist/input/InputManager.d.ts.map +1 -1
  161. package/dist/input/KeyboardHandler.d.ts +4 -0
  162. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  163. package/dist/input/PasteHTMLHandler.d.ts +7 -4
  164. package/dist/input/PasteHTMLHandler.d.ts.map +1 -1
  165. package/dist/input/PasteHandler.d.ts +33 -6
  166. package/dist/input/PasteHandler.d.ts.map +1 -1
  167. package/dist/input/PasteRichBlockHandler.d.ts +3 -2
  168. package/dist/input/PasteRichBlockHandler.d.ts.map +1 -1
  169. package/dist/markdown.mjs +1 -1
  170. package/dist/model/Document.d.ts +42 -0
  171. package/dist/model/Document.d.ts.map +1 -1
  172. package/dist/model/DocumentNormalization.d.ts +10 -0
  173. package/dist/model/DocumentNormalization.d.ts.map +1 -0
  174. package/dist/model/FileHandlerDispatcher.d.ts +27 -0
  175. package/dist/model/FileHandlerDispatcher.d.ts.map +1 -0
  176. package/dist/model/FileHandlerRegistry.d.ts +6 -1
  177. package/dist/model/FileHandlerRegistry.d.ts.map +1 -1
  178. package/dist/model/InputRuleRegistry.d.ts +9 -1
  179. package/dist/model/InputRuleRegistry.d.ts.map +1 -1
  180. package/dist/model/KeymapRegistry.d.ts +14 -1
  181. package/dist/model/KeymapRegistry.d.ts.map +1 -1
  182. package/dist/model/MarkdownSyntaxRegistry.d.ts +2 -0
  183. package/dist/model/MarkdownSyntaxRegistry.d.ts.map +1 -1
  184. package/dist/model/PluginCallbackExecutor.d.ts +44 -0
  185. package/dist/model/PluginCallbackExecutor.d.ts.map +1 -0
  186. package/dist/model/SanitizeConfig.d.ts +8 -0
  187. package/dist/model/SanitizeConfig.d.ts.map +1 -1
  188. package/dist/model/SchemaRegistry.d.ts +24 -0
  189. package/dist/model/SchemaRegistry.d.ts.map +1 -1
  190. package/dist/model/Selection.d.ts +4 -0
  191. package/dist/model/Selection.d.ts.map +1 -1
  192. package/dist/notectl-core.mjs +1 -1
  193. package/dist/notectl-core.umd.js +1 -1
  194. package/dist/notectl-core.umd.js.map +1 -1
  195. package/dist/plugins/Plugin.d.ts +3 -1
  196. package/dist/plugins/Plugin.d.ts.map +1 -1
  197. package/dist/plugins/PluginContextFactory.d.ts +9 -2
  198. package/dist/plugins/PluginContextFactory.d.ts.map +1 -1
  199. package/dist/plugins/PluginLifecycle.d.ts +6 -0
  200. package/dist/plugins/PluginLifecycle.d.ts.map +1 -1
  201. package/dist/plugins/PluginManager.d.ts +9 -2
  202. package/dist/plugins/PluginManager.d.ts.map +1 -1
  203. package/dist/plugins/RegistrationTracker.d.ts +2 -0
  204. package/dist/plugins/RegistrationTracker.d.ts.map +1 -1
  205. package/dist/plugins/alignment.mjs +1 -1
  206. package/dist/plugins/bidi-isolation.mjs +1 -1
  207. package/dist/plugins/blockquote.mjs +1 -1
  208. package/dist/plugins/caret-navigation.mjs +1 -1
  209. package/dist/plugins/code-block/CodeBlockSchema.d.ts +6 -2
  210. package/dist/plugins/code-block/CodeBlockSchema.d.ts.map +1 -1
  211. package/dist/plugins/code-block.mjs +1 -1
  212. package/dist/plugins/font-size.mjs +1 -1
  213. package/dist/plugins/font.mjs +1 -1
  214. package/dist/plugins/formula/FormulaPasteInterceptor.d.ts.map +1 -1
  215. package/dist/plugins/formula.mjs +1 -1
  216. package/dist/plugins/gap-cursor.mjs +1 -1
  217. package/dist/plugins/hard-break.mjs +1 -1
  218. package/dist/plugins/heading.mjs +1 -1
  219. package/dist/plugins/highlight.mjs +1 -1
  220. package/dist/plugins/horizontal-rule.mjs +1 -1
  221. package/dist/plugins/image.mjs +1 -1
  222. package/dist/plugins/inline-code.mjs +1 -1
  223. package/dist/plugins/language.mjs +1 -1
  224. package/dist/plugins/link.mjs +1 -1
  225. package/dist/plugins/list/ListCommands.d.ts.map +1 -1
  226. package/dist/plugins/list/ListPlugin.d.ts +9 -0
  227. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  228. package/dist/plugins/list.mjs +1 -1
  229. package/dist/plugins/print.mjs +1 -1
  230. package/dist/plugins/shared/NodeSpecPatching.d.ts +2 -2
  231. package/dist/plugins/shared/NodeSpecPatching.d.ts.map +1 -1
  232. package/dist/plugins/shared.mjs +1 -1
  233. package/dist/plugins/smart-paste.mjs +1 -1
  234. package/dist/plugins/strikethrough.mjs +1 -1
  235. package/dist/plugins/super-sub.mjs +1 -1
  236. package/dist/plugins/table.mjs +1 -1
  237. package/dist/plugins/text-color.mjs +1 -1
  238. package/dist/plugins/text-direction-auto.mjs +1 -1
  239. package/dist/plugins/text-direction.mjs +1 -1
  240. package/dist/plugins/text-formatting.mjs +1 -1
  241. package/dist/plugins/toolbar.mjs +1 -1
  242. package/dist/plugins/video/VideoNodeSpec.d.ts.map +1 -1
  243. package/dist/plugins/video/VideoPlugin.d.ts.map +1 -1
  244. package/dist/plugins/video/VideoProviders.d.ts +3 -3
  245. package/dist/plugins/video/VideoSanitizeHook.d.ts +4 -20
  246. package/dist/plugins/video/VideoSanitizeHook.d.ts.map +1 -1
  247. package/dist/plugins/video.mjs +1 -1
  248. package/dist/presets/full.mjs +1 -1
  249. package/dist/presets/minimal.mjs +1 -1
  250. package/dist/presets.mjs +1 -1
  251. package/dist/register.mjs +1 -1
  252. package/dist/serialization/DocumentParser.d.ts.map +1 -1
  253. package/dist/serialization/DocumentSerializer.d.ts.map +1 -1
  254. package/dist/serialization/HTMLSanitization.d.ts +12 -0
  255. package/dist/serialization/HTMLSanitization.d.ts.map +1 -1
  256. package/dist/state/EditorState.d.ts.map +1 -1
  257. package/dist/state/History.d.ts.map +1 -1
  258. package/dist/state/Mapping.d.ts +2 -0
  259. package/dist/state/Mapping.d.ts.map +1 -1
  260. package/dist/state/StepHandlers.d.ts.map +1 -1
  261. package/dist/state/TransactionBuilder.d.ts +2 -0
  262. package/dist/state/TransactionBuilder.d.ts.map +1 -1
  263. package/dist/state/TransactionFinalizer.d.ts +10 -0
  264. package/dist/state/TransactionFinalizer.d.ts.map +1 -0
  265. package/dist/state/TransactionSnapshot.d.ts +32 -0
  266. package/dist/state/TransactionSnapshot.d.ts.map +1 -0
  267. package/dist/test/TestUtils.d.ts.map +1 -1
  268. package/dist/view/BlockRendering.d.ts +13 -2
  269. package/dist/view/BlockRendering.d.ts.map +1 -1
  270. package/dist/view/DecorationRendering.d.ts +19 -8
  271. package/dist/view/DecorationRendering.d.ts.map +1 -1
  272. package/dist/view/EditorView.d.ts +4 -0
  273. package/dist/view/EditorView.d.ts.map +1 -1
  274. package/dist/view/EditorViewEvents.d.ts +8 -0
  275. package/dist/view/EditorViewEvents.d.ts.map +1 -1
  276. package/dist/view/NodeViewCallbackBoundary.d.ts +12 -0
  277. package/dist/view/NodeViewCallbackBoundary.d.ts.map +1 -0
  278. package/dist/view/NodeViewOwnership.d.ts +12 -0
  279. package/dist/view/NodeViewOwnership.d.ts.map +1 -0
  280. package/dist/view/NodeViewRegistry.d.ts +7 -1
  281. package/dist/view/NodeViewRegistry.d.ts.map +1 -1
  282. package/dist/view/Reconciler.d.ts +6 -0
  283. package/dist/view/Reconciler.d.ts.map +1 -1
  284. package/package.json +6 -6
  285. package/dist/chunks/AlignmentPlugin-C9Rr_R-g.mjs +0 -2
  286. package/dist/chunks/AlignmentPlugin-C9Rr_R-g.mjs.map +0 -1
  287. package/dist/chunks/AttributedMarkCommands-BCvmqeFZ.mjs +0 -2
  288. package/dist/chunks/AttributedMarkCommands-BCvmqeFZ.mjs.map +0 -1
  289. package/dist/chunks/BlockInsertion-CYH2gRkY.mjs +0 -2
  290. package/dist/chunks/BlockquotePlugin-0bZSbkyo.mjs +0 -2
  291. package/dist/chunks/CaretNavigationPlugin-BPZ9b6XR.mjs +0 -2
  292. package/dist/chunks/CaretNavigationPlugin-BPZ9b6XR.mjs.map +0 -1
  293. package/dist/chunks/CodeBlockPlugin-BCJ3faXx.mjs +0 -2
  294. package/dist/chunks/ColorGrid-DQEkJ-0y.mjs +0 -2
  295. package/dist/chunks/ColorPickerPopup-CyF26zIU.mjs +0 -2
  296. package/dist/chunks/ColorValidation-DAijTjG9.mjs +0 -2
  297. package/dist/chunks/Commands-D5ND50PQ.mjs +0 -2
  298. package/dist/chunks/Commands-D5ND50PQ.mjs.map +0 -1
  299. package/dist/chunks/ContentModel-NpAj7vGW.mjs +0 -2
  300. package/dist/chunks/Decoration-BOP1TAUd.mjs +0 -2
  301. package/dist/chunks/Decoration-BOP1TAUd.mjs.map +0 -1
  302. package/dist/chunks/Document-827l3P80.mjs +0 -2
  303. package/dist/chunks/Document-827l3P80.mjs.map +0 -1
  304. package/dist/chunks/DocumentParser-D2tr3ZKn.mjs +0 -2
  305. package/dist/chunks/DocumentParser-D2tr3ZKn.mjs.map +0 -1
  306. package/dist/chunks/FontSizePlugin-8CAvj1RD.mjs +0 -2
  307. package/dist/chunks/FormulaPlugin-DJ39BtqV.mjs +0 -2
  308. package/dist/chunks/GapCursorNavigation-DCWOmopl.mjs +0 -2
  309. package/dist/chunks/GapCursorNavigation-DCWOmopl.mjs.map +0 -1
  310. package/dist/chunks/GapCursorPlugin-2iR6506y.mjs +0 -2
  311. package/dist/chunks/GapCursorPlugin-2iR6506y.mjs.map +0 -1
  312. package/dist/chunks/HTMLUtils-Bhg3_P8B.mjs +0 -2
  313. package/dist/chunks/HardBreakPlugin-vniSvTgq.mjs +0 -2
  314. package/dist/chunks/HeadingPlugin-DUKsLuMd.mjs +0 -2
  315. package/dist/chunks/HorizontalRulePlugin-B9OvwrKB.mjs +0 -2
  316. package/dist/chunks/InlineCodePlugin-uxgMUX_E.mjs +0 -2
  317. package/dist/chunks/ListPlugin-BchSFWVn.mjs +0 -2
  318. package/dist/chunks/ListPlugin-BchSFWVn.mjs.map +0 -1
  319. package/dist/chunks/MarkdownHTMLRegistry-Q7l0d6Ma.mjs +0 -2
  320. package/dist/chunks/MarkdownParser-Dp62mfUq.mjs +0 -2
  321. package/dist/chunks/MarkdownSerializer-DBELFAeo.mjs +0 -2
  322. package/dist/chunks/NodeSelectionCommands-WH5snxr_.mjs +0 -2
  323. package/dist/chunks/NodeSpecPatching-B_yLknTl.mjs +0 -2
  324. package/dist/chunks/NodeSpecPatching-B_yLknTl.mjs.map +0 -1
  325. package/dist/chunks/PopupKeyboardPatterns-tUrT9TyV.mjs +0 -2
  326. package/dist/chunks/PopupManager-Cj86uDEB.mjs +0 -2
  327. package/dist/chunks/PrintPlugin-D2javl_d.mjs +0 -2
  328. package/dist/chunks/PrintPlugin-D2javl_d.mjs.map +0 -1
  329. package/dist/chunks/SchemaRegistry-CkBN-1yW.mjs +0 -2
  330. package/dist/chunks/SchemaRegistry-CkBN-1yW.mjs.map +0 -1
  331. package/dist/chunks/Selection-HYoVFpAx.mjs +0 -2
  332. package/dist/chunks/Selection-HYoVFpAx.mjs.map +0 -1
  333. package/dist/chunks/SimpleMark-gTQaSJcO.mjs +0 -2
  334. package/dist/chunks/SmartPastePlugin-BvJQ-fOz.mjs +0 -2
  335. package/dist/chunks/StyleRuntime-DW6omotc.mjs +0 -2
  336. package/dist/chunks/SuperSubPlugin-DTZB0Y3D.mjs +0 -2
  337. package/dist/chunks/TableDimensions-BBhjHNjQ.mjs +0 -2
  338. package/dist/chunks/TableDimensions-BBhjHNjQ.mjs.map +0 -1
  339. package/dist/chunks/TablePlugin-CPvg9YZS.mjs +0 -2
  340. package/dist/chunks/TextDirectionAutoPlugin-DRGbgTlx.mjs +0 -2
  341. package/dist/chunks/TextDirectionPlugin-BCeYyJHo.mjs +0 -2
  342. package/dist/chunks/TextDirectionPlugin-BCeYyJHo.mjs.map +0 -1
  343. package/dist/chunks/TextFormattingPlugin-BhRxSC8q.mjs +0 -2
  344. package/dist/chunks/ThemeEngine-BUVo_zaT.mjs +0 -3
  345. package/dist/chunks/VideoPlugin-BugkI7-m.mjs +0 -2
  346. package/dist/chunks/VideoPlugin-BugkI7-m.mjs.map +0 -1
  347. package/dist/chunks/WordBoundary-CFpIJDNP.mjs +0 -2
  348. package/dist/chunks/WordBoundary-CFpIJDNP.mjs.map +0 -1
  349. package/dist/chunks/full-JM0-SwWy.mjs +0 -2
  350. package/dist/chunks/minimal-DSlR2A27.mjs +0 -2
  351. package/dist/chunks/register-BjsdJ3Aq.mjs +0 -2
  352. package/dist/chunks/register-BjsdJ3Aq.mjs.map +0 -1
@@ -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{_ as g,s as w}from"./BlockInsertion-CYH2gRkY.mjs";import{a as x,d as v,h as C,l as y,n as S,r as R,u as z}from"./TableDimensions-BBhjHNjQ.mjs";import{i as I,t as k}from"./Decoration-BOP1TAUd.mjs";import{n as A}from"./TypedKeys-CA4bfw9O.mjs";import{c as E,i as P,o as M}from"./PluginHelpers-KDuTlmXm.mjs";import{t as L}from"./EditorEventBoundary-zpYRxryo.mjs";import{c as B,o as H,s as N}from"./StyleRuntime-DW6omotc.mjs";import{i as $}from"./Platform-ByobkiCc.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-DQEkJ-0y.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 V(t,e=1e3){return"number"==typeof t&&Number.isFinite(t)&&Number.isInteger(t)?t<=1?1:Math.min(t,e):1}function q(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=V(d.attrs?.colspan),h=V(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=q(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=V(t.attrs?.rowspan),u=V(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=q(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?q(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 E(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=q(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",C({children:[l]},e.getSchemaRegistry())),o.setData("text/plain",function(t){const e=q(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 A("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:z,maxRowHeightPx:z,keyboardResizeStepPx:8,keyboardResizeLargeStepPx:32}),gt=new A("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=q(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=q(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=v(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:v(t)}function Bt(t,e,n=1){return v(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=q(o);if(!qt(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=q(o);if(!qt(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=q(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=q(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=g(t,l.id,"start");if(e)return i.setSelection(e),i.build()}const s=t.doc.children[n-1];if(s){const e=g(t,s.id,"end");if(e)return i.setSelection(e),i.build()}return null}function jt(t,e,n){const o=t.getState(),i=P(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(!w(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 Vt(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 qt(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 Vt(t,"left",e)}(t,e)),t.registerCommand("addColumnRight",()=>function(t,e){return Vt(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 z of m){if("separator"===z.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=z.label,"submenu"===z.type&&(t.dataset.submenu=z.id,t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded","false")),"item"===z.type&&(t.dataset.command=z.command),t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),t.addEventListener("click",n=>{n.stopPropagation(),"item"===z.type?(e.executeCommand(z.command),S()):"submenu"===z.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:()=>S(),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,S,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:S},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 S();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),S()))}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:$(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)||S()};let C=null,y=!1;function S(){if(!a)return;a=!1,w(),u.remove(),null!==C&&(clearTimeout(C),C=null),y&&(document.removeEventListener("mousedown",v,!0),y=!1),oe.get(e)?.delete(S),r?.();const t=s.restoreFocusTo;t?.isConnected&&requestAnimationFrame(()=>t.focus({preventScroll:!0}))}C=setTimeout(()=>{C=null,document.addEventListener("mousedown",v,!0),y=!0},0);const R=oe.get(e)??/* @__PURE__ */new Set;return R.add(S),oe.set(e,R),{isOpen:()=>a,close:S,destroy:S}}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=q(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){N(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=q(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=q(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",N(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 q(t).columnCount}positionControls(){const t=Ce(this.tableEl,this.container),e=this.tableEl.getBoundingClientRect();N(this.colBar,{left:`${String(t.left)}px`,top:`${String(t.top-24)}px`}),B(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&&N(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);B(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;N(t,{top:`${o}px`,height:`${l}px`}),i=o+l}}B(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;N(t,{width:`${i.width||n.offsetWidth}px`,left:`${r.left}px`}),N(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){N(this.colResizeBar,{left:`${String(t.left)}px`,top:`${String(t.top)}px`,width:`${String(e.width)}px`,height:`${String(e.height)}px`}),N(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;N(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;N(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;H(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 B(this.tableEl,"minWidth",`${String(r)}px`),void(o.length>=this.numCols&&o.every((t,n)=>n===e||null!==t)?B(this.tableEl,"width",`${String(r)}px`):H(this.tableEl,"width"))}const o=this.tableEl.querySelectorAll(":scope > tbody > tr")[e];o&&(H(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?(H(o,"width"),o.removeAttribute("data-notectl-width-px")):(B(o,"width",`${String(r)}px`),o.setAttribute("data-notectl-width-px",String(r))),n+=r??this.config.minColumnWidthPx}B(this.tableEl,"minWidth",`${String(n)}px`),t.length>=this.numCols&&t.every(t=>null!==t)?B(this.tableEl,"width",`${String(n)}px`):H(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?(H(t,"height"),t.removeAttribute("data-notectl-min-height-px")):(B(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`,N(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);N(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);N(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?(B(t,"--ntbl-border-color","transparent"),t.classList.add("notectl-table--borderless")):e?(B(t,"--ntbl-border-color",e),t.classList.remove("notectl-table--borderless")):(H(t,"--ntbl-border-color"),t.classList.remove("notectl-table--borderless"))}function ke(t,e,n,o=ze){const r=q(n).columnCount;for(B(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?(B(t,"width",`${String(r)}px`),t.setAttribute("data-notectl-width-px",String(r))):(H(t,"width"),t.removeAttribute("data-notectl-width-px")),s+=r??o.minColumnWidthPx}r>0?(B(t,"minWidth",`${String(s)}px`),l.length>=r&&l.slice(0,r).every(t=>"number"==typeof t)?B(t,"width",`${String(s)}px`):H(t,"width")):(H(t,"minWidth"),H(t,"width"))}function Ae(t,e){const n=e.attrs?.minHeightPx;t.removeAttribute("height"),"number"==typeof n&&Number.isFinite(n)&&n>0?(B(t,"height",`${String(n)}px`),t.setAttribute("data-notectl-min-height-px",String(n))):(H(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 M(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&&q(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=q(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=q(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?q(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(!L(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=>{L(o,n)&&ut(o,t,e)},i=o=>{L(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=q(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 k.empty;if(!this.selectionService.getSelectedRange())return k.empty;const e=t.selection;if(!p(e)||!et(t,e.anchor.blockId))return this.selectionService.clearSelectionSilent(),k.empty;const n=this.selectionService.getSelectedCellIds();if(0===n.length)return k.empty;const o=[];for(const r of n)o.push(I(r,{class:"notectl-table-cell--selected"}));return k.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=q(t),i=t.attrs?.columnWidthsPx;if(Array.isArray(i)&&r.columnCount>0){const t=Array.from({length:r.columnCount},(t,n)=>{const o=x(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,q(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${y(S,"width",t,r)}>`).join("")}</colgroup><tbody>${o}</tbody></table>`},sanitize:{tags:["table","colgroup","col","thead","tbody","tfoot"],attrs:[S,"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=x(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${y(R,"height",t.attrs?.minHeightPx,n)}>${e}</tr>`,sanitize:{tags:["tr"],attrs:[R,"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=q(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=q(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&&B(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=V(t.attrs?.colspan),o=V(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=V(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-CPvg9YZS.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-OFOU6r_s.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-DRGbgTlx.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as t,c as e,n as i,o,r}from"./PluginHelpers-KDuTlmXm.mjs";import{r as s}from"./Platform-ByobkiCc.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-OFOU6r_s.mjs";import{r as h}from"./DirectionDetection-CDVSEWQ6.mjs";var m=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)}},u={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 e(d,t,u)}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(t){this.locale=await o(t,this.config.locale,u,p),this.directableTypes=new Set(this.config.directableTypes),this.patchNodeSpecs(t),this.registerCommands(t),this.registerKeymaps(t),this.registerToolbarItem(t),this.registerService(t),s()||(this.shiftDirHandler=new m(t),this.shiftDirHandler.attach(t.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=r(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=r(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(e,o){const r=e.getState(),s=t(r);if(0===s.length)return!1;const n=r.transaction("command");let a=!1;for(const t of s){const e=r.getBlock(t);if(!e||!this.directableTypes.has(e.type))continue;const i=r.getNodePath(t);i&&(n.setNodeAttr(i,{...e.attrs,dir:o}),a=!0)}return!!a&&i(e,n.setSelection(r.selection).build())}isNonDefaultDirection(t){const e=r(t);if(!e||!this.directableTypes.has(e.type))return!1;const i=e.attrs?.dir;return null!=i&&"auto"!==i}isDirectable(t){const e=r(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{u as n,p as r,f as t};
2
- //# sourceMappingURL=TextDirectionPlugin-BCeYyJHo.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextDirectionPlugin-BCeYyJHo.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":"yXAUA,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{i as t}from"./TypeBrands-Ch9856Gb.mjs";import{_ as e,m as i}from"./Commands-D5ND50PQ.mjs";import{c as s,n as o,o as r,s as n}from"./PluginHelpers-KDuTlmXm.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,e(s.getState(),t(r.type)))),g){const e=this.getMarkLabel(r.type);s.registerToolbarItem({id:r.type,group:"format",icon:r.icon,label:e,tooltip:`${e} (${l(r.keyBinding)})`,command:a,isActive:e=>i(e,t(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-BhRxSC8q.mjs.map
@@ -1,3 +0,0 @@
1
- import{i as e,n as o,r as t,t as r}from"./SyntaxTokenTypes-BUCOMtL8.mjs";import{n,t as a}from"./TypedKeys-CA4bfw9O.mjs";var c="data-notectl-static";function i(e){return e.hasAttribute(c)}function d(){/* @__PURE__ */
2
- return new Error("Cannot initialize a static print replica (data-notectl-static). Remove the marker and its shadow content to reuse the element as an editor.")}var l=96/25.4,s={DINA4:"din-a4",DINA5:"din-a5",USLetter:"us-letter",USLegal:"us-legal"};function f(e){return Math.round(e*l)}var u=new Map([[s.DINA4,{widthMm:210,heightMm:297,widthPx:f(210),heightPx:f(297)}],[s.DINA5,{widthMm:148,heightMm:210,widthPx:f(148),heightPx:f(210)}],[s.USLetter,{widthMm:215.9,heightMm:279.4,widthPx:f(215.9),heightPx:f(279.4)}],[s.USLegal,{widthMm:215.9,heightMm:355.6,widthPx:f(215.9),heightPx:f(355.6)}]]),g=new Map([[s.DINA4,"A4"],[s.DINA5,"A5"],[s.USLetter,"letter"],[s.USLegal,"legal"]]);function b(e){const o=u.get(e);if(!o)throw new Error(`Unknown paper size: ${e}`);return o}var p=48,m=56,h=24;function k(e){return Object.values(s).includes(e)}function v(e){const o=g.get(e);if(!o)throw new Error(`Unknown paper size: ${e}`);return o}var y={Light:"light",Dark:"dark",System:"system"},B={name:"light",primitives:{background:"#ffffff",foreground:"#1a1a1a",mutedForeground:"#666666",border:"#d0d0d0",borderFocus:"#4a90d9",primary:"#4a90d9",primaryForeground:"#1a5fa0",primaryMuted:"#d0e0f0",surfaceRaised:"#f8f8f8",surfaceOverlay:"#ffffff",hoverBackground:"#e8e8e8",activeBackground:"#d0e0f0",danger:"#dc2626",dangerMuted:"#fee2e2",success:"#1a8c1a",shadow:"rgba(0, 0, 0, 0.15)",focusRing:"rgba(74, 144, 217, 0.2)"},inlineCode:{background:"#edf0f5",foreground:"#334155"},codeBlock:{background:"#f8fafc",foreground:"#334155",headerBackground:"#f1f5f9",headerForeground:"#64748b",headerBorder:"#e2e8f0",syntax:{keyword:"#d73a49",string:"#032f62",comment:{color:"#6a737d",fontStyle:"italic"},number:"#005cc5",function:"#6f42c1",operator:"#d73a49",punctuation:"#24292e",boolean:"#005cc5",null:"#005cc5",property:"#005cc5",type:"#e36209",annotation:"#6f42c1",tag:"#22863a",attribute:"#6f42c1",constant:"#005cc5",regex:"#032f62"}},tooltip:{background:"#1a1a1a",foreground:"#ffffff"}},w={name:"dark",primitives:{background:"#1e1e2e",foreground:"#cdd6f4",mutedForeground:"#7f849c",border:"#45475a",borderFocus:"#89b4fa",primary:"#89b4fa",primaryForeground:"#89b4fa",primaryMuted:"rgba(137, 180, 250, 0.15)",surfaceRaised:"#313244",surfaceOverlay:"#313244",hoverBackground:"#45475a",activeBackground:"rgba(137, 180, 250, 0.15)",danger:"#f38ba8",dangerMuted:"rgba(243, 139, 168, 0.15)",success:"#a6e3a1",shadow:"rgba(0, 0, 0, 0.4)",focusRing:"rgba(137, 180, 250, 0.25)"},inlineCode:{background:"#313244",foreground:"#cdd6f4"},codeBlock:{background:"#313244",foreground:"#cdd6f4",headerBackground:"#45475a",headerForeground:"#bac2de",headerBorder:"#585b70",syntax:{keyword:"#cba6f7",string:"#a6e3a1",comment:{color:"#9399b2",fontStyle:"italic"},number:"#fab387",function:"#89b4fa",operator:"#89dceb",punctuation:"#bac2de",boolean:"#fab387",null:"#f38ba8",property:"#89b4fa",type:"#fab387",annotation:"#cba6f7",tag:"#a6e3a1",attribute:"#89b4fa",constant:"#f9e2af",regex:"#a6e3a1"}},tooltip:{background:"#585b70",foreground:"#cdd6f4"}};function x(e,o){return{name:o.name,primitives:{...e.primitives,...o.primitives},toolbar:o.toolbar?{...e.toolbar,...o.toolbar}:e.toolbar,inlineCode:o.inlineCode?{...e.inlineCode,...o.inlineCode}:e.inlineCode,codeBlock:o.codeBlock?{...e.codeBlock,...o.codeBlock,syntax:o.codeBlock?.syntax?e.codeBlock?.syntax?{...e.codeBlock.syntax,...o.codeBlock.syntax}:void 0:e.codeBlock?.syntax}:e.codeBlock,tooltip:o.tooltip?{...e.tooltip,...o.tooltip}:e.tooltip}}function M(e){if("object"==typeof e)return e;switch(e){case y.Light:return B;case y.Dark:return w;default:return B}}var S=new n("print"),$=new a("print:before"),C=new a("print:after"),F=[["primitives.background","--notectl-bg"],["primitives.foreground","--notectl-fg"],["primitives.mutedForeground","--notectl-fg-muted"],["primitives.border","--notectl-border"],["primitives.borderFocus","--notectl-border-focus"],["primitives.primary","--notectl-primary"],["primitives.primaryForeground","--notectl-primary-fg"],["primitives.primaryMuted","--notectl-primary-muted"],["primitives.surfaceRaised","--notectl-surface-raised"],["primitives.surfaceOverlay","--notectl-surface-overlay"],["primitives.hoverBackground","--notectl-hover-bg"],["primitives.activeBackground","--notectl-active-bg"],["primitives.danger","--notectl-danger"],["primitives.dangerMuted","--notectl-danger-muted"],["primitives.success","--notectl-success"],["primitives.shadow","--notectl-shadow"],["primitives.focusRing","--notectl-focus-ring"],["toolbar.background","--notectl-toolbar-bg"],["toolbar.borderColor","--notectl-toolbar-border"],["inlineCode.background","--notectl-code-bg"],["inlineCode.foreground","--notectl-code-color"],["codeBlock.background","--notectl-code-block-bg"],["codeBlock.foreground","--notectl-code-block-color"],["codeBlock.headerBackground","--notectl-code-block-header-bg"],["codeBlock.headerForeground","--notectl-code-block-header-color"],["codeBlock.headerBorder","--notectl-code-block-header-border"],["tooltip.background","--notectl-tooltip-bg"],["tooltip.foreground","--notectl-tooltip-fg"],...r.map(e=>[`codeBlock.syntax.${e}`,`--notectl-code-token-${e}`])],A=r.map(e=>[`--notectl-code-token-${e}`,"var(--notectl-code-block-color)"]),j=new Map([["--notectl-toolbar-bg","var(--notectl-surface-raised)"],["--notectl-toolbar-border","var(--notectl-border)"],["--notectl-code-bg","var(--notectl-surface-raised)"],["--notectl-code-color","var(--notectl-fg)"],["--notectl-code-block-bg","var(--notectl-surface-raised)"],["--notectl-code-block-color","var(--notectl-fg)"],["--notectl-code-block-header-bg","var(--notectl-surface-raised)"],["--notectl-code-block-header-color","var(--notectl-fg-muted)"],["--notectl-code-block-header-border","var(--notectl-border)"],["--notectl-tooltip-bg","var(--notectl-fg)"],["--notectl-tooltip-fg","var(--notectl-bg)"],...A]);function D(e,t){const r=t.split(".");let n=e;for(const o of r){if(null==n)return;if("object"!=typeof n)return;n=n[o]}return"string"==typeof n?n:"object"==typeof n&&null!==n&&"color"in n?o(n):void 0}function L(o){const n=[":host {"];for(const[e,t]of F){const r=D(o,e);if(void 0!==r)n.push(`\t${t}: ${r};`);else{const e=j.get(t);e&&n.push(`\t${t}: ${e};`)}}return o.codeBlock?.syntax&&function(o,n){for(const a of r){const r=o[a];if("object"!=typeof r)continue;const c=t(r);c&&n.push(`\t--notectl-code-token-${a}-font-style: ${c};`);const i=e(r);i&&n.push(`\t--notectl-code-token-${a}-font-weight: ${i};`)}}(o.codeBlock.syntax,n),n.push("}"),n.join("\n")}function P(e){const o=new CSSStyleSheet;return o.replaceSync(L(e)),o}export{k as _,S as a,i as b,y as c,m as d,p as f,b as g,v as h,$ as i,x as l,s as m,L as n,w as o,h as p,C as r,B as s,P as t,M as u,c as v,d as y};
3
- //# sourceMappingURL=ThemeEngine-BUVo_zaT.mjs.map
@@ -1,2 +0,0 @@
1
- import{n as t,r as e}from"./HTMLUtils-Bhg3_P8B.mjs";import{_ as n,o,p as i,w as r}from"./Document-827l3P80.mjs";import{c as a,l,o as s,r as d,t as c,u}from"./Selection-HYoVFpAx.mjs";import{a as p}from"./TypeBrands-Ch9856Gb.mjs";import{s as h}from"./BlockInsertion-CYH2gRkY.mjs";import{t as m}from"./NodeSelectionCommands-WH5snxr_.mjs";import{c as v,o as f}from"./PluginHelpers-KDuTlmXm.mjs";import{c as b,r as g}from"./StyleRuntime-DW6omotc.mjs";import{t as y}from"./Platform-ByobkiCc.mjs";import{n as x}from"./DomUtils-Bf7JLFlx.mjs";import{t as _}from"./ShortcutFormatting-TwiufqeV.mjs";import{a as w}from"./PopupPositioning-BFh6Ed1D.mjs";import A from"dompurify";var k=/^[A-Za-z0-9_-]{11}$/,C=/^\d+$/,P=/^[A-Za-z0-9]+$/,z=/^[A-Za-z0-9]+$/;function E(t,e){const n=t.indexOf(e);if(-1!==n)return t[n+1]}function L(t,e,n){const o=e.searchParams.get("h")??n;return o&&P.test(o)?{videoId:t,hash:o}:{videoId:t}}var S=[{id:"youtube",label:"YouTube",hostnames:["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com","youtu.be","youtube-nocookie.com","www.youtube-nocookie.com"],embedHostnames:["www.youtube-nocookie.com","youtube-nocookie.com","www.youtube.com","youtube.com"],parse(t){const e=t.hostname.toLowerCase(),n=t.pathname.split("/").filter(Boolean);if("youtu.be"===e){const t=n[0];return t&&k.test(t)?{videoId:t}:null}const o=t.searchParams.get("v");if(o&&k.test(o))return{videoId:o};for(const i of["embed","shorts","live","v"]){const t=E(n,i);if(t&&k.test(t))return{videoId:t}}return null},buildEmbedUrl(t,e){const n=e.privacy?"www.youtube-nocookie.com":"www.youtube.com",o=V({rel:"0",...e.autoplay?{autoplay:"1"}:{}});return`https://${n}/embed/${t.videoId}${o}`},buildWatchUrl:t=>`https://www.youtube.com/watch?v=${t.videoId}`,thumbnailUrl:t=>`https://i.ytimg.com/vi/${t.videoId}/hqdefault.jpg`},{id:"vimeo",label:"Vimeo",hostnames:["vimeo.com","www.vimeo.com","player.vimeo.com"],embedHostnames:["player.vimeo.com"],parse(t){const e=t.pathname.split("/").filter(Boolean),n=E(e,"video");if(n&&C.test(n))return L(n,t,void 0);const o=e.find(t=>C.test(t));return o?L(o,t,e[e.indexOf(o)+1]):null},buildEmbedUrl(t,e){const n=V({...t.hash?{h:t.hash}:{},...e.privacy?{dnt:"1"}:{},...e.autoplay?{autoplay:"1"}:{}});return`https://player.vimeo.com/video/${t.videoId}${n}`},buildWatchUrl(t){const e=`https://vimeo.com/${t.videoId}`;return t.hash?`${e}/${t.hash}`:e}},{id:"dailymotion",label:"Dailymotion",hostnames:["dailymotion.com","www.dailymotion.com","geo.dailymotion.com","dai.ly"],embedHostnames:["www.dailymotion.com","geo.dailymotion.com"],parse(t){const e=t.hostname.toLowerCase(),n=t.pathname.split("/").filter(Boolean);if("dai.ly"===e){const t=n[0];return t&&z.test(t)?{videoId:t}:null}const o=E(n,"video");return o&&z.test(o)?{videoId:o}:null},buildEmbedUrl(t,e){const n=V(e.autoplay?{autoplay:"1"}:{});return`https://www.dailymotion.com/embed/video/${t.videoId}${n}`},buildWatchUrl:t=>`https://www.dailymotion.com/video/${t.videoId}`,thumbnailUrl:t=>`https://www.dailymotion.com/thumbnail/video/${t.videoId}`}];function I(t,e=S){const n=B(t);if(!n)return null;if("https:"!==n.protocol&&"http:"!==n.protocol)return null;const o=n.hostname.toLowerCase();for(const i of e){if(!i.hostnames.includes(o))continue;const t=i.parse(n);if(t)return{provider:i.id,videoId:t.videoId,...t.hash?{hash:t.hash}:{}}}return null}function R(t,e=S){return e.find(e=>e.id===t)}function $(t,e){const n=R(t.provider,e);return n?n.buildWatchUrl(t):null}function N(t,e){return R(t.provider,e)?.thumbnailUrl?.(t)}function H(t,e=S){return R(t,e)?.label??t}function B(t){try{return new URL(t.trim())}catch{return null}}function V(t){const e=Object.entries(t);return 0===e.length?"":`?${e.map(([t,e])=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&")}`}var M={growWidth:"Mod-Shift-ArrowRight",shrinkWidth:"Mod-Shift-ArrowLeft",growWidthLarge:"Mod-Shift-Alt-ArrowRight",shrinkWidthLarge:"Mod-Shift-Alt-ArrowLeft",resetSize:"Mod-Shift-0"},W={providers:S,facade:!0,useProviderThumbnail:!1,privacy:!0,allowedAspectRatios:["16/9","4/3","1/1","9/16"],defaultAspectRatio:"16/9",defaultWidthPercent:100,minWidthPercent:25,widthStep:10,widthStepLarge:25,resizable:!0},D="video",j=/^\d+(?:\.\d+)?\s*\/\s*\d+(?:\.\d+)?$/;function T(t,e){if(!t||!j.test(t.trim()))return e.defaultAspectRatio;const[n,o]=t.split("/");return`${n?.trim()} / ${o?.trim()}`}function O(t,e){return Number.isFinite(t)?Math.max(e.minWidthPercent,Math.min(100,Math.round(t))):e.defaultWidthPercent}var U=/^[A-Za-z0-9_-]+$/;function F(t){return t.length>0&&t.length<=64&&U.test(t)}function K(t,e){return{provider:t?.provider??"",videoId:t?.videoId??"",...t?.hash?{hash:t.hash}:{},aspectRatio:T(t?.aspectRatio,e),widthPercent:O(t?.widthPercent??e.defaultWidthPercent,e),align:t?.align??"center",title:t?.title??"",...t?.caption?{caption:t.caption}:{},privacy:t?.privacy??e.privacy}}function q(t,e){const n=I(t.url,e.providers);return n?{provider:n.provider,videoId:n.videoId,...n.hash?{hash:n.hash}:{},aspectRatio:T(t.aspectRatio,e),widthPercent:e.defaultWidthPercent,align:"center",title:t.title,...t.caption?{caption:t.caption}:{},privacy:e.privacy}:null}function G(t){return{provider:t.provider,videoId:t.videoId,aspectRatio:t.aspectRatio,widthPercent:t.widthPercent,align:t.align,title:t.title,privacy:t.privacy,...t.hash?{hash:t.hash}:{},...t.caption?{caption:t.caption}:{}}}function X(t){const e=t.selection;if(!l(e))return null;const n=t.getBlock(e.nodeId);if(!n||"video"!==n.type)return null;const o=t.getNodePath(e.nodeId);return o?{block:n,path:o}:null}function Z(t,e){const n=t.getState(),o=X(n);return!!o&&(t.dispatch(n.transaction("command").setNodeAttr(o.path,e).build()),!0)}function Y(t){const e=t.getState(),n=X(e);if(!n)return!1;const o=m(e,d(n.block.id,n.path));return!!o&&(t.dispatch(o),!0)}var J=0;function Q(t){return`${t}-${J+=1}`}function tt(t,e){const n=Q("notectl-video-field"),o=document.createElement("div");o.className="notectl-video-popup__field";const i=document.createElement("label");i.className="notectl-video-popup__label",i.setAttribute("for",n),i.textContent=e.label,o.appendChild(i);const r=document.createElement("input");r.id=n,r.type=e.type,r.value=e.value,r.placeholder=e.placeholder,r.className="notectl-video-popup__input",r.setAttribute("aria-label",e.ariaLabel),e.required&&r.setAttribute("aria-required","true");const a=[];if(e.hint){const t=`${n}-hint`,i=document.createElement("p");i.id=t,i.className="notectl-video-popup__hint",i.textContent=e.hint,o.appendChild(i),a.push(t)}return e.describedBy&&a.push(e.describedBy),a.length>0&&r.setAttribute("aria-describedby",a.join(" ")),o.insertBefore(r,o.children[1]??null),t.appendChild(o),r}var et=class{context;config;locale;panel=null;outsideHandler=null;constructor(t,e,n){this.context=t,this.config=e,this.locale=n}get isOpen(){return null!==this.panel}openInsert(){this.context.isReadOnly()||this.open({rect:nt(),mode:"insert",label:this.locale.insertDialogLabel,onSubmit:t=>{const e=q(t,this.config);e&&function(t,e){const n=t.getState(),s=n.selection;if(a(s))return!1;const c=G(e),u=l(s)?s.nodeId:s.anchor.blockId,m=function(t,e){if("table_cell"===t.getBlock(e)?.type)return e;const n=t.getNodePath(e);if(n)for(const o of n)if("table_cell"===t.getBlock(o)?.type)return o}(n,u);m?function(t,e,n,a){const l=t.getNodePath(n),s=t.getBlock(n);if(!l||!s)return!1;const c=o(p(D),[],void 0,a),u=t.transaction("command"),h=i(s);for(let o=h.length-1;o>=0;o--){const t=s.children.findIndex(t=>r(t)&&t.id===h[o]?.id);-1!==t&&u.removeNode(l,t)}u.insertNode(l,0,c),u.setSelection(d(c.id,[...l,c.id])),e.dispatch(u.build())}(n,t,m,c):function(t,e,n,i){const r=o(p(D),[],void 0,i),a=t.transaction("command");!!h(t,a,n,r)&&(a.setSelection(d(r.id,[])),e.dispatch(a.build()))}(n,t,u,c)}(this.context,e)}})}openInsertReplacingRange(t,e){this.context.isReadOnly()||this.open({rect:nt(),mode:"insert",label:this.locale.insertDialogLabel,initial:{url:e},onSubmit:e=>{const i=q(e,this.config);i&&function(t,e,i){const a=t.getState(),l=a.getBlock(e.blockId);if(!l)return!1;const s=function(t,e){const n=t.getNodePath(e);if(!n||0===n.length)return null;if(1===n.length){const n=t.doc.children.findIndex(t=>t.id===e);return-1===n?null:{parentPath:[],index:n}}const o=n[n.length-2],i=o?t.getBlock(o):void 0;if(!i)return null;const a=i.children.findIndex(t=>r(t)&&t.id===e);return-1===a?null:{parentPath:n.slice(0,-1),index:a}}(a,e.blockId);if(!s)return!1;const c=0===Math.max(0,n(l).length-(e.end-e.start))&&"paragraph"===l.type,u=o(p(D),[],void 0,G(i)),h=0===s.parentPath.length?[]:[...s.parentPath,u.id],m=a.transaction("command");c?(m.removeNode(s.parentPath,s.index),m.insertNode(s.parentPath,s.index,u),0===s.parentPath.length&&s.index>=a.doc.children.length-1&&m.insertNode([],s.index+1,o(p("paragraph")))):(m.deleteTextAt(e.blockId,e.start,e.end),m.insertNode(s.parentPath,s.index+1,u)),m.setSelection(d(u.id,h)),t.dispatch(m.build())}(this.context,t,i)}})}openEditForSelected(){if(this.context.isReadOnly())return;const t=this.context.getState(),e=t.selection;if(!l(e))return;const n=t.getBlock(e.nodeId);if(!n||"video"!==n.type)return;const o=K(n.attrs,this.config),i={url:$({provider:o.provider,videoId:o.videoId,...o.hash?{hash:o.hash}:{}},this.config.providers)??"",title:o.title,caption:o.caption??"",aspectRatio:o.aspectRatio};this.open({rect:this.videoRect(e.nodeId),mode:"edit",label:this.locale.editDialogLabel,initial:i,onSubmit:t=>{!function(t,e,n){const o=X(t.getState());if(!o)return!1;const i=I(e.url,n.providers);if(!i)return!1;const r=function(t,e){const n={};for(const[o,i]of Object.entries(t??{}))e.includes(o)||"string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i||(n[o]=i);return n}(o.block.attrs,["hash","caption"]);r.provider=i.provider,r.videoId=i.videoId,r.title=e.title,r.aspectRatio=T(e.aspectRatio,n),i.hash&&(r.hash=i.hash),e.caption.trim()&&(r.caption=e.caption.trim()),Z(t,r)}(this.context,t,this.config)}})}close(t){this.panel&&(this.outsideHandler&&(document.removeEventListener("mousedown",this.outsideHandler,!0),this.outsideHandler=null),this.panel.remove(),this.panel=null,t&&this.context.getContainer().focus())}open(t){this.close(!1);const e=document.createElement("div");e.className="notectl-video-overlay",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","false"),e.setAttribute("aria-label",t.label),this.panel=e,function(t,e){const{config:n,locale:o,initial:i,mode:r}=e;t.classList.add("notectl-video-popup");const a=Q("notectl-video-error"),l=document.createElement("p");l.id=a,l.className="notectl-video-popup__error",l.setAttribute("role","alert");const s=tt(t,{label:o.urlLabel,ariaLabel:o.urlAria,placeholder:o.urlPlaceholder,value:i?.url??"",type:"url",required:!0,describedBy:a}),d=tt(t,{label:o.titleLabel,ariaLabel:o.titleAria,placeholder:o.titlePlaceholder,value:i?.title??"",type:"text",required:!0,hint:o.titleHint}),c=tt(t,{label:o.captionLabel,ariaLabel:o.captionAria,placeholder:o.captionPlaceholder,value:i?.caption??"",type:"text"}),u=function(t,e,n,o){const i=Q("notectl-video-field"),r=document.createElement("div");r.className="notectl-video-popup__field";const a=document.createElement("label");a.className="notectl-video-popup__label",a.setAttribute("for",i),a.textContent=n.aspectRatioLabel,r.appendChild(a);const l=document.createElement("select");l.id=i,l.className="notectl-video-popup__select",l.setAttribute("aria-label",n.aspectRatioAria);const s=e.allowedAspectRatios.includes(o)?e.allowedAspectRatios:[o,...e.allowedAspectRatios];for(const d of s){const t=document.createElement("option");t.value=d,t.textContent=d,d===o&&(t.selected=!0),l.appendChild(t)}return r.appendChild(l),t.appendChild(r),l}(t,n,o,i?.aspectRatio??n.defaultAspectRatio);t.appendChild(l);const p=document.createElement("div");p.className="notectl-video-popup__actions";const h=document.createElement("button");h.type="button",h.className="notectl-video-popup__cancel",h.textContent=o.cancelButton;const m=document.createElement("button");m.type="button",m.className="notectl-video-popup__submit",m.textContent="edit"===r?o.updateButton:o.insertButton,m.setAttribute("aria-label","edit"===r?o.updateAria:o.insertAria),p.append(h,m),t.appendChild(p);const v=(t,e)=>{l.textContent=t,e.focus()},f=()=>{const t=s.value.trim();if(!I(t,n.providers))return void v(o.invalidUrl,s);const i=d.value.trim();i?(l.textContent="",e.onSubmit({url:t,title:i,caption:c.value.trim(),aspectRatio:u.value}),e.onClose()):v(o.titleRequired,d)};h.addEventListener("mousedown",t=>t.preventDefault()),h.addEventListener("click",t=>{t.preventDefault(),e.onClose()}),m.addEventListener("mousedown",t=>t.preventDefault()),m.addEventListener("click",t=>{t.preventDefault(),f()});for(const b of[s,d,c])b.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),f())});requestAnimationFrame(()=>s.focus())}(e,{mode:t.mode,initial:t.initial,config:this.config,locale:this.locale,onSubmit:t.onSubmit,onClose:()=>this.close(!0)}),e.addEventListener("keydown",t=>{"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),this.close(!0))}),this.context.getPluginContainer("top").appendChild(e),w(e),function(t,e){const n=e?e.bottom:window.innerHeight/3,o=e?e.left:window.innerWidth/3,i=t.offsetWidth||320,r=window.innerWidth-i-8,a=Math.max(8,Math.min(o,r)),l=window.innerHeight-t.offsetHeight-8,s=Math.min(n+8,Math.max(8,l));t.style.left=`${Math.round(a)}px`,t.style.top=`${Math.round(s)}px`}(e,t.rect),this.installOutsideHandler()}videoRect(t){const e=this.context.getContainer().querySelector(`[data-block-id="${t}"]`);return e?e.getBoundingClientRect():null}installOutsideHandler(){const t=t=>{this.panel&&!t.composedPath().includes(this.panel)&&this.close(!1)};this.outsideHandler=t,requestAnimationFrame(()=>{this.outsideHandler&&document.addEventListener("mousedown",t,!0)})}};function nt(){const t=window.getSelection();if(!t||0===t.rangeCount)return null;const e=t.getRangeAt(0).getBoundingClientRect();return 0===e.width&&0===e.height&&0===e.top&&0===e.left?null:e}var ot={insertVideo:"Insert Video",insertVideoTooltip:"Insert Video",urlLabel:"Video URL",urlPlaceholder:"https://www.youtube.com/watch?v=...",urlAria:"Video URL",titleLabel:"Title",titlePlaceholder:"Describe the video",titleAria:"Video title",titleHint:"Describes the video for screen readers. Required.",captionLabel:"Caption",captionPlaceholder:"Optional visible caption",captionAria:"Video caption",aspectRatioLabel:"Aspect ratio",aspectRatioAria:"Video aspect ratio",insertButton:"Insert",insertAria:"Insert video",updateButton:"Update",updateAria:"Update video",cancelButton:"Cancel",insertDialogLabel:"Insert video",editDialogLabel:"Edit video",invalidUrl:"Enter a YouTube, Vimeo, or Dailymotion video URL.",titleRequired:"Enter a title so screen readers can describe the video.",play:t=>t?`Play video: ${t}`:"Play video",loading:"Loading video...",providerBadge:t=>`${t} video`,closePlayer:"Close video player",videoAria:(t,e)=>e?`${t} video: ${e}`:`${t} video`,videoSelected:"Video selected.",videoSelectedWithTitle:t=>`Video selected: ${t}.`,resizeHint:(t,e)=>`${t} / ${e} to resize.`,keyboardResizeHint:(t,e)=>`${t} / ${e} to resize`,videoResized:t=>`Video resized to ${t} percent width.`,resetToDefaultSize:"Video reset to full width.",enteredPlayer:t=>t?`Playing ${t}. Press Escape to return to the document.`:"Playing video. Press Escape to return to the document.",exitedPlayer:"Returned to the document.",videoOptions:"Video options",editVideo:"Edit video",alignStart:"Align left",alignCenter:"Align center",alignEnd:"Align right",deleteVideo:"Delete video",embedPrompt:"Embed this video?",embedConfirm:"Embed",embedDismiss:"Keep as link",embedOfferAnnounce:t=>`${t} link pasted. Press Embed to turn it into a video, or continue editing to keep it as a link.`,embeddedAnnounce:"Video embedded."},it=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar--O0A9OTR.mjs"),"./locales/de.ts":()=>import("./de-BxQIt_1Y.mjs"),"./locales/es.ts":()=>import("./es-BQweZX6P.mjs"),"./locales/fr.ts":()=>import("./fr-C3EKRThN.mjs"),"./locales/hi.ts":()=>import("./hi-L6pJxZam.mjs"),"./locales/pt.ts":()=>import("./pt-Bb908r0n.mjs"),"./locales/ru.ts":()=>import("./ru-DkW9XZFy.mjs"),"./locales/zh.ts":()=>import("./zh-ikm3rSTR.mjs")});async function rt(t){return v(it,t,ot)}var at={start:"notectl-video--start",center:"notectl-video--center",end:"notectl-video--end"};function lt(t,e){for(const o of Object.values(at))t.classList.remove(o);const n=at[e]??at.center;t.classList.add(n)}function st(t,e,n){b(t,"aspect-ratio",e),b(t,"width",`${n}%`)}var dt=/^[A-Za-z0-9]+$/;function ct(t){return{provider:t.provider,videoId:t.videoId,...t.hash?{hash:t.hash}:{}}}function ut(t,e){const n=Number.parseFloat(t.getAttribute("width")??""),o=Number.parseFloat(t.getAttribute("height")??"");return Number.isFinite(n)&&Number.isFinite(o)&&n>0&&o>0?T(`${n}/${o}`,e):e.defaultAspectRatio}function pt(t,e,n){const o=function(t,e,n){const o=R(t.provider,e);return o?o.buildEmbedUrl(t,n):null}({provider:t.provider,videoId:t.videoId,...t.hash?{hash:t.hash}:{}},e.providers,{privacy:t.privacy,autoplay:!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches})??"",i=document.createElement("iframe");return i.className="notectl-video__iframe",i.setAttribute("src",o),i.setAttribute("title",t.title||n.providerBadge(H(t.provider,e.providers))),i.setAttribute("allow","autoplay; fullscreen; picture-in-picture; encrypted-media"),i.setAttribute("allowfullscreen","true"),i.setAttribute("referrerpolicy","no-referrer"),i.setAttribute("loading","lazy"),i.setAttribute("frameborder","0"),i}var ht=class{frame;getAttrs;config;locale;announce;facadeButton=null;player=null;iframe=null;escapeHandler=null;renderedKey="";constructor(t){this.frame=t.frame,this.getAttrs=t.getAttrs,this.config=t.config,this.locale=t.locale,this.announce=t.announce,this.renderFacade()}get isActive(){return null!==this.player}facadeKey(t){return[t.provider,t.videoId,t.hash??"",t.privacy,t.title,this.config.useProviderThumbnail].join("|")}renderFacade(){this.facadeButton?.remove();const t=this.getAttrs();this.renderedKey=this.facadeKey(t);const e=document.createElement("button");e.type="button",e.className="notectl-video__facade",e.setAttribute("aria-label",this.locale.play(t.title));const n=document.createElement("span");if(n.className="notectl-video__poster",n.setAttribute("aria-hidden","true"),this.config.useProviderThumbnail){const e=N({provider:t.provider,videoId:t.videoId},this.config.providers);e&&b(n,"background-image",`url("${e}")`)}const o=document.createElement("span");o.className="notectl-video__play-icon",o.setAttribute("aria-hidden","true"),o.innerHTML='<svg viewBox="0 0 68 48" width="48" height="34" aria-hidden="true" focusable="false"><path d="M66.5 7.7c-.8-2.9-2.5-5.4-5.4-6.2C55.8.1 34 0 34 0S12.2.1 6.9 1.5C4 2.3 2.3 4.8 1.5 7.7.1 13 0 24 0 24s.1 11 1.5 16.3c.8 2.9 2.5 5.4 5.4 6.2C12.2 47.9 34 48 34 48s21.8-.1 27.1-1.5c2.9-.8 4.6-3.3 5.4-6.2C67.9 35 68 24 68 24s-.1-11-1.5-16.3z" fill="currentColor"/><path d="M45 24 27 14v20z" fill="#fff"/></svg>';const i=document.createElement("span");i.className="notectl-video__badge",i.setAttribute("aria-hidden","true"),i.textContent=this.locale.providerBadge(H(t.provider,this.config.providers)),e.append(n,o,i),e.addEventListener("mousedown",t=>t.stopPropagation()),e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.activate()}),this.facadeButton=e,this.frame.insertBefore(e,this.frame.firstChild)}update(){const t=this.getAttrs(),e=this.facadeKey(t);if(e!==this.renderedKey){if(this.renderedKey=e,this.isActive&&this.iframe){const e=pt(t,this.config,this.locale);return this.iframe.replaceWith(e),void(this.iframe=e)}this.renderFacade()}}activate(){if(this.isActive||!this.facadeButton)return;const t=this.getAttrs(),e=document.createElement("div");e.className="notectl-video__player";const n=document.createElement("button");n.type="button",n.className="notectl-video__exit",n.setAttribute("aria-label",this.locale.closePlayer),n.innerHTML='<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M19 6.4 17.6 5 12 10.6 6.4 5 5 6.4 10.6 12 5 17.6 6.4 19 12 13.4 17.6 19 19 17.6 13.4 12z" fill="currentColor"/></svg>',n.addEventListener("mousedown",t=>t.stopPropagation()),n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.deactivate(!0)});const o=pt(t,this.config,this.locale);e.append(n,o),this.facadeButton.remove(),this.facadeButton=null,this.frame.insertBefore(e,this.frame.firstChild),this.player=e,this.iframe=o,this.escapeHandler=t=>{"Escape"===t.key&&(t.stopPropagation(),this.deactivate(!0))},this.frame.addEventListener("keydown",this.escapeHandler),o.focus(),this.announce(this.locale.enteredPlayer(t.title))}deactivate(t){this.player&&(this.escapeHandler&&(this.frame.removeEventListener("keydown",this.escapeHandler),this.escapeHandler=null),this.player.remove(),this.player=null,this.iframe=null,this.renderFacade(),t&&this.facadeButton?.focus(),this.announce(this.locale.exitedPlayer))}destroy(){this.escapeHandler&&(this.frame.removeEventListener("keydown",this.escapeHandler),this.escapeHandler=null),this.player?.remove(),this.player=null,this.iframe=null,this.facadeButton?.remove(),this.facadeButton=null}},mt=["w","e"],vt={w:-1,e:1},ft=null;function bt(){ft?.remove(),ft=null}function gt(t,e,n,o,i,r){let a=0,l=0,s=0,d=0,c=vt[e];const u=t=>{const e=(t.clientX-a)*c;var n,r;n=l+(s>0?e/s*100:0),r=i.minPercent,d=Math.max(r,Math.min(100,n)),i.applyLiveWidth(d),o.textContent=i.formatPercent(Math.round(d))},p=t=>{document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",p),n.classList.remove("notectl-video__resize-overlay--active"),o.classList.remove("notectl-video__size-indicator--visible"),bt(),i.commit(Math.round(d)),t.target?.releasePointerCapture?.(t.pointerId)};r(()=>{document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",p)}),t.addEventListener("pointerdown",t=>{t.preventDefault(),t.stopPropagation(),a=t.clientX,l=i.getWidthPercent(),d=l,s=i.getReferenceWidth(),c=i.isRtl()?-vt[e]:vt[e],n.classList.add("notectl-video__resize-overlay--active"),o.textContent=i.formatPercent(Math.round(l)),o.classList.add("notectl-video__size-indicator--visible"),function(t){bt(),ft=document.createElement("style");const e=g(t);e&&ft.setAttribute("nonce",e),ft.textContent="*{cursor:ew-resize!important;user-select:none!important}",document.head.appendChild(ft)}(n),t.target.setPointerCapture(t.pointerId),document.addEventListener("pointermove",u),document.addEventListener("pointerup",p)})}function yt(t,e,n){const o=document.createElement("button");return o.type="button",o.className="notectl-video__tool",o.setAttribute("aria-label",t),o.title=t,o.innerHTML=e,o.addEventListener("mousedown",t=>t.preventDefault()),o.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),n()}),o}function xt(t){const{config:e,locale:n,resolvedKeymap:o,announce:i,actions:r}=t;return(t,a,l)=>{const s=document.createElement("figure");s.className="notectl-video",s.setAttribute("data-block-id",t.id),s.setAttribute("data-void","true"),s.setAttribute("data-selectable","true");const d=document.createElement("div");d.className="notectl-video__frame",s.appendChild(d);let c=t.id,u=K(t.attrs,e),p=null,h=null,m=null;const v=new ht({frame:d,getAttrs:()=>u,config:e,locale:n,announce:i});function f(t){var o;u=K(t.attrs,e),st(d,u.aspectRatio,u.widthPercent),lt(s,u.align),s.setAttribute("aria-label",n.videoAria(H(u.provider,e.providers),u.title)),(o=u.caption)?(p||(p=document.createElement("figcaption"),p.className="notectl-video__caption",s.appendChild(p)),p.textContent!==o&&(p.textContent=o)):p&&(p.remove(),p=null),v.update(),m?.update(u.align)}function g(){h&&(h.destroy(),h.element.remove(),h=null)}return f(t),{dom:s,contentDOM:null,update:t=>"video"===t.type&&(c=t.id,s.setAttribute("data-block-id",t.id),f(t),!0),selectNode(){s.classList.add("notectl-video--selected"),e.resizable&&!h&&(h=function(t,e){const n=document.createElement("div");n.className="notectl-video__resize-overlay",n.setAttribute("data-notectl-no-print","");const o=document.createElement("div");o.className="notectl-video__size-indicator",n.appendChild(o);let i=null;for(const r of mt){const e=document.createElement("div");e.className=`notectl-video__resize-handle notectl-video__resize-handle--${r}`,e.setAttribute("aria-hidden","true"),gt(e,r,n,o,t,t=>{i=t}),n.appendChild(e)}if(e){const t=document.createElement("div");t.className="notectl-video__keyboard-hint",t.setAttribute("aria-hidden","true"),t.textContent=e,n.appendChild(t)}return{element:n,destroy(){i?.(),bt()}}}({minPercent:e.minWidthPercent,getWidthPercent:()=>u.widthPercent,getReferenceWidth:()=>s.clientWidth||d.clientWidth,isRtl:()=>"rtl"===y(s),applyLiveWidth:t=>b(d,"width",`${t}%`),commit:t=>function(t){const e=a(),n=e.getBlock(c);if(!n)return;const o=e.getNodePath(c);if(!o)return;const i={...n.attrs??{},widthPercent:t};l(e.transaction("command").setNodeAttr(o,i).build())}(t),formatPercent:t=>`${t}%`},function(t,e){const n=t.shrinkWidth??null,o=t.growWidth??null;return n&&o?e.keyboardResizeHint(_(n),_(o)):""}(o,n)),d.appendChild(h.element)),m||(m=function(t){const{locale:e,actions:n}=t,o=document.createElement("div");o.className="notectl-video__toolbar",o.setAttribute("role","toolbar"),o.setAttribute("aria-label",e.videoOptions),o.setAttribute("data-notectl-no-print",""),o.addEventListener("mousedown",t=>t.stopPropagation());const i=yt(e.editVideo,'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="currentColor"/></svg>',()=>n.edit()),r={start:yt(e.alignStart,'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M3 4h18v2H3V4zm0 7h12v2H3v-2zm0 7h18v2H3v-2zm0-3.5h12v-2H3v2z" fill="currentColor"/></svg>',()=>n.align("start")),center:yt(e.alignCenter,'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M3 4h18v2H3V4zm3 7h12v2H6v-2zm-3 7h18v2H3v-2zm3-3.5h12v-2H6v2z" fill="currentColor"/></svg>',()=>n.align("center")),end:yt(e.alignEnd,'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M3 4h18v2H3V4zm6 7h12v2H9v-2zm-6 7h18v2H3v-2zm6-3.5h12v-2H9v2z" fill="currentColor"/></svg>',()=>n.align("end"))},a=yt(e.deleteVideo,'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" fill="currentColor"/></svg>',()=>n.remove()),l=()=>{const t=document.createElement("span");return t.className="notectl-video__tool-separator",t.setAttribute("aria-hidden","true"),t};o.append(i,l(),r.start,r.center,r.end,l(),a);const s=t=>{for(const e of["start","center","end"]){const n=e===t;r[e].classList.toggle("notectl-video__tool--active",n),r[e].setAttribute("aria-pressed",n?"true":"false")}};return s(t.initialAlign),{element:o,update:s,destroy(){o.remove()}}}({locale:n,actions:r,initialAlign:u.align}),s.appendChild(m.element))},deselectNode(){s.classList.remove("notectl-video--selected"),g(),m?.destroy(),m=null},destroy(){g(),m?.destroy(),m=null,v.destroy()}}}}function _t(t){return(e,n,o)=>{const i=function(t,e,n){const o=t.trim();if(o&&!/\s/.test(o)){const t=I(o,n);if(t)return{url:o,match:t}}const i=function(t){if(!t)return null;const e=function(t){const e=document.createElement("template");return e.innerHTML=t,e.content}(t),n=e.querySelector("iframe");if(!n)return null;const o=e.cloneNode(!0);for(const i of Array.from(o.querySelectorAll("iframe")))i.remove();return""!==(o.textContent??"").trim()?null:n.getAttribute("src")}(e);if(i){const t=I(i,n);if(t)return{url:$(t,n)??i,match:t}}return null}(e,n,t.providers);if(!i)return null;const r=o.selection;if(!u(r)||!s(r))return null;const a=r.anchor.blockId,l=r.anchor.offset,d=l+i.url.length,p=o.transaction("paste").insertText(a,l,i.url,[]).setSelection(c(a,d)).build();return t.onOffer({blockId:a,start:l,end:d},i.match),p}}var wt=0,At=/* @__PURE__ */new Set,kt=null;var Ct=class{id="video";name="Video";priority=47;config;resolvedKeymap;context=null;locale=ot;overlay=null;embedPrompt=null;constructor(t){this.config={...W,...t},this.resolvedKeymap={...M,...t?.keymap}}async init(n){this.context=n,this.locale=await f(n,this.config.locale,ot,rt),n.registerStyleSheet('\n.notectl-video {\n\tmargin: 12px 0;\n\tposition: relative;\n\tuser-select: none;\n}\n\n.notectl-video--center { text-align: center; }\n.notectl-video--start { text-align: start; }\n.notectl-video--end { text-align: end; }\n\n.notectl-video__frame {\n\tdisplay: inline-block;\n\tposition: relative;\n\twidth: 100%;\n\tmax-width: 100%;\n\tvertical-align: top;\n\toverflow: hidden;\n\tborder-radius: 8px;\n\tbackground: #000;\n\ttext-align: start;\n}\n\n/* Facade (click-to-load) */\n.notectl-video__facade {\n\tposition: absolute;\n\tinset: 0;\n\twidth: 100%;\n\theight: 100%;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: 0;\n\tborder: 0;\n\tcursor: pointer;\n\tbackground: #14181c;\n\tcolor: #fff;\n}\n\n.notectl-video__facade:focus-visible {\n\toutline: 3px solid var(--notectl-primary);\n\toutline-offset: -3px;\n}\n\n.notectl-video__poster {\n\tposition: absolute;\n\tinset: 0;\n\tbackground-size: cover;\n\tbackground-position: center;\n\tbackground-repeat: no-repeat;\n}\n\n.notectl-video__poster::after {\n\tcontent: "";\n\tposition: absolute;\n\tinset: 0;\n\tbackground: rgba(0, 0, 0, 0.25);\n}\n\n.notectl-video__play-icon {\n\tposition: relative;\n\tz-index: 1;\n\tdisplay: inline-flex;\n\tfilter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));\n\ttransition: transform 0.12s ease;\n}\n\n.notectl-video__facade:hover .notectl-video__play-icon {\n\ttransform: scale(1.08);\n}\n\n.notectl-video__badge {\n\tposition: absolute;\n\tz-index: 1;\n\tbottom: 8px;\n\tinset-inline-start: 8px;\n\tpadding: 2px 6px;\n\tborder-radius: 4px;\n\tbackground: rgba(0, 0, 0, 0.65);\n\tcolor: #fff;\n\tfont-size: 12px;\n\tfont-weight: 600;\n}\n\n/* Player (activated iframe + exit control) */\n.notectl-video__player {\n\tposition: absolute;\n\tinset: 0;\n}\n\n.notectl-video__iframe {\n\tposition: absolute;\n\tinset: 0;\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0;\n\tdisplay: block;\n}\n\n.notectl-video__exit {\n\tposition: absolute;\n\tz-index: 2;\n\ttop: 6px;\n\tinset-inline-end: 6px;\n\twidth: 28px;\n\theight: 28px;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tborder: 0;\n\tborder-radius: 50%;\n\tcursor: pointer;\n\tbackground: rgba(0, 0, 0, 0.65);\n\tcolor: #fff;\n}\n\n.notectl-video__exit:focus-visible {\n\toutline: 2px solid #fff;\n\toutline-offset: 2px;\n}\n\n/* Static fallback link (no-JS / export rehydration) */\n.notectl-video__fallback-link {\n\tposition: absolute;\n\tinset: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: 8px;\n\tcolor: #fff;\n\ttext-decoration: underline;\n\ttext-align: center;\n}\n\n/* Caption */\n.notectl-video__caption {\n\tmargin-top: 6px;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg-muted);\n\ttext-align: center;\n}\n\n/* Selection */\n.notectl-video--selected .notectl-video__frame {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n\n/* Resize overlay + side handles */\n.notectl-video__resize-overlay {\n\tposition: absolute;\n\tinset: 0;\n\tpointer-events: none;\n}\n\n.notectl-video__resize-handle {\n\tposition: absolute;\n\ttop: 50%;\n\ttransform: translateY(-50%);\n\twidth: 8px;\n\theight: 44px;\n\tmax-height: 60%;\n\tborder: 2px solid var(--notectl-primary);\n\tborder-radius: 6px;\n\tbackground: var(--notectl-surface-raised);\n\tpointer-events: all;\n\tcursor: ew-resize;\n\tz-index: 2;\n}\n\n.notectl-video__resize-handle--w { inset-inline-start: -5px; }\n.notectl-video__resize-handle--e { inset-inline-end: -5px; }\n\n.notectl-video__size-indicator {\n\tposition: absolute;\n\tbottom: -28px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tpadding: 2px 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\topacity: 0;\n\ttransition: opacity 0.15s;\n\tz-index: 3;\n}\n\n.notectl-video__size-indicator--visible { opacity: 1; }\n\n.notectl-video__keyboard-hint {\n\tdisplay: none;\n\tposition: absolute;\n\tbottom: -28px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tpadding: 2px 8px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 3;\n}\n\n.notectl-video--selected .notectl-video__keyboard-hint { display: block; }\n.notectl-video__resize-overlay--active ~ .notectl-video__keyboard-hint,\n.notectl-video__resize-overlay--active .notectl-video__keyboard-hint { display: none; }\n\n/* On-selection toolbar */\n.notectl-video__toolbar {\n\tposition: absolute;\n\ttop: -44px;\n\tleft: 50%;\n\ttransform: translateX(-50%);\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 2px;\n\tpadding: 2px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbackground: var(--notectl-surface-overlay);\n\tbox-shadow: 0 2px 8px var(--notectl-shadow);\n\tz-index: 10;\n}\n\n.notectl-video__tool {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\theight: 28px;\n\tborder: none;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-video__tool:hover { background: var(--notectl-hover-bg); }\n\n.notectl-video__tool--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary);\n}\n\n.notectl-video__tool:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 1px;\n}\n\n.notectl-video__tool svg { width: 16px; height: 16px; }\n\n.notectl-video__tool-separator {\n\twidth: 1px;\n\theight: 18px;\n\tmargin: 0 2px;\n\tbackground: var(--notectl-border);\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.notectl-video__play-icon,\n\t.notectl-video__size-indicator {\n\t\ttransition: none;\n\t}\n}\n\n@media (forced-colors: active) {\n\t.notectl-video__frame { outline: 1px solid CanvasText; }\n\t.notectl-video__facade { border: 1px solid ButtonText; }\n\t.notectl-video__play-icon { forced-color-adjust: none; }\n\t.notectl-video__resize-handle { background: ButtonFace; border-color: ButtonText; }\n\t.notectl-video--selected .notectl-video__frame { outline: 2px solid Highlight; }\n}\n'),n.registerStyleSheet("\n.notectl-video-overlay {\n\tposition: fixed;\n\tz-index: 1000;\n\tbox-sizing: border-box;\n\tmin-width: 300px;\n\tmax-width: 92vw;\n\tpadding: 12px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 8px;\n\tbackground: var(--notectl-surface-overlay);\n\tcolor: var(--notectl-fg);\n\tbox-shadow: 0 6px 24px var(--notectl-shadow);\n}\n\n.notectl-video-popup {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 10px;\n}\n\n.notectl-video-popup__field {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n}\n\n.notectl-video-popup__label {\n\tfont-size: 12px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-fg-muted);\n}\n\n.notectl-video-popup__input,\n.notectl-video-popup__select {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg);\n\tfont: inherit;\n}\n\n.notectl-video-popup__input:focus-visible,\n.notectl-video-popup__select:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 1px;\n}\n\n.notectl-video-popup__hint {\n\tmargin: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n}\n\n.notectl-video-popup__error:not(:empty) {\n\tmargin: 0;\n\tpadding: 6px 8px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-danger-muted);\n\tcolor: var(--notectl-danger);\n\tfont-size: 12px;\n}\n\n.notectl-video-popup__actions {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\tgap: 8px;\n\tmargin-top: 2px;\n}\n\n.notectl-video-popup__cancel,\n.notectl-video-popup__submit {\n\tpadding: 7px 14px;\n\tcursor: pointer;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg);\n\tfont: inherit;\n}\n\n.notectl-video-popup__submit {\n\tborder-color: var(--notectl-primary);\n\tbackground: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg);\n\tfont-weight: 600;\n}\n\n.notectl-video-popup__cancel:focus-visible,\n.notectl-video-popup__submit:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n\n/* Ask-first paste affordance */\n.notectl-video-embed-prompt {\n\tposition: fixed;\n\tz-index: 1000;\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\tpadding: 6px 8px 6px 12px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 8px;\n\tbackground: var(--notectl-surface-overlay);\n\tcolor: var(--notectl-fg);\n\tbox-shadow: 0 4px 16px var(--notectl-shadow);\n\tfont-size: 13px;\n}\n\n.notectl-video-embed-prompt__text {\n\tmargin-inline-end: 4px;\n}\n\n.notectl-video-embed-prompt__embed,\n.notectl-video-embed-prompt__dismiss {\n\tpadding: 4px 10px;\n\tcursor: pointer;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg);\n\tfont: inherit;\n}\n\n.notectl-video-embed-prompt__embed {\n\tborder-color: var(--notectl-primary);\n\tbackground: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg);\n\tfont-weight: 600;\n}\n\n.notectl-video-embed-prompt__embed:focus-visible,\n.notectl-video-embed-prompt__dismiss:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n\n@media (forced-colors: active) {\n\t.notectl-video-overlay,\n\t.notectl-video-embed-prompt {\n\t\tborder: 1px solid CanvasText;\n\t}\n\t.notectl-video-popup__submit,\n\t.notectl-video-embed-prompt__embed {\n\t\tborder: 1px solid ButtonText;\n\t}\n}\n"),function(t){for(const e of t)At.add(e);wt+=1,kt||(kt=t=>{if("iframe"!==t.nodeName.toLowerCase())return;const e=t;e.hasAttribute("srcdoc")?e.parentNode?.removeChild(e):function(t,e){const n=B(t);return!!n&&"https:"===n.protocol&&e.has(n.hostname.toLowerCase())}(e.getAttribute("src")??"",At)||e.parentNode?.removeChild(e)},A.addHook("uponSanitizeElement",kt))}(function(t=S){const e=/* @__PURE__ */new Set;for(const n of t)for(const t of n.embedHostnames)e.add(t.toLowerCase());return e}(this.config.providers)),n.registerNodeSpec(function(n,o){const i=n.providers;return{type:"video",group:"block",isVoid:!0,selectable:!0,attrs:{provider:{default:""},videoId:{default:""},hash:{default:""},aspectRatio:{default:n.defaultAspectRatio},widthPercent:{default:n.defaultWidthPercent},align:{default:"center"},title:{default:""},caption:{default:""},privacy:{default:n.privacy}},toDOM(t){const e=K(t.attrs,n),r=x("figure",t.id);r.className="notectl-video",r.setAttribute("data-void","true"),r.setAttribute("data-selectable","true"),r.setAttribute("data-video-provider",e.provider),r.setAttribute("data-video-id",e.videoId),e.hash&&r.setAttribute("data-video-hash",e.hash),lt(r,e.align),r.setAttribute("aria-label",o.videoAria(H(e.provider,i),e.title));const a=document.createElement("div");a.className="notectl-video__frame",st(a,e.aspectRatio,e.widthPercent);const l=$(ct(e),i);if(l){const t=document.createElement("a");t.className="notectl-video__fallback-link",t.href=l,t.rel="noopener noreferrer",t.textContent=e.title||l,a.appendChild(t)}if(r.appendChild(a),e.caption){const t=document.createElement("figcaption");t.className="notectl-video__caption",t.textContent=e.caption,r.appendChild(t)}return r},toHTML(o){const r=K(o.attrs,n),a=ct(r),l=$(a,i),s=[`data-video-provider="${t(r.provider)}"`,`data-video-id="${t(r.videoId)}"`,`data-video-ratio="${t(r.aspectRatio)}"`,`data-video-width="${r.widthPercent}"`,`data-video-privacy="${r.privacy?"true":"false"}"`];r.hash&&s.push(`data-video-hash="${t(r.hash)}"`),r.title&&s.push(`data-video-title="${t(r.title)}"`);const d=n.useProviderThumbnail?N(a,i):void 0,c=d?`<img src="${t(d)}" alt="">`:e(r.title||l||""),u=l?`<a href="${t(l)}" rel="noopener noreferrer">${c}</a>`:c,p=r.caption?`<figcaption>${e(r.caption)}</figcaption>`:"";return`<figure ${s.join(" ")}>${u}${p}</figure>`},parseHTML:[{tag:"figure",priority:60,getAttrs:t=>function(t,e){const n=t.getAttribute("data-video-provider"),o=t.getAttribute("data-video-id");if(!n||!o)return!1;if(!F(o))return!1;if(!R(n,e.providers))return!1;const i=t.getAttribute("data-video-title")??t.querySelector("a")?.textContent?.trim()??t.getAttribute("aria-label")??"",r=t.querySelector("figcaption")?.textContent?.trim()??"",a=t.getAttribute("data-video-width"),l={provider:n,videoId:o,aspectRatio:T(t.getAttribute("data-video-ratio")??void 0,e),widthPercent:O(a?Number.parseFloat(a):e.defaultWidthPercent,e),align:"center",title:i,privacy:"false"!==t.getAttribute("data-video-privacy")},s=t.getAttribute("data-video-hash");return s&&dt.test(s)&&(l.hash=s),r&&(l.caption=r),l}(t,n)},{tag:"iframe",priority:60,getAttrs:t=>function(t,e){const n=I(t.getAttribute("src")??"",e.providers);if(!n||!F(n.videoId))return!1;const o={provider:n.provider,videoId:n.videoId,aspectRatio:ut(t,e),widthPercent:e.defaultWidthPercent,align:"center",title:t.getAttribute("title")??"",privacy:e.privacy};return n.hash&&(o.hash=n.hash),o}(t,n)}],sanitize:{tags:["figure","figcaption","a","img","iframe"],attrs:["href","rel","src","alt","title","allow","allowfullscreen","referrerpolicy","loading","width","height","frameborder","class","style"]}}}(this.config,this.locale)),this.overlay=new et(n,this.config,this.locale),this.registerNodeView(n),function(t){t.registerCommand("removeVideo",()=>Y(t))}(n),this.registerInsertCommand(n),this.registerResizeCommands(n),this.registerResizeKeymaps(n),this.registerPasteInterceptor(n),this.registerToolbarItem(n)}destroy(){(wt=Math.max(0,wt-1))>0||!kt||(A.removeHook("uponSanitizeElement"),kt=null,At.clear()),this.embedPrompt?.close(),this.embedPrompt=null,this.overlay?.close(!1),this.overlay=null,this.context=null}onStateChange(t,e,n){this.context&&!this.isVideoSelected(t)&&this.isVideoSelected(e)&&this.announceVideoSelection(e)}registerNodeView(t){t.registerNodeView(D,xt({config:this.config,locale:this.locale,resolvedKeymap:this.resolvedKeymap,announce:e=>t.announce(e),actions:{edit:()=>this.overlay?.openEditForSelected(),align:e=>function(t,e){const n=X(t.getState());return!!n&&Z(t,{...n.block.attrs??{},align:e})}(t,e),remove:()=>Y(t)}}))}registerInsertCommand(t){t.registerCommand("insertVideo",()=>(this.isVideoSelected(t.getState())?this.overlay?.openEditForSelected():this.overlay?.openInsert(),!0))}registerResizeCommands(t){const e=this.config.widthStep,n=this.config.widthStepLarge,o=e=>{const n=function(t,e,n){const o=X(t.getState());if(!o)return!1;const i=o.block.attrs?.widthPercent??n.defaultWidthPercent,r=O(i+e,n);return r!==i&&Z(t,{...o.block.attrs??{},widthPercent:r})}(t,e,this.config);return n&&this.announceCurrentSize(t),n};t.registerCommand("resizeVideoGrow",()=>o(e)),t.registerCommand("resizeVideoShrink",()=>o(-e)),t.registerCommand("resizeVideoGrowLarge",()=>o(n)),t.registerCommand("resizeVideoShrinkLarge",()=>o(-n)),t.registerCommand("resetVideoSize",()=>{const e=function(t,e){const n=X(t.getState());return!!n&&Z(t,{...n.block.attrs??{},widthPercent:e.defaultWidthPercent})}(t,this.config);return e&&t.announce(this.locale.resetToDefaultSize),e})}registerResizeKeymaps(t){const e={growWidth:"resizeVideoGrow",shrinkWidth:"resizeVideoShrink",growWidthLarge:"resizeVideoGrowLarge",shrinkWidthLarge:"resizeVideoShrinkLarge",resetSize:"resetVideoSize"},n={};for(const[o,i]of Object.entries(e)){const e=this.resolvedKeymap[o]??null;e&&(n[e]=()=>t.executeCommand(i))}Object.keys(n).length>0&&t.registerKeymap(n)}registerPasteInterceptor(t){t.registerPasteInterceptor(_t({providers:this.config.providers,onOffer:(t,e)=>this.offerEmbed(t,e)}),{name:"video",priority:40})}offerEmbed(t,e){if(!this.context)return;const o=this.context,i=H(e.provider,this.config.providers);this.embedPrompt?.close(),requestAnimationFrame(()=>{o.announce(this.locale.embedOfferAnnounce(i));const e=function(t,e){const o=t.getBlock(e.blockId);if(!o)return"";const i=n(o);return i.slice(e.start,Math.min(e.end,i.length))}(o.getState(),t);this.embedPrompt=function(t){const{locale:e}=t,n=document.createElement("div");n.className="notectl-video-embed-prompt",n.setAttribute("role","dialog"),n.setAttribute("aria-label",e.embedPrompt);const o=document.createElement("span");o.className="notectl-video-embed-prompt__text",o.textContent=e.embedPrompt;const i=document.createElement("button");i.type="button",i.className="notectl-video-embed-prompt__embed",i.textContent=e.embedConfirm;const r=document.createElement("button");r.type="button",r.className="notectl-video-embed-prompt__dismiss",r.textContent=e.embedDismiss,n.append(o,i,r);let a=null,l=!1;const s=()=>{l||(l=!0,a&&(document.removeEventListener("mousedown",a,!0),a=null),n.remove())},d=t=>{s(),t()};return i.addEventListener("mousedown",t=>t.preventDefault()),i.addEventListener("click",e=>{e.preventDefault(),d(t.onEmbed)}),r.addEventListener("mousedown",t=>t.preventDefault()),r.addEventListener("click",e=>{e.preventDefault(),d(t.onDismiss)}),n.addEventListener("keydown",e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),d(t.onDismiss))}),t.container.appendChild(n),w(n),function(t,e){const n=e?e.bottom:window.innerHeight/3,o=e?e.left:window.innerWidth/3,i=t.offsetWidth||240,r=window.innerWidth-i-8,a=Math.max(8,Math.min(o,r)),l=window.innerHeight-t.offsetHeight-8,s=Math.min(n+8,Math.max(8,l));t.style.left=`${Math.round(a)}px`,t.style.top=`${Math.round(s)}px`}(n,t.rect),a=e=>{e.composedPath().includes(n)||d(t.onDismiss)},requestAnimationFrame(()=>{a&&document.addEventListener("mousedown",a,!0),i.focus()}),{close:s}}({container:o.getPluginContainer("top"),rect:Pt(),locale:this.locale,onEmbed:()=>{this.embedPrompt=null,this.overlay?.openInsertReplacingRange(t,e)},onDismiss:()=>{this.embedPrompt=null,o.getContainer().focus()}})})}registerToolbarItem(t){t.registerToolbarItem({id:"video",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zm6 4.5v7l6-3.5-6-3.5z" fill="currentColor"/></svg>',label:this.locale.insertVideo,tooltip:this.locale.insertVideoTooltip,command:"insertVideo"})}isVideoSelected(t){const e=t.selection;return!!l(e)&&t.getBlock(e.nodeId)?.type===D}announceVideoSelection(t){if(!this.context)return;const e=t.selection;if(!l(e))return;const n=t.getBlock(e.nodeId);if(!n||"video"!==n.type)return;const o=n.attrs?.title??"",i=[o?this.locale.videoSelectedWithTitle(o):this.locale.videoSelected],r=this.resolvedKeymap.shrinkWidth??null,a=this.resolvedKeymap.growWidth??null;r&&a&&i.push(this.locale.resizeHint(_(r),_(a))),this.context.announce(i.join(" "))}announceCurrentSize(t){const e=function(t,e){const n=X(t);return n?n.block.attrs?.widthPercent??e.defaultWidthPercent:null}(t.getState(),this.config);null!==e&&t.announce(this.locale.videoResized(e))}};function Pt(){const t=window.getSelection();if(!t||0===t.rangeCount)return null;const e=t.getRangeAt(0).getBoundingClientRect();return 0===e.width&&0===e.height&&0===e.top&&0===e.left?null:e}export{M as a,W as i,ot as n,S as o,rt as r,I as s,Ct as t};
2
- //# sourceMappingURL=VideoPlugin-BugkI7-m.mjs.map