@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":"SchemaRegistry-Cs7rxafF.mjs","names":["formatDeclaration","parseDeclaration","RESERVED_PREFIX","CLASS_NAME_PATTERN","StyleClassRegistry","byClassName","Map","byDeclaration","size","this","register","styleClass","className","declaration","parsed","TypeError","JSON","stringify","normalized","test","startsWith","Object","freeze","validateStyleClass","sameClass","get","sameDeclaration","registrations","entry","set","remove","isSameDeclaration","delete","list","values","map","clear","SchemaRegistry","_nodeSpecs","_nodeSpecExtensions","_finalizedNodeSpecs","_markSpecs","_inlineNodeSpecs","_styleClasses","registerNodeSpec","spec","has","type","Error","invalidateFinalizedNodeSpecs","getNodeSpec","getFinalizedNodeSpecs","removeNodeSpec","getNodeTypes","keys","registerNodeSpecExtension","extension","extensions","push","removeNodeSpecExtension","index","indexOf","splice","length","finalize","finalized","baseSpec","resolved","registerMarkSpec","getMarkSpec","removeMarkSpec","getMarkTypes","registerInlineNodeSpec","getInlineNodeSpec","removeInlineNodeSpec","getInlineNodeTypes","registerStyleClass","removeStyleClass","getStyleClass","getStyleClasses","getBlockParseRules","collectParseRules","getInlineParseRules","getMarkParseRules","getAllowedTags","collectSanitizeValues","Set","sanitize","tags","getAllowedAttrs","base","readsClasses","add","attrs","getElementSanitizeValidators","validators","specMap","getAllFinalizedSpecMaps","tag","validator","entries","elementValidators","normalizedTag","toLowerCase","specs","results","parseHTML","rule","sort","a","b","priority","align","initial","extractor","allSpecs","value"],"sources":["../../src/model/StyleClassRegistry.ts","../../src/model/SchemaRegistry.ts"],"sourcesContent":["/**\n * The style classes of one editor and the rules they follow: one class per\n * declaration and one declaration per class, each a plain CSS class name\n * outside notectl's reserved prefix. Registering the same pair again (for\n * example from a second plugin) is counted, so every registrant can remove its\n * own registration without taking the class from the others.\n */\n\nimport {\n\ttype CSSDeclaration,\n\ttype StyleClass,\n\tformatDeclaration,\n\tparseDeclaration,\n} from './StyleClass.js';\n\n/** Reserved for the class names notectl generates itself (`notectl-align-*`, `notectl-s-*`). */\nconst RESERVED_PREFIX = 'notectl-';\n\n/** One CSS identifier that is valid in a `class` attribute and a selector without escaping. */\nconst CLASS_NAME_PATTERN: RegExp = /^-?[A-Za-z_][A-Za-z0-9_-]*$/;\n\ninterface StyleClassEntry {\n\treadonly styleClass: StyleClass;\n\tregistrations: number;\n}\n\nexport class StyleClassRegistry {\n\tprivate readonly byClassName = new Map<string, StyleClassEntry>();\n\tprivate readonly byDeclaration = new Map<string, StyleClassEntry>();\n\n\t/** Number of distinct registered style classes. */\n\tget size(): number {\n\t\treturn this.byClassName.size;\n\t}\n\n\t/**\n\t * Registers a style class. Throws a `TypeError` when it is invalid, when its\n\t * class already stands for another declaration, or when its declaration\n\t * already has another class.\n\t */\n\tregister(styleClass: StyleClass): void {\n\t\tconst { className, declaration }: StyleClass = validateStyleClass(styleClass);\n\t\tconst sameClass: StyleClassEntry | undefined = this.byClassName.get(className);\n\t\tif (sameClass && sameClass.styleClass.declaration !== declaration) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Class \"${className}\" already stands for \"${sameClass.styleClass.declaration}\"; give \"${declaration}\" its own class.`,\n\t\t\t);\n\t\t}\n\t\tconst sameDeclaration: StyleClassEntry | undefined = this.byDeclaration.get(declaration);\n\t\tif (sameDeclaration && sameDeclaration.styleClass.className !== className) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`\"${declaration}\" already has the class \"${sameDeclaration.styleClass.className}\"; a declaration can have only one class.`,\n\t\t\t);\n\t\t}\n\t\tif (sameClass) {\n\t\t\tsameClass.registrations++;\n\t\t\treturn;\n\t\t}\n\t\tconst entry: StyleClassEntry = {\n\t\t\tstyleClass: Object.freeze({ className, declaration }),\n\t\t\tregistrations: 1,\n\t\t};\n\t\tthis.byClassName.set(className, entry);\n\t\tthis.byDeclaration.set(declaration, entry);\n\t}\n\n\t/** Removes one registration of `styleClass`; others keep the class registered. */\n\tremove(styleClass: StyleClass): void {\n\t\tconst entry: StyleClassEntry | undefined = this.byClassName.get(styleClass.className);\n\t\tif (!entry || !this.isSameDeclaration(entry, styleClass)) return;\n\t\tentry.registrations--;\n\t\tif (entry.registrations > 0) return;\n\t\tthis.byClassName.delete(entry.styleClass.className);\n\t\tthis.byDeclaration.delete(entry.styleClass.declaration);\n\t}\n\n\t/** Returns the style class with this class name, or `undefined`. */\n\tget(className: string): StyleClass | undefined {\n\t\treturn this.byClassName.get(className)?.styleClass;\n\t}\n\n\t/** Returns all style classes in registration order. */\n\tlist(): readonly StyleClass[] {\n\t\treturn [...this.byClassName.values()].map((entry: StyleClassEntry) => entry.styleClass);\n\t}\n\n\tclear(): void {\n\t\tthis.byClassName.clear();\n\t\tthis.byDeclaration.clear();\n\t}\n\n\tprivate isSameDeclaration(entry: StyleClassEntry, styleClass: StyleClass): boolean {\n\t\tconst parsed: CSSDeclaration | undefined =\n\t\t\ttypeof styleClass.declaration === 'string'\n\t\t\t\t? parseDeclaration(styleClass.declaration)\n\t\t\t\t: undefined;\n\t\treturn parsed !== undefined && formatDeclaration(parsed) === entry.styleClass.declaration;\n\t}\n}\n\n/**\n * Validates a style class and returns a frozen copy with its declaration in\n * `property: value` form. Throws a `TypeError` that explains how to fix the\n * first problem it finds.\n */\nexport function validateStyleClass(styleClass: StyleClass): StyleClass {\n\tconst declaration: unknown = styleClass?.declaration;\n\tconst parsed: CSSDeclaration | undefined =\n\t\ttypeof declaration === 'string' ? parseDeclaration(declaration) : undefined;\n\tif (!parsed) {\n\t\tthrow new TypeError(\n\t\t\t`Invalid declaration ${JSON.stringify(declaration)}: use one CSS declaration such as \"color: #e03131\".`,\n\t\t);\n\t}\n\tconst normalized: string = formatDeclaration(parsed);\n\tconst className: unknown = styleClass.className;\n\tif (typeof className !== 'string' || !CLASS_NAME_PATTERN.test(className)) {\n\t\tthrow new TypeError(\n\t\t\t`Invalid class name ${JSON.stringify(className)} for \"${normalized}\": use one CSS class name of letters, digits, \"-\" and \"_\", not starting with a digit.`,\n\t\t);\n\t}\n\tif (className.startsWith(RESERVED_PREFIX)) {\n\t\tthrow new TypeError(\n\t\t\t`Class \"${className}\" for \"${normalized}\" uses the reserved prefix \"${RESERVED_PREFIX}\".`,\n\t\t);\n\t}\n\treturn Object.freeze({ className, declaration: normalized });\n}\n","/**\n * SchemaRegistry: central registry for node specs, mark specs,\n * and inline node specs registered by plugins.\n *\n * Model-only — no imports from input/, plugins/, or view/ layers.\n */\n\nimport type { InlineNodeSpec } from './InlineNodeSpec.js';\nimport type { MarkSpec } from './MarkSpec.js';\nimport type { NodeSpec } from './NodeSpec.js';\nimport type { ParseRule } from './ParseRule.js';\nimport type { ElementSanitizeValidator } from './SanitizeConfig.js';\nimport type { StyleClass } from './StyleClass.js';\nimport { StyleClassRegistry } from './StyleClassRegistry.js';\n\n/** Priority assigned to parse rules that do not declare an explicit `priority`. */\nconst DEFAULT_PARSE_PRIORITY = 50;\n\n/** Declarative transformation applied after a target NodeSpec is registered. */\nexport type NodeSpecExtension = (spec: NodeSpec) => NodeSpec;\n\nexport class SchemaRegistry {\n\tprivate readonly _nodeSpecs = new Map<string, NodeSpec>();\n\tprivate readonly _nodeSpecExtensions = new Map<string, NodeSpecExtension[]>();\n\tprivate _finalizedNodeSpecs: Map<string, NodeSpec> | null = null;\n\tprivate readonly _markSpecs = new Map<string, MarkSpec>();\n\tprivate readonly _inlineNodeSpecs = new Map<string, InlineNodeSpec>();\n\tprivate readonly _styleClasses = new StyleClassRegistry();\n\n\t// --- NodeSpec ---\n\n\tregisterNodeSpec<T extends string>(spec: NodeSpec<T>): void {\n\t\tif (this._nodeSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`NodeSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._nodeSpecs.set(spec.type, spec);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\tgetNodeSpec(type: string): NodeSpec | undefined {\n\t\treturn this.getFinalizedNodeSpecs().get(type);\n\t}\n\n\tremoveNodeSpec(type: string): void {\n\t\tif (this._nodeSpecs.delete(type)) this.invalidateFinalizedNodeSpecs();\n\t}\n\n\tgetNodeTypes(): string[] {\n\t\treturn [...this._nodeSpecs.keys()];\n\t}\n\n\t/**\n\t * Registers a composable NodeSpec extension independently of target order.\n\t * Extensions may be declared before their target plugin and are materialized\n\t * together by {@link finalize}. The function identity is also the cleanup key.\n\t */\n\tregisterNodeSpecExtension(type: string, extension: NodeSpecExtension): void {\n\t\tconst extensions = this._nodeSpecExtensions.get(type) ?? [];\n\t\textensions.push(extension);\n\t\tthis._nodeSpecExtensions.set(type, extensions);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\t/** Removes one previously registered NodeSpec extension by identity. */\n\tremoveNodeSpecExtension(type: string, extension: NodeSpecExtension): void {\n\t\tconst extensions = this._nodeSpecExtensions.get(type);\n\t\tif (!extensions) return;\n\t\tconst index = extensions.indexOf(extension);\n\t\tif (index === -1) return;\n\t\textensions.splice(index, 1);\n\t\tif (extensions.length === 0) this._nodeSpecExtensions.delete(type);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\t/**\n\t * Materializes the complete schema after all plugins have declared their base\n\t * specs and extensions. Calling it again after registrations change rebuilds\n\t * the snapshot; reads also finalize lazily for standalone registry consumers.\n\t */\n\tfinalize(): void {\n\t\tconst finalized = new Map<string, NodeSpec>();\n\t\tfor (const [type, baseSpec] of this._nodeSpecs) {\n\t\t\tlet resolved: NodeSpec = baseSpec;\n\t\t\tfor (const extension of this._nodeSpecExtensions.get(type) ?? []) {\n\t\t\t\tresolved = extension(resolved);\n\t\t\t\tif (resolved.type !== type) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`NodeSpec extension for \"${type}\" must preserve node type; received \"${resolved.type}\".`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinalized.set(type, resolved);\n\t\t}\n\t\tthis._finalizedNodeSpecs = finalized;\n\t}\n\n\t// --- MarkSpec ---\n\n\tregisterMarkSpec<T extends string>(spec: MarkSpec<T>): void {\n\t\tif (this._markSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`MarkSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._markSpecs.set(spec.type, spec);\n\t}\n\n\tgetMarkSpec(type: string): MarkSpec | undefined {\n\t\treturn this._markSpecs.get(type);\n\t}\n\n\tremoveMarkSpec(type: string): void {\n\t\tthis._markSpecs.delete(type);\n\t}\n\n\tgetMarkTypes(): string[] {\n\t\treturn [...this._markSpecs.keys()];\n\t}\n\n\t// --- InlineNodeSpec ---\n\n\tregisterInlineNodeSpec<T extends string>(spec: InlineNodeSpec<T>): void {\n\t\tif (this._inlineNodeSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`InlineNodeSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._inlineNodeSpecs.set(spec.type, spec);\n\t}\n\n\tgetInlineNodeSpec(type: string): InlineNodeSpec | undefined {\n\t\treturn this._inlineNodeSpecs.get(type);\n\t}\n\n\tremoveInlineNodeSpec(type: string): void {\n\t\tthis._inlineNodeSpecs.delete(type);\n\t}\n\n\tgetInlineNodeTypes(): string[] {\n\t\treturn [...this._inlineNodeSpecs.keys()];\n\t}\n\n\t// --- Style Classes ---\n\n\t/**\n\t * Registers an application CSS class for one CSS declaration (#269).\n\t * Class-based HTML export writes the class wherever it would write the\n\t * declaration, and HTML import and paste read the class back as the\n\t * declaration. Throws a `TypeError` when the class is invalid or contradicts a\n\t * registered one; registering the same pair again is counted.\n\t */\n\tregisterStyleClass(styleClass: StyleClass): void {\n\t\tthis._styleClasses.register(styleClass);\n\t}\n\n\t/** Removes one registration of `styleClass`; the class stays while others registered it too. */\n\tremoveStyleClass(styleClass: StyleClass): void {\n\t\tthis._styleClasses.remove(styleClass);\n\t}\n\n\t/** Returns the style class with this class name, or `undefined`. */\n\tgetStyleClass(className: string): StyleClass | undefined {\n\t\treturn this._styleClasses.get(className);\n\t}\n\n\t/** Returns all style classes in registration order. */\n\tgetStyleClasses(): readonly StyleClass[] {\n\t\treturn this._styleClasses.list();\n\t}\n\n\t// --- Parse Rules & Sanitize Config ---\n\n\t/** Returns all NodeSpec parseHTML rules, sorted by priority descending. */\n\tgetBlockParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this.getFinalizedNodeSpecs());\n\t}\n\n\t/** Returns all InlineNodeSpec parseHTML rules, sorted by priority descending. */\n\tgetInlineParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this._inlineNodeSpecs);\n\t}\n\n\t/** Returns all MarkSpec parseHTML rules, sorted by priority descending. */\n\tgetMarkParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this._markSpecs);\n\t}\n\n\t/** Returns all allowed HTML tags from base defaults + all spec sanitize configs. */\n\tgetAllowedTags(): string[] {\n\t\treturn [\n\t\t\t...this.collectSanitizeValues(\n\t\t\t\tnew Set(['p', 'br', 'div', 'span']),\n\t\t\t\t(spec) => spec.sanitize?.tags,\n\t\t\t),\n\t\t];\n\t}\n\n\t/**\n\t * Returns all allowed HTML attributes from base defaults + all spec sanitize configs.\n\t * `class` is allowed while content HTML can carry classes that import reads back.\n\t */\n\tgetAllowedAttrs(): string[] {\n\t\tconst base = new Set<string>(['style', 'dir', 'id']);\n\t\tif (this.readsClasses()) base.add('class');\n\t\treturn [...this.collectSanitizeValues(base, (spec) => spec.sanitize?.attrs)];\n\t}\n\n\t/** Returns registry-owned, per-tag element validators for one sanitize operation. */\n\tgetElementSanitizeValidators(): ReadonlyMap<string, readonly ElementSanitizeValidator[]> {\n\t\tconst validators = new Map<string, ElementSanitizeValidator[]>();\n\t\tfor (const specMap of this.getAllFinalizedSpecMaps()) {\n\t\t\tfor (const spec of specMap.values()) {\n\t\t\t\tfor (const [tag, validator] of Object.entries(spec.sanitize?.elementValidators ?? {})) {\n\t\t\t\t\tconst normalizedTag = tag.toLowerCase();\n\t\t\t\t\tconst entries = validators.get(normalizedTag) ?? [];\n\t\t\t\t\tentries.push(validator);\n\t\t\t\t\tvalidators.set(normalizedTag, entries);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn validators;\n\t}\n\n\tprivate collectParseRules(\n\t\tspecs: ReadonlyMap<string, { readonly parseHTML?: readonly ParseRule[] }>,\n\t): { readonly rule: ParseRule; readonly type: string }[] {\n\t\tconst results: { readonly rule: ParseRule; readonly type: string }[] = [];\n\t\tfor (const [type, spec] of specs) {\n\t\t\tif (spec.parseHTML) {\n\t\t\t\tfor (const rule of spec.parseHTML) {\n\t\t\t\t\tresults.push({ rule, type });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn results.sort(\n\t\t\t(a, b) =>\n\t\t\t\t(b.rule.priority ?? DEFAULT_PARSE_PRIORITY) - (a.rule.priority ?? DEFAULT_PARSE_PRIORITY),\n\t\t);\n\t}\n\n\t/**\n\t * Whether content HTML can carry classes that import reads back: registered\n\t * style classes, or the `notectl-align-*` classes class-based export writes\n\t * for every block type that declares `align` (#275).\n\t */\n\tprivate readsClasses(): boolean {\n\t\tif (this._styleClasses.size > 0) return true;\n\t\tfor (const spec of this.getFinalizedNodeSpecs().values()) {\n\t\t\tif (spec.attrs?.align) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate collectSanitizeValues(\n\t\tinitial: Set<string>,\n\t\textractor: (spec: {\n\t\t\treadonly sanitize?: { readonly tags?: readonly string[]; readonly attrs?: readonly string[] };\n\t\t}) => readonly string[] | undefined,\n\t): Set<string> {\n\t\tconst allSpecs: readonly ReadonlyMap<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\treadonly sanitize?: {\n\t\t\t\t\treadonly tags?: readonly string[];\n\t\t\t\t\treadonly attrs?: readonly string[];\n\t\t\t\t};\n\t\t\t}\n\t\t>[] = this.getAllFinalizedSpecMaps();\n\t\tfor (const specMap of allSpecs) {\n\t\t\tfor (const spec of specMap.values()) {\n\t\t\t\tconst values: readonly string[] | undefined = extractor(spec);\n\t\t\t\tif (values) {\n\t\t\t\t\tfor (const value of values) initial.add(value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn initial;\n\t}\n\n\tprivate getFinalizedNodeSpecs(): ReadonlyMap<string, NodeSpec> {\n\t\tif (!this._finalizedNodeSpecs) this.finalize();\n\t\treturn this._finalizedNodeSpecs ?? new Map();\n\t}\n\n\tprivate getAllFinalizedSpecMaps(): readonly ReadonlyMap<\n\t\tstring,\n\t\t{\n\t\t\treadonly sanitize?: {\n\t\t\t\treadonly tags?: readonly string[];\n\t\t\t\treadonly attrs?: readonly string[];\n\t\t\t\treadonly elementValidators?: Readonly<Record<string, ElementSanitizeValidator>>;\n\t\t\t};\n\t\t}\n\t>[] {\n\t\treturn [this.getFinalizedNodeSpecs(), this._inlineNodeSpecs, this._markSpecs];\n\t}\n\n\tprivate invalidateFinalizedNodeSpecs(): void {\n\t\tthis._finalizedNodeSpecs = null;\n\t}\n\n\t// --- Bulk ---\n\n\tclear(): void {\n\t\tthis._nodeSpecs.clear();\n\t\tthis._nodeSpecExtensions.clear();\n\t\tthis._finalizedNodeSpecs = null;\n\t\tthis._markSpecs.clear();\n\t\tthis._inlineNodeSpecs.clear();\n\t\tthis._styleClasses.clear();\n\t}\n}\n"],"mappings":"Y,8CAgBA,IAAME,EAAkB,WAGlBC,EAA6B,8BAOtBC,EAAb,MACCC,2BAA+B,IAAIC,IACnCC,6BAAiC,IAAID,IAGrC,QAAIE,GACH,OAAOC,KAAKJ,YAAYG,IACzB,CAOA,QAAAE,CAASC,GACR,MAAMC,UAAEA,EAAAC,YAAWA,GAgErB,SAAmCF,GAClC,MAAME,EAAuBF,GAAYE,YACnCC,EACkB,iBAAhBD,EAA2BZ,EAAiBY,QAAe,EACnE,IAAKC,EACJ,MAAM,IAAIC,UACT,uBAAuBC,KAAKC,UAAUJ,yDAGxC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,EAAG,OAAO,EACxC,IAAK,MAAMqC,KAAQpC,KAAK0C,wBAAwBjB,SAC/C,GAAIW,EAAKgD,OAAOmB,MAAO,OAAO,EAE/B,OAAO,CACR,CAEA,qBAAA3B,CACC4B,EACAC,GAIA,MAAMC,EAQA1G,KAAKwF,0BACX,IAAK,MAAMD,KAAWmB,EACrB,IAAK,MAAMtE,KAAQmD,EAAQ9D,SAAU,CACpC,MAAMA,EAAwCgF,EAAUrE,GACxD,GAAIX,EACH,IAAK,MAAMkF,KAASlF,EAAQ+E,EAAQrB,IAAIwB,EAE1C,CAED,OAAOH,CACR,CAEA,qBAAA9D,GAEC,OADK1C,KAAK+B,qBAAqB/B,KAAKuD,WAC7BvD,KAAK+B,oCAAuB,IAAIlC,GACxC,CAEA,uBAAA2F,GAUC,MAAO,CAACxF,KAAK0C,wBAAyB1C,KAAKiC,iBAAkBjC,KAAKgC,WACnE,CAEA,4BAAAQ,GACCxC,KAAK+B,oBAAsB,IAC5B,CAIA,KAAAJ,GACC3B,KAAK6B,WAAWF,QAChB3B,KAAK8B,oBAAoBH,QACzB3B,KAAK+B,oBAAsB,KAC3B/B,KAAKgC,WAAWL,QAChB3B,KAAKiC,iBAAiBN,QACtB3B,KAAKkC,cAAcP,OACpB,U"}
1
+ {"version":3,"file":"SchemaRegistry-CT3T7S1i.mjs","names":["formatDeclaration","parseDeclaration","RESERVED_PREFIX","CLASS_NAME_PATTERN","StyleClassRegistry","byClassName","Map","byDeclaration","size","this","register","styleClass","className","declaration","parsed","TypeError","JSON","stringify","normalized","test","startsWith","Object","freeze","validateStyleClass","sameClass","get","sameDeclaration","registrations","entry","set","remove","isSameDeclaration","delete","list","values","map","clear","SchemaRegistry","_nodeSpecs","_nodeSpecExtensions","_finalizedNodeSpecs","_markSpecs","_inlineNodeSpecs","_styleClasses","registerNodeSpec","spec","has","type","Error","invalidateFinalizedNodeSpecs","getNodeSpec","getFinalizedNodeSpecs","removeNodeSpec","getNodeTypes","keys","registerNodeSpecExtension","extension","extensions","push","removeNodeSpecExtension","index","indexOf","splice","length","finalize","finalized","baseSpec","resolved","registerMarkSpec","getMarkSpec","removeMarkSpec","getMarkTypes","registerInlineNodeSpec","getInlineNodeSpec","removeInlineNodeSpec","getInlineNodeTypes","registerStyleClass","removeStyleClass","getStyleClass","getStyleClasses","getBlockParseRules","collectParseRules","getInlineParseRules","getMarkParseRules","getAllowedTags","collectSanitizeValues","Set","sanitize","tags","getAllowedAttrs","base","readsClasses","add","attrs","getElementSanitizeValidators","validators","specMap","getAllFinalizedSpecMaps","tag","validator","entries","elementValidators","normalizedTag","toLowerCase","specs","results","parseHTML","rule","sort","a","b","priority","align","initial","extractor","allSpecs","value"],"sources":["../../src/model/StyleClassRegistry.ts","../../src/model/SchemaRegistry.ts"],"sourcesContent":["/**\n * The style classes of one editor and the rules they follow: one class per\n * declaration and one declaration per class, each a plain CSS class name\n * outside notectl's reserved prefix. Registering the same pair again (for\n * example from a second plugin) is counted, so every registrant can remove its\n * own registration without taking the class from the others.\n */\n\nimport {\n\ttype CSSDeclaration,\n\ttype StyleClass,\n\tformatDeclaration,\n\tparseDeclaration,\n} from './StyleClass.js';\n\n/** Reserved for the class names notectl generates itself (`notectl-align-*`, `notectl-s-*`). */\nconst RESERVED_PREFIX = 'notectl-';\n\n/** One CSS identifier that is valid in a `class` attribute and a selector without escaping. */\nconst CLASS_NAME_PATTERN: RegExp = /^-?[A-Za-z_][A-Za-z0-9_-]*$/;\n\ninterface StyleClassEntry {\n\treadonly styleClass: StyleClass;\n\tregistrations: number;\n}\n\nexport class StyleClassRegistry {\n\tprivate readonly byClassName = new Map<string, StyleClassEntry>();\n\tprivate readonly byDeclaration = new Map<string, StyleClassEntry>();\n\n\t/** Number of distinct registered style classes. */\n\tget size(): number {\n\t\treturn this.byClassName.size;\n\t}\n\n\t/**\n\t * Registers a style class. Throws a `TypeError` when it is invalid, when its\n\t * class already stands for another declaration, or when its declaration\n\t * already has another class.\n\t */\n\tregister(styleClass: StyleClass): void {\n\t\tconst { className, declaration }: StyleClass = validateStyleClass(styleClass);\n\t\tconst sameClass: StyleClassEntry | undefined = this.byClassName.get(className);\n\t\tif (sameClass && sameClass.styleClass.declaration !== declaration) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Class \"${className}\" already stands for \"${sameClass.styleClass.declaration}\"; give \"${declaration}\" its own class.`,\n\t\t\t);\n\t\t}\n\t\tconst sameDeclaration: StyleClassEntry | undefined = this.byDeclaration.get(declaration);\n\t\tif (sameDeclaration && sameDeclaration.styleClass.className !== className) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`\"${declaration}\" already has the class \"${sameDeclaration.styleClass.className}\"; a declaration can have only one class.`,\n\t\t\t);\n\t\t}\n\t\tif (sameClass) {\n\t\t\tsameClass.registrations++;\n\t\t\treturn;\n\t\t}\n\t\tconst entry: StyleClassEntry = {\n\t\t\tstyleClass: Object.freeze({ className, declaration }),\n\t\t\tregistrations: 1,\n\t\t};\n\t\tthis.byClassName.set(className, entry);\n\t\tthis.byDeclaration.set(declaration, entry);\n\t}\n\n\t/** Removes one registration of `styleClass`; others keep the class registered. */\n\tremove(styleClass: StyleClass): void {\n\t\tconst entry: StyleClassEntry | undefined = this.byClassName.get(styleClass.className);\n\t\tif (!entry || !this.isSameDeclaration(entry, styleClass)) return;\n\t\tentry.registrations--;\n\t\tif (entry.registrations > 0) return;\n\t\tthis.byClassName.delete(entry.styleClass.className);\n\t\tthis.byDeclaration.delete(entry.styleClass.declaration);\n\t}\n\n\t/** Returns the style class with this class name, or `undefined`. */\n\tget(className: string): StyleClass | undefined {\n\t\treturn this.byClassName.get(className)?.styleClass;\n\t}\n\n\t/** Returns all style classes in registration order. */\n\tlist(): readonly StyleClass[] {\n\t\treturn [...this.byClassName.values()].map((entry: StyleClassEntry) => entry.styleClass);\n\t}\n\n\tclear(): void {\n\t\tthis.byClassName.clear();\n\t\tthis.byDeclaration.clear();\n\t}\n\n\tprivate isSameDeclaration(entry: StyleClassEntry, styleClass: StyleClass): boolean {\n\t\tconst parsed: CSSDeclaration | undefined =\n\t\t\ttypeof styleClass.declaration === 'string'\n\t\t\t\t? parseDeclaration(styleClass.declaration)\n\t\t\t\t: undefined;\n\t\treturn parsed !== undefined && formatDeclaration(parsed) === entry.styleClass.declaration;\n\t}\n}\n\n/**\n * Validates a style class and returns a frozen copy with its declaration in\n * `property: value` form. Throws a `TypeError` that explains how to fix the\n * first problem it finds.\n */\nexport function validateStyleClass(styleClass: StyleClass): StyleClass {\n\tconst declaration: unknown = styleClass?.declaration;\n\tconst parsed: CSSDeclaration | undefined =\n\t\ttypeof declaration === 'string' ? parseDeclaration(declaration) : undefined;\n\tif (!parsed) {\n\t\tthrow new TypeError(\n\t\t\t`Invalid declaration ${JSON.stringify(declaration)}: use one CSS declaration such as \"color: #e03131\".`,\n\t\t);\n\t}\n\tconst normalized: string = formatDeclaration(parsed);\n\tconst className: unknown = styleClass.className;\n\tif (typeof className !== 'string' || !CLASS_NAME_PATTERN.test(className)) {\n\t\tthrow new TypeError(\n\t\t\t`Invalid class name ${JSON.stringify(className)} for \"${normalized}\": use one CSS class name of letters, digits, \"-\" and \"_\", not starting with a digit.`,\n\t\t);\n\t}\n\tif (className.startsWith(RESERVED_PREFIX)) {\n\t\tthrow new TypeError(\n\t\t\t`Class \"${className}\" for \"${normalized}\" uses the reserved prefix \"${RESERVED_PREFIX}\".`,\n\t\t);\n\t}\n\treturn Object.freeze({ className, declaration: normalized });\n}\n","/**\n * SchemaRegistry: central registry for node specs, mark specs,\n * and inline node specs registered by plugins.\n *\n * Model-only — no imports from input/, plugins/, or view/ layers.\n */\n\nimport type { InlineNodeSpec } from './InlineNodeSpec.js';\nimport type { MarkSpec } from './MarkSpec.js';\nimport type { NodeSpec } from './NodeSpec.js';\nimport type { ParseRule } from './ParseRule.js';\nimport type { ElementSanitizeValidator } from './SanitizeConfig.js';\nimport type { StyleClass } from './StyleClass.js';\nimport { StyleClassRegistry } from './StyleClassRegistry.js';\n\n/** Priority assigned to parse rules that do not declare an explicit `priority`. */\nconst DEFAULT_PARSE_PRIORITY = 50;\n\n/** Declarative transformation applied after a target NodeSpec is registered. */\nexport type NodeSpecExtension = (spec: NodeSpec) => NodeSpec;\n\nexport class SchemaRegistry {\n\tprivate readonly _nodeSpecs = new Map<string, NodeSpec>();\n\tprivate readonly _nodeSpecExtensions = new Map<string, NodeSpecExtension[]>();\n\tprivate _finalizedNodeSpecs: Map<string, NodeSpec> | null = null;\n\tprivate readonly _markSpecs = new Map<string, MarkSpec>();\n\tprivate readonly _inlineNodeSpecs = new Map<string, InlineNodeSpec>();\n\tprivate readonly _styleClasses = new StyleClassRegistry();\n\n\t// --- NodeSpec ---\n\n\tregisterNodeSpec<T extends string>(spec: NodeSpec<T>): void {\n\t\tif (this._nodeSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`NodeSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._nodeSpecs.set(spec.type, spec);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\tgetNodeSpec(type: string): NodeSpec | undefined {\n\t\treturn this.getFinalizedNodeSpecs().get(type);\n\t}\n\n\tremoveNodeSpec(type: string): void {\n\t\tif (this._nodeSpecs.delete(type)) this.invalidateFinalizedNodeSpecs();\n\t}\n\n\tgetNodeTypes(): string[] {\n\t\treturn [...this._nodeSpecs.keys()];\n\t}\n\n\t/**\n\t * Registers a composable NodeSpec extension independently of target order.\n\t * Extensions may be declared before their target plugin and are materialized\n\t * together by {@link finalize}. The function identity is also the cleanup key.\n\t */\n\tregisterNodeSpecExtension(type: string, extension: NodeSpecExtension): void {\n\t\tconst extensions = this._nodeSpecExtensions.get(type) ?? [];\n\t\textensions.push(extension);\n\t\tthis._nodeSpecExtensions.set(type, extensions);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\t/** Removes one previously registered NodeSpec extension by identity. */\n\tremoveNodeSpecExtension(type: string, extension: NodeSpecExtension): void {\n\t\tconst extensions = this._nodeSpecExtensions.get(type);\n\t\tif (!extensions) return;\n\t\tconst index = extensions.indexOf(extension);\n\t\tif (index === -1) return;\n\t\textensions.splice(index, 1);\n\t\tif (extensions.length === 0) this._nodeSpecExtensions.delete(type);\n\t\tthis.invalidateFinalizedNodeSpecs();\n\t}\n\n\t/**\n\t * Materializes the complete schema after all plugins have declared their base\n\t * specs and extensions. Calling it again after registrations change rebuilds\n\t * the snapshot; reads also finalize lazily for standalone registry consumers.\n\t */\n\tfinalize(): void {\n\t\tconst finalized = new Map<string, NodeSpec>();\n\t\tfor (const [type, baseSpec] of this._nodeSpecs) {\n\t\t\tlet resolved: NodeSpec = baseSpec;\n\t\t\tfor (const extension of this._nodeSpecExtensions.get(type) ?? []) {\n\t\t\t\tresolved = extension(resolved);\n\t\t\t\tif (resolved.type !== type) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`NodeSpec extension for \"${type}\" must preserve node type; received \"${resolved.type}\".`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinalized.set(type, resolved);\n\t\t}\n\t\tthis._finalizedNodeSpecs = finalized;\n\t}\n\n\t// --- MarkSpec ---\n\n\tregisterMarkSpec<T extends string>(spec: MarkSpec<T>): void {\n\t\tif (this._markSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`MarkSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._markSpecs.set(spec.type, spec);\n\t}\n\n\tgetMarkSpec(type: string): MarkSpec | undefined {\n\t\treturn this._markSpecs.get(type);\n\t}\n\n\tremoveMarkSpec(type: string): void {\n\t\tthis._markSpecs.delete(type);\n\t}\n\n\tgetMarkTypes(): string[] {\n\t\treturn [...this._markSpecs.keys()];\n\t}\n\n\t// --- InlineNodeSpec ---\n\n\tregisterInlineNodeSpec<T extends string>(spec: InlineNodeSpec<T>): void {\n\t\tif (this._inlineNodeSpecs.has(spec.type)) {\n\t\t\tthrow new Error(`InlineNodeSpec for type \"${spec.type}\" is already registered.`);\n\t\t}\n\t\tthis._inlineNodeSpecs.set(spec.type, spec);\n\t}\n\n\tgetInlineNodeSpec(type: string): InlineNodeSpec | undefined {\n\t\treturn this._inlineNodeSpecs.get(type);\n\t}\n\n\tremoveInlineNodeSpec(type: string): void {\n\t\tthis._inlineNodeSpecs.delete(type);\n\t}\n\n\tgetInlineNodeTypes(): string[] {\n\t\treturn [...this._inlineNodeSpecs.keys()];\n\t}\n\n\t// --- Style Classes ---\n\n\t/**\n\t * Registers an application CSS class for one CSS declaration (#269).\n\t * Class-based HTML export writes the class wherever it would write the\n\t * declaration, and HTML import and paste read the class back as the\n\t * declaration. Throws a `TypeError` when the class is invalid or contradicts a\n\t * registered one; registering the same pair again is counted.\n\t */\n\tregisterStyleClass(styleClass: StyleClass): void {\n\t\tthis._styleClasses.register(styleClass);\n\t}\n\n\t/** Removes one registration of `styleClass`; the class stays while others registered it too. */\n\tremoveStyleClass(styleClass: StyleClass): void {\n\t\tthis._styleClasses.remove(styleClass);\n\t}\n\n\t/** Returns the style class with this class name, or `undefined`. */\n\tgetStyleClass(className: string): StyleClass | undefined {\n\t\treturn this._styleClasses.get(className);\n\t}\n\n\t/** Returns all style classes in registration order. */\n\tgetStyleClasses(): readonly StyleClass[] {\n\t\treturn this._styleClasses.list();\n\t}\n\n\t// --- Parse Rules & Sanitize Config ---\n\n\t/** Returns all NodeSpec parseHTML rules, sorted by priority descending. */\n\tgetBlockParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this.getFinalizedNodeSpecs());\n\t}\n\n\t/** Returns all InlineNodeSpec parseHTML rules, sorted by priority descending. */\n\tgetInlineParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this._inlineNodeSpecs);\n\t}\n\n\t/** Returns all MarkSpec parseHTML rules, sorted by priority descending. */\n\tgetMarkParseRules(): readonly { readonly rule: ParseRule; readonly type: string }[] {\n\t\treturn this.collectParseRules(this._markSpecs);\n\t}\n\n\t/** Returns all allowed HTML tags from base defaults + all spec sanitize configs. */\n\tgetAllowedTags(): string[] {\n\t\treturn [\n\t\t\t...this.collectSanitizeValues(\n\t\t\t\tnew Set(['p', 'br', 'div', 'span']),\n\t\t\t\t(spec) => spec.sanitize?.tags,\n\t\t\t),\n\t\t];\n\t}\n\n\t/**\n\t * Returns all allowed HTML attributes from base defaults + all spec sanitize configs.\n\t * `class` is allowed while content HTML can carry classes that import reads back.\n\t */\n\tgetAllowedAttrs(): string[] {\n\t\tconst base = new Set<string>(['style', 'dir', 'id']);\n\t\tif (this.readsClasses()) base.add('class');\n\t\treturn [...this.collectSanitizeValues(base, (spec) => spec.sanitize?.attrs)];\n\t}\n\n\t/** Returns registry-owned, per-tag element validators for one sanitize operation. */\n\tgetElementSanitizeValidators(): ReadonlyMap<string, readonly ElementSanitizeValidator[]> {\n\t\tconst validators = new Map<string, ElementSanitizeValidator[]>();\n\t\tfor (const specMap of this.getAllFinalizedSpecMaps()) {\n\t\t\tfor (const spec of specMap.values()) {\n\t\t\t\tfor (const [tag, validator] of Object.entries(spec.sanitize?.elementValidators ?? {})) {\n\t\t\t\t\tconst normalizedTag = tag.toLowerCase();\n\t\t\t\t\tconst entries = validators.get(normalizedTag) ?? [];\n\t\t\t\t\tentries.push(validator);\n\t\t\t\t\tvalidators.set(normalizedTag, entries);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn validators;\n\t}\n\n\tprivate collectParseRules(\n\t\tspecs: ReadonlyMap<string, { readonly parseHTML?: readonly ParseRule[] }>,\n\t): { readonly rule: ParseRule; readonly type: string }[] {\n\t\tconst results: { readonly rule: ParseRule; readonly type: string }[] = [];\n\t\tfor (const [type, spec] of specs) {\n\t\t\tif (spec.parseHTML) {\n\t\t\t\tfor (const rule of spec.parseHTML) {\n\t\t\t\t\tresults.push({ rule, type });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn results.sort(\n\t\t\t(a, b) =>\n\t\t\t\t(b.rule.priority ?? DEFAULT_PARSE_PRIORITY) - (a.rule.priority ?? DEFAULT_PARSE_PRIORITY),\n\t\t);\n\t}\n\n\t/**\n\t * Whether content HTML can carry classes that import reads back: registered\n\t * style classes, or the `notectl-align-*` classes class-based export writes\n\t * for every block type that declares `align` (#275).\n\t */\n\tprivate readsClasses(): boolean {\n\t\tif (this._styleClasses.size > 0) return true;\n\t\tfor (const spec of this.getFinalizedNodeSpecs().values()) {\n\t\t\tif (spec.attrs?.align) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate collectSanitizeValues(\n\t\tinitial: Set<string>,\n\t\textractor: (spec: {\n\t\t\treadonly sanitize?: { readonly tags?: readonly string[]; readonly attrs?: readonly string[] };\n\t\t}) => readonly string[] | undefined,\n\t): Set<string> {\n\t\tconst allSpecs: readonly ReadonlyMap<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\treadonly sanitize?: {\n\t\t\t\t\treadonly tags?: readonly string[];\n\t\t\t\t\treadonly attrs?: readonly string[];\n\t\t\t\t};\n\t\t\t}\n\t\t>[] = this.getAllFinalizedSpecMaps();\n\t\tfor (const specMap of allSpecs) {\n\t\t\tfor (const spec of specMap.values()) {\n\t\t\t\tconst values: readonly string[] | undefined = extractor(spec);\n\t\t\t\tif (values) {\n\t\t\t\t\tfor (const value of values) initial.add(value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn initial;\n\t}\n\n\tprivate getFinalizedNodeSpecs(): ReadonlyMap<string, NodeSpec> {\n\t\tif (!this._finalizedNodeSpecs) this.finalize();\n\t\treturn this._finalizedNodeSpecs ?? new Map();\n\t}\n\n\tprivate getAllFinalizedSpecMaps(): readonly ReadonlyMap<\n\t\tstring,\n\t\t{\n\t\t\treadonly sanitize?: {\n\t\t\t\treadonly tags?: readonly string[];\n\t\t\t\treadonly attrs?: readonly string[];\n\t\t\t\treadonly elementValidators?: Readonly<Record<string, ElementSanitizeValidator>>;\n\t\t\t};\n\t\t}\n\t>[] {\n\t\treturn [this.getFinalizedNodeSpecs(), this._inlineNodeSpecs, this._markSpecs];\n\t}\n\n\tprivate invalidateFinalizedNodeSpecs(): void {\n\t\tthis._finalizedNodeSpecs = null;\n\t}\n\n\t// --- Bulk ---\n\n\tclear(): void {\n\t\tthis._nodeSpecs.clear();\n\t\tthis._nodeSpecExtensions.clear();\n\t\tthis._finalizedNodeSpecs = null;\n\t\tthis._markSpecs.clear();\n\t\tthis._inlineNodeSpecs.clear();\n\t\tthis._styleClasses.clear();\n\t}\n}\n"],"mappings":"Y,8CAgBA,IAAME,EAAkB,WAGlBC,EAA6B,8BAOtBC,EAAb,MACCC,2BAA+B,IAAIC,IACnCC,6BAAiC,IAAID,IAGrC,QAAIE,GACH,OAAOC,KAAKJ,YAAYG,IACzB,CAOA,QAAAE,CAASC,GACR,MAAMC,UAAEA,EAAAC,YAAWA,GAgErB,SAAmCF,GAClC,MAAME,EAAuBF,GAAYE,YACnCC,EACkB,iBAAhBD,EAA2BZ,EAAiBY,QAAe,EACnE,IAAKC,EACJ,MAAM,IAAIC,UACT,uBAAuBC,KAAKC,UAAUJ,yDAGxC,MAAMK,EAAqBlB,EAAkBc,GACvCF,EAAqBD,EAAWC,UACtC,GAAyB,iBAAdA,IAA2BT,EAAmBgB,KAAKP,GAC7D,MAAM,IAAIG,UACT,sBAAsBC,KAAKC,UAAUL,WAAmBM,0FAG1D,GAAIN,EAAUQ,WAAWlB,GACxB,MAAM,IAAIa,UACT,UAAUH,WAAmBM,gCAAyChB,OAGxE,OAAOmB,OAAOC,OAAO,CAAEV,YAAWC,YAAaK,GAChD,CAtFiDK,CAAmBZ,GAC5Da,EAAyCf,KAAKJ,YAAYoB,IAAIb,GACpE,GAAIY,GAAaA,EAAUb,WAAWE,cAAgBA,EACrD,MAAM,IAAIE,UACT,UAAUH,0BAAkCY,EAAUb,WAAWE,uBAAuBA,qBAG1F,MAAMa,EAA+CjB,KAAKF,cAAckB,IAAIZ,GAC5E,GAAIa,GAAmBA,EAAgBf,WAAWC,YAAcA,EAC/D,MAAM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4BAAAQ,GACCxC,KAAK+B,oBAAsB,IAC5B,CAIA,KAAAJ,GACC3B,KAAK6B,WAAWF,QAChB3B,KAAK8B,oBAAoBH,QACzB3B,KAAK+B,oBAAsB,KAC3B/B,KAAKgC,WAAWL,QAChB3B,KAAKiC,iBAAiBN,QACtB3B,KAAKkC,cAAcP,OACpB,U"}
@@ -1,2 +1,2 @@
1
- import{c as t,f as e}from"./Selection-DC6AOGgF.mjs";import{C as o,l as s}from"./BlockInsertion-CXfXqUZl.mjs";import{t as n}from"./Commands-Bk7Cl1nH.mjs";function c(c,f){const r=c.selection;if(!e(r))return{state:c,blockId:s(r),offset:0,placement:"beside"};if(t(r)){const{blockId:t,offset:e}=r.anchor;return{state:c,blockId:t,offset:e,placement:"inside"}}const a=n(c,f),i=o(r,c.getBlockOrder());return{state:c.apply(f.build()),blockId:a??i.blockId,offset:a?0:i.offset,placement:"inside"}}function f(t){if("beside"!==t.placement)return t.state.getBlock(t.blockId)}export{c as n,f as t};
2
- //# sourceMappingURL=SelectionReplacement-vC1xhFS0.mjs.map
1
+ import{c as t,f as e}from"./Selection-DC6AOGgF.mjs";import{C as o,l as s}from"./BlockInsertion-CXfXqUZl.mjs";import{t as n}from"./Commands-vqbwh6Ic.mjs";function c(c,f){const r=c.selection;if(!e(r))return{state:c,blockId:s(r),offset:0,placement:"beside"};if(t(r)){const{blockId:t,offset:e}=r.anchor;return{state:c,blockId:t,offset:e,placement:"inside"}}const a=n(c,f),i=o(r,c.getBlockOrder());return{state:c.apply(f.build()),blockId:a??i.blockId,offset:a?0:i.offset,placement:"inside"}}function f(t){if("beside"!==t.placement)return t.state.getBlock(t.blockId)}export{c as n,f as t};
2
+ //# sourceMappingURL=SelectionReplacement-Cj4FLlPz.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionReplacement-vC1xhFS0.mjs","names":["isCollapsed","isTextSelection","resolveInsertPoint","resolveAnchorBlockId","addDeleteSelectionSteps","resolveReplacementTarget","state","builder","selection","blockId","offset","placement","anchor","landingId","start","getBlockOrder","apply","build","getReceivingBlock","target","getBlock"],"sources":["../../src/commands/SelectionReplacement.ts"],"sourcesContent":["/**\n * Selection replacement for paste paths: deletes a range selection and resolves\n * where the replacing content goes in the document that results from the\n * deletion. Every paste strategy must resolve positions through this module,\n * never against the state before the deletion, and decide by the receiving\n * block, never by the selection anchor (#267).\n */\n\nimport type { BlockNode } from '../model/Document.js';\nimport type { EditorSelection } from '../model/Selection.js';\nimport { isCollapsed, isTextSelection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { resolveAnchorBlockId } from './BlockInsertion.js';\nimport type { InsertPoint } from './CommandHelpers.js';\nimport { resolveInsertPoint } from './CommandHelpers.js';\nimport { addDeleteSelectionSteps } from './Commands.js';\n\n/**\n * How replacing content relates to {@link ReplacementTarget.blockId}: `inside` goes\n * into the block at the target offset, `beside` goes next to a selected or\n * gap-adjacent block, which itself receives nothing.\n */\nexport type ReplacementPlacement = 'inside' | 'beside';\n\n/** Where replacing content goes once the current selection has been deleted. */\nexport interface ReplacementTarget {\n\t/** The document after the deletion. Resolve parents, siblings and indices here. */\n\treadonly state: EditorState;\n\t/** Receiving block (caret, range start or landing block), or the selected/adjacent block. */\n\treadonly blockId: BlockId;\n\t/** Text offset within {@link blockId}; 0 when the content goes beside it. */\n\treadonly offset: number;\n\treadonly placement: ReplacementPlacement;\n}\n\n/**\n * Deletes the selection through `builder` and resolves the replacement target.\n *\n * A text range is deleted and the target is its start in document order, so the\n * result does not depend on the selection direction: the anchor of a backward\n * range may be merged away by the deletion. When the deletion removes the start\n * block, the landing block it creates is the target. A collapsed caret, a node\n * selection and a gap cursor delete nothing and resolve against `state` itself;\n * the latter two place content beside their block.\n *\n * `builder` must be a fresh builder created from `state`, because the returned\n * state reflects every step it has recorded.\n */\nexport function resolveReplacementTarget(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n): ReplacementTarget {\n\tconst selection: EditorSelection = state.selection;\n\tif (!isTextSelection(selection)) {\n\t\treturn { state, blockId: resolveAnchorBlockId(selection), offset: 0, placement: 'beside' };\n\t}\n\tif (isCollapsed(selection)) {\n\t\tconst { blockId, offset } = selection.anchor;\n\t\treturn { state, blockId, offset, placement: 'inside' };\n\t}\n\n\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\tconst start: InsertPoint = resolveInsertPoint(selection, state.getBlockOrder());\n\treturn {\n\t\tstate: state.apply(builder.build()),\n\t\tblockId: landingId ?? start.blockId,\n\t\toffset: landingId ? 0 : start.offset,\n\t\tplacement: 'inside',\n\t};\n}\n\n/**\n * The block that receives the replacing content, looked up after the deletion, or\n * `undefined` when the content goes beside the target block. Decisions about how\n * to paste belong to this block, never to the selection anchor: the anchor of a\n * backward range sits in a different block or is merged away entirely.\n */\nexport function getReceivingBlock(target: ReplacementTarget): BlockNode | undefined {\n\tif (target.placement === 'beside') return undefined;\n\treturn target.state.getBlock(target.blockId);\n}\n"],"mappings":"Y,6IAkDA,SAAgBK,EACfC,EACAC,GAEA,MAAMC,EAA6BF,EAAME,UACzC,IAAKP,EAAgBO,GACpB,MAAO,CAAEF,QAAOG,QAASN,EAAqBK,GAAYE,OAAQ,EAAGC,UAAW,UAEjF,GAAIX,EAAYQ,GAAY,CAC3B,MAAMC,QAAEA,EAAAC,OAASA,GAAWF,EAAUI,OACtC,MAAO,CAAEN,QAAOG,UAASC,SAAQC,UAAW,SAC7C,CAEA,MAAME,EAAiCT,EAAwBE,EAAOC,GAChEO,EAAqBZ,EAAmBM,EAAWF,EAAMS,iBAC/D,MAAO,CACNT,MAAOA,EAAMU,MAAMT,EAAQU,SAC3BR,QAASI,GAAaC,EAAML,QAC5BC,OAAQG,EAAY,EAAIC,EAAMJ,OAC9BC,UAAW,SAEb,CAQA,SAAgBO,EAAkBC,GACjC,GAAyB,WAArBA,EAAOR,UACX,OAAOQ,EAAOb,MAAMc,SAASD,EAAOV,QACrC,Q"}
1
+ {"version":3,"file":"SelectionReplacement-Cj4FLlPz.mjs","names":["isCollapsed","isTextSelection","resolveInsertPoint","resolveAnchorBlockId","addDeleteSelectionSteps","resolveReplacementTarget","state","builder","selection","blockId","offset","placement","anchor","landingId","start","getBlockOrder","apply","build","getReceivingBlock","target","getBlock"],"sources":["../../src/commands/SelectionReplacement.ts"],"sourcesContent":["/**\n * Selection replacement for paste paths: deletes a range selection and resolves\n * where the replacing content goes in the document that results from the\n * deletion. Every paste strategy must resolve positions through this module,\n * never against the state before the deletion, and decide by the receiving\n * block, never by the selection anchor (#267).\n */\n\nimport type { BlockNode } from '../model/Document.js';\nimport type { EditorSelection } from '../model/Selection.js';\nimport { isCollapsed, isTextSelection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { resolveAnchorBlockId } from './BlockInsertion.js';\nimport type { InsertPoint } from './CommandHelpers.js';\nimport { resolveInsertPoint } from './CommandHelpers.js';\nimport { addDeleteSelectionSteps } from './Commands.js';\n\n/**\n * How replacing content relates to {@link ReplacementTarget.blockId}: `inside` goes\n * into the block at the target offset, `beside` goes next to a selected or\n * gap-adjacent block, which itself receives nothing.\n */\nexport type ReplacementPlacement = 'inside' | 'beside';\n\n/** Where replacing content goes once the current selection has been deleted. */\nexport interface ReplacementTarget {\n\t/** The document after the deletion. Resolve parents, siblings and indices here. */\n\treadonly state: EditorState;\n\t/** Receiving block (caret, range start or landing block), or the selected/adjacent block. */\n\treadonly blockId: BlockId;\n\t/** Text offset within {@link blockId}; 0 when the content goes beside it. */\n\treadonly offset: number;\n\treadonly placement: ReplacementPlacement;\n}\n\n/**\n * Deletes the selection through `builder` and resolves the replacement target.\n *\n * A text range is deleted and the target is its start in document order, so the\n * result does not depend on the selection direction: the anchor of a backward\n * range may be merged away by the deletion. When the deletion removes the start\n * block, the landing block it creates is the target. A collapsed caret, a node\n * selection and a gap cursor delete nothing and resolve against `state` itself;\n * the latter two place content beside their block.\n *\n * `builder` must be a fresh builder created from `state`, because the returned\n * state reflects every step it has recorded.\n */\nexport function resolveReplacementTarget(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n): ReplacementTarget {\n\tconst selection: EditorSelection = state.selection;\n\tif (!isTextSelection(selection)) {\n\t\treturn { state, blockId: resolveAnchorBlockId(selection), offset: 0, placement: 'beside' };\n\t}\n\tif (isCollapsed(selection)) {\n\t\tconst { blockId, offset } = selection.anchor;\n\t\treturn { state, blockId, offset, placement: 'inside' };\n\t}\n\n\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\tconst start: InsertPoint = resolveInsertPoint(selection, state.getBlockOrder());\n\treturn {\n\t\tstate: state.apply(builder.build()),\n\t\tblockId: landingId ?? start.blockId,\n\t\toffset: landingId ? 0 : start.offset,\n\t\tplacement: 'inside',\n\t};\n}\n\n/**\n * The block that receives the replacing content, looked up after the deletion, or\n * `undefined` when the content goes beside the target block. Decisions about how\n * to paste belong to this block, never to the selection anchor: the anchor of a\n * backward range sits in a different block or is merged away entirely.\n */\nexport function getReceivingBlock(target: ReplacementTarget): BlockNode | undefined {\n\tif (target.placement === 'beside') return undefined;\n\treturn target.state.getBlock(target.blockId);\n}\n"],"mappings":"Y,6IAkDA,SAAgBK,EACfC,EACAC,GAEA,MAAMC,EAA6BF,EAAME,UACzC,IAAKP,EAAgBO,GACpB,MAAO,CAAEF,QAAOG,QAASN,EAAqBK,GAAYE,OAAQ,EAAGC,UAAW,UAEjF,GAAIX,EAAYQ,GAAY,CAC3B,MAAMC,QAAEA,EAAAC,OAASA,GAAWF,EAAUI,OACtC,MAAO,CAAEN,QAAOG,UAASC,SAAQC,UAAW,SAC7C,CAEA,MAAME,EAAiCT,EAAwBE,EAAOC,GAChEO,EAAqBZ,EAAmBM,EAAWF,EAAMS,iBAC/D,MAAO,CACNT,MAAOA,EAAMU,MAAMT,EAAQU,SAC3BR,QAASI,GAAaC,EAAML,QAC5BC,OAAQG,EAAY,EAAIC,EAAMJ,OAC9BC,UAAW,SAEb,CAQA,SAAgBO,EAAkBC,GACjC,GAAyB,WAArBA,EAAOR,UACX,OAAOQ,EAAOb,MAAMc,SAASD,EAAOV,QACrC,Q"}
@@ -1,2 +1,2 @@
1
- import{a as t,d as e,o as n,u as o}from"./Selection-DC6AOGgF.mjs";import{t as r}from"./TypeBrands-Ch9856Gb.mjs";import{r as f,t as s}from"./DomUtils-Bf7JLFlx.mjs";var i="data-cursor-wrapper";function c(t){return t instanceof HTMLElement&&"false"===t.getAttribute("contenteditable")}function a(t){return t instanceof HTMLElement&&t.hasAttribute("data-widget")}function d(t){return t instanceof HTMLElement&&t.hasAttribute("data-cursor-wrapper")}function u(t){return t.querySelector("[data-content-dom]")??t}function l(t,e={}){const n=e.includeCursorWrapper??!1;return document.createTreeWalker(t,NodeFilter.SHOW_ALL,{acceptNode:e=>d(e)?n?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_REJECT:a(e)||function(t,e){let n=t.parentNode;for(;n&&n!==e;){if(c(n))return!0;n=n.parentNode}return!1}(e,t)||e instanceof HTMLElement&&e.hasAttribute("data-block-id")&&e!==t?NodeFilter.FILTER_REJECT:e.nodeType===Node.TEXT_NODE||c(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})}function N(){return window.getSelection()}function h(t,e){const n=t.getRootNode();if(!(n instanceof ShadowRoot))return null;if(!("getComposedRanges"in e))return null;let o;try{o=e.getComposedRanges({shadowRoots:[n]})}catch{try{o=e.getComposedRanges(n)}catch{return null}}const r=o[0];if(!r)return null;const f="direction"in e&&"backward"===e.direction;return{anchorNode:f?r.endContainer:r.startContainer,anchorOffset:f?r.endOffset:r.startOffset,focusNode:f?r.startContainer:r.endContainer,focusOffset:f?r.startOffset:r.endOffset}}function T(t,e){const n=h(t,e);if(n)return n;const o=e.anchorNode;if(!o)return null;const r=e.focusNode;return r?{anchorNode:o,anchorOffset:e.anchorOffset,focusNode:r,focusOffset:e.focusOffset}:null}function E(t,n){const r=N();if(!r)return;if(o(n))return void r.removeAllRanges();if(e(n)){const e=t.querySelector(`[data-block-id="${n.nodeId}"]`);if(!e)return;const o=e.parentNode;if(!o)return;const f=C(o,e);try{r.setBaseAndExtent(o,f,o,f+1)}catch{}return}const f=g(t,n.anchor),s=g(t,n.head);if(f&&s)try{r.setBaseAndExtent(f.node,f.offset,s.node,s.offset)}catch{}}function p(t){const e=N();if(!e||0===e.rangeCount)return null;const o=T(t,e);if(!o)return null;if(!t.contains(o.anchorNode)||!t.contains(o.focusNode))return null;const r=y(t,o.anchorNode,o.anchorOffset),f=y(t,o.focusNode,o.focusOffset);return r&&f?n(r,f):null}function m(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))return null;const o=y(t,e.startContainer,e.startOffset),r=y(t,e.endContainer,e.endOffset);return o&&r?n(o,r):null}function g(t,e){let n=null;if(e.path&&e.path.length>0){let o=t;for(const t of e.path){const e=o.querySelector(`:scope [data-block-id="${t}"]`);if(!e)break;o=e}o!==t&&o.getAttribute("data-block-id")===e.blockId&&(n=o)}if(n??=t.querySelector(`[data-block-id="${e.blockId}"]`),!n)return null;const o=u(n),r=function(t){let e=null;for(const n of Array.from(t.childNodes))if(!a(n)){if(e)return null;if("BR"!==n.nodeName)return null;e=n}return e}(o);if(r)return{node:o,offset:C(o,r)};let f=e.offset;const s=l(o);let i=s.nextNode();for(;i;){if(i.nodeType===Node.TEXT_NODE){const t=i.textContent?.length??0;if(f<=t)return{node:i,offset:f};f-=t}else if(c(i)){if(0===f){const t=i.parentNode;if(t)return{node:t,offset:C(t,i)}}f-=1}i=s.nextNode()}const d=o.lastChild;return d?d.nodeType===Node.TEXT_NODE?{node:d,offset:d.textContent?.length??0}:{node:o,offset:o.childNodes.length}:{node:o,offset:0}}function y(e,n,o){const i=f(e,n);if(!i)return null;const a=i.getAttribute("data-block-id");if(!a)return null;const d=r(a),N=s(e,i),h=u(i);if(n===i||n===h){const e=n===h?h:i;let r=0,f=0;for(const t of Array.from(e.childNodes)){if(f>=o)break;r+=O(t),f++}return t(d,r,N.length>1?N:void 0)}if(h!==i&&!h.contains(n))return t(d,0,N.length>1?N:void 0);let T=0;const E=l(h);let p=E.nextNode();for(;p;){if(p===n)return p.nodeType===Node.TEXT_NODE?t(d,T+o,N.length>1?N:void 0):t(d,T,N.length>1?N:void 0);p.nodeType===Node.TEXT_NODE?T+=p.textContent?.length??0:c(p)&&(T+=1),p=E.nextNode()}if(n.nodeType===Node.ELEMENT_NODE){const e=function(t,e){let n=0,o=0;for(const r of Array.from(t.childNodes)){if(o>=e)break;n+=O(r),o++}return n}(n,o),r=function(t,e){let n=0,o=e;for(;o&&o!==t;){const t=o.parentNode;if(!t)return null;for(const e of Array.from(t.childNodes)){if(e===o)break;n+=O(e)}o=t}return o===t?n:null}(h,n);return t(d,null===r?e:r+e,N.length>1?N:void 0)}return t(d,0,N.length>1?N:void 0)}function C(t,e){let n=0;for(const o of Array.from(t.childNodes)){if(o===e)return n;n++}return n}function O(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent?.length??0;if(a(t))return 0;if(c(t))return 1;let e=0;for(const n of Array.from(t.childNodes))e+=O(n);return e}export{T as a,i as c,u as d,h as i,l,m as n,p as o,N as r,E as s,y as t,d as u};
2
- //# sourceMappingURL=SelectionSync-BkjCwGp-.mjs.map
1
+ import{a as t,d as e,o as n,u as o}from"./Selection-DC6AOGgF.mjs";import{t as r}from"./TypeBrands-Ch9856Gb.mjs";import{r as f,t as s}from"./DomUtils-Bf7JLFlx.mjs";var i="data-cursor-wrapper";function c(t){return t instanceof HTMLElement&&"false"===t.getAttribute("contenteditable")}function a(t){return t instanceof HTMLElement&&t.hasAttribute("data-widget")}function d(t){return t instanceof HTMLElement&&t.hasAttribute("data-cursor-wrapper")}function u(t){return t.querySelector("[data-content-dom]")??t}function l(t,e={}){const n=e.includeCursorWrapper??!1;return document.createTreeWalker(t,NodeFilter.SHOW_ALL,{acceptNode:e=>d(e)?n?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_REJECT:a(e)||function(t,e){let n=t.parentNode;for(;n&&n!==e;){if(c(n))return!0;n=n.parentNode}return!1}(e,t)||e instanceof HTMLElement&&e.hasAttribute("data-block-id")&&e!==t?NodeFilter.FILTER_REJECT:e.nodeType===Node.TEXT_NODE||c(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})}function N(){return window.getSelection()}function h(t,e){const n=t.getRootNode();if(!(n instanceof ShadowRoot))return null;if(!("getComposedRanges"in e))return null;let o;try{o=e.getComposedRanges({shadowRoots:[n]})}catch{try{o=e.getComposedRanges(n)}catch{return null}}const r=o[0];if(!r)return null;const f="direction"in e&&"backward"===e.direction;return{anchorNode:f?r.endContainer:r.startContainer,anchorOffset:f?r.endOffset:r.startOffset,focusNode:f?r.startContainer:r.endContainer,focusOffset:f?r.startOffset:r.endOffset}}function T(t,e){const n=h(t,e);if(n)return n;const o=e.anchorNode;if(!o)return null;const r=e.focusNode;return r?{anchorNode:o,anchorOffset:e.anchorOffset,focusNode:r,focusOffset:e.focusOffset}:null}function p(t,n){const r=N();if(!r)return;if(o(n))return void r.removeAllRanges();if(e(n)){const e=t.querySelector(`[data-block-id="${n.nodeId}"]`);if(!e)return;const o=e.parentNode;if(!o)return;const f=C(o,e);try{r.setBaseAndExtent(o,f,o,f+1)}catch{}return}const f=g(t,n.anchor),s=g(t,n.head);if(f&&s)try{r.setBaseAndExtent(f.node,f.offset,s.node,s.offset)}catch{}}function E(t){const e=N();if(!e||0===e.rangeCount)return null;const o=T(t,e);if(!o)return null;if(!t.contains(o.anchorNode)||!t.contains(o.focusNode))return null;const r=y(t,o.anchorNode,o.anchorOffset),f=y(t,o.focusNode,o.focusOffset);return r&&f?n(r,f):null}function m(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))return null;const o=y(t,e.startContainer,e.startOffset),r=y(t,e.endContainer,e.endOffset);return o&&r?n(o,r):null}function g(t,e){let n=null;if(e.path&&e.path.length>0){let o=t;for(const t of e.path){const e=o.querySelector(`:scope [data-block-id="${t}"]`);if(!e)break;o=e}o!==t&&o.getAttribute("data-block-id")===e.blockId&&(n=o)}if(n??=t.querySelector(`[data-block-id="${e.blockId}"]`),!n)return null;const o=u(n),r=function(t){let e=null;for(const n of Array.from(t.childNodes))if(!a(n)){if(e)return null;if("BR"!==n.nodeName)return null;e=n}return e}(o);if(r)return{node:o,offset:C(o,r)};let f=e.offset;const s=l(o);let i=s.nextNode();for(;i;){if(i.nodeType===Node.TEXT_NODE){const t=i.textContent?.length??0;if(f<=t)return{node:i,offset:f};f-=t}else if(c(i)){if(0===f){const t=i.parentNode;if(t)return{node:t,offset:C(t,i)}}f-=1}i=s.nextNode()}const d=o.lastChild;return d?d.nodeType===Node.TEXT_NODE?{node:d,offset:d.textContent?.length??0}:{node:o,offset:o.childNodes.length}:{node:o,offset:0}}function y(e,n,o){const i=f(e,n);if(!i)return null;const a=i.getAttribute("data-block-id");if(!a)return null;const d=r(a),N=s(e,i),h=u(i);if(n===i||n===h){const e=n===h?h:i;let r=0,f=0;for(const t of Array.from(e.childNodes)){if(f>=o)break;r+=O(t),f++}return t(d,r,N.length>1?N:void 0)}if(h!==i&&!h.contains(n))return t(d,0,N.length>1?N:void 0);let T=0;const p=l(h);let E=p.nextNode();for(;E;){if(E===n)return E.nodeType===Node.TEXT_NODE?t(d,T+o,N.length>1?N:void 0):t(d,T,N.length>1?N:void 0);E.nodeType===Node.TEXT_NODE?T+=E.textContent?.length??0:c(E)&&(T+=1),E=p.nextNode()}if(n.nodeType===Node.ELEMENT_NODE){const e=function(t,e){let n=0,o=0;for(const r of Array.from(t.childNodes)){if(o>=e)break;n+=O(r),o++}return n}(n,o),r=function(t,e){let n=0,o=e;for(;o&&o!==t;){const t=o.parentNode;if(!t)return null;for(const e of Array.from(t.childNodes)){if(e===o)break;n+=O(e)}o=t}return o===t?n:null}(h,n);return t(d,null===r?e:r+e,N.length>1?N:void 0)}return t(d,0,N.length>1?N:void 0)}function C(t,e){let n=0;for(const o of Array.from(t.childNodes)){if(o===e)return n;n++}return n}function O(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent?.length??0;if(a(t))return 0;if(c(t))return 1;let e=0;for(const n of Array.from(t.childNodes))e+=O(n);return e}export{T as a,p as c,d,c as f,h as i,i as l,m as n,E as o,u as p,N as r,g as s,y as t,l as u};
2
+ //# sourceMappingURL=SelectionSync-8y0nbBHZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionSync-BkjCwGp-.mjs","names":["toBlockId","createPosition","isNodeSelection","createSelection","isGapCursor","blockId","findBlockAncestor","buildBlockPath","CURSOR_WRAPPER_ATTR","isInlineNodeEl","node","HTMLElement","getAttribute","isWidgetEl","hasAttribute","isCursorWrapperEl","resolveContentRoot","blockEl","querySelector","createInlineContentWalker","options","includeCursorWrapper","document","createTreeWalker","NodeFilter","SHOW_ALL","acceptNode","n","FILTER_SKIP","FILTER_REJECT","root","parent","parentNode","isInsideInlineElement","nodeType","Node","TEXT_NODE","FILTER_ACCEPT","getSelection","window","readComposedSelection","container","sel","getRootNode","ShadowRoot","ranges","getComposedRanges","shadowRoots","range","isBackward","direction","anchorNode","endContainer","startContainer","anchorOffset","endOffset","startOffset","focusNode","focusOffset","readDOMSelectionEndpoints","domSel","composed","syncSelectionToDOM","selection","removeAllRanges","nodeId","childIdx","childIndexOf","setBaseAndExtent","anchorPos","statePositionToDOM","anchor","headPos","head","offset","readSelectionFromDOM","rangeCount","endpoints","contains","domPositionToState","domRangeToState","pos","path","length","current","id","found","contentEl","placeholderBr","br","child","Array","from","childNodes","nodeName","findPlaceholderBr","remaining","walker","nextNode","len","textContent","lastChild","domOffset","rawBlockId","bid","targetEl","childOffset","inlineContentWidth","walkerNode","ELEMENT_NODE","childIndex","inlineOffsetForChildIndex","offsetBeforeNode","sibling","inlineOffsetBeforeNode","idx","c","width"],"sources":["../../src/view/InlineContentDOM.ts","../../src/view/SelectionSync.ts"],"sourcesContent":["/**\n * Classification of the DOM that renders a block's inline content.\n *\n * Shared by selection mapping and rendered-text reading so both agree on\n * which DOM nodes are document content: text nodes count their length, inline\n * node elements count one position, and view chrome counts nothing.\n */\n\n/** Attribute marking the temporary IME cursor wrapper (see `CursorWrapper`). */\nexport const CURSOR_WRAPPER_ATTR = 'data-cursor-wrapper';\n\n/** Zero-width space the cursor wrapper holds so the browser can compose into it. */\nexport const ZERO_WIDTH_SPACE = '​';\n\n/**\n * True when `node` is an InlineNode element — rendered `contenteditable=\"false\"`\n * and counted as width 1 in state offset space.\n */\nexport function isInlineNodeEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.getAttribute('contenteditable') === 'false';\n}\n\n/**\n * True when `node` is a view-chrome widget (`data-widget`), such as the checklist\n * checkbox marker. Widgets are rendered into the editable DOM for accessibility\n * but are not document content, so they count as zero width in offset space.\n */\nexport function isWidgetEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute('data-widget');\n}\n\n/** True when `node` is the temporary IME cursor wrapper element. */\nexport function isCursorWrapperEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute(CURSOR_WRAPPER_ATTR);\n}\n\n/**\n * Resolves the content root for inline content walking.\n * If the block element has a contentDOM (marked with data-content-dom),\n * returns it so the walker skips NodeView structural elements (headers, etc.).\n */\nexport function resolveContentRoot(blockEl: Element): Element {\n\tconst contentDOM: Element | null = blockEl.querySelector('[data-content-dom]');\n\treturn contentDOM ?? blockEl;\n}\n\nexport interface InlineContentWalkerOptions {\n\t/**\n\t * Descend into the IME cursor wrapper instead of skipping it. Selection\n\t * mapping skips it because its zero-width space is not content; reading\n\t * composed text needs it because the browser composes inside it.\n\t */\n\treadonly includeCursorWrapper?: boolean;\n}\n\n/**\n * Creates a TreeWalker that visits text nodes and contentEditable=\"false\"\n * inline elements within a block, skipping mark wrappers and nested blocks.\n */\nexport function createInlineContentWalker(\n\tblockEl: Element,\n\toptions: InlineContentWalkerOptions = {},\n): TreeWalker {\n\tconst includeCursorWrapper: boolean = options.includeCursorWrapper ?? false;\n\treturn document.createTreeWalker(blockEl, NodeFilter.SHOW_ALL, {\n\t\tacceptNode: (n: Node) => {\n\t\t\t// The cursor wrapper holds a ZWS for stored marks during IME composition\n\t\t\tif (isCursorWrapperEl(n)) {\n\t\t\t\treturn includeCursorWrapper ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Skip view-chrome widgets (e.g. the checklist checkbox marker). They are\n\t\t\t// contentEditable=\"false\" but not document content, so they carry zero\n\t\t\t// width in offset space and must never become a caret position.\n\t\t\tif (isWidgetEl(n)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip anything inside an inline element (contentEditable=\"false\")\n\t\t\tif (isInsideInlineElement(n, blockEl)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip nested block elements and their descendants\n\t\t\tif (n instanceof HTMLElement && n.hasAttribute('data-block-id') && n !== blockEl) {\n\t\t\t\treturn NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Accept text nodes\n\t\t\tif (n.nodeType === Node.TEXT_NODE) return NodeFilter.FILTER_ACCEPT;\n\t\t\t// Accept inline elements (contentEditable=\"false\")\n\t\t\tif (isInlineNodeEl(n)) {\n\t\t\t\treturn NodeFilter.FILTER_ACCEPT;\n\t\t\t}\n\t\t\t// Skip other elements (mark wrappers, decoration wrappers) — descend\n\t\t\treturn NodeFilter.FILTER_SKIP;\n\t\t},\n\t});\n}\n\n/** Checks if a node is inside a contentEditable=\"false\" inline element. */\nfunction isInsideInlineElement(node: Node, root: Element): boolean {\n\tlet parent: Node | null = node.parentNode;\n\twhile (parent && parent !== root) {\n\t\tif (isInlineNodeEl(parent)) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = parent.parentNode;\n\t}\n\treturn false;\n}\n","/**\n * Selection synchronization between editor state and DOM.\n */\n\nimport type { EditorSelection, Position, Selection } from '../model/Selection.js';\nimport {\n\tcreatePosition,\n\tcreateSelection,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../model/Selection.js';\nimport { blockId as toBlockId } from '../model/TypeBrands.js';\nimport { buildBlockPath, findBlockAncestor } from './DomUtils.js';\nimport {\n\tcreateInlineContentWalker,\n\tisInlineNodeEl,\n\tisWidgetEl,\n\tresolveContentRoot,\n} from './InlineContentDOM.js';\n\ninterface DOMPosition {\n\tnode: Node;\n\toffset: number;\n}\n\n/**\n * Returns the lone `<br>` placeholder of an empty block, ignoring view-chrome\n * widgets. Returns null when the block holds real inline content.\n */\nfunction findPlaceholderBr(contentEl: Element): Node | null {\n\tlet br: Node | null = null;\n\tfor (const child of Array.from(contentEl.childNodes)) {\n\t\tif (isWidgetEl(child)) continue;\n\t\tif (br) return null;\n\t\tif (child.nodeName === 'BR') {\n\t\t\tbr = child;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn br;\n}\n\n/** Gets the selection object for writing (collapse, setBaseAndExtent). */\nexport function getSelection(): globalThis.Selection | null {\n\treturn window.getSelection();\n}\n\n/**\n * Endpoints returned by reading selection via getComposedRanges().\n * Used to correctly read selection inside Shadow DOM on Safari 17+,\n * Chrome 137+, and Firefox 142+.\n */\nexport interface SelectionEndpoints {\n\tanchorNode: Node;\n\tanchorOffset: number;\n\tfocusNode: Node;\n\tfocusOffset: number;\n}\n\n/**\n * Reads the selection endpoints using getComposedRanges() when inside a\n * Shadow DOM. Returns null if not in a shadow root or the API is unavailable.\n *\n * Handles two call signatures:\n * - Modern (Chrome 137+, Firefox 142+): sel.getComposedRanges({ shadowRoots: [root] })\n * - Legacy (Safari 17+): sel.getComposedRanges(root)\n *\n * StaticRange always uses document order. When `Selection.direction` is\n * `\"backward\"`, anchor/focus are swapped to reconstruct the correct\n * directional endpoints. When direction is `\"none\"` or absent the\n * forward (document-order) mapping is used.\n *\n * Note: Safari 17–18 supports getComposedRanges but not\n * Selection.direction — backward selections will be read as forward.\n */\nexport function readComposedSelection(\n\tcontainer: HTMLElement,\n\tsel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst root = container.getRootNode();\n\tif (!(root instanceof ShadowRoot)) return null;\n\tif (!('getComposedRanges' in sel)) return null;\n\n\tlet ranges: StaticRange[];\n\ttry {\n\t\t// Modern syntax (Chrome 137+, Firefox 142+)\n\t\tranges = (\n\t\t\tsel as unknown as {\n\t\t\t\tgetComposedRanges(opts: { shadowRoots: ShadowRoot[] }): StaticRange[];\n\t\t\t}\n\t\t).getComposedRanges({ shadowRoots: [root] });\n\t} catch {\n\t\ttry {\n\t\t\t// Legacy syntax (Safari 17+)\n\t\t\tranges = (\n\t\t\t\tsel as unknown as {\n\t\t\t\t\tgetComposedRanges(...roots: ShadowRoot[]): StaticRange[];\n\t\t\t\t}\n\t\t\t).getComposedRanges(root);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst range = ranges[0];\n\tif (!range) return null;\n\n\tconst isBackward: boolean =\n\t\t'direction' in sel && (sel as unknown as { direction: string }).direction === 'backward';\n\n\treturn {\n\t\tanchorNode: isBackward ? range.endContainer : range.startContainer,\n\t\tanchorOffset: isBackward ? range.endOffset : range.startOffset,\n\t\tfocusNode: isBackward ? range.startContainer : range.endContainer,\n\t\tfocusOffset: isBackward ? range.startOffset : range.endOffset,\n\t};\n}\n\n/**\n * Reads the DOM selection endpoints, preferring `getComposedRanges()` when\n * the container is inside a Shadow DOM.\n *\n * Returns `null` when `anchorNode` is unavailable (no selection).\n *\n * In Shadow DOM mode the endpoints come from a `StaticRange` which uses\n * document order. `Selection.direction` is used to reconstruct anchor/focus\n * for backward selections.\n */\nexport function readDOMSelectionEndpoints(\n\tcontainer: HTMLElement,\n\tdomSel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst composed: SelectionEndpoints | null = readComposedSelection(container, domSel);\n\tif (composed) return composed;\n\n\tconst anchorNode: Node | null = domSel.anchorNode;\n\tif (!anchorNode) return null;\n\tconst focusNode: Node | null = domSel.focusNode;\n\tif (!focusNode) return null;\n\n\treturn {\n\t\tanchorNode,\n\t\tanchorOffset: domSel.anchorOffset,\n\t\tfocusNode,\n\t\tfocusOffset: domSel.focusOffset,\n\t};\n}\n\n/** Syncs the editor state selection to the DOM. */\nexport function syncSelectionToDOM(container: HTMLElement, selection: EditorSelection): void {\n\tconst domSel = getSelection();\n\tif (!domSel) return;\n\n\t// GapCursor: clear browser selection (gap cursor has no DOM equivalent)\n\tif (isGapCursor(selection)) {\n\t\tdomSel.removeAllRanges();\n\t\treturn;\n\t}\n\n\t// NodeSelection: select the entire block element\n\tif (isNodeSelection(selection)) {\n\t\tconst blockEl = container.querySelector(`[data-block-id=\"${selection.nodeId}\"]`);\n\t\tif (!blockEl) return;\n\t\tconst parent = blockEl.parentNode;\n\t\tif (!parent) return;\n\t\tconst childIdx = childIndexOf(parent, blockEl);\n\t\ttry {\n\t\t\tdomSel.setBaseAndExtent(parent, childIdx, parent, childIdx + 1);\n\t\t} catch {\n\t\t\t// Selection may fail if DOM is not yet rendered\n\t\t}\n\t\treturn;\n\t}\n\n\tconst anchorPos = statePositionToDOM(container, selection.anchor);\n\tconst headPos = statePositionToDOM(container, selection.head);\n\n\tif (!anchorPos || !headPos) return;\n\n\ttry {\n\t\tdomSel.setBaseAndExtent(anchorPos.node, anchorPos.offset, headPos.node, headPos.offset);\n\t} catch {\n\t\t// Selection may fail if DOM is not yet rendered\n\t}\n}\n\n/** Reads the current DOM selection and converts it to a state selection. */\nexport function readSelectionFromDOM(container: HTMLElement): Selection | null {\n\tconst domSel = getSelection();\n\tif (!domSel || domSel.rangeCount === 0) return null;\n\n\tconst endpoints: SelectionEndpoints | null = readDOMSelectionEndpoints(container, domSel);\n\tif (!endpoints) return null;\n\n\tif (!container.contains(endpoints.anchorNode) || !container.contains(endpoints.focusNode)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, endpoints.anchorNode, endpoints.anchorOffset);\n\tconst head = domPositionToState(container, endpoints.focusNode, endpoints.focusOffset);\n\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/**\n * Converts a DOM range (e.g. a `StaticRange` from `InputEvent.getTargetRanges()`)\n * to a state selection. Returns `null` when either endpoint lies outside the\n * container or cannot be mapped to a block position.\n */\nexport function domRangeToState(container: HTMLElement, range: AbstractRange): Selection | null {\n\tif (!container.contains(range.startContainer) || !container.contains(range.endContainer)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, range.startContainer, range.startOffset);\n\tconst head = domPositionToState(container, range.endContainer, range.endOffset);\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/** Converts a state position (blockId + offset) to a DOM position (node + offset). */\nfunction statePositionToDOM(container: HTMLElement, pos: Position): DOMPosition | null {\n\t// If path is available, navigate directly to the leaf block\n\tlet blockEl: Element | null = null;\n\tif (pos.path && pos.path.length > 0) {\n\t\tlet current: Element = container;\n\t\tfor (const id of pos.path) {\n\t\t\tconst found = current.querySelector(`:scope [data-block-id=\"${id}\"]`);\n\t\t\tif (!found) break;\n\t\t\tcurrent = found;\n\t\t}\n\t\tif (current !== container && current.getAttribute('data-block-id') === pos.blockId) {\n\t\t\tblockEl = current;\n\t\t}\n\t}\n\tblockEl ??= container.querySelector(`[data-block-id=\"${pos.blockId}\"]`);\n\tif (!blockEl) return null;\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle empty blocks rendered as a single <br> placeholder. View-chrome\n\t// widgets (e.g. the checklist marker) are ignored, so the caret lands after\n\t// the widget and before the <br> rather than at the very start of the block.\n\tconst placeholderBr = findPlaceholderBr(contentEl);\n\tif (placeholderBr) {\n\t\treturn { node: contentEl, offset: childIndexOf(contentEl, placeholderBr) };\n\t}\n\n\t// Walk through text nodes and inline elements to find the correct position\n\tlet remaining = pos.offset;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet current = walker.nextNode();\n\twhile (current) {\n\t\tif (current.nodeType === Node.TEXT_NODE) {\n\t\t\tconst len = current.textContent?.length ?? 0;\n\t\t\tif (remaining <= len) {\n\t\t\t\treturn { node: current, offset: remaining };\n\t\t\t}\n\t\t\tremaining -= len;\n\t\t} else if (isInlineNodeEl(current)) {\n\t\t\t// InlineNode element — width 1 in state offset space\n\t\t\tif (remaining === 0) {\n\t\t\t\t// Position before this inline element\n\t\t\t\tconst parent = current.parentNode;\n\t\t\t\tif (parent) {\n\t\t\t\t\tconst childIndex = childIndexOf(parent, current);\n\t\t\t\t\treturn { node: parent, offset: childIndex };\n\t\t\t\t}\n\t\t\t}\n\t\t\tremaining -= 1;\n\t\t}\n\t\tcurrent = walker.nextNode();\n\t}\n\n\t// Fallback: position at end of block\n\tconst lastChild = contentEl.lastChild;\n\tif (lastChild) {\n\t\tif (lastChild.nodeType === Node.TEXT_NODE) {\n\t\t\treturn { node: lastChild, offset: lastChild.textContent?.length ?? 0 };\n\t\t}\n\t\treturn { node: contentEl, offset: contentEl.childNodes.length };\n\t}\n\n\treturn { node: contentEl, offset: 0 };\n}\n\n/** Converts a DOM position to a state position, including nested path. */\nexport function domPositionToState(\n\tcontainer: HTMLElement,\n\tnode: Node,\n\tdomOffset: number,\n): Position | null {\n\t// Find the innermost block element\n\tconst blockEl = findBlockAncestor(container, node);\n\tif (!blockEl) return null;\n\n\tconst rawBlockId = blockEl.getAttribute('data-block-id');\n\tif (!rawBlockId) return null;\n\tconst bid = toBlockId(rawBlockId);\n\n\t// Build path by collecting all data-block-id ancestors from leaf to root\n\tconst path = buildBlockPath(container, blockEl);\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle clicks on the block or content element itself (e.g. empty paragraph with <br>)\n\tif (node === blockEl || node === contentEl) {\n\t\tconst targetEl: Element = node === contentEl ? contentEl : blockEl;\n\t\tlet childOffset = 0;\n\t\tlet childIdx = 0;\n\t\tfor (const child of Array.from(targetEl.childNodes)) {\n\t\t\tif (childIdx >= domOffset) break;\n\t\t\tchildOffset += inlineContentWidth(child);\n\t\t\tchildIdx++;\n\t\t}\n\t\treturn createPosition(bid, childOffset, path.length > 1 ? path : undefined);\n\t}\n\n\t// If node is outside the contentDOM (e.g. in NodeView header), map to offset 0\n\tif (contentEl !== blockEl && !contentEl.contains(node)) {\n\t\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n\t}\n\n\t// Calculate offset by walking text nodes and inline elements\n\tlet offset = 0;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet walkerNode = walker.nextNode();\n\twhile (walkerNode) {\n\t\tif (walkerNode === node) {\n\t\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\t\treturn createPosition(bid, offset + domOffset, path.length > 1 ? path : undefined);\n\t\t\t}\n\t\t\t// Node is an inline element — return offset at its start\n\t\t\treturn createPosition(bid, offset, path.length > 1 ? path : undefined);\n\t\t}\n\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\toffset += walkerNode.textContent?.length ?? 0;\n\t\t} else if (isInlineNodeEl(walkerNode)) {\n\t\t\toffset += 1;\n\t\t}\n\t\twalkerNode = walker.nextNode();\n\t}\n\n\t// If the node is not a text node, try to find the offset from element context\n\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\tconst childOffset = inlineOffsetForChildIndex(node, domOffset);\n\t\tconst offsetBeforeNode = inlineOffsetBeforeNode(contentEl, node);\n\t\tconst totalOffset = offsetBeforeNode === null ? childOffset : offsetBeforeNode + childOffset;\n\t\treturn createPosition(bid, totalOffset, path.length > 1 ? path : undefined);\n\t}\n\n\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n}\n\n/** Counts inline width for the first `childIndex` children of an element. */\nfunction inlineOffsetForChildIndex(node: Node, childIndex: number): number {\n\tlet childOffset = 0;\n\tlet childIdx = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\tif (childIdx >= childIndex) break;\n\t\tchildOffset += inlineContentWidth(child);\n\t\tchildIdx++;\n\t}\n\treturn childOffset;\n}\n\n/** Returns the inline offset from `root` to the start of `node`, or null when unrelated. */\nfunction inlineOffsetBeforeNode(root: Element, node: Node): number | null {\n\tlet offset = 0;\n\tlet current: Node | null = node;\n\n\twhile (current && current !== root) {\n\t\tconst parent: Node | null = current.parentNode;\n\t\tif (!parent) return null;\n\n\t\tfor (const sibling of Array.from(parent.childNodes) as Node[]) {\n\t\t\tif (sibling === current) break;\n\t\t\toffset += inlineContentWidth(sibling);\n\t\t}\n\n\t\tcurrent = parent;\n\t}\n\n\treturn current === root ? offset : null;\n}\n\n/** Returns the child index of a node within its parent. */\nfunction childIndexOf(parent: Node, child: Node): number {\n\tlet idx = 0;\n\tfor (const c of Array.from(parent.childNodes)) {\n\t\tif (c === child) return idx;\n\t\tidx++;\n\t}\n\treturn idx;\n}\n\n/** Counts the inline content width of a DOM node (text length + 1 per inline element). */\nfunction inlineContentWidth(node: Node): number {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\treturn node.textContent?.length ?? 0;\n\t}\n\t// View-chrome widgets (e.g. the checklist marker) are not document content.\n\tif (isWidgetEl(node)) {\n\t\treturn 0;\n\t}\n\tif (isInlineNodeEl(node)) {\n\t\treturn 1;\n\t}\n\t// Mark wrapper or other element — sum children\n\tlet width = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\twidth += inlineContentWidth(child);\n\t}\n\treturn width;\n}\n"],"mappings":"Y,uJASA,IAAaQ,EAAsB,sBASnC,SAAgBC,EAAeC,GAC9B,OAAOA,aAAgBC,aAAwD,UAAzCD,EAAKE,aAAa,kBACzD,CAOA,SAAgBC,EAAWH,GAC1B,OAAOA,aAAgBC,aAAeD,EAAKI,aAAa,cACzD,CAGA,SAAgBC,EAAkBL,GACjC,OAAOA,aAAgBC,aAAeD,EAAKI,aAAA,sBAC5C,CAOA,SAAgBE,EAAmBC,GAElC,OADmCA,EAAQC,cAAc,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EAAK,EAAGtB,EAAKC,OAAS,EAAID,OAAO,EACxD,CAmCA,SAASf,EAAapC,EAAc2D,GACnC,IAAIyB,EAAM,EACV,IAAK,MAAMC,KAAKzB,MAAMC,KAAK7D,EAAO8D,YAAa,CAC9C,GAAIuB,IAAM1B,EAAO,OAAOyB,EACxBA,GACD,CACA,OAAOA,CACR,CAGA,SAASR,EAAmBjG,GAC3B,GAAIA,EAAKwB,WAAaC,KAAKC,UAC1B,OAAO1B,EAAK0F,aAAajB,QAAU,EAGpC,GAAItE,EAAWH,GACd,OAAO,EAER,GAAID,EAAeC,GAClB,OAAO,EAGR,IAAI2G,EAAQ,EACZ,IAAK,MAAM3B,KAASC,MAAMC,KAAKlF,EAAKmF,YACnCwB,GAASV,EAAmBjB,GAE7B,OAAO2B,CACR,Q"}
1
+ {"version":3,"file":"SelectionSync-8y0nbBHZ.mjs","names":["toBlockId","createPosition","isNodeSelection","createSelection","isGapCursor","blockId","findBlockAncestor","buildBlockPath","CURSOR_WRAPPER_ATTR","isInlineNodeEl","node","HTMLElement","getAttribute","isWidgetEl","hasAttribute","isCursorWrapperEl","resolveContentRoot","blockEl","querySelector","createInlineContentWalker","options","includeCursorWrapper","document","createTreeWalker","NodeFilter","SHOW_ALL","acceptNode","n","FILTER_SKIP","FILTER_REJECT","root","parent","parentNode","isInsideInlineElement","nodeType","Node","TEXT_NODE","FILTER_ACCEPT","getSelection","window","readComposedSelection","container","sel","getRootNode","ShadowRoot","ranges","getComposedRanges","shadowRoots","range","isBackward","direction","anchorNode","endContainer","startContainer","anchorOffset","endOffset","startOffset","focusNode","focusOffset","readDOMSelectionEndpoints","domSel","composed","syncSelectionToDOM","selection","removeAllRanges","nodeId","childIdx","childIndexOf","setBaseAndExtent","anchorPos","statePositionToDOM","anchor","headPos","head","offset","readSelectionFromDOM","rangeCount","endpoints","contains","domPositionToState","domRangeToState","pos","path","length","current","id","found","contentEl","placeholderBr","br","child","Array","from","childNodes","nodeName","findPlaceholderBr","remaining","walker","nextNode","len","textContent","lastChild","domOffset","rawBlockId","bid","targetEl","childOffset","inlineContentWidth","walkerNode","ELEMENT_NODE","childIndex","inlineOffsetForChildIndex","offsetBeforeNode","sibling","inlineOffsetBeforeNode","idx","c","width"],"sources":["../../src/view/InlineContentDOM.ts","../../src/view/SelectionSync.ts"],"sourcesContent":["/**\n * Classification of the DOM that renders a block's inline content.\n *\n * Shared by selection mapping and rendered-text reading so both agree on\n * which DOM nodes are document content: text nodes count their length, inline\n * node elements count one position, and view chrome counts nothing.\n */\n\n/** Attribute marking the temporary IME cursor wrapper (see `CursorWrapper`). */\nexport const CURSOR_WRAPPER_ATTR = 'data-cursor-wrapper';\n\n/** Zero-width space the cursor wrapper holds so the browser can compose into it. */\nexport const ZERO_WIDTH_SPACE = '​';\n\n/**\n * True when `node` is an InlineNode element — rendered `contenteditable=\"false\"`\n * and counted as width 1 in state offset space.\n */\nexport function isInlineNodeEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.getAttribute('contenteditable') === 'false';\n}\n\n/**\n * True when `node` is a view-chrome widget (`data-widget`), such as the checklist\n * checkbox marker. Widgets are rendered into the editable DOM for accessibility\n * but are not document content, so they count as zero width in offset space.\n */\nexport function isWidgetEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute('data-widget');\n}\n\n/** True when `node` is the temporary IME cursor wrapper element. */\nexport function isCursorWrapperEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute(CURSOR_WRAPPER_ATTR);\n}\n\n/**\n * Resolves the content root for inline content walking.\n * If the block element has a contentDOM (marked with data-content-dom),\n * returns it so the walker skips NodeView structural elements (headers, etc.).\n */\nexport function resolveContentRoot(blockEl: Element): Element {\n\tconst contentDOM: Element | null = blockEl.querySelector('[data-content-dom]');\n\treturn contentDOM ?? blockEl;\n}\n\nexport interface InlineContentWalkerOptions {\n\t/**\n\t * Descend into the IME cursor wrapper instead of skipping it. Selection\n\t * mapping skips it because its zero-width space is not content; reading\n\t * composed text needs it because the browser composes inside it.\n\t */\n\treadonly includeCursorWrapper?: boolean;\n}\n\n/**\n * Creates a TreeWalker that visits text nodes and contentEditable=\"false\"\n * inline elements within a block, skipping mark wrappers and nested blocks.\n */\nexport function createInlineContentWalker(\n\tblockEl: Element,\n\toptions: InlineContentWalkerOptions = {},\n): TreeWalker {\n\tconst includeCursorWrapper: boolean = options.includeCursorWrapper ?? false;\n\treturn document.createTreeWalker(blockEl, NodeFilter.SHOW_ALL, {\n\t\tacceptNode: (n: Node) => {\n\t\t\t// The cursor wrapper holds a ZWS for stored marks during IME composition\n\t\t\tif (isCursorWrapperEl(n)) {\n\t\t\t\treturn includeCursorWrapper ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Skip view-chrome widgets (e.g. the checklist checkbox marker). They are\n\t\t\t// contentEditable=\"false\" but not document content, so they carry zero\n\t\t\t// width in offset space and must never become a caret position.\n\t\t\tif (isWidgetEl(n)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip anything inside an inline element (contentEditable=\"false\")\n\t\t\tif (isInsideInlineElement(n, blockEl)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip nested block elements and their descendants\n\t\t\tif (n instanceof HTMLElement && n.hasAttribute('data-block-id') && n !== blockEl) {\n\t\t\t\treturn NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Accept text nodes\n\t\t\tif (n.nodeType === Node.TEXT_NODE) return NodeFilter.FILTER_ACCEPT;\n\t\t\t// Accept inline elements (contentEditable=\"false\")\n\t\t\tif (isInlineNodeEl(n)) {\n\t\t\t\treturn NodeFilter.FILTER_ACCEPT;\n\t\t\t}\n\t\t\t// Skip other elements (mark wrappers, decoration wrappers) — descend\n\t\t\treturn NodeFilter.FILTER_SKIP;\n\t\t},\n\t});\n}\n\n/** Checks if a node is inside a contentEditable=\"false\" inline element. */\nfunction isInsideInlineElement(node: Node, root: Element): boolean {\n\tlet parent: Node | null = node.parentNode;\n\twhile (parent && parent !== root) {\n\t\tif (isInlineNodeEl(parent)) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = parent.parentNode;\n\t}\n\treturn false;\n}\n","/**\n * Selection synchronization between editor state and DOM.\n */\n\nimport type { EditorSelection, Position, Selection } from '../model/Selection.js';\nimport {\n\tcreatePosition,\n\tcreateSelection,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../model/Selection.js';\nimport { blockId as toBlockId } from '../model/TypeBrands.js';\nimport { buildBlockPath, findBlockAncestor } from './DomUtils.js';\nimport {\n\tcreateInlineContentWalker,\n\tisInlineNodeEl,\n\tisWidgetEl,\n\tresolveContentRoot,\n} from './InlineContentDOM.js';\n\ninterface DOMPosition {\n\tnode: Node;\n\toffset: number;\n}\n\n/**\n * Returns the lone `<br>` placeholder of an empty block, ignoring view-chrome\n * widgets. Returns null when the block holds real inline content.\n */\nfunction findPlaceholderBr(contentEl: Element): Node | null {\n\tlet br: Node | null = null;\n\tfor (const child of Array.from(contentEl.childNodes)) {\n\t\tif (isWidgetEl(child)) continue;\n\t\tif (br) return null;\n\t\tif (child.nodeName === 'BR') {\n\t\t\tbr = child;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn br;\n}\n\n/** Gets the selection object for writing (collapse, setBaseAndExtent). */\nexport function getSelection(): globalThis.Selection | null {\n\treturn window.getSelection();\n}\n\n/**\n * Endpoints returned by reading selection via getComposedRanges().\n * Used to correctly read selection inside Shadow DOM on Safari 17+,\n * Chrome 137+, and Firefox 142+.\n */\nexport interface SelectionEndpoints {\n\tanchorNode: Node;\n\tanchorOffset: number;\n\tfocusNode: Node;\n\tfocusOffset: number;\n}\n\n/**\n * Reads the selection endpoints using getComposedRanges() when inside a\n * Shadow DOM. Returns null if not in a shadow root or the API is unavailable.\n *\n * Handles two call signatures:\n * - Modern (Chrome 137+, Firefox 142+): sel.getComposedRanges({ shadowRoots: [root] })\n * - Legacy (Safari 17+): sel.getComposedRanges(root)\n *\n * StaticRange always uses document order. When `Selection.direction` is\n * `\"backward\"`, anchor/focus are swapped to reconstruct the correct\n * directional endpoints. When direction is `\"none\"` or absent the\n * forward (document-order) mapping is used.\n *\n * Note: Safari 17–18 supports getComposedRanges but not\n * Selection.direction — backward selections will be read as forward.\n */\nexport function readComposedSelection(\n\tcontainer: HTMLElement,\n\tsel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst root = container.getRootNode();\n\tif (!(root instanceof ShadowRoot)) return null;\n\tif (!('getComposedRanges' in sel)) return null;\n\n\tlet ranges: StaticRange[];\n\ttry {\n\t\t// Modern syntax (Chrome 137+, Firefox 142+)\n\t\tranges = (\n\t\t\tsel as unknown as {\n\t\t\t\tgetComposedRanges(opts: { shadowRoots: ShadowRoot[] }): StaticRange[];\n\t\t\t}\n\t\t).getComposedRanges({ shadowRoots: [root] });\n\t} catch {\n\t\ttry {\n\t\t\t// Legacy syntax (Safari 17+)\n\t\t\tranges = (\n\t\t\t\tsel as unknown as {\n\t\t\t\t\tgetComposedRanges(...roots: ShadowRoot[]): StaticRange[];\n\t\t\t\t}\n\t\t\t).getComposedRanges(root);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst range = ranges[0];\n\tif (!range) return null;\n\n\tconst isBackward: boolean =\n\t\t'direction' in sel && (sel as unknown as { direction: string }).direction === 'backward';\n\n\treturn {\n\t\tanchorNode: isBackward ? range.endContainer : range.startContainer,\n\t\tanchorOffset: isBackward ? range.endOffset : range.startOffset,\n\t\tfocusNode: isBackward ? range.startContainer : range.endContainer,\n\t\tfocusOffset: isBackward ? range.startOffset : range.endOffset,\n\t};\n}\n\n/**\n * Reads the DOM selection endpoints, preferring `getComposedRanges()` when\n * the container is inside a Shadow DOM.\n *\n * Returns `null` when `anchorNode` is unavailable (no selection).\n *\n * In Shadow DOM mode the endpoints come from a `StaticRange` which uses\n * document order. `Selection.direction` is used to reconstruct anchor/focus\n * for backward selections.\n */\nexport function readDOMSelectionEndpoints(\n\tcontainer: HTMLElement,\n\tdomSel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst composed: SelectionEndpoints | null = readComposedSelection(container, domSel);\n\tif (composed) return composed;\n\n\tconst anchorNode: Node | null = domSel.anchorNode;\n\tif (!anchorNode) return null;\n\tconst focusNode: Node | null = domSel.focusNode;\n\tif (!focusNode) return null;\n\n\treturn {\n\t\tanchorNode,\n\t\tanchorOffset: domSel.anchorOffset,\n\t\tfocusNode,\n\t\tfocusOffset: domSel.focusOffset,\n\t};\n}\n\n/** Syncs the editor state selection to the DOM. */\nexport function syncSelectionToDOM(container: HTMLElement, selection: EditorSelection): void {\n\tconst domSel = getSelection();\n\tif (!domSel) return;\n\n\t// GapCursor: clear browser selection (gap cursor has no DOM equivalent)\n\tif (isGapCursor(selection)) {\n\t\tdomSel.removeAllRanges();\n\t\treturn;\n\t}\n\n\t// NodeSelection: select the entire block element\n\tif (isNodeSelection(selection)) {\n\t\tconst blockEl = container.querySelector(`[data-block-id=\"${selection.nodeId}\"]`);\n\t\tif (!blockEl) return;\n\t\tconst parent = blockEl.parentNode;\n\t\tif (!parent) return;\n\t\tconst childIdx = childIndexOf(parent, blockEl);\n\t\ttry {\n\t\t\tdomSel.setBaseAndExtent(parent, childIdx, parent, childIdx + 1);\n\t\t} catch {\n\t\t\t// Selection may fail if DOM is not yet rendered\n\t\t}\n\t\treturn;\n\t}\n\n\tconst anchorPos = statePositionToDOM(container, selection.anchor);\n\tconst headPos = statePositionToDOM(container, selection.head);\n\n\tif (!anchorPos || !headPos) return;\n\n\ttry {\n\t\tdomSel.setBaseAndExtent(anchorPos.node, anchorPos.offset, headPos.node, headPos.offset);\n\t} catch {\n\t\t// Selection may fail if DOM is not yet rendered\n\t}\n}\n\n/** Reads the current DOM selection and converts it to a state selection. */\nexport function readSelectionFromDOM(container: HTMLElement): Selection | null {\n\tconst domSel = getSelection();\n\tif (!domSel || domSel.rangeCount === 0) return null;\n\n\tconst endpoints: SelectionEndpoints | null = readDOMSelectionEndpoints(container, domSel);\n\tif (!endpoints) return null;\n\n\tif (!container.contains(endpoints.anchorNode) || !container.contains(endpoints.focusNode)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, endpoints.anchorNode, endpoints.anchorOffset);\n\tconst head = domPositionToState(container, endpoints.focusNode, endpoints.focusOffset);\n\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/**\n * Converts a DOM range (e.g. a `StaticRange` from `InputEvent.getTargetRanges()`)\n * to a state selection. Returns `null` when either endpoint lies outside the\n * container or cannot be mapped to a block position.\n */\nexport function domRangeToState(container: HTMLElement, range: AbstractRange): Selection | null {\n\tif (!container.contains(range.startContainer) || !container.contains(range.endContainer)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, range.startContainer, range.startOffset);\n\tconst head = domPositionToState(container, range.endContainer, range.endOffset);\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/** Converts a state position (blockId + offset) to a DOM position (node + offset). */\nexport function statePositionToDOM(container: HTMLElement, pos: Position): DOMPosition | null {\n\t// If path is available, navigate directly to the leaf block\n\tlet blockEl: Element | null = null;\n\tif (pos.path && pos.path.length > 0) {\n\t\tlet current: Element = container;\n\t\tfor (const id of pos.path) {\n\t\t\tconst found = current.querySelector(`:scope [data-block-id=\"${id}\"]`);\n\t\t\tif (!found) break;\n\t\t\tcurrent = found;\n\t\t}\n\t\tif (current !== container && current.getAttribute('data-block-id') === pos.blockId) {\n\t\t\tblockEl = current;\n\t\t}\n\t}\n\tblockEl ??= container.querySelector(`[data-block-id=\"${pos.blockId}\"]`);\n\tif (!blockEl) return null;\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle empty blocks rendered as a single <br> placeholder. View-chrome\n\t// widgets (e.g. the checklist marker) are ignored, so the caret lands after\n\t// the widget and before the <br> rather than at the very start of the block.\n\tconst placeholderBr = findPlaceholderBr(contentEl);\n\tif (placeholderBr) {\n\t\treturn { node: contentEl, offset: childIndexOf(contentEl, placeholderBr) };\n\t}\n\n\t// Walk through text nodes and inline elements to find the correct position\n\tlet remaining = pos.offset;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet current = walker.nextNode();\n\twhile (current) {\n\t\tif (current.nodeType === Node.TEXT_NODE) {\n\t\t\tconst len = current.textContent?.length ?? 0;\n\t\t\tif (remaining <= len) {\n\t\t\t\treturn { node: current, offset: remaining };\n\t\t\t}\n\t\t\tremaining -= len;\n\t\t} else if (isInlineNodeEl(current)) {\n\t\t\t// InlineNode element — width 1 in state offset space\n\t\t\tif (remaining === 0) {\n\t\t\t\t// Position before this inline element\n\t\t\t\tconst parent = current.parentNode;\n\t\t\t\tif (parent) {\n\t\t\t\t\tconst childIndex = childIndexOf(parent, current);\n\t\t\t\t\treturn { node: parent, offset: childIndex };\n\t\t\t\t}\n\t\t\t}\n\t\t\tremaining -= 1;\n\t\t}\n\t\tcurrent = walker.nextNode();\n\t}\n\n\t// Fallback: position at end of block\n\tconst lastChild = contentEl.lastChild;\n\tif (lastChild) {\n\t\tif (lastChild.nodeType === Node.TEXT_NODE) {\n\t\t\treturn { node: lastChild, offset: lastChild.textContent?.length ?? 0 };\n\t\t}\n\t\treturn { node: contentEl, offset: contentEl.childNodes.length };\n\t}\n\n\treturn { node: contentEl, offset: 0 };\n}\n\n/** Converts a DOM position to a state position, including nested path. */\nexport function domPositionToState(\n\tcontainer: HTMLElement,\n\tnode: Node,\n\tdomOffset: number,\n): Position | null {\n\t// Find the innermost block element\n\tconst blockEl = findBlockAncestor(container, node);\n\tif (!blockEl) return null;\n\n\tconst rawBlockId = blockEl.getAttribute('data-block-id');\n\tif (!rawBlockId) return null;\n\tconst bid = toBlockId(rawBlockId);\n\n\t// Build path by collecting all data-block-id ancestors from leaf to root\n\tconst path = buildBlockPath(container, blockEl);\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle clicks on the block or content element itself (e.g. empty paragraph with <br>)\n\tif (node === blockEl || node === contentEl) {\n\t\tconst targetEl: Element = node === contentEl ? contentEl : blockEl;\n\t\tlet childOffset = 0;\n\t\tlet childIdx = 0;\n\t\tfor (const child of Array.from(targetEl.childNodes)) {\n\t\t\tif (childIdx >= domOffset) break;\n\t\t\tchildOffset += inlineContentWidth(child);\n\t\t\tchildIdx++;\n\t\t}\n\t\treturn createPosition(bid, childOffset, path.length > 1 ? path : undefined);\n\t}\n\n\t// If node is outside the contentDOM (e.g. in NodeView header), map to offset 0\n\tif (contentEl !== blockEl && !contentEl.contains(node)) {\n\t\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n\t}\n\n\t// Calculate offset by walking text nodes and inline elements\n\tlet offset = 0;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet walkerNode = walker.nextNode();\n\twhile (walkerNode) {\n\t\tif (walkerNode === node) {\n\t\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\t\treturn createPosition(bid, offset + domOffset, path.length > 1 ? path : undefined);\n\t\t\t}\n\t\t\t// Node is an inline element — return offset at its start\n\t\t\treturn createPosition(bid, offset, path.length > 1 ? path : undefined);\n\t\t}\n\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\toffset += walkerNode.textContent?.length ?? 0;\n\t\t} else if (isInlineNodeEl(walkerNode)) {\n\t\t\toffset += 1;\n\t\t}\n\t\twalkerNode = walker.nextNode();\n\t}\n\n\t// If the node is not a text node, try to find the offset from element context\n\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\tconst childOffset = inlineOffsetForChildIndex(node, domOffset);\n\t\tconst offsetBeforeNode = inlineOffsetBeforeNode(contentEl, node);\n\t\tconst totalOffset = offsetBeforeNode === null ? childOffset : offsetBeforeNode + childOffset;\n\t\treturn createPosition(bid, totalOffset, path.length > 1 ? path : undefined);\n\t}\n\n\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n}\n\n/** Counts inline width for the first `childIndex` children of an element. */\nfunction inlineOffsetForChildIndex(node: Node, childIndex: number): number {\n\tlet childOffset = 0;\n\tlet childIdx = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\tif (childIdx >= childIndex) break;\n\t\tchildOffset += inlineContentWidth(child);\n\t\tchildIdx++;\n\t}\n\treturn childOffset;\n}\n\n/** Returns the inline offset from `root` to the start of `node`, or null when unrelated. */\nfunction inlineOffsetBeforeNode(root: Element, node: Node): number | null {\n\tlet offset = 0;\n\tlet current: Node | null = node;\n\n\twhile (current && current !== root) {\n\t\tconst parent: Node | null = current.parentNode;\n\t\tif (!parent) return null;\n\n\t\tfor (const sibling of Array.from(parent.childNodes) as Node[]) {\n\t\t\tif (sibling === current) break;\n\t\t\toffset += inlineContentWidth(sibling);\n\t\t}\n\n\t\tcurrent = parent;\n\t}\n\n\treturn current === root ? offset : null;\n}\n\n/** Returns the child index of a node within its parent. */\nfunction childIndexOf(parent: Node, child: Node): number {\n\tlet idx = 0;\n\tfor (const c of Array.from(parent.childNodes)) {\n\t\tif (c === child) return idx;\n\t\tidx++;\n\t}\n\treturn idx;\n}\n\n/** Counts the inline content width of a DOM node (text length + 1 per inline element). */\nfunction inlineContentWidth(node: Node): number {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\treturn node.textContent?.length ?? 0;\n\t}\n\t// View-chrome widgets (e.g. the checklist marker) are not document content.\n\tif (isWidgetEl(node)) {\n\t\treturn 0;\n\t}\n\tif (isInlineNodeEl(node)) {\n\t\treturn 1;\n\t}\n\t// Mark wrapper or other element — sum children\n\tlet width = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\twidth += inlineContentWidth(child);\n\t}\n\treturn width;\n}\n"],"mappings":"Y,uJASA,IAAaQ,EAAsB,sBASnC,SAAgBC,EAAeC,GAC9B,OAAOA,aAAgBC,aAAwD,UAAzCD,EAAKE,aAAa,kBACzD,CAOA,SAA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OqD,IAAYtD,EAAO4C,EAAS,IACpC,CAtC2BwC,CAAuB3B,EAAW7E,GAE3D,OAAOT,EAAeuG,EADmB,OAArBQ,EAA4BN,EAAcM,EAAmBN,EACzCxB,EAAKC,OAAS,EAAID,OAAO,EAClE,CAEA,OAAOjF,EAAeuG,EAAK,EAAGtB,EAAKC,OAAS,EAAID,OAAO,EACxD,CAmCA,SAASf,EAAapC,EAAc2D,GACnC,IAAIyB,EAAM,EACV,IAAK,MAAMC,KAAKzB,MAAMC,KAAK7D,EAAO8D,YAAa,CAC9C,GAAIuB,IAAM1B,EAAO,OAAOyB,EACxBA,GACD,CACA,OAAOA,CACR,CAGA,SAASR,EAAmBjG,GAC3B,GAAIA,EAAKwB,WAAaC,KAAKC,UAC1B,OAAO1B,EAAK0F,aAAajB,QAAU,EAGpC,GAAItE,EAAWH,GACd,OAAO,EAER,GAAID,EAAeC,GAClB,OAAO,EAGR,IAAI2G,EAAQ,EACZ,IAAK,MAAM3B,KAASC,MAAMC,KAAKlF,EAAKmF,YACnCwB,GAASV,EAAmBjB,GAE7B,OAAO2B,CACR,Q"}
@@ -0,0 +1,2 @@
1
+ import{i as o}from"./TypeBrands-Ch9856Gb.mjs";import{i as r,t as a}from"./MarkCommands-C0ps9h0z.mjs";import{r as t}from"./LocaleLoader-DEpTFuVc.mjs";function e(e,m){const i=o(m.markSpec.type);e.registerMarkSpec(m.markSpec),e.registerCommand(m.command,()=>t(e,r(e.getState(),i))),m.keyBinding&&e.registerKeymap({[m.keyBinding]:()=>e.executeCommand(m.command)}),m.toolbar&&e.registerToolbarItem({id:m.toolbar.id,group:m.toolbar.group,icon:m.toolbar.icon,label:m.toolbar.label,tooltip:m.toolbar.tooltip,command:m.command,isActive:o=>a(o,i)})}export{e as t};
2
+ //# sourceMappingURL=SimpleMark-DPTsIl9w.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleMark-D6vz3Nfd.mjs","names":["markType","toggleMark","isMarkActive","dispatchIfPresent","registerSimpleMark","context","def","type","markSpec","registerMarkSpec","registerCommand","command","getState","keyBinding","registerKeymap","executeCommand","toolbar","registerToolbarItem","id","group","icon","label","tooltip","isActive","state"],"sources":["../../src/plugins/shared/SimpleMark.ts"],"sourcesContent":["/**\n * Registers the common core of a simple toggle mark: its MarkSpec, a toggle\n * command, an optional keyboard shortcut, and an optional toolbar button.\n *\n * Plugins that need more (input rules, exclusivity middleware, config-driven\n * variants) layer those on top after calling this — it deliberately models only\n * the shared core, not every mark plugin.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport type { MarkSpec } from '../../model/MarkSpec.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent } from './PluginHelpers.js';\n\nexport interface SimpleMarkToolbar {\n\treadonly id: string;\n\treadonly group: string;\n\treadonly icon: string;\n\treadonly label: string;\n\treadonly tooltip: string;\n}\n\nexport interface SimpleMarkDefinition {\n\t/** The mark spec to register (defines DOM/HTML rendering and parsing). */\n\treadonly markSpec: MarkSpec;\n\t/** Toggle command name, e.g. `'toggleStrikethrough'`. */\n\treadonly command: string;\n\t/** Keyboard shortcut bound to the command; omit or `null` to skip. */\n\treadonly keyBinding?: string | null;\n\t/** Toolbar button; omit to skip. */\n\treadonly toolbar?: SimpleMarkToolbar;\n}\n\n/** Registers a simple toggle mark's spec, command, keymap, and toolbar item. */\nexport function registerSimpleMark(context: PluginContext, def: SimpleMarkDefinition): void {\n\tconst type = markType(def.markSpec.type);\n\n\tcontext.registerMarkSpec(def.markSpec);\n\n\tcontext.registerCommand(def.command, () =>\n\t\tdispatchIfPresent(context, toggleMark(context.getState(), type)),\n\t);\n\n\tif (def.keyBinding) {\n\t\tcontext.registerKeymap({ [def.keyBinding]: () => context.executeCommand(def.command) });\n\t}\n\n\tif (def.toolbar) {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: def.toolbar.id,\n\t\t\tgroup: def.toolbar.group,\n\t\t\ticon: def.toolbar.icon,\n\t\t\tlabel: def.toolbar.label,\n\t\t\ttooltip: def.toolbar.tooltip,\n\t\t\tcommand: def.command,\n\t\t\tisActive: (state) => isMarkActive(state, type),\n\t\t});\n\t}\n}\n"],"mappings":"Y,0IAmCA,SAAgBI,EAAmBC,EAAwBC,GAC1D,MAAMC,EAAOP,EAASM,EAAIE,SAASD,MAEnCF,EAAQI,iBAAiBH,EAAIE,UAE7BH,EAAQK,gBAAgBJ,EAAIK,QAAA,IAC3BR,EAAkBE,EAASJ,EAAWI,EAAQO,WAAYL,KAGvDD,EAAIO,YACPR,EAAQS,eAAe,CAAA,CAAGR,EAAIO,YAAA,IAAmBR,EAAQU,eAAeT,EAAIK,WAGzEL,EAAIU,SACPX,EAAQY,oBAAoB,CAC3BC,GAAIZ,EAAIU,QAAQE,GAChBC,MAAOb,EAAIU,QAAQG,MACnBC,KAAMd,EAAIU,QAAQI,KAClBC,MAAOf,EAAIU,QAAQK,MACnBC,QAAShB,EAAIU,QAAQM,QACrBX,QAASL,EAAIK,QACbY,SAAWC,GAAUtB,EAAasB,EAAOjB,IAG5C,Q"}
1
+ {"version":3,"file":"SimpleMark-DPTsIl9w.mjs","names":["markType","toggleMark","isMarkActive","dispatchIfPresent","registerSimpleMark","context","def","type","markSpec","registerMarkSpec","registerCommand","command","getState","keyBinding","registerKeymap","executeCommand","toolbar","registerToolbarItem","id","group","icon","label","tooltip","isActive","state"],"sources":["../../src/plugins/shared/SimpleMark.ts"],"sourcesContent":["/**\n * Registers the common core of a simple toggle mark: its MarkSpec, a toggle\n * command, an optional keyboard shortcut, and an optional toolbar button.\n *\n * Plugins that need more (input rules, exclusivity middleware, config-driven\n * variants) layer those on top after calling this — it deliberately models only\n * the shared core, not every mark plugin.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport type { MarkSpec } from '../../model/MarkSpec.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent } from './PluginHelpers.js';\n\nexport interface SimpleMarkToolbar {\n\treadonly id: string;\n\treadonly group: string;\n\treadonly icon: string;\n\treadonly label: string;\n\treadonly tooltip: string;\n}\n\nexport interface SimpleMarkDefinition {\n\t/** The mark spec to register (defines DOM/HTML rendering and parsing). */\n\treadonly markSpec: MarkSpec;\n\t/** Toggle command name, e.g. `'toggleStrikethrough'`. */\n\treadonly command: string;\n\t/** Keyboard shortcut bound to the command; omit or `null` to skip. */\n\treadonly keyBinding?: string | null;\n\t/** Toolbar button; omit to skip. */\n\treadonly toolbar?: SimpleMarkToolbar;\n}\n\n/** Registers a simple toggle mark's spec, command, keymap, and toolbar item. */\nexport function registerSimpleMark(context: PluginContext, def: SimpleMarkDefinition): void {\n\tconst type = markType(def.markSpec.type);\n\n\tcontext.registerMarkSpec(def.markSpec);\n\n\tcontext.registerCommand(def.command, () =>\n\t\tdispatchIfPresent(context, toggleMark(context.getState(), type)),\n\t);\n\n\tif (def.keyBinding) {\n\t\tcontext.registerKeymap({ [def.keyBinding]: () => context.executeCommand(def.command) });\n\t}\n\n\tif (def.toolbar) {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: def.toolbar.id,\n\t\t\tgroup: def.toolbar.group,\n\t\t\ticon: def.toolbar.icon,\n\t\t\tlabel: def.toolbar.label,\n\t\t\ttooltip: def.toolbar.tooltip,\n\t\t\tcommand: def.command,\n\t\t\tisActive: (state) => isMarkActive(state, type),\n\t\t});\n\t}\n}\n"],"mappings":"Y,yIAmCA,SAAgBI,EAAmBC,EAAwBC,GAC1D,MAAMC,EAAOP,EAASM,EAAIE,SAASD,MAEnCF,EAAQI,iBAAiBH,EAAIE,UAE7BH,EAAQK,gBAAgBJ,EAAIK,QAAA,IAC3BR,EAAkBE,EAASJ,EAAWI,EAAQO,WAAYL,KAGvDD,EAAIO,YACPR,EAAQS,eAAe,CAAA,CAAGR,EAAIO,YAAA,IAAmBR,EAAQU,eAAeT,EAAIK,WAGzEL,EAAIU,SACPX,EAAQY,oBAAoB,CAC3BC,GAAIZ,EAAIU,QAAQE,GAChBC,MAAOb,EAAIU,QAAQG,MACnBC,KAAMd,EAAIU,QAAQI,KAClBC,MAAOf,EAAIU,QAAQK,MACnBC,QAAShB,EAAIU,QAAQM,QACrBX,QAASL,EAAIK,QACbY,SAAWC,GAAUtB,EAAasB,EAAOjB,IAG5C,Q"}
@@ -0,0 +1,2 @@
1
+ import{E as t,_ as e,k as n,p as o}from"./Document-ssR6hBzG.mjs";import{n as s}from"./Selection-DC6AOGgF.mjs";import{a as c}from"./TypeBrands-Ch9856Gb.mjs";import{s as i}from"./BlockInsertion-CXfXqUZl.mjs";import{n as r}from"./TypedKeys-CA4bfw9O.mjs";import{s as a,t as l}from"./LocaleLoader-DEpTFuVc.mjs";import{n as d,t as u}from"./SelectionReplacement-Cj4FLlPz.mjs";import{o as h}from"./xml-BsV44TrJ.mjs";import{i as m,o as g,r as f,t as p}from"./XmlSupport-3Za6SIqF.mjs";var x=/\n(?:[ \t]*\n)+/;function j(t,e){return!t.detection&&!e.detection||!(!t.detection||!e.detection)&&t.detection.language===e.detection.language}function k(t,e){const n=`${t.text}\n\n${e.text}`;if(!t.detection&&!e.detection)return{text:n,detection:null};const o=t.detection,s=e.detection;return{text:n,detection:{language:o.language,formattedText:`${o.formattedText}\n\n${s.formattedText}`,confidence:Math.max(o.confidence,s.confidence)}}}var b={detectedAsCodeBlock:t=>`Pasted as ${t} code block with syntax highlighting.`,detectedMixedContent:(t,e,n)=>{const o=[];if(t>0&&o.push(`${t} paragraph${t>1?"s":""}`),e>0){const t=n.join(", ");o.push(`${e} code block${e>1?"s":""} (${t})`)}return`Pasted as ${o.join(" and ")}.`}},C=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BWOue6jG.mjs"),"./locales/de.ts":()=>import("./de-CTzAMkXC.mjs"),"./locales/es.ts":()=>import("./es-DDoqchUq.mjs"),"./locales/fr.ts":()=>import("./fr-eC0UdAPu.mjs"),"./locales/hi.ts":()=>import("./hi-DY55FuDK.mjs"),"./locales/nl.ts":()=>import("./nl-GBpv7W4L.mjs"),"./locales/pt.ts":()=>import("./pt-Bu7Mbz67.mjs"),"./locales/ru.ts":()=>import("./ru-DyCTlhjg.mjs"),"./locales/zh.ts":()=>import("./zh-D1HSmSOf.mjs")});async function B(t){return l(C,t,b)}var S=new r("smartPaste"),y=[g,m,f,p],T=class{id="smart-paste";name="Smart Paste";dependencies=["code-block"];config;detectors=[];context=null;locale=b;constructor(t){this.config={...t}}async init(t){this.context=t,this.locale=await a(t,this.config.locale,b,B);const e=t.getService(h);if(e){for(const t of y){const n=e.get(t.id);e.register(n?{...n,detection:t.detection}:t)}e.onRegister(t=>{t.detection&&this.detectors.push(t.detection)})}if(this.config.detectors)for(const n of this.config.detectors)this.detectors.push(n);t.registerPasteInterceptor(this.handlePaste,{name:"smart-paste",priority:50}),t.registerService(S,{registerDetector:t=>{this.detectors.push(t)}})}destroy(){this.context=null,this.detectors.length=0}handlePaste=(t,e,n)=>{const o=function(t,e){const n=t.split(x).map(t=>t.trim()).filter(t=>t.length>0);if(0===n.length)return null;let o=!1;const s=n.map(t=>{const n=function(t,e){let n=null;for(const o of e){const e=o.detect(t);e&&(null===n||e.confidence>n.confidence||e.confidence===n.confidence&&e.language<n.language)&&(n=e)}return n}(t,e);return n&&(o=!0),{text:t,detection:n}});return o?function(t){if(t.length<=1)return t;const e=[t[0]];for(let n=1;n<t.length;n++){const o=t[n],s=e[e.length-1];j(s,o)?e[e.length-1]=k(s,o):e.push(o)}return e}(s):null}(t,this.detectors);if(!o)return null;const s=n.transaction("paste"),c=d(n,s);if("code_block"===u(c)?.type)return null;const i={builder:s,target:c,selection:n.selection};return 1===o.length&&o[0]?.detection?this.handleSingleCodeBlock(i,o[0].detection):this.handleMixedContent(i,o)};handleSingleCodeBlock(t,e){const n=this.buildCodeBlockTransaction(t,e);return n&&this.context&&this.context.announce(this.locale.detectedAsCodeBlock(e.language)),n}buildCodeBlockTransaction(t,e){const{builder:n,target:o,selection:c}=t,r=this.createCodeBlockNode(e);return i(o.state,n,o.blockId,[r],c,this.context?.getSchemaRegistry())?(n.setSelection(s(r.id,e.formattedText.length)),n.build()):null}handleMixedContent(t,e){const n=this.buildMultiBlockTransaction(t,e);return n&&this.context&&this.announceMixedContent(e),n}buildMultiBlockTransaction(t,e){const{builder:o,selection:c}=t,{state:r,blockId:a}=t.target,l=e.map(t=>t.detection?this.createCodeBlockNode(t.detection):this.createParagraphNode(t.text));if(!i(r,o,a,l,c,this.context?.getSchemaRegistry()))return null;const d=l[l.length-1];return d&&o.setSelection(s(d.id,n(d))),o.build()}createCodeBlockNode(n){return o(c("code_block"),[e(n.formattedText)],t(),{language:n.language,backgroundColor:""})}createParagraphNode(n){return o(c("paragraph"),[e(n)],t())}announceMixedContent(t){let e=0,n=0;const o=[];for(const s of t)s.detection?(n++,o.includes(s.detection.language)||o.push(s.detection.language)):e++;this.context?.announce(this.locale.detectedMixedContent(e,n,o))}};export{B as i,S as n,b as r,T as t};
2
+ //# sourceMappingURL=SmartPastePlugin-BSMHDDQ2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SmartPastePlugin-BHsYKbgd.mjs","names":["generateBlockId","createTextNode","getBlockLength","createBlockNode","createCollapsedSelection","nodeType","insertBlocksAfterAnchor","ServiceKey","loadLocaleModule","resolveLocale","resolveReplacementTarget","getReceivingBlock","LANGUAGE_REGISTRY_SERVICE_KEY","JSON_SUPPORT","JAVA_SUPPORT","TYPESCRIPT_SUPPORT","XML_SUPPORT","BLANK_LINE_SPLIT","canMerge","a","b","detection","language","merge","joinedText","text","detA","detB","formattedText","confidence","Math","max","SMART_PASTE_LOCALE_EN","detectedAsCodeBlock","detectedMixedContent","textCount","codeCount","languages","parts","push","langList","join","localeModules","Object","assign","async","loadSmartPasteLocale","lang","SMART_PASTE_SERVICE_KEY","BUILTIN_LANGUAGE_SUPPORTS","SmartPastePlugin","id","name","dependencies","config","detectors","context","locale","constructor","this","init","registry","getService","support","existing","get","register","onRegister","detector","registerPasteInterceptor","handlePaste","priority","registerService","registerDetector","destroy","length","plainText","_html","state","segments","trimmed","split","map","s","trim","filter","hasCode","segmentText","best","result","detect","detectBest","merged","i","current","previous","mergeAdjacentSegments","splitAndClassify","builder","transaction","target","type","paste","selection","handleSingleCodeBlock","handleMixedContent","tr","buildCodeBlockTransaction","announce","codeBlock","createCodeBlockNode","blockId","getSchemaRegistry","setSelection","build","buildMultiBlockTransaction","announceMixedContent","working","anchorBlockId","blocks","segment","createParagraphNode","lastBlock","backgroundColor","includes"],"sources":["../../src/plugins/smart-paste/ContentSplitter.ts","../../src/plugins/smart-paste/SmartPasteLocale.ts","../../src/plugins/smart-paste/SmartPasteTypes.ts","../../src/plugins/smart-paste/SmartPastePlugin.ts"],"sourcesContent":["/**\n * Splits pasted text at blank-line boundaries and classifies each segment\n * using content detectors. Adjacent segments of the same type are merged.\n */\n\nimport type { ContentDetector, DetectionResult, PasteSegment } from './SmartPasteTypes.js';\n\n/** Pattern matching one or more consecutive blank lines (may contain whitespace). */\nconst BLANK_LINE_SPLIT: RegExp = /\\n(?:[ \\t]*\\n)+/;\n\n/**\n * Splits text at blank-line boundaries and classifies each segment\n * using the provided detectors. Returns null if no code is detected\n * in any segment (the paste should fall through to default handling).\n */\nexport function splitAndClassify(\n\ttext: string,\n\tdetectors: readonly ContentDetector[],\n): readonly PasteSegment[] | null {\n\tconst rawSegments: readonly string[] = text.split(BLANK_LINE_SPLIT);\n\tconst trimmed: readonly string[] = rawSegments\n\t\t.map((s: string) => s.trim())\n\t\t.filter((s: string) => s.length > 0);\n\n\tif (trimmed.length === 0) return null;\n\n\tlet hasCode = false;\n\tconst segments: PasteSegment[] = trimmed.map((segmentText: string): PasteSegment => {\n\t\tconst detection: DetectionResult | null = detectBest(segmentText, detectors);\n\t\tif (detection) hasCode = true;\n\t\treturn { text: segmentText, detection };\n\t});\n\n\tif (!hasCode) return null;\n\n\treturn mergeAdjacentSegments(segments);\n}\n\n/**\n * Merges adjacent segments that share the same classification:\n * consecutive text segments become one paragraph, consecutive code\n * segments of the same language become one code block.\n */\nexport function mergeAdjacentSegments(segments: readonly PasteSegment[]): readonly PasteSegment[] {\n\tif (segments.length <= 1) return segments;\n\n\tconst merged: PasteSegment[] = [segments[0] as PasteSegment];\n\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tconst current: PasteSegment = segments[i] as PasteSegment;\n\t\tconst previous: PasteSegment = merged[merged.length - 1] as PasteSegment;\n\n\t\tif (canMerge(previous, current)) {\n\t\t\tmerged[merged.length - 1] = merge(previous, current);\n\t\t} else {\n\t\t\tmerged.push(current);\n\t\t}\n\t}\n\n\treturn merged;\n}\n\n/**\n * Picks the highest-confidence detection result from all detectors.\n * Ties are broken deterministically by lexicographic language id so the\n * outcome does not depend on detector registration order.\n */\nfunction detectBest(text: string, detectors: readonly ContentDetector[]): DetectionResult | null {\n\tlet best: DetectionResult | null = null;\n\n\tfor (const detector of detectors) {\n\t\tconst result: DetectionResult | null = detector.detect(text);\n\t\tif (!result) continue;\n\t\tif (\n\t\t\tbest === null ||\n\t\t\tresult.confidence > best.confidence ||\n\t\t\t(result.confidence === best.confidence && result.language < best.language)\n\t\t) {\n\t\t\tbest = result;\n\t\t}\n\t}\n\n\treturn best;\n}\n\n/** Two segments can merge if both are text or both are code of the same language. */\nfunction canMerge(a: PasteSegment, b: PasteSegment): boolean {\n\tif (!a.detection && !b.detection) return true;\n\tif (a.detection && b.detection) return a.detection.language === b.detection.language;\n\treturn false;\n}\n\n/** Merges two compatible segments into one. */\nfunction merge(a: PasteSegment, b: PasteSegment): PasteSegment {\n\tconst joinedText: string = `${a.text}\\n\\n${b.text}`;\n\n\tif (!a.detection && !b.detection) {\n\t\treturn { text: joinedText, detection: null };\n\t}\n\n\tconst detA: DetectionResult = a.detection as DetectionResult;\n\tconst detB: DetectionResult = b.detection as DetectionResult;\n\n\treturn {\n\t\ttext: joinedText,\n\t\tdetection: {\n\t\t\tlanguage: detA.language,\n\t\t\tformattedText: `${detA.formattedText}\\n\\n${detB.formattedText}`,\n\t\t\tconfidence: Math.max(detA.confidence, detB.confidence),\n\t\t},\n\t};\n}\n","/** Locale interface and default English locale for the SmartPastePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\nexport interface SmartPasteLocale {\n\treadonly detectedAsCodeBlock: (language: string) => string;\n\treadonly detectedMixedContent: (\n\t\ttextCount: number,\n\t\tcodeCount: number,\n\t\tlanguages: readonly string[],\n\t) => string;\n}\n\nexport const SMART_PASTE_LOCALE_EN: SmartPasteLocale = {\n\tdetectedAsCodeBlock: (language: string) =>\n\t\t`Pasted as ${language} code block with syntax highlighting.`,\n\tdetectedMixedContent: (textCount: number, codeCount: number, languages: readonly string[]) => {\n\t\tconst parts: string[] = [];\n\t\tif (textCount > 0) {\n\t\t\tparts.push(`${textCount} paragraph${textCount > 1 ? 's' : ''}`);\n\t\t}\n\t\tif (codeCount > 0) {\n\t\t\tconst langList: string = languages.join(', ');\n\t\t\tparts.push(`${codeCount} code block${codeCount > 1 ? 's' : ''} (${langList})`);\n\t\t}\n\t\treturn `Pasted as ${parts.join(' and ')}.`;\n\t},\n};\n\nconst localeModules: LocaleModuleMap<SmartPasteLocale> = import.meta.glob<{\n\tdefault: SmartPasteLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadSmartPasteLocale(lang: string): Promise<SmartPasteLocale> {\n\treturn loadLocaleModule(localeModules, lang, SMART_PASTE_LOCALE_EN);\n}\n","/**\n * Types for the smart paste plugin — content detection and formatting.\n */\n\nimport { ServiceKey } from '../Plugin.js';\nimport type { SmartPasteLocale } from './SmartPasteLocale.js';\n\n/** Result of detecting structured content in pasted text. */\nexport interface DetectionResult {\n\treadonly language: string;\n\treadonly formattedText: string;\n\treadonly confidence: number;\n}\n\n/** A classified segment of pasted text — either plain text or detected code. */\nexport interface PasteSegment {\n\treadonly text: string;\n\treadonly detection: DetectionResult | null;\n}\n\n/** Interface for content detectors that identify and format pasted text. */\nexport interface ContentDetector {\n\treadonly id: string;\n\tdetect(text: string): DetectionResult | null;\n}\n\n/** Configuration for the SmartPastePlugin. */\nexport interface SmartPasteConfig {\n\treadonly detectors?: readonly ContentDetector[];\n\treadonly locale?: SmartPasteLocale;\n}\n\n/** Public service for registering additional content detectors at runtime. */\nexport interface SmartPasteService {\n\tregisterDetector(detector: ContentDetector): void;\n}\n\nexport const SMART_PASTE_SERVICE_KEY = new ServiceKey<SmartPasteService>('smartPaste');\n","/**\n * SmartPastePlugin: detects structured content in clipboard text\n * and inserts it as formatted code blocks with syntax highlighting.\n * Mixed content (text + code) is split into separate blocks.\n */\n\nimport { insertBlocksAfterAnchor } from '../../commands/BlockInsertion.js';\nimport {\n\ttype ReplacementTarget,\n\tgetReceivingBlock,\n\tresolveReplacementTarget,\n} from '../../commands/SelectionReplacement.js';\nimport {\n\ttype BlockNode,\n\tcreateBlockNode,\n\tcreateTextNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n} from '../../model/Document.js';\nimport { type EditorSelection, createCollapsedSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction, TransactionBuilder } from '../../state/Transaction.js';\nimport type { PasteInterceptor, Plugin, PluginContext } from '../Plugin.js';\nimport { LANGUAGE_REGISTRY_SERVICE_KEY } from '../language/LanguageTypes.js';\nimport {\n\tJAVA_SUPPORT,\n\tJSON_SUPPORT,\n\tTYPESCRIPT_SUPPORT,\n\tXML_SUPPORT,\n} from '../language/bundles/index.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { splitAndClassify } from './ContentSplitter.js';\nimport {\n\tSMART_PASTE_LOCALE_EN,\n\ttype SmartPasteLocale,\n\tloadSmartPasteLocale,\n} from './SmartPasteLocale.js';\nimport type {\n\tContentDetector,\n\tDetectionResult,\n\tPasteSegment,\n\tSmartPasteConfig,\n} from './SmartPasteTypes.js';\nimport { SMART_PASTE_SERVICE_KEY } from './SmartPasteTypes.js';\n\nconst BUILTIN_LANGUAGE_SUPPORTS = [\n\tJAVA_SUPPORT,\n\tJSON_SUPPORT,\n\tTYPESCRIPT_SUPPORT,\n\tXML_SUPPORT,\n] as const;\n\n/** A paste whose selection deletion is already recorded in `builder`. */\ninterface ReplacementPaste {\n\treadonly builder: TransactionBuilder;\n\treadonly target: ReplacementTarget;\n\treadonly selection: EditorSelection;\n}\n\nexport class SmartPastePlugin implements Plugin {\n\treadonly id = 'smart-paste';\n\treadonly name = 'Smart Paste';\n\treadonly dependencies = ['code-block'] as const;\n\n\tprivate readonly config: SmartPasteConfig;\n\tprivate readonly detectors: ContentDetector[] = [];\n\tprivate context: PluginContext | null = null;\n\tprivate locale: SmartPasteLocale = SMART_PASTE_LOCALE_EN;\n\n\tconstructor(config?: Partial<SmartPasteConfig>) {\n\t\tthis.config = { ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.context = context;\n\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSMART_PASTE_LOCALE_EN,\n\t\t\tloadSmartPasteLocale,\n\t\t);\n\n\t\t// Detection belongs to Smart Paste, while Code Block contributes only\n\t\t// highlighting. Preserve those existing capabilities when adding detectors.\n\t\tconst registry = context.getService(LANGUAGE_REGISTRY_SERVICE_KEY);\n\t\tif (registry) {\n\t\t\tfor (const support of BUILTIN_LANGUAGE_SUPPORTS) {\n\t\t\t\tconst existing = registry.get(support.id);\n\t\t\t\tregistry.register(existing ? { ...existing, detection: support.detection } : support);\n\t\t\t}\n\t\t\tregistry.onRegister((support) => {\n\t\t\t\tif (support.detection) {\n\t\t\t\t\tthis.detectors.push(support.detection);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// Register config-provided detectors\n\t\tif (this.config.detectors) {\n\t\t\tfor (const detector of this.config.detectors) {\n\t\t\t\tthis.detectors.push(detector);\n\t\t\t}\n\t\t}\n\n\t\t// Register paste interceptor\n\t\tcontext.registerPasteInterceptor(this.handlePaste, { name: 'smart-paste', priority: 50 });\n\n\t\t// Register service for external detector registration\n\t\tcontext.registerService(SMART_PASTE_SERVICE_KEY, {\n\t\t\tregisterDetector: (detector: ContentDetector) => {\n\t\t\t\tthis.detectors.push(detector);\n\t\t\t},\n\t\t});\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t\tthis.detectors.length = 0;\n\t}\n\n\t// --- Paste Interceptor ---\n\n\tprivate readonly handlePaste: PasteInterceptor = (\n\t\tplainText: string,\n\t\t_html: string,\n\t\tstate: EditorState,\n\t): Transaction | null => {\n\t\tconst segments: readonly PasteSegment[] | null = splitAndClassify(plainText, this.detectors);\n\t\tif (!segments) return null;\n\n\t\t// Text that lands in a code block is pasted literally by the code block.\n\t\tconst builder: TransactionBuilder = state.transaction('paste');\n\t\tconst target: ReplacementTarget = resolveReplacementTarget(state, builder);\n\t\tif (getReceivingBlock(target)?.type === 'code_block') return null;\n\n\t\tconst paste: ReplacementPaste = { builder, target, selection: state.selection };\n\n\t\t// Single code-only segment: use existing fast path\n\t\tif (segments.length === 1 && segments[0]?.detection) {\n\t\t\treturn this.handleSingleCodeBlock(paste, segments[0].detection);\n\t\t}\n\n\t\t// Mixed content: create multiple blocks\n\t\treturn this.handleMixedContent(paste, segments);\n\t};\n\n\t// --- Single Code Block (existing behavior) ---\n\n\tprivate handleSingleCodeBlock(\n\t\tpaste: ReplacementPaste,\n\t\tdetection: DetectionResult,\n\t): Transaction | null {\n\t\tconst tr: Transaction | null = this.buildCodeBlockTransaction(paste, detection);\n\t\tif (tr && this.context) {\n\t\t\tthis.context.announce(this.locale.detectedAsCodeBlock(detection.language));\n\t\t}\n\t\treturn tr;\n\t}\n\n\tprivate buildCodeBlockTransaction(\n\t\tpaste: ReplacementPaste,\n\t\tdetection: DetectionResult,\n\t): Transaction | null {\n\t\tconst { builder, target, selection } = paste;\n\n\t\t// Create the code block node\n\t\tconst codeBlock: BlockNode = this.createCodeBlockNode(detection);\n\n\t\t// Insert at cursor (actual parent or root escape, empty anchor removal)\n\t\tif (\n\t\t\t!insertBlocksAfterAnchor(\n\t\t\t\ttarget.state,\n\t\t\t\tbuilder,\n\t\t\t\ttarget.blockId,\n\t\t\t\t[codeBlock],\n\t\t\t\tselection,\n\t\t\t\tthis.context?.getSchemaRegistry(),\n\t\t\t)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tbuilder.setSelection(createCollapsedSelection(codeBlock.id, detection.formattedText.length));\n\n\t\treturn builder.build();\n\t}\n\n\t// --- Mixed Content (multiple blocks) ---\n\n\tprivate handleMixedContent(\n\t\tpaste: ReplacementPaste,\n\t\tsegments: readonly PasteSegment[],\n\t): Transaction | null {\n\t\tconst tr: Transaction | null = this.buildMultiBlockTransaction(paste, segments);\n\t\tif (tr && this.context) {\n\t\t\tthis.announceMixedContent(segments);\n\t\t}\n\t\treturn tr;\n\t}\n\n\tprivate buildMultiBlockTransaction(\n\t\tpaste: ReplacementPaste,\n\t\tsegments: readonly PasteSegment[],\n\t): Transaction | null {\n\t\tconst { builder, selection } = paste;\n\t\tconst { state: working, blockId: anchorBlockId } = paste.target;\n\t\tconst blocks: readonly BlockNode[] = segments.map((segment) =>\n\t\t\tsegment.detection\n\t\t\t\t? this.createCodeBlockNode(segment.detection)\n\t\t\t\t: this.createParagraphNode(segment.text),\n\t\t);\n\t\tif (\n\t\t\t!insertBlocksAfterAnchor(\n\t\t\t\tworking,\n\t\t\t\tbuilder,\n\t\t\t\tanchorBlockId,\n\t\t\t\tblocks,\n\t\t\t\tselection,\n\t\t\t\tthis.context?.getSchemaRegistry(),\n\t\t\t)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst lastBlock = blocks[blocks.length - 1];\n\t\tif (lastBlock) {\n\t\t\tbuilder.setSelection(createCollapsedSelection(lastBlock.id, getBlockLength(lastBlock)));\n\t\t}\n\n\t\treturn builder.build();\n\t}\n\n\tprivate createCodeBlockNode(detection: DetectionResult): BlockNode {\n\t\treturn createBlockNode(\n\t\t\tnodeType('code_block'),\n\t\t\t[createTextNode(detection.formattedText)],\n\t\t\tgenerateBlockId(),\n\t\t\t{ language: detection.language, backgroundColor: '' },\n\t\t);\n\t}\n\n\tprivate createParagraphNode(text: string): BlockNode {\n\t\treturn createBlockNode(nodeType('paragraph'), [createTextNode(text)], generateBlockId());\n\t}\n\n\tprivate announceMixedContent(segments: readonly PasteSegment[]): void {\n\t\tlet textCount = 0;\n\t\tlet codeCount = 0;\n\t\tconst languages: string[] = [];\n\n\t\tfor (const segment of segments) {\n\t\t\tif (segment.detection) {\n\t\t\t\tcodeCount++;\n\t\t\t\tif (!languages.includes(segment.detection.language)) {\n\t\t\t\t\tlanguages.push(segment.detection.language);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttextCount++;\n\t\t\t}\n\t\t}\n\n\t\tthis.context?.announce(this.locale.detectedMixedContent(textCount, codeCount, languages));\n\t}\n}\n"],"mappings":"Y,gdAQA,IAAMiB,EAA2B,kBA8EjC,SAASC,EAASC,EAAiBC,GAClC,OAAKD,EAAEE,YAAcD,EAAEC,cACnBF,EAAEE,YAAaD,EAAEC,YAAkBF,EAAEE,UAAUC,WAAaF,EAAEC,UAAUC,QAE7E,CAGA,SAASC,EAAMJ,EAAiBC,GAC/B,MAAMI,EAAqB,GAAGL,EAAEM,WAAWL,EAAEK,OAE7C,IAAKN,EAAEE,YAAcD,EAAEC,UACtB,MAAO,CAAEI,KAAMD,EAAYH,UAAW,MAGvC,MAAMK,EAAwBP,EAAEE,UAC1BM,EAAwBP,EAAEC,UAEhC,MAAO,CACNI,KAAMD,EACNH,UAAW,CACVC,SAAUI,EAAKJ,SACfM,cAAe,GAAGF,EAAKE,oBAAoBD,EAAKC,gBAChDC,WAAYC,KAAKC,IAAIL,EAAKG,WAAYF,EAAKE,aAG9C,CClGA,IAAaG,EAA0C,CACtDC,oBAAsBX,GACrB,aAAaA,yCACdY,qBAAA,CAAuBC,EAAmBC,EAAmBC,KAC5D,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ClDA,EAAQnG,UACLsC,KAAKmD,oBAAoBU,EAAQnG,WACjCsC,KAAK8D,oBAAoBD,EAAQ/F,OAErC,IACEnB,EACA+G,EACAnB,EACAoB,EACAC,EACAhB,EACA5C,KAAKH,SAASwD,qBAGf,OAAO,KAGR,MAAMU,EAAYH,EAAOA,EAAO5C,OAAS,GAKzC,OAJI+C,GACHxB,EAAQe,aAAa7G,EAAyBsH,EAAUvE,GAAIjD,EAAewH,KAGrExB,EAAQgB,OAChB,CAEA,mBAAAJ,CAA4BzF,GAC3B,OAAOlB,EACNE,EAAS,cACT,CAACJ,EAAeoB,EAAUO,gBAC1B5B,IACA,CAAEsB,SAAUD,EAAUC,SAAUqG,gBAAiB,IAEnD,CAEA,mBAAAF,CAA4BhG,GAC3B,OAAOtB,EAAgBE,EAAS,aAAc,CAACJ,EAAewB,IAAQzB,IACvE,CAEA,oBAAAoH,CAA6BrC,GAC5B,IAAI5C,EAAY,EACZC,EAAY,EAChB,MAAMC,EAAsB,GAE5B,IAAK,MAAMmF,KAAWzC,EACjByC,EAAQnG,WACXe,IACKC,EAAUuF,SAASJ,EAAQnG,UAAUC,WACzCe,EAAUE,KAAKiF,EAAQnG,UAAUC,WAGlCa,IAIFwB,KAAKH,SAASoD,SAASjD,KAAKF,OAAOvB,qBAAqBC,EAAWC,EAAWC,GAC/E,U"}
1
+ {"version":3,"file":"SmartPastePlugin-BSMHDDQ2.mjs","names":["generateBlockId","createTextNode","getBlockLength","createBlockNode","createCollapsedSelection","nodeType","insertBlocksAfterAnchor","ServiceKey","resolveLocale","loadLocaleModule","resolveReplacementTarget","getReceivingBlock","LANGUAGE_REGISTRY_SERVICE_KEY","JSON_SUPPORT","JAVA_SUPPORT","TYPESCRIPT_SUPPORT","XML_SUPPORT","BLANK_LINE_SPLIT","canMerge","a","b","detection","language","merge","joinedText","text","detA","detB","formattedText","confidence","Math","max","SMART_PASTE_LOCALE_EN","detectedAsCodeBlock","detectedMixedContent","textCount","codeCount","languages","parts","push","langList","join","localeModules","Object","assign","async","loadSmartPasteLocale","lang","SMART_PASTE_SERVICE_KEY","BUILTIN_LANGUAGE_SUPPORTS","SmartPastePlugin","id","name","dependencies","config","detectors","context","locale","constructor","this","init","registry","getService","support","existing","get","register","onRegister","detector","registerPasteInterceptor","handlePaste","priority","registerService","registerDetector","destroy","length","plainText","_html","state","segments","trimmed","split","map","s","trim","filter","hasCode","segmentText","best","result","detect","detectBest","merged","i","current","previous","mergeAdjacentSegments","splitAndClassify","builder","transaction","target","type","paste","selection","handleSingleCodeBlock","handleMixedContent","tr","buildCodeBlockTransaction","announce","codeBlock","createCodeBlockNode","blockId","getSchemaRegistry","setSelection","build","buildMultiBlockTransaction","announceMixedContent","working","anchorBlockId","blocks","segment","createParagraphNode","lastBlock","backgroundColor","includes"],"sources":["../../src/plugins/smart-paste/ContentSplitter.ts","../../src/plugins/smart-paste/SmartPasteLocale.ts","../../src/plugins/smart-paste/SmartPasteTypes.ts","../../src/plugins/smart-paste/SmartPastePlugin.ts"],"sourcesContent":["/**\n * Splits pasted text at blank-line boundaries and classifies each segment\n * using content detectors. Adjacent segments of the same type are merged.\n */\n\nimport type { ContentDetector, DetectionResult, PasteSegment } from './SmartPasteTypes.js';\n\n/** Pattern matching one or more consecutive blank lines (may contain whitespace). */\nconst BLANK_LINE_SPLIT: RegExp = /\\n(?:[ \\t]*\\n)+/;\n\n/**\n * Splits text at blank-line boundaries and classifies each segment\n * using the provided detectors. Returns null if no code is detected\n * in any segment (the paste should fall through to default handling).\n */\nexport function splitAndClassify(\n\ttext: string,\n\tdetectors: readonly ContentDetector[],\n): readonly PasteSegment[] | null {\n\tconst rawSegments: readonly string[] = text.split(BLANK_LINE_SPLIT);\n\tconst trimmed: readonly string[] = rawSegments\n\t\t.map((s: string) => s.trim())\n\t\t.filter((s: string) => s.length > 0);\n\n\tif (trimmed.length === 0) return null;\n\n\tlet hasCode = false;\n\tconst segments: PasteSegment[] = trimmed.map((segmentText: string): PasteSegment => {\n\t\tconst detection: DetectionResult | null = detectBest(segmentText, detectors);\n\t\tif (detection) hasCode = true;\n\t\treturn { text: segmentText, detection };\n\t});\n\n\tif (!hasCode) return null;\n\n\treturn mergeAdjacentSegments(segments);\n}\n\n/**\n * Merges adjacent segments that share the same classification:\n * consecutive text segments become one paragraph, consecutive code\n * segments of the same language become one code block.\n */\nexport function mergeAdjacentSegments(segments: readonly PasteSegment[]): readonly PasteSegment[] {\n\tif (segments.length <= 1) return segments;\n\n\tconst merged: PasteSegment[] = [segments[0] as PasteSegment];\n\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tconst current: PasteSegment = segments[i] as PasteSegment;\n\t\tconst previous: PasteSegment = merged[merged.length - 1] as PasteSegment;\n\n\t\tif (canMerge(previous, current)) {\n\t\t\tmerged[merged.length - 1] = merge(previous, current);\n\t\t} else {\n\t\t\tmerged.push(current);\n\t\t}\n\t}\n\n\treturn merged;\n}\n\n/**\n * Picks the highest-confidence detection result from all detectors.\n * Ties are broken deterministically by lexicographic language id so the\n * outcome does not depend on detector registration order.\n */\nfunction detectBest(text: string, detectors: readonly ContentDetector[]): DetectionResult | null {\n\tlet best: DetectionResult | null = null;\n\n\tfor (const detector of detectors) {\n\t\tconst result: DetectionResult | null = detector.detect(text);\n\t\tif (!result) continue;\n\t\tif (\n\t\t\tbest === null ||\n\t\t\tresult.confidence > best.confidence ||\n\t\t\t(result.confidence === best.confidence && result.language < best.language)\n\t\t) {\n\t\t\tbest = result;\n\t\t}\n\t}\n\n\treturn best;\n}\n\n/** Two segments can merge if both are text or both are code of the same language. */\nfunction canMerge(a: PasteSegment, b: PasteSegment): boolean {\n\tif (!a.detection && !b.detection) return true;\n\tif (a.detection && b.detection) return a.detection.language === b.detection.language;\n\treturn false;\n}\n\n/** Merges two compatible segments into one. */\nfunction merge(a: PasteSegment, b: PasteSegment): PasteSegment {\n\tconst joinedText: string = `${a.text}\\n\\n${b.text}`;\n\n\tif (!a.detection && !b.detection) {\n\t\treturn { text: joinedText, detection: null };\n\t}\n\n\tconst detA: DetectionResult = a.detection as DetectionResult;\n\tconst detB: DetectionResult = b.detection as DetectionResult;\n\n\treturn {\n\t\ttext: joinedText,\n\t\tdetection: {\n\t\t\tlanguage: detA.language,\n\t\t\tformattedText: `${detA.formattedText}\\n\\n${detB.formattedText}`,\n\t\t\tconfidence: Math.max(detA.confidence, detB.confidence),\n\t\t},\n\t};\n}\n","/** Locale interface and default English locale for the SmartPastePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\nexport interface SmartPasteLocale {\n\treadonly detectedAsCodeBlock: (language: string) => string;\n\treadonly detectedMixedContent: (\n\t\ttextCount: number,\n\t\tcodeCount: number,\n\t\tlanguages: readonly string[],\n\t) => string;\n}\n\nexport const SMART_PASTE_LOCALE_EN: SmartPasteLocale = {\n\tdetectedAsCodeBlock: (language: string) =>\n\t\t`Pasted as ${language} code block with syntax highlighting.`,\n\tdetectedMixedContent: (textCount: number, codeCount: number, languages: readonly string[]) => {\n\t\tconst parts: string[] = [];\n\t\tif (textCount > 0) {\n\t\t\tparts.push(`${textCount} paragraph${textCount > 1 ? 's' : ''}`);\n\t\t}\n\t\tif (codeCount > 0) {\n\t\t\tconst langList: string = languages.join(', ');\n\t\t\tparts.push(`${codeCount} code block${codeCount > 1 ? 's' : ''} (${langList})`);\n\t\t}\n\t\treturn `Pasted as ${parts.join(' and ')}.`;\n\t},\n};\n\nconst localeModules: LocaleModuleMap<SmartPasteLocale> = import.meta.glob<{\n\tdefault: SmartPasteLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadSmartPasteLocale(lang: string): Promise<SmartPasteLocale> {\n\treturn loadLocaleModule(localeModules, lang, SMART_PASTE_LOCALE_EN);\n}\n","/**\n * Types for the smart paste plugin — content detection and formatting.\n */\n\nimport { ServiceKey } from '../Plugin.js';\nimport type { SmartPasteLocale } from './SmartPasteLocale.js';\n\n/** Result of detecting structured content in pasted text. */\nexport interface DetectionResult {\n\treadonly language: string;\n\treadonly formattedText: string;\n\treadonly confidence: number;\n}\n\n/** A classified segment of pasted text — either plain text or detected code. */\nexport interface PasteSegment {\n\treadonly text: string;\n\treadonly detection: DetectionResult | null;\n}\n\n/** Interface for content detectors that identify and format pasted text. */\nexport interface ContentDetector {\n\treadonly id: string;\n\tdetect(text: string): DetectionResult | null;\n}\n\n/** Configuration for the SmartPastePlugin. */\nexport interface SmartPasteConfig {\n\treadonly detectors?: readonly ContentDetector[];\n\treadonly locale?: SmartPasteLocale;\n}\n\n/** Public service for registering additional content detectors at runtime. */\nexport interface SmartPasteService {\n\tregisterDetector(detector: ContentDetector): void;\n}\n\nexport const SMART_PASTE_SERVICE_KEY = new ServiceKey<SmartPasteService>('smartPaste');\n","/**\n * SmartPastePlugin: detects structured content in clipboard text\n * and inserts it as formatted code blocks with syntax highlighting.\n * Mixed content (text + code) is split into separate blocks.\n */\n\nimport { insertBlocksAfterAnchor } from '../../commands/BlockInsertion.js';\nimport {\n\ttype ReplacementTarget,\n\tgetReceivingBlock,\n\tresolveReplacementTarget,\n} from '../../commands/SelectionReplacement.js';\nimport {\n\ttype BlockNode,\n\tcreateBlockNode,\n\tcreateTextNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n} from '../../model/Document.js';\nimport { type EditorSelection, createCollapsedSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction, TransactionBuilder } from '../../state/Transaction.js';\nimport type { PasteInterceptor, Plugin, PluginContext } from '../Plugin.js';\nimport { LANGUAGE_REGISTRY_SERVICE_KEY } from '../language/LanguageTypes.js';\nimport {\n\tJAVA_SUPPORT,\n\tJSON_SUPPORT,\n\tTYPESCRIPT_SUPPORT,\n\tXML_SUPPORT,\n} from '../language/bundles/index.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { splitAndClassify } from './ContentSplitter.js';\nimport {\n\tSMART_PASTE_LOCALE_EN,\n\ttype SmartPasteLocale,\n\tloadSmartPasteLocale,\n} from './SmartPasteLocale.js';\nimport type {\n\tContentDetector,\n\tDetectionResult,\n\tPasteSegment,\n\tSmartPasteConfig,\n} from './SmartPasteTypes.js';\nimport { SMART_PASTE_SERVICE_KEY } from './SmartPasteTypes.js';\n\nconst BUILTIN_LANGUAGE_SUPPORTS = [\n\tJAVA_SUPPORT,\n\tJSON_SUPPORT,\n\tTYPESCRIPT_SUPPORT,\n\tXML_SUPPORT,\n] as const;\n\n/** A paste whose selection deletion is already recorded in `builder`. */\ninterface ReplacementPaste {\n\treadonly builder: TransactionBuilder;\n\treadonly target: ReplacementTarget;\n\treadonly selection: EditorSelection;\n}\n\nexport class SmartPastePlugin implements Plugin {\n\treadonly id = 'smart-paste';\n\treadonly name = 'Smart Paste';\n\treadonly dependencies = ['code-block'] as const;\n\n\tprivate readonly config: SmartPasteConfig;\n\tprivate readonly detectors: ContentDetector[] = [];\n\tprivate context: PluginContext | null = null;\n\tprivate locale: SmartPasteLocale = SMART_PASTE_LOCALE_EN;\n\n\tconstructor(config?: Partial<SmartPasteConfig>) {\n\t\tthis.config = { ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.context = context;\n\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSMART_PASTE_LOCALE_EN,\n\t\t\tloadSmartPasteLocale,\n\t\t);\n\n\t\t// Detection belongs to Smart Paste, while Code Block contributes only\n\t\t// highlighting. Preserve those existing capabilities when adding detectors.\n\t\tconst registry = context.getService(LANGUAGE_REGISTRY_SERVICE_KEY);\n\t\tif (registry) {\n\t\t\tfor (const support of BUILTIN_LANGUAGE_SUPPORTS) {\n\t\t\t\tconst existing = registry.get(support.id);\n\t\t\t\tregistry.register(existing ? { ...existing, detection: support.detection } : support);\n\t\t\t}\n\t\t\tregistry.onRegister((support) => {\n\t\t\t\tif (support.detection) {\n\t\t\t\t\tthis.detectors.push(support.detection);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// Register config-provided detectors\n\t\tif (this.config.detectors) {\n\t\t\tfor (const detector of this.config.detectors) {\n\t\t\t\tthis.detectors.push(detector);\n\t\t\t}\n\t\t}\n\n\t\t// Register paste interceptor\n\t\tcontext.registerPasteInterceptor(this.handlePaste, { name: 'smart-paste', priority: 50 });\n\n\t\t// Register service for external detector registration\n\t\tcontext.registerService(SMART_PASTE_SERVICE_KEY, {\n\t\t\tregisterDetector: (detector: ContentDetector) => {\n\t\t\t\tthis.detectors.push(detector);\n\t\t\t},\n\t\t});\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t\tthis.detectors.length = 0;\n\t}\n\n\t// --- Paste Interceptor ---\n\n\tprivate readonly handlePaste: PasteInterceptor = (\n\t\tplainText: string,\n\t\t_html: string,\n\t\tstate: EditorState,\n\t): Transaction | null => {\n\t\tconst segments: readonly PasteSegment[] | null = splitAndClassify(plainText, this.detectors);\n\t\tif (!segments) return null;\n\n\t\t// Text that lands in a code block is pasted literally by the code block.\n\t\tconst builder: TransactionBuilder = state.transaction('paste');\n\t\tconst target: ReplacementTarget = resolveReplacementTarget(state, builder);\n\t\tif (getReceivingBlock(target)?.type === 'code_block') return null;\n\n\t\tconst paste: ReplacementPaste = { builder, target, selection: state.selection };\n\n\t\t// Single code-only segment: use existing fast path\n\t\tif (segments.length === 1 && segments[0]?.detection) {\n\t\t\treturn this.handleSingleCodeBlock(paste, segments[0].detection);\n\t\t}\n\n\t\t// Mixed content: create multiple blocks\n\t\treturn this.handleMixedContent(paste, segments);\n\t};\n\n\t// --- Single Code Block (existing behavior) ---\n\n\tprivate handleSingleCodeBlock(\n\t\tpaste: ReplacementPaste,\n\t\tdetection: DetectionResult,\n\t): Transaction | null {\n\t\tconst tr: Transaction | null = this.buildCodeBlockTransaction(paste, detection);\n\t\tif (tr && this.context) {\n\t\t\tthis.context.announce(this.locale.detectedAsCodeBlock(detection.language));\n\t\t}\n\t\treturn tr;\n\t}\n\n\tprivate buildCodeBlockTransaction(\n\t\tpaste: ReplacementPaste,\n\t\tdetection: DetectionResult,\n\t): Transaction | null {\n\t\tconst { builder, target, selection } = paste;\n\n\t\t// Create the code block node\n\t\tconst codeBlock: BlockNode = this.createCodeBlockNode(detection);\n\n\t\t// Insert at cursor (actual parent or root escape, empty anchor removal)\n\t\tif (\n\t\t\t!insertBlocksAfterAnchor(\n\t\t\t\ttarget.state,\n\t\t\t\tbuilder,\n\t\t\t\ttarget.blockId,\n\t\t\t\t[codeBlock],\n\t\t\t\tselection,\n\t\t\t\tthis.context?.getSchemaRegistry(),\n\t\t\t)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tbuilder.setSelection(createCollapsedSelection(codeBlock.id, detection.formattedText.length));\n\n\t\treturn builder.build();\n\t}\n\n\t// --- Mixed Content (multiple blocks) ---\n\n\tprivate handleMixedContent(\n\t\tpaste: ReplacementPaste,\n\t\tsegments: readonly PasteSegment[],\n\t): Transaction | null {\n\t\tconst tr: Transaction | null = this.buildMultiBlockTransaction(paste, segments);\n\t\tif (tr && this.context) {\n\t\t\tthis.announceMixedContent(segments);\n\t\t}\n\t\treturn tr;\n\t}\n\n\tprivate buildMultiBlockTransaction(\n\t\tpaste: ReplacementPaste,\n\t\tsegments: readonly PasteSegment[],\n\t): Transaction | null {\n\t\tconst { builder, selection } = paste;\n\t\tconst { state: working, blockId: anchorBlockId } = paste.target;\n\t\tconst blocks: readonly BlockNode[] = segments.map((segment) =>\n\t\t\tsegment.detection\n\t\t\t\t? this.createCodeBlockNode(segment.detection)\n\t\t\t\t: this.createParagraphNode(segment.text),\n\t\t);\n\t\tif (\n\t\t\t!insertBlocksAfterAnchor(\n\t\t\t\tworking,\n\t\t\t\tbuilder,\n\t\t\t\tanchorBlockId,\n\t\t\t\tblocks,\n\t\t\t\tselection,\n\t\t\t\tthis.context?.getSchemaRegistry(),\n\t\t\t)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst lastBlock = blocks[blocks.length - 1];\n\t\tif (lastBlock) {\n\t\t\tbuilder.setSelection(createCollapsedSelection(lastBlock.id, getBlockLength(lastBlock)));\n\t\t}\n\n\t\treturn builder.build();\n\t}\n\n\tprivate createCodeBlockNode(detection: DetectionResult): BlockNode {\n\t\treturn createBlockNode(\n\t\t\tnodeType('code_block'),\n\t\t\t[createTextNode(detection.formattedText)],\n\t\t\tgenerateBlockId(),\n\t\t\t{ language: detection.language, backgroundColor: '' },\n\t\t);\n\t}\n\n\tprivate createParagraphNode(text: string): BlockNode {\n\t\treturn createBlockNode(nodeType('paragraph'), [createTextNode(text)], generateBlockId());\n\t}\n\n\tprivate announceMixedContent(segments: readonly PasteSegment[]): void {\n\t\tlet textCount = 0;\n\t\tlet codeCount = 0;\n\t\tconst languages: string[] = [];\n\n\t\tfor (const segment of segments) {\n\t\t\tif (segment.detection) {\n\t\t\t\tcodeCount++;\n\t\t\t\tif (!languages.includes(segment.detection.language)) {\n\t\t\t\t\tlanguages.push(segment.detection.language);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttextCount++;\n\t\t\t}\n\t\t}\n\n\t\tthis.context?.announce(this.locale.detectedMixedContent(textCount, codeCount, languages));\n\t}\n}\n"],"mappings":"Y,+cAQA,IAAMiB,EAA2B,kBA8EjC,SAASC,EAASC,EAAiBC,GAClC,OAAKD,EAAEE,YAAcD,EAAEC,cACnBF,EAAEE,YAAaD,EAAEC,YAAkBF,EAAEE,UAAUC,WAAaF,EAAEC,UAAUC,QAE7E,CAGA,SAASC,EAAMJ,EAAiBC,GAC/B,MAAMI,EAAqB,GAAGL,EAAEM,WAAWL,EAAEK,OAE7C,IAAKN,EAAEE,YAAcD,EAAEC,UACtB,MAAO,CAAEI,KAAMD,EAAYH,UAAW,MAGvC,MAAMK,EAAwBP,EAAEE,UAC1BM,EAAwBP,EAAEC,UAEhC,MAAO,CACNI,KAAMD,EACNH,UAAW,CACVC,SAAUI,EAAKJ,SACfM,cAAe,GAAGF,EAAKE,oBAAoBD,EAAKC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D,qBAAqBrC,GAEpB2B,CACR,CAEA,0BAAAS,CACCb,EACAvB,GAEA,MAAMmB,QAAEA,EAAAK,UAASA,GAAcD,GACvBxB,MAAOuC,EAASN,QAASO,GAAkBhB,EAAMF,OACnDmB,EAA+BxC,EAASG,IAAKsC,GAClDA,EAAQnG,UACLsC,KAAKmD,oBAAoBU,EAAQnG,WACjCsC,KAAK8D,oBAAoBD,EAAQ/F,OAErC,IACEnB,EACA+G,EACAnB,EACAoB,EACAC,EACAhB,EACA5C,KAAKH,SAASwD,qBAGf,OAAO,KAGR,MAAMU,EAAYH,EAAOA,EAAO5C,OAAS,GAKzC,OAJI+C,GACHxB,EAAQe,aAAa7G,EAAyBsH,EAAUvE,GAAIjD,EAAewH,KAGrExB,EAAQgB,OAChB,CAEA,mBAAAJ,CAA4BzF,GAC3B,OAAOlB,EACNE,EAAS,cACT,CAACJ,EAAeoB,EAAUO,gBAC1B5B,IACA,CAAEsB,SAAUD,EAAUC,SAAUqG,gBAAiB,IAEnD,CAEA,mBAAAF,CAA4BhG,GAC3B,OAAOtB,EAAgBE,EAAS,aAAc,CAACJ,EAAewB,IAAQzB,IACvE,CAEA,oBAAAoH,CAA6BrC,GAC5B,IAAI5C,EAAY,EACZC,EAAY,EAChB,MAAMC,EAAsB,GAE5B,IAAK,MAAMmF,KAAWzC,EACjByC,EAAQnG,WACXe,IACKC,EAAUuF,SAASJ,EAAQnG,UAAUC,WACzCe,EAAUE,KAAKiF,EAAQnG,UAAUC,WAGlCa,IAIFwB,KAAKH,SAASoD,SAASjD,KAAKF,OAAOvB,qBAAqBC,EAAWC,EAAWC,GAC/E,U"}
@@ -0,0 +1,2 @@
1
+ import{s as t,t as s}from"./LocaleLoader-DEpTFuVc.mjs";import{t as o}from"./MarkInputRule-DNneF2gp.mjs";import{t as r}from"./ShortcutFormatting-TwiufqeV.mjs";import{t as i}from"./SimpleMark-DPTsIl9w.mjs";var e={label:"Strikethrough",tooltip:t=>`Strikethrough (${t})`},a=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-XmSFrtmd.mjs"),"./locales/de.ts":()=>import("./de-DViI26lG.mjs"),"./locales/es.ts":()=>import("./es-paXY7HFt.mjs"),"./locales/fr.ts":()=>import("./fr-ZsRdLuys.mjs"),"./locales/hi.ts":()=>import("./hi-CTWubxLY.mjs"),"./locales/nl.ts":()=>import("./nl-Cwl5dxFZ.mjs"),"./locales/pt.ts":()=>import("./pt-paXY7HFt.mjs"),"./locales/ru.ts":()=>import("./ru-Y11wuxOB.mjs"),"./locales/zh.ts":()=>import("./zh-C7iCgCRP.mjs")});async function l(t){return s(a,t,e)}var h={},m=class{id="strikethrough";name="Strikethrough";priority=22;config;locale;constructor(t){this.config={...h,...t}}async init(s){this.locale=await t(s,this.config.locale,e,l),i(s,{markSpec:{type:"strikethrough",rank:3,toDOM:()=>document.createElement("s"),toHTMLString:(t,s)=>`<s>${s}</s>`,parseHTML:[{tag:"s"},{tag:"strike"},{tag:"del"},{tag:"span",getAttrs:t=>!!t.style.textDecoration.includes("line-through")&&{}}],sanitize:{tags:["s"]}},command:"toggleStrikethrough",keyBinding:"Mod-Shift-X",toolbar:{id:"strikethrough",group:"format",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"/></svg>',label:this.locale.label,tooltip:this.locale.tooltip(r("Mod-Shift-X"))}}),!1!==this.config.inputRule&&s.registerInputRule(o("strikethrough","~~"))}};export{e as n,l as r,m as t};
2
+ //# sourceMappingURL=StrikethroughPlugin-CqqIF3Zk.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"StrikethroughPlugin-v-VJZzUZ.mjs","names":["loadLocaleModule","resolveLocale","createMarkInputRule","formatShortcut","registerSimpleMark","STRIKETHROUGH_LOCALE_EN","label","tooltip","shortcut","localeModules","Object","assign","async","loadStrikethroughLocale","lang","DEFAULT_CONFIG","StrikethroughPlugin","id","name","priority","config","locale","constructor","this","init","context","markSpec","type","rank","toDOM","document","createElement","toHTMLString","_mark","content","parseHTML","tag","getAttrs","el","style","textDecoration","includes","sanitize","tags","command","keyBinding","toolbar","group","icon","inputRule","registerInputRule"],"sources":["../../src/plugins/strikethrough/StrikethroughLocale.ts","../../src/plugins/strikethrough/StrikethroughPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the StrikethroughPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface StrikethroughLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const STRIKETHROUGH_LOCALE_EN: StrikethroughLocale = {\n\tlabel: 'Strikethrough',\n\ttooltip: (shortcut: string) => `Strikethrough (${shortcut})`,\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<StrikethroughLocale> = import.meta.glob<{\n\tdefault: StrikethroughLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadStrikethroughLocale(lang: string): Promise<StrikethroughLocale> {\n\treturn loadLocaleModule(localeModules, lang, STRIKETHROUGH_LOCALE_EN);\n}\n","/**\n * StrikethroughPlugin: registers a strikethrough inline mark with MarkSpec,\n * toggle command, keyboard shortcut (Mod-Shift-X), and a toolbar button.\n */\n\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { createMarkInputRule } from '../shared/MarkInputRule.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { formatShortcut } from '../shared/ShortcutFormatting.js';\nimport { registerSimpleMark } from '../shared/SimpleMark.js';\nimport {\n\tSTRIKETHROUGH_LOCALE_EN,\n\ttype StrikethroughLocale,\n\tloadStrikethroughLocale,\n} from './StrikethroughLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tstrikethrough: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\nexport interface StrikethroughConfig {\n\t/** Live Markdown shortcut: `~~x~~` to strikethrough. Default true. */\n\treadonly inputRule?: boolean;\n\treadonly locale?: StrikethroughLocale;\n}\n\nconst DEFAULT_CONFIG: StrikethroughConfig = {};\n\n// --- Plugin ---\n\nexport class StrikethroughPlugin implements Plugin {\n\treadonly id = 'strikethrough';\n\treadonly name = 'Strikethrough';\n\treadonly priority = 22;\n\n\tprivate readonly config: StrikethroughConfig;\n\tprivate locale!: StrikethroughLocale;\n\n\tconstructor(config?: Partial<StrikethroughConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSTRIKETHROUGH_LOCALE_EN,\n\t\t\tloadStrikethroughLocale,\n\t\t);\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z\"/></svg>';\n\n\t\tregisterSimpleMark(context, {\n\t\t\tmarkSpec: {\n\t\t\t\ttype: 'strikethrough',\n\t\t\t\trank: 3,\n\t\t\t\ttoDOM() {\n\t\t\t\t\treturn document.createElement('s');\n\t\t\t\t},\n\t\t\t\ttoHTMLString: (_mark, content) => `<s>${content}</s>`,\n\t\t\t\tparseHTML: [\n\t\t\t\t\t{ tag: 's' },\n\t\t\t\t\t{ tag: 'strike' },\n\t\t\t\t\t{ tag: 'del' },\n\t\t\t\t\t{\n\t\t\t\t\t\ttag: 'span',\n\t\t\t\t\t\tgetAttrs: (el: HTMLElement) => {\n\t\t\t\t\t\t\treturn el.style.textDecoration.includes('line-through') ? {} : false;\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tsanitize: { tags: ['s'] },\n\t\t\t},\n\t\t\tcommand: 'toggleStrikethrough',\n\t\t\tkeyBinding: 'Mod-Shift-X',\n\t\t\ttoolbar: {\n\t\t\t\tid: 'strikethrough',\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon,\n\t\t\t\tlabel: this.locale.label,\n\t\t\t\ttooltip: this.locale.tooltip(formatShortcut('Mod-Shift-X')),\n\t\t\t},\n\t\t});\n\n\t\tif (this.config.inputRule !== false) {\n\t\t\tcontext.registerInputRule(createMarkInputRule('strikethrough', '~~'));\n\t\t}\n\t}\n}\n"],"mappings":"Y,iMAeA,IAAaK,EAA+C,CAC3DC,MAAO,gBACPC,QAAUC,GAAqB,kBAAkBA,MAK5CC,iBAAsDC,OAAAC,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAI5DC,eAAsBC,EAAwBC,GAC7C,OAAOd,EAAiBS,EAAeK,EAAMT,EAC9C,CCIA,IAAMU,EAAsC,CAAC,EAIhCC,EAAb,MACCC,GAAc,gBACdC,KAAgB,gBAChBC,SAAoB,GAEpBC,OACAC,OAEA,WAAAC,CAAYF,GACXG,KAAKH,OAAS,IAAKL,KAAmBK,EACvC,CAEA,UAAMI,CAAKC,GACVF,KAAKF,aAAepB,EACnBwB,EACAF,KAAKH,OAAOC,OACZhB,EACAQ,GAKDT,EAAmBqB,EAAS,CAC3BC,SAAU,CACTC,KAAM,gBACNC,KAAM,EACNC,MAAA,IACQC,SAASC,cAAc,KAE/BC,aAAA,CAAeC,EAAOC,IAAY,MAAMA,QACxCC,UAAW,CACV,CAAEC,IAAK,KACP,CAAEA,IAAK,UACP,CAAEA,IAAK,OACP,CACCA,IAAK,OACLC,SAAWC,KACHA,EAAGC,MAAMC,eAAeC,SAAS,iBAAkB,CAAC,IAI9DC,SAAU,CAAEC,KAAM,CAAC,OAEpBC,QAAS,sBACTC,WAAY,cACZC,QAAS,CACR7B,GAAI,gBACJ8B,MAAO,SACPC,KAAA,uIACA1C,MAAOiB,KAAKF,OAAOf,MACnBC,QAASgB,KAAKF,OAAOd,QAAQJ,EAAe,oBAIhB,IAA1BoB,KAAKH,OAAO6B,WACfxB,EAAQyB,kBAAkBhD,EAAoB,gBAAiB,MAEjE,U"}
1
+ {"version":3,"file":"StrikethroughPlugin-CqqIF3Zk.mjs","names":["resolveLocale","loadLocaleModule","createMarkInputRule","formatShortcut","registerSimpleMark","STRIKETHROUGH_LOCALE_EN","label","tooltip","shortcut","localeModules","Object","assign","async","loadStrikethroughLocale","lang","DEFAULT_CONFIG","StrikethroughPlugin","id","name","priority","config","locale","constructor","this","init","context","markSpec","type","rank","toDOM","document","createElement","toHTMLString","_mark","content","parseHTML","tag","getAttrs","el","style","textDecoration","includes","sanitize","tags","command","keyBinding","toolbar","group","icon","inputRule","registerInputRule"],"sources":["../../src/plugins/strikethrough/StrikethroughLocale.ts","../../src/plugins/strikethrough/StrikethroughPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the StrikethroughPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface StrikethroughLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const STRIKETHROUGH_LOCALE_EN: StrikethroughLocale = {\n\tlabel: 'Strikethrough',\n\ttooltip: (shortcut: string) => `Strikethrough (${shortcut})`,\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<StrikethroughLocale> = import.meta.glob<{\n\tdefault: StrikethroughLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadStrikethroughLocale(lang: string): Promise<StrikethroughLocale> {\n\treturn loadLocaleModule(localeModules, lang, STRIKETHROUGH_LOCALE_EN);\n}\n","/**\n * StrikethroughPlugin: registers a strikethrough inline mark with MarkSpec,\n * toggle command, keyboard shortcut (Mod-Shift-X), and a toolbar button.\n */\n\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { createMarkInputRule } from '../shared/MarkInputRule.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { formatShortcut } from '../shared/ShortcutFormatting.js';\nimport { registerSimpleMark } from '../shared/SimpleMark.js';\nimport {\n\tSTRIKETHROUGH_LOCALE_EN,\n\ttype StrikethroughLocale,\n\tloadStrikethroughLocale,\n} from './StrikethroughLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tstrikethrough: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\nexport interface StrikethroughConfig {\n\t/** Live Markdown shortcut: `~~x~~` to strikethrough. Default true. */\n\treadonly inputRule?: boolean;\n\treadonly locale?: StrikethroughLocale;\n}\n\nconst DEFAULT_CONFIG: StrikethroughConfig = {};\n\n// --- Plugin ---\n\nexport class StrikethroughPlugin implements Plugin {\n\treadonly id = 'strikethrough';\n\treadonly name = 'Strikethrough';\n\treadonly priority = 22;\n\n\tprivate readonly config: StrikethroughConfig;\n\tprivate locale!: StrikethroughLocale;\n\n\tconstructor(config?: Partial<StrikethroughConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSTRIKETHROUGH_LOCALE_EN,\n\t\t\tloadStrikethroughLocale,\n\t\t);\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z\"/></svg>';\n\n\t\tregisterSimpleMark(context, {\n\t\t\tmarkSpec: {\n\t\t\t\ttype: 'strikethrough',\n\t\t\t\trank: 3,\n\t\t\t\ttoDOM() {\n\t\t\t\t\treturn document.createElement('s');\n\t\t\t\t},\n\t\t\t\ttoHTMLString: (_mark, content) => `<s>${content}</s>`,\n\t\t\t\tparseHTML: [\n\t\t\t\t\t{ tag: 's' },\n\t\t\t\t\t{ tag: 'strike' },\n\t\t\t\t\t{ tag: 'del' },\n\t\t\t\t\t{\n\t\t\t\t\t\ttag: 'span',\n\t\t\t\t\t\tgetAttrs: (el: HTMLElement) => {\n\t\t\t\t\t\t\treturn el.style.textDecoration.includes('line-through') ? {} : false;\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tsanitize: { tags: ['s'] },\n\t\t\t},\n\t\t\tcommand: 'toggleStrikethrough',\n\t\t\tkeyBinding: 'Mod-Shift-X',\n\t\t\ttoolbar: {\n\t\t\t\tid: 'strikethrough',\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon,\n\t\t\t\tlabel: this.locale.label,\n\t\t\t\ttooltip: this.locale.tooltip(formatShortcut('Mod-Shift-X')),\n\t\t\t},\n\t\t});\n\n\t\tif (this.config.inputRule !== false) {\n\t\t\tcontext.registerInputRule(createMarkInputRule('strikethrough', '~~'));\n\t\t}\n\t}\n}\n"],"mappings":"Y,gMAeA,IAAaK,EAA+C,CAC3DC,MAAO,gBACPC,QAAUC,GAAqB,kBAAkBA,MAK5CC,iBAAsDC,OAAAC,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAI5DC,eAAsBC,EAAwBC,GAC7C,OAAOb,EAAiBQ,EAAeK,EAAMT,EAC9C,CCIA,IAAMU,EAAsC,CAAC,EAIhCC,EAAb,MACCC,GAAc,gBACdC,KAAgB,gBAChBC,SAAoB,GAEpBC,OACAC,OAEA,WAAAC,CAAYF,GACXG,KAAKH,OAAS,IAAKL,KAAmBK,EACvC,CAEA,UAAMI,CAAKC,GACVF,KAAKF,aAAerB,EACnByB,EACAF,KAAKH,OAAOC,OACZhB,EACAQ,GAKDT,EAAmBqB,EAAS,CAC3BC,SAAU,CACTC,KAAM,gBACNC,KAAM,EACNC,MAAA,IACQC,SAASC,cAAc,KAE/BC,aAAA,CAAeC,EAAOC,IAAY,MAAMA,QACxCC,UAAW,CACV,CAAEC,IAAK,KACP,CAAEA,IAAK,UACP,CAAEA,IAAK,OACP,CACCA,IAAK,OACLC,SAAWC,KACHA,EAAGC,MAAMC,eAAeC,SAAS,iBAAkB,CAAC,IAI9DC,SAAU,CAAEC,KAAM,CAAC,OAEpBC,QAAS,sBACTC,WAAY,cACZC,QAAS,CACR7B,GAAI,gBACJ8B,MAAO,SACPC,KAAA,uIACA1C,MAAOiB,KAAKF,OAAOf,MACnBC,QAASgB,KAAKF,OAAOd,QAAQJ,EAAe,oBAIhB,IAA1BoB,KAAKH,OAAO6B,WACfxB,EAAQyB,kBAAkBhD,EAAoB,gBAAiB,MAEjE,U"}
@@ -0,0 +1,2 @@
1
+ import{i as s}from"./TypeBrands-Ch9856Gb.mjs";import{i as t,t as e}from"./MarkCommands-C0ps9h0z.mjs";import{c as i,r,s as o,t as p}from"./LocaleLoader-DEpTFuVc.mjs";import{t as c}from"./ShortcutFormatting-TwiufqeV.mjs";var a={superscriptLabel:"Superscript",superscriptTooltip:s=>`Superscript (${s})`,subscriptLabel:"Subscript",subscriptTooltip:s=>`Subscript (${s})`},n=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-NV_puwI2.mjs"),"./locales/de.ts":()=>import("./de-BX4y4PlH.mjs"),"./locales/es.ts":()=>import("./es-BdpTTRuX.mjs"),"./locales/fr.ts":()=>import("./fr-CKjH6tJI.mjs"),"./locales/hi.ts":()=>import("./hi-DsdXcOB6.mjs"),"./locales/nl.ts":()=>import("./nl-xfiNOCgg.mjs"),"./locales/pt.ts":()=>import("./pt-OXa_IR4Q.mjs"),"./locales/ru.ts":()=>import("./ru-d68SZpEe.mjs"),"./locales/zh.ts":()=>import("./zh-BP97XjlS.mjs")});async function l(s){return p(n,s,a)}var u={superscript:!0,subscript:!0},m=[{type:"superscript",opposite:"subscript",configKey:"superscript",rank:4,tag:"sup",icon:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">','<path d="M16 7.41L11.41 12 16 16.59 14.59 18l-6-6 6-6z"',' fill="none"/>','<path d="M9.64 7.64c.23-.5.36-1.05.36-1.64'," 0-2.21-1.79-4-4-4H2v14h4.36c2.34 0 4.24-1.9"," 4.24-4.24 0-1.6-.89-2.99-2.2-3.71zM4.5 4.5H6c.83"," 0 1.5.67 1.5 1.5S6.83 7.5 6 7.5H4.5v-3zm2 9H4.5v-3H6.5c.83",' 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z" fill="none"/>','<path d="M15.97 3.84c0-.47.19-.91.53-1.21.34-.31.8-.49'," 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02","-.96-.43-1.83-1.13-2.42C19.36.77 18.45.44 17.5.44c-.88"," 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34"," 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53"," 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54","-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96"," 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56","-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46",'-.59-.46-.94z"/>','<path d="M5.88 20h2.66l3.4-5.42L15.3 20h2.67l-4.73-7.38',' 4.37-6.62h-2.6l-3.07 4.98L8.92 6h-2.6l4.26 6.58z"/>',"</svg>"].join(""),keyBinding:"Mod-.",toHTMLString:s=>`<sup>${s}</sup>`,parseHTML:[{tag:"sup"}],sanitize:{tags:["sup"]}},{type:"subscript",opposite:"superscript",configKey:"subscript",rank:4,tag:"sub",icon:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">','<path d="M15.97 16.84c0-.47.19-.91.53-1.21.34-.31.8-.49'," 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02","-.96-.43-1.83-1.13-2.42-.7-.58-1.61-.91-2.56-.91-.88"," 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34"," 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53"," 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54","-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96"," 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56","-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46",'-.59-.46-.94z"/>','<path d="M5.88 18h2.66l3.4-5.42L15.3 18h2.67l-4.73-7.38',' 4.37-6.62h-2.6l-3.07 4.98L8.92 4h-2.6l4.26 6.58z"/>',"</svg>"].join(""),keyBinding:"Mod-,",toHTMLString:s=>`<sub>${s}</sub>`,parseHTML:[{tag:"sub"}],sanitize:{tags:["sub"]}}],g=class{id="super-sub";name="Superscript & Subscript";priority=23;config;locale;constructor(s){this.config={...u,...s}}async init(s){this.locale=await o(s,this.config.locale,a,l);const t=m.filter(s=>this.config[s.configKey]);for(const e of t)this.registerMark(s,e);this.registerKeymaps(s,t),this.registerExclusivityMiddleware(s,t),this.registerDisabledToolbarItems(s)}registerMark(o,p){const a=i(p.type),n=this.isToolbarVisible(p.configKey);if(o.registerMarkSpec({type:p.type,rank:p.rank,toDOM:()=>document.createElement(p.tag),toHTMLString:(s,t)=>p.toHTMLString(t),parseHTML:p.parseHTML,sanitize:p.sanitize}),o.registerCommand(a,()=>r(o,t(o.getState(),s(p.type)))),n){const t="superscript"===p.type?this.locale.superscriptLabel:this.locale.subscriptLabel,i="superscript"===p.type?this.locale.superscriptTooltip(c(p.keyBinding)):this.locale.subscriptTooltip(c(p.keyBinding));o.registerToolbarItem({id:p.type,group:"format",icon:p.icon,label:t,tooltip:i,command:a,isActive:t=>e(t,s(p.type))})}}registerKeymaps(s,t){const e={};for(const r of t){const t=i(r.type);e[r.keyBinding]=()=>s.executeCommand(t)}Object.keys(e).length>0&&s.registerKeymap(e)}registerExclusivityMiddleware(t,e){e.some(s=>"superscript"===s.type)&&e.some(s=>"subscript"===s.type)&&t.registerMiddleware((t,e,i)=>{let r=!1;const o=[];for(const c of t.steps){if("addMark"!==c.type){o.push(c);continue}const t=c.mark.type,e=m.find(s=>s.type===t);if(!e){o.push(c);continue}r=!0;const i={type:"removeMark",blockId:c.blockId,from:c.from,to:c.to,mark:{type:s(e.opposite)},...c.path?{path:c.path}:{}};o.push(i,c)}let p=t.storedMarksAfter;if(p){const s=p.some(s=>"superscript"===s.type),t=p.some(s=>"subscript"===s.type);if(s&&t){const s=p.findLastIndex(s=>"superscript"===s.type)>p.findLastIndex(s=>"subscript"===s.type)?"subscript":"superscript";p=p.filter(t=>t.type!==s),r=!0}}i(r?{...t,steps:o,storedMarksAfter:p}:t)},{name:"super-sub:exclusivity"})}registerDisabledToolbarItems(s){if(this.config.toolbar)for(const t of m){const e=this.config[t.configKey],r=this.config.toolbar[t.configKey]??!0;if(!e&&r){const e="superscript"===t.type?this.locale.superscriptLabel:this.locale.subscriptLabel;s.registerToolbarItem({id:t.type,group:"format",icon:t.icon,label:e,command:i(t.type),isEnabled:()=>!1})}}}isToolbarVisible(s){return!this.config.toolbar||(this.config.toolbar[s]??!0)}};export{a as n,l as r,g as t};
2
+ //# sourceMappingURL=SuperSubPlugin-5ZFM6wdU.mjs.map