@notectl/core 2.3.7 → 2.4.0

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 (388) hide show
  1. package/dist/chunks/AlignmentPlugin-Cp7HYGaH.mjs +2 -0
  2. package/dist/chunks/AlignmentPlugin-Cp7HYGaH.mjs.map +1 -0
  3. package/dist/chunks/{AttrRegistry-CtNhf2EF.mjs → AttrRegistry-Di936wMv.mjs} +2 -2
  4. package/dist/chunks/{AttrRegistry-CtNhf2EF.mjs.map → AttrRegistry-Di936wMv.mjs.map} +1 -1
  5. package/dist/chunks/{AttributedMarkCommands-B3MQdob_.mjs → AttributedMarkCommands-DKHuhZA7.mjs} +2 -2
  6. package/dist/chunks/{AttributedMarkCommands-B3MQdob_.mjs.map → AttributedMarkCommands-DKHuhZA7.mjs.map} +1 -1
  7. package/dist/chunks/BidiIsolationPlugin-GWukKdgJ.mjs +2 -0
  8. package/dist/chunks/{BidiIsolationPlugin-cOLlL3Y9.mjs.map → BidiIsolationPlugin-GWukKdgJ.mjs.map} +1 -1
  9. package/dist/chunks/BlockAlignment-BqyBQ4uV.mjs +2 -0
  10. package/dist/chunks/BlockAlignment-BqyBQ4uV.mjs.map +1 -0
  11. package/dist/chunks/{BlockInsertion-O5pAFKid.mjs → BlockInsertion-CxKdCKJd.mjs} +2 -2
  12. package/dist/chunks/{BlockInsertion-O5pAFKid.mjs.map → BlockInsertion-CxKdCKJd.mjs.map} +1 -1
  13. package/dist/chunks/BlockquotePlugin-CSL_7Yit.mjs +2 -0
  14. package/dist/chunks/BlockquotePlugin-CSL_7Yit.mjs.map +1 -0
  15. package/dist/chunks/CSSValueEquivalence-DeyUKPQ7.mjs +2 -0
  16. package/dist/chunks/CSSValueEquivalence-DeyUKPQ7.mjs.map +1 -0
  17. package/dist/chunks/{CaretNavigationPlugin-DEZU09LJ.mjs → CaretNavigationPlugin-BxWjR7SN.mjs} +2 -2
  18. package/dist/chunks/{CaretNavigationPlugin-DEZU09LJ.mjs.map → CaretNavigationPlugin-BxWjR7SN.mjs.map} +1 -1
  19. package/dist/chunks/CodeBlockPlugin-BIrkK4ER.mjs +2 -0
  20. package/dist/chunks/{CodeBlockPlugin-BandNM3t.mjs.map → CodeBlockPlugin-BIrkK4ER.mjs.map} +1 -1
  21. package/dist/chunks/ColorPickerPopup-B6340f3p.mjs +2 -0
  22. package/dist/chunks/{ColorPickerPopup-CFYCCN7m.mjs.map → ColorPickerPopup-B6340f3p.mjs.map} +1 -1
  23. package/dist/chunks/{ColorValidation-B9d_umnf.mjs → ColorValidation-ZBKZ_gTr.mjs} +2 -2
  24. package/dist/chunks/ColorValidation-ZBKZ_gTr.mjs.map +1 -0
  25. package/dist/chunks/Commands-DBBCAYBn.mjs +2 -0
  26. package/dist/chunks/Commands-DBBCAYBn.mjs.map +1 -0
  27. package/dist/chunks/{ContentModel-Bzmzeqwg.mjs → ContentModel-BLC3Tez8.mjs} +2 -2
  28. package/dist/chunks/{ContentModel-Bzmzeqwg.mjs.map → ContentModel-BLC3Tez8.mjs.map} +1 -1
  29. package/dist/chunks/{CursorMarks-dx51OGBf.mjs → CursorMarks-CqHLzGNI.mjs} +2 -2
  30. package/dist/chunks/{CursorMarks-dx51OGBf.mjs.map → CursorMarks-CqHLzGNI.mjs.map} +1 -1
  31. package/dist/chunks/{Decoration-BwhoA4MU.mjs → Decoration-BoFcdSXk.mjs} +2 -2
  32. package/dist/chunks/{Decoration-BwhoA4MU.mjs.map → Decoration-BoFcdSXk.mjs.map} +1 -1
  33. package/dist/chunks/{DirectionDetection-ZrkMhyaL.mjs → DirectionDetection-a-1iksmh.mjs} +2 -2
  34. package/dist/chunks/{DirectionDetection-ZrkMhyaL.mjs.map → DirectionDetection-a-1iksmh.mjs.map} +1 -1
  35. package/dist/chunks/{Document-D_2cIBJG.mjs → Document-ssR6hBzG.mjs} +2 -2
  36. package/dist/chunks/{Document-D_2cIBJG.mjs.map → Document-ssR6hBzG.mjs.map} +1 -1
  37. package/dist/chunks/DocumentParser-BKUrtgw1.mjs +2 -0
  38. package/dist/chunks/DocumentParser-BKUrtgw1.mjs.map +1 -0
  39. package/dist/chunks/FontPlugin-BcXNFqqO.mjs +2 -0
  40. package/dist/chunks/FontPlugin-BcXNFqqO.mjs.map +1 -0
  41. package/dist/chunks/FontSizePlugin-BQ9Aj8cT.mjs +2 -0
  42. package/dist/chunks/FontSizePlugin-BQ9Aj8cT.mjs.map +1 -0
  43. package/dist/chunks/FormulaPlugin-Bw_sO_lq.mjs +2 -0
  44. package/dist/chunks/FormulaPlugin-Bw_sO_lq.mjs.map +1 -0
  45. package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs +2 -0
  46. package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs.map +1 -0
  47. package/dist/chunks/HTMLUtils-DTpsjZyK.mjs +2 -0
  48. package/dist/chunks/HTMLUtils-DTpsjZyK.mjs.map +1 -0
  49. package/dist/chunks/{HardBreakPlugin-CC4rntSX.mjs → HardBreakPlugin-svNnJ9Xj.mjs} +2 -2
  50. package/dist/chunks/{HardBreakPlugin-CC4rntSX.mjs.map → HardBreakPlugin-svNnJ9Xj.mjs.map} +1 -1
  51. package/dist/chunks/HeadingPlugin-B7EfynaH.mjs +2 -0
  52. package/dist/chunks/HeadingPlugin-B7EfynaH.mjs.map +1 -0
  53. package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs +2 -0
  54. package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs.map +1 -0
  55. package/dist/chunks/HorizontalRulePlugin-CQ5NT2Mo.mjs +2 -0
  56. package/dist/chunks/{HorizontalRulePlugin-CxmUMM34.mjs.map → HorizontalRulePlugin-CQ5NT2Mo.mjs.map} +1 -1
  57. package/dist/chunks/ImagePlugin-BzLvPXGo.mjs +2 -0
  58. package/dist/chunks/ImagePlugin-BzLvPXGo.mjs.map +1 -0
  59. package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs +2 -0
  60. package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs.map +1 -0
  61. package/dist/chunks/InlineStyleMarkSpec-BhfGgfH9.mjs +2 -0
  62. package/dist/chunks/InlineStyleMarkSpec-BhfGgfH9.mjs.map +1 -0
  63. package/dist/chunks/{LinkPlugin-Bsmt97Kw.mjs → LinkPlugin-BuzrXo2c.mjs} +2 -2
  64. package/dist/chunks/{LinkPlugin-Bsmt97Kw.mjs.map → LinkPlugin-BuzrXo2c.mjs.map} +1 -1
  65. package/dist/chunks/{ListPlugin--dqEctgn.mjs → ListPlugin-DTgpvBEt.mjs} +2 -2
  66. package/dist/chunks/{ListPlugin--dqEctgn.mjs.map → ListPlugin-DTgpvBEt.mjs.map} +1 -1
  67. package/dist/chunks/MarkCommands-C0ps9h0z.mjs +2 -0
  68. package/dist/chunks/MarkCommands-C0ps9h0z.mjs.map +1 -0
  69. package/dist/chunks/MarkdownHTMLRegistry-BunUDiza.mjs +2 -0
  70. package/dist/chunks/{MarkdownHTMLRegistry-CISsC0lH.mjs.map → MarkdownHTMLRegistry-BunUDiza.mjs.map} +1 -1
  71. package/dist/chunks/{MarkdownParser-D1d9zB0R.mjs → MarkdownParser-CvYOvU3d.mjs} +2 -2
  72. package/dist/chunks/{MarkdownParser-D1d9zB0R.mjs.map → MarkdownParser-CvYOvU3d.mjs.map} +1 -1
  73. package/dist/chunks/MarkdownSerializer-CdUBWWGI.mjs +2 -0
  74. package/dist/chunks/MarkdownSerializer-CdUBWWGI.mjs.map +1 -0
  75. package/dist/chunks/NavigationQueries-CaKfccu7.mjs +2 -0
  76. package/dist/chunks/NavigationQueries-CaKfccu7.mjs.map +1 -0
  77. package/dist/chunks/NodeResolver-F4RtpoEd.mjs +2 -0
  78. package/dist/chunks/NodeResolver-F4RtpoEd.mjs.map +1 -0
  79. package/dist/chunks/{NodeSelectionCommands-DK3iEh18.mjs → NodeSelectionCommands-B0Sb4ux4.mjs} +2 -2
  80. package/dist/chunks/{NodeSelectionCommands-DK3iEh18.mjs.map → NodeSelectionCommands-B0Sb4ux4.mjs.map} +1 -1
  81. package/dist/chunks/PluginHelpers-B3gk3VB3.mjs +2 -0
  82. package/dist/chunks/{PluginHelpers-WG1Lzzh3.mjs.map → PluginHelpers-B3gk3VB3.mjs.map} +1 -1
  83. package/dist/chunks/{PrintPlugin-BQ7LWbEB.mjs → PrintPlugin-BxNlFk2c.mjs} +2 -2
  84. package/dist/chunks/{PrintPlugin-BQ7LWbEB.mjs.map → PrintPlugin-BxNlFk2c.mjs.map} +1 -1
  85. package/dist/chunks/{RangeIterator-DDOxTQIf.mjs → RangeIterator-sJ_c9MNr.mjs} +2 -2
  86. package/dist/chunks/{RangeIterator-DDOxTQIf.mjs.map → RangeIterator-sJ_c9MNr.mjs.map} +1 -1
  87. package/dist/chunks/Schema-BSM4YLNT.mjs +2 -0
  88. package/dist/chunks/Schema-BSM4YLNT.mjs.map +1 -0
  89. package/dist/chunks/SchemaRegistry-Cs7rxafF.mjs +2 -0
  90. package/dist/chunks/SchemaRegistry-Cs7rxafF.mjs.map +1 -0
  91. package/dist/chunks/SelectionSync-BkjCwGp-.mjs +2 -0
  92. package/dist/chunks/SelectionSync-BkjCwGp-.mjs.map +1 -0
  93. package/dist/chunks/{SelectionTransactions-DNCzsl_b.mjs → SelectionTransactions-mQ1NfMEg.mjs} +2 -2
  94. package/dist/chunks/{SelectionTransactions-DNCzsl_b.mjs.map → SelectionTransactions-mQ1NfMEg.mjs.map} +1 -1
  95. package/dist/chunks/SimpleMark-D6vz3Nfd.mjs +2 -0
  96. package/dist/chunks/{SimpleMark-CTDtEIMV.mjs.map → SimpleMark-D6vz3Nfd.mjs.map} +1 -1
  97. package/dist/chunks/{SmartPastePlugin-CjExbE9Q.mjs → SmartPastePlugin-C3SVKkWK.mjs} +2 -2
  98. package/dist/chunks/{SmartPastePlugin-CjExbE9Q.mjs.map → SmartPastePlugin-C3SVKkWK.mjs.map} +1 -1
  99. package/dist/chunks/{StrikethroughPlugin-d-EW2YYx.mjs → StrikethroughPlugin-v-VJZzUZ.mjs} +2 -2
  100. package/dist/chunks/{StrikethroughPlugin-d-EW2YYx.mjs.map → StrikethroughPlugin-v-VJZzUZ.mjs.map} +1 -1
  101. package/dist/chunks/StyleClassNames-BsAx7k5T.mjs +2 -0
  102. package/dist/chunks/StyleClassNames-BsAx7k5T.mjs.map +1 -0
  103. package/dist/chunks/{SuperSubPlugin-C-kvFQyx.mjs → SuperSubPlugin-x1iPnZyt.mjs} +2 -2
  104. package/dist/chunks/{SuperSubPlugin-C-kvFQyx.mjs.map → SuperSubPlugin-x1iPnZyt.mjs.map} +1 -1
  105. package/dist/chunks/TableDimensions-BSEOEox2.mjs +2 -0
  106. package/dist/chunks/TableDimensions-BSEOEox2.mjs.map +1 -0
  107. package/dist/chunks/TablePlugin-WPwp902E.mjs +2 -0
  108. package/dist/chunks/TablePlugin-WPwp902E.mjs.map +1 -0
  109. package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs +2 -0
  110. package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs.map +1 -0
  111. package/dist/chunks/{TextDirectionAutoPlugin-LVDkKdDX.mjs → TextDirectionAutoPlugin-DOH5cfyy.mjs} +2 -2
  112. package/dist/chunks/{TextDirectionAutoPlugin-LVDkKdDX.mjs.map → TextDirectionAutoPlugin-DOH5cfyy.mjs.map} +1 -1
  113. package/dist/chunks/{TextDirectionPlugin-CtGwof7i.mjs → TextDirectionPlugin-JwlR-R-b.mjs} +2 -2
  114. package/dist/chunks/{TextDirectionPlugin-CtGwof7i.mjs.map → TextDirectionPlugin-JwlR-R-b.mjs.map} +1 -1
  115. package/dist/chunks/TextDirectionService-BcX07mw2.mjs +2 -0
  116. package/dist/chunks/{TextDirectionService-OFOU6r_s.mjs.map → TextDirectionService-BcX07mw2.mjs.map} +1 -1
  117. package/dist/chunks/{TextFormattingPlugin-DlS0SeW7.mjs → TextFormattingPlugin-Kc_UNoOz.mjs} +2 -2
  118. package/dist/chunks/{TextFormattingPlugin-DlS0SeW7.mjs.map → TextFormattingPlugin-Kc_UNoOz.mjs.map} +1 -1
  119. package/dist/chunks/ToolbarPlugin-DmVI7MN9.mjs +2 -0
  120. package/dist/chunks/ToolbarPlugin-DmVI7MN9.mjs.map +1 -0
  121. package/dist/chunks/VideoPlugin-D3zGQ6QV.mjs +2 -0
  122. package/dist/chunks/VideoPlugin-D3zGQ6QV.mjs.map +1 -0
  123. package/dist/chunks/color-picker-D6HrTsDM.mjs +2 -0
  124. package/dist/chunks/color-picker-D6HrTsDM.mjs.map +1 -0
  125. package/dist/chunks/full-BiQ93ERr.mjs +2 -0
  126. package/dist/chunks/{full-9sO5JbWG.mjs.map → full-BiQ93ERr.mjs.map} +1 -1
  127. package/dist/chunks/minimal-DO7LiFTa.mjs +2 -0
  128. package/dist/chunks/{minimal-C07d5reO.mjs.map → minimal-DO7LiFTa.mjs.map} +1 -1
  129. package/dist/chunks/register-Cb1YTAN4.mjs +3 -0
  130. package/dist/chunks/register-Cb1YTAN4.mjs.map +1 -0
  131. package/dist/commands/Commands.d.ts.map +1 -1
  132. package/dist/commands/CompositionCommands.d.ts +47 -0
  133. package/dist/commands/CompositionCommands.d.ts.map +1 -0
  134. package/dist/commands/CompositionRebase.d.ts +24 -0
  135. package/dist/commands/CompositionRebase.d.ts.map +1 -0
  136. package/dist/commands/PasteCommand.d.ts.map +1 -1
  137. package/dist/commands/SelectionDeletion.d.ts +15 -5
  138. package/dist/commands/SelectionDeletion.d.ts.map +1 -1
  139. package/dist/fonts/math.mjs +1 -1
  140. package/dist/fonts.mjs +1 -1
  141. package/dist/full.mjs +1 -1
  142. package/dist/html.mjs +1 -1
  143. package/dist/index.d.ts +1 -0
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/input/CompositionController.d.ts +78 -0
  146. package/dist/input/CompositionController.d.ts.map +1 -0
  147. package/dist/input/HTMLParser.d.ts +15 -2
  148. package/dist/input/HTMLParser.d.ts.map +1 -1
  149. package/dist/input/InputHandler.d.ts +34 -1
  150. package/dist/input/InputHandler.d.ts.map +1 -1
  151. package/dist/input/InputManager.d.ts +3 -0
  152. package/dist/input/InputManager.d.ts.map +1 -1
  153. package/dist/input/PasteHTMLHandler.d.ts.map +1 -1
  154. package/dist/markdown.mjs +1 -1
  155. package/dist/model/BlockAlignment.d.ts +6 -0
  156. package/dist/model/BlockAlignment.d.ts.map +1 -1
  157. package/dist/model/BlockOffsetText.d.ts +11 -0
  158. package/dist/model/BlockOffsetText.d.ts.map +1 -0
  159. package/dist/model/CompositionState.d.ts +14 -0
  160. package/dist/model/CompositionState.d.ts.map +1 -1
  161. package/dist/model/HTMLUtils.d.ts +16 -3
  162. package/dist/model/HTMLUtils.d.ts.map +1 -1
  163. package/dist/model/MarkSpec.d.ts +5 -3
  164. package/dist/model/MarkSpec.d.ts.map +1 -1
  165. package/dist/model/NodeResolver.d.ts +2 -0
  166. package/dist/model/NodeResolver.d.ts.map +1 -1
  167. package/dist/model/NodeSpec.d.ts +2 -1
  168. package/dist/model/NodeSpec.d.ts.map +1 -1
  169. package/dist/model/Schema.d.ts +2 -0
  170. package/dist/model/Schema.d.ts.map +1 -1
  171. package/dist/model/SchemaRegistry.d.ts +26 -1
  172. package/dist/model/SchemaRegistry.d.ts.map +1 -1
  173. package/dist/model/StyleClass.d.ts +45 -0
  174. package/dist/model/StyleClass.d.ts.map +1 -0
  175. package/dist/model/StyleClassRegistry.d.ts +28 -0
  176. package/dist/model/StyleClassRegistry.d.ts.map +1 -0
  177. package/dist/model/TextChange.d.ts +40 -0
  178. package/dist/model/TextChange.d.ts.map +1 -0
  179. package/dist/notectl-core.mjs +1 -1
  180. package/dist/notectl-core.umd.js +1 -1
  181. package/dist/notectl-core.umd.js.map +1 -1
  182. package/dist/plugins/Plugin.d.ts +11 -0
  183. package/dist/plugins/Plugin.d.ts.map +1 -1
  184. package/dist/plugins/PluginContextFactory.d.ts +2 -0
  185. package/dist/plugins/PluginContextFactory.d.ts.map +1 -1
  186. package/dist/plugins/RegistrationTracker.d.ts.map +1 -1
  187. package/dist/plugins/alignment/AlignmentPlugin.d.ts +17 -0
  188. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
  189. package/dist/plugins/alignment.mjs +1 -1
  190. package/dist/plugins/bidi-isolation.mjs +1 -1
  191. package/dist/plugins/blockquote.mjs +1 -1
  192. package/dist/plugins/caret-navigation.mjs +1 -1
  193. package/dist/plugins/code-block.mjs +1 -1
  194. package/dist/plugins/font/FontPlugin.d.ts +13 -0
  195. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  196. package/dist/plugins/font-size/FontSizeOperations.d.ts +2 -0
  197. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
  198. package/dist/plugins/font-size/FontSizePlugin.d.ts +11 -0
  199. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  200. package/dist/plugins/font-size.mjs +1 -1
  201. package/dist/plugins/font.mjs +1 -1
  202. package/dist/plugins/formula/FormulaPlugin.d.ts.map +1 -1
  203. package/dist/plugins/formula/latex/LatexParser.d.ts.map +1 -1
  204. package/dist/plugins/formula/latex/LatexSymbols.d.ts.map +1 -1
  205. package/dist/plugins/formula/latex/LookupOwn.d.ts +6 -0
  206. package/dist/plugins/formula/latex/LookupOwn.d.ts.map +1 -0
  207. package/dist/plugins/formula/latex/handlers/Accents.d.ts.map +1 -1
  208. package/dist/plugins/formula/latex/handlers/Delimiters.d.ts.map +1 -1
  209. package/dist/plugins/formula/latex/handlers/Environments.d.ts.map +1 -1
  210. package/dist/plugins/formula/latex/handlers/Fonts.d.ts.map +1 -1
  211. package/dist/plugins/formula/latex/handlers/Spacing.d.ts.map +1 -1
  212. package/dist/plugins/formula.mjs +1 -1
  213. package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -1
  214. package/dist/plugins/gap-cursor.mjs +1 -1
  215. package/dist/plugins/hard-break.mjs +1 -1
  216. package/dist/plugins/heading.mjs +1 -1
  217. package/dist/plugins/highlight/HighlightPlugin.d.ts +11 -0
  218. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +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/InlineCodePlugin.d.ts.map +1 -1
  223. package/dist/plugins/inline-code.mjs +1 -1
  224. package/dist/plugins/link.mjs +1 -1
  225. package/dist/plugins/list.mjs +1 -1
  226. package/dist/plugins/print.mjs +1 -1
  227. package/dist/plugins/shared/ColorValidation.d.ts +12 -4
  228. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
  229. package/dist/plugins/shared/InlineStyleMarkSpec.d.ts +10 -0
  230. package/dist/plugins/shared/InlineStyleMarkSpec.d.ts.map +1 -1
  231. package/dist/plugins/shared/StyleClassNames.d.ts +10 -0
  232. package/dist/plugins/shared/StyleClassNames.d.ts.map +1 -0
  233. package/dist/plugins/shared.mjs +1 -1
  234. package/dist/plugins/smart-paste.mjs +1 -1
  235. package/dist/plugins/strikethrough.mjs +1 -1
  236. package/dist/plugins/super-sub.mjs +1 -1
  237. package/dist/plugins/table.mjs +1 -1
  238. package/dist/plugins/text-color/TextColorPlugin.d.ts +11 -0
  239. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  240. package/dist/plugins/text-color.mjs +1 -1
  241. package/dist/plugins/text-direction-auto.mjs +1 -1
  242. package/dist/plugins/text-direction.mjs +1 -1
  243. package/dist/plugins/text-formatting.mjs +1 -1
  244. package/dist/plugins/toolbar.mjs +1 -1
  245. package/dist/plugins/video.mjs +1 -1
  246. package/dist/presets/full.mjs +1 -1
  247. package/dist/presets/minimal.mjs +1 -1
  248. package/dist/presets.mjs +1 -1
  249. package/dist/register.mjs +1 -1
  250. package/dist/serialization/AlignmentHTML.d.ts +43 -0
  251. package/dist/serialization/AlignmentHTML.d.ts.map +1 -0
  252. package/dist/serialization/CSSClassCollector.d.ts +20 -17
  253. package/dist/serialization/CSSClassCollector.d.ts.map +1 -1
  254. package/dist/serialization/CSSValueEquivalence.d.ts +24 -0
  255. package/dist/serialization/CSSValueEquivalence.d.ts.map +1 -0
  256. package/dist/serialization/DocumentParser.d.ts +2 -1
  257. package/dist/serialization/DocumentParser.d.ts.map +1 -1
  258. package/dist/serialization/DocumentSerializer.d.ts +0 -4
  259. package/dist/serialization/DocumentSerializer.d.ts.map +1 -1
  260. package/dist/serialization/FirstTagAttributes.d.ts +16 -0
  261. package/dist/serialization/FirstTagAttributes.d.ts.map +1 -0
  262. package/dist/serialization/HTMLParseRules.d.ts +32 -0
  263. package/dist/serialization/HTMLParseRules.d.ts.map +1 -0
  264. package/dist/serialization/HTMLParseSession.d.ts +21 -0
  265. package/dist/serialization/HTMLParseSession.d.ts.map +1 -0
  266. package/dist/serialization/MarkSerializer.d.ts.map +1 -1
  267. package/dist/serialization/StyleClassHTML.d.ts +37 -0
  268. package/dist/serialization/StyleClassHTML.d.ts.map +1 -0
  269. package/dist/serialization/StyleRehydration.d.ts +16 -0
  270. package/dist/serialization/StyleRehydration.d.ts.map +1 -0
  271. package/dist/serialization/TableDimensions.d.ts.map +1 -1
  272. package/dist/serialization/index.d.ts +2 -1
  273. package/dist/serialization/index.d.ts.map +1 -1
  274. package/dist/serialization/markdown/InlineSerializers.d.ts.map +1 -1
  275. package/dist/state/EditorState.d.ts.map +1 -1
  276. package/dist/state/History.d.ts +2 -1
  277. package/dist/state/History.d.ts.map +1 -1
  278. package/dist/state/NavigationQueries.d.ts.map +1 -1
  279. package/dist/state/SelectionValidation.d.ts +12 -0
  280. package/dist/state/SelectionValidation.d.ts.map +1 -0
  281. package/dist/state/StepMapping.d.ts.map +1 -1
  282. package/dist/state/TransactionBuilder.d.ts +7 -1
  283. package/dist/state/TransactionBuilder.d.ts.map +1 -1
  284. package/dist/test/TestUtils.d.ts.map +1 -1
  285. package/dist/view/CursorWrapper.d.ts.map +1 -1
  286. package/dist/view/EditorView.d.ts +25 -1
  287. package/dist/view/EditorView.d.ts.map +1 -1
  288. package/dist/view/InlineContentDOM.d.ts +44 -0
  289. package/dist/view/InlineContentDOM.d.ts.map +1 -0
  290. package/dist/view/Reconciler.d.ts +20 -1
  291. package/dist/view/Reconciler.d.ts.map +1 -1
  292. package/dist/view/RenderedBlockText.d.ts +27 -0
  293. package/dist/view/RenderedBlockText.d.ts.map +1 -0
  294. package/dist/view/SelectionSync.d.ts.map +1 -1
  295. package/package.json +2 -1
  296. package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs +0 -2
  297. package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs.map +0 -1
  298. package/dist/chunks/BidiIsolationPlugin-cOLlL3Y9.mjs +0 -2
  299. package/dist/chunks/BlockquotePlugin-D-jRWLQB.mjs +0 -2
  300. package/dist/chunks/BlockquotePlugin-D-jRWLQB.mjs.map +0 -1
  301. package/dist/chunks/CodeBlockPlugin-BandNM3t.mjs +0 -2
  302. package/dist/chunks/ColorPickerPopup-CFYCCN7m.mjs +0 -2
  303. package/dist/chunks/ColorValidation-B9d_umnf.mjs.map +0 -1
  304. package/dist/chunks/Commands-D-0UXYvo.mjs +0 -2
  305. package/dist/chunks/Commands-D-0UXYvo.mjs.map +0 -1
  306. package/dist/chunks/DocumentParser-i-CreJ48.mjs +0 -2
  307. package/dist/chunks/DocumentParser-i-CreJ48.mjs.map +0 -1
  308. package/dist/chunks/FontPlugin-BySgRcF3.mjs +0 -2
  309. package/dist/chunks/FontPlugin-BySgRcF3.mjs.map +0 -1
  310. package/dist/chunks/FontSizePlugin-zJDiyhUv.mjs +0 -2
  311. package/dist/chunks/FontSizePlugin-zJDiyhUv.mjs.map +0 -1
  312. package/dist/chunks/FormulaPlugin-CI0r4X1o.mjs +0 -2
  313. package/dist/chunks/FormulaPlugin-CI0r4X1o.mjs.map +0 -1
  314. package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs +0 -2
  315. package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs.map +0 -1
  316. package/dist/chunks/HTMLUtils-B0nGyFLb.mjs +0 -2
  317. package/dist/chunks/HTMLUtils-B0nGyFLb.mjs.map +0 -1
  318. package/dist/chunks/HeadingPlugin-BCh12hFT.mjs +0 -2
  319. package/dist/chunks/HeadingPlugin-BCh12hFT.mjs.map +0 -1
  320. package/dist/chunks/HighlightPlugin-By7CWUss.mjs +0 -2
  321. package/dist/chunks/HighlightPlugin-By7CWUss.mjs.map +0 -1
  322. package/dist/chunks/HorizontalRulePlugin-CxmUMM34.mjs +0 -2
  323. package/dist/chunks/ImagePlugin-C_MuvfYo.mjs +0 -2
  324. package/dist/chunks/ImagePlugin-C_MuvfYo.mjs.map +0 -1
  325. package/dist/chunks/InlineCodePlugin-C1SqGfv5.mjs +0 -2
  326. package/dist/chunks/InlineCodePlugin-C1SqGfv5.mjs.map +0 -1
  327. package/dist/chunks/InlineStyleMarkSpec-Cx3goc3W.mjs +0 -2
  328. package/dist/chunks/InlineStyleMarkSpec-Cx3goc3W.mjs.map +0 -1
  329. package/dist/chunks/MarkCommands-CJvLGL5G.mjs +0 -2
  330. package/dist/chunks/MarkCommands-CJvLGL5G.mjs.map +0 -1
  331. package/dist/chunks/MarkdownHTMLRegistry-CISsC0lH.mjs +0 -2
  332. package/dist/chunks/MarkdownSerializer-Oex2RzNw.mjs +0 -2
  333. package/dist/chunks/MarkdownSerializer-Oex2RzNw.mjs.map +0 -1
  334. package/dist/chunks/NavigationQueries-Bt4zZ17v.mjs +0 -2
  335. package/dist/chunks/NavigationQueries-Bt4zZ17v.mjs.map +0 -1
  336. package/dist/chunks/NodeResolver-BtIknXqD.mjs +0 -2
  337. package/dist/chunks/NodeResolver-BtIknXqD.mjs.map +0 -1
  338. package/dist/chunks/PluginHelpers-WG1Lzzh3.mjs +0 -2
  339. package/dist/chunks/SchemaRegistry-acc6q_5x.mjs +0 -2
  340. package/dist/chunks/SchemaRegistry-acc6q_5x.mjs.map +0 -1
  341. package/dist/chunks/SelectionSync-CwOHMMfI.mjs +0 -2
  342. package/dist/chunks/SelectionSync-CwOHMMfI.mjs.map +0 -1
  343. package/dist/chunks/SimpleMark-CTDtEIMV.mjs +0 -2
  344. package/dist/chunks/TableDimensions-BcARMxQB.mjs +0 -2
  345. package/dist/chunks/TableDimensions-BcARMxQB.mjs.map +0 -1
  346. package/dist/chunks/TablePlugin-CdXY0Px5.mjs +0 -2
  347. package/dist/chunks/TablePlugin-CdXY0Px5.mjs.map +0 -1
  348. package/dist/chunks/TextColorPlugin-BLTKft_Z.mjs +0 -2
  349. package/dist/chunks/TextColorPlugin-BLTKft_Z.mjs.map +0 -1
  350. package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +0 -2
  351. package/dist/chunks/ToolbarPlugin-CMHJCdYY.mjs +0 -2
  352. package/dist/chunks/ToolbarPlugin-CMHJCdYY.mjs.map +0 -1
  353. package/dist/chunks/VideoPlugin-C9z4JfP_.mjs +0 -2
  354. package/dist/chunks/VideoPlugin-C9z4JfP_.mjs.map +0 -1
  355. package/dist/chunks/color-picker-DJ05ey9o.mjs +0 -2
  356. package/dist/chunks/color-picker-DJ05ey9o.mjs.map +0 -1
  357. package/dist/chunks/full-9sO5JbWG.mjs +0 -2
  358. package/dist/chunks/minimal-C07d5reO.mjs +0 -2
  359. package/dist/chunks/register-DMdtiQ_Z.mjs +0 -3
  360. package/dist/chunks/register-DMdtiQ_Z.mjs.map +0 -1
  361. package/dist/editor/styles/base.d.ts +0 -3
  362. package/dist/editor/styles/base.d.ts.map +0 -1
  363. package/dist/editor/styles/color-picker.d.ts +0 -3
  364. package/dist/editor/styles/color-picker.d.ts.map +0 -1
  365. package/dist/editor/styles/font-select.d.ts +0 -3
  366. package/dist/editor/styles/font-select.d.ts.map +0 -1
  367. package/dist/editor/styles/font-size-select.d.ts +0 -3
  368. package/dist/editor/styles/font-size-select.d.ts.map +0 -1
  369. package/dist/editor/styles/heading-select.d.ts +0 -3
  370. package/dist/editor/styles/heading-select.d.ts.map +0 -1
  371. package/dist/editor/styles/image.d.ts +0 -3
  372. package/dist/editor/styles/image.d.ts.map +0 -1
  373. package/dist/editor/styles/reduced-motion.d.ts +0 -3
  374. package/dist/editor/styles/reduced-motion.d.ts.map +0 -1
  375. package/dist/editor/styles/table.d.ts +0 -3
  376. package/dist/editor/styles/table.d.ts.map +0 -1
  377. package/dist/editor/styles/toolbar.d.ts +0 -3
  378. package/dist/editor/styles/toolbar.d.ts.map +0 -1
  379. package/dist/plugins/blockquote/BlockquoteStyles.d.ts +0 -3
  380. package/dist/plugins/blockquote/BlockquoteStyles.d.ts.map +0 -1
  381. package/dist/plugins/formula/FormulaStyles.d.ts +0 -12
  382. package/dist/plugins/formula/FormulaStyles.d.ts.map +0 -1
  383. package/dist/plugins/image/ImagePopupStyles.d.ts +0 -3
  384. package/dist/plugins/image/ImagePopupStyles.d.ts.map +0 -1
  385. package/dist/plugins/video/VideoPopupStyles.d.ts +0 -3
  386. package/dist/plugins/video/VideoPopupStyles.d.ts.map +0 -1
  387. package/dist/plugins/video/VideoStyles.d.ts +0 -3
  388. package/dist/plugins/video/VideoStyles.d.ts.map +0 -1
