@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{o as t}from"./HTMLUtils-Bhg3_P8B.mjs";function n(t,n=[]){return{kind:"text",text:t,marks:n}}function e(t){return{kind:"inline",node:t}}function r(t,n,e){const r=[];return o(t,n,e,{onText(t,n){r.push({kind:"text",text:t,marks:n})},onInline(t){r.push({kind:"inline",node:t})}}),r}function o(t,n,e,r){for(const{child:o,from:i,to:f}of E(l(t)))if(!(f<=n||i>=e))if(s(o))r.onInline?.(o);else{const t=Math.max(0,n-i),s=Math.min(o.text.length,e-i),f=o.text.slice(t,s);f.length>0&&r.onText(f,o.marks)}}function i(t){return"object"==typeof t&&null!==t&&"text"===t.type&&"string"==typeof t.text}function s(t){return"object"==typeof t&&null!==t&&"inline"===t.type&&"string"==typeof t.inlineType}function f(t){return"object"==typeof t&&null!==t&&"string"==typeof t.id&&"string"==typeof t.type&&"text"!==t.type&&"inline"!==t.type&&Array.isArray(t.children)}function u(t){return t.children.every(t=>i(t)||s(t))}function c(t){return t.children.filter(t=>i(t))}function l(t){return t.children.filter(t=>i(t)||s(t))}function a(t){return t.children.filter(t=>f(t))}function h(){return`block-${crypto.randomUUID()}`}function y(t){return{children:t??[g("paragraph")]}}function g(n,e,r,o,i){const s=t(i);return{id:r??h(),...s?{htmlId:s}:{},type:n,...o?{attrs:o}:{},children:e??[m("")]}}function m(t,n){return{type:"text",text:t,marks:n??[]}}function p(t,n,e){return{type:"inline",inlineType:t,attrs:n??{},marks:e??[]}}function d(t){return g("paragraph",[m("")],t)}function k(t){const n=l(t);let e="";for(const r of n)i(r)&&(e+=r.text);return e}function x(t){let n=0;for(const{to:e}of E(l(t)))n=e;return n}function A(t,n){const e=l(t);for(const{child:r,from:o,to:i}of E(e))if(s(r)){if(n===o)return[]}else{if(n>=o&&n<i)return r.marks;if(n===o&&0===r.text.length)return r.marks}for(let r=e.length-1;r>=0;r--){const t=e[r];if(t&&i(t))return t.marks}return[]}function b(t,n,e){const r=A(t,n);if(0===r.length)return r;const o=function(t,n){for(const{child:e,from:r,to:o}of E(l(t)))if(s(e)){if(n===r)return[]}else if(n>=r&&n<o)return e.marks;return[]}(t,n);return r.filter(t=>e(t.type)||o.some(n=>j(n,t)))}function j(t,n){if(t.type!==n.type)return!1;const e=t.attrs,r=n.attrs;if(!e&&!r)return!0;if(!e||!r)return!1;const o=Object.keys(e),i=Object.keys(r);return o.length===i.length&&o.every(t=>e[t]===r[t])}function v(t,n){return t===n||void 0!==t&&void 0!==n&&null!==t&&null!==n&&!(!Array.isArray(t)&&!Array.isArray(n))&&!(!Array.isArray(t)||!Array.isArray(n)||t.length!==n.length)&&t.every((t,e)=>t===n[e])}function T(t,n){if(t===n)return!0;if(!t||!n)return!1;const e=Object.keys(t),r=Object.keys(n);return e.length===r.length&&e.every(e=>v(t[e],n[e]))}function O(t,n){return t.length===n.length&&t.every(t=>n.some(n=>j(t,n)))}function I(t,n){return t.some(t=>t.type===n)}function M(t,n){return I(t,n.type)?t:[...t,n]}function U(t,n){return t.filter(t=>t.type!==n)}function D(t){if(0===t.length)return[m("")];if(t.every(t=>i(t)))return function(t){if(0===t.length)return[m("")];const n=[];for(const e of t){const t=n[n.length-1];t&&O(t.marks,e.marks)?n[n.length-1]=m(t.text+e.text,t.marks):(e.text.length>0||0===n.length)&&n.push(e)}return 0===n.length?[m("")]:n}(t);const n=[];for(const r of t){if(s(r)){n.push(r);continue}const t=n[n.length-1];t&&i(t)&&O(t.marks,r.marks)?n[n.length-1]=m(t.text+r.text,t.marks):(r.text.length>0||0===n.length)&&n.push(r)}const e=n.filter((t,e)=>{if(s(t))return!0;if(t.text.length>0)return!0;if(1===n.length)return!0;const r=n[e-1],o=n[e+1];return!(r&&s(r)||o&&s(o))});return 0===e.length?[m("")]:e.some(t=>i(t))?e:[m(""),...e]}function w(t){return"inline"===t.kind?t.node:m(t.text,t.marks)}function C(t){return D(t.map(w))}function*E(t){let n=0;for(const e of t){const t=s(e)?1:e.text.length;yield{child:e,from:n,to:n+t},n+=t}}function H(t,n){let e=0;for(const{child:r,from:o,to:i}of E(l(t)))if(s(r)){if(o>=n)return e}else{if(i>=n)return e+(n-o);e+=r.text.length}return e}function L(t,n){const e=l(t);for(const{child:r,from:o}of E(e)){if(s(r)){if(n===o)return{kind:"inline",node:r};continue}const t=n-o;if(t>=0&&t<r.text.length)return{kind:"text",char:r.text[t]??"",marks:r.marks}}return null}export{D as A,e as C,i as D,u as E,C as M,n as N,O,E as P,I as S,s as T,k as _,w as a,l as b,d as c,o as d,h as f,A as g,x as h,H as i,U as j,j as k,p as l,r as m,v as n,g as o,a as p,T as r,y as s,M as t,m as u,L as v,f as w,c as x,b as y};
2
- //# sourceMappingURL=Document-827l3P80.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Document-827l3P80.mjs","names":[],"sources":["../../src/model/Document.ts"],"sourcesContent":["/**\n * Core document model types for the Notectl editor.\n * All types are deeply readonly — mutations create new instances.\n */\n\nimport { normalizeHTMLId } from './HTMLUtils.js';\nimport type { BlockId, InlineTypeName, MarkTypeName, NodeTypeName } from './TypeBrands.js';\n\n// --- Mark Types ---\n\nexport interface Mark {\n\treadonly type: MarkTypeName;\n\treadonly attrs?: Readonly<Record<string, string | number | boolean>>;\n}\n\nexport interface BoldMark extends Mark {\n\treadonly type: MarkTypeName & 'bold';\n}\n\nexport interface ItalicMark extends Mark {\n\treadonly type: MarkTypeName & 'italic';\n}\n\nexport interface UnderlineMark extends Mark {\n\treadonly type: MarkTypeName & 'underline';\n}\n\n// --- Node Types ---\n\n/** JSON-compatible primitive stored in a block attribute. */\nexport type BlockAttrPrimitive = string | number | boolean | null;\n\n/** Scalar member permitted inside a structured block-attribute array. */\nexport type BlockAttrArrayValue = BlockAttrPrimitive;\n\n/**\n * Immutable JSON-compatible block attribute value.\n *\n * Marks and inline nodes intentionally retain their scalar-only attributes.\n * Block nodes may additionally own structured state (for example a table's\n * logical column-width vector) without encoding it in delimiter strings.\n */\nexport type BlockAttrValue = Exclude<BlockAttrPrimitive, null> | readonly BlockAttrArrayValue[];\n\nexport interface BlockAttrs {\n\treadonly [key: string]: BlockAttrValue;\n}\n\nexport interface TextNode {\n\treadonly type: 'text';\n\treadonly text: string;\n\treadonly marks: readonly Mark[];\n}\n\n/** Atomic inline element (width 1 in offset space). */\nexport interface InlineNode {\n\treadonly type: 'inline';\n\treadonly inlineType: InlineTypeName;\n\treadonly attrs: Readonly<Record<string, string | number | boolean>>;\n\t/**\n\t * Marks applied to this atomic node (e.g. a `link` on an inline image). Inline\n\t * nodes carry marks just like text nodes do, so a linked inline image survives\n\t * import, export, and rendering without the link being dropped.\n\t */\n\treadonly marks: readonly Mark[];\n}\n\n/** A child of a BlockNode: text, inline element, or nested block. */\nexport type ChildNode = TextNode | InlineNode | BlockNode;\n\nexport interface BlockNode {\n\t/** Internal editor identity, serialized to HTML as `data-block-id`. */\n\treadonly id: BlockId;\n\t/** Optional document-local HTML target, serialized to the block element's `id` attribute. */\n\treadonly htmlId?: string;\n\treadonly type: NodeTypeName;\n\treadonly attrs?: BlockAttrs;\n\treadonly children: readonly ChildNode[];\n}\n\nexport interface Document {\n\treadonly children: readonly BlockNode[];\n}\n\n// --- Text Segment (for mark-preserving undo) ---\n\nexport interface TextSegment {\n\treadonly text: string;\n\treadonly marks: readonly Mark[];\n}\n\n/** A content segment: either text (with marks) or an inline node. */\nexport type ContentSegment =\n\t| { readonly kind: 'text'; readonly text: string; readonly marks: readonly Mark[] }\n\t| { readonly kind: 'inline'; readonly node: InlineNode };\n\n/** Creates a text {@link ContentSegment}. */\nexport function textSegment(text: string, marks: readonly Mark[] = []): ContentSegment {\n\treturn { kind: 'text', text, marks };\n}\n\n/** Creates an inline {@link ContentSegment} wrapping an {@link InlineNode}. */\nexport function inlineSegment(node: InlineNode): ContentSegment {\n\treturn { kind: 'inline', node };\n}\n\n/** Returns content segments (text and inline) for a block range. */\nexport function getBlockContentSegmentsInRange(\n\tblock: BlockNode,\n\tfrom: number,\n\tto: number,\n): readonly ContentSegment[] {\n\tconst segments: ContentSegment[] = [];\n\tforEachInlineChildInRange(block, from, to, {\n\t\tonText(text: string, marks: readonly Mark[]): void {\n\t\t\tsegments.push({ kind: 'text', text, marks });\n\t\t},\n\t\tonInline(node: InlineNode): void {\n\t\t\tsegments.push({ kind: 'inline', node });\n\t\t},\n\t});\n\treturn segments;\n}\n\n/** Visitor callbacks invoked by {@link forEachInlineChildInRange} for each in-range child. */\nexport interface BlockRangeVisitor {\n\t/** Called with the clipped text and its marks for each text node overlapping the range. */\n\treadonly onText: (text: string, marks: readonly Mark[]) => void;\n\t/** Called for each inline node falling within the range. */\n\treadonly onInline?: (node: InlineNode) => void;\n}\n\n/**\n * Walks the inline children of `block` overlapping `[from, to)` and invokes the\n * matching visitor callback for each. Text nodes are clipped to the range before\n * `onText` fires; empty slices are skipped. This is the single read-only walker\n * for range-based inline serialization (segments, HTML, clipboard).\n */\nexport function forEachInlineChildInRange(\n\tblock: BlockNode,\n\tfrom: number,\n\tto: number,\n\tvisitor: BlockRangeVisitor,\n): void {\n\tfor (const { child, from: childFrom, to: childEnd } of walkInlineContent(\n\t\tgetInlineChildren(block),\n\t)) {\n\t\tif (childEnd <= from || childFrom >= to) continue;\n\n\t\tif (isInlineNode(child)) {\n\t\t\tvisitor.onInline?.(child);\n\t\t} else {\n\t\t\tconst sliceFrom: number = Math.max(0, from - childFrom);\n\t\t\tconst sliceTo: number = Math.min(child.text.length, to - childFrom);\n\t\t\tconst text: string = child.text.slice(sliceFrom, sliceTo);\n\t\t\tif (text.length > 0) {\n\t\t\t\tvisitor.onText(text, child.marks);\n\t\t\t}\n\t\t}\n\t}\n}\n\n// --- Type Guards ---\n\n/** Checks whether a value is a {@link TextNode}. */\nexport function isTextNode(node: unknown): node is TextNode {\n\treturn (\n\t\ttypeof node === 'object' &&\n\t\tnode !== null &&\n\t\t(node as TextNode).type === 'text' &&\n\t\ttypeof (node as TextNode).text === 'string'\n\t);\n}\n\n/** Checks whether a value is an {@link InlineNode}. */\nexport function isInlineNode(node: unknown): node is InlineNode {\n\treturn (\n\t\ttypeof node === 'object' &&\n\t\tnode !== null &&\n\t\t(node as InlineNode).type === 'inline' &&\n\t\ttypeof (node as InlineNode).inlineType === 'string'\n\t);\n}\n\n/** Checks whether a value is a {@link BlockNode}. */\nexport function isBlockNode(node: unknown): node is BlockNode {\n\treturn (\n\t\ttypeof node === 'object' &&\n\t\tnode !== null &&\n\t\ttypeof (node as BlockNode).id === 'string' &&\n\t\ttypeof (node as BlockNode).type === 'string' &&\n\t\t(node as BlockNode).type !== ('text' as string) &&\n\t\t(node as BlockNode).type !== ('inline' as string) &&\n\t\tArray.isArray((node as BlockNode).children)\n\t);\n}\n\n// --- Child Node Helpers ---\n\n/** Returns true if a block has only inline content (TextNodes and InlineNodes). */\nexport function isLeafBlock(node: BlockNode): boolean {\n\treturn node.children.every((c) => isTextNode(c) || isInlineNode(c));\n}\n\n/** Returns only the TextNode children of a block. */\nexport function getTextChildren(node: BlockNode): readonly TextNode[] {\n\treturn node.children.filter((c): c is TextNode => isTextNode(c));\n}\n\n/** Returns the inline content children (TextNode | InlineNode) of a block. */\nexport function getInlineChildren(node: BlockNode): readonly (TextNode | InlineNode)[] {\n\treturn node.children.filter((c): c is TextNode | InlineNode => isTextNode(c) || isInlineNode(c));\n}\n\n/** Returns only the BlockNode children of a block. */\nexport function getBlockChildren(node: BlockNode): readonly BlockNode[] {\n\treturn node.children.filter((c): c is BlockNode => isBlockNode(c));\n}\n\n// --- Factory Functions ---\n\n/** Generates a unique block ID using crypto.randomUUID(). */\nexport function generateBlockId(): BlockId {\n\treturn `block-${crypto.randomUUID()}` as BlockId;\n}\n\n/** Creates a new empty {@link Document} with a single empty paragraph. */\nexport function createDocument(children?: readonly BlockNode[]): Document {\n\treturn {\n\t\tchildren: children ?? [createBlockNode('paragraph' as NodeTypeName)],\n\t};\n}\n\n/** Creates a new {@link BlockNode}. */\nexport function createBlockNode(\n\ttype: NodeTypeName,\n\tchildren?: readonly ChildNode[],\n\tid?: BlockId,\n\tattrs?: BlockAttrs,\n\thtmlId?: string,\n): BlockNode {\n\tconst normalizedHTMLId: string | undefined = normalizeHTMLId(htmlId);\n\treturn {\n\t\tid: id ?? generateBlockId(),\n\t\t...(normalizedHTMLId ? { htmlId: normalizedHTMLId } : {}),\n\t\ttype,\n\t\t...(attrs ? { attrs } : {}),\n\t\tchildren: children ?? [createTextNode('')],\n\t};\n}\n\n/** Creates a new {@link TextNode}. */\nexport function createTextNode(text: string, marks?: readonly Mark[]): TextNode {\n\treturn {\n\t\ttype: 'text',\n\t\ttext,\n\t\tmarks: marks ?? [],\n\t};\n}\n\n/** Creates a new {@link InlineNode}. */\nexport function createInlineNode(\n\tinlineType: InlineTypeName,\n\tattrs?: Readonly<Record<string, string | number | boolean>>,\n\tmarks?: readonly Mark[],\n): InlineNode {\n\treturn {\n\t\ttype: 'inline',\n\t\tinlineType,\n\t\tattrs: attrs ?? {},\n\t\tmarks: marks ?? [],\n\t};\n}\n\n/** Creates an empty paragraph block node with the given ID. */\nexport function createEmptyParagraph(id?: BlockId): BlockNode {\n\treturn createBlockNode('paragraph' as NodeTypeName, [createTextNode('')], id);\n}\n\n// --- Utility Functions ---\n\n/** Extracts plain text from a block (InlineNodes are skipped). */\nexport function getBlockText(block: BlockNode): string {\n\tconst inlineChildren: readonly (TextNode | InlineNode)[] = getInlineChildren(block);\n\tlet text = '';\n\tfor (const child of inlineChildren) {\n\t\tif (isTextNode(child)) {\n\t\t\ttext += child.text;\n\t\t}\n\t}\n\treturn text;\n}\n\n/** Returns the length of a block's inline content (InlineNodes count as 1). */\nexport function getBlockLength(block: BlockNode): number {\n\tlet len = 0;\n\tfor (const { to } of walkInlineContent(getInlineChildren(block))) {\n\t\tlen = to;\n\t}\n\treturn len;\n}\n\n/** Returns the marks active at the given offset (empty for InlineNode offsets). */\nexport function getBlockMarksAtOffset(block: BlockNode, offset: number): readonly Mark[] {\n\tconst inlineChildren: readonly (TextNode | InlineNode)[] = getInlineChildren(block);\n\n\tfor (const { child, from, to } of walkInlineContent(inlineChildren)) {\n\t\tif (isInlineNode(child)) {\n\t\t\tif (offset === from) return [];\n\t\t\tcontinue;\n\t\t}\n\t\tif (offset >= from && offset < to) {\n\t\t\treturn child.marks;\n\t\t}\n\t\t// Empty text node (from === to): match exactly at its position.\n\t\tif (offset === from && child.text.length === 0) {\n\t\t\treturn child.marks;\n\t\t}\n\t}\n\n\t// Fall back to last text child's marks\n\tfor (let i: number = inlineChildren.length - 1; i >= 0; i--) {\n\t\tconst child: TextNode | InlineNode | undefined = inlineChildren[i];\n\t\tif (child && isTextNode(child)) {\n\t\t\treturn child.marks;\n\t\t}\n\t}\n\treturn [];\n}\n\n/** Returns the marks of the text content immediately to the right of `offset`. */\nfunction getMarksAfterOffset(block: BlockNode, offset: number): readonly Mark[] {\n\tfor (const { child, from, to } of walkInlineContent(getInlineChildren(block))) {\n\t\tif (isInlineNode(child)) {\n\t\t\tif (offset === from) return [];\n\t\t\tcontinue;\n\t\t}\n\t\tif (offset >= from && offset < to) return child.marks;\n\t}\n\treturn [];\n}\n\n/**\n * Returns the marks that text typed at a collapsed cursor should carry.\n *\n * Marks are derived from the content around `offset` (via\n * {@link getBlockMarksAtOffset}). A mark whose spec is non-inclusive\n * (`isMarkInclusive` returns `false`) is only kept when it also covers the\n * content to the right of the cursor, so it never bleeds past its right\n * boundary onto newly typed text. Inclusive marks (the default) are unaffected.\n */\nexport function getCursorMarks(\n\tblock: BlockNode,\n\toffset: number,\n\tisMarkInclusive: (type: MarkTypeName) => boolean,\n): readonly Mark[] {\n\tconst marks: readonly Mark[] = getBlockMarksAtOffset(block, offset);\n\tif (marks.length === 0) return marks;\n\n\tconst after: readonly Mark[] = getMarksAfterOffset(block, offset);\n\treturn marks.filter(\n\t\t(mark) => isMarkInclusive(mark.type) || after.some((a) => marksEqual(a, mark)),\n\t);\n}\n\n/** Checks whether two marks are equal by type and attrs. */\nexport function marksEqual(a: Mark, b: Mark): boolean {\n\tif (a.type !== b.type) return false;\n\tconst aAttrs = a.attrs;\n\tconst bAttrs = b.attrs;\n\tif (!aAttrs && !bAttrs) return true;\n\tif (!aAttrs || !bAttrs) return false;\n\tconst aKeys = Object.keys(aAttrs);\n\tconst bKeys = Object.keys(bAttrs);\n\tif (aKeys.length !== bKeys.length) return false;\n\treturn aKeys.every((key) => aAttrs[key] === bAttrs[key]);\n}\n\n/** Deep equality for immutable, JSON-compatible block attribute values. */\nexport function blockAttrValuesEqual(\n\ta: BlockAttrValue | undefined,\n\tb: BlockAttrValue | undefined,\n): boolean {\n\tif (a === b) return true;\n\tif (a === undefined || b === undefined || a === null || b === null) return false;\n\tif (Array.isArray(a) || Array.isArray(b)) {\n\t\tif (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;\n\t\treturn a.every((value, index) => value === b[index]);\n\t}\n\treturn false;\n}\n\n/** Deep equality for block attribute records. */\nexport function blockAttrsEqual(a: BlockAttrs | undefined, b: BlockAttrs | undefined): boolean {\n\tif (a === b) return true;\n\tif (!a || !b) return false;\n\tconst aKeys: readonly string[] = Object.keys(a);\n\tconst bKeys: readonly string[] = Object.keys(b);\n\tif (aKeys.length !== bKeys.length) return false;\n\treturn aKeys.every((key) => blockAttrValuesEqual(a[key], b[key]));\n}\n\n/** Checks whether two mark arrays contain the same marks (order-independent). */\nexport function markSetsEqual(a: readonly Mark[], b: readonly Mark[]): boolean {\n\tif (a.length !== b.length) return false;\n\treturn a.every((markA) => b.some((markB) => marksEqual(markA, markB)));\n}\n\n/** Returns true if the mark set contains a mark of the given type. */\nexport function hasMark(marks: readonly Mark[], markType: MarkTypeName): boolean {\n\treturn marks.some((m) => m.type === markType);\n}\n\n/** Adds a mark to a mark set (no duplicates). */\nexport function addMarkToSet(marks: readonly Mark[], mark: Mark): readonly Mark[] {\n\tif (hasMark(marks, mark.type)) return marks;\n\treturn [...marks, mark];\n}\n\n/** Removes a mark type from a mark set. */\nexport function removeMarkFromSet(marks: readonly Mark[], markType: MarkTypeName): readonly Mark[] {\n\treturn marks.filter((m) => m.type !== markType);\n}\n\n/**\n * Normalizes text nodes within a block: merges adjacent nodes with identical marks,\n * removes empty text nodes (keeping at least one).\n */\nexport function normalizeTextNodes(nodes: readonly TextNode[]): readonly TextNode[] {\n\tif (nodes.length === 0) return [createTextNode('')];\n\n\tconst result: TextNode[] = [];\n\tfor (const node of nodes) {\n\t\tconst prev: TextNode | undefined = result[result.length - 1];\n\t\tif (prev && markSetsEqual(prev.marks, node.marks)) {\n\t\t\tresult[result.length - 1] = createTextNode(prev.text + node.text, prev.marks);\n\t\t} else if (node.text.length > 0 || result.length === 0) {\n\t\t\tresult.push(node);\n\t\t}\n\t}\n\n\treturn result.length === 0 ? [createTextNode('')] : result;\n}\n\n/**\n * Normalizes mixed inline content: merges adjacent TextNodes with same marks,\n * removes empty TextNodes adjacent to InlineNodes, preserves InlineNodes as-is.\n * Guarantees at least one TextNode exists if all text is empty.\n */\nexport function normalizeInlineContent(\n\tnodes: readonly (TextNode | InlineNode)[],\n): readonly (TextNode | InlineNode)[] {\n\tif (nodes.length === 0) return [createTextNode('')];\n\n\t// Fast path: no InlineNodes, delegate to normalizeTextNodes\n\tif (nodes.every((n): n is TextNode => isTextNode(n))) {\n\t\treturn normalizeTextNodes(nodes);\n\t}\n\n\tconst result: (TextNode | InlineNode)[] = [];\n\n\tfor (const node of nodes) {\n\t\tif (isInlineNode(node)) {\n\t\t\tresult.push(node);\n\t\t\tcontinue;\n\t\t}\n\t\t// TextNode: try to merge with previous TextNode\n\t\tconst prev: TextNode | InlineNode | undefined = result[result.length - 1];\n\t\tif (prev && isTextNode(prev) && markSetsEqual(prev.marks, node.marks)) {\n\t\t\tresult[result.length - 1] = createTextNode(prev.text + node.text, prev.marks);\n\t\t} else if (node.text.length > 0 || result.length === 0) {\n\t\t\tresult.push(node);\n\t\t}\n\t}\n\n\t// Remove empty TextNodes that are adjacent to InlineNodes\n\tconst cleaned: (TextNode | InlineNode)[] = result.filter((node, i) => {\n\t\tif (isInlineNode(node)) return true;\n\t\tif (node.text.length > 0) return true;\n\t\t// Keep if it's the only node\n\t\tif (result.length === 1) return true;\n\t\t// Remove empty TextNode if adjacent to InlineNode\n\t\tconst prev: TextNode | InlineNode | undefined = result[i - 1];\n\t\tconst next: TextNode | InlineNode | undefined = result[i + 1];\n\t\tif ((prev && isInlineNode(prev)) || (next && isInlineNode(next))) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t});\n\n\t// Ensure at least one TextNode exists\n\tif (cleaned.length === 0) return [createTextNode('')];\n\tif (!cleaned.some((n) => isTextNode(n))) {\n\t\treturn [createTextNode(''), ...cleaned];\n\t}\n\n\treturn cleaned;\n}\n\n/** Materializes a single {@link ContentSegment} into its inline child node. */\nexport function contentSegmentToInlineNode(segment: ContentSegment): TextNode | InlineNode {\n\treturn segment.kind === 'inline' ? segment.node : createTextNode(segment.text, segment.marks);\n}\n\n/**\n * Materializes content segments (text + inline) into normalized inline children.\n * Inverse of {@link getBlockContentSegmentsInRange}: used when turning a range of\n * segments back into a block's children (paste insertion, slice extraction).\n */\nexport function segmentsToInlineChildren(\n\tsegments: readonly ContentSegment[],\n): readonly (TextNode | InlineNode)[] {\n\treturn normalizeInlineContent(segments.map(contentSegmentToInlineNode));\n}\n\n/** Yields each inline child with its offset range. InlineNodes have width 1. */\nexport function* walkInlineContent(children: readonly (TextNode | InlineNode)[]): Generator<{\n\treadonly child: TextNode | InlineNode;\n\treadonly from: number;\n\treadonly to: number;\n}> {\n\tlet pos = 0;\n\tfor (const child of children) {\n\t\tconst width: number = isInlineNode(child) ? 1 : child.text.length;\n\t\tyield { child, from: pos, to: pos + width };\n\t\tpos += width;\n\t}\n}\n\n/**\n * Converts a block-space offset to a text-space offset.\n *\n * Block-space counts InlineNodes as width 1, but `getBlockText()` skips them.\n * This function maps a block offset to the equivalent position in the\n * text-only string returned by `getBlockText()`.\n */\nexport function blockOffsetToTextOffset(block: BlockNode, blockOffset: number): number {\n\tlet textPos = 0;\n\n\tfor (const { child, from, to } of walkInlineContent(getInlineChildren(block))) {\n\t\tif (isInlineNode(child)) {\n\t\t\tif (from >= blockOffset) return textPos;\n\t\t} else {\n\t\t\tif (to >= blockOffset) return textPos + (blockOffset - from);\n\t\t\ttextPos += child.text.length;\n\t\t}\n\t}\n\n\treturn textPos;\n}\n\n/** Returns the content at a specific offset: text char, inline node, or null. */\nexport function getContentAtOffset(\n\tblock: BlockNode,\n\toffset: number,\n):\n\t| { readonly kind: 'text'; readonly char: string; readonly marks: readonly Mark[] }\n\t| { readonly kind: 'inline'; readonly node: InlineNode }\n\t| null {\n\tconst inlineChildren: readonly (TextNode | InlineNode)[] = getInlineChildren(block);\n\n\tfor (const { child, from } of walkInlineContent(inlineChildren)) {\n\t\tif (isInlineNode(child)) {\n\t\t\tif (offset === from) return { kind: 'inline', node: child };\n\t\t\tcontinue;\n\t\t}\n\t\tconst localOffset: number = offset - from;\n\t\tif (localOffset >= 0 && localOffset < child.text.length) {\n\t\t\treturn {\n\t\t\t\tkind: 'text',\n\t\t\t\tchar: child.text[localOffset] ?? '',\n\t\t\t\tmarks: child.marks,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn null;\n}\n"],"mappings":"6CAiGA,SAAgB,EAAY,EAAc,EAAyB,IAClE,MAAO,CAAE,KAAM,OAAQ,OAAM,QAC9B,CAGA,SAAgB,EAAc,GAC7B,MAAO,CAAE,KAAM,SAAU,OAC1B,CAGA,SAAgB,EACf,EACA,EACA,GAEA,MAAM,EAA6B,GASnC,OARA,EAA0B,EAAO,EAAM,EAAI,CAC1C,MAAA,CAAO,EAAc,GACpB,EAAS,KAAK,CAAE,KAAM,OAAQ,OAAM,SACrC,EACA,QAAA,CAAS,GACR,EAAS,KAAK,CAAE,KAAM,SAAU,QACjC,IAEM,CACR,CAgBA,SAAgB,EACf,EACA,EACA,EACA,GAEA,IAAK,MAAM,MAAE,EAAO,KAAM,EAAW,GAAI,KAAc,EACtD,EAAkB,IAElB,KAAI,GAAY,GAAQ,GAAa,GAErC,GAAI,EAAa,GAChB,EAAQ,WAAW,OACb,CACN,MAAM,EAAoB,KAAK,IAAI,EAAG,EAAO,GACvC,EAAkB,KAAK,IAAI,EAAM,KAAK,OAAQ,EAAK,GACnD,EAAe,EAAM,KAAK,MAAM,EAAW,GAC7C,EAAK,OAAS,GACjB,EAAQ,OAAO,EAAM,EAAM,MAE7B,CAEF,CAKA,SAAgB,EAAW,GAC1B,MACiB,iBAAT,GACE,OAAT,GAC4B,SAA3B,EAAkB,MACgB,iBAA3B,EAAkB,IAE5B,CAGA,SAAgB,EAAa,GAC5B,MACiB,iBAAT,GACE,OAAT,GAC8B,WAA7B,EAAoB,MACsB,iBA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B,GACzD,IAAI,EAAU,EAEd,IAAK,MAAM,MAAE,EAAA,KAAO,EAAA,GAAM,KAAQ,EAAkB,EAAkB,IACrE,GAAI,EAAa,OACZ,GAAQ,EAAa,OAAO,MAC1B,CACN,GAAI,GAAM,EAAa,OAAO,GAAW,EAAc,GACvD,GAAW,EAAM,KAAK,MACvB,CAGD,OAAO,CACR,CAGA,SAAgB,EACf,EACA,GAKA,MAAM,EAAqD,EAAkB,GAE7E,IAAK,MAAM,MAAE,EAAA,KAAO,KAAU,EAAkB,GAAiB,CAChE,GAAI,EAAa,GAAQ,CACxB,GAAI,IAAW,EAAM,MAAO,CAAE,KAAM,SAAU,KAAM,GACpD,QACD,CACA,MAAM,EAAsB,EAAS,EACrC,GAAI,GAAe,GAAK,EAAc,EAAM,KAAK,OAChD,MAAO,CACN,KAAM,OACN,KAAM,EAAM,KAAK,IAAgB,GACjC,MAAO,EAAM,MAGhB,CAEA,OAAO,IACR"}
@@ -1,2 +0,0 @@
1
- import{o as t,t as e}from"./HTMLUtils-Bhg3_P8B.mjs";import{T as o,b as n,l as r,o as s,s as i,u as a}from"./Document-827l3P80.mjs";import{a as c,i as l,r as u}from"./TypeBrands-Ch9856Gb.mjs";import{n as f}from"./ContentModel-NpAj7vGW.mjs";import{b as d,c as p,f as h,n as g,o as y,p as m,r as A,s as N,t as T,y as E}from"./TableDimensions-BBhjHNjQ.mjs";import b from"dompurify";var L=/[ \t\n\r\f]+/g,O=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","UL","OL","LI","TABLE","THEAD","TBODY","TFOOT","TR","TD","TH","HR","FIGURE","FIGCAPTION","SECTION","ARTICLE","HEADER","FOOTER","MAIN","ASIDE","NAV","DL","DT","DD"]),w=new Set(["PRE","TEXTAREA"]),v=new Set(["pre","pre-wrap","pre-line","break-spaces"]);function D(t){k(t)}function k(t){const e={lastTextNode:null,collapsePending:!0};for(const o of Array.from(t.childNodes))C(o,e);x(e.lastTextNode)}function C(t,e){if(t.nodeType===Node.TEXT_NODE)return void function(t,e){let o=t.data.replace(L," ");e.collapsePending&&o.startsWith(" ")&&(o=o.slice(1)),t.data=o,0!==o.length&&(e.collapsePending=o.endsWith(" "),e.lastTextNode=t)}(t,e);if(t.nodeType!==Node.ELEMENT_NODE)return;const o=t;if(function(t){if(w.has(t.tagName))return!0;const e=(t.style?.whiteSpace??"").toLowerCase();return v.has(e)}(o))_(e);else{if(function(t){return O.has(t.tagName)}(o))return _(e),void k(o);for(const t of Array.from(o.childNodes))C(t,e)}}function _(t){x(t.lastTextNode),t.lastTextNode=null,t.collapsePending=!0}function x(t){t?.data.endsWith(" ")&&(t.data=t.data.slice(0,-1))}function R(t,o,n){const r=o?o.getAllowedTags():["p","br","div","span"],s=o?o.getAllowedAttrs():["style","dir","id"];s.includes("data-block-id")||s.push("data-block-id"),n?.styleMap&&!s.includes("class")&&s.push("class");const a=document.createElement("template");a.innerHTML=b.sanitize(t,{ALLOWED_TAGS:r,ALLOWED_ATTR:s,ALLOWED_URI_REGEXP:e,...E()});const c=a.content;n?.styleMap&&function(t,e){const o=t.querySelectorAll("[class]");for(const n of Array.from(o)){const t=n,o=Array.from(t.classList),r=[];for(const n of o){const o=e.get(n);if(o){const e=t.getAttribute("style")??"",s=e&&!e.endsWith(";")?"; ":"";t.setAttribute("style",e+s+o),r.push(n)}}for(const e of r)t.classList.remove(e)}}(c,n.styleMap),D(c);const l=o?.getBlockParseRules()??[],u=[],d=/* @__PURE__ */new Set;for(const e of Array.from(c.childNodes))M(e,u,l,d,o);if(0===u.length)return i();const p=i(u);return o?f(p,o):p}function M(t,e,o,n,r){if(t.nodeType===Node.ELEMENT_NODE){const i=t,l=i.tagName.toLowerCase();if("ul"===l||"ol"===l){const t="ol"===l?"ordered":"bullet",o=i.getAttribute("dir");return void P(i,t,0,e,n,r,o&&m.has(o)?o:void 0)}if("table"===l)return void function(t,e,o,n){const r=[],i=function(t){const e=[];for(const o of Array.from(t.children)){const t=o.tagName.toLowerCase();if("col"===t){j(o,void 0,e);continue}if("colgroup"!==t)continue;const n=o,r=S(n),s=Array.from(n.children).filter(t=>"col"===t.tagName.toLowerCase());if(0!==s.length)for(const o of s)j(o,r,e);else I(r,N(n.getAttribute("span")),e)}return y(e)}(t),a=function(t){const e=[];for(const o of Array.from(t.children)){const t=o.tagName.toLowerCase();if("tr"===t)e.push(o);else if("thead"===t||"tbody"===t||"tfoot"===t)for(const n of Array.from(o.children))"tr"===n.tagName.toLowerCase()&&e.push(n)}return e}(t);for(const l of a){const t=[];for(const r of Array.from(l.children)){const e=r.tagName.toLowerCase();if("td"!==e&&"th"!==e)continue;const i=r,a=q(i,o,n),l={};X(i,l);const u=s(c("table_cell"),a,d(i,o),Object.keys(l).length>0?l:void 0,Q(i));t.push(u)}const e={};B(l,e),r.push(s(c("table_row"),t,d(l,o),Object.keys(e).length>0?e:void 0,Q(l)))}if(r.length>0){const n={};!function(t,e){const o=t.getAttribute("style")??"",n=W.exec(o);n?.[1]&&(e.borderColor="transparent"===n[1]?"none":n[1])}(t,n),i&&(n.columnWidthsPx=i),e.push(s(c("table"),r,d(t,o),Object.keys(n).length>0?n:void 0,Q(t)))}}(i,e,n,r);if("blockquote"===l)return void function(t,e,o,n){const r=F(t,n?.getBlockParseRules()??[],o,n);0===r.length&&r.push(s(c("paragraph"),[a("")]));const i={};$(t,i),K(t,i),e.push(s(c("blockquote"),r,d(t,o),Object.keys(i).length>0?i:void 0,Q(t)))}(i,e,n,r);const u=J(i,o);if(u){const t=r?.getNodeSpec(u.type),o=t?.isVoid?[a("")]:G(i,r),l={...u.attrs};return t?.attrs?.align&&$(i,l),t?.attrs?.dir&&K(i,l),void e.push(s(c(u.type),o,d(i,n),Object.keys(l).length>0?l:void 0,Q(i)))}const f=G(i,r),p={};$(i,p),K(i,p),e.push(s(c("paragraph"),f,d(i,n),Object.keys(p).length>0?p:void 0,Q(i)))}else t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()&&e.push(s(c("paragraph"),[a(t.textContent.trim())]))}function P(t,e,o,n,r,s,i){for(const a of Array.from(t.children)){const t=a.tagName.toLowerCase();if("li"===t){const t=a,c=t.querySelector(':scope > input[type="checkbox"]'),l={listType:null!==c?"checklist":e,indent:o,checked:c?.hasAttribute("checked")??!1},u=t.getAttribute("dir"),f=u&&m.has(u)?u:i;f&&(l.dir=f),n.push(H(t,l,r,c,s));for(const e of Array.from(t.children)){const t=e.tagName.toLowerCase();if("ul"===t||"ol"===t){const i="ol"===t?"ordered":"bullet",a=e.getAttribute("dir");P(e,i,o+1,n,r,s,a&&m.has(a)?a:f)}}}else if("ul"===t||"ol"===t){const e="ol"===t?"ordered":"bullet",c=a.getAttribute("dir");P(a,e,o+1,n,r,s,c&&m.has(c)?c:i)}}}function H(t,e,o,r,i){const l=Q(t),u=i?.getBlockParseRules()??[],f=t=>{if(t.nodeType!==Node.ELEMENT_NODE)return!1;const e=t.tagName.toLowerCase();return"ul"===e||"ol"===e};if(!Array.from(t.childNodes).some(t=>!f(t)&&U(t,u))){const n=G(t,i,!0);return s(c("list_item"),n,d(t,o),e,l)}const p=F(t,u,o,i,t=>f(t)||t===r),h=1===p.length?p[0]:void 0;return!h||"paragraph"!==h.type||h.attrs||h.htmlId?0===p.length?s(c("list_item"),[a("")],d(t,o),e,l):s(c("list_item"),p,d(t,o),e,l):s(c("list_item"),n(h),d(t,o),e,l)}function j(t,e,o){I(S(t)??e,N(t.getAttribute("span")),o)}function I(t,e,o){const n=T-o.length,r=Math.min(e,Math.max(0,n));for(let s=0;s<r;s++)o.push(t??null)}function S(t){return p(t,g,["width"],"width")}function B(t,e){const o=p(t,A,["min-height","height"],"height");void 0!==o&&(e.minHeightPx=o)}var W=/--ntbl-bc:\s*(#[0-9a-fA-F]{3,8}|transparent)/;function X(t,e){const o=t.getAttribute("colspan");if(o){const t=N(o);t>1&&(e.colspan=t)}const n=t.getAttribute("rowspan");if(n){const t=N(n);t>1&&(e.rowspan=t)}}function q(t,e,o){const n=F(t,o?.getBlockParseRules()??[],e,o);return 0===n.length&&n.push(s(c("paragraph"),[a("")])),n}function F(t,e,o,n,r){const i=[];let a=[];const l=()=>{(function(t){for(const e of t){if(e.nodeType===Node.ELEMENT_NODE)return!0;if(e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())return!0}return!1})(a)&&i.push(s(c("paragraph"),V(a,n))),a=[]};for(const s of Array.from(t.childNodes))r?.(s)||(U(s,e)?(l(),M(s,i,e,o,n)):a.push(s));return l(),i}function U(t,e){if(t.nodeType!==Node.ELEMENT_NODE)return!1;const o=t,n=o.tagName.toLowerCase();return"p"===n||"ul"===n||"ol"===n||"table"===n||"blockquote"===n||null!==J(o,e)}function G(t,e,o){return V([t],e,o)}function V(t,e,n){const r=[],s=e?.getMarkParseRules()??[],i=e?.getInlineParseRules()??[];for(const o of t)z(o,[],r,s,i,n);return 1===r.length&&o(r[0])&&"hard_break"===r[0].inlineType?[a("")]:r.length>0?r:[a("")]}function z(t,e,o,n,s,i){if(t.nodeType===Node.TEXT_NODE){const n=t.textContent??"";return void(n&&o.push(a(n,[...e])))}if(t.nodeType!==Node.ELEMENT_NODE)return;const c=t,f=c.tagName.toLowerCase();if(i&&("ul"===f||"ol"===f))return;if(i&&"input"===f&&"checkbox"===c.getAttribute("type"))return;for(const a of s)if(a.rule.tag===f){if(a.rule.getAttrs){const t=a.rule.getAttrs(c);if(!1===t)continue;return void o.push(r(u(a.type),t,[...e]))}return void o.push(r(u(a.type),void 0,[...e]))}const d=[...e],p=/* @__PURE__ */new Set;for(const r of n)if(r.rule.tag===f&&!p.has(r.type))if(r.rule.getAttrs){const t=r.rule.getAttrs(c);if(!1===t)continue;d.some(t=>t.type===r.type)||(d.push({type:l(r.type),...Object.keys(t).length>0?{attrs:t}:{}}),p.add(r.type))}else d.some(t=>t.type===r.type)||(d.push({type:l(r.type)}),p.add(r.type));for(const r of Array.from(c.childNodes))z(r,d,o,n,s,i)}function K(t,e){const o=t.getAttribute("dir");if(o&&m.has(o))return void(e.dir=o);const n=t.style?.direction??"";n&&m.has(n)&&(e.dir=n)}function Q(e){return t(e.getAttribute("id"))}var Y={left:"start",right:"end"};function $(t,e){let o=t.style?.textAlign??"";const n=Y[o];if(n&&(o=n),o&&h.has(o))e.align=o;else for(const r of Array.from(t.classList)){let t=r.match(/^notectl-align-(\w+)$/)?.[1];const o=Y[t??""];if(o&&(t=o),t&&h.has(t))return void(e.align=t)}}function J(t,e){const o=t.tagName.toLowerCase();for(const n of e)if(n.rule.tag===o){if(n.rule.getAttrs){const e=n.rule.getAttrs(t);if(!1===e)continue;return{type:n.type,attrs:e}}return{type:n.type}}return null}export{D as n,R as t};
2
- //# sourceMappingURL=DocumentParser-D2tr3ZKn.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DocumentParser-D2tr3ZKn.mjs","names":[],"sources":["../../src/serialization/HTMLWhitespace.ts","../../src/serialization/DocumentParser.ts"],"sourcesContent":["/**\n * HTML whitespace normalization, shared by the paste parser (`HTMLParser`) and the\n * `setContentHTML` parser (`DocumentParser`).\n *\n * Per the CSS Text / HTML whitespace processing model for `white-space: normal`,\n * whitespace in normal flow content is *insignificant*: runs of ASCII whitespace\n * (space, tab, line feed, carriage return, form feed) collapse to a single space,\n * and whitespace at the edges of a block collapses away entirely. Only `<br>` is a\n * real line break. Source-formatted HTML (server-rendered, hand-indented, or\n * hard-wrapped by a browser's clipboard serializer) therefore carries newlines and\n * indentation that must NOT survive parsing.\n *\n * This pass rewrites text-node data in place so both parsers can walk a tree whose\n * whitespace already matches what a browser would render. It only touches\n * `Text.data`; marks, block ids, and attributes are left untouched.\n */\n\n/**\n * ASCII whitespace per the HTML spec. Deliberately NOT `\\s`: `\\s` also matches\n * non-breaking space (` `) and other Unicode spaces, which are significant\n * content and must be preserved verbatim.\n */\nconst COLLAPSIBLE_WHITESPACE: RegExp = /[ \\t\\n\\r\\f]+/g;\n\n/**\n * Tags that establish a block formatting context in normal flow. Each starts a\n * fresh inline run whose leading/trailing whitespace is trimmed independently.\n * Self-contained (not coupled to the parsers' tag sets); unknown tags are treated\n * as inline.\n */\nconst FLOW_BLOCK_TAGS: ReadonlySet<string> = new Set([\n\t'P',\n\t'DIV',\n\t'H1',\n\t'H2',\n\t'H3',\n\t'H4',\n\t'H5',\n\t'H6',\n\t'BLOCKQUOTE',\n\t'UL',\n\t'OL',\n\t'LI',\n\t'TABLE',\n\t'THEAD',\n\t'TBODY',\n\t'TFOOT',\n\t'TR',\n\t'TD',\n\t'TH',\n\t'HR',\n\t'FIGURE',\n\t'FIGCAPTION',\n\t'SECTION',\n\t'ARTICLE',\n\t'HEADER',\n\t'FOOTER',\n\t'MAIN',\n\t'ASIDE',\n\t'NAV',\n\t'DL',\n\t'DT',\n\t'DD',\n]);\n\n/** Tags whose descendant whitespace is significant and must be preserved verbatim. */\nconst PRESERVE_TAGS: ReadonlySet<string> = new Set(['PRE', 'TEXTAREA']);\n\n/** `white-space` values that preserve whitespace (the `pre*` family). */\nconst PRESERVE_WHITESPACE_VALUES: ReadonlySet<string> = new Set([\n\t'pre',\n\t'pre-wrap',\n\t'pre-line',\n\t'break-spaces',\n]);\n\n/** Mutable state threaded through a single inline formatting context. */\ninterface CollapseState {\n\t/** Most recent non-empty text node in this context, for trailing-space trimming. */\n\tlastTextNode: Text | null;\n\t/**\n\t * Whether a leading space on the next text node should be dropped. True at the\n\t * start of a context and after any text node that ended with a space.\n\t */\n\tcollapsePending: boolean;\n}\n\n/**\n * Collapses insignificant HTML whitespace throughout `root`, mutating text-node\n * data in place. Call once on a (disposable) parsed fragment before walking it.\n */\nexport function normalizeHTMLWhitespace(root: DocumentFragment | HTMLElement): void {\n\tnormalizeContext(root);\n}\n\n/** Processes one inline formatting context, then trims its trailing whitespace. */\nfunction normalizeContext(container: DocumentFragment | HTMLElement): void {\n\tconst state: CollapseState = { lastTextNode: null, collapsePending: true };\n\tfor (const child of Array.from(container.childNodes)) {\n\t\tprocessNode(child, state);\n\t}\n\ttrimTrailingSpace(state.lastTextNode);\n}\n\nfunction processNode(node: ChildNode, state: CollapseState): void {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\tcollapseTextNode(node as Text, state);\n\t\treturn;\n\t}\n\tif (node.nodeType !== Node.ELEMENT_NODE) return;\n\n\tconst el = node as HTMLElement;\n\n\t// Whitespace-preserving subtree (code blocks etc.): end the current inline run\n\t// and leave the subtree untouched.\n\tif (isPreserveElement(el)) {\n\t\tendInlineRun(state);\n\t\treturn;\n\t}\n\n\t// Block element: the current inline run ends here; recurse as a fresh context.\n\tif (isFlowBlockElement(el)) {\n\t\tendInlineRun(state);\n\t\tnormalizeContext(el);\n\t\treturn;\n\t}\n\n\t// Inline element: keep collapsing within the same context.\n\tfor (const child of Array.from(el.childNodes)) {\n\t\tprocessNode(child, state);\n\t}\n}\n\n/** Collapses whitespace runs in a text node and drops a leading space when pending. */\nfunction collapseTextNode(text: Text, state: CollapseState): void {\n\tlet data: string = text.data.replace(COLLAPSIBLE_WHITESPACE, ' ');\n\tif (state.collapsePending && data.startsWith(' ')) {\n\t\tdata = data.slice(1);\n\t}\n\ttext.data = data;\n\n\t// Fully collapsed away (e.g. a whitespace-only node): leave `collapsePending` as\n\t// is so a later node still drops its leading space.\n\tif (data.length === 0) return;\n\n\tstate.collapsePending = data.endsWith(' ');\n\tstate.lastTextNode = text;\n}\n\n/** Ends the current inline run at a block/preserve boundary and resets state. */\nfunction endInlineRun(state: CollapseState): void {\n\ttrimTrailingSpace(state.lastTextNode);\n\tstate.lastTextNode = null;\n\tstate.collapsePending = true;\n}\n\n/** Removes the single (already-collapsed) trailing space from a text node, if any. */\nfunction trimTrailingSpace(node: Text | null): void {\n\tif (node?.data.endsWith(' ')) {\n\t\tnode.data = node.data.slice(0, -1);\n\t}\n}\n\nfunction isFlowBlockElement(el: HTMLElement): boolean {\n\treturn FLOW_BLOCK_TAGS.has(el.tagName);\n}\n\nfunction isPreserveElement(el: HTMLElement): boolean {\n\tif (PRESERVE_TAGS.has(el.tagName)) return true;\n\tconst whiteSpace: string = (el.style?.whiteSpace ?? '').toLowerCase();\n\treturn PRESERVE_WHITESPACE_VALUES.has(whiteSpace);\n}\n","/**\n * DocumentParser: converts sanitized HTML strings into immutable Document instances.\n * Pure functions — no class state, no DOM mutation beyond a temporary `<template>`.\n */\n\nimport DOMPurify from 'dompurify';\nimport { hoistDisallowedBlocks } from '../model/ContentModel.js';\nimport type {\n\tBlockAttrValue,\n\tBlockNode,\n\tDocument,\n\tInlineNode,\n\tMark,\n\tTextNode,\n} from '../model/Document.js';\nimport {\n\tcreateBlockNode,\n\tcreateDocument,\n\tcreateInlineNode,\n\tcreateTextNode,\n\tgetInlineChildren,\n\tisInlineNode,\n} from '../model/Document.js';\nimport { SAFE_URI_REGEXP, normalizeHTMLId } from '../model/HTMLUtils.js';\nimport type { ParseRule } from '../model/ParseRule.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { type InlineTypeName, inlineType, markType, nodeType } from '../model/TypeBrands.js';\nimport { adoptBlockId } from './BlockIdHTML.js';\nimport { VALID_ALIGNMENTS, VALID_DIRECTIONS } from './DocumentSerializer.js';\nimport { preserveHTMLIdSanitizeConfig } from './HTMLSanitization.js';\nimport { normalizeHTMLWhitespace } from './HTMLWhitespace.js';\nimport {\n\tMAX_SERIALIZED_TABLE_COLUMNS,\n\tTABLE_COLUMN_WIDTH_DATA_ATTRIBUTE,\n\tTABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE,\n\tnormalizeTableColumnWidthsPx,\n\tparseTableColumnSpan,\n\treadTableDimensionPx,\n} from './TableDimensions.js';\n\n/** Options for `parseHTMLToDocument` when importing class-based HTML. */\nexport interface ParseHTMLOptions {\n\t/**\n\t * Style map from a previous `getContentHTML({ cssMode: 'classes' })` call.\n\t * Used to rehydrate class-based HTML back into styled content.\n\t */\n\treadonly styleMap?: ReadonlyMap<string, string>;\n}\n\n/** Parses an HTML string into a Document, applying sanitization and schema parse rules. */\nexport function parseHTMLToDocument(\n\thtml: string,\n\tregistry?: SchemaRegistry,\n\toptions?: ParseHTMLOptions,\n): Document {\n\tconst allowedTags: string[] = registry ? registry.getAllowedTags() : ['p', 'br', 'div', 'span'];\n\tconst allowedAttrs: string[] = registry ? registry.getAllowedAttrs() : ['style', 'dir', 'id'];\n\n\t// `data-block-id` carries block identity across `setContentHTML(getContentHTML())`.\n\t// Whitelist it through DOMPurify so the adoption logic below sees it.\n\tif (!allowedAttrs.includes('data-block-id')) {\n\t\tallowedAttrs.push('data-block-id');\n\t}\n\n\t// When a styleMap is provided, also allow `class` through DOMPurify\n\t// so we can read class names and rehydrate styles before parsing.\n\tif (options?.styleMap && !allowedAttrs.includes('class')) {\n\t\tallowedAttrs.push('class');\n\t}\n\n\tconst template = document.createElement('template');\n\ttemplate.innerHTML = DOMPurify.sanitize(html, {\n\t\tALLOWED_TAGS: allowedTags,\n\t\tALLOWED_ATTR: allowedAttrs,\n\t\tALLOWED_URI_REGEXP: SAFE_URI_REGEXP,\n\t\t...preserveHTMLIdSanitizeConfig(),\n\t});\n\tconst root: DocumentFragment = template.content;\n\n\t// Rehydrate class-based HTML: convert notectl class names back to inline styles\n\tif (options?.styleMap) {\n\t\trehydrateClasses(root, options.styleMap);\n\t}\n\n\t// Collapse insignificant HTML whitespace so source-formatted/indented input does\n\t// not leave stray newlines and indentation inside block text content.\n\tnormalizeHTMLWhitespace(root);\n\n\tconst blockRules = registry?.getBlockParseRules() ?? [];\n\tconst blocks: BlockNode[] = [];\n\tconst adoptedIds = new Set<string>();\n\n\tfor (const child of Array.from(root.childNodes)) {\n\t\tparseChildNode(child, blocks, blockRules, adoptedIds, registry);\n\t}\n\n\tif (blocks.length === 0) return createDocument();\n\tconst doc: Document = createDocument(blocks);\n\t// Repair schema-invalid nesting an importer may have produced (e.g. a `<table>`\n\t// inside an `<li>` builds `list_item > table`, which the flat-with-indent item\n\t// model forbids): the disallowed block is hoisted to a valid ancestor (#194).\n\treturn registry ? hoistDisallowedBlocks(doc, registry) : doc;\n}\n\n/**\n * Parses a single child node into block(s), handling all supported block types:\n * lists, tables, block parse rules (headings, blockquotes, code blocks, images, hr),\n * and fallback paragraphs. Used by both top-level parsing and table cell content parsing.\n */\nfunction parseChildNode(\n\tchild: ChildNode,\n\tblocks: BlockNode[],\n\tblockRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n\tadoptedIds: Set<string>,\n\tregistry?: SchemaRegistry,\n): void {\n\tif (child.nodeType === Node.ELEMENT_NODE) {\n\t\tconst el = child as HTMLElement;\n\t\tconst tag: string = el.tagName.toLowerCase();\n\n\t\t// Lists need cross-element logic — handle before parse rules\n\t\tif (tag === 'ul' || tag === 'ol') {\n\t\t\tconst listType: string = tag === 'ol' ? 'ordered' : 'bullet';\n\t\t\tconst listDir: string | null = el.getAttribute('dir');\n\t\t\tconst parentDir: string | undefined =\n\t\t\t\tlistDir && VALID_DIRECTIONS.has(listDir) ? listDir : undefined;\n\t\t\tparseListElement(el, listType, 0, blocks, adoptedIds, registry, parentDir);\n\t\t\treturn;\n\t\t}\n\n\t\t// Tables produce nested block structure: table > table_row > table_cell > paragraph\n\t\tif (tag === 'table') {\n\t\t\tparseTableElement(el, blocks, adoptedIds, registry);\n\t\t\treturn;\n\t\t}\n\n\t\t// Blockquotes are container blocks (issue #136): parse their children\n\t\t// recursively into block nodes instead of flattening to inline content.\n\t\tif (tag === 'blockquote') {\n\t\t\tparseBlockquoteElement(el, blocks, adoptedIds, registry);\n\t\t\treturn;\n\t\t}\n\n\t\t// Try block parse rules\n\t\tconst match = matchBlockParseRule(el, blockRules);\n\t\tif (match) {\n\t\t\tconst spec = registry?.getNodeSpec(match.type);\n\t\t\tconst children: (TextNode | InlineNode)[] = spec?.isVoid\n\t\t\t\t? [createTextNode('')]\n\t\t\t\t: parseElementToInlineContent(el, registry);\n\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\t...(match.attrs as Record<string, string | number | boolean> | undefined),\n\t\t\t};\n\t\t\tif (spec?.attrs?.align) {\n\t\t\t\textractAlignment(el, attrs);\n\t\t\t}\n\t\t\tif (spec?.attrs?.dir) {\n\t\t\t\textractDirection(el, attrs);\n\t\t\t}\n\t\t\tblocks.push(\n\t\t\t\tcreateBlockNode(\n\t\t\t\t\tnodeType(match.type),\n\t\t\t\t\tchildren,\n\t\t\t\t\tadoptBlockId(el, adoptedIds),\n\t\t\t\t\tObject.keys(attrs).length > 0 ? attrs : undefined,\n\t\t\t\t\textractHTMLId(el),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Fallback to paragraph\n\t\tconst inlineContent = parseElementToInlineContent(el, registry);\n\t\tconst attrs: Record<string, string | number | boolean> = {};\n\t\textractAlignment(el, attrs);\n\t\textractDirection(el, attrs);\n\t\tblocks.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType('paragraph'),\n\t\t\t\tinlineContent,\n\t\t\t\tadoptBlockId(el, adoptedIds),\n\t\t\t\tObject.keys(attrs).length > 0 ? attrs : undefined,\n\t\t\t\textractHTMLId(el),\n\t\t\t),\n\t\t);\n\t} else if (child.nodeType === Node.TEXT_NODE && child.textContent?.trim()) {\n\t\tblocks.push(createBlockNode(nodeType('paragraph'), [createTextNode(child.textContent.trim())]));\n\t}\n}\n\n/**\n * Recursively parses a list element (`<ul>` or `<ol>`), creating list_item blocks\n * with correct indent depth. Handles nested lists inside `<li>` elements.\n */\nfunction parseListElement(\n\tlistEl: Element,\n\tlistType: string,\n\tdepth: number,\n\tblocks: BlockNode[],\n\tadoptedIds: Set<string>,\n\tregistry?: SchemaRegistry,\n\tparentDir?: string,\n): void {\n\tfor (const child of Array.from(listEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\n\t\tif (tag === 'li') {\n\t\t\tconst li: HTMLElement = child as HTMLElement;\n\n\t\t\t// Check for checklist: <input type=\"checkbox\">\n\t\t\tconst checkbox: HTMLInputElement | null = li.querySelector(':scope > input[type=\"checkbox\"]');\n\t\t\tconst isChecklist: boolean = checkbox !== null;\n\t\t\tconst checked: boolean = checkbox?.hasAttribute('checked') ?? false;\n\n\t\t\tconst resolvedType: string = isChecklist ? 'checklist' : listType;\n\n\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\tlistType: resolvedType,\n\t\t\t\tindent: depth,\n\t\t\t\tchecked,\n\t\t\t};\n\n\t\t\t// Propagate direction: item's own dir > parent list dir\n\t\t\tconst liDir: string | null = li.getAttribute('dir');\n\t\t\tconst effectiveDir: string | undefined =\n\t\t\t\tliDir && VALID_DIRECTIONS.has(liDir) ? liDir : parentDir;\n\t\t\tif (effectiveDir) {\n\t\t\t\tattrs.dir = effectiveDir;\n\t\t\t}\n\n\t\t\tblocks.push(parseListItemBlock(li, attrs, adoptedIds, checkbox, registry));\n\n\t\t\t// Check for nested lists inside this <li>\n\t\t\tfor (const liChild of Array.from(li.children)) {\n\t\t\t\tconst liChildTag: string = liChild.tagName.toLowerCase();\n\t\t\t\tif (liChildTag === 'ul' || liChildTag === 'ol') {\n\t\t\t\t\tconst nestedType: string = liChildTag === 'ol' ? 'ordered' : 'bullet';\n\t\t\t\t\tconst nestedDir: string | null = liChild.getAttribute('dir');\n\t\t\t\t\tconst nestedEffectiveDir: string | undefined =\n\t\t\t\t\t\tnestedDir && VALID_DIRECTIONS.has(nestedDir) ? nestedDir : effectiveDir;\n\t\t\t\t\tparseListElement(\n\t\t\t\t\t\tliChild,\n\t\t\t\t\t\tnestedType,\n\t\t\t\t\t\tdepth + 1,\n\t\t\t\t\t\tblocks,\n\t\t\t\t\t\tadoptedIds,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t\tnestedEffectiveDir,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (tag === 'ul' || tag === 'ol') {\n\t\t\t// Direct nested list without wrapping <li> — increment depth\n\t\t\tconst nestedType: string = tag === 'ol' ? 'ordered' : 'bullet';\n\t\t\tconst nestedDir: string | null = child.getAttribute('dir');\n\t\t\tconst nestedEffectiveDir: string | undefined =\n\t\t\t\tnestedDir && VALID_DIRECTIONS.has(nestedDir) ? nestedDir : parentDir;\n\t\t\tparseListElement(\n\t\t\t\tchild,\n\t\t\t\tnestedType,\n\t\t\t\tdepth + 1,\n\t\t\t\tblocks,\n\t\t\t\tadoptedIds,\n\t\t\t\tregistry,\n\t\t\t\tnestedEffectiveDir,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Parses one `<li>` into its `list_item` block (#194). An item whose children\n * are inline-only stays a leaf; block-level children other than nested lists\n * (a second paragraph, code, a quote, a heading) make it a container with\n * block children. Nested `<ul>`/`<ol>` are excluded here — the caller hoists\n * them into flat siblings one indent deeper. A lone plain paragraph unwraps\n * back to a leaf so the common tight/loose single-paragraph item keeps its\n * inline shape.\n */\nfunction parseListItemBlock(\n\tli: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n\tadoptedIds: Set<string>,\n\tcheckbox: HTMLInputElement | null,\n\tregistry?: SchemaRegistry,\n): BlockNode {\n\tconst htmlId: string | undefined = extractHTMLId(li);\n\tconst blockRules = registry?.getBlockParseRules() ?? [];\n\tconst isHoistedList = (node: ChildNode): boolean => {\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) return false;\n\t\tconst tag: string = (node as Element).tagName.toLowerCase();\n\t\treturn tag === 'ul' || tag === 'ol';\n\t};\n\tconst hasBlockContent: boolean = Array.from(li.childNodes).some(\n\t\t(node) => !isHoistedList(node) && isBlockLevelChild(node, blockRules),\n\t);\n\n\tif (!hasBlockContent) {\n\t\tconst inlineContent = parseElementToInlineContent(li, registry, true);\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\tinlineContent,\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\tconst skip = (node: ChildNode): boolean => isHoistedList(node) || node === checkbox;\n\tconst innerBlocks: BlockNode[] = parseBlockContainerChildren(\n\t\tli,\n\t\tblockRules,\n\t\tadoptedIds,\n\t\tregistry,\n\t\tskip,\n\t);\n\n\t// A lone attribute-less paragraph is the leaf shape in disguise.\n\tconst only: BlockNode | undefined = innerBlocks.length === 1 ? innerBlocks[0] : undefined;\n\tif (only && only.type === 'paragraph' && !only.attrs && !only.htmlId) {\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\tgetInlineChildren(only),\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\tif (innerBlocks.length === 0) {\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\t[createTextNode('')],\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\treturn createBlockNode(\n\t\tnodeType('list_item'),\n\t\tinnerBlocks,\n\t\tadoptBlockId(li, adoptedIds),\n\t\tattrs,\n\t\thtmlId,\n\t);\n}\n\n/**\n * Parses a `<table>` element into nested block structure:\n * table > table_row > table_cell > paragraph.\n * Handles `<thead>`, `<tbody>`, `<tfoot>` transparently.\n */\nfunction parseTableElement(\n\ttableEl: Element,\n\tblocks: BlockNode[],\n\tadoptedIds: Set<string>,\n\tregistry?: SchemaRegistry,\n): void {\n\tconst rows: BlockNode[] = [];\n\tconst columnWidthsPx: readonly (number | null)[] | undefined =\n\t\textractTableColumnWidthsPx(tableEl);\n\n\t// Collect <tr> elements, handling <thead>/<tbody>/<tfoot> wrappers\n\tconst rowElements: Element[] = collectTableRows(tableEl);\n\n\tfor (const trEl of rowElements) {\n\t\tconst cells: BlockNode[] = [];\n\n\t\tfor (const cellChild of Array.from(trEl.children)) {\n\t\t\tconst cellTag: string = cellChild.tagName.toLowerCase();\n\t\t\tif (cellTag !== 'td' && cellTag !== 'th') continue;\n\n\t\t\tconst cellEl: HTMLElement = cellChild as HTMLElement;\n\t\t\tconst cellContent: BlockNode[] = parseTableCellContent(cellEl, adoptedIds, registry);\n\t\t\tconst cellAttrs: Record<string, string | number | boolean> = {};\n\t\t\textractCellSpanAttrs(cellEl, cellAttrs);\n\t\t\tconst cellBlock: BlockNode = createBlockNode(\n\t\t\t\tnodeType('table_cell'),\n\t\t\t\tcellContent,\n\t\t\t\tadoptBlockId(cellEl, adoptedIds),\n\t\t\t\tObject.keys(cellAttrs).length > 0 ? cellAttrs : undefined,\n\t\t\t\textractHTMLId(cellEl),\n\t\t\t);\n\t\t\tcells.push(cellBlock);\n\t\t}\n\n\t\tconst rowAttrs: Record<string, string | number | boolean> = {};\n\t\textractTableRowMinHeight(trEl as HTMLElement, rowAttrs);\n\t\t// Preserve empty rows. Besides retaining authored table structure, an empty\n\t\t// `<tr>` may carry the canonical minimum-height metadata by itself.\n\t\trows.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType('table_row'),\n\t\t\t\tcells,\n\t\t\t\tadoptBlockId(trEl, adoptedIds),\n\t\t\t\tObject.keys(rowAttrs).length > 0 ? rowAttrs : undefined,\n\t\t\t\textractHTMLId(trEl as HTMLElement),\n\t\t\t),\n\t\t);\n\t}\n\n\tif (rows.length > 0) {\n\t\tconst tableAttrs: Record<string, BlockAttrValue> = {};\n\t\textractTableBorderColor(tableEl as HTMLElement, tableAttrs);\n\t\tif (columnWidthsPx) tableAttrs.columnWidthsPx = columnWidthsPx;\n\t\tblocks.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType('table'),\n\t\t\t\trows,\n\t\t\t\tadoptBlockId(tableEl, adoptedIds),\n\t\t\t\tObject.keys(tableAttrs).length > 0 ? tableAttrs : undefined,\n\t\t\t\textractHTMLId(tableEl as HTMLElement),\n\t\t\t),\n\t\t);\n\t}\n}\n\n/** Collects canonical logical column widths from direct `<colgroup>/<col>` children. */\nfunction extractTableColumnWidthsPx(tableEl: Element): readonly (number | null)[] | undefined {\n\tconst widths: (number | null)[] = [];\n\n\tfor (const child of Array.from(tableEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\t\tif (tag === 'col') {\n\t\t\tappendColumnElementWidths(child as HTMLElement, undefined, widths);\n\t\t\tcontinue;\n\t\t}\n\t\tif (tag !== 'colgroup') continue;\n\n\t\tconst groupEl: HTMLElement = child as HTMLElement;\n\t\tconst groupWidth: number | undefined = readTableColumnWidthPx(groupEl);\n\t\tconst columns: HTMLElement[] = Array.from(groupEl.children).filter(\n\t\t\t(element): element is HTMLElement => element.tagName.toLowerCase() === 'col',\n\t\t);\n\t\tif (columns.length === 0) {\n\t\t\tappendRepeatedWidth(groupWidth, parseTableColumnSpan(groupEl.getAttribute('span')), widths);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const column of columns) appendColumnElementWidths(column, groupWidth, widths);\n\t}\n\n\treturn normalizeTableColumnWidthsPx(widths);\n}\n\nfunction appendColumnElementWidths(\n\tcolumn: HTMLElement,\n\tinheritedWidth: number | undefined,\n\twidths: (number | null)[],\n): void {\n\tconst width: number | undefined = readTableColumnWidthPx(column) ?? inheritedWidth;\n\tappendRepeatedWidth(width, parseTableColumnSpan(column.getAttribute('span')), widths);\n}\n\nfunction appendRepeatedWidth(\n\twidth: number | undefined,\n\tspan: number,\n\twidths: (number | null)[],\n): void {\n\tconst remaining: number = MAX_SERIALIZED_TABLE_COLUMNS - widths.length;\n\tconst count: number = Math.min(span, Math.max(0, remaining));\n\tfor (let index = 0; index < count; index++) widths.push(width ?? null);\n}\n\nfunction readTableColumnWidthPx(element: HTMLElement): number | undefined {\n\treturn readTableDimensionPx(element, TABLE_COLUMN_WIDTH_DATA_ATTRIBUTE, ['width'], 'width');\n}\n\n/** Extracts one row's validated minimum height from canonical or conventional HTML. */\nfunction extractTableRowMinHeight(\n\trow: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n): void {\n\tconst minHeightPx: number | undefined = readTableDimensionPx(\n\t\trow,\n\t\tTABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE,\n\t\t['min-height', 'height'],\n\t\t'height',\n\t);\n\tif (minHeightPx !== undefined) attrs.minHeightPx = minHeightPx;\n}\n\n/** Collects `<tr>` elements from a table, traversing through `<thead>`/`<tbody>`/`<tfoot>`. */\nfunction collectTableRows(tableEl: Element): Element[] {\n\tconst rows: Element[] = [];\n\tfor (const child of Array.from(tableEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\t\tif (tag === 'tr') {\n\t\t\trows.push(child);\n\t\t} else if (tag === 'thead' || tag === 'tbody' || tag === 'tfoot') {\n\t\t\tfor (const nested of Array.from(child.children)) {\n\t\t\t\tif (nested.tagName.toLowerCase() === 'tr') {\n\t\t\t\t\trows.push(nested);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn rows;\n}\n\n/** Regex to extract the `--ntbl-bc` CSS custom property from inline styles. */\nconst BORDER_COLOR_RE = /--ntbl-bc:\\s*(#[0-9a-fA-F]{3,8}|transparent)/;\n\n/** Extracts `borderColor` from a table element's inline style (`--ntbl-bc` CSS variable). */\nfunction extractTableBorderColor(el: HTMLElement, attrs: Record<string, BlockAttrValue>): void {\n\tconst style: string = el.getAttribute('style') ?? '';\n\tconst match: RegExpMatchArray | null = BORDER_COLOR_RE.exec(style);\n\tif (!match?.[1]) return;\n\tattrs.borderColor = match[1] === 'transparent' ? 'none' : match[1];\n}\n\n/** Extracts `colspan` and `rowspan` attributes from a table cell element. */\nfunction extractCellSpanAttrs(\n\tel: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n): void {\n\tconst colspan: string | null = el.getAttribute('colspan');\n\tif (colspan) {\n\t\tconst value: number = parseTableColumnSpan(colspan);\n\t\tif (value > 1) attrs.colspan = value;\n\t}\n\tconst rowspan: string | null = el.getAttribute('rowspan');\n\tif (rowspan) {\n\t\tconst value: number = parseTableColumnSpan(rowspan);\n\t\tif (value > 1) attrs.rowspan = value;\n\t}\n}\n\n/**\n * Parses a `<blockquote>` into a container block whose children are block nodes\n * (issue #136). Block-level children (lists, paragraphs, headings, nested quotes)\n * are parsed recursively; a quote holding only inline content becomes a single\n * paragraph child so the container invariant (block children only) always holds.\n */\nfunction parseBlockquoteElement(\n\tel: HTMLElement,\n\tblocks: BlockNode[],\n\tadoptedIds: Set<string>,\n\tregistry?: SchemaRegistry,\n): void {\n\tconst blockRules = registry?.getBlockParseRules() ?? [];\n\tconst innerBlocks: BlockNode[] = parseBlockContainerChildren(\n\t\tel,\n\t\tblockRules,\n\t\tadoptedIds,\n\t\tregistry,\n\t);\n\n\t// Empty or whitespace-only blockquote: keep a single empty paragraph so the\n\t// container always holds editable content.\n\tif (innerBlocks.length === 0) {\n\t\tinnerBlocks.push(createBlockNode(nodeType('paragraph'), [createTextNode('')]));\n\t}\n\n\t// Preserve direction/alignment on the container so the HTML round-trip is stable.\n\tconst attrs: Record<string, string | number | boolean> = {};\n\textractAlignment(el, attrs);\n\textractDirection(el, attrs);\n\n\tblocks.push(\n\t\tcreateBlockNode(\n\t\t\tnodeType('blockquote'),\n\t\t\tinnerBlocks,\n\t\t\tadoptBlockId(el, adoptedIds),\n\t\t\tObject.keys(attrs).length > 0 ? attrs : undefined,\n\t\t\textractHTMLId(el),\n\t\t),\n\t);\n}\n\n/** Parses a table cell's content into blocks, supporting all block types (lists, quotes, etc.). */\nfunction parseTableCellContent(\n\tcellEl: HTMLElement,\n\tadoptedIds: Set<string>,\n\tregistry?: SchemaRegistry,\n): BlockNode[] {\n\tconst blockRules = registry?.getBlockParseRules() ?? [];\n\tconst cellBlocks: BlockNode[] = parseBlockContainerChildren(\n\t\tcellEl,\n\t\tblockRules,\n\t\tadoptedIds,\n\t\tregistry,\n\t);\n\n\t// No blocks produced: treat the cell as one empty paragraph.\n\tif (cellBlocks.length === 0) {\n\t\tcellBlocks.push(createBlockNode(nodeType('paragraph'), [createTextNode('')]));\n\t}\n\n\treturn cellBlocks;\n}\n\ntype BlockParseRules = readonly { readonly rule: ParseRule; readonly type: string }[];\n\n/**\n * Parses the children of a block container (blockquote, table cell) into block\n * nodes. Consecutive inline content (text nodes and inline elements such as\n * `<em>`, `<strong>`, `<a>`) is coalesced into a single paragraph with its marks\n * intact, while genuine block children (paragraphs, headings, lists, tables,\n * nested blockquotes) are parsed recursively. This preserves the common quote\n * shape that mixes text with inline marks as one paragraph (issue #141).\n */\nfunction parseBlockContainerChildren(\n\tel: HTMLElement,\n\tblockRules: BlockParseRules,\n\tadoptedIds: Set<string>,\n\tregistry?: SchemaRegistry,\n\tskip?: (node: ChildNode) => boolean,\n): BlockNode[] {\n\tconst blocks: BlockNode[] = [];\n\tlet inlineRun: ChildNode[] = [];\n\n\tconst flushInlineRun = (): void => {\n\t\tif (inlineRunHasContent(inlineRun)) {\n\t\t\tblocks.push(\n\t\t\t\tcreateBlockNode(nodeType('paragraph'), parseNodesToInlineContent(inlineRun, registry)),\n\t\t\t);\n\t\t}\n\t\tinlineRun = [];\n\t};\n\n\tfor (const child of Array.from(el.childNodes)) {\n\t\tif (skip?.(child)) continue;\n\t\tif (isBlockLevelChild(child, blockRules)) {\n\t\t\tflushInlineRun();\n\t\t\tparseChildNode(child, blocks, blockRules, adoptedIds, registry);\n\t\t} else {\n\t\t\tinlineRun.push(child);\n\t\t}\n\t}\n\tflushInlineRun();\n\n\treturn blocks;\n}\n\n/**\n * Whether a child node is block-level content. Known container tags (lists,\n * tables, nested blockquotes) and any element matching a block parse rule\n * (paragraphs, headings, code blocks, ...) are block-level; text nodes and\n * inline elements (`<em>`, `<a>`, `<br>`, ...) are not.\n */\nfunction isBlockLevelChild(node: ChildNode, blockRules: BlockParseRules): boolean {\n\tif (node.nodeType !== Node.ELEMENT_NODE) return false;\n\tconst el = node as HTMLElement;\n\tconst tag: string = el.tagName.toLowerCase();\n\tif (tag === 'p' || tag === 'ul' || tag === 'ol' || tag === 'table' || tag === 'blockquote') {\n\t\treturn true;\n\t}\n\treturn matchBlockParseRule(el, blockRules) !== null;\n}\n\n/** Whether an inline run carries meaningful content (non-whitespace text or any element). */\nfunction inlineRunHasContent(nodes: readonly ChildNode[]): boolean {\n\tfor (const node of nodes) {\n\t\tif (node.nodeType === Node.ELEMENT_NODE) return true;\n\t\tif (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) return true;\n\t}\n\treturn false;\n}\n\n/**\n * Parses an HTML element's inline children into (TextNode | InlineNode)[].\n * Applies mark parse rules and inline node parse rules.\n */\nfunction parseElementToInlineContent(\n\tel: HTMLElement,\n\tregistry?: SchemaRegistry,\n\tskipNestedLists?: boolean,\n): (TextNode | InlineNode)[] {\n\treturn parseNodesToInlineContent([el], registry, skipNestedLists);\n}\n\n/**\n * Walks a list of sibling DOM nodes into inline content, applying mark and\n * inline-node parse rules. Each node is walked from an empty mark set, so a run\n * mixing text and inline elements (e.g. `text <em>x</em> end`) coalesces into a\n * single inline sequence with marks preserved on the styled run.\n */\nfunction parseNodesToInlineContent(\n\tnodes: readonly ChildNode[],\n\tregistry?: SchemaRegistry,\n\tskipNestedLists?: boolean,\n): (TextNode | InlineNode)[] {\n\tconst result: (TextNode | InlineNode)[] = [];\n\tconst markRules = registry?.getMarkParseRules() ?? [];\n\tconst inlineRules = registry?.getInlineParseRules() ?? [];\n\tfor (const node of nodes) {\n\t\twalkElement(node, [], result, markRules, inlineRules, skipNestedLists);\n\t}\n\n\t// A lone <br> as the only content of a block is a placeholder for an empty\n\t// paragraph (e.g. `<p><br></p>`), not a real hard break. Normalize to empty text.\n\tif (result.length === 1 && isInlineNode(result[0]) && result[0].inlineType === 'hard_break') {\n\t\treturn [createTextNode('')];\n\t}\n\n\treturn result.length > 0 ? result : [createTextNode('')];\n}\n\n/**\n * Recursively walks DOM nodes, collecting marks from parse rules,\n * matching inline node parse rules, and producing TextNodes/InlineNodes.\n */\nfunction walkElement(\n\tnode: Node,\n\tcurrentMarks: Mark[],\n\tresult: (TextNode | InlineNode)[],\n\tmarkRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n\tinlineRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n\tskipNestedLists?: boolean,\n): void {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\tconst text: string = node.textContent ?? '';\n\t\tif (text) {\n\t\t\tresult.push(createTextNode(text, [...currentMarks]));\n\t\t}\n\t\treturn;\n\t}\n\n\tif (node.nodeType !== Node.ELEMENT_NODE) return;\n\n\tconst el = node as HTMLElement;\n\tconst tag: string = el.tagName.toLowerCase();\n\n\t// Skip nested lists inside <li> (handled by parseListElement)\n\tif (skipNestedLists && (tag === 'ul' || tag === 'ol')) return;\n\n\t// Skip checkbox inputs inside list items (already handled by parseListElement)\n\tif (skipNestedLists && tag === 'input' && el.getAttribute('type') === 'checkbox') return;\n\n\t// Try inline node parse rules first (atomic — no recursion)\n\tfor (const entry of inlineRules) {\n\t\tif (entry.rule.tag !== tag) continue;\n\n\t\tif (entry.rule.getAttrs) {\n\t\t\tconst attrs = entry.rule.getAttrs(el);\n\t\t\tif (attrs === false) continue;\n\t\t\tresult.push(\n\t\t\t\tcreateInlineNode(\n\t\t\t\t\tinlineType(entry.type) as InlineTypeName,\n\t\t\t\t\tattrs as Readonly<Record<string, string | number | boolean>>,\n\t\t\t\t\t[...currentMarks],\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tresult.push(\n\t\t\tcreateInlineNode(inlineType(entry.type) as InlineTypeName, undefined, [...currentMarks]),\n\t\t);\n\t\treturn;\n\t}\n\n\tconst marks: Mark[] = [...currentMarks];\n\n\t// Try mark parse rules — collect all matching marks for this element\n\tconst matchedTypes = new Set<string>();\n\tfor (const entry of markRules) {\n\t\tif (entry.rule.tag !== tag) continue;\n\t\tif (matchedTypes.has(entry.type)) continue;\n\n\t\tif (entry.rule.getAttrs) {\n\t\t\tconst attrs = entry.rule.getAttrs(el);\n\t\t\tif (attrs === false) continue;\n\t\t\tif (!marks.some((m) => m.type === entry.type)) {\n\t\t\t\tmarks.push({\n\t\t\t\t\ttype: markType(entry.type),\n\t\t\t\t\t...(Object.keys(attrs).length > 0 ? { attrs } : {}),\n\t\t\t\t} as Mark);\n\t\t\t\tmatchedTypes.add(entry.type);\n\t\t\t}\n\t\t} else {\n\t\t\tif (!marks.some((m) => m.type === entry.type)) {\n\t\t\t\tmarks.push({ type: markType(entry.type) });\n\t\t\t\tmatchedTypes.add(entry.type);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const child of Array.from(el.childNodes)) {\n\t\twalkElement(child, marks, result, markRules, inlineRules, skipNestedLists);\n\t}\n}\n\n/** Extracts a validated `dir` attribute or inline `direction` style from an element. */\nfunction extractDirection(el: HTMLElement, attrs: Record<string, string | number | boolean>): void {\n\tconst dir: string | null = el.getAttribute('dir');\n\tif (dir && VALID_DIRECTIONS.has(dir)) {\n\t\tattrs.dir = dir;\n\t\treturn;\n\t}\n\n\t// Fallback: check inline style `direction: rtl/ltr` (common in paste from Word/Docs)\n\tconst styleDir: string = el.style?.direction ?? '';\n\tif (styleDir && VALID_DIRECTIONS.has(styleDir)) {\n\t\tattrs.dir = styleDir;\n\t}\n}\n\n/** Reads a conforming document-local HTML target from a block element. */\nfunction extractHTMLId(el: HTMLElement): string | undefined {\n\treturn normalizeHTMLId(el.getAttribute('id'));\n}\n\n/** Legacy physical → logical alignment mapping for backward-compatible parsing. */\nconst LEGACY_ALIGNMENT_MAP: Readonly<Record<string, string>> = { left: 'start', right: 'end' };\n\n/** Extracts validated `text-align` from an element's style or class and adds it to attrs. */\nfunction extractAlignment(el: HTMLElement, attrs: Record<string, string | number | boolean>): void {\n\t// Check inline style first (works for both normal and rehydrated HTML)\n\tlet align: string = el.style?.textAlign ?? '';\n\tconst mappedAlign: string | undefined = LEGACY_ALIGNMENT_MAP[align];\n\tif (mappedAlign) align = mappedAlign;\n\tif (align && VALID_ALIGNMENTS.has(align)) {\n\t\tattrs.align = align;\n\t\treturn;\n\t}\n\n\t// Check for notectl-align-* class names (from class-based HTML)\n\tfor (const cls of Array.from(el.classList)) {\n\t\tconst match: RegExpMatchArray | null = cls.match(/^notectl-align-(\\w+)$/);\n\t\tlet alignValue: string | undefined = match?.[1];\n\t\tconst mappedAlignValue: string | undefined = LEGACY_ALIGNMENT_MAP[alignValue ?? ''];\n\t\tif (mappedAlignValue) alignValue = mappedAlignValue;\n\t\tif (alignValue && VALID_ALIGNMENTS.has(alignValue)) {\n\t\t\tattrs.align = alignValue;\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/**\n * Rehydrates class-based HTML by converting notectl class names back to inline styles.\n * This allows existing parse rules (which read inline styles) to work unchanged.\n */\nfunction rehydrateClasses(root: DocumentFragment, styleMap: ReadonlyMap<string, string>): void {\n\tconst elements: NodeListOf<Element> = root.querySelectorAll('[class]');\n\tfor (const el of Array.from(elements)) {\n\t\tconst htmlEl = el as HTMLElement;\n\t\tconst classes: string[] = Array.from(htmlEl.classList);\n\t\tconst toRemove: string[] = [];\n\n\t\tfor (const cls of classes) {\n\t\t\tconst declarations: string | undefined = styleMap.get(cls);\n\t\t\tif (declarations) {\n\t\t\t\t// Append declarations to existing inline style\n\t\t\t\tconst existing: string = htmlEl.getAttribute('style') ?? '';\n\t\t\t\tconst separator: string = existing && !existing.endsWith(';') ? '; ' : '';\n\t\t\t\thtmlEl.setAttribute('style', existing + separator + declarations);\n\t\t\t\ttoRemove.push(cls);\n\t\t\t}\n\t\t}\n\n\t\t// Remove rehydrated class names\n\t\tfor (const cls of toRemove) {\n\t\t\thtmlEl.classList.remove(cls);\n\t\t}\n\t}\n}\n\n/** Matches an element against block parse rules. Returns matched type and attrs. */\nfunction matchBlockParseRule(\n\tel: HTMLElement,\n\trules: readonly { readonly rule: ParseRule; readonly type: string }[],\n): { readonly type: string; readonly attrs?: Record<string, unknown> } | null {\n\tconst tag: string = el.tagName.toLowerCase();\n\tfor (const entry of rules) {\n\t\tif (entry.rule.tag !== tag) continue;\n\t\tif (entry.rule.getAttrs) {\n\t\t\tconst attrs = entry.rule.getAttrs(el);\n\t\t\tif (attrs === false) continue;\n\t\t\treturn { type: entry.type, attrs };\n\t\t}\n\t\treturn { type: entry.type };\n\t}\n\treturn null;\n}\n"],"mappings":"0XAsBA,IAAM,EAAiC,gBAQjC,EAAuC,IAAI,IAAI,CACpD,IAC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AK,MAAM,KAAO,MAAM,KAAK,EAAG,WAAY,CAE3C,IAAI,EADmC,EAAI,MAAM,2BACJ,GAC7C,MAAM,EAAuC,EAAqB,GAAc,IAEhF,GADI,IAAkB,EAAa,GAC/B,GAAc,EAAiB,IAAI,GAEtC,YADA,EAAM,MAAQ,EAGhB,CACD,CAgCA,SAAS,EACR,EACA,GAEA,MAAM,EAAc,EAAG,QAAQ,cAC/B,IAAK,MAAM,KAAS,EACnB,GAAI,EAAM,KAAK,MAAQ,EAAvB,CACA,GAAI,EAAM,KAAK,SAAU,CACxB,MAAM,EAAQ,EAAM,KAAK,SAAS,GAClC,IAAc,IAAV,EAAiB,SACrB,MAAO,CAAE,KAAM,EAAM,KAAM,QAC5B,CACA,MAAO,CAAE,KAAM,EAAM,KANO,CAQ7B,OAAO,IACR"}
@@ -1,2 +0,0 @@
1
- import{D as t,P as e,T as n,b as o,h as i}from"./Document-827l3P80.mjs";import{d as r,l as s,o as c,u as a}from"./Selection-HYoVFpAx.mjs";import{i as l}from"./TypeBrands-Ch9856Gb.mjs";import{i as f,n as u,r as d,t as p}from"./AttributedMarkCommands-BCvmqeFZ.mjs";import{c as m,n as h,o as z}from"./PluginHelpers-KDuTlmXm.mjs";import{c as k}from"./StyleRuntime-DW6omotc.mjs";import{r as g}from"./ColorValidation-DAijTjG9.mjs";import{t as b}from"./InlineStyleMarkSpec-CjSRj4f_.mjs";var S={label:"Font Size",tooltip:"Font Size",customFontSizeAria:"Custom font size",fontSizesAria:"Font sizes"},v=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BzqAYGER.mjs"),"./locales/de.ts":()=>import("./de-C-Yf378-.mjs"),"./locales/es.ts":()=>import("./es-CUKJujcb.mjs"),"./locales/fr.ts":()=>import("./fr-D0MDdoir.mjs"),"./locales/hi.ts":()=>import("./hi-B2uhiPCN.mjs"),"./locales/pt.ts":()=>import("./pt-BCXgUDiU.mjs"),"./locales/ru.ts":()=>import("./ru-DV-lgEtM.mjs"),"./locales/zh.ts":()=>import("./zh-oZl1P_p0.mjs")});async function x(t){return m(v,t,S)}function y(t){return void 0!==t?.attrs?.fontSize}function _(t){const i=t.selection;if(s(i)){const e=t.getBlock(i.nodeId);return e&&y(t.schema.getNodeSpec?.(e.type))?{kind:"block",path:t.getNodePath(i.nodeId)??[i.nodeId],attrs:e.attrs??{}}:null}const r=function(t){const i=t.selection;if(!a(i)||c(i))return null;if(i.anchor.blockId!==i.head.blockId)return null;const r=Math.min(i.anchor.offset,i.head.offset);if(Math.max(i.anchor.offset,i.head.offset)-r!==1)return null;const s=t.getBlock(i.anchor.blockId);if(!s)return null;for(const{child:c,from:a}of e(o(s)))if(a===r&&n(c))return{node:c,blockId:i.anchor.blockId,offset:r};return null}(t);return r&&y(t.schema.getInlineNodeSpec?.(r.node.inlineType))?{kind:"inline",blockId:r.blockId,offset:r.offset,attrs:r.node.attrs}:null}function I(t){const e=t?.fontSize;return"string"==typeof e&&e.length>0?e:null}function w(t,e){return{...t??{},fontSize:e}}function N(t){return I(t.attrs)}function C(t,e,n,o){const i=e.transaction("command");return"block"===n.kind?i.setNodeAttr(n.path,w(n.attrs,o)):i.setInlineNodeAttr(n.blockId,n.offset,w(n.attrs,o)),t.dispatch(i.build()),!0}var A=l("fontSize");function F(t){const e=t.selection;if(!a(e))return[];const n=t.getBlockOrder(),o=r(e,n),s=n.indexOf(o.from.blockId),c=n.indexOf(o.to.blockId),l=[];for(let r=s;r<=c;r++){const e=n[r];if(!e)continue;const a=t.getBlock(e);if(!a)continue;const f=r===s?o.from.offset:0,u=r===c?o.to.offset:i(a);y(t.schema.getNodeSpec?.(a.type))?l.push({kind:"blockNode",path:t.getNodePath(e)??[e],attrs:a.attrs??{}}):f!==u&&E(t,a,e,f,u,l)}return l}function E(e,n,i,r,s,c){let a,l=0,f=!1;for(const u of o(n))if(t(u)){const t=l+u.text.length;u.text.length>0&&t>r&&l<s&&(f=!0,a||(a=u.marks.find(t=>t.type===A))),l=t}else l>=r&&l<s&&y(e.schema.getInlineNodeSpec?.(u.inlineType))&&c.push({kind:"inlineNode",blockId:i,offset:l,attrs:u.attrs}),l+=1;f&&c.push({kind:"text",blockId:i,from:r,to:s,mark:a})}function j(t,e,n){const o=F(e);if(0===o.length)return!1;const i=e.transaction("command");let r=!1;for(const s of o){if("text"===s.kind){""===n?s.mark&&(i.removeMark(s.blockId,s.from,s.to,s.mark),r=!0):(s.mark&&i.removeMark(s.blockId,s.from,s.to,s.mark),i.addMark(s.blockId,s.from,s.to,{type:A,attrs:{size:n}}),r=!0);continue}const t=I(s.attrs);n===t||""===n&&null===t||("blockNode"===s.kind?i.setNodeAttr(s.path,w(s.attrs,n)):i.setInlineNodeAttr(s.blockId,s.offset,w(s.attrs,n)),r=!0)}return!!r&&(i.setSelection(e.selection),t.dispatch(i.build()),!0)}function T(t){const e=F(t).filter(t=>"text"!==t.kind).map(t=>t.attrs);return 0===e.length?null:new Set(e.map(t=>I(t)??""))}function M(t,e){const n=function(t){const e=_(t);if(e)return N(e);const n=T(t);if(n&&1===n.size){const[t]=n;if(t)return t}return u(t,"fontSize",t=>t.attrs.size??null)}(t);if(!n)return e;const o=Number.parseInt(n,10);return Number.isNaN(o)?e:o}function P(t,e,n){const o=_(e);if(o)return C(t,e,o,n);const i=e.selection;return!!a(i)&&(c(i)?h(t,p(e,{type:l("fontSize"),attrs:{size:n}})):j(t,e,n))}function D(t,e){const n=_(e);if(n)return null!==N(n)&&C(t,e,n,"");const o=e.selection;return!!a(o)&&(c(o)?h(t,f(e,l("fontSize"))):j(t,e,""))}function L(t,e,n,o,i){const r=function(t,e,n){if("up"===e){for(const e of n)if(e>t)return e;return null}for(let o=n.length-1;o>=0;o--){const e=n[o];if(void 0!==e&&e<t)return e}return null}(M(e,i),n,o);return null!==r&&(r===i?D(t,e):P(t,e,`${r}px`))}function B(t,e,n){e===n?t.executeCommand("removeFontSize"):P(t,t.getState(),`${e}px`)}function O(t,e){const n=document.createElement("button");n.type="button",n.id=`notectl-font-size-option-${t}`,n.className="notectl-font-size-picker__item",n.setAttribute("role","option"),n.setAttribute("aria-selected",String(e)),e&&n.classList.add("notectl-font-size-picker__item--active");const o=document.createElement("span");o.className="notectl-font-size-picker__check",o.textContent=e?"✓":"",n.appendChild(o);const i=document.createElement("span");return i.className="notectl-font-size-picker__label",i.textContent=String(t),n.appendChild(i),n}var $=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,64,72,96],K=class{id="fontSize";name="Font Size";priority=21;config;sizes;defaultSize;locale;constructor(t){var e;this.config={...t},this.sizes=function(t){if(!t||0===t.length)return $;const e=[...new Set(t)].filter(t=>Number.isInteger(t)&&t>0);return e.sort((t,e)=>t-e),e.length>0?e:$}(t?.sizes),this.defaultSize=(e=t?.defaultSize,void 0===e?16:Number.isInteger(e)&&e>0?e:16)}async init(t){this.locale=await z(t,this.config.locale,S,x),t.registerStyleSheet("\n/* Font Size Select — Width overrides for combobox button */\n.notectl-toolbar-btn--fontSize {\n\tmin-width: 60px;\n\tmax-width: 80px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n\tmin-width: 140px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n\tpadding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tfont-family: inherit;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n\toutline: none;\n\tbox-sizing: border-box;\n\t-moz-appearance: textfield;\n}\n\n.notectl-font-size-picker__input::-webkit-inner-spin-button,\n.notectl-font-size-picker__input::-webkit-outer-spin-button {\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n\tmax-height: 280px;\n\toverflow-y: auto;\n\tpadding: 4px 0;\n}\n\n.notectl-font-size-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--focused {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-font-size-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n"),this.registerMarkSpec(t),this.registerCommands(t),this.registerKeymaps(t),this.registerToolbarItem(t),this.applyDefaultSizeToContainer(t)}destroy(){}registerMarkSpec(t){t.registerMarkSpec(b({type:"fontSize",rank:4,valueAttr:"size",domStyleProperty:"fontSize",cssProperty:"font-size",validate:g}))}registerCommands(t){t.registerCommand("removeFontSize",()=>D(t,t.getState())),t.registerCommand("setFontSize",()=>!1),t.registerCommand("increaseFontSize",()=>L(t,t.getState(),"up",this.sizes,this.defaultSize)),t.registerCommand("decreaseFontSize",()=>L(t,t.getState(),"down",this.sizes,this.defaultSize))}registerKeymaps(t){t.registerKeymap({"Mod-Shift-+":()=>L(t,t.getState(),"up",this.sizes,this.defaultSize),"Mod-Shift-_":()=>L(t,t.getState(),"down",this.sizes,this.defaultSize)})}registerToolbarItem(t){t.registerToolbarItem({id:"fontSize",group:"format",label:this.locale.label,tooltip:this.locale.tooltip,command:"removeFontSize",popupType:"combobox",getLabel:t=>String(M(t,this.defaultSize)),renderPopup:(t,e,n)=>{!function(t,e,n){t.classList.add("notectl-font-size-picker");const o=M(e.getState(),n.defaultSize),i=function(t,e){const n=document.createElement("input");return n.type="number",n.className="notectl-font-size-picker__input",n.min=String(1),n.max=String(400),n.value=String(t),n.setAttribute("aria-label",e.locale.customFontSizeAria),n}(o,n);!function(t,e){const n=document.createElement("div");n.className="notectl-font-size-picker__input-wrapper",n.appendChild(e),t.appendChild(n)}(t,i);const{list:r,items:s}=function(t,e,n,o){const i=document.createElement("div");i.className="notectl-font-size-picker__list",i.setAttribute("role","listbox"),i.setAttribute("aria-label",o.locale.fontSizesAria);const r=[];for(const s of t){const t=O(s,s===e);t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),B(n,s,o.defaultSize),o.onClose({restoreFocusTo:o.contentElement})}),r.push(t),i.appendChild(t)}return{list:i,items:r}}(n.sizes,o,e,n);t.appendChild(r),function(t,e,n,o){const i=e.indexOf(n);if(i<0)return;const r=t[i];r&&(requestAnimationFrame(()=>{r.scrollIntoView({block:"nearest"})}),o.setAttribute("aria-activedescendant",r.id))}(s,n.sizes,o,r),function(t,e,n,o,i){let r=-1;const s=t=>{r>=0&&r<n.length&&n[r]?.classList.remove("notectl-font-size-picker__item--focused"),r=t;const o=n[r];r>=0&&r<n.length&&o&&(o.classList.add("notectl-font-size-picker__item--focused"),o.scrollIntoView({block:"nearest"}),e.setAttribute("aria-activedescendant",o.id))},c=t=>{t.preventDefault(),t.stopPropagation()};t.addEventListener("keydown",e=>{if("Enter"===e.key){c(e);const n=Number.parseInt(t.value,10);!Number.isNaN(n)&&n>=1&&n<=400&&(B(o,n,i.defaultSize),i.onClose({restoreFocusTo:i.contentElement}))}else"ArrowDown"===e.key?(c(e),s(0),n[0]?.focus()):"Escape"===e.key&&(c(e),i.onClose({restoreFocusTo:i.contentElement}))}),e.addEventListener("keydown",e=>{if("ArrowDown"===e.key)c(e),r<n.length-1&&(s(r+1),n[r]?.focus());else if("ArrowUp"===e.key)c(e),r>0?(s(r-1),n[r]?.focus()):(s(-1),t.focus());else if("Enter"===e.key){c(e);const t=i.sizes[r];r>=0&&r<i.sizes.length&&void 0!==t&&(B(o,t,i.defaultSize),i.onClose({restoreFocusTo:i.contentElement}))}else"Escape"===e.key&&(c(e),i.onClose({restoreFocusTo:i.contentElement}))})}(i,r,s,e,n)}(t,e,{sizes:this.sizes,defaultSize:this.defaultSize,onClose:n,contentElement:e.getContainer(),locale:this.locale})},isActive:t=>function(t){const e=_(t);if(e)return null!==N(e);const n=T(t);return!(!n||![...n].some(t=>t.length>0))||d(t,"fontSize")}(t)})}applyDefaultSizeToContainer(t){k(t.getContainer(),"fontSize",`${this.defaultSize}px`)}};export{S as n,x as r,K as t};
2
- //# sourceMappingURL=FontSizePlugin-8CAvj1RD.mjs.map
@@ -1,2 +0,0 @@
1
- import{P as t,T as e,b as n,l as i,o as a}from"./Document-827l3P80.mjs";import{l as r,o,r as l,t as s,u as c}from"./Selection-HYoVFpAx.mjs";import{a as p,r as u}from"./TypeBrands-Ch9856Gb.mjs";import{c as d,w as m}from"./BlockInsertion-CYH2gRkY.mjs";import{t as h}from"./Commands-D5ND50PQ.mjs";import{c as f,i as b,o as g}from"./PluginHelpers-KDuTlmXm.mjs";import{n as v}from"./DomUtils-Bf7JLFlx.mjs";import{t as x}from"./SelectionSync-BSHIw1EE.mjs";import{a as y}from"./PopupPositioning-BFh6Ed1D.mjs";import{r as w}from"./ColorValidation-DAijTjG9.mjs";import L from"dompurify";var k={"&":"&amp;","<":"&lt;",">":"&gt;"},S={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function C(t){return t.replace(/[&<>]/g,t=>k[t]??t)}function $(t){return t.replace(/[&<>"]/g,t=>S[t]??t)}function A(t){if(!t)return"";let e="";for(const[n,i]of Object.entries(t))!1!==i&&null!=i&&(e+=!0!==i?` ${n}="${$(String(i))}"`:` ${n}="true"`);return e}function z(t,e,n){return`<${t}${A(n)}>${e}</${t}>`}function _(t,e){return z("mi",C(t),e)}function E(t,e){return z("mn",C(t),e)}function B(t,e){return z("mo",C(t),e)}function I(t,e){return z("mtext",C(t),e)}function P(t){return function(t,e){return`<${t}${A(e)}></${t}>`}("mspace",t)}function D(t,e){return z("mrow",t,e)}function N(t){return 0===t.length?"":1===t.length?t[0]??"":D(t.join(""))}function F(t,e,n){return z("mfrac",`${t}${e}`,n)}function q(t,e,n){return z("mover",`${t}${e}`,n)}function R(t,e,n){return z("munder",`${t}${e}`,n)}function O(t){return z("mtd",t)}function T(t){return z("mtr",t.map(O).join(""))}var M={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&#39;":"'"};function j(t){const e=t.display?"block":"inline",n=t.alt?` alttext="${$(t.alt)}"`:"",i=void 0!==t.latex&&""!==t.latex,a=`<annotation encoding="application/x-tex">${C(t.latex??"")}</annotation>`;return`<math display="${e}"${n}>${i?`<semantics>${t.presentation}${a}</semantics>`:t.presentation}</math>`}function H(t){const e=t.match(/<annotation\b[^>]*\bencoding=["']application\/x-tex["'][^>]*>([\s\S]*?)<\/annotation>/i);var n;if(e&&void 0!==e[1])return(n=e[1],n.replace(/&(?:amp|lt|gt|quot|apos|#39);/g,t=>M[t]??t)).trim()}function G(t){return t.replace(/^(<math\b[^>]*?)\s+mathsize=(?:"[^"]*"|'[^']*')/i,"$1")}var U=/<math[\s>]/i;function K(t){return U.test(t.mathml)?function(t,e){const n=t.replace(/^(<math\b[^>]*?)\s+alttext=["'][^"']*["']/i,"$1");return e?n.replace(/^<math\b/i,`<math alttext="${$(e)}"`):n}(t.mathml,t.alt):""}function W(t,e){const n=K(e);n?t.innerHTML=n:t.textContent=e.latex||e.alt||"⊡"}function V(t,e){const n="string"==typeof e?.fontSize?e.fontSize:"";t.style.fontSize=n}function Z(t){return{mathml:"string"==typeof t?.mathml?t.mathml:"",latex:"string"==typeof t?.latex?t.latex:"",alt:"string"==typeof t?.alt?t.alt:"",fontSize:"string"==typeof t?.fontSize?t.fontSize:""}}function X(t){const e=K(t);return e?function(t,e){const n=G(t);return e?n.replace(/^<math\b/i,`<math mathsize="${$(e)}"`):n}(e,w(t.fontSize)?t.fontSize:""):e}function Q(t){const e=t.getAttribute("mathsize")??"";return w(e)?e:""}function J(t,e){if("block"===t.getAttribute("display")!==e)return!1;const n=G(function(t){return t.replace(/^(<math\b[^>]*?)\s+data-block-id=(?:"[^"]*"|'[^']*')/i,"$1")}(t.outerHTML));return{mathml:n,latex:H(n)??"",alt:t.getAttribute("alttext")??"",fontSize:Q(t)}}var Y="math_inline",tt="math_display",et={insertInline:"Mod-Shift-E",insertDisplay:"Mod-Shift-M"},nt=[12,16,20,24,32,40,48,64,96],it={},at=["math","semantics","annotation","mrow","mi","mn","mo","mtext","ms","mspace","mfrac","msqrt","mroot","msup","msub","msubsup","mover","munder","munderover","mmultiscripts","mprescripts","none","mtable","mtr","mlabeledtr","mtd","mpadded","mphantom","mstyle","merror","menclose","mfenced","maction"],rt=["display","encoding","mathvariant","mathsize","mathcolor","mathbackground","displaystyle","scriptlevel","scriptminsize","scriptsizemultiplier","stretchy","symmetric","largeop","movablelimits","accent","accentunder","form","fence","separator","lspace","rspace","voffset","minsize","maxsize","linethickness","columnalign","rowalign","columnspacing","rowspacing","columnlines","rowlines","columnspan","rowspan","align","open","close","separators","notation","alttext","depth","width","height"];function ot(t){const e=t.selection;if(!r(e))return null;const n=t.getBlock(e.nodeId);return n&&"math_display"===n.type?e.nodeId:null}function lt(t){return{mathml:t.mathml,latex:t.latex,alt:t.alt,fontSize:t.fontSize}}function st(t,e){const n=t.selection;if(0===e.length||!c(n))return null;const a=t.transaction("command"),r=o(n)?void 0:h(t,a);let l,p;if(r)l=r,p=0;else{const e=m(n,t.getBlockOrder());l=e.blockId,p=e.offset}for(const o of e)a.insertInlineNode(l,p,i(u(Y),lt(o))),p+=1;return a.setSelection(s(l,p)),a.build()}function ct(t,e){const n=b(t);if(0===e.length||!n)return null;const i=e.map(t=>a(p(tt),[],void 0,lt(t))),r=t.transaction("command");if(!d(t,r,n,i))return null;const o=i[i.length-1];return o?(r.setSelection(l(o.id,[])),r.build()):null}function pt(t){return{mathml:t.mathml,latex:t.latex,alt:t.alt,fontSize:t.fontSize}}function ut(t,e,n){const i=pt(n);n.display?function(t,e){const n=function(t,e){return ct(t,[e])}(t.getState(),e);!!n&&t.dispatch(n)}(t,i):function(t,e){const n=function(t,e){return st(t,[e])}(t.getState(),e);!!n&&t.dispatch(n)}(t,i),t.announce(e.inserted)}function dt(t,e){return void 0===e?{node:t}:{node:t,kind:e}}function mt(t,e,n=!1){return{node:t,kind:e,bigOp:!0,intLike:n}}var ht=/* @__PURE__ */function(t){return t.Ordinary="ordinary",t.Binary="binary",t.Relation="relation",t.Arrow="arrow",t.Open="open",t.Close="close",t.Function="function",t.BigOp="bigop",t.Punct="punct",t}({});function ft(t,e){return{char:t,kind:e}}var bt="ordinary",gt="binary",vt="relation",xt="arrow",yt="function",wt="bigop",Lt="punct",kt={alpha:ft("α",bt),beta:ft("β",bt),gamma:ft("γ",bt),delta:ft("δ",bt),epsilon:ft("ϵ",bt),varepsilon:ft("ε",bt),zeta:ft("ζ",bt),eta:ft("η",bt),theta:ft("θ",bt),vartheta:ft("ϑ",bt),iota:ft("ι",bt),kappa:ft("κ",bt),lambda:ft("λ",bt),mu:ft("μ",bt),nu:ft("ν",bt),xi:ft("ξ",bt),omicron:ft("ο",bt),pi:ft("π",bt),varpi:ft("ϖ",bt),rho:ft("ρ",bt),varrho:ft("ϱ",bt),sigma:ft("σ",bt),varsigma:ft("ς",bt),tau:ft("τ",bt),upsilon:ft("υ",bt),phi:ft("ϕ",bt),varphi:ft("φ",bt),chi:ft("χ",bt),psi:ft("ψ",bt),omega:ft("ω",bt),Gamma:ft("Γ",bt),Delta:ft("Δ",bt),Theta:ft("Θ",bt),Lambda:ft("Λ",bt),Xi:ft("Ξ",bt),Pi:ft("Π",bt),Sigma:ft("Σ",bt),Upsilon:ft("Υ",bt),Phi:ft("Φ",bt),Psi:ft("Ψ",bt),Omega:ft("Ω",bt)},St={sin:ft("sin",yt),cos:ft("cos",yt),tan:ft("tan",yt),cot:ft("cot",yt),sec:ft("sec",yt),csc:ft("csc",yt),sinh:ft("sinh",yt),cosh:ft("cosh",yt),tanh:ft("tanh",yt),coth:ft("coth",yt),arcsin:ft("arcsin",yt),arccos:ft("arccos",yt),arctan:ft("arctan",yt),log:ft("log",yt),ln:ft("ln",yt),lg:ft("lg",yt),exp:ft("exp",yt),deg:ft("deg",yt),det:ft("det",yt),dim:ft("dim",yt),hom:ft("hom",yt),ker:ft("ker",yt),arg:ft("arg",yt),Pr:ft("Pr",yt)},Ct={sum:ft("∑",wt),prod:ft("∏",wt),coprod:ft("∐",wt),int:ft("∫",wt),iint:ft("∬",wt),iiint:ft("∭",wt),oint:ft("∮",wt),bigcup:ft("⋃",wt),bigcap:ft("⋂",wt),bigsqcup:ft("⨆",wt),bigvee:ft("⋁",wt),bigwedge:ft("⋀",wt),bigoplus:ft("⨁",wt),bigotimes:ft("⨂",wt),bigodot:ft("⨀",wt),biguplus:ft("⨄",wt),lim:ft("lim",wt),limsup:ft("lim sup",wt),liminf:ft("lim inf",wt),injlim:ft("inj lim",wt),projlim:ft("proj lim",wt),max:ft("max",wt),min:ft("min",wt),sup:ft("sup",wt),inf:ft("inf",wt),gcd:ft("gcd",wt)},$t={times:ft("×",gt),div:ft("÷",gt),pm:ft("±",gt),mp:ft("∓",gt),cdot:ft("⋅",gt),ast:ft("∗",gt),star:ft("⋆",gt),circ:ft("∘",gt),bullet:ft("∙",gt),oplus:ft("⊕",gt),ominus:ft("⊖",gt),otimes:ft("⊗",gt),oslash:ft("⊘",gt),odot:ft("⊙",gt),cap:ft("∩",gt),cup:ft("∪",gt),uplus:ft("⊎",gt),sqcap:ft("⊓",gt),sqcup:ft("⊔",gt),wedge:ft("∧",gt),land:ft("∧",gt),vee:ft("∨",gt),lor:ft("∨",gt),setminus:ft("∖",gt),wr:ft("≀",gt),diamond:ft("⋄",gt),bigtriangleup:ft("△",gt),bigtriangledown:ft("▽",gt),triangleleft:ft("◁",gt),triangleright:ft("▷",gt),amalg:ft("⨿",gt),dagger:ft("†",gt),ddagger:ft("‡",gt)},At={leq:ft("≤",vt),le:ft("≤",vt),geq:ft("≥",vt),ge:ft("≥",vt),neq:ft("≠",vt),ne:ft("≠",vt),equiv:ft("≡",vt),sim:ft("∼",vt),simeq:ft("≃",vt),cong:ft("≅",vt),approx:ft("≈",vt),propto:ft("∝",vt),prec:ft("≺",vt),succ:ft("≻",vt),preceq:ft("⪯",vt),succeq:ft("⪰",vt),ll:ft("≪",vt),gg:ft("≫",vt),lll:ft("⋘",vt),ggg:ft("⋙",vt),subset:ft("⊂",vt),supset:ft("⊃",vt),subseteq:ft("⊆",vt),supseteq:ft("⊇",vt),subsetneq:ft("⊊",vt),supsetneq:ft("⊋",vt),sqsubseteq:ft("⊑",vt),sqsupseteq:ft("⊒",vt),in:ft("∈",vt),ni:ft("∋",vt),notin:ft("∉",vt),mid:ft("∣",vt),parallel:ft("∥",vt),perp:ft("⊥",vt),models:ft("⊨",vt),vdash:ft("⊢",vt),dashv:ft("⊣",vt),doteq:ft("≐",vt),asymp:ft("≍",vt),bowtie:ft("⋈",vt),smile:ft("⌣",vt),frown:ft("⌢",vt)},zt={leftarrow:ft("←",xt),gets:ft("←",xt),rightarrow:ft("→",xt),to:ft("→",xt),leftrightarrow:ft("↔",xt),Leftarrow:ft("⇐",xt),Rightarrow:ft("⇒",xt),Leftrightarrow:ft("⇔",xt),mapsto:ft("↦",xt),longrightarrow:ft("⟶",xt),longleftarrow:ft("⟵",xt),longleftrightarrow:ft("⟷",xt),Longrightarrow:ft("⟹",xt),Longleftarrow:ft("⟸",xt),Longleftrightarrow:ft("⟺",xt),implies:ft("⟹",xt),iff:ft("⟺",xt),uparrow:ft("↑",xt),downarrow:ft("↓",xt),updownarrow:ft("↕",xt),nearrow:ft("↗",xt),searrow:ft("↘",xt),swarrow:ft("↙",xt),nwarrow:ft("↖",xt),hookleftarrow:ft("↩",xt),hookrightarrow:ft("↪",xt),rightharpoonup:ft("⇀",xt),rightharpoondown:ft("⇁",xt),leftharpoonup:ft("↼",xt),leftharpoondown:ft("↽",xt),nleftarrow:ft("↚",xt),nrightarrow:ft("↛",xt)},_t={langle:ft("⟨","open"),rangle:ft("⟩","close"),lceil:ft("⌈","open"),rceil:ft("⌉","close"),lfloor:ft("⌊","open"),rfloor:ft("⌋","close"),lbrace:ft("{","open"),rbrace:ft("}","close"),lbrack:ft("[","open"),rbrack:ft("]","close"),lvert:ft("|","open"),rvert:ft("|","close"),lVert:ft("‖","open"),rVert:ft("‖","close"),vert:ft("|","relation"),Vert:ft("‖","relation"),backslash:ft("\\",bt)},Et={infty:ft("∞",bt),partial:ft("∂",bt),nabla:ft("∇",bt),forall:ft("∀",bt),exists:ft("∃",bt),nexists:ft("∄",bt),emptyset:ft("∅",bt),varnothing:ft("∅",bt),aleph:ft("ℵ",bt),beth:ft("ℶ",bt),hbar:ft("ℏ",bt),ell:ft("ℓ",bt),Re:ft("ℜ",bt),Im:ft("ℑ",bt),wp:ft("℘",bt),prime:ft("′",bt),angle:ft("∠",bt),measuredangle:ft("∡",bt),triangle:ft("△",bt),neg:ft("¬",bt),lnot:ft("¬",bt),top:ft("⊤",bt),bot:ft("⊥",bt),flat:ft("♭",bt),natural:ft("♮",bt),sharp:ft("♯",bt),clubsuit:ft("♣",bt),diamondsuit:ft("♢",bt),heartsuit:ft("♡",bt),spadesuit:ft("♠",bt),surd:ft("√",bt),complement:ft("∁",bt),square:ft("□",bt),blacksquare:ft("■",bt),bigstar:ft("★",bt),checkmark:ft("✓",bt),degree:ft("°",bt),cdots:ft("⋯",bt),ldots:ft("…",bt),dots:ft("…",bt),dotsb:ft("⋯",bt),vdots:ft("⋮",bt),ddots:ft("⋱",bt)},Bt={colon:ft(":",Lt),cdotp:ft("·",Lt),ldotp:ft(".",Lt)},It={...kt,...St,...Ct,...$t,...At,...zt,..._t,...Et,...Bt},Pt={"(":ft("(","open"),")":ft(")","close"),"[":ft("[","open"),"]":ft("]","close"),"|":ft("|","relation"),"/":ft("/",bt)};function Dt(t){if("."===t)return ft("",bt);if(t.startsWith("\\")){const e=t.slice(1);return"{"===e?ft("{","open"):"}"===e?ft("}","close"):"|"===e?ft("‖","relation"):"\\"===e?ft("\\",bt):_t[e]}return Pt[t]}var Nt=/* @__PURE__ */function(t){return t.Command="command",t.GroupOpen="groupOpen",t.GroupClose="groupClose",t.Superscript="superscript",t.Subscript="subscript",t.Prime="prime",t.Ampersand="ampersand",t.RowBreak="rowBreak",t.NbSpace="nbSpace",t.Number="number",t.Char="char",t}({}),Ft=new Set(["{","}","%","$","#","&","_",",",":",";","!"," ","|","\\",".","/","'","~","^"]);function qt(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function Rt(t){return t>="0"&&t<="9"}function Ot(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function Tt(t,e,n){return{type:t,value:e,position:n}}function Mt(t,e){const n=t[e+1];if(void 0!==n&&!qt(n))return"\\"===n?Tt("rowBreak","\\",e):Tt("command",n,e);let i=e+1;for(;i<t.length;){const e=t[i];if(void 0===e||!qt(e))break;i+=1}return Tt("command",t.slice(e+1,i),e)}function jt(t,e){let n=e;for(;n<t.length;){const e=t[n];if(void 0===e||!Rt(e))break;n+=1}if("."===t[n]&&void 0!==t[n+1]&&Rt(t[n+1]??""))for(n+=1;n<t.length;){const e=t[n];if(void 0===e||!Rt(e))break;n+=1}return Tt("number",t.slice(e,n),e)}function Ht(t,e){switch(t){case"{":return Tt("groupOpen",t,e);case"}":return Tt("groupClose",t,e);case"^":return Tt("superscript",t,e);case"_":return Tt("subscript",t,e);case"'":return Tt("prime",t,e);case"&":return Tt("ampersand",t,e);case"~":return Tt("nbSpace",t,e);default:return Tt("char",t,e)}}function Gt(t,e){return{glyph:t,under:!1,stretchy:e}}function Ut(t,e){return{glyph:t,under:!0,stretchy:e}}var Kt={hat:Gt("^",!1),widehat:Gt("^",!0),check:Gt("ˇ",!1),tilde:Gt("~",!1),widetilde:Gt("~",!0),bar:Gt("‾",!1),overline:Gt("‾",!0),vec:Gt("→",!1),overrightarrow:Gt("→",!0),overleftarrow:Gt("←",!0),overleftrightarrow:Gt("↔",!0),dot:Gt("˙",!1),ddot:Gt("¨",!1),dddot:Gt("⃛",!1),acute:Gt("´",!1),grave:Gt("`",!1),breve:Gt("˘",!1),mathring:Gt("˚",!1),overbrace:Gt("⏞",!0),underline:Ut("_",!0),underbrace:Ut("⏟",!0),underrightarrow:Ut("→",!0),underleftarrow:Ut("←",!0)},Wt={matrix:{open:"",close:""},pmatrix:{open:"(",close:")"},bmatrix:{open:"[",close:"]"},Bmatrix:{open:"{",close:"}"},vmatrix:{open:"|",close:"|"},Vmatrix:{open:"‖",close:"‖"},cases:{open:"{",close:"",columnalign:"left"},aligned:{open:"",close:"",columnalign:"right left"},align:{open:"",close:"",columnalign:"right left"},gathered:{open:"",close:"",columnalign:"center"},smallmatrix:{open:"",close:""}};function Vt(t){return t.type===Nt.Command&&"end"===t.value}function Zt(t){return t.type===Nt.Ampersand||t.type===Nt.RowBreak||t.type===Nt.Command&&"end"===t.value}var Xt={",":"0.167em",":":"0.222em",";":"0.278em","!":"-0.167em"," ":"0.25em",quad:"1em",qquad:"2em",thinspace:"0.167em",medspace:"0.222em",thickspace:"0.278em",negthinspace:"-0.167em",negmedspace:"-0.222em",negthickspace:"-0.278em",enspace:"0.5em"};function Qt(t){return t in Xt}function Jt(t){const e=Xt[t];if(void 0!==e)return P({width:e})}function Yt(){return P({width:"0.25em"})}function te(t){const e=t.parseRawArgument();return(n=e)in Wt||"array"===n?function(t,e){"array"===t&&(e.parseOptionalArgument(),e.parseRawArgument());const n=function(t,e){const n=[];let i=[],a=[];const r=()=>{i.push(D(a.join(""))),a=[]},o=()=>{r(),n.push(i),i=[]};for(;;){const n=e.peek();if(void 0===n){e.error({message:`Unterminated environment \\begin{${t}}`});break}if(Vt(n)){e.next(),e.parseRawArgument();break}if(n.type===Nt.Ampersand){e.next(),r();continue}if(n.type===Nt.RowBreak){e.next(),o();continue}if(n.type===Nt.GroupClose){e.next(),e.error({message:"Unmatched brace",position:n.position});continue}const i=e.parseAtomsUntil(Zt);a.push(...i.map(t=>t.node))}return(a.length>0||i.length>0)&&o(),0===n.length&&n.push([""]),n}(t,e).map(t=>t.map(t=>t)),i=Wt[t]??{open:"",close:""},a=(r=n,o=i.columnalign?{columnalign:i.columnalign}:void 0,z("mtable",r.map(T).join(""),o));var r,o;return i.open||i.close?dt(D(`${i.open?B(i.open,{stretchy:!0,fence:!0}):""}${a}${i.close?B(i.close,{stretchy:!0,fence:!0}):""}`)):dt(a)}(e,t):(t.error({message:"Unknown environment",command:e}),dt(z("merror",I(e))));var n}function ee(t){return t.type===Nt.Command&&"right"===t.value}function ne(t){const e=t.next();return void 0===e?".":e.type===Nt.Command?`\\${e.value}`:e.value}function ie(t){return t&&""!==t.char?B(t.char,{fence:!0,stretchy:!0}):""}var ae={},re={"double-struck":{upperBase:120120,lowerBase:120146,digitBase:120792,holes:{C:8450,H:8461,N:8469,P:8473,Q:8474,R:8477,Z:8484}},script:{upperBase:119964,lowerBase:119990,holes:{B:8492,E:8496,F:8497,H:8459,I:8464,L:8466,M:8499,R:8475,e:8495,g:8458,o:8500}},fraktur:{upperBase:120068,lowerBase:120094,holes:{C:8493,H:8460,I:8465,R:8476,Z:8488}},bold:{upperBase:119808,lowerBase:119834,digitBase:120782,holes:ae},italic:{upperBase:119860,lowerBase:119886,holes:{h:8462}},"sans-serif":{upperBase:120224,lowerBase:120250,digitBase:120802,holes:ae},monospace:{upperBase:120432,lowerBase:120458,digitBase:120822,holes:ae}};function oe(t,e){if(1!==t.length)return null;const n=re[e],i=n.holes[t];return void 0!==i?String.fromCodePoint(i):function(t){return t>="A"&&t<="Z"}(t)?String.fromCodePoint(n.upperBase+(t.charCodeAt(0)-65)):function(t){return t>="a"&&t<="z"}(t)?String.fromCodePoint(n.lowerBase+(t.charCodeAt(0)-97)):function(t){return t>="0"&&t<="9"}(t)&&void 0!==n.digitBase?String.fromCodePoint(n.digitBase+(t.charCodeAt(0)-48)):null}var le=/<(mi|mn)>([^<]*)<\/\1>/g,se=/<mi>([^<]*)<\/mi>/g;var ce={mathbb:"double-struck",mathcal:"script",mathscr:"script",mathfrak:"fraktur",mathbf:"bold",mathit:"italic",mathsf:"sans-serif",mathtt:"monospace"},pe={boldsymbol:"bold-italic",bm:"bold-italic"},ue={text:void 0,textnormal:"normal",textrm:"normal",textbf:"bold",textit:"italic",textsf:"sans-serif",texttt:"monospace",mbox:void 0};function de(t,e){if("operatorname"===t)return dt(_(e.parseRawArgument(),{mathvariant:"normal"}));if(t in ue){const n=ue[t],i=e.parseRawArgument();return dt(n?I(i,{mathvariant:n}):I(i))}const n=ce[t];if(void 0!==n)return dt((i=e.parseArgument(),a=n,i.replace(le,(t,e,n)=>{const i=function(t,e){let n="";for(const i of t)n+=oe(i,e)??i;return n}(n,a);return"mn"===e?E(i):_(i)})));var i,a;if("mathrm"===t)return dt(e.parseArgument().replace(se,(t,e)=>_(e,{mathvariant:"normal"})));const r=pe[t],o=e.parseArgument();return dt(void 0===r?o:z("mstyle",o,{mathvariant:r}))}var me=new Set(["frac","dfrac","tfrac","cfrac"]),he=new Set(["binom","dbinom","tbinom","choose"]),fe=new Set(["overset","underset","stackrel"]);var be=new Set(["∫","∬","∭","∮"]);var ge=class{source;tokens;pos=0;depth=0;depthExceeded=!1;errors=[];display;constructor(t,e,n){this.source=t,this.tokens=e,this.display=n}get collectedErrors(){return this.errors}peek(){return this.tokens[this.pos]}next(){const t=this.tokens[this.pos];return void 0!==t&&(this.pos+=1),t}error(t){this.errors.push(t)}parseTopLevel(){const t=[];for(;;){const e=this.peek();if(void 0===e)break;if(e.type===Nt.GroupClose){this.next(),this.error({message:"Unmatched brace",position:e.position});continue}const n=this.parseAtomWithScripts();void 0!==n&&t.push(n)}return t}parseExpression(t){const e=[];for(;;){const n=this.peek();if(void 0===n||t(n))break;if(n.type===Nt.GroupClose)break;const i=this.parseAtomWithScripts();void 0!==i&&e.push(i)}return e}parseAtomsUntil(t){return this.parseExpression(t)}parseAtomWithScripts(){const t=this.parseBaseAtom();if(void 0!==t)return this.attachScripts(t)}attachScripts(t){let e,n,i,a="";for(;;){const t=this.peek();if(void 0===t)break;if(t.type!==Nt.Prime)if(t.type!==Nt.Command||"limits"!==t.value)if(t.type!==Nt.Command||"nolimits"!==t.value)if(t.type!==Nt.Superscript){if(t.type!==Nt.Subscript)break;this.next(),e=this.combineSub(e,this.parseArgument())}else this.next(),n=this.combineSup(n,this.parseArgument());else this.next(),i="nolimits";else this.next(),i="limits";else this.next(),a+="′"}return a&&(n=void 0===n?B(a):D(`${B(a)}${n}`)),void 0===e&&void 0===n?t:dt(this.buildScripts(t,e,n,i))}combineSup(t,e){return void 0===t?e:(this.error({message:"Double superscript"}),D(`${t}${e}`))}combineSub(t,e){return void 0===t?e:(this.error({message:"Double subscript"}),D(`${t}${e}`))}buildScripts(t,e,n,i){const a=!0===t.bigOp&&!0!==t.intLike&&this.display;if("limits"===i||"nolimits"!==i&&a){if(void 0!==e&&void 0!==n)return function(t,e,n){return z("munderover",`${t}${e}${n}`)}(t.node,e,n);if(void 0!==e)return R(t.node,e);if(void 0!==n)return q(t.node,n)}return void 0!==e&&void 0!==n?function(t,e,n){return z("msubsup",`${t}${e}${n}`)}(t.node,e,n):void 0!==e?function(t,e){return z("msub",`${t}${e}`)}(t.node,e):void 0!==n?function(t,e){return z("msup",`${t}${e}`)}(t.node,n):t.node}parseBaseAtom(){if(this.depth>=256)return this.bailDeepNesting();this.depth+=1;try{return this.parseBaseAtomInner()}finally{this.depth-=1}}bailDeepNesting(){const t=this.next();if(void 0!==t&&!this.depthExceeded)return this.depthExceeded=!0,this.error({message:"Maximum nesting depth exceeded",position:t.position}),dt(z("merror",I("⋯")))}parseBaseAtomInner(){const t=this.next();if(void 0!==t)switch(t.type){case Nt.Number:return dt(E(t.value));case Nt.Char:return this.parseChar(t.value);case Nt.GroupOpen:return this.parseGroup();case Nt.NbSpace:return dt(Yt());case Nt.Command:return this.parseCommand(t);case Nt.Superscript:case Nt.Subscript:case Nt.Prime:return this.pos-=1,this.attachScripts(dt(D("")));case Nt.Ampersand:case Nt.RowBreak:case Nt.GroupClose:default:return}}parseGroup(){const t=this.parseExpression(()=>!1);return this.expect(Nt.GroupClose),dt(N(t.map(t=>t.node)))}parseChar(t){const e=Dt(t);return!e||e.kind!==ht.Open&&e.kind!==ht.Close?dt("+"===t||"-"===t||"*"===t||"="===t||"/"===t||"|"===t||","===t||";"===t||"."===t||":"===t||"!"===t||"?"===t||"<"===t||">"===t?B(t):_(t)):dt(B(t,{fence:!0}),e.kind)}parseCommand(t){const e=t.value,n=function(t){return It[t]}(e);if(n)return this.symbolAtom(n);if(1===(i=e).length&&Ft.has(i))return this.controlSymbolAtom(e);var i;const a=this.dispatchStructural(e);if(void 0!==a)return a;const r=this.dispatchSpecial(e,t);return void 0!==r?r:(this.error({message:"Unknown command",command:`\\${e}`,position:t.position}),dt(z("merror",I(`\\${e}`))))}dispatchStructural(t){if(function(t){return me.has(t)}(t))return dt(F((e=this).parseArgument(),e.parseArgument()));var e;if(function(t){return he.has(t)}(t))return function(t){const e=F(t.parseArgument(),t.parseArgument(),{linethickness:0});return dt(D(`${B("(",{fence:!0})}${e}${B(")",{fence:!0})}`))}(this);if("sqrt"===t)return function(t){const e=t.parseOptionalArgument(),n=t.parseArgument();return dt(void 0===e||""===e?function(t){return z("msqrt",t)}(n):function(t,e){return z("mroot",`${t}${e}`)}(n,e))}(this);if(function(t){return fe.has(t)}(t))return function(t,e){const n=e.parseArgument(),i=e.parseArgument();return dt("underset"===t?R(i,n):q(i,n))}(t,this);if(function(t){return t in Kt}(t))return function(t,e){const n=Kt[t];if(!n)return dt("");const i=e.parseArgument(),a=B(n.glyph,{stretchy:n.stretchy}),r=n.under?{accentunder:!0}:{accent:!0};return dt(n.under?R(i,a,r):q(i,a,r))}(t,this);if(function(t){return t in ce||t in pe||t in ue||"mathrm"===t||"operatorname"===t}(t))return de(t,this);if(Qt(t)){const e=Jt(t);return void 0===e?void 0:dt(e)}}dispatchSpecial(t,e){return"left"===t?function(t){const e=Dt(ne(t)),n=t.parseAtomsUntil(ee),i=t.peek();let a=".";void 0!==i&&ee(i)?(t.next(),a=ne(t)):t.error({message:"Unmatched \\left"});const r=Dt(a),o=ie(e),l=ie(r);return dt(N([o,...n.map(t=>t.node),l]))}(this):"begin"===t?te(this):"pmod"===t?function(t){const e=t.parseArgument(),n=B("(",{fence:!0}),i=B(")",{fence:!0});return dt(D(`${n}${I("mod")}${Yt()}${e}${i}`))}(this):"bmod"===t||"mod"===t?dt(B("mod",{lspace:"0.222em",rspace:"0.222em"})):"substack"===t?function(t){!function(t){const e=t.peek();void 0!==e&&e.type===Nt.GroupOpen&&t.next()}(t);const e=[];let n=[];for(;;){const i=t.peek();if(void 0===i||i.type===Nt.GroupClose)break;if(i.type===Nt.RowBreak){t.next(),e.push(N(n)),n=[];continue}const a=t.parseAtomsUntil(t=>t.type===Nt.RowBreak);n.push(...a.map(t=>t.node))}return function(t){const e=t.peek();void 0!==e&&e.type===Nt.GroupClose&&t.next()}(t),e.push(N(n)),dt(z("mtable",e.map(t=>z("mtr",z("mtd",t))).join("")))}(this):"right"===t?(n=e.position,ne(this),this.error({message:"Unmatched \\right",position:n}),dt(N([]))):void 0;var n}symbolAtom(t){switch(t.kind){case ht.Ordinary:return dt(_(t.char),t.kind);case ht.Function:return dt(_(t.char,{mathvariant:"normal"}),t.kind);case ht.BigOp:return this.bigOperator(t);case ht.Open:case ht.Close:return dt(B(t.char,{fence:!0}),t.kind);default:return dt(B(t.char),t.kind)}}bigOperator(t){if(/[a-z]/i.test(t.char))return mt(B(t.char,{movablelimits:!0}),t.kind);const e=be.has(t.char);return mt(B(t.char,{movablelimits:!0,largeop:!0}),t.kind,e)}controlSymbolAtom(t){if(Qt(t)){const e=Jt(t);return void 0===e?void 0:dt(e)}return"{"===t?dt(B("{",{fence:!0}),ht.Open):"}"===t?dt(B("}",{fence:!0}),ht.Close):dt("|"===t?B("‖"):"\\"===t?B("\\"):"/"===t?B("/"):"'"===t?B("′"):"."===t?B("."):I(t))}parseArgument(){return""===(t=this.parseArgumentRaw())?D(""):t;var t}parseArgumentRaw(){const t=this.peek();if(void 0===t)return"";if(t.type===Nt.GroupOpen){this.next();const t=this.parseExpression(()=>!1);return this.expect(Nt.GroupClose),N(t.map(t=>t.node))}return this.parseBaseAtom()?.node??""}parseOptionalArgument(){const t=this.peek();if(void 0===t||t.type!==Nt.Char||"["!==t.value)return;this.next();const e=this.parseExpression(t=>t.type===Nt.Char&&"]"===t.value),n=this.peek();return void 0!==n&&n.type===Nt.Char&&"]"===n.value&&this.next(),N(e.map(t=>t.node))}parseRawArgument(){const t=this.peek();if(void 0===t)return"";if(t.type!==Nt.GroupOpen)return this.next(),t.value;const e=t.position;this.next();let n=1,i=this.source.length;for(;;){const t=this.next();if(void 0===t)break;if(t.type===Nt.GroupOpen)n+=1;else if(t.type===Nt.GroupClose&&(n-=1,0===n)){i=t.position;break}}return this.source.slice(e+1,i)}expect(t){const e=this.peek();void 0===e||e.type!==t?t===Nt.GroupClose&&this.error({message:"Unmatched brace"}):this.next()}},ve="<mrow></mrow>";function xe(t,e){const n=e?.display??!1;if(""===t.trim())return{presentation:ve,errors:[]};const{atoms:i,errors:a}=function(t,e){const n=new ge(t,function(t){const e=[];let n=0;for(;n<t.length;){const i=t[n]??"";if("\\"===i){const i=Mt(t,n);if(e.push(i),n+="rowBreak"===i.type?2:Math.max(1,i.value.length)+1,"command"===i.type&&qt(i.value[0]??""))for(;n<t.length&&Ot(t[n]??"");)n+=1;continue}if(Rt(i)){const i=jt(t,n);e.push(i),n+=i.value.length;continue}if(Ot(i)){n+=1;continue}const a=Ht(i,n);a&&e.push(a),n+=1}return e}(t),e);return{atoms:n.parseTopLevel(),errors:n.collectedErrors}}(t,n);return{presentation:ye(i),errors:a}}function ye(t){if(0===t.length)return ve;if(1===t.length){const e=t[0];return e?e.node:ve}return D(t.map(t=>t.node).join(""))}var we=/(?<!\$)\$([^$\n\uFFFC]+)\$$/,Le=/\$\$([^$\n\uFFFC]+)\$\$$/;function ke(t,e){const n=t.getBlock(e);return void 0!==n&&"code_block"!==n.type}function Se(t,e){const n=t-e;return n<0?null:{from:n,to:t}}var Ce={insertInline:"Insert formula",insertInlineTooltip:"Insert inline formula",editFormula:"Edit formula",latexLabel:"LaTeX",latexPlaceholder:"e.g. \\frac{a}{b} + \\sqrt{x}",previewLabel:"Preview",insertButton:"Insert",updateButton:"Update",cancelButton:"Cancel",displayToggle:"Display (block) equation",sizeLabel:"Size",sizeDefault:"Default",altLabel:"Description",altPlaceholder:"Spoken description (optional)",paletteLabel:"Symbols and structures",emptyPreview:"Nothing to preview yet.",inserted:"Formula inserted.",updated:"Formula updated.",editing:"Editing formula.",selected:"Formula selected. Press Enter to edit.",unknownCommand:t=>`Unknown LaTeX command: ${t}`,groupFractions:"Fractions",groupScripts:"Scripts",groupRoots:"Roots",groupAccents:"Accents",groupOperators:"Operators",groupFunctions:"Functions",groupGreek:"Greek letters",groupRelations:"Relations",groupSets:"Sets",groupLogic:"Logic",groupArrows:"Arrows",groupDelimiters:"Brackets",groupDots:"Dots",groupMatrices:"Matrices"},$e=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-D1jFXqLJ.mjs"),"./locales/de.ts":()=>import("./de-DY3obIAF.mjs"),"./locales/es.ts":()=>import("./es-CtOtKQCP.mjs"),"./locales/fr.ts":()=>import("./fr-DjMZ-3K5.mjs"),"./locales/hi.ts":()=>import("./hi-4CiAKVjT.mjs"),"./locales/pt.ts":()=>import("./pt-BkpVtod-.mjs"),"./locales/ru.ts":()=>import("./ru-BotG0MFT.mjs"),"./locales/zh.ts":()=>import("./zh-CWGAPVei.mjs")});async function Ae(t){return f($e,t,Ce)}var ze=/^\s*\$\$([^\n]+?)\$\$\s*$/;function _e(t,e){const{presentation:n}=xe(t,{display:e});return{mathml:j({presentation:n,latex:t,display:e}),latex:t,alt:"",fontSize:""}}var Ee=class{root;buttons=[];activeIndex=0;constructor(t,e,n){this.root=document.createElement("div"),this.root.className="notectl-math-palette",this.root.setAttribute("role","toolbar"),this.root.setAttribute("aria-label",e);for(const i of t)this.root.appendChild(this.buildGroup(i,n));this.root.addEventListener("keydown",t=>this.onKeydown(t)),this.setActive(0)}focus(){this.buttons[this.activeIndex]?.focus()}activeButton(){return this.buttons[this.activeIndex]}buildGroup(t,e){const n=document.createElement("div");n.className="notectl-math-palette__group",n.setAttribute("role","group"),n.setAttribute("aria-label",t.label);for(const i of t.items){const t=document.createElement("button");t.type="button",t.className="notectl-math-palette__btn",t.textContent=i.label,t.setAttribute("aria-label",i.ariaLabel),t.tabIndex=-1,t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),t.addEventListener("click",()=>e(i.snippet)),this.buttons.push(t),n.appendChild(t)}return n}onKeydown(t){if("Enter"===t.key||" "===t.key)return t.preventDefault(),t.stopPropagation(),void this.buttons[this.activeIndex]?.click();const e=this.buttons.length-1;let n=this.activeIndex;switch(t.key){case"ArrowRight":case"ArrowDown":n=this.activeIndex>=e?0:this.activeIndex+1;break;case"ArrowLeft":case"ArrowUp":n=this.activeIndex<=0?e:this.activeIndex-1;break;case"Home":n=0;break;case"End":n=e;break;default:return}t.preventDefault(),t.stopPropagation(),this.setActive(n),this.buttons[n]?.focus()}setActive(t){const e=this.buttons[this.activeIndex];e&&(e.tabIndex=-1);const n=this.buttons[t];n&&(n.tabIndex=0),this.activeIndex=t}},Be=0,Ie=class{root;options;textarea;preview;previewEmpty;errorsList;altInput;commitBtn;palette=null;displayCheckbox=null;cancelBtn=null;fontSizeSelect=null;display;lastErrorKey="";constructor(t){this.options=t,this.display=t.initialDisplay??!1;const e=++Be;this.root=document.createElement("div"),this.root.className="notectl-formula-editor",this.root.setAttribute("role","group"),this.root.setAttribute("aria-label",t.locale.latexLabel),t.palette&&t.palette.length>0&&(this.palette=new Ee(t.palette,t.locale.paletteLabel,t=>this.insertSnippet(t)),this.root.appendChild(this.palette.root)),this.textarea=this.buildLatexField(e),this.preview=document.createElement("div"),this.previewEmpty=document.createElement("div"),this.errorsList=document.createElement("ul"),this.altInput=this.buildAltField(e),this.commitBtn=document.createElement("button"),this.root.appendChild(this.buildPreview()),this.root.appendChild(this.errorsList),this.root.appendChild(this.altInput.parentElement),t.fontSizes&&t.fontSizes.length>0&&this.root.appendChild(this.buildSizeField(e)),"insert"===t.mode&&this.root.appendChild(this.buildDisplayToggle(e)),this.root.appendChild(this.buildActions()),this.errorsList.className="notectl-formula-editor__errors",this.errorsList.id=`notectl-formula-errors-${e}`,this.errorsList.setAttribute("aria-live","polite"),this.textarea.setAttribute("aria-describedby",this.errorsList.id),this.root.addEventListener("keydown",t=>this.onRootKeydown(t)),this.update()}focus(){this.textarea.focus(),this.textarea.setSelectionRange(this.textarea.value.length,this.textarea.value.length)}onRootKeydown(t){if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void this.options.onCancel();"Tab"===t.key&&(t.preventDefault(),t.stopPropagation(),this.moveFocus(!t.shiftKey))}focusStops(){const t=[],e=this.palette?.activeButton();return e&&t.push(e),t.push(this.textarea,this.altInput),this.fontSizeSelect&&t.push(this.fontSizeSelect),this.displayCheckbox&&t.push(this.displayCheckbox),this.cancelBtn&&t.push(this.cancelBtn),t.push(this.commitBtn),t}moveFocus(t){const e=this.focusStops();if(0===e.length)return;const n=this.activeElement();let i=e.findIndex(t=>t===n);-1===i&&n&&this.palette?.root.contains(n)&&(i=0),-1===i&&(i=t?e.length-1:0),e[(i+(t?1:-1)+e.length)%e.length]?.focus()}activeElement(){let t=this.root.getRootNode().activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}getResult(){const t=this.textarea.value.trim(),e=this.altInput.value.trim(),{presentation:n}=xe(t,{display:this.display});return{latex:t,mathml:j({presentation:n,latex:t,display:this.display,alt:e||void 0}),alt:e,display:this.display,fontSize:this.fontSizeSelect?.value??""}}insertSnippet(t){const e=this.textarea.selectionStart??this.textarea.value.length,n=this.textarea.selectionEnd??e,i=t.indexOf("$0"),a=i>=0?t.replace("$0",""):t,r=i>=0?i:a.length,o=this.textarea.value;this.textarea.value=o.slice(0,e)+a+o.slice(n);const l=e+r;this.textarea.focus(),this.textarea.setSelectionRange(l,l),this.update()}buildLatexField(t){const e=document.createElement("div");e.className="notectl-formula-editor__field";const n=document.createElement("label");n.className="notectl-formula-editor__label",n.htmlFor=`notectl-formula-latex-${t}`,n.textContent=this.options.locale.latexLabel;const i=document.createElement("textarea");return i.id=`notectl-formula-latex-${t}`,i.className="notectl-formula-editor__input",i.placeholder=this.options.locale.latexPlaceholder,i.rows=2,i.spellcheck=!1,i.value=this.options.initialLatex??"",i.addEventListener("input",()=>this.update()),i.addEventListener("keydown",t=>this.onTextareaKeydown(t)),e.appendChild(n),e.appendChild(i),this.root.appendChild(e),i}buildPreview(){const t=document.createElement("div");t.className="notectl-formula-editor__field";const e=document.createElement("span");return e.className="notectl-formula-editor__label",e.textContent=this.options.locale.previewLabel,this.preview.className="notectl-formula-editor__preview",this.previewEmpty.className="notectl-formula-editor__preview-empty",this.previewEmpty.textContent=this.options.locale.emptyPreview,t.appendChild(e),t.appendChild(this.previewEmpty),t.appendChild(this.preview),t}buildAltField(t){const e=document.createElement("div");e.className="notectl-formula-editor__field";const n=document.createElement("label");n.className="notectl-formula-editor__label",n.htmlFor=`notectl-formula-alt-${t}`,n.textContent=this.options.locale.altLabel;const i=document.createElement("input");return i.id=`notectl-formula-alt-${t}`,i.type="text",i.className="notectl-formula-editor__alt",i.placeholder=this.options.locale.altPlaceholder,i.value=this.options.initialAlt??"",e.appendChild(n),e.appendChild(i),i}buildSizeField(t){const e=document.createElement("div");e.className="notectl-formula-editor__field";const n=document.createElement("label");n.className="notectl-formula-editor__label",n.htmlFor=`notectl-formula-size-${t}`,n.textContent=this.options.locale.sizeLabel;const i=document.createElement("select");i.id=`notectl-formula-size-${t}`,i.className="notectl-formula-editor__size";const a=this.options.initialFontSize??"";i.appendChild(this.buildSizeOption("",this.options.locale.sizeDefault));for(const r of this.options.fontSizes??[])i.appendChild(this.buildSizeOption(`${r}px`,String(r)));return a&&!Array.from(i.options).some(t=>t.value===a)&&i.appendChild(this.buildSizeOption(a,a.replace("px",""))),i.value=a,i.addEventListener("change",()=>this.applyPreviewFontSize()),this.fontSizeSelect=i,e.appendChild(n),e.appendChild(i),e}buildSizeOption(t,e){const n=document.createElement("option");return n.value=t,n.textContent=e,n}applyPreviewFontSize(){this.preview.style.fontSize=this.fontSizeSelect?.value||""}buildDisplayToggle(t){const e=document.createElement("label");e.className="notectl-formula-editor__toggle",e.htmlFor=`notectl-formula-display-${t}`;const n=document.createElement("input");n.id=`notectl-formula-display-${t}`,n.type="checkbox",n.checked=this.display,n.addEventListener("change",()=>{this.display=n.checked,this.update()}),this.displayCheckbox=n;const i=document.createElement("span");return i.textContent=this.options.locale.displayToggle,e.appendChild(n),e.appendChild(i),e}buildActions(){const t=document.createElement("div");t.className="notectl-formula-editor__actions";const e=document.createElement("button");return e.type="button",e.className="notectl-formula-editor__btn",e.textContent=this.options.locale.cancel,e.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),e.addEventListener("click",()=>this.options.onCancel()),this.cancelBtn=e,this.commitBtn.type="button",this.commitBtn.className="notectl-formula-editor__btn notectl-formula-editor__btn--primary",this.commitBtn.textContent="edit"===this.options.mode?this.options.locale.commitUpdate:this.options.locale.commitInsert,this.commitBtn.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),this.commitBtn.addEventListener("click",()=>this.commit()),t.appendChild(e),t.appendChild(this.commitBtn),t}onTextareaKeydown(t){"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.commit())}commit(){const t=this.getResult();t.latex?this.options.onCommit(t):this.options.onCancel()}update(){this.applyPreviewFontSize();const t=this.textarea.value.trim();if(!t)return this.preview.innerHTML="",this.previewEmpty.hidden=!1,void this.renderErrors([]);this.previewEmpty.hidden=!0;const{presentation:e,errors:n}=xe(t,{display:this.display});this.preview.innerHTML=j({presentation:e,display:this.display}),this.renderErrors(n.map(t=>t.command??t.message))}renderErrors(t){const e=t.join("");if(e!==this.lastErrorKey){this.lastErrorKey=e,this.errorsList.replaceChildren();for(const e of t){const t=document.createElement("li");t.textContent=e.startsWith("\\")?this.options.locale.unknownCommand(e):e,this.errorsList.appendChild(t)}}}};function Pe(t){return[{id:"fractions",label:(e={fractions:t.groupFractions,scripts:t.groupScripts,roots:t.groupRoots,accents:t.groupAccents,operators:t.groupOperators,functions:t.groupFunctions,greek:t.groupGreek,relations:t.groupRelations,sets:t.groupSets,logic:t.groupLogic,arrows:t.groupArrows,delimiters:t.groupDelimiters,dots:t.groupDots,matrices:t.groupMatrices}).fractions,items:[{label:"a╱b",ariaLabel:"Fraction",snippet:"\\frac{$0}{}"},{label:"⒞",ariaLabel:"Binomial coefficient",snippet:"\\binom{$0}{}"}]},{id:"scripts",label:e.scripts,items:[{label:"xⁿ",ariaLabel:"Superscript",snippet:"^{$0}"},{label:"xₙ",ariaLabel:"Subscript",snippet:"_{$0}"},{label:"xⁿₘ",ariaLabel:"Subscript and superscript",snippet:"_{$0}^{}"}]},{id:"roots",label:e.roots,items:[{label:"√",ariaLabel:"Square root",snippet:"\\sqrt{$0}"},{label:"ⁿ√",ariaLabel:"N-th root",snippet:"\\sqrt[$0]{}"}]},{id:"accents",label:e.accents,items:[{label:"→",ariaLabel:"Vector",snippet:"\\vec{$0}"},{label:"â",ariaLabel:"Hat",snippet:"\\hat{$0}"},{label:"ā",ariaLabel:"Overline",snippet:"\\overline{$0}"},{label:"ȧ",ariaLabel:"Dot above",snippet:"\\dot{$0}"},{label:"ã",ariaLabel:"Tilde",snippet:"\\tilde{$0}"}]},{id:"operators",label:e.operators,items:[{label:"∑",ariaLabel:"Sum with limits",snippet:"\\sum_{$0}^{}"},{label:"∏",ariaLabel:"Product with limits",snippet:"\\prod_{$0}^{}"},{label:"∫",ariaLabel:"Integral with limits",snippet:"\\int_{$0}^{}"},{label:"∬",ariaLabel:"Double integral",snippet:"\\iint "},{label:"∮",ariaLabel:"Contour integral",snippet:"\\oint "},{label:"lim",ariaLabel:"Limit",snippet:"\\lim_{$0}"},{label:"∂",ariaLabel:"Partial derivative",snippet:"\\partial "},{label:"∇",ariaLabel:"Nabla (del)",snippet:"\\nabla "},{label:"×",ariaLabel:"Times",snippet:"\\times "},{label:"·",ariaLabel:"Dot product",snippet:"\\cdot "},{label:"±",ariaLabel:"Plus or minus",snippet:"\\pm "},{label:"÷",ariaLabel:"Division",snippet:"\\div "},{label:"∞",ariaLabel:"Infinity",snippet:"\\infty "}]},{id:"functions",label:e.functions,items:[{label:"sin",ariaLabel:"Sine",snippet:"\\sin "},{label:"cos",ariaLabel:"Cosine",snippet:"\\cos "},{label:"tan",ariaLabel:"Tangent",snippet:"\\tan "},{label:"log",ariaLabel:"Logarithm",snippet:"\\log "},{label:"ln",ariaLabel:"Natural logarithm",snippet:"\\ln "},{label:"exp",ariaLabel:"Exponential function",snippet:"\\exp "}]},{id:"greek",label:e.greek,items:[{label:"α",ariaLabel:"Alpha",snippet:"\\alpha "},{label:"β",ariaLabel:"Beta",snippet:"\\beta "},{label:"γ",ariaLabel:"Gamma",snippet:"\\gamma "},{label:"δ",ariaLabel:"Delta",snippet:"\\delta "},{label:"ε",ariaLabel:"Epsilon",snippet:"\\varepsilon "},{label:"ζ",ariaLabel:"Zeta",snippet:"\\zeta "},{label:"η",ariaLabel:"Eta",snippet:"\\eta "},{label:"θ",ariaLabel:"Theta",snippet:"\\theta "},{label:"κ",ariaLabel:"Kappa",snippet:"\\kappa "},{label:"λ",ariaLabel:"Lambda",snippet:"\\lambda "},{label:"μ",ariaLabel:"Mu",snippet:"\\mu "},{label:"ν",ariaLabel:"Nu",snippet:"\\nu "},{label:"ξ",ariaLabel:"Xi",snippet:"\\xi "},{label:"π",ariaLabel:"Pi",snippet:"\\pi "},{label:"ρ",ariaLabel:"Rho",snippet:"\\rho "},{label:"σ",ariaLabel:"Sigma",snippet:"\\sigma "},{label:"τ",ariaLabel:"Tau",snippet:"\\tau "},{label:"φ",ariaLabel:"Phi",snippet:"\\varphi "},{label:"χ",ariaLabel:"Chi",snippet:"\\chi "},{label:"ψ",ariaLabel:"Psi",snippet:"\\psi "},{label:"ω",ariaLabel:"Omega",snippet:"\\omega "},{label:"Γ",ariaLabel:"Capital gamma",snippet:"\\Gamma "},{label:"Δ",ariaLabel:"Capital delta",snippet:"\\Delta "},{label:"Θ",ariaLabel:"Capital theta",snippet:"\\Theta "},{label:"Λ",ariaLabel:"Capital lambda",snippet:"\\Lambda "},{label:"Π",ariaLabel:"Capital pi",snippet:"\\Pi "},{label:"Σ",ariaLabel:"Capital sigma",snippet:"\\Sigma "},{label:"Φ",ariaLabel:"Capital phi",snippet:"\\Phi "},{label:"Ψ",ariaLabel:"Capital psi",snippet:"\\Psi "},{label:"Ω",ariaLabel:"Capital omega",snippet:"\\Omega "}]},{id:"relations",label:e.relations,items:[{label:"≤",ariaLabel:"Less than or equal to",snippet:"\\leq "},{label:"≥",ariaLabel:"Greater than or equal to",snippet:"\\geq "},{label:"≠",ariaLabel:"Not equal to",snippet:"\\neq "},{label:"≈",ariaLabel:"Approximately equal to",snippet:"\\approx "},{label:"≡",ariaLabel:"Equivalent to",snippet:"\\equiv "},{label:"∼",ariaLabel:"Similar to",snippet:"\\sim "},{label:"≅",ariaLabel:"Congruent to",snippet:"\\cong "},{label:"∝",ariaLabel:"Proportional to",snippet:"\\propto "}]},{id:"sets",label:e.sets,items:[{label:"∈",ariaLabel:"Element of",snippet:"\\in "},{label:"∉",ariaLabel:"Not an element of",snippet:"\\notin "},{label:"⊂",ariaLabel:"Subset of",snippet:"\\subset "},{label:"⊆",ariaLabel:"Subset of or equal to",snippet:"\\subseteq "},{label:"∪",ariaLabel:"Union",snippet:"\\cup "},{label:"∩",ariaLabel:"Intersection",snippet:"\\cap "},{label:"∅",ariaLabel:"Empty set",snippet:"\\emptyset "},{label:"ℝ",ariaLabel:"Real numbers",snippet:"\\mathbb{R}"},{label:"ℕ",ariaLabel:"Natural numbers",snippet:"\\mathbb{N}"},{label:"ℤ",ariaLabel:"Integers",snippet:"\\mathbb{Z}"},{label:"ℚ",ariaLabel:"Rational numbers",snippet:"\\mathbb{Q}"},{label:"ℂ",ariaLabel:"Complex numbers",snippet:"\\mathbb{C}"}]},{id:"logic",label:e.logic,items:[{label:"∀",ariaLabel:"For all",snippet:"\\forall "},{label:"∃",ariaLabel:"There exists",snippet:"\\exists "},{label:"¬",ariaLabel:"Logical not",snippet:"\\neg "},{label:"∧",ariaLabel:"Logical and",snippet:"\\land "},{label:"∨",ariaLabel:"Logical or",snippet:"\\lor "},{label:"⟹",ariaLabel:"Implies",snippet:"\\implies "},{label:"⟺",ariaLabel:"If and only if",snippet:"\\iff "}]},{id:"arrows",label:e.arrows,items:[{label:"→",ariaLabel:"Right arrow",snippet:"\\to "},{label:"⇒",ariaLabel:"Rightwards double arrow",snippet:"\\Rightarrow "},{label:"↔",ariaLabel:"Left-right arrow",snippet:"\\leftrightarrow "},{label:"↦",ariaLabel:"Maps to",snippet:"\\mapsto "}]},{id:"delimiters",label:e.delimiters,items:[{label:"( )",ariaLabel:"Auto-sized parentheses",snippet:"\\left($0\\right)"},{label:"[ ]",ariaLabel:"Auto-sized brackets",snippet:"\\left[$0\\right]"},{label:"{ }",ariaLabel:"Auto-sized braces",snippet:"\\left\\{$0\\right\\}"},{label:"|x|",ariaLabel:"Absolute value",snippet:"\\left|$0\\right|"},{label:"‖x‖",ariaLabel:"Norm",snippet:"\\left\\|$0\\right\\|"},{label:"⌊x⌋",ariaLabel:"Floor",snippet:"\\left\\lfloor $0\\right\\rfloor"},{label:"⌈x⌉",ariaLabel:"Ceiling",snippet:"\\left\\lceil $0\\right\\rceil"}]},{id:"dots",label:e.dots,items:[{label:"⋯",ariaLabel:"Centred ellipsis",snippet:"\\cdots "},{label:"…",ariaLabel:"Baseline ellipsis",snippet:"\\ldots "},{label:"⋮",ariaLabel:"Vertical ellipsis",snippet:"\\vdots "},{label:"⋱",ariaLabel:"Diagonal ellipsis",snippet:"\\ddots "}]},{id:"matrices",label:e.matrices,items:[{label:"[ ]",ariaLabel:"Bracket matrix",snippet:"\\begin{bmatrix} $0 & \\\\ & \\end{bmatrix}"},{label:"( )",ariaLabel:"Parenthesis matrix",snippet:"\\begin{pmatrix} $0 & \\\\ & \\end{pmatrix}"},{label:"{",ariaLabel:"Cases",snippet:"\\begin{cases} $0 & \\\\ & \\end{cases}"}]}];var e}function De(t,e){const n=new Ie({locale:(i=e.locale,{latexLabel:i.latexLabel,latexPlaceholder:i.latexPlaceholder,previewLabel:i.previewLabel,emptyPreview:i.emptyPreview,altLabel:i.altLabel,altPlaceholder:i.altPlaceholder,displayToggle:i.displayToggle,sizeLabel:i.sizeLabel,sizeDefault:i.sizeDefault,commitInsert:i.insertButton,commitUpdate:i.updateButton,cancel:i.cancelButton,paletteLabel:i.paletteLabel,unknownCommand:i.unknownCommand}),mode:e.mode,initialLatex:e.initialLatex,initialAlt:e.initialAlt,initialDisplay:e.initialDisplay,initialFontSize:e.initialFontSize,fontSizes:e.fontSizes,palette:Pe(e.locale),onCommit:e.onCommit,onCancel:e.onClose});var i;return t.appendChild(n.root),requestAnimationFrame(()=>n.focus()),n}var Ne=class{context;locale;fontSizes;panel=null;outsideHandler=null;constructor(t,e,n){this.context=t,this.locale=e,this.fontSizes=n}isOpen(){return null!==this.panel}openInsert(t){if(this.context.isReadOnly())return;const e=Fe();this.open({rect:e,mode:"insert",initialDisplay:t,onCommit:t=>{ut(this.context,this.locale,t),this.close(!0)}})}openEdit(t){this.context.isReadOnly()||(this.context.announce(this.locale.editing),this.open({rect:t.rect??Fe(),mode:"edit",initialLatex:t.latex,initialAlt:t.alt,initialDisplay:"display"===t.kind,initialFontSize:t.fontSize,onCommit:e=>{this.commitEdit(t,e),this.context.announce(this.locale.updated),this.close(!0)}}))}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())}commitEdit(t,e){const n=pt(e);"inline"===t.kind&&t.blockId&&void 0!==t.offset?function(t,e,n,i){const a=t.getState().transaction("command").setInlineNodeAttr(e,n,lt(i)).build();t.dispatch(a)}(this.context,t.blockId,t.offset,n):"display"===t.kind&&t.path&&function(t,e,n){const i=t.getState().transaction("command").setNodeAttr(e,lt(n)).build();t.dispatch(i)}(this.context,t.path,n)}open(t){this.close(!1);const e=document.createElement("div");e.className="notectl-formula-overlay",e.setAttribute("role","dialog"),e.setAttribute("aria-label","edit"===t.mode?this.locale.editFormula:this.locale.insertInline),this.panel=e,De(e,{context:this.context,locale:this.locale,mode:t.mode,initialLatex:t.initialLatex,initialAlt:t.initialAlt,initialDisplay:t.initialDisplay,initialFontSize:t.initialFontSize,fontSizes:this.fontSizes,onCommit:t.onCommit,onClose:()=>this.close(!0)}),this.context.getPluginContainer("top").appendChild(e),y(e),function(t,e){const n=e?e.bottom:window.innerHeight/3,i=e?e.left:window.innerWidth/3,a=t.offsetWidth||360,r=window.innerWidth-a-8,o=Math.max(8,Math.min(i,r)),l=window.innerHeight-t.offsetHeight-8,s=Math.min(n+8,Math.max(8,l));t.style.left=`${Math.round(o)}px`,t.style.top=`${Math.round(s)}px`}(e,t.rect),this.installOutsideHandler()}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 Fe(){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}function qe(t){const e=document.createElement("template");return e.innerHTML=t,e.content}function Re(t){const e=function(t){const e=L.sanitize(t,{ALLOWED_TAGS:[...at],ALLOWED_ATTR:[...rt]});return/<math[\s>]/i.test(e)?e:null}(t.outerHTML);if(!e)return null;const n=G(e);return{mathml:n,latex:H(n)??"",alt:"",fontSize:Q(t)}}var Oe=class{id="formula";name="Formula";priority=46;config;resolvedKeymap;fontSizes;locale=Ce;overlay=null;context=null;clickHandler=null;constructor(t){this.config={...it,...t},this.resolvedKeymap={...et,...t?.keymap},this.fontSizes=this.config.fontSizes??nt}async init(t){var e;if(this.context=t,this.locale=await g(t,this.config.locale,Ce,Ae),t.registerStyleSheet("\n.notectl-math math {\n\tfont-family: 'Notectl Math', math;\n}\n\n.notectl-math--inline {\n\tdisplay: inline-block;\n\tvertical-align: middle;\n\tpadding: 0 1px;\n\tborder-radius: 3px;\n\tcursor: pointer;\n}\n\n.notectl-math--inline:hover {\n\tbackground: var(--notectl-highlight, rgba(0, 0, 0, 0.06));\n}\n\n.notectl-math--inline:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 1px;\n}\n\n.notectl-math--inline math {\n\tfont-size: 1.15em;\n}\n\n.notectl-math--display {\n\tdisplay: block;\n\tmargin: 12px 0;\n\ttext-align: center;\n\tcursor: pointer;\n\tuser-select: none;\n\t-webkit-user-select: none;\n}\n\n.notectl-math--display math {\n\tfont-size: 1.35em;\n\tdisplay: inline-block;\n}\n\n.notectl-math--display.notectl-math--selected {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 4px;\n\tborder-radius: 6px;\n}\n\n.notectl-math__error,\n.notectl-math merror {\n\tcolor: var(--notectl-danger, #c0392b);\n\tbackground: var(--notectl-danger-bg, rgba(192, 57, 43, 0.1));\n\tborder-radius: 3px;\n\tpadding: 0 2px;\n}\n"),t.registerStyleSheet("\n.notectl-formula-editor {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tpadding: 10px;\n\tmin-width: 320px;\n\tmax-width: 460px;\n\tbox-sizing: border-box;\n}\n\n.notectl-formula-editor__field {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n}\n\n.notectl-formula-editor__label {\n\tfont-size: 12px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-fg-muted, #555);\n}\n\n.notectl-formula-editor__input {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tpadding: 6px 8px;\n\tfont-family: 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;\n\tfont-size: 13px;\n\tline-height: 1.5;\n\tresize: vertical;\n\tmin-height: 56px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-overlay, #fff);\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-formula-editor__alt {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tpadding: 5px 8px;\n\tfont-size: 13px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-overlay, #fff);\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-formula-editor__size {\n\tbox-sizing: border-box;\n\tpadding: 5px 8px;\n\tfont-size: 13px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-overlay, #fff);\n\tcolor: var(--notectl-fg);\n\tcursor: pointer;\n}\n\n.notectl-formula-editor__size:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 1px;\n}\n\n.notectl-formula-editor__preview {\n\tmin-height: 44px;\n\tpadding: 8px;\n\tborder: 1px dashed var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised, #fafafa);\n\ttext-align: center;\n\toverflow-x: auto;\n}\n\n.notectl-formula-editor__preview math {\n\tfont-family: 'Notectl Math', math;\n\tfont-size: 1.3em;\n}\n\n.notectl-formula-editor__preview-empty {\n\tcolor: var(--notectl-fg-muted, #888);\n\tfont-size: 13px;\n}\n\n.notectl-formula-editor__errors {\n\tcolor: var(--notectl-danger, #c0392b);\n\tfont-size: 12px;\n\tmargin: 0;\n\tpadding-inline-start: 16px;\n}\n\n.notectl-formula-editor__row {\n\tdisplay: flex;\n\tgap: 8px;\n\talign-items: center;\n}\n\n.notectl-formula-editor__toggle {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 6px;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-formula-editor__actions {\n\tdisplay: flex;\n\tgap: 8px;\n\tjustify-content: flex-end;\n\tmargin-top: 2px;\n}\n\n.notectl-formula-editor__btn {\n\tpadding: 6px 14px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-raised);\n\tcolor: var(--notectl-fg);\n\tcursor: pointer;\n\tfont-size: 13px;\n}\n\n.notectl-formula-editor__btn--primary {\n\tbackground: var(--notectl-primary);\n\tborder-color: var(--notectl-primary);\n\tcolor: var(--notectl-primary-fg, #fff);\n}\n\n.notectl-formula-editor__btn:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n\n.notectl-formula-overlay {\n\tposition: fixed;\n\tz-index: 1000;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 8px;\n\tbackground: var(--notectl-surface-overlay, #fff);\n\tbox-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);\n}\n\n.notectl-math-palette {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 8px;\n\tpadding: 2px 2px 8px;\n\tborder-bottom: 1px solid var(--notectl-border);\n\tmargin-bottom: 2px;\n\tmax-height: 216px;\n\toverflow-y: auto;\n}\n\n.notectl-math-palette__group {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 2px;\n}\n\n.notectl-math-palette__group + .notectl-math-palette__group {\n\tborder-inline-start: 1px solid var(--notectl-border);\n\tpadding-inline-start: 6px;\n}\n\n.notectl-math-palette__btn {\n\tmin-width: 30px;\n\theight: 30px;\n\tpadding: 0 6px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcolor: var(--notectl-fg);\n\tcursor: pointer;\n\tfont-size: 15px;\n\tline-height: 1;\n}\n\n.notectl-math-palette__btn:hover {\n\tbackground: var(--notectl-surface-raised);\n}\n\n.notectl-math-palette__btn:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 1px;\n}\n"),this.config.mathFont&&t.registerStyleSheet(function(t){const e=(t.family.split(",")[0]??t.name).trim().replace(/['"]/g,"");return(t.fontFaces??[]).map(t=>{const n=[`font-family: '${e}'`,`src: ${t.src}`];return t.weight&&n.push(`font-weight: ${t.weight}`),t.style&&n.push(`font-style: ${t.style}`),n.push(`font-display: ${t.display??"swap"}`),`@font-face { ${n.join("; ")}; }`}).join("\n")}(this.config.mathFont)),t.registerInlineNodeSpec({type:Y,attrs:{mathml:{default:""},latex:{default:""},alt:{default:""},fontSize:{default:""}},toDOM(t){const e=document.createElement("span");return e.className="notectl-math notectl-math--inline",e.setAttribute("contenteditable","false"),e.setAttribute("data-inline-type",Y),W(e,Z(t.attrs)),V(e,t.attrs),e},toHTMLString:t=>X(Z(t.attrs)),toMarkdown:t=>`$${String(t.attrs.latex??"")}$`,parseHTML:[{tag:"math",getAttrs:t=>J(t,!1)}],sanitize:{tags:[...at],attrs:[...rt]}}),t.registerNodeSpec({type:tt,group:"block",isVoid:!0,selectable:!0,attrs:{mathml:{default:""},latex:{default:""},alt:{default:""},fontSize:{default:""}},toDOM(t){const e=v("div",t.id);return e.className="notectl-math notectl-math--display",e.setAttribute("data-void","true"),e.setAttribute("data-selectable","true"),W(e,Z(t.attrs)),V(e,t.attrs),e},toHTML:t=>X(Z(t.attrs)),toMarkdown:t=>`$$\n${String(t.attrs?.latex??"")}\n$$`,parseHTML:[{tag:"math",getAttrs:t=>J(t,!0)}],sanitize:{tags:[...at],attrs:[...rt]}}),this.overlay=new Ne(t,this.locale,this.fontSizes),t.registerNodeView(tt,(e={onEdit:(t,e)=>this.editDisplay(t,e),onSelect:()=>t.announce(this.locale.selected)},t=>{let n=t.id,i=!1;const a=v("div",t.id);return a.className="notectl-math notectl-math--display",a.setAttribute("data-void","true"),a.setAttribute("data-selectable","true"),W(a,Z(t.attrs)),V(a,t.attrs),a.addEventListener("dblclick",t=>{t.preventDefault(),e.onEdit(n,a.getBoundingClientRect())}),{dom:a,contentDOM:null,update:t=>"math_display"===t.type&&(n=t.id,a.setAttribute("data-block-id",t.id),W(a,Z(t.attrs)),V(a,t.attrs),!0),selectNode(){a.classList.add("notectl-math--selected"),i||(i=!0,e.onSelect())},deselectNode(){a.classList.remove("notectl-math--selected"),i=!1}}})),!1!==this.config.inputRule)for(const n of[{pattern:Le,handler(t,e){const n=t.selection;if(!c(n)||!o(n))return null;const i=(e[1]??"").trim();if(!i)return null;const r=n.anchor.blockId;if(!ke(t,r))return null;const s=Se(n.anchor.offset,e[0].length);if(!s)return null;const u=t.doc.children.findIndex(t=>t.id===r);if(-1===u)return null;const{presentation:d}=xe(i,{display:!0}),m=j({presentation:d,latex:i,display:!0}),h=t.transaction("input").deleteTextAt(r,s.from,s.to);return function(t,e,n){const i=a(p(tt),[],void 0,lt(n)),r=a(p("paragraph"));t.insertNode([],e,i).insertNode([],e+1,r).setSelection(l(i.id,[]))}(h,u+1,{mathml:m,latex:i,alt:"",fontSize:""}),h.build()}},{pattern:we,handler(t,e){const n=t.selection;if(!c(n)||!o(n))return null;const a=(e[1]??"").trim();if(!a)return null;const r=n.anchor.blockId;if(!ke(t,r))return null;const l=Se(n.anchor.offset,e[0].length);if(!l)return null;const{presentation:p}=xe(a,{display:!1}),d=j({presentation:p,latex:a,display:!1}),m=i(u(Y),{mathml:d,latex:a,alt:"",fontSize:""});return t.transaction("input").deleteTextAt(r,l.from,l.to).insertInlineNode(r,l.from,m).setSelection(s(r,l.from+1)).build()}}])t.registerInputRule(n);t.registerMarkdownSyntax({id:"formula",matchInline(t,e){if("$"!==t[e]||"$"===t[e+1])return null;const n=function(t,e){for(let n=e;n<t.length;n++){const e=t[n]??"";if("\n"===e)return-1;if("$"===e)return n}return-1}(t,e+1);if(-1===n)return null;const i=t.slice(e+1,n).trim();return""===i?null:{type:Y,attrs:{..._e(i,!1)},length:n-e+1}},matchBlock(t,e){const n=t[e]??"",i=n.match(ze);if(i?.[1]?.trim())return{type:tt,attrs:{..._e(i[1].trim(),!0)},linesConsumed:1};if("$$"!==n.trim())return null;const a=[];let r=e+1;for(;r<t.length&&"$$"!==(t[r]??"").trim();)a.push(t[r]??""),r++;return r>=t.length?null:{type:tt,attrs:{..._e(a.join("\n").trim(),!0)},linesConsumed:r-e+1}}}),t.registerPasteInterceptor((t,e,n)=>{if(!function(t){if(!t)return!1;const e=qe(t);if(!e.querySelector("math"))return!1;const n=e.cloneNode(!0);for(const i of Array.from(n.querySelectorAll('math, [aria-hidden="true"]')))i.remove();return""===(n.textContent??"").trim()}(e))return null;const i=function(t){if(!t)return[];const e=qe(t);for(const n of Array.from(e.querySelectorAll('[aria-hidden="true"]')))n.remove();return Array.from(e.querySelectorAll("math"))}(e).map(Re).filter(t=>null!==t);return 0===i.length?null:i.every(t=>{return e=t.mathml,!/<math\b[^>]*\bdisplay=["']block["']/i.test(e);var e})?st(n,i):ct(n,i)},{name:"formula",priority:40}),this.registerCommands(t),this.registerKeymap(t),function(t,e,n){t.registerToolbarItem({id:"formula",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round"><path d="M18 5 H6 L12 12 L6 19 H18"/></svg>',label:e.insertInline,tooltip:e.insertInlineTooltip,command:"insertInlineFormula",popupType:"custom",renderPopup:(t,i,a)=>{De(t,{context:i,locale:e,mode:"insert",fontSizes:n,onClose:a,onCommit:t=>{ut(i,e,t),a(),i.getContainer().focus()}})}})}(t,this.locale,this.fontSizes),this.installClickToEdit(t)}destroy(){this.clickHandler&&this.context&&this.context.getContainer().removeEventListener("click",this.clickHandler),this.clickHandler=null,this.overlay?.close(!1),this.overlay=null,this.context=null}registerCommands(i){i.registerCommand("insertInlineFormula",()=>{const a=function(i){const a=i.selection;if(!c(a)||!o(a))return null;const r=a.anchor.blockId,l=i.getBlock(r);if(!l)return null;const s=a.anchor.offset;for(const{child:o,from:c,to:p}of t(n(l)))if(e(o)&&"math_inline"===o.inlineType&&(p===s||c===s)){const t=Z(o.attrs);return{kind:"inline",blockId:r,offset:c,latex:t.latex,alt:t.alt,fontSize:t.fontSize,rect:null}}return null}(i.getState());return a?(this.overlay?.openEdit(a),!0):(this.overlay?.openInsert(!1),!0)}),i.registerCommand("insertDisplayFormula",()=>{const t=ot(i.getState());return t?(this.editDisplay(t,null),!0):(this.overlay?.openInsert(!0),!0)})}registerKeymap(t){const e={},n=this.resolvedKeymap.insertInline,i=this.resolvedKeymap.insertDisplay;n&&(e[n]=()=>t.executeCommand("insertInlineFormula")),i&&(e[i]=()=>t.executeCommand("insertDisplayFormula")),e.Enter=()=>{const e=ot(t.getState());return!!e&&(this.editDisplay(e,null),!0)},t.registerKeymap(e,{priority:"context"})}installClickToEdit(i){const a=i.getContainer(),r=r=>{if(i.isReadOnly())return;const o=r.target?.closest(".notectl-math--inline");if(!o)return;const l=function(i,a,r){const o=x(i,a,0);if(!o)return null;const l=function(i,a,r){const o=i.getBlock(a);if(!o)return null;for(const{child:l,from:s}of t(n(o)))if(s===r&&e(l)&&"math_inline"===l.inlineType)return Z(l.attrs);return null}(r,o.blockId,o.offset);return l?{kind:"inline",blockId:o.blockId,offset:o.offset,latex:l.latex,alt:l.alt,fontSize:l.fontSize,rect:a.getBoundingClientRect()}:null}(a,o,i.getState());l&&(r.preventDefault(),this.overlay?.openEdit(l))};this.clickHandler=r,a.addEventListener("click",r)}editDisplay(t,e){if(!this.overlay||!this.context)return;const n=function(t,e,n){const i=t.getBlock(e);if(!i||"math_display"!==i.type)return null;const a=Z(i.attrs);return{kind:"display",path:t.getNodePath(e)??[e],latex:a.latex,alt:a.alt,fontSize:a.fontSize,rect:n}}(this.context.getState(),t,e);n&&this.overlay.openEdit(n)}};export{rt as a,j as c,xe as i,Ce as n,at as o,Ae as r,et as s,Oe as t};
2
- //# sourceMappingURL=FormulaPlugin-DJ39BtqV.mjs.map
@@ -1,2 +0,0 @@
1
- import{h as t}from"./Document-827l3P80.mjs";import{r}from"./NodeResolver-Dleih-8R.mjs";import{a as e,c as n,r as o,t as s}from"./Selection-HYoVFpAx.mjs";import{i}from"./NavigationQueries-Bt4zZ17v.mjs";import{t as l}from"./Platform-ByobkiCc.mjs";function u(t,r,e){return t.transaction("input").setSelection(s(r,e)).setStoredMarks(null,t.storedMarks).build()}function c(t,e){const n=r(t.doc,e)??[];return t.transaction("input").setSelection(o(e,n)).setStoredMarks(null,t.storedMarks).build()}function f(t,r,n,o,s){return t.transaction("input").setSelection(e({blockId:r,offset:n},{blockId:o,offset:s})).setStoredMarks(null,t.storedMarks).build()}function a(r,e,o){const s=r.selection;if(!n(s))return null;const f=r.getBlockOrder(),a=f.indexOf(s.blockId);if(a<0)return null;const d=function(t,r,e){if(!e)return t;if("left"!==t&&"right"!==t)return t;const n=e.querySelector(`[data-block-id="${r}"]`);return n instanceof HTMLElement?"rtl"!==l(n)?t:"left"===t?"right":"left":t}(e,s.blockId,o);if("before"===s.side&&("right"===d||"down"===d)||"after"===s.side&&("left"===d||"up"===d))return c(r,s.blockId);const m="before"===s.side?a-1:a+1;if(m<0||m>=f.length)return null;const k=f[m];if(!k)return null;if(i(r,k))return c(r,k);const p=r.getBlock(k);return p?u(r,k,"left"===d||"up"===d?t(p):0):null}export{c as i,f as n,u as r,a as t};
2
- //# sourceMappingURL=GapCursorNavigation-DCWOmopl.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GapCursorNavigation-DCWOmopl.mjs","names":[],"sources":["../../src/state/SelectionTransactions.ts","../../src/view/GapCursorNavigation.ts"],"sourcesContent":["/**\n * Shared transaction builders for cursor and selection movement.\n *\n * These helpers encapsulate the common pattern of building a transaction\n * that sets a new selection and clears storedMarks.\n */\n\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n} from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from './EditorState.js';\nimport type { Transaction } from './Transaction.js';\n\n/** Builds a collapsed-cursor transaction that clears storedMarks. */\nexport function moveTx(state: EditorState, blockId: BlockId, offset: number): Transaction {\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createCollapsedSelection(blockId, offset))\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n\n/** Builds a NodeSelection transaction that clears storedMarks. */\nexport function nodeSelTx(state: EditorState, targetId: BlockId): Transaction {\n\tconst path: BlockId[] = (findNodePath(state.doc, targetId) ?? []) as BlockId[];\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createNodeSelection(targetId, path))\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n\n/** Builds a range-selection transaction that clears storedMarks. */\nexport function extendTx(\n\tstate: EditorState,\n\tanchorBlockId: BlockId,\n\tanchorOffset: number,\n\theadBlockId: BlockId,\n\theadOffset: number,\n): Transaction {\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(\n\t\t\tcreateSelection(\n\t\t\t\t{ blockId: anchorBlockId, offset: anchorOffset },\n\t\t\t\t{ blockId: headBlockId, offset: headOffset },\n\t\t\t),\n\t\t)\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n","import { getBlockLength } from '../model/Document.js';\nimport { isGapCursor } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport { getTextDirection } from '../platform/Platform.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock } from '../state/NavigationQueries.js';\nimport { moveTx, nodeSelTx } from '../state/SelectionTransactions.js';\nimport type { Transaction } from '../state/Transaction.js';\n\nexport type GapCursorDirection = 'left' | 'right' | 'up' | 'down';\n\n/**\n * Navigates from a GapCursor position.\n *\n * - Arrow toward the adjacent void block -> NodeSelection of that block.\n * - Arrow away from the void block -> find next block: void -> NodeSelection,\n * text -> TextSelection, document boundary -> no-op.\n */\nexport function navigateFromGapCursor(\n\tstate: EditorState,\n\tdirection: GapCursorDirection,\n\tcontainer?: HTMLElement,\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (!isGapCursor(sel)) return null;\n\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\tif (blockIdx < 0) return null;\n\n\t// Resolve effective horizontal direction for RTL blocks\n\tconst effectiveDir: GapCursorDirection = resolveEffectiveDirection(\n\t\tdirection,\n\t\tsel.blockId,\n\t\tcontainer,\n\t);\n\n\tconst towardVoid: boolean =\n\t\t(sel.side === 'before' && (effectiveDir === 'right' || effectiveDir === 'down')) ||\n\t\t(sel.side === 'after' && (effectiveDir === 'left' || effectiveDir === 'up'));\n\n\tif (towardVoid) return nodeSelTx(state, sel.blockId);\n\n\t// Moving away from the void block - find the neighbor in the other direction\n\tconst awayIdx: number = sel.side === 'before' ? blockIdx - 1 : blockIdx + 1;\n\tif (awayIdx < 0 || awayIdx >= blockOrder.length) return null;\n\n\tconst targetId: BlockId | undefined = blockOrder[awayIdx];\n\tif (!targetId) return null;\n\n\tif (isVoidBlock(state, targetId)) return nodeSelTx(state, targetId);\n\n\t// Text block: place cursor at start or end\n\tconst targetBlock = state.getBlock(targetId);\n\tif (!targetBlock) return null;\n\n\tconst targetOffset: number =\n\t\teffectiveDir === 'left' || effectiveDir === 'up' ? getBlockLength(targetBlock) : 0;\n\treturn moveTx(state, targetId, targetOffset);\n}\n\n/**\n * Resolves the effective navigation direction by flipping left/right\n * when the block is RTL. Vertical directions are unaffected.\n */\nfunction resolveEffectiveDirection(\n\tdirection: GapCursorDirection,\n\tblockId: BlockId,\n\tcontainer?: HTMLElement,\n): GapCursorDirection {\n\tif (!container) return direction;\n\tif (direction !== 'left' && direction !== 'right') return direction;\n\n\tconst blockEl: Element | null = container.querySelector(`[data-block-id=\"${blockId}\"]`);\n\tif (!(blockEl instanceof HTMLElement)) return direction;\n\n\tconst isRtl: boolean = getTextDirection(blockEl) === 'rtl';\n\tif (!isRtl) return direction;\n\n\treturn direction === 'left' ? 'right' : 'left';\n}\n"],"mappings":"qPAkBA,SAAgB,EAAO,EAAoB,EAAkB,GAC5D,OAAO,EACL,YAAY,SACZ,aAAa,EAAyB,EAAS,IAC/C,eAAe,KAAM,EAAM,aAC3B,OACH,CAGA,SAAgB,EAAU,EAAoB,GAC7C,MAAM,EAAmB,EAAa,EAAM,IAAK,IAAa,GAC9D,OAAO,EACL,YAAY,SACZ,aAAa,EAAoB,EAAU,IAC3C,eAAe,KAAM,EAAM,aAC3B,OACH,CAGA,SAAgB,EACf,EACA,EACA,EACA,EACA,GAEA,OAAO,EACL,YAAY,SACZ,aACA,EACC,CAAE,QAAS,EAAe,OAAQ,GAClC,CAAE,QAAS,EAAa,OAAQ,KAGjC,eAAe,KAAM,EAAM,aAC3B,OACH,CCpCA,SAAgB,EACf,EACA,EACA,GAEA,MAAM,EAAM,EAAM,UAClB,IAAK,EAAY,GAAM,OAAO,KAE9B,MAAM,EAAiC,EAAM,gBACvC,EAAmB,EAAW,QAAQ,EAAI,SAChD,GAAI,EAAW,EAAG,OAAO,KAGzB,MAAM,EAkCP,SACC,EACA,EACA,GAEA,IAAK,EAAW,OAAO,EACvB,GAAkB,SAAd,GAAsC,UAAd,EAAuB,OAAO,EAE1D,MAAM,EAA0B,EAAU,cAAc,mBAAmB,OAC3E,OAAM,aAAmB,YAE4B,QAA9B,EAAiB,GACrB,EAEE,SAAd,EAAuB,QAAU,OALM,CAM/C,CAjD0C,CACxC,EACA,EAAI,QACJ,GAOD,GAHe,WAAb,EAAI,OAAuC,UAAjB,GAA6C,SAAjB,IACzC,UAAb,EAAI,OAAsC,SAAjB,GAA4C,OAAjB,GAEtC,OAAO,EAAU,EAAO,EAAI,SAG5C,MAAM,EAA+B,WAAb,EAAI,KAAoB,EAAW,EAAI,EAAW,EAC1E,GAAI,EAAU,GAAK,GAAW,EAAW,OAAQ,OAAO,KAExD,MAAM,EAAgC,EAAW,GACjD,IAAK,EAAU,OAAO,KAEtB,GAAI,EAAY,EAAO,GAAW,OAAO,EAAU,EAAO,GAG1D,MAAM,EAAc,EAAM,SAAS,GACnC,OAAK,EAIE,EAAO,EAAO,EADH,SAAjB,GAA4C,OAAjB,EAAwB,EAAe,GAAe,GAHzD,IAK1B"}
@@ -1,2 +0,0 @@
1
- import{c as t}from"./Selection-HYoVFpAx.mjs";import{c as e,o as n}from"./PluginHelpers-KDuTlmXm.mjs";import{t as o}from"./GapCursorNavigation-DCWOmopl.mjs";var r={gapCursorActive:"Gap cursor active. Type to insert new paragraph."},s=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-CR6UdFL9.mjs"),"./locales/de.ts":()=>import("./de-CHcv_Vmf.mjs"),"./locales/es.ts":()=>import("./es-BIXm2Coj.mjs"),"./locales/fr.ts":()=>import("./fr-Bg937iAy.mjs"),"./locales/hi.ts":()=>import("./hi-B5cl8TWK.mjs"),"./locales/pt.ts":()=>import("./pt-UPF7DBlz.mjs"),"./locales/ru.ts":()=>import("./ru-CkG_bpfo.mjs"),"./locales/zh.ts":()=>import("./zh-CWIzJcXi.mjs")});async function i(t){return e(s,t,r)}var a=class{id="gap-cursor";name="Gap Cursor";priority=5;context=null;activeCursorBlockId=null;activeCursorSide=null;locale=r;async init(e){this.locale=await n(e,void 0,r,i),this.context=e,e.registerStyleSheet("\n.notectl-gap-cursor--before,\n.notectl-gap-cursor--after {\n\tposition: relative;\n}\n.notectl-gap-cursor--before::before {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(-50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n.notectl-gap-cursor--after::after {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\tbottom: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n\t.notectl-gap-cursor--before::before,\n\t.notectl-gap-cursor--after::after {\n\t\tanimation: none;\n\t}\n}\n@keyframes notectl-gap-blink {\n\t50% { opacity: 0; }\n}\n");const s={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"},a={};for(const[n,r]of Object.entries(s))a[n]=()=>{const n=e.getState();if(!t(n.selection))return!1;const s=o(n,r,e.getContainer());return!!s&&(e.dispatch(s),!0)};e.registerKeymap(a,{priority:"navigation"})}onReady(){this.context&&this.syncCursorClass(this.context.getState())}onStateChange(e,n,o){this.context&&(this.syncCursorClass(n),!t(e.selection)&&t(n.selection)&&this.context.announce(this.locale.gapCursorActive))}destroy(){this.clearCursorClass(),this.context=null}syncCursorClass(e){if(this.clearCursorClass(),!t(e.selection)||!this.context)return;const n="before"===e.selection.side?"notectl-gap-cursor--before":"notectl-gap-cursor--after",o=this.context.getContainer().querySelector(`[data-block-id="${e.selection.blockId}"]`);o instanceof HTMLElement&&(o.classList.add(n),this.activeCursorBlockId=e.selection.blockId,this.activeCursorSide=e.selection.side)}clearCursorClass(){if(!this.context||!this.activeCursorBlockId||!this.activeCursorSide)return;const t=this.context.getContainer().querySelector(`[data-block-id="${this.activeCursorBlockId}"]`);t instanceof HTMLElement&&t.classList.remove("notectl-gap-cursor--before","notectl-gap-cursor--after"),this.activeCursorBlockId=null,this.activeCursorSide=null}};export{a as t};
2
- //# sourceMappingURL=GapCursorPlugin-2iR6506y.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GapCursorPlugin-2iR6506y.mjs","names":[],"sources":["../../src/plugins/gap-cursor/GapCursorLocale.ts","../../src/plugins/gap-cursor/GapCursorPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the GapCursorPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface GapCursorLocale {\n\treadonly gapCursorActive: string;\n}\n\n// --- Default English Locale ---\n\nexport const GAP_CURSOR_LOCALE_EN: GapCursorLocale = {\n\tgapCursorActive: 'Gap cursor active. Type to insert new paragraph.',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<GapCursorLocale> = import.meta.glob<{\n\tdefault: GapCursorLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadGapCursorLocale(lang: string): Promise<GapCursorLocale> {\n\treturn loadLocaleModule(localeModules, lang, GAP_CURSOR_LOCALE_EN);\n}\n","/**\n * GapCursorPlugin: renders a virtual cursor at boundaries of void blocks\n * where no native browser caret can exist (e.g. between two HRs or at\n * the document edge adjacent to a void block).\n */\n\nimport { isGapCursor } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport { navigateFromGapCursor } from '../../view/GapCursorNavigation.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport {\n\tGAP_CURSOR_LOCALE_EN,\n\ttype GapCursorLocale,\n\tloadGapCursorLocale,\n} from './GapCursorLocale.js';\n\nconst GAP_CURSOR_CSS = `\n.notectl-gap-cursor--before,\n.notectl-gap-cursor--after {\n\tposition: relative;\n}\n.notectl-gap-cursor--before::before {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(-50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n.notectl-gap-cursor--after::after {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\tbottom: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n\t.notectl-gap-cursor--before::before,\n\t.notectl-gap-cursor--after::after {\n\t\tanimation: none;\n\t}\n}\n@keyframes notectl-gap-blink {\n\t50% { opacity: 0; }\n}\n`;\n\nexport class GapCursorPlugin implements Plugin {\n\treadonly id = 'gap-cursor';\n\treadonly name = 'Gap Cursor';\n\treadonly priority = 5;\n\n\tprivate context: PluginContext | null = null;\n\tprivate activeCursorBlockId: BlockId | null = null;\n\tprivate activeCursorSide: 'before' | 'after' | null = null;\n\tprivate locale: GapCursorLocale = GAP_CURSOR_LOCALE_EN;\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tundefined,\n\t\t\tGAP_CURSOR_LOCALE_EN,\n\t\t\tloadGapCursorLocale,\n\t\t);\n\n\t\tthis.context = context;\n\n\t\tcontext.registerStyleSheet(GAP_CURSOR_CSS);\n\n\t\tconst directions: Record<string, 'left' | 'right' | 'up' | 'down'> = {\n\t\t\tArrowLeft: 'left',\n\t\t\tArrowRight: 'right',\n\t\t\tArrowUp: 'up',\n\t\t\tArrowDown: 'down',\n\t\t};\n\n\t\tconst keymap: Record<string, () => boolean> = {};\n\t\tfor (const [key, dir] of Object.entries(directions)) {\n\t\t\tkeymap[key] = (): boolean => {\n\t\t\t\tconst state: EditorState = context.getState();\n\t\t\t\tif (!isGapCursor(state.selection)) return false;\n\n\t\t\t\tconst container: HTMLElement = context.getContainer();\n\t\t\t\tconst tr: Transaction | null = navigateFromGapCursor(state, dir, container);\n\t\t\t\tif (tr) {\n\t\t\t\t\tcontext.dispatch(tr);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t};\n\t\t}\n\n\t\tcontext.registerKeymap(keymap, { priority: 'navigation' });\n\t}\n\n\tonReady(): void {\n\t\tif (!this.context) return;\n\t\tthis.syncCursorClass(this.context.getState());\n\t}\n\n\tonStateChange(oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tif (!this.context) return;\n\n\t\tthis.syncCursorClass(newState);\n\n\t\tif (!isGapCursor(oldState.selection) && isGapCursor(newState.selection)) {\n\t\t\tthis.context.announce(this.locale.gapCursorActive);\n\t\t}\n\t}\n\n\tdestroy(): void {\n\t\tthis.clearCursorClass();\n\t\tthis.context = null;\n\t}\n\n\tprivate syncCursorClass(state: EditorState): void {\n\t\tthis.clearCursorClass();\n\t\tif (!isGapCursor(state.selection) || !this.context) return;\n\n\t\tconst className: string =\n\t\t\tstate.selection.side === 'before'\n\t\t\t\t? 'notectl-gap-cursor--before'\n\t\t\t\t: 'notectl-gap-cursor--after';\n\n\t\tconst blockEl: Element | null = this.context\n\t\t\t.getContainer()\n\t\t\t.querySelector(`[data-block-id=\"${state.selection.blockId}\"]`);\n\t\tif (!(blockEl instanceof HTMLElement)) return;\n\n\t\tblockEl.classList.add(className);\n\t\tthis.activeCursorBlockId = state.selection.blockId;\n\t\tthis.activeCursorSide = state.selection.side;\n\t}\n\n\tprivate clearCursorClass(): void {\n\t\tif (!this.context || !this.activeCursorBlockId || !this.activeCursorSide) return;\n\n\t\tconst blockEl: Element | null = this.context\n\t\t\t.getContainer()\n\t\t\t.querySelector(`[data-block-id=\"${this.activeCursorBlockId}\"]`);\n\t\tif (blockEl instanceof HTMLElement) {\n\t\t\tblockEl.classList.remove('notectl-gap-cursor--before', 'notectl-gap-cursor--after');\n\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A,CAAwB,GAEvB,GADA,KAAK,oBACA,EAAY,EAAM,aAAe,KAAK,QAAS,OAEpD,MAAM,EACoB,WAAzB,EAAM,UAAU,KACb,6BACA,4BAEE,EAA0B,KAAK,QACnC,eACA,cAAc,mBAAmB,EAAM,UAAU,aAC7C,aAAmB,cAEzB,EAAQ,UAAU,IAAI,GACtB,KAAK,oBAAsB,EAAM,UAAU,QAC3C,KAAK,iBAAmB,EAAM,UAAU,KACzC,CAEA,gBAAA,GACC,IAAK,KAAK,UAAY,KAAK,sBAAwB,KAAK,iBAAkB,OAE1E,MAAM,EAA0B,KAAK,QACnC,eACA,cAAc,mBAAmB,KAAK,yBACpC,aAAmB,aACtB,EAAQ,UAAU,OAAO,6BAA8B,6BAGxD,KAAK,oBAAsB,KAC3B,KAAK,iBAAmB,IACzB"}
@@ -1,2 +0,0 @@
1
- var t=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;function e(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var n=e,r=/[\t\n\f\r ]/;function o(t){return"string"==typeof t&&t.length>0&&!r.test(t)?t:void 0}function i(t){if(!t.startsWith("#")||1===t.length)return[];const e=new URL(t,"https://notectl.invalid/").hash.slice(1);if(""===e)return[];const n=function(t){const e=[],n=new TextEncoder;for(let r=0;r<t.length;){const o=t[r+1],i=t[r+2];if("%"===t[r]&&o&&i&&s(o)&&s(i)){e.push(Number.parseInt(`${o}${i}`,16)),r+=3;continue}const a=t.codePointAt(r);if(void 0===a)break;const c=String.fromCodePoint(a);e.push(...n.encode(c)),r+=c.length}return(new TextDecoder).decode(Uint8Array.from(e))}(e);return n===e?[e]:[e,n]}function s(t){return t>="0"&&t<="9"||t>="a"&&t<="f"||t>="A"&&t<="F"}var a=new Set(["http:","https:","mailto:","tel:"]),c=/[\u0000-\u001F\u007F]/g;function l(t){const e=t.replace(c,"").trim();if(""===e)return"";if(e.startsWith("#")||e.startsWith("/"))return e;try{const t=new URL(e,"http://_invalid_base_/");return a.has(t.protocol)?e:""}catch{return""}}var u=new Set(["p","div","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","table","colgroup","thead","tbody","tfoot","tr","td","th","pre","figure","figcaption","section","article","header","footer"]),h=new Set(["br","hr","img","input","col","area","meta","link"]);function f(t,e=" "){const n=function(t){const e=[];let n=0,r=0;for(;r<t.length;){if("<"!==t[r]){r+=1;continue}let o=r+1;o<t.length&&"/"===t[o]&&(o+=1);const i=t[o];if(o>=t.length||!i||!g(i)){r+=1;continue}const s=p(t,o+1);if(void 0===s)break;r>n&&e.push(t.slice(n,r)),e.push(t.slice(r,s+1)),r=s+1,n=r}return n<t.length&&e.push(t.slice(n)),e}(t),r=[];let o=0,i="";const s=()=>{const t=i.trim();t.length>0&&r.push(`${e.repeat(o)}${t}`),i=""};for(const a of n){const t=a.startsWith("<")?d(a):"",n=u.has(t),c=h.has(t);n||c?(s(),a.startsWith("</")?(o=Math.max(0,o-1),r.push(`${e.repeat(o)}${a}`)):(r.push(`${e.repeat(o)}${a}`),!n||c||a.endsWith("/>")||(o+=1))):i+=a}return s(),r.join("\n")}function p(t,e){let n;for(let r=e;r<t.length;r+=1){const e=t[r]??"";if(n)e===n&&(n=void 0);else if('"'!==e&&"'"!==e){if(">"===e)return r}else n=e}}function g(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function d(t){return t.match(/^<\/?([a-zA-Z][a-zA-Z0-9]*)/)?.[1]?.toLowerCase()??""}export{i as a,f as i,n,o,e as r,l as s,t};
2
- //# sourceMappingURL=HTMLUtils-Bhg3_P8B.mjs.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./Commands-D5ND50PQ.mjs";var r=class{id="hard-break";name="Hard Break";priority=10;init(e){this.registerInlineNodeSpec(e),this.registerCommands(e),this.registerKeymap(e)}registerInlineNodeSpec(e){e.registerInlineNodeSpec({type:"hard_break",toDOM:()=>document.createElement("br"),toHTMLString:()=>"<br>",parseHTML:[{tag:"br"}],sanitize:{tags:["br"]}})}registerCommands(r){r.registerCommand("insertHardBreak",()=>{const t=e(r.getState());return!!t&&(r.dispatch(t),!0)})}registerKeymap(r){r.registerKeymap({"Shift-Enter":()=>{const t=e(r.getState());return!!t&&(r.dispatch(t),!0)}})}};export{r as t};
2
- //# sourceMappingURL=HardBreakPlugin-vniSvTgq.mjs.map
@@ -1,2 +0,0 @@
1
- import{D as t,_ as e,b as n,f as o,h as i}from"./Document-827l3P80.mjs";import{o as r,t as a,u as s}from"./Selection-HYoVFpAx.mjs";import{a as c}from"./TypeBrands-Ch9856Gb.mjs";import{c as l,o as g}from"./PluginHelpers-KDuTlmXm.mjs";import{s as p}from"./StyleRuntime-DW6omotc.mjs";import{n as d}from"./DomUtils-Bf7JLFlx.mjs";function h(t,e,n,o){const i=document.createElement("button");i.type="button",i.className="notectl-heading-picker__item",i.setAttribute("role","option"),i.setAttribute("aria-selected",String(e)),e&&i.classList.add("notectl-heading-picker__item--active");const r=document.createElement("span");r.className="notectl-heading-picker__check",r.textContent=e?"✓":"",i.appendChild(r);const a=document.createElement("span");return a.className="notectl-heading-picker__label",a.textContent=t,o&&p(a,{fontSize:o.fontSize,fontWeight:o.fontWeight}),i.appendChild(a),i.addEventListener("mousedown",n),i}function u(t,e){return t[`heading${e}`]}function f(t,e){const n=t.getState();if(!s(n.selection))return!1;const o=n.getBlock(n.selection.anchor.blockId);return!!o&&(o.type===e?k(t,c("paragraph")):k(t,c(e)))}function m(t,e){const n=t.getState(),o=n.selection;if(!s(o))return!1;const i=n.getBlock(o.anchor.blockId);return!!i&&("heading"===i.type&&i.attrs?.level===e?k(t,c("paragraph")):k(t,c("heading"),{level:e}))}function k(e,o,r){const a=e.getState(),c=a.selection;if(!s(c))return!1;const l=a.getBlock(c.anchor.blockId);if(!l)return!1;const g=a.transaction("command"),p=e.getSchemaRegistry().getNodeSpec(o);p?.excludeMarks&&p.excludeMarks.length>0&&(function(e,o,r){if(0===i(o))return;const a=new Set(r),s=n(o);let c=0;for(const n of s)if(t(n)){if(n.text.length>0)for(const t of n.marks)a.has(t.type)&&e.removeMark(o.id,c,c+n.text.length,t);c+=n.text.length}else c+=1}(g,l,p.excludeMarks),function(t,e,n){if(!e.storedMarks)return;const o=new Set(n),i=e.storedMarks.filter(t=>!o.has(t.type));i.length!==e.storedMarks.length&&t.setStoredMarks(i.length>0?i:null,e.storedMarks)}(g,a,p.excludeMarks));const d=g.setBlockType(c.anchor.blockId,o,r).setSelection(c).build();return e.dispatch(d),!0}var b=new Set(["heading","title","subtitle"]);var y={paragraph:"Paragraph",title:"Title",subtitle:"Subtitle",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",blockTypeLabel:"Block Type",blockTypesAria:"Block types"},v=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-0g2bmXTn.mjs"),"./locales/de.ts":()=>import("./de-Bwxlcuee.mjs"),"./locales/es.ts":()=>import("./es-C7uVqFYr.mjs"),"./locales/fr.ts":()=>import("./fr-D5ulA3Z6.mjs"),"./locales/hi.ts":()=>import("./hi-CrmakMVj.mjs"),"./locales/pt.ts":()=>import("./pt-_qxIe7zX.mjs"),"./locales/ru.ts":()=>import("./ru-Cs8KCNyq.mjs"),"./locales/zh.ts":()=>import("./zh-BQ73oqxc.mjs")});async function x(t){return l(v,t,y)}var S={levels:[1,2,3,4,5,6]},T={1:"h1",2:"h2",3:"h3",4:"h4",5:"h5",6:"h6"},B=class{id="heading";name="Heading";priority=30;config;locale;constructor(t){this.config={...S,...t}}async init(t){this.locale=await g(t,this.config.locale,y,x),t.registerStyleSheet("\n/* Heading Select — Width overrides for combobox button */\n.notectl-toolbar-btn--heading {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-heading-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-heading-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n"),this.registerNodeSpecs(t),function(t,e){t.registerCommand("setTitle",()=>f(t,"title")),t.registerCommand("setSubtitle",()=>f(t,"subtitle"));for(const n of e.levels)t.registerCommand(`setHeading${n}`,()=>m(t,n));t.registerCommand("toggleHeading",()=>m(t,1)),t.registerCommand("setParagraph",()=>k(t,c("paragraph")))}(t,this.config),function(t,n){const l={Enter:()=>function(t){return function(t,e){const n=t.getState();if(!s(n.selection))return!1;const o=n.selection;if(!r(o))return!1;const i=n.getBlock(o.anchor.blockId);return!(!i||!b.has(i.type))&&e({state:n,block:i,blockId:o.anchor.blockId,offset:o.anchor.offset})}(t,n=>{if(""===e(n.block)){const e=n.state.transaction("input").setBlockType(n.blockId,c("paragraph")).setSelection(n.state.selection).build();return t.dispatch(e),!0}const r=i(n.block);if(n.offset>=r){const e=o(),i=n.state.transaction("input").splitBlock(n.blockId,n.offset,e).setBlockType(e,c("paragraph")).setSelection(a(e,0)).build();return t.dispatch(i),!0}return!1})}(t)};for(const e of n.levels)e<=6&&(l[`Mod-Shift-${e}`]=()=>t.executeCommand(`setHeading${e}`));t.registerKeymap(l)}(t,this.config),!1!==this.config.inputRule&&function(t,e){for(const n of e.levels){const e="#".repeat(n),o=new RegExp(`^${e} $`);t.registerInputRule({pattern:o,handler(t,e,o,i){const l=t.selection;if(!s(l))return null;if(!r(l))return null;const g=t.getBlock(l.anchor.blockId);return g&&"paragraph"===g.type?t.transaction("input").deleteTextAt(l.anchor.blockId,o,o+n+1).setBlockType(l.anchor.blockId,c("heading"),{level:n}).setSelection(a(l.anchor.blockId,0)).build():null}})}}(t,this.config),function(t,e,n){t.registerBlockTypePickerEntry({id:"paragraph",label:n.paragraph,command:"setParagraph",priority:10,isActive:t=>!!s(t.selection)&&"paragraph"===t.getBlock(t.selection.anchor.blockId)?.type}),t.registerBlockTypePickerEntry({id:"title",label:n.title,command:"setTitle",priority:20,style:{fontSize:"1.6em",fontWeight:"700"},isActive:t=>!!s(t.selection)&&"title"===t.getBlock(t.selection.anchor.blockId)?.type}),t.registerBlockTypePickerEntry({id:"subtitle",label:n.subtitle,command:"setSubtitle",priority:30,style:{fontSize:"1.3em",fontWeight:"500"},isActive:t=>!!s(t.selection)&&"subtitle"===t.getBlock(t.selection.anchor.blockId)?.type});for(const o of e.levels)t.registerBlockTypePickerEntry({id:`heading-${o}`,label:u(n,o),command:`setHeading${o}`,priority:100+o,style:{fontSize:1.4-.1*o+"em",fontWeight:"600"},isActive:t=>{if(!s(t.selection))return!1;const e=t.getBlock(t.selection.anchor.blockId);return"heading"===e?.type&&e.attrs?.level===o}})}(t,this.config,this.locale),function(t,e){t.registerToolbarItem({id:"heading",group:"block",label:e.blockTypeLabel,tooltip:e.blockTypeLabel,command:"setParagraph",popupType:"combobox",getLabel:n=>function(t,e,n){if(!s(t.selection))return n.paragraph;const o=e.getBlockTypePickerRegistry().getBlockTypePickerEntries();for(const i of o)if(i.isActive(t))return i.label;return n.paragraph}(n,t,e),renderPopup:(t,n,o)=>{!function(t,e,n,o){t.classList.add("notectl-heading-picker");const i=e.getState();if(!s(i.selection))return;const r=e.getContainer(),a=document.createElement("div");a.className="notectl-heading-picker__list",a.setAttribute("role","listbox"),a.setAttribute("aria-label",n.blockTypesAria);const c=e.getBlockTypePickerRegistry().getBlockTypePickerEntries();for(const s of c){const t=s.isActive(i);a.appendChild(h(s.label,t,t=>{t.preventDefault(),t.stopPropagation(),e.executeCommand(s.command),o({restoreFocusTo:r})},s.style))}t.appendChild(a)}(t,n,e,o)},isActive:e=>t.getBlockTypePickerRegistry().getBlockTypePickerEntries().some(t=>"paragraph"!==t.id&&t.isActive(e))})}(t,this.locale)}registerNodeSpecs(t){t.registerNodeSpec({type:"title",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],toDOM(t){const e=d("h1",t.id);return e.classList.add("notectl-title"),e},toHTML:(t,e)=>`<h1 class="notectl-title">${e||"<br>"}</h1>`,parseHTML:[{tag:"h1",priority:60,getAttrs:t=>!!t.classList.contains("notectl-title")&&{}}],sanitize:{tags:["h1"],attrs:["class"]}}),t.registerNodeSpec({type:"subtitle",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],toDOM(t){const e=d("h2",t.id);return e.classList.add("notectl-subtitle"),e},toHTML:(t,e)=>`<h2 class="notectl-subtitle">${e||"<br>"}</h2>`,parseHTML:[{tag:"h2",priority:60,getAttrs:t=>!!t.classList.contains("notectl-subtitle")&&{}}],sanitize:{tags:["h2"],attrs:["class"]}}),t.registerNodeSpec({type:"heading",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],attrs:{level:{default:1}},toDOM:t=>d(T[t.attrs?.level??1]??"h1",t.id),toHTML(t,e){const n=T[t.attrs?.level??1]??"h1";return`<${n}>${e||"<br>"}</${n}>`},parseHTML:[{tag:"h1",getAttrs:()=>({level:1})},{tag:"h2",getAttrs:()=>({level:2})},{tag:"h3",getAttrs:()=>({level:3})},{tag:"h4",getAttrs:()=>({level:4})},{tag:"h5",getAttrs:()=>({level:5})},{tag:"h6",getAttrs:()=>({level:6})}],sanitize:{tags:["h1","h2","h3","h4","h5","h6"]}})}};export{y as n,x as r,B as t};
2
- //# sourceMappingURL=HeadingPlugin-DUKsLuMd.mjs.map
@@ -1,2 +0,0 @@
1
- import{o as t}from"./Document-827l3P80.mjs";import{o,t as e,u as r}from"./Selection-HYoVFpAx.mjs";import{a as i}from"./TypeBrands-Ch9856Gb.mjs";import{s}from"./BlockInsertion-CYH2gRkY.mjs";import{c as l,i as n,o as a}from"./PluginHelpers-KDuTlmXm.mjs";import{n as c}from"./DomUtils-Bf7JLFlx.mjs";import{t as m}from"./ShortcutFormatting-TwiufqeV.mjs";var p={label:"Horizontal Rule",tooltip:t=>`Horizontal Rule (${t})`},u=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-CrOb0jL2.mjs"),"./locales/de.ts":()=>import("./de-C7uehgMu.mjs"),"./locales/es.ts":()=>import("./es-xuahrvJN.mjs"),"./locales/fr.ts":()=>import("./fr-B9pBLaVx.mjs"),"./locales/hi.ts":()=>import("./hi-DWX6k5ZD.mjs"),"./locales/pt.ts":()=>import("./pt-DFKJVh7k.mjs"),"./locales/ru.ts":()=>import("./ru-q8kz-237.mjs"),"./locales/zh.ts":()=>import("./zh-BGYJXxVl.mjs")});async function h(t){return l(u,t,p)}var d={},g=class{id="horizontal-rule";name="Horizontal Rule";priority=40;config;locale;constructor(t){this.config={...d,...t}}async init(t){this.locale=await a(t,this.config.locale,p,h),this.registerNodeSpec(t),this.registerCommands(t),this.registerKeymap(t),!1!==this.config.inputRule&&this.registerInputRule(t),this.registerToolbarItem(t)}registerNodeSpec(t){t.registerNodeSpec({type:"horizontal_rule",group:"block",isVoid:!0,toDOM:t=>c("hr",t.id),toHTML:()=>"<hr>",parseHTML:[{tag:"hr"}],sanitize:{tags:["hr"]}})}registerCommands(t){t.registerCommand("insertHorizontalRule",()=>this.insertHorizontalRule(t))}registerKeymap(t){t.registerKeymap({"Mod-Shift-H":()=>t.executeCommand("insertHorizontalRule")})}registerInputRule(s){s.registerInputRule({pattern:/^-{3,} $/,handler(s,l,n,a){const c=s.selection;if(!r(c))return null;if(!o(c))return null;const m=s.getBlock(c.anchor.blockId);if(!m||"paragraph"!==m.type)return null;const p=function(t){const o=t.selection;return r(o)?t.doc.children.findIndex(t=>t.id===o.anchor.blockId):-1}(s);if(-1===p)return null;const u=t(i("paragraph"));return s.transaction("input").deleteTextAt(c.anchor.blockId,0,a).setBlockType(c.anchor.blockId,i("horizontal_rule")).insertNode([],p+1,u).setSelection(e(u.id,0)).build()}})}registerToolbarItem(t){t.registerToolbarItem({id:"horizontal-rule",group:"block",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11h16v2H4z"/></svg>',label:this.locale.label,tooltip:this.locale.tooltip(m("Mod-Shift-H")),command:"insertHorizontalRule",isActive:()=>!1})}insertHorizontalRule(o){const r=o.getState(),l=n(r);if(!l)return!1;const a=r.transaction("command"),c=s(r,a,l,t(i("horizontal_rule")));return!!c&&(a.setSelection(e(c.id,0)),o.dispatch(a.build()),!0)}};export{p as n,h as r,g as t};
2
- //# sourceMappingURL=HorizontalRulePlugin-B9OvwrKB.mjs.map
@@ -1,2 +0,0 @@
1
- import{m as t}from"./Document-827l3P80.mjs";import{o as e,t as o,u as r}from"./Selection-HYoVFpAx.mjs";import{i as n}from"./TypeBrands-Ch9856Gb.mjs";import{c as s,o as i}from"./PluginHelpers-KDuTlmXm.mjs";import{t as l}from"./ShortcutFormatting-TwiufqeV.mjs";import{t as a}from"./SimpleMark-gTQaSJcO.mjs";var c={label:"Inline Code",tooltip:t=>`Inline Code (${t})`},m=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-CMXjVzFx.mjs"),"./locales/de.ts":()=>import("./de-e6J6nvAD.mjs"),"./locales/es.ts":()=>import("./es-fTW0TkYV.mjs"),"./locales/fr.ts":()=>import("./fr-CQs0-pNX.mjs"),"./locales/hi.ts":()=>import("./hi-C2jEsf8v.mjs"),"./locales/pt.ts":()=>import("./pt-BDam9cDu.mjs"),"./locales/ru.ts":()=>import("./ru-QcTo2yoL.mjs"),"./locales/zh.ts":()=>import("./zh-DWN1Jqn3.mjs")});async function d(t){return s(m,t,c)}var p={toolbar:!0,keymap:"Mod-E",inputRule:!0},u=new Set(["bold","italic","underline","strikethrough","highlight","font","fontSize","superscript","subscript"]),f=class{id="inline-code";name="Inline Code";priority=22;config;locale;constructor(t){this.config={...p,...t}}async init(t){this.locale=await i(t,this.config.locale,c,d),t.registerStyleSheet("\n.notectl-content code {\n\tfont-family: ui-monospace, 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;\n\tfont-size: 0.9em;\n\tpadding: 0.15em 0.35em;\n\tborder-radius: 4px;\n\tbackground-color: var(--notectl-code-bg);\n\tcolor: var(--notectl-code-color);\n\tword-break: break-word;\n}\n@media (forced-colors: active) {\n\t.notectl-content code {\n\t\tborder: 1px solid LinkText;\n\t}\n}\n"),this.registerMark(t),!1!==this.config.inputRule&&this.registerInputRule(t),this.registerExclusivityMiddleware(t)}registerMark(t){a(t,{markSpec:{type:"code",rank:3,toDOM:()=>document.createElement("code"),toHTMLString:(t,e)=>`<code>${e}</code>`,parseHTML:[{tag:"code",getAttrs:t=>"PRE"!==t.parentElement?.tagName&&{}},{tag:"span",getAttrs:t=>{const e=t.style.fontFamily.replace(/['"]/g,"").trim();return!!/^monospace$/i.test(e)&&{}}}],sanitize:{tags:["code"]}},command:"toggleInlineCode",keyBinding:null!==this.config.keymap?this.config.keymap??"Mod-E":null,toolbar:!1!==this.config.toolbar?{id:"inline_code",group:"format",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0L19.2 12l-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>',label:this.locale.label,tooltip:this.locale.tooltip(l(this.config.keymap??"Mod-E"))}:void 0})}registerInputRule(t){t.registerInputRule({pattern:/(?:^|[^`])(`([^`\uFFFC]+)`)$/,handler(t,s,i,l){const a=t.selection;if(!r(a))return null;if(!e(a))return null;const c=t.getBlock(a.anchor.blockId);if(!c||"code_block"===c.type)return null;const m=s[2],d=s[1];if(!m||!d)return null;const p=l-d.length;return t.transaction("input").deleteTextAt(a.anchor.blockId,p,l).insertText(a.anchor.blockId,p,m,[{type:n("code")}]).setSelection(o(a.anchor.blockId,p+m.length)).build()}})}registerExclusivityMiddleware(e){e.registerMiddleware((e,o,r)=>{let s=!1;const i=[];for(const a of e.steps){if("addMark"!==a.type){i.push(a);continue}const e=a.mark.type;if("code"===e){const e=o.getBlock(a.blockId);if(e){const o=t(e,a.from,a.to),r=/* @__PURE__ */new Set;for(const t of o)if("text"===t.kind)for(const e of t.marks)u.has(e.type)&&r.add(e.type);for(const t of r)s=!0,i.push({type:"removeMark",blockId:a.blockId,from:a.from,to:a.to,mark:{type:n(t)},...a.path?{path:a.path}:{}})}i.push(a);continue}if(u.has(e)){const e=o.getBlock(a.blockId);if(e&&t(e,a.from,a.to).some(t=>"text"===t.kind&&t.marks.some(t=>"code"===t.type))){s=!0;continue}}i.push(a)}let l=e.storedMarksAfter;if(l){const t=l.some(t=>"code"===t.type),e=l.some(t=>u.has(t.type));t&&e&&(l=l.filter(t=>!u.has(t.type)),s=!0)}r(s?{...e,steps:i,storedMarksAfter:l}:e)},{name:"inline-code:mark-exclusivity",priority:50})}};export{c as n,d as r,f as t};
2
- //# sourceMappingURL=InlineCodePlugin-uxgMUX_E.mjs.map