@notectl/core 2.3.6 → 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 (401) 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/{ColorGrid-D0vLHsG6.mjs → ColorGrid-DAs0--ty.mjs} +2 -2
  22. package/dist/chunks/{ColorGrid-D0vLHsG6.mjs.map → ColorGrid-DAs0--ty.mjs.map} +1 -1
  23. package/dist/chunks/ColorPickerPopup-B6340f3p.mjs +2 -0
  24. package/dist/chunks/{ColorPickerPopup-_C5JZhki.mjs.map → ColorPickerPopup-B6340f3p.mjs.map} +1 -1
  25. package/dist/chunks/{ColorValidation-B9d_umnf.mjs → ColorValidation-ZBKZ_gTr.mjs} +2 -2
  26. package/dist/chunks/ColorValidation-ZBKZ_gTr.mjs.map +1 -0
  27. package/dist/chunks/Commands-DBBCAYBn.mjs +2 -0
  28. package/dist/chunks/Commands-DBBCAYBn.mjs.map +1 -0
  29. package/dist/chunks/{ContentModel-Bzmzeqwg.mjs → ContentModel-BLC3Tez8.mjs} +2 -2
  30. package/dist/chunks/{ContentModel-Bzmzeqwg.mjs.map → ContentModel-BLC3Tez8.mjs.map} +1 -1
  31. package/dist/chunks/{CursorMarks-dx51OGBf.mjs → CursorMarks-CqHLzGNI.mjs} +2 -2
  32. package/dist/chunks/{CursorMarks-dx51OGBf.mjs.map → CursorMarks-CqHLzGNI.mjs.map} +1 -1
  33. package/dist/chunks/{Decoration-BwhoA4MU.mjs → Decoration-BoFcdSXk.mjs} +2 -2
  34. package/dist/chunks/{Decoration-BwhoA4MU.mjs.map → Decoration-BoFcdSXk.mjs.map} +1 -1
  35. package/dist/chunks/{DirectionDetection-ZrkMhyaL.mjs → DirectionDetection-a-1iksmh.mjs} +2 -2
  36. package/dist/chunks/{DirectionDetection-ZrkMhyaL.mjs.map → DirectionDetection-a-1iksmh.mjs.map} +1 -1
  37. package/dist/chunks/{Document-D_2cIBJG.mjs → Document-ssR6hBzG.mjs} +2 -2
  38. package/dist/chunks/{Document-D_2cIBJG.mjs.map → Document-ssR6hBzG.mjs.map} +1 -1
  39. package/dist/chunks/DocumentParser-BKUrtgw1.mjs +2 -0
  40. package/dist/chunks/DocumentParser-BKUrtgw1.mjs.map +1 -0
  41. package/dist/chunks/FontPlugin-BcXNFqqO.mjs +2 -0
  42. package/dist/chunks/FontPlugin-BcXNFqqO.mjs.map +1 -0
  43. package/dist/chunks/FontSizePlugin-BQ9Aj8cT.mjs +2 -0
  44. package/dist/chunks/FontSizePlugin-BQ9Aj8cT.mjs.map +1 -0
  45. package/dist/chunks/FormulaPlugin-Bw_sO_lq.mjs +2 -0
  46. package/dist/chunks/FormulaPlugin-Bw_sO_lq.mjs.map +1 -0
  47. package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs +2 -0
  48. package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs.map +1 -0
  49. package/dist/chunks/HTMLUtils-DTpsjZyK.mjs +2 -0
  50. package/dist/chunks/HTMLUtils-DTpsjZyK.mjs.map +1 -0
  51. package/dist/chunks/{HardBreakPlugin-CC4rntSX.mjs → HardBreakPlugin-svNnJ9Xj.mjs} +2 -2
  52. package/dist/chunks/{HardBreakPlugin-CC4rntSX.mjs.map → HardBreakPlugin-svNnJ9Xj.mjs.map} +1 -1
  53. package/dist/chunks/HeadingPlugin-B7EfynaH.mjs +2 -0
  54. package/dist/chunks/HeadingPlugin-B7EfynaH.mjs.map +1 -0
  55. package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs +2 -0
  56. package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs.map +1 -0
  57. package/dist/chunks/HorizontalRulePlugin-CQ5NT2Mo.mjs +2 -0
  58. package/dist/chunks/{HorizontalRulePlugin-CxmUMM34.mjs.map → HorizontalRulePlugin-CQ5NT2Mo.mjs.map} +1 -1
  59. package/dist/chunks/ImagePlugin-BzLvPXGo.mjs +2 -0
  60. package/dist/chunks/ImagePlugin-BzLvPXGo.mjs.map +1 -0
  61. package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs +2 -0
  62. package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs.map +1 -0
  63. package/dist/chunks/InlineStyleMarkSpec-BhfGgfH9.mjs +2 -0
  64. package/dist/chunks/InlineStyleMarkSpec-BhfGgfH9.mjs.map +1 -0
  65. package/dist/chunks/{LinkPlugin-BwXDGHPe.mjs → LinkPlugin-BuzrXo2c.mjs} +2 -2
  66. package/dist/chunks/{LinkPlugin-BwXDGHPe.mjs.map → LinkPlugin-BuzrXo2c.mjs.map} +1 -1
  67. package/dist/chunks/ListPlugin-DTgpvBEt.mjs +2 -0
  68. package/dist/chunks/{ListPlugin-DSFPSWQC.mjs.map → ListPlugin-DTgpvBEt.mjs.map} +1 -1
  69. package/dist/chunks/MarkCommands-C0ps9h0z.mjs +2 -0
  70. package/dist/chunks/MarkCommands-C0ps9h0z.mjs.map +1 -0
  71. package/dist/chunks/MarkdownHTMLRegistry-BunUDiza.mjs +2 -0
  72. package/dist/chunks/{MarkdownHTMLRegistry-CISsC0lH.mjs.map → MarkdownHTMLRegistry-BunUDiza.mjs.map} +1 -1
  73. package/dist/chunks/{MarkdownParser-D1d9zB0R.mjs → MarkdownParser-CvYOvU3d.mjs} +2 -2
  74. package/dist/chunks/{MarkdownParser-D1d9zB0R.mjs.map → MarkdownParser-CvYOvU3d.mjs.map} +1 -1
  75. package/dist/chunks/MarkdownSerializer-CdUBWWGI.mjs +2 -0
  76. package/dist/chunks/MarkdownSerializer-CdUBWWGI.mjs.map +1 -0
  77. package/dist/chunks/NavigationQueries-CaKfccu7.mjs +2 -0
  78. package/dist/chunks/NavigationQueries-CaKfccu7.mjs.map +1 -0
  79. package/dist/chunks/NodeResolver-F4RtpoEd.mjs +2 -0
  80. package/dist/chunks/NodeResolver-F4RtpoEd.mjs.map +1 -0
  81. package/dist/chunks/{NodeSelectionCommands-DK3iEh18.mjs → NodeSelectionCommands-B0Sb4ux4.mjs} +2 -2
  82. package/dist/chunks/{NodeSelectionCommands-DK3iEh18.mjs.map → NodeSelectionCommands-B0Sb4ux4.mjs.map} +1 -1
  83. package/dist/chunks/PluginHelpers-B3gk3VB3.mjs +2 -0
  84. package/dist/chunks/{PluginHelpers-WG1Lzzh3.mjs.map → PluginHelpers-B3gk3VB3.mjs.map} +1 -1
  85. package/dist/chunks/{PrintPlugin-BQ7LWbEB.mjs → PrintPlugin-BxNlFk2c.mjs} +2 -2
  86. package/dist/chunks/{PrintPlugin-BQ7LWbEB.mjs.map → PrintPlugin-BxNlFk2c.mjs.map} +1 -1
  87. package/dist/chunks/{RangeIterator-DDOxTQIf.mjs → RangeIterator-sJ_c9MNr.mjs} +2 -2
  88. package/dist/chunks/{RangeIterator-DDOxTQIf.mjs.map → RangeIterator-sJ_c9MNr.mjs.map} +1 -1
  89. package/dist/chunks/Schema-BSM4YLNT.mjs +2 -0
  90. package/dist/chunks/Schema-BSM4YLNT.mjs.map +1 -0
  91. package/dist/chunks/SchemaRegistry-Cs7rxafF.mjs +2 -0
  92. package/dist/chunks/SchemaRegistry-Cs7rxafF.mjs.map +1 -0
  93. package/dist/chunks/SelectionSync-BkjCwGp-.mjs +2 -0
  94. package/dist/chunks/SelectionSync-BkjCwGp-.mjs.map +1 -0
  95. package/dist/chunks/{SelectionTransactions-DNCzsl_b.mjs → SelectionTransactions-mQ1NfMEg.mjs} +2 -2
  96. package/dist/chunks/{SelectionTransactions-DNCzsl_b.mjs.map → SelectionTransactions-mQ1NfMEg.mjs.map} +1 -1
  97. package/dist/chunks/SimpleMark-D6vz3Nfd.mjs +2 -0
  98. package/dist/chunks/{SimpleMark-CTDtEIMV.mjs.map → SimpleMark-D6vz3Nfd.mjs.map} +1 -1
  99. package/dist/chunks/{SmartPastePlugin-CjExbE9Q.mjs → SmartPastePlugin-C3SVKkWK.mjs} +2 -2
  100. package/dist/chunks/{SmartPastePlugin-CjExbE9Q.mjs.map → SmartPastePlugin-C3SVKkWK.mjs.map} +1 -1
  101. package/dist/chunks/{StrikethroughPlugin-d-EW2YYx.mjs → StrikethroughPlugin-v-VJZzUZ.mjs} +2 -2
  102. package/dist/chunks/{StrikethroughPlugin-d-EW2YYx.mjs.map → StrikethroughPlugin-v-VJZzUZ.mjs.map} +1 -1
  103. package/dist/chunks/StyleClassNames-BsAx7k5T.mjs +2 -0
  104. package/dist/chunks/StyleClassNames-BsAx7k5T.mjs.map +1 -0
  105. package/dist/chunks/{SuperSubPlugin-C-kvFQyx.mjs → SuperSubPlugin-x1iPnZyt.mjs} +2 -2
  106. package/dist/chunks/{SuperSubPlugin-C-kvFQyx.mjs.map → SuperSubPlugin-x1iPnZyt.mjs.map} +1 -1
  107. package/dist/chunks/TableDimensions-BSEOEox2.mjs +2 -0
  108. package/dist/chunks/TableDimensions-BSEOEox2.mjs.map +1 -0
  109. package/dist/chunks/TablePlugin-WPwp902E.mjs +2 -0
  110. package/dist/chunks/TablePlugin-WPwp902E.mjs.map +1 -0
  111. package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs +2 -0
  112. package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs.map +1 -0
  113. package/dist/chunks/{TextDirectionAutoPlugin-LVDkKdDX.mjs → TextDirectionAutoPlugin-DOH5cfyy.mjs} +2 -2
  114. package/dist/chunks/{TextDirectionAutoPlugin-LVDkKdDX.mjs.map → TextDirectionAutoPlugin-DOH5cfyy.mjs.map} +1 -1
  115. package/dist/chunks/{TextDirectionPlugin-CtGwof7i.mjs → TextDirectionPlugin-JwlR-R-b.mjs} +2 -2
  116. package/dist/chunks/{TextDirectionPlugin-CtGwof7i.mjs.map → TextDirectionPlugin-JwlR-R-b.mjs.map} +1 -1
  117. package/dist/chunks/TextDirectionService-BcX07mw2.mjs +2 -0
  118. package/dist/chunks/{TextDirectionService-OFOU6r_s.mjs.map → TextDirectionService-BcX07mw2.mjs.map} +1 -1
  119. package/dist/chunks/{TextFormattingPlugin-DlS0SeW7.mjs → TextFormattingPlugin-Kc_UNoOz.mjs} +2 -2
  120. package/dist/chunks/{TextFormattingPlugin-DlS0SeW7.mjs.map → TextFormattingPlugin-Kc_UNoOz.mjs.map} +1 -1
  121. package/dist/chunks/ToolbarPlugin-DmVI7MN9.mjs +2 -0
  122. package/dist/chunks/ToolbarPlugin-DmVI7MN9.mjs.map +1 -0
  123. package/dist/chunks/VideoPlugin-D3zGQ6QV.mjs +2 -0
  124. package/dist/chunks/VideoPlugin-D3zGQ6QV.mjs.map +1 -0
  125. package/dist/chunks/color-picker-D6HrTsDM.mjs +2 -0
  126. package/dist/chunks/color-picker-D6HrTsDM.mjs.map +1 -0
  127. package/dist/chunks/full-BiQ93ERr.mjs +2 -0
  128. package/dist/chunks/{full-Cshz7aTP.mjs.map → full-BiQ93ERr.mjs.map} +1 -1
  129. package/dist/chunks/minimal-DO7LiFTa.mjs +2 -0
  130. package/dist/chunks/{minimal-7XqMY9kC.mjs.map → minimal-DO7LiFTa.mjs.map} +1 -1
  131. package/dist/chunks/register-Cb1YTAN4.mjs +3 -0
  132. package/dist/chunks/register-Cb1YTAN4.mjs.map +1 -0
  133. package/dist/commands/Commands.d.ts.map +1 -1
  134. package/dist/commands/CompositionCommands.d.ts +47 -0
  135. package/dist/commands/CompositionCommands.d.ts.map +1 -0
  136. package/dist/commands/CompositionRebase.d.ts +24 -0
  137. package/dist/commands/CompositionRebase.d.ts.map +1 -0
  138. package/dist/commands/PasteCommand.d.ts.map +1 -1
  139. package/dist/commands/SelectionDeletion.d.ts +15 -5
  140. package/dist/commands/SelectionDeletion.d.ts.map +1 -1
  141. package/dist/fonts/math.mjs +1 -1
  142. package/dist/fonts.mjs +1 -1
  143. package/dist/full.mjs +1 -1
  144. package/dist/html.mjs +1 -1
  145. package/dist/index.d.ts +1 -0
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/input/CompositionController.d.ts +78 -0
  148. package/dist/input/CompositionController.d.ts.map +1 -0
  149. package/dist/input/HTMLParser.d.ts +15 -2
  150. package/dist/input/HTMLParser.d.ts.map +1 -1
  151. package/dist/input/InputHandler.d.ts +34 -1
  152. package/dist/input/InputHandler.d.ts.map +1 -1
  153. package/dist/input/InputManager.d.ts +3 -0
  154. package/dist/input/InputManager.d.ts.map +1 -1
  155. package/dist/input/PasteHTMLHandler.d.ts.map +1 -1
  156. package/dist/markdown.mjs +1 -1
  157. package/dist/model/BlockAlignment.d.ts +6 -0
  158. package/dist/model/BlockAlignment.d.ts.map +1 -1
  159. package/dist/model/BlockOffsetText.d.ts +11 -0
  160. package/dist/model/BlockOffsetText.d.ts.map +1 -0
  161. package/dist/model/CompositionState.d.ts +14 -0
  162. package/dist/model/CompositionState.d.ts.map +1 -1
  163. package/dist/model/HTMLUtils.d.ts +16 -3
  164. package/dist/model/HTMLUtils.d.ts.map +1 -1
  165. package/dist/model/MarkSpec.d.ts +5 -3
  166. package/dist/model/MarkSpec.d.ts.map +1 -1
  167. package/dist/model/NodeResolver.d.ts +2 -0
  168. package/dist/model/NodeResolver.d.ts.map +1 -1
  169. package/dist/model/NodeSpec.d.ts +2 -1
  170. package/dist/model/NodeSpec.d.ts.map +1 -1
  171. package/dist/model/Schema.d.ts +2 -0
  172. package/dist/model/Schema.d.ts.map +1 -1
  173. package/dist/model/SchemaRegistry.d.ts +26 -1
  174. package/dist/model/SchemaRegistry.d.ts.map +1 -1
  175. package/dist/model/StyleClass.d.ts +45 -0
  176. package/dist/model/StyleClass.d.ts.map +1 -0
  177. package/dist/model/StyleClassRegistry.d.ts +28 -0
  178. package/dist/model/StyleClassRegistry.d.ts.map +1 -0
  179. package/dist/model/TextChange.d.ts +40 -0
  180. package/dist/model/TextChange.d.ts.map +1 -0
  181. package/dist/notectl-core.mjs +1 -1
  182. package/dist/notectl-core.umd.js +1 -1
  183. package/dist/notectl-core.umd.js.map +1 -1
  184. package/dist/plugins/Plugin.d.ts +11 -0
  185. package/dist/plugins/Plugin.d.ts.map +1 -1
  186. package/dist/plugins/PluginContextFactory.d.ts +2 -0
  187. package/dist/plugins/PluginContextFactory.d.ts.map +1 -1
  188. package/dist/plugins/RegistrationTracker.d.ts.map +1 -1
  189. package/dist/plugins/alignment/AlignmentPlugin.d.ts +17 -0
  190. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
  191. package/dist/plugins/alignment.mjs +1 -1
  192. package/dist/plugins/bidi-isolation.mjs +1 -1
  193. package/dist/plugins/blockquote.mjs +1 -1
  194. package/dist/plugins/caret-navigation.mjs +1 -1
  195. package/dist/plugins/code-block.mjs +1 -1
  196. package/dist/plugins/font/FontPlugin.d.ts +13 -0
  197. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  198. package/dist/plugins/font-size/FontSizeOperations.d.ts +2 -0
  199. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
  200. package/dist/plugins/font-size/FontSizePlugin.d.ts +11 -0
  201. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  202. package/dist/plugins/font-size.mjs +1 -1
  203. package/dist/plugins/font.mjs +1 -1
  204. package/dist/plugins/formula/FormulaPlugin.d.ts.map +1 -1
  205. package/dist/plugins/formula/latex/LatexParser.d.ts.map +1 -1
  206. package/dist/plugins/formula/latex/LatexSymbols.d.ts.map +1 -1
  207. package/dist/plugins/formula/latex/LookupOwn.d.ts +6 -0
  208. package/dist/plugins/formula/latex/LookupOwn.d.ts.map +1 -0
  209. package/dist/plugins/formula/latex/handlers/Accents.d.ts.map +1 -1
  210. package/dist/plugins/formula/latex/handlers/Delimiters.d.ts.map +1 -1
  211. package/dist/plugins/formula/latex/handlers/Environments.d.ts.map +1 -1
  212. package/dist/plugins/formula/latex/handlers/Fonts.d.ts.map +1 -1
  213. package/dist/plugins/formula/latex/handlers/Spacing.d.ts.map +1 -1
  214. package/dist/plugins/formula.mjs +1 -1
  215. package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -1
  216. package/dist/plugins/gap-cursor.mjs +1 -1
  217. package/dist/plugins/hard-break.mjs +1 -1
  218. package/dist/plugins/heading.mjs +1 -1
  219. package/dist/plugins/highlight/HighlightPlugin.d.ts +11 -0
  220. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  221. package/dist/plugins/highlight.mjs +1 -1
  222. package/dist/plugins/horizontal-rule.mjs +1 -1
  223. package/dist/plugins/image.mjs +1 -1
  224. package/dist/plugins/inline-code/InlineCodePlugin.d.ts.map +1 -1
  225. package/dist/plugins/inline-code.mjs +1 -1
  226. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  227. package/dist/plugins/link.mjs +1 -1
  228. package/dist/plugins/list/ListPlugin.d.ts +2 -1
  229. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  230. package/dist/plugins/list.mjs +1 -1
  231. package/dist/plugins/print.mjs +1 -1
  232. package/dist/plugins/shared/ColorGrid.d.ts.map +1 -1
  233. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
  234. package/dist/plugins/shared/ColorValidation.d.ts +12 -4
  235. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
  236. package/dist/plugins/shared/InlineStyleMarkSpec.d.ts +10 -0
  237. package/dist/plugins/shared/InlineStyleMarkSpec.d.ts.map +1 -1
  238. package/dist/plugins/shared/StyleClassNames.d.ts +10 -0
  239. package/dist/plugins/shared/StyleClassNames.d.ts.map +1 -0
  240. package/dist/plugins/shared.mjs +1 -1
  241. package/dist/plugins/smart-paste.mjs +1 -1
  242. package/dist/plugins/strikethrough.mjs +1 -1
  243. package/dist/plugins/super-sub.mjs +1 -1
  244. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
  245. package/dist/plugins/table.mjs +1 -1
  246. package/dist/plugins/text-color/TextColorPlugin.d.ts +11 -0
  247. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  248. package/dist/plugins/text-color.mjs +1 -1
  249. package/dist/plugins/text-direction-auto.mjs +1 -1
  250. package/dist/plugins/text-direction.mjs +1 -1
  251. package/dist/plugins/text-formatting.mjs +1 -1
  252. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
  253. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  254. package/dist/plugins/toolbar.mjs +1 -1
  255. package/dist/plugins/video.mjs +1 -1
  256. package/dist/presets/full.mjs +1 -1
  257. package/dist/presets/minimal.mjs +1 -1
  258. package/dist/presets.mjs +1 -1
  259. package/dist/register.mjs +1 -1
  260. package/dist/serialization/AlignmentHTML.d.ts +43 -0
  261. package/dist/serialization/AlignmentHTML.d.ts.map +1 -0
  262. package/dist/serialization/CSSClassCollector.d.ts +20 -17
  263. package/dist/serialization/CSSClassCollector.d.ts.map +1 -1
  264. package/dist/serialization/CSSValueEquivalence.d.ts +24 -0
  265. package/dist/serialization/CSSValueEquivalence.d.ts.map +1 -0
  266. package/dist/serialization/DocumentParser.d.ts +2 -1
  267. package/dist/serialization/DocumentParser.d.ts.map +1 -1
  268. package/dist/serialization/DocumentSerializer.d.ts +0 -4
  269. package/dist/serialization/DocumentSerializer.d.ts.map +1 -1
  270. package/dist/serialization/FirstTagAttributes.d.ts +16 -0
  271. package/dist/serialization/FirstTagAttributes.d.ts.map +1 -0
  272. package/dist/serialization/HTMLParseRules.d.ts +32 -0
  273. package/dist/serialization/HTMLParseRules.d.ts.map +1 -0
  274. package/dist/serialization/HTMLParseSession.d.ts +21 -0
  275. package/dist/serialization/HTMLParseSession.d.ts.map +1 -0
  276. package/dist/serialization/MarkSerializer.d.ts.map +1 -1
  277. package/dist/serialization/StyleClassHTML.d.ts +37 -0
  278. package/dist/serialization/StyleClassHTML.d.ts.map +1 -0
  279. package/dist/serialization/StyleRehydration.d.ts +16 -0
  280. package/dist/serialization/StyleRehydration.d.ts.map +1 -0
  281. package/dist/serialization/TableDimensions.d.ts.map +1 -1
  282. package/dist/serialization/index.d.ts +2 -1
  283. package/dist/serialization/index.d.ts.map +1 -1
  284. package/dist/serialization/markdown/InlineSerializers.d.ts.map +1 -1
  285. package/dist/state/EditorState.d.ts.map +1 -1
  286. package/dist/state/History.d.ts +2 -1
  287. package/dist/state/History.d.ts.map +1 -1
  288. package/dist/state/NavigationQueries.d.ts.map +1 -1
  289. package/dist/state/SelectionValidation.d.ts +12 -0
  290. package/dist/state/SelectionValidation.d.ts.map +1 -0
  291. package/dist/state/StepMapping.d.ts.map +1 -1
  292. package/dist/state/TransactionBuilder.d.ts +7 -1
  293. package/dist/state/TransactionBuilder.d.ts.map +1 -1
  294. package/dist/test/PluginTestUtils.d.ts +25 -0
  295. package/dist/test/PluginTestUtils.d.ts.map +1 -1
  296. package/dist/test/TestUtils.d.ts.map +1 -1
  297. package/dist/view/CursorWrapper.d.ts.map +1 -1
  298. package/dist/view/EditorView.d.ts +25 -1
  299. package/dist/view/EditorView.d.ts.map +1 -1
  300. package/dist/view/InlineContentDOM.d.ts +44 -0
  301. package/dist/view/InlineContentDOM.d.ts.map +1 -0
  302. package/dist/view/Reconciler.d.ts +20 -1
  303. package/dist/view/Reconciler.d.ts.map +1 -1
  304. package/dist/view/RenderedBlockText.d.ts +27 -0
  305. package/dist/view/RenderedBlockText.d.ts.map +1 -0
  306. package/dist/view/SelectionSync.d.ts.map +1 -1
  307. package/package.json +3 -2
  308. package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs +0 -2
  309. package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs.map +0 -1
  310. package/dist/chunks/BidiIsolationPlugin-cOLlL3Y9.mjs +0 -2
  311. package/dist/chunks/BlockquotePlugin-D-jRWLQB.mjs +0 -2
  312. package/dist/chunks/BlockquotePlugin-D-jRWLQB.mjs.map +0 -1
  313. package/dist/chunks/CodeBlockPlugin-BandNM3t.mjs +0 -2
  314. package/dist/chunks/ColorPickerPopup-_C5JZhki.mjs +0 -2
  315. package/dist/chunks/ColorValidation-B9d_umnf.mjs.map +0 -1
  316. package/dist/chunks/Commands-D-0UXYvo.mjs +0 -2
  317. package/dist/chunks/Commands-D-0UXYvo.mjs.map +0 -1
  318. package/dist/chunks/DocumentParser-i-CreJ48.mjs +0 -2
  319. package/dist/chunks/DocumentParser-i-CreJ48.mjs.map +0 -1
  320. package/dist/chunks/FontPlugin-C_ScWZ0P.mjs +0 -2
  321. package/dist/chunks/FontPlugin-C_ScWZ0P.mjs.map +0 -1
  322. package/dist/chunks/FontSizePlugin-DB_0njtC.mjs +0 -2
  323. package/dist/chunks/FontSizePlugin-DB_0njtC.mjs.map +0 -1
  324. package/dist/chunks/FormulaPlugin-CI0r4X1o.mjs +0 -2
  325. package/dist/chunks/FormulaPlugin-CI0r4X1o.mjs.map +0 -1
  326. package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs +0 -2
  327. package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs.map +0 -1
  328. package/dist/chunks/HTMLUtils-B0nGyFLb.mjs +0 -2
  329. package/dist/chunks/HTMLUtils-B0nGyFLb.mjs.map +0 -1
  330. package/dist/chunks/HeadingPlugin-LK8Pg4h0.mjs +0 -2
  331. package/dist/chunks/HeadingPlugin-LK8Pg4h0.mjs.map +0 -1
  332. package/dist/chunks/HighlightPlugin-B4WlZawl.mjs +0 -2
  333. package/dist/chunks/HighlightPlugin-B4WlZawl.mjs.map +0 -1
  334. package/dist/chunks/HorizontalRulePlugin-CxmUMM34.mjs +0 -2
  335. package/dist/chunks/ImagePlugin-C5ESNNsA.mjs +0 -2
  336. package/dist/chunks/ImagePlugin-C5ESNNsA.mjs.map +0 -1
  337. package/dist/chunks/InlineCodePlugin-C1SqGfv5.mjs +0 -2
  338. package/dist/chunks/InlineCodePlugin-C1SqGfv5.mjs.map +0 -1
  339. package/dist/chunks/InlineStyleMarkSpec-Cx3goc3W.mjs +0 -2
  340. package/dist/chunks/InlineStyleMarkSpec-Cx3goc3W.mjs.map +0 -1
  341. package/dist/chunks/ListPlugin-DSFPSWQC.mjs +0 -2
  342. package/dist/chunks/MarkCommands-CJvLGL5G.mjs +0 -2
  343. package/dist/chunks/MarkCommands-CJvLGL5G.mjs.map +0 -1
  344. package/dist/chunks/MarkdownHTMLRegistry-CISsC0lH.mjs +0 -2
  345. package/dist/chunks/MarkdownSerializer-Oex2RzNw.mjs +0 -2
  346. package/dist/chunks/MarkdownSerializer-Oex2RzNw.mjs.map +0 -1
  347. package/dist/chunks/NavigationQueries-Bt4zZ17v.mjs +0 -2
  348. package/dist/chunks/NavigationQueries-Bt4zZ17v.mjs.map +0 -1
  349. package/dist/chunks/NodeResolver-BtIknXqD.mjs +0 -2
  350. package/dist/chunks/NodeResolver-BtIknXqD.mjs.map +0 -1
  351. package/dist/chunks/PluginHelpers-WG1Lzzh3.mjs +0 -2
  352. package/dist/chunks/SchemaRegistry-acc6q_5x.mjs +0 -2
  353. package/dist/chunks/SchemaRegistry-acc6q_5x.mjs.map +0 -1
  354. package/dist/chunks/SelectionSync-CwOHMMfI.mjs +0 -2
  355. package/dist/chunks/SelectionSync-CwOHMMfI.mjs.map +0 -1
  356. package/dist/chunks/SimpleMark-CTDtEIMV.mjs +0 -2
  357. package/dist/chunks/TableDimensions-BcARMxQB.mjs +0 -2
  358. package/dist/chunks/TableDimensions-BcARMxQB.mjs.map +0 -1
  359. package/dist/chunks/TablePlugin-C4WMYGWN.mjs +0 -2
  360. package/dist/chunks/TablePlugin-C4WMYGWN.mjs.map +0 -1
  361. package/dist/chunks/TextColorPlugin-D_MhNJT6.mjs +0 -2
  362. package/dist/chunks/TextColorPlugin-D_MhNJT6.mjs.map +0 -1
  363. package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +0 -2
  364. package/dist/chunks/ToolbarPlugin-O7TirXQP.mjs +0 -2
  365. package/dist/chunks/ToolbarPlugin-O7TirXQP.mjs.map +0 -1
  366. package/dist/chunks/VideoPlugin-C9z4JfP_.mjs +0 -2
  367. package/dist/chunks/VideoPlugin-C9z4JfP_.mjs.map +0 -1
  368. package/dist/chunks/color-picker-DJ05ey9o.mjs +0 -2
  369. package/dist/chunks/color-picker-DJ05ey9o.mjs.map +0 -1
  370. package/dist/chunks/full-Cshz7aTP.mjs +0 -2
  371. package/dist/chunks/minimal-7XqMY9kC.mjs +0 -2
  372. package/dist/chunks/register-BVvV0Vl_.mjs +0 -3
  373. package/dist/chunks/register-BVvV0Vl_.mjs.map +0 -1
  374. package/dist/editor/styles/base.d.ts +0 -3
  375. package/dist/editor/styles/base.d.ts.map +0 -1
  376. package/dist/editor/styles/color-picker.d.ts +0 -3
  377. package/dist/editor/styles/color-picker.d.ts.map +0 -1
  378. package/dist/editor/styles/font-select.d.ts +0 -3
  379. package/dist/editor/styles/font-select.d.ts.map +0 -1
  380. package/dist/editor/styles/font-size-select.d.ts +0 -3
  381. package/dist/editor/styles/font-size-select.d.ts.map +0 -1
  382. package/dist/editor/styles/heading-select.d.ts +0 -3
  383. package/dist/editor/styles/heading-select.d.ts.map +0 -1
  384. package/dist/editor/styles/image.d.ts +0 -3
  385. package/dist/editor/styles/image.d.ts.map +0 -1
  386. package/dist/editor/styles/reduced-motion.d.ts +0 -3
  387. package/dist/editor/styles/reduced-motion.d.ts.map +0 -1
  388. package/dist/editor/styles/table.d.ts +0 -3
  389. package/dist/editor/styles/table.d.ts.map +0 -1
  390. package/dist/editor/styles/toolbar.d.ts +0 -3
  391. package/dist/editor/styles/toolbar.d.ts.map +0 -1
  392. package/dist/plugins/blockquote/BlockquoteStyles.d.ts +0 -3
  393. package/dist/plugins/blockquote/BlockquoteStyles.d.ts.map +0 -1
  394. package/dist/plugins/formula/FormulaStyles.d.ts +0 -12
  395. package/dist/plugins/formula/FormulaStyles.d.ts.map +0 -1
  396. package/dist/plugins/image/ImagePopupStyles.d.ts +0 -3
  397. package/dist/plugins/image/ImagePopupStyles.d.ts.map +0 -1
  398. package/dist/plugins/video/VideoPopupStyles.d.ts +0 -3
  399. package/dist/plugins/video/VideoPopupStyles.d.ts.map +0 -1
  400. package/dist/plugins/video/VideoStyles.d.ts +0 -3
  401. package/dist/plugins/video/VideoStyles.d.ts.map +0 -1