@@ -1,2 +0,0 @@
1
- import{I as e,P as n,V as t,k as r}from"./Document-D_2cIBJG.mjs";import{c as o,f as s,p as i}from"./Selection-DC6AOGgF.mjs";import{i as c}from"./TypeBrands-Ch9856Gb.mjs";import{n as a}from"./CursorMarks-dx51OGBf.mjs";import{n as l}from"./RangeIterator-DDOxTQIf.mjs";function u(){return{nodeTypes:["paragraph"],markTypes:["bold","italic","underline"],getNodeSpec:()=>{}}}function f(e){return{nodeTypes:e.getNodeTypes(),markTypes:e.getMarkTypes(),getNodeSpec:n=>e.getNodeSpec(n),getInlineNodeSpec:n=>e.getInlineNodeSpec(n),getMarkSpec:n=>e.getMarkSpec(n)}}function d(e,n){return e.markTypes.includes(n)}function m(e,n){return e.nodeTypes.includes(n)}var p={bold:!0,italic:!0,underline:!0};function k(n,t,r=p){if(function(e,n){const t=e;return"bold"===t?!n.bold:"italic"===t?!n.italic:"underline"===t&&!n.underline}(t,r))return null;if(!d(n.schema,t))return null;if(!s(n.selection))return null;const c={type:t},u=n.selection;if(o(u)){if(!n.getBlock(u.anchor.blockId))return null;const r=a(n),o=e(r,t)?r.filter(e=>e.type!==t):[...r,c];return n.transaction("command").setStoredMarks(o,n.storedMarks).setSelection(u).build()}const f=i(u,n.getBlockOrder()),m=n.transaction("command"),k=T(n,t);return l(n,f,(e,n,t)=>{k?m.removeMark(e,n,t,c):m.addMark(e,n,t,c)}),m.setSelection(u),m.build()}function g(e,n){return k(e,c("bold"),n)}function y(e,n){return k(e,c("italic"),n)}function S(e,n){return k(e,c("underline"),n)}function b(n,t){const r=n.selection;return!!s(r)&&(o(r)?e(a(n),t):T(n,t))}function T(e,n){const t=e.selection;if(!s(t))return!1;const o=e.getBlockOrder(),c=i(t,o),a=o.indexOf(c.from.blockId),l=o.indexOf(c.to.blockId);let u=!1;for(let s=a;s<=l;s++){const t=o[s];if(!t)continue;const i=e.getBlock(t);if(!i)continue;const f=r(i),d=M(i,s===a?c.from.offset:0,s===l?c.to.offset:f,n);if("missing"===d)return!1;"present"===d&&(u=!0)}return u}function M(r,o,s,i){let c=0,a=!1;for(const l of n(r))if(t(l)){const n=c+l.text.length;if(n>o&&c<s&&(a=!0,!e(l.marks,i)))return"missing";c=n}else c+=1;return a?"present":"empty"}export{S as a,m as c,k as i,f as l,g as n,u as o,y as r,d as s,b as t};
2
- //# sourceMappingURL=MarkCommands-CJvLGL5G.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkCommands-CJvLGL5G.mjs","names":[],"sources":["../../src/model/Schema.ts","../../src/commands/MarkCommands.ts"],"sourcesContent":["/**\n * Schema definition for the Notectl editor.\n * Defines which node types and marks are allowed.\n */\n\nimport type { InlineNodeSpec } from './InlineNodeSpec.js';\nimport type { MarkSpec } from './MarkSpec.js';\nimport type { NodeSpec } from './NodeSpec.js';\nimport type { SchemaRegistry } from './SchemaRegistry.js';\n\nexport interface Schema {\n\treadonly nodeTypes: readonly string[];\n\treadonly markTypes: readonly string[];\n\t/** Looks up the full NodeSpec for a given type. Available when created via schemaFromRegistry. */\n\treadonly getNodeSpec?: (type: string) => NodeSpec | undefined;\n\t/** Looks up the full InlineNodeSpec for a given type. Available via schemaFromRegistry. */\n\treadonly getInlineNodeSpec?: (type: string) => InlineNodeSpec | undefined;\n\t/** Looks up the full MarkSpec for a given type. Available via schemaFromRegistry. */\n\treadonly getMarkSpec?: (type: string) => MarkSpec | undefined;\n}\n\n/** Creates the default schema with paragraph nodes and bold/italic/underline marks. */\nexport function defaultSchema(): Schema {\n\treturn {\n\t\tnodeTypes: ['paragraph'],\n\t\tmarkTypes: ['bold', 'italic', 'underline'],\n\t\tgetNodeSpec: () => undefined,\n\t};\n}\n\n/** Derives a Schema from a SchemaRegistry's registered specs. */\nexport function schemaFromRegistry(registry: SchemaRegistry): Schema {\n\treturn {\n\t\tnodeTypes: registry.getNodeTypes(),\n\t\tmarkTypes: registry.getMarkTypes(),\n\t\tgetNodeSpec: (type: string) => registry.getNodeSpec(type),\n\t\tgetInlineNodeSpec: (type: string) => registry.getInlineNodeSpec(type),\n\t\tgetMarkSpec: (type: string) => registry.getMarkSpec(type),\n\t};\n}\n\n/** Checks whether the given mark type is allowed by the schema. */\nexport function isMarkAllowed(schema: Schema, markType: string): boolean {\n\treturn schema.markTypes.includes(markType);\n}\n\n/** Checks whether the given node type is allowed by the schema. */\nexport function isNodeTypeAllowed(schema: Schema, nodeType: string): boolean {\n\treturn schema.nodeTypes.includes(nodeType);\n}\n","/**\n * Mark-related commands: toggling bold/italic/underline and checking\n * whether a mark is active.\n */\n\nimport {\n\ttype BlockNode,\n\ttype Mark,\n\tgetBlockLength,\n\tgetInlineChildren,\n\thasMark,\n\tisTextNode,\n} from '../model/Document.js';\nimport { isMarkAllowed } from '../model/Schema.js';\nimport { isCollapsed, isTextSelection, selectionRange } from '../model/Selection.js';\nimport type { MarkTypeName } from '../model/TypeBrands.js';\nimport { markType as mkType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { resolveCursorMarks } from './CursorMarks.js';\nimport { forEachBlockInRange } from './RangeIterator.js';\n\n// --- Feature Configuration ---\n\nexport interface FeatureConfig {\n\treadonly bold: boolean;\n\treadonly italic: boolean;\n\treadonly underline: boolean;\n}\n\nconst defaultFeatures: FeatureConfig = { bold: true, italic: true, underline: true };\n\n/**\n * Toggles a mark on the current selection.\n * If collapsed, toggles stored marks. If range, applies/removes from text.\n */\nexport function toggleMark(\n\tstate: EditorState,\n\tmarkType: MarkTypeName,\n\tfeatures: FeatureConfig = defaultFeatures,\n): Transaction | null {\n\tif (isFeatureGated(markType, features)) return null;\n\tif (!isMarkAllowed(state.schema, markType)) return null;\n\tif (!isTextSelection(state.selection)) return null;\n\n\tconst mark: Mark = { type: markType };\n\tconst sel = state.selection;\n\n\tif (isCollapsed(sel)) {\n\t\t// Toggle stored marks\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return null;\n\t\tconst currentMarks = resolveCursorMarks(state);\n\t\tconst hasIt = hasMark(currentMarks, markType);\n\t\tconst newMarks = hasIt\n\t\t\t? currentMarks.filter((m) => m.type !== markType)\n\t\t\t: [...currentMarks, mark];\n\n\t\treturn state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t}\n\n\t// Range selection — apply/remove mark to all blocks in range\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\t// Determine if we should add or remove\n\tconst shouldRemove = isMarkActiveInRange(state, markType);\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tif (shouldRemove) {\n\t\t\tbuilder.removeMark(blockId, from, to, mark);\n\t\t} else {\n\t\t\tbuilder.addMark(blockId, from, to, mark);\n\t\t}\n\t});\n\n\tbuilder.setSelection(sel);\n\treturn builder.build();\n}\n\nexport function toggleBold(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('bold'), features);\n}\n\nexport function toggleItalic(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('italic'), features);\n}\n\nexport function toggleUnderline(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('underline'), features);\n}\n\n/** Checks if a mark is active at the current selection. */\nexport function isMarkActive(state: EditorState, markType: MarkTypeName): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tif (isCollapsed(sel)) {\n\t\treturn hasMark(resolveCursorMarks(state), markType);\n\t}\n\n\treturn isMarkActiveInRange(state, markType);\n}\n\n/** Per-slice result of scanning a block for a mark. */\ntype SliceMarkStatus = 'present' | 'missing' | 'empty';\n\n/** Checks if a mark is active across the entire selection range. */\nfunction isMarkActiveInRange(state: EditorState, markType: MarkTypeName): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(sel, blockOrder);\n\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tlet sawMarkedText = false;\n\tfor (let i = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\t\tconst blockLen = getBlockLength(block);\n\t\tconst from = i === fromIdx ? range.from.offset : 0;\n\t\tconst to = i === toIdx ? range.to.offset : blockLen;\n\n\t\tconst status = markStatusInBlock(block, from, to, markType);\n\t\tif (status === 'missing') return false;\n\t\tif (status === 'present') sawMarkedText = true;\n\t}\n\n\t// Active only when the range actually contains text that carries the mark.\n\t// A range with no markable text (only empty blocks, or a void block such as a\n\t// lone display formula on Ctrl+A) is NOT active — returning true there would\n\t// light up every toolbar format button.\n\treturn sawMarkedText;\n}\n\n/**\n * Scans a block's `[from, to)` slice for `markType`. Returns:\n * - `missing` when some text character in the slice lacks the mark,\n * - `present` when the slice has text and all of it carries the mark,\n * - `empty` when the slice has no markable text (empty slice or only InlineNodes).\n *\n * An `empty` slice is neutral: it neither activates nor inverts the range check,\n * so an empty paragraph in the middle of a multi-block selection does not flip\n * the result (regression #130).\n */\nfunction markStatusInBlock(\n\tblock: BlockNode,\n\tfrom: number,\n\tto: number,\n\tmarkType: MarkTypeName,\n): SliceMarkStatus {\n\tlet pos = 0;\n\tlet sawText = false;\n\tfor (const child of getInlineChildren(block)) {\n\t\tif (isTextNode(child)) {\n\t\t\tconst childEnd = pos + child.text.length;\n\t\t\tif (childEnd > from && pos < to) {\n\t\t\t\tsawText = true;\n\t\t\t\tif (!hasMark(child.marks, markType)) return 'missing';\n\t\t\t}\n\t\t\tpos = childEnd;\n\t\t} else {\n\t\t\t// InlineNode: atomic, width 1, carries no marks.\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn sawText ? 'present' : 'empty';\n}\n\nfunction isFeatureGated(type: MarkTypeName, features: FeatureConfig): boolean {\n\tconst key = type as string;\n\tif (key === 'bold') return !features.bold;\n\tif (key === 'italic') return !features.italic;\n\tif (key === 'underline') return !features.underline;\n\treturn false;\n}\n"],"mappings":"0QAsBA,SAAgB,IACf,MAAO,CACN,UAAW,CAAC,aACZ,UAAW,CAAC,OAAQ,SAAU,aAC9B,YAAA,OAEF,CAGA,SAAgB,EAAmB,GAClC,MAAO,CACN,UAAW,EAAS,eACpB,UAAW,EAAS,eACpB,YAAc,GAAiB,EAAS,YAAY,GACpD,kBAAoB,GAAiB,EAAS,kBAAkB,GAChE,YAAc,GAAiB,EAAS,YAAY,GAEtD,CAGA,SAAgB,EAAc,EAAgB,GAC7C,OAAO,EAAO,UAAU,SAAS,EAClC,CAGA,SAAgB,EAAkB,EAAgB,GACjD,OAAO,EAAO,UAAU,SAAS,EAClC,CCnBA,IAAM,EAAiC,CAAE,MAAM,EAAM,QAAQ,EAAM,WAAW,GAM9E,SAAgB,EACf,EACA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AK,EAAgB,GAAM,OAAO,EAClC,MAAM,EAAa,EAAM,gBACnB,EAAQ,EAAe,EAAK,GAE5B,EAAU,EAAW,QAAQ,EAAM,KAAK,SACxC,EAAQ,EAAW,QAAQ,EAAM,GAAG,SAE1C,IAAI,GAAgB,EACpB,IAAK,IAAI,EAAI,EAAS,GAAK,EAAO,IAAK,CACtC,MAAM,EAAU,EAAW,GAC3B,IAAK,EAAS,SACd,MAAM,EAAQ,EAAM,SAAS,GAC7B,IAAK,EAAO,SACZ,MAAM,EAAW,EAAe,GAI1B,EAAS,EAAkB,EAHpB,IAAM,EAAU,EAAM,KAAK,OAAS,EACtC,IAAM,EAAQ,EAAM,GAAG,OAAS,EAEO,GAClD,GAAe,YAAX,EAAsB,OAAO,EAClB,YAAX,IAAsB,GAAgB,EAC3C,CAMA,OAAO,CACR,CAYA,SAAS,EACR,EACA,EACA,EACA,GAEA,IAAI,EAAM,EACN,GAAU,EACd,IAAK,MAAM,KAAS,EAAkB,GACrC,GAAI,EAAW,GAAQ,CACtB,MAAM,EAAW,EAAM,EAAM,KAAK,OAClC,GAAI,EAAW,GAAQ,EAAM,IAC5B,GAAU,GACL,EAAQ,EAAM,MAAO,IAAW,MAAO,UAE7C,EAAM,CACP,MAEC,GAAO,EAGT,OAAO,EAAU,UAAY,OAC9B"}
@@ -1,2 +0,0 @@
1
- import{n as t,s as e}from"./HTMLUtils-B0nGyFLb.mjs";import{l as n,n as r,o as i,r as s}from"./TableDimensions-BcARMxQB.mjs";import{t as o}from"./SchemaRegistry-acc6q_5x.mjs";var a=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;function c(t){let e=t.trim();e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1));const n=[];let r="";for(let i=0;i<e.length;i++){const t=e[i]??"";"\\"!==t||"|"!==e[i+1]?"|"!==t?r+=t:(n.push(r.trim()),r=""):(r+="|",i++)}return n.push(r.trim()),n}function l(t){const e=t.trim(),n=e.startsWith(":"),r=e.endsWith(":");return n&&r?"center":r?"end":n?"start":null}function u(t,e,n){const r=t[e]??"",i=t[e+1]??"";if(!r.includes("|"))return null;if(!a.test(i))return null;const s=c(r),o=c(i).map(l);if(o.length!==s.length)return null;const u=[];let g=e+2;for(;g<t.length;){const e=t[g]??"";if(""===e.trim())break;if(!e.includes("|")&&(!n||n(e)))break;u.push(c(e)),g++}return{aligns:o,header:s,rows:u,linesConsumed:g-e}}var g=/[!-/:-@[-`{-~]/,h=/&(#[xX][0-9a-fA-F]{1,6}|#[0-9]{1,7}|[a-zA-Z][a-zA-Z0-9]{1,31});/y,f={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",copy:"©",reg:"®",hellip:"…",mdash:"—",ndash:"–"};function p(t){if("#"===t[0]){const e="x"===t[1]||"X"===t[1],n=Number.parseInt(t.slice(e?2:1),e?16:10);if(!Number.isFinite(n)||n<0||n>1114111)return`&${t};`;if(0===n)return"�";try{const t=String.fromCodePoint(n);return"\n"===t||"\r"===t?" ":t}catch{return"�"}}return f[t]??function(t){if("undefined"==typeof document)return null;const e=m.get(t);if(void 0!==e)return e;const n=document.createElement("div");n.innerHTML=`&${t};`;const r=n.textContent??"",i=""!==r&&r!==`&${t};`?r:null;return m.set(t,i),i}(t)??`&${t};`}function d(t,e){return h.lastIndex=e,h.exec(t)}var m=/* @__PURE__ */new Map;function b(t){let e="",n=0;for(;n<t.length;){const r=t[n]??"";if("\\"===r&&g.test(t[n+1]??""))e+=t[n+1],n+=2;else{if("&"===r){const r=d(t,n);if(r?.[1]){e+=p(r[1]),n+=r[0].length;continue}}e+=r,n++}}return e}function $(t){let e="",n=0;for(;n<t.length;){const r=t[n]??"";if("&"===r){const r=d(t,n);if(r?.[1]){e+=p(r[1]),n+=r[0].length;continue}}e+=r,n++}return e}var y,k=/* @__PURE__ */new Set(["address","article","aside","blockquote","details","div","dl","dd","dt","figure","figcaption","footer","form","h1","h2","h3","h4","h5","h6","header","hr","iframe","main","nav","ol","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul","video"]),M=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,T=/^ {0,3}(`{3,}|~{3,})[ \t]*(.*)$/,S=/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/,x=/^ {0,3}>[ ]?/,L=/^([ \t]*)([-*+])(?:([ \t]+)(.*))?$/,H=/^([ \t]*)(\d{1,9})([.)])(?:([ \t]+)(.*))?$/,w=/^\[([ xX])\][ \t]+(.*)$/,N=/^ {0,3}=+[ \t]*$/,z=/^ {0,3}-+[ \t]*$/,A=/^ {0,3}<(\/?)([a-zA-Z][a-zA-Z0-9-]*)|^ {0,3}<!--/;function v(t){return""===t.trim()}function D(t){const e=t.match(T);return e?"`"===(e[1]??"")[0]&&(e[2]??"").includes("`")?null:e:null}function O(t,e=!0,n=[]){return _(t.replace(/\r\n?/g,"\n").replace(/\n$/,"").split("\n"),e,n)}function _(t,e,n,r=0){const i=[];let s=0;for(;s<t.length;){const o=t[s]??"";if(v(o)){s++;continue}const a=P(n,t,s,i);if(a>0){s+=a;continue}if(e){const e=u(t,s,J);if(e){i.push({type:"table",aligns:e.aligns,header:e.header,rows:e.rows}),s+=e.linesConsumed;continue}}const c=D(o);if(c){s=C(t,s,c,i);continue}const l=o.match(M);if(l){const t=(l[2]??"").trim(),e=/^#+$/.test(t)?"":t;i.push({type:"heading",level:(l[1]??"#").length,text:e}),s++;continue}if(S.test(o)){i.push({type:"hr"}),s++;continue}if(x.test(o)){if(r>=32){s=K(t,s,i);continue}s=R(t,s,i,e,n,r);continue}const g=r<32?X(o):null;s=g?V(t,s,g,i,e,n,r):q(o)?I(t,s,i):U(o)?G(t,s,i):K(t,s,i)}return i}function C(t,e,n,r){const i=n[1]??"```",s=i[0]??"`",o=b((n[2]??"").trim().split(/\s+/)[0]??""),a=new RegExp(`^ {0,3}\\${s}{${i.length},}[ \\t]*$`),c=t[e]??"",l=c.length-c.trimStart().length,u=[];let g=e+1;for(;g<t.length;){const e=t[g]??"";if(a.test(e)){g++;break}u.push(j(e,l)),g++}return r.push({type:"code_block",language:o,code:u.join("\n")}),g}function j(t,e){let n=0;for(;n<e&&" "===t[n];)n++;return t.slice(n)}function q(t){return W(t)>=4}function W(t){let e=0;for(const n of t)if(" "===n)e++;else{if("\t"!==n)break;e+=4-e%4}return e}function E(t,e){let n=0,r=0;for(;r<t.length;){const e=t[r]??"";if(" "===e)n++;else{if("\t"!==e)break;n+=4-n%4}r++}return" ".repeat(Math.max(0,n-e))+t.slice(r)}function F(t,e){let n=0,r=0;for(;r<t.length&&n<e;){const i=t[r]??"";if(" "===i)n++,r++;else{if("\t"!==i)break;{const i=n+4-n%4;if(i>e)return" ".repeat(i-e)+t.slice(r+1);n=i,r++}}}return t.slice(r)}function I(t,e,n){const r=[],i=[];let s=e;for(;s<t.length;){const e=t[s]??"";if(v(e))i.push(F(e,4)),s++;else{if(W(e)<4)break;for(;i.length>0;)r.push(i.shift()??"");r.push(F(e,4)),s++}}return n.push({type:"code_block",language:"",code:r.join("\n")}),s-i.length}function P(t,e,n,r){for(const i of t){const t=i.matchBlock?.(e,n);if(t&&t.linesConsumed>0)return r.push({type:"extension_block",nodeType:t.type,attrs:t.attrs}),t.linesConsumed}return 0}function R(t,e,n,r,i,s){const o=[];let a=e,c=!1;for(;a<t.length;){const e=t[a]??"";if(x.test(e)){const t=e.replace(x,"");o.push(t),c=Z(t),a++;continue}if(!c||v(e)||J(e)||r&&u(t,a,J))break;o.push(e),a++}return n.push({type:"blockquote",children:_(o,r,i,s+1)}),a}function Z(t){let e=t;for(;;){if(x.test(e)){e=e.replace(x,"");continue}const t=X(e);if(!t||""===t.firstText)break;e=t.firstText}return""!==e.trim()&&!J(e)&&W(e)<4}function X(t){const e=t.match(L),n=e?null:t.match(H),r=e??n;if(!r)return null;const i=W(r[1]??"");if(i>3)return null;const s=i+((e?r[2]:`${r[2]}${r[3]}`)??"-").length,o=function(t,e){let n=t;for(const r of e)if(" "===r)n++;else{if("\t"!==r)break;n+=4-n%4}return n-t}(s,(e?r[3]:r[4])??""),a=(e?r[4]:r[5])??"",c=n?Number.parseInt(r[2]??"1",10):1;let l,u;""===a.trim()?(l=s+1,u=""):o>=5?(l=s+1,u=" ".repeat(o-1)+a):(l=s+o,u=a);const g=u.match(w);return g?{listType:"checklist",checked:"x"===(g[1]??" ").toLowerCase(),contentColumn:l,firstText:g[2]??"",startNumber:c}:{listType:n?"ordered":"bullet",checked:!1,contentColumn:l,firstText:u,startNumber:c}}function V(t,e,n,r,i,s,o){const a=[],c=function(){let t=null;return(e,n)=>{if(t)return t.test(e)&&(t=null),!1;const r=D(e);if(r){const e=r[1]??"```",n=e[0]??"`";return t=new RegExp(`^ {0,3}\\${n}{${e.length},}[ \\t]*$`),!1}return!v(e)&&(x.test(e)||X(e)?Z(e):W(e)>=4?n:!J(e))}}();let l=n.firstText,g=""!==l&&c(l,!1),h=0,f=e+1;for(;f<t.length;){const e=t[f]??"";if(v(e)){if(""===l&&0===a.length)break;h++,g=!1,f++;continue}if(W(e)>=n.contentColumn){for(;h>0;)a.push(""),h--;const t=E(e,n.contentColumn);a.push(t),g=c(t,g),f++;continue}if(X(e))break;if(!g)break;if(J(e))break;if(i&&u(t,f,J))break;const r=e.trimStart(),s=a[a.length-1];void 0!==s?a[a.length-1]=`${s}\n${r}`:l=""===l?r:`${l}\n${r}`,g=c(r,g),f++}return function(t,e,n,r,i,s,o){const a=""===e?[...n]:[e,...n],c=0===a.length?[]:_(a,i,s,o+1),l=[],u=[];for(const h of c)"list_item"===h.type?l.push({...h,indent:h.indent+1}):u.push(h);const g=u[0];1===u.length&&"paragraph"===g?.type?r.push(B(t,g.text)):0===u.length?r.push(B(t,"")):r.push(B(t,"",u)),r.push(...l)}(n,l,a,r,i,s,o),f}function B(t,e,n){const r={type:"list_item",listType:t.listType,indent:0,checked:t.checked,text:e};return n?{...r,children:n}:r}function U(t){const e=t.match(A);if(!e)return!1;if(t.trimStart().startsWith("\x3c!--"))return!0;const n=(e[2]??"").toLowerCase();return k.has(n)}function G(t,e,n){const r=[];let i=e;for(;i<t.length;){const e=t[i]??"";if(v(e))break;r.push(e),i++}return n.push({type:"html",html:r.join("\n")}),i}function J(t){return!!(v(t)||M.test(t)||D(t)||S.test(t)||x.test(t)||function(t){const e=X(t);return!!e&&""!==e.firstText.trim()&&("ordered"!==e.listType||1===e.startNumber)}(t)||U(t))}function K(t,e,n){const r=[t[e]??""];let i=e+1;for(;i<t.length;){const e=t[i]??"";if(N.test(e))return n.push({type:"heading",level:1,text:Y(r)}),i+1;if(z.test(e))return n.push({type:"heading",level:2,text:Y(r)}),i+1;if(J(e))break;r.push(e),i++}return n.push({type:"paragraph",text:Q(r)}),i}function Q(t){return t.map((e,n)=>n===t.length-1?e.trim():e.trimStart()).join("\n")}function Y(t){return t.map(t=>t.trim()).join(" ").trim()}function tt(a){return a||(y??=function(){const a=new o;return function(e){e.registerNodeSpec({type:"paragraph",toDOM:et,toHTML:(t,e)=>`<p>${e||"<br>"}</p>`,parseHTML:[{tag:"p"},{tag:"div",priority:10}],sanitize:{tags:["p"]}}),e.registerNodeSpec({type:"heading",toDOM:et,toHTML(t,e){const n=t.attrs?.level,r="number"==typeof n&&Number.isFinite(n)?Math.max(1,Math.min(6,Math.floor(n))):1;return`<h${r}>${e||"<br>"}</h${r}>`},parseHTML:[1,2,3,4,5,6].map(t=>({tag:`h${t}`,getAttrs:()=>({level:t})})),sanitize:{tags:["h1","h2","h3","h4","h5","h6"]}}),e.registerNodeSpec({type:"list_item",toDOM:et,toHTML(t,e){if("checklist"!==t.attrs?.listType)return`<li>${e||"<br>"}</li>`;const n=!0===t.attrs.checked;return`<li role="checkbox" aria-checked="${String(n)}"><input type="checkbox" disabled${n?" checked":""}>${e||"<br>"}</li>`},parseHTML:[{tag:"li"}],sanitize:{tags:["ul","ol","li","input"],attrs:["type","disabled","checked","role","aria-checked"]}}),e.registerNodeSpec({type:"blockquote",toDOM:et,toHTML:(t,e)=>`<blockquote>${e||"<br>"}</blockquote>`,parseHTML:[{tag:"blockquote"}],sanitize:{tags:["blockquote"]}}),e.registerNodeSpec({type:"code_block",toDOM:et,toHTML(e,n){const r=String(e.attrs?.language??"");return`<pre><code${r?` class="language-${t(r)}"`:""}>${n}</code></pre>`},parseHTML:[{tag:"pre",getAttrs:t=>({language:t.querySelector("code")?.className.match(/(?:^|\s)language-(\S+)/)?.[1]??""})}],sanitize:{tags:["pre","code"],attrs:["class"]}}),e.registerNodeSpec({type:"horizontal_rule",isVoid:!0,toDOM:et,toHTML:()=>"<hr>",parseHTML:[{tag:"hr"}],sanitize:{tags:["hr"]}}),e.registerNodeSpec({type:"image",isVoid:!0,attrs:{src:{default:""},alt:{default:""},title:{default:""},align:{default:"center"}},toDOM:et,toHTML(e){const n=t(String(e.attrs?.src??"")),r=t(String(e.attrs?.alt??"")),i=String(e.attrs?.title??""),s=(t,e)=>"number"==typeof e&&Number.isFinite(e)&&e>0?` ${t}="${String(e)}"`:"";return`<figure><img src="${n}" alt="${r}"${i?` title="${t(i)}"`:""}${s("width",e.attrs?.width)}${s("height",e.attrs?.height)}></figure>`},parseHTML:[{tag:"figure",getAttrs(t){const e=t.querySelector("img");return!!e&&nt(e)}},{tag:"img",getAttrs:t=>nt(t)}],sanitize:{tags:["figure","img"],attrs:["src","alt","title","width","height"]}}),e.registerNodeSpec({type:"table",toDOM:et,toHTML(t,e,s){const o=i(t.attrs?.columnWidthsPx),a=o?`<colgroup>${o.map(t=>`<col${n(r,"width",t,s)}>`).join("")}</colgroup>`:"";return`<table${o?function(t,e){const n=t.reduce((t,e)=>t+(e??60),0),r=t.every(t=>null!==t)?`width: ${String(n)}px; min-width: ${String(n)}px; table-layout: fixed`:`width: 100%; min-width: ${String(n)}px; table-layout: fixed`;return e?.styleAttr(r)??` style="${r}"`}(o,s):""}>${a}<tbody>${e}</tbody></table>`},sanitize:{tags:["table","colgroup","col","thead","tbody","tfoot"],attrs:["span","width",r]}}),e.registerNodeSpec({type:"table_row",toDOM:et,toHTML:(t,e,r)=>`<tr${n(s,"height",t.attrs?.minHeightPx,r)}>${e}</tr>`,sanitize:{tags:["tr"],attrs:["height",s]}}),e.registerNodeSpec({type:"table_cell",toDOM:et,toHTML(t,e){const n=(t,e)=>"number"==typeof e&&Number.isInteger(e)&&e>1?` ${t}="${String(e)}"`:"";return`<td${n("colspan",t.attrs?.colspan)}${n("rowspan",t.attrs?.rowspan)}>${e}</td>`},sanitize:{tags:["td","th"],attrs:["colspan","rowspan"]}})}(a),function(n){for(const t of[{type:"bold",rank:0,tag:"strong",parseTags:["strong","b"]},{type:"italic",rank:1,tag:"em",parseTags:["em","i"]},{type:"underline",rank:2,tag:"u",parseTags:["u"]},{type:"code",rank:3,tag:"code",parseTags:["code"]},{type:"strikethrough",rank:4,tag:"s",parseTags:["s","strike","del"]}])n.registerMarkSpec({type:t.type,rank:t.rank,toDOM:et,toHTMLString:(e,n)=>`<${t.tag}>${n}</${t.tag}>`,parseHTML:t.parseTags.map(t=>({tag:t,getAttrs:"code"===t?t=>"PRE"!==t.parentElement?.tagName&&{}:void 0})),sanitize:{tags:t.parseTags}});n.registerMarkSpec({type:"link",rank:10,toDOM:et,toHTMLString(n,r){const i=t(e(String(n.attrs?.href??""))),s=String(n.attrs?.title??"");return`<a href="${i}"${s?` title="${t(s)}"`:""}>${r}</a>`},parseHTML:[{tag:"a",getAttrs(t){const n=e(t.getAttribute("href")??""),r=t.getAttribute("title");return r?{href:n,title:r}:{href:n}}}],sanitize:{tags:["a"],attrs:["href","title"]}})}(a),function(e){e.registerInlineNodeSpec({type:"hard_break",toDOM:et,toHTMLString:()=>"<br>",parseHTML:[{tag:"br"}],sanitize:{tags:["br"]}}),e.registerInlineNodeSpec({type:"image_inline",toDOM:et,toHTMLString(e){const n=t(String(e.attrs.src??"")),r=t(String(e.attrs.alt??"")),i=String(e.attrs.title??"");return`<img src="${n}" alt="${r}"${i?` title="${t(i)}"`:""}>`},parseHTML:[{tag:"img",getAttrs:t=>rt(t)}],sanitize:{tags:["img"],attrs:["src","alt","title"]}})}(a),a}(),y)}function et(){throw new Error("The Markdown HTML registry cannot render editor DOM.")}function nt(t){const e={...rt(t),align:"center"};for(const n of["width","height"]){const r=Number.parseFloat(t.getAttribute(n)??"");Number.isFinite(r)&&r>0&&(e[n]=r)}return e}function rt(t){const e={src:t.getAttribute("src")??"",alt:t.getAttribute("alt")??""},n=t.getAttribute("title");return n&&(e.title=n),e}export{z as a,O as c,b as d,d as f,N as i,$ as l,M as n,S as o,T as r,D as s,tt as t,p as u};
2
- //# sourceMappingURL=MarkdownHTMLRegistry-CISsC0lH.mjs.map
@@ -1,2 +0,0 @@
1
- import{t}from"./rolldown-runtime-H_PjY6_i.mjs";import{o as n}from"./HTMLUtils-B0nGyFLb.mjs";import{B as e,D as r,H as o,P as s,_ as i,j as l,z as c}from"./Document-D_2cIBJG.mjs";import{r as a}from"./AttrRegistry-CtNhf2EF.mjs";import{_ as u,a as f,h as p,i as h,v as m}from"./TableDimensions-BcARMxQB.mjs";import{a as g,i as $,o as d,r as k,t as y}from"./MarkdownHTMLRegistry-CISsC0lH.mjs";function b(t){const n=t?.flavor??"gfm";return{flavor:n,gfm:"gfm"===n,htmlFallback:!1!==t?.htmlFallback,headingStyle:t?.headingStyle??"atx",bullet:t?.bullet??"-",emphasis:t?.emphasis??"*",codeFence:t?.codeFence??"```",listIndent:t?.listIndent??2}}function S(t){return{flavor:t.flavor,htmlFallback:t.htmlFallback}}var x=/* @__PURE__ */new Set(["\\","`","*","[","]","<",">"]);function v(t,n){const e=t[n-1],r=t[n+1];return void 0!==e&&void 0!==r&&/\w/.test(e)&&/\w/.test(r)}function M(t,n){let e="";for(let r=0;r<t.length;r++){const o=t[r]??"";x.has(o)?e+=`\\${o}`:"_"!==o||v(t,r)?e+="~"===o&&n?"\\~":"&"!==o?o:"&amp;":e+="\\_"}return e}var j=/^(\s*)([#>])/,F=/^(\s*)([-*+])(\s)/,T=/^(\s*)(\d{1,9})([.)])(\s)/;function w(t){return j.test(t)?t.replace(j,(t,n,e)=>`${n}\\${e}`):F.test(t)?t.replace(F,(t,n,e,r)=>`${n}\\${e}${r}`):T.test(t)?t.replace(T,(t,n,e,r,o)=>`${n}${e}\\${r}${o}`):function(t){return d.test(t)||$.test(t)||g.test(t)||k.test(t)}(t)?t.replace(/\S/,t=>`\\${t}`):t}function H(t){return/[\s()]/.test(t)?`<${t.replace(/([<>])/g,"\\$1")}>`:t}function L(t){return t.replace(/(["\\])/g,"\\$1")}var _={styleAttr:t=>t?` style="${t}"`:""};function I(t,n){const e=t.type;return"link"===e||"bold"===e||"italic"===e||!("strikethrough"!==e||!n)}function N(t,n){const e=n.opts.emphasis;switch(t.type){case"bold":return{open:e.repeat(2),close:e.repeat(2)};case"italic":return{open:e,close:e};case"strikethrough":return{open:"~~",close:"~~"};default:{const n=String(t.attrs?.href??""),e=String(t.attrs?.title??"");return{open:"[",close:`](${H(n)}${e?` "${L(e)}"`:""})`}}}}function D(t){return"link"!==t.type}function O(t,n){return t.type===n.type&&JSON.stringify(t.attrs??{})===JSON.stringify(n.attrs??{})}function z(t,n){const e=[],r=[];for(const o of t.marks)I(o,n)&&("link"===o.type?e.push(o):r.push(o));return[...e,...r]}function A(t,n){const e=[],r=[...t];for(let o=r.length-1;o>=0;o--){const t=r[o];t&&!D(t)&&(e.push(t),r.splice(o,1))}for(const o of n){if(!D(o))continue;const t=r.findIndex(t=>O(t,o));if(-1!==t){const n=r[t];n&&e.push(n),r.splice(t,1)}}for(const o of r)e.push(o);return e}function P(t,n){if(""===t.text)return"";if(t.marks.some(t=>"code"===t.type))return function(t){const n=function(t){let n=0,e=0;for(const r of t)"`"===r?(e++,n=Math.max(n,e)):e=0;return"`".repeat(n+1)}(t);return`${n}${t.startsWith("`")||t.endsWith("`")||t.length>0&&0===t.trim().length?` ${t} `:t}${n}`}(t.text);const e=n.opts.gfm,r=t.marks.filter(t=>!I(t,e)&&"code"!==t.type);return r.length>0&&n.opts.htmlFallback?m(t.text,r,y(n.registry),n.markOrder,_):M(t.text,e)}function W(t,n){if("hard_break"===t.inlineType)return"\\\n";if("image_inline"===t.inlineType)return function(t,n){const e=String(t.attrs.src??""),r=String(t.attrs.alt??""),o=String(t.attrs.title??""),s=o?` "${L(o)}"`:"";return`![${M(r,n.opts.gfm)}](${H(e)}${s})`}(t,n);const e=n.registry?.getInlineNodeSpec(t.inlineType),r=e?.toMarkdown?.(t,S(n.opts));return null!=r?r:n.opts.htmlFallback&&e?.toHTMLString?e.toHTMLString(t):""}function B(t){const n=[];for(const e of t){const t=n[n.length-1];!c(e)&&t&&!c(t)&&o(t.marks,e.marks)?n[n.length-1]={type:"text",text:t.text+e.text,marks:t.marks}:n.push(e)}return n}function J(t,n){return!(!t||c(t))&&t.marks.some(t=>O(t,n))}function R(t,n){return 0===n.length?[...t]:t.filter(t=>!n.some(n=>O(n,t)))}function q(t,n,e,r,o){const s=t.marks.filter(t=>function(t,n){return I(t,n)&&"link"!==t.type}(t,r));if(0===s.length)return void o.push(t);const l=t.text,c=function(t){let n=0;for(;n<t.length&&/\s/.test(t[n]);)n++;return n}(l);if(c===l.length){const r=s.filter(t=>!(J(n,t)&&J(e,t)));return void o.push(i(l,R(t.marks,r)))}const a=function(t){let n=t.length;for(;n>0&&/\s/.test(t[n-1]);)n--;return t.length-n}(l),u=l.slice(0,c),f=l.slice(c,l.length-a),p=l.slice(l.length-a);if(u){const e=s.filter(t=>!J(n,t));o.push(i(u,R(t.marks,e)))}if(o.push(i(f,t.marks)),p){const n=s.filter(t=>!J(e,t));o.push(i(p,R(t.marks,n)))}}function U(t,n){const e=n.opts.gfm,r=function(t,n){const e=[];for(let r=0;r<t.length;r++){const o=t[r];o&&(c(o)?e.push(o):q(o,t[r-1],t[r+1],n,e))}return B(e)}(B(t),e);let o="",s=[];const i=t=>{for(let e=s.length-1;e>=t;e--){const t=s[e];t&&(o+=N(t,n).close)}s=s.slice(0,t)};for(const l of r){const t=A(z(l,e),s);let r=0;for(;r<s.length&&r<t.length&&O(s[r],t[r]);)r++;i(r);for(let e=r;e<t.length;e++){const r=t[e];r&&(o+=N(r,n).open,s.push(r))}o+=c(l)?W(l,n):P(l,n)}return i(0),o}function C(t,n){const e=[];let r=0;for(;r<t.length;){const o=t[r];if(o)if(a(o,"list_item")){const o=[];for(;r<t.length;){const n=t[r];if(!n||!a(n,"list_item"))break;o.push(n),r++}e.push(n.opts.htmlFallback&&o.some(G)?K(o,n):V(o,n))}else e.push(E(o,n)),r++;else r++}return e.filter(t=>t.length>0).join("\n\n")}function E(t,n){if(n.opts.htmlFallback&&G(t))return K([t],n);const o=t.type;return"paragraph"===o?function(t,n){const e=U(s(t),n);return""===e.trim()?"":e.split("\n").map(w).join("\n")}(t,n):"heading"===o?function(t,n){const e=function(t){return t<1?1:t>6?6:Math.floor(t)}(t.attrs?.level??1),r=U(s(t),n).replace(/\n/g," ");if("setext"===n.opts.headingStyle&&e<=2&&""!==r)return`${r}\n${(1===e?"=":"-").repeat(Math.max(3,r.length))}`;const o="#".repeat(e);return r?`${o} ${r}`:o}(t,n):"code_block"===o?function(t,n){const e=String(t.attrs?.language??""),r=l(t),o=n.opts.codeFence[0]??"`",s=o.repeat(Math.max(3,function(t,n){let e=0,r=0;for(const o of t)o===n?(r++,e=Math.max(e,r)):r=0;return e}(r,o)+1));return`${s}${e}\n${r}\n${s}`}(t,n):"horizontal_rule"===o?n.inListItem?"***":"---":"image"===o?function(t,n){const e=String(t.attrs?.src??""),r=String(t.attrs?.alt??""),o=String(t.attrs?.title??""),s=t.attrs?.width,i=t.attrs?.height,l=t.attrs?.align;if((void 0!==s||void 0!==i||void 0!==l&&"center"!==l)&&n.opts.htmlFallback){const e=n.registry?.getNodeSpec("image")?.toHTML?.(t,"");if(e)return e}const c=o?` "${L(o)}"`:"";return`![${M(r,n.opts.gfm)}](${H(e)}${c})`}(t,n):"blockquote"===o?function(t,n){return C(r(t),n).split("\n").map(t=>""===t?">":`> ${t}`).join("\n")}(t,n):"table"===o?function(t,n){const e=r(t);if(0===e.length)return"";if(!n.opts.gfm&&n.opts.htmlFallback)return K([t],n);if(n.opts.htmlFallback&&(function(t){for(const n of t)for(const t of r(n)){const n=t.attrs?.colspan,e=t.attrs?.rowspan;if((n??1)>1||(e??1)>1)return!0}return!1}(e)||function(t,n){return!!h(t.attrs?.columnWidthsPx)||n.some(t=>void 0!==f(t.attrs?.minHeightPx))}(t,e)))return K([t],n);const o=e.map(t=>r(t).map(t=>function(t,n){return r(t).map(t=>U(s(t),n)).join(" ").replace(/\n/g," ").replace(/\|/g,"\\|").trim()}(t,n))),i=o.reduce((t,n)=>Math.max(t,n.length),0);if(0===i)return"";const l=t=>{const n=[...t];for(;n.length<i;)n.push("");return`| ${n.join(" | ")} |`},c=e[0],a=Array.from({length:i},(t,n)=>{return e=function(t,n){if(!t)return;const e=r(t)[n];return e?r(e)[0]?.attrs?.align:void 0}(c,n),"start"===e?":---":"center"===e?":---:":"end"===e?"---:":"---";var e}),u=[];u.push(l(o[0]??[])),u.push(`| ${a.join(" | ")} |`);for(let r=1;r<o.length;r++)u.push(l(o[r]??[]));return u.join("\n")}(t,n):"title"===o?Q(t,n,1):"subtitle"===o?Q(t,n,2):function(t,n){const o=n.registry?.getNodeSpec(t.type),i=e(t)?U(s(t),n):C(r(t),n),l=o?.toMarkdown?.(t,i,S(n.opts));return null!=l?l:n.opts.htmlFallback&&o?.toHTML?o.toHTML(t,i):i}(t,n)}function G(t){return!!n(t.htmlId)||r(t).some(G)}function K(t,n){return p({children:t},y(n.registry),{includeBlockIds:!1})}function Q(t,n,e){if(n.opts.htmlFallback){const e=U(s(t),n),r=n.registry?.getNodeSpec(t.type)?.toHTML?.(t,e);if(r)return r}const r=U(s(t),n).replace(/\n/g," "),o="#".repeat(e);return r?`${o} ${r}`:o}function V(t,n){const o=[],i=[],l=[];let c=-1;for(const a of t){const t=String(a.attrs?.listType??"bullet"),u=Math.max(0,a.attrs?.indent??0),f=Math.min(u,c+1);c=f;const p=0===f?0:l[f-1]??0,h=" ".repeat(p);let m;if(i.length=f+1,l.length=f+1,"ordered"===t)i[f]=(i[f]??0)+1,m=`${i[f]}.`;else if("checklist"===t){const t=!0===a.attrs?.checked;m=`${n.opts.bullet} [${t?"x":" "}]`}else m=n.opts.bullet;const g="checklist"===t?n.opts.bullet.length+1:m.length+1;if(l[f]=p+g,e(a)){const t=w(U(s(a),n).replace(/\n/g," "));o.push(t?`${h}${m} ${t}`:`${h}${m}`);continue}const $=C(r(a),{...n,inListItem:!0});if(""===$){o.push(`${h}${m}`);continue}const d=" ".repeat(l[f]??p+g),k=$.split("\n");o.push(`${h}${m} ${k[0]??""}`);for(let n=1;n<k.length;n++){const t=k[n]??"";o.push(""===t?"":`${d}${t}`)}}return o.join("\n")}var X=/* @__PURE__ */t({serializeDocumentToMarkdown:()=>Y});function Y(t,n,e){const r={registry:n,opts:b(e),markOrder:n?u(n):void 0};return function(t){const n=t.trim();return n.length>0?`${n}\n`:""}(C(t.children,r))}export{Y as n,X as t};
2
- //# sourceMappingURL=MarkdownSerializer-Oex2RzNw.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownSerializer-Oex2RzNw.mjs","names":[],"sources":["../../src/serialization/markdown/MarkdownContext.ts","../../src/serialization/markdown/MarkdownEscape.ts","../../src/serialization/markdown/InlineSerializers.ts","../../src/serialization/markdown/BlockSerializers.ts","../../src/serialization/MarkdownSerializer.ts"],"sourcesContent":["/**\n * Resolved serialization options and the context threaded through the Markdown\n * serializer. Kept separate from the serializer modules so block/inline\n * serializers can share the type without a circular import.\n */\n\nimport type { MarkdownExportContext } from '../../model/NodeSpec.js';\nimport type { SchemaRegistry } from '../../model/SchemaRegistry.js';\nimport type { MarkdownSerializeOptions } from '../MarkdownTypes.js';\n\n/** Fully-resolved serialization options (no `undefined`). */\nexport interface ResolvedSerializeOptions {\n\treadonly flavor: 'commonmark' | 'gfm';\n\treadonly gfm: boolean;\n\treadonly htmlFallback: boolean;\n\treadonly headingStyle: 'atx' | 'setext';\n\treadonly bullet: string;\n\treadonly emphasis: string;\n\treadonly codeFence: string;\n\treadonly listIndent: number;\n}\n\n/** Internal context shared by all serialization helpers. */\nexport interface SerContext {\n\treadonly registry?: SchemaRegistry;\n\treadonly opts: ResolvedSerializeOptions;\n\t/** Precomputed mark rank map (built once per pass) for HTML-fallback marks. */\n\treadonly markOrder?: Map<string, number>;\n\t/**\n\t * True while serializing the block children of a list item (#194): thematic\n\t * breaks emit `***` there, because `---` on an indented continuation line\n\t * would re-parse as a setext underline or a bullet marker.\n\t */\n\treadonly inListItem?: boolean;\n}\n\n/** Resolves user-facing options into a complete settings object with defaults. */\nexport function resolveSerializeOptions(\n\toptions?: MarkdownSerializeOptions,\n): ResolvedSerializeOptions {\n\tconst flavor: 'commonmark' | 'gfm' = options?.flavor ?? 'gfm';\n\treturn {\n\t\tflavor,\n\t\tgfm: flavor === 'gfm',\n\t\thtmlFallback: options?.htmlFallback !== false,\n\t\theadingStyle: options?.headingStyle ?? 'atx',\n\t\tbullet: options?.bullet ?? '-',\n\t\temphasis: options?.emphasis ?? '*',\n\t\tcodeFence: options?.codeFence ?? '```',\n\t\tlistIndent: options?.listIndent ?? 2,\n\t};\n}\n\n/** Builds the public {@link MarkdownExportContext} passed to per-spec hooks. */\nexport function exportContext(opts: ResolvedSerializeOptions): MarkdownExportContext {\n\treturn { flavor: opts.flavor, htmlFallback: opts.htmlFallback };\n}\n","/**\n * CommonMark escaping rules for Markdown serialization.\n *\n * Escaping is contextual: inline text backslash-escapes characters that would\n * otherwise start emphasis/code/links, while the start of a line additionally\n * escapes block markers (`#`, `>`, `-`, …) so prose never accidentally becomes\n * a heading or list on re-parse. Output stays minimal: we do not escape every\n * punctuation character, only those that are actually ambiguous in context.\n */\n\nimport { FENCE_OPEN, SETEXT_H1, SETEXT_H2, THEMATIC_BREAK } from './BlockTokenizer.js';\n\n/** Inline specials that always need escaping in text content. */\nconst ALWAYS_ESCAPE = new Set(['\\\\', '`', '*', '[', ']', '<', '>']);\n\n/** Whether the character at `i` sits between two word characters (intra-word). */\nfunction isIntraWord(text: string, i: number): boolean {\n\tconst prev: string | undefined = text[i - 1];\n\tconst next: string | undefined = text[i + 1];\n\tif (prev === undefined || next === undefined) return false;\n\treturn /\\w/.test(prev) && /\\w/.test(next);\n}\n\n/**\n * Escapes inline text so it round-trips as literal content. `~` is escaped only\n * for GFM (where `~~` is strikethrough); `_` is escaped only when it is not\n * intra-word, matching CommonMark's emphasis rules (so `a_b_c` stays literal).\n */\nexport function escapeInline(text: string, gfm: boolean): string {\n\tlet out = '';\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst ch: string = text[i] ?? '';\n\t\tif (ALWAYS_ESCAPE.has(ch)) {\n\t\t\tout += `\\\\${ch}`;\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === '_' && !isIntraWord(text, i)) {\n\t\t\tout += '\\\\_';\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === '~' && gfm) {\n\t\t\tout += '\\\\~';\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === '&') {\n\t\t\tout += '&amp;';\n\t\t\tcontinue;\n\t\t}\n\t\tout += ch;\n\t}\n\treturn out;\n}\n\n/** Pattern matching a leading block marker that must be escaped in paragraph text. */\nconst LINE_START_MARKER = /^(\\s*)([#>])/;\n/** Pattern matching a leading list bullet (`- `, `* `, `+ `). */\nconst LINE_START_BULLET = /^(\\s*)([-*+])(\\s)/;\n/** Pattern matching a leading ordered marker (`1.` / `1)`). */\nconst LINE_START_ORDERED = /^(\\s*)(\\d{1,9})([.)])(\\s)/;\n\n/**\n * Whether a whole line would re-parse as a block construct that spans the entire\n * line: a thematic break, a setext underline, or an opening code fence. These\n * carry no trailing content marker (unlike `#`/`-`/`1.`), so they slip past the\n * leading-marker rules above. Backtick fences and `*`/`_`/`~` breaks are already\n * neutralized by inline escaping (they arrive backslash-prefixed); what reaches\n * here is `-`/`=` runs and, under CommonMark, `~~~` fences.\n */\nfunction reparsesAsBlockLine(line: string): boolean {\n\treturn (\n\t\tTHEMATIC_BREAK.test(line) ||\n\t\tSETEXT_H1.test(line) ||\n\t\tSETEXT_H2.test(line) ||\n\t\tFENCE_OPEN.test(line)\n\t);\n}\n\n/**\n * Escapes leading block markers at the start of a paragraph line so the text\n * does not re-parse as a heading, blockquote, list, thematic break, setext\n * underline, or code fence.\n */\nexport function escapeLineStart(line: string): string {\n\tif (LINE_START_MARKER.test(line)) {\n\t\treturn line.replace(LINE_START_MARKER, (_m, ws: string, marker: string) => `${ws}\\\\${marker}`);\n\t}\n\tif (LINE_START_BULLET.test(line)) {\n\t\treturn line.replace(\n\t\t\tLINE_START_BULLET,\n\t\t\t(_m, ws: string, marker: string, sp: string) => `${ws}\\\\${marker}${sp}`,\n\t\t);\n\t}\n\tif (LINE_START_ORDERED.test(line)) {\n\t\treturn line.replace(\n\t\t\tLINE_START_ORDERED,\n\t\t\t(_m, ws: string, num: string, marker: string, sp: string) => `${ws}${num}\\\\${marker}${sp}`,\n\t\t);\n\t}\n\tif (reparsesAsBlockLine(line)) {\n\t\t// Backslash the first non-space character: that breaks the run so the line\n\t\t// stays a paragraph, and `\\-` / `\\=` / `\\~` decode back to the literal char.\n\t\treturn line.replace(/\\S/, (ch) => `\\\\${ch}`);\n\t}\n\treturn line;\n}\n\n/** Escapes the destination of a link/image so spaces and parens stay intact. */\nexport function escapeLinkDestination(url: string): string {\n\tif (/[\\s()]/.test(url)) {\n\t\treturn `<${url.replace(/([<>])/g, '\\\\$1')}>`;\n\t}\n\treturn url;\n}\n\n/** Escapes a link/image title for the `\"...\"` form. */\nexport function escapeLinkTitle(title: string): string {\n\treturn title.replace(/([\"\\\\])/g, '\\\\$1');\n}\n\n/**\n * Picks a backtick fence long enough to wrap `content` as an inline code span.\n * CommonMark requires a fence longer than any backtick run inside the content.\n */\nexport function codeSpanFence(content: string): string {\n\tlet longest = 0;\n\tlet current = 0;\n\tfor (const ch of content) {\n\t\tif (ch === '`') {\n\t\t\tcurrent++;\n\t\t\tlongest = Math.max(longest, current);\n\t\t} else {\n\t\t\tcurrent = 0;\n\t\t}\n\t}\n\treturn '`'.repeat(longest + 1);\n}\n\n/** Wraps `content` in a correctly sized inline code span, padding when needed. */\nexport function wrapCodeSpan(content: string): string {\n\tconst fence: string = codeSpanFence(content);\n\t// Pad with a space when content starts/ends with a backtick or is all spaces,\n\t// per CommonMark's code-span stripping rule.\n\tconst needsPad: boolean =\n\t\tcontent.startsWith('`') ||\n\t\tcontent.endsWith('`') ||\n\t\t(content.length > 0 && content.trim().length === 0);\n\tconst inner: string = needsPad ? ` ${content} ` : content;\n\treturn `${fence}${inner}${fence}`;\n}\n","/**\n * Inline Markdown serialization: marks (emphasis nesting), code spans, links and\n * inline nodes. Marks with no portable Markdown form (underline, highlight, …)\n * fall back to raw inline HTML via the existing `MarkSerializer` (D3).\n *\n * Emphasis delimiters are emitted with a ProseMirror-markdown-style\n * reconciliation: shared \"mixable\" marks keep their open position across\n * adjacent text runs, so the serializer never produces ambiguous adjacent\n * delimiters (e.g. `**a*****b***`) that would mis-parse on round-trip.\n */\n\nimport type { InlineNode, Mark, TextNode } from '../../model/Document.js';\nimport { createTextNode, isInlineNode, markSetsEqual } from '../../model/Document.js';\nimport type { HTMLExportContext } from '../../model/NodeSpec.js';\nimport { serializeMarksToHTML } from '../MarkSerializer.js';\nimport { type SerContext, exportContext } from './MarkdownContext.js';\nimport {\n\tescapeInline,\n\tescapeLinkDestination,\n\tescapeLinkTitle,\n\twrapCodeSpan,\n} from './MarkdownEscape.js';\nimport { resolveMarkdownHTMLRegistry } from './MarkdownHTMLRegistry.js';\n\n/** Inline HTML export context (inline-style mode) for HTML-fallback marks. */\nconst INLINE_HTML_CTX: HTMLExportContext = {\n\tstyleAttr: (declarations: string) => (declarations ? ` style=\"${declarations}\"` : ''),\n};\n\n/** Whether a mark is serialized as a Markdown delimiter (vs. HTML fallback / code). */\nfunction isStackMark(mark: Mark, gfm: boolean): boolean {\n\tconst t: string = mark.type;\n\tif (t === 'link' || t === 'bold' || t === 'italic') return true;\n\tif (t === 'strikethrough' && gfm) return true;\n\treturn false;\n}\n\n/** Returns the open/close delimiter pair for a stack mark. */\nfunction delimiters(mark: Mark, ctx: SerContext): { open: string; close: string } {\n\tconst emphasis: string = ctx.opts.emphasis;\n\tswitch (mark.type) {\n\t\tcase 'bold':\n\t\t\treturn { open: emphasis.repeat(2), close: emphasis.repeat(2) };\n\t\tcase 'italic':\n\t\t\treturn { open: emphasis, close: emphasis };\n\t\tcase 'strikethrough':\n\t\t\treturn { open: '~~', close: '~~' };\n\t\tdefault: {\n\t\t\t// link\n\t\t\tconst href: string = String(mark.attrs?.href ?? '');\n\t\t\tconst title: string = String(mark.attrs?.title ?? '');\n\t\t\tconst dest: string = escapeLinkDestination(href);\n\t\t\tconst titlePart: string = title ? ` \"${escapeLinkTitle(title)}\"` : '';\n\t\t\treturn { open: '[', close: `](${dest}${titlePart})` };\n\t\t}\n\t}\n}\n\n/** Mixable marks may be reordered to keep shared marks open; link may not. */\nfunction isMixable(mark: Mark): boolean {\n\treturn mark.type !== 'link';\n}\n\n/** Structural equality for stack marks (type + attrs). */\nfunction marksEqual(a: Mark, b: Mark): boolean {\n\tif (a.type !== b.type) return false;\n\treturn JSON.stringify(a.attrs ?? {}) === JSON.stringify(b.attrs ?? {});\n}\n\n/** Collects the stack (delimiter) marks of a text or inline node, link outermost. */\nfunction stackMarksOf(node: TextNode | InlineNode, gfm: boolean): Mark[] {\n\tconst link: Mark[] = [];\n\tconst emphasis: Mark[] = [];\n\tfor (const mark of node.marks) {\n\t\tif (!isStackMark(mark, gfm)) continue;\n\t\tif (mark.type === 'link') link.push(mark);\n\t\telse emphasis.push(mark);\n\t}\n\treturn [...link, ...emphasis];\n}\n\n/**\n * Reorders a node's stack marks so that mixable marks already open (in `active`)\n * keep their position, minimizing close/reopen churn. Link stays outermost.\n */\nfunction reorderToActive(marks: readonly Mark[], active: readonly Mark[]): Mark[] {\n\tconst result: Mark[] = [];\n\tconst remaining: Mark[] = [...marks];\n\n\t// Non-mixable (link) first, preserving its position.\n\tfor (let i = remaining.length - 1; i >= 0; i--) {\n\t\tconst mark = remaining[i];\n\t\tif (mark && !isMixable(mark)) {\n\t\t\tresult.push(mark);\n\t\t\tremaining.splice(i, 1);\n\t\t}\n\t}\n\n\t// Then mixable marks already active, in active order.\n\tfor (const a of active) {\n\t\tif (!isMixable(a)) continue;\n\t\tconst idx: number = remaining.findIndex((m) => marksEqual(m, a));\n\t\tif (idx !== -1) {\n\t\t\tconst found = remaining[idx];\n\t\t\tif (found) result.push(found);\n\t\t\tremaining.splice(idx, 1);\n\t\t}\n\t}\n\n\t// Finally any new mixable marks.\n\tfor (const m of remaining) result.push(m);\n\treturn result;\n}\n\n/** Renders the literal content of a text node (code span, HTML-fallback, or escaped text). */\nfunction renderTextContent(node: TextNode, ctx: SerContext): string {\n\tif (node.text === '') return '';\n\n\tconst hasCode: boolean = node.marks.some((m) => m.type === 'code');\n\tif (hasCode) return wrapCodeSpan(node.text);\n\n\tconst gfm: boolean = ctx.opts.gfm;\n\tconst fallbackMarks: Mark[] = node.marks.filter((m) => !isStackMark(m, gfm) && m.type !== 'code');\n\n\tif (fallbackMarks.length > 0 && ctx.opts.htmlFallback) {\n\t\treturn serializeMarksToHTML(\n\t\t\tnode.text,\n\t\t\tfallbackMarks,\n\t\t\tresolveMarkdownHTMLRegistry(ctx.registry),\n\t\t\tctx.markOrder,\n\t\t\tINLINE_HTML_CTX,\n\t\t);\n\t}\n\t// htmlFallback off: keep text, drop styling.\n\treturn escapeInline(node.text, gfm);\n}\n\n/** Serializes a single inline node (hard break, inline image, math, plugin extensions). */\nfunction serializeInlineNode(node: InlineNode, ctx: SerContext): string {\n\tif (node.inlineType === 'hard_break') return '\\\\\\n';\n\tif (node.inlineType === 'image_inline') return serializeInlineImage(node, ctx);\n\n\tconst spec = ctx.registry?.getInlineNodeSpec(node.inlineType);\n\tconst md: string | null | undefined = spec?.toMarkdown?.(node, exportContext(ctx.opts));\n\tif (md != null) return md;\n\n\tif (ctx.opts.htmlFallback && spec?.toHTMLString) return spec.toHTMLString(node);\n\treturn '';\n}\n\n/** Serializes an inline image node to `![alt](src \"title\")` (engine-owned standard construct). */\nfunction serializeInlineImage(node: InlineNode, ctx: SerContext): string {\n\tconst src: string = String(node.attrs.src ?? '');\n\tconst alt: string = String(node.attrs.alt ?? '');\n\tconst title: string = String(node.attrs.title ?? '');\n\tconst titlePart: string = title ? ` \"${escapeLinkTitle(title)}\"` : '';\n\treturn `![${escapeInline(alt, ctx.opts.gfm)}](${escapeLinkDestination(src)}${titlePart})`;\n}\n\n/** Merges adjacent text nodes with identical mark sets; inline nodes are boundaries. */\nfunction mergeAdjacent(children: readonly (TextNode | InlineNode)[]): (TextNode | InlineNode)[] {\n\tconst result: (TextNode | InlineNode)[] = [];\n\tfor (const child of children) {\n\t\tconst prev = result[result.length - 1];\n\t\tif (\n\t\t\t!isInlineNode(child) &&\n\t\t\tprev &&\n\t\t\t!isInlineNode(prev) &&\n\t\t\tmarkSetsEqual(prev.marks, child.marks)\n\t\t) {\n\t\t\tresult[result.length - 1] = { type: 'text', text: prev.text + child.text, marks: prev.marks };\n\t\t} else {\n\t\t\tresult.push(child);\n\t\t}\n\t}\n\treturn result;\n}\n\n/** A flanking-sensitive emphasis mark (bold/italic/strike) whose delimiters must hug non-whitespace. */\nfunction isFlankingMark(mark: Mark, gfm: boolean): boolean {\n\treturn isStackMark(mark, gfm) && mark.type !== 'link';\n}\n\n/** Whether a sibling carries a mark equal to `mark` (false for inline nodes / no sibling). */\nfunction siblingHasMark(node: TextNode | InlineNode | undefined, mark: Mark): boolean {\n\tif (!node || isInlineNode(node)) return false;\n\treturn node.marks.some((m) => marksEqual(m, mark));\n}\n\n/** Length of the leading run of ASCII/Unicode whitespace in `text`. */\nfunction leadingWhitespace(text: string): number {\n\tlet i = 0;\n\twhile (i < text.length && /\\s/.test(text[i] as string)) i++;\n\treturn i;\n}\n\n/** Length of the trailing run of whitespace in `text`. */\nfunction trailingWhitespace(text: string): number {\n\tlet i: number = text.length;\n\twhile (i > 0 && /\\s/.test(text[i - 1] as string)) i--;\n\treturn text.length - i;\n}\n\n/** Returns `marks` with every mark in `strip` removed. */\nfunction withoutMarks(marks: readonly Mark[], strip: readonly Mark[]): Mark[] {\n\tif (strip.length === 0) return [...marks];\n\treturn marks.filter((m) => !strip.some((s) => marksEqual(s, m)));\n}\n\n/** Splits one text node's edge whitespace out of its flanking emphasis marks. */\nfunction expelNodeWhitespace(\n\tnode: TextNode,\n\tprev: TextNode | InlineNode | undefined,\n\tnext: TextNode | InlineNode | undefined,\n\tgfm: boolean,\n\tout: (TextNode | InlineNode)[],\n): void {\n\tconst flanking: Mark[] = node.marks.filter((m) => isFlankingMark(m, gfm));\n\tif (flanking.length === 0) {\n\t\tout.push(node);\n\t\treturn;\n\t}\n\n\tconst text: string = node.text;\n\tconst leadLen: number = leadingWhitespace(text);\n\n\t// All whitespace: a flanking mark survives only when interior on BOTH sides\n\t// (a same-mark neighbor before and after); otherwise it is expelled.\n\tif (leadLen === text.length) {\n\t\tconst strip: Mark[] = flanking.filter(\n\t\t\t(m) => !(siblingHasMark(prev, m) && siblingHasMark(next, m)),\n\t\t);\n\t\tout.push(createTextNode(text, withoutMarks(node.marks, strip)));\n\t\treturn;\n\t}\n\n\tconst trailLen: number = trailingWhitespace(text);\n\tconst lead: string = text.slice(0, leadLen);\n\tconst core: string = text.slice(leadLen, text.length - trailLen);\n\tconst trail: string = text.slice(text.length - trailLen);\n\n\tif (lead) {\n\t\tconst strip: Mark[] = flanking.filter((m) => !siblingHasMark(prev, m));\n\t\tout.push(createTextNode(lead, withoutMarks(node.marks, strip)));\n\t}\n\tout.push(createTextNode(core, node.marks));\n\tif (trail) {\n\t\tconst strip: Mark[] = flanking.filter((m) => !siblingHasMark(next, m));\n\t\tout.push(createTextNode(trail, withoutMarks(node.marks, strip)));\n\t}\n}\n\n/**\n * Expels whitespace from the edges of flanking-sensitive emphasis spans\n * (bold/italic/strikethrough). A `**` delimiter that hugs whitespace\n * (`**end **`) is not flanking, so CommonMark — and this engine's own parser —\n * read it literally, breaking the round-trip. Whitespace at a mark's span\n * boundary is moved outside the mark; whitespace interior to a span is kept.\n */\nfunction expelEdgeWhitespace(\n\tchildren: readonly (TextNode | InlineNode)[],\n\tgfm: boolean,\n): (TextNode | InlineNode)[] {\n\tconst out: (TextNode | InlineNode)[] = [];\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (!child) continue;\n\t\tif (isInlineNode(child)) {\n\t\t\tout.push(child);\n\t\t\tcontinue;\n\t\t}\n\t\texpelNodeWhitespace(child, children[i - 1], children[i + 1], gfm, out);\n\t}\n\treturn mergeAdjacent(out);\n}\n\n/** Serializes inline children of a leaf block to a Markdown string. */\nexport function serializeInlineContent(\n\tchildren: readonly (TextNode | InlineNode)[],\n\tctx: SerContext,\n): string {\n\tconst gfm: boolean = ctx.opts.gfm;\n\tconst merged: (TextNode | InlineNode)[] = expelEdgeWhitespace(mergeAdjacent(children), gfm);\n\tlet out = '';\n\tlet active: Mark[] = [];\n\n\tconst closeFrom = (keep: number): void => {\n\t\tfor (let i = active.length - 1; i >= keep; i--) {\n\t\t\tconst mark = active[i];\n\t\t\tif (mark) out += delimiters(mark, ctx).close;\n\t\t}\n\t\tactive = active.slice(0, keep);\n\t};\n\n\tfor (const child of merged) {\n\t\t// Inline nodes carry stack marks too (e.g. a `link` on an inline image), so\n\t\t// they flow through the same open/close reconciliation as text. The only\n\t\t// difference is the literal content emitted between the delimiters.\n\t\tconst target: Mark[] = reorderToActive(stackMarksOf(child, gfm), active);\n\n\t\tlet keep = 0;\n\t\twhile (\n\t\t\tkeep < active.length &&\n\t\t\tkeep < target.length &&\n\t\t\tmarksEqual(active[keep] as Mark, target[keep] as Mark)\n\t\t) {\n\t\t\tkeep++;\n\t\t}\n\t\tcloseFrom(keep);\n\t\tfor (let i = keep; i < target.length; i++) {\n\t\t\tconst mark = target[i];\n\t\t\tif (!mark) continue;\n\t\t\tout += delimiters(mark, ctx).open;\n\t\t\tactive.push(mark);\n\t\t}\n\n\t\tout += isInlineNode(child) ? serializeInlineNode(child, ctx) : renderTextContent(child, ctx);\n\t}\n\n\tcloseFrom(0);\n\treturn out;\n}\n","/**\n * Block-level Markdown serialization.\n *\n * Leaf/self-contained blocks (paragraph, heading, code_block, horizontal_rule,\n * image) have built-in emitters keyed by type name — the same centralized,\n * by-type-name mapping the importer uses, and the shape `prosemirror-markdown`\n * uses. Container/structural blocks (blockquote, list, table) are engine-owned\n * because their children need per-line prefixing/indentation that cannot be\n * composed from a wrapper (D12): each container serializes its own children and\n * applies its prefix to those known lines (never a post-hoc regex on assembled\n * output). Unknown/superset blocks defer to the per-spec `toMarkdown` hook, then\n * to a raw-HTML fallback via `toHTML` (D3, D4).\n */\n\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport {\n\tgetBlockChildren,\n\tgetBlockText,\n\tgetInlineChildren,\n\tisLeafBlock,\n} from '../../model/Document.js';\nimport { normalizeHTMLId } from '../../model/HTMLUtils.js';\nimport { serializeDocumentToHTML } from '../DocumentSerializer.js';\nimport {\n\thasExplicitTableColumnWidth,\n\tnormalizeSerializedTableDimensionPx,\n} from '../TableDimensions.js';\nimport { serializeInlineContent } from './InlineSerializers.js';\nimport { type SerContext, exportContext } from './MarkdownContext.js';\nimport {\n\tescapeInline,\n\tescapeLineStart,\n\tescapeLinkDestination,\n\tescapeLinkTitle,\n} from './MarkdownEscape.js';\nimport { resolveMarkdownHTMLRegistry } from './MarkdownHTMLRegistry.js';\n\n/** Serializes a sequence of blocks, grouping consecutive list items, joined by blank lines. */\nexport function serializeBlocks(blocks: readonly BlockNode[], ctx: SerContext): string {\n\tconst parts: string[] = [];\n\tlet i = 0;\n\twhile (i < blocks.length) {\n\t\tconst block: BlockNode | undefined = blocks[i];\n\t\tif (!block) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isNodeOfType(block, 'list_item')) {\n\t\t\tconst items: BlockNode[] = [];\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst item: BlockNode | undefined = blocks[i];\n\t\t\t\tif (!item || !isNodeOfType(item, 'list_item')) break;\n\t\t\t\titems.push(item);\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tparts.push(\n\t\t\t\tctx.opts.htmlFallback && items.some(hasHTMLIdInTree)\n\t\t\t\t\t? serializeHTMLFallback(items, ctx)\n\t\t\t\t\t: serializeListGroup(items, ctx),\n\t\t\t);\n\t\t} else {\n\t\t\tparts.push(serializeBlock(block, ctx));\n\t\t\ti++;\n\t\t}\n\t}\n\treturn parts.filter((p) => p.length > 0).join('\\n\\n');\n}\n\n/** Serializes a single (non-list-item) block. */\nexport function serializeBlock(block: BlockNode, ctx: SerContext): string {\n\tif (ctx.opts.htmlFallback && hasHTMLIdInTree(block)) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\tconst type: string = block.type;\n\n\tif (type === 'paragraph') return serializeParagraph(block, ctx);\n\tif (type === 'heading') return serializeHeading(block, ctx);\n\tif (type === 'code_block') return serializeCodeBlock(block, ctx);\n\tif (type === 'horizontal_rule') return ctx.inListItem ? '***' : '---';\n\tif (type === 'image') return serializeImage(block, ctx);\n\tif (type === 'blockquote') return serializeBlockquote(block, ctx);\n\tif (type === 'table') return serializeTable(block, ctx);\n\tif (type === 'title') return serializeTitleLike(block, ctx, 1);\n\tif (type === 'subtitle') return serializeTitleLike(block, ctx, 2);\n\n\treturn serializeUnknownBlock(block, ctx);\n}\n\n/** Whether a block subtree carries HTML-only identity that Markdown cannot express. */\nfunction hasHTMLIdInTree(block: BlockNode): boolean {\n\tif (normalizeHTMLId(block.htmlId)) return true;\n\treturn getBlockChildren(block).some(hasHTMLIdInTree);\n}\n\n/** Emits a complete block run as raw HTML without leaking internal block IDs. */\nfunction serializeHTMLFallback(blocks: readonly BlockNode[], ctx: SerContext): string {\n\treturn serializeDocumentToHTML({ children: blocks }, resolveMarkdownHTMLRegistry(ctx.registry), {\n\t\tincludeBlockIds: false,\n\t});\n}\n\n/** Paragraph: inline content with leading block markers escaped per line. */\nfunction serializeParagraph(block: BlockNode, ctx: SerContext): string {\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx);\n\tif (content.trim() === '') return '';\n\treturn content.split('\\n').map(escapeLineStart).join('\\n');\n}\n\n/** Heading: ATX (`## h`) by default, setext for levels 1-2 when requested. */\nfunction serializeHeading(block: BlockNode, ctx: SerContext): string {\n\tconst level: number = clampLevel((block.attrs?.level as number | undefined) ?? 1);\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx).replace(/\\n/g, ' ');\n\n\tif (ctx.opts.headingStyle === 'setext' && level <= 2 && content !== '') {\n\t\tconst underline: string = level === 1 ? '=' : '-';\n\t\treturn `${content}\\n${underline.repeat(Math.max(3, content.length))}`;\n\t}\n\tconst hashes: string = '#'.repeat(level);\n\treturn content ? `${hashes} ${content}` : hashes;\n}\n\nfunction clampLevel(level: number): number {\n\tif (level < 1) return 1;\n\tif (level > 6) return 6;\n\treturn Math.floor(level);\n}\n\n/** Fenced code block; the fence is grown to exceed any fence run inside the code. */\nfunction serializeCodeBlock(block: BlockNode, ctx: SerContext): string {\n\tconst lang: string = String(block.attrs?.language ?? '');\n\tconst code: string = getBlockText(block);\n\tconst fenceChar: string = ctx.opts.codeFence[0] ?? '`';\n\tconst fence: string = fenceChar.repeat(Math.max(3, longestRun(code, fenceChar) + 1));\n\treturn `${fence}${lang}\\n${code}\\n${fence}`;\n}\n\n/** Length of the longest consecutive run of `ch` in `text`. */\nfunction longestRun(text: string, ch: string): number {\n\tlet longest = 0;\n\tlet current = 0;\n\tfor (const c of text) {\n\t\tif (c === ch) {\n\t\t\tcurrent++;\n\t\t\tlongest = Math.max(longest, current);\n\t\t} else {\n\t\t\tcurrent = 0;\n\t\t}\n\t}\n\treturn longest;\n}\n\n/** Standalone image on its own line; styling-bearing images use HTML fallback (D3). */\nfunction serializeImage(block: BlockNode, ctx: SerContext): string {\n\tconst src: string = String(block.attrs?.src ?? '');\n\tconst alt: string = String(block.attrs?.alt ?? '');\n\tconst title: string = String(block.attrs?.title ?? '');\n\tconst width = block.attrs?.width as number | undefined;\n\tconst height = block.attrs?.height as number | undefined;\n\tconst align = block.attrs?.align as string | undefined;\n\tconst hasStyling: boolean =\n\t\twidth !== undefined || height !== undefined || (align !== undefined && align !== 'center');\n\n\tif (hasStyling && ctx.opts.htmlFallback) {\n\t\tconst html: string | undefined = ctx.registry?.getNodeSpec('image')?.toHTML?.(block, '');\n\t\tif (html) return html;\n\t}\n\n\tconst titlePart: string = title ? ` \"${escapeLinkTitle(title)}\"` : '';\n\treturn `![${escapeInline(alt, ctx.opts.gfm)}](${escapeLinkDestination(src)}${titlePart})`;\n}\n\n/** Blockquote container: serialize children, then prefix every line with `> `. */\nfunction serializeBlockquote(block: BlockNode, ctx: SerContext): string {\n\tconst inner: string = serializeBlocks(getBlockChildren(block), ctx);\n\treturn inner\n\t\t.split('\\n')\n\t\t.map((line) => (line === '' ? '>' : `> ${line}`))\n\t\t.join('\\n');\n}\n\n/** title/subtitle: HTML fallback (`<h1 class>`) by default; degrade to `#`/`##` otherwise (D5). */\nfunction serializeTitleLike(block: BlockNode, ctx: SerContext, level: number): string {\n\tif (ctx.opts.htmlFallback) {\n\t\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx);\n\t\tconst html: string | undefined = ctx.registry\n\t\t\t?.getNodeSpec(block.type)\n\t\t\t?.toHTML?.(block, content);\n\t\tif (html) return html;\n\t}\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx).replace(/\\n/g, ' ');\n\tconst hashes: string = '#'.repeat(level);\n\treturn content ? `${hashes} ${content}` : hashes;\n}\n\n/** Unknown / superset block: per-spec `toMarkdown` hook, then raw-HTML fallback, then degrade. */\nfunction serializeUnknownBlock(block: BlockNode, ctx: SerContext): string {\n\tconst spec = ctx.registry?.getNodeSpec(block.type);\n\tconst content: string = isLeafBlock(block)\n\t\t? serializeInlineContent(getInlineChildren(block), ctx)\n\t\t: serializeBlocks(getBlockChildren(block), ctx);\n\n\tconst md: string | null | undefined = spec?.toMarkdown?.(block, content, exportContext(ctx.opts));\n\tif (md != null) return md;\n\n\tif (ctx.opts.htmlFallback && spec?.toHTML) return spec.toHTML(block, content);\n\n\t// htmlFallback off: keep textual content, drop the unrepresentable wrapper.\n\treturn content;\n}\n\n/**\n * Serializes a run of consecutive list items into Markdown list lines.\n *\n * Indent maps to CommonMark content columns (#194): each level's items are\n * padded to the content column of the last item one level up, so the parser\n * reads them back as nested (a `1. ` parent needs three columns, `- ` two).\n * Container items emit their block children indented to their own content\n * column, separated by the blank lines `serializeBlocks` produces.\n *\n * A nesting level is valid only when the level above it has a preceding item to\n * anchor the content column. An item whose stored indent skips a level (an\n * orphan, e.g. a first item the user tabbed in) is clamped to one deeper than\n * the previous item's effective level. This keeps every marker at a content\n * column an actual parent established, so the emitted pad never lands at four or\n * more columns — which the parser would read as indented code, merging the item\n * into its predecessor or dropping its marker (grammar disagreement). The stored\n * indent is preserved in the model; only its Markdown rendering normalizes.\n */\nfunction serializeListGroup(items: readonly BlockNode[], ctx: SerContext): string {\n\tconst lines: string[] = [];\n\tconst counters: number[] = [];\n\tconst contentColumns: number[] = [];\n\tlet previousIndent = -1;\n\n\tfor (const item of items) {\n\t\tconst listType: string = String(item.attrs?.listType ?? 'bullet');\n\t\tconst storedIndent: number = Math.max(0, (item.attrs?.indent as number | undefined) ?? 0);\n\t\t// Clamp to at most one level deeper than the previous item so a parent\n\t\t// content column always exists (no orphan levels, no >=4-column pad).\n\t\tconst indent: number = Math.min(storedIndent, previousIndent + 1);\n\t\tpreviousIndent = indent;\n\t\tconst padWidth: number = indent === 0 ? 0 : (contentColumns[indent - 1] ?? 0);\n\t\tconst pad: string = ' '.repeat(padWidth);\n\n\t\t// Reset deeper counters/columns when we step back out.\n\t\tcounters.length = indent + 1;\n\t\tcontentColumns.length = indent + 1;\n\n\t\tlet marker: string;\n\t\tif (listType === 'ordered') {\n\t\t\tcounters[indent] = (counters[indent] ?? 0) + 1;\n\t\t\tmarker = `${counters[indent]}.`;\n\t\t} else if (listType === 'checklist') {\n\t\t\tconst checked: boolean = item.attrs?.checked === true;\n\t\t\tmarker = `${ctx.opts.bullet} [${checked ? 'x' : ' '}]`;\n\t\t} else {\n\t\t\tmarker = ctx.opts.bullet;\n\t\t}\n\n\t\t// The task marker belongs to the first content line, not the geometry:\n\t\t// continuation lines of `- [x] foo` align to the bullet's content column.\n\t\tconst markerWidth: number =\n\t\t\tlistType === 'checklist' ? ctx.opts.bullet.length + 1 : marker.length + 1;\n\t\tcontentColumns[indent] = padWidth + markerWidth;\n\n\t\tif (isLeafBlock(item)) {\n\t\t\t// The item content is now block-tokenized on re-import, so a leaf whose\n\t\t\t// text begins with a block marker (`# `, `- `, `> `, `1. `) must be\n\t\t\t// line-start escaped or it reimports as a heading/nested-item child.\n\t\t\tconst content: string = escapeLineStart(\n\t\t\t\tserializeInlineContent(getInlineChildren(item), ctx).replace(/\\n/g, ' '),\n\t\t\t);\n\t\t\tlines.push(content ? `${pad}${marker} ${content}` : `${pad}${marker}`);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Container item (#194): serialize the block children, put the first line\n\t\t// on the marker line, and indent the rest to the item's content column.\n\t\tconst inner: string = serializeBlocks(getBlockChildren(item), { ...ctx, inListItem: true });\n\t\tif (inner === '') {\n\t\t\tlines.push(`${pad}${marker}`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst contentPad: string = ' '.repeat(contentColumns[indent] ?? padWidth + markerWidth);\n\t\tconst innerLines: string[] = inner.split('\\n');\n\t\tlines.push(`${pad}${marker} ${innerLines[0] ?? ''}`);\n\t\tfor (let li = 1; li < innerLines.length; li++) {\n\t\t\tconst innerLine: string = innerLines[li] ?? '';\n\t\t\tlines.push(innerLine === '' ? '' : `${contentPad}${innerLine}`);\n\t\t}\n\t}\n\n\treturn lines.join('\\n');\n}\n\n/** GFM table; tables with colspan/rowspan fall back to raw HTML (D3, no GFM equivalent). */\nfunction serializeTable(block: BlockNode, ctx: SerContext): string {\n\tconst rows: readonly BlockNode[] = getBlockChildren(block);\n\tif (rows.length === 0) return '';\n\n\t// CommonMark has no table syntax. Keep the semantic hierarchy through the\n\t// same raw-HTML seam used for spans and HTML IDs.\n\tif (!ctx.opts.gfm && ctx.opts.htmlFallback) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\n\t// GFM has no syntax for either logical column widths or row minimum\n\t// heights. Preserve them through the existing semantic HTML seam when it\n\t// is available. With `htmlFallback: false`, the documented behavior is a\n\t// plain pipe table whose dimensions reset to automatic on re-import.\n\tif (ctx.opts.htmlFallback && (hasSpannedCells(rows) || hasExplicitTableDimensions(block, rows))) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\n\tconst matrix: string[][] = rows.map((row) =>\n\t\tgetBlockChildren(row).map((cell) => serializeCell(cell, ctx)),\n\t);\n\tconst columns: number = matrix.reduce((max, row) => Math.max(max, row.length), 0);\n\tif (columns === 0) return '';\n\n\tconst renderRow = (cells: string[]): string => {\n\t\tconst padded: string[] = [...cells];\n\t\twhile (padded.length < columns) padded.push('');\n\t\treturn `| ${padded.join(' | ')} |`;\n\t};\n\n\tconst headerRow: BlockNode | undefined = rows[0];\n\tconst delimiters: string[] = Array.from({ length: columns }, (_v, col) =>\n\t\talignMarker(columnAlign(headerRow, col)),\n\t);\n\n\tconst out: string[] = [];\n\tout.push(renderRow(matrix[0] ?? []));\n\tout.push(`| ${delimiters.join(' | ')} |`);\n\tfor (let i = 1; i < matrix.length; i++) {\n\t\tout.push(renderRow(matrix[i] ?? []));\n\t}\n\treturn out.join('\\n');\n}\n\n/** Reads the column alignment from a header cell's paragraph `align` attribute. */\nfunction columnAlign(headerRow: BlockNode | undefined, col: number): string | undefined {\n\tif (!headerRow) return undefined;\n\tconst cell: BlockNode | undefined = getBlockChildren(headerRow)[col];\n\tif (!cell) return undefined;\n\tconst paragraph: BlockNode | undefined = getBlockChildren(cell)[0];\n\treturn paragraph?.attrs?.align as string | undefined;\n}\n\n/** Maps a logical alignment to its GFM delimiter marker. */\nfunction alignMarker(align: string | undefined): string {\n\tif (align === 'start') return ':---';\n\tif (align === 'center') return ':---:';\n\tif (align === 'end') return '---:';\n\treturn '---';\n}\n\n/** Whether any cell in the rows carries a colspan/rowspan > 1. */\nfunction hasSpannedCells(rows: readonly BlockNode[]): boolean {\n\tfor (const row of rows) {\n\t\tfor (const cell of getBlockChildren(row)) {\n\t\t\tconst colspan = cell.attrs?.colspan as number | undefined;\n\t\t\tconst rowspan = cell.attrs?.rowspan as number | undefined;\n\t\t\tif ((colspan ?? 1) > 1 || (rowspan ?? 1) > 1) return true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/** Whether the table carries any safe dimension that GFM cannot represent. */\nfunction hasExplicitTableDimensions(table: BlockNode, rows: readonly BlockNode[]): boolean {\n\tif (hasExplicitTableColumnWidth(table.attrs?.columnWidthsPx)) return true;\n\treturn rows.some(\n\t\t(row: BlockNode): boolean =>\n\t\t\tnormalizeSerializedTableDimensionPx(row.attrs?.minHeightPx) !== undefined,\n\t);\n}\n\n/** Serializes a table cell to single-line inline Markdown, escaping pipes. */\nfunction serializeCell(cell: BlockNode, ctx: SerContext): string {\n\tconst blocks: readonly BlockNode[] = getBlockChildren(cell);\n\tconst inline: string = blocks\n\t\t.map((b) => serializeInlineContent(getInlineChildren(b), ctx))\n\t\t.join(' ')\n\t\t.replace(/\\n/g, ' ');\n\treturn inline.replace(/\\|/g, '\\\\|').trim();\n}\n","/**\n * MarkdownSerializer: converts an immutable Document into a Markdown string.\n *\n * Mirrors `DocumentSerializer.ts` (HTML) but is reached **only** via dynamic\n * `import()` from the async web-component method and the paste branch, so the\n * bundler genuinely code-splits the engine out of the core chunk (D13). Pure\n * functions — operate on Document/SchemaRegistry, no class state.\n */\n\nimport type { Document } from '../model/Document.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { buildMarkOrder } from './MarkSerializer.js';\nimport type { MarkdownSerializeOptions } from './MarkdownTypes.js';\nimport { serializeBlocks } from './markdown/BlockSerializers.js';\nimport { type SerContext, resolveSerializeOptions } from './markdown/MarkdownContext.js';\n\n/**\n * Serializes a document to a Markdown string.\n *\n * Standard CommonMark/GFM constructs are emitted by the engine's built-in\n * by-type mappings; unrepresentable nodes/marks emit raw HTML (valid Markdown)\n * when `htmlFallback` is on (default), or degrade gracefully when off (D3).\n */\nexport function serializeDocumentToMarkdown(\n\tdoc: Document,\n\tregistry?: SchemaRegistry,\n\toptions?: MarkdownSerializeOptions,\n): string {\n\tconst ctx: SerContext = {\n\t\tregistry,\n\t\topts: resolveSerializeOptions(options),\n\t\tmarkOrder: registry ? buildMarkOrder(registry) : undefined,\n\t};\n\tconst body: string = serializeBlocks(doc.children, ctx);\n\treturn finalizeDocument(body);\n}\n\n/**\n * Closes the assembled document with a single trailing newline, dropping any\n * leading/trailing blank lines. It intentionally does NOT touch the interior:\n * each block serializer is responsible for emitting clean lines, and\n * `serializeBlocks` already joins blocks with exactly one blank line. Trimming\n * only the document boundaries is provably code-safe, since a document never\n * begins or ends inside a code body (blocks open and close on their own\n * delimiters), so significant blank lines and trailing spaces inside a\n * `code_block` survive verbatim at any nesting depth.\n */\nfunction finalizeDocument(markdown: string): string {\n\tconst trimmed: string = markdown.trim();\n\treturn trimmed.length > 0 ? `${trimmed}\\n` : '';\n}\n"],"mappings":"qYAqCA,SAAgB,EACf,GAEA,MAAM,EAA+B,GAAS,QAAU,MACxD,MAAO,CACN,SACA,IAAgB,QAAX,EACL,cAAwC,IAA1B,GAAS,aACvB,aAAc,GAAS,cAAgB,MACvC,OAAQ,GAAS,QAAU,IAC3B,SAAU,GAAS,UAAY,IAC/B,UAAW,GAAS,WAAa,MACjC,WAAY,GAAS,YAAc,EAErC,CAGA,SAAgB,EAAc,GAC7B,MAAO,CAAE,OAAQ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,EAAgB,EAAgB,EAAiB,GAAO,IAAK,EAAK,YAAY,IACpF,GAAc,KAAV,EAAc,CACjB,EAAM,KAAK,GAAG,IAAM,KACpB,QACD,CACA,MAAM,EAAqB,IAAI,OAAO,EAAe,IAAW,EAAW,GACrE,EAAuB,EAAM,MAAM,MACzC,EAAM,KAAK,GAAG,IAAM,KAAU,EAAW,IAAM,MAC/C,IAAK,IAAI,EAAK,EAAG,EAAK,EAAW,OAAQ,IAAM,CAC9C,MAAM,EAAoB,EAAW,IAAO,GAC5C,EAAM,KAAmB,KAAd,EAAmB,GAAK,GAAG,IAAa,IACpD,CACD,CAEA,OAAO,EAAM,KAAK,KACnB,6DC/QA,SAAgB,EACf,EACA,EACA,GAEA,MAAM,EAAkB,CACvB,WACA,KAAM,EAAwB,GAC9B,UAAW,EAAW,EAAe,QAAY,GAGlD,OAaD,SAA0B,GACzB,MAAM,EAAkB,EAAS,OACjC,OAAO,EAAQ,OAAS,EAAI,GAAG,MAAc,EAC9C,CAhBQ,CADc,EAAgB,EAAI,SAAU,GAEpD"}
@@ -1,2 +0,0 @@
1
- function t(t,n){const e=t.getBlock(n);if(!e)return!1;const r=t.schema.getNodeSpec;return!!r&&!0===r(e.type)?.isVoid}function n(t,n,e){const r=t.getNodePath(n),o=t.getNodePath(e);if(!r||!o)return!1;if(r.length!==o.length)return!1;for(let c=0;c<r.length-1;c++)if(r[c]!==o[c])return!1;return!0}function e(t,n){const e=t.schema.getNodeSpec;if(!e)return!1;const r=t.getNodePath(n);if(!r||r.length<=1)return!1;for(let o=0;o<r.length-1;o++){const n=r[o];if(!n)continue;const c=t.getBlock(n);if(c&&e(c.type)?.isolating)return!0}return!1}function r(t,n){const e=t.schema.getNodeSpec;if(!e)return!1;const r=t.getBlock(n);return!!r&&!0===e(r.type)?.isolating}function o(n,e,r){const o=n.getBlockOrder(),i=o.indexOf(e);if(i<0)return null;const u=r?i+1:i-1;if(u<0||u>=o.length)return null;const s=o[u];return s&&c(n,e,s)?{targetId:s,isVoid:t(n,s)}:null}function c(t,o,c){if(r(t,o)||r(t,c))return!1;const i=e(t,o),u=e(t,c);return i===u&&(!i||!u||n(t,o,c))}export{o as a,t as i,e as n,n as o,r,c as t};
2
- //# sourceMappingURL=NavigationQueries-Bt4zZ17v.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NavigationQueries-Bt4zZ17v.mjs","names":[],"sources":["../../src/state/NavigationQueries.ts"],"sourcesContent":["/**\n * Pure navigation query functions for block boundary and isolating checks.\n *\n * These utilities inspect the document structure and schema to answer\n * questions about block traversal — whether a block is void, isolating,\n * or whether navigation between two blocks is allowed.\n */\n\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from './EditorState.js';\n\n/** Returns true if the block with the given ID is a void block (e.g. image, HR). */\nexport function isVoidBlock(state: EditorState, bid: BlockId): boolean {\n\tconst block = state.getBlock(bid);\n\tif (!block) return false;\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\treturn getNodeSpec(block.type)?.isVoid === true;\n}\n\n/** Checks whether two blocks share the same parent in the document tree. */\nexport function sharesParent(state: EditorState, blockIdA: BlockId, blockIdB: BlockId): boolean {\n\tconst pathA = state.getNodePath(blockIdA);\n\tconst pathB = state.getNodePath(blockIdB);\n\tif (!pathA || !pathB) return false;\n\tif (pathA.length !== pathB.length) return false;\n\t// Compare parent paths (all but last element)\n\tfor (let i = 0; i < pathA.length - 1; i++) {\n\t\tif (pathA[i] !== pathB[i]) return false;\n\t}\n\treturn true;\n}\n\n/** Checks whether a block is inside an isolating node (e.g. table_cell). */\nexport function isInsideIsolating(state: EditorState, blockId: BlockId): boolean {\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\tconst path = state.getNodePath(blockId);\n\tif (!path || path.length <= 1) return false;\n\n\t// Check ancestors (not the block itself)\n\tfor (let i = 0; i < path.length - 1; i++) {\n\t\tconst ancestorId = path[i];\n\t\tif (!ancestorId) continue;\n\t\tconst ancestor = state.getBlock(ancestorId);\n\t\tif (!ancestor) continue;\n\t\tconst spec = getNodeSpec(ancestor.type);\n\t\tif (spec?.isolating) return true;\n\t}\n\treturn false;\n}\n\n/** Returns true if the block itself has the isolating property. */\nexport function isIsolatingBlock(state: EditorState, blockId: BlockId): boolean {\n\tconst getNodeSpec = state.schema.getNodeSpec;\n\tif (!getNodeSpec) return false;\n\tconst block = state.getBlock(blockId);\n\tif (!block) return false;\n\treturn getNodeSpec(block.type)?.isolating === true;\n}\n\n/** The block reached by crossing one block boundary, plus whether it is void. */\nexport interface AdjacentBlock {\n\treadonly targetId: BlockId;\n\treadonly isVoid: boolean;\n}\n\n/**\n * Resolves the block immediately before/after `fromBlockId` in document order\n * when the boundary may be crossed. Returns `null` at a document boundary or\n * when an isolating boundary blocks the crossing.\n */\nexport function resolveAdjacentBlock(\n\tstate: EditorState,\n\tfromBlockId: BlockId,\n\tforward: boolean,\n): AdjacentBlock | null {\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst idx: number = blockOrder.indexOf(fromBlockId);\n\tif (idx < 0) return null;\n\n\tconst targetIdx: number = forward ? idx + 1 : idx - 1;\n\tif (targetIdx < 0 || targetIdx >= blockOrder.length) return null;\n\n\tconst targetId: BlockId | undefined = blockOrder[targetIdx];\n\tif (!targetId) return null;\n\tif (!canCrossBlockBoundary(state, fromBlockId, targetId)) return null;\n\n\treturn { targetId, isVoid: isVoidBlock(state, targetId) };\n}\n\n/**\n * Checks whether navigation between two blocks is allowed.\n * Prevents crossing isolating boundaries (e.g. table cells).\n */\nexport function canCrossBlockBoundary(state: EditorState, fromId: BlockId, toId: BlockId): boolean {\n\t// A block that is itself isolating cannot be crossed into via arrow keys\n\tif (isIsolatingBlock(state, fromId) || isIsolatingBlock(state, toId)) return false;\n\n\tconst fromInside: boolean = isInsideIsolating(state, fromId);\n\tconst toInside: boolean = isInsideIsolating(state, toId);\n\n\t// One inside isolating, the other not → disallow\n\tif (fromInside !== toInside) return false;\n\n\t// Both inside isolating → must share the same parent\n\tif (fromInside && toInside) return sharesParent(state, fromId, toId);\n\n\treturn true;\n}\n"],"mappings":"AAYA,SAAgB,EAAY,EAAoB,GAC/C,MAAM,EAAQ,EAAM,SAAS,GAC7B,IAAK,EAAO,OAAO,EACnB,MAAM,EAAc,EAAM,OAAO,YACjC,QAAK,IACsC,IAApC,EAAY,EAAM,OAAO,MACjC,CAGA,SAAgB,EAAa,EAAoB,EAAmB,GACnE,MAAM,EAAQ,EAAM,YAAY,GAC1B,EAAQ,EAAM,YAAY,GAChC,IAAK,IAAU,EAAO,OAAO,EAC7B,GAAI,EAAM,SAAW,EAAM,OAAQ,OAAO,EAE1C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAS,EAAG,IACrC,GAAI,EAAM,KAAO,EAAM,GAAI,OAAO,EAEnC,OAAO,CACR,CAGA,SAAgB,EAAkB,EAAoB,GACrD,MAAM,EAAc,EAAM,OAAO,YACjC,IAAK,EAAa,OAAO,EACzB,MAAM,EAAO,EAAM,YAAY,GAC/B,IAAK,GAAQ,EAAK,QAAU,EAAG,OAAO,EAGtC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAS,EAAG,IAAK,CACzC,MAAM,EAAa,EAAK,GACxB,IAAK,EAAY,SACjB,MAAM,EAAW,EAAM,SAAS,GAChC,GAAK,GACQ,EAAY,EAAS,OACxB,UAAW,OAAO,CAC7B,CACA,OAAO,CACR,CAGA,SAAgB,EAAiB,EAAoB,GACpD,MAAM,EAAc,EAAM,OAAO,YACjC,IAAK,EAAa,OAAO,EACzB,MAAM,EAAQ,EAAM,SAAS,GAC7B,QAAK,IACyC,IAAvC,EAAY,EAAM,OAAO,SACjC,CAaA,SAAgB,EACf,EACA,EACA,GAEA,MAAM,EAAiC,EAAM,gBACvC,EAAc,EAAW,QAAQ,GACvC,GAAI,EAAM,EAAG,OAAO,KAEpB,MAAM,EAAoB,EAAU,EAAM,EAAI,EAAM,EACpD,GAAI,EAAY,GAAK,GAAa,EAAW,OAAQ,OAAO,KAE5D,MAAM,EAAgC,EAAW,GACjD,OAAK,GACA,EAAsB,EAAO,EAAa,GAExC,CAAE,WAAU,OAAQ,EAAY,EAAO,IAHxB,IAIvB,CAMA,SAAgB,EAAsB,EAAoB,EAAiB,GAE1E,GAAI,EAAiB,EAAO,IAAW,EAAiB,EAAO,GAAO,OAAO,EAE7E,MAAM,EAAsB,EAAkB,EAAO,GAC/C,EAAoB,EAAkB,EAAO,GAGnD,OAAI,IAAe,KAGf,IAAc,GAAiB,EAAa,EAAO,EAAQ,GAGhE"}
@@ -1,2 +0,0 @@
1
- import{R as n}from"./Document-D_2cIBJG.mjs";function t(t,i){if(0===i.length)return;let r=t.children.find(n=>n.id===i[0]);if(r){for(let t=1;t<i.length;t++){const e=i[t];if(!e)return;const o=r?.children.find(t=>n(t)&&t.id===e);if(!o)return;r=o}return r}}function i(i,r,e){if(0===r.length){const t=i.children[e];return t&&n(t)?t:void 0}const o=t(i,r);if(!o)return;const f=o.children[e];return f&&n(f)?f:void 0}function r(i,r){if(0===r.length)return;if(1===r.length){const n=i.children.findIndex(n=>n.id===r[0]);if(-1===n)return;return{parent:i,index:n}}const e=t(i,r.slice(0,-1));if(!e)return;const o=r[r.length-1];if(!o)return;const f=e.children.findIndex(t=>n(t)&&t.id===o);return-1!==f?{parent:e,index:f}:void 0}function e(n,t){for(const i of n.children){if(i.id===t)return[t];const n=o(i,t);if(n)return[i.id,...n]}}function o(t,i){for(const r of t.children){if(!n(r))continue;if(r.id===i)return[i];const t=o(r,i);if(t)return[r.id,...t]}}function f(n,t){for(const i of n.children)c(i,[i.id],t)}function c(t,i,r){r(t,i);for(const e of t.children)n(e)&&c(e,[...i,e.id],r)}function u(n,t){for(const i of n.children){if(i.id===t)return i;const n=d(i,t);if(n)return n}}function d(t,i){for(const r of t.children){if(!n(r))continue;if(r.id===i)return r;const t=d(r,i);if(t)return t}}function s(n,i){const r=e(n,i);if(!r)return;const o=t(n,r);return o?{node:o,path:r}:void 0}function l(n,i,r){const o=e(n,i);if(o&&!(o.length<2))for(let e=o.length-2;e>=0;e--){const i=o.slice(0,e+1),f=t(n,i);if(f?.type===r)return{node:f,path:i}}}function h(n,t,i){return void 0!==l(n,t,i)}export{h as a,r as c,s as i,f as l,u as n,i as o,e as r,t as s,l as t};
2
- //# sourceMappingURL=NodeResolver-BtIknXqD.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NodeResolver-BtIknXqD.mjs","names":[],"sources":["../../src/model/NodeResolver.ts"],"sourcesContent":["/**\n * Utilities for resolving nodes by path within the document tree.\n * Supports both flat and recursive (nested) document structures.\n */\n\nimport type { BlockNode, Document } from './Document.js';\nimport { isBlockNode } from './Document.js';\n\n/**\n * Resolves a node in the document tree by its path (array of block IDs).\n * The path traces the lineage from the root block down to the target.\n */\nexport function resolveNodeByPath(doc: Document, path: readonly string[]): BlockNode | undefined {\n\tif (path.length === 0) return undefined;\n\n\tlet current: BlockNode | undefined = doc.children.find((b) => b.id === path[0]);\n\tif (!current) return undefined;\n\n\tfor (let i = 1; i < path.length; i++) {\n\t\tconst childId = path[i];\n\t\tif (!childId) return undefined;\n\t\tconst next: BlockNode | undefined = current?.children.find(\n\t\t\t(c): c is BlockNode => isBlockNode(c) && c.id === childId,\n\t\t);\n\t\tif (!next) return undefined;\n\t\tcurrent = next;\n\t}\n\n\treturn current;\n}\n\n/**\n * Resolves the block child at `(parentPath, index)`. `parentPath = []` addresses\n * the document root; otherwise the path traces from the document root to the\n * containing block. Returns `undefined` when the parent does not exist or the\n * indexed slot is missing / occupied by a non-block child.\n */\nexport function resolveChildAt(\n\tdoc: Document,\n\tparentPath: readonly string[],\n\tindex: number,\n): BlockNode | undefined {\n\tif (parentPath.length === 0) {\n\t\tconst child = doc.children[index];\n\t\treturn child && isBlockNode(child) ? child : undefined;\n\t}\n\tconst parent = resolveNodeByPath(doc, parentPath);\n\tif (!parent) return undefined;\n\tconst child = parent.children[index];\n\treturn child && isBlockNode(child) ? child : undefined;\n}\n\n/**\n * Resolves the parent of a node at the given path.\n * Returns the parent container (Document or BlockNode) and the child's index within it.\n */\nexport function resolveParentByPath(\n\tdoc: Document,\n\tpath: readonly string[],\n): { parent: Document | BlockNode; index: number } | undefined {\n\tif (path.length === 0) return undefined;\n\n\tif (path.length === 1) {\n\t\tconst index = doc.children.findIndex((b) => b.id === path[0]);\n\t\tif (index === -1) return undefined;\n\t\treturn { parent: doc, index };\n\t}\n\n\tconst parentPath = path.slice(0, -1);\n\tconst parent = resolveNodeByPath(doc, parentPath);\n\tif (!parent) return undefined;\n\n\tconst childId = path[path.length - 1];\n\tif (!childId) return undefined;\n\tconst index = parent.children.findIndex(\n\t\t(c): c is BlockNode => isBlockNode(c) && c.id === childId,\n\t);\n\tif (index === -1) return undefined;\n\n\treturn { parent, index };\n}\n\n/**\n * Finds the path (array of block IDs) to a node by its ID.\n * Performs recursive DFS through the document tree.\n */\nexport function findNodePath(doc: Document, nodeId: string): string[] | undefined {\n\tfor (const block of doc.children) {\n\t\tif (block.id === nodeId) return [nodeId];\n\n\t\tconst subPath = findNodePathInBlock(block, nodeId);\n\t\tif (subPath) return [block.id, ...subPath];\n\t}\n\treturn undefined;\n}\n\nfunction findNodePathInBlock(block: BlockNode, nodeId: string): string[] | undefined {\n\tfor (const child of block.children) {\n\t\tif (!isBlockNode(child)) continue;\n\t\tif (child.id === nodeId) return [nodeId];\n\n\t\tconst subPath = findNodePathInBlock(child, nodeId);\n\t\tif (subPath) return [child.id, ...subPath];\n\t}\n\treturn undefined;\n}\n\n/**\n * Walks all block nodes in the document tree in depth-first order.\n * Visits every BlockNode, including nested ones, with their full path.\n */\nexport function walkNodes(\n\tdoc: Document,\n\tcallback: (node: BlockNode, path: string[]) => void,\n): void {\n\tfor (const block of doc.children) {\n\t\twalkNodeRecursive(block, [block.id], callback);\n\t}\n}\n\nfunction walkNodeRecursive(\n\tnode: BlockNode,\n\tpath: string[],\n\tcallback: (node: BlockNode, path: string[]) => void,\n): void {\n\tcallback(node, path);\n\tfor (const child of node.children) {\n\t\tif (isBlockNode(child)) {\n\t\t\twalkNodeRecursive(child, [...path, child.id], callback);\n\t\t}\n\t}\n}\n\n/**\n * Finds a block node by ID anywhere in the document tree (recursive DFS).\n */\nexport function findNode(doc: Document, nodeId: string): BlockNode | undefined {\n\tfor (const block of doc.children) {\n\t\tif (block.id === nodeId) return block;\n\t\tconst found = findNodeInBlock(block, nodeId);\n\t\tif (found) return found;\n\t}\n\treturn undefined;\n}\n\nfunction findNodeInBlock(block: BlockNode, nodeId: string): BlockNode | undefined {\n\tfor (const child of block.children) {\n\t\tif (!isBlockNode(child)) continue;\n\t\tif (child.id === nodeId) return child;\n\t\tconst found = findNodeInBlock(child, nodeId);\n\t\tif (found) return found;\n\t}\n\treturn undefined;\n}\n\n/**\n * Finds a block node and returns it together with its path.\n */\nexport function findNodeWithPath(\n\tdoc: Document,\n\tnodeId: string,\n): { node: BlockNode; path: string[] } | undefined {\n\tconst path = findNodePath(doc, nodeId);\n\tif (!path) return undefined;\n\tconst node = resolveNodeByPath(doc, path);\n\tif (!node) return undefined;\n\treturn { node, path };\n}\n\n/**\n * Returns the nearest ancestor of the given node whose type matches `type`,\n * together with its path. Excludes the node itself. Returns undefined when no\n * matching ancestor exists.\n */\nexport function findAncestorOfType(\n\tdoc: Document,\n\tnodeId: string,\n\ttype: string,\n): { node: BlockNode; path: string[] } | undefined {\n\tconst path = findNodePath(doc, nodeId);\n\tif (!path || path.length < 2) return undefined;\n\t// Walk ancestors from nearest to root, skipping the node itself (last entry).\n\tfor (let i = path.length - 2; i >= 0; i--) {\n\t\tconst ancestorPath = path.slice(0, i + 1);\n\t\tconst ancestor = resolveNodeByPath(doc, ancestorPath);\n\t\tif (ancestor?.type === type) return { node: ancestor, path: ancestorPath };\n\t}\n\treturn undefined;\n}\n\n/** Returns true if the node has an ancestor (excluding itself) of the given type. */\nexport function hasAncestorOfType(doc: Document, nodeId: string, type: string): boolean {\n\treturn findAncest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,GACjC,EAAW,EAAkB,EAAK,GACxC,GAAI,GAAU,OAAS,EAAM,MAAO,CAAE,KAAM,EAAU,KAAM,EAC7D,CAED,CAGA,SAAgB,EAAkB,EAAe,EAAgB,GAChE,YAAiD,IAA1C,EAAmB,EAAK,EAAQ,EACxC"}
@@ -1,2 +0,0 @@
1
- import{d as e,f as n}from"./Selection-DC6AOGgF.mjs";import{n as t}from"./TypedKeys-CA4bfw9O.mjs";var o=class{resolvedLocale;constructor(e){this.resolvedLocale="browser"===e?"undefined"!=typeof navigator?navigator.language.split("-")[0]??"en":"en":e}getLocale(){return this.resolvedLocale}},r=new t("locale");async function c(e,n,t){if("en"===n)return t;const o=e[`./locales/${n}.ts`];if(!o)return t;try{return(await o()).default}catch{return t}}function s(e,n){return!!n&&(e.dispatch(n),!0)}function a(e){return e.charAt(0).toUpperCase()+e.slice(1)}function i(e){return`toggle${a(e)}`}async function l(e,n,t,o){if(n)return n;const c=e.getService(r)?.getLocale()??"en";return"en"===c?t:o(c)}function u(t){const o=t.selection;return e(o)?t.getBlock(o.nodeId):n(o)?t.getBlock(o.anchor.blockId):void 0}function d(t){const o=t.selection;return e(o)?o.nodeId:n(o)?o.anchor.blockId:void 0}function f(t){const o=t.selection;if(e(o))return[o.nodeId];if(!n(o))return[];const r=o.anchor.blockId,c=o.head.blockId;if(r===c)return[r];const s=t.getBlockOrder(),a=s.indexOf(r),i=s.indexOf(c);if(-1===a||-1===i)return[];const l=Math.min(a,i),u=Math.max(a,i);return s.slice(l,u+1)}export{f as a,c,d as i,o as l,s as n,l as o,u as r,i as s,a as t,r as u};
2
- //# sourceMappingURL=PluginHelpers-WG1Lzzh3.mjs.map
@@ -1,2 +0,0 @@
1
- var e=class{_nodeSpecs=/* @__PURE__ */new Map;_nodeSpecExtensions=/* @__PURE__ */new Map;_finalizedNodeSpecs=null;_markSpecs=/* @__PURE__ */new Map;_inlineNodeSpecs=/* @__PURE__ */new Map;registerNodeSpec(e){if(this._nodeSpecs.has(e.type))throw new Error(`NodeSpec for type "${e.type}" is already registered.`);this._nodeSpecs.set(e.type,e),this.invalidateFinalizedNodeSpecs()}getNodeSpec(e){return this.getFinalizedNodeSpecs().get(e)}removeNodeSpec(e){this._nodeSpecs.delete(e)&&this.invalidateFinalizedNodeSpecs()}getNodeTypes(){return[...this._nodeSpecs.keys()]}registerNodeSpecExtension(e,t){const s=this._nodeSpecExtensions.get(e)??[];s.push(t),this._nodeSpecExtensions.set(e,s),this.invalidateFinalizedNodeSpecs()}removeNodeSpecExtension(e,t){const s=this._nodeSpecExtensions.get(e);if(!s)return;const i=s.indexOf(t);-1!==i&&(s.splice(i,1),0===s.length&&this._nodeSpecExtensions.delete(e),this.invalidateFinalizedNodeSpecs())}finalize(){const e=/* @__PURE__ */new Map;for(const[t,s]of this._nodeSpecs){let i=s;for(const e of this._nodeSpecExtensions.get(t)??[])if(i=e(i),i.type!==t)throw new Error(`NodeSpec extension for "${t}" must preserve node type; received "${i.type}".`);e.set(t,i)}this._finalizedNodeSpecs=e}registerMarkSpec(e){if(this._markSpecs.has(e.type))throw new Error(`MarkSpec for type "${e.type}" is already registered.`);this._markSpecs.set(e.type,e)}getMarkSpec(e){return this._markSpecs.get(e)}removeMarkSpec(e){this._markSpecs.delete(e)}getMarkTypes(){return[...this._markSpecs.keys()]}registerInlineNodeSpec(e){if(this._inlineNodeSpecs.has(e.type))throw new Error(`InlineNodeSpec for type "${e.type}" is already registered.`);this._inlineNodeSpecs.set(e.type,e)}getInlineNodeSpec(e){return this._inlineNodeSpecs.get(e)}removeInlineNodeSpec(e){this._inlineNodeSpecs.delete(e)}getInlineNodeTypes(){return[...this._inlineNodeSpecs.keys()]}getBlockParseRules(){return this.collectParseRules(this.getFinalizedNodeSpecs())}getInlineParseRules(){return this.collectParseRules(this._inlineNodeSpecs)}getMarkParseRules(){return this.collectParseRules(this._markSpecs)}getAllowedTags(){return[...this.collectSanitizeValues(/* @__PURE__ */new Set(["p","br","div","span"]),e=>e.sanitize?.tags)]}getAllowedAttrs(){return[...this.collectSanitizeValues(/* @__PURE__ */new Set(["style","dir","id"]),e=>e.sanitize?.attrs)]}getElementSanitizeValidators(){const e=/* @__PURE__ */new Map;for(const t of this.getAllFinalizedSpecMaps())for(const s of t.values())for(const[t,i]of Object.entries(s.sanitize?.elementValidators??{})){const s=t.toLowerCase(),n=e.get(s)??[];n.push(i),e.set(s,n)}return e}collectParseRules(e){const t=[];for(const[s,i]of e)if(i.parseHTML)for(const e of i.parseHTML)t.push({rule:e,type:s});return t.sort((e,t)=>(t.rule.priority??50)-(e.rule.priority??50))}collectSanitizeValues(e,t){const s=this.getAllFinalizedSpecMaps();for(const i of s)for(const s of i.values()){const i=t(s);if(i)for(const t of i)e.add(t)}return e}getFinalizedNodeSpecs(){return this._finalizedNodeSpecs||this.finalize(),this._finalizedNodeSpecs??/* @__PURE__ */new Map}getAllFinalizedSpecMaps(){return[this.getFinalizedNodeSpecs(),this._inlineNodeSpecs,this._markSpecs]}invalidateFinalizedNodeSpecs(){this._finalizedNodeSpecs=null}clear(){this._nodeSpecs.clear(),this._nodeSpecExtensions.clear(),this._finalizedNodeSpecs=null,this._markSpecs.clear(),this._inlineNodeSpecs.clear()}};export{e as t};
2
- //# sourceMappingURL=SchemaRegistry-acc6q_5x.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaRegistry-acc6q_5x.mjs","names":[],"sources":["../../src/model/SchemaRegistry.ts"],"sourcesContent":["/**\n * SchemaRegistry: central registry for node specs, mark specs,\n * and inline node specs registered by plugins.\n *\n * Model-only — no imports from input/, plugins/, or view/ layers.\n */\n\nimport type { InlineNodeSpec } from './InlineNodeSpec.js';\nimport type { MarkSpec } from './MarkSpec.js';\nimport type { NodeSpec } from './NodeSpec.js';\nimport type { ParseRule } from './ParseRule.js';\nimport type { ElementSanitizeValidator } from './SanitizeConfig.js';\n\n/** Priority assigned to parse rules that do not declare an explicit `priority`. */\nconst DEFAULT_PARSE_PRIORITY = 50;\n\n/** Declarative transformation applied after a target NodeSpec is registered. */\nexport type NodeSpecExtension = (spec: NodeSpec) => NodeSpec;\n\nexport class SchemaRegistry {\n\tprivate readonly _nodeSpecs = new Map<string, NodeSpec>();\n\tprivate readonly _nodeSpecExtensions = new Map<string, NodeSpecExtension[]>();\n\tprivate _finalizedNodeSpecs: Map<string, NodeSpec> | null = null;\n\tprivate readonly _markSpecs = new Map<string, MarkSpec>();\n\tprivate readonly _inlineNodeSpecs = new Map<string, InlineNodeSpec>();\n\n\t// --- NodeSpec ---\n\n\tregisterNodeSpec<T extends string>(spec: NodeSpec<T>): void {\n\t\tif (this._nodeSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`NodeSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._nodeSpecs.set(spec.type, spec);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\tgetNodeSpec(type: string): NodeSpec | undefined {\n\t\treturn this.getFinalizedNodeSpecs().get(type);\n\t}\n\n\tremoveNodeSpec(type: string): void {\n\t\tif (this._nodeSpecs.delete(type)) this.invalidateFinalizedNodeSpecs();\n\t}\n\n\tgetNodeTypes(): string[] {\n\t\treturn [...this._nodeSpecs.keys()];\n\t}\n\n\t/**\n\t * Registers a composable NodeSpec extension independently of target order.\n\t * Extensions may be declared before their target plugin and are materialized\n\t * together by {@link finalize}. The function identity is also the cleanup key.\n\t */\n\tregisterNodeSpecExtension(type: string, extension: NodeSpecExtension): void {\n\t\tconst extensions = this._nodeSpecExtensions.get(type) ?? [];\n\t\textensions.push(extension);\n\t\tthis._nodeSpecExtensions.set(type, extensions);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\t/** Removes one previously registered NodeSpec extension by identity. */\n\tremoveNodeSpecExtension(type: string, extension: NodeSpecExtension): void {\n\t\tconst extensions = this._nodeSpecExtensions.get(type);\n\t\tif (!extensions) return;\n\t\tconst index = extensions.indexOf(extension);\n\t\tif (index === -1) return;\n\t\textensions.splice(index, 1);\n\t\tif (extensions.length === 0) this._nodeSpecExtensions.delete(type);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\t/**\n\t * Materializes the complete schema after all plugins have declared their base\n\t * specs and extensions. Calling it again after registrations change rebuilds\n\t * the snapshot; reads also finalize lazily for standalone registry consumers.\n\t */\n\tfinalize(): void {\n\t\tconst finalized = new Map<string, NodeSpec>();\n\t\tfor (const [type, baseSpec] of this._nodeSpecs) {\n\t\t\tlet resolved: NodeSpec = baseSpec;\n\t\t\tfor (const extension of this._nodeSpecExtensions.get(type) ?? []) {\n\t\t\t\tresolved = extension(resolved);\n\t\t\t\tif (resolved.type !== type) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`NodeSpec extension for \"${type}\" must preserve node type; received \"${resolved.type}\".`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinalized.set(type, resolved);\n\t\t}\n\t\tthis._finalizedNodeSpecs = finalized;\n\t}\n\n\t// --- MarkSpec ---\n\n\tregisterMarkSpec<T extends string>(spec: MarkSpec<T>): void {\n\t\tif (this._markSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`MarkSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._markSpecs.set(spec.type, spec);\n\t}\n\n\tgetMarkSpec(type: string): MarkSpec | undefined {\n\t\treturn this._markSpecs.get(type);\n\t}\n\n\tremoveMarkSpec(type: string): void {\n\t\tthis._markSpecs.delete(type);\n\t}\n\n\tgetMarkTypes(): string[] {\n\t\treturn [...this._markSpecs.keys()];\n\t}\n\n\t// --- InlineNodeSpec ---\n\n\tregisterInlineNodeSpec<T extends string>(spec: InlineNodeSpec<T>): void {\n\t\tif (this._inlineNodeSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`InlineNodeSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._inlineNodeSpecs.set(spec.type, spec);\n\t}\n\n\tgetInlineNodeSpec(type: string): InlineNodeSpec | undefined {\n\t\treturn this._inlineNodeSpecs.get(type);\n\t}\n\n\tremoveInlineNodeSpec(type: string): void {\n\t\tthis._inlineNodeSpecs.delete(type);\n\t}\n\n\tgetInlineNodeTypes(): string[] {\n\t\treturn [...this._inlineNodeSpecs.keys()];\n\t}\n\n\t// --- Parse Rules & Sanitize Config ---\n\n\t/** Returns all NodeSpec parseHTML rules, sorted by priority descending. */\n\tgetBlockParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this.getFinalizedNodeSpecs());\n\t}\n\n\t/** Returns all InlineNodeSpec parseHTML rules, sorted by priority descending. */\n\tgetInlineParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this._inlineNodeSpecs);\n\t}\n\n\t/** Returns all MarkSpec parseHTML rules, sorted by priority descending. */\n\tgetMarkParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this._markSpecs);\n\t}\n\n\t/** Returns all allowed HTML tags from base defaults + all spec sanitize configs. */\n\tgetAllowedTags(): string[] {\n\t\treturn [\n\t\t\t...this.collectSanitizeValues(\n\t\t\t\tnew Set(['p', 'br', 'div', 'span']),\n\t\t\t\t(spec) => spec.sanitize?.tags,\n\t\t\t),\n\t\t];\n\t}\n\n\t/** Returns all allowed HTML attributes from base defaults + all spec sanitize configs. */\n\tgetAllowedAttrs(): string[] {\n\t\treturn [\n\t\t\t...this.collectSanitizeValues(\n\t\t\t\tnew Set(['style', 'dir', 'id']),\n\t\t\t\t(spec) => spec.sanitize?.attrs,\n\t\t\t),\n\t\t];\n\t}\n\n\t/** Returns registry-owned, per-tag element validators for one sanitize operation. */\n\tgetElementSanitizeValidators(): ReadonlyMap<string, readonly ElementSanitizeValidator[]> {\n\t\tconst validators = new Map<string, ElementSanitizeValidator[]>();\n\t\tfor (const specMap of this.getAllFinalizedSpecMaps()) {\n\t\t\tfor (const spec of specMap.values()) {\n\t\t\t\tfor (const [tag, validator] of Object.entries(spec.sanitize?.elementValidators ?? {})) {\n\t\t\t\t\tconst normalizedTag = tag.toLowerCase();\n\t\t\t\t\tconst entries = validators.get(normalizedTag) ?? [];\n\t\t\t\t\tentries.push(validator);\n\t\t\t\t\tvalidators.set(normalizedTag, entries);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn validators;\n\t}\n\n\tprivate collectParseRules(\n\t\tspecs: ReadonlyMap<string, { readonly parseHTML?: readonly ParseRule[] }>,\n\t): { readonly rule: ParseRule; readonly type: string }[] {\n\t\tconst results: { readonly rule: ParseRule; readonly type: string }[] = [];\n\t\tfor (const [type, spec] of specs) {\n\t\t\tif (spec.parseHTML) {\n\t\t\t\tfor (const rule of spec.parseHTML) {\n\t\t\t\t\tresults.push({ rule, type });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn results.sort(\n\t\t\t(a, b) =>\n\t\t\t\t(b.rule.priority ?? DEFAULT_PARSE_PRIORITY) - (a.rule.priority ?? DEFAULT_PARSE_PRIORITY),\n\t\t);\n\t}\n\n\tprivate collectSanitizeValues(\n\t\tinitial: Set<string>,\n\t\textractor: (spec: {\n\t\t\treadonly sanitize?: { readonly tags?: readonly string[]; readonly attrs?: readonly string[] };\n\t\t}) => readonly string[] | undefined,\n\t): Set<string> {\n\t\tconst allSpecs: readonly ReadonlyMap<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\treadonly sanitize?: {\n\t\t\t\t\treadonly tags?: readonly string[];\n\t\t\t\t\treadonly attrs?: readonly string[];\n\t\t\t\t};\n\t\t\t}\n\t\t>[] = this.getAllFinalizedSpecMaps();\n\t\tfor (const specMap of allSpecs) {\n\t\t\tfor (const spec of specMap.values()) {\n\t\t\t\tconst values: readonly string[] | undefined = extractor(spec);\n\t\t\t\tif (values) {\n\t\t\t\t\tfor (const value of values) initial.add(value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn initial;\n\t}\n\n\tprivate getFinalizedNodeSpecs(): ReadonlyMap<string, NodeSpec> {\n\t\tif (!this._finalizedNodeSpecs) this.finalize();\n\t\treturn this._finalizedNodeSpecs ?? new Map();\n\t}\n\n\tprivate getAllFinalizedSpecMaps(): readonly ReadonlyMap<\n\t\tstring,\n\t\t{\n\t\t\treadonly sanitize?: {\n\t\t\t\treadonly tags?: readonly string[];\n\t\t\t\treadonly attrs?: readonly string[];\n\t\t\t\treadonly elementValidators?: Readonly<Record<string, ElementSanitizeValidator>>;\n\t\t\t};\n\t\t}\n\t>[] {\n\t\treturn [this.getFinalizedNodeSpecs(), this._inlineNodeSpecs, this._markSpecs];\n\t}\n\n\tprivate invalidateFinalizedNodeSpecs(): void {\n\t\tthis._finalizedNodeSpecs = null;\n\t}\n\n\t// --- Bulk ---\n\n\tclear(): void {\n\t\tthis._nodeSpecs.clear();\n\t\tthis._nodeSpecExtensions.clear();\n\t\tthis._finalizedNodeSpecs = null;\n\t\tthis._markSpecs.clear();\n\t\tthis._inlineNodeSpecs.clear();\n\t}\n}\n"],"mappings":"AAcA,IAKa,EAAb,MACC,0BAA8B,IAAI,IAClC,mCAAuC,IAAI,IAC3C,oBAA4D,KAC5D,0BAA8B,IAAI,IAClC,gCAAoC,IAAI,IAIxC,gBAAA,CAAmC,GAClC,GAAI,KAAK,WAAW,IAAI,EAAK,MAC5B,MAAM,IAAI,MAAM,sBAAsB,EAAK,gCAE5C,KAAK,WAAW,IAAI,EAAK,KAAM,GAC/B,KAAK,8BACN,CAEA,WAAA,CAAY,GACX,OAAO,KAAK,wBAAwB,IAAI,EACzC,CAEA,cAAA,CAAe,GACV,KAAK,WAAW,OAAO,IAAO,KAAK,8BACxC,CAEA,YAAA,GACC,MAAO,IAAI,KAAK,WAAW,OAC5B,CAOA,yBAAA,CAA0B,EAAc,GACvC,MAAM,EAAa,KAAK,oBAAoB,IAAI,IAAS,GACzD,EAAW,KAAK,GAChB,KAAK,oBAAoB,IAAI,EAAM,GACnC,KAAK,8BACN,CAGA,uBAAA,CAAwB,EAAc,GACrC,MAAM,EAAa,KAAK,oBAAoB,I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BAAiB,OACvB"}
@@ -1,2 +0,0 @@
1
- import{a as t,d as e,o as n,u as o}from"./Selection-DC6AOGgF.mjs";import{t as r}from"./TypeBrands-Ch9856Gb.mjs";import{r as f,t as s}from"./DomUtils-Bf7JLFlx.mjs";function i(t){return t instanceof HTMLElement&&"false"===t.getAttribute("contenteditable")}function c(t){return t instanceof HTMLElement&&t.hasAttribute("data-widget")}function a(){return window.getSelection()}function d(t,e){const n=t.getRootNode();if(!(n instanceof ShadowRoot))return null;if(!("getComposedRanges"in e))return null;let o;try{o=e.getComposedRanges({shadowRoots:[n]})}catch{try{o=e.getComposedRanges(n)}catch{return null}}const r=o[0];if(!r)return null;const f="direction"in e&&"backward"===e.direction;return{anchorNode:f?r.endContainer:r.startContainer,anchorOffset:f?r.endOffset:r.startOffset,focusNode:f?r.startContainer:r.endContainer,focusOffset:f?r.startOffset:r.endOffset}}function u(t,e){const n=d(t,e);if(n)return n;const o=e.anchorNode;if(!o)return null;const r=e.focusNode;return r?{anchorNode:o,anchorOffset:e.anchorOffset,focusNode:r,focusOffset:e.focusOffset}:null}function l(t,n){const r=a();if(!r)return;if(o(n))return void r.removeAllRanges();if(e(n)){const e=t.querySelector(`[data-block-id="${n.nodeId}"]`);if(!e)return;const o=e.parentNode;if(!o)return;const f=p(o,e);try{r.setBaseAndExtent(o,f,o,f+1)}catch{}return}const f=T(t,n.anchor),s=T(t,n.head);if(f&&s)try{r.setBaseAndExtent(f.node,f.offset,s.node,s.offset)}catch{}}function N(t){const e=a();if(!e||0===e.rangeCount)return null;const o=u(t,e);if(!o)return null;if(!t.contains(o.anchorNode)||!t.contains(o.focusNode))return null;const r=E(t,o.anchorNode,o.anchorOffset),f=E(t,o.focusNode,o.focusOffset);return r&&f?n(r,f):null}function h(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))return null;const o=E(t,e.startContainer,e.startOffset),r=E(t,e.endContainer,e.endOffset);return o&&r?n(o,r):null}function T(t,e){let n=null;if(e.path&&e.path.length>0){let o=t;for(const t of e.path){const e=o.querySelector(`:scope [data-block-id="${t}"]`);if(!e)break;o=e}o!==t&&o.getAttribute("data-block-id")===e.blockId&&(n=o)}if(n??=t.querySelector(`[data-block-id="${e.blockId}"]`),!n)return null;const o=g(n),r=function(t){let e=null;for(const n of Array.from(t.childNodes))if(!c(n)){if(e)return null;if("BR"!==n.nodeName)return null;e=n}return e}(o);if(r)return{node:o,offset:p(o,r)};let f=e.offset;const s=m(o);let a=s.nextNode();for(;a;){if(a.nodeType===Node.TEXT_NODE){const t=a.textContent?.length??0;if(f<=t)return{node:a,offset:f};f-=t}else if(i(a)){if(0===f){const t=a.parentNode;if(t)return{node:t,offset:p(t,a)}}f-=1}a=s.nextNode()}const d=o.lastChild;return d?d.nodeType===Node.TEXT_NODE?{node:d,offset:d.textContent?.length??0}:{node:o,offset:o.childNodes.length}:{node:o,offset:0}}function E(e,n,o){const c=f(e,n);if(!c)return null;const a=c.getAttribute("data-block-id");if(!a)return null;const d=r(a),u=s(e,c),l=g(c);if(n===c||n===l){const e=n===l?l:c;let r=0,f=0;for(const t of Array.from(e.childNodes)){if(f>=o)break;r+=y(t),f++}return t(d,r,u.length>1?u:void 0)}if(l!==c&&!l.contains(n))return t(d,0,u.length>1?u:void 0);let N=0;const h=m(l);let T=h.nextNode();for(;T;){if(T===n)return T.nodeType===Node.TEXT_NODE?t(d,N+o,u.length>1?u:void 0):t(d,N,u.length>1?u:void 0);T.nodeType===Node.TEXT_NODE?N+=T.textContent?.length??0:i(T)&&(N+=1),T=h.nextNode()}if(n.nodeType===Node.ELEMENT_NODE){const e=function(t,e){let n=0,o=0;for(const r of Array.from(t.childNodes)){if(o>=e)break;n+=y(r),o++}return n}(n,o),r=function(t,e){let n=0,o=e;for(;o&&o!==t;){const t=o.parentNode;if(!t)return null;for(const e of Array.from(t.childNodes)){if(e===o)break;n+=y(e)}o=t}return o===t?n:null}(l,n);return t(d,null===r?e:r+e,u.length>1?u:void 0)}return t(d,0,u.length>1?u:void 0)}function m(t){return document.createTreeWalker(t,NodeFilter.SHOW_ALL,{acceptNode:e=>e instanceof HTMLElement&&e.hasAttribute("data-cursor-wrapper")||c(e)||function(t,e){let n=t.parentNode;for(;n&&n!==e;){if(i(n))return!0;n=n.parentNode}return!1}(e,t)||e instanceof HTMLElement&&e.hasAttribute("data-block-id")&&e!==t?NodeFilter.FILTER_REJECT:e.nodeType===Node.TEXT_NODE||i(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})}function p(t,e){let n=0;for(const o of Array.from(t.childNodes)){if(o===e)return n;n++}return n}function g(t){return t.querySelector("[data-content-dom]")??t}function y(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent?.length??0;if(c(t))return 0;if(i(t))return 1;let e=0;for(const n of Array.from(t.childNodes))e+=y(n);return e}export{u as a,d as i,h as n,N as o,a as r,l as s,E as t};
2
- //# sourceMappingURL=SelectionSync-CwOHMMfI.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectionSync-CwOHMMfI.mjs","names":[],"sources":["../../src/view/SelectionSync.ts"],"sourcesContent":["/**\n * Selection synchronization between editor state and DOM.\n */\n\nimport type { EditorSelection, Position, Selection } from '../model/Selection.js';\nimport {\n\tcreatePosition,\n\tcreateSelection,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../model/Selection.js';\nimport { blockId as toBlockId } from '../model/TypeBrands.js';\nimport { buildBlockPath, findBlockAncestor } from './DomUtils.js';\n\ninterface DOMPosition {\n\tnode: Node;\n\toffset: number;\n}\n\n/**\n * True when `node` is an InlineNode element — rendered `contenteditable=\"false\"`\n * and counted as width 1 in state offset space.\n */\nfunction isInlineNodeEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.getAttribute('contenteditable') === 'false';\n}\n\n/**\n * True when `node` is a view-chrome widget (`data-widget`), such as the checklist\n * checkbox marker. Widgets are rendered into the editable DOM for accessibility\n * but are not document content, so they count as zero width in offset space.\n */\nfunction isWidgetEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute('data-widget');\n}\n\n/**\n * Returns the lone `<br>` placeholder of an empty block, ignoring view-chrome\n * widgets. Returns null when the block holds real inline content.\n */\nfunction findPlaceholderBr(contentEl: Element): Node | null {\n\tlet br: Node | null = null;\n\tfor (const child of Array.from(contentEl.childNodes)) {\n\t\tif (isWidgetEl(child)) continue;\n\t\tif (br) return null;\n\t\tif (child.nodeName === 'BR') {\n\t\t\tbr = child;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn br;\n}\n\n/** Gets the selection object for writing (collapse, setBaseAndExtent). */\nexport function getSelection(): globalThis.Selection | null {\n\treturn window.getSelection();\n}\n\n/**\n * Endpoints returned by reading selection via getComposedRanges().\n * Used to correctly read selection inside Shadow DOM on Safari 17+,\n * Chrome 137+, and Firefox 142+.\n */\nexport interface SelectionEndpoints {\n\tanchorNode: Node;\n\tanchorOffset: number;\n\tfocusNode: Node;\n\tfocusOffset: number;\n}\n\n/**\n * Reads the selection endpoints using getComposedRanges() when inside a\n * Shadow DOM. Returns null if not in a shadow root or the API is unavailable.\n *\n * Handles two call signatures:\n * - Modern (Chrome 137+, Firefox 142+): sel.getComposedRanges({ shadowRoots: [root] })\n * - Legacy (Safari 17+): sel.getComposedRanges(root)\n *\n * StaticRange always uses document order. When `Selection.direction` is\n * `\"backward\"`, anchor/focus are swapped to reconstruct the correct\n * directional endpoints. When direction is `\"none\"` or absent the\n * forward (document-order) mapping is used.\n *\n * Note: Safari 17–18 supports getComposedRanges but not\n * Selection.direction — backward selections will be read as forward.\n */\nexport function readComposedSelection(\n\tcontainer: HTMLElement,\n\tsel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst root = container.getRootNode();\n\tif (!(root instanceof ShadowRoot)) return null;\n\tif (!('getComposedRanges' in sel)) return null;\n\n\tlet ranges: StaticRange[];\n\ttry {\n\t\t// Modern syntax (Chrome 137+, Firefox 142+)\n\t\tranges = (\n\t\t\tsel as unknown as {\n\t\t\t\tgetComposedRanges(opts: { shadowRoots: ShadowRoot[] }): StaticRange[];\n\t\t\t}\n\t\t).getComposedRanges({ shadowRoots: [root] });\n\t} catch {\n\t\ttry {\n\t\t\t// Legacy syntax (Safari 17+)\n\t\t\tranges = (\n\t\t\t\tsel as unknown as {\n\t\t\t\t\tgetComposedRanges(...roots: ShadowRoot[]): StaticRange[];\n\t\t\t\t}\n\t\t\t).getComposedRanges(root);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst range = ranges[0];\n\tif (!range) return null;\n\n\tconst isBackward: boolean =\n\t\t'direction' in sel && (sel as unknown as { direction: string }).direction === 'backward';\n\n\treturn {\n\t\tanchorNode: isBackward ? range.endContainer : range.startContainer,\n\t\tanchorOffset: isBackward ? range.endOffset : range.startOffset,\n\t\tfocusNode: isBackward ? range.startContainer : range.endContainer,\n\t\tfocusOffset: isBackward ? range.startOffset : range.endOffset,\n\t};\n}\n\n/**\n * Reads the DOM selection endpoints, preferring `getComposedRanges()` when\n * the container is inside a Shadow DOM.\n *\n * Returns `null` when `anchorNode` is unavailable (no selection).\n *\n * In Shadow DOM mode the endpoints come from a `StaticRange` which uses\n * document order. `Selection.direction` is used to reconstruct anchor/focus\n * for backward selections.\n */\nexport function readDOMSelectionEndpoints(\n\tcontainer: HTMLElement,\n\tdomSel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst composed: SelectionEndpoints | null = readComposedSelection(container, domSel);\n\tif (composed) return composed;\n\n\tconst anchorNode: Node | null = domSel.anchorNode;\n\tif (!anchorNode) return null;\n\tconst focusNode: Node | null = domSel.focusNode;\n\tif (!focusNode) return null;\n\n\treturn {\n\t\tanchorNode,\n\t\tanchorOffset: domSel.anchorOffset,\n\t\tfocusNode,\n\t\tfocusOffset: domSel.focusOffset,\n\t};\n}\n\n/** Syncs the editor state selection to the DOM. */\nexport function syncSelectionToDOM(container: HTMLElement, selection: EditorSelection): void {\n\tconst domSel = getSelection();\n\tif (!domSel) return;\n\n\t// GapCursor: clear browser selection (gap cursor has no DOM equivalent)\n\tif (isGapCursor(selection)) {\n\t\tdomSel.removeAllRanges();\n\t\treturn;\n\t}\n\n\t// NodeSelection: select the entire block element\n\tif (isNodeSelection(selection)) {\n\t\tconst blockEl = container.querySelector(`[data-block-id=\"${selection.nodeId}\"]`);\n\t\tif (!blockEl) return;\n\t\tconst parent = blockEl.parentNode;\n\t\tif (!parent) return;\n\t\tconst childIdx = childIndexOf(parent, blockEl);\n\t\ttry {\n\t\t\tdomSel.setBaseAndExtent(parent, childIdx, parent, childIdx + 1);\n\t\t} catch {\n\t\t\t// Selection may fail if DOM is not yet rendered\n\t\t}\n\t\treturn;\n\t}\n\n\tconst anchorPos = statePositionToDOM(container, selection.anchor);\n\tconst headPos = statePositionToDOM(container, selection.head);\n\n\tif (!anchorPos || !headPos) return;\n\n\ttry {\n\t\tdomSel.setBaseAndExtent(anchorPos.node, anchorPos.offset, headPos.node, headPos.offset);\n\t} catch {\n\t\t// Selection may fail if DOM is not yet rendered\n\t}\n}\n\n/** Reads the current DOM selection and converts it to a state selection. */\nexport function readSelectionFromDOM(container: HTMLElement): Selection | null {\n\tconst domSel = getSelection();\n\tif (!domSel || domSel.rangeCount === 0) return null;\n\n\tconst endpoints: SelectionEndpoints | null = readDOMSelectionEndpoints(container, domSel);\n\tif (!endpoints) return null;\n\n\tif (!container.contains(endpoints.anchorNode) || !container.contains(endpoints.focusNode)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, endpoints.anchorNode, endpoints.anchorOffset);\n\tconst head = domPositionToState(container, endpoints.focusNode, endpoints.focusOffset);\n\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/**\n * Converts a DOM range (e.g. a `StaticRange` from `InputEvent.getTargetRanges()`)\n * to a state selection. Returns `null` when either endpoint lies outside the\n * container or cannot be mapped to a block position.\n */\nexport function domRangeToState(container: HTMLElement, range: AbstractRange): Selection | null {\n\tif (!container.contains(range.startContainer) || !container.contains(range.endContainer)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, range.startContainer, range.startOffset);\n\tconst head = domPositionToState(container, range.endContainer, range.endOffset);\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/** Converts a state position (blockId + offset) to a DOM position (node + offset). */\nfunction statePositionToDOM(container: HTMLElement, pos: Position): DOMPosition | null {\n\t// If path is available, navigate directly to the leaf block\n\tlet blockEl: Element | null = null;\n\tif (pos.path && pos.path.length > 0) {\n\t\tlet current: Element = container;\n\t\tfor (const id of pos.path) {\n\t\t\tconst found = current.querySelector(`:scope [data-block-id=\"${id}\"]`);\n\t\t\tif (!found) break;\n\t\t\tcurrent = found;\n\t\t}\n\t\tif (current !== container && current.getAttribute('data-block-id') === pos.blockId) {\n\t\t\tblockEl = current;\n\t\t}\n\t}\n\tblockEl ??= container.querySelector(`[data-block-id=\"${pos.blockId}\"]`);\n\tif (!blockEl) return null;\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle empty blocks rendered as a single <br> placeholder. View-chrome\n\t// widgets (e.g. the checklist marker) are ignored, so the caret lands after\n\t// the widget and before the <br> rather than at the very start of the block.\n\tconst placeholderBr = findPlaceholderBr(contentEl);\n\tif (placeholderBr) {\n\t\treturn { node: contentEl, offset: childIndexOf(contentEl, placeholderBr) };\n\t}\n\n\t// Walk through text nodes and inline elements to find the correct position\n\tlet remaining = pos.offset;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet current = walker.nextNode();\n\twhile (current) {\n\t\tif (current.nodeType === Node.TEXT_NODE) {\n\t\t\tconst len = current.textContent?.length ?? 0;\n\t\t\tif (remaining <= len) {\n\t\t\t\treturn { node: current, offset: remaining };\n\t\t\t}\n\t\t\tremaining -= len;\n\t\t} else if (isInlineNodeEl(current)) {\n\t\t\t// InlineNode element — width 1 in state offset space\n\t\t\tif (remaining === 0) {\n\t\t\t\t// Position before this inline element\n\t\t\t\tconst parent = current.parentNode;\n\t\t\t\tif (parent) {\n\t\t\t\t\tconst childIndex = childIndexOf(parent, current);\n\t\t\t\t\treturn { node: parent, offset: childIndex };\n\t\t\t\t}\n\t\t\t}\n\t\t\tremaining -= 1;\n\t\t}\n\t\tcurrent = walker.nextNode();\n\t}\n\n\t// Fallback: position at end of block\n\tconst lastChild = contentEl.lastChild;\n\tif (lastChild) {\n\t\tif (lastChild.nodeType === Node.TEXT_NODE) {\n\t\t\treturn { node: lastChild, offset: lastChild.textContent?.length ?? 0 };\n\t\t}\n\t\treturn { node: contentEl, offset: contentEl.childNodes.length };\n\t}\n\n\treturn { node: contentEl, offset: 0 };\n}\n\n/** Converts a DOM position to a state position, including nested path. */\nexport function domPositionToState(\n\tcontainer: HTMLElement,\n\tnode: Node,\n\tdomOffset: number,\n): Position | null {\n\t// Find the innermost block element\n\tconst blockEl = findBlockAncestor(container, node);\n\tif (!blockEl) return null;\n\n\tconst rawBlockId = blockEl.getAttribute('data-block-id');\n\tif (!rawBlockId) return null;\n\tconst bid = toBlockId(rawBlockId);\n\n\t// Build path by collecting all data-block-id ancestors from leaf to root\n\tconst path = buildBlockPath(container, blockEl);\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle clicks on the block or content element itself (e.g. empty paragraph with <br>)\n\tif (node === blockEl || node === contentEl) {\n\t\tconst targetEl: Element = node === contentEl ? contentEl : blockEl;\n\t\tlet childOffset = 0;\n\t\tlet childIdx = 0;\n\t\tfor (const child of Array.from(targetEl.childNodes)) {\n\t\t\tif (childIdx >= domOffset) break;\n\t\t\tchildOffset += inlineContentWidth(child);\n\t\t\tchildIdx++;\n\t\t}\n\t\treturn createPosition(bid, childOffset, path.length > 1 ? path : undefined);\n\t}\n\n\t// If node is outside the contentDOM (e.g. in NodeView header), map to offset 0\n\tif (contentEl !== blockEl && !contentEl.contains(node)) {\n\t\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n\t}\n\n\t// Calculate offset by walking text nodes and inline elements\n\tlet offset = 0;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet walkerNode = walker.nextNode();\n\twhile (walkerNode) {\n\t\tif (walkerNode === node) {\n\t\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\t\treturn createPosition(bid, offset + domOffset, path.length > 1 ? path : undefined);\n\t\t\t}\n\t\t\t// Node is an inline element — return offset at its start\n\t\t\treturn createPosition(bid, offset, path.length > 1 ? path : undefined);\n\t\t}\n\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\toffset += walkerNode.textContent?.length ?? 0;\n\t\t} else if (isInlineNodeEl(walkerNode)) {\n\t\t\toffset += 1;\n\t\t}\n\t\twalkerNode = walker.nextNode();\n\t}\n\n\t// If the node is not a text node, try to find the offset from element context\n\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\tconst childOffset = inlineOffsetForChildIndex(node, domOffset);\n\t\tconst offsetBeforeNode = inlineOffsetBeforeNode(contentEl, node);\n\t\tconst totalOffset = offsetBeforeNode === null ? childOffset : offsetBeforeNode + childOffset;\n\t\treturn createPosition(bid, totalOffset, path.length > 1 ? path : undefined);\n\t}\n\n\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n}\n\n/** Counts inline width for the first `childIndex` children of an element. */\nfunction inlineOffsetForChildIndex(node: Node, childIndex: number): number {\n\tlet childOffset = 0;\n\tlet childIdx = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\tif (childIdx >= childIndex) break;\n\t\tchildOffset += inlineContentWidth(child);\n\t\tchildIdx++;\n\t}\n\treturn childOffset;\n}\n\n/** Returns the inline offset from `root` to the start of `node`, or null when unrelated. */\nfunction inlineOffsetBeforeNode(root: Element, node: Node): number | null {\n\tlet offset = 0;\n\tlet current: Node | null = node;\n\n\twhile (current && current !== root) {\n\t\tconst parent: Node | null = current.parentNode;\n\t\tif (!parent) return null;\n\n\t\tfor (const sibling of Array.from(parent.childNodes) as Node[]) {\n\t\t\tif (sibling === current) break;\n\t\t\toffset += inlineContentWidth(sibling);\n\t\t}\n\n\t\tcurrent = parent;\n\t}\n\n\treturn current === root ? offset : null;\n}\n\n/** Checks if a node is inside a contentEditable=\"false\" inline element. */\nfunction isInsideInlineElement(node: Node, root: Element): boolean {\n\tlet parent: Node | null = node.parentNode;\n\twhile (parent && parent !== root) {\n\t\tif (isInlineNodeEl(parent)) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = parent.parentNode;\n\t}\n\treturn false;\n}\n\n/**\n * Creates a TreeWalker that visits text nodes and contentEditable=\"false\"\n * inline elements within a block, skipping mark wrappers and nested blocks.\n */\nfunction createInlineContentWalker(blockEl: Element): TreeWalker {\n\treturn document.createTreeWalker(blockEl, NodeFilter.SHOW_ALL, {\n\t\tacceptNode: (n: Node) => {\n\t\t\t// Skip cursor wrapper (ZWS for stored marks during IME composition)\n\t\t\tif (n instanceof HTMLElement && n.hasAttribute('data-cursor-wrapper')) {\n\t\t\t\treturn NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Skip view-chrome widgets (e.g. the checklist checkbox marker). They are\n\t\t\t// contentEditable=\"false\" but not document content, so they carry zero\n\t\t\t// width in offset space and must never become a caret position.\n\t\t\tif (isWidgetEl(n)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip anything inside an inline element (contentEditable=\"false\")\n\t\t\tif (isInsideInlineElement(n, blockEl)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip nested block elements and their descendants\n\t\t\tif (n instanceof HTMLElement && n.hasAttribute('data-block-id') && n !== blockEl) {\n\t\t\t\treturn NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Accept text nodes\n\t\t\tif (n.nodeType === Node.TEXT_NODE) return NodeFilter.FILTER_ACCEPT;\n\t\t\t// Accept inline elements (contentEditable=\"false\")\n\t\t\tif (isInlineNodeEl(n)) {\n\t\t\t\treturn NodeFilter.FILTER_ACCEPT;\n\t\t\t}\n\t\t\t// Skip other elements (mark wrappers, decoration wrappers) — descend\n\t\t\treturn NodeFilter.FILTER_SKIP;\n\t\t},\n\t});\n}\n\n/** Returns the child index of a node within its parent. */\nfunction childIndexOf(parent: Node, child: Node): number {\n\tlet idx = 0;\n\tfor (const c of Array.from(parent.childNodes)) {\n\t\tif (c === child) return idx;\n\t\tidx++;\n\t}\n\treturn idx;\n}\n\n/**\n * Resolves the content root for inline content walking.\n * If the block element has a contentDOM (marked with data-content-dom),\n * returns it so the walker skips NodeView structural elements (headers, etc.).\n */\nfunction resolveContentRoot(blockEl: Element): Element {\n\tconst contentDOM: Element | null = blockEl.querySelector('[data-content-dom]');\n\treturn contentDOM ?? blockEl;\n}\n\n/** Counts the inline content width of a DOM node (text length + 1 per inline element). */\nfunction inlineContentWidth(node: Node): number {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\treturn node.textContent?.length ?? 0;\n\t}\n\t// View-chrome widgets (e.g. the checklist marker) are not document content.\n\tif (isWidgetEl(node)) {\n\t\treturn 0;\n\t}\n\tif (isInlineNodeEl(node)) {\n\t\treturn 1;\n\t}\n\t// Mark wrapper or other element — sum children\n\tlet width = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\twidth += inlineContentWidth(child);\n\t}\n\treturn width;\n}\n"],"mappings":"mKAuBA,SAAS,EAAe,GACvB,OAAO,aAAgB,aAAwD,UAAzC,EAAK,aAAa,kBACzD,CAOA,SAAS,EAAW,GACnB,OAAO,aAAgB,aAAe,EAAK,aAAa,cACzD,CAqBA,SAAgB,IACf,OAAO,OAAO,cACf,CA8BA,SAAgB,EACf,EACA,GAEA,MAAM,EAAO,EAAU,cACvB,KAAM,aAAgB,YAAa,OAAO,KAC1C,KAAM,sBAAuB,GAAM,OAAO,KAE1C,IAAI,EACJ,IAEC,EACC,EAGC,kBAAkB,CAAE,YAAa,CAAC,IACrC,CAAA,MACC,IAEC,EACC,EAGC,kBAAkB,EACrB,CAAA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,WAAW,cAM9C,WAAW,aAGrB,CAGA,SAAS,EAAa,EAAc,GACnC,IAAI,EAAM,EACV,IAAK,MAAM,KAAK,MAAM,KAAK,EAAO,YAAa,CAC9C,GAAI,IAAM,EAAO,OAAO,EACxB,GACD,CACA,OAAO,CACR,CAOA,SAAS,EAAmB,GAE3B,OADmC,EAAQ,cAAc,uBACpC,CACtB,CAGA,SAAS,EAAmB,GAC3B,GAAI,EAAK,WAAa,KAAK,UAC1B,OAAO,EAAK,aAAa,QAAU,EAGpC,GAAI,EAAW,GACd,OAAO,EAER,GAAI,EAAe,GAClB,OAAO,EAGR,IAAI,EAAQ,EACZ,IAAK,MAAM,KAAS,MAAM,KAAK,EAAK,YACnC,GAAS,EAAmB,GAE7B,OAAO,CACR"}
@@ -1,2 +0,0 @@
1
- import{i as o}from"./TypeBrands-Ch9856Gb.mjs";import{i as r,t}from"./MarkCommands-CJvLGL5G.mjs";import{n as a}from"./PluginHelpers-WG1Lzzh3.mjs";function e(e,m){const i=o(m.markSpec.type);e.registerMarkSpec(m.markSpec),e.registerCommand(m.command,()=>a(e,r(e.getState(),i))),m.keyBinding&&e.registerKeymap({[m.keyBinding]:()=>e.executeCommand(m.command)}),m.toolbar&&e.registerToolbarItem({id:m.toolbar.id,group:m.toolbar.group,icon:m.toolbar.icon,label:m.toolbar.label,tooltip:m.toolbar.tooltip,command:m.command,isActive:o=>t(o,i)})}export{e as t};
2
- //# sourceMappingURL=SimpleMark-CTDtEIMV.mjs.map
@@ -1,2 +0,0 @@
1
- import{n as t,o as e,r as n,t as s}from"./HTMLUtils-B0nGyFLb.mjs";import{B as r,D as i,H as o,P as c,V as l,z as a}from"./Document-D_2cIBJG.mjs";import{t as u}from"./TypeBrands-Ch9856Gb.mjs";import{r as f}from"./AttrRegistry-CtNhf2EF.mjs";import{n as d,t as p}from"./HTMLSanitization-Ce9dVT1q.mjs";var g=/^[A-Za-z0-9_-]{1,64}$/;function h(t){return g.test(t)}function m(t,e){const n=t.getAttribute("data-block-id");if(n&&h(n)&&!e.has(n))return e.add(n),u(n)}function $(t){return t.split(";").map(t=>t.trim()).filter(t=>t.length>0).sort().join("; ")}function y(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36).padStart(6,"0")}var x=class{classMap=/* @__PURE__ */new Map;usedHashes=/* @__PURE__ */new Set;getClassName(t){const e=$(t),n=this.classMap.get(e);if(n)return n;let s=y(e),r=0;for(;this.usedHashes.has(s);)r++,s=y(e+String(r));const i=`notectl-s-${s}`;return this.usedHashes.add(s),this.classMap.set(e,i),i}getAlignmentClassName(t){const e=$(`text-align: ${t}`),n=this.classMap.get(e);if(n)return n;const s=`notectl-align-${t}`;return this.classMap.set(e,s),s}toCSS(){if(0===this.classMap.size)return"";const t=[];for(const[e,n]of this.classMap)t.push(`.${n} { ${e}; }`);return t.join("\n")}toStyleMap(){const t=/* @__PURE__ */new Map;for(const[e,n]of this.classMap)t.set(n,e);return t}};function M(t){const e=t.getMarkTypes(),n=/* @__PURE__ */new Map;for(const s of e){const e=t.getMarkSpec(s);e&&n.set(s,e.rank??99)}return n}function A(t,e,n,s,r,i){if(0===e.length)return t;const o=s??M(n),c=[...e].sort((t,e)=>(o.get(t.type)??99)-(o.get(e.type)??99)),l=[],a=[];for(const f of c){const t=n.getMarkSpec(f.type);if(t?.toHTMLStyle){const e=t.toHTMLStyle(f);e&&l.push(e)}else a.push(f)}let u=t;l.length>0&&(u=i(u,l.join("; ")));for(const f of a){const t=n.getMarkSpec(f.type);t?.toHTMLString&&(u=t.toHTMLString(f,u,r))}return u}function k(t,e,s,r,i,o){return""===t?"":A(n(t),e,s,r,i,o)}function S(t){return(e,n)=>{const s=t?t.styleAttr(n):` style="${n}"`;return s?`<span${s}>${e}</span>`:e}}function b(t){return(e,n)=>`<span class="${t.getClassName(n)}">${e}</span>`}function L(t,e,n,s,r){return k(t,e,n,s,r,S(r))}function v(t,e,n,s,r){return A(t,e,n,s,r,S(r))}function T(t,e,n,s,r,i){return k(t,e,n,r,i,b(s))}function C(t,e,n,s,r,i){return A(t,e,n,r,i,b(s))}var w=/* @__PURE__ */new Set(["start","center","end","justify"]),H={left:"start",right:"end"},N=/* @__PURE__ */new Set(["ltr","rtl"]);function j(t){return{styleAttr:e=>e?` class="${t.getClassName(e)}"`:""}}function _(t,e,n){const s=W(t);if(!s)return t;const r=t.slice(s.start,s.end+1),i=new RegExp(`\\s${e}\\s*=\\s*("([^"]*)"|'([^']*)')`),o=r.match(i);if(o){const c=o[2]??o[3]??"";if("style"===e&&/(?:^|;)\s*text-align\s*:/i.test(c))return t;const l=` ${e}="${c}${"style"===e?"; ":" "}${n}"`,a=r.replace(i,l);return`${t.slice(0,s.start)}${a}${t.slice(s.end+1)}`}const c=r.endsWith("/>")?`${r.slice(0,-2)} ${e}="${n}"/>`:`${r.slice(0,-1)} ${e}="${n}">`;return`${t.slice(0,s.start)}${c}${t.slice(s.end+1)}`}function E(t){return" "===t||"\t"===t||"\n"===t||"\f"===t||"\r"===t}function I(n,s){const r=e(s);return r?function(t,e,n){const s=W(t);if(!s)return t;const r=` ${e}="${n}"`,i=function(t,e){const n=[];let s=1;for(;s<t.length&&!E(t[s]??"")&&">"!==t[s]&&"/"!==t[s];)s++;for(;s<t.length;){for(;E(t[s]??"");)s++;if(">"===t[s]||void 0===t[s])break;if("/"===t[s]&&">"===t[s+1])break;const r=s;for(;s<t.length&&!E(t[s]??"")&&"="!==t[s]&&">"!==t[s]&&"/"!==t[s];)s++;const i=t.slice(r,s);if(""!==i){for(;E(t[s]??"");)s++;if("="===t[s]){for(s++;E(t[s]??"");)s++;const e=t[s];if('"'===e||"'"===e){for(s++;s<t.length&&t[s]!==e;)s++;t[s]===e&&s++}else for(;s<t.length&&!E(t[s]??"")&&">"!==t[s]&&("/"!==t[s]||">"!==t[s+1]);)s++}i.toLowerCase()===e.toLowerCase()&&n.push({start:r,end:s})}else s++}let r=t;for(let i=n.length-1;i>=0;i--){const t=n[i];t&&(r=`${r.slice(0,t.start)}${r.slice(t.end)}`)}return r}(t.slice(s.start,s.end+1),e),o=i.endsWith("/>")?`${i.slice(0,-2)}${r}/>`:`${i.slice(0,-1)}${r}>`;return`${t.slice(0,s.start)}${o}${t.slice(s.end+1)}`}(n,"id",t(r)):n}function W(t){let e=t.indexOf("<");for(;e>=0;){const n=t[e+1];if(n&&/[A-Za-z]/.test(n)){let n;for(let s=e+2;s<t.length;s++){const r=t[s]??"";if(n)r===n&&(n=void 0);else if('"'!==r&&"'"!==r){if(">"===r)return{start:e,end:s}}else n=r}return}e=t.indexOf("<",e+1)}}function D(t){const e=W(t);return e?t.slice(e.start,e.end+1):""}function O(t){return p(...t?[]:["data-block-id"])}function R(t,e,n){const r=!1!==n?.includeBlockIds,i={registry:e,exportCtx:{styleAttr:t=>t?` style="${t}"`:""},includeBlockIds:r},o=z(t.children,i),c=e?e.getAllowedTags():["p","br","div","span"],l=e?e.getAllowedAttrs():["style","dir","id"];return d(o,{ALLOWED_TAGS:c,ALLOWED_ATTR:l,ALLOWED_URI_REGEXP:s,...O(r)},e)}function B(t,e,n){const r=!1!==n?.includeBlockIds,i=new x,o={registry:e,collector:i,exportCtx:j(i),includeBlockIds:r},c=z(t.children,o),l=e?e.getAllowedTags():["p","br","div","span"],a=e?e.getAllowedAttrs():["style","class","dir","id"],u=(a.includes("class")?[...a]:[...a,"class"]).filter(t=>"style"!==t);return{html:d(c,{ALLOWED_TAGS:l,ALLOWED_ATTR:u,ALLOWED_URI_REGEXP:s,...O(r)},e),css:i.toCSS(),styleMap:i.toStyleMap()}}function z(t,e){const n=[];let s=0;for(;s<t.length;){const r=t[s];if(r)if(f(r,"list_item")){const r=[];for(;s<t.length;){const e=t[s];if(!e||!f(e,"list_item"))break;r.push(e),s++}n.push(G(r,e))}else n.push(F(r,e)),s++;else s++}return n.join("")}function G(t,e){const n=[],s=[];for(let r=0;r<t.length;r++){const i=t[r];if(!i)continue;const o=i.attrs?.listType??"bullet",c=i.attrs?.indent??0,l="ordered"===o?"ol":"ul";for(;s.length>0;){const t=s[s.length-1];if(!t)break;if(t.indent>c)n.push(`</${t.tag}></li>`),s.pop();else{if(t.indent!==c||t.tag===l)break;n.push(`</${t.tag}></li>`),s.pop()}}if(0===s.length)n.push(`<${l}>`),s.push({tag:l,indent:c});else{const t=s[s.length-1];t&&c>t.indent&&(n.push(`<${l}>`),s.push({tag:l,indent:c}))}const a=F(i,e),u=t[r+1],f=u?u.attrs?.indent??0:void 0;void 0!==f&&f>c?n.push(P(a)):n.push(a)}for(;s.length>0;){const t=s.pop();if(!t)break;n.push(`</${t.tag}>`),s.length>0&&n.push("</li>")}return n.join("")}function P(t){return t.endsWith("</li>")?t.slice(0,-5):t}function F(e,s){const u=r(e)?function(t,e){const s=function(t){if(t.length<=1)return t;const e=[];for(const n of t){if(a(n)){e.push(n);continue}const t=e[e.length-1];t&&l(t)&&o(t.marks,n.marks)?e[e.length-1]={type:"text",text:t.text+n.text,marks:t.marks}:e.push(n)}return e}(c(t)),r=[],i=e.registry?M(e.registry):void 0;for(const o of s)if(a(o)){const t=e.registry?.getInlineNodeSpec(o.inlineType);if(t?.toHTMLString){const n=t.toHTMLString(o);e.registry&&o.marks.length>0?r.push(e.collector?C(n,o.marks,e.registry,e.collector,i,e.exportCtx):v(n,o.marks,e.registry,i,e.exportCtx)):r.push(n)}}else e.registry&&e.collector?r.push(T(o.text,o.marks,e.registry,e.collector,i,e.exportCtx)):e.registry?r.push(L(o.text,o.marks,e.registry,i,e.exportCtx)):""!==o.text&&r.push(n(o.text));return r.join("")}(e,s):z(i(e),s),f=s.registry?.getNodeSpec(e.type);let d;d=f?.toHTML?f.toHTML(e,u,s.exportCtx):`<p>${u||"<br>"}</p>`,s.includeBlockIds&&h(e.id)&&(D(d).includes(" data-block-id=")||(d=_(d,"data-block-id",t(e.id)))),d=I(d,e.htmlId);const p=e.attrs?.align,g=p?H[p]??p:void 0;if(g&&"start"!==g&&w.has(g)){const e=t(g);if(s.collector){const e=s.collector.getAlignmentClassName(g);d=_(d,"class",t(e))}else d=_(d,"style",`text-align: ${e}`)}const m=e.attrs?.dir;return m&&N.has(m)&&(D(d).includes(" dir=")||(d=_(d,"dir",t(m)))),d}var U=1e4;function V(t,e=1,n=1e4){if("number"!=typeof t||!Number.isFinite(t))return null;const s=X(e,1),r=Math.max(s,X(n,U));return Math.min(r,Math.max(s,t))}function X(t,e){return Number.isFinite(t)?Math.min(U,Math.max(1,t)):e}var Z="data-notectl-width-px",q="data-notectl-min-height-px",J=1e3,K=/^\d+(?:\.\d+)?$/,Q=/^(\d+(?:\.\d+)?)px$/i,Y=/^\d+$/;function tt(t){if("number"==typeof t&&Number.isFinite(t)&&!(t<1||t>1e4))return V(t)??void 0}function et(t){if(null===t)return;const e=t.trim().match(Q);return e?.[1]?lt(e[1]):void 0}function nt(t,e,n,s){const r=ct(t.getAttribute(e),!1);if(void 0!==r)return r;for(const i of n){const e=et(t.style.getPropertyValue(i));if(void 0!==e)return e}return ct(t.getAttribute(s),!0)}function st(t){if(null===t)return 1;const e=t.trim();if(!Y.test(e))return 1;const n=Number(e);return!Number.isSafeInteger(n)||n<1||n>1e3?1:n}function rt(t){if(!Array.isArray(t))return;const e=Array.from(t.slice(0,1e3),t=>tt(t)??null);return e.some(t=>null!==t)?e:void 0}function it(t){return void 0!==rt(t)}function ot(t,e,n,s){const r=tt(n);if(void 0===r)return"";const i=`${e}: ${String(r)}px`,o=s?.styleAttr(i)??` style="${i}"`;return` ${t}="${String(r)}"${o}`}function ct(t,e){if(null===t)return;const n=t.trim();if(K.test(n))return lt(n);if(!e)return;const s=n.match(Q);return s?.[1]?lt(s[1]):void 0}function lt(t){return tt(Number(t))}export{M as _,tt as a,nt as c,V as d,w as f,I as g,R as h,it as i,ot as l,B as m,Z as n,rt as o,N as p,q as r,st as s,J as t,U as u,L as v,m as y};
2
- //# sourceMappingURL=TableDimensions-BcARMxQB.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableDimensions-BcARMxQB.mjs","names":[],"sources":["../../src/serialization/BlockIdHTML.ts","../../src/serialization/CSSClassCollector.ts","../../src/serialization/MarkSerializer.ts","../../src/serialization/DocumentSerializer.ts","../../src/model/TableDimensions.ts","../../src/serialization/TableDimensions.ts"],"sourcesContent":["/**\n * Shared rules for the `data-block-id` HTML wire format.\n *\n * Block identity round-trips through `getContentHTML` → `setContentHTML` so the\n * caret-preserving `EditorView.replaceState()` keeps the cursor on the same block\n * across content sync (Angular signal forms, RxJS pipes — see ARCHITECTURE §9.2).\n * Both serializer and parser must agree on the same shape; this module is the\n * single source of truth.\n */\n\nimport { type BlockId, blockId } from '../model/TypeBrands.js';\n\n/**\n * Conservative pattern for `data-block-id` values: alphanumeric, underscore,\n * hyphen, max 64 chars. Defense-in-depth — IDs flow in-memory only, but we keep\n * the wire shape narrow to rule out attribute-injection vectors and to allow\n * `escapeAttr` to be a no-op for valid IDs.\n */\nexport const SAFE_BLOCK_ID_PATTERN: RegExp = /^[A-Za-z0-9_-]{1,64}$/;\n\n/** True if `value` is shaped like a safe `data-block-id`. */\nexport function isSafeBlockId(value: string): boolean {\n\treturn SAFE_BLOCK_ID_PATTERN.test(value);\n}\n\n/**\n * Adopts the `data-block-id` attribute from a parsed element so that block\n * identity survives an HTML round-trip. Returns `undefined` (caller generates\n * a fresh ID) when:\n * - the attribute is missing (e.g. user-pasted external HTML),\n * - the value is malformed,\n * - or the value collides with an already-adopted ID in this parse pass\n * (e.g. concatenated HTML from two documents).\n */\nexport function adoptBlockId(el: Element, used: Set<string>): BlockId | undefined {\n\tconst raw: string | null = el.getAttribute('data-block-id');\n\tif (!raw) return undefined;\n\tif (!isSafeBlockId(raw)) return undefined;\n\tif (used.has(raw)) return undefined;\n\tused.add(raw);\n\treturn blockId(raw);\n}\n","/**\n * CSSClassCollector: maps CSS declarations to unique class names during serialization.\n * Deduplicates identical declaration sets and produces a minimal stylesheet.\n * Uses content-hash (FNV-1a) for deterministic, document-order-independent class names.\n */\n\n/** Prefix for generated style class names (avoids collisions with user classes). */\nconst CLASS_PREFIX = 'notectl-s-';\n\n/** Base for hash encoding output. */\nconst HASH_BASE = 36;\n/** Pad length for consistent 6-char hashes. */\nconst HASH_PAD_LENGTH = 6;\n\n/**\n * Normalizes a CSS declarations string by sorting individual declarations alphabetically.\n * This ensures `\"color: red; font-size: 14px\"` and `\"font-size: 14px; color: red\"` map\n * to the same class name.\n */\nfunction normalizeDeclarations(declarations: string): string {\n\treturn declarations\n\t\t.split(';')\n\t\t.map((d) => d.trim())\n\t\t.filter((d) => d.length > 0)\n\t\t.sort()\n\t\t.join('; ');\n}\n\n/** FNV-1a 32-bit offset basis. */\nconst FNV_OFFSET_BASIS = 0x811c9dc5;\n/** FNV-1a 32-bit prime. */\nconst FNV_PRIME = 0x01000193;\n\n/**\n * FNV-1a 32-bit hash function.\n * Fast, no crypto dependency, excellent distribution for short strings.\n */\nfunction fnv1aHash(input: string): string {\n\tlet hash: number = FNV_OFFSET_BASIS;\n\tfor (let i = 0; i < input.length; i++) {\n\t\thash ^= input.charCodeAt(i);\n\t\thash = Math.imul(hash, FNV_PRIME);\n\t}\n\t// Convert to unsigned 32-bit, then to base-36, padded to 6 chars\n\tconst unsigned: number = hash >>> 0;\n\treturn unsigned.toString(HASH_BASE).padStart(HASH_PAD_LENGTH, '0');\n}\n\n/**\n * Stateful collector that assigns CSS class names to unique declaration sets.\n * Used during a single serialization pass, then produces the collected stylesheet.\n *\n * Class names are deterministic: the same declarations always produce the same\n * class name, regardless of encounter order across documents.\n */\nexport class CSSClassCollector {\n\t/** Maps normalized declarations → class name. */\n\tprivate readonly classMap: Map<string, string> = new Map();\n\t/** Tracks used hashes to handle the (extremely rare) collision case. */\n\tprivate readonly usedHashes: Set<string> = new Set();\n\n\t/**\n\t * Returns the class name for the given CSS declarations.\n\t * If the same (normalized) declarations were seen before, returns the existing class.\n\t */\n\tgetClassName(declarations: string): string {\n\t\tconst normalized: string = normalizeDeclarations(declarations);\n\t\tconst existing: string | undefined = this.classMap.get(normalized);\n\t\tif (existing) return existing;\n\n\t\tlet hash: string = fnv1aHash(normalized);\n\t\tlet suffix = 0;\n\t\t// Collision handling: append suffix counter if the hash is already in use\n\t\t// for a different declarations string\n\t\twhile (this.usedHashes.has(hash)) {\n\t\t\tsuffix++;\n\t\t\thash = fnv1aHash(normalized + String(suffix));\n\t\t}\n\n\t\tconst className: string = `${CLASS_PREFIX}${hash}`;\n\t\tthis.usedHashes.add(hash);\n\t\tthis.classMap.set(normalized, className);\n\t\treturn className;\n\t}\n\n\t/**\n\t * Returns the semantic alignment class name for a given alignment value.\n\t * Unlike style classes, alignment classes use descriptive names.\n\t */\n\tgetAlignmentClassName(alignment: string): string {\n\t\t// Key by the normalized declaration so the \"one declaration → one class\"\n\t\t// invariant is shared with getClassName(); if a style class for the same\n\t\t// declaration already exists, reuse it rather than minting a second name.\n\t\tconst normalized: string = normalizeDeclarations(`text-align: ${alignment}`);\n\t\tconst existing: string | undefined = this.classMap.get(normalized);\n\t\tif (existing) return existing;\n\n\t\tconst className = `notectl-align-${alignment}`;\n\t\tthis.classMap.set(normalized, className);\n\t\treturn className;\n\t}\n\n\t/** Produces CSS rules for all collected classes. Returns empty string if none collected. */\n\ttoCSS(): string {\n\t\tif (this.classMap.size === 0) return '';\n\n\t\tconst rules: string[] = [];\n\t\tfor (const [declarations, className] of this.classMap) {\n\t\t\trules.push(`.${className} { ${declarations}; }`);\n\t\t}\n\t\treturn rules.join('\\n');\n\t}\n\n\t/**\n\t * Returns a map from class name → CSS declarations for round-trip support.\n\t * Used by `setContentHTML` to rehydrate class-based HTML.\n\t */\n\ttoStyleMap(): ReadonlyMap<string, string> {\n\t\tconst map = new Map<string, string>();\n\t\tfor (const [declarations, className] of this.classMap) {\n\t\t\tmap.set(className, declarations);\n\t\t}\n\t\treturn map;\n\t}\n}\n","/**\n * MarkSerializer: shared mark serialization logic for DocumentSerializer and ClipboardHandler.\n * Separates style-based marks (merged into a single `<span style>`) from tag-based marks\n * (nested wrappers in rank order).\n */\n\nimport type { Mark } from '../model/Document.js';\nimport { escapeHTML } from '../model/HTMLUtils.js';\nimport type { MarkSpec } from '../model/MarkSpec.js';\nimport type { HTMLExportContext } from '../model/NodeSpec.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport type { CSSClassCollector } from './CSSClassCollector.js';\n\n/** Rank assigned to marks whose spec does not declare an explicit `rank`. */\nconst DEFAULT_MARK_RANK = 99;\n\n/** Builds a map of mark type name to rank from the registry (compute once per pass). */\nexport function buildMarkOrder(registry: SchemaRegistry): Map<string, number> {\n\tconst types: readonly string[] = registry.getMarkTypes();\n\tconst order = new Map<string, number>();\n\tfor (const t of types) {\n\t\tconst spec: MarkSpec | undefined = registry.getMarkSpec(t);\n\t\tif (spec) order.set(t, spec.rank ?? DEFAULT_MARK_RANK);\n\t}\n\treturn order;\n}\n\n/**\n * Wraps already-rendered inner HTML in its marks. Style-based marks\n * (`toHTMLStyle`) are merged into a single span via `wrapStyleSpan`; tag-based\n * marks (`toHTMLString`) then wrap the result in rank order. The inner HTML is\n * emitted verbatim (callers pre-escape text; rendered inline-node HTML must not\n * be re-escaped).\n */\nfunction wrapMarks(\n\tinnerHTML: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tmarkOrder: Map<string, number> | undefined,\n\texportCtx: HTMLExportContext | undefined,\n\twrapStyleSpan: (html: string, declarations: string) => string,\n): string {\n\tif (marks.length === 0) return innerHTML;\n\n\tconst order: Map<string, number> = markOrder ?? buildMarkOrder(registry);\n\tconst sortedMarks: Mark[] = [...marks].sort(\n\t\t(a, b) => (order.get(a.type) ?? DEFAULT_MARK_RANK) - (order.get(b.type) ?? DEFAULT_MARK_RANK),\n\t);\n\n\tconst styleParts: string[] = [];\n\tconst tagMarks: Mark[] = [];\n\n\tfor (const mark of sortedMarks) {\n\t\tconst markSpec: MarkSpec | undefined = registry.getMarkSpec(mark.type);\n\t\tif (markSpec?.toHTMLStyle) {\n\t\t\tconst style: string | null = markSpec.toHTMLStyle(mark);\n\t\t\tif (style) {\n\t\t\t\tstyleParts.push(style);\n\t\t\t}\n\t\t} else {\n\t\t\ttagMarks.push(mark);\n\t\t}\n\t}\n\n\t// Wrap with the merged style span first (closest to content).\n\tlet html: string = innerHTML;\n\tif (styleParts.length > 0) {\n\t\thtml = wrapStyleSpan(html, styleParts.join('; '));\n\t}\n\n\t// Then wrap with tag-based marks in rank order.\n\tfor (const mark of tagMarks) {\n\t\tconst markSpec: MarkSpec | undefined = registry.getMarkSpec(mark.type);\n\t\tif (markSpec?.toHTMLString) {\n\t\t\thtml = markSpec.toHTMLString(mark, html, exportCtx);\n\t\t}\n\t}\n\n\treturn html;\n}\n\n/**\n * Shared text mark-serialization core: escapes `text`, then delegates to\n * {@link wrapMarks}. The two public entry points differ only in how the merged\n * style declarations become a `<span>`.\n */\nfunction serializeMarks(\n\ttext: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tmarkOrder: Map<string, number> | undefined,\n\texportCtx: HTMLExportContext | undefined,\n\twrapStyleSpan: (html: string, declarations: string) => string,\n): string {\n\tif (text === '') return '';\n\treturn wrapMarks(escapeHTML(text), marks, registry, markOrder, exportCtx, wrapStyleSpan);\n}\n\n/** Builds the inline-style `<span style>` wrapper used by the style-attribute mode. */\nfunction inlineStyleSpanWrapper(\n\texportCtx: HTMLExportContext | undefined,\n): (html: string, declarations: string) => string {\n\treturn (html, declarations) => {\n\t\tconst attr: string = exportCtx ? exportCtx.styleAttr(declarations) : ` style=\"${declarations}\"`;\n\t\treturn attr ? `<span${attr}>${html}</span>` : html;\n\t};\n}\n\n/** Builds the `<span class>` wrapper used by the CSS-class mode. */\nfunction classSpanWrapper(\n\tcollector: CSSClassCollector,\n): (html: string, declarations: string) => string {\n\treturn (html, declarations) =>\n\t\t`<span class=\"${collector.getClassName(declarations)}\">${html}</span>`;\n}\n\n/**\n * Serializes text with marks to HTML.\n * Style-based marks (`toHTMLStyle`) are merged into a single `<span style=\"...\">`.\n * Tag-based marks (`toHTMLString`) wrap the content in rank order.\n */\nexport function serializeMarksToHTML(\n\ttext: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tmarkOrder?: Map<string, number>,\n\texportCtx?: HTMLExportContext,\n): string {\n\treturn serializeMarks(\n\t\ttext,\n\t\tmarks,\n\t\tregistry,\n\t\tmarkOrder,\n\t\texportCtx,\n\t\tinlineStyleSpanWrapper(exportCtx),\n\t);\n}\n\n/**\n * Wraps an already-rendered inline-node HTML fragment (e.g. `<img>`) in its marks\n * using inline-style spans, mirroring {@link serializeMarksToHTML} but without\n * escaping the fragment. Lets a linked inline image export as `<a …><img …></a>`.\n */\nexport function serializeInlineNodeMarksToHTML(\n\tinnerHTML: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tmarkOrder?: Map<string, number>,\n\texportCtx?: HTMLExportContext,\n): string {\n\treturn wrapMarks(\n\t\tinnerHTML,\n\t\tmarks,\n\t\tregistry,\n\t\tmarkOrder,\n\t\texportCtx,\n\t\tinlineStyleSpanWrapper(exportCtx),\n\t);\n}\n\n/**\n * Serializes text with marks to HTML using CSS class names instead of inline styles.\n * Style-based marks (`toHTMLStyle`) are collected into a `CSSClassCollector` and emitted\n * as `<span class=\"...\">`. Tag-based marks (`toHTMLString`) wrap identically to the inline path.\n */\nexport function serializeMarksToClassHTML(\n\ttext: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tcollector: CSSClassCollector,\n\tmarkOrder?: Map<string, number>,\n\texportCtx?: HTMLExportContext,\n): string {\n\treturn serializeMarks(text, marks, registry, markOrder, exportCtx, classSpanWrapper(collector));\n}\n\n/**\n * Wraps an already-rendered inline-node HTML fragment in its marks using\n * CSS-class spans, mirroring {@link serializeMarksToClassHTML} but without\n * escaping the fragment.\n */\nexport function serializeInlineNodeMarksToClassHTML(\n\tinnerHTML: string,\n\tmarks: readonly Mark[],\n\tregistry: SchemaRegistry,\n\tcollector: CSSClassCollector,\n\tmarkOrder?: Map<string, number>,\n\texportCtx?: HTMLExportContext,\n): string {\n\treturn wrapMarks(innerHTML, marks, registry, markOrder, exportCtx, classSpanWrapper(collector));\n}\n","/**\n * DocumentSerializer: converts an immutable Document into sanitized HTML.\n * Pure functions — operates on Document/SchemaRegistry, no class state.\n */\n\nimport { isNodeOfType } from '../model/AttrRegistry.js';\nimport type { BlockNode, Document, InlineNode, TextNode } from '../model/Document.js';\nimport {\n\tgetBlockChildren,\n\tgetInlineChildren,\n\tisInlineNode,\n\tisLeafBlock,\n\tisTextNode,\n\tmarkSetsEqual,\n} from '../model/Document.js';\nimport { SAFE_URI_REGEXP, escapeAttr, escapeHTML, normalizeHTMLId } from '../model/HTMLUtils.js';\nimport type { HTMLExportContext } from '../model/NodeSpec.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { isSafeBlockId } from './BlockIdHTML.js';\nimport { CSSClassCollector } from './CSSClassCollector.js';\nimport type { ContentCSSResult, SerializeOptions } from './ContentHTMLTypes.js';\nimport { preserveHTMLIdSanitizeConfig, sanitizeHTML } from './HTMLSanitization.js';\nimport {\n\tbuildMarkOrder,\n\tserializeInlineNodeMarksToClassHTML,\n\tserializeInlineNodeMarksToHTML,\n\tserializeMarksToClassHTML,\n\tserializeMarksToHTML,\n} from './MarkSerializer.js';\n\n/** Internal context threaded through all serialization helpers. */\ninterface SerializerContext {\n\treadonly registry?: SchemaRegistry;\n\treadonly collector?: CSSClassCollector;\n\treadonly exportCtx?: HTMLExportContext;\n\t/** Resolved from {@link SerializeOptions.includeBlockIds}; defaults to `true`. */\n\treadonly includeBlockIds: boolean;\n}\n\n/** Known-safe alignment values accepted by the serializer (defense-in-depth). */\nexport const VALID_ALIGNMENTS: ReadonlySet<string> = new Set(['start', 'center', 'end', 'justify']);\n\n/** Legacy physical → logical alignment mapping (mirrors DocumentParser). */\nconst LEGACY_ALIGNMENT_MAP: Readonly<Record<string, string>> = { left: 'start', right: 'end' };\n\n/** Known-safe direction values (defense-in-depth). `auto` is excluded — it's the default. */\nexport const VALID_DIRECTIONS: ReadonlySet<string> = new Set(['ltr', 'rtl']);\n\n/** Creates an HTMLExportContext for inline style mode. */\nfunction createInlineExportContext(): HTMLExportContext {\n\treturn {\n\t\tstyleAttr(declarations: string): string {\n\t\t\tif (!declarations) return '';\n\t\t\treturn ` style=\"${declarations}\"`;\n\t\t},\n\t};\n}\n\n/** Creates an HTMLExportContext for CSS class mode. */\nfunction createClassExportContext(collector: CSSClassCollector): HTMLExportContext {\n\treturn {\n\t\tstyleAttr(declarations: string): string {\n\t\t\tif (!declarations) return '';\n\t\t\tconst className: string = collector.getClassName(declarations);\n\t\t\treturn ` class=\"${className}\"`;\n\t\t},\n\t};\n}\n\n/**\n * Injects or merges an attribute into the first opening tag of an HTML fragment.\n * Values are expected to be pre-escaped by the caller.\n */\nfunction injectAttrIntoFirstTag(html: string, attr: string, value: string): string {\n\tconst firstTagRange: { start: number; end: number } | undefined = findFirstOpeningTagRange(html);\n\tif (!firstTagRange) return html;\n\tconst firstTag: string = html.slice(firstTagRange.start, firstTagRange.end + 1);\n\tconst pattern: RegExp = new RegExp(`\\\\s${attr}\\\\s*=\\\\s*(\\\"([^\\\"]*)\\\"|'([^']*)')`);\n\tconst existing: RegExpMatchArray | null = firstTag.match(pattern);\n\tif (existing) {\n\t\tconst existingValue: string = existing[2] ?? existing[3] ?? '';\n\t\tif (attr === 'style' && /(?:^|;)\\s*text-align\\s*:/i.test(existingValue)) {\n\t\t\treturn html;\n\t\t}\n\t\tconst sep: string = attr === 'style' ? '; ' : ' ';\n\t\tconst mergedAttr: string = ` ${attr}=\"${existingValue}${sep}${value}\"`;\n\t\tconst nextFirstTag: string = firstTag.replace(pattern, mergedAttr);\n\t\treturn `${html.slice(0, firstTagRange.start)}${nextFirstTag}${html.slice(firstTagRange.end + 1)}`;\n\t}\n\tconst isSelfClosing: boolean = firstTag.endsWith('/>');\n\tconst injectedFirstTag: string = isSelfClosing\n\t\t? `${firstTag.slice(0, -2)} ${attr}=\"${value}\"/>`\n\t\t: `${firstTag.slice(0, -1)} ${attr}=\"${value}\">`;\n\treturn `${html.slice(0, firstTagRange.start)}${injectedFirstTag}${html.slice(firstTagRange.end + 1)}`;\n}\n\n/** Replaces an attribute on the first opening tag, or adds it when absent. */\nfunction setAttrOnFirstTag(html: string, attr: string, value: string): string {\n\tconst firstTagRange: { start: number; end: number } | undefined = findFirstOpeningTagRange(html);\n\tif (!firstTagRange) return html;\n\tconst firstTag: string = html.slice(firstTagRange.start, firstTagRange.end + 1);\n\tconst replacement: string = ` ${attr}=\"${value}\"`;\n\tconst withoutExisting: string = removeAttributes(firstTag, attr);\n\tconst isSelfClosing: boolean = withoutExisting.endsWith('/>');\n\tconst nextFirstTag: string = isSelfClosing\n\t\t? `${withoutExisting.slice(0, -2)}${replacement}/>`\n\t\t: `${withoutExisting.slice(0, -1)}${replacement}>`;\n\treturn `${html.slice(0, firstTagRange.start)}${nextFirstTag}${html.slice(firstTagRange.end + 1)}`;\n}\n\n/** Removes real attributes by name without matching attribute-like text inside quoted values. */\nfunction removeAttributes(openingTag: string, attr: string): string {\n\tconst ranges: { readonly start: number; readonly end: number }[] = [];\n\tlet index = 1;\n\n\t// Skip the tag name.\n\twhile (\n\t\tindex < openingTag.length &&\n\t\t!isTagWhitespace(openingTag[index] ?? '') &&\n\t\topeningTag[index] !== '>' &&\n\t\topeningTag[index] !== '/'\n\t) {\n\t\tindex++;\n\t}\n\n\twhile (index < openingTag.length) {\n\t\twhile (isTagWhitespace(openingTag[index] ?? '')) index++;\n\t\tif (openingTag[index] === '>' || openingTag[index] === undefined) break;\n\t\tif (openingTag[index] === '/' && openingTag[index + 1] === '>') break;\n\n\t\tconst start: number = index;\n\t\twhile (\n\t\t\tindex < openingTag.length &&\n\t\t\t!isTagWhitespace(openingTag[index] ?? '') &&\n\t\t\topeningTag[index] !== '=' &&\n\t\t\topeningTag[index] !== '>' &&\n\t\t\topeningTag[index] !== '/'\n\t\t) {\n\t\t\tindex++;\n\t\t}\n\t\tconst name: string = openingTag.slice(start, index);\n\t\tif (name === '') {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\twhile (isTagWhitespace(openingTag[index] ?? '')) index++;\n\t\tif (openingTag[index] === '=') {\n\t\t\tindex++;\n\t\t\twhile (isTagWhitespace(openingTag[index] ?? '')) index++;\n\t\t\tconst quote: string | undefined = openingTag[index];\n\t\t\tif (quote === '\"' || quote === \"'\") {\n\t\t\t\tindex++;\n\t\t\t\twhile (index < openingTag.length && openingTag[index] !== quote) index++;\n\t\t\t\tif (openingTag[index] === quote) index++;\n\t\t\t} else {\n\t\t\t\twhile (\n\t\t\t\t\tindex < openingTag.length &&\n\t\t\t\t\t!isTagWhitespace(openingTag[index] ?? '') &&\n\t\t\t\t\topeningTag[index] !== '>' &&\n\t\t\t\t\t!(openingTag[index] === '/' && openingTag[index + 1] === '>')\n\t\t\t\t) {\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (name.toLowerCase() === attr.toLowerCase()) ranges.push({ start, end: index });\n\t}\n\n\tlet result: string = openingTag;\n\tfor (let rangeIndex = ranges.length - 1; rangeIndex >= 0; rangeIndex--) {\n\t\tconst range = ranges[rangeIndex];\n\t\tif (range) result = `${result.slice(0, range.start)}${result.slice(range.end)}`;\n\t}\n\treturn result;\n}\n\nfunction isTagWhitespace(character: string): boolean {\n\treturn (\n\t\tcharacter === ' ' ||\n\t\tcharacter === '\\t' ||\n\t\tcharacter === '\\n' ||\n\t\tcharacter === '\\f' ||\n\t\tcharacter === '\\r'\n\t);\n}\n\n/** Applies a validated semantic HTML ID to the first element emitted for a block. */\nexport function setHTMLIdOnFirstTag(html: string, value: unknown): string {\n\tconst htmlId: string | undefined = normalizeHTMLId(value);\n\treturn htmlId ? setAttrOnFirstTag(html, 'id', escapeAttr(htmlId)) : html;\n}\n\n/** Finds the first opening tag range, treating `>` inside quotes as attribute text. */\nfunction findFirstOpeningTagRange(html: string): { start: number; end: number } | undefined {\n\tlet start: number = html.indexOf('<');\n\twhile (start >= 0) {\n\t\tconst nextChar: string | undefined = html[start + 1];\n\t\tif (nextChar && /[A-Za-z]/.test(nextChar)) {\n\t\t\tlet quote: '\"' | \"'\" | undefined;\n\t\t\tfor (let i = start + 2; i < html.length; i++) {\n\t\t\t\tconst char: string = html[i] ?? '';\n\t\t\t\tif (quote) {\n\t\t\t\t\tif (char === quote) quote = undefined;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (char === '\"' || char === \"'\") {\n\t\t\t\t\tquote = char;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (char === '>') {\n\t\t\t\t\treturn { start, end: i };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\tstart = html.indexOf('<', start + 1);\n\t}\n\treturn undefined;\n}\n\n/** Returns the first opening tag of `html` (quote-aware), or `''` if none exists. */\nfunction firstOpeningTag(html: string): string {\n\tconst range: { start: number; end: number } | undefined = findFirstOpeningTagRange(html);\n\tif (!range) return '';\n\treturn html.slice(range.start, range.end + 1);\n}\n\n/**\n * DOMPurify config fragment that controls `data-block-id` in the output.\n *\n * `data-block-id` is a `data-*` attribute, which DOMPurify permits by default\n * (`ALLOW_DATA_ATTR`) regardless of `ALLOWED_ATTR`. Excluding it therefore\n * requires `FORBID_ATTR` — this is the load-bearing strip that guarantees clean\n * output even when a third-party `NodeSpec.toHTML` emits its own id (the central\n * injection in `serializeBlock` is merely skipped). Including it needs no special\n * config; the centrally injected attribute passes as a data-* attribute.\n */\nfunction blockIdSanitizeConfig(includeBlockIds: boolean): {\n\treadonly SANITIZE_DOM: false;\n\treadonly FORBID_ATTR?: string[];\n} {\n\treturn preserveHTMLIdSanitizeConfig(...(includeBlockIds ? [] : ['data-block-id']));\n}\n\n/** Serializes a full document to sanitized HTML, wrapping list items in `<ul>`/`<ol>`. */\nexport function serializeDocumentToHTML(\n\tdoc: Document,\n\tregistry?: SchemaRegistry,\n\toptions?: SerializeOptions,\n): string {\n\tconst includeBlockIds: boolean = options?.includeBlockIds !== false;\n\tconst exportCtx: HTMLExportContext = createInlineExportContext();\n\tconst ctx: SerializerContext = { registry, exportCtx, includeBlockIds };\n\tconst html: string = serializeBlocks(doc.children, ctx);\n\n\tconst allowedTags: string[] = registry ? registry.getAllowedTags() : ['p', 'br', 'div', 'span'];\n\tconst allowedAttrs: string[] = registry ? registry.getAllowedAttrs() : ['style', 'dir', 'id'];\n\n\treturn sanitizeHTML(\n\t\thtml,\n\t\t{\n\t\t\tALLOWED_TAGS: allowedTags,\n\t\t\tALLOWED_ATTR: allowedAttrs,\n\t\t\tALLOWED_URI_REGEXP: SAFE_URI_REGEXP,\n\t\t\t...blockIdSanitizeConfig(includeBlockIds),\n\t\t},\n\t\tregistry,\n\t);\n}\n\n/**\n * Serializes a document to HTML with CSS class names instead of inline styles.\n * Returns the HTML and a collected stylesheet with only the rules actually used.\n */\nexport function serializeDocumentToCSS(\n\tdoc: Document,\n\tregistry?: SchemaRegistry,\n\toptions?: SerializeOptions,\n): ContentCSSResult {\n\tconst includeBlockIds: boolean = options?.includeBlockIds !== false;\n\tconst collector = new CSSClassCollector();\n\tconst exportCtx: HTMLExportContext = createClassExportContext(collector);\n\tconst ctx: SerializerContext = { registry, collector, exportCtx, includeBlockIds };\n\tconst html: string = serializeBlocks(doc.children, ctx);\n\n\tconst allowedTags: string[] = registry ? registry.getAllowedTags() : ['p', 'br', 'div', 'span'];\n\tconst baseAttrs: string[] = registry\n\t\t? registry.getAllowedAttrs()\n\t\t: ['style', 'class', 'dir', 'id'];\n\n\t// In class mode, allow `class` through DOMPurify (it is not a data-* attr, so\n\t// it must be in ALLOWED_ATTR).\n\tconst withClass: string[] = baseAttrs.includes('class')\n\t\t? [...baseAttrs]\n\t\t: [...baseAttrs, 'class'];\n\n\t// Defense-in-depth: strip `style` attribute in class mode to guarantee\n\t// zero inline styles — even from third-party plugins that forgot to use ctx.styleAttr().\n\tconst filteredAttrs: string[] = withClass.filter((attr) => attr !== 'style');\n\n\tconst sanitizedHTML: string = sanitizeHTML(\n\t\thtml,\n\t\t{\n\t\t\tALLOWED_TAGS: allowedTags,\n\t\t\tALLOWED_ATTR: filteredAttrs,\n\t\t\tALLOWED_URI_REGEXP: SAFE_URI_REGEXP,\n\t\t\t...blockIdSanitizeConfig(includeBlockIds),\n\t\t},\n\t\tregistry,\n\t);\n\n\treturn { html: sanitizedHTML, css: collector.toCSS(), styleMap: collector.toStyleMap() };\n}\n\n/** Serializes a sequence of blocks to HTML, grouping consecutive list items into wrappers. */\nfunction serializeBlocks(blocks: readonly BlockNode[], ctx: SerializerContext): string {\n\tconst parts: string[] = [];\n\tlet i = 0;\n\n\twhile (i < blocks.length) {\n\t\tconst block: BlockNode | undefined = blocks[i];\n\t\tif (!block) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isNodeOfType(block, 'list_item')) {\n\t\t\t// Collect consecutive list items\n\t\t\tconst listItems: BlockNode[] = [];\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst item: BlockNode | undefined = blocks[i];\n\t\t\t\tif (!item || !isNodeOfType(item, 'list_item')) break;\n\t\t\t\tlistItems.push(item);\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tparts.push(serializeListGroup(listItems, ctx));\n\t\t} else {\n\t\t\tparts.push(serializeBlock(block, ctx));\n\t\t\ti++;\n\t\t}\n\t}\n\n\treturn parts.join('');\n}\n\n/**\n * Serializes a group of consecutive list items into properly nested `<ul>`/`<ol>` wrappers.\n * Uses a stack-based algorithm to handle indent-based nesting.\n * Produces valid HTML5: nested lists open *inside* the parent `<li>`.\n */\nfunction serializeListGroup(items: readonly BlockNode[], ctx: SerializerContext): string {\n\tconst parts: string[] = [];\n\tconst stack: { tag: string; indent: number }[] = [];\n\n\tfor (let idx = 0; idx < items.length; idx++) {\n\t\tconst item: BlockNode | undefined = items[idx];\n\t\tif (!item) continue;\n\n\t\tconst listType: string = (item.attrs?.listType as string) ?? 'bullet';\n\t\tconst indent: number = (item.attrs?.indent as number) ?? 0;\n\t\tconst tag: string = listType === 'ordered' ? 'ol' : 'ul';\n\t\t// Pop wrapper levels that are deeper than current indent,\n\t\t// or at the same level when the tag type changes\n\t\twhile (stack.length > 0) {\n\t\t\tconst top = stack[stack.length - 1];\n\t\t\tif (!top) break;\n\n\t\t\tif (top.indent > indent) {\n\t\t\t\tparts.push(`</${top.tag}></li>`);\n\t\t\t\tstack.pop();\n\t\t\t} else if (top.indent === indent && top.tag !== tag) {\n\t\t\t\tparts.push(`</${top.tag}></li>`);\n\t\t\t\tstack.pop();\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (stack.length === 0) {\n\t\t\tparts.push(`<${tag}>`);\n\t\t\tstack.push({ tag, indent });\n\t\t} else {\n\t\t\tconst top = stack[stack.length - 1];\n\t\t\tif (top && indent > top.indent) {\n\t\t\t\tparts.push(`<${tag}>`);\n\t\t\t\tstack.push({ tag, indent });\n\t\t\t}\n\t\t}\n\n\t\tconst content: string = serializeBlock(item, ctx);\n\n\t\t// Look ahead: if the next item is deeper, strip </li> so the nested\n\t\t// list opens inside this <li> (valid HTML5 nesting).\n\t\tconst nextItem: BlockNode | undefined = items[idx + 1];\n\t\tconst nextIndent: number | undefined = nextItem\n\t\t\t? ((nextItem.attrs?.indent as number) ?? 0)\n\t\t\t: undefined;\n\n\t\tif (nextIndent !== undefined && nextIndent > indent) {\n\t\t\tparts.push(stripTrailingLiClose(content));\n\t\t} else {\n\t\t\tparts.push(content);\n\t\t}\n\t}\n\n\t// Close all remaining open wrappers\n\twhile (stack.length > 0) {\n\t\tconst top = stack.pop();\n\t\tif (!top) break;\n\t\tparts.push(`</${top.tag}>`);\n\t\tif (stack.length > 0) {\n\t\t\tparts.push('</li>');\n\t\t}\n\t}\n\n\treturn parts.join('');\n}\n\n/** Removes the trailing `</li>` from serialized list item HTML. */\nfunction stripTrailingLiClose(html: string): string {\n\tconst suffix = '</li>';\n\tif (html.endsWith(suffix)) {\n\t\treturn html.slice(0, -suffix.length);\n\t}\n\treturn html;\n}\n\n/** Serializes a single block to HTML using its NodeSpec. */\nfunction serializeBlock(block: BlockNode, ctx: SerializerContext): string {\n\tconst content: string = isLeafBlock(block)\n\t\t? serializeInlineContent(block, ctx)\n\t\t: serializeBlocks(getBlockChildren(block), ctx);\n\tconst spec = ctx.registry?.getNodeSpec(block.type);\n\n\tlet html: string;\n\tif (spec?.toHTML) {\n\t\thtml = spec.toHTML(block, content, ctx.exportCtx);\n\t} else {\n\t\thtml = `<p>${content || '<br>'}</p>`;\n\t}\n\n\t// Centrally inject `data-block-id` so each `NodeSpec.toHTML` is relieved of\n\t// the responsibility — and the round-trip identity contract holds for every\n\t// block type, including ones added by future plugins. The serializer's\n\t// allowlist passes `data-block-id` through DOMPurify. Skip if the spec\n\t// already emits one (mirrors the existing `dir` defense-in-depth pattern).\n\t// `escapeAttr` is defense-in-depth — `isSafeBlockId` already excludes any\n\t// character that would need escaping. Skipped entirely when the caller opted\n\t// out via `includeBlockIds: false`; the allowlist strip is the guarantee.\n\tif (ctx.includeBlockIds && isSafeBlockId(block.id)) {\n\t\tif (!firstOpeningTag(html).includes(' data-block-id=')) {\n\t\t\thtml = injectAttrIntoFirstTag(html, 'data-block-id', escapeAttr(block.id));\n\t\t}\n\t}\n\n\t// HTML IDs are semantic, document-local targets and therefore independent of\n\t// the editor's internal `data-block-id` wire identity. The model value wins\n\t// over a NodeSpec-provided `id` so serialization can never emit duplicates.\n\thtml = setHTMLIdOnFirstTag(html, block.htmlId);\n\n\t// Inject alignment into the first opening tag (validated against allowlist).\n\tconst rawAlign: string | undefined = (block.attrs as Record<string, unknown>)?.align as\n\t\t| string\n\t\t| undefined;\n\tconst align: string | undefined = rawAlign\n\t\t? (LEGACY_ALIGNMENT_MAP[rawAlign] ?? rawAlign)\n\t\t: undefined;\n\tif (align && align !== 'start' && VALID_ALIGNMENTS.has(align)) {\n\t\tconst safeAlign: string = escapeAttr(align);\n\t\tif (ctx.collector) {\n\t\t\tconst className: string = ctx.collector.getAlignmentClassName(align);\n\t\t\thtml = injectAttrIntoFirstTag(html, 'class', escapeAttr(className));\n\t\t} else {\n\t\t\thtml = injectAttrIntoFirstTag(html, 'style', `text-align: ${safeAlign}`);\n\t\t}\n\t}\n\n\t// Defense-in-depth: inject dir into the first opening tag if not already present.\n\t// NodeSpec toHTML may already inject it; this ensures it survives even without a plugin.\n\tconst dir: string | undefined = (block.attrs as Record<string, unknown>)?.dir as\n\t\t| string\n\t\t| undefined;\n\tif (dir && VALID_DIRECTIONS.has(dir)) {\n\t\tif (!firstOpeningTag(html).includes(' dir=')) {\n\t\t\thtml = injectAttrIntoFirstTag(html, 'dir', escapeAttr(dir));\n\t\t}\n\t}\n\n\treturn html;\n}\n\n/** Serializes inline children (TextNode + InlineNode) of a block. */\nfunction serializeInlineContent(block: BlockNode, ctx: SerializerContext): string {\n\tconst children: readonly (TextNode | InlineNode)[] = getInlineChildren(block);\n\tconst merged: readonly (TextNode | InlineNode)[] = mergeAdjacentTextNodes(children);\n\tconst parts: string[] = [];\n\tconst markOrder: Map<string, number> | undefined = ctx.registry\n\t\t? buildMarkOrder(ctx.registry)\n\t\t: undefined;\n\n\tfor (const child of merged) {\n\t\tif (isInlineNode(child)) {\n\t\t\tconst inlineSpec = ctx.registry?.getInlineNodeSpec(child.inlineType);\n\t\t\tif (inlineSpec?.toHTMLString) {\n\t\t\t\tconst inlineHTML: string = inlineSpec.toHTMLString(child);\n\t\t\t\t// Wrap the atomic node in its marks (e.g. a linked inline image → <a><img></a>).\n\t\t\t\tif (ctx.registry && child.marks.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\tctx.collector\n\t\t\t\t\t\t\t? serializeInlineNodeMarksToClassHTML(\n\t\t\t\t\t\t\t\t\tinlineHTML,\n\t\t\t\t\t\t\t\t\tchild.marks,\n\t\t\t\t\t\t\t\t\tctx.registry,\n\t\t\t\t\t\t\t\t\tctx.collector,\n\t\t\t\t\t\t\t\t\tmarkOrder,\n\t\t\t\t\t\t\t\t\tctx.exportCtx,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: serializeInlineNodeMarksToHTML(\n\t\t\t\t\t\t\t\t\tinlineHTML,\n\t\t\t\t\t\t\t\t\tchild.marks,\n\t\t\t\t\t\t\t\t\tctx.registry,\n\t\t\t\t\t\t\t\t\tmarkOrder,\n\t\t\t\t\t\t\t\t\tctx.exportCtx,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tparts.push(inlineHTML);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (ctx.registry && ctx.collector) {\n\t\t\tparts.push(\n\t\t\t\tserializeMarksToClassHTML(\n\t\t\t\t\tchild.text,\n\t\t\t\t\tchild.marks,\n\t\t\t\t\tctx.registry,\n\t\t\t\t\tctx.collector,\n\t\t\t\t\tmarkOrder,\n\t\t\t\t\tctx.exportCtx,\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (ctx.registry) {\n\t\t\tparts.push(\n\t\t\t\tserializeMarksToHTML(child.text, child.marks, ctx.registry, markOrder, ctx.exportCtx),\n\t\t\t);\n\t\t} else if (child.text !== '') {\n\t\t\tparts.push(escapeHTML(child.text));\n\t\t}\n\t}\n\n\treturn parts.join('');\n}\n\n/**\n * Merges adjacent TextNodes that share identical mark sets.\n * InlineNodes act as merge boundaries.\n */\nfunction mergeAdjacentTextNodes(\n\tchildren: readonly (TextNode | InlineNode)[],\n): readonly (TextNode | InlineNode)[] {\n\tif (children.length <= 1) return children;\n\n\tconst result: (TextNode | InlineNode)[] = [];\n\n\tfor (const child of children) {\n\t\tif (isInlineNode(child)) {\n\t\t\tresult.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst prev: TextNode | InlineNode | undefined = result[result.length - 1];\n\t\tif (prev && isTextNode(prev) && markSetsEqual(prev.marks, child.marks)) {\n\t\t\tresult[result.length - 1] = {\n\t\t\t\ttype: 'text',\n\t\t\t\ttext: prev.text + child.text,\n\t\t\t\tmarks: prev.marks,\n\t\t\t};\n\t\t} else {\n\t\t\tresult.push(child);\n\t\t}\n\t}\n\n\treturn result;\n}\n","/** Shared, DOM-free table-dimension bounds and normalization. */\n\n/** Smallest supported table column width or row minimum height, in CSS pixels. */\nexport const MIN_TABLE_DIMENSION_PX = 1;\n\n/** Largest supported table column width or row minimum height, in CSS pixels. */\nexport const MAX_TABLE_DIMENSION_PX = 10_000;\n\n/**\n * Normalizes a finite numeric table dimension into the requested bounded range.\n * Non-numeric and non-finite input is rejected with `null`.\n */\nexport function normalizeTableDimensionPx(\n\tvalue: unknown,\n\tminimum = MIN_TABLE_DIMENSION_PX,\n\tmaximum = MAX_TABLE_DIMENSION_PX,\n): number | null {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) return null;\n\n\tconst normalizedMinimum: number = normalizeBound(minimum, MIN_TABLE_DIMENSION_PX);\n\tconst normalizedMaximum: number = Math.max(\n\t\tnormalizedMinimum,\n\t\tnormalizeBound(maximum, MAX_TABLE_DIMENSION_PX),\n\t);\n\treturn Math.min(normalizedMaximum, Math.max(normalizedMinimum, value));\n}\n\nfunction normalizeBound(value: number, fallback: number): number {\n\tif (!Number.isFinite(value)) return fallback;\n\treturn Math.min(MAX_TABLE_DIMENSION_PX, Math.max(MIN_TABLE_DIMENSION_PX, value));\n}\n","/**\n * Safe table-dimension parsing and HTML serialization helpers.\n *\n * Table dimensions are stored as finite CSS-pixel numbers. HTML import accepts\n * notectl's numeric wire attributes and a deliberately small conventional\n * subset: unitless numeric presentation attributes and exact `px` CSS values.\n * Arbitrary CSS expressions never cross into document attributes.\n */\n\nimport type { HTMLExportContext } from '../model/NodeSpec.js';\nimport {\n\tMAX_TABLE_DIMENSION_PX,\n\tMIN_TABLE_DIMENSION_PX,\n\tnormalizeTableDimensionPx,\n} from '../model/TableDimensions.js';\n\n/** Canonical HTML metadata carrying one logical column's width in CSS pixels. */\nexport const TABLE_COLUMN_WIDTH_DATA_ATTRIBUTE = 'data-notectl-width-px';\n\n/** Canonical HTML metadata carrying one logical row's minimum height in CSS pixels. */\nexport const TABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE = 'data-notectl-min-height-px';\n\n/** Defensive upper bound for a serialized `<col>` vector. */\nexport const MAX_SERIALIZED_TABLE_COLUMNS = 1_000;\n\n/** HTML's upper bound for a `<col span>` value. */\nexport const MAX_TABLE_COLUMN_SPAN = 1_000;\n\nconst DECIMAL_NUMBER_RE = /^\\d+(?:\\.\\d+)?$/;\nconst CSS_PX_RE = /^(\\d+(?:\\.\\d+)?)px$/i;\nconst POSITIVE_INTEGER_RE = /^\\d+$/;\n\n/** Returns a bounded, finite CSS-pixel value without clamping untrusted serialized input. */\nexport function normalizeSerializedTableDimensionPx(value: unknown): number | undefined {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) return undefined;\n\tif (value < MIN_TABLE_DIMENSION_PX || value > MAX_TABLE_DIMENSION_PX) return undefined;\n\treturn normalizeTableDimensionPx(value) ?? undefined;\n}\n\n/** Parses notectl's canonical numeric `data-notectl-*-px` value. */\nexport function parseTableDimensionMetadata(raw: string | null): number | undefined {\n\treturn parseDecimal(raw, false);\n}\n\n/** Parses a conventional numeric or `px` presentation attribute. */\nexport function parseConventionalTableDimension(raw: string | null): number | undefined {\n\treturn parseDecimal(raw, true);\n}\n\n/** Parses an exact CSS `<length>` in pixels. Other units and expressions are rejected. */\nexport function parseCSSTableDimension(raw: string | null): number | undefined {\n\tif (raw === null) return undefined;\n\tconst match: RegExpMatchArray | null = raw.trim().match(CSS_PX_RE);\n\treturn match?.[1] ? parseBoundedNumber(match[1]) : undefined;\n}\n\n/**\n * Reads a dimension from an element using deterministic precedence:\n * notectl metadata, exact CSS properties, then a conventional HTML attribute.\n */\nexport function readTableDimensionPx(\n\telement: HTMLElement,\n\tmetadataAttribute: string,\n\tcssProperties: readonly string[],\n\tconventionalAttribute: string,\n): number | undefined {\n\tconst metadata: number | undefined = parseTableDimensionMetadata(\n\t\telement.getAttribute(metadataAttribute),\n\t);\n\tif (metadata !== undefined) return metadata;\n\n\tfor (const property of cssProperties) {\n\t\tconst cssValue: number | undefined = parseCSSTableDimension(\n\t\t\telement.style.getPropertyValue(property),\n\t\t);\n\t\tif (cssValue !== undefined) return cssValue;\n\t}\n\n\treturn parseConventionalTableDimension(element.getAttribute(conventionalAttribute));\n}\n\n/** Parses a bounded positive integer HTML span, falling back to one when malformed. */\nexport function parseTableColumnSpan(raw: string | null): number {\n\tif (raw === null) return 1;\n\tconst normalized: string = raw.trim();\n\tif (!POSITIVE_INTEGER_RE.test(normalized)) return 1;\n\tconst value: number = Number(normalized);\n\tif (!Number.isSafeInteger(value) || value < 1 || value > MAX_TABLE_COLUMN_SPAN) return 1;\n\treturn value;\n}\n\n/**\n * Normalizes an untrusted logical column-width vector. Invalid entries become\n * automatic (`null`); a vector with no explicit width is omitted.\n */\nexport function normalizeTableColumnWidthsPx(\n\tvalue: unknown,\n): readonly (number | null)[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst widths: (number | null)[] = Array.from(\n\t\tvalue.slice(0, MAX_SERIALIZED_TABLE_COLUMNS),\n\t\t(entry: unknown): number | null => normalizeSerializedTableDimensionPx(entry) ?? null,\n\t);\n\treturn widths.some((width: number | null): boolean => width !== null) ? widths : undefined;\n}\n\n/** True when a table column-width vector contains at least one safe explicit value. */\nexport function hasExplicitTableColumnWidth(value: unknown): boolean {\n\treturn normalizeTableColumnWidthsPx(value) !== undefined;\n}\n\n/**\n * Emits canonical metadata plus mode-aware visual CSS for one safe dimension.\n * `ctx.styleAttr()` remains the sole generated-style path in class/CSP mode.\n */\nexport function serializeTableDimensionAttrs(\n\tmetadataAttribute: string,\n\tcssProperty: 'width' | 'height',\n\tvalue: unknown,\n\tctx?: HTMLExportContext,\n): string {\n\tconst dimension: number | undefined = normalizeSerializedTableDimensionPx(value);\n\tif (dimension === undefined) return '';\n\tconst declarations = `${cssProperty}: ${String(dimension)}px`;\n\tconst styleAttribute: string = ctx?.styleAttr(declarations) ?? ` style=\"${declarations}\"`;\n\treturn ` ${metadataAttribute}=\"${String(dimension)}\"${styleAttribute}`;\n}\n\nfunction parseDecimal(raw: string | null, allowPx: boolean): number | undefined {\n\tif (raw === null) return undefined;\n\tconst normalized: string = raw.trim();\n\tif (DECIMAL_NUMBER_RE.test(normalized)) return parseBoundedNumber(normalized);\n\tif (!allowPx) return undefined;\n\tconst match: RegExpMatchArray | null = normalized.match(CSS_PX_RE);\n\treturn match?.[1] ? parseBoundedNumber(match[1]) : undefined;\n}\n\nfunction parseBoundedNumber(raw: string): number | undefined {\n\tconst value: number = Number(raw);\n\treturn normalizeSerializedTableDimensionPx(value);\n}\n"],"mappings":"0SAkBA,IAAa,EAAgC,wBAG7C,SAAgB,EAAc,GAC7B,OAAO,EAAsB,KAAK,EACnC,CAWA,SAAgB,EAAa,EAAa,GACzC,MAAM,EAAqB,EAAG,aAAa,iBAC3C,GAAK,GACA,EAAc,KACf,EAAK,IAAI,GAEb,OADA,EAAK,IAAI,GACF,EAAQ,EAChB,CCtBA,SAAS,EAAsB,GAC9B,OAAO,EACL,MAAM,KACN,IAAK,GAAM,EAAE,QACb,OAAQ,GAAM,EAAE,OAAS,GACzB,OACA,KAAK,KACR,CAWA,SAAS,EAAU,GAClB,IAAI,EAToB,WAUxB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IACjC,GAAQ,EAAM,WAAW,GACzB,EAAO,KAAK,KAAK,EAVD,UAcjB,OADyB,IAAS,GAClB,SAnCC,IAmCmB,SAjCb,EAiCuC,IAC/D,CASA,IAAa,EAAb,MAEC,wBAAiD,IAAI,IAErD,0BAA2C,IAAI,IAM/C,YAAA,CAAa,GACZ,MAAM,EAAqB,EAAsB,GAC3C,EAA+B,KAAK,SAAS,IAAI,GACvD,GAAI,EAAU,OAAO,EAErB,IAAI,EAAe,EAAU,GACzB,EA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