@notectl/core 2.4.2 → 2.5.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 (415) hide show
  1. package/dist/chunks/AlignmentPlugin-C26pIVcw.mjs +2 -0
  2. package/dist/chunks/{AlignmentPlugin-Cp7HYGaH.mjs.map → AlignmentPlugin-C26pIVcw.mjs.map} +1 -1
  3. package/dist/chunks/BidiIsolationPlugin-nWd1NEF-.mjs +2 -0
  4. package/dist/chunks/{BidiIsolationPlugin-GWukKdgJ.mjs.map → BidiIsolationPlugin-nWd1NEF-.mjs.map} +1 -1
  5. package/dist/chunks/BlockquotePlugin-Bag42Zc0.mjs +2 -0
  6. package/dist/chunks/{BlockquotePlugin-CSL_7Yit.mjs.map → BlockquotePlugin-Bag42Zc0.mjs.map} +1 -1
  7. package/dist/chunks/CaretNavigationPlugin-DUAoHygg.mjs +2 -0
  8. package/dist/chunks/{CaretNavigationPlugin-BQPqqK4n.mjs.map → CaretNavigationPlugin-DUAoHygg.mjs.map} +1 -1
  9. package/dist/chunks/CodeBlockPlugin-Dk_J8NAl.mjs +2 -0
  10. package/dist/chunks/{CodeBlockPlugin-B4AcDJRK.mjs.map → CodeBlockPlugin-Dk_J8NAl.mjs.map} +1 -1
  11. package/dist/chunks/Commands-vqbwh6Ic.mjs +2 -0
  12. package/dist/chunks/{Commands-Bk7Cl1nH.mjs.map → Commands-vqbwh6Ic.mjs.map} +1 -1
  13. package/dist/chunks/DocumentParser-D4g5npEi.mjs +2 -0
  14. package/dist/chunks/DocumentParser-D4g5npEi.mjs.map +1 -0
  15. package/dist/chunks/EditorUI-DrQI95FW.mjs +2 -0
  16. package/dist/chunks/EditorUI-DrQI95FW.mjs.map +1 -0
  17. package/dist/chunks/FontPlugin-Bzlluh1_.mjs +2 -0
  18. package/dist/chunks/{FontPlugin-BcXNFqqO.mjs.map → FontPlugin-Bzlluh1_.mjs.map} +1 -1
  19. package/dist/chunks/FontSizePlugin-kv3zHG0f.mjs +2 -0
  20. package/dist/chunks/{FontSizePlugin-Dswra3oU.mjs.map → FontSizePlugin-kv3zHG0f.mjs.map} +1 -1
  21. package/dist/chunks/FormulaPlugin-20vW4Gge.mjs +2 -0
  22. package/dist/chunks/{FormulaPlugin-DVpLaKi5.mjs.map → FormulaPlugin-20vW4Gge.mjs.map} +1 -1
  23. package/dist/chunks/GapCursorPlugin-BPyNXY4H.mjs +2 -0
  24. package/dist/chunks/{GapCursorPlugin-QDGwnaRR.mjs.map → GapCursorPlugin-BPyNXY4H.mjs.map} +1 -1
  25. package/dist/chunks/HTMLSanitization-BRipXyhI.mjs +2 -0
  26. package/dist/chunks/HTMLSanitization-BRipXyhI.mjs.map +1 -0
  27. package/dist/chunks/{HardBreakPlugin-gjCq8prD.mjs → HardBreakPlugin-lo8Mcg9G.mjs} +2 -2
  28. package/dist/chunks/{HardBreakPlugin-gjCq8prD.mjs.map → HardBreakPlugin-lo8Mcg9G.mjs.map} +1 -1
  29. package/dist/chunks/HeadingPlugin-CEZF5DBM.mjs +2 -0
  30. package/dist/chunks/{HeadingPlugin-B7EfynaH.mjs.map → HeadingPlugin-CEZF5DBM.mjs.map} +1 -1
  31. package/dist/chunks/HighlightPlugin-yH44UWoe.mjs +2 -0
  32. package/dist/chunks/{HighlightPlugin-LdO0INtJ.mjs.map → HighlightPlugin-yH44UWoe.mjs.map} +1 -1
  33. package/dist/chunks/HorizontalRulePlugin-SNNum-9V.mjs +2 -0
  34. package/dist/chunks/{HorizontalRulePlugin-YywXVZYr.mjs.map → HorizontalRulePlugin-SNNum-9V.mjs.map} +1 -1
  35. package/dist/chunks/ImagePlugin-aeqHr5zx.mjs +2 -0
  36. package/dist/chunks/{ImagePlugin-BAhZuVdE.mjs.map → ImagePlugin-aeqHr5zx.mjs.map} +1 -1
  37. package/dist/chunks/InlineCodePlugin-CIks06ti.mjs +2 -0
  38. package/dist/chunks/{InlineCodePlugin-Bu9-rE4B.mjs.map → InlineCodePlugin-CIks06ti.mjs.map} +1 -1
  39. package/dist/chunks/LinkPlugin-CFw22a9X.mjs +2 -0
  40. package/dist/chunks/LinkPlugin-CFw22a9X.mjs.map +1 -0
  41. package/dist/chunks/ListPlugin-ZNEx8pvk.mjs +2 -0
  42. package/dist/chunks/{ListPlugin-U1r4p_fE.mjs.map → ListPlugin-ZNEx8pvk.mjs.map} +1 -1
  43. package/dist/chunks/LocaleLoader-DEpTFuVc.mjs +2 -0
  44. package/dist/chunks/LocaleLoader-DEpTFuVc.mjs.map +1 -0
  45. package/dist/chunks/{MarkdownHTMLRegistry-BunUDiza.mjs → MarkdownHTMLRegistry-Cj7N2wqs.mjs} +2 -2
  46. package/dist/chunks/{MarkdownHTMLRegistry-BunUDiza.mjs.map → MarkdownHTMLRegistry-Cj7N2wqs.mjs.map} +1 -1
  47. package/dist/chunks/{MarkdownParser-uX1p_GQk.mjs → MarkdownParser-JOfPSvGv.mjs} +2 -2
  48. package/dist/chunks/{MarkdownParser-uX1p_GQk.mjs.map → MarkdownParser-JOfPSvGv.mjs.map} +1 -1
  49. package/dist/chunks/{MarkdownSerializer--MrgJTdJ.mjs → MarkdownSerializer-Y6saYClE.mjs} +2 -2
  50. package/dist/chunks/{MarkdownSerializer--MrgJTdJ.mjs.map → MarkdownSerializer-Y6saYClE.mjs.map} +1 -1
  51. package/dist/chunks/PopupManager-DpxoBl54.mjs +2 -0
  52. package/dist/chunks/PopupManager-DpxoBl54.mjs.map +1 -0
  53. package/dist/chunks/PopupPositioning-CIqgpqlW.mjs.map +1 -1
  54. package/dist/chunks/PrintPlugin-CYkdUy-m.mjs +2 -0
  55. package/dist/chunks/{PrintPlugin-DAEiEyKQ.mjs.map → PrintPlugin-CYkdUy-m.mjs.map} +1 -1
  56. package/dist/chunks/{SchemaRegistry-Cs7rxafF.mjs → SchemaRegistry-CT3T7S1i.mjs} +2 -2
  57. package/dist/chunks/{SchemaRegistry-Cs7rxafF.mjs.map → SchemaRegistry-CT3T7S1i.mjs.map} +1 -1
  58. package/dist/chunks/{SelectionReplacement-vC1xhFS0.mjs → SelectionReplacement-Cj4FLlPz.mjs} +2 -2
  59. package/dist/chunks/{SelectionReplacement-vC1xhFS0.mjs.map → SelectionReplacement-Cj4FLlPz.mjs.map} +1 -1
  60. package/dist/chunks/{SelectionSync-BkjCwGp-.mjs → SelectionSync-8y0nbBHZ.mjs} +2 -2
  61. package/dist/chunks/{SelectionSync-BkjCwGp-.mjs.map → SelectionSync-8y0nbBHZ.mjs.map} +1 -1
  62. package/dist/chunks/SimpleMark-DPTsIl9w.mjs +2 -0
  63. package/dist/chunks/{SimpleMark-D6vz3Nfd.mjs.map → SimpleMark-DPTsIl9w.mjs.map} +1 -1
  64. package/dist/chunks/SmartPastePlugin-BSMHDDQ2.mjs +2 -0
  65. package/dist/chunks/{SmartPastePlugin-BHsYKbgd.mjs.map → SmartPastePlugin-BSMHDDQ2.mjs.map} +1 -1
  66. package/dist/chunks/StrikethroughPlugin-CqqIF3Zk.mjs +2 -0
  67. package/dist/chunks/{StrikethroughPlugin-v-VJZzUZ.mjs.map → StrikethroughPlugin-CqqIF3Zk.mjs.map} +1 -1
  68. package/dist/chunks/SuperSubPlugin-5ZFM6wdU.mjs +2 -0
  69. package/dist/chunks/{SuperSubPlugin-x1iPnZyt.mjs.map → SuperSubPlugin-5ZFM6wdU.mjs.map} +1 -1
  70. package/dist/chunks/{TableDimensions-BSEOEox2.mjs → TableDimensions-B-OWjTuW.mjs} +2 -2
  71. package/dist/chunks/{TableDimensions-BSEOEox2.mjs.map → TableDimensions-B-OWjTuW.mjs.map} +1 -1
  72. package/dist/chunks/TablePlugin-D1Wg-pjl.mjs +2 -0
  73. package/dist/chunks/TablePlugin-D1Wg-pjl.mjs.map +1 -0
  74. package/dist/chunks/TableSelectionTypes-t2cLhe16.mjs +2 -0
  75. package/dist/chunks/TableSelectionTypes-t2cLhe16.mjs.map +1 -0
  76. package/dist/chunks/TextColorPlugin-Dwp7eW7F.mjs +2 -0
  77. package/dist/chunks/{TextColorPlugin-Bnl9of9E.mjs.map → TextColorPlugin-Dwp7eW7F.mjs.map} +1 -1
  78. package/dist/chunks/{TextDirectionAutoPlugin-DOH5cfyy.mjs → TextDirectionAutoPlugin-CkIETM5n.mjs} +2 -2
  79. package/dist/chunks/{TextDirectionAutoPlugin-DOH5cfyy.mjs.map → TextDirectionAutoPlugin-CkIETM5n.mjs.map} +1 -1
  80. package/dist/chunks/TextDirectionPlugin-DAcPR5Qc.mjs +2 -0
  81. package/dist/chunks/{TextDirectionPlugin-JwlR-R-b.mjs.map → TextDirectionPlugin-DAcPR5Qc.mjs.map} +1 -1
  82. package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +2 -0
  83. package/dist/chunks/{TextDirectionService-BcX07mw2.mjs.map → TextDirectionService-OFOU6r_s.mjs.map} +1 -1
  84. package/dist/chunks/TextFormattingPlugin-vml-lduV.mjs +2 -0
  85. package/dist/chunks/{TextFormattingPlugin-Kc_UNoOz.mjs.map → TextFormattingPlugin-vml-lduV.mjs.map} +1 -1
  86. package/dist/chunks/ToolbarPlugin-Cxmb0MFr.mjs +2 -0
  87. package/dist/chunks/ToolbarPlugin-Cxmb0MFr.mjs.map +1 -0
  88. package/dist/chunks/VideoPlugin-lZCBlIon.mjs +2 -0
  89. package/dist/chunks/{VideoPlugin-DJXfuNA9.mjs.map → VideoPlugin-lZCBlIon.mjs.map} +1 -1
  90. package/dist/chunks/ar-Dp1oBWyG.mjs +2 -0
  91. package/dist/chunks/ar-Dp1oBWyG.mjs.map +1 -0
  92. package/dist/chunks/de-D3J8XPCR.mjs +2 -0
  93. package/dist/chunks/de-D3J8XPCR.mjs.map +1 -0
  94. package/dist/chunks/es-Bbz885DZ.mjs +2 -0
  95. package/dist/chunks/es-Bbz885DZ.mjs.map +1 -0
  96. package/dist/chunks/fr-GEgM1j3w.mjs +2 -0
  97. package/dist/chunks/fr-GEgM1j3w.mjs.map +1 -0
  98. package/dist/chunks/full-wDTdOuGt.mjs +2 -0
  99. package/dist/chunks/{full-BsWAZr1w.mjs.map → full-wDTdOuGt.mjs.map} +1 -1
  100. package/dist/chunks/hi-CKg8i4Mm.mjs +2 -0
  101. package/dist/chunks/hi-CKg8i4Mm.mjs.map +1 -0
  102. package/dist/chunks/minimal-FfmHwMGU.mjs +2 -0
  103. package/dist/chunks/{minimal-DO7LiFTa.mjs.map → minimal-FfmHwMGU.mjs.map} +1 -1
  104. package/dist/chunks/nl-2IdjTNeJ.mjs +2 -0
  105. package/dist/chunks/nl-2IdjTNeJ.mjs.map +1 -0
  106. package/dist/chunks/nl-B1i04NvZ.mjs +2 -0
  107. package/dist/chunks/nl-B1i04NvZ.mjs.map +1 -0
  108. package/dist/chunks/nl-BEmzpzKO.mjs +2 -0
  109. package/dist/chunks/nl-BEmzpzKO.mjs.map +1 -0
  110. package/dist/chunks/nl-B_U0D3Qq.mjs +2 -0
  111. package/dist/chunks/nl-B_U0D3Qq.mjs.map +1 -0
  112. package/dist/chunks/nl-C437Xz6z.mjs +2 -0
  113. package/dist/chunks/nl-C437Xz6z.mjs.map +1 -0
  114. package/dist/chunks/nl-C5P8Fogm.mjs +2 -0
  115. package/dist/chunks/nl-C5P8Fogm.mjs.map +1 -0
  116. package/dist/chunks/nl-CST62bzx.mjs +2 -0
  117. package/dist/chunks/nl-CST62bzx.mjs.map +1 -0
  118. package/dist/chunks/nl-CWQT-W-6.mjs +2 -0
  119. package/dist/chunks/nl-CWQT-W-6.mjs.map +1 -0
  120. package/dist/chunks/nl-CdpcDkbM.mjs +2 -0
  121. package/dist/chunks/nl-CdpcDkbM.mjs.map +1 -0
  122. package/dist/chunks/nl-CgYWZnga.mjs +2 -0
  123. package/dist/chunks/nl-CgYWZnga.mjs.map +1 -0
  124. package/dist/chunks/nl-Cr--x8bX.mjs +2 -0
  125. package/dist/chunks/nl-Cr--x8bX.mjs.map +1 -0
  126. package/dist/chunks/nl-Cwl5dxFZ.mjs +2 -0
  127. package/dist/chunks/nl-Cwl5dxFZ.mjs.map +1 -0
  128. package/dist/chunks/nl-Czjd9Bw9.mjs +2 -0
  129. package/dist/chunks/nl-Czjd9Bw9.mjs.map +1 -0
  130. package/dist/chunks/nl-DUOT2ZMQ.mjs +2 -0
  131. package/dist/chunks/nl-DUOT2ZMQ.mjs.map +1 -0
  132. package/dist/chunks/nl-DYnRYvZ5.mjs +2 -0
  133. package/dist/chunks/nl-DYnRYvZ5.mjs.map +1 -0
  134. package/dist/chunks/nl-DaNJ-ffX.mjs +2 -0
  135. package/dist/chunks/nl-DaNJ-ffX.mjs.map +1 -0
  136. package/dist/chunks/nl-DeOJ64xy.mjs +2 -0
  137. package/dist/chunks/nl-DeOJ64xy.mjs.map +1 -0
  138. package/dist/chunks/nl-DwZajfpP.mjs +2 -0
  139. package/dist/chunks/nl-DwZajfpP.mjs.map +1 -0
  140. package/dist/chunks/nl-Dyjc9M7o.mjs +2 -0
  141. package/dist/chunks/nl-Dyjc9M7o.mjs.map +1 -0
  142. package/dist/chunks/nl-GBpv7W4L.mjs +2 -0
  143. package/dist/chunks/nl-GBpv7W4L.mjs.map +1 -0
  144. package/dist/chunks/nl-HFfWJOEo.mjs +2 -0
  145. package/dist/chunks/nl-HFfWJOEo.mjs.map +1 -0
  146. package/dist/chunks/nl-KqmiCeD7.mjs +2 -0
  147. package/dist/chunks/nl-KqmiCeD7.mjs.map +1 -0
  148. package/dist/chunks/nl-_QT7e2Qt.mjs +2 -0
  149. package/dist/chunks/nl-_QT7e2Qt.mjs.map +1 -0
  150. package/dist/chunks/nl-i79IajbC.mjs +2 -0
  151. package/dist/chunks/nl-i79IajbC.mjs.map +1 -0
  152. package/dist/chunks/nl-lcZvrAz6.mjs +2 -0
  153. package/dist/chunks/nl-lcZvrAz6.mjs.map +1 -0
  154. package/dist/chunks/nl-tWJ2imhe.mjs +2 -0
  155. package/dist/chunks/nl-tWJ2imhe.mjs.map +1 -0
  156. package/dist/chunks/nl-xfiNOCgg.mjs +2 -0
  157. package/dist/chunks/nl-xfiNOCgg.mjs.map +1 -0
  158. package/dist/chunks/pt-DP5c76Vo.mjs +2 -0
  159. package/dist/chunks/pt-DP5c76Vo.mjs.map +1 -0
  160. package/dist/chunks/register-DSRtHVkk.mjs +3 -0
  161. package/dist/chunks/register-DSRtHVkk.mjs.map +1 -0
  162. package/dist/chunks/ru--iYEtsT5.mjs +2 -0
  163. package/dist/chunks/ru--iYEtsT5.mjs.map +1 -0
  164. package/dist/chunks/src-DDkRstYh.mjs +2 -0
  165. package/dist/chunks/src-DDkRstYh.mjs.map +1 -0
  166. package/dist/chunks/zh-DUS7JduA.mjs +2 -0
  167. package/dist/chunks/zh-DUS7JduA.mjs.map +1 -0
  168. package/dist/commands/Commands.d.ts +3 -0
  169. package/dist/commands/Commands.d.ts.map +1 -1
  170. package/dist/commands/CompositionCommands.d.ts +14 -8
  171. package/dist/commands/CompositionCommands.d.ts.map +1 -1
  172. package/dist/commands/CompositionFallback.d.ts +13 -0
  173. package/dist/commands/CompositionFallback.d.ts.map +1 -0
  174. package/dist/commands/CompositionRebase.d.ts +17 -10
  175. package/dist/commands/CompositionRebase.d.ts.map +1 -1
  176. package/dist/editor/locales/nl.d.ts +4 -0
  177. package/dist/editor/locales/nl.d.ts.map +1 -0
  178. package/dist/editor/styles/link.d.ts +2 -2
  179. package/dist/editor/styles/link.d.ts.map +1 -1
  180. package/dist/fonts.mjs +1 -1
  181. package/dist/full.mjs +1 -1
  182. package/dist/html.mjs +1 -1
  183. package/dist/i18n/Locale.d.ts +1 -0
  184. package/dist/i18n/Locale.d.ts.map +1 -1
  185. package/dist/input/CompositionController.d.ts.map +1 -1
  186. package/dist/input/HTMLLineBreaks.d.ts +14 -0
  187. package/dist/input/HTMLLineBreaks.d.ts.map +1 -0
  188. package/dist/input/HTMLParser.d.ts +1 -7
  189. package/dist/input/HTMLParser.d.ts.map +1 -1
  190. package/dist/input/PasteHTMLHandler.d.ts +0 -1
  191. package/dist/input/PasteHTMLHandler.d.ts.map +1 -1
  192. package/dist/markdown.mjs +1 -1
  193. package/dist/notectl-core.mjs +1 -1
  194. package/dist/notectl-core.umd.js +1 -1
  195. package/dist/notectl-core.umd.js.map +1 -1
  196. package/dist/plugins/PluginContextFactory.d.ts +1 -0
  197. package/dist/plugins/PluginContextFactory.d.ts.map +1 -1
  198. package/dist/plugins/PluginManager.d.ts +5 -0
  199. package/dist/plugins/PluginManager.d.ts.map +1 -1
  200. package/dist/plugins/alignment/locales/nl.d.ts +4 -0
  201. package/dist/plugins/alignment/locales/nl.d.ts.map +1 -0
  202. package/dist/plugins/alignment.mjs +1 -1
  203. package/dist/plugins/bidi-isolation/locales/nl.d.ts +4 -0
  204. package/dist/plugins/bidi-isolation/locales/nl.d.ts.map +1 -0
  205. package/dist/plugins/bidi-isolation.mjs +1 -1
  206. package/dist/plugins/blockquote/locales/nl.d.ts +4 -0
  207. package/dist/plugins/blockquote/locales/nl.d.ts.map +1 -0
  208. package/dist/plugins/blockquote.mjs +1 -1
  209. package/dist/plugins/caret-navigation/locales/nl.d.ts +4 -0
  210. package/dist/plugins/caret-navigation/locales/nl.d.ts.map +1 -0
  211. package/dist/plugins/caret-navigation.mjs +1 -1
  212. package/dist/plugins/code-block/locales/nl.d.ts +4 -0
  213. package/dist/plugins/code-block/locales/nl.d.ts.map +1 -0
  214. package/dist/plugins/code-block.mjs +1 -1
  215. package/dist/plugins/editor-ui/EditorUI.d.ts +50 -0
  216. package/dist/plugins/editor-ui/EditorUI.d.ts.map +1 -0
  217. package/dist/plugins/editor-ui/EditorUIRuntime.d.ts +44 -0
  218. package/dist/plugins/editor-ui/EditorUIRuntime.d.ts.map +1 -0
  219. package/dist/plugins/editor-ui/index.d.ts +6 -0
  220. package/dist/plugins/editor-ui/index.d.ts.map +1 -0
  221. package/dist/plugins/font/locales/nl.d.ts +4 -0
  222. package/dist/plugins/font/locales/nl.d.ts.map +1 -0
  223. package/dist/plugins/font-size/locales/nl.d.ts +4 -0
  224. package/dist/plugins/font-size/locales/nl.d.ts.map +1 -0
  225. package/dist/plugins/font-size.mjs +1 -1
  226. package/dist/plugins/font.mjs +1 -1
  227. package/dist/plugins/formula/locales/nl.d.ts +4 -0
  228. package/dist/plugins/formula/locales/nl.d.ts.map +1 -0
  229. package/dist/plugins/formula.mjs +1 -1
  230. package/dist/plugins/gap-cursor/locales/nl.d.ts +4 -0
  231. package/dist/plugins/gap-cursor/locales/nl.d.ts.map +1 -0
  232. package/dist/plugins/gap-cursor.mjs +1 -1
  233. package/dist/plugins/hard-break.mjs +1 -1
  234. package/dist/plugins/heading/locales/nl.d.ts +4 -0
  235. package/dist/plugins/heading/locales/nl.d.ts.map +1 -0
  236. package/dist/plugins/heading.mjs +1 -1
  237. package/dist/plugins/highlight/locales/nl.d.ts +4 -0
  238. package/dist/plugins/highlight/locales/nl.d.ts.map +1 -0
  239. package/dist/plugins/highlight.mjs +1 -1
  240. package/dist/plugins/horizontal-rule/locales/nl.d.ts +4 -0
  241. package/dist/plugins/horizontal-rule/locales/nl.d.ts.map +1 -0
  242. package/dist/plugins/horizontal-rule.mjs +1 -1
  243. package/dist/plugins/image/locales/nl.d.ts +4 -0
  244. package/dist/plugins/image/locales/nl.d.ts.map +1 -0
  245. package/dist/plugins/image.mjs +1 -1
  246. package/dist/plugins/inline-code/locales/nl.d.ts +4 -0
  247. package/dist/plugins/inline-code/locales/nl.d.ts.map +1 -0
  248. package/dist/plugins/inline-code.mjs +1 -1
  249. package/dist/plugins/link/{LinkPreview.d.ts → LinkBubble.d.ts} +10 -7
  250. package/dist/plugins/link/LinkBubble.d.ts.map +1 -0
  251. package/dist/plugins/link/LinkBubbleContent.d.ts +4 -0
  252. package/dist/plugins/link/LinkBubbleContent.d.ts.map +1 -0
  253. package/dist/plugins/link/LinkInteractionController.d.ts +17 -3
  254. package/dist/plugins/link/LinkInteractionController.d.ts.map +1 -1
  255. package/dist/plugins/link/LinkLocale.d.ts +3 -0
  256. package/dist/plugins/link/LinkLocale.d.ts.map +1 -1
  257. package/dist/plugins/link/LinkPlugin.d.ts +0 -1
  258. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  259. package/dist/plugins/link/LinkRange.d.ts +12 -0
  260. package/dist/plugins/link/LinkRange.d.ts.map +1 -0
  261. package/dist/plugins/link/locales/ar.d.ts.map +1 -1
  262. package/dist/plugins/link/locales/de.d.ts.map +1 -1
  263. package/dist/plugins/link/locales/es.d.ts.map +1 -1
  264. package/dist/plugins/link/locales/fr.d.ts.map +1 -1
  265. package/dist/plugins/link/locales/hi.d.ts.map +1 -1
  266. package/dist/plugins/link/locales/nl.d.ts +4 -0
  267. package/dist/plugins/link/locales/nl.d.ts.map +1 -0
  268. package/dist/plugins/link/locales/pt.d.ts.map +1 -1
  269. package/dist/plugins/link/locales/ru.d.ts.map +1 -1
  270. package/dist/plugins/link/locales/zh.d.ts.map +1 -1
  271. package/dist/plugins/link.mjs +1 -1
  272. package/dist/plugins/list/locales/nl.d.ts +4 -0
  273. package/dist/plugins/list/locales/nl.d.ts.map +1 -0
  274. package/dist/plugins/list.mjs +1 -1
  275. package/dist/plugins/print/locales/nl.d.ts +4 -0
  276. package/dist/plugins/print/locales/nl.d.ts.map +1 -0
  277. package/dist/plugins/print.mjs +1 -1
  278. package/dist/plugins/shared/PopupManager.d.ts +15 -2
  279. package/dist/plugins/shared/PopupManager.d.ts.map +1 -1
  280. package/dist/plugins/shared/PopupPositioning.d.ts +2 -6
  281. package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -1
  282. package/dist/plugins/shared/index.d.ts +1 -1
  283. package/dist/plugins/shared/index.d.ts.map +1 -1
  284. package/dist/plugins/shared.mjs +1 -1
  285. package/dist/plugins/smart-paste/locales/nl.d.ts +4 -0
  286. package/dist/plugins/smart-paste/locales/nl.d.ts.map +1 -0
  287. package/dist/plugins/smart-paste.mjs +1 -1
  288. package/dist/plugins/strikethrough/locales/nl.d.ts +4 -0
  289. package/dist/plugins/strikethrough/locales/nl.d.ts.map +1 -0
  290. package/dist/plugins/strikethrough.mjs +1 -1
  291. package/dist/plugins/super-sub/locales/nl.d.ts +4 -0
  292. package/dist/plugins/super-sub/locales/nl.d.ts.map +1 -0
  293. package/dist/plugins/super-sub.mjs +1 -1
  294. package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
  295. package/dist/plugins/table/TableSelection.d.ts +4 -20
  296. package/dist/plugins/table/TableSelection.d.ts.map +1 -1
  297. package/dist/plugins/table/TableSelectionTypes.d.ts +21 -0
  298. package/dist/plugins/table/TableSelectionTypes.d.ts.map +1 -0
  299. package/dist/plugins/table/locales/nl.d.ts +4 -0
  300. package/dist/plugins/table/locales/nl.d.ts.map +1 -0
  301. package/dist/plugins/table.mjs +1 -1
  302. package/dist/plugins/text-color/locales/nl.d.ts +4 -0
  303. package/dist/plugins/text-color/locales/nl.d.ts.map +1 -0
  304. package/dist/plugins/text-color.mjs +1 -1
  305. package/dist/plugins/text-direction/locales/nl.d.ts +4 -0
  306. package/dist/plugins/text-direction/locales/nl.d.ts.map +1 -0
  307. package/dist/plugins/text-direction-auto.mjs +1 -1
  308. package/dist/plugins/text-direction.mjs +1 -1
  309. package/dist/plugins/text-formatting/locales/nl.d.ts +4 -0
  310. package/dist/plugins/text-formatting/locales/nl.d.ts.map +1 -0
  311. package/dist/plugins/text-formatting.mjs +1 -1
  312. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +2 -2
  313. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
  314. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +2 -1
  315. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  316. package/dist/plugins/toolbar/ToolbarPopupController.d.ts +8 -3
  317. package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
  318. package/dist/plugins/toolbar/ToolbarRegistry.d.ts +4 -0
  319. package/dist/plugins/toolbar/ToolbarRegistry.d.ts.map +1 -1
  320. package/dist/plugins/toolbar/locales/nl.d.ts +4 -0
  321. package/dist/plugins/toolbar/locales/nl.d.ts.map +1 -0
  322. package/dist/plugins/toolbar.mjs +1 -1
  323. package/dist/plugins/video/locales/nl.d.ts +4 -0
  324. package/dist/plugins/video/locales/nl.d.ts.map +1 -0
  325. package/dist/plugins/video.mjs +1 -1
  326. package/dist/presets/full.mjs +1 -1
  327. package/dist/presets/minimal.mjs +1 -1
  328. package/dist/presets.mjs +1 -1
  329. package/dist/register.mjs +1 -1
  330. package/dist/serialization/DocumentParser.d.ts +2 -2
  331. package/dist/serialization/DocumentParser.d.ts.map +1 -1
  332. package/dist/serialization/HTMLParseRules.d.ts.map +1 -1
  333. package/dist/serialization/HTMLSanitization.d.ts +6 -0
  334. package/dist/serialization/HTMLSanitization.d.ts.map +1 -1
  335. package/dist/serialization/PreformattedText.d.ts +3 -0
  336. package/dist/serialization/PreformattedText.d.ts.map +1 -0
  337. package/dist/state/RangeMapping.d.ts +10 -0
  338. package/dist/state/RangeMapping.d.ts.map +1 -0
  339. package/dist/ui.d.ts +3 -0
  340. package/dist/ui.d.ts.map +1 -0
  341. package/dist/ui.mjs +1 -0
  342. package/dist/view/EditorInteraction.d.ts +23 -0
  343. package/dist/view/EditorInteraction.d.ts.map +1 -0
  344. package/dist/view/EditorView.d.ts +2 -0
  345. package/dist/view/EditorView.d.ts.map +1 -1
  346. package/dist/view/SelectionGeometry.d.ts +29 -0
  347. package/dist/view/SelectionGeometry.d.ts.map +1 -0
  348. package/dist/view/SelectionObserver.d.ts +19 -0
  349. package/dist/view/SelectionObserver.d.ts.map +1 -0
  350. package/dist/view/SelectionSync.d.ts +7 -0
  351. package/dist/view/SelectionSync.d.ts.map +1 -1
  352. package/package.json +6 -2
  353. package/dist/chunks/AlignmentPlugin-Cp7HYGaH.mjs +0 -2
  354. package/dist/chunks/BidiIsolationPlugin-GWukKdgJ.mjs +0 -2
  355. package/dist/chunks/BlockquotePlugin-CSL_7Yit.mjs +0 -2
  356. package/dist/chunks/CaretNavigationPlugin-BQPqqK4n.mjs +0 -2
  357. package/dist/chunks/CodeBlockPlugin-B4AcDJRK.mjs +0 -2
  358. package/dist/chunks/Commands-Bk7Cl1nH.mjs +0 -2
  359. package/dist/chunks/DocumentParser-C99N0MWF.mjs +0 -2
  360. package/dist/chunks/DocumentParser-C99N0MWF.mjs.map +0 -1
  361. package/dist/chunks/FontPlugin-BcXNFqqO.mjs +0 -2
  362. package/dist/chunks/FontSizePlugin-Dswra3oU.mjs +0 -2
  363. package/dist/chunks/FormulaPlugin-DVpLaKi5.mjs +0 -2
  364. package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs +0 -2
  365. package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs +0 -2
  366. package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs.map +0 -1
  367. package/dist/chunks/HeadingPlugin-B7EfynaH.mjs +0 -2
  368. package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs +0 -2
  369. package/dist/chunks/HorizontalRulePlugin-YywXVZYr.mjs +0 -2
  370. package/dist/chunks/ImagePlugin-BAhZuVdE.mjs +0 -2
  371. package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs +0 -2
  372. package/dist/chunks/LinkPlugin-CAUaWW5-.mjs +0 -2
  373. package/dist/chunks/LinkPlugin-CAUaWW5-.mjs.map +0 -1
  374. package/dist/chunks/ListPlugin-U1r4p_fE.mjs +0 -2
  375. package/dist/chunks/PluginHelpers-B3gk3VB3.mjs +0 -2
  376. package/dist/chunks/PluginHelpers-B3gk3VB3.mjs.map +0 -1
  377. package/dist/chunks/PopupManager-Dxv0OVMo.mjs +0 -2
  378. package/dist/chunks/PopupManager-Dxv0OVMo.mjs.map +0 -1
  379. package/dist/chunks/PrintPlugin-DAEiEyKQ.mjs +0 -2
  380. package/dist/chunks/SimpleMark-D6vz3Nfd.mjs +0 -2
  381. package/dist/chunks/SmartPastePlugin-BHsYKbgd.mjs +0 -2
  382. package/dist/chunks/StrikethroughPlugin-v-VJZzUZ.mjs +0 -2
  383. package/dist/chunks/SuperSubPlugin-x1iPnZyt.mjs +0 -2
  384. package/dist/chunks/TablePlugin-CjKThPug.mjs +0 -2
  385. package/dist/chunks/TablePlugin-CjKThPug.mjs.map +0 -1
  386. package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs +0 -2
  387. package/dist/chunks/TextDirectionPlugin-JwlR-R-b.mjs +0 -2
  388. package/dist/chunks/TextDirectionService-BcX07mw2.mjs +0 -2
  389. package/dist/chunks/TextFormattingPlugin-Kc_UNoOz.mjs +0 -2
  390. package/dist/chunks/ToolbarPlugin-CgZA2hz8.mjs +0 -2
  391. package/dist/chunks/ToolbarPlugin-CgZA2hz8.mjs.map +0 -1
  392. package/dist/chunks/VideoPlugin-DJXfuNA9.mjs +0 -2
  393. package/dist/chunks/ar-DhwCFHql.mjs +0 -2
  394. package/dist/chunks/ar-DhwCFHql.mjs.map +0 -1
  395. package/dist/chunks/de-CjLUbQmg.mjs +0 -2
  396. package/dist/chunks/de-CjLUbQmg.mjs.map +0 -1
  397. package/dist/chunks/es-CMSzvjOT.mjs +0 -2
  398. package/dist/chunks/es-CMSzvjOT.mjs.map +0 -1
  399. package/dist/chunks/fr-DB_OvHWH.mjs +0 -2
  400. package/dist/chunks/fr-DB_OvHWH.mjs.map +0 -1
  401. package/dist/chunks/full-BsWAZr1w.mjs +0 -2
  402. package/dist/chunks/hi-ChNQZZ1z.mjs +0 -2
  403. package/dist/chunks/hi-ChNQZZ1z.mjs.map +0 -1
  404. package/dist/chunks/minimal-DO7LiFTa.mjs +0 -2
  405. package/dist/chunks/pt-CI8t6oul.mjs +0 -2
  406. package/dist/chunks/pt-CI8t6oul.mjs.map +0 -1
  407. package/dist/chunks/register-DXLu8Njp.mjs +0 -3
  408. package/dist/chunks/register-DXLu8Njp.mjs.map +0 -1
  409. package/dist/chunks/ru-9WtNGZtl.mjs +0 -2
  410. package/dist/chunks/ru-9WtNGZtl.mjs.map +0 -1
  411. package/dist/chunks/src-5GKFQ2mQ.mjs +0 -2
  412. package/dist/chunks/src-5GKFQ2mQ.mjs.map +0 -1
  413. package/dist/chunks/zh-BrqJ4ywP.mjs +0 -2
  414. package/dist/chunks/zh-BrqJ4ywP.mjs.map +0 -1
  415. package/dist/plugins/link/LinkPreview.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownSerializer--MrgJTdJ.mjs","names":["__exportAll","normalizeHTMLId","INLINE_STYLE_EXPORT_CONTEXT","isLeafBlock","getBlockChildren","markSetsEqual","getInlineChildren","createTextNode","getBlockText","isInlineNode","isNodeOfType","buildMarkOrder","normalizeSerializedTableDimensionPx","hasExplicitTableColumnWidth","serializeDocumentToHTML","serializeMarksToHTML","SETEXT_H2","SETEXT_H1","THEMATIC_BREAK","FENCE_OPEN","resolveMarkdownHTMLRegistry","resolveSerializeOptions","options","flavor","gfm","htmlFallback","headingStyle","bullet","emphasis","codeFence","listIndent","exportContext","opts","ALWAYS_ESCAPE","Set","isIntraWord","text","i","prev","next","test","escapeInline","out","length","ch","has","LINE_START_MARKER","LINE_START_BULLET","LINE_START_ORDERED","escapeLineStart","line","replace","_m","ws","marker","sp","num","reparsesAsBlockLine","escapeLinkDestination","url","escapeLinkTitle","title","isStackMark","mark","t","type","delimiters","ctx","open","repeat","close","href","String","attrs","isMixable","marksEqual","a","b","JSON","stringify","stackMarksOf","node","link","marks","push","reorderToActive","active","result","remaining","splice","idx","findIndex","m","found","renderTextContent","some","content","fence","longest","current","Math","max","codeSpanFence","startsWith","endsWith","trim","wrapCodeSpan","fallbackMarks","filter","registry","markOrder","serializeInlineNode","inlineType","src","alt","titlePart","serializeInlineImage","spec","getInlineNodeSpec","md","toMarkdown","toHTMLString","mergeAdjacent","children","child","siblingHasMark","withoutMarks","strip","s","expelNodeWhitespace","flanking","isFlankingMark","leadLen","leadingWhitespace","trailLen","trailingWhitespace","lead","slice","core","trail","serializeInlineContent","merged","expelEdgeWhitespace","closeFrom","keep","target","serializeBlocks","blocks","parts","block","items","item","hasHTMLIdInTree","serializeHTMLFallback","serializeListGroup","serializeBlock","p","join","split","map","serializeParagraph","level","floor","clampLevel","hashes","serializeHeading","lang","language","code","fenceChar","c","longestRun","serializeCodeBlock","inListItem","width","height","align","html","getNodeSpec","toHTML","serializeImage","serializeBlockquote","rows","row","cell","colspan","rowspan","hasSpannedCells","table","columnWidthsPx","minHeightPx","hasExplicitTableDimensions","matrix","serializeCell","columns","reduce","renderRow","cells","padded","headerRow","Array","from","_v","col","alignMarker","columnAlign","serializeTable","serializeTitleLike","serializeUnknownBlock","htmlId","includeBlockIds","lines","counters","contentColumns","previousIndent","listType","storedIndent","indent","min","padWidth","pad","checked","markerWidth","inner","contentPad","innerLines","li","innerLine","MarkdownSerializer_exports","serializeDocumentToMarkdown","doc","markdown","trimmed","finalizeDocument"],"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 { INLINE_STYLE_EXPORT_CONTEXT } from '../../model/HTMLUtils.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/** 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_STYLE_EXPORT_CONTEXT,\n\t\t);\n\t}\n\t// htmlFallback off: keep text, drop styling.\n\treturn escapeInline(node.text, gfm);\n}\n\n/** Serializes a single inline node (hard break, inline image, math, plugin extensions). */\nfunction serializeInlineNode(node: InlineNode, ctx: SerContext): string {\n\tif (node.inlineType === 'hard_break') return '\\\\\\n';\n\tif (node.inlineType === 'image_inline') return serializeInlineImage(node, ctx);\n\n\tconst spec = ctx.registry?.getInlineNodeSpec(node.inlineType);\n\tconst md: string | null | undefined = spec?.toMarkdown?.(node, exportContext(ctx.opts));\n\tif (md != null) return md;\n\n\tif (ctx.opts.htmlFallback && spec?.toHTMLString) return spec.toHTMLString(node);\n\treturn '';\n}\n\n/** Serializes an inline image node to `![alt](src \"title\")` (engine-owned standard construct). */\nfunction serializeInlineImage(node: InlineNode, ctx: SerContext): string {\n\tconst src: string = String(node.attrs.src ?? '');\n\tconst alt: string = String(node.attrs.alt ?? '');\n\tconst title: string = String(node.attrs.title ?? '');\n\tconst titlePart: string = title ? ` \"${escapeLinkTitle(title)}\"` : '';\n\treturn `![${escapeInline(alt, ctx.opts.gfm)}](${escapeLinkDestination(src)}${titlePart})`;\n}\n\n/** Merges adjacent text nodes with identical mark sets; inline nodes are boundaries. */\nfunction mergeAdjacent(children: readonly (TextNode | InlineNode)[]): (TextNode | InlineNode)[] {\n\tconst result: (TextNode | InlineNode)[] = [];\n\tfor (const child of children) {\n\t\tconst prev = result[result.length - 1];\n\t\tif (\n\t\t\t!isInlineNode(child) &&\n\t\t\tprev &&\n\t\t\t!isInlineNode(prev) &&\n\t\t\tmarkSetsEqual(prev.marks, child.marks)\n\t\t) {\n\t\t\tresult[result.length - 1] = { type: 'text', text: prev.text + child.text, marks: prev.marks };\n\t\t} else {\n\t\t\tresult.push(child);\n\t\t}\n\t}\n\treturn result;\n}\n\n/** A flanking-sensitive emphasis mark (bold/italic/strike) whose delimiters must hug non-whitespace. */\nfunction isFlankingMark(mark: Mark, gfm: boolean): boolean {\n\treturn isStackMark(mark, gfm) && mark.type !== 'link';\n}\n\n/** Whether a sibling carries a mark equal to `mark` (false for inline nodes / no sibling). */\nfunction siblingHasMark(node: TextNode | InlineNode | undefined, mark: Mark): boolean {\n\tif (!node || isInlineNode(node)) return false;\n\treturn node.marks.some((m) => marksEqual(m, mark));\n}\n\n/** Length of the leading run of ASCII/Unicode whitespace in `text`. */\nfunction leadingWhitespace(text: string): number {\n\tlet i = 0;\n\twhile (i < text.length && /\\s/.test(text[i] as string)) i++;\n\treturn i;\n}\n\n/** Length of the trailing run of whitespace in `text`. */\nfunction trailingWhitespace(text: string): number {\n\tlet i: number = text.length;\n\twhile (i > 0 && /\\s/.test(text[i - 1] as string)) i--;\n\treturn text.length - i;\n}\n\n/** Returns `marks` with every mark in `strip` removed. */\nfunction withoutMarks(marks: readonly Mark[], strip: readonly Mark[]): Mark[] {\n\tif (strip.length === 0) return [...marks];\n\treturn marks.filter((m) => !strip.some((s) => marksEqual(s, m)));\n}\n\n/** Splits one text node's edge whitespace out of its flanking emphasis marks. */\nfunction expelNodeWhitespace(\n\tnode: TextNode,\n\tprev: TextNode | InlineNode | undefined,\n\tnext: TextNode | InlineNode | undefined,\n\tgfm: boolean,\n\tout: (TextNode | InlineNode)[],\n): void {\n\tconst flanking: Mark[] = node.marks.filter((m) => isFlankingMark(m, gfm));\n\tif (flanking.length === 0) {\n\t\tout.push(node);\n\t\treturn;\n\t}\n\n\tconst text: string = node.text;\n\tconst leadLen: number = leadingWhitespace(text);\n\n\t// All whitespace: a flanking mark survives only when interior on BOTH sides\n\t// (a same-mark neighbor before and after); otherwise it is expelled.\n\tif (leadLen === text.length) {\n\t\tconst strip: Mark[] = flanking.filter(\n\t\t\t(m) => !(siblingHasMark(prev, m) && siblingHasMark(next, m)),\n\t\t);\n\t\tout.push(createTextNode(text, withoutMarks(node.marks, strip)));\n\t\treturn;\n\t}\n\n\tconst trailLen: number = trailingWhitespace(text);\n\tconst lead: string = text.slice(0, leadLen);\n\tconst core: string = text.slice(leadLen, text.length - trailLen);\n\tconst trail: string = text.slice(text.length - trailLen);\n\n\tif (lead) {\n\t\tconst strip: Mark[] = flanking.filter((m) => !siblingHasMark(prev, m));\n\t\tout.push(createTextNode(lead, withoutMarks(node.marks, strip)));\n\t}\n\tout.push(createTextNode(core, node.marks));\n\tif (trail) {\n\t\tconst strip: Mark[] = flanking.filter((m) => !siblingHasMark(next, m));\n\t\tout.push(createTextNode(trail, withoutMarks(node.marks, strip)));\n\t}\n}\n\n/**\n * Expels whitespace from the edges of flanking-sensitive emphasis spans\n * (bold/italic/strikethrough). A `**` delimiter that hugs whitespace\n * (`**end **`) is not flanking, so CommonMark — and this engine's own parser —\n * read it literally, breaking the round-trip. Whitespace at a mark's span\n * boundary is moved outside the mark; whitespace interior to a span is kept.\n */\nfunction expelEdgeWhitespace(\n\tchildren: readonly (TextNode | InlineNode)[],\n\tgfm: boolean,\n): (TextNode | InlineNode)[] {\n\tconst out: (TextNode | InlineNode)[] = [];\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (!child) continue;\n\t\tif (isInlineNode(child)) {\n\t\t\tout.push(child);\n\t\t\tcontinue;\n\t\t}\n\t\texpelNodeWhitespace(child, children[i - 1], children[i + 1], gfm, out);\n\t}\n\treturn mergeAdjacent(out);\n}\n\n/** Serializes inline children of a leaf block to a Markdown string. */\nexport function serializeInlineContent(\n\tchildren: readonly (TextNode | InlineNode)[],\n\tctx: SerContext,\n): string {\n\tconst gfm: boolean = ctx.opts.gfm;\n\tconst merged: (TextNode | InlineNode)[] = expelEdgeWhitespace(mergeAdjacent(children), gfm);\n\tlet out = '';\n\tlet active: Mark[] = [];\n\n\tconst closeFrom = (keep: number): void => {\n\t\tfor (let i = active.length - 1; i >= keep; i--) {\n\t\t\tconst mark = active[i];\n\t\t\tif (mark) out += delimiters(mark, ctx).close;\n\t\t}\n\t\tactive = active.slice(0, keep);\n\t};\n\n\tfor (const child of merged) {\n\t\t// Inline nodes carry stack marks too (e.g. a `link` on an inline image), so\n\t\t// they flow through the same open/close reconciliation as text. The only\n\t\t// difference is the literal content emitted between the delimiters.\n\t\tconst target: Mark[] = reorderToActive(stackMarksOf(child, gfm), active);\n\n\t\tlet keep = 0;\n\t\twhile (\n\t\t\tkeep < active.length &&\n\t\t\tkeep < target.length &&\n\t\t\tmarksEqual(active[keep] as Mark, target[keep] as Mark)\n\t\t) {\n\t\t\tkeep++;\n\t\t}\n\t\tcloseFrom(keep);\n\t\tfor (let i = keep; i < target.length; i++) {\n\t\t\tconst mark = target[i];\n\t\t\tif (!mark) continue;\n\t\t\tout += delimiters(mark, ctx).open;\n\t\t\tactive.push(mark);\n\t\t}\n\n\t\tout += isInlineNode(child) ? serializeInlineNode(child, ctx) : renderTextContent(child, ctx);\n\t}\n\n\tcloseFrom(0);\n\treturn out;\n}\n","/**\n * Block-level Markdown serialization.\n *\n * Leaf/self-contained blocks (paragraph, heading, code_block, horizontal_rule,\n * image) have built-in emitters keyed by type name — the same centralized,\n * by-type-name mapping the importer uses, and the shape `prosemirror-markdown`\n * uses. Container/structural blocks (blockquote, list, table) are engine-owned\n * because their children need per-line prefixing/indentation that cannot be\n * composed from a wrapper (D12): each container serializes its own children and\n * applies its prefix to those known lines (never a post-hoc regex on assembled\n * output). Unknown/superset blocks defer to the per-spec `toMarkdown` hook, then\n * to a raw-HTML fallback via `toHTML` (D3, D4).\n */\n\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport {\n\tgetBlockChildren,\n\tgetBlockText,\n\tgetInlineChildren,\n\tisLeafBlock,\n} from '../../model/Document.js';\nimport { normalizeHTMLId } from '../../model/HTMLUtils.js';\nimport { serializeDocumentToHTML } from '../DocumentSerializer.js';\nimport {\n\thasExplicitTableColumnWidth,\n\tnormalizeSerializedTableDimensionPx,\n} from '../TableDimensions.js';\nimport { serializeInlineContent } from './InlineSerializers.js';\nimport { type SerContext, exportContext } from './MarkdownContext.js';\nimport {\n\tescapeInline,\n\tescapeLineStart,\n\tescapeLinkDestination,\n\tescapeLinkTitle,\n} from './MarkdownEscape.js';\nimport { resolveMarkdownHTMLRegistry } from './MarkdownHTMLRegistry.js';\n\n/** Serializes a sequence of blocks, grouping consecutive list items, joined by blank lines. */\nexport function serializeBlocks(blocks: readonly BlockNode[], ctx: SerContext): string {\n\tconst parts: string[] = [];\n\tlet i = 0;\n\twhile (i < blocks.length) {\n\t\tconst block: BlockNode | undefined = blocks[i];\n\t\tif (!block) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isNodeOfType(block, 'list_item')) {\n\t\t\tconst items: BlockNode[] = [];\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst item: BlockNode | undefined = blocks[i];\n\t\t\t\tif (!item || !isNodeOfType(item, 'list_item')) break;\n\t\t\t\titems.push(item);\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tparts.push(\n\t\t\t\tctx.opts.htmlFallback && items.some(hasHTMLIdInTree)\n\t\t\t\t\t? serializeHTMLFallback(items, ctx)\n\t\t\t\t\t: serializeListGroup(items, ctx),\n\t\t\t);\n\t\t} else {\n\t\t\tparts.push(serializeBlock(block, ctx));\n\t\t\ti++;\n\t\t}\n\t}\n\treturn parts.filter((p) => p.length > 0).join('\\n\\n');\n}\n\n/** Serializes a single (non-list-item) block. */\nexport function serializeBlock(block: BlockNode, ctx: SerContext): string {\n\tif (ctx.opts.htmlFallback && hasHTMLIdInTree(block)) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\tconst type: string = block.type;\n\n\tif (type === 'paragraph') return serializeParagraph(block, ctx);\n\tif (type === 'heading') return serializeHeading(block, ctx);\n\tif (type === 'code_block') return serializeCodeBlock(block, ctx);\n\tif (type === 'horizontal_rule') return ctx.inListItem ? '***' : '---';\n\tif (type === 'image') return serializeImage(block, ctx);\n\tif (type === 'blockquote') return serializeBlockquote(block, ctx);\n\tif (type === 'table') return serializeTable(block, ctx);\n\tif (type === 'title') return serializeTitleLike(block, ctx, 1);\n\tif (type === 'subtitle') return serializeTitleLike(block, ctx, 2);\n\n\treturn serializeUnknownBlock(block, ctx);\n}\n\n/** Whether a block subtree carries HTML-only identity that Markdown cannot express. */\nfunction hasHTMLIdInTree(block: BlockNode): boolean {\n\tif (normalizeHTMLId(block.htmlId)) return true;\n\treturn getBlockChildren(block).some(hasHTMLIdInTree);\n}\n\n/** Emits a complete block run as raw HTML without leaking internal block IDs. */\nfunction serializeHTMLFallback(blocks: readonly BlockNode[], ctx: SerContext): string {\n\treturn serializeDocumentToHTML({ children: blocks }, resolveMarkdownHTMLRegistry(ctx.registry), {\n\t\tincludeBlockIds: false,\n\t});\n}\n\n/** Paragraph: inline content with leading block markers escaped per line. */\nfunction serializeParagraph(block: BlockNode, ctx: SerContext): string {\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx);\n\tif (content.trim() === '') return '';\n\treturn content.split('\\n').map(escapeLineStart).join('\\n');\n}\n\n/** Heading: ATX (`## h`) by default, setext for levels 1-2 when requested. */\nfunction serializeHeading(block: BlockNode, ctx: SerContext): string {\n\tconst level: number = clampLevel((block.attrs?.level as number | undefined) ?? 1);\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx).replace(/\\n/g, ' ');\n\n\tif (ctx.opts.headingStyle === 'setext' && level <= 2 && content !== '') {\n\t\tconst underline: string = level === 1 ? '=' : '-';\n\t\treturn `${content}\\n${underline.repeat(Math.max(3, content.length))}`;\n\t}\n\tconst hashes: string = '#'.repeat(level);\n\treturn content ? `${hashes} ${content}` : hashes;\n}\n\nfunction clampLevel(level: number): number {\n\tif (level < 1) return 1;\n\tif (level > 6) return 6;\n\treturn Math.floor(level);\n}\n\n/** Fenced code block; the fence is grown to exceed any fence run inside the code. */\nfunction serializeCodeBlock(block: BlockNode, ctx: SerContext): string {\n\tconst lang: string = String(block.attrs?.language ?? '');\n\tconst code: string = getBlockText(block);\n\tconst fenceChar: string = ctx.opts.codeFence[0] ?? '`';\n\tconst fence: string = fenceChar.repeat(Math.max(3, longestRun(code, fenceChar) + 1));\n\treturn `${fence}${lang}\\n${code}\\n${fence}`;\n}\n\n/** Length of the longest consecutive run of `ch` in `text`. */\nfunction longestRun(text: string, ch: string): number {\n\tlet longest = 0;\n\tlet current = 0;\n\tfor (const c of text) {\n\t\tif (c === ch) {\n\t\t\tcurrent++;\n\t\t\tlongest = Math.max(longest, current);\n\t\t} else {\n\t\t\tcurrent = 0;\n\t\t}\n\t}\n\treturn longest;\n}\n\n/** Standalone image on its own line; styling-bearing images use HTML fallback (D3). */\nfunction serializeImage(block: BlockNode, ctx: SerContext): string {\n\tconst src: string = String(block.attrs?.src ?? '');\n\tconst alt: string = String(block.attrs?.alt ?? '');\n\tconst title: string = String(block.attrs?.title ?? '');\n\tconst width = block.attrs?.width as number | undefined;\n\tconst height = block.attrs?.height as number | undefined;\n\tconst align = block.attrs?.align as string | undefined;\n\tconst hasStyling: boolean =\n\t\twidth !== undefined || height !== undefined || (align !== undefined && align !== 'center');\n\n\tif (hasStyling && ctx.opts.htmlFallback) {\n\t\tconst html: string | undefined = ctx.registry?.getNodeSpec('image')?.toHTML?.(block, '');\n\t\tif (html) return html;\n\t}\n\n\tconst titlePart: string = title ? ` \"${escapeLinkTitle(title)}\"` : '';\n\treturn `![${escapeInline(alt, ctx.opts.gfm)}](${escapeLinkDestination(src)}${titlePart})`;\n}\n\n/** Blockquote container: serialize children, then prefix every line with `> `. */\nfunction serializeBlockquote(block: BlockNode, ctx: SerContext): string {\n\tconst inner: string = serializeBlocks(getBlockChildren(block), ctx);\n\treturn inner\n\t\t.split('\\n')\n\t\t.map((line) => (line === '' ? '>' : `> ${line}`))\n\t\t.join('\\n');\n}\n\n/** title/subtitle: HTML fallback (`<h1 class>`) by default; degrade to `#`/`##` otherwise (D5). */\nfunction serializeTitleLike(block: BlockNode, ctx: SerContext, level: number): string {\n\tif (ctx.opts.htmlFallback) {\n\t\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx);\n\t\tconst html: string | undefined = ctx.registry\n\t\t\t?.getNodeSpec(block.type)\n\t\t\t?.toHTML?.(block, content);\n\t\tif (html) return html;\n\t}\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx).replace(/\\n/g, ' ');\n\tconst hashes: string = '#'.repeat(level);\n\treturn content ? `${hashes} ${content}` : hashes;\n}\n\n/** Unknown / superset block: per-spec `toMarkdown` hook, then raw-HTML fallback, then degrade. */\nfunction serializeUnknownBlock(block: BlockNode, ctx: SerContext): string {\n\tconst spec = ctx.registry?.getNodeSpec(block.type);\n\tconst content: string = isLeafBlock(block)\n\t\t? serializeInlineContent(getInlineChildren(block), ctx)\n\t\t: serializeBlocks(getBlockChildren(block), ctx);\n\n\tconst md: string | null | undefined = spec?.toMarkdown?.(block, content, exportContext(ctx.opts));\n\tif (md != null) return md;\n\n\tif (ctx.opts.htmlFallback && spec?.toHTML) return spec.toHTML(block, content);\n\n\t// htmlFallback off: keep textual content, drop the unrepresentable wrapper.\n\treturn content;\n}\n\n/**\n * Serializes a run of consecutive list items into Markdown list lines.\n *\n * Indent maps to CommonMark content columns (#194): each level's items are\n * padded to the content column of the last item one level up, so the parser\n * reads them back as nested (a `1. ` parent needs three columns, `- ` two).\n * Container items emit their block children indented to their own content\n * column, separated by the blank lines `serializeBlocks` produces.\n *\n * A nesting level is valid only when the level above it has a preceding item to\n * anchor the content column. An item whose stored indent skips a level (an\n * orphan, e.g. a first item the user tabbed in) is clamped to one deeper than\n * the previous item's effective level. This keeps every marker at a content\n * column an actual parent established, so the emitted pad never lands at four or\n * more columns — which the parser would read as indented code, merging the item\n * into its predecessor or dropping its marker (grammar disagreement). The stored\n * indent is preserved in the model; only its Markdown rendering normalizes.\n */\nfunction serializeListGroup(items: readonly BlockNode[], ctx: SerContext): string {\n\tconst lines: string[] = [];\n\tconst counters: number[] = [];\n\tconst contentColumns: number[] = [];\n\tlet previousIndent = -1;\n\n\tfor (const item of items) {\n\t\tconst listType: string = String(item.attrs?.listType ?? 'bullet');\n\t\tconst storedIndent: number = Math.max(0, (item.attrs?.indent as number | undefined) ?? 0);\n\t\t// Clamp to at most one level deeper than the previous item so a parent\n\t\t// content column always exists (no orphan levels, no >=4-column pad).\n\t\tconst indent: number = Math.min(storedIndent, previousIndent + 1);\n\t\tpreviousIndent = indent;\n\t\tconst padWidth: number = indent === 0 ? 0 : (contentColumns[indent - 1] ?? 0);\n\t\tconst pad: string = ' '.repeat(padWidth);\n\n\t\t// Reset deeper counters/columns when we step back out.\n\t\tcounters.length = indent + 1;\n\t\tcontentColumns.length = indent + 1;\n\n\t\tlet marker: string;\n\t\tif (listType === 'ordered') {\n\t\t\tcounters[indent] = (counters[indent] ?? 0) + 1;\n\t\t\tmarker = `${counters[indent]}.`;\n\t\t} else if (listType === 'checklist') {\n\t\t\tconst checked: boolean = item.attrs?.checked === true;\n\t\t\tmarker = `${ctx.opts.bullet} [${checked ? 'x' : ' '}]`;\n\t\t} else {\n\t\t\tmarker = ctx.opts.bullet;\n\t\t}\n\n\t\t// The task marker belongs to the first content line, not the geometry:\n\t\t// continuation lines of `- [x] foo` align to the bullet's content column.\n\t\tconst markerWidth: number =\n\t\t\tlistType === 'checklist' ? ctx.opts.bullet.length + 1 : marker.length + 1;\n\t\tcontentColumns[indent] = padWidth + markerWidth;\n\n\t\tif (isLeafBlock(item)) {\n\t\t\t// The item content is now block-tokenized on re-import, so a leaf whose\n\t\t\t// text begins with a block marker (`# `, `- `, `> `, `1. `) must be\n\t\t\t// line-start escaped or it reimports as a heading/nested-item child.\n\t\t\tconst content: string = escapeLineStart(\n\t\t\t\tserializeInlineContent(getInlineChildren(item), ctx).replace(/\\n/g, ' '),\n\t\t\t);\n\t\t\tlines.push(content ? `${pad}${marker} ${content}` : `${pad}${marker}`);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Container item (#194): serialize the block children, put the first line\n\t\t// on the marker line, and indent the rest to the item's content column.\n\t\tconst inner: string = serializeBlocks(getBlockChildren(item), { ...ctx, inListItem: true });\n\t\tif (inner === '') {\n\t\t\tlines.push(`${pad}${marker}`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst contentPad: string = ' '.repeat(contentColumns[indent] ?? padWidth + markerWidth);\n\t\tconst innerLines: string[] = inner.split('\\n');\n\t\tlines.push(`${pad}${marker} ${innerLines[0] ?? ''}`);\n\t\tfor (let li = 1; li < innerLines.length; li++) {\n\t\t\tconst innerLine: string = innerLines[li] ?? '';\n\t\t\tlines.push(innerLine === '' ? '' : `${contentPad}${innerLine}`);\n\t\t}\n\t}\n\n\treturn lines.join('\\n');\n}\n\n/** GFM table; tables with colspan/rowspan fall back to raw HTML (D3, no GFM equivalent). */\nfunction serializeTable(block: BlockNode, ctx: SerContext): string {\n\tconst rows: readonly BlockNode[] = getBlockChildren(block);\n\tif (rows.length === 0) return '';\n\n\t// CommonMark has no table syntax. Keep the semantic hierarchy through the\n\t// same raw-HTML seam used for spans and HTML IDs.\n\tif (!ctx.opts.gfm && ctx.opts.htmlFallback) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\n\t// GFM has no syntax for either logical column widths or row minimum\n\t// heights. Preserve them through the existing semantic HTML seam when it\n\t// is available. With `htmlFallback: false`, the documented behavior is a\n\t// plain pipe table whose dimensions reset to automatic on re-import.\n\tif (ctx.opts.htmlFallback && (hasSpannedCells(rows) || hasExplicitTableDimensions(block, rows))) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\n\tconst matrix: string[][] = rows.map((row) =>\n\t\tgetBlockChildren(row).map((cell) => serializeCell(cell, ctx)),\n\t);\n\tconst columns: number = matrix.reduce((max, row) => Math.max(max, row.length), 0);\n\tif (columns === 0) return '';\n\n\tconst renderRow = (cells: string[]): string => {\n\t\tconst padded: string[] = [...cells];\n\t\twhile (padded.length < columns) padded.push('');\n\t\treturn `| ${padded.join(' | ')} |`;\n\t};\n\n\tconst headerRow: BlockNode | undefined = rows[0];\n\tconst delimiters: string[] = Array.from({ length: columns }, (_v, col) =>\n\t\talignMarker(columnAlign(headerRow, col)),\n\t);\n\n\tconst out: string[] = [];\n\tout.push(renderRow(matrix[0] ?? []));\n\tout.push(`| ${delimiters.join(' | ')} |`);\n\tfor (let i = 1; i < matrix.length; i++) {\n\t\tout.push(renderRow(matrix[i] ?? []));\n\t}\n\treturn out.join('\\n');\n}\n\n/** Reads the column alignment from a header cell's paragraph `align` attribute. */\nfunction columnAlign(headerRow: BlockNode | undefined, col: number): string | undefined {\n\tif (!headerRow) return undefined;\n\tconst cell: BlockNode | undefined = getBlockChildren(headerRow)[col];\n\tif (!cell) return undefined;\n\tconst paragraph: BlockNode | undefined = getBlockChildren(cell)[0];\n\treturn paragraph?.attrs?.align as string | undefined;\n}\n\n/** Maps a logical alignment to its GFM delimiter marker. */\nfunction alignMarker(align: string | undefined): string {\n\tif (align === 'start') return ':---';\n\tif (align === 'center') return ':---:';\n\tif (align === 'end') return '---:';\n\treturn '---';\n}\n\n/** Whether any cell in the rows carries a colspan/rowspan > 1. */\nfunction hasSpannedCells(rows: readonly BlockNode[]): boolean {\n\tfor (const row of rows) {\n\t\tfor (const cell of getBlockChildren(row)) {\n\t\t\tconst colspan = cell.attrs?.colspan as number | undefined;\n\t\t\tconst rowspan = cell.attrs?.rowspan as number | undefined;\n\t\t\tif ((colspan ?? 1) > 1 || (rowspan ?? 1) > 1) return true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/** Whether the table carries any safe dimension that GFM cannot represent. */\nfunction hasExplicitTableDimensions(table: BlockNode, rows: readonly BlockNode[]): boolean {\n\tif (hasExplicitTableColumnWidth(table.attrs?.columnWidthsPx)) return true;\n\treturn rows.some(\n\t\t(row: BlockNode): boolean =>\n\t\t\tnormalizeSerializedTableDimensionPx(row.attrs?.minHeightPx) !== undefined,\n\t);\n}\n\n/** Serializes a table cell to single-line inline Markdown, escaping pipes. */\nfunction serializeCell(cell: BlockNode, ctx: SerContext): string {\n\tconst blocks: readonly BlockNode[] = getBlockChildren(cell);\n\tconst inline: string = blocks\n\t\t.map((b) => serializeInlineContent(getInlineChildren(b), ctx))\n\t\t.join(' ')\n\t\t.replace(/\\n/g, ' ');\n\treturn inline.replace(/\\|/g, '\\\\|').trim();\n}\n","/**\n * MarkdownSerializer: converts an immutable Document into a Markdown string.\n *\n * Mirrors `DocumentSerializer.ts` (HTML) but is reached **only** via dynamic\n * `import()` from the async web-component method and the paste branch, so the\n * bundler genuinely code-splits the engine out of the core chunk (D13). Pure\n * functions — operate on Document/SchemaRegistry, no class state.\n */\n\nimport type { Document } from '../model/Document.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { buildMarkOrder } from './MarkSerializer.js';\nimport type { MarkdownSerializeOptions } from './MarkdownTypes.js';\nimport { serializeBlocks } from './markdown/BlockSerializers.js';\nimport { type SerContext, resolveSerializeOptions } from './markdown/MarkdownContext.js';\n\n/**\n * Serializes a document to a Markdown string.\n *\n * Standard CommonMark/GFM constructs are emitted by the engine's built-in\n * by-type mappings; unrepresentable nodes/marks emit raw HTML (valid Markdown)\n * when `htmlFallback` is on (default), or degrade gracefully when off (D3).\n */\nexport function serializeDocumentToMarkdown(\n\tdoc: Document,\n\tregistry?: SchemaRegistry,\n\toptions?: MarkdownSerializeOptions,\n): string {\n\tconst ctx: SerContext = {\n\t\tregistry,\n\t\topts: resolveSerializeOptions(options),\n\t\tmarkOrder: registry ? buildMarkOrder(registry) : undefined,\n\t};\n\tconst body: string = serializeBlocks(doc.children, ctx);\n\treturn finalizeDocument(body);\n}\n\n/**\n * Closes the assembled document with a single trailing newline, dropping any\n * leading/trailing blank lines. It intentionally does NOT touch the interior:\n * each block serializer is responsible for emitting clean lines, and\n * `serializeBlocks` already joins blocks with exactly one blank line. Trimming\n * only the document boundaries is provably code-safe, since a document never\n * begins or ends inside a code body (blocks open and close on their own\n * delimiters), so significant blank lines and trailing spaces inside a\n * `code_block` survive verbatim at any nesting depth.\n */\nfunction finalizeDocument(markdown: string): string {\n\tconst trimmed: string = markdown.trim();\n\treturn trimmed.length > 0 ? `${trimmed}\\n` : '';\n}\n"],"mappings":"O,gYAqCA,SAAgBqB,EACfC,GAEA,MAAMC,EAA+BD,GAASC,QAAU,MACxD,MAAO,CACNA,SACAC,IAAgB,QAAXD,EACLE,cAAwC,IAA1BH,GAASG,aACvBC,aAAcJ,GAASI,cAAgB,MACvCC,OAAQL,GAASK,QAAU,IAC3BC,SAAUN,GAASM,UAAY,IAC/BC,UAAWP,GAASO,WAAa,MACjCC,WAAYR,GAASQ,YAAc,EAErC,CAGA,SAAgBC,EAAcC,GAC7B,MAAO,CAAET,OAAQS,EAAKT,OAAQE,aAAcO,EAAKP,aAClD,CC3CA,IAAMQ,iBAAgB,IAAIC,IAAI,CAAC,KAAM,IAAK,IAAK,IAAK,IAAK,IAAK,MAG9D,SAASC,EAAYC,EAAcC,GAClC,MAAMC,EAA2BF,EAAKC,EAAI,GACpCE,EAA2BH,EAAKC,EAAI,GAC1C,YAAa,IAATC,QAA+B,IAATC,GACnB,KAAKC,KAAKF,IAAS,KAAKE,KAAKD,EACrC,CAOA,SAAgBE,EAAaL,EAAcZ,GAC1C,IAAIkB,EAAM,GACV,IAAK,IAAIL,EAAI,EAAGA,EAAID,EAAKO,OAAQN,IAAK,CACrC,MAAMO,EAAaR,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wBC,GAC9BwF,UAAWD,EAAWlG,EAAekG,QAAY,GAGlD,OAaD,SAA0B0H,GACzB,MAAMC,EAAkBD,EAAS9H,OACjC,OAAO+H,EAAQ7L,OAAS,EAAI,GAAG6L,MAAc,EAC9C,CAhBQC,CADcvF,EAAgBoF,EAAI3G,SAAUxD,GAEpD,Q"}
1
+ {"version":3,"file":"MarkdownSerializer-Y6saYClE.mjs","names":["__exportAll","normalizeHTMLId","INLINE_STYLE_EXPORT_CONTEXT","isLeafBlock","getBlockChildren","markSetsEqual","getInlineChildren","createTextNode","getBlockText","isInlineNode","isNodeOfType","buildMarkOrder","normalizeSerializedTableDimensionPx","hasExplicitTableColumnWidth","serializeDocumentToHTML","serializeMarksToHTML","SETEXT_H2","SETEXT_H1","THEMATIC_BREAK","FENCE_OPEN","resolveMarkdownHTMLRegistry","resolveSerializeOptions","options","flavor","gfm","htmlFallback","headingStyle","bullet","emphasis","codeFence","listIndent","exportContext","opts","ALWAYS_ESCAPE","Set","isIntraWord","text","i","prev","next","test","escapeInline","out","length","ch","has","LINE_START_MARKER","LINE_START_BULLET","LINE_START_ORDERED","escapeLineStart","line","replace","_m","ws","marker","sp","num","reparsesAsBlockLine","escapeLinkDestination","url","escapeLinkTitle","title","isStackMark","mark","t","type","delimiters","ctx","open","repeat","close","href","String","attrs","isMixable","marksEqual","a","b","JSON","stringify","stackMarksOf","node","link","marks","push","reorderToActive","active","result","remaining","splice","idx","findIndex","m","found","renderTextContent","some","content","fence","longest","current","Math","max","codeSpanFence","startsWith","endsWith","trim","wrapCodeSpan","fallbackMarks","filter","registry","markOrder","serializeInlineNode","inlineType","src","alt","titlePart","serializeInlineImage","spec","getInlineNodeSpec","md","toMarkdown","toHTMLString","mergeAdjacent","children","child","siblingHasMark","withoutMarks","strip","s","expelNodeWhitespace","flanking","isFlankingMark","leadLen","leadingWhitespace","trailLen","trailingWhitespace","lead","slice","core","trail","serializeInlineContent","merged","expelEdgeWhitespace","closeFrom","keep","target","serializeBlocks","blocks","parts","block","items","item","hasHTMLIdInTree","serializeHTMLFallback","serializeListGroup","serializeBlock","p","join","split","map","serializeParagraph","level","floor","clampLevel","hashes","serializeHeading","lang","language","code","fenceChar","c","longestRun","serializeCodeBlock","inListItem","width","height","align","html","getNodeSpec","toHTML","serializeImage","serializeBlockquote","rows","row","cell","colspan","rowspan","hasSpannedCells","table","columnWidthsPx","minHeightPx","hasExplicitTableDimensions","matrix","serializeCell","columns","reduce","renderRow","cells","padded","headerRow","Array","from","_v","col","alignMarker","columnAlign","serializeTable","serializeTitleLike","serializeUnknownBlock","htmlId","includeBlockIds","lines","counters","contentColumns","previousIndent","listType","storedIndent","indent","min","padWidth","pad","checked","markerWidth","inner","contentPad","innerLines","li","innerLine","MarkdownSerializer_exports","serializeDocumentToMarkdown","doc","markdown","trimmed","finalizeDocument"],"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 { INLINE_STYLE_EXPORT_CONTEXT } from '../../model/HTMLUtils.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/** 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_STYLE_EXPORT_CONTEXT,\n\t\t);\n\t}\n\t// htmlFallback off: keep text, drop styling.\n\treturn escapeInline(node.text, gfm);\n}\n\n/** Serializes a single inline node (hard break, inline image, math, plugin extensions). */\nfunction serializeInlineNode(node: InlineNode, ctx: SerContext): string {\n\tif (node.inlineType === 'hard_break') return '\\\\\\n';\n\tif (node.inlineType === 'image_inline') return serializeInlineImage(node, ctx);\n\n\tconst spec = ctx.registry?.getInlineNodeSpec(node.inlineType);\n\tconst md: string | null | undefined = spec?.toMarkdown?.(node, exportContext(ctx.opts));\n\tif (md != null) return md;\n\n\tif (ctx.opts.htmlFallback && spec?.toHTMLString) return spec.toHTMLString(node);\n\treturn '';\n}\n\n/** Serializes an inline image node to `![alt](src \"title\")` (engine-owned standard construct). */\nfunction serializeInlineImage(node: InlineNode, ctx: SerContext): string {\n\tconst src: string = String(node.attrs.src ?? '');\n\tconst alt: string = String(node.attrs.alt ?? '');\n\tconst title: string = String(node.attrs.title ?? '');\n\tconst titlePart: string = title ? ` \"${escapeLinkTitle(title)}\"` : '';\n\treturn `![${escapeInline(alt, ctx.opts.gfm)}](${escapeLinkDestination(src)}${titlePart})`;\n}\n\n/** Merges adjacent text nodes with identical mark sets; inline nodes are boundaries. */\nfunction mergeAdjacent(children: readonly (TextNode | InlineNode)[]): (TextNode | InlineNode)[] {\n\tconst result: (TextNode | InlineNode)[] = [];\n\tfor (const child of children) {\n\t\tconst prev = result[result.length - 1];\n\t\tif (\n\t\t\t!isInlineNode(child) &&\n\t\t\tprev &&\n\t\t\t!isInlineNode(prev) &&\n\t\t\tmarkSetsEqual(prev.marks, child.marks)\n\t\t) {\n\t\t\tresult[result.length - 1] = { type: 'text', text: prev.text + child.text, marks: prev.marks };\n\t\t} else {\n\t\t\tresult.push(child);\n\t\t}\n\t}\n\treturn result;\n}\n\n/** A flanking-sensitive emphasis mark (bold/italic/strike) whose delimiters must hug non-whitespace. */\nfunction isFlankingMark(mark: Mark, gfm: boolean): boolean {\n\treturn isStackMark(mark, gfm) && mark.type !== 'link';\n}\n\n/** Whether a sibling carries a mark equal to `mark` (false for inline nodes / no sibling). */\nfunction siblingHasMark(node: TextNode | InlineNode | undefined, mark: Mark): boolean {\n\tif (!node || isInlineNode(node)) return false;\n\treturn node.marks.some((m) => marksEqual(m, mark));\n}\n\n/** Length of the leading run of ASCII/Unicode whitespace in `text`. */\nfunction leadingWhitespace(text: string): number {\n\tlet i = 0;\n\twhile (i < text.length && /\\s/.test(text[i] as string)) i++;\n\treturn i;\n}\n\n/** Length of the trailing run of whitespace in `text`. */\nfunction trailingWhitespace(text: string): number {\n\tlet i: number = text.length;\n\twhile (i > 0 && /\\s/.test(text[i - 1] as string)) i--;\n\treturn text.length - i;\n}\n\n/** Returns `marks` with every mark in `strip` removed. */\nfunction withoutMarks(marks: readonly Mark[], strip: readonly Mark[]): Mark[] {\n\tif (strip.length === 0) return [...marks];\n\treturn marks.filter((m) => !strip.some((s) => marksEqual(s, m)));\n}\n\n/** Splits one text node's edge whitespace out of its flanking emphasis marks. */\nfunction expelNodeWhitespace(\n\tnode: TextNode,\n\tprev: TextNode | InlineNode | undefined,\n\tnext: TextNode | InlineNode | undefined,\n\tgfm: boolean,\n\tout: (TextNode | InlineNode)[],\n): void {\n\tconst flanking: Mark[] = node.marks.filter((m) => isFlankingMark(m, gfm));\n\tif (flanking.length === 0) {\n\t\tout.push(node);\n\t\treturn;\n\t}\n\n\tconst text: string = node.text;\n\tconst leadLen: number = leadingWhitespace(text);\n\n\t// All whitespace: a flanking mark survives only when interior on BOTH sides\n\t// (a same-mark neighbor before and after); otherwise it is expelled.\n\tif (leadLen === text.length) {\n\t\tconst strip: Mark[] = flanking.filter(\n\t\t\t(m) => !(siblingHasMark(prev, m) && siblingHasMark(next, m)),\n\t\t);\n\t\tout.push(createTextNode(text, withoutMarks(node.marks, strip)));\n\t\treturn;\n\t}\n\n\tconst trailLen: number = trailingWhitespace(text);\n\tconst lead: string = text.slice(0, leadLen);\n\tconst core: string = text.slice(leadLen, text.length - trailLen);\n\tconst trail: string = text.slice(text.length - trailLen);\n\n\tif (lead) {\n\t\tconst strip: Mark[] = flanking.filter((m) => !siblingHasMark(prev, m));\n\t\tout.push(createTextNode(lead, withoutMarks(node.marks, strip)));\n\t}\n\tout.push(createTextNode(core, node.marks));\n\tif (trail) {\n\t\tconst strip: Mark[] = flanking.filter((m) => !siblingHasMark(next, m));\n\t\tout.push(createTextNode(trail, withoutMarks(node.marks, strip)));\n\t}\n}\n\n/**\n * Expels whitespace from the edges of flanking-sensitive emphasis spans\n * (bold/italic/strikethrough). A `**` delimiter that hugs whitespace\n * (`**end **`) is not flanking, so CommonMark — and this engine's own parser —\n * read it literally, breaking the round-trip. Whitespace at a mark's span\n * boundary is moved outside the mark; whitespace interior to a span is kept.\n */\nfunction expelEdgeWhitespace(\n\tchildren: readonly (TextNode | InlineNode)[],\n\tgfm: boolean,\n): (TextNode | InlineNode)[] {\n\tconst out: (TextNode | InlineNode)[] = [];\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tif (!child) continue;\n\t\tif (isInlineNode(child)) {\n\t\t\tout.push(child);\n\t\t\tcontinue;\n\t\t}\n\t\texpelNodeWhitespace(child, children[i - 1], children[i + 1], gfm, out);\n\t}\n\treturn mergeAdjacent(out);\n}\n\n/** Serializes inline children of a leaf block to a Markdown string. */\nexport function serializeInlineContent(\n\tchildren: readonly (TextNode | InlineNode)[],\n\tctx: SerContext,\n): string {\n\tconst gfm: boolean = ctx.opts.gfm;\n\tconst merged: (TextNode | InlineNode)[] = expelEdgeWhitespace(mergeAdjacent(children), gfm);\n\tlet out = '';\n\tlet active: Mark[] = [];\n\n\tconst closeFrom = (keep: number): void => {\n\t\tfor (let i = active.length - 1; i >= keep; i--) {\n\t\t\tconst mark = active[i];\n\t\t\tif (mark) out += delimiters(mark, ctx).close;\n\t\t}\n\t\tactive = active.slice(0, keep);\n\t};\n\n\tfor (const child of merged) {\n\t\t// Inline nodes carry stack marks too (e.g. a `link` on an inline image), so\n\t\t// they flow through the same open/close reconciliation as text. The only\n\t\t// difference is the literal content emitted between the delimiters.\n\t\tconst target: Mark[] = reorderToActive(stackMarksOf(child, gfm), active);\n\n\t\tlet keep = 0;\n\t\twhile (\n\t\t\tkeep < active.length &&\n\t\t\tkeep < target.length &&\n\t\t\tmarksEqual(active[keep] as Mark, target[keep] as Mark)\n\t\t) {\n\t\t\tkeep++;\n\t\t}\n\t\tcloseFrom(keep);\n\t\tfor (let i = keep; i < target.length; i++) {\n\t\t\tconst mark = target[i];\n\t\t\tif (!mark) continue;\n\t\t\tout += delimiters(mark, ctx).open;\n\t\t\tactive.push(mark);\n\t\t}\n\n\t\tout += isInlineNode(child) ? serializeInlineNode(child, ctx) : renderTextContent(child, ctx);\n\t}\n\n\tcloseFrom(0);\n\treturn out;\n}\n","/**\n * Block-level Markdown serialization.\n *\n * Leaf/self-contained blocks (paragraph, heading, code_block, horizontal_rule,\n * image) have built-in emitters keyed by type name — the same centralized,\n * by-type-name mapping the importer uses, and the shape `prosemirror-markdown`\n * uses. Container/structural blocks (blockquote, list, table) are engine-owned\n * because their children need per-line prefixing/indentation that cannot be\n * composed from a wrapper (D12): each container serializes its own children and\n * applies its prefix to those known lines (never a post-hoc regex on assembled\n * output). Unknown/superset blocks defer to the per-spec `toMarkdown` hook, then\n * to a raw-HTML fallback via `toHTML` (D3, D4).\n */\n\nimport { isNodeOfType } from '../../model/AttrRegistry.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport {\n\tgetBlockChildren,\n\tgetBlockText,\n\tgetInlineChildren,\n\tisLeafBlock,\n} from '../../model/Document.js';\nimport { normalizeHTMLId } from '../../model/HTMLUtils.js';\nimport { serializeDocumentToHTML } from '../DocumentSerializer.js';\nimport {\n\thasExplicitTableColumnWidth,\n\tnormalizeSerializedTableDimensionPx,\n} from '../TableDimensions.js';\nimport { serializeInlineContent } from './InlineSerializers.js';\nimport { type SerContext, exportContext } from './MarkdownContext.js';\nimport {\n\tescapeInline,\n\tescapeLineStart,\n\tescapeLinkDestination,\n\tescapeLinkTitle,\n} from './MarkdownEscape.js';\nimport { resolveMarkdownHTMLRegistry } from './MarkdownHTMLRegistry.js';\n\n/** Serializes a sequence of blocks, grouping consecutive list items, joined by blank lines. */\nexport function serializeBlocks(blocks: readonly BlockNode[], ctx: SerContext): string {\n\tconst parts: string[] = [];\n\tlet i = 0;\n\twhile (i < blocks.length) {\n\t\tconst block: BlockNode | undefined = blocks[i];\n\t\tif (!block) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isNodeOfType(block, 'list_item')) {\n\t\t\tconst items: BlockNode[] = [];\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst item: BlockNode | undefined = blocks[i];\n\t\t\t\tif (!item || !isNodeOfType(item, 'list_item')) break;\n\t\t\t\titems.push(item);\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tparts.push(\n\t\t\t\tctx.opts.htmlFallback && items.some(hasHTMLIdInTree)\n\t\t\t\t\t? serializeHTMLFallback(items, ctx)\n\t\t\t\t\t: serializeListGroup(items, ctx),\n\t\t\t);\n\t\t} else {\n\t\t\tparts.push(serializeBlock(block, ctx));\n\t\t\ti++;\n\t\t}\n\t}\n\treturn parts.filter((p) => p.length > 0).join('\\n\\n');\n}\n\n/** Serializes a single (non-list-item) block. */\nexport function serializeBlock(block: BlockNode, ctx: SerContext): string {\n\tif (ctx.opts.htmlFallback && hasHTMLIdInTree(block)) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\tconst type: string = block.type;\n\n\tif (type === 'paragraph') return serializeParagraph(block, ctx);\n\tif (type === 'heading') return serializeHeading(block, ctx);\n\tif (type === 'code_block') return serializeCodeBlock(block, ctx);\n\tif (type === 'horizontal_rule') return ctx.inListItem ? '***' : '---';\n\tif (type === 'image') return serializeImage(block, ctx);\n\tif (type === 'blockquote') return serializeBlockquote(block, ctx);\n\tif (type === 'table') return serializeTable(block, ctx);\n\tif (type === 'title') return serializeTitleLike(block, ctx, 1);\n\tif (type === 'subtitle') return serializeTitleLike(block, ctx, 2);\n\n\treturn serializeUnknownBlock(block, ctx);\n}\n\n/** Whether a block subtree carries HTML-only identity that Markdown cannot express. */\nfunction hasHTMLIdInTree(block: BlockNode): boolean {\n\tif (normalizeHTMLId(block.htmlId)) return true;\n\treturn getBlockChildren(block).some(hasHTMLIdInTree);\n}\n\n/** Emits a complete block run as raw HTML without leaking internal block IDs. */\nfunction serializeHTMLFallback(blocks: readonly BlockNode[], ctx: SerContext): string {\n\treturn serializeDocumentToHTML({ children: blocks }, resolveMarkdownHTMLRegistry(ctx.registry), {\n\t\tincludeBlockIds: false,\n\t});\n}\n\n/** Paragraph: inline content with leading block markers escaped per line. */\nfunction serializeParagraph(block: BlockNode, ctx: SerContext): string {\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx);\n\tif (content.trim() === '') return '';\n\treturn content.split('\\n').map(escapeLineStart).join('\\n');\n}\n\n/** Heading: ATX (`## h`) by default, setext for levels 1-2 when requested. */\nfunction serializeHeading(block: BlockNode, ctx: SerContext): string {\n\tconst level: number = clampLevel((block.attrs?.level as number | undefined) ?? 1);\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx).replace(/\\n/g, ' ');\n\n\tif (ctx.opts.headingStyle === 'setext' && level <= 2 && content !== '') {\n\t\tconst underline: string = level === 1 ? '=' : '-';\n\t\treturn `${content}\\n${underline.repeat(Math.max(3, content.length))}`;\n\t}\n\tconst hashes: string = '#'.repeat(level);\n\treturn content ? `${hashes} ${content}` : hashes;\n}\n\nfunction clampLevel(level: number): number {\n\tif (level < 1) return 1;\n\tif (level > 6) return 6;\n\treturn Math.floor(level);\n}\n\n/** Fenced code block; the fence is grown to exceed any fence run inside the code. */\nfunction serializeCodeBlock(block: BlockNode, ctx: SerContext): string {\n\tconst lang: string = String(block.attrs?.language ?? '');\n\tconst code: string = getBlockText(block);\n\tconst fenceChar: string = ctx.opts.codeFence[0] ?? '`';\n\tconst fence: string = fenceChar.repeat(Math.max(3, longestRun(code, fenceChar) + 1));\n\treturn `${fence}${lang}\\n${code}\\n${fence}`;\n}\n\n/** Length of the longest consecutive run of `ch` in `text`. */\nfunction longestRun(text: string, ch: string): number {\n\tlet longest = 0;\n\tlet current = 0;\n\tfor (const c of text) {\n\t\tif (c === ch) {\n\t\t\tcurrent++;\n\t\t\tlongest = Math.max(longest, current);\n\t\t} else {\n\t\t\tcurrent = 0;\n\t\t}\n\t}\n\treturn longest;\n}\n\n/** Standalone image on its own line; styling-bearing images use HTML fallback (D3). */\nfunction serializeImage(block: BlockNode, ctx: SerContext): string {\n\tconst src: string = String(block.attrs?.src ?? '');\n\tconst alt: string = String(block.attrs?.alt ?? '');\n\tconst title: string = String(block.attrs?.title ?? '');\n\tconst width = block.attrs?.width as number | undefined;\n\tconst height = block.attrs?.height as number | undefined;\n\tconst align = block.attrs?.align as string | undefined;\n\tconst hasStyling: boolean =\n\t\twidth !== undefined || height !== undefined || (align !== undefined && align !== 'center');\n\n\tif (hasStyling && ctx.opts.htmlFallback) {\n\t\tconst html: string | undefined = ctx.registry?.getNodeSpec('image')?.toHTML?.(block, '');\n\t\tif (html) return html;\n\t}\n\n\tconst titlePart: string = title ? ` \"${escapeLinkTitle(title)}\"` : '';\n\treturn `![${escapeInline(alt, ctx.opts.gfm)}](${escapeLinkDestination(src)}${titlePart})`;\n}\n\n/** Blockquote container: serialize children, then prefix every line with `> `. */\nfunction serializeBlockquote(block: BlockNode, ctx: SerContext): string {\n\tconst inner: string = serializeBlocks(getBlockChildren(block), ctx);\n\treturn inner\n\t\t.split('\\n')\n\t\t.map((line) => (line === '' ? '>' : `> ${line}`))\n\t\t.join('\\n');\n}\n\n/** title/subtitle: HTML fallback (`<h1 class>`) by default; degrade to `#`/`##` otherwise (D5). */\nfunction serializeTitleLike(block: BlockNode, ctx: SerContext, level: number): string {\n\tif (ctx.opts.htmlFallback) {\n\t\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx);\n\t\tconst html: string | undefined = ctx.registry\n\t\t\t?.getNodeSpec(block.type)\n\t\t\t?.toHTML?.(block, content);\n\t\tif (html) return html;\n\t}\n\tconst content: string = serializeInlineContent(getInlineChildren(block), ctx).replace(/\\n/g, ' ');\n\tconst hashes: string = '#'.repeat(level);\n\treturn content ? `${hashes} ${content}` : hashes;\n}\n\n/** Unknown / superset block: per-spec `toMarkdown` hook, then raw-HTML fallback, then degrade. */\nfunction serializeUnknownBlock(block: BlockNode, ctx: SerContext): string {\n\tconst spec = ctx.registry?.getNodeSpec(block.type);\n\tconst content: string = isLeafBlock(block)\n\t\t? serializeInlineContent(getInlineChildren(block), ctx)\n\t\t: serializeBlocks(getBlockChildren(block), ctx);\n\n\tconst md: string | null | undefined = spec?.toMarkdown?.(block, content, exportContext(ctx.opts));\n\tif (md != null) return md;\n\n\tif (ctx.opts.htmlFallback && spec?.toHTML) return spec.toHTML(block, content);\n\n\t// htmlFallback off: keep textual content, drop the unrepresentable wrapper.\n\treturn content;\n}\n\n/**\n * Serializes a run of consecutive list items into Markdown list lines.\n *\n * Indent maps to CommonMark content columns (#194): each level's items are\n * padded to the content column of the last item one level up, so the parser\n * reads them back as nested (a `1. ` parent needs three columns, `- ` two).\n * Container items emit their block children indented to their own content\n * column, separated by the blank lines `serializeBlocks` produces.\n *\n * A nesting level is valid only when the level above it has a preceding item to\n * anchor the content column. An item whose stored indent skips a level (an\n * orphan, e.g. a first item the user tabbed in) is clamped to one deeper than\n * the previous item's effective level. This keeps every marker at a content\n * column an actual parent established, so the emitted pad never lands at four or\n * more columns — which the parser would read as indented code, merging the item\n * into its predecessor or dropping its marker (grammar disagreement). The stored\n * indent is preserved in the model; only its Markdown rendering normalizes.\n */\nfunction serializeListGroup(items: readonly BlockNode[], ctx: SerContext): string {\n\tconst lines: string[] = [];\n\tconst counters: number[] = [];\n\tconst contentColumns: number[] = [];\n\tlet previousIndent = -1;\n\n\tfor (const item of items) {\n\t\tconst listType: string = String(item.attrs?.listType ?? 'bullet');\n\t\tconst storedIndent: number = Math.max(0, (item.attrs?.indent as number | undefined) ?? 0);\n\t\t// Clamp to at most one level deeper than the previous item so a parent\n\t\t// content column always exists (no orphan levels, no >=4-column pad).\n\t\tconst indent: number = Math.min(storedIndent, previousIndent + 1);\n\t\tpreviousIndent = indent;\n\t\tconst padWidth: number = indent === 0 ? 0 : (contentColumns[indent - 1] ?? 0);\n\t\tconst pad: string = ' '.repeat(padWidth);\n\n\t\t// Reset deeper counters/columns when we step back out.\n\t\tcounters.length = indent + 1;\n\t\tcontentColumns.length = indent + 1;\n\n\t\tlet marker: string;\n\t\tif (listType === 'ordered') {\n\t\t\tcounters[indent] = (counters[indent] ?? 0) + 1;\n\t\t\tmarker = `${counters[indent]}.`;\n\t\t} else if (listType === 'checklist') {\n\t\t\tconst checked: boolean = item.attrs?.checked === true;\n\t\t\tmarker = `${ctx.opts.bullet} [${checked ? 'x' : ' '}]`;\n\t\t} else {\n\t\t\tmarker = ctx.opts.bullet;\n\t\t}\n\n\t\t// The task marker belongs to the first content line, not the geometry:\n\t\t// continuation lines of `- [x] foo` align to the bullet's content column.\n\t\tconst markerWidth: number =\n\t\t\tlistType === 'checklist' ? ctx.opts.bullet.length + 1 : marker.length + 1;\n\t\tcontentColumns[indent] = padWidth + markerWidth;\n\n\t\tif (isLeafBlock(item)) {\n\t\t\t// The item content is now block-tokenized on re-import, so a leaf whose\n\t\t\t// text begins with a block marker (`# `, `- `, `> `, `1. `) must be\n\t\t\t// line-start escaped or it reimports as a heading/nested-item child.\n\t\t\tconst content: string = escapeLineStart(\n\t\t\t\tserializeInlineContent(getInlineChildren(item), ctx).replace(/\\n/g, ' '),\n\t\t\t);\n\t\t\tlines.push(content ? `${pad}${marker} ${content}` : `${pad}${marker}`);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Container item (#194): serialize the block children, put the first line\n\t\t// on the marker line, and indent the rest to the item's content column.\n\t\tconst inner: string = serializeBlocks(getBlockChildren(item), { ...ctx, inListItem: true });\n\t\tif (inner === '') {\n\t\t\tlines.push(`${pad}${marker}`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst contentPad: string = ' '.repeat(contentColumns[indent] ?? padWidth + markerWidth);\n\t\tconst innerLines: string[] = inner.split('\\n');\n\t\tlines.push(`${pad}${marker} ${innerLines[0] ?? ''}`);\n\t\tfor (let li = 1; li < innerLines.length; li++) {\n\t\t\tconst innerLine: string = innerLines[li] ?? '';\n\t\t\tlines.push(innerLine === '' ? '' : `${contentPad}${innerLine}`);\n\t\t}\n\t}\n\n\treturn lines.join('\\n');\n}\n\n/** GFM table; tables with colspan/rowspan fall back to raw HTML (D3, no GFM equivalent). */\nfunction serializeTable(block: BlockNode, ctx: SerContext): string {\n\tconst rows: readonly BlockNode[] = getBlockChildren(block);\n\tif (rows.length === 0) return '';\n\n\t// CommonMark has no table syntax. Keep the semantic hierarchy through the\n\t// same raw-HTML seam used for spans and HTML IDs.\n\tif (!ctx.opts.gfm && ctx.opts.htmlFallback) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\n\t// GFM has no syntax for either logical column widths or row minimum\n\t// heights. Preserve them through the existing semantic HTML seam when it\n\t// is available. With `htmlFallback: false`, the documented behavior is a\n\t// plain pipe table whose dimensions reset to automatic on re-import.\n\tif (ctx.opts.htmlFallback && (hasSpannedCells(rows) || hasExplicitTableDimensions(block, rows))) {\n\t\treturn serializeHTMLFallback([block], ctx);\n\t}\n\n\tconst matrix: string[][] = rows.map((row) =>\n\t\tgetBlockChildren(row).map((cell) => serializeCell(cell, ctx)),\n\t);\n\tconst columns: number = matrix.reduce((max, row) => Math.max(max, row.length), 0);\n\tif (columns === 0) return '';\n\n\tconst renderRow = (cells: string[]): string => {\n\t\tconst padded: string[] = [...cells];\n\t\twhile (padded.length < columns) padded.push('');\n\t\treturn `| ${padded.join(' | ')} |`;\n\t};\n\n\tconst headerRow: BlockNode | undefined = rows[0];\n\tconst delimiters: string[] = Array.from({ length: columns }, (_v, col) =>\n\t\talignMarker(columnAlign(headerRow, col)),\n\t);\n\n\tconst out: string[] = [];\n\tout.push(renderRow(matrix[0] ?? []));\n\tout.push(`| ${delimiters.join(' | ')} |`);\n\tfor (let i = 1; i < matrix.length; i++) {\n\t\tout.push(renderRow(matrix[i] ?? []));\n\t}\n\treturn out.join('\\n');\n}\n\n/** Reads the column alignment from a header cell's paragraph `align` attribute. */\nfunction columnAlign(headerRow: BlockNode | undefined, col: number): string | undefined {\n\tif (!headerRow) return undefined;\n\tconst cell: BlockNode | undefined = getBlockChildren(headerRow)[col];\n\tif (!cell) return undefined;\n\tconst paragraph: BlockNode | undefined = getBlockChildren(cell)[0];\n\treturn paragraph?.attrs?.align as string | undefined;\n}\n\n/** Maps a logical alignment to its GFM delimiter marker. */\nfunction alignMarker(align: string | undefined): string {\n\tif (align === 'start') return ':---';\n\tif (align === 'center') return ':---:';\n\tif (align === 'end') return '---:';\n\treturn '---';\n}\n\n/** Whether any cell in the rows carries a colspan/rowspan > 1. */\nfunction hasSpannedCells(rows: readonly BlockNode[]): boolean {\n\tfor (const row of rows) {\n\t\tfor (const cell of getBlockChildren(row)) {\n\t\t\tconst colspan = cell.attrs?.colspan as number | undefined;\n\t\t\tconst rowspan = cell.attrs?.rowspan as number | undefined;\n\t\t\tif ((colspan ?? 1) > 1 || (rowspan ?? 1) > 1) return true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/** Whether the table carries any safe dimension that GFM cannot represent. */\nfunction hasExplicitTableDimensions(table: BlockNode, rows: readonly BlockNode[]): boolean {\n\tif (hasExplicitTableColumnWidth(table.attrs?.columnWidthsPx)) return true;\n\treturn rows.some(\n\t\t(row: BlockNode): boolean =>\n\t\t\tnormalizeSerializedTableDimensionPx(row.attrs?.minHeightPx) !== undefined,\n\t);\n}\n\n/** Serializes a table cell to single-line inline Markdown, escaping pipes. */\nfunction serializeCell(cell: BlockNode, ctx: SerContext): string {\n\tconst blocks: readonly BlockNode[] = getBlockChildren(cell);\n\tconst inline: string = blocks\n\t\t.map((b) => serializeInlineContent(getInlineChildren(b), ctx))\n\t\t.join(' ')\n\t\t.replace(/\\n/g, ' ');\n\treturn inline.replace(/\\|/g, '\\\\|').trim();\n}\n","/**\n * MarkdownSerializer: converts an immutable Document into a Markdown string.\n *\n * Mirrors `DocumentSerializer.ts` (HTML) but is reached **only** via dynamic\n * `import()` from the async web-component method and the paste branch, so the\n * bundler genuinely code-splits the engine out of the core chunk (D13). Pure\n * functions — operate on Document/SchemaRegistry, no class state.\n */\n\nimport type { Document } from '../model/Document.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { buildMarkOrder } from './MarkSerializer.js';\nimport type { MarkdownSerializeOptions } from './MarkdownTypes.js';\nimport { serializeBlocks } from './markdown/BlockSerializers.js';\nimport { type SerContext, resolveSerializeOptions } from './markdown/MarkdownContext.js';\n\n/**\n * Serializes a document to a Markdown string.\n *\n * Standard CommonMark/GFM constructs are emitted by the engine's built-in\n * by-type mappings; unrepresentable nodes/marks emit raw HTML (valid Markdown)\n * when `htmlFallback` is on (default), or degrade gracefully when off (D3).\n */\nexport function serializeDocumentToMarkdown(\n\tdoc: Document,\n\tregistry?: SchemaRegistry,\n\toptions?: MarkdownSerializeOptions,\n): string {\n\tconst ctx: SerContext = {\n\t\tregistry,\n\t\topts: resolveSerializeOptions(options),\n\t\tmarkOrder: registry ? buildMarkOrder(registry) : undefined,\n\t};\n\tconst body: string = serializeBlocks(doc.children, ctx);\n\treturn finalizeDocument(body);\n}\n\n/**\n * Closes the assembled document with a single trailing newline, dropping any\n * leading/trailing blank lines. It intentionally does NOT touch the interior:\n * each block serializer is responsible for emitting clean lines, and\n * `serializeBlocks` already joins blocks with exactly one blank line. Trimming\n * only the document boundaries is provably code-safe, since a document never\n * begins or ends inside a code body (blocks open and close on their own\n * delimiters), so significant blank lines and trailing spaces inside a\n * `code_block` survive verbatim at any nesting depth.\n */\nfunction finalizeDocument(markdown: string): string {\n\tconst trimmed: string = markdown.trim();\n\treturn trimmed.length > 0 ? `${trimmed}\\n` : '';\n}\n"],"mappings":"O,gYAqCA,SAAgBqB,EACfC,GAEA,MAAMC,EAA+BD,GAASC,QAAU,MACxD,MAAO,CACNA,SACAC,IAAgB,QAAXD,EACLE,cAAwC,IAA1BH,GAASG,aACvBC,aAAcJ,GAASI,cAAgB,MACvCC,OAAQL,GAASK,QAAU,IAC3BC,SAAUN,GAASM,UAAY,IAC/BC,UAAWP,GAASO,WAAa,MACjCC,WAAYR,GAASQ,YAAc,EAErC,CAGA,SAAgBC,EAAcC,GAC7B,MAAO,CAAET,OAAQS,EAAKT,OAAQE,aAAcO,EAAKP,aAClD,CC3CA,IAAMQ,iBAAgB,IAAIC,IAAI,CAAC,KAAM,IAAK,IAAK,IAAK,IAAK,IAAK,MAG9D,SAASC,EAAYC,EAAcC,GAClC,MAAMC,EAA2BF,EAAKC,EAAI,GACpCE,EAA2BH,EAAKC,EAAI,GAC1C,YAAa,IAATC,QAA+B,IAATC,GACnB,KAAKC,KAAKF,IAAS,KAAKE,KAAKD,EACrC,CAOA,SAAgBE,EAAaL,EAAcZ,GAC1C,IA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,C,4DC/QA,SAAgBwE,EACfC,EACAzH,EACAvF,GAEA,MAAM6C,EAAkB,CACvB0C,WACA7E,KAAMX,EAAwBC,GAC9BwF,UAAWD,EAAWlG,EAAekG,QAAY,GAGlD,OAaD,SAA0B0H,GACzB,MAAMC,EAAkBD,EAAS9H,OACjC,OAAO+H,EAAQ7L,OAAS,EAAI,GAAG6L,MAAc,EAC9C,CAhBQC,CADcvF,EAAgBoF,EAAI3G,SAAUxD,GAEpD,Q"}
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./TypedKeys-CA4bfw9O.mjs";import{i as t}from"./Platform-ByobkiCc.mjs";import{a as o,i as n,t as s}from"./PopupPositioning-CIqgpqlW.mjs";var r={error(e,t){void 0===t?console.error(e):console.error(e,t)},warn(e,t){void 0===t?console.warn(e):console.warn(e,t)},info(e,t){void 0===t?console.info(e):console.info(e,t)},debug(e,t){void 0===t?console.debug(e):console.debug(e,t)}},i={error(){},warn(){},info(){},debug(){}};function c(e,t){const o=`[${t}]`;return{error(t,n){l(()=>e.error(`${o} ${t}`,n))},warn(t,n){l(()=>e.warn(`${o} ${t}`,n))},info(t,n){l(()=>e.info(`${o} ${t}`,n))},debug(t,n){l(()=>e.debug(`${o} ${t}`,n))}}}function l(e){try{const t=e();null===t||"object"!=typeof t&&"function"!=typeof t||Promise.resolve(t).then(void 0,()=>{})}catch{}}var a=new e("popup"),u=class{registerInteraction;stack=[];referenceNode;destroyed=!1;constructor(e,t){this.registerInteraction=t,this.referenceNode=e}open(e){if(this.destroyed)throw new Error("Popup service has been destroyed.");const t=document.createElement("div");t.className=e.className?`notectl-popup ${e.className}`:"notectl-popup",e.ariaRole&&t.setAttribute("role",e.ariaRole),e.ariaLabel&&t.setAttribute("aria-label",e.ariaLabel);const n=e.parent?this.findEntryByHandle(e.parent):null;let r;const i={close:e=>this.closeEntry(r,e),getElement:()=>t,updatePosition:()=>this.reposition(i)},c=o=>{const n=o.composedPath();if(!n.includes(t)){for(const e of this.stack)if(n.includes(e.element))return;e.anchor instanceof HTMLElement&&n.includes(e.anchor)||this.closeEntry(r,{restoreFocusTo:null})}};r={element:t,config:e,clickOutsideHandler:c,parent:n,listenerRegistrationTimer:null,documentListenerAttached:!1,focusFrame:null,cleanups:[]},this.stack.push(r);const l=this.registerInteraction?.(t);l&&r.cleanups.push(l);try{e.content(t,e=>this.closeEntry(r,e))}catch(a){throw this.closeEntry(r,{restoreFocusTo:null}),a}if(!this.stack.includes(r))return i;t.addEventListener("keydown",e=>{"Escape"!==e.key||e.isComposing||e.defaultPrevented||this.stack.at(-1)===r&&(e.preventDefault(),e.stopPropagation(),this.closeEntry(r))});try{const n=e.referenceNode??this.referenceNode;if(s(t,n),o(t),this.positionEntry(r),!this.stack.includes(r))return i;if("getRect"in e.anchor&&e.anchor.subscribe){const t=e.anchor.subscribe(()=>this.reposition(i));this.stack.includes(r)?r.cleanups.push(t):t()}return this.stack.includes(r)?(this.observePosition(r),r.listenerRegistrationTimer=setTimeout(()=>{r.listenerRegistrationTimer=null,this.stack.includes(r)&&(document.addEventListener("mousedown",c),document.addEventListener("touchstart",c),r.documentListenerAttached=!0)},0),!1!==e.autoFocus&&this.focusFirstItem(r),i):i}catch(a){throw this.closeEntry(r,{restoreFocusTo:null}),a}}close(){const e=this.stack[this.stack.length-1];e&&this.closeEntry(e)}closeAll(){for(;this.stack.length>0;){const e=this.stack[this.stack.length-1];e&&this.closeEntry(e)}}isOpen(){return this.stack.length>0}destroy(){for(this.destroyed=!0;this.stack.length;){const e=this.stack.at(-1);e&&this.closeEntry(e,{restoreFocusTo:null})}}closeEntry(e,t){if(-1===this.stack.indexOf(e))return;const o=[];for(const n of[...this.stack].reverse()){let t=n.parent;for(;t&&t!==e;)t=t.parent;t===e&&(o.push(n),this.removeEntry(n))}this.removeEntry(e);for(const n of o)this.notifyClose(n);void 0!==t&&"restoreFocusTo"in t?t.restoreFocusTo?.focus():e.config.restoreFocusTo&&e.config.restoreFocusTo.focus(),this.notifyClose(e)}notifyClose(e){try{e.config.onClose?.()}catch(t){r.error("[PopupManager] onClose failed",t)}}removeEntry(e){const t=this.stack.indexOf(e);if(-1!==t){this.stack.splice(t,1);for(const t of e.cleanups)try{t()}catch(o){r.error("[PopupManager] cleanup failed",o)}null!==e.focusFrame&&cancelAnimationFrame(e.focusFrame),null!==e.listenerRegistrationTimer&&(clearTimeout(e.listenerRegistrationTimer),e.listenerRegistrationTimer=null),e.element.remove(),e.documentListenerAttached&&(document.removeEventListener("mousedown",e.clickOutsideHandler),document.removeEventListener("touchstart",e.clickOutsideHandler),e.documentListenerAttached=!1)}}reposition(e){const t=this.findEntryByHandle(e);t&&this.positionEntry(t)}positionEntry(e){const t=e.config,o=t.anchor instanceof HTMLElement?t.anchor.getBoundingClientRect():"getRect"in t.anchor?t.anchor.getRect():t.anchor;o?n(e.element,o,{position:t.position??"below-start",isRtl:this.isRtlContext()}):this.closeEntry(e,{restoreFocusTo:null})}findEntryByHandle(e){const t=e.getElement();return this.stack.find(e=>e.element===t)??null}isRtlContext(){return this.referenceNode instanceof HTMLElement&&t(this.referenceNode)}focusFirstItem(e){const t=e.element;e.focusFrame=requestAnimationFrame(()=>{e.focusFrame=null,t.isConnected&&(t.querySelector('[role="menuitem"]')??t.querySelector('[role="option"]')??t.querySelector('[role="gridcell"]')??t.querySelector("input, textarea")??t.querySelector("button"))?.focus()})}observePosition(e){let t=null;const o=()=>{null===t&&(t=requestAnimationFrame(()=>{t=null,this.stack.includes(e)&&this.positionEntry(e)}))},n=(t,n)=>{t.addEventListener(n,o,!0),e.cleanups.push(()=>t.removeEventListener(n,o,!0))};n(window,"resize"),n(document,"scroll"),n(this.referenceNode.getRootNode(),"scroll"),window.visualViewport&&(n(window.visualViewport,"resize"),n(window.visualViewport,"scroll"));const s="undefined"==typeof ResizeObserver?null:new ResizeObserver(o);s?.observe(e.element),e.config.anchor instanceof HTMLElement&&s?.observe(e.config.anchor),e.cleanups.push(()=>{s?.disconnect(),null!==t&&cancelAnimationFrame(t)})}};export{i as a,c as i,a as n,r,u as t};
2
+ //# sourceMappingURL=PopupManager-DpxoBl54.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PopupManager-DpxoBl54.mjs","names":["ServiceKey","isRtlContext","promoteToTopLayer","positionPopup","appendToRoot","consoleLogger","error","message","cause","console","warn","info","debug","silentLogger","scopedLogger","base","scope","prefix","invokeLogger","callback","result","Promise","resolve","then","PopupServiceKey","PopupManager","registerInteraction","stack","referenceNode","destroyed","constructor","this","open","config","Error","popup","document","createElement","className","ariaRole","setAttribute","ariaLabel","parentEntry","parent","findEntryByHandle","entry","handle","close","options","closeEntry","getElement","updatePosition","reposition","clickOutsideHandler","e","path","composedPath","includes","stackEntry","element","anchor","HTMLElement","restoreFocusTo","listenerRegistrationTimer","documentListenerAttached","focusFrame","cleanups","push","unregister","content","addEventListener","event","key","isComposing","defaultPrevented","at","preventDefault","stopPropagation","refNode","positionEntry","subscribe","unsubscribe","observePosition","setTimeout","autoFocus","focusFirstItem","top","length","closeAll","isOpen","destroy","indexOf","descendants","child","reverse","removeEntry","notifyClose","focus","onClose","index","splice","cleanup","cancelAnimationFrame","clearTimeout","remove","removeEventListener","anchorRect","getBoundingClientRect","getRect","position","isRtl","find","requestAnimationFrame","isConnected","querySelector","frame","update","listen","target","name","window","getRootNode","visualViewport","resize","ResizeObserver","observe","disconnect"],"sources":["../../src/plugins/Logger.ts","../../src/plugins/shared/PopupManager.ts"],"sourcesContent":["/**\n * Structured logger interface for the plugin infrastructure.\n *\n * Rationale:\n * - Direct `console.*` calls in shipped code leak debug artifacts to users\n * and give embedding applications no way to silence, redirect, or\n * instrument editor errors.\n * - A small Logger interface decouples the plugin runtime from its output\n * sink, enabling dependency injection (Clean Code / DIP) and trivial\n * replacement by test doubles.\n *\n * The API deliberately mirrors the widely understood `console` / Pino shape\n * (`error`, `warn`, `info`, `debug`) so that embedders can supply a custom\n * logger with a one-line adapter.\n */\n\n/**\n * Minimal structured logger.\n *\n * All methods accept an optional `cause` — typically the `Error` being\n * reported, but it may carry arbitrary diagnostic context.\n */\nexport interface Logger {\n\terror(message: string, cause?: unknown): void;\n\twarn(message: string, cause?: unknown): void;\n\tinfo(message: string, cause?: unknown): void;\n\tdebug(message: string, cause?: unknown): void;\n}\n\n/**\n * Default logger that forwards to the global `console`.\n *\n * This preserves the prior behavior (errors land in the browser console)\n * while still routing through the Logger interface so embedders can opt\n * into their own sink.\n */\nexport const consoleLogger: Logger = {\n\terror(message: string, cause?: unknown): void {\n\t\tif (cause === undefined) {\n\t\t\tconsole.error(message);\n\t\t} else {\n\t\t\tconsole.error(message, cause);\n\t\t}\n\t},\n\twarn(message: string, cause?: unknown): void {\n\t\tif (cause === undefined) {\n\t\t\tconsole.warn(message);\n\t\t} else {\n\t\t\tconsole.warn(message, cause);\n\t\t}\n\t},\n\tinfo(message: string, cause?: unknown): void {\n\t\tif (cause === undefined) {\n\t\t\tconsole.info(message);\n\t\t} else {\n\t\t\tconsole.info(message, cause);\n\t\t}\n\t},\n\tdebug(message: string, cause?: unknown): void {\n\t\tif (cause === undefined) {\n\t\t\tconsole.debug(message);\n\t\t} else {\n\t\t\tconsole.debug(message, cause);\n\t\t}\n\t},\n};\n\n/**\n * No-op logger that swallows every message.\n *\n * Useful for tests that want full silence, and for embedders that supply\n * their own error-reporting pipeline and do not want the editor to log at all.\n */\nexport const silentLogger: Logger = {\n\terror(): void {},\n\twarn(): void {},\n\tinfo(): void {},\n\tdebug(): void {},\n};\n\n/**\n * Wraps a logger so every message is prefixed with `[scope]`.\n *\n * Scoping keeps call sites concise while still producing messages that\n * clearly identify their origin in aggregated log output.\n */\nexport function scopedLogger(base: Logger, scope: string): Logger {\n\tconst prefix = `[${scope}]`;\n\treturn {\n\t\terror(message: string, cause?: unknown): void {\n\t\t\tinvokeLogger(() => base.error(`${prefix} ${message}`, cause));\n\t\t},\n\t\twarn(message: string, cause?: unknown): void {\n\t\t\tinvokeLogger(() => base.warn(`${prefix} ${message}`, cause));\n\t\t},\n\t\tinfo(message: string, cause?: unknown): void {\n\t\t\tinvokeLogger(() => base.info(`${prefix} ${message}`, cause));\n\t\t},\n\t\tdebug(message: string, cause?: unknown): void {\n\t\t\tinvokeLogger(() => base.debug(`${prefix} ${message}`, cause));\n\t\t},\n\t};\n}\n\n/** Keeps application-owned telemetry from escaping editor recovery boundaries. */\nfunction invokeLogger(callback: () => void): void {\n\ttry {\n\t\tconst result: unknown = callback();\n\t\tif (result !== null && (typeof result === 'object' || typeof result === 'function')) {\n\t\t\tvoid Promise.resolve(result).then(undefined, () => undefined);\n\t\t}\n\t} catch {\n\t\t// Logging is best-effort and must never become a second runtime failure.\n\t}\n}\n","/**\n * Central popup lifecycle manager. Handles creation, positioning,\n * click-outside closing, Escape key, focus restoration, and popup stacking\n * for submenus/nested popups.\n */\n\nimport { isRtlContext } from '../../platform/Platform.js';\nimport type { ViewportRect } from '../../view/SelectionGeometry.js';\nimport { consoleLogger } from '../Logger.js';\nimport { ServiceKey } from '../Plugin.js';\nimport {\n\ttype PopupPosition,\n\tappendToRoot,\n\tpositionPopup,\n\tpromoteToTopLayer,\n} from './PopupPositioning.js';\n\n// --- Types ---\n\n/** Options for overriding focus restoration when closing a popup. */\nexport interface PopupCloseOptions {\n\t/**\n\t * Override the default focus target on close.\n\t * - `HTMLElement` → focus that element instead of `config.restoreFocusTo`\n\t * - `null` → skip focus restoration entirely\n\t * - `undefined` / omitted → use default `config.restoreFocusTo`\n\t */\n\treadonly restoreFocusTo?: HTMLElement | null;\n}\n\nexport interface PopupConfig {\n\treadonly anchor: HTMLElement | ViewportRect | PopupAnchor;\n\treadonly content: (container: HTMLElement, close: (options?: PopupCloseOptions) => void) => void;\n\treadonly className?: string;\n\treadonly ariaRole?: 'menu' | 'listbox' | 'grid' | 'dialog';\n\treadonly ariaLabel?: string;\n\t/** Focus the first control on open. Disable for non-modal previews while editing. */\n\treadonly autoFocus?: boolean;\n\treadonly restoreFocusTo?: HTMLElement;\n\treadonly onClose?: () => void;\n\treadonly position?: PopupPosition;\n\treadonly parent?: PopupHandle;\n\treadonly referenceNode?: Node;\n}\n\nexport interface PopupHandle {\n\tclose(options?: PopupCloseOptions): void;\n\tgetElement(): HTMLElement;\n\t/** Re-measures the anchor and applies viewport collision handling. */\n\tupdatePosition(): void;\n}\n\n/** A live viewport anchor. A null rectangle closes the popup without moving focus. */\nexport interface PopupAnchor {\n\tgetRect(): ViewportRect | null;\n\tsubscribe?(listener: () => void): () => void;\n}\n\nexport interface PopupServiceAPI {\n\topen(config: PopupConfig): PopupHandle;\n\tclose(): void;\n\tcloseAll(): void;\n\tisOpen(): boolean;\n\treposition(handle: PopupHandle): void;\n}\n\nexport const PopupServiceKey = new ServiceKey<PopupServiceAPI>('popup');\n\n// --- Internal Entry ---\n\ninterface PopupEntry {\n\treadonly element: HTMLElement;\n\treadonly config: PopupConfig;\n\treadonly clickOutsideHandler: (e: Event) => void;\n\treadonly parent: PopupEntry | null;\n\tlistenerRegistrationTimer: ReturnType<typeof setTimeout> | null;\n\tdocumentListenerAttached: boolean;\n\tfocusFrame: number | null;\n\treadonly cleanups: (() => void)[];\n}\n\n// --- Manager ---\n\nexport class PopupManager implements PopupServiceAPI {\n\tprivate readonly stack: PopupEntry[] = [];\n\tprivate readonly referenceNode: Node;\n\tprivate destroyed = false;\n\n\tconstructor(\n\t\treferenceNode: Node,\n\t\tprivate readonly registerInteraction?: (element: HTMLElement) => () => void,\n\t) {\n\t\tthis.referenceNode = referenceNode;\n\t}\n\n\t/** Opens a popup with the given configuration. Returns a handle for closing it. */\n\topen(config: PopupConfig): PopupHandle {\n\t\tif (this.destroyed) throw new Error('Popup service has been destroyed.');\n\t\tconst popup: HTMLDivElement = document.createElement('div');\n\t\tpopup.className = config.className ? `notectl-popup ${config.className}` : 'notectl-popup';\n\n\t\tif (config.ariaRole) {\n\t\t\tpopup.setAttribute('role', config.ariaRole);\n\t\t}\n\t\tif (config.ariaLabel) {\n\t\t\tpopup.setAttribute('aria-label', config.ariaLabel);\n\t\t}\n\n\t\tconst parentEntry: PopupEntry | null = config.parent\n\t\t\t? this.findEntryByHandle(config.parent)\n\t\t\t: null;\n\n\t\tlet entry!: PopupEntry;\n\t\tconst handle: PopupHandle = {\n\t\t\tclose: (options?: PopupCloseOptions) => this.closeEntry(entry, options),\n\t\t\tgetElement: () => popup,\n\t\t\tupdatePosition: () => this.reposition(handle),\n\t\t};\n\n\t\tconst clickOutsideHandler = (e: Event): void => {\n\t\t\tconst path: EventTarget[] = e.composedPath();\n\t\t\tif (path.includes(popup)) return;\n\n\t\t\t// Don't close if click is inside any ancestor popup in the stack\n\t\t\tfor (const stackEntry of this.stack) {\n\t\t\t\tif (path.includes(stackEntry.element)) return;\n\t\t\t}\n\n\t\t\t// Don't close if click is on the anchor element\n\t\t\tif (config.anchor instanceof HTMLElement && path.includes(config.anchor)) return;\n\n\t\t\tthis.closeEntry(entry, { restoreFocusTo: null });\n\t\t};\n\n\t\tentry = {\n\t\t\telement: popup,\n\t\t\tconfig,\n\t\t\tclickOutsideHandler,\n\t\t\tparent: parentEntry,\n\t\t\tlistenerRegistrationTimer: null,\n\t\t\tdocumentListenerAttached: false,\n\t\t\tfocusFrame: null,\n\t\t\tcleanups: [],\n\t\t};\n\n\t\tthis.stack.push(entry);\n\t\tconst unregister = this.registerInteraction?.(popup);\n\t\tif (unregister) entry.cleanups.push(unregister);\n\t\ttry {\n\t\t\tconfig.content(popup, (options?: PopupCloseOptions) => this.closeEntry(entry, options));\n\t\t} catch (error) {\n\t\t\tthis.closeEntry(entry, { restoreFocusTo: null });\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!this.stack.includes(entry)) {\n\t\t\treturn handle;\n\t\t}\n\n\t\t// Feature handlers on this same container run first and may consume Escape\n\t\t// or close with their own focus target before the default dismissal runs.\n\t\tpopup.addEventListener('keydown', (event) => {\n\t\t\tif (event.key !== 'Escape' || event.isComposing || event.defaultPrevented) return;\n\t\t\tif (this.stack.at(-1) !== entry) return;\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tthis.closeEntry(entry);\n\t\t});\n\n\t\ttry {\n\t\t\tconst refNode: Node = config.referenceNode ?? this.referenceNode;\n\t\t\tappendToRoot(popup, refNode);\n\t\t\t// Promote to the top layer before measuring/positioning so the popup\n\t\t\t// escapes any ancestor stacking context in the host page.\n\t\t\tpromoteToTopLayer(popup);\n\n\t\t\tthis.positionEntry(entry);\n\t\t\tif (!this.stack.includes(entry)) return handle;\n\t\t\tif ('getRect' in config.anchor && config.anchor.subscribe) {\n\t\t\t\tconst unsubscribe = config.anchor.subscribe(() => this.reposition(handle));\n\t\t\t\tif (this.stack.includes(entry)) entry.cleanups.push(unsubscribe);\n\t\t\t\telse unsubscribe();\n\t\t\t}\n\t\t\tif (!this.stack.includes(entry)) return handle;\n\t\t\tthis.observePosition(entry);\n\n\t\t\tentry.listenerRegistrationTimer = setTimeout(() => {\n\t\t\t\tentry.listenerRegistrationTimer = null;\n\t\t\t\tif (!this.stack.includes(entry)) return;\n\t\t\t\tdocument.addEventListener('mousedown', clickOutsideHandler);\n\t\t\t\tdocument.addEventListener('touchstart', clickOutsideHandler);\n\t\t\t\tentry.documentListenerAttached = true;\n\t\t\t}, 0);\n\n\t\t\tif (config.autoFocus !== false) this.focusFirstItem(entry);\n\n\t\t\treturn handle;\n\t\t} catch (error) {\n\t\t\tthis.closeEntry(entry, { restoreFocusTo: null });\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Closes the topmost popup in the stack. */\n\tclose(): void {\n\t\tconst top: PopupEntry | undefined = this.stack[this.stack.length - 1];\n\t\tif (top) {\n\t\t\tthis.closeEntry(top);\n\t\t}\n\t}\n\n\t/** Closes all open popups. */\n\tcloseAll(): void {\n\t\twhile (this.stack.length > 0) {\n\t\t\tconst top: PopupEntry | undefined = this.stack[this.stack.length - 1];\n\t\t\tif (top) {\n\t\t\t\tthis.closeEntry(top);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Returns true if any popup is currently open. */\n\tisOpen(): boolean {\n\t\treturn this.stack.length > 0;\n\t}\n\n\t/** Cleans up all popups and event listeners. */\n\tdestroy(): void {\n\t\tthis.destroyed = true;\n\t\twhile (this.stack.length) {\n\t\t\tconst entry = this.stack.at(-1);\n\t\t\tif (entry) this.closeEntry(entry, { restoreFocusTo: null });\n\t\t}\n\t}\n\n\t// --- Internal ---\n\n\tprivate closeEntry(entry: PopupEntry, options?: PopupCloseOptions): void {\n\t\tconst index: number = this.stack.indexOf(entry);\n\t\tif (index === -1) return;\n\n\t\t// Only descendants belong to this popup; other root popups keep their lifecycle.\n\t\tconst descendants: PopupEntry[] = [];\n\t\tfor (const child of [...this.stack].reverse()) {\n\t\t\tlet parent = child.parent;\n\t\t\twhile (parent && parent !== entry) parent = parent.parent;\n\t\t\tif (parent === entry) {\n\t\t\t\tdescendants.push(child);\n\t\t\t\tthis.removeEntry(child);\n\t\t\t}\n\t\t}\n\n\t\tthis.removeEntry(entry);\n\t\t// Detach the complete group before callbacks may re-enter close().\n\t\tfor (const child of descendants) this.notifyClose(child);\n\n\t\tif (options !== undefined && 'restoreFocusTo' in options) {\n\t\t\toptions.restoreFocusTo?.focus();\n\t\t} else if (entry.config.restoreFocusTo) {\n\t\t\tentry.config.restoreFocusTo.focus();\n\t\t}\n\t\tthis.notifyClose(entry);\n\t}\n\n\tprivate notifyClose(entry: PopupEntry): void {\n\t\ttry {\n\t\t\tentry.config.onClose?.();\n\t\t} catch (error) {\n\t\t\tconsoleLogger.error('[PopupManager] onClose failed', error);\n\t\t}\n\t}\n\n\tprivate removeEntry(entry: PopupEntry): void {\n\t\tconst index: number = this.stack.indexOf(entry);\n\t\tif (index === -1) return;\n\n\t\tthis.stack.splice(index, 1);\n\t\tfor (const cleanup of entry.cleanups) {\n\t\t\ttry {\n\t\t\t\tcleanup();\n\t\t\t} catch (error) {\n\t\t\t\tconsoleLogger.error('[PopupManager] cleanup failed', error);\n\t\t\t}\n\t\t}\n\t\tif (entry.focusFrame !== null) cancelAnimationFrame(entry.focusFrame);\n\t\tif (entry.listenerRegistrationTimer !== null) {\n\t\t\tclearTimeout(entry.listenerRegistrationTimer);\n\t\t\tentry.listenerRegistrationTimer = null;\n\t\t}\n\t\tentry.element.remove();\n\t\tif (entry.documentListenerAttached) {\n\t\t\tdocument.removeEventListener('mousedown', entry.clickOutsideHandler);\n\t\t\tdocument.removeEventListener('touchstart', entry.clickOutsideHandler);\n\t\t\tentry.documentListenerAttached = false;\n\t\t}\n\t}\n\n\t/** Re-anchors an open popup after its anchor moved, for example through scrolling or resizing. */\n\treposition(handle: PopupHandle): void {\n\t\tconst entry: PopupEntry | null = this.findEntryByHandle(handle);\n\t\tif (entry) this.positionEntry(entry);\n\t}\n\n\tprivate positionEntry(entry: PopupEntry): void {\n\t\tconst config: PopupConfig = entry.config;\n\t\tconst anchorRect: ViewportRect | null =\n\t\t\tconfig.anchor instanceof HTMLElement\n\t\t\t\t? config.anchor.getBoundingClientRect()\n\t\t\t\t: 'getRect' in config.anchor\n\t\t\t\t\t? config.anchor.getRect()\n\t\t\t\t\t: config.anchor;\n\t\tif (!anchorRect) {\n\t\t\tthis.closeEntry(entry, { restoreFocusTo: null });\n\t\t\treturn;\n\t\t}\n\t\tpositionPopup(entry.element, anchorRect, {\n\t\t\tposition: config.position ?? 'below-start',\n\t\t\tisRtl: this.isRtlContext(),\n\t\t});\n\t}\n\n\tprivate findEntryByHandle(handle: PopupHandle): PopupEntry | null {\n\t\tconst element: HTMLElement = handle.getElement();\n\t\treturn this.stack.find((e) => e.element === element) ?? null;\n\t}\n\n\t/** Detects whether the editor context is RTL from the computed style. */\n\tprivate isRtlContext(): boolean {\n\t\tif (this.referenceNode instanceof HTMLElement) {\n\t\t\treturn isRtlContext(this.referenceNode);\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate focusFirstItem(entry: PopupEntry): void {\n\t\tconst popup = entry.element;\n\t\tentry.focusFrame = requestAnimationFrame(() => {\n\t\t\tentry.focusFrame = null;\n\t\t\tif (!popup.isConnected) return;\n\t\t\tconst firstFocusable: HTMLElement | null =\n\t\t\t\tpopup.querySelector('[role=\"menuitem\"]') ??\n\t\t\t\tpopup.querySelector('[role=\"option\"]') ??\n\t\t\t\tpopup.querySelector('[role=\"gridcell\"]') ??\n\t\t\t\t// `input, textarea` returns whichever comes first in the DOM, so a\n\t\t\t\t// popup whose primary field is a textarea (e.g. the formula editor's\n\t\t\t\t// LaTeX field) focuses that rather than a later text input.\n\t\t\t\tpopup.querySelector('input, textarea') ??\n\t\t\t\tpopup.querySelector('button');\n\t\t\tfirstFocusable?.focus();\n\t\t});\n\t}\n\n\tprivate observePosition(entry: PopupEntry): void {\n\t\tlet frame: number | null = null;\n\t\tconst update = (): void => {\n\t\t\tif (frame !== null) return;\n\t\t\tframe = requestAnimationFrame(() => {\n\t\t\t\tframe = null;\n\t\t\t\tif (this.stack.includes(entry)) this.positionEntry(entry);\n\t\t\t});\n\t\t};\n\t\tconst listen = (target: EventTarget, name: string): void => {\n\t\t\ttarget.addEventListener(name, update, true);\n\t\t\tentry.cleanups.push(() => target.removeEventListener(name, update, true));\n\t\t};\n\t\tlisten(window, 'resize');\n\t\tlisten(document, 'scroll');\n\t\tlisten(this.referenceNode.getRootNode(), 'scroll');\n\t\tif (window.visualViewport) {\n\t\t\tlisten(window.visualViewport, 'resize');\n\t\t\tlisten(window.visualViewport, 'scroll');\n\t\t}\n\t\tconst resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(update);\n\t\tresize?.observe(entry.element);\n\t\tif (entry.config.anchor instanceof HTMLElement) resize?.observe(entry.config.anchor);\n\t\tentry.cleanups.push(() => {\n\t\t\tresize?.disconnect();\n\t\t\tif (frame !== null) cancelAnimationFrame(frame);\n\t\t});\n\t}\n}\n"],"mappings":"Y,+IAoCA,IAAaK,EAAwB,CACpC,KAAAC,CAAMC,EAAiBC,QACR,IAAVA,EACHC,QAAQH,MAAMC,GAEdE,QAAQH,MAAMC,EAASC,EAEzB,EACA,IAAAE,CAAKH,EAAiBC,QACP,I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AAQ,UACfH,EAAOjF,SAAU,UACjBiF,EAAOtF,KAAKH,cAAc6F,cAAe,UACrCD,OAAOE,iBACVL,EAAOG,OAAOE,eAAgB,UAC9BL,EAAOG,OAAOE,eAAgB,WAE/B,MAAMC,EAAmC,oBAAnBC,eAAiC,KAAO,IAAIA,eAAeR,GACjFO,GAAQE,QAAQhF,EAAMc,SAClBd,EAAMZ,OAAO2B,kBAAkBC,aAAa8D,GAAQE,QAAQhF,EAAMZ,OAAO2B,QAC7Ef,EAAMqB,SAASC,KAAA,KACdwD,GAAQG,aACM,OAAVX,GAAgBb,qBAAqBa,IAE3C,U"}
@@ -1 +1 @@
1
- {"version":3,"file":"PopupPositioning-CIqgpqlW.mjs","names":["setStyleProperties","measureContainingBlockOffset","popup","prevTop","style","top","prevLeft","left","prevRight","right","leftRect","getBoundingClientRect","x","y","rightRect","rightX","window","innerWidth","positionPopup","anchor","options","offset","vpWidth","vpHeight","innerHeight","position","zIndex","cbOffset","popupWidth","offsetWidth","popupHeight","offsetHeight","styles","bottom","isRtl","appendToRoot","element","referenceNode","root","getRootNode","ShadowRoot","appendChild","document","body","getDeepActiveHTMLElement","active","Document","activeElement","shadowRoot","HTMLElement","promoteToTopLayer","showPopover","setAttribute","removeAttribute","margin","inset"],"sources":["../../src/plugins/shared/PopupPositioning.ts"],"sourcesContent":["/**\n * Shared popup positioning logic. Positions a popup element relative to an\n * anchor rectangle, clamping to the viewport. Also provides a shadow DOM-aware\n * append helper.\n */\n\nimport { setStyleProperties } from '../../style/StyleRuntime.js';\n\n// --- Types ---\n\nexport type PopupPosition = 'below-start' | 'below-end' | 'right';\n\nexport interface PositionOptions {\n\treadonly position: PopupPosition;\n\treadonly offset?: number;\n\treadonly isRtl?: boolean;\n}\n\nexport interface ContainingBlockOffset {\n\treadonly x: number;\n\treadonly y: number;\n\treadonly rightX: number;\n}\n\n// --- Constants ---\n\nconst DEFAULT_OFFSET = 2;\nconst Z_INDEX = '10000';\nconst POPUP_MIN_MARGIN = 4;\n\n// --- Containing Block Offset ---\n\n/**\n * Measures the offset between the popup's CSS containing block and the\n * viewport. When an ancestor has `transform`, `will-change: transform`,\n * `filter`, or `perspective`, `position: fixed` resolves relative to that\n * ancestor — not the viewport. This probe detects the shift so callers\n * can compensate.\n *\n * Technique: temporarily set `top: 0; left: 0` on the fixed-position\n * element and read `getBoundingClientRect()`. If no containing-block\n * ancestor exists the rect origin is `(0, 0)`; otherwise it equals the\n * ancestor's offset.\n */\nexport function measureContainingBlockOffset(popup: HTMLElement): ContainingBlockOffset {\n\tconst prevTop: string = popup.style.top;\n\tconst prevLeft: string = popup.style.left;\n\tconst prevRight: string = popup.style.right;\n\n\t// Probe 1: left-edge offset\n\tpopup.style.top = '0px';\n\tpopup.style.left = '0px';\n\tpopup.style.right = 'auto';\n\n\tconst leftRect: DOMRect = popup.getBoundingClientRect();\n\tconst x: number = leftRect.left;\n\tconst y: number = leftRect.top;\n\n\t// Probe 2: right-edge offset\n\tpopup.style.left = 'auto';\n\tpopup.style.right = '0px';\n\n\tconst rightRect: DOMRect = popup.getBoundingClientRect();\n\tconst rightX: number = window.innerWidth - rightRect.right;\n\n\tpopup.style.top = prevTop;\n\tpopup.style.left = prevLeft;\n\tpopup.style.right = prevRight;\n\n\treturn { x, y, rightX };\n}\n\n// --- Positioning ---\n\n/**\n * Positions a popup element relative to the given anchor rectangle.\n * Uses fixed positioning and clamps to the viewport edges.\n * Automatically compensates for ancestors that create a new containing\n * block (e.g. `transform`, `will-change: transform`).\n */\nexport function positionPopup(popup: HTMLElement, anchor: DOMRect, options: PositionOptions): void {\n\tconst offset: number = options.offset ?? DEFAULT_OFFSET;\n\tconst vpWidth: number = window.innerWidth;\n\tconst vpHeight: number = window.innerHeight;\n\n\t// Apply fixed positioning first so offsetWidth/offsetHeight reflect\n\t// shrink-to-fit sizing rather than normal-flow block width.\n\tsetStyleProperties(popup, { position: 'fixed', zIndex: Z_INDEX });\n\n\t// Detect containing-block offset caused by ancestor transforms etc.\n\tconst cbOffset: ContainingBlockOffset = measureContainingBlockOffset(popup);\n\n\tconst popupWidth: number = popup.offsetWidth;\n\tconst popupHeight: number = popup.offsetHeight;\n\n\tconst styles: Record<string, string> = {};\n\n\tswitch (options.position) {\n\t\tcase 'below-start': {\n\t\t\tlet top: number = anchor.bottom + offset;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: anchor to physical right edge (visual start)\n\t\t\t\tlet right: number = vpWidth - anchor.right;\n\t\t\t\tif (right + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tright = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (right < POPUP_MIN_MARGIN) right = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.right = `${right - cbOffset.rightX}px`;\n\t\t\t\tstyles.left = 'auto';\n\t\t\t} else {\n\t\t\t\tlet left: number = anchor.left;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'below-end': {\n\t\t\tlet top: number = anchor.bottom + offset;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: \"end\" = physical left edge\n\t\t\t\tlet left: number = anchor.left;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t} else {\n\t\t\t\t// LTR: \"end\" = physical right edge\n\t\t\t\tlet right: number = vpWidth - anchor.right;\n\t\t\t\tif (right + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tright = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (right < POPUP_MIN_MARGIN) right = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.right = `${right - cbOffset.rightX}px`;\n\t\t\t\tstyles.left = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'right': {\n\t\t\tlet top: number = anchor.top;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: open submenu to the physical left\n\t\t\t\tlet left: number = anchor.left - popupWidth - offset;\n\t\t\t\tif (left < POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = anchor.right + offset;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = vpHeight - popupHeight - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t} else {\n\t\t\t\tlet left: number = anchor.right + offset;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = anchor.left - popupWidth - offset;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = vpHeight - popupHeight - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tsetStyleProperties(popup, styles);\n}\n\n/**\n * Appends an element to the appropriate root: the shadow root if the\n * reference node lives inside one, otherwise `document.body`.\n */\nexport function appendToRoot(element: HTMLElement, referenceNode: Node): void {\n\tconst root: Node = referenceNode.getRootNode();\n\tif (root instanceof ShadowRoot) {\n\t\troot.appendChild(element);\n\t} else {\n\t\tdocument.body.appendChild(element);\n\t}\n}\n\n/** Returns the focused element in the reference node's root, including nested shadow roots. */\nexport function getDeepActiveHTMLElement(referenceNode: Node): HTMLElement | null {\n\tconst root: Node = referenceNode.getRootNode();\n\tlet active: Element | null =\n\t\troot instanceof ShadowRoot || root instanceof Document\n\t\t\t? root.activeElement\n\t\t\t: document.activeElement;\n\twhile (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;\n\treturn active instanceof HTMLElement ? active : null;\n}\n\n/**\n * Promotes a popup/overlay to the browser's top layer via the Popover API so it\n * paints above — and receives pointer events ahead of — every stacking context\n * in the host page. A high `z-index` alone is not enough: an ancestor that forms\n * a stacking context (e.g. Starlight's `isolation: isolate` content wrapper)\n * traps the popup below a sibling such as the fixed table-of-contents sidebar,\n * so clicks on the overlapped region hit the sidebar and dismiss the popup.\n *\n * The element keeps living in the editor's shadow DOM, so its registered styles\n * still apply; only its paint layer changes. Must be called while the element is\n * connected to the document and BEFORE positioning, so subsequent\n * `offsetWidth`/containing-block measurements reflect the displayed top-layer\n * box.\n *\n * No-ops when the Popover API is unavailable (older engines, happy-dom in unit\n * tests); callers then fall back to plain `z-index` stacking. Neutralizes the UA\n * popover box styles (`inset: 0; margin: auto`) so the caller's explicit\n * `top`/`left` placement is what positions the element.\n */\nexport function promoteToTopLayer(element: HTMLElement): void {\n\tif (typeof element.showPopover !== 'function') return;\n\telement.setAttribute('popover', 'manual');\n\ttry {\n\t\telement.showPopover();\n\t} catch {\n\t\telement.removeAttribute('popover');\n\t\treturn;\n\t}\n\tsetStyleProperties(element, { margin: '0', inset: 'auto' });\n}\n"],"mappings":"Y,oCA4CA,SAAgBC,EAA6BC,GAC5C,MAAMC,EAAkBD,EAAME,MAAMC,IAC9BC,EAAmBJ,EAAME,MAAMG,KAC/BC,EAAoBN,EAAME,MAAMK,MAGtCP,EAAME,MAAMC,IAAM,MAClBH,EAAME,MAAMG,KAAO,MACnBL,EAAME,MAAMK,MAAQ,OAEpB,MAAMC,EAAoBR,EAAMS,wBAC1BC,EAAYF,EAASH,KACrBM,EAAYH,EAASL,IAG3BH,EAAME,MAAMG,KAAO,OACnBL,EAAME,MAAMK,MAAQ,MAEpB,MAAMK,EAAqBZ,EAAM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ASf,EAAnB,KACdoB,EAAOvB,MAAQ,MAChB,KAAO,CACN,IAAIF,EAAeY,EAAOV,MAAQY,EAC9Bd,EAAOqB,EAAaN,EA5JH,IA6JpBf,EAAOY,EAAOZ,KAAOqB,EAAaP,GAE/BhB,EAAMyB,EAAcP,EA/JH,IAgKpBlB,EAAMkB,EAAWO,EAhKG,GAkKjBvB,EAlKiB,IAkKQA,EAlKR,GAmKjBF,EAnKiB,IAmKOA,EAnKP,GAoKrB2B,EAAO3B,IAASA,EAAMsB,EAASd,EAAlB,KACbmB,EAAOzB,KAAUA,EAAOoB,EAASf,EAAnB,KACdoB,EAAOvB,MAAQ,MAChB,CACA,KACD,EAGDT,EAAmBE,EAAO8B,EAC3B,CAMA,SAAgBG,EAAaC,EAAsBC,GAClD,MAAMC,EAAaD,EAAcE,cAC7BD,aAAgBE,WACnBF,EAAKG,YAAYL,GAEjBM,SAASC,KAAKF,YAAYL,EAE5B,CAGA,SAAgBQ,EAAyBP,GACxC,MAAMC,EAAaD,EAAcE,cACjC,IAAIM,EACHP,aAAgBE,YAAcF,aAAgBQ,SAC3CR,EAAKS,cACLL,SAASK,cACb,KAAOF,GAAQG,YAAYD,eAAeF,EAASA,EAAOG,WAAWD,cACrE,OAAOF,aAAkBI,YAAcJ,EAAS,IACjD,CAqBA,SAAgBK,EAAkBd,GACjC,GAAmC,mBAAxBA,EAAQe,YAAnB,CACAf,EAAQgB,aAAa,UAAW,UAChC,IACChB,EAAQe,aACT,CAAA,MAEC,YADAf,EAAQiB,gBAAgB,UAEzB,CACArD,EAAmBoC,EAAS,CAAEkB,OAAQ,IAAKC,MAAO,QARH,CAShD,Q"}
1
+ {"version":3,"file":"PopupPositioning-CIqgpqlW.mjs","names":["setStyleProperties","measureContainingBlockOffset","popup","prevTop","style","top","prevLeft","left","prevRight","right","leftRect","getBoundingClientRect","x","y","rightRect","rightX","window","innerWidth","positionPopup","anchor","options","offset","vpWidth","vpHeight","innerHeight","position","zIndex","cbOffset","popupWidth","offsetWidth","popupHeight","offsetHeight","styles","bottom","isRtl","appendToRoot","element","referenceNode","root","getRootNode","ShadowRoot","appendChild","document","body","getDeepActiveHTMLElement","active","Document","activeElement","shadowRoot","HTMLElement","promoteToTopLayer","showPopover","setAttribute","removeAttribute","margin","inset"],"sources":["../../src/plugins/shared/PopupPositioning.ts"],"sourcesContent":["/**\n * Shared popup positioning logic. Positions a popup element relative to an\n * anchor rectangle, clamping to the viewport. Also provides a shadow DOM-aware\n * append helper.\n */\n\nimport { setStyleProperties } from '../../style/StyleRuntime.js';\nimport type { ViewportRect } from '../../view/SelectionGeometry.js';\n\n// --- Types ---\n\nexport type PopupPosition = 'below-start' | 'below-end' | 'right';\n\nexport interface PositionOptions {\n\treadonly position: PopupPosition;\n\treadonly offset?: number;\n\treadonly isRtl?: boolean;\n}\n\nexport interface ContainingBlockOffset {\n\treadonly x: number;\n\treadonly y: number;\n\treadonly rightX: number;\n}\n\n// --- Constants ---\n\nconst DEFAULT_OFFSET = 2;\nconst Z_INDEX = '10000';\nconst POPUP_MIN_MARGIN = 4;\n\n// --- Containing Block Offset ---\n\n/**\n * Measures the offset between the popup's CSS containing block and the\n * viewport. When an ancestor has `transform`, `will-change: transform`,\n * `filter`, or `perspective`, `position: fixed` resolves relative to that\n * ancestor — not the viewport. This probe detects the shift so callers\n * can compensate.\n *\n * Technique: temporarily set `top: 0; left: 0` on the fixed-position\n * element and read `getBoundingClientRect()`. If no containing-block\n * ancestor exists the rect origin is `(0, 0)`; otherwise it equals the\n * ancestor's offset.\n */\nexport function measureContainingBlockOffset(popup: HTMLElement): ContainingBlockOffset {\n\tconst prevTop: string = popup.style.top;\n\tconst prevLeft: string = popup.style.left;\n\tconst prevRight: string = popup.style.right;\n\n\t// Probe 1: left-edge offset\n\tpopup.style.top = '0px';\n\tpopup.style.left = '0px';\n\tpopup.style.right = 'auto';\n\n\tconst leftRect: DOMRect = popup.getBoundingClientRect();\n\tconst x: number = leftRect.left;\n\tconst y: number = leftRect.top;\n\n\t// Probe 2: right-edge offset\n\tpopup.style.left = 'auto';\n\tpopup.style.right = '0px';\n\n\tconst rightRect: DOMRect = popup.getBoundingClientRect();\n\tconst rightX: number = window.innerWidth - rightRect.right;\n\n\tpopup.style.top = prevTop;\n\tpopup.style.left = prevLeft;\n\tpopup.style.right = prevRight;\n\n\treturn { x, y, rightX };\n}\n\n// --- Positioning ---\n\n/**\n * Positions a popup element relative to the given anchor rectangle.\n * Uses fixed positioning and clamps to the viewport edges.\n * Automatically compensates for ancestors that create a new containing\n * block (e.g. `transform`, `will-change: transform`).\n */\nexport function positionPopup(\n\tpopup: HTMLElement,\n\tanchor: ViewportRect,\n\toptions: PositionOptions,\n): void {\n\tconst offset: number = options.offset ?? DEFAULT_OFFSET;\n\tconst vpWidth: number = window.innerWidth;\n\tconst vpHeight: number = window.innerHeight;\n\n\t// Apply fixed positioning first so offsetWidth/offsetHeight reflect\n\t// shrink-to-fit sizing rather than normal-flow block width.\n\tsetStyleProperties(popup, { position: 'fixed', zIndex: Z_INDEX });\n\n\t// Detect containing-block offset caused by ancestor transforms etc.\n\tconst cbOffset: ContainingBlockOffset = measureContainingBlockOffset(popup);\n\n\tconst popupWidth: number = popup.offsetWidth;\n\tconst popupHeight: number = popup.offsetHeight;\n\n\tconst styles: Record<string, string> = {};\n\n\tswitch (options.position) {\n\t\tcase 'below-start': {\n\t\t\tlet top: number = anchor.bottom + offset;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: anchor to physical right edge (visual start)\n\t\t\t\tlet right: number = vpWidth - anchor.right;\n\t\t\t\tif (right + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tright = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (right < POPUP_MIN_MARGIN) right = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.right = `${right - cbOffset.rightX}px`;\n\t\t\t\tstyles.left = 'auto';\n\t\t\t} else {\n\t\t\t\tlet left: number = anchor.left;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'below-end': {\n\t\t\tlet top: number = anchor.bottom + offset;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: \"end\" = physical left edge\n\t\t\t\tlet left: number = anchor.left;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t} else {\n\t\t\t\t// LTR: \"end\" = physical right edge\n\t\t\t\tlet right: number = vpWidth - anchor.right;\n\t\t\t\tif (right + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tright = vpWidth - popupWidth - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = anchor.top - popupHeight - offset;\n\t\t\t\t}\n\t\t\t\tif (right < POPUP_MIN_MARGIN) right = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.right = `${right - cbOffset.rightX}px`;\n\t\t\t\tstyles.left = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 'right': {\n\t\t\tlet top: number = anchor.top;\n\n\t\t\tif (options.isRtl) {\n\t\t\t\t// RTL: open submenu to the physical left\n\t\t\t\tlet left: number = anchor.left - popupWidth - offset;\n\t\t\t\tif (left < POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = anchor.right + offset;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = vpHeight - popupHeight - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t} else {\n\t\t\t\tlet left: number = anchor.right + offset;\n\t\t\t\tif (left + popupWidth > vpWidth - POPUP_MIN_MARGIN) {\n\t\t\t\t\tleft = anchor.left - popupWidth - offset;\n\t\t\t\t}\n\t\t\t\tif (top + popupHeight > vpHeight - POPUP_MIN_MARGIN) {\n\t\t\t\t\ttop = vpHeight - popupHeight - POPUP_MIN_MARGIN;\n\t\t\t\t}\n\t\t\t\tif (left < POPUP_MIN_MARGIN) left = POPUP_MIN_MARGIN;\n\t\t\t\tif (top < POPUP_MIN_MARGIN) top = POPUP_MIN_MARGIN;\n\t\t\t\tstyles.top = `${top - cbOffset.y}px`;\n\t\t\t\tstyles.left = `${left - cbOffset.x}px`;\n\t\t\t\tstyles.right = 'auto';\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tsetStyleProperties(popup, styles);\n}\n\n/**\n * Appends an element to the appropriate root: the shadow root if the\n * reference node lives inside one, otherwise `document.body`.\n */\nexport function appendToRoot(element: HTMLElement, referenceNode: Node): void {\n\tconst root: Node = referenceNode.getRootNode();\n\tif (root instanceof ShadowRoot) {\n\t\troot.appendChild(element);\n\t} else {\n\t\tdocument.body.appendChild(element);\n\t}\n}\n\n/** Returns the focused element in the reference node's root, including nested shadow roots. */\nexport function getDeepActiveHTMLElement(referenceNode: Node): HTMLElement | null {\n\tconst root: Node = referenceNode.getRootNode();\n\tlet active: Element | null =\n\t\troot instanceof ShadowRoot || root instanceof Document\n\t\t\t? root.activeElement\n\t\t\t: document.activeElement;\n\twhile (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;\n\treturn active instanceof HTMLElement ? active : null;\n}\n\n/**\n * Promotes a popup/overlay to the browser's top layer via the Popover API so it\n * paints above — and receives pointer events ahead of — every stacking context\n * in the host page. A high `z-index` alone is not enough: an ancestor that forms\n * a stacking context (e.g. Starlight's `isolation: isolate` content wrapper)\n * traps the popup below a sibling such as the fixed table-of-contents sidebar,\n * so clicks on the overlapped region hit the sidebar and dismiss the popup.\n *\n * The element keeps living in the editor's shadow DOM, so its registered styles\n * still apply; only its paint layer changes. Must be called while the element is\n * connected to the document and BEFORE positioning, so subsequent\n * `offsetWidth`/containing-block measurements reflect the displayed top-layer\n * box.\n *\n * No-ops when the Popover API is unavailable (older engines, happy-dom in unit\n * tests); callers then fall back to plain `z-index` stacking. Neutralizes the UA\n * popover box styles (`inset: 0; margin: auto`) so the caller's explicit\n * `top`/`left` placement is what positions the element.\n */\nexport function promoteToTopLayer(element: HTMLElement): void {\n\tif (typeof element.showPopover !== 'function') return;\n\telement.setAttribute('popover', 'manual');\n\ttry {\n\t\telement.showPopover();\n\t} catch {\n\t\telement.removeAttribute('popover');\n\t\treturn;\n\t}\n\tsetStyleProperties(element, { margin: '0', inset: 'auto' });\n}\n"],"mappings":"Y,oCA6CA,SAAgBC,EAA6BC,GAC5C,MAAMC,EAAkBD,EAAME,MAAMC,IAC9BC,EAAmBJ,EAAME,MAAMG,KAC/BC,EAAoBN,EAAME,MAAMK,MAGtCP,EAAME,MAAMC,IAAM,MAClBH,EAAME,MAAMG,KAAO,MACnBL,EAAME,MAAMK,MAAQ,OAEpB,MAAMC,EAAoBR,EAAMS,wBAC1BC,EAAYF,EAASH,KACrBM,EAAYH,EAASL,IAG3BH,EAAME,MAAMG,KAAO,OACnBL,EAAME,MAAMK,MAAQ,MAEpB,MAAMK,EAAqBZ,EAAMS,wBAC3BI,EAAiBC,OAAOC,WAAaH,EAAUL,MAMrD,OAJAP,EAAME,MAAMC,IAAMF,EAClBD,EAAME,MAAMG,KAAOD,EACnBJ,EAAME,MAAMK,MAAQD,EAEb,CAAEI,IAAGC,IAAGE,SAChB,CAUA,SAAgBG,EACfhB,EACAiB,EACAC,GAEA,MAAMC,EAAiBD,EAAQC,QA3DT,EA4DhBC,EAAkBN,OAAOC,WACzBM,EAAmBP,OAAOQ,YAIhCxB,EAAmBE,EAAO,CAAEuB,SAAU,QAASC,OAhEhC,UAmEf,MAAMC,EAAkC1B,EAA6BC,GAE/D0B,EAAqB1B,EAAM2B,YAC3BC,EAAsB5B,EAAM6B,aAE5BC,EAAiC,CAAC,EAExC,OAAQZ,EAAQK,UACf,IAAK,cAAe,CACnB,IAAIpB,EAAcc,EAAOc,OAASZ,EAElC,GAAID,EAAQc,MAAO,CAElB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AAKF,YAAYL,EAE5B,CAGA,SAAgBQ,EAAyBP,GACxC,MAAMC,EAAaD,EAAcE,cACjC,IAAIM,EACHP,aAAgBE,YAAcF,aAAgBQ,SAC3CR,EAAKS,cACLL,SAASK,cACb,KAAOF,GAAQG,YAAYD,eAAeF,EAASA,EAAOG,WAAWD,cACrE,OAAOF,aAAkBI,YAAcJ,EAAS,IACjD,CAqBA,SAAgBK,EAAkBd,GACjC,GAAmC,mBAAxBA,EAAQe,YAAnB,CACAf,EAAQgB,aAAa,UAAW,UAChC,IACChB,EAAQe,aACT,CAAA,MAEC,YADAf,EAAQiB,gBAAgB,UAEzB,CACArD,EAAmBoC,EAAS,CAAEkB,OAAQ,IAAKC,MAAO,QARH,CAShD,Q"}
@@ -0,0 +1,2 @@
1
+ import{i as t,o as e,r as n}from"./HTMLUtils-DTpsjZyK.mjs";import{a as o,d as r,f as s,h as i,i as a,n as c,r as l,s as u,v as d}from"./ThemeEngine-kIXtSRkI.mjs";import{n as f}from"./HTMLSanitization-BRipXyhI.mjs";import{s as p,t as h}from"./LocaleLoader-DEpTFuVc.mjs";import{i as m,l as g,n as y,s as b}from"./StyleRuntime-C0RSqKzG.mjs";import{t as v}from"./ShortcutFormatting-TwiufqeV.mjs";var $={label:"Print",tooltip:t=>`Print (${t})`,printingAnnouncement:"Printing"},S=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-Uzo1Azdw.mjs"),"./locales/de.ts":()=>import("./de-DcMhfRBu.mjs"),"./locales/es.ts":()=>import("./es-BJHF95J_.mjs"),"./locales/fr.ts":()=>import("./fr-KXmbys88.mjs"),"./locales/hi.ts":()=>import("./hi-l6DA-aOw.mjs"),"./locales/nl.ts":()=>import("./nl-CgYWZnga.mjs"),"./locales/pt.ts":()=>import("./pt-C8sOyw0V.mjs"),"./locales/ru.ts":()=>import("./ru-B1m8J9dl.mjs"),"./locales/zh.ts":()=>import("./zh-dGSDBBzb.mjs")});async function w(t){return h(S,t,$)}var T=["h1","h2","h3","h4","h5","h6","p","div","span","br","hr","strong","b","em","i","u","s","sub","sup","small","ul","ol","li","table","thead","tbody","tr","th","td","img"],k=["style","class","src","alt","width","height","colspan","rowspan"];function j(t){const e="function"==typeof t?t():t;return f(e,{ALLOWED_TAGS:[...T],ALLOWED_ATTR:[...k]})}var C=/* @__PURE__ */new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),A=/* @__PURE__ */new Set(["TABLE","THEAD","TBODY","TFOOT","TR"]),L=/* @__PURE__ */new Set(["AUDIO","CANVAS","EMBED","IFRAME","IMG","INPUT","METER","OBJECT","PROGRESS","SELECT","TEXTAREA","VIDEO"]);function E(t,e){let n;do{n=`${t}-${crypto.randomUUID()}`}while(e.has(n));return e.add(n),n}function x(t){const e=/* @__PURE__ */new Map;t.matches("[data-block-id][id]")&&""!==t.id&&e.set(t.id,t);for(const n of t.querySelectorAll("[data-block-id][id]")){const t=n.id;""===t||e.has(t)||e.set(t,n)}return e}function M(t,n){for(const o of e(n)){const e=t.get(o);if(e)return e}}function R(t,e,n,o){const r=E("notectl-print-destination",n),s=E("notectl-print-destination-slot",o),i=e.createElement("slot");i.name=s,i.setAttribute("data-notectl-print-destination-slot",""),function(t,e){if(C.has(t.tagName)||L.has(t.tagName))t.before(e);else{if(A.has(t.tagName)){const n=t.querySelector("th, td");if(n)return void n.insertBefore(e,n.firstChild);const o=t.closest("table");if(o?.parentNode)return void o.before(e)}t.insertBefore(e,t.firstChild)}}(t,i);const a=e.createElement("a");return a.id=r,a.setAttribute("href",`#${r}`),a.slot=s,a.tabIndex=-1,a.setAttribute("aria-hidden","true"),a.setAttribute("data-notectl-print-destination",""),function(t){for(const[e,n]of Object.entries({all:"initial",display:"block",position:"absolute",width:"0",height:"0",margin:"0",padding:"0",border:"0",overflow:"hidden","pointer-events":"none","font-size":"0","line-height":"0",color:"transparent",background:"transparent"}))t.style.setProperty(e,n,"important")}(a),{id:r,marker:a}}var N="notectl-host";function B(t){const e=Array.from(t.styleSheets),n=t.adoptedStyleSheets;return n&&e.push(...n),e}function H(t,e){const n=t[e]??'"';let o=e+1;for(;o<t.length;){const e=t[o]??"";if("\\"!==e){if(e===n)return o+1;o++}else o+=2}return t.length}function z(t,e){if("url("!==t.slice(e,e+4).toLowerCase())return!1;const n=e>0?t[e-1]??"":"";return!/[\w-]/.test(n)}function P(t,e){let n=e+4;for(;n<t.length&&/\s/.test(t[n]??"");)n++;const o=t[n]??"";let r;if('"'===o||"'"===o){const e=H(t,n);r=t.slice(n+1,e-1),n=e}else{const e=t.indexOf(")",n);if(-1===e)return null;r=t.slice(n,e).trim(),n=e}for(;n<t.length&&/\s/.test(t[n]??"");)n++;return")"!==t[n]?null:{end:n+1,url:(s=r,s.replace(/\\([0-9a-f]{1,6}\s?|[\s\S])/gi,(t,e)=>{const n=e.trim();if(/^[0-9a-f]{1,6}$/i.test(n)){const t=Number.parseInt(n,16);return t>0&&t<=1114111?String.fromCodePoint(t):"�"}return e}))};var s}function q(t,e,n){if(!e||!function(t){return!t.startsWith("#")&&!t.startsWith("//")&&!/^[a-z][a-z0-9+.-]*:/i.test(t)}(e))return t;try{return`url("${new URL(e,n).href}")`}catch{return t}}function D(t,e){if(!t.toLowerCase().includes("url("))return t;let n="",o=0;for(;o<t.length;){const r=t[o]??"";if('"'===r||"'"===r){const e=H(t,o);n+=t.slice(o,e),o=e;continue}if(z(t,o)){const r=P(t,o);if(r){n+=q(t.slice(o,r.end),r.url,e),o=r.end;continue}}n+=r,o++}return n}function O(t){return t.anonymousLayerCount+=1,`notectl-anonymous-${t.anonymousLayerCount}`}var I={media:[],layers:[],supports:[]};function U(t,e,n,o){const r=e.trim(),s=o?.trim()??"";return{media:r&&"all"!==r?[...t.media,r]:t.media,layers:null===n?t.layers:[...t.layers,""===n?null:n],supports:s?[...t.supports,s]:t.supports}}function W(t,e,n){const o=[N];for(const c of n.layers)o.push(c??O(t));const r=0===(s=n.supports).length?"":1===s.length?` supports(${s[0]})`:` supports(${s.map(t=>`(${t})`).join(" and ")})`;var s;const i=n.media.length?` ${n.media.join(" and ")}`:"";var a;t.segments.push({kind:"import",statement:`@import url("${a=e,a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}") layer(${o.join(".")})${r}${i};`})}function V(t,e){const n=e.trim();return n&&"all"!==n?`@media ${n} {\n${t}\n}`:t}function G(t,e){if(e.seen.has(t))return;if(e.seen.add(t),t.disabled)return;const n=U(I,t.media.mediaText,null,null);let o;try{o=t.cssRules}catch{return void(t.href&&W(e,t.href,n))}const r=t.href??e.baseURL,s=[];for(const a of o)3!==a.type?s.push(D(a.cssText,r)):K(a,e,s,n);const i=s.join("\n");i&&function(t,e){const n=t.segments[t.segments.length-1];"rules"!==n?.kind?t.segments.push({kind:"rules",css:e}):t.segments[t.segments.length-1]={kind:"rules",css:`${n.css}\n${e}`}}(e,V(i,t.media.mediaText))}function K(t,e,n,o){const r=t.layerName??null,s=t.supportsText??null,i=U(o,t.media.mediaText,r,s),a=t.styleSheet;if(a&&!e.seen.has(a)){let o;try{o=a.cssRules}catch{o=null}if(o){e.seen.add(a);const c=a.href??e.baseURL,l=[];for(const t of o)3!==t.type?l.push(D(t.cssText,c)):K(t,e,l,i);let u=l.join("\n");return void(u&&(null!==r&&(u=""===r?`@layer {\n${u}\n}`:`@layer ${r} {\n${u}\n}`),s?.trim()&&(u=`@supports (${s.trim()}) {\n${u}\n}`),n.push(V(u,t.media.mediaText))))}}const c=a?.href??t.href;c&&W(e,c,i)}var F="notectl-print",Y="notectl-custom";function _(t){return t.replace(/;$/gm," !important;")}function X(t){return _(c(u).replace(":host {",`${t} {`))}function J(t,e){const n=getComputedStyle(t),o=[];for(let r=0;r<n.length;r++){const t=n[r]??"";if(t.startsWith("--notectl-")){const e=n.getPropertyValue(t).trim();e&&o.push(` ${t}: ${e};`)}}return 0===o.length?"":`${e} {\n${o.join("\n")}\n}`}var Z=["","transparent","rgba(0, 0, 0, 0)"];function Q(t){let e=t;for(;e;){const t=getComputedStyle(e).getPropertyValue("background-color").trim();if(!Z.includes(t))return t;const n=e.getRootNode();e=e.parentElement??(n instanceof ShadowRoot?n.host:null)}return"#ffffff"}function tt(t,e,n="#ffffff",o="body"){const r=getComputedStyle(t),s=["font-family","font-size","font-weight","line-height","letter-spacing","word-spacing","color"],i=[" margin: 0;",` background: ${n};`];for(const a of s){if("color"===a&&e){i.push(` color: ${e};`);continue}const t=r.getPropertyValue(a).trim();t&&i.push(` ${a}: ${t};`)}return`${o} {\n${i.join("\n")}\n}`}var et=["display: block","position: static","inset: auto","width: auto","height: auto","min-width: 0","min-height: 0","max-width: none","max-height: none","margin: 0","padding: 0","border: none","border-radius: 0","outline: none","box-shadow: none","background: transparent","overflow: visible","transform: none","filter: none","opacity: 1","contain: none","float: none","visibility: visible","clip: auto","clip-path: none","content-visibility: visible"],nt=["display: block","visibility: visible","opacity: 1","position: static","height: auto","min-height: 0","max-height: none","overflow: visible","transform: none","filter: none","contain: none","clip: auto","clip-path: none","content-visibility: visible"];function ot(t){return[`${t} {`,...et.map(t=>` ${t} !important;`),"}"].join("\n")}function rt(t,e,n){const o=t.tagName.toLowerCase(),r=[],s=!1!==n.forceLightTheme,a=[ot(o),["html, body {",...nt.map(t=>` ${t} !important;`),"}"].join("\n")];if(s&&a.push(X(`:root, ${o}`)),!1!==n.printBackground&&a.push("* {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n}"),r.push(`@layer ${F} {\n${a.join("\n\n")}\n}`),!s){const e=J(t,`:root, ${o}`);e&&r.push(e)}const c=s?u.primitives.foreground:void 0,l=s?"#ffffff":Q(e);r.push(tt(t,c,l));const d=function(t){const e=[];if(t.margin?e.push(` margin: ${t.margin};`):t.paperSize&&e.push(" margin: 0;"),t.paperSize||t.orientation){const n=[t.paperSize?i(t.paperSize):"A4"];t.orientation&&n.push(t.orientation),e.push(` size: ${n.join(" ")};`)}return 0===e.length?"":`@page {\n${e.join("\n")}\n}`}(n);return d&&r.push(d),n.customCSS&&(r.push(n.customCSS),r.push(`@layer ${Y} {\n${n.customCSS}\n}`)),r.join("\n\n")}function st(t,e,n,o){const r=`${t.tagName.toLowerCase()}[${o}]`,s=!1!==n.forceLightTheme,i=[ot(r)];s&&i.push(X(r)),!1!==n.printBackground&&i.push(`${r}, ${r} * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n}`);const a=s?u.primitives.foreground:void 0,c=s?"#ffffff":Q(e);i.push(_(tt(t,a,c,r)));const l=[`@layer ${F} {\n${i.join("\n\n")}\n}`];if(!s){const e=J(t,r);e&&l.push(e)}return l.join("\n\n")}var it="data-notectl-print-fallback",at=["(function () {"," var head = document.head;"," if (head && head.querySelector('meta[name=\"notectl-print-export\"]')) {"," var bundles = document.querySelectorAll('template[data-notectl-print-styles]');"," for (var b = 0; b < bundles.length; b++) {"," if (bundles[b].content) head.appendChild(bundles[b].content);"," bundles[b].parentNode.removeChild(bundles[b]);"," }"," }"," var statics = document.querySelectorAll('[data-notectl-static]');"," for (var i = 0; i < statics.length; i++) {"," var host = statics[i];"," if (!host.shadowRoot && host.attachShadow) {"," for (var j = 0; j < host.children.length; j++) {"," var child = host.children[j];"," if (child.tagName !== 'TEMPLATE') continue;"," if (!child.getAttribute('shadowrootmode') || !child.content) continue;"," host.attachShadow({ mode: 'open' }).appendChild(child.content);"," host.removeChild(child);"," break;"," }"," }"," if (!host.shadowRoot) continue;"," var fallbacks = host.querySelectorAll('[data-notectl-print-fallback]');"," for (var k = 0; k < fallbacks.length; k++) {"," fallbacks[k].parentNode.removeChild(fallbacks[k]);"," }"," }","})();"].join("\n");function ct(t){return t.replace(/<\//g,"<\\/")}function lt(t,e){const o=[];for(const r of Array.from(t.attributes))e(r.name)&&o.push(""===r.value?r.name:`${r.name}="${n(r.value)}"`);return o.length>0?` ${o.join(" ")}`:""}function ut(t){return t?lt(t,t=>"class"===t||t.startsWith("data-")):""}function dt(t){const e=function(t){if(!(t instanceof HTMLElement))return"";const e=[];for(let n=0;n<t.style.length;n++){const o=t.style[n]??"";if(!o.startsWith("--notectl-"))continue;const r=t.style.getPropertyValue(o).trim();r&&e.push(`${o}: ${r}`)}return e.join("; ")}(t);return e?` style="${n(e)}"`:""}function ft(e){const o=e.host.ownerDocument,r=e.host.tagName.toLowerCase(),s="export"===e.variant,i=s?["style","id",d]:["style",d],a=(c=e.host,l=i,lt(c,t=>!l.includes(t)));var c,l;const u=e.carryThemeContext?dt(e.host):"",f=e.carryThemeContext?ut(o.documentElement)+dt(o.documentElement):"",p=e.carryThemeContext?ut(o.body)+dt(o.body):"",h=e.styleNonce?` nonce="${n(e.styleNonce)}"`:"",m=['<meta charset="utf-8">',`<title>${t(e.title)}</title>`];s&&m.push('<meta name="notectl-print-export">'),m.push(`<style${h}>@layer ${Y}, ${F}, ${N};</style>`),m.push(`<style${h}>${ct(e.documentCSS)}</style>`);const g=e.hostSegments.map(t=>{const e="import"===t.kind?t.statement:`@layer ${N} {\n${t.css}\n}`;return`<style${h}>${ct(e)}</style>`});s||m.push(...g);const y=s?`<template data-notectl-print-styles><style>${ct(e.standaloneCSS)}</style>${g.join("")}</template>`:"",b=s?`<div ${it}><style>@scope ([${it}]) {\n${ct(e.shadowCSS)}\n}</style>${e.fallbackContentHTML}</div>`:"",v=s?`<script>${at}<\/script>`:"",$=[`<${r}${a}${u} ${d}>`,'<template shadowrootmode="open">',`<style${h}>${ct(e.shadowCSS)}</style>`,e.contentHTML,"</template>",...b?[b]:[],...e.destinationMarkersHTML?[e.destinationMarkersHTML]:[],`</${r}>`,...y?[y]:[],...v?[v]:[]];return["<!DOCTYPE html>",`<html lang="${n(e.lang)}"${f}>`,"<head>",...m,"</head>",`<body${p}>`,...$,"</body>","</html>"].join("\n")}function pt(t,e,n,o){const r=/* @__PURE__ */new Set;function s(t){return t??{}}function i(r){const s={options:r,cancelled:!1};if(o.emit(a,s),s.cancelled)return null;const i=s.options,c=function(t,e){const n=[],o=function(t){const e=[],n=[];for(const o of t.adoptedStyleSheets){const t=m(o)?n:e;for(const e of o.cssRules)t.push(e.cssText)}return{base:e.join("\n"),runtime:n.join("\n")}}(t);o.base&&n.push(`@layer notectl-base {\n${o.base}\n}`),o.runtime&&n.push(o.runtime);const r=function(t){const e=[];e.push(".notectl-content { height: auto !important; max-height: none !important; min-height: 0 !important; overflow: visible !important; }"),t.paperSize&&e.push(".notectl-content { padding: 48px 56px !important; }");const n=[];return n.push("[data-notectl-no-print] { display: none !important; }"),n.push(".notectl-code-block { white-space: pre-wrap !important; word-break: break-all !important; page-break-inside: avoid; }"),n.push("img { page-break-inside: avoid; }"),n.push(".notectl-table { break-inside: avoid; }"),!1!==t.printBackground&&n.push("* { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }"),e.push(`@media print {\n ${n.join("\n ")}\n}`),e.join("\n\n")}(e);return r&&n.push(r),e.customCSS&&n.push(e.customCSS),n.join("\n\n")}(t,i),u=function(t){const e={segments:[],seen:/* @__PURE__ */new Set,baseURL:t.ownerDocument.baseURI??"",anonymousLayerCount:0};for(const n of function(t){const e=[];let n=t.getRootNode();for(;n instanceof ShadowRoot;)e.push(n),n=n.host.getRootNode();return e.push(t.ownerDocument),e.reverse()}(t))for(const t of B(n))G(t,e);return e.segments}(e),f=function(t,e){const n=function(t){return(t.querySelector(".notectl-content")??t).cloneNode(!0)}(t);return function(t){t.removeAttribute("contenteditable");for(const e of["notectl-node-selected","notectl-content--empty","notectl-table-cell--selected"]){t.classList.remove(e);for(const n of t.querySelectorAll(`.${e}`))n.classList.remove(e)}t.removeAttribute("data-placeholder")}(n),function(t,e){if(e.excludeBlockTypes)for(const n of e.excludeBlockTypes){const e=t.querySelectorAll(`[data-block-type="${n}"]`);for(const t of e)t.remove()}if(e.pageBreakBefore)for(const n of e.pageBreakBefore){const e=t.querySelectorAll(`[data-block-type="${n}"]`);for(const t of e)b(t,{breakBefore:"page",pageBreakBefore:"always"})}}(n,e),function(t,e){if(e.header){const n=document.createElement("div");n.className="notectl-print-header",n.innerHTML=j(e.header),t.insertBefore(n,t.firstChild)}if(e.footer){const n=document.createElement("div");n.className="notectl-print-footer",n.innerHTML=j(e.footer),t.appendChild(n)}}(n,e),n}(n,i),p=f.cloneNode(!0);!function(t){const e=x(t);if(0===e.size)return;const n=/* @__PURE__ */new Set;""!==t.id&&n.add(t.id);for(const r of t.querySelectorAll("[id]"))n.add(r.id);const o=/* @__PURE__ */new Map;for(const r of function(t){const e=[];return t.matches("[data-block-id][id]")&&""!==t.id&&e.push(t),e.push(...t.querySelectorAll("[data-block-id][id]")),e}(t)){const t=E("notectl-print-fallback-destination",n);o.set(r,t),r.id=t}for(const r of t.querySelectorAll("a[href]")){const t=M(e,r.getAttribute("href")??""),n=t?o.get(t):void 0;n&&r.setAttribute("href",`#${n}`)}}(p);const h=p.outerHTML,g=function(t){const e=x(t);if(0===e.size)return{markers:[]};const n=t.ownerDocument,o=/* @__PURE__ */new Set;""!==t.id&&o.add(t.id);for(const a of t.querySelectorAll("[id]"))o.add(a.id);const r=/* @__PURE__ */new Set;for(const a of t.querySelectorAll("slot[name]"))r.add(a.name);const s=/* @__PURE__ */new Map,i=[];for(const a of t.querySelectorAll("a[href]")){const t=a.getAttribute("href")??"";if(!t.startsWith("#"))continue;const c=M(e,t);if(!c)continue;let l=s.get(c);l||(l=R(c,n,o,r),s.set(c,l),i.push(l.marker)),a.setAttribute("href",`#${l.id}`)}return{markers:i}}(f),y=f.outerHTML,v=g.markers.map(t=>t.outerHTML).join(""),$=i.title??"",S=e.ownerDocument,w=e.closest("[lang]")?.getAttribute("lang")??(S.documentElement.lang||"en"),T={documentCSS:st(e,n,i,d),standaloneCSS:rt(e,n,i),hostSegments:u,shadowCSS:c,host:e,contentHTML:y,fallbackContentHTML:h,destinationMarkersHTML:v,title:$,lang:w,carryThemeContext:!1===i.forceLightTheme,variant:"export"},k=ft(T),C={html:k};return o.emit(l,C),{html:k,input:T}}return{print(t){const e=i(s(t));if(!e)return;const o=ft({...e.input,documentCSS:e.input.standaloneCSS,variant:"internal",styleNonce:y(n)}),a=document.createElement("iframe");g(a,"position:fixed;left:-9999px;width:0;height:0;border:none"),document.body.appendChild(a);const c=a.contentDocument,l=a.contentWindow;if(!c||!l)return void document.body.removeChild(a);c.open(),c.write(o),c.close();const u=()=>{a.remove()},d=()=>{l.addEventListener("afterprint",u,{once:!0}),l.print()};if("complete"===c.readyState)return void d();let f=!1;const p=()=>{f||(f=!0,r.delete(h),window.clearTimeout(m),d())},h=()=>{f=!0,window.clearTimeout(m),l.removeEventListener("load",p),a.remove()},m=window.setTimeout(p,4e3);r.add(h),l.addEventListener("load",p,{once:!0})},toHTML:t=>i(s(t))?.html??"",dispose(){for(const t of r)t();r.clear()}}}var ht={print(){},toHTML:()=>"",dispose(){}},mt=class{id="print";name="Print";config;service=null;locale;constructor(t){this.config=t??{}}async init(t){this.locale=await p(t,this.config.locale,$,w);const e=t.getContainer(),n=e.getRootNode();if(n instanceof ShadowRoot){const o=n.host,r=t.getEventBus();this.service=pt(n,o,e,r)}else this.service=ht;t.registerService(o,this.service);const r=this.config.defaults??{},s=this.service,i=this.locale;t.registerCommand("print",()=>(t.announce(i.printingAnnouncement),s.print(r),!0));const a=this.config.keyBinding??"Mod-P";if(t.registerKeymap({[a]:()=>(t.executeCommand("print"),!0)}),!1!==this.config.showToolbarItem){const e=v(a);t.registerToolbarItem({id:"print",group:"actions",label:this.locale.label,tooltip:this.locale.tooltip(e),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"/></svg>',command:"print"})}}destroy(){this.service?.dispose(),this.service=null}};export{$ as n,w as r,mt as t};
2
+ //# sourceMappingURL=PrintPlugin-CYkdUy-m.mjs.map