@@ -1,2 +0,0 @@
1
- import{B as t,D as e,E as n,_ as i,j as s,p as c}from"./Document-D_2cIBJG.mjs";import{c as o,f as r,n as l,p as a}from"./Selection-DC6AOGgF.mjs";import{a as d,t as h}from"./TypeBrands-Ch9856Gb.mjs";import{l as u}from"./BlockInsertion-O5pAFKid.mjs";import{t as m}from"./RangeIterator-DDOxTQIf.mjs";import{r as p}from"./AttrRegistry-CtNhf2EF.mjs";import{o as k,t as f}from"./Decoration-BwhoA4MU.mjs";import{c as g,o as b}from"./PluginHelpers-WG1Lzzh3.mjs";import{c as y}from"./StyleRuntime-C0RSqKzG.mjs";import{n as v}from"./DomUtils-Bf7JLFlx.mjs";function x(t,e,n){return"checklist"===t?{listType:t,indent:e,checked:n??!1}:{listType:t,indent:e}}function I(t,e){const n=t.getBlock(e);if("list_item"===n?.type)return n;const i=t.getNodePath(e);if(i)for(let s=i.length-2;s>=0;s--){const e=i[s],n=e?t.getBlock(e):void 0;if("list_item"===n?.type)return n}}function T(t,n){const i=t.getBlock(n);if(!i||"list_item"!==i.type)return;const s=t.getNodePath(n);if(!s)return;const c=s.slice(0,-1),o=c[c.length-1],r=(o?e(t.getBlock(o)):t.doc.children).findIndex(t=>t.id===n);return r<0?void 0:{item:i,parentPath:c,index:r}}function B(t,n){t.removeNode(n.parentPath,n.index),e(n.item).forEach((e,i)=>{t.insertNode(n.parentPath,n.index+i,e)})}function S(e,n){const i=e.getState(),s=i.selection;return!!r(s)&&(s.anchor.blockId!==s.head.blockId?function(e,n,i){const s=n.selection;if(!r(s))return!1;const c=a(s,n.getBlockOrder()),o=_(n,c,i),l=n.transaction("command"),h=function(t,e){const n=[],i=/* @__PURE__ */new Set;return m(t,e,e=>{const s=t.getBlock(e);if(!s)return;const c=I(t,e)??s;i.has(c.id)||(i.add(c.id),n.push(c))}),n}(n,c);for(let r=h.length-1;r>=0;r--){const e=h[r];if(e)if(o)if(t(e))l.setBlockType(e.id,d("paragraph"));else{const t=T(n,e.id);t&&B(l,t)}else{const t=p(e,"list_item")?e.attrs.indent:0,n=p(e,"list_item")&&"checklist"===e.attrs.listType&&e.attrs.checked;l.setBlockType(e.id,d("list_item"),x(i,t,n))}}return l.setSelection(s),e.dispatch(l.build()),!0}(e,i,n):function(e,n,i){const s=n.selection;if(!r(s))return!1;const c=n.getBlock(s.anchor.blockId);if(!c)return!1;const o=I(n,s.anchor.blockId),l=o??c;if(o&&o.attrs?.listType===i){const i=n.transaction("command");if(t(o))i.setBlockType(o.id,d("paragraph"));else{const t=T(n,o.id);if(!t)return!1;B(i,t)}return i.setSelection(s),e.dispatch(i.build()),!0}const a=x(i,p(l,"list_item")?l.attrs.indent:0),h=n.transaction("command").setBlockType(l.id,d("list_item"),a).setSelection(s).build();return e.dispatch(h),!0}(e,i,n))}function C(t,e,n){const i=t.getState();if(!r(i.selection))return!1;if(i.selection.anchor.blockId!==i.selection.head.blockId)return function(t,e,n,i){const s=e.selection;if(!r(s))return!1;const c=a(s,e.getBlockOrder()),o=e.transaction("command");let l=!1;const h=/* @__PURE__ */new Set;return m(e,c,t=>{const s=I(e,t);if(!s||!p(s,"list_item"))return;if(h.has(s.id))return;h.add(s.id);const c=s.attrs.indent+n;c<0||c>i||(o.setBlockType(s.id,d("list_item"),x(s.attrs.listType,c,s.attrs.checked)),l=!0)}),!!l&&(o.setSelection(s),t.dispatch(o.build()),!0)}(t,i,e,n);const s=i.selection,c=I(i,s.anchor.blockId);if(!c||!p(c,"list_item"))return!1;const o=c.attrs.indent+e;if(o<0||o>n)return!1;const l=x(c.attrs.listType,o,c.attrs.checked),h=i.transaction("command").setBlockType(c.id,d("list_item"),l).setSelection(s).build();return t.dispatch(h),!0}function L(t,e){const{interactiveCheckboxes:n,targetId:i,locale:s}=e;if(t.isReadOnly()&&!n)return!1;const c=t.getState(),o=i??(r(c.selection)?c.selection.anchor.blockId:null);if(!o)return!1;const l=I(c,o);if(!l||!p(l,"list_item")||"checklist"!==l.attrs.listType)return!1;const a=!l.attrs.checked,h=x(l.attrs.listType,l.attrs.indent,a),u=c.transaction("command").setBlockType(l.id,d("list_item"),h).setSelection(c.selection);t.isReadOnly()&&n&&u.readonlyAllowed(),t.dispatch(u.build());const m=t.getState().getBlock(l.id);return!(!m||!p(m,"list_item")||"checklist"!==m.attrs.listType||m.attrs.checked!==a||(t.announce(a?s.checkedAnnouncement:s.uncheckedAnnouncement),0))}function _(t,e,n){let i=!0;return m(t,e,e=>{const s=I(t,e);s&&"list_item"===s.type&&s.attrs?.listType===n||(i=!1)}),i}var w=[{type:"bullet",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"/></svg>',inputPattern:/^[-*] $/,inputPrefix:"- "},{type:"ordered",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"/></svg>',inputPattern:/^\d+\. $/,inputPrefix:"1. "},{type:"checklist",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 7h-9v2h9V7zm0 8h-9v2h9v-2zM5.54 11L2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 11zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 19z"/></svg>',inputPattern:/^\[[ x]] $/,inputPrefix:"[ ] "}];function H(t,n){const i=t.getState();if(!r(i.selection))return!1;const s=i.selection;if(!o(s))return!1;const c=i.getBlock(s.anchor.blockId);if(!c)return!1;if("list_item"===c.type)return n({state:i,item:c,child:void 0,childIndex:-1,childCount:0,blockId:s.anchor.blockId,offset:s.anchor.offset});const l=i.getParent(s.anchor.blockId);if(!l||"list_item"!==l.type)return!1;const a=e(l),d=a.findIndex(t=>t.id===c.id);return!(d<0)&&n({state:i,item:l,child:c,childIndex:d,childCount:a.length,blockId:s.anchor.blockId,offset:s.anchor.offset})}var z={bulletList:"Bullet List",numberedList:"Numbered List",checklist:"Checklist",checkboxLabel:"To-do item",checkedAnnouncement:"Checked",uncheckedAnnouncement:"Unchecked"},j=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-Cy_77yRf.mjs"),"./locales/de.ts":()=>import("./de-CaeEIyzV.mjs"),"./locales/es.ts":()=>import("./es-DFokqQst.mjs"),"./locales/fr.ts":()=>import("./fr-5HkMazAf.mjs"),"./locales/hi.ts":()=>import("./hi-BzbMD_cP.mjs"),"./locales/pt.ts":()=>import("./pt-CR4j8gtE.mjs"),"./locales/ru.ts":()=>import("./ru-DiwQV30V.mjs"),"./locales/zh.ts":()=>import("./zh-BQqf3wJZ.mjs")});async function A(t){return g(j,t,z)}var P="notectl-checklist-marker";function $(t,e){const n=document.createElement("span");return n.className=P,n.setAttribute("role","checkbox"),n.setAttribute("aria-checked",String(t)),n.setAttribute("aria-label",e),n.setAttribute("contenteditable","false"),n.setAttribute("data-widget","true"),n}function N(t,e){return{bullet:e.bulletList,ordered:e.numberedList,checklist:e.checklist}[t]}function M(t,e){if(!r(t.selection))return!1;if(t.selection.anchor.blockId!==t.selection.head.blockId){const n=a(t.selection,t.getBlockOrder());return _(t,n,e)}const n=I(t,t.selection.anchor.blockId);return"list_item"===n?.type&&n.attrs?.listType===e}var O={types:["bullet","ordered","checklist"],maxIndent:4},E=class{id="list";name="List";priority=35;config;locale;context=null;checkboxClickHandler=null;constructor(t){this.config={...O,...t}}async init(t){this.context=t,this.locale=await b(t,this.config.locale,z,A);const e=this.getEnabledTypes();t.registerStyleSheet("\n/* List Wrappers — suppress native markers, we use ::before pseudo-elements */\n.notectl-list {\n\tlist-style: none;\n\tmargin: 0;\n\tpadding: 0;\n}\n\n/* Ordered List — each <ol> wrapper resets the counter */\n.notectl-list--ordered {\n\tcounter-reset: notectl-ordered;\n}\n\n/* List Items */\n.notectl-list-item {\n\tmargin: 0;\n\tpadding: 2px 0;\n\tpadding-inline-start: 24px;\n\tmin-height: 1.6em;\n\tposition: relative;\n}\n\n.notectl-list-item::before {\n\tposition: absolute;\n\tinset-inline-start: 0;\n\tdisplay: inline-block;\n\twidth: 24px;\n\ttext-align: center;\n\t-webkit-user-select: none;\n\tuser-select: none;\n\tpointer-events: none;\n}\n\n/* Container items (#194): block children inherit the item's start padding.\n Trim the first/last child paragraph padding so the first text line sits on\n the marker's line and the item keeps the leaf item's vertical rhythm. */\n.notectl-list-item > p:first-of-type {\n\tpadding-top: 0;\n}\n\n.notectl-list-item > p:last-of-type {\n\tpadding-bottom: 0;\n}\n\n/* Bullet List */\n.notectl-list-item--bullet::before {\n\tcontent: '\\2022';\n\tcolor: var(--notectl-fg);\n}\n\n/* Ordered List — counter increment per item */\n.notectl-list-item--ordered {\n\tcounter-increment: notectl-ordered;\n}\n\n.notectl-list-item--ordered::before {\n\tcontent: counter(notectl-ordered) '.';\n\tcolor: var(--notectl-fg);\n\tfont-size: 14px;\n}\n\n/* Checklist — the marker is a real role=\"checkbox\" element (see ListMarker.ts)\n positioned over the reserved marker zone. inline-block keeps the parent's\n line-through (on checked items) from striking the glyph. */\n.notectl-checklist-marker {\n\tposition: absolute;\n\tinset-inline-start: 0;\n\tdisplay: inline-block;\n\twidth: 24px;\n\ttext-align: center;\n\tfont-size: 16px;\n\tcolor: var(--notectl-fg-muted);\n\tcursor: pointer;\n\ttext-decoration: none;\n\t-webkit-user-select: none;\n\tuser-select: none;\n}\n\n.notectl-checklist-marker::before {\n\tcontent: '\\2610';\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] .notectl-checklist-marker {\n\tcolor: var(--notectl-success);\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] .notectl-checklist-marker::before {\n\tcontent: '\\2611';\n}\n\n.notectl-list-item--checklist[data-checked=\"true\"] {\n\tcolor: var(--notectl-fg-muted);\n\ttext-decoration: line-through;\n}\n"),this.registerNodeSpec(t),function(t,e,n,i){for(const s of n)t.registerCommand(`toggleList:${s.type}`,()=>S(t,s.type));if(t.registerCommand("indentListItem",()=>C(t,1,e.maxIndent)),t.registerCommand("outdentListItem",()=>C(t,-1,e.maxIndent)),e.types.includes("checklist")){const n=()=>L(t,{interactiveCheckboxes:e.interactiveCheckboxes,locale:i});t.registerCommand("toggleChecklistItem",n,{readonlyAllowed:e.interactiveCheckboxes}),t.registerKeymap({"Mod-Enter":n},{priority:"navigation"})}t.registerKeymap({Tab:()=>C(t,1,e.maxIndent),"Shift-Tab":()=>C(t,-1,e.maxIndent)})}(t,this.config,e,this.locale),function(t){t.registerKeymap({Enter:()=>function(t){return H(t,e=>{if(e.child)return function(t,e,s){if(!u(s))return!1;if(e.childIndex!==e.childCount-1)return!1;const o=T(e.state,e.item.id);if(!o)return!1;const r=e.state.transaction("input");if(1===e.childCount)return B(r,o),r.setSelection(e.state.selection),t.dispatch(r.build()),!0;const a=p(e.item,"list_item")?e.item.attrs.listType:"bullet",h=p(e.item,"list_item")?e.item.attrs.indent:0,m=n(),k=c(d("list_item"),[i("")],m,x(a,h));return r.removeNode([...o.parentPath,e.item.id],e.childIndex).insertNode(o.parentPath,o.index+1,k).setSelection(l(m,0)),t.dispatch(r.build()),!0}(t,e,e.child);if(""===s(e.item)){const n=e.state.transaction("input").setBlockType(e.blockId,d("paragraph")).setSelection(e.state.selection).build();return t.dispatch(n),!0}const o=n(),r=x(p(e.item,"list_item")?e.item.attrs.listType:"bullet",p(e.item,"list_item")?e.item.attrs.indent:0),a=e.state.transaction("input").splitBlock(e.blockId,e.offset,o).setBlockType(o,d("list_item"),r).setSelection(l(o,0)).build();return t.dispatch(a),!0})}(t),Backspace:()=>function(t){return H(t,e=>{if(0!==e.offset)return!1;if(e.child){if(0!==e.childIndex)return!1;const n=T(e.state,e.item.id);if(!n)return!1;const i=e.state.transaction("input");return B(i,n),i.setSelection(e.state.selection),t.dispatch(i.build()),!0}const n=e.state.transaction("input").setBlockType(e.blockId,d("paragraph")).setSelection(e.state.selection).build();return t.dispatch(n),!0})}(t)})}(t),!1!==this.config.inputRule&&function(t,e){for(const n of e)t.registerInputRule({pattern:n.inputPattern,handler:(t,e,i,s)=>{const c=t.selection;if(!r(c))return null;if(!o(c))return null;const a=t.getBlock(c.anchor.blockId);if(!a||"paragraph"!==a.type)return null;if("list_item"===t.getParent(c.anchor.blockId)?.type)return null;const h=e[0]??"",u=h.length,m=x(n.type,0,h.includes("[x]"));return t.transaction("input").deleteTextAt(c.anchor.blockId,i,i+u).setBlockType(c.anchor.blockId,d("list_item"),m).setSelection(l(c.anchor.blockId,0)).build()}})}(t,e),function(t,e,n){for(const i of e)t.registerToolbarItem({id:`list-${i.type}`,group:"block",icon:i.icon,label:N(i.type,n),command:`toggleList:${i.type}`,isActive:t=>M(t,i.type)})}(t,e,this.locale),this.registerCheckboxClickHandler(t)}decorations(t){const e=[];for(const n of t.getBlockOrder()){const i=t.getBlock(n);if(!i||!p(i,"list_item")||"checklist"!==i.attrs.listType)continue;const s=i.attrs.checked;e.push(k(n,0,()=>$(s,this.locale.checkboxLabel),{key:`checklist-marker:${s}`}))}return f.create(e)}destroy(){this.checkboxClickHandler&&this.context&&this.context.getContainer().removeEventListener("mousedown",this.checkboxClickHandler),this.checkboxClickHandler=null,this.context=null}registerNodeSpec(t){const e=this.locale.checkboxLabel;t.registerNodeSpec({type:"list_item",group:"block",content:{allow:["text","paragraph","heading","code_block","blockquote","horizontal_rule"]},attrs:{listType:{default:"bullet"},indent:{default:0},checked:{default:!1}},toDOM(t){const n=t.attrs?.listType??"bullet",i=t.attrs?.indent??0,s=t.attrs?.checked??!1,c=v("li",t.id);return c.setAttribute("role","listitem"),c.setAttribute("data-list-type",n),c.setAttribute("data-indent",String(i)),c.className=`notectl-list-item notectl-list-item--${n}`,i>0&&y(c,"marginLeft",24*i+"px"),"checklist"===n&&(c.setAttribute("data-checked",String(s)),c.appendChild($(s,e))),c.setAttribute("aria-level",String(i+1)),c},wrapper(t){const e=t.attrs?.listType??"bullet";return{tag:"ordered"===e?"ol":"ul",key:`list-${e}`,className:`notectl-list notectl-list--${e}`,attrs:{role:"list"}}},toHTML(t,e){const n=t.attrs?.listType??"bullet",i=t.attrs?.checked??!1;return"checklist"===n?`<li role="checkbox" aria-checked="${String(i)}"><input type="checkbox" disabled${i?" checked":""}>${e||"<br>"}</li>`:`<li>${e||"<br>"}</li>`},parseHTML:[{tag:"li"}],sanitize:{tags:["ul","ol","li","input"],attrs:["type","disabled","checked","role","aria-checked"]}})}registerCheckboxClickHandler(t){this.config.types.includes("checklist")&&(this.checkboxClickHandler=e=>{if(t.isReadOnly()&&!this.config.interactiveCheckboxes)return;const n=e.target;if(!(n instanceof HTMLElement))return;const i=n.closest(`.${P}`);if(!i)return;const s=i.closest(".notectl-list-item--checklist");if(!s)return;e.preventDefault();const c=s.getAttribute("data-block-id");c&&L(t,{interactiveCheckboxes:this.config.interactiveCheckboxes,targetId:h(c),locale:this.locale})},t.getContainer().addEventListener("mousedown",this.checkboxClickHandler))}getEnabledTypes(){return w.filter(t=>this.config.types.includes(t.type))}};export{z as n,A as r,E as t};
2
- //# sourceMappingURL=ListPlugin-DSFPSWQC.mjs.map
@@ -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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MLUtils-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 finalizeDoc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GAA2C,IAAxB,EAAK,OAAO,QACrC,EAAS,GAAG,EAAI,KAAK,WAAW,EAAU,IAAM,MACjD,MACC,EAAS,EAAI,KAAK,OAKnB,MAAM,EACQ,cAAb,EAA2B,EAAI,KAAK,OAAO,OAAS,EAAI,EAAO,OAAS,EAGzE,GAFA,EAAe,GAAU,EAAW,EAEhC,EAAY,GAAO,CAItB,MAAM,EAAkB,EACvB,EAAuB,EAAkB,GAAO,GAAK,QAAQ,MAAO,MAErE,EAAM,KAAK,EAAU,GAAG,IAAM,KAAU,IAAY,GAAG,IAAM,KAC7D,QACD,CAIA,MAAM,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 findAncestorOfType(doc, nodeId, type) !== undefined;\n}\n"],"mappings":"4CAYA,SAAgB,EAAkB,EAAe,GAChD,GAAoB,IAAhB,EAAK,OAAc,OAEvB,IAAI,EAAiC,EAAI,SAAS,KAAM,GAAM,EAAE,KAAO,EAAK,IAC5E,GAAK,EAAL,CAEA,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,IAAK,CACrC,MAAM,EAAU,EAAK,GACrB,IAAK,EAAS,OACd,MAAM,EAA8B,GAAS,SAAS,KACpD,GAAsB,EAAY,IAAM,EAAE,KAAO,GAEnD,IAAK,EAAM,OACX,EAAU,CACX,CAEA,OAAO,CAZc,CAatB,CAQA,SAAgB,EACf,EACA,EACA,GAEA,GAA0B,IAAtB,EAAW,OAAc,CAC5B,MAAM,EAAQ,EAAI,SAAS,GAC3B,OAAO,GAAS,EAAY,GAAS,OAAQ,CAC9C,CACA,MAAM,EAAS,EAAkB,EAAK,GACtC,IAAK,EAAQ,OACb,MAAM,EAAQ,EAAO,SAAS,GAC9B,OAAO,GAAS,EAAY,GAAS,OAAQ,CAC9C,CAMA,SAAgB,EACf,EACA,GAEA,GAAoB,IAAhB,EAAK,OAAc,OAEvB,GAAoB,IAAhB,EAAK,OAAc,CACtB,MAAM,EAAQ,EAAI,SAAS,UAAW,GAAM,EAAE,KAAO,EAAK,IAC1D,IAAc,IAAV,EAAc,OAClB,MAA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,EAAO,GACrC,GAAI,EAAO,OAAO,CACnB,CAED,CAKA,SAAgB,EACf,EACA,GAEA,MAAM,EAAO,EAAa,EAAK,GAC/B,IAAK,EAAM,OACX,MAAM,EAAO,EAAkB,EAAK,GACpC,OAAK,EACE,CAAE,OAAM,aADf,CAED,CAOA,SAAgB,EACf,EACA,EACA,GAEA,MAAM,EAAO,EAAa,EAAK,GAC/B,GAAK,KAAQ,EAAK,OAAS,GAE3B,IAAK,IAAI,EAAI,EAAK,OAAS,EAAG,GAAK,EAAG,IAAK,CAC1C,MAAM,EAAe,EAAK,MAAM,EAAG,EAAI,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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EAAU,GACxD,GAAI,EACH,IAAK,MAAM,KAAS,EAAQ,EAAQ,IAAI,EAE1C,CAED,OAAO,CACR,CAEA,qBAAA,GAEC,OADK,KAAK,qBAAqB,KAAK,WAC7B,KAAK,oCAAuB,IAAI,GACxC,CAEA,uBAAA,GAUC,MAAO,CAAC,KAAK,wBAAyB,KAAK,iBAAkB,KAAK,WACnE,CAEA,4BAAA,GACC,KAAK,oBAAsB,IAC5B,CAIA,KAAA,GACC,KAAK,WAAW,QAChB,KAAK,oBAAoB,QACzB,KAAK,oBAAsB,KAC3B,KAAK,WAAW,QAChB,KAAK,iBAAiB,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,GAC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AA0B,GAClC,OAAO,SAAS,iBAAiB,EAAS,WAAW,SAAU,CAC9D,WAAa,GAER,aAAa,aAAe,EAAE,aAAa,wBAM3C,EAAW,IAzBlB,SAA+B,EAAY,GAC1C,IAAI,EAAsB,EAAK,WAC/B,KAAO,GAAU,IAAW,GAAM,CACjC,GAAI,EAAe,GAClB,OAAO,EAER,EAAS,EAAO,UACjB,CACA,OAAO,CACR,CAkBO,CAAsB,EAAG,IAEzB,aAAa,aAAe,EAAE,aAAa,kBAAoB,IAAM,EATjE,WAAW,cAaf,EAAE,WAAa,KAAK,WAEpB,EAAe,GAFuB,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