@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.
- package/dist/chunks/AlignmentPlugin-C26pIVcw.mjs +2 -0
- package/dist/chunks/{AlignmentPlugin-Cp7HYGaH.mjs.map → AlignmentPlugin-C26pIVcw.mjs.map} +1 -1
- package/dist/chunks/BidiIsolationPlugin-nWd1NEF-.mjs +2 -0
- package/dist/chunks/{BidiIsolationPlugin-GWukKdgJ.mjs.map → BidiIsolationPlugin-nWd1NEF-.mjs.map} +1 -1
- package/dist/chunks/BlockquotePlugin-Bag42Zc0.mjs +2 -0
- package/dist/chunks/{BlockquotePlugin-CSL_7Yit.mjs.map → BlockquotePlugin-Bag42Zc0.mjs.map} +1 -1
- package/dist/chunks/CaretNavigationPlugin-DUAoHygg.mjs +2 -0
- package/dist/chunks/{CaretNavigationPlugin-BQPqqK4n.mjs.map → CaretNavigationPlugin-DUAoHygg.mjs.map} +1 -1
- package/dist/chunks/CodeBlockPlugin-Dk_J8NAl.mjs +2 -0
- package/dist/chunks/{CodeBlockPlugin-B4AcDJRK.mjs.map → CodeBlockPlugin-Dk_J8NAl.mjs.map} +1 -1
- package/dist/chunks/Commands-vqbwh6Ic.mjs +2 -0
- package/dist/chunks/{Commands-Bk7Cl1nH.mjs.map → Commands-vqbwh6Ic.mjs.map} +1 -1
- package/dist/chunks/DocumentParser-D4g5npEi.mjs +2 -0
- package/dist/chunks/DocumentParser-D4g5npEi.mjs.map +1 -0
- package/dist/chunks/EditorUI-DrQI95FW.mjs +2 -0
- package/dist/chunks/EditorUI-DrQI95FW.mjs.map +1 -0
- package/dist/chunks/FontPlugin-Bzlluh1_.mjs +2 -0
- package/dist/chunks/{FontPlugin-BcXNFqqO.mjs.map → FontPlugin-Bzlluh1_.mjs.map} +1 -1
- package/dist/chunks/FontSizePlugin-kv3zHG0f.mjs +2 -0
- package/dist/chunks/{FontSizePlugin-Dswra3oU.mjs.map → FontSizePlugin-kv3zHG0f.mjs.map} +1 -1
- package/dist/chunks/FormulaPlugin-20vW4Gge.mjs +2 -0
- package/dist/chunks/{FormulaPlugin-DVpLaKi5.mjs.map → FormulaPlugin-20vW4Gge.mjs.map} +1 -1
- package/dist/chunks/GapCursorPlugin-BPyNXY4H.mjs +2 -0
- package/dist/chunks/{GapCursorPlugin-QDGwnaRR.mjs.map → GapCursorPlugin-BPyNXY4H.mjs.map} +1 -1
- package/dist/chunks/HTMLSanitization-BRipXyhI.mjs +2 -0
- package/dist/chunks/HTMLSanitization-BRipXyhI.mjs.map +1 -0
- package/dist/chunks/{HardBreakPlugin-gjCq8prD.mjs → HardBreakPlugin-lo8Mcg9G.mjs} +2 -2
- package/dist/chunks/{HardBreakPlugin-gjCq8prD.mjs.map → HardBreakPlugin-lo8Mcg9G.mjs.map} +1 -1
- package/dist/chunks/HeadingPlugin-CEZF5DBM.mjs +2 -0
- package/dist/chunks/{HeadingPlugin-B7EfynaH.mjs.map → HeadingPlugin-CEZF5DBM.mjs.map} +1 -1
- package/dist/chunks/HighlightPlugin-yH44UWoe.mjs +2 -0
- package/dist/chunks/{HighlightPlugin-LdO0INtJ.mjs.map → HighlightPlugin-yH44UWoe.mjs.map} +1 -1
- package/dist/chunks/HorizontalRulePlugin-SNNum-9V.mjs +2 -0
- package/dist/chunks/{HorizontalRulePlugin-YywXVZYr.mjs.map → HorizontalRulePlugin-SNNum-9V.mjs.map} +1 -1
- package/dist/chunks/ImagePlugin-aeqHr5zx.mjs +2 -0
- package/dist/chunks/{ImagePlugin-BAhZuVdE.mjs.map → ImagePlugin-aeqHr5zx.mjs.map} +1 -1
- package/dist/chunks/InlineCodePlugin-CIks06ti.mjs +2 -0
- package/dist/chunks/{InlineCodePlugin-Bu9-rE4B.mjs.map → InlineCodePlugin-CIks06ti.mjs.map} +1 -1
- package/dist/chunks/LinkPlugin-CFw22a9X.mjs +2 -0
- package/dist/chunks/LinkPlugin-CFw22a9X.mjs.map +1 -0
- package/dist/chunks/ListPlugin-ZNEx8pvk.mjs +2 -0
- package/dist/chunks/{ListPlugin-U1r4p_fE.mjs.map → ListPlugin-ZNEx8pvk.mjs.map} +1 -1
- package/dist/chunks/LocaleLoader-DEpTFuVc.mjs +2 -0
- package/dist/chunks/LocaleLoader-DEpTFuVc.mjs.map +1 -0
- package/dist/chunks/{MarkdownHTMLRegistry-BunUDiza.mjs → MarkdownHTMLRegistry-Cj7N2wqs.mjs} +2 -2
- package/dist/chunks/{MarkdownHTMLRegistry-BunUDiza.mjs.map → MarkdownHTMLRegistry-Cj7N2wqs.mjs.map} +1 -1
- package/dist/chunks/{MarkdownParser-uX1p_GQk.mjs → MarkdownParser-JOfPSvGv.mjs} +2 -2
- package/dist/chunks/{MarkdownParser-uX1p_GQk.mjs.map → MarkdownParser-JOfPSvGv.mjs.map} +1 -1
- package/dist/chunks/{MarkdownSerializer--MrgJTdJ.mjs → MarkdownSerializer-Y6saYClE.mjs} +2 -2
- package/dist/chunks/{MarkdownSerializer--MrgJTdJ.mjs.map → MarkdownSerializer-Y6saYClE.mjs.map} +1 -1
- package/dist/chunks/PopupManager-DpxoBl54.mjs +2 -0
- package/dist/chunks/PopupManager-DpxoBl54.mjs.map +1 -0
- package/dist/chunks/PopupPositioning-CIqgpqlW.mjs.map +1 -1
- package/dist/chunks/PrintPlugin-CYkdUy-m.mjs +2 -0
- package/dist/chunks/{PrintPlugin-DAEiEyKQ.mjs.map → PrintPlugin-CYkdUy-m.mjs.map} +1 -1
- package/dist/chunks/{SchemaRegistry-Cs7rxafF.mjs → SchemaRegistry-CT3T7S1i.mjs} +2 -2
- package/dist/chunks/{SchemaRegistry-Cs7rxafF.mjs.map → SchemaRegistry-CT3T7S1i.mjs.map} +1 -1
- package/dist/chunks/{SelectionReplacement-vC1xhFS0.mjs → SelectionReplacement-Cj4FLlPz.mjs} +2 -2
- package/dist/chunks/{SelectionReplacement-vC1xhFS0.mjs.map → SelectionReplacement-Cj4FLlPz.mjs.map} +1 -1
- package/dist/chunks/{SelectionSync-BkjCwGp-.mjs → SelectionSync-8y0nbBHZ.mjs} +2 -2
- package/dist/chunks/{SelectionSync-BkjCwGp-.mjs.map → SelectionSync-8y0nbBHZ.mjs.map} +1 -1
- package/dist/chunks/SimpleMark-DPTsIl9w.mjs +2 -0
- package/dist/chunks/{SimpleMark-D6vz3Nfd.mjs.map → SimpleMark-DPTsIl9w.mjs.map} +1 -1
- package/dist/chunks/SmartPastePlugin-BSMHDDQ2.mjs +2 -0
- package/dist/chunks/{SmartPastePlugin-BHsYKbgd.mjs.map → SmartPastePlugin-BSMHDDQ2.mjs.map} +1 -1
- package/dist/chunks/StrikethroughPlugin-CqqIF3Zk.mjs +2 -0
- package/dist/chunks/{StrikethroughPlugin-v-VJZzUZ.mjs.map → StrikethroughPlugin-CqqIF3Zk.mjs.map} +1 -1
- package/dist/chunks/SuperSubPlugin-5ZFM6wdU.mjs +2 -0
- package/dist/chunks/{SuperSubPlugin-x1iPnZyt.mjs.map → SuperSubPlugin-5ZFM6wdU.mjs.map} +1 -1
- package/dist/chunks/{TableDimensions-BSEOEox2.mjs → TableDimensions-B-OWjTuW.mjs} +2 -2
- package/dist/chunks/{TableDimensions-BSEOEox2.mjs.map → TableDimensions-B-OWjTuW.mjs.map} +1 -1
- package/dist/chunks/TablePlugin-D1Wg-pjl.mjs +2 -0
- package/dist/chunks/TablePlugin-D1Wg-pjl.mjs.map +1 -0
- package/dist/chunks/TableSelectionTypes-t2cLhe16.mjs +2 -0
- package/dist/chunks/TableSelectionTypes-t2cLhe16.mjs.map +1 -0
- package/dist/chunks/TextColorPlugin-Dwp7eW7F.mjs +2 -0
- package/dist/chunks/{TextColorPlugin-Bnl9of9E.mjs.map → TextColorPlugin-Dwp7eW7F.mjs.map} +1 -1
- package/dist/chunks/{TextDirectionAutoPlugin-DOH5cfyy.mjs → TextDirectionAutoPlugin-CkIETM5n.mjs} +2 -2
- package/dist/chunks/{TextDirectionAutoPlugin-DOH5cfyy.mjs.map → TextDirectionAutoPlugin-CkIETM5n.mjs.map} +1 -1
- package/dist/chunks/TextDirectionPlugin-DAcPR5Qc.mjs +2 -0
- package/dist/chunks/{TextDirectionPlugin-JwlR-R-b.mjs.map → TextDirectionPlugin-DAcPR5Qc.mjs.map} +1 -1
- package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +2 -0
- package/dist/chunks/{TextDirectionService-BcX07mw2.mjs.map → TextDirectionService-OFOU6r_s.mjs.map} +1 -1
- package/dist/chunks/TextFormattingPlugin-vml-lduV.mjs +2 -0
- package/dist/chunks/{TextFormattingPlugin-Kc_UNoOz.mjs.map → TextFormattingPlugin-vml-lduV.mjs.map} +1 -1
- package/dist/chunks/ToolbarPlugin-Cxmb0MFr.mjs +2 -0
- package/dist/chunks/ToolbarPlugin-Cxmb0MFr.mjs.map +1 -0
- package/dist/chunks/VideoPlugin-lZCBlIon.mjs +2 -0
- package/dist/chunks/{VideoPlugin-DJXfuNA9.mjs.map → VideoPlugin-lZCBlIon.mjs.map} +1 -1
- package/dist/chunks/ar-Dp1oBWyG.mjs +2 -0
- package/dist/chunks/ar-Dp1oBWyG.mjs.map +1 -0
- package/dist/chunks/de-D3J8XPCR.mjs +2 -0
- package/dist/chunks/de-D3J8XPCR.mjs.map +1 -0
- package/dist/chunks/es-Bbz885DZ.mjs +2 -0
- package/dist/chunks/es-Bbz885DZ.mjs.map +1 -0
- package/dist/chunks/fr-GEgM1j3w.mjs +2 -0
- package/dist/chunks/fr-GEgM1j3w.mjs.map +1 -0
- package/dist/chunks/full-wDTdOuGt.mjs +2 -0
- package/dist/chunks/{full-BsWAZr1w.mjs.map → full-wDTdOuGt.mjs.map} +1 -1
- package/dist/chunks/hi-CKg8i4Mm.mjs +2 -0
- package/dist/chunks/hi-CKg8i4Mm.mjs.map +1 -0
- package/dist/chunks/minimal-FfmHwMGU.mjs +2 -0
- package/dist/chunks/{minimal-DO7LiFTa.mjs.map → minimal-FfmHwMGU.mjs.map} +1 -1
- package/dist/chunks/nl-2IdjTNeJ.mjs +2 -0
- package/dist/chunks/nl-2IdjTNeJ.mjs.map +1 -0
- package/dist/chunks/nl-B1i04NvZ.mjs +2 -0
- package/dist/chunks/nl-B1i04NvZ.mjs.map +1 -0
- package/dist/chunks/nl-BEmzpzKO.mjs +2 -0
- package/dist/chunks/nl-BEmzpzKO.mjs.map +1 -0
- package/dist/chunks/nl-B_U0D3Qq.mjs +2 -0
- package/dist/chunks/nl-B_U0D3Qq.mjs.map +1 -0
- package/dist/chunks/nl-C437Xz6z.mjs +2 -0
- package/dist/chunks/nl-C437Xz6z.mjs.map +1 -0
- package/dist/chunks/nl-C5P8Fogm.mjs +2 -0
- package/dist/chunks/nl-C5P8Fogm.mjs.map +1 -0
- package/dist/chunks/nl-CST62bzx.mjs +2 -0
- package/dist/chunks/nl-CST62bzx.mjs.map +1 -0
- package/dist/chunks/nl-CWQT-W-6.mjs +2 -0
- package/dist/chunks/nl-CWQT-W-6.mjs.map +1 -0
- package/dist/chunks/nl-CdpcDkbM.mjs +2 -0
- package/dist/chunks/nl-CdpcDkbM.mjs.map +1 -0
- package/dist/chunks/nl-CgYWZnga.mjs +2 -0
- package/dist/chunks/nl-CgYWZnga.mjs.map +1 -0
- package/dist/chunks/nl-Cr--x8bX.mjs +2 -0
- package/dist/chunks/nl-Cr--x8bX.mjs.map +1 -0
- package/dist/chunks/nl-Cwl5dxFZ.mjs +2 -0
- package/dist/chunks/nl-Cwl5dxFZ.mjs.map +1 -0
- package/dist/chunks/nl-Czjd9Bw9.mjs +2 -0
- package/dist/chunks/nl-Czjd9Bw9.mjs.map +1 -0
- package/dist/chunks/nl-DUOT2ZMQ.mjs +2 -0
- package/dist/chunks/nl-DUOT2ZMQ.mjs.map +1 -0
- package/dist/chunks/nl-DYnRYvZ5.mjs +2 -0
- package/dist/chunks/nl-DYnRYvZ5.mjs.map +1 -0
- package/dist/chunks/nl-DaNJ-ffX.mjs +2 -0
- package/dist/chunks/nl-DaNJ-ffX.mjs.map +1 -0
- package/dist/chunks/nl-DeOJ64xy.mjs +2 -0
- package/dist/chunks/nl-DeOJ64xy.mjs.map +1 -0
- package/dist/chunks/nl-DwZajfpP.mjs +2 -0
- package/dist/chunks/nl-DwZajfpP.mjs.map +1 -0
- package/dist/chunks/nl-Dyjc9M7o.mjs +2 -0
- package/dist/chunks/nl-Dyjc9M7o.mjs.map +1 -0
- package/dist/chunks/nl-GBpv7W4L.mjs +2 -0
- package/dist/chunks/nl-GBpv7W4L.mjs.map +1 -0
- package/dist/chunks/nl-HFfWJOEo.mjs +2 -0
- package/dist/chunks/nl-HFfWJOEo.mjs.map +1 -0
- package/dist/chunks/nl-KqmiCeD7.mjs +2 -0
- package/dist/chunks/nl-KqmiCeD7.mjs.map +1 -0
- package/dist/chunks/nl-_QT7e2Qt.mjs +2 -0
- package/dist/chunks/nl-_QT7e2Qt.mjs.map +1 -0
- package/dist/chunks/nl-i79IajbC.mjs +2 -0
- package/dist/chunks/nl-i79IajbC.mjs.map +1 -0
- package/dist/chunks/nl-lcZvrAz6.mjs +2 -0
- package/dist/chunks/nl-lcZvrAz6.mjs.map +1 -0
- package/dist/chunks/nl-tWJ2imhe.mjs +2 -0
- package/dist/chunks/nl-tWJ2imhe.mjs.map +1 -0
- package/dist/chunks/nl-xfiNOCgg.mjs +2 -0
- package/dist/chunks/nl-xfiNOCgg.mjs.map +1 -0
- package/dist/chunks/pt-DP5c76Vo.mjs +2 -0
- package/dist/chunks/pt-DP5c76Vo.mjs.map +1 -0
- package/dist/chunks/register-DSRtHVkk.mjs +3 -0
- package/dist/chunks/register-DSRtHVkk.mjs.map +1 -0
- package/dist/chunks/ru--iYEtsT5.mjs +2 -0
- package/dist/chunks/ru--iYEtsT5.mjs.map +1 -0
- package/dist/chunks/src-DDkRstYh.mjs +2 -0
- package/dist/chunks/src-DDkRstYh.mjs.map +1 -0
- package/dist/chunks/zh-DUS7JduA.mjs +2 -0
- package/dist/chunks/zh-DUS7JduA.mjs.map +1 -0
- package/dist/commands/Commands.d.ts +3 -0
- package/dist/commands/Commands.d.ts.map +1 -1
- package/dist/commands/CompositionCommands.d.ts +14 -8
- package/dist/commands/CompositionCommands.d.ts.map +1 -1
- package/dist/commands/CompositionFallback.d.ts +13 -0
- package/dist/commands/CompositionFallback.d.ts.map +1 -0
- package/dist/commands/CompositionRebase.d.ts +17 -10
- package/dist/commands/CompositionRebase.d.ts.map +1 -1
- package/dist/editor/locales/nl.d.ts +4 -0
- package/dist/editor/locales/nl.d.ts.map +1 -0
- package/dist/editor/styles/link.d.ts +2 -2
- package/dist/editor/styles/link.d.ts.map +1 -1
- package/dist/fonts.mjs +1 -1
- package/dist/full.mjs +1 -1
- package/dist/html.mjs +1 -1
- package/dist/i18n/Locale.d.ts +1 -0
- package/dist/i18n/Locale.d.ts.map +1 -1
- package/dist/input/CompositionController.d.ts.map +1 -1
- package/dist/input/HTMLLineBreaks.d.ts +14 -0
- package/dist/input/HTMLLineBreaks.d.ts.map +1 -0
- package/dist/input/HTMLParser.d.ts +1 -7
- package/dist/input/HTMLParser.d.ts.map +1 -1
- package/dist/input/PasteHTMLHandler.d.ts +0 -1
- package/dist/input/PasteHTMLHandler.d.ts.map +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/notectl-core.mjs +1 -1
- package/dist/notectl-core.umd.js +1 -1
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginContextFactory.d.ts +1 -0
- package/dist/plugins/PluginContextFactory.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +5 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/locales/nl.d.ts +4 -0
- package/dist/plugins/alignment/locales/nl.d.ts.map +1 -0
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/bidi-isolation/locales/nl.d.ts +4 -0
- package/dist/plugins/bidi-isolation/locales/nl.d.ts.map +1 -0
- package/dist/plugins/bidi-isolation.mjs +1 -1
- package/dist/plugins/blockquote/locales/nl.d.ts +4 -0
- package/dist/plugins/blockquote/locales/nl.d.ts.map +1 -0
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation/locales/nl.d.ts +4 -0
- package/dist/plugins/caret-navigation/locales/nl.d.ts.map +1 -0
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/locales/nl.d.ts +4 -0
- package/dist/plugins/code-block/locales/nl.d.ts.map +1 -0
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/editor-ui/EditorUI.d.ts +50 -0
- package/dist/plugins/editor-ui/EditorUI.d.ts.map +1 -0
- package/dist/plugins/editor-ui/EditorUIRuntime.d.ts +44 -0
- package/dist/plugins/editor-ui/EditorUIRuntime.d.ts.map +1 -0
- package/dist/plugins/editor-ui/index.d.ts +6 -0
- package/dist/plugins/editor-ui/index.d.ts.map +1 -0
- package/dist/plugins/font/locales/nl.d.ts +4 -0
- package/dist/plugins/font/locales/nl.d.ts.map +1 -0
- package/dist/plugins/font-size/locales/nl.d.ts +4 -0
- package/dist/plugins/font-size/locales/nl.d.ts.map +1 -0
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/formula/locales/nl.d.ts +4 -0
- package/dist/plugins/formula/locales/nl.d.ts.map +1 -0
- package/dist/plugins/formula.mjs +1 -1
- package/dist/plugins/gap-cursor/locales/nl.d.ts +4 -0
- package/dist/plugins/gap-cursor/locales/nl.d.ts.map +1 -0
- package/dist/plugins/gap-cursor.mjs +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/locales/nl.d.ts +4 -0
- package/dist/plugins/heading/locales/nl.d.ts.map +1 -0
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/locales/nl.d.ts +4 -0
- package/dist/plugins/highlight/locales/nl.d.ts.map +1 -0
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule/locales/nl.d.ts +4 -0
- package/dist/plugins/horizontal-rule/locales/nl.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/locales/nl.d.ts +4 -0
- package/dist/plugins/image/locales/nl.d.ts.map +1 -0
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/inline-code/locales/nl.d.ts +4 -0
- package/dist/plugins/inline-code/locales/nl.d.ts.map +1 -0
- package/dist/plugins/inline-code.mjs +1 -1
- package/dist/plugins/link/{LinkPreview.d.ts → LinkBubble.d.ts} +10 -7
- package/dist/plugins/link/LinkBubble.d.ts.map +1 -0
- package/dist/plugins/link/LinkBubbleContent.d.ts +4 -0
- package/dist/plugins/link/LinkBubbleContent.d.ts.map +1 -0
- package/dist/plugins/link/LinkInteractionController.d.ts +17 -3
- package/dist/plugins/link/LinkInteractionController.d.ts.map +1 -1
- package/dist/plugins/link/LinkLocale.d.ts +3 -0
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -1
- package/dist/plugins/link/LinkPlugin.d.ts +0 -1
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link/LinkRange.d.ts +12 -0
- package/dist/plugins/link/LinkRange.d.ts.map +1 -0
- package/dist/plugins/link/locales/ar.d.ts.map +1 -1
- package/dist/plugins/link/locales/de.d.ts.map +1 -1
- package/dist/plugins/link/locales/es.d.ts.map +1 -1
- package/dist/plugins/link/locales/fr.d.ts.map +1 -1
- package/dist/plugins/link/locales/hi.d.ts.map +1 -1
- package/dist/plugins/link/locales/nl.d.ts +4 -0
- package/dist/plugins/link/locales/nl.d.ts.map +1 -0
- package/dist/plugins/link/locales/pt.d.ts.map +1 -1
- package/dist/plugins/link/locales/ru.d.ts.map +1 -1
- package/dist/plugins/link/locales/zh.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/locales/nl.d.ts +4 -0
- package/dist/plugins/list/locales/nl.d.ts.map +1 -0
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print/locales/nl.d.ts +4 -0
- package/dist/plugins/print/locales/nl.d.ts.map +1 -0
- package/dist/plugins/print.mjs +1 -1
- package/dist/plugins/shared/PopupManager.d.ts +15 -2
- package/dist/plugins/shared/PopupManager.d.ts.map +1 -1
- package/dist/plugins/shared/PopupPositioning.d.ts +2 -6
- package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -1
- package/dist/plugins/shared/index.d.ts +1 -1
- package/dist/plugins/shared/index.d.ts.map +1 -1
- package/dist/plugins/shared.mjs +1 -1
- package/dist/plugins/smart-paste/locales/nl.d.ts +4 -0
- package/dist/plugins/smart-paste/locales/nl.d.ts.map +1 -0
- package/dist/plugins/smart-paste.mjs +1 -1
- package/dist/plugins/strikethrough/locales/nl.d.ts +4 -0
- package/dist/plugins/strikethrough/locales/nl.d.ts.map +1 -0
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub/locales/nl.d.ts +4 -0
- package/dist/plugins/super-sub/locales/nl.d.ts.map +1 -0
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
- package/dist/plugins/table/TableSelection.d.ts +4 -20
- package/dist/plugins/table/TableSelection.d.ts.map +1 -1
- package/dist/plugins/table/TableSelectionTypes.d.ts +21 -0
- package/dist/plugins/table/TableSelectionTypes.d.ts.map +1 -0
- package/dist/plugins/table/locales/nl.d.ts +4 -0
- package/dist/plugins/table/locales/nl.d.ts.map +1 -0
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/locales/nl.d.ts +4 -0
- package/dist/plugins/text-color/locales/nl.d.ts.map +1 -0
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-direction/locales/nl.d.ts +4 -0
- package/dist/plugins/text-direction/locales/nl.d.ts.map +1 -0
- package/dist/plugins/text-direction-auto.mjs +1 -1
- package/dist/plugins/text-direction.mjs +1 -1
- package/dist/plugins/text-formatting/locales/nl.d.ts +4 -0
- package/dist/plugins/text-formatting/locales/nl.d.ts.map +1 -0
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +2 -2
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +2 -1
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts +8 -3
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarRegistry.d.ts +4 -0
- package/dist/plugins/toolbar/ToolbarRegistry.d.ts.map +1 -1
- package/dist/plugins/toolbar/locales/nl.d.ts +4 -0
- package/dist/plugins/toolbar/locales/nl.d.ts.map +1 -0
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/plugins/video/locales/nl.d.ts +4 -0
- package/dist/plugins/video/locales/nl.d.ts.map +1 -0
- package/dist/plugins/video.mjs +1 -1
- package/dist/presets/full.mjs +1 -1
- package/dist/presets/minimal.mjs +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/register.mjs +1 -1
- package/dist/serialization/DocumentParser.d.ts +2 -2
- package/dist/serialization/DocumentParser.d.ts.map +1 -1
- package/dist/serialization/HTMLParseRules.d.ts.map +1 -1
- package/dist/serialization/HTMLSanitization.d.ts +6 -0
- package/dist/serialization/HTMLSanitization.d.ts.map +1 -1
- package/dist/serialization/PreformattedText.d.ts +3 -0
- package/dist/serialization/PreformattedText.d.ts.map +1 -0
- package/dist/state/RangeMapping.d.ts +10 -0
- package/dist/state/RangeMapping.d.ts.map +1 -0
- package/dist/ui.d.ts +3 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.mjs +1 -0
- package/dist/view/EditorInteraction.d.ts +23 -0
- package/dist/view/EditorInteraction.d.ts.map +1 -0
- package/dist/view/EditorView.d.ts +2 -0
- package/dist/view/EditorView.d.ts.map +1 -1
- package/dist/view/SelectionGeometry.d.ts +29 -0
- package/dist/view/SelectionGeometry.d.ts.map +1 -0
- package/dist/view/SelectionObserver.d.ts +19 -0
- package/dist/view/SelectionObserver.d.ts.map +1 -0
- package/dist/view/SelectionSync.d.ts +7 -0
- package/dist/view/SelectionSync.d.ts.map +1 -1
- package/package.json +6 -2
- package/dist/chunks/AlignmentPlugin-Cp7HYGaH.mjs +0 -2
- package/dist/chunks/BidiIsolationPlugin-GWukKdgJ.mjs +0 -2
- package/dist/chunks/BlockquotePlugin-CSL_7Yit.mjs +0 -2
- package/dist/chunks/CaretNavigationPlugin-BQPqqK4n.mjs +0 -2
- package/dist/chunks/CodeBlockPlugin-B4AcDJRK.mjs +0 -2
- package/dist/chunks/Commands-Bk7Cl1nH.mjs +0 -2
- package/dist/chunks/DocumentParser-C99N0MWF.mjs +0 -2
- package/dist/chunks/DocumentParser-C99N0MWF.mjs.map +0 -1
- package/dist/chunks/FontPlugin-BcXNFqqO.mjs +0 -2
- package/dist/chunks/FontSizePlugin-Dswra3oU.mjs +0 -2
- package/dist/chunks/FormulaPlugin-DVpLaKi5.mjs +0 -2
- package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs +0 -2
- package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs +0 -2
- package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs.map +0 -1
- package/dist/chunks/HeadingPlugin-B7EfynaH.mjs +0 -2
- package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-YywXVZYr.mjs +0 -2
- package/dist/chunks/ImagePlugin-BAhZuVdE.mjs +0 -2
- package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs +0 -2
- package/dist/chunks/LinkPlugin-CAUaWW5-.mjs +0 -2
- package/dist/chunks/LinkPlugin-CAUaWW5-.mjs.map +0 -1
- package/dist/chunks/ListPlugin-U1r4p_fE.mjs +0 -2
- package/dist/chunks/PluginHelpers-B3gk3VB3.mjs +0 -2
- package/dist/chunks/PluginHelpers-B3gk3VB3.mjs.map +0 -1
- package/dist/chunks/PopupManager-Dxv0OVMo.mjs +0 -2
- package/dist/chunks/PopupManager-Dxv0OVMo.mjs.map +0 -1
- package/dist/chunks/PrintPlugin-DAEiEyKQ.mjs +0 -2
- package/dist/chunks/SimpleMark-D6vz3Nfd.mjs +0 -2
- package/dist/chunks/SmartPastePlugin-BHsYKbgd.mjs +0 -2
- package/dist/chunks/StrikethroughPlugin-v-VJZzUZ.mjs +0 -2
- package/dist/chunks/SuperSubPlugin-x1iPnZyt.mjs +0 -2
- package/dist/chunks/TablePlugin-CjKThPug.mjs +0 -2
- package/dist/chunks/TablePlugin-CjKThPug.mjs.map +0 -1
- package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs +0 -2
- package/dist/chunks/TextDirectionPlugin-JwlR-R-b.mjs +0 -2
- package/dist/chunks/TextDirectionService-BcX07mw2.mjs +0 -2
- package/dist/chunks/TextFormattingPlugin-Kc_UNoOz.mjs +0 -2
- package/dist/chunks/ToolbarPlugin-CgZA2hz8.mjs +0 -2
- package/dist/chunks/ToolbarPlugin-CgZA2hz8.mjs.map +0 -1
- package/dist/chunks/VideoPlugin-DJXfuNA9.mjs +0 -2
- package/dist/chunks/ar-DhwCFHql.mjs +0 -2
- package/dist/chunks/ar-DhwCFHql.mjs.map +0 -1
- package/dist/chunks/de-CjLUbQmg.mjs +0 -2
- package/dist/chunks/de-CjLUbQmg.mjs.map +0 -1
- package/dist/chunks/es-CMSzvjOT.mjs +0 -2
- package/dist/chunks/es-CMSzvjOT.mjs.map +0 -1
- package/dist/chunks/fr-DB_OvHWH.mjs +0 -2
- package/dist/chunks/fr-DB_OvHWH.mjs.map +0 -1
- package/dist/chunks/full-BsWAZr1w.mjs +0 -2
- package/dist/chunks/hi-ChNQZZ1z.mjs +0 -2
- package/dist/chunks/hi-ChNQZZ1z.mjs.map +0 -1
- package/dist/chunks/minimal-DO7LiFTa.mjs +0 -2
- package/dist/chunks/pt-CI8t6oul.mjs +0 -2
- package/dist/chunks/pt-CI8t6oul.mjs.map +0 -1
- package/dist/chunks/register-DXLu8Njp.mjs +0 -3
- package/dist/chunks/register-DXLu8Njp.mjs.map +0 -1
- package/dist/chunks/ru-9WtNGZtl.mjs +0 -2
- package/dist/chunks/ru-9WtNGZtl.mjs.map +0 -1
- package/dist/chunks/src-5GKFQ2mQ.mjs +0 -2
- package/dist/chunks/src-5GKFQ2mQ.mjs.map +0 -1
- package/dist/chunks/zh-BrqJ4ywP.mjs +0 -2
- package/dist/chunks/zh-BrqJ4ywP.mjs.map +0 -1
- package/dist/plugins/link/LinkPreview.d.ts.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as t,B as n,D as o,E as e,N as r,g as c,h as i,k as s}from"./Document-ssR6hBzG.mjs";import{r as l}from"./NodeResolver-F4RtpoEd.mjs";import{c as f,d as u,f as d,i as a,n as k,o as b,p as m,u as h}from"./Selection-DC6AOGgF.mjs";import{r as I}from"./TypeBrands-Ch9856Gb.mjs";import{i as g,n as p,o as B,r as x}from"./NavigationQueries-CaKfccu7.mjs";import{C as N,b as S,c as v,w as O,y as j}from"./BlockInsertion-CXfXqUZl.mjs";import{t as A}from"./CursorMarks-CqHLzGNI.mjs";import{t as T}from"./ContentModel-dkGOh3N7.mjs";import{n as w,r as M,t as y}from"./NodeSelectionCommands-CAqIHW_6.mjs";function C(t,n){if("after"===n.side)return D(t,n);const o=t.getBlockOrder(),e=o.indexOf(n.blockId);if(e<=0)return null;const r=o[e-1];if(!r)return null;if(g(t,r)){const n=l(t.doc,r)??[];return t.transaction("input").setSelection(a(r,n)).build()}const c=t.getBlock(r);if(!c)return null;const i=s(c);return t.transaction("input").setSelection(k(r,i)).build()}function P(t,n){if("before"===n.side)return D(t,n);const o=t.getBlockOrder(),e=o.indexOf(n.blockId);if(e>=o.length-1)return null;const r=o[e+1];if(!r)return null;if(g(t,r)){const n=l(t.doc,r)??[];return t.transaction("input").setSelection(a(r,n)).build()}return t.transaction("input").setSelection(k(r,0)).build()}function D(t,n){const o=l(t.doc,n.blockId)??[],e=a(n.blockId,o);return y(t,e)}function _(t,n){const o=l(t.doc,n);if(!o||0===o.length)return-1;const e=o[0];return t.doc.children.findIndex(t=>t.id===e)}function E(t,n,o){const e=s(n),r=n.id===o.from.blockId?o.from.offset:0,c=n.id===o.to.blockId?o.to.offset:e;r<c&&t.deleteTextAt(n.id,r,c)}function Q(t,n,o){const r=/* @__PURE__ */new Map;let c;for(let s=o.length-1;s>=0;s--){const{parentPath:l,siblings:f,index:u}=O(t,o[s]);if(u<0)continue;const d=l.join("/"),a=r.get(d)??0;if(r.set(d,a+1),f.length-a>1){n.removeNode(l,u);continue}const k=e();n.insertNode(l,0,i(k)),n.removeNode(l,1),0===s&&(c=k)}return c}function R(t,o){return n(o)&&!g(t,o.id)}function q(t,o,r,c,f){const u=t.doc.children[c],d=t.doc.children[f];if(!u||!d)return;const a=t.getBlock(r.to.blockId);if(!a)return;const k=R(t,u),b=R(t,d),m=0===r.from.offset&&z(u)===r.from.blockId,h=r.to.offset===s(a)&&F(d)===r.to.blockId,I=!k&&(n(u)||m),g=!b&&(n(d)||h);let p;k?E(o,u,r):I||L(t,o,[u.id],u,l(t.doc,r.from.blockId)??[],r.from.blockId,r.from.offset),b?E(o,d,r):g||U(t,o,[d.id],d,l(t.doc,r.to.blockId)??[],r.to.blockId,r.to.offset);let B=0;I&&b?p=r.to.blockId:I&&(p=e(),o.insertNode([],c,i(p)),B=1);const x=[];I&&x.push(c);for(let n=c+1;n<f;n++)x.push(n);g&&x.push(f);for(let n=x.length-1;n>=0;n--)o.removeNode([],x[n]+B);return k&&b&&o.mergeBlocksAt(r.from.blockId,r.to.blockId),p}function z(t){if(n(t))return t.id;const e=o(t)[0];return e?z(e):t.id}function F(t){if(n(t))return t.id;const e=o(t),r=e[e.length-1];return r?F(r):t.id}function G(t,n){return!!t.schema.getNodeSpec?.(n.type)?.content&&T(t.schema,n.type,"paragraph")}function H(t,n,e,r,c,i){const s=o(r),l=G(t,r);for(let o=i-1;o>=c;o--){const r=s[o];r&&(l?n.removeNode(e,o):J(t,n,[...e,r.id],r))}}function J(t,r,c,l){if(n(l)){const t=s(l);return void(t>0&&r.deleteTextAt(l.id,0,t))}const f=o(l);if(!G(t,l))return void H(t,r,c,l,0,f.length);const u=1===f.length?f[0]:void 0;if(!u||!v(u)){for(let t=f.length-1;t>=0;t--)r.removeNode(c,t);r.insertNode(c,0,i(e()))}}function K(t,n){const e=n.indexOf(t.id),r=e>=0?n[e+1]:void 0;return o(t).findIndex(t=>t.id===r)}function L(t,n,e,r,c,i,l){const f=o(r),u=K(r,c);if(u<0)return;H(t,n,e,r,u+1,f.length);const d=f[u];if(d.id===i){const t=s(d);return void(l<t&&n.deleteTextAt(i,l,t))}L(t,n,[...e,d.id],d,c,i,l)}function U(t,n,e,r,c,i,s){const l=o(r),f=K(r,c);if(f<0)return;H(t,n,e,r,0,f);const u=l[f];u.id!==i?U(t,n,[...e,u.id],u,c,i,s):s>0&&n.deleteTextAt(i,0,s)}function V(t,n,o="input"){const r=t.selection;if(u(r))return M(t,r,n,o);if(h(r))return function(t,n,o,r){const{parentPath:c,siblings:s,index:l}=O(t,n.blockId),f="before"===n.side?Math.max(l,0):l>=0?l+1:s.length,u=e(),d=t.transaction(r);return d.insertNode(c,f,i(u)),d.insertText(u,0,o,[]),d.setSelection(k(u,o.length)),d.build()}(t,r,n,o);const c=t.transaction(o),s=et(t);let l;f(r)||(l=rt(t,c));const d=N(r,t.getBlockOrder()),a=l??d.blockId,b=l?0:d.offset;return c.insertText(a,b,n,s),c.setSelection(k(a,b+n.length)),c.build()}function W(t){if(u(t.selection))return y(t,t.selection);if(h(t.selection))return null;if(f(t.selection))return null;if(function(t){if(!d(t.selection))return!1;const n=ot(t);if(!n)return!1;const o=m(t.selection,t.getBlockOrder());return o.from.blockId===n.from.blockId&&o.from.offset===n.from.offset&&o.to.blockId===n.to.blockId&&o.to.offset===n.to.offset}(t))return function(t){const n=e(),o=t.transaction("input"),r=t.doc.children.length;o.insertNode([],0,i(n));for(let e=r;e>=1;e--)o.removeNode([],e);return o.setSelection(k(n,0)),o.build()}(t);const n=t.transaction("input"),o=rt(t,n),r=m(t.selection,t.getBlockOrder()),c=o??r.from.blockId,s=o?0:r.from.offset;return n.setSelection(k(c,s)),n.build()}function X(t){const n=t.selection;if(u(n))return w(t,n);if(h(n))return function(t,n){const{parentPath:o,index:r}=O(t,n.blockId);if(r<0)return null;const c="before"===n.side?r:r+1,s=e(),l=t.transaction("input");return l.insertNode(o,c,i(s)),l.setSelection(k(s,0)),l.build()}(t,n);const o=t.transaction("input");let r;f(n)||(r=rt(t,o));const c=N(n,t.getBlockOrder()),s=r??c.blockId,l=r?0:c.offset,d=e();return o.splitBlock(s,l,d),o.setSelection(k(d,0)),o.build()}function Y(t){const n=t.selection;if(!d(n))return null;const o=t.transaction("input");let e;if(f(n)||(e=rt(t,o)),e)o.insertInlineNode(e,0,c(I("hard_break"))),o.setSelection(k(e,1));else{const{blockId:e,offset:r}=N(n,t.getBlockOrder());o.insertInlineNode(e,r,c(I("hard_break"))),o.setSelection(k(e,r+1))}return o.build()}function Z(t){return tt(t,"backward")}function $(t){return tt(t,"forward")}function tt(t,n){const o=t.selection;if(!d(o))return null;const e=t.getBlockOrder(),r=e.indexOf(o.anchor.blockId),c="backward"===n?r-1:r+1;if(c<0||c>=e.length)return null;const i=e[c];if(!i)return null;if(x(t,o.anchor.blockId)||x(t,i))return null;const f=B(t,o.anchor.blockId,i);if(!f&&p(t,o.anchor.blockId))return null;if(g(t,i)){const n=l(t.doc,i)??[];return t.transaction("input").setSelection(a(i,n)).build()}if(!f)return null;if("backward"===n){const n=t.getBlock(i);if(!n)return null;const e=s(n);return t.transaction("input").mergeBlocksAt(i,o.anchor.blockId).setSelection(k(i,e)).build()}return t.transaction("input").mergeBlocksAt(o.anchor.blockId,i).setSelection(k(o.anchor.blockId,o.anchor.offset)).build()}function nt(t){const n=ot(t);return n?t.transaction("command").setSelection(b(n.from,n.to)).build():t.transaction("command").setSelection(t.selection).build()}function ot(t){const n=t.doc.children,o=n[0],e=n[n.length-1];if(!o||!e)return null;const r=j(o),c=S(e),i=t.getBlock(c);return{from:{blockId:r,offset:0},to:{blockId:c,offset:i?s(i):0}}}function et(n){if(n.storedMarks)return n.storedMarks;const o=n.selection;if(!d(o))return[];const e=n.getBlock(o.anchor.blockId);return e?f(o)?r(e,o.anchor.offset,t=>A(n.schema,t)):t(e,o.anchor.offset):[]}function rt(t,n){if(!d(t.selection))return;const o=t.getBlockOrder(),r=m(t.selection,o),c=o.indexOf(r.from.blockId),s=o.indexOf(r.to.blockId);if(c===s)return void n.deleteTextAt(r.from.blockId,r.from.offset,r.to.offset);const l=_(t,r.from.blockId),f=_(t,r.to.blockId);return l===f||l<0||f<0?function(t,n,o,r,c,s){const l=o.slice(c,s+1),f=l.findIndex(n=>!g(t,n));if(f<0)return function(t,n,o){const r=o[0];if(!r)return;const{parentPath:c,index:s}=O(t,r);if(s<0)return;const l=Q(t,n,o);if(l)return l;const f=e();return n.insertNode(c,s,i(f)),f}(t,n,l);const u=l[f],d=[];let a,k=[];for(const e of l){a&&B(t,a,e)||(k=[],d.push(k)),g(t,e)||k.push(e),a=e;const o=t.getBlock(e);o&&E(n,o,r)}Q(t,n,l.filter(n=>g(t,n)));for(const[e,...i]of d)if(e)for(const t of i)n.mergeBlocksAt(e,t);return 0===f?void 0:u}(t,n,o,r,c,s):q(t,n,r,l,f)}export{Z as a,nt as c,P as d,V as i,X as l,W as n,$ as o,Y as r,et as s,rt as t,C as u};
|
|
2
|
+
//# sourceMappingURL=Commands-vqbwh6Ic.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Commands-Bk7Cl1nH.mjs","names":["getBlockMarksAtOffset","isLeafBlock","getBlockChildren","generateBlockId","getCursorMarks","createInlineNode","createEmptyParagraph","getBlockLength","findNodePath","isCollapsed","isNodeSelection","isTextSelection","createNodeSelection","createCollapsedSelection","createSelection","selectionRange","isGapCursor","inlineType","isVoidBlock","isInsideIsolating","sharesParent","isIsolatingBlock","resolveInsertPoint","findLastLeafBlockId","isEmptyParagraph","resolveSiblingContext","findFirstLeafBlockId","isMarkInclusive","canContain","insertParagraphAfterNodeSelection","insertTextAfterNodeSelection","deleteNodeSelection","deleteBackwardAtGap","state","sel","side","deleteVoidAtGap","blockOrder","getBlockOrder","blockIdx","indexOf","blockId","prevId","path","doc","transaction","setSelection","build","prevBlock","getBlock","prevLen","deleteForwardAtGap","length","nextId","nodeSel","getRootBlockIndex","rootId","children","findIndex","c","id","deleteSelectedText","builder","block","range","from","offset","to","deleteTextAt","removeVoidBlocks","ids","removedPerParent","Map","swappedInForFirst","i","parentPath","siblings","index","parentKey","join","removedBefore","get","set","removeNode","replacementId","insertNode","isTextLeaf","deleteCrossRootRange","fromRootIdx","toRootIdx","fromRoot","toRoot","toLeaf","fromIsLeaf","toIsLeaf","fromAtStart","firstLeafId","toAtEnd","lastLeafId","fromWholesale","toWholesale","landingId","trimContainerTail","trimContainerHead","shift","removeIdxs","push","k","mergeBlocksAt","first","last","hasFlowContent","container","schema","getNodeSpec","type","content","deleteCoveredChildren","containerPath","removable","child","clearBlockContent","only","boundaryChildIndex","leafPath","pos","targetChildId","leafId","leafOffset","boundaryIdx","boundaryChild","len","insertTextCommand","text","origin","selection","insertIdx","Math","max","newId","insertText","insertTextAtGap","marks","storedMarks","anchor","resolveActiveMarks","addDeleteSelectionSteps","resolved","insertBlockId","insertOffset","deleteSelectionCommand","docRange","documentRange","selectionCoversDocument","newBlockId","originalCount","clearDocument","cursorBlockId","cursorOffset","splitBlockCommand","insertParagraphAtGap","splitBlock","insertHardBreakCommand","insertInlineNode","mergeBlockBackward","mergeAdjacentBlock","mergeBlockForward","direction","adjacentIdx","adjacentId","sameParent","selectAll","blocks","firstBlock","lastBlock","lastLeaf","fromIdx","toIdx","rangeIds","slice","survivorIdx","swappedIn","replaceVoidOnlyRange","survivorId","groups","previousId","group","filter","targetId","sourceIds","sourceId","deleteLeafRange"],"sources":["../../src/commands/GapCursorCommands.ts","../../src/commands/SelectionDeletion.ts","../../src/commands/Commands.ts"],"sourcesContent":["/**\n * Commands for GapCursor: deleting void blocks adjacent to gap cursors\n * and inserting paragraphs at gap positions.\n */\n\nimport { createEmptyParagraph, generateBlockId, getBlockLength } from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { GapCursorSelection, NodeSelection } from '../model/Selection.js';\nimport { createCollapsedSelection, createNodeSelection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock } from '../state/NavigationQueries.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { resolveSiblingContext } from './CommandHelpers.js';\nimport { deleteNodeSelection } from './NodeSelectionCommands.js';\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Backspace.\n *\n * - `side === 'after'` → void block is behind the cursor → delete it.\n * - `side === 'before'` → void block is ahead → navigate backward (to previous block).\n * - At document start with `side === 'before'` → `null` (no-op).\n */\nexport function deleteBackwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'after') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'before': navigate to previous block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx <= 0) return null;\n\n\tconst prevId: BlockId | undefined = blockOrder[blockIdx - 1];\n\tif (!prevId) return null;\n\n\tif (isVoidBlock(state, prevId)) {\n\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\tconst prevBlock = state.getBlock(prevId);\n\tif (!prevBlock) return null;\n\tconst prevLen: number = getBlockLength(prevBlock);\n\treturn state.transaction('input').setSelection(createCollapsedSelection(prevId, prevLen)).build();\n}\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Delete.\n *\n * - `side === 'before'` → void block is ahead of the cursor → delete it.\n * - `side === 'after'` → void block is behind → navigate forward (to next block).\n * - At document end with `side === 'after'` → `null` (no-op).\n */\nexport function deleteForwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'before') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'after': navigate to next block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx >= blockOrder.length - 1) return null;\n\n\tconst nextId: BlockId | undefined = blockOrder[blockIdx + 1];\n\tif (!nextId) return null;\n\n\tif (isVoidBlock(state, nextId)) {\n\t\tconst path = findNodePath(state.doc, nextId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(nextId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\treturn state.transaction('input').setSelection(createCollapsedSelection(nextId, 0)).build();\n}\n\n/** Deletes the void block that the GapCursor is adjacent to, delegating to deleteNodeSelection. */\nfunction deleteVoidAtGap(state: EditorState, sel: GapCursorSelection): Transaction | null {\n\tconst path = (findNodePath(state.doc, sel.blockId) ?? []) as BlockId[];\n\tconst nodeSel: NodeSelection = createNodeSelection(sel.blockId, path);\n\treturn deleteNodeSelection(state, nodeSel);\n}\n\n/** Inserts a new paragraph at a GapCursor position (before or after the void block). */\nexport function insertParagraphAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tconst { parentPath, index } = resolveSiblingContext(state, sel.blockId);\n\tif (index < 0) return null;\n\n\tconst insertIdx: number = sel.side === 'before' ? index : index + 1;\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\treturn builder.build();\n}\n\n/** Inserts text in a new paragraph at a GapCursor position. */\nexport function insertTextAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n\ttext: string,\n\torigin: 'input' | 'paste',\n): Transaction {\n\tconst { parentPath, siblings, index } = resolveSiblingContext(state, sel.blockId);\n\tconst insertIdx: number =\n\t\tsel.side === 'before' ? Math.max(index, 0) : index >= 0 ? index + 1 : siblings.length;\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction(origin);\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.insertText(newId, 0, text, []);\n\tbuilder.setSelection(createCollapsedSelection(newId, text.length));\n\treturn builder.build();\n}\n","/**\n * Range-deletion helpers for multi-block text selections, split out of\n * Commands.ts. Handles two cases: a selection whose blocks share one root\n * ancestor (leaf range) and a selection spanning different root ancestors\n * (cross-root range).\n *\n * A void block (image, horizontal rule) at either end of a range is wholly\n * selected — it has no partial content and cannot host the caret — so it is\n * removed outright and never merged into (#224).\n *\n * Containers keep their shape: a free-flowing container (blockquote, list\n * item, table cell) loses the children a range covers, while a fixed-shape one\n * (a table, a table row) keeps every child and only has its content cleared.\n */\n\nimport { canContain } from '../model/ContentModel.js';\nimport type { BlockNode } from '../model/Document.js';\nimport {\n\tcreateEmptyParagraph,\n\tgenerateBlockId,\n\tgetBlockChildren,\n\tgetBlockLength,\n\tisLeafBlock,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock, sharesParent } from '../state/NavigationQueries.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { isEmptyParagraph } from './BlockInsertion.js';\nimport { resolveSiblingContext } from './CommandHelpers.js';\n\n/** A normalized text-selection range (document-order from/to positions). */\nexport interface DeletionRange {\n\treadonly from: { readonly blockId: BlockId; readonly offset: number };\n\treadonly to: { readonly blockId: BlockId; readonly offset: number };\n}\n\n/** Returns the root-level ancestor index in `doc.children` for a given block. */\nexport function getRootBlockIndex(state: EditorState, blockId: BlockId): number {\n\tconst path = findNodePath(state.doc, blockId);\n\tif (!path || path.length === 0) return -1;\n\tconst rootId: string = path[0] as string;\n\treturn state.doc.children.findIndex((c) => c.id === rootId);\n}\n\n/**\n * Deletes a multi-block selection where all blocks share the same root ancestor.\n *\n * Container boundaries survive: only consecutive leaves with the same immediate\n * parent merge into their group's first text leaf. Selected void blocks are\n * removed in place before any merges. Returns the first text leaf when it is\n * not the from-block (the caret then lands at offset 0), or the landing paragraph\n * swapped in when the range is void-only; undefined when the from-block survives.\n */\nexport function deleteLeafRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tblockOrder: readonly BlockId[],\n\trange: DeletionRange,\n\tfromIdx: number,\n\ttoIdx: number,\n): BlockId | undefined {\n\tconst rangeIds: readonly BlockId[] = blockOrder.slice(fromIdx, toIdx + 1);\n\tconst survivorIdx: number = rangeIds.findIndex((id) => !isVoidBlock(state, id));\n\tif (survivorIdx < 0) return replaceVoidOnlyRange(state, builder, rangeIds);\n\tconst survivorId: BlockId = rangeIds[survivorIdx] as BlockId;\n\n\t// Group the original leaf order, including voids: returning to a parent\n\t// after a nested container starts a new group, even if that container's\n\t// only leaf is a selected void that will be replaced below.\n\tconst groups: BlockId[][] = [];\n\tlet previousId: BlockId | undefined;\n\tlet group: BlockId[] = [];\n\tfor (const id of rangeIds) {\n\t\tif (!previousId || !sharesParent(state, previousId, id)) {\n\t\t\tgroup = [];\n\t\t\tgroups.push(group);\n\t\t}\n\t\tif (!isVoidBlock(state, id)) group.push(id);\n\t\tpreviousId = id;\n\t\tconst block: BlockNode | undefined = state.getBlock(id);\n\t\tif (block) deleteSelectedText(builder, block, range);\n\t}\n\t// Positional removals still refer to the original sibling indexes. All voids\n\t// must be removed (last first) before merging shifts any of those indexes.\n\tremoveVoidBlocks(\n\t\tstate,\n\t\tbuilder,\n\t\trangeIds.filter((id) => isVoidBlock(state, id)),\n\t);\n\tfor (const [targetId, ...sourceIds] of groups) {\n\t\tif (!targetId) continue;\n\t\tfor (const sourceId of sourceIds) builder.mergeBlocksAt(targetId, sourceId);\n\t}\n\n\treturn survivorIdx === 0 ? undefined : survivorId;\n}\n\n/** Deletes the part of `block`'s inline content that lies inside `range`. */\nfunction deleteSelectedText(\n\tbuilder: TransactionBuilder,\n\tblock: BlockNode,\n\trange: DeletionRange,\n): void {\n\tconst length: number = getBlockLength(block);\n\tconst from: number = block.id === range.from.blockId ? range.from.offset : 0;\n\tconst to: number = block.id === range.to.blockId ? range.to.offset : length;\n\tif (from < to) builder.deleteTextAt(block.id, from, to);\n}\n\n/**\n * Removes a range made only of void blocks and returns the empty paragraph\n * that takes their place and hosts the caret.\n */\nfunction replaceVoidOnlyRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tids: readonly BlockId[],\n): BlockId | undefined {\n\tconst first: BlockId | undefined = ids[0];\n\tif (!first) return undefined;\n\tconst { parentPath, index } = resolveSiblingContext(state, first);\n\tif (index < 0) return undefined;\n\n\tconst swappedIn: BlockId | undefined = removeVoidBlocks(state, builder, ids);\n\tif (swappedIn) return swappedIn;\n\n\t// Earlier siblings are untouched, so the first block's slot is still `index`.\n\tconst landingId: BlockId = generateBlockId();\n\tbuilder.insertNode(parentPath, index, createEmptyParagraph(landingId));\n\treturn landingId;\n}\n\n/**\n * Removes void blocks in place, last first so positional indexes stay valid.\n * A parent about to lose its last child keeps an empty paragraph instead, so\n * containers such as table cells never end up empty. Returns the paragraph\n * swapped in for the first block, if one was needed.\n */\nfunction removeVoidBlocks(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tids: readonly BlockId[],\n): BlockId | undefined {\n\tconst removedPerParent = new Map<string, number>();\n\tlet swappedInForFirst: BlockId | undefined;\n\n\tfor (let i = ids.length - 1; i >= 0; i--) {\n\t\tconst { parentPath, siblings, index } = resolveSiblingContext(state, ids[i] as BlockId);\n\t\tif (index < 0) continue;\n\t\tconst parentKey: string = parentPath.join('/');\n\t\tconst removedBefore: number = removedPerParent.get(parentKey) ?? 0;\n\t\tremovedPerParent.set(parentKey, removedBefore + 1);\n\n\t\tif (siblings.length - removedBefore > 1) {\n\t\t\tbuilder.removeNode(parentPath, index);\n\t\t\tcontinue;\n\t\t}\n\t\t// Last remaining child (so at index 0): swap in an empty paragraph.\n\t\tconst replacementId: BlockId = generateBlockId();\n\t\tbuilder.insertNode(parentPath, 0, createEmptyParagraph(replacementId));\n\t\tbuilder.removeNode(parentPath, 1);\n\t\tif (i === 0) swappedInForFirst = replacementId;\n\t}\n\n\treturn swappedInForFirst;\n}\n\n/** A leaf block that can hold a caret: any leaf except a void one. */\nfunction isTextLeaf(state: EditorState, block: BlockNode): boolean {\n\treturn isLeafBlock(block) && !isVoidBlock(state, block.id);\n}\n\n/**\n * Deletes a selection spanning different root-level ancestors.\n *\n * The selected span is deleted while every unselected leaf survives. A\n * composite/container root (a multi-block `list_item`, a `blockquote`, a\n * `table`) whose boundary sits *inside* it is trimmed, not wiped: the from-root\n * keeps everything before `range.from`, the to-root keeps everything after\n * `range.to`. Trimming keeps the shape of fixed-shape containers (see\n * {@link hasFlowContent}): the covered cells of a table are cleared, never\n * removed, so its rows keep equal cell counts. A container is removed wholesale\n * only when the boundary lands at its very edge (offset 0 of its first leaf, or\n * the end of its last leaf), so the whole container is genuinely inside the\n * selection. Root blocks strictly between the endpoints are always removed, and\n * a void root at either end is always removed wholesale.\n *\n * Returns the block hosting the caret when the from-root was removed wholesale\n * (its cursor block went with it): the surviving to-leaf, or a landing paragraph\n * inserted in the from-root's slot. Undefined otherwise, since the from boundary\n * leaf then survives and hosts the caret.\n */\nexport function deleteCrossRootRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\trange: DeletionRange,\n\tfromRootIdx: number,\n\ttoRootIdx: number,\n): BlockId | undefined {\n\tconst fromRoot = state.doc.children[fromRootIdx];\n\tconst toRoot = state.doc.children[toRootIdx];\n\tif (!fromRoot || !toRoot) return undefined;\n\n\tconst toLeaf = state.getBlock(range.to.blockId);\n\tif (!toLeaf) return undefined;\n\n\tconst fromIsLeaf: boolean = isTextLeaf(state, fromRoot);\n\tconst toIsLeaf: boolean = isTextLeaf(state, toRoot);\n\n\t// A non-text root is removed wholesale (rather than trimmed) when it is void,\n\t// or when the boundary sits at its very edge and so covers the whole\n\t// container: the from-root's edge is offset 0 of its first leaf, the\n\t// to-root's is the end of its last leaf.\n\tconst fromAtStart: boolean =\n\t\trange.from.offset === 0 && firstLeafId(fromRoot) === range.from.blockId;\n\tconst toAtEnd: boolean =\n\t\trange.to.offset === getBlockLength(toLeaf) && lastLeafId(toRoot) === range.to.blockId;\n\tconst fromWholesale: boolean = !fromIsLeaf && (isLeafBlock(fromRoot) || fromAtStart);\n\tconst toWholesale: boolean = !toIsLeaf && (isLeafBlock(toRoot) || toAtEnd);\n\n\t// --- from side: keep everything before range.from within the from-root ---\n\tif (fromIsLeaf) {\n\t\tdeleteSelectedText(builder, fromRoot, range);\n\t} else if (!fromWholesale) {\n\t\ttrimContainerTail(\n\t\t\tstate,\n\t\t\tbuilder,\n\t\t\t[fromRoot.id],\n\t\t\tfromRoot,\n\t\t\tfindNodePath(state.doc, range.from.blockId) ?? [],\n\t\t\trange.from.blockId,\n\t\t\trange.from.offset,\n\t\t);\n\t}\n\n\t// --- to side: keep everything after range.to within the to-root ---\n\tif (toIsLeaf) {\n\t\tdeleteSelectedText(builder, toRoot, range);\n\t} else if (!toWholesale) {\n\t\ttrimContainerHead(\n\t\t\tstate,\n\t\t\tbuilder,\n\t\t\t[toRoot.id],\n\t\t\ttoRoot,\n\t\t\tfindNodePath(state.doc, range.to.blockId) ?? [],\n\t\t\trange.to.blockId,\n\t\t\trange.to.offset,\n\t\t);\n\t}\n\n\t// --- root-level removals: middle roots always, endpoints only when wholesale ---\n\t// A wholesale-removed from-root takes its cursor block with it. A surviving\n\t// to-leaf slides into the from-root's slot and hosts the caret at its start;\n\t// otherwise a landing paragraph is inserted there for the caret and any\n\t// follow-up insert.\n\tlet landingId: BlockId | undefined;\n\tlet shift = 0;\n\tif (fromWholesale && toIsLeaf) {\n\t\tlandingId = range.to.blockId;\n\t} else if (fromWholesale) {\n\t\tlandingId = generateBlockId();\n\t\tbuilder.insertNode([], fromRootIdx, createEmptyParagraph(landingId));\n\t\tshift = 1;\n\t}\n\n\tconst removeIdxs: number[] = [];\n\tif (fromWholesale) removeIdxs.push(fromRootIdx);\n\tfor (let i = fromRootIdx + 1; i < toRootIdx; i++) removeIdxs.push(i);\n\tif (toWholesale) removeIdxs.push(toRootIdx);\n\t// Descending so each positional removal stays valid against the evolving doc.\n\tfor (let k = removeIdxs.length - 1; k >= 0; k--) {\n\t\tbuilder.removeNode([], (removeIdxs[k] as number) + shift);\n\t}\n\n\t// Join the boundary only when both roots are leaves: their inline content\n\t// merges into one block (the \"outta\" behavior). Merging across a composite\n\t// boundary is deliberately skipped — trimming already preserved every\n\t// unselected leaf, and there is no single valid block to merge into.\n\tif (fromIsLeaf && toIsLeaf) {\n\t\tbuilder.mergeBlocksAt(range.from.blockId, range.to.blockId);\n\t}\n\n\treturn landingId;\n}\n\n/** The id of a block's first leaf descendant (itself when already a leaf). */\nfunction firstLeafId(block: BlockNode): BlockId {\n\tif (isLeafBlock(block)) return block.id;\n\tconst first: BlockNode | undefined = getBlockChildren(block)[0];\n\treturn first ? firstLeafId(first) : block.id;\n}\n\n/** The id of a block's last leaf descendant (itself when already a leaf). */\nfunction lastLeafId(block: BlockNode): BlockId {\n\tif (isLeafBlock(block)) return block.id;\n\tconst children: readonly BlockNode[] = getBlockChildren(block);\n\tconst last: BlockNode | undefined = children[children.length - 1];\n\treturn last ? lastLeafId(last) : block.id;\n}\n\n/**\n * Whether a container's children are free-flowing blocks that a deletion may\n * remove one by one. That holds when its content rule admits a paragraph\n * (blockquote, list item, table cell), since an empty paragraph can always\n * stand in for removed content. Any other container has a fixed shape (a\n * table's rows, a row's cells, which must keep equal counts), so a deletion\n * clears its covered children instead. Without a content rule the shape is\n * unknown, and keeping it is the safe choice.\n */\nfunction hasFlowContent(state: EditorState, container: BlockNode): boolean {\n\tif (!state.schema.getNodeSpec?.(container.type)?.content) return false;\n\treturn canContain(state.schema, container.type, 'paragraph');\n}\n\n/**\n * Deletes the children of `container` in `[from, to)`, last first so positional\n * removals stay valid: a flow container removes them, a fixed-shape container\n * clears them in place (see {@link hasFlowContent}).\n */\nfunction deleteCoveredChildren(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tfrom: number,\n\tto: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst removable: boolean = hasFlowContent(state, container);\n\tfor (let i = to - 1; i >= from; i--) {\n\t\tconst child: BlockNode | undefined = children[i];\n\t\tif (!child) continue;\n\t\tif (removable) builder.removeNode(containerPath, i);\n\t\telse clearBlockContent(state, builder, [...containerPath, child.id], child);\n\t}\n}\n\n/**\n * Empties a fully covered block while keeping the block itself: a flow\n * container ends up holding one empty paragraph (as a cut table cell does), a\n * fixed-shape container clears each child, and a text leaf loses its text. A\n * void leaf has no text (length 0), so it stays as it is.\n */\nfunction clearBlockContent(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tpath: readonly BlockId[],\n\tblock: BlockNode,\n): void {\n\tif (isLeafBlock(block)) {\n\t\tconst length: number = getBlockLength(block);\n\t\tif (length > 0) builder.deleteTextAt(block.id, 0, length);\n\t\treturn;\n\t}\n\n\tconst children: readonly BlockNode[] = getBlockChildren(block);\n\tif (!hasFlowContent(state, block)) {\n\t\tdeleteCoveredChildren(state, builder, path, block, 0, children.length);\n\t\treturn;\n\t}\n\tconst only: BlockNode | undefined = children.length === 1 ? children[0] : undefined;\n\tif (only && isEmptyParagraph(only)) return;\n\tfor (let i = children.length - 1; i >= 0; i--) builder.removeNode(path, i);\n\tbuilder.insertNode(path, 0, createEmptyParagraph(generateBlockId()));\n}\n\n/** Index of the child of `container` on the path to the boundary leaf, or -1. */\nfunction boundaryChildIndex(container: BlockNode, leafPath: readonly string[]): number {\n\tconst pos: number = leafPath.indexOf(container.id);\n\tconst targetChildId: string | undefined = pos >= 0 ? leafPath[pos + 1] : undefined;\n\treturn getBlockChildren(container).findIndex((c) => c.id === targetChildId);\n}\n\n/**\n * Trims a container to keep only content up to `(leafId, leafOffset)`, deleting\n * every child after the boundary at each level (see {@link deleteCoveredChildren})\n * and the boundary leaf's tail text. `containerPath` is the path to (and\n * including) `container`; `leafPath` is the boundary leaf's full node path, used\n * to descend to the boundary child.\n */\nfunction trimContainerTail(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tleafPath: readonly string[],\n\tleafId: BlockId,\n\tleafOffset: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst boundaryIdx: number = boundaryChildIndex(container, leafPath);\n\tif (boundaryIdx < 0) return;\n\n\tdeleteCoveredChildren(state, builder, containerPath, container, boundaryIdx + 1, children.length);\n\n\tconst boundaryChild: BlockNode = children[boundaryIdx] as BlockNode;\n\tif (boundaryChild.id === leafId) {\n\t\tconst len: number = getBlockLength(boundaryChild);\n\t\tif (leafOffset < len) builder.deleteTextAt(leafId, leafOffset, len);\n\t\treturn;\n\t}\n\ttrimContainerTail(\n\t\tstate,\n\t\tbuilder,\n\t\t[...containerPath, boundaryChild.id],\n\t\tboundaryChild,\n\t\tleafPath,\n\t\tleafId,\n\t\tleafOffset,\n\t);\n}\n\n/**\n * Trims a container to keep only content from `(leafId, leafOffset)` onward,\n * deleting every child before the boundary at each level and the boundary\n * leaf's head text. Mirrors {@link trimContainerTail}.\n */\nfunction trimContainerHead(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tleafPath: readonly string[],\n\tleafId: BlockId,\n\tleafOffset: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst boundaryIdx: number = boundaryChildIndex(container, leafPath);\n\tif (boundaryIdx < 0) return;\n\n\t// The boundary keeps its identity, so the descent below still finds it.\n\tdeleteCoveredChildren(state, builder, containerPath, container, 0, boundaryIdx);\n\n\tconst boundaryChild: BlockNode = children[boundaryIdx] as BlockNode;\n\tif (boundaryChild.id === leafId) {\n\t\tif (leafOffset > 0) builder.deleteTextAt(leafId, 0, leafOffset);\n\t\treturn;\n\t}\n\ttrimContainerHead(\n\t\tstate,\n\t\tbuilder,\n\t\t[...containerPath, boundaryChild.id],\n\t\tboundaryChild,\n\t\tleafPath,\n\t\tleafId,\n\t\tleafOffset,\n\t);\n}\n","/**\n * Core editor commands and barrel re-exports from submodules.\n *\n * This module contains text insertion, block splitting, block merging,\n * selection deletion, and select-all. Mark, delete, gap-cursor, node-selection,\n * and word-boundary commands are re-exported from their respective modules.\n */\n\nimport {\n\ttype Mark,\n\tcreateEmptyParagraph,\n\tcreateInlineNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetBlockMarksAtOffset,\n\tgetCursorMarks,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n\tisTextSelection,\n\tselectionRange,\n} from '../model/Selection.js';\nimport { type BlockId, inlineType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport {\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../state/NavigationQueries.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { resolveInsertPoint } from './CommandHelpers.js';\nimport { isMarkInclusive } from './CursorMarks.js';\nimport { insertParagraphAtGap, insertTextAtGap } from './GapCursorCommands.js';\nimport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n} from './NodeSelectionCommands.js';\nimport { deleteCrossRootRange, deleteLeafRange, getRootBlockIndex } from './SelectionDeletion.js';\n\n// --- Re-exports from submodules ---\n\nexport {\n\tcanCrossBlockBoundary,\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../state/NavigationQueries.js';\n\nexport type { FeatureConfig } from './MarkCommands.js';\nexport {\n\tisMarkActive,\n\ttoggleBold,\n\ttoggleItalic,\n\ttoggleMark,\n\ttoggleUnderline,\n} from './MarkCommands.js';\n\nexport {\n\tdeleteBackward,\n\tdeleteForward,\n\tdeleteSoftLineBackward,\n\tdeleteSoftLineForward,\n\tdeleteWordBackward,\n\tdeleteWordForward,\n} from './DeleteCommands.js';\n\nexport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n\tnavigateArrowIntoVoid,\n} from './NodeSelectionCommands.js';\n\nexport {\n\tdeleteBackwardAtGap,\n\tdeleteForwardAtGap,\n\tinsertParagraphAtGap,\n\tinsertTextAtGap,\n} from './GapCursorCommands.js';\n\nexport {\n\tfindWordBoundaryBackward,\n\tfindWordBoundaryForward,\n} from './WordBoundary.js';\n\nexport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from './AttributedMarkCommands.js';\n\nexport { forEachBlockIdInRange, forEachBlockInRange } from './RangeIterator.js';\n\n// --- Text Commands ---\n\n/** Inserts text at the current selection, replacing any selected range. */\nexport function insertTextCommand(\n\tstate: EditorState,\n\ttext: string,\n\torigin: 'input' | 'paste' = 'input',\n): Transaction {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert paragraph after void block with the text\n\tif (isNodeSelection(sel)) {\n\t\treturn insertTextAfterNodeSelection(state, sel, text, origin);\n\t}\n\n\t// GapCursor: insert paragraph at the gap position with the text\n\tif (isGapCursor(sel)) {\n\t\treturn insertTextAtGap(state, sel, text, origin);\n\t}\n\n\tconst builder = state.transaction(origin);\n\tconst marks = resolveActiveMarks(state);\n\n\tlet landingId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tlandingId = addDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst resolved = resolveInsertPoint(sel, state.getBlockOrder());\n\tconst insertBlockId: BlockId = landingId ?? resolved.blockId;\n\tconst insertOffset: number = landingId ? 0 : resolved.offset;\n\n\tbuilder.insertText(insertBlockId, insertOffset, text, marks);\n\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + text.length));\n\n\treturn builder.build();\n}\n\n/** Deletes the current selection. */\nexport function deleteSelectionCommand(state: EditorState): Transaction | null {\n\tif (isNodeSelection(state.selection)) {\n\t\treturn deleteNodeSelection(state, state.selection);\n\t}\n\tif (isGapCursor(state.selection)) return null;\n\tif (isCollapsed(state.selection)) return null;\n\n\t// Deleting a selection that spans the whole document resets it to the\n\t// canonical empty state (a single empty paragraph). Without this, the range\n\t// merge keeps the first block's type and attributes, leaving e.g. an empty\n\t// centered title behind so the placeholder never returns.\n\tif (selectionCoversDocument(state)) {\n\t\treturn clearDocument(state);\n\t}\n\n\tconst builder = state.transaction('input');\n\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\tconst cursorBlockId: BlockId = landingId ?? range.from.blockId;\n\tconst cursorOffset: number = landingId ? 0 : range.from.offset;\n\tbuilder.setSelection(createCollapsedSelection(cursorBlockId, cursorOffset));\n\n\treturn builder.build();\n}\n\n/** Splits the current block at the cursor position (Enter key). */\nexport function splitBlockCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert empty paragraph after the void block\n\tif (isNodeSelection(sel)) {\n\t\treturn insertParagraphAfterNodeSelection(state, sel);\n\t}\n\n\t// GapCursor: insert empty paragraph at the gap position\n\tif (isGapCursor(sel)) {\n\t\treturn insertParagraphAtGap(state, sel);\n\t}\n\n\tconst builder = state.transaction('input');\n\n\tlet landingId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tlandingId = addDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst resolved = resolveInsertPoint(sel, state.getBlockOrder());\n\tconst blockId: BlockId = landingId ?? resolved.blockId;\n\tconst offset: number = landingId ? 0 : resolved.offset;\n\tconst newBlockId = generateBlockId();\n\n\t// splitBlock operates at the same level in the tree — the StepApplication\n\t// handles this correctly because it looks up the block by ID recursively.\n\tbuilder.splitBlock(blockId, offset, newBlockId);\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\n/** Inserts a hard line break (InlineNode) at the current cursor position. */\nexport function insertHardBreakCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (!isTextSelection(sel)) return null;\n\n\tconst builder = state.transaction('input');\n\n\tlet cursorBlockId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\t\tcursorBlockId = landingId;\n\t}\n\n\tif (cursorBlockId) {\n\t\t// Cross-root deletion replaced from-block; insert hard break in landing block\n\t\tbuilder.insertInlineNode(cursorBlockId, 0, createInlineNode(inlineType('hard_break')));\n\t\tbuilder.setSelection(createCollapsedSelection(cursorBlockId, 1));\n\t} else {\n\t\tconst { blockId: insertBlockId, offset: insertOffset } = resolveInsertPoint(\n\t\t\tsel,\n\t\t\tstate.getBlockOrder(),\n\t\t);\n\t\tbuilder.insertInlineNode(\n\t\t\tinsertBlockId,\n\t\t\tinsertOffset,\n\t\t\tcreateInlineNode(inlineType('hard_break')),\n\t\t);\n\t\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + 1));\n\t}\n\n\treturn builder.build();\n}\n\n/**\n * Merges the current block with the previous block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockBackward(state: EditorState): Transaction | null {\n\treturn mergeAdjacentBlock(state, 'backward');\n}\n\n/**\n * Merges the next block into the current block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockForward(state: EditorState): Transaction | null {\n\treturn mergeAdjacentBlock(state, 'forward');\n}\n\n/**\n * Shared implementation for merging adjacent blocks in either direction.\n * Validates selection, isolating boundaries, and void blocks before merging.\n */\nfunction mergeAdjacentBlock(\n\tstate: EditorState,\n\tdirection: 'backward' | 'forward',\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return null;\n\n\tconst blockOrder = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.anchor.blockId);\n\n\tconst adjacentIdx: number = direction === 'backward' ? blockIdx - 1 : blockIdx + 1;\n\tif (adjacentIdx < 0 || adjacentIdx >= blockOrder.length) return null;\n\n\tconst adjacentId: BlockId | undefined = blockOrder[adjacentIdx];\n\tif (!adjacentId) return null;\n\n\tif (isIsolatingBlock(state, sel.anchor.blockId) || isIsolatingBlock(state, adjacentId)) {\n\t\treturn null;\n\t}\n\tconst sameParent: boolean = sharesParent(state, sel.anchor.blockId, adjacentId);\n\tif (!sameParent && isInsideIsolating(state, sel.anchor.blockId)) return null;\n\n\tif (isVoidBlock(state, adjacentId)) {\n\t\tconst path = findNodePath(state.doc, adjacentId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(adjacentId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\t// Text merges cannot cross container boundaries: their inverse split must\n\t// restore the source under the same parent as the target.\n\tif (!sameParent) return null;\n\n\tif (direction === 'backward') {\n\t\tconst prevBlock = state.getBlock(adjacentId);\n\t\tif (!prevBlock) return null;\n\t\tconst prevLen: number = getBlockLength(prevBlock);\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.mergeBlocksAt(adjacentId, sel.anchor.blockId)\n\t\t\t.setSelection(createCollapsedSelection(adjacentId, prevLen))\n\t\t\t.build();\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.mergeBlocksAt(sel.anchor.blockId, adjacentId)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Selects all content in the editor, using leaf block endpoints. */\nexport function selectAll(state: EditorState): Transaction {\n\tconst docRange = documentRange(state);\n\tif (!docRange) return state.transaction('command').setSelection(state.selection).build();\n\n\treturn state\n\t\t.transaction('command')\n\t\t.setSelection(createSelection(docRange.from, docRange.to))\n\t\t.build();\n}\n\n// --- Internal Helpers ---\n\ninterface DocumentPosition {\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Endpoints of a full-document selection: the start of the first leaf block to\n * the end of the last leaf block. Returns `null` for an empty document.\n */\nfunction documentRange(\n\tstate: EditorState,\n): { from: DocumentPosition; to: DocumentPosition } | null {\n\tconst blocks = state.doc.children;\n\tconst firstBlock = blocks[0];\n\tconst lastBlock = blocks[blocks.length - 1];\n\tif (!firstBlock || !lastBlock) return null;\n\n\tconst firstLeafId: BlockId = findFirstLeafBlockId(firstBlock);\n\tconst lastLeafId: BlockId = findLastLeafBlockId(lastBlock);\n\tconst lastLeaf = state.getBlock(lastLeafId);\n\tconst lastLeafLen: number = lastLeaf ? getBlockLength(lastLeaf) : 0;\n\n\treturn {\n\t\tfrom: { blockId: firstLeafId, offset: 0 },\n\t\tto: { blockId: lastLeafId, offset: lastLeafLen },\n\t};\n}\n\n/** True when the current text selection spans the entire document. */\nfunction selectionCoversDocument(state: EditorState): boolean {\n\tif (!isTextSelection(state.selection)) return false;\n\tconst docRange = documentRange(state);\n\tif (!docRange) return false;\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\treturn (\n\t\trange.from.blockId === docRange.from.blockId &&\n\t\trange.from.offset === docRange.from.offset &&\n\t\trange.to.blockId === docRange.to.blockId &&\n\t\trange.to.offset === docRange.to.offset\n\t);\n}\n\n/**\n * Replaces the whole document with a single empty paragraph and places the\n * cursor inside it. The fresh paragraph is inserted before the originals are\n * removed so the document never passes through a zero-children state.\n */\nfunction clearDocument(state: EditorState): Transaction {\n\tconst newBlockId: BlockId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tconst originalCount: number = state.doc.children.length;\n\n\tbuilder.insertNode([], 0, createEmptyParagraph(newBlockId));\n\t// The originals shifted to indices 1..originalCount; remove them descending\n\t// so each index stays valid as the document shrinks.\n\tfor (let i = originalCount; i >= 1; i--) {\n\t\tbuilder.removeNode([], i);\n\t}\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\nfunction resolveActiveMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return [];\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return [];\n\n\t// A range replaced by typing inherits the marks at its anchor (raw content\n\t// marks); only a collapsed cursor honors right-boundary inclusivity.\n\tif (!isCollapsed(sel)) return getBlockMarksAtOffset(block, sel.anchor.offset);\n\n\treturn getCursorMarks(block, sel.anchor.offset, (type) => isMarkInclusive(state.schema, type));\n}\n\n/**\n * Adds steps to delete the current text selection.\n * Returns a replacement cursor block ID when the original from-block\n * was inside a composite root that got removed (undefined otherwise).\n */\nexport function addDeleteSelectionSteps(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n): BlockId | undefined {\n\tif (!isTextSelection(state.selection)) return undefined;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(state.selection, blockOrder);\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tif (fromIdx === toIdx) {\n\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, range.to.offset);\n\t\treturn undefined;\n\t}\n\n\tconst fromRootIdx: number = getRootBlockIndex(state, range.from.blockId);\n\tconst toRootIdx: number = getRootBlockIndex(state, range.to.blockId);\n\n\tif (fromRootIdx === toRootIdx || fromRootIdx < 0 || toRootIdx < 0) {\n\t\treturn deleteLeafRange(state, builder, blockOrder, range, fromIdx, toIdx);\n\t}\n\n\treturn deleteCrossRootRange(state, builder, range, fromRootIdx, toRootIdx);\n}\n"],"mappings":"Y,2kBAuBA,SAAgBgC,EACfC,EACAC,GAEA,GAAiB,UAAbA,EAAIC,KACP,OAAOC,EAAgBH,EAAOC,GAI/B,MAAMG,EAAiCJ,EAAMK,gBACvCC,EAAmBF,EAAWG,QAAQN,EAAIO,SAEhD,GAAIF,GAAY,EAAG,OAAO,KAE1B,MAAMG,EAA8BL,EAAWE,EAAW,GAC1D,IAAKG,EAAQ,OAAO,KAEpB,GAAIxB,EAAYe,EAAOS,GAAS,CAC/B,MAAMC,EAAOnC,EAAayB,EAAMW,IAAKF,IAAW,GAChD,OAAOT,EACLY,YAAY,SACZC,aAAalC,EAAoB8B,EAAQC,IACzCI,OACH,CAEA,MAAMC,EAAYf,EAAMgB,SAASP,GACjC,IAAKM,EAAW,OAAO,KACvB,MAAME,EAAkB3C,EAAeyC,GACvC,OAAOf,EAAMY,YAAY,SAASC,aAAajC,EAAyB6B,EAAQQ,IAAUH,OAC3F,CASA,SAAgBI,EACflB,EACAC,GAEA,GAAiB,WAAbA,EAAIC,KACP,OAAOC,EAAgBH,EAAOC,GAI/B,MAAMG,EAAiCJ,EAAMK,gBACvCC,EAAmBF,EAAWG,QAAQN,EAAIO,SAEhD,GAAIF,GAAYF,EAAWe,OAAS,EAAG,OAAO,KAE9C,MAAMC,EAA8BhB,EAAWE,EAAW,GAC1D,IAAKc,EAAQ,OAAO,KAEpB,GAAInC,EAAYe,EAAOoB,GAAS,CAC/B,MAAMV,EAAOnC,EAAayB,EAAMW,IAAKS,IAAW,GAChD,OAAOpB,EACLY,YAAY,SACZC,aAAalC,EAAoByC,EAAQV,IACzCI,OACH,CAEA,OAAOd,EAAMY,YAAY,SAASC,aAAajC,EAAyBwC,EAAQ,IAAIN,OACrF,CA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F,EAAO9E,KAAKgF,IAERxK,EAAYe,EAAO2B,IAAK8H,EAAMhF,KAAK9C,GACxC6H,EAAa7H,EACb,MAAMG,EAA+B9B,EAAMgB,SAASW,GAChDG,GAAOF,EAAmBC,EAASC,EAAOC,EAC/C,CAGAK,EACCpC,EACA6B,EACAoH,EAASS,OAAQ/H,GAAO1C,EAAYe,EAAO2B,KAE5C,IAAK,MAAOgI,KAAaC,KAAcL,EACtC,GAAKI,EACL,IAAK,MAAME,KAAYD,EAAW/H,EAAQ8C,cAAcgF,EAAUE,GAGnE,OAAuB,IAAhBV,OAAoB,EAAYG,CACxC,CC6USQ,CAAgB9J,EAAO6B,EAASzB,EAAY2B,EAAOgH,EAASC,GAG7D1F,EAAqBtD,EAAO6B,EAASE,EAAOwB,EAAaC,EACjE,Q"}
|
|
1
|
+
{"version":3,"file":"Commands-vqbwh6Ic.mjs","names":["getBlockMarksAtOffset","isLeafBlock","getBlockChildren","generateBlockId","getCursorMarks","createInlineNode","createEmptyParagraph","getBlockLength","findNodePath","isCollapsed","isNodeSelection","isTextSelection","createNodeSelection","createCollapsedSelection","createSelection","selectionRange","isGapCursor","inlineType","isVoidBlock","isInsideIsolating","sharesParent","isIsolatingBlock","resolveInsertPoint","findLastLeafBlockId","isEmptyParagraph","resolveSiblingContext","findFirstLeafBlockId","isMarkInclusive","canContain","insertParagraphAfterNodeSelection","insertTextAfterNodeSelection","deleteNodeSelection","deleteBackwardAtGap","state","sel","side","deleteVoidAtGap","blockOrder","getBlockOrder","blockIdx","indexOf","blockId","prevId","path","doc","transaction","setSelection","build","prevBlock","getBlock","prevLen","deleteForwardAtGap","length","nextId","nodeSel","getRootBlockIndex","rootId","children","findIndex","c","id","deleteSelectedText","builder","block","range","from","offset","to","deleteTextAt","removeVoidBlocks","ids","removedPerParent","Map","swappedInForFirst","i","parentPath","siblings","index","parentKey","join","removedBefore","get","set","removeNode","replacementId","insertNode","isTextLeaf","deleteCrossRootRange","fromRootIdx","toRootIdx","fromRoot","toRoot","toLeaf","fromIsLeaf","toIsLeaf","fromAtStart","firstLeafId","toAtEnd","lastLeafId","fromWholesale","toWholesale","landingId","trimContainerTail","trimContainerHead","shift","removeIdxs","push","k","mergeBlocksAt","first","last","hasFlowContent","container","schema","getNodeSpec","type","content","deleteCoveredChildren","containerPath","removable","child","clearBlockContent","only","boundaryChildIndex","leafPath","pos","targetChildId","leafId","leafOffset","boundaryIdx","boundaryChild","len","insertTextCommand","text","origin","selection","insertIdx","Math","max","newId","insertText","insertTextAtGap","marks","resolveActiveMarks","addDeleteSelectionSteps","resolved","insertBlockId","insertOffset","deleteSelectionCommand","docRange","documentRange","selectionCoversDocument","newBlockId","originalCount","clearDocument","cursorBlockId","cursorOffset","splitBlockCommand","insertParagraphAtGap","splitBlock","insertHardBreakCommand","insertInlineNode","mergeBlockBackward","mergeAdjacentBlock","mergeBlockForward","direction","anchor","adjacentIdx","adjacentId","sameParent","selectAll","blocks","firstBlock","lastBlock","lastLeaf","storedMarks","fromIdx","toIdx","rangeIds","slice","survivorIdx","swappedIn","replaceVoidOnlyRange","survivorId","groups","previousId","group","filter","targetId","sourceIds","sourceId","deleteLeafRange"],"sources":["../../src/commands/GapCursorCommands.ts","../../src/commands/SelectionDeletion.ts","../../src/commands/Commands.ts"],"sourcesContent":["/**\n * Commands for GapCursor: deleting void blocks adjacent to gap cursors\n * and inserting paragraphs at gap positions.\n */\n\nimport { createEmptyParagraph, generateBlockId, getBlockLength } from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { GapCursorSelection, NodeSelection } from '../model/Selection.js';\nimport { createCollapsedSelection, createNodeSelection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock } from '../state/NavigationQueries.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { resolveSiblingContext } from './CommandHelpers.js';\nimport { deleteNodeSelection } from './NodeSelectionCommands.js';\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Backspace.\n *\n * - `side === 'after'` → void block is behind the cursor → delete it.\n * - `side === 'before'` → void block is ahead → navigate backward (to previous block).\n * - At document start with `side === 'before'` → `null` (no-op).\n */\nexport function deleteBackwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'after') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'before': navigate to previous block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx <= 0) return null;\n\n\tconst prevId: BlockId | undefined = blockOrder[blockIdx - 1];\n\tif (!prevId) return null;\n\n\tif (isVoidBlock(state, prevId)) {\n\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\tconst prevBlock = state.getBlock(prevId);\n\tif (!prevBlock) return null;\n\tconst prevLen: number = getBlockLength(prevBlock);\n\treturn state.transaction('input').setSelection(createCollapsedSelection(prevId, prevLen)).build();\n}\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Delete.\n *\n * - `side === 'before'` → void block is ahead of the cursor → delete it.\n * - `side === 'after'` → void block is behind → navigate forward (to next block).\n * - At document end with `side === 'after'` → `null` (no-op).\n */\nexport function deleteForwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'before') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'after': navigate to next block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx >= blockOrder.length - 1) return null;\n\n\tconst nextId: BlockId | undefined = blockOrder[blockIdx + 1];\n\tif (!nextId) return null;\n\n\tif (isVoidBlock(state, nextId)) {\n\t\tconst path = findNodePath(state.doc, nextId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(nextId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\treturn state.transaction('input').setSelection(createCollapsedSelection(nextId, 0)).build();\n}\n\n/** Deletes the void block that the GapCursor is adjacent to, delegating to deleteNodeSelection. */\nfunction deleteVoidAtGap(state: EditorState, sel: GapCursorSelection): Transaction | null {\n\tconst path = (findNodePath(state.doc, sel.blockId) ?? []) as BlockId[];\n\tconst nodeSel: NodeSelection = createNodeSelection(sel.blockId, path);\n\treturn deleteNodeSelection(state, nodeSel);\n}\n\n/** Inserts a new paragraph at a GapCursor position (before or after the void block). */\nexport function insertParagraphAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tconst { parentPath, index } = resolveSiblingContext(state, sel.blockId);\n\tif (index < 0) return null;\n\n\tconst insertIdx: number = sel.side === 'before' ? index : index + 1;\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\treturn builder.build();\n}\n\n/** Inserts text in a new paragraph at a GapCursor position. */\nexport function insertTextAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n\ttext: string,\n\torigin: 'input' | 'paste',\n): Transaction {\n\tconst { parentPath, siblings, index } = resolveSiblingContext(state, sel.blockId);\n\tconst insertIdx: number =\n\t\tsel.side === 'before' ? Math.max(index, 0) : index >= 0 ? index + 1 : siblings.length;\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction(origin);\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.insertText(newId, 0, text, []);\n\tbuilder.setSelection(createCollapsedSelection(newId, text.length));\n\treturn builder.build();\n}\n","/**\n * Range-deletion helpers for multi-block text selections, split out of\n * Commands.ts. Handles two cases: a selection whose blocks share one root\n * ancestor (leaf range) and a selection spanning different root ancestors\n * (cross-root range).\n *\n * A void block (image, horizontal rule) at either end of a range is wholly\n * selected — it has no partial content and cannot host the caret — so it is\n * removed outright and never merged into (#224).\n *\n * Containers keep their shape: a free-flowing container (blockquote, list\n * item, table cell) loses the children a range covers, while a fixed-shape one\n * (a table, a table row) keeps every child and only has its content cleared.\n */\n\nimport { canContain } from '../model/ContentModel.js';\nimport type { BlockNode } from '../model/Document.js';\nimport {\n\tcreateEmptyParagraph,\n\tgenerateBlockId,\n\tgetBlockChildren,\n\tgetBlockLength,\n\tisLeafBlock,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock, sharesParent } from '../state/NavigationQueries.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { isEmptyParagraph } from './BlockInsertion.js';\nimport { resolveSiblingContext } from './CommandHelpers.js';\n\n/** A normalized text-selection range (document-order from/to positions). */\nexport interface DeletionRange {\n\treadonly from: { readonly blockId: BlockId; readonly offset: number };\n\treadonly to: { readonly blockId: BlockId; readonly offset: number };\n}\n\n/** Returns the root-level ancestor index in `doc.children` for a given block. */\nexport function getRootBlockIndex(state: EditorState, blockId: BlockId): number {\n\tconst path = findNodePath(state.doc, blockId);\n\tif (!path || path.length === 0) return -1;\n\tconst rootId: string = path[0] as string;\n\treturn state.doc.children.findIndex((c) => c.id === rootId);\n}\n\n/**\n * Deletes a multi-block selection where all blocks share the same root ancestor.\n *\n * Container boundaries survive: only consecutive leaves with the same immediate\n * parent merge into their group's first text leaf. Selected void blocks are\n * removed in place before any merges. Returns the first text leaf when it is\n * not the from-block (the caret then lands at offset 0), or the landing paragraph\n * swapped in when the range is void-only; undefined when the from-block survives.\n */\nexport function deleteLeafRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tblockOrder: readonly BlockId[],\n\trange: DeletionRange,\n\tfromIdx: number,\n\ttoIdx: number,\n): BlockId | undefined {\n\tconst rangeIds: readonly BlockId[] = blockOrder.slice(fromIdx, toIdx + 1);\n\tconst survivorIdx: number = rangeIds.findIndex((id) => !isVoidBlock(state, id));\n\tif (survivorIdx < 0) return replaceVoidOnlyRange(state, builder, rangeIds);\n\tconst survivorId: BlockId = rangeIds[survivorIdx] as BlockId;\n\n\t// Group the original leaf order, including voids: returning to a parent\n\t// after a nested container starts a new group, even if that container's\n\t// only leaf is a selected void that will be replaced below.\n\tconst groups: BlockId[][] = [];\n\tlet previousId: BlockId | undefined;\n\tlet group: BlockId[] = [];\n\tfor (const id of rangeIds) {\n\t\tif (!previousId || !sharesParent(state, previousId, id)) {\n\t\t\tgroup = [];\n\t\t\tgroups.push(group);\n\t\t}\n\t\tif (!isVoidBlock(state, id)) group.push(id);\n\t\tpreviousId = id;\n\t\tconst block: BlockNode | undefined = state.getBlock(id);\n\t\tif (block) deleteSelectedText(builder, block, range);\n\t}\n\t// Positional removals still refer to the original sibling indexes. All voids\n\t// must be removed (last first) before merging shifts any of those indexes.\n\tremoveVoidBlocks(\n\t\tstate,\n\t\tbuilder,\n\t\trangeIds.filter((id) => isVoidBlock(state, id)),\n\t);\n\tfor (const [targetId, ...sourceIds] of groups) {\n\t\tif (!targetId) continue;\n\t\tfor (const sourceId of sourceIds) builder.mergeBlocksAt(targetId, sourceId);\n\t}\n\n\treturn survivorIdx === 0 ? undefined : survivorId;\n}\n\n/** Deletes the part of `block`'s inline content that lies inside `range`. */\nfunction deleteSelectedText(\n\tbuilder: TransactionBuilder,\n\tblock: BlockNode,\n\trange: DeletionRange,\n): void {\n\tconst length: number = getBlockLength(block);\n\tconst from: number = block.id === range.from.blockId ? range.from.offset : 0;\n\tconst to: number = block.id === range.to.blockId ? range.to.offset : length;\n\tif (from < to) builder.deleteTextAt(block.id, from, to);\n}\n\n/**\n * Removes a range made only of void blocks and returns the empty paragraph\n * that takes their place and hosts the caret.\n */\nfunction replaceVoidOnlyRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tids: readonly BlockId[],\n): BlockId | undefined {\n\tconst first: BlockId | undefined = ids[0];\n\tif (!first) return undefined;\n\tconst { parentPath, index } = resolveSiblingContext(state, first);\n\tif (index < 0) return undefined;\n\n\tconst swappedIn: BlockId | undefined = removeVoidBlocks(state, builder, ids);\n\tif (swappedIn) return swappedIn;\n\n\t// Earlier siblings are untouched, so the first block's slot is still `index`.\n\tconst landingId: BlockId = generateBlockId();\n\tbuilder.insertNode(parentPath, index, createEmptyParagraph(landingId));\n\treturn landingId;\n}\n\n/**\n * Removes void blocks in place, last first so positional indexes stay valid.\n * A parent about to lose its last child keeps an empty paragraph instead, so\n * containers such as table cells never end up empty. Returns the paragraph\n * swapped in for the first block, if one was needed.\n */\nfunction removeVoidBlocks(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tids: readonly BlockId[],\n): BlockId | undefined {\n\tconst removedPerParent = new Map<string, number>();\n\tlet swappedInForFirst: BlockId | undefined;\n\n\tfor (let i = ids.length - 1; i >= 0; i--) {\n\t\tconst { parentPath, siblings, index } = resolveSiblingContext(state, ids[i] as BlockId);\n\t\tif (index < 0) continue;\n\t\tconst parentKey: string = parentPath.join('/');\n\t\tconst removedBefore: number = removedPerParent.get(parentKey) ?? 0;\n\t\tremovedPerParent.set(parentKey, removedBefore + 1);\n\n\t\tif (siblings.length - removedBefore > 1) {\n\t\t\tbuilder.removeNode(parentPath, index);\n\t\t\tcontinue;\n\t\t}\n\t\t// Last remaining child (so at index 0): swap in an empty paragraph.\n\t\tconst replacementId: BlockId = generateBlockId();\n\t\tbuilder.insertNode(parentPath, 0, createEmptyParagraph(replacementId));\n\t\tbuilder.removeNode(parentPath, 1);\n\t\tif (i === 0) swappedInForFirst = replacementId;\n\t}\n\n\treturn swappedInForFirst;\n}\n\n/** A leaf block that can hold a caret: any leaf except a void one. */\nfunction isTextLeaf(state: EditorState, block: BlockNode): boolean {\n\treturn isLeafBlock(block) && !isVoidBlock(state, block.id);\n}\n\n/**\n * Deletes a selection spanning different root-level ancestors.\n *\n * The selected span is deleted while every unselected leaf survives. A\n * composite/container root (a multi-block `list_item`, a `blockquote`, a\n * `table`) whose boundary sits *inside* it is trimmed, not wiped: the from-root\n * keeps everything before `range.from`, the to-root keeps everything after\n * `range.to`. Trimming keeps the shape of fixed-shape containers (see\n * {@link hasFlowContent}): the covered cells of a table are cleared, never\n * removed, so its rows keep equal cell counts. A container is removed wholesale\n * only when the boundary lands at its very edge (offset 0 of its first leaf, or\n * the end of its last leaf), so the whole container is genuinely inside the\n * selection. Root blocks strictly between the endpoints are always removed, and\n * a void root at either end is always removed wholesale.\n *\n * Returns the block hosting the caret when the from-root was removed wholesale\n * (its cursor block went with it): the surviving to-leaf, or a landing paragraph\n * inserted in the from-root's slot. Undefined otherwise, since the from boundary\n * leaf then survives and hosts the caret.\n */\nexport function deleteCrossRootRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\trange: DeletionRange,\n\tfromRootIdx: number,\n\ttoRootIdx: number,\n): BlockId | undefined {\n\tconst fromRoot = state.doc.children[fromRootIdx];\n\tconst toRoot = state.doc.children[toRootIdx];\n\tif (!fromRoot || !toRoot) return undefined;\n\n\tconst toLeaf = state.getBlock(range.to.blockId);\n\tif (!toLeaf) return undefined;\n\n\tconst fromIsLeaf: boolean = isTextLeaf(state, fromRoot);\n\tconst toIsLeaf: boolean = isTextLeaf(state, toRoot);\n\n\t// A non-text root is removed wholesale (rather than trimmed) when it is void,\n\t// or when the boundary sits at its very edge and so covers the whole\n\t// container: the from-root's edge is offset 0 of its first leaf, the\n\t// to-root's is the end of its last leaf.\n\tconst fromAtStart: boolean =\n\t\trange.from.offset === 0 && firstLeafId(fromRoot) === range.from.blockId;\n\tconst toAtEnd: boolean =\n\t\trange.to.offset === getBlockLength(toLeaf) && lastLeafId(toRoot) === range.to.blockId;\n\tconst fromWholesale: boolean = !fromIsLeaf && (isLeafBlock(fromRoot) || fromAtStart);\n\tconst toWholesale: boolean = !toIsLeaf && (isLeafBlock(toRoot) || toAtEnd);\n\n\t// --- from side: keep everything before range.from within the from-root ---\n\tif (fromIsLeaf) {\n\t\tdeleteSelectedText(builder, fromRoot, range);\n\t} else if (!fromWholesale) {\n\t\ttrimContainerTail(\n\t\t\tstate,\n\t\t\tbuilder,\n\t\t\t[fromRoot.id],\n\t\t\tfromRoot,\n\t\t\tfindNodePath(state.doc, range.from.blockId) ?? [],\n\t\t\trange.from.blockId,\n\t\t\trange.from.offset,\n\t\t);\n\t}\n\n\t// --- to side: keep everything after range.to within the to-root ---\n\tif (toIsLeaf) {\n\t\tdeleteSelectedText(builder, toRoot, range);\n\t} else if (!toWholesale) {\n\t\ttrimContainerHead(\n\t\t\tstate,\n\t\t\tbuilder,\n\t\t\t[toRoot.id],\n\t\t\ttoRoot,\n\t\t\tfindNodePath(state.doc, range.to.blockId) ?? [],\n\t\t\trange.to.blockId,\n\t\t\trange.to.offset,\n\t\t);\n\t}\n\n\t// --- root-level removals: middle roots always, endpoints only when wholesale ---\n\t// A wholesale-removed from-root takes its cursor block with it. A surviving\n\t// to-leaf slides into the from-root's slot and hosts the caret at its start;\n\t// otherwise a landing paragraph is inserted there for the caret and any\n\t// follow-up insert.\n\tlet landingId: BlockId | undefined;\n\tlet shift = 0;\n\tif (fromWholesale && toIsLeaf) {\n\t\tlandingId = range.to.blockId;\n\t} else if (fromWholesale) {\n\t\tlandingId = generateBlockId();\n\t\tbuilder.insertNode([], fromRootIdx, createEmptyParagraph(landingId));\n\t\tshift = 1;\n\t}\n\n\tconst removeIdxs: number[] = [];\n\tif (fromWholesale) removeIdxs.push(fromRootIdx);\n\tfor (let i = fromRootIdx + 1; i < toRootIdx; i++) removeIdxs.push(i);\n\tif (toWholesale) removeIdxs.push(toRootIdx);\n\t// Descending so each positional removal stays valid against the evolving doc.\n\tfor (let k = removeIdxs.length - 1; k >= 0; k--) {\n\t\tbuilder.removeNode([], (removeIdxs[k] as number) + shift);\n\t}\n\n\t// Join the boundary only when both roots are leaves: their inline content\n\t// merges into one block (the \"outta\" behavior). Merging across a composite\n\t// boundary is deliberately skipped — trimming already preserved every\n\t// unselected leaf, and there is no single valid block to merge into.\n\tif (fromIsLeaf && toIsLeaf) {\n\t\tbuilder.mergeBlocksAt(range.from.blockId, range.to.blockId);\n\t}\n\n\treturn landingId;\n}\n\n/** The id of a block's first leaf descendant (itself when already a leaf). */\nfunction firstLeafId(block: BlockNode): BlockId {\n\tif (isLeafBlock(block)) return block.id;\n\tconst first: BlockNode | undefined = getBlockChildren(block)[0];\n\treturn first ? firstLeafId(first) : block.id;\n}\n\n/** The id of a block's last leaf descendant (itself when already a leaf). */\nfunction lastLeafId(block: BlockNode): BlockId {\n\tif (isLeafBlock(block)) return block.id;\n\tconst children: readonly BlockNode[] = getBlockChildren(block);\n\tconst last: BlockNode | undefined = children[children.length - 1];\n\treturn last ? lastLeafId(last) : block.id;\n}\n\n/**\n * Whether a container's children are free-flowing blocks that a deletion may\n * remove one by one. That holds when its content rule admits a paragraph\n * (blockquote, list item, table cell), since an empty paragraph can always\n * stand in for removed content. Any other container has a fixed shape (a\n * table's rows, a row's cells, which must keep equal counts), so a deletion\n * clears its covered children instead. Without a content rule the shape is\n * unknown, and keeping it is the safe choice.\n */\nfunction hasFlowContent(state: EditorState, container: BlockNode): boolean {\n\tif (!state.schema.getNodeSpec?.(container.type)?.content) return false;\n\treturn canContain(state.schema, container.type, 'paragraph');\n}\n\n/**\n * Deletes the children of `container` in `[from, to)`, last first so positional\n * removals stay valid: a flow container removes them, a fixed-shape container\n * clears them in place (see {@link hasFlowContent}).\n */\nfunction deleteCoveredChildren(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tfrom: number,\n\tto: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst removable: boolean = hasFlowContent(state, container);\n\tfor (let i = to - 1; i >= from; i--) {\n\t\tconst child: BlockNode | undefined = children[i];\n\t\tif (!child) continue;\n\t\tif (removable) builder.removeNode(containerPath, i);\n\t\telse clearBlockContent(state, builder, [...containerPath, child.id], child);\n\t}\n}\n\n/**\n * Empties a fully covered block while keeping the block itself: a flow\n * container ends up holding one empty paragraph (as a cut table cell does), a\n * fixed-shape container clears each child, and a text leaf loses its text. A\n * void leaf has no text (length 0), so it stays as it is.\n */\nfunction clearBlockContent(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tpath: readonly BlockId[],\n\tblock: BlockNode,\n): void {\n\tif (isLeafBlock(block)) {\n\t\tconst length: number = getBlockLength(block);\n\t\tif (length > 0) builder.deleteTextAt(block.id, 0, length);\n\t\treturn;\n\t}\n\n\tconst children: readonly BlockNode[] = getBlockChildren(block);\n\tif (!hasFlowContent(state, block)) {\n\t\tdeleteCoveredChildren(state, builder, path, block, 0, children.length);\n\t\treturn;\n\t}\n\tconst only: BlockNode | undefined = children.length === 1 ? children[0] : undefined;\n\tif (only && isEmptyParagraph(only)) return;\n\tfor (let i = children.length - 1; i >= 0; i--) builder.removeNode(path, i);\n\tbuilder.insertNode(path, 0, createEmptyParagraph(generateBlockId()));\n}\n\n/** Index of the child of `container` on the path to the boundary leaf, or -1. */\nfunction boundaryChildIndex(container: BlockNode, leafPath: readonly string[]): number {\n\tconst pos: number = leafPath.indexOf(container.id);\n\tconst targetChildId: string | undefined = pos >= 0 ? leafPath[pos + 1] : undefined;\n\treturn getBlockChildren(container).findIndex((c) => c.id === targetChildId);\n}\n\n/**\n * Trims a container to keep only content up to `(leafId, leafOffset)`, deleting\n * every child after the boundary at each level (see {@link deleteCoveredChildren})\n * and the boundary leaf's tail text. `containerPath` is the path to (and\n * including) `container`; `leafPath` is the boundary leaf's full node path, used\n * to descend to the boundary child.\n */\nfunction trimContainerTail(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tleafPath: readonly string[],\n\tleafId: BlockId,\n\tleafOffset: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst boundaryIdx: number = boundaryChildIndex(container, leafPath);\n\tif (boundaryIdx < 0) return;\n\n\tdeleteCoveredChildren(state, builder, containerPath, container, boundaryIdx + 1, children.length);\n\n\tconst boundaryChild: BlockNode = children[boundaryIdx] as BlockNode;\n\tif (boundaryChild.id === leafId) {\n\t\tconst len: number = getBlockLength(boundaryChild);\n\t\tif (leafOffset < len) builder.deleteTextAt(leafId, leafOffset, len);\n\t\treturn;\n\t}\n\ttrimContainerTail(\n\t\tstate,\n\t\tbuilder,\n\t\t[...containerPath, boundaryChild.id],\n\t\tboundaryChild,\n\t\tleafPath,\n\t\tleafId,\n\t\tleafOffset,\n\t);\n}\n\n/**\n * Trims a container to keep only content from `(leafId, leafOffset)` onward,\n * deleting every child before the boundary at each level and the boundary\n * leaf's head text. Mirrors {@link trimContainerTail}.\n */\nfunction trimContainerHead(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tleafPath: readonly string[],\n\tleafId: BlockId,\n\tleafOffset: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst boundaryIdx: number = boundaryChildIndex(container, leafPath);\n\tif (boundaryIdx < 0) return;\n\n\t// The boundary keeps its identity, so the descent below still finds it.\n\tdeleteCoveredChildren(state, builder, containerPath, container, 0, boundaryIdx);\n\n\tconst boundaryChild: BlockNode = children[boundaryIdx] as BlockNode;\n\tif (boundaryChild.id === leafId) {\n\t\tif (leafOffset > 0) builder.deleteTextAt(leafId, 0, leafOffset);\n\t\treturn;\n\t}\n\ttrimContainerHead(\n\t\tstate,\n\t\tbuilder,\n\t\t[...containerPath, boundaryChild.id],\n\t\tboundaryChild,\n\t\tleafPath,\n\t\tleafId,\n\t\tleafOffset,\n\t);\n}\n","/**\n * Core editor commands and barrel re-exports from submodules.\n *\n * This module contains text insertion, block splitting, block merging,\n * selection deletion, and select-all. Mark, delete, gap-cursor, node-selection,\n * and word-boundary commands are re-exported from their respective modules.\n */\n\nimport {\n\ttype Mark,\n\tcreateEmptyParagraph,\n\tcreateInlineNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetBlockMarksAtOffset,\n\tgetCursorMarks,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n\tisTextSelection,\n\tselectionRange,\n} from '../model/Selection.js';\nimport { type BlockId, inlineType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport {\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../state/NavigationQueries.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { resolveInsertPoint } from './CommandHelpers.js';\nimport { isMarkInclusive } from './CursorMarks.js';\nimport { insertParagraphAtGap, insertTextAtGap } from './GapCursorCommands.js';\nimport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n} from './NodeSelectionCommands.js';\nimport { deleteCrossRootRange, deleteLeafRange, getRootBlockIndex } from './SelectionDeletion.js';\n\n// --- Re-exports from submodules ---\n\nexport {\n\tcanCrossBlockBoundary,\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../state/NavigationQueries.js';\n\nexport type { FeatureConfig } from './MarkCommands.js';\nexport {\n\tisMarkActive,\n\ttoggleBold,\n\ttoggleItalic,\n\ttoggleMark,\n\ttoggleUnderline,\n} from './MarkCommands.js';\n\nexport {\n\tdeleteBackward,\n\tdeleteForward,\n\tdeleteSoftLineBackward,\n\tdeleteSoftLineForward,\n\tdeleteWordBackward,\n\tdeleteWordForward,\n} from './DeleteCommands.js';\n\nexport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n\tnavigateArrowIntoVoid,\n} from './NodeSelectionCommands.js';\n\nexport {\n\tdeleteBackwardAtGap,\n\tdeleteForwardAtGap,\n\tinsertParagraphAtGap,\n\tinsertTextAtGap,\n} from './GapCursorCommands.js';\n\nexport {\n\tfindWordBoundaryBackward,\n\tfindWordBoundaryForward,\n} from './WordBoundary.js';\n\nexport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from './AttributedMarkCommands.js';\n\nexport { forEachBlockIdInRange, forEachBlockInRange } from './RangeIterator.js';\n\n// --- Text Commands ---\n\n/** Inserts text at the current selection, replacing any selected range. */\nexport function insertTextCommand(\n\tstate: EditorState,\n\ttext: string,\n\torigin: 'input' | 'paste' = 'input',\n): Transaction {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert paragraph after void block with the text\n\tif (isNodeSelection(sel)) {\n\t\treturn insertTextAfterNodeSelection(state, sel, text, origin);\n\t}\n\n\t// GapCursor: insert paragraph at the gap position with the text\n\tif (isGapCursor(sel)) {\n\t\treturn insertTextAtGap(state, sel, text, origin);\n\t}\n\n\tconst builder = state.transaction(origin);\n\tconst marks = resolveActiveMarks(state);\n\n\tlet landingId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tlandingId = addDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst resolved = resolveInsertPoint(sel, state.getBlockOrder());\n\tconst insertBlockId: BlockId = landingId ?? resolved.blockId;\n\tconst insertOffset: number = landingId ? 0 : resolved.offset;\n\n\tbuilder.insertText(insertBlockId, insertOffset, text, marks);\n\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + text.length));\n\n\treturn builder.build();\n}\n\n/** Deletes the current selection. */\nexport function deleteSelectionCommand(state: EditorState): Transaction | null {\n\tif (isNodeSelection(state.selection)) {\n\t\treturn deleteNodeSelection(state, state.selection);\n\t}\n\tif (isGapCursor(state.selection)) return null;\n\tif (isCollapsed(state.selection)) return null;\n\n\t// Deleting a selection that spans the whole document resets it to the\n\t// canonical empty state (a single empty paragraph). Without this, the range\n\t// merge keeps the first block's type and attributes, leaving e.g. an empty\n\t// centered title behind so the placeholder never returns.\n\tif (selectionCoversDocument(state)) {\n\t\treturn clearDocument(state);\n\t}\n\n\tconst builder = state.transaction('input');\n\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\tconst cursorBlockId: BlockId = landingId ?? range.from.blockId;\n\tconst cursorOffset: number = landingId ? 0 : range.from.offset;\n\tbuilder.setSelection(createCollapsedSelection(cursorBlockId, cursorOffset));\n\n\treturn builder.build();\n}\n\n/** Splits the current block at the cursor position (Enter key). */\nexport function splitBlockCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert empty paragraph after the void block\n\tif (isNodeSelection(sel)) {\n\t\treturn insertParagraphAfterNodeSelection(state, sel);\n\t}\n\n\t// GapCursor: insert empty paragraph at the gap position\n\tif (isGapCursor(sel)) {\n\t\treturn insertParagraphAtGap(state, sel);\n\t}\n\n\tconst builder = state.transaction('input');\n\n\tlet landingId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tlandingId = addDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst resolved = resolveInsertPoint(sel, state.getBlockOrder());\n\tconst blockId: BlockId = landingId ?? resolved.blockId;\n\tconst offset: number = landingId ? 0 : resolved.offset;\n\tconst newBlockId = generateBlockId();\n\n\t// splitBlock operates at the same level in the tree — the StepApplication\n\t// handles this correctly because it looks up the block by ID recursively.\n\tbuilder.splitBlock(blockId, offset, newBlockId);\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\n/** Inserts a hard line break (InlineNode) at the current cursor position. */\nexport function insertHardBreakCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (!isTextSelection(sel)) return null;\n\n\tconst builder = state.transaction('input');\n\n\tlet cursorBlockId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\t\tcursorBlockId = landingId;\n\t}\n\n\tif (cursorBlockId) {\n\t\t// Cross-root deletion replaced from-block; insert hard break in landing block\n\t\tbuilder.insertInlineNode(cursorBlockId, 0, createInlineNode(inlineType('hard_break')));\n\t\tbuilder.setSelection(createCollapsedSelection(cursorBlockId, 1));\n\t} else {\n\t\tconst { blockId: insertBlockId, offset: insertOffset } = resolveInsertPoint(\n\t\t\tsel,\n\t\t\tstate.getBlockOrder(),\n\t\t);\n\t\tbuilder.insertInlineNode(\n\t\t\tinsertBlockId,\n\t\t\tinsertOffset,\n\t\t\tcreateInlineNode(inlineType('hard_break')),\n\t\t);\n\t\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + 1));\n\t}\n\n\treturn builder.build();\n}\n\n/**\n * Merges the current block with the previous block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockBackward(state: EditorState): Transaction | null {\n\treturn mergeAdjacentBlock(state, 'backward');\n}\n\n/**\n * Merges the next block into the current block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockForward(state: EditorState): Transaction | null {\n\treturn mergeAdjacentBlock(state, 'forward');\n}\n\n/**\n * Shared implementation for merging adjacent blocks in either direction.\n * Validates selection, isolating boundaries, and void blocks before merging.\n */\nfunction mergeAdjacentBlock(\n\tstate: EditorState,\n\tdirection: 'backward' | 'forward',\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return null;\n\n\tconst blockOrder = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.anchor.blockId);\n\n\tconst adjacentIdx: number = direction === 'backward' ? blockIdx - 1 : blockIdx + 1;\n\tif (adjacentIdx < 0 || adjacentIdx >= blockOrder.length) return null;\n\n\tconst adjacentId: BlockId | undefined = blockOrder[adjacentIdx];\n\tif (!adjacentId) return null;\n\n\tif (isIsolatingBlock(state, sel.anchor.blockId) || isIsolatingBlock(state, adjacentId)) {\n\t\treturn null;\n\t}\n\tconst sameParent: boolean = sharesParent(state, sel.anchor.blockId, adjacentId);\n\tif (!sameParent && isInsideIsolating(state, sel.anchor.blockId)) return null;\n\n\tif (isVoidBlock(state, adjacentId)) {\n\t\tconst path = findNodePath(state.doc, adjacentId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(adjacentId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\t// Text merges cannot cross container boundaries: their inverse split must\n\t// restore the source under the same parent as the target.\n\tif (!sameParent) return null;\n\n\tif (direction === 'backward') {\n\t\tconst prevBlock = state.getBlock(adjacentId);\n\t\tif (!prevBlock) return null;\n\t\tconst prevLen: number = getBlockLength(prevBlock);\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.mergeBlocksAt(adjacentId, sel.anchor.blockId)\n\t\t\t.setSelection(createCollapsedSelection(adjacentId, prevLen))\n\t\t\t.build();\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.mergeBlocksAt(sel.anchor.blockId, adjacentId)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Selects all content in the editor, using leaf block endpoints. */\nexport function selectAll(state: EditorState): Transaction {\n\tconst docRange = documentRange(state);\n\tif (!docRange) return state.transaction('command').setSelection(state.selection).build();\n\n\treturn state\n\t\t.transaction('command')\n\t\t.setSelection(createSelection(docRange.from, docRange.to))\n\t\t.build();\n}\n\n// --- Internal Helpers ---\n\ninterface DocumentPosition {\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Endpoints of a full-document selection: the start of the first leaf block to\n * the end of the last leaf block. Returns `null` for an empty document.\n */\nfunction documentRange(\n\tstate: EditorState,\n): { from: DocumentPosition; to: DocumentPosition } | null {\n\tconst blocks = state.doc.children;\n\tconst firstBlock = blocks[0];\n\tconst lastBlock = blocks[blocks.length - 1];\n\tif (!firstBlock || !lastBlock) return null;\n\n\tconst firstLeafId: BlockId = findFirstLeafBlockId(firstBlock);\n\tconst lastLeafId: BlockId = findLastLeafBlockId(lastBlock);\n\tconst lastLeaf = state.getBlock(lastLeafId);\n\tconst lastLeafLen: number = lastLeaf ? getBlockLength(lastLeaf) : 0;\n\n\treturn {\n\t\tfrom: { blockId: firstLeafId, offset: 0 },\n\t\tto: { blockId: lastLeafId, offset: lastLeafLen },\n\t};\n}\n\n/** True when the current text selection spans the entire document. */\nfunction selectionCoversDocument(state: EditorState): boolean {\n\tif (!isTextSelection(state.selection)) return false;\n\tconst docRange = documentRange(state);\n\tif (!docRange) return false;\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\treturn (\n\t\trange.from.blockId === docRange.from.blockId &&\n\t\trange.from.offset === docRange.from.offset &&\n\t\trange.to.blockId === docRange.to.blockId &&\n\t\trange.to.offset === docRange.to.offset\n\t);\n}\n\n/**\n * Replaces the whole document with a single empty paragraph and places the\n * cursor inside it. The fresh paragraph is inserted before the originals are\n * removed so the document never passes through a zero-children state.\n */\nfunction clearDocument(state: EditorState): Transaction {\n\tconst newBlockId: BlockId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tconst originalCount: number = state.doc.children.length;\n\n\tbuilder.insertNode([], 0, createEmptyParagraph(newBlockId));\n\t// The originals shifted to indices 1..originalCount; remove them descending\n\t// so each index stays valid as the document shrinks.\n\tfor (let i = originalCount; i >= 1; i--) {\n\t\tbuilder.removeNode([], i);\n\t}\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\n/** The marks text typed over the current selection receives. */\nexport function resolveActiveMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return [];\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return [];\n\n\t// A range replaced by typing inherits the marks at its anchor (raw content\n\t// marks); only a collapsed cursor honors right-boundary inclusivity.\n\tif (!isCollapsed(sel)) return getBlockMarksAtOffset(block, sel.anchor.offset);\n\n\treturn getCursorMarks(block, sel.anchor.offset, (type) => isMarkInclusive(state.schema, type));\n}\n\n/**\n * Adds steps to delete the current text selection.\n * Returns a replacement cursor block ID when the original from-block\n * was inside a composite root that got removed (undefined otherwise).\n */\nexport function addDeleteSelectionSteps(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n): BlockId | undefined {\n\tif (!isTextSelection(state.selection)) return undefined;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(state.selection, blockOrder);\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tif (fromIdx === toIdx) {\n\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, range.to.offset);\n\t\treturn undefined;\n\t}\n\n\tconst fromRootIdx: number = getRootBlockIndex(state, range.from.blockId);\n\tconst toRootIdx: number = getRootBlockIndex(state, range.to.blockId);\n\n\tif (fromRootIdx === toRootIdx || fromRootIdx < 0 || toRootIdx < 0) {\n\t\treturn deleteLeafRange(state, builder, blockOrder, range, fromIdx, toIdx);\n\t}\n\n\treturn deleteCrossRootRange(state, builder, range, fromRootIdx, toRootIdx);\n}\n"],"mappings":"Y,2kBAuBA,SAAgBgC,EACfC,EACAC,GAEA,GAAiB,UAAbA,EAAIC,KACP,OAAOC,EAAgBH,EAAOC,GAI/B,MAAMG,EAAiCJ,EAAMK,gBACvCC,EAAmBF,EAAWG,QAAQN,EAAIO,SAEhD,GAAIF,GAAY,EAAG,OAAO,KAE1B,MAAMG,EAA8BL,EAAWE,EAAW,GAC1D,IAAKG,EAAQ,OAAO,KAEpB,GAAIxB,EAAYe,EAAO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,EAAO6B,EAASE,EAAOwB,EAAaC,EACjE,Q"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as t,n as e}from"./HTMLUtils-DTpsjZyK.mjs";import{P as n,_ as o,g as r,m as s,p as a,z as i}from"./Document-ssR6hBzG.mjs";import{a as c,i as l,r as u}from"./TypeBrands-Ch9856Gb.mjs";import{n as d}from"./ContentModel-dkGOh3N7.mjs";import{C as f,S as p,T as h,c as g,f as m,g as y,h as N,n as T,o as E,r as A,s as b,t as k}from"./TableDimensions-B-OWjTuW.mjs";import{r as L,t as O}from"./HTMLSanitization-BRipXyhI.mjs";var w=/* @__PURE__ */new Set(["p","div","ul","ol","table","blockquote","pre"]);function v(t,e){const n=t.tagName.toLowerCase();for(const{rule:o,type:r}of e){if(o.tag!==n)continue;const e=o.getAttrs?.(t);if(!1!==e)return{type:r,...e?{attrs:e}:{}}}return null}function D(t,e,n){const o=t.tagName.toLowerCase(),r=[...e];for(const{rule:s,type:a}of n){if(s.tag!==o||r.some(t=>t.type===a))continue;const e=s.getAttrs?.(t);!1!==e&&r.push({type:l(a),...e&&Object.keys(e).length>0?{attrs:e}:{}})}return r}function C(t,e,n,o=w){return!v(t,n)&&(o.has(t.tagName.toLowerCase())||null!==v(t,e))}function _(t,e,n,o=w){return R(e,n,o)(t)}function R(t,e,n=w){const o=/* @__PURE__ */new WeakMap,r=s=>{const a=o.get(s);if(void 0!==a)return a;const i=!v(s,e)&&Array.from(s.children).some(o=>{const s=o;return C(s,t,e,n)||r(s)});return o.set(s,i),i};return r}var x=/[ \t\n\r\f]+/g,I=/* @__PURE__ */new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","UL","OL","LI","TABLE","THEAD","TBODY","TFOOT","TR","TD","TH","HR","FIGURE","FIGCAPTION","SECTION","ARTICLE","HEADER","FOOTER","MAIN","ASIDE","NAV","DL","DT","DD"]),M=/* @__PURE__ */new Set(["PRE","TEXTAREA"]),S=/* @__PURE__ */new Set(["pre","pre-wrap","pre-line","break-spaces"]);function j(t){P(t)}function P(t){const e={lastTextNode:null,collapsePending:!0};for(const n of Array.from(t.childNodes))H(n,e);B(e.lastTextNode)}function H(t,e){if(t.nodeType===Node.TEXT_NODE)return void function(t,e){let n=t.data.replace(x," ");e.collapsePending&&n.startsWith(" ")&&(n=n.slice(1)),t.data=n,0!==n.length&&(e.collapsePending=n.endsWith(" "),e.lastTextNode=t)}(t,e);if(t.nodeType!==Node.ELEMENT_NODE)return;const n=t;if(function(t){if(M.has(t.tagName))return!0;const e=(t.style?.whiteSpace??"").toLowerCase();return S.has(e)}(n))W(e);else{if(function(t){return I.has(t.tagName)}(n))return W(e),void P(n);for(const t of Array.from(n.childNodes))H(t,e)}}function W(t){B(t.lastTextNode),t.lastTextNode=null,t.collapsePending=!0}function B(t){t?.data.endsWith(" ")&&(t.data=t.data.slice(0,-1))}function X(t){const e=t.ownerDocument.createTreeWalker(t),n=[];let o=e.nextNode();for(;o;)o.nodeType===Node.TEXT_NODE?n.push(o.textContent??""):"BR"===o.nodeName&&n.push("\n"),o=e.nextNode();return n.join("")}function q(t,e){!function(t){for(const e of Array.from(t.querySelectorAll("[style]"))){const t=F(e);if(!t||t.length>0)continue;const n=e.getAttribute("style")??"";p(n).length>256||(t.cssText=n)}}(t),y(t,e,256)}function F(t){return t.style}function U(t,n,o){const r=[...n?n.getAllowedTags():["p","br","div","span"],"pre"],a=n?n.getAllowedAttrs():["style","dir","id"];a.includes("data-block-id")||a.push("data-block-id"),o?.styleMap&&!a.includes("class")&&a.push("class");const i=L(t,{ALLOWED_TAGS:r,ALLOWED_ATTR:a,ALLOWED_URI_REGEXP:e,...O()},n);q(i,N(n,o?.styleMap)),j(i);const c=function(t){const e=t?.getBlockParseRules()??[],n=t?.getInlineParseRules()??[],o=t?.getMarkParseRules()??[],r=/* @__PURE__ */new WeakMap,s=t=>{const e=r.get(t);if(e)return e;const n=t.parentElement,a=D(t,n?s(n):[],o);return r.set(t,a),a};return{registry:t,blockRules:e,inlineRules:n,markRules:o,adoptedIds:/* @__PURE__ */new Set,hasBlockDescendants:R(e,n),ancestorMarks:t=>t.parentElement?s(t.parentElement):[]}}(n),l=[];for(const e of Array.from(i.childNodes))G(e,l,c);if(0===l.length)return s();const u=s(l);return n?d(u,n):u}function G(t,e,n){const{adoptedIds:r,registry:s}=n;if(t.nodeType===Node.ELEMENT_NODE){const i=t,l=i.tagName.toLowerCase();if("ul"===l||"ol"===l){const t="ol"===l?"ordered":"bullet",o=i.getAttribute("dir");return void V(i,t,0,e,n,o&&m.has(o)?o:void 0)}if("table"===l)return void function(t,e,n){const{adoptedIds:o,registry:r}=n,s=[],i=function(t){const e=[];for(const n of Array.from(t.children)){const t=n.tagName.toLowerCase();if("col"===t){K(n,void 0,e);continue}if("colgroup"!==t)continue;const o=n,r=Y(o),s=Array.from(o.children).filter(t=>"col"===t.tagName.toLowerCase());if(0!==s.length)for(const n of s)K(n,r,e);else Q(r,b(o.getAttribute("span")),e)}return E(e)}(t),l=!r||!!r.getNodeSpec("table_cell")?.attrs?.align,u=function(t){const e=[];for(const n of Array.from(t.children)){const t=n.tagName.toLowerCase();if("tr"===t)e.push(n);else if("thead"===t||"tbody"===t||"tfoot"===t)for(const o of Array.from(n.children))"tr"===o.tagName.toLowerCase()&&e.push(o)}return e}(t);for(const d of u){const t=[];for(const r of Array.from(d.children)){const e=r.tagName.toLowerCase();if("td"!==e&&"th"!==e)continue;const s=r,i=tt(s,n),u={};$(s,u),l&<(s,u);const d=a(c("table_cell"),i,f(s,o),Object.keys(u).length>0?u:void 0,ct(s));t.push(d)}const e={};J(d,e),s.push(a(c("table_row"),t,f(d,o),Object.keys(e).length>0?e:void 0,ct(d)))}if(s.length>0){const n={};!function(t,e){const n=t.getAttribute("style")??"",o=Z.exec(n);o?.[1]&&(e.borderColor="transparent"===o[1]?"none":o[1])}(t,n),i&&(n.columnWidthsPx=i),e.push(a(c("table"),s,f(t,o),Object.keys(n).length>0?n:void 0,ct(t)))}}(i,e,n);if("blockquote"===l)return void function(t,e,n){const r=et(t,n);0===r.length&&r.push(a(c("paragraph"),[o("")]));const s={};lt(t,s),it(t,s),e.push(a(c("blockquote"),r,f(t,n.adoptedIds),Object.keys(s).length>0?s:void 0,ct(t)))}(i,e,n);const u=v(i,n.blockRules);if("pre"===l&&!u)return void function(t,e,n){const r={};lt(t,r),it(t,r);for(const[s,i]of X(t).split("\n").entries())e.push(a(c("paragraph"),[o(i)],0===s?f(t,n.adoptedIds):void 0,Object.keys(r).length>0?r:void 0,0===s?ct(t):void 0))}(i,e,n);if("paragraph"===(u?.type??"paragraph")&&n.hasBlockDescendants(i))return void function(t,e,n){const o={};lt(t,o),it(t,o);const r=et(t,n);for(const s of r)e.push(ot(s,o,n.registry))}(i,e,n);const d=u?s?.getNodeSpec(u.type):void 0,p=d?.isVoid?[o("")]:"code_block"===u?.type?[o(X(i))]:rt(i,n),h={...u?.attrs};u&&!d?.attrs?.align||lt(i,h),u&&!d?.attrs?.dir||it(i,h),e.push(a(c(u?.type??"paragraph"),p,f(i,r),Object.keys(h).length>0?h:void 0,ct(i)))}else t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()&&e.push(a(c("paragraph"),[o(t.textContent.trim())]))}function V(t,e,n,o,r,s){for(const a of Array.from(t.children)){const t=a.tagName.toLowerCase();if("li"===t){const t=a,i=t.querySelector(':scope > input[type="checkbox"]'),c={listType:null!==i?"checklist":e,indent:n,checked:i?.hasAttribute("checked")??!1},l=t.getAttribute("dir"),u=l&&m.has(l)?l:s;u&&(c.dir=u),o.push(z(t,c,i,r));for(const e of Array.from(t.children)){const t=e.tagName.toLowerCase();if("ul"===t||"ol"===t){const s="ol"===t?"ordered":"bullet",a=e.getAttribute("dir");V(e,s,n+1,o,r,a&&m.has(a)?a:u)}}}else if("ul"===t||"ol"===t){const e="ol"===t?"ordered":"bullet",i=a.getAttribute("dir");V(a,e,n+1,o,r,i&&m.has(i)?i:s)}}}function z(t,e,r,s){const{adoptedIds:i}=s,l=ct(t),u=t=>{if(t.nodeType!==Node.ELEMENT_NODE)return!1;const e=t.tagName.toLowerCase();return"ul"===e||"ol"===e};if(!Array.from(t.childNodes).some(t=>!u(t)&&nt(t,s))){const n=rt(t,s,!0);return a(c("list_item"),n,f(t,i),e,l)}const d=et(t,s,t=>u(t)||t===r),p=1===d.length?d[0]:void 0;return!p||"paragraph"!==p.type||p.attrs||p.htmlId?0===d.length?a(c("list_item"),[o("")],f(t,i),e,l):a(c("list_item"),d,f(t,i),e,l):a(c("list_item"),n(p),f(t,i),e,l)}function K(t,e,n){Q(Y(t)??e,b(t.getAttribute("span")),n)}function Q(t,e,n){const o=k-n.length,r=Math.min(e,Math.max(0,o));for(let s=0;s<r;s++)n.push(t??null)}function Y(t){return g(t,T,["width"],"width")}function J(t,e){const n=g(t,A,["min-height","height"],"height");void 0!==n&&(e.minHeightPx=n)}var Z=/--ntbl-bc:\s*(#[0-9a-fA-F]{3,8}|transparent)/;function $(t,e){const n=t.getAttribute("colspan");if(n){const t=b(n);t>1&&(e.colspan=t)}const o=t.getAttribute("rowspan");if(o){const t=b(o);t>1&&(e.rowspan=t)}}function tt(t,e){const n=et(t,e);return 0===n.length&&n.push(a(c("paragraph"),[o("")])),n}function et(t,e,n){const o=[];let r=[];const s=()=>{(function(t){for(const e of t){if(e.nodeType===Node.ELEMENT_NODE)return!0;if(e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())return!0}return!1})(r)&&o.push(a(c("paragraph"),st(r,e))),r=[]};for(const a of Array.from(t.childNodes))n?.(a)||(nt(a,e)?(s(),G(a,o,e)):r.push(a));return s(),o}function nt(t,e){if(t.nodeType!==Node.ELEMENT_NODE)return!1;const n=t;return C(n,e.blockRules,e.inlineRules)||e.hasBlockDescendants(n)}function ot(t,e,n){const o=n?.getNodeSpec(t.type),r={...t.attrs};let s=!1;for(const[a,i]of Object.entries(e))void 0===r[a]&&(n&&!o?.attrs?.[a]||(r[a]=i,s=!0));return s?a(t.type,t.children,t.id,r,t.htmlId):t}function rt(t,e,n){return st([t],e,n)}function st(t,e,n){const r=[];for(const o of t)at(o,e.ancestorMarks(o),r,e.markRules,e.inlineRules,n);return 1===r.length&&i(r[0])&&"hard_break"===r[0].inlineType?[o("")]:r.length>0?r:[o("")]}function at(t,e,n,s,a,i){if(t.nodeType===Node.TEXT_NODE){const r=t.textContent??"";return void(r&&n.push(o(r,[...e])))}if(t.nodeType!==Node.ELEMENT_NODE)return;const c=t,l=c.tagName.toLowerCase();if(i&&("ul"===l||"ol"===l))return;if(i&&"input"===l&&"checkbox"===c.getAttribute("type"))return;const d=v(c,a);if(d)return void n.push(r(u(d.type),d.attrs,e));const f=D(c,e,s);for(const o of Array.from(c.childNodes))at(o,f,n,s,a,i)}function it(t,e){const n=t.getAttribute("dir");if(n&&m.has(n))return void(e.dir=n);const o=t.style?.direction??"";o&&m.has(o)&&(e.dir=o)}function ct(e){return t(e.getAttribute("id"))}function lt(t,e){const n=h(t);n&&(e.align=n)}export{R as a,v as c,j as i,D as l,q as n,_ as o,X as r,C as s,U as t};
|
|
2
|
+
//# sourceMappingURL=DocumentParser-D4g5npEi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentParser-D4g5npEi.mjs","names":["normalizeHTMLId","SAFE_URI_REGEXP","getInlineChildren","createTextNode","createInlineNode","createDocument","createBlockNode","isInlineNode","nodeType","markType","inlineType","hoistDisallowedBlocks","adoptBlockId","splitDeclarations","readElementAlignment","readTableDimensionPx","VALID_DIRECTIONS","rehydrateStyleClasses","createClassDeclarationResolver","TABLE_COLUMN_WIDTH_DATA_ATTRIBUTE","normalizeTableColumnWidthsPx","TABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE","parseTableColumnSpan","MAX_SERIALIZED_TABLE_COLUMNS","sanitizeHTMLFragment","preserveHTMLIdSanitizeConfig","BLOCK_TAGS","Set","matchHTMLParseRule","element","rules","tag","tagName","toLowerCase","rule","type","attrs","getAttrs","parseHTMLMarks","el","currentMarks","markRules","marks","some","mark","push","Object","keys","length","isHTMLBlockElement","blockRules","inlineRules","blockTags","has","hasHTMLBlockDescendants","createBlockDescendantCheck","known","WeakMap","check","cached","get","result","Array","from","children","child","set","COLLAPSIBLE_WHITESPACE","FLOW_BLOCK_TAGS","PRESERVE_TAGS","PRESERVE_WHITESPACE_VALUES","normalizeHTMLWhitespace","root","normalizeContext","container","state","lastTextNode","collapsePending","childNodes","processNode","trimTrailingSpace","node","Node","TEXT_NODE","text","data","replace","startsWith","slice","endsWith","collapseTextNode","ELEMENT_NODE","whiteSpace","style","isPreserveElement","endInlineRun","isFlowBlockElement","readPreformattedText","walker","ownerDocument","createTreeWalker","parts","nextNode","textContent","nodeName","join","rehydrateStyles","resolveClass","querySelectorAll","inlineStyleOf","getAttribute","cssText","restoreInlineStyles","parseHTMLToDocument","html","registry","options","allowedTags","getAllowedTags","allowedAttrs","getAllowedAttrs","includes","styleMap","ALLOWED_TAGS","ALLOWED_ATTR","ALLOWED_URI_REGEXP","session","getBlockParseRules","getInlineParseRules","getMarkParseRules","ownMarks","marksOf","parent","parentElement","adoptedIds","hasBlockDescendants","ancestorMarks","createHTMLParseSession","blocks","parseChildNode","doc","listType","listDir","parseListElement","tableEl","rows","columnWidthsPx","widths","appendColumnElementWidths","groupEl","groupWidth","readTableColumnWidthPx","columns","filter","column","appendRepeatedWidth","extractTableColumnWidthsPx","cellsAlign","getNodeSpec","align","rowElements","nested","collectTableRows","trEl","cells","cellChild","cellTag","cellEl","cellContent","parseTableCellContent","cellAttrs","extractCellSpanAttrs","extractAlignment","cellBlock","extractHTMLId","rowAttrs","extractTableRowMinHeight","tableAttrs","match","BORDER_COLOR_RE","exec","borderColor","extractTableBorderColor","parseTableElement","innerBlocks","parseBlockContainerChildren","extractDirection","parseBlockquoteElement","index","line","split","entries","parsePreformattedFallback","inherited","block","inheritBlockAttrs","parseWrapperElement","spec","isVoid","parseElementToInlineContent","dir","trim","listEl","depth","parentDir","li","checkbox","querySelector","indent","checked","hasAttribute","liDir","effectiveDir","parseListItemBlock","liChild","liChildTag","nestedType","nestedDir","htmlId","isHoistedList","isBlockLevelChild","inlineContent","only","inheritedWidth","width","span","remaining","count","Math","min","max","row","minHeightPx","colspan","value","rowspan","cellBlocks","skip","inlineRun","flushInlineRun","nodes","inlineRunHasContent","parseNodesToInlineContent","changed","name","id","skipNestedLists","walkElement","inlineMatch","styleDir","direction"],"sources":["../../src/serialization/HTMLParseRules.ts","../../src/serialization/HTMLParseSession.ts","../../src/serialization/HTMLWhitespace.ts","../../src/serialization/PreformattedText.ts","../../src/serialization/StyleRehydration.ts","../../src/serialization/DocumentParser.ts"],"sourcesContent":["import type { Mark } from '../model/Document.js';\nimport type { ParseRule } from '../model/ParseRule.js';\nimport { markType } from '../model/TypeBrands.js';\n\n/** Parse rules with the node, mark or inline type they produce, in priority order. */\nexport type ParseRules = readonly { readonly rule: ParseRule; readonly type: string }[];\n\n/** Structural tags handled by the document parser independently of schema rules. */\nconst BLOCK_TAGS: ReadonlySet<string> = new Set([\n\t'p',\n\t'div',\n\t'ul',\n\t'ol',\n\t'table',\n\t'blockquote',\n\t'pre',\n]);\n\n/** Returns the first accepting rule in priority order, including its parsed attributes. */\nexport function matchHTMLParseRule(\n\telement: HTMLElement,\n\trules: ParseRules,\n): { readonly type: string; readonly attrs?: Record<string, unknown> } | null {\n\tconst tag: string = element.tagName.toLowerCase();\n\tfor (const { rule, type } of rules) {\n\t\tif (rule.tag !== tag) continue;\n\t\tconst attrs = rule.getAttrs?.(element);\n\t\tif (attrs !== false) return { type, ...(attrs ? { attrs } : {}) };\n\t}\n\treturn null;\n}\n\n/** Reads the element's own marks, shared by the inline walker and wrappers. */\nexport function parseHTMLMarks(\n\tel: HTMLElement,\n\tcurrentMarks: readonly Mark[],\n\tmarkRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n): Mark[] {\n\tconst tag: string = el.tagName.toLowerCase();\n\tconst marks: Mark[] = [...currentMarks];\n\n\tfor (const { rule, type } of markRules) {\n\t\tif (rule.tag !== tag || marks.some((mark) => mark.type === type)) continue;\n\t\tconst attrs = rule.getAttrs?.(el);\n\t\tif (attrs === false) continue;\n\t\tmarks.push({\n\t\t\ttype: markType(type),\n\t\t\t...(attrs && Object.keys(attrs).length > 0 ? { attrs } : {}),\n\t\t} as Mark);\n\t}\n\n\treturn marks;\n}\n\n/** Inline node rules take precedence, just as they do when parsing inline content. */\nexport function isHTMLBlockElement(\n\telement: HTMLElement,\n\tblockRules: ParseRules,\n\tinlineRules: ParseRules,\n\tblockTags: ReadonlySet<string> = BLOCK_TAGS,\n): boolean {\n\tif (matchHTMLParseRule(element, inlineRules)) return false;\n\treturn (\n\t\tblockTags.has(element.tagName.toLowerCase()) || matchHTMLParseRule(element, blockRules) !== null\n\t);\n}\n\n/**\n * Looks through transparent intermediate wrappers for block content. Atomic\n * inline nodes own their markup, so their descendants must never be unwrapped.\n */\nexport function hasHTMLBlockDescendants(\n\telement: HTMLElement,\n\tblockRules: ParseRules,\n\tinlineRules: ParseRules,\n\tblockTags: ReadonlySet<string> = BLOCK_TAGS,\n): boolean {\n\treturn createBlockDescendantCheck(blockRules, inlineRules, blockTags)(element);\n}\n\n/**\n * Creates a {@link hasHTMLBlockDescendants} check that remembers every\n * element's answer. Parsers ask it for each level of nested wrappers, so\n * without the memo a deep wrapper chain rescans the same subtree at every\n * level (#263). Use one check per parse, while the DOM does not change.\n */\nexport function createBlockDescendantCheck(\n\tblockRules: ParseRules,\n\tinlineRules: ParseRules,\n\tblockTags: ReadonlySet<string> = BLOCK_TAGS,\n): (element: HTMLElement) => boolean {\n\tconst known = new WeakMap<Element, boolean>();\n\tconst check = (element: HTMLElement): boolean => {\n\t\tconst cached: boolean | undefined = known.get(element);\n\t\tif (cached !== undefined) return cached;\n\t\tconst result: boolean =\n\t\t\t!matchHTMLParseRule(element, inlineRules) &&\n\t\t\tArray.from(element.children).some((child) => {\n\t\t\t\tconst el = child as HTMLElement;\n\t\t\t\treturn isHTMLBlockElement(el, blockRules, inlineRules, blockTags) || check(el);\n\t\t\t});\n\t\tknown.set(element, result);\n\t\treturn result;\n\t};\n\treturn check;\n}\n","/**\n * State shared by one HTML import: the registry's parse rules, read once, the\n * block ids adopted so far, and per-element answers the parser needs again and\n * again. Transparent wrappers (#223) make the parser ask about the same\n * elements at every nesting level, so each answer is computed once per element\n * instead of once per level (#263).\n */\n\nimport type { Mark } from '../model/Document.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { type ParseRules, createBlockDescendantCheck, parseHTMLMarks } from './HTMLParseRules.js';\n\nexport interface HTMLParseSession {\n\treadonly registry?: SchemaRegistry;\n\treadonly blockRules: ParseRules;\n\treadonly inlineRules: ParseRules;\n\treadonly markRules: ParseRules;\n\t/** HTML block ids adopted so far, so a repeated id gets a fresh one. */\n\treadonly adoptedIds: Set<string>;\n\t/** Whether `element` wraps block-level content, looking through transparent wrappers. */\n\thasBlockDescendants(element: HTMLElement): boolean;\n\t/** The marks the ancestors of `node` apply to it, such as a wrapper's link or color. */\n\tancestorMarks(node: Node): readonly Mark[];\n}\n\n/**\n * Creates the session for one parse. The DOM must not change while it is in\n * use, because answers are remembered per element.\n */\nexport function createHTMLParseSession(registry?: SchemaRegistry): HTMLParseSession {\n\tconst blockRules: ParseRules = registry?.getBlockParseRules() ?? [];\n\tconst inlineRules: ParseRules = registry?.getInlineParseRules() ?? [];\n\tconst markRules: ParseRules = registry?.getMarkParseRules() ?? [];\n\tconst ownMarks = new WeakMap<Element, readonly Mark[]>();\n\n\tconst marksOf = (element: HTMLElement): readonly Mark[] => {\n\t\tconst cached: readonly Mark[] | undefined = ownMarks.get(element);\n\t\tif (cached) return cached;\n\t\tconst parent: HTMLElement | null = element.parentElement;\n\t\tconst marks: readonly Mark[] = parseHTMLMarks(\n\t\t\telement,\n\t\t\tparent ? marksOf(parent) : [],\n\t\t\tmarkRules,\n\t\t);\n\t\townMarks.set(element, marks);\n\t\treturn marks;\n\t};\n\n\treturn {\n\t\tregistry,\n\t\tblockRules,\n\t\tinlineRules,\n\t\tmarkRules,\n\t\tadoptedIds: new Set<string>(),\n\t\thasBlockDescendants: createBlockDescendantCheck(blockRules, inlineRules),\n\t\tancestorMarks: (node: Node): readonly Mark[] =>\n\t\t\tnode.parentElement ? marksOf(node.parentElement) : [],\n\t};\n}\n","/**\n * HTML whitespace normalization, shared by the paste parser (`HTMLParser`) and the\n * `setContentHTML` parser (`DocumentParser`).\n *\n * Per the CSS Text / HTML whitespace processing model for `white-space: normal`,\n * whitespace in normal flow content is *insignificant*: runs of ASCII whitespace\n * (space, tab, line feed, carriage return, form feed) collapse to a single space,\n * and whitespace at the edges of a block collapses away entirely. Only `<br>` is a\n * real line break. Source-formatted HTML (server-rendered, hand-indented, or\n * hard-wrapped by a browser's clipboard serializer) therefore carries newlines and\n * indentation that must NOT survive parsing.\n *\n * This pass rewrites text-node data in place so both parsers can walk a tree whose\n * whitespace already matches what a browser would render. It only touches\n * `Text.data`; marks, block ids, and attributes are left untouched.\n */\n\n/**\n * ASCII whitespace per the HTML spec. Deliberately NOT `\\s`: `\\s` also matches\n * non-breaking space (` `) and other Unicode spaces, which are significant\n * content and must be preserved verbatim.\n */\nconst COLLAPSIBLE_WHITESPACE: RegExp = /[ \\t\\n\\r\\f]+/g;\n\n/**\n * Tags that establish a block formatting context in normal flow. Each starts a\n * fresh inline run whose leading/trailing whitespace is trimmed independently.\n * Self-contained (not coupled to the parsers' tag sets); unknown tags are treated\n * as inline.\n */\nconst FLOW_BLOCK_TAGS: ReadonlySet<string> = new Set([\n\t'P',\n\t'DIV',\n\t'H1',\n\t'H2',\n\t'H3',\n\t'H4',\n\t'H5',\n\t'H6',\n\t'BLOCKQUOTE',\n\t'UL',\n\t'OL',\n\t'LI',\n\t'TABLE',\n\t'THEAD',\n\t'TBODY',\n\t'TFOOT',\n\t'TR',\n\t'TD',\n\t'TH',\n\t'HR',\n\t'FIGURE',\n\t'FIGCAPTION',\n\t'SECTION',\n\t'ARTICLE',\n\t'HEADER',\n\t'FOOTER',\n\t'MAIN',\n\t'ASIDE',\n\t'NAV',\n\t'DL',\n\t'DT',\n\t'DD',\n]);\n\n/** Tags whose descendant whitespace is significant and must be preserved verbatim. */\nconst PRESERVE_TAGS: ReadonlySet<string> = new Set(['PRE', 'TEXTAREA']);\n\n/** `white-space` values that preserve whitespace (the `pre*` family). */\nconst PRESERVE_WHITESPACE_VALUES: ReadonlySet<string> = new Set([\n\t'pre',\n\t'pre-wrap',\n\t'pre-line',\n\t'break-spaces',\n]);\n\n/** Mutable state threaded through a single inline formatting context. */\ninterface CollapseState {\n\t/** Most recent non-empty text node in this context, for trailing-space trimming. */\n\tlastTextNode: Text | null;\n\t/**\n\t * Whether a leading space on the next text node should be dropped. True at the\n\t * start of a context and after any text node that ended with a space.\n\t */\n\tcollapsePending: boolean;\n}\n\n/**\n * Collapses insignificant HTML whitespace throughout `root`, mutating text-node\n * data in place. Call once on a (disposable) parsed fragment before walking it.\n */\nexport function normalizeHTMLWhitespace(root: DocumentFragment | HTMLElement): void {\n\tnormalizeContext(root);\n}\n\n/** Processes one inline formatting context, then trims its trailing whitespace. */\nfunction normalizeContext(container: DocumentFragment | HTMLElement): void {\n\tconst state: CollapseState = { lastTextNode: null, collapsePending: true };\n\tfor (const child of Array.from(container.childNodes)) {\n\t\tprocessNode(child, state);\n\t}\n\ttrimTrailingSpace(state.lastTextNode);\n}\n\nfunction processNode(node: ChildNode, state: CollapseState): void {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\tcollapseTextNode(node as Text, state);\n\t\treturn;\n\t}\n\tif (node.nodeType !== Node.ELEMENT_NODE) return;\n\n\tconst el = node as HTMLElement;\n\n\t// Whitespace-preserving subtree (code blocks etc.): end the current inline run\n\t// and leave the subtree untouched.\n\tif (isPreserveElement(el)) {\n\t\tendInlineRun(state);\n\t\treturn;\n\t}\n\n\t// Block element: the current inline run ends here; recurse as a fresh context.\n\tif (isFlowBlockElement(el)) {\n\t\tendInlineRun(state);\n\t\tnormalizeContext(el);\n\t\treturn;\n\t}\n\n\t// Inline element: keep collapsing within the same context.\n\tfor (const child of Array.from(el.childNodes)) {\n\t\tprocessNode(child, state);\n\t}\n}\n\n/** Collapses whitespace runs in a text node and drops a leading space when pending. */\nfunction collapseTextNode(text: Text, state: CollapseState): void {\n\tlet data: string = text.data.replace(COLLAPSIBLE_WHITESPACE, ' ');\n\tif (state.collapsePending && data.startsWith(' ')) {\n\t\tdata = data.slice(1);\n\t}\n\ttext.data = data;\n\n\t// Fully collapsed away (e.g. a whitespace-only node): leave `collapsePending` as\n\t// is so a later node still drops its leading space.\n\tif (data.length === 0) return;\n\n\tstate.collapsePending = data.endsWith(' ');\n\tstate.lastTextNode = text;\n}\n\n/** Ends the current inline run at a block/preserve boundary and resets state. */\nfunction endInlineRun(state: CollapseState): void {\n\ttrimTrailingSpace(state.lastTextNode);\n\tstate.lastTextNode = null;\n\tstate.collapsePending = true;\n}\n\n/** Removes the single (already-collapsed) trailing space from a text node, if any. */\nfunction trimTrailingSpace(node: Text | null): void {\n\tif (node?.data.endsWith(' ')) {\n\t\tnode.data = node.data.slice(0, -1);\n\t}\n}\n\nfunction isFlowBlockElement(el: HTMLElement): boolean {\n\treturn FLOW_BLOCK_TAGS.has(el.tagName);\n}\n\nfunction isPreserveElement(el: HTMLElement): boolean {\n\tif (PRESERVE_TAGS.has(el.tagName)) return true;\n\tconst whiteSpace: string = (el.style?.whiteSpace ?? '').toLowerCase();\n\treturn PRESERVE_WHITESPACE_VALUES.has(whiteSpace);\n}\n","/** Reads preformatted text without marks, retaining both literal newlines and `<br>` lines. */\nexport function readPreformattedText(element: HTMLElement): string {\n\tconst walker: TreeWalker = element.ownerDocument.createTreeWalker(element);\n\tconst parts: string[] = [];\n\tlet node: Node | null = walker.nextNode();\n\twhile (node) {\n\t\tif (node.nodeType === Node.TEXT_NODE) parts.push(node.textContent ?? '');\n\t\telse if (node.nodeName === 'BR') parts.push('\\n');\n\t\tnode = walker.nextNode();\n\t}\n\treturn parts.join('');\n}\n","/**\n * Style rehydration for HTML import and paste: before the parse rules run,\n * every style the HTML gives an element becomes readable through the CSSOM\n * (`el.style`), which is where the rules read it. Import and both paste routes\n * share this one step, so they read styles alike on every page.\n */\n\nimport { splitDeclarations } from '../model/StyleClass.js';\nimport { type ClassDeclarationResolver, rehydrateStyleClasses } from './StyleClassHTML.js';\n\n/**\n * The most declarations rehydrated on one element, from its `style` attribute\n * and from its classes each. Formatting needs far fewer. Input with more is not\n * formatting, and Chromium applies many distinct custom properties through the\n * CSSOM in superlinear time, so such an element keeps those styles unapplied\n * (#274).\n */\nexport const MAX_REHYDRATED_DECLARATIONS = 256;\n\n/**\n * Rehydrates the styles of parsed content HTML in cascade order: first each\n * element's own `style` attribute, then the declarations its classes stand for,\n * which only fill properties the element does not set inline (#269).\n */\nexport function rehydrateStyles(root: ParentNode, resolveClass: ClassDeclarationResolver): void {\n\trestoreInlineStyles(root);\n\trehydrateStyleClasses(root, resolveClass, MAX_REHYDRATED_DECLARATIONS);\n}\n\n/**\n * Applies `style` attributes the browser kept out of the CSSOM. Under a strict\n * CSP (`style-src-attr 'none'`) Chromium keeps the attribute text but leaves\n * `el.style` empty, even in inert template content (#272), while CSSOM writes\n * stay allowed. Without such a policy the CSSOM already holds the declarations,\n * so only an attribute the browser rejected entirely is parsed again, which\n * yields no declarations either. Afterwards the attribute holds the browser's\n * serialization, so code that needs the raw text reads it before this step.\n */\nfunction restoreInlineStyles(root: ParentNode): void {\n\tfor (const element of Array.from(root.querySelectorAll('[style]'))) {\n\t\tconst style: CSSStyleDeclaration | undefined = inlineStyleOf(element);\n\t\tif (!style || style.length > 0) continue;\n\t\tconst text: string = element.getAttribute('style') ?? '';\n\t\tif (splitDeclarations(text).length > MAX_REHYDRATED_DECLARATIONS) continue;\n\t\t// One write through the browser's own CSS parser, which reads priorities,\n\t\t// shorthands and comments as it reads the attribute on a page without a CSP.\n\t\tstyle.cssText = text;\n\t}\n}\n\n/** The CSSOM declaration of an element, unless its namespace has none. */\nfunction inlineStyleOf(element: Element): CSSStyleDeclaration | undefined {\n\treturn (element as Partial<ElementCSSInlineStyle>).style;\n}\n","/**\n * DocumentParser: converts sanitized HTML into immutable Document instances.\n * Pure functions — no class state, no DOM mutation beyond a disposable fragment.\n */\n\nimport type { BlockAlignment } from '../model/BlockAlignment.js';\nimport { hoistDisallowedBlocks } from '../model/ContentModel.js';\nimport type {\n\tBlockAttrValue,\n\tBlockNode,\n\tDocument,\n\tInlineNode,\n\tMark,\n\tTextNode,\n} from '../model/Document.js';\nimport {\n\tcreateBlockNode,\n\tcreateDocument,\n\tcreateInlineNode,\n\tcreateTextNode,\n\tgetInlineChildren,\n\tisInlineNode,\n} from '../model/Document.js';\nimport { SAFE_URI_REGEXP, normalizeHTMLId } from '../model/HTMLUtils.js';\nimport type { ParseRule } from '../model/ParseRule.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { type InlineTypeName, inlineType, nodeType } from '../model/TypeBrands.js';\nimport { readElementAlignment } from './AlignmentHTML.js';\nimport { adoptBlockId } from './BlockIdHTML.js';\nimport { VALID_DIRECTIONS } from './DocumentSerializer.js';\nimport { isHTMLBlockElement, matchHTMLParseRule, parseHTMLMarks } from './HTMLParseRules.js';\nimport { type HTMLParseSession, createHTMLParseSession } from './HTMLParseSession.js';\nimport { preserveHTMLIdSanitizeConfig, sanitizeHTMLFragment } from './HTMLSanitization.js';\nimport { normalizeHTMLWhitespace } from './HTMLWhitespace.js';\nimport { readPreformattedText } from './PreformattedText.js';\nimport { createClassDeclarationResolver } from './StyleClassHTML.js';\nimport { rehydrateStyles } from './StyleRehydration.js';\nimport {\n\tMAX_SERIALIZED_TABLE_COLUMNS,\n\tTABLE_COLUMN_WIDTH_DATA_ATTRIBUTE,\n\tTABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE,\n\tnormalizeTableColumnWidthsPx,\n\tparseTableColumnSpan,\n\treadTableDimensionPx,\n} from './TableDimensions.js';\n\n/** Options for `parseHTMLToDocument` when importing class-based HTML. */\nexport interface ParseHTMLOptions {\n\t/**\n\t * Style map from a previous `getContentHTML({ cssMode: 'classes' })` call.\n\t * Used to rehydrate class-based HTML back into styled content. Registered\n\t * style classes and notectl's alignment classes need no style map.\n\t */\n\treadonly styleMap?: ReadonlyMap<string, string>;\n}\n\n/** Parses HTML into a Document, applying sanitization and schema parse rules. */\nexport function parseHTMLToDocument(\n\thtml: string | DocumentFragment,\n\tregistry?: SchemaRegistry,\n\toptions?: ParseHTMLOptions,\n): Document {\n\t// Pre remains visible to the parser even without a code spec, so the fallback\n\t// can split significant lines rather than collapse them during sanitization.\n\tconst allowedTags: string[] = [\n\t\t...(registry ? registry.getAllowedTags() : ['p', 'br', 'div', 'span']),\n\t\t'pre',\n\t];\n\tconst allowedAttrs: string[] = registry ? registry.getAllowedAttrs() : ['style', 'dir', 'id'];\n\n\t// `data-block-id` carries block identity across `setContentHTML(getContentHTML())`.\n\t// Whitelist it through DOMPurify so the adoption logic below sees it.\n\tif (!allowedAttrs.includes('data-block-id')) {\n\t\tallowedAttrs.push('data-block-id');\n\t}\n\n\t// When a styleMap is provided, also allow `class` through DOMPurify\n\t// so we can read class names and rehydrate styles before parsing.\n\tif (options?.styleMap && !allowedAttrs.includes('class')) {\n\t\tallowedAttrs.push('class');\n\t}\n\n\tconst root: DocumentFragment = sanitizeHTMLFragment(\n\t\thtml,\n\t\t{\n\t\t\tALLOWED_TAGS: allowedTags,\n\t\t\tALLOWED_ATTR: allowedAttrs,\n\t\t\tALLOWED_URI_REGEXP: SAFE_URI_REGEXP,\n\t\t\t...preserveHTMLIdSanitizeConfig(),\n\t\t},\n\t\tregistry,\n\t);\n\n\t// Make inline styles and classes readable through the CSSOM, where parse rules read them.\n\trehydrateStyles(root, createClassDeclarationResolver(registry, options?.styleMap));\n\n\t// Collapse insignificant HTML whitespace so source-formatted/indented input does\n\t// not leave stray newlines and indentation inside block text content.\n\tnormalizeHTMLWhitespace(root);\n\n\tconst session: HTMLParseSession = createHTMLParseSession(registry);\n\tconst blocks: BlockNode[] = [];\n\n\tfor (const child of Array.from(root.childNodes)) {\n\t\tparseChildNode(child, blocks, session);\n\t}\n\n\tif (blocks.length === 0) return createDocument();\n\tconst doc: Document = createDocument(blocks);\n\t// Repair schema-invalid nesting an importer may have produced (e.g. a `<table>`\n\t// inside an `<li>` builds `list_item > table`, which the flat-with-indent item\n\t// model forbids): the disallowed block is hoisted to a valid ancestor (#194).\n\treturn registry ? hoistDisallowedBlocks(doc, registry) : doc;\n}\n\n/**\n * Parses a single child node into block(s), handling all supported block types:\n * lists, tables, block parse rules (headings, blockquotes, code blocks, images, hr),\n * and fallback paragraphs. Used by both top-level parsing and table cell content parsing.\n */\nfunction parseChildNode(child: ChildNode, blocks: BlockNode[], session: HTMLParseSession): void {\n\tconst { adoptedIds, registry } = session;\n\tif (child.nodeType === Node.ELEMENT_NODE) {\n\t\tconst el = child as HTMLElement;\n\t\tconst tag: string = el.tagName.toLowerCase();\n\n\t\t// Lists need cross-element logic — handle before parse rules\n\t\tif (tag === 'ul' || tag === 'ol') {\n\t\t\tconst listType: string = tag === 'ol' ? 'ordered' : 'bullet';\n\t\t\tconst listDir: string | null = el.getAttribute('dir');\n\t\t\tconst parentDir: string | undefined =\n\t\t\t\tlistDir && VALID_DIRECTIONS.has(listDir) ? listDir : undefined;\n\t\t\tparseListElement(el, listType, 0, blocks, session, parentDir);\n\t\t\treturn;\n\t\t}\n\n\t\t// Tables produce nested block structure: table > table_row > table_cell > paragraph\n\t\tif (tag === 'table') {\n\t\t\tparseTableElement(el, blocks, session);\n\t\t\treturn;\n\t\t}\n\n\t\t// Blockquotes are container blocks (issue #136): parse their children\n\t\t// recursively into block nodes instead of flattening to inline content.\n\t\tif (tag === 'blockquote') {\n\t\t\tparseBlockquoteElement(el, blocks, session);\n\t\t\treturn;\n\t\t}\n\n\t\t// Try block parse rules\n\t\tconst match = matchHTMLParseRule(el, session.blockRules);\n\t\tif (tag === 'pre' && !match) {\n\t\t\tparsePreformattedFallback(el, blocks, session);\n\t\t\treturn;\n\t\t}\n\n\t\t// A paragraph cannot hold blocks. An element that resolves to `paragraph`\n\t\t// (the generic `<div>` rule or the fallback below) but wraps block-level\n\t\t// children is a transparent wrapper, the shape web pages, Google Docs and\n\t\t// Word put around their content: its children become sibling blocks\n\t\t// instead of being flattened into one inline run (#223).\n\t\tif ((match?.type ?? 'paragraph') === 'paragraph' && session.hasBlockDescendants(el)) {\n\t\t\tparseWrapperElement(el, blocks, session);\n\t\t\treturn;\n\t\t}\n\n\t\tconst spec = match ? registry?.getNodeSpec(match.type) : undefined;\n\t\tconst children: (TextNode | InlineNode)[] = spec?.isVoid\n\t\t\t? [createTextNode('')]\n\t\t\t: match?.type === 'code_block'\n\t\t\t\t? [createTextNode(readPreformattedText(el))]\n\t\t\t\t: parseElementToInlineContent(el, session);\n\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t...(match?.attrs as Record<string, string | number | boolean> | undefined),\n\t\t};\n\t\t// Known block types only accept declared attributes. The paragraph\n\t\t// fallback retains the permissive behavior of registry-free import.\n\t\tif (!match || spec?.attrs?.align) extractAlignment(el, attrs);\n\t\tif (!match || spec?.attrs?.dir) extractDirection(el, attrs);\n\t\tblocks.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType(match?.type ?? 'paragraph'),\n\t\t\t\tchildren,\n\t\t\t\tadoptBlockId(el, adoptedIds),\n\t\t\t\tObject.keys(attrs).length > 0 ? attrs : undefined,\n\t\t\t\textractHTMLId(el),\n\t\t\t),\n\t\t);\n\t} else if (child.nodeType === Node.TEXT_NODE && child.textContent?.trim()) {\n\t\tblocks.push(createBlockNode(nodeType('paragraph'), [createTextNode(child.textContent.trim())]));\n\t}\n}\n\n/** A schema without code blocks keeps each preformatted line as a paragraph. */\nfunction parsePreformattedFallback(\n\tel: HTMLElement,\n\tblocks: BlockNode[],\n\tsession: HTMLParseSession,\n): void {\n\tconst attrs: Record<string, string | number | boolean> = {};\n\textractAlignment(el, attrs);\n\textractDirection(el, attrs);\n\tfor (const [index, line] of readPreformattedText(el).split('\\n').entries()) {\n\t\tblocks.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType('paragraph'),\n\t\t\t\t[createTextNode(line)],\n\t\t\t\tindex === 0 ? adoptBlockId(el, session.adoptedIds) : undefined,\n\t\t\t\tObject.keys(attrs).length > 0 ? attrs : undefined,\n\t\t\t\tindex === 0 ? extractHTMLId(el) : undefined,\n\t\t\t),\n\t\t);\n\t}\n}\n\n/**\n * Recursively parses a list element (`<ul>` or `<ol>`), creating list_item blocks\n * with correct indent depth. Handles nested lists inside `<li>` elements.\n */\nfunction parseListElement(\n\tlistEl: Element,\n\tlistType: string,\n\tdepth: number,\n\tblocks: BlockNode[],\n\tsession: HTMLParseSession,\n\tparentDir?: string,\n): void {\n\tfor (const child of Array.from(listEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\n\t\tif (tag === 'li') {\n\t\t\tconst li: HTMLElement = child as HTMLElement;\n\n\t\t\t// Check for checklist: <input type=\"checkbox\">\n\t\t\tconst checkbox: HTMLInputElement | null = li.querySelector(':scope > input[type=\"checkbox\"]');\n\t\t\tconst isChecklist: boolean = checkbox !== null;\n\t\t\tconst checked: boolean = checkbox?.hasAttribute('checked') ?? false;\n\n\t\t\tconst resolvedType: string = isChecklist ? 'checklist' : listType;\n\n\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\tlistType: resolvedType,\n\t\t\t\tindent: depth,\n\t\t\t\tchecked,\n\t\t\t};\n\n\t\t\t// Propagate direction: item's own dir > parent list dir\n\t\t\tconst liDir: string | null = li.getAttribute('dir');\n\t\t\tconst effectiveDir: string | undefined =\n\t\t\t\tliDir && VALID_DIRECTIONS.has(liDir) ? liDir : parentDir;\n\t\t\tif (effectiveDir) {\n\t\t\t\tattrs.dir = effectiveDir;\n\t\t\t}\n\n\t\t\tblocks.push(parseListItemBlock(li, attrs, checkbox, session));\n\n\t\t\t// Check for nested lists inside this <li>\n\t\t\tfor (const liChild of Array.from(li.children)) {\n\t\t\t\tconst liChildTag: string = liChild.tagName.toLowerCase();\n\t\t\t\tif (liChildTag === 'ul' || liChildTag === 'ol') {\n\t\t\t\t\tconst nestedType: string = liChildTag === 'ol' ? 'ordered' : 'bullet';\n\t\t\t\t\tconst nestedDir: string | null = liChild.getAttribute('dir');\n\t\t\t\t\tconst nestedEffectiveDir: string | undefined =\n\t\t\t\t\t\tnestedDir && VALID_DIRECTIONS.has(nestedDir) ? nestedDir : effectiveDir;\n\t\t\t\t\tparseListElement(liChild, nestedType, depth + 1, blocks, session, nestedEffectiveDir);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (tag === 'ul' || tag === 'ol') {\n\t\t\t// Direct nested list without wrapping <li> — increment depth\n\t\t\tconst nestedType: string = tag === 'ol' ? 'ordered' : 'bullet';\n\t\t\tconst nestedDir: string | null = child.getAttribute('dir');\n\t\t\tconst nestedEffectiveDir: string | undefined =\n\t\t\t\tnestedDir && VALID_DIRECTIONS.has(nestedDir) ? nestedDir : parentDir;\n\t\t\tparseListElement(child, nestedType, depth + 1, blocks, session, nestedEffectiveDir);\n\t\t}\n\t}\n}\n\n/**\n * Parses one `<li>` into its `list_item` block (#194). An item whose children\n * are inline-only stays a leaf; block-level children other than nested lists\n * (a second paragraph, code, a quote, a heading) make it a container with\n * block children. Nested `<ul>`/`<ol>` are excluded here — the caller hoists\n * them into flat siblings one indent deeper. A lone plain paragraph unwraps\n * back to a leaf so the common tight/loose single-paragraph item keeps its\n * inline shape.\n */\nfunction parseListItemBlock(\n\tli: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n\tcheckbox: HTMLInputElement | null,\n\tsession: HTMLParseSession,\n): BlockNode {\n\tconst { adoptedIds } = session;\n\tconst htmlId: string | undefined = extractHTMLId(li);\n\tconst isHoistedList = (node: ChildNode): boolean => {\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) return false;\n\t\tconst tag: string = (node as Element).tagName.toLowerCase();\n\t\treturn tag === 'ul' || tag === 'ol';\n\t};\n\tconst hasBlockContent: boolean = Array.from(li.childNodes).some(\n\t\t(node) => !isHoistedList(node) && isBlockLevelChild(node, session),\n\t);\n\n\tif (!hasBlockContent) {\n\t\tconst inlineContent = parseElementToInlineContent(li, session, true);\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\tinlineContent,\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\tconst skip = (node: ChildNode): boolean => isHoistedList(node) || node === checkbox;\n\tconst innerBlocks: BlockNode[] = parseBlockContainerChildren(li, session, skip);\n\n\t// A lone attribute-less paragraph is the leaf shape in disguise.\n\tconst only: BlockNode | undefined = innerBlocks.length === 1 ? innerBlocks[0] : undefined;\n\tif (only && only.type === 'paragraph' && !only.attrs && !only.htmlId) {\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\tgetInlineChildren(only),\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\tif (innerBlocks.length === 0) {\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\t[createTextNode('')],\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\treturn createBlockNode(\n\t\tnodeType('list_item'),\n\t\tinnerBlocks,\n\t\tadoptBlockId(li, adoptedIds),\n\t\tattrs,\n\t\thtmlId,\n\t);\n}\n\n/**\n * Parses a `<table>` element into nested block structure:\n * table > table_row > table_cell > paragraph.\n * Handles `<thead>`, `<tbody>`, `<tfoot>` transparently.\n */\nfunction parseTableElement(tableEl: Element, blocks: BlockNode[], session: HTMLParseSession): void {\n\tconst { adoptedIds, registry } = session;\n\tconst rows: BlockNode[] = [];\n\tconst columnWidthsPx: readonly (number | null)[] | undefined =\n\t\textractTableColumnWidthsPx(tableEl);\n\t// Like every other block, a cell takes alignment only when its spec declares it.\n\tconst cellsAlign: boolean = !registry || !!registry.getNodeSpec('table_cell')?.attrs?.align;\n\n\t// Collect <tr> elements, handling <thead>/<tbody>/<tfoot> wrappers\n\tconst rowElements: Element[] = collectTableRows(tableEl);\n\n\tfor (const trEl of rowElements) {\n\t\tconst cells: BlockNode[] = [];\n\n\t\tfor (const cellChild of Array.from(trEl.children)) {\n\t\t\tconst cellTag: string = cellChild.tagName.toLowerCase();\n\t\t\tif (cellTag !== 'td' && cellTag !== 'th') continue;\n\n\t\t\tconst cellEl: HTMLElement = cellChild as HTMLElement;\n\t\t\tconst cellContent: BlockNode[] = parseTableCellContent(cellEl, session);\n\t\t\tconst cellAttrs: Record<string, string | number | boolean> = {};\n\t\t\textractCellSpanAttrs(cellEl, cellAttrs);\n\t\t\tif (cellsAlign) extractAlignment(cellEl, cellAttrs);\n\t\t\tconst cellBlock: BlockNode = createBlockNode(\n\t\t\t\tnodeType('table_cell'),\n\t\t\t\tcellContent,\n\t\t\t\tadoptBlockId(cellEl, adoptedIds),\n\t\t\t\tObject.keys(cellAttrs).length > 0 ? cellAttrs : undefined,\n\t\t\t\textractHTMLId(cellEl),\n\t\t\t);\n\t\t\tcells.push(cellBlock);\n\t\t}\n\n\t\tconst rowAttrs: Record<string, string | number | boolean> = {};\n\t\textractTableRowMinHeight(trEl as HTMLElement, rowAttrs);\n\t\t// Preserve empty rows. Besides retaining authored table structure, an empty\n\t\t// `<tr>` may carry the canonical minimum-height metadata by itself.\n\t\trows.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType('table_row'),\n\t\t\t\tcells,\n\t\t\t\tadoptBlockId(trEl, adoptedIds),\n\t\t\t\tObject.keys(rowAttrs).length > 0 ? rowAttrs : undefined,\n\t\t\t\textractHTMLId(trEl as HTMLElement),\n\t\t\t),\n\t\t);\n\t}\n\n\tif (rows.length > 0) {\n\t\tconst tableAttrs: Record<string, BlockAttrValue> = {};\n\t\textractTableBorderColor(tableEl as HTMLElement, tableAttrs);\n\t\tif (columnWidthsPx) tableAttrs.columnWidthsPx = columnWidthsPx;\n\t\tblocks.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType('table'),\n\t\t\t\trows,\n\t\t\t\tadoptBlockId(tableEl, adoptedIds),\n\t\t\t\tObject.keys(tableAttrs).length > 0 ? tableAttrs : undefined,\n\t\t\t\textractHTMLId(tableEl as HTMLElement),\n\t\t\t),\n\t\t);\n\t}\n}\n\n/** Collects canonical logical column widths from direct `<colgroup>/<col>` children. */\nfunction extractTableColumnWidthsPx(tableEl: Element): readonly (number | null)[] | undefined {\n\tconst widths: (number | null)[] = [];\n\n\tfor (const child of Array.from(tableEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\t\tif (tag === 'col') {\n\t\t\tappendColumnElementWidths(child as HTMLElement, undefined, widths);\n\t\t\tcontinue;\n\t\t}\n\t\tif (tag !== 'colgroup') continue;\n\n\t\tconst groupEl: HTMLElement = child as HTMLElement;\n\t\tconst groupWidth: number | undefined = readTableColumnWidthPx(groupEl);\n\t\tconst columns: HTMLElement[] = Array.from(groupEl.children).filter(\n\t\t\t(element): element is HTMLElement => element.tagName.toLowerCase() === 'col',\n\t\t);\n\t\tif (columns.length === 0) {\n\t\t\tappendRepeatedWidth(groupWidth, parseTableColumnSpan(groupEl.getAttribute('span')), widths);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const column of columns) appendColumnElementWidths(column, groupWidth, widths);\n\t}\n\n\treturn normalizeTableColumnWidthsPx(widths);\n}\n\nfunction appendColumnElementWidths(\n\tcolumn: HTMLElement,\n\tinheritedWidth: number | undefined,\n\twidths: (number | null)[],\n): void {\n\tconst width: number | undefined = readTableColumnWidthPx(column) ?? inheritedWidth;\n\tappendRepeatedWidth(width, parseTableColumnSpan(column.getAttribute('span')), widths);\n}\n\nfunction appendRepeatedWidth(\n\twidth: number | undefined,\n\tspan: number,\n\twidths: (number | null)[],\n): void {\n\tconst remaining: number = MAX_SERIALIZED_TABLE_COLUMNS - widths.length;\n\tconst count: number = Math.min(span, Math.max(0, remaining));\n\tfor (let index = 0; index < count; index++) widths.push(width ?? null);\n}\n\nfunction readTableColumnWidthPx(element: HTMLElement): number | undefined {\n\treturn readTableDimensionPx(element, TABLE_COLUMN_WIDTH_DATA_ATTRIBUTE, ['width'], 'width');\n}\n\n/** Extracts one row's validated minimum height from canonical or conventional HTML. */\nfunction extractTableRowMinHeight(\n\trow: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n): void {\n\tconst minHeightPx: number | undefined = readTableDimensionPx(\n\t\trow,\n\t\tTABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE,\n\t\t['min-height', 'height'],\n\t\t'height',\n\t);\n\tif (minHeightPx !== undefined) attrs.minHeightPx = minHeightPx;\n}\n\n/** Collects `<tr>` elements from a table, traversing through `<thead>`/`<tbody>`/`<tfoot>`. */\nfunction collectTableRows(tableEl: Element): Element[] {\n\tconst rows: Element[] = [];\n\tfor (const child of Array.from(tableEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\t\tif (tag === 'tr') {\n\t\t\trows.push(child);\n\t\t} else if (tag === 'thead' || tag === 'tbody' || tag === 'tfoot') {\n\t\t\tfor (const nested of Array.from(child.children)) {\n\t\t\t\tif (nested.tagName.toLowerCase() === 'tr') {\n\t\t\t\t\trows.push(nested);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn rows;\n}\n\n/** Regex to extract the `--ntbl-bc` CSS custom property from inline styles. */\nconst BORDER_COLOR_RE = /--ntbl-bc:\\s*(#[0-9a-fA-F]{3,8}|transparent)/;\n\n/** Extracts `borderColor` from a table element's inline style (`--ntbl-bc` CSS variable). */\nfunction extractTableBorderColor(el: HTMLElement, attrs: Record<string, BlockAttrValue>): void {\n\tconst style: string = el.getAttribute('style') ?? '';\n\tconst match: RegExpMatchArray | null = BORDER_COLOR_RE.exec(style);\n\tif (!match?.[1]) return;\n\tattrs.borderColor = match[1] === 'transparent' ? 'none' : match[1];\n}\n\n/** Extracts `colspan` and `rowspan` attributes from a table cell element. */\nfunction extractCellSpanAttrs(\n\tel: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n): void {\n\tconst colspan: string | null = el.getAttribute('colspan');\n\tif (colspan) {\n\t\tconst value: number = parseTableColumnSpan(colspan);\n\t\tif (value > 1) attrs.colspan = value;\n\t}\n\tconst rowspan: string | null = el.getAttribute('rowspan');\n\tif (rowspan) {\n\t\tconst value: number = parseTableColumnSpan(rowspan);\n\t\tif (value > 1) attrs.rowspan = value;\n\t}\n}\n\n/**\n * Parses a `<blockquote>` into a container block whose children are block nodes\n * (issue #136). Block-level children (lists, paragraphs, headings, nested quotes)\n * are parsed recursively; a quote holding only inline content becomes a single\n * paragraph child so the container invariant (block children only) always holds.\n */\nfunction parseBlockquoteElement(\n\tel: HTMLElement,\n\tblocks: BlockNode[],\n\tsession: HTMLParseSession,\n): void {\n\tconst innerBlocks: BlockNode[] = parseBlockContainerChildren(el, session);\n\n\t// Empty or whitespace-only blockquote: keep a single empty paragraph so the\n\t// container always holds editable content.\n\tif (innerBlocks.length === 0) {\n\t\tinnerBlocks.push(createBlockNode(nodeType('paragraph'), [createTextNode('')]));\n\t}\n\n\t// Preserve direction/alignment on the container so the HTML round-trip is stable.\n\tconst attrs: Record<string, string | number | boolean> = {};\n\textractAlignment(el, attrs);\n\textractDirection(el, attrs);\n\n\tblocks.push(\n\t\tcreateBlockNode(\n\t\t\tnodeType('blockquote'),\n\t\t\tinnerBlocks,\n\t\t\tadoptBlockId(el, session.adoptedIds),\n\t\t\tObject.keys(attrs).length > 0 ? attrs : undefined,\n\t\t\textractHTMLId(el),\n\t\t),\n\t);\n}\n\n/** Parses a table cell's content into blocks, supporting all block types (lists, quotes, etc.). */\nfunction parseTableCellContent(cellEl: HTMLElement, session: HTMLParseSession): BlockNode[] {\n\tconst cellBlocks: BlockNode[] = parseBlockContainerChildren(cellEl, session);\n\n\t// No blocks produced: treat the cell as one empty paragraph.\n\tif (cellBlocks.length === 0) {\n\t\tcellBlocks.push(createBlockNode(nodeType('paragraph'), [createTextNode('')]));\n\t}\n\n\treturn cellBlocks;\n}\n\n/**\n * Parses the children of a block container (blockquote, table cell, multi-block\n * list item, transparent wrapper) into block nodes. Consecutive inline content\n * (text nodes and inline elements such as\n * `<em>`, `<strong>`, `<a>`) is coalesced into a single paragraph with its marks\n * intact, while genuine block children (paragraphs, headings, lists, tables,\n * nested blockquotes) are parsed recursively. This preserves the common quote\n * shape that mixes text with inline marks as one paragraph (issue #141).\n */\nfunction parseBlockContainerChildren(\n\tel: HTMLElement,\n\tsession: HTMLParseSession,\n\tskip?: (node: ChildNode) => boolean,\n): BlockNode[] {\n\tconst blocks: BlockNode[] = [];\n\tlet inlineRun: ChildNode[] = [];\n\n\tconst flushInlineRun = (): void => {\n\t\tif (inlineRunHasContent(inlineRun)) {\n\t\t\tblocks.push(\n\t\t\t\tcreateBlockNode(nodeType('paragraph'), parseNodesToInlineContent(inlineRun, session)),\n\t\t\t);\n\t\t}\n\t\tinlineRun = [];\n\t};\n\n\tfor (const child of Array.from(el.childNodes)) {\n\t\tif (skip?.(child)) continue;\n\t\tif (isBlockLevelChild(child, session)) {\n\t\t\tflushInlineRun();\n\t\t\tparseChildNode(child, blocks, session);\n\t\t} else {\n\t\t\tinlineRun.push(child);\n\t\t}\n\t}\n\tflushInlineRun();\n\n\treturn blocks;\n}\n\n/**\n * Both blocks and transparent wrappers around blocks end an inline run.\n * Ordinary inline elements and atomic inline nodes stay inside that run.\n */\nfunction isBlockLevelChild(node: ChildNode, session: HTMLParseSession): boolean {\n\tif (node.nodeType !== Node.ELEMENT_NODE) return false;\n\tconst el = node as HTMLElement;\n\treturn (\n\t\tisHTMLBlockElement(el, session.blockRules, session.inlineRules) ||\n\t\tsession.hasBlockDescendants(el)\n\t);\n}\n\n/**\n * Parses a transparent wrapper (a `<div>` or an unknown element around\n * block-level children) into the blocks it wraps (#223). The wrapper itself\n * yields no block, so its `id` is not adopted as an `htmlId` (wrapper-only\n * elements never own one). Its `dir` and `text-align`, which CSS inherits into\n * every child, are carried onto child blocks that accept the attribute but do\n * not set their own.\n */\nfunction parseWrapperElement(\n\tel: HTMLElement,\n\tblocks: BlockNode[],\n\tsession: HTMLParseSession,\n): void {\n\tconst inherited: Record<string, string | number | boolean> = {};\n\textractAlignment(el, inherited);\n\textractDirection(el, inherited);\n\n\tconst innerBlocks: BlockNode[] = parseBlockContainerChildren(el, session);\n\tfor (const block of innerBlocks) {\n\t\tblocks.push(inheritBlockAttrs(block, inherited, session.registry));\n\t}\n}\n\n/**\n * Returns the block extended with every inherited attribute it accepts but does\n * not set itself. With a registry, a block accepts an attribute only when its\n * NodeSpec declares it (mirroring the block parse rule path); without one, all\n * attributes are accepted (mirroring the paragraph fallback path).\n */\nfunction inheritBlockAttrs(\n\tblock: BlockNode,\n\tinherited: Record<string, string | number | boolean>,\n\tregistry?: SchemaRegistry,\n): BlockNode {\n\tconst spec = registry?.getNodeSpec(block.type);\n\tconst attrs: Record<string, BlockAttrValue> = { ...block.attrs };\n\tlet changed = false;\n\tfor (const [name, value] of Object.entries(inherited)) {\n\t\tif (attrs[name] !== undefined) continue;\n\t\tif (registry && !spec?.attrs?.[name]) continue;\n\t\tattrs[name] = value;\n\t\tchanged = true;\n\t}\n\tif (!changed) return block;\n\treturn createBlockNode(block.type, block.children, block.id, attrs, block.htmlId);\n}\n\n/** Whether an inline run carries meaningful content (non-whitespace text or any element). */\nfunction inlineRunHasContent(nodes: readonly ChildNode[]): boolean {\n\tfor (const node of nodes) {\n\t\tif (node.nodeType === Node.ELEMENT_NODE) return true;\n\t\tif (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) return true;\n\t}\n\treturn false;\n}\n\n/**\n * Parses an HTML element's inline children into (TextNode | InlineNode)[].\n * Applies mark parse rules and inline node parse rules.\n */\nfunction parseElementToInlineContent(\n\tel: HTMLElement,\n\tsession: HTMLParseSession,\n\tskipNestedLists?: boolean,\n): (TextNode | InlineNode)[] {\n\treturn parseNodesToInlineContent([el], session, skipNestedLists);\n}\n\n/**\n * Walks a list of sibling DOM nodes into inline content, applying mark and\n * inline-node parse rules. DOM ancestors retain the formatting of transparent\n * wrappers even after those wrappers cease to be model blocks. Mixed text and\n * inline elements still coalesce into one sequence with their own marks intact.\n */\nfunction parseNodesToInlineContent(\n\tnodes: readonly ChildNode[],\n\tsession: HTMLParseSession,\n\tskipNestedLists?: boolean,\n): (TextNode | InlineNode)[] {\n\tconst result: (TextNode | InlineNode)[] = [];\n\tfor (const node of nodes) {\n\t\twalkElement(\n\t\t\tnode,\n\t\t\tsession.ancestorMarks(node),\n\t\t\tresult,\n\t\t\tsession.markRules,\n\t\t\tsession.inlineRules,\n\t\t\tskipNestedLists,\n\t\t);\n\t}\n\n\t// A lone <br> as the only content of a block is a placeholder for an empty\n\t// paragraph (e.g. `<p><br></p>`), not a real hard break. Normalize to empty text.\n\tif (result.length === 1 && isInlineNode(result[0]) && result[0].inlineType === 'hard_break') {\n\t\treturn [createTextNode('')];\n\t}\n\n\treturn result.length > 0 ? result : [createTextNode('')];\n}\n\n/**\n * Recursively walks DOM nodes, collecting marks from parse rules,\n * matching inline node parse rules, and producing TextNodes/InlineNodes.\n */\nfunction walkElement(\n\tnode: Node,\n\tcurrentMarks: readonly Mark[],\n\tresult: (TextNode | InlineNode)[],\n\tmarkRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n\tinlineRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n\tskipNestedLists?: boolean,\n): void {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\tconst text: string = node.textContent ?? '';\n\t\tif (text) {\n\t\t\tresult.push(createTextNode(text, [...currentMarks]));\n\t\t}\n\t\treturn;\n\t}\n\n\tif (node.nodeType !== Node.ELEMENT_NODE) return;\n\n\tconst el = node as HTMLElement;\n\tconst tag: string = el.tagName.toLowerCase();\n\n\t// Skip nested lists inside <li> (handled by parseListElement)\n\tif (skipNestedLists && (tag === 'ul' || tag === 'ol')) return;\n\n\t// Skip checkbox inputs inside list items (already handled by parseListElement)\n\tif (skipNestedLists && tag === 'input' && el.getAttribute('type') === 'checkbox') return;\n\n\t// Inline nodes are atomic and take precedence over descendant markup.\n\tconst inlineMatch = matchHTMLParseRule(el, inlineRules);\n\tif (inlineMatch) {\n\t\tresult.push(\n\t\t\tcreateInlineNode(\n\t\t\t\tinlineType(inlineMatch.type) as InlineTypeName,\n\t\t\t\tinlineMatch.attrs as Readonly<Record<string, string | number | boolean>> | undefined,\n\t\t\t\tcurrentMarks,\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\n\tconst marks: Mark[] = parseHTMLMarks(el, currentMarks, markRules);\n\tfor (const child of Array.from(el.childNodes)) {\n\t\twalkElement(child, marks, result, markRules, inlineRules, skipNestedLists);\n\t}\n}\n\n/** Extracts a validated `dir` attribute or inline `direction` style from an element. */\nfunction extractDirection(el: HTMLElement, attrs: Record<string, string | number | boolean>): void {\n\tconst dir: string | null = el.getAttribute('dir');\n\tif (dir && VALID_DIRECTIONS.has(dir)) {\n\t\tattrs.dir = dir;\n\t\treturn;\n\t}\n\n\t// Fallback: check inline style `direction: rtl/ltr` (common in paste from Word/Docs)\n\tconst styleDir: string = el.style?.direction ?? '';\n\tif (styleDir && VALID_DIRECTIONS.has(styleDir)) {\n\t\tattrs.dir = styleDir;\n\t}\n}\n\n/** Reads a conforming document-local HTML target from a block element. */\nfunction extractHTMLId(el: HTMLElement): string | undefined {\n\treturn normalizeHTMLId(el.getAttribute('id'));\n}\n\n/**\n * Adds the element's validated alignment to attrs: its inline `text-align`,\n * which rehydration also derives from alignment classes.\n */\nfunction extractAlignment(el: HTMLElement, attrs: Record<string, string | number | boolean>): void {\n\tconst align: BlockAlignment | undefined = readElementAlignment(el);\n\tif (align) attrs.align = align;\n}\n"],"mappings":"Y,8ZAQA,IAAM0B,iBAAkC,IAAIC,IAAI,CAC/C,IACA,MACA,KACA,KACA,QACA,aACA,QAID,SAAgBC,EACfC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IC,EAAcC,GACvD,IAAK,MAAMwB,KAASH,MAAMC,KAAKxB,EAAGuC,YACjCyK,GAAYtL,EAAOvB,EAAOmB,EAAQpB,EAAWU,EAAamM,EAE5D,CAGA,SAAS5D,GAAiBnJ,EAAiBH,GAC1C,MAAMoK,EAAqBjK,EAAGuE,aAAa,OAC3C,GAAI0F,GAAOxL,EAAiBqC,IAAImJ,GAE/B,YADApK,EAAMoK,IAAMA,GAKb,MAAMiD,EAAmBlN,EAAGsD,OAAO6J,WAAa,GAC5CD,GAAYzO,EAAiBqC,IAAIoM,KACpCrN,EAAMoK,IAAMiD,EAEd,CAGA,SAAS3E,GAAcvI,GACtB,OAAOvC,EAAgBuC,EAAGuE,aAAa,MACxC,CAMA,SAAS8D,GAAiBrI,EAAiBH,GAC1C,MAAM2H,EAAoCjJ,EAAqByB,GAC3DwH,IAAO3H,EAAM2H,MAAQA,EAC1B,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorUI-DrQI95FW.mjs","names":["ServiceKey","EditorUIServiceKey"],"sources":["../../src/plugins/editor-ui/EditorUI.ts"],"sourcesContent":["import { ServiceKey } from '../../model/TypedKeys.js';\nimport type { SelectionView } from '../../view/SelectionGeometry.js';\nimport type { PopupAnchor, PopupConfig, PopupHandle } from '../shared/PopupManager.js';\nimport type { PopupType, ToolbarGroup } from '../toolbar/ToolbarItem.js';\n\n/** Evaluated presentation data, never live plugin callbacks or mutable registry entries. */\nexport interface EditorAction {\n\treadonly id: string;\n\treadonly group: ToolbarGroup;\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly icon: string;\n\treadonly active: boolean;\n\treadonly enabled: boolean;\n\treadonly popupType: PopupType | null;\n\t/** Current combobox value, distinct from its accessible name. */\n\treadonly value: string | null;\n}\n\nexport interface ActionPopupOptions {\n\t/** Defaults to a live selection anchor. */\n\treadonly anchor?: PopupConfig['anchor'];\n\treadonly restoreFocusTo?: HTMLElement;\n\t/** Optional control whose aria-expanded state follows the popup. */\n\treadonly trigger?: HTMLElement;\n}\n\nexport interface EditorUIService {\n\tgetActions(): readonly EditorAction[];\n\t/** Immediately receives a snapshot, then changes; returns an idempotent unsubscribe. */\n\tsubscribeActions(listener: (actions: readonly EditorAction[]) => void): () => void;\n\t/** Re-evaluates callbacks after application state changes outside a transaction. */\n\trefresh(): void;\n\t/** Executes a button action against the current model selection. Popups use openAction. */\n\texecuteAction(id: string): boolean;\n\t/** Renders any registered popup type using the feature's existing implementation. */\n\topenAction(id: string, options?: ActionPopupOptions): PopupHandle | null;\n\tclosePopup(): void;\n\tisPopupOpen(): boolean;\n\tgetSelection(): SelectionView;\n\tsubscribeSelection(listener: (selection: SelectionView) => void): () => void;\n\t/** Coalesced remeasurement for application-driven layout changes. */\n\tinvalidateGeometry(): void;\n\tcreateSelectionAnchor(edge?: 'bounds' | 'anchor' | 'focus'): PopupAnchor;\n\t/** Registers a UI subtree, including one outside the editor's shadow root. */\n\tregisterInteraction(element: HTMLElement): () => void;\n\t/** Focuses a connected control in a registered interaction subtree. */\n\tfocus(element: HTMLElement): boolean;\n\t/** Returns to the editor and restores the latest transaction-mapped selection. */\n\tfocusEditor(): boolean;\n}\n\nexport const EditorUIServiceKey = new ServiceKey<EditorUIService>('editorUI');\n"],"mappings":"Y,iCAoDA,IAAaC,EAAqB,IAAID,EAA4B,mB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as t}from"./TypeBrands-Ch9856Gb.mjs";import{i as e,n as o,r as n,t as i}from"./AttributedMarkCommands-DKHuhZA7.mjs";import{r as s,s as r,t as a}from"./LocaleLoader-DEpTFuVc.mjs";import{c as l,n as c}from"./StyleRuntime-C0RSqKzG.mjs";import{r as m}from"./ColorValidation-ZBKZ_gTr.mjs";import{n as f,t as p}from"./InlineStyleMarkSpec-BhfGgfH9.mjs";import{t as d}from"./StyleClassNames-BsAx7k5T.mjs";var h={label:"Font",tooltip:"Font Family"},g=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-DahJwMI9.mjs"),"./locales/de.ts":()=>import("./de-DiPz7abS.mjs"),"./locales/es.ts":()=>import("./es-CCQFu1t1.mjs"),"./locales/fr.ts":()=>import("./fr-BwWrFThE.mjs"),"./locales/hi.ts":()=>import("./hi-B-ZuX4aN.mjs"),"./locales/nl.ts":()=>import("./nl-C5P8Fogm.mjs"),"./locales/pt.ts":()=>import("./pt-Dg2ctkug.mjs"),"./locales/ru.ts":()=>import("./ru-DJMpeuey.mjs"),"./locales/zh.ts":()=>import("./zh-CRsDvfPR.mjs")});async function u(t){return a(g,t,h)}var y={type:"font",rank:6,valueAttr:"family",domStyleProperty:"fontFamily",cssProperty:"font-family",validate:m,transformParsed:t=>t.replace(/"/g,"'")},v=class{id="font";name="Font";priority=22;config;locale;injectedStyleElement=null;context=null;constructor(t){this.config=t}async init(t){this.locale=await r(t,this.config.locale,h,u),t.registerStyleSheet(".notectl-toolbar-btn--font{min-width:100px;max-width:160px}.notectl-font-picker{min-width:200px;max-height:320px;overflow-y:auto}.notectl-font-picker__list{padding:4px 0}.notectl-font-picker__item{cursor:pointer;width:100%;color:var(--notectl-fg);text-align:start;white-space:nowrap;background:0 0;border:none;align-items:center;gap:8px;padding:7px 12px;font-family:inherit;font-size:14px;line-height:1.4;transition:background .1s;display:flex}@media (hover:hover){.notectl-font-picker__item:hover{background:var(--notectl-hover-bg)}}.notectl-font-picker__item--active{background:var(--notectl-active-bg);color:var(--notectl-accent-fg)}@media (hover:hover){.notectl-font-picker__item--active:hover{background:var(--notectl-active-bg)}}.notectl-font-picker__check{width:16px;color:var(--notectl-accent-fg);flex-shrink:0;justify-content:center;align-items:center;font-size:13px;font-weight:600;display:inline-flex}.notectl-font-picker__label{flex:1}.notectl-font-picker__separator{background:var(--notectl-border);height:1px;margin:4px 8px}"),this.context=t,this.registerMarkSpec(t),this.registerStyleClasses(t),this.registerCommands(t),this.config.fonts.length>0&&this.registerToolbarItem(t),this.injectFontFaces()}destroy(){this.injectedStyleElement?.remove(),this.injectedStyleElement=null,this.context=null}registerMarkSpec(t){const e=this.config.fonts.map(t=>t.family);t.registerMarkSpec(p({...y,knownValues:e}))}registerStyleClasses(t){d(t,"FontPlugin",this.config.styleClasses,t=>f(y.cssProperty,this.familyOf(t)))}familyOf(t){const e=this.config.fonts.find(e=>e.name===t);if(e)return e.family;const o=this.config.fonts.map(t=>`"${t.name}"`).join(", ")||"none";throw new TypeError(`"${t}" is not the name of a configured font; configured: ${o}.`)}registerCommands(t){t.registerCommand("removeFont",()=>{const e=t.getState();return this.removeFont(t,e)}),t.registerCommand("setFont",()=>!1)}get defaultFont(){if(this.config.defaultFont){const t=this.config.fonts.find(t=>t.name===this.config.defaultFont);if(t)return t}return this.config.fonts[0]}registerToolbarItem(t){t.registerToolbarItem({id:"font",group:"format",label:this.locale.label,tooltip:this.locale.tooltip,command:"removeFont",popupType:"combobox",getLabel:t=>this.resolveFontName(this.getActiveFont(t)),renderPopup:(t,e,o)=>{this.renderFontPopup(t,e,o)},isActive:t=>this.isFontActive(t)})}resolveFontName(t){return t?this.config.fonts.find(e=>e.family===t)?.name??(t.split(",")[0]??"").trim().replace(/['"]/g,""):this.defaultFont?.name??this.locale.label}isFontActive(t){return n(t,"font")}getActiveFont(t){return o(t,"font",t=>t.attrs.family??null)}applyFont(e,o,n){const r={type:t("font"),attrs:{family:n}};return s(e,i(o,r))}removeFont(o,n){return s(o,e(n,t("font")))}injectFontFaces(){const t=[];for(const n of this.config.fonts)if(n.fontFaces?.length)for(const e of n.fontFaces){const o=[`font-family: '${(n.family.split(",")[0]??"").trim().replace(/['"]/g,"")}'`,`src: ${e.src}`];e.weight&&o.push(`font-weight: ${e.weight}`),e.style&&o.push(`font-style: ${e.style}`),o.push(`font-display: ${e.display??"swap"}`),t.push(`@font-face {\n\t${o.join(";\n\t")};\n}`)}if(0===t.length)return;const e=document.createElement("style");e.setAttribute("data-notectl-fonts","");const o=this.context?c(this.context.getContainer()):void 0;o&&e.setAttribute("nonce",o),e.textContent=t.join("\n\n"),document.head.appendChild(e),this.injectedStyleElement=e}renderFontPopup(t,e,o){t.classList.add("notectl-font-picker");const n=e.getState(),i=this.getActiveFont(n),s=this.defaultFont?.family,r=e.getContainer(),a=document.createElement("div");a.className="notectl-font-picker__list",a.setAttribute("role","listbox"),a.setAttribute("aria-label",this.locale.label);for(const l of this.config.fonts){const t=void 0!==s&&l.family===s,n=t&&!i||i===l.family,c=this.createFontItem(l.name,l.family,n,()=>{t?e.executeCommand("removeFont"):this.applyFont(e,e.getState(),l.family),o({restoreFocusTo:r})});l.category&&c.setAttribute("data-category",l.category),a.appendChild(c)}t.appendChild(a)}createFontItem(t,e,o,n){const i=document.createElement("button");i.type="button",i.className="notectl-font-picker__item",i.setAttribute("role","option"),i.setAttribute("aria-selected",String(o)),o&&i.classList.add("notectl-font-picker__item--active");const s=document.createElement("span");s.className="notectl-font-picker__check",s.textContent=o?"✓":"",i.appendChild(s);const r=document.createElement("span");return r.className="notectl-font-picker__label",r.textContent=t,e&&l(r,"fontFamily",e),i.appendChild(r),i.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),i.addEventListener("click",n),i}};export{h as n,u as r,v as t};
|
|
2
|
+
//# sourceMappingURL=FontPlugin-Bzlluh1_.mjs.map
|