@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FontPlugin-BcXNFqqO.mjs","names":["FONT_SELECT_CSS","markType","removeAttributedMark","getMarkAttrAtSelection","isAttributedMarkActive","applyAttributedMark","loadLocaleModule","dispatchIfPresent","resolveLocale","setStyleProperty","getStyleNonceForNode","isValidCSSFontFamily","styleDeclaration","createInlineStyleMarkSpec","registerStyleClassNames","FONT_LOCALE_EN","label","tooltip","localeModules","Object","assign","async","loadFontLocale","lang","FONT_MARK","type","rank","valueAttr","domStyleProperty","cssProperty","validate","transformParsed","family","replace","FontPlugin","id","name","priority","config","locale","injectedStyleElement","context","constructor","this","init","registerStyleSheet","registerMarkSpec","registerStyleClasses","registerCommands","fonts","length","registerToolbarItem","injectFontFaces","destroy","remove","knownValues","map","font","styleClasses","key","familyOf","find","f","names","join","TypeError","registerCommand","state","getState","removeFont","defaultFont","found","group","command","popupType","getLabel","resolveFontName","getActiveFont","renderPopup","container","ctx","onClose","renderFontPopup","isActive","isFontActive","split","trim","m","attrs","applyFont","mark","rules","fontFaces","face","declarations","src","weight","push","style","display","document","createElement","setAttribute","nonce","getContainer","textContent","head","appendChild","classList","add","activeFont","defaultFamily","contentElement","list","className","isDefault","item","createFontItem","executeCommand","restoreFocusTo","category","onActivate","String","check","addEventListener","e","preventDefault","stopPropagation"],"sources":["../../src/editor/styles/font-select.css?inline","../../src/plugins/font/FontLocale.ts","../../src/plugins/font/FontPlugin.ts"],"sourcesContent":["/** Font picker toolbar combobox + popup styles. */\n/* Font Select — Width overrides for combobox button */\n.notectl-toolbar-btn--font {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Font Picker Popup */\n.notectl-font-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-font-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-font-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-font-picker__label {\n\tflex: 1;\n}\n\n.notectl-font-picker__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 8px;\n}\n","/** Locale interface and default English locale for the FontPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface FontLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_LOCALE_EN: FontLocale = {\n\tlabel: 'Font',\n\ttooltip: 'Font Family',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<FontLocale> = import.meta.glob<{\n\tdefault: FontLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadFontLocale(lang: string): Promise<FontLocale> {\n\treturn loadLocaleModule(localeModules, lang, FONT_LOCALE_EN);\n}\n","/**\n * FontPlugin: registers a font-family mark, a combobox-style toolbar selector\n * for font selection, and a developer-friendly API for registering custom fonts\n * (WOFF2, TTF, OTF).\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport FONT_SELECT_CSS from '../../editor/styles/font-select.css?inline';\nimport type { StyleClassNames } from '../../model/StyleClass.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { getStyleNonceForNode, setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isValidCSSFontFamily } from '../shared/ColorValidation.js';\nimport {\n\ttype InlineStyleMarkConfig,\n\tcreateInlineStyleMarkSpec,\n\tstyleDeclaration,\n} from '../shared/InlineStyleMarkSpec.js';\nimport { dispatchIfPresent, resolveLocale } from '../shared/PluginHelpers.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport { registerStyleClassNames } from '../shared/StyleClassNames.js';\nimport { FONT_LOCALE_EN, type FontLocale, loadFontLocale } from './FontLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfont: { family: string };\n\t}\n}\n\n// --- Public Types ---\n\n/** Describes a single @font-face source. */\nexport interface FontFaceDescriptor {\n\t/** CSS `src` value, e.g. `\"url('/fonts/My.woff2') format('woff2')\"`. */\n\treadonly src: string;\n\t/** Font weight, e.g. `'400'` or `'300 700'` for variable fonts. */\n\treadonly weight?: string;\n\t/** Font style, e.g. `'normal'` or `'italic'`. */\n\treadonly style?: string;\n\t/** Font display strategy. Defaults to `'swap'`. */\n\treadonly display?: string;\n}\n\n/** Defines a font available in the editor. */\nexport interface FontDefinition {\n\t/** Display name shown in the toolbar dropdown. */\n\treadonly name: string;\n\t/** CSS `font-family` value, e.g. `\"'Fira Code', monospace\"`. */\n\treadonly family: string;\n\t/** Font category for grouping in the UI. */\n\treadonly category?: 'serif' | 'sans-serif' | 'monospace' | 'display' | 'handwriting';\n\t/**\n\t * Optional `@font-face` descriptors. When provided, the plugin\n\t * auto-injects the corresponding CSS rules into the document.\n\t */\n\treadonly fontFaces?: readonly FontFaceDescriptor[];\n}\n\n// --- Configuration ---\n\nexport interface FontConfig {\n\t/**\n\t * Fonts available in the editor. System fonts require no `fontFaces`.\n\t * Custom fonts with `fontFaces` get their `@font-face` rules auto-injected.\n\t *\n\t * Use `STARTER_FONTS` for a pre-configured set of fonts:\n\t * ```ts\n\t * new FontPlugin({ fonts: [...STARTER_FONTS] })\n\t * ```\n\t */\n\treadonly fonts: readonly FontDefinition[];\n\t/**\n\t * Name of the font that acts as the editor's default.\n\t * Selecting this font removes the mark (since the editor already uses it).\n\t * Defaults to the first font in the list.\n\t */\n\treadonly defaultFont?: string;\n\t/**\n\t * Your own CSS class per font in HTML content, keyed by font name, e.g.\n\t * `{ 'Fira Code': 'font-mono' }`. Class-based export (`getContentHTML({ cssMode: 'classes' })`)\n\t * writes these classes instead of generated `notectl-s-*` names, and HTML import\n\t * and paste recognize them, so content round-trips with your stylesheet. Keys must\n\t * name fonts in `fonts`. Invalid keys or class names make editor initialization\n\t * fail with a `TypeError` that explains the fix.\n\t */\n\treadonly styleClasses?: StyleClassNames<string>;\n\treadonly locale?: FontLocale;\n}\n\n/** The font mark: one `font-family` declaration per text run. */\nconst FONT_MARK: InlineStyleMarkConfig = {\n\ttype: 'font',\n\trank: 6,\n\tvalueAttr: 'family',\n\tdomStyleProperty: 'fontFamily',\n\tcssProperty: 'font-family',\n\tvalidate: isValidCSSFontFamily,\n\t// Browsers normalize CSS quotes to double-quotes; our internal\n\t// convention uses single-quotes.\n\ttransformParsed: (family: string) => family.replace(/\"/g, \"'\"),\n};\n\n// --- Plugin ---\n\nexport class FontPlugin implements Plugin {\n\treadonly id = 'font';\n\treadonly name = 'Font';\n\treadonly priority = 22;\n\n\tprivate readonly config: FontConfig;\n\tprivate locale!: FontLocale;\n\tprivate injectedStyleElement: HTMLStyleElement | null = null;\n\tprivate context: PluginContext | null = null;\n\n\tconstructor(config: FontConfig) {\n\t\tthis.config = config;\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(context, this.config.locale, FONT_LOCALE_EN, loadFontLocale);\n\n\t\tcontext.registerStyleSheet(FONT_SELECT_CSS);\n\t\tthis.context = context;\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerStyleClasses(context);\n\t\tthis.registerCommands(context);\n\t\tif (this.config.fonts.length > 0) {\n\t\t\tthis.registerToolbarItem(context);\n\t\t}\n\t\tthis.injectFontFaces();\n\t}\n\n\tdestroy(): void {\n\t\tthis.injectedStyleElement?.remove();\n\t\tthis.injectedStyleElement = null;\n\t\tthis.context = null;\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tconst knownValues: readonly string[] = this.config.fonts.map((font) => font.family);\n\t\tcontext.registerMarkSpec(createInlineStyleMarkSpec({ ...FONT_MARK, knownValues }));\n\t}\n\n\tprivate registerStyleClasses(context: PluginContext): void {\n\t\tregisterStyleClassNames(context, 'FontPlugin', this.config.styleClasses, (key: string) =>\n\t\t\tstyleDeclaration(FONT_MARK.cssProperty, this.familyOf(key)),\n\t\t);\n\t}\n\n\t/** The family of a configured font name. Throws a `TypeError` for an unknown name. */\n\tprivate familyOf(name: string): string {\n\t\tconst font: FontDefinition | undefined = this.config.fonts.find((f) => f.name === name);\n\t\tif (font) return font.family;\n\t\tconst names: string = this.config.fonts.map((f) => `\"${f.name}\"`).join(', ') || 'none';\n\t\tthrow new TypeError(`\"${name}\" is not the name of a configured font; configured: ${names}.`);\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFont', () => {\n\t\t\tconst state: EditorState = context.getState();\n\t\t\treturn this.removeFont(context, state);\n\t\t});\n\n\t\tcontext.registerCommand('setFont', () => {\n\t\t\treturn false;\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate get defaultFont(): FontDefinition | undefined {\n\t\tif (this.config.defaultFont) {\n\t\t\tconst found: FontDefinition | undefined = this.config.fonts.find(\n\t\t\t\t(f) => f.name === this.config.defaultFont,\n\t\t\t);\n\t\t\tif (found) return found;\n\t\t}\n\t\treturn this.config.fonts[0];\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'font',\n\t\t\tgroup: 'format',\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFont',\n\t\t\tpopupType: 'combobox',\n\t\t\tgetLabel: (state: EditorState): string => this.resolveFontName(this.getActiveFont(state)),\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\tthis.renderFontPopup(container, ctx, onClose);\n\t\t\t},\n\t\t\tisActive: (state) => this.isFontActive(state),\n\t\t});\n\t}\n\n\tprivate resolveFontName(family: string | null): string {\n\t\tif (!family) return this.defaultFont?.name ?? this.locale.label;\n\t\tconst match: FontDefinition | undefined = this.config.fonts.find((f) => f.family === family);\n\t\treturn match?.name ?? (family.split(',')[0] ?? '').trim().replace(/['\"]/g, '');\n\t}\n\n\t// --- State Queries ---\n\n\tprivate isFontActive(state: EditorState): boolean {\n\t\treturn isAttributedMarkActive(state, 'font');\n\t}\n\n\tgetActiveFont(state: EditorState): string | null {\n\t\treturn getMarkAttrAtSelection(state, 'font', (m) => m.attrs.family ?? null);\n\t}\n\n\t// --- Font Application ---\n\n\tapplyFont(context: PluginContext, state: EditorState, family: string): boolean {\n\t\tconst mark = { type: markType('font'), attrs: { family } };\n\t\treturn dispatchIfPresent(context, applyAttributedMark(state, mark));\n\t}\n\n\tprivate removeFont(context: PluginContext, state: EditorState): boolean {\n\t\treturn dispatchIfPresent(context, removeAttributedMark(state, markType('font')));\n\t}\n\n\t// --- @font-face Injection ---\n\n\tprivate injectFontFaces(): void {\n\t\tconst rules: string[] = [];\n\n\t\tfor (const font of this.config.fonts) {\n\t\t\tif (!font.fontFaces?.length) continue;\n\n\t\t\tfor (const face of font.fontFaces) {\n\t\t\t\tconst familyName: string = (font.family.split(',')[0] ?? '').trim().replace(/['\"]/g, '');\n\t\t\t\tconst declarations: string[] = [`font-family: '${familyName}'`, `src: ${face.src}`];\n\t\t\t\tif (face.weight) {\n\t\t\t\t\tdeclarations.push(`font-weight: ${face.weight}`);\n\t\t\t\t}\n\t\t\t\tif (face.style) {\n\t\t\t\t\tdeclarations.push(`font-style: ${face.style}`);\n\t\t\t\t}\n\t\t\t\tdeclarations.push(`font-display: ${face.display ?? 'swap'}`);\n\n\t\t\t\trules.push(`@font-face {\\n\\t${declarations.join(';\\n\\t')};\\n}`);\n\t\t\t}\n\t\t}\n\n\t\tif (rules.length === 0) return;\n\n\t\tconst style: HTMLStyleElement = document.createElement('style');\n\t\tstyle.setAttribute('data-notectl-fonts', '');\n\t\tconst nonce = this.context ? getStyleNonceForNode(this.context.getContainer()) : undefined;\n\t\tif (nonce) {\n\t\t\tstyle.setAttribute('nonce', nonce);\n\t\t}\n\t\tstyle.textContent = rules.join('\\n\\n');\n\t\tdocument.head.appendChild(style);\n\t\tthis.injectedStyleElement = style;\n\t}\n\n\t// --- Popup Rendering ---\n\n\tprivate renderFontPopup(\n\t\tcontainer: HTMLElement,\n\t\tcontext: PluginContext,\n\t\tonClose: (options?: PopupCloseOptions) => void,\n\t): void {\n\t\tcontainer.classList.add('notectl-font-picker');\n\n\t\tconst state: EditorState = context.getState();\n\t\tconst activeFont: string | null = this.getActiveFont(state);\n\t\tconst defaultFamily: string | undefined = this.defaultFont?.family;\n\t\tconst contentElement: HTMLElement = context.getContainer();\n\n\t\tconst list: HTMLDivElement = document.createElement('div');\n\t\tlist.className = 'notectl-font-picker__list';\n\t\tlist.setAttribute('role', 'listbox');\n\t\tlist.setAttribute('aria-label', this.locale.label);\n\n\t\tfor (const font of this.config.fonts) {\n\t\t\tconst isDefault: boolean = defaultFamily !== undefined && font.family === defaultFamily;\n\t\t\tconst isActive: boolean = isDefault\n\t\t\t\t? !activeFont || activeFont === font.family\n\t\t\t\t: activeFont === font.family;\n\n\t\t\tconst item: HTMLButtonElement = this.createFontItem(font.name, font.family, isActive, () => {\n\t\t\t\tif (isDefault) {\n\t\t\t\t\tcontext.executeCommand('removeFont');\n\t\t\t\t} else {\n\t\t\t\t\tthis.applyFont(context, context.getState(), font.family);\n\t\t\t\t}\n\t\t\t\tonClose({ restoreFocusTo: contentElement });\n\t\t\t});\n\n\t\t\tif (font.category) {\n\t\t\t\titem.setAttribute('data-category', font.category);\n\t\t\t}\n\n\t\t\tlist.appendChild(item);\n\t\t}\n\n\t\tcontainer.appendChild(list);\n\t}\n\n\tprivate createFontItem(\n\t\tname: string,\n\t\tfamily: string,\n\t\tisActive: boolean,\n\t\tonActivate: () => void,\n\t): HTMLButtonElement {\n\t\tconst item: HTMLButtonElement = document.createElement('button');\n\t\titem.type = 'button';\n\t\titem.className = 'notectl-font-picker__item';\n\t\titem.setAttribute('role', 'option');\n\t\titem.setAttribute('aria-selected', String(isActive));\n\n\t\tif (isActive) {\n\t\t\titem.classList.add('notectl-font-picker__item--active');\n\t\t}\n\n\t\t// Checkmark indicator\n\t\tconst check: HTMLSpanElement = document.createElement('span');\n\t\tcheck.className = 'notectl-font-picker__check';\n\t\tcheck.textContent = isActive ? '\\u2713' : '';\n\t\titem.appendChild(check);\n\n\t\t// Font name label (rendered in the font itself for preview)\n\t\tconst label: HTMLSpanElement = document.createElement('span');\n\t\tlabel.className = 'notectl-font-picker__label';\n\t\tlabel.textContent = name;\n\t\tif (family) {\n\t\t\tsetStyleProperty(label, 'fontFamily', family);\n\t\t}\n\t\titem.appendChild(label);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t});\n\t\titem.addEventListener('click', onActivate);\n\t\treturn item;\n\t}\n}\n"],"mappings":"Y,+YCaae,EAA6B,CACzCC,MAAO,OACPC,QAAS,eAKJC,iBAA6CC,OAAAC,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAInDC,eAAsBC,EAAeC,GACpC,OAAOjB,EAAiBY,EAAeK,EAAMR,EAC9C,CCwEA,IAAMS,EAAmC,CACxCC,KAAM,OACNC,KAAM,EACNC,UAAW,SACXC,iBAAkB,aAClBC,YAAa,cACbC,SAAUnB,EAGVoB,gBAAkBC,GAAmBA,EAAOC,QAAQ,KAAM,MAK9CC,EAAb,MACCC,GAAc,OACdC,KAAgB,OAChBC,SAAoB,GAEpBC,OACAC,OACAC,qBAAwD,KACxDC,QAAwC,KAExC,WAAAC,CAAYJ,GACXK,KAAKL,OAASA,CACf,CAEA,UAAMM,CAAKH,GACVE,KAAKJ,aAAe/B,EAAciC,EAASE,KAAKL,OAAOC,OAAQxB,EAAgBO,GAE/EmB,EAAQI,mB,khCACRF,KAAKF,QAAUA,EACfE,KAAKG,iBAAiBL,GACtBE,KAAKI,qBAAqBN,GAC1BE,KAAKK,iBAAiBP,GAClBE,KAAKL,OAAOW,MAAMC,OAAS,GAC9BP,KAAKQ,oBAAoBV,GAE1BE,KAAKS,iBACN,CAEA,OAAAC,GACCV,KAAKH,sBAAsBc,SAC3BX,KAAKH,qBAAuB,KAC5BG,KAAKF,QAAU,IAChB,CAIA,gBAAAK,CAAyBL,GACxB,MAAMc,EAAiCZ,KAAKL,O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,QACtDsB,EAAMT,UAAY,6BAClBS,EAAMlB,YAActB,EAAW,IAAW,GAC1CiC,EAAKT,YAAYgB,GAGjB,MAAM3G,EAAyBoF,SAASC,cAAc,QAatD,OAZArF,EAAMkG,UAAY,6BAClBlG,EAAMyF,YAAcrE,EAChBJ,GACHvB,EAAiBO,EAAO,aAAcgB,GAEvCoF,EAAKT,YAAY3F,GAEjBoG,EAAKQ,iBAAiB,YAAcC,IACnCA,EAAEC,iBACFD,EAAEE,oBAEHX,EAAKQ,iBAAiB,QAASH,GACxBL,CACR,U"}
|
|
1
|
+
{"version":3,"file":"FontPlugin-Bzlluh1_.mjs","names":["FONT_SELECT_CSS","markType","removeAttributedMark","getMarkAttrAtSelection","isAttributedMarkActive","applyAttributedMark","dispatchIfPresent","resolveLocale","loadLocaleModule","setStyleProperty","getStyleNonceForNode","isValidCSSFontFamily","styleDeclaration","createInlineStyleMarkSpec","registerStyleClassNames","FONT_LOCALE_EN","label","tooltip","localeModules","Object","assign","async","loadFontLocale","lang","FONT_MARK","type","rank","valueAttr","domStyleProperty","cssProperty","validate","transformParsed","family","replace","FontPlugin","id","name","priority","config","locale","injectedStyleElement","context","constructor","this","init","registerStyleSheet","registerMarkSpec","registerStyleClasses","registerCommands","fonts","length","registerToolbarItem","injectFontFaces","destroy","remove","knownValues","map","font","styleClasses","key","familyOf","find","f","names","join","TypeError","registerCommand","state","getState","removeFont","defaultFont","found","group","command","popupType","getLabel","resolveFontName","getActiveFont","renderPopup","container","ctx","onClose","renderFontPopup","isActive","isFontActive","split","trim","m","attrs","applyFont","mark","rules","fontFaces","face","declarations","src","weight","push","style","display","document","createElement","setAttribute","nonce","getContainer","textContent","head","appendChild","classList","add","activeFont","defaultFamily","contentElement","list","className","isDefault","item","createFontItem","executeCommand","restoreFocusTo","category","onActivate","String","check","addEventListener","e","preventDefault","stopPropagation"],"sources":["../../src/editor/styles/font-select.css?inline","../../src/plugins/font/FontLocale.ts","../../src/plugins/font/FontPlugin.ts"],"sourcesContent":["/** Font picker toolbar combobox + popup styles. */\n/* Font Select — Width overrides for combobox button */\n.notectl-toolbar-btn--font {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Font Picker Popup */\n.notectl-font-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-font-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-font-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-font-picker__label {\n\tflex: 1;\n}\n\n.notectl-font-picker__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 8px;\n}\n","/** Locale interface and default English locale for the FontPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface FontLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_LOCALE_EN: FontLocale = {\n\tlabel: 'Font',\n\ttooltip: 'Font Family',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<FontLocale> = import.meta.glob<{\n\tdefault: FontLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadFontLocale(lang: string): Promise<FontLocale> {\n\treturn loadLocaleModule(localeModules, lang, FONT_LOCALE_EN);\n}\n","/**\n * FontPlugin: registers a font-family mark, a combobox-style toolbar selector\n * for font selection, and a developer-friendly API for registering custom fonts\n * (WOFF2, TTF, OTF).\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport FONT_SELECT_CSS from '../../editor/styles/font-select.css?inline';\nimport type { StyleClassNames } from '../../model/StyleClass.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { getStyleNonceForNode, setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isValidCSSFontFamily } from '../shared/ColorValidation.js';\nimport {\n\ttype InlineStyleMarkConfig,\n\tcreateInlineStyleMarkSpec,\n\tstyleDeclaration,\n} from '../shared/InlineStyleMarkSpec.js';\nimport { dispatchIfPresent, resolveLocale } from '../shared/PluginHelpers.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport { registerStyleClassNames } from '../shared/StyleClassNames.js';\nimport { FONT_LOCALE_EN, type FontLocale, loadFontLocale } from './FontLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfont: { family: string };\n\t}\n}\n\n// --- Public Types ---\n\n/** Describes a single @font-face source. */\nexport interface FontFaceDescriptor {\n\t/** CSS `src` value, e.g. `\"url('/fonts/My.woff2') format('woff2')\"`. */\n\treadonly src: string;\n\t/** Font weight, e.g. `'400'` or `'300 700'` for variable fonts. */\n\treadonly weight?: string;\n\t/** Font style, e.g. `'normal'` or `'italic'`. */\n\treadonly style?: string;\n\t/** Font display strategy. Defaults to `'swap'`. */\n\treadonly display?: string;\n}\n\n/** Defines a font available in the editor. */\nexport interface FontDefinition {\n\t/** Display name shown in the toolbar dropdown. */\n\treadonly name: string;\n\t/** CSS `font-family` value, e.g. `\"'Fira Code', monospace\"`. */\n\treadonly family: string;\n\t/** Font category for grouping in the UI. */\n\treadonly category?: 'serif' | 'sans-serif' | 'monospace' | 'display' | 'handwriting';\n\t/**\n\t * Optional `@font-face` descriptors. When provided, the plugin\n\t * auto-injects the corresponding CSS rules into the document.\n\t */\n\treadonly fontFaces?: readonly FontFaceDescriptor[];\n}\n\n// --- Configuration ---\n\nexport interface FontConfig {\n\t/**\n\t * Fonts available in the editor. System fonts require no `fontFaces`.\n\t * Custom fonts with `fontFaces` get their `@font-face` rules auto-injected.\n\t *\n\t * Use `STARTER_FONTS` for a pre-configured set of fonts:\n\t * ```ts\n\t * new FontPlugin({ fonts: [...STARTER_FONTS] })\n\t * ```\n\t */\n\treadonly fonts: readonly FontDefinition[];\n\t/**\n\t * Name of the font that acts as the editor's default.\n\t * Selecting this font removes the mark (since the editor already uses it).\n\t * Defaults to the first font in the list.\n\t */\n\treadonly defaultFont?: string;\n\t/**\n\t * Your own CSS class per font in HTML content, keyed by font name, e.g.\n\t * `{ 'Fira Code': 'font-mono' }`. Class-based export (`getContentHTML({ cssMode: 'classes' })`)\n\t * writes these classes instead of generated `notectl-s-*` names, and HTML import\n\t * and paste recognize them, so content round-trips with your stylesheet. Keys must\n\t * name fonts in `fonts`. Invalid keys or class names make editor initialization\n\t * fail with a `TypeError` that explains the fix.\n\t */\n\treadonly styleClasses?: StyleClassNames<string>;\n\treadonly locale?: FontLocale;\n}\n\n/** The font mark: one `font-family` declaration per text run. */\nconst FONT_MARK: InlineStyleMarkConfig = {\n\ttype: 'font',\n\trank: 6,\n\tvalueAttr: 'family',\n\tdomStyleProperty: 'fontFamily',\n\tcssProperty: 'font-family',\n\tvalidate: isValidCSSFontFamily,\n\t// Browsers normalize CSS quotes to double-quotes; our internal\n\t// convention uses single-quotes.\n\ttransformParsed: (family: string) => family.replace(/\"/g, \"'\"),\n};\n\n// --- Plugin ---\n\nexport class FontPlugin implements Plugin {\n\treadonly id = 'font';\n\treadonly name = 'Font';\n\treadonly priority = 22;\n\n\tprivate readonly config: FontConfig;\n\tprivate locale!: FontLocale;\n\tprivate injectedStyleElement: HTMLStyleElement | null = null;\n\tprivate context: PluginContext | null = null;\n\n\tconstructor(config: FontConfig) {\n\t\tthis.config = config;\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(context, this.config.locale, FONT_LOCALE_EN, loadFontLocale);\n\n\t\tcontext.registerStyleSheet(FONT_SELECT_CSS);\n\t\tthis.context = context;\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerStyleClasses(context);\n\t\tthis.registerCommands(context);\n\t\tif (this.config.fonts.length > 0) {\n\t\t\tthis.registerToolbarItem(context);\n\t\t}\n\t\tthis.injectFontFaces();\n\t}\n\n\tdestroy(): void {\n\t\tthis.injectedStyleElement?.remove();\n\t\tthis.injectedStyleElement = null;\n\t\tthis.context = null;\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tconst knownValues: readonly string[] = this.config.fonts.map((font) => font.family);\n\t\tcontext.registerMarkSpec(createInlineStyleMarkSpec({ ...FONT_MARK, knownValues }));\n\t}\n\n\tprivate registerStyleClasses(context: PluginContext): void {\n\t\tregisterStyleClassNames(context, 'FontPlugin', this.config.styleClasses, (key: string) =>\n\t\t\tstyleDeclaration(FONT_MARK.cssProperty, this.familyOf(key)),\n\t\t);\n\t}\n\n\t/** The family of a configured font name. Throws a `TypeError` for an unknown name. */\n\tprivate familyOf(name: string): string {\n\t\tconst font: FontDefinition | undefined = this.config.fonts.find((f) => f.name === name);\n\t\tif (font) return font.family;\n\t\tconst names: string = this.config.fonts.map((f) => `\"${f.name}\"`).join(', ') || 'none';\n\t\tthrow new TypeError(`\"${name}\" is not the name of a configured font; configured: ${names}.`);\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFont', () => {\n\t\t\tconst state: EditorState = context.getState();\n\t\t\treturn this.removeFont(context, state);\n\t\t});\n\n\t\tcontext.registerCommand('setFont', () => {\n\t\t\treturn false;\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate get defaultFont(): FontDefinition | undefined {\n\t\tif (this.config.defaultFont) {\n\t\t\tconst found: FontDefinition | undefined = this.config.fonts.find(\n\t\t\t\t(f) => f.name === this.config.defaultFont,\n\t\t\t);\n\t\t\tif (found) return found;\n\t\t}\n\t\treturn this.config.fonts[0];\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'font',\n\t\t\tgroup: 'format',\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFont',\n\t\t\tpopupType: 'combobox',\n\t\t\tgetLabel: (state: EditorState): string => this.resolveFontName(this.getActiveFont(state)),\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\tthis.renderFontPopup(container, ctx, onClose);\n\t\t\t},\n\t\t\tisActive: (state) => this.isFontActive(state),\n\t\t});\n\t}\n\n\tprivate resolveFontName(family: string | null): string {\n\t\tif (!family) return this.defaultFont?.name ?? this.locale.label;\n\t\tconst match: FontDefinition | undefined = this.config.fonts.find((f) => f.family === family);\n\t\treturn match?.name ?? (family.split(',')[0] ?? '').trim().replace(/['\"]/g, '');\n\t}\n\n\t// --- State Queries ---\n\n\tprivate isFontActive(state: EditorState): boolean {\n\t\treturn isAttributedMarkActive(state, 'font');\n\t}\n\n\tgetActiveFont(state: EditorState): string | null {\n\t\treturn getMarkAttrAtSelection(state, 'font', (m) => m.attrs.family ?? null);\n\t}\n\n\t// --- Font Application ---\n\n\tapplyFont(context: PluginContext, state: EditorState, family: string): boolean {\n\t\tconst mark = { type: markType('font'), attrs: { family } };\n\t\treturn dispatchIfPresent(context, applyAttributedMark(state, mark));\n\t}\n\n\tprivate removeFont(context: PluginContext, state: EditorState): boolean {\n\t\treturn dispatchIfPresent(context, removeAttributedMark(state, markType('font')));\n\t}\n\n\t// --- @font-face Injection ---\n\n\tprivate injectFontFaces(): void {\n\t\tconst rules: string[] = [];\n\n\t\tfor (const font of this.config.fonts) {\n\t\t\tif (!font.fontFaces?.length) continue;\n\n\t\t\tfor (const face of font.fontFaces) {\n\t\t\t\tconst familyName: string = (font.family.split(',')[0] ?? '').trim().replace(/['\"]/g, '');\n\t\t\t\tconst declarations: string[] = [`font-family: '${familyName}'`, `src: ${face.src}`];\n\t\t\t\tif (face.weight) {\n\t\t\t\t\tdeclarations.push(`font-weight: ${face.weight}`);\n\t\t\t\t}\n\t\t\t\tif (face.style) {\n\t\t\t\t\tdeclarations.push(`font-style: ${face.style}`);\n\t\t\t\t}\n\t\t\t\tdeclarations.push(`font-display: ${face.display ?? 'swap'}`);\n\n\t\t\t\trules.push(`@font-face {\\n\\t${declarations.join(';\\n\\t')};\\n}`);\n\t\t\t}\n\t\t}\n\n\t\tif (rules.length === 0) return;\n\n\t\tconst style: HTMLStyleElement = document.createElement('style');\n\t\tstyle.setAttribute('data-notectl-fonts', '');\n\t\tconst nonce = this.context ? getStyleNonceForNode(this.context.getContainer()) : undefined;\n\t\tif (nonce) {\n\t\t\tstyle.setAttribute('nonce', nonce);\n\t\t}\n\t\tstyle.textContent = rules.join('\\n\\n');\n\t\tdocument.head.appendChild(style);\n\t\tthis.injectedStyleElement = style;\n\t}\n\n\t// --- Popup Rendering ---\n\n\tprivate renderFontPopup(\n\t\tcontainer: HTMLElement,\n\t\tcontext: PluginContext,\n\t\tonClose: (options?: PopupCloseOptions) => void,\n\t): void {\n\t\tcontainer.classList.add('notectl-font-picker');\n\n\t\tconst state: EditorState = context.getState();\n\t\tconst activeFont: string | null = this.getActiveFont(state);\n\t\tconst defaultFamily: string | undefined = this.defaultFont?.family;\n\t\tconst contentElement: HTMLElement = context.getContainer();\n\n\t\tconst list: HTMLDivElement = document.createElement('div');\n\t\tlist.className = 'notectl-font-picker__list';\n\t\tlist.setAttribute('role', 'listbox');\n\t\tlist.setAttribute('aria-label', this.locale.label);\n\n\t\tfor (const font of this.config.fonts) {\n\t\t\tconst isDefault: boolean = defaultFamily !== undefined && font.family === defaultFamily;\n\t\t\tconst isActive: boolean = isDefault\n\t\t\t\t? !activeFont || activeFont === font.family\n\t\t\t\t: activeFont === font.family;\n\n\t\t\tconst item: HTMLButtonElement = this.createFontItem(font.name, font.family, isActive, () => {\n\t\t\t\tif (isDefault) {\n\t\t\t\t\tcontext.executeCommand('removeFont');\n\t\t\t\t} else {\n\t\t\t\t\tthis.applyFont(context, context.getState(), font.family);\n\t\t\t\t}\n\t\t\t\tonClose({ restoreFocusTo: contentElement });\n\t\t\t});\n\n\t\t\tif (font.category) {\n\t\t\t\titem.setAttribute('data-category', font.category);\n\t\t\t}\n\n\t\t\tlist.appendChild(item);\n\t\t}\n\n\t\tcontainer.appendChild(list);\n\t}\n\n\tprivate createFontItem(\n\t\tname: string,\n\t\tfamily: string,\n\t\tisActive: boolean,\n\t\tonActivate: () => void,\n\t): HTMLButtonElement {\n\t\tconst item: HTMLButtonElement = document.createElement('button');\n\t\titem.type = 'button';\n\t\titem.className = 'notectl-font-picker__item';\n\t\titem.setAttribute('role', 'option');\n\t\titem.setAttribute('aria-selected', String(isActive));\n\n\t\tif (isActive) {\n\t\t\titem.classList.add('notectl-font-picker__item--active');\n\t\t}\n\n\t\t// Checkmark indicator\n\t\tconst check: HTMLSpanElement = document.createElement('span');\n\t\tcheck.className = 'notectl-font-picker__check';\n\t\tcheck.textContent = isActive ? '\\u2713' : '';\n\t\titem.appendChild(check);\n\n\t\t// Font name label (rendered in the font itself for preview)\n\t\tconst label: HTMLSpanElement = document.createElement('span');\n\t\tlabel.className = 'notectl-font-picker__label';\n\t\tlabel.textContent = name;\n\t\tif (family) {\n\t\t\tsetStyleProperty(label, 'fontFamily', family);\n\t\t}\n\t\titem.appendChild(label);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t});\n\t\titem.addEventListener('click', onActivate);\n\t\treturn item;\n\t}\n}\n"],"mappings":"Y,8YCaae,EAA6B,CACzCC,MAAO,OACPC,QAAS,eAKJC,iBAA6CC,OAAAC,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAInDC,eAAsBC,EAAeC,GACpC,OAAOf,EAAiBU,EAAeK,EAAMR,EAC9C,CCwEA,IAAMS,EAAmC,CACxCC,KAAM,OACNC,KAAM,EACNC,UAAW,SACXC,iBAAkB,aAClBC,YAAa,cACbC,SAAUnB,EAGVoB,gBAAkBC,GAAmBA,EAAOC,QAAQ,KAAM,MAK9CC,EAAb,MACCC,GAAc,OACdC,KAAgB,OAChBC,SAAoB,GAEpBC,OACAC,OACAC,qBAAwD,KACxDC,QAAwC,KAExC,WAAAC,CAAYJ,GACXK,KAAKL,OAASA,CACf,CAEA,UAAMM,CAAKH,GACVE,KAAKJ,aAAehC,EAAckC,EAASE,KAAKL,OAAOC,OAAQxB,EAAgBO,GAE/EmB,EAAQI,mB,khCACRF,KAAKF,QAAUA,EACfE,KAAKG,iBAAiBL,GACtBE,KAAKI,qBAAqBN,GAC1BE,KAAKK,iBAAiBP,GAClBE,KAAKL,OAAOW,MAAMC,OAAS,GAC9BP,KAAKQ,oBAAoBV,GAE1BE,KAAKS,iBACN,CAEA,OAAAC,GACCV,KAAKH,sBAAsBc,SAC3BX,KAAKH,qBAAuB,KAC5BG,KAAKF,QAAU,IAChB,CAIA,gBAAAK,CAAyBL,GACxB,MA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c,EAAyBvB,SAASC,cAAc,QACtDsB,EAAMT,UAAY,6BAClBS,EAAMlB,YAActB,EAAW,IAAW,GAC1CiC,EAAKT,YAAYgB,GAGjB,MAAM3G,EAAyBoF,SAASC,cAAc,QAatD,OAZArF,EAAMkG,UAAY,6BAClBlG,EAAMyF,YAAcrE,EAChBJ,GACHvB,EAAiBO,EAAO,aAAcgB,GAEvCoF,EAAKT,YAAY3F,GAEjBoG,EAAKQ,iBAAiB,YAAcC,IACnCA,EAAEC,iBACFD,EAAEE,oBAEHX,EAAKQ,iBAAiB,QAASH,GACxBL,CACR,U"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{J as t,P as e,V as n,k as o,z as i}from"./Document-ssR6hBzG.mjs";import{c as r,d as s,f as c,p as a}from"./Selection-DC6AOGgF.mjs";import{i as l}from"./TypeBrands-Ch9856Gb.mjs";import{i as f,n as u,r as d,t as p}from"./AttributedMarkCommands-DKHuhZA7.mjs";import{r as m,s as h,t as k}from"./LocaleLoader-DEpTFuVc.mjs";import{c as z}from"./StyleRuntime-C0RSqKzG.mjs";import{i as g}from"./ColorValidation-ZBKZ_gTr.mjs";import{n as b,t as S}from"./InlineStyleMarkSpec-BhfGgfH9.mjs";import{t as v}from"./StyleClassNames-BsAx7k5T.mjs";var x={label:"Font Size",tooltip:"Font Size",customFontSizeAria:"Custom font size",fontSizesAria:"Font sizes"},y=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BzqAYGER.mjs"),"./locales/de.ts":()=>import("./de-C-Yf378-.mjs"),"./locales/es.ts":()=>import("./es-CUKJujcb.mjs"),"./locales/fr.ts":()=>import("./fr-D0MDdoir.mjs"),"./locales/hi.ts":()=>import("./hi-B2uhiPCN.mjs"),"./locales/nl.ts":()=>import("./nl-C437Xz6z.mjs"),"./locales/pt.ts":()=>import("./pt-BCXgUDiU.mjs"),"./locales/ru.ts":()=>import("./ru-DV-lgEtM.mjs"),"./locales/zh.ts":()=>import("./zh-oZl1P_p0.mjs")});async function _(t){return k(y,t,x)}function w(t){return void 0!==t?.attrs?.fontSize}function I(n){const o=n.selection;if(s(o)){const t=n.getBlock(o.nodeId);return t&&w(n.schema.getNodeSpec?.(t.type))?{kind:"block",path:n.getNodePath(o.nodeId)??[o.nodeId],attrs:t.attrs??{}}:null}const a=function(n){const o=n.selection;if(!c(o)||r(o))return null;if(o.anchor.blockId!==o.head.blockId)return null;const s=Math.min(o.anchor.offset,o.head.offset);if(Math.max(o.anchor.offset,o.head.offset)-s!==1)return null;const a=n.getBlock(o.anchor.blockId);if(!a)return null;for(const{child:r,from:c}of t(e(a)))if(c===s&&i(r))return{node:r,blockId:o.anchor.blockId,offset:s};return null}(n);return a&&w(n.schema.getInlineNodeSpec?.(a.node.inlineType))?{kind:"inline",blockId:a.blockId,offset:a.offset,attrs:a.node.attrs}:null}function C(t){const e=t?.fontSize;return"string"==typeof e&&e.length>0?e:null}function N(t,e){return{...t??{},fontSize:e}}function A(t){return C(t.attrs)}function j(t,e,n,o){const i=e.transaction("command");return"block"===n.kind?i.setNodeAttr(n.path,N(n.attrs,o)):i.setInlineNodeAttr(n.blockId,n.offset,N(n.attrs,o)),t.dispatch(i.build()),!0}var E=l("fontSize");function F(t){const e=t.selection;if(!c(e))return[];const n=t.getBlockOrder(),i=a(e,n),r=n.indexOf(i.from.blockId),s=n.indexOf(i.to.blockId),l=[];for(let c=r;c<=s;c++){const e=n[c];if(!e)continue;const a=t.getBlock(e);if(!a)continue;const f=c===r?i.from.offset:0,u=c===s?i.to.offset:o(a);w(t.schema.getNodeSpec?.(a.type))?l.push({kind:"blockNode",path:t.getNodePath(e)??[e],attrs:a.attrs??{}}):f!==u&&T(t,a,e,f,u,l)}return l}function T(t,o,i,r,s,c){let a,l=0,f=!1;for(const u of e(o))if(n(u)){const t=l+u.text.length;u.text.length>0&&t>r&&l<s&&(f=!0,a||(a=u.marks.find(t=>t.type===E))),l=t}else l>=r&&l<s&&w(t.schema.getInlineNodeSpec?.(u.inlineType))&&c.push({kind:"inlineNode",blockId:i,offset:l,attrs:u.attrs}),l+=1;f&&c.push({kind:"text",blockId:i,from:r,to:s,mark:a})}function M(t,e,n){const o=F(e);if(0===o.length)return!1;const i=e.transaction("command");let r=!1;for(const s of o){if("text"===s.kind){""===n?s.mark&&(i.removeMark(s.blockId,s.from,s.to,s.mark),r=!0):(s.mark&&i.removeMark(s.blockId,s.from,s.to,s.mark),i.addMark(s.blockId,s.from,s.to,{type:E,attrs:{size:n}}),r=!0);continue}const t=C(s.attrs);n===t||""===n&&null===t||("blockNode"===s.kind?i.setNodeAttr(s.path,N(s.attrs,n)):i.setInlineNodeAttr(s.blockId,s.offset,N(s.attrs,n)),r=!0)}return!!r&&(i.setSelection(e.selection),t.dispatch(i.build()),!0)}function L(t){const e=F(t).filter(t=>"text"!==t.kind).map(t=>t.attrs);return 0===e.length?null:new Set(e.map(t=>C(t)??""))}function P(t){return`${t}px`}function D(t,e){const n=function(t){const e=I(t);if(e)return A(e);const n=L(t);if(n&&1===n.size){const[t]=n;if(t)return t}return u(t,"fontSize",t=>t.attrs.size??null)}(t);if(!n)return e;const o=Number.parseInt(n,10);return Number.isNaN(o)?e:o}function O(t,e,n){const o=I(e);if(o)return j(t,e,o,n);const i=e.selection;if(!c(i))return!1;if(r(i)){const o={type:l("fontSize"),attrs:{size:n}};return m(t,p(e,o))}return M(t,e,n)}function B(t,e){const n=I(e);if(n)return null!==A(n)&&j(t,e,n,"");const o=e.selection;return!!c(o)&&(r(o)?m(t,f(e,l("fontSize"))):M(t,e,""))}function $(t,e,n,o,i){const r=function(t,e,n){if("up"===e){for(const e of n)if(e>t)return e;return null}for(let o=n.length-1;o>=0;o--){const e=n[o];if(void 0!==e&&e<t)return e}return null}(D(e,i),n,o);return null!==r&&(r===i?B(t,e):O(t,e,P(r)))}function V(t,e,n){e===n?t.executeCommand("removeFontSize"):O(t,t.getState(),P(e))}function K(t,e){const n=document.createElement("button");n.type="button",n.id=`notectl-font-size-option-${t}`,n.className="notectl-font-size-picker__item",n.setAttribute("role","option"),n.setAttribute("aria-selected",String(e)),e&&n.classList.add("notectl-font-size-picker__item--active");const o=document.createElement("span");o.className="notectl-font-size-picker__check",o.textContent=e?"✓":"",n.appendChild(o);const i=document.createElement("span");return i.className="notectl-font-size-picker__label",i.textContent=String(t),n.appendChild(i),n}var q=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,64,72,96],J={type:"fontSize",rank:4,valueAttr:"size",domStyleProperty:"fontSize",cssProperty:"font-size",validate:g},Q=/^[1-9]\d*$/,R=class{id="fontSize";name="Font Size";priority=21;config;sizes;defaultSize;locale;constructor(t){var e;this.config={...t},this.sizes=function(t){if(!t||0===t.length)return q;const e=[...new Set(t)].filter(t=>Number.isInteger(t)&&t>0);return e.sort((t,e)=>t-e),e.length>0?e:q}(t?.sizes),this.defaultSize=(e=t?.defaultSize,void 0===e?16:Number.isInteger(e)&&e>0?e:16)}async init(t){this.locale=await h(t,this.config.locale,x,_),t.registerStyleSheet(".notectl-toolbar-btn--fontSize{min-width:60px;max-width:80px}.notectl-font-size-picker{flex-direction:column;min-width:140px;display:flex}.notectl-font-size-picker__input-wrapper{padding:8px 8px 4px}.notectl-font-size-picker__input{border:1px solid var(--notectl-border);width:100%;color:var(--notectl-fg);background:var(--notectl-surface-overlay);box-sizing:border-box;-moz-appearance:textfield;border-radius:4px;outline:none;padding:6px 8px;font-family:inherit;font-size:13px}.notectl-font-size-picker__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.notectl-font-size-picker__input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.notectl-font-size-picker__input:focus{border-color:var(--notectl-border-focus);box-shadow:0 0 0 2px var(--notectl-focus-ring)}.notectl-font-size-picker__list{max-height:280px;padding:4px 0;overflow-y:auto}.notectl-font-size-picker__item{cursor:pointer;width:100%;color:var(--notectl-fg);text-align:start;white-space:nowrap;background:0 0;border:none;outline: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-size-picker__item:hover{background:var(--notectl-hover-bg)}}.notectl-font-size-picker__item--active{background:var(--notectl-active-bg);color:var(--notectl-accent-fg)}@media (hover:hover){.notectl-font-size-picker__item--active:hover{background:var(--notectl-active-bg)}}.notectl-font-size-picker__item--focused{outline:2px solid var(--notectl-primary);outline-offset:-2px}.notectl-font-size-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-size-picker__label{flex:1}"),this.registerMarkSpec(t),this.registerStyleClasses(t),this.registerCommands(t),this.registerKeymaps(t),this.registerToolbarItem(t),this.applyDefaultSizeToContainer(t)}destroy(){}registerMarkSpec(t){t.registerMarkSpec(S(J))}registerStyleClasses(t){v(t,"FontSizePlugin",this.config.styleClasses,t=>b(J.cssProperty,P(function(t){if(!Q.test(t))throw new TypeError(`"${t}" is not a font size; use whole pixel numbers such as 18.`);return Number(t)}(t))))}registerCommands(t){t.registerCommand("removeFontSize",()=>B(t,t.getState())),t.registerCommand("setFontSize",()=>!1),t.registerCommand("increaseFontSize",()=>$(t,t.getState(),"up",this.sizes,this.defaultSize)),t.registerCommand("decreaseFontSize",()=>$(t,t.getState(),"down",this.sizes,this.defaultSize))}registerKeymaps(t){t.registerKeymap({"Mod-Shift-+":()=>$(t,t.getState(),"up",this.sizes,this.defaultSize),"Mod-Shift-_":()=>$(t,t.getState(),"down",this.sizes,this.defaultSize)})}registerToolbarItem(t){t.registerToolbarItem({id:"fontSize",group:"format",label:this.locale.label,tooltip:this.locale.tooltip,command:"removeFontSize",popupType:"combobox",getLabel:t=>String(D(t,this.defaultSize)),renderPopup:(t,e,n)=>{!function(t,e,n){t.classList.add("notectl-font-size-picker");const o=D(e.getState(),n.defaultSize),i=function(t,e){const n=document.createElement("input");return n.type="number",n.className="notectl-font-size-picker__input",n.min=String(1),n.max=String(400),n.value=String(t),n.setAttribute("aria-label",e.locale.customFontSizeAria),n}(o,n);!function(t,e){const n=document.createElement("div");n.className="notectl-font-size-picker__input-wrapper",n.appendChild(e),t.appendChild(n)}(t,i);const{list:r,items:s}=function(t,e,n,o){const i=document.createElement("div");i.className="notectl-font-size-picker__list",i.setAttribute("role","listbox"),i.setAttribute("aria-label",o.locale.fontSizesAria);const r=[];for(const s of t){const t=K(s,s===e);t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),t.addEventListener("click",()=>{V(n,s,o.defaultSize),o.onClose({restoreFocusTo:o.contentElement})}),r.push(t),i.appendChild(t)}return{list:i,items:r}}(n.sizes,o,e,n);t.appendChild(r),function(t,e,n,o){const i=e.indexOf(n);if(i<0)return;const r=t[i];r&&(requestAnimationFrame(()=>{r.scrollIntoView({block:"nearest"})}),o.setAttribute("aria-activedescendant",r.id))}(s,n.sizes,o,r),function(t,e,n,o,i){let r=-1;const s=t=>{r>=0&&r<n.length&&n[r]?.classList.remove("notectl-font-size-picker__item--focused"),r=t;const o=n[r];r>=0&&r<n.length&&o&&(o.classList.add("notectl-font-size-picker__item--focused"),o.scrollIntoView({block:"nearest"}),e.setAttribute("aria-activedescendant",o.id))},c=t=>{t.preventDefault(),t.stopPropagation()};t.addEventListener("keydown",e=>{if("Enter"===e.key){c(e);const n=Number.parseInt(t.value,10);!Number.isNaN(n)&&n>=1&&n<=400&&(V(o,n,i.defaultSize),i.onClose({restoreFocusTo:i.contentElement}))}else"ArrowDown"===e.key?(c(e),s(0),n[0]?.focus()):"Escape"===e.key&&(c(e),i.onClose({restoreFocusTo:i.contentElement}))}),e.addEventListener("keydown",e=>{"ArrowDown"===e.key?(c(e),r<n.length-1&&(s(r+1),n[r]?.focus())):"ArrowUp"===e.key?(c(e),r>0?(s(r-1),n[r]?.focus()):(s(-1),t.focus())):"Enter"===e.key?(c(e),n[r]?.click()):"Escape"===e.key&&(c(e),i.onClose({restoreFocusTo:i.contentElement}))})}(i,r,s,e,n)}(t,e,{sizes:this.sizes,defaultSize:this.defaultSize,onClose:n,contentElement:e.getContainer(),locale:this.locale})},isActive:t=>function(t){const e=I(t);if(e)return null!==A(e);const n=L(t);return!(!n||![...n].some(t=>t.length>0))||d(t,"fontSize")}(t)})}applyDefaultSizeToContainer(t){const e=t.getContainer();z(e,"fontSize",`${this.defaultSize}px`)}};export{x as n,_ as r,R as t};
|
|
2
|
+
//# sourceMappingURL=FontSizePlugin-kv3zHG0f.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FontSizePlugin-Dswra3oU.mjs","names":["FONT_SIZE_SELECT_CSS","walkInlineContent","getInlineChildren","isTextNode","getBlockLength","isInlineNode","isCollapsed","isNodeSelection","isTextSelection","selectionRange","markType","removeAttributedMark","getMarkAttrAtSelection","isAttributedMarkActive","applyAttributedMark","loadLocaleModule","dispatchIfPresent","resolveLocale","setStyleProperty","isValidCSSFontSize","styleDeclaration","createInlineStyleMarkSpec","registerStyleClassNames","FONT_SIZE_LOCALE_EN","label","tooltip","customFontSizeAria","fontSizesAria","localeModules","Object","assign","async","loadFontSizeLocale","lang","specDeclaresFontSize","spec","attrs","fontSize","nodeFontSizeTarget","state","sel","selection","block","getBlock","nodeId","schema","getNodeSpec","type","kind","path","getNodePath","inline","anchor","blockId","head","from","Math","min","offset","max","child","childFrom","node","singleSelectedInlineNode","getInlineNodeSpec","inlineType","readFontSize","length","mergeFontSize","size","nodeFontSizeValue","target","dispatchNodeFontSize","context","builder","transaction","setNodeAttr","setInlineNodeAttr","dispatch","build","FONT_SIZE_TYPE","rangeCarriers","blockOrder","getBlockOrder","range","fromIdx","indexOf","toIdx","to","carriers","i","push","collectInlineCarriers","textMark","pos","hasText","end","text","marks","find","m","mark","dispatchRangeFontSize","changed","carrier","removeMark","addMark","current","setSelection","rangeNodeSizes","nodeAttrs","filter","map","Set","pixelFontSize","getActiveSizeNumeric","defaultSize","raw","sizes","only","getActiveSize","parsed","Number","parseInt","isNaN","applyFontSize","removeFontSize","stepFontSize","direction","next","getNextPresetSize","selectSize","executeCommand","getState","buildSizeItem","isActive","item","document","createElement","id","className","setAttribute","String","classList","add","check","textContent","appendChild","DEFAULT_FONT_SIZES","FONT_SIZE_MARK","rank","valueAttr","domStyleProperty","cssProperty","validate","PIXEL_SIZE_KEY","FontSizePlugin","name","priority","config","locale","constructor","this","unique","n","isInteger","sort","a","b","resolveSizes","init","registerStyleSheet","registerMarkSpec","registerStyleClasses","registerCommands","registerKeymaps","registerToolbarItem","applyDefaultSizeToContainer","destroy","styleClasses","key","test","TypeError","pixelSizeKey","registerCommand","registerKeymap","group","command","popupType","getLabel","renderPopup","container","ctx","onClose","currentSize","input","value","buildCustomInput","wrapper","appendInputWrapper","list","items","addEventListener","e","preventDefault","stopPropagation","restoreFocusTo","contentElement","buildSizeList","activeIdx","activeItem","requestAnimationFrame","scrollIntoView","scrollActiveIntoView","focusedIndex","setFocused","idx","remove","el","consume","val","focus","click","attachKeyboardNavigation","renderFontSizePopup","getContainer","some","isFontSizeActive"],"sources":["../../src/editor/styles/font-size-select.css?inline","../../src/plugins/font-size/FontSizeLocale.ts","../../src/plugins/font-size/FontSizeOperations.ts","../../src/plugins/font-size/FontSizePopup.ts","../../src/plugins/font-size/FontSizePlugin.ts"],"sourcesContent":["/** Font size picker toolbar combobox + popup styles. */\n/* Font Size Select — Width overrides for combobox button */\n.notectl-toolbar-btn--fontSize {\n\tmin-width: 60px;\n\tmax-width: 80px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n\tmin-width: 140px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n\tpadding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tfont-family: inherit;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n\toutline: none;\n\tbox-sizing: border-box;\n\t-moz-appearance: textfield;\n}\n\n.notectl-font-size-picker__input::-webkit-inner-spin-button,\n.notectl-font-size-picker__input::-webkit-outer-spin-button {\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n\tmax-height: 280px;\n\toverflow-y: auto;\n\tpadding: 4px 0;\n}\n\n.notectl-font-size-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--focused {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-font-size-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n","/** Locale interface and default English locale for the FontSizePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface FontSizeLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly customFontSizeAria: string;\n\treadonly fontSizesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_SIZE_LOCALE_EN: FontSizeLocale = {\n\tlabel: 'Font Size',\n\ttooltip: 'Font Size',\n\tcustomFontSizeAria: 'Custom font size',\n\tfontSizesAria: 'Font sizes',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<FontSizeLocale> = import.meta.glob<{\n\tdefault: FontSizeLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadFontSizeLocale(lang: string): Promise<FontSizeLocale> {\n\treturn loadLocaleModule(localeModules, lang, FONT_SIZE_LOCALE_EN);\n}\n","/**\n * Pure business logic for font-size state queries and transaction builders.\n * All functions are DOM-free and operate on EditorState / PluginContext.\n *\n * Delegates to the generic AttributedMarkCommands helpers for the\n * collapsed-vs-range branching logic.\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport type { BlockAttrs, BlockNode, InlineNode, Mark } from '../../model/Document.js';\nimport {\n\tgetBlockLength,\n\tgetInlineChildren,\n\tisInlineNode,\n\tisTextNode,\n\twalkInlineContent,\n} from '../../model/Document.js';\nimport {\n\tisCollapsed,\n\tisNodeSelection,\n\tisTextSelection,\n\tselectionRange,\n} from '../../model/Selection.js';\nimport { type BlockId, type MarkTypeName, markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent } from '../shared/PluginHelpers.js';\n\n// --- Node-level font sizing ---\n//\n// Marks only apply to text, so they cannot size atomic nodes such as a formula\n// (an inline node carries no marks; a display formula is a void block). Instead,\n// a node opts into font sizing by declaring a `fontSize` attribute in its schema\n// spec; the font-size controls then read/write that attribute. This stays generic\n// (no formula-specific coupling) — any node or inline node can opt in the same way.\n\ntype InlineNodeAttrs = Readonly<Record<string, string | number | boolean>>;\n\ntype NodeFontSizeTarget =\n\t| { readonly kind: 'block'; readonly path: readonly BlockId[]; readonly attrs: BlockAttrs }\n\t| {\n\t\t\treadonly kind: 'inline';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly attrs: InlineNodeAttrs;\n\t };\n\nfunction specDeclaresFontSize(\n\tspec: { readonly attrs?: Readonly<Record<string, unknown>> } | undefined,\n): boolean {\n\treturn spec?.attrs?.fontSize !== undefined;\n}\n\n/**\n * Resolves the node the current selection targets for font sizing, when that\n * node's schema spec declares a `fontSize` attribute: a void/selectable block\n * under a NodeSelection, or a single atomic inline node under a width-1 text\n * selection. Returns null for ordinary text (which uses the fontSize mark).\n */\nfunction nodeFontSizeTarget(state: EditorState): NodeFontSizeTarget | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) {\n\t\tconst block = state.getBlock(sel.nodeId);\n\t\tif (!block || !specDeclaresFontSize(state.schema.getNodeSpec?.(block.type))) return null;\n\t\tconst path: readonly BlockId[] = state.getNodePath(sel.nodeId) ?? [sel.nodeId];\n\t\treturn { kind: 'block', path, attrs: block.attrs ?? {} };\n\t}\n\tconst inline = singleSelectedInlineNode(state);\n\tif (inline && specDeclaresFontSize(state.schema.getInlineNodeSpec?.(inline.node.inlineType))) {\n\t\treturn {\n\t\t\tkind: 'inline',\n\t\t\tblockId: inline.blockId,\n\t\t\toffset: inline.offset,\n\t\t\tattrs: inline.node.attrs,\n\t\t};\n\t}\n\treturn null;\n}\n\n/** Returns the single inline node a width-1 text selection covers, if any. */\nfunction singleSelectedInlineNode(\n\tstate: EditorState,\n): { readonly node: InlineNode; readonly blockId: BlockId; readonly offset: number } | null {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel) || isCollapsed(sel)) return null;\n\tif (sel.anchor.blockId !== sel.head.blockId) return null;\n\tconst from: number = Math.min(sel.anchor.offset, sel.head.offset);\n\tconst to: number = Math.max(sel.anchor.offset, sel.head.offset);\n\tif (to - from !== 1) return null;\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tfor (const { child, from: childFrom } of walkInlineContent(getInlineChildren(block))) {\n\t\tif (childFrom === from && isInlineNode(child)) {\n\t\t\treturn { node: child, blockId: sel.anchor.blockId, offset: from };\n\t\t}\n\t}\n\treturn null;\n}\n\n/** Reads a fontSize attr value from raw attrs, or null when unset. */\nfunction readFontSize(attrs: BlockAttrs | InlineNodeAttrs | undefined): string | null {\n\tconst fontSize = attrs?.fontSize;\n\treturn typeof fontSize === 'string' && fontSize.length > 0 ? fontSize : null;\n}\n\n/** Merges a fontSize value ('' clears it) into existing attrs, preserving the rest. */\nfunction mergeFontSize(\n\tattrs: InlineNodeAttrs | undefined,\n\tsize: string,\n): Record<string, string | number | boolean>;\nfunction mergeFontSize(attrs: BlockAttrs | undefined, size: string): BlockAttrs;\nfunction mergeFontSize(attrs: BlockAttrs | InlineNodeAttrs | undefined, size: string): BlockAttrs {\n\treturn { ...(attrs ?? {}), fontSize: size };\n}\n\n/** The node's current fontSize value, or null when unset. */\nfunction nodeFontSizeValue(target: NodeFontSizeTarget): string | null {\n\treturn readFontSize(target.attrs);\n}\n\n/** Writes `size` (or '' to clear) onto a single target node's fontSize attr. */\nfunction dispatchNodeFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\ttarget: NodeFontSizeTarget,\n\tsize: string,\n): boolean {\n\tconst builder = state.transaction('command');\n\tif (target.kind === 'block') {\n\t\tbuilder.setNodeAttr(target.path, mergeFontSize(target.attrs, size));\n\t} else {\n\t\tbuilder.setInlineNodeAttr(target.blockId, target.offset, mergeFontSize(target.attrs, size));\n\t}\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n// --- Range carriers (text marks + font-size-aware nodes) ---\n//\n// A font-size operation over a selection range touches every \"carrier\" it spans:\n// text runs (which take the fontSize mark) and atomic font-size-aware nodes such\n// as formulas (which take the fontSize attr). This is what lets a select-all that\n// includes a formula resize the formula alongside the surrounding text.\n\nconst FONT_SIZE_TYPE: MarkTypeName = markType('fontSize');\n\ntype FontSizeCarrier =\n\t| {\n\t\t\treadonly kind: 'text';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly from: number;\n\t\t\treadonly to: number;\n\t\t\treadonly mark: Mark | undefined;\n\t }\n\t| { readonly kind: 'blockNode'; readonly path: readonly BlockId[]; readonly attrs: BlockAttrs }\n\t| {\n\t\t\treadonly kind: 'inlineNode';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly attrs: InlineNodeAttrs;\n\t };\n\n/** Enumerates the font-size carriers within the current (non-collapsed) text range. */\nfunction rangeCarriers(state: EditorState): FontSizeCarrier[] {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return [];\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst range = selectionRange(sel, blockOrder);\n\tconst fromIdx: number = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx: number = blockOrder.indexOf(range.to.blockId);\n\tconst carriers: FontSizeCarrier[] = [];\n\n\tfor (let i = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\t\tconst from: number = i === fromIdx ? range.from.offset : 0;\n\t\tconst to: number = i === toIdx ? range.to.offset : getBlockLength(block);\n\n\t\t// Atomic, font-size-aware block (e.g. a display formula): size the whole node.\n\t\tif (specDeclaresFontSize(state.schema.getNodeSpec?.(block.type))) {\n\t\t\tcarriers.push({\n\t\t\t\tkind: 'blockNode',\n\t\t\t\tpath: state.getNodePath(blockId) ?? [blockId],\n\t\t\t\tattrs: block.attrs ?? {},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (from === to) continue;\n\t\tcollectInlineCarriers(state, block, blockId, from, to, carriers);\n\t}\n\treturn carriers;\n}\n\n/** Adds a text carrier (when the slice holds text) plus any font-size-aware inline nodes. */\nfunction collectInlineCarriers(\n\tstate: EditorState,\n\tblock: BlockNode,\n\tblockId: BlockId,\n\tfrom: number,\n\tto: number,\n\tcarriers: FontSizeCarrier[],\n): void {\n\tlet pos = 0;\n\tlet hasText = false;\n\tlet textMark: Mark | undefined;\n\tfor (const child of getInlineChildren(block)) {\n\t\tif (isTextNode(child)) {\n\t\t\tconst end: number = pos + child.text.length;\n\t\t\tif (child.text.length > 0 && end > from && pos < to) {\n\t\t\t\thasText = true;\n\t\t\t\tif (!textMark) textMark = child.marks.find((m) => m.type === FONT_SIZE_TYPE);\n\t\t\t}\n\t\t\tpos = end;\n\t\t} else {\n\t\t\tif (\n\t\t\t\tpos >= from &&\n\t\t\t\tpos < to &&\n\t\t\t\tspecDeclaresFontSize(state.schema.getInlineNodeSpec?.(child.inlineType))\n\t\t\t) {\n\t\t\t\tcarriers.push({ kind: 'inlineNode', blockId, offset: pos, attrs: child.attrs });\n\t\t\t}\n\t\t\tpos += 1;\n\t\t}\n\t}\n\tif (hasText) carriers.push({ kind: 'text', blockId, from, to, mark: textMark });\n}\n\n/** Sizes every carrier in the range ('' clears). Returns false when nothing changed. */\nfunction dispatchRangeFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst carriers: FontSizeCarrier[] = rangeCarriers(state);\n\tif (carriers.length === 0) return false;\n\tconst builder = state.transaction('command');\n\tlet changed = false;\n\n\tfor (const carrier of carriers) {\n\t\tif (carrier.kind === 'text') {\n\t\t\tif (size === '') {\n\t\t\t\tif (carrier.mark) {\n\t\t\t\t\tbuilder.removeMark(carrier.blockId, carrier.from, carrier.to, carrier.mark);\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (carrier.mark)\n\t\t\t\t\tbuilder.removeMark(carrier.blockId, carrier.from, carrier.to, carrier.mark);\n\t\t\t\tbuilder.addMark(carrier.blockId, carrier.from, carrier.to, {\n\t\t\t\t\ttype: FONT_SIZE_TYPE,\n\t\t\t\t\tattrs: { size },\n\t\t\t\t});\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst current: string | null = readFontSize(carrier.attrs);\n\t\tif (size === current || (size === '' && current === null)) continue;\n\t\tif (carrier.kind === 'blockNode') {\n\t\t\tbuilder.setNodeAttr(carrier.path, mergeFontSize(carrier.attrs, size));\n\t\t} else {\n\t\t\tbuilder.setInlineNodeAttr(\n\t\t\t\tcarrier.blockId,\n\t\t\t\tcarrier.offset,\n\t\t\t\tmergeFontSize(carrier.attrs, size),\n\t\t\t);\n\t\t}\n\t\tchanged = true;\n\t}\n\n\tif (!changed) return false;\n\tbuilder.setSelection(state.selection);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** The set of fontSize values carried by font-size-aware nodes in the range, or null when none. */\nfunction rangeNodeSizes(state: EditorState): Set<string> | null {\n\tconst nodeAttrs: (BlockAttrs | InlineNodeAttrs)[] = rangeCarriers(state)\n\t\t.filter((carrier) => carrier.kind !== 'text')\n\t\t.map((carrier) => carrier.attrs);\n\tif (nodeAttrs.length === 0) return null;\n\treturn new Set(nodeAttrs.map((attrs) => readFontSize(attrs) ?? ''));\n}\n\n// --- State Queries ---\n\n/** The `fontSize` mark value of a pixel size, e.g. `18px`. */\nexport function pixelFontSize(size: number): string {\n\treturn `${size}px`;\n}\n\n/** Returns the raw fontSize CSS value at the current selection, or null. */\nexport function getActiveSize(state: EditorState): string | null {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return nodeFontSizeValue(target);\n\t// Additive: when a range spans font-size-aware nodes (e.g. a formula) that all\n\t// share one explicit size, report it; otherwise read the text mark as before.\n\tconst sizes = rangeNodeSizes(state);\n\tif (sizes && sizes.size === 1) {\n\t\tconst [only] = sizes;\n\t\tif (only) return only;\n\t}\n\treturn getMarkAttrAtSelection(state, 'fontSize', (m) => m.attrs.size ?? null);\n}\n\n/** Returns the active font size as a number, falling back to defaultSize. */\nexport function getActiveSizeNumeric(state: EditorState, defaultSize: number): number {\n\tconst raw: string | null = getActiveSize(state);\n\tif (!raw) return defaultSize;\n\tconst parsed: number = Number.parseInt(raw, 10);\n\treturn Number.isNaN(parsed) ? defaultSize : parsed;\n}\n\n/** Returns true when the selection carries a fontSize (mark or node attribute). */\nexport function isFontSizeActive(state: EditorState): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return nodeFontSizeValue(target) !== null;\n\tconst sizes = rangeNodeSizes(state);\n\tif (sizes && [...sizes].some((size) => size.length > 0)) return true;\n\treturn isAttributedMarkActive(state, 'fontSize');\n}\n\n// --- Commands ---\n\n/**\n * Applies the given CSS size to the selection: as a node `fontSize` attribute\n * when a font-size-aware node is selected (e.g. a formula), otherwise as a\n * fontSize mark on the selected text.\n */\nexport function applyFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return dispatchNodeFontSize(context, state, target, size);\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tif (isCollapsed(sel)) {\n\t\tconst mark = { type: markType('fontSize'), attrs: { size } };\n\t\treturn dispatchIfPresent(context, applyAttributedMark(state, mark));\n\t}\n\treturn dispatchRangeFontSize(context, state, size);\n}\n\n/** Removes the fontSize (node attribute or mark) from the current selection. */\nexport function removeFontSize(context: PluginContext, state: EditorState): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) {\n\t\tif (nodeFontSizeValue(target) === null) return false;\n\t\treturn dispatchNodeFontSize(context, state, target, '');\n\t}\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tif (isCollapsed(sel)) {\n\t\treturn dispatchIfPresent(context, removeAttributedMark(state, markType('fontSize')));\n\t}\n\treturn dispatchRangeFontSize(context, state, '');\n}\n\n/** Steps the font size up or down through the preset list. */\nexport function stepFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n\tdefaultSize: number,\n): boolean {\n\tconst current: number = getActiveSizeNumeric(state, defaultSize);\n\tconst next: number | null = getNextPresetSize(current, direction, sizes);\n\tif (next === null) return false;\n\n\tif (next === defaultSize) {\n\t\treturn removeFontSize(context, state);\n\t}\n\treturn applyFontSize(context, state, pixelFontSize(next));\n}\n\n/**\n * Selects a specific font size: removes the mark when size equals the\n * default, otherwise applies the new size.\n */\nexport function selectSize(context: PluginContext, size: number, defaultSize: number): void {\n\tif (size === defaultSize) {\n\t\tcontext.executeCommand('removeFontSize');\n\t} else {\n\t\tapplyFontSize(context, context.getState(), pixelFontSize(size));\n\t}\n}\n\n// --- Helpers ---\n\n/** Finds the next preset size in the given direction, or null at boundaries. */\nexport function getNextPresetSize(\n\tcurrent: number,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n): number | null {\n\tif (direction === 'up') {\n\t\tfor (const size of sizes) {\n\t\t\tif (size > current) return size;\n\t\t}\n\t\treturn null;\n\t}\n\tfor (let i: number = sizes.length - 1; i >= 0; i--) {\n\t\tconst size: number | undefined = sizes[i];\n\t\tif (size !== undefined && size < current) return size;\n\t}\n\treturn null;\n}\n","/**\n * Renders the font-size picker popup with a custom numeric input\n * and an accessible preset list with keyboard navigation.\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport type { FontSizeLocale } from './FontSizeLocale.js';\nimport { getActiveSizeNumeric, selectSize } from './FontSizeOperations.js';\n\n// --- Constants ---\n\nconst MIN_CUSTOM_SIZE = 1;\nconst MAX_CUSTOM_SIZE = 400;\n\n// --- Config ---\n\nexport interface FontSizePopupConfig {\n\treadonly sizes: readonly number[];\n\treadonly defaultSize: number;\n\treadonly onClose: (options?: PopupCloseOptions) => void;\n\treadonly contentElement: HTMLElement;\n\treadonly locale: FontSizeLocale;\n}\n\n// --- Public Entry Point ---\n\n/** Builds the font-size picker DOM inside the given container. */\nexport function renderFontSizePopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tcontainer.classList.add('notectl-font-size-picker');\n\n\tconst currentSize: number = getActiveSizeNumeric(context.getState(), config.defaultSize);\n\n\tconst input: HTMLInputElement = buildCustomInput(currentSize, config);\n\tappendInputWrapper(container, input);\n\n\tconst { list, items } = buildSizeList(config.sizes, currentSize, context, config);\n\tcontainer.appendChild(list);\n\n\tscrollActiveIntoView(items, config.sizes, currentSize, list);\n\tattachKeyboardNavigation(input, list, items, context, config);\n}\n\n// --- Custom Input ---\n\nfunction buildCustomInput(currentSize: number, config: FontSizePopupConfig): HTMLInputElement {\n\tconst input: HTMLInputElement = document.createElement('input');\n\tinput.type = 'number';\n\tinput.className = 'notectl-font-size-picker__input';\n\tinput.min = String(MIN_CUSTOM_SIZE);\n\tinput.max = String(MAX_CUSTOM_SIZE);\n\tinput.value = String(currentSize);\n\tinput.setAttribute('aria-label', config.locale.customFontSizeAria);\n\treturn input;\n}\n\nfunction appendInputWrapper(container: HTMLElement, input: HTMLInputElement): void {\n\tconst wrapper: HTMLDivElement = document.createElement('div');\n\twrapper.className = 'notectl-font-size-picker__input-wrapper';\n\twrapper.appendChild(input);\n\tcontainer.appendChild(wrapper);\n}\n\n// --- Size List ---\n\ninterface SizeListResult {\n\treadonly list: HTMLDivElement;\n\treadonly items: HTMLButtonElement[];\n}\n\nfunction buildSizeList(\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): SizeListResult {\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-font-size-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', config.locale.fontSizesAria);\n\n\tconst items: HTMLButtonElement[] = [];\n\n\tfor (const size of sizes) {\n\t\tconst isActive: boolean = size === currentSize;\n\t\tconst item: HTMLButtonElement = buildSizeItem(size, isActive);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t});\n\t\titem.addEventListener('click', () => {\n\t\t\tselectSize(context, size, config.defaultSize);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t});\n\n\t\titems.push(item);\n\t\tlist.appendChild(item);\n\t}\n\n\treturn { list, items };\n}\n\nfunction buildSizeItem(size: number, isActive: boolean): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.id = `notectl-font-size-option-${size}`;\n\titem.className = 'notectl-font-size-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-font-size-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-font-size-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst label: HTMLSpanElement = document.createElement('span');\n\tlabel.className = 'notectl-font-size-picker__label';\n\tlabel.textContent = String(size);\n\titem.appendChild(label);\n\n\treturn item;\n}\n\n// --- Scroll ---\n\nfunction scrollActiveIntoView(\n\titems: HTMLButtonElement[],\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tlist: HTMLDivElement,\n): void {\n\tconst activeIdx: number = sizes.indexOf(currentSize);\n\tif (activeIdx < 0) return;\n\n\tconst activeItem: HTMLButtonElement | undefined = items[activeIdx];\n\tif (!activeItem) return;\n\n\trequestAnimationFrame(() => {\n\t\tactiveItem.scrollIntoView({ block: 'nearest' });\n\t});\n\tlist.setAttribute('aria-activedescendant', activeItem.id);\n}\n\n// --- Keyboard Navigation ---\n\nfunction attachKeyboardNavigation(\n\tinput: HTMLInputElement,\n\tlist: HTMLDivElement,\n\titems: HTMLButtonElement[],\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tlet focusedIndex = -1;\n\n\tconst setFocused = (idx: number): void => {\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length) {\n\t\t\titems[focusedIndex]?.classList.remove('notectl-font-size-picker__item--focused');\n\t\t}\n\t\tfocusedIndex = idx;\n\t\tconst el: HTMLButtonElement | undefined = items[focusedIndex];\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length && el) {\n\t\t\tel.classList.add('notectl-font-size-picker__item--focused');\n\t\t\tel.scrollIntoView({ block: 'nearest' });\n\t\t\tlist.setAttribute('aria-activedescendant', el.id);\n\t\t}\n\t};\n\n\t// As an editable combobox (input + listbox), this popup owns its keyboard\n\t// model. `consume` claims a handled key so the toolbar's generic popup\n\t// handler does not also act on it and advance focus a second time (#144).\n\tconst consume = (e: KeyboardEvent): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t};\n\n\tinput.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\tconsume(e);\n\t\t\tconst val: number = Number.parseInt(input.value, 10);\n\t\t\tif (!Number.isNaN(val) && val >= MIN_CUSTOM_SIZE && val <= MAX_CUSTOM_SIZE) {\n\t\t\t\tselectSize(context, val, config.defaultSize);\n\t\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t\t}\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\tconsume(e);\n\t\t\tsetFocused(0);\n\t\t\titems[0]?.focus();\n\t\t} else if (e.key === 'Escape') {\n\t\t\tconsume(e);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n\n\tlist.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'ArrowDown') {\n\t\t\tconsume(e);\n\t\t\tif (focusedIndex < items.length - 1) {\n\t\t\t\tsetFocused(focusedIndex + 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowUp') {\n\t\t\tconsume(e);\n\t\t\tif (focusedIndex > 0) {\n\t\t\t\tsetFocused(focusedIndex - 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t} else {\n\t\t\t\tsetFocused(-1);\n\t\t\t\tinput.focus();\n\t\t\t}\n\t\t} else if (e.key === 'Enter') {\n\t\t\tconsume(e);\n\t\t\titems[focusedIndex]?.click();\n\t\t} else if (e.key === 'Escape') {\n\t\t\tconsume(e);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n}\n","/**\n * FontSizePlugin: registers a fontSize mark with attrs, a combobox-style\n * toolbar selector with WCAG-accessible popup, and commands for\n * increasing / decreasing font size.\n */\n\nimport FONT_SIZE_SELECT_CSS from '../../editor/styles/font-size-select.css?inline';\nimport type { StyleClassNames } from '../../model/StyleClass.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isValidCSSFontSize } from '../shared/ColorValidation.js';\nimport {\n\ttype InlineStyleMarkConfig,\n\tcreateInlineStyleMarkSpec,\n\tstyleDeclaration,\n} from '../shared/InlineStyleMarkSpec.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { registerStyleClassNames } from '../shared/StyleClassNames.js';\nimport { FONT_SIZE_LOCALE_EN, type FontSizeLocale, loadFontSizeLocale } from './FontSizeLocale.js';\nimport {\n\tgetActiveSizeNumeric,\n\tisFontSizeActive,\n\tpixelFontSize,\n\tremoveFontSize,\n\tstepFontSize,\n} from './FontSizeOperations.js';\nimport { renderFontSizePopup } from './FontSizePopup.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfontSize: { size: string };\n\t}\n}\n\n// --- Constants ---\n\n/** Default preset sizes shown in the font size dropdown. */\nexport const DEFAULT_FONT_SIZES: readonly number[] = [\n\t8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96,\n];\n\nconst DEFAULT_FONT_SIZE = 16;\n\n// --- Configuration ---\n\nexport interface FontSizeConfig {\n\t/**\n\t * Preset sizes shown in the font size dropdown.\n\t * Must contain positive integers. Values are sorted and deduplicated automatically.\n\t * Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The base font size that text has when no fontSize mark is applied.\n\t * Shown as the initial value in the toolbar combo and used as the\n\t * \"neutral\" size — selecting it removes the mark instead of applying one.\n\t * Defaults to 16.\n\t */\n\treadonly defaultSize?: number;\n\t/**\n\t * Your own CSS class per font size in HTML content, keyed by pixel size, e.g.\n\t * `{ 14: 'text-sm', 18: 'text-lg' }`. Class-based export (`getContentHTML({ cssMode: 'classes' })`)\n\t * writes these classes instead of generated `notectl-s-*` names, and HTML import\n\t * and paste recognize them, so content round-trips with your stylesheet. Sizes\n\t * outside `sizes` may have a class too. Invalid keys or class names make editor\n\t * initialization fail with a `TypeError` that explains the fix.\n\t */\n\treadonly styleClasses?: StyleClassNames<number>;\n\treadonly locale?: FontSizeLocale;\n}\n\n/** The font size mark: one `font-size` declaration per text run. */\nconst FONT_SIZE_MARK: InlineStyleMarkConfig = {\n\ttype: 'fontSize',\n\trank: 4,\n\tvalueAttr: 'size',\n\tdomStyleProperty: 'fontSize',\n\tcssProperty: 'font-size',\n\tvalidate: isValidCSSFontSize,\n};\n\n/** A whole number of pixels without unit, as `styleClasses` keys are written. */\nconst PIXEL_SIZE_KEY: RegExp = /^[1-9]\\d*$/;\n\n// --- Plugin ---\n\nexport class FontSizePlugin implements Plugin {\n\treadonly id = 'fontSize';\n\treadonly name = 'Font Size';\n\treadonly priority = 21;\n\n\tprivate readonly config: FontSizeConfig;\n\tprivate readonly sizes: readonly number[];\n\tprivate readonly defaultSize: number;\n\tprivate locale!: FontSizeLocale;\n\n\tconstructor(config?: Partial<FontSizeConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.sizes = resolveSizes(config?.sizes);\n\t\tthis.defaultSize = resolveDefaultSize(config?.defaultSize);\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tFONT_SIZE_LOCALE_EN,\n\t\t\tloadFontSizeLocale,\n\t\t);\n\n\t\tcontext.registerStyleSheet(FONT_SIZE_SELECT_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerStyleClasses(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.applyDefaultSizeToContainer(context);\n\t}\n\n\tdestroy(): void {\n\t\t// no-op: nothing to clean up\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec(createInlineStyleMarkSpec(FONT_SIZE_MARK));\n\t}\n\n\tprivate registerStyleClasses(context: PluginContext): void {\n\t\tregisterStyleClassNames(context, 'FontSizePlugin', this.config.styleClasses, (key: string) =>\n\t\t\tstyleDeclaration(FONT_SIZE_MARK.cssProperty, pixelFontSize(pixelSizeKey(key))),\n\t\t);\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFontSize', () => {\n\t\t\treturn removeFontSize(context, context.getState());\n\t\t});\n\n\t\tcontext.registerCommand('setFontSize', () => {\n\t\t\treturn false;\n\t\t});\n\n\t\tcontext.registerCommand('increaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t});\n\n\t\tcontext.registerCommand('decreaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t});\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-+': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t\t'Mod-Shift-_': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'fontSize',\n\t\t\tgroup: 'format',\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFontSize',\n\t\t\tpopupType: 'combobox',\n\t\t\tgetLabel: (state: EditorState): string =>\n\t\t\t\tString(getActiveSizeNumeric(state, this.defaultSize)),\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderFontSizePopup(container, ctx, {\n\t\t\t\t\tsizes: this.sizes,\n\t\t\t\t\tdefaultSize: this.defaultSize,\n\t\t\t\t\tonClose,\n\t\t\t\t\tcontentElement: ctx.getContainer(),\n\t\t\t\t\tlocale: this.locale,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state) => isFontSizeActive(state),\n\t\t});\n\t}\n\n\t/**\n\t * Sets the configured default font size on the editor content container\n\t * so that unformatted text renders at the correct size instead of the\n\t * browser default (16px).\n\t */\n\tprivate applyDefaultSizeToContainer(context: PluginContext): void {\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tsetStyleProperty(container, 'fontSize', `${this.defaultSize}px`);\n\t}\n}\n\n// --- Helpers ---\n\nfunction resolveSizes(sizes: readonly number[] | undefined): readonly number[] {\n\tif (!sizes || sizes.length === 0) return DEFAULT_FONT_SIZES;\n\tconst unique: number[] = [...new Set(sizes)].filter((n) => Number.isInteger(n) && n > 0);\n\tunique.sort((a, b) => a - b);\n\treturn unique.length > 0 ? unique : DEFAULT_FONT_SIZES;\n}\n\nfunction resolveDefaultSize(size: number | undefined): number {\n\tif (size === undefined) return DEFAULT_FONT_SIZE;\n\treturn Number.isInteger(size) && size > 0 ? size : DEFAULT_FONT_SIZE;\n}\n\n/** Reads a `styleClasses` key as a pixel size. Throws a `TypeError` for anything else. */\nfunction pixelSizeKey(key: string): number {\n\tif (!PIXEL_SIZE_KEY.test(key)) {\n\t\tthrow new TypeError(`\"${key}\" is not a font size; use whole pixel numbers such as 18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,eACpBjE,OAAQE,KAAKF,UAGfzB,SAAWhG,GF+Hd,SAAiCA,GAChC,MAAMgC,EAASjC,EAAmBC,GAClC,GAAIgC,EAAQ,OAAqC,OAA9BD,EAAkBC,GACrC,MAAM+C,EAAQT,EAAetE,GAC7B,SAAI+E,IAAS,IAAIA,GAAO4G,KAAM7J,GAASA,EAAKF,OAAS,KAC9CtD,EAAuB0B,EAAO,WACtC,CErIwB4L,CAAiB5L,IAExC,CAOA,2BAAA0I,CAAoCxG,GACnC,MAAMsH,EAAyBtH,EAAQwJ,eACvC/M,EAAiB6K,EAAW,WAAY,GAAG7B,KAAK9C,gBACjD,U"}
|
|
1
|
+
{"version":3,"file":"FontSizePlugin-kv3zHG0f.mjs","names":["FONT_SIZE_SELECT_CSS","walkInlineContent","getInlineChildren","isTextNode","getBlockLength","isInlineNode","isCollapsed","isNodeSelection","isTextSelection","selectionRange","markType","removeAttributedMark","getMarkAttrAtSelection","isAttributedMarkActive","applyAttributedMark","dispatchIfPresent","resolveLocale","loadLocaleModule","setStyleProperty","isValidCSSFontSize","styleDeclaration","createInlineStyleMarkSpec","registerStyleClassNames","FONT_SIZE_LOCALE_EN","label","tooltip","customFontSizeAria","fontSizesAria","localeModules","Object","assign","async","loadFontSizeLocale","lang","specDeclaresFontSize","spec","attrs","fontSize","nodeFontSizeTarget","state","sel","selection","block","getBlock","nodeId","schema","getNodeSpec","type","kind","path","getNodePath","inline","anchor","blockId","head","from","Math","min","offset","max","child","childFrom","node","singleSelectedInlineNode","getInlineNodeSpec","inlineType","readFontSize","length","mergeFontSize","size","nodeFontSizeValue","target","dispatchNodeFontSize","context","builder","transaction","setNodeAttr","setInlineNodeAttr","dispatch","build","FONT_SIZE_TYPE","rangeCarriers","blockOrder","getBlockOrder","range","fromIdx","indexOf","toIdx","to","carriers","i","push","collectInlineCarriers","textMark","pos","hasText","end","text","marks","find","m","mark","dispatchRangeFontSize","changed","carrier","removeMark","addMark","current","setSelection","rangeNodeSizes","nodeAttrs","filter","map","Set","pixelFontSize","getActiveSizeNumeric","defaultSize","raw","sizes","only","getActiveSize","parsed","Number","parseInt","isNaN","applyFontSize","removeFontSize","stepFontSize","direction","next","getNextPresetSize","selectSize","executeCommand","getState","buildSizeItem","isActive","item","document","createElement","id","className","setAttribute","String","classList","add","check","textContent","appendChild","DEFAULT_FONT_SIZES","FONT_SIZE_MARK","rank","valueAttr","domStyleProperty","cssProperty","validate","PIXEL_SIZE_KEY","FontSizePlugin","name","priority","config","locale","constructor","this","unique","n","isInteger","sort","a","b","resolveSizes","init","registerStyleSheet","registerMarkSpec","registerStyleClasses","registerCommands","registerKeymaps","registerToolbarItem","applyDefaultSizeToContainer","destroy","styleClasses","key","test","TypeError","pixelSizeKey","registerCommand","registerKeymap","group","command","popupType","getLabel","renderPopup","container","ctx","onClose","currentSize","input","value","buildCustomInput","wrapper","appendInputWrapper","list","items","addEventListener","e","preventDefault","stopPropagation","restoreFocusTo","contentElement","buildSizeList","activeIdx","activeItem","requestAnimationFrame","scrollIntoView","scrollActiveIntoView","focusedIndex","setFocused","idx","remove","el","consume","val","focus","click","attachKeyboardNavigation","renderFontSizePopup","getContainer","some","isFontSizeActive"],"sources":["../../src/editor/styles/font-size-select.css?inline","../../src/plugins/font-size/FontSizeLocale.ts","../../src/plugins/font-size/FontSizeOperations.ts","../../src/plugins/font-size/FontSizePopup.ts","../../src/plugins/font-size/FontSizePlugin.ts"],"sourcesContent":["/** Font size picker toolbar combobox + popup styles. */\n/* Font Size Select — Width overrides for combobox button */\n.notectl-toolbar-btn--fontSize {\n\tmin-width: 60px;\n\tmax-width: 80px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n\tmin-width: 140px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n\tpadding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tfont-family: inherit;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n\toutline: none;\n\tbox-sizing: border-box;\n\t-moz-appearance: textfield;\n}\n\n.notectl-font-size-picker__input::-webkit-inner-spin-button,\n.notectl-font-size-picker__input::-webkit-outer-spin-button {\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n\tmax-height: 280px;\n\toverflow-y: auto;\n\tpadding: 4px 0;\n}\n\n.notectl-font-size-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-accent-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--focused {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-font-size-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-accent-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n","/** Locale interface and default English locale for the FontSizePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface FontSizeLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly customFontSizeAria: string;\n\treadonly fontSizesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_SIZE_LOCALE_EN: FontSizeLocale = {\n\tlabel: 'Font Size',\n\ttooltip: 'Font Size',\n\tcustomFontSizeAria: 'Custom font size',\n\tfontSizesAria: 'Font sizes',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<FontSizeLocale> = import.meta.glob<{\n\tdefault: FontSizeLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadFontSizeLocale(lang: string): Promise<FontSizeLocale> {\n\treturn loadLocaleModule(localeModules, lang, FONT_SIZE_LOCALE_EN);\n}\n","/**\n * Pure business logic for font-size state queries and transaction builders.\n * All functions are DOM-free and operate on EditorState / PluginContext.\n *\n * Delegates to the generic AttributedMarkCommands helpers for the\n * collapsed-vs-range branching logic.\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport type { BlockAttrs, BlockNode, InlineNode, Mark } from '../../model/Document.js';\nimport {\n\tgetBlockLength,\n\tgetInlineChildren,\n\tisInlineNode,\n\tisTextNode,\n\twalkInlineContent,\n} from '../../model/Document.js';\nimport {\n\tisCollapsed,\n\tisNodeSelection,\n\tisTextSelection,\n\tselectionRange,\n} from '../../model/Selection.js';\nimport { type BlockId, type MarkTypeName, markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent } from '../shared/PluginHelpers.js';\n\n// --- Node-level font sizing ---\n//\n// Marks only apply to text, so they cannot size atomic nodes such as a formula\n// (an inline node carries no marks; a display formula is a void block). Instead,\n// a node opts into font sizing by declaring a `fontSize` attribute in its schema\n// spec; the font-size controls then read/write that attribute. This stays generic\n// (no formula-specific coupling) — any node or inline node can opt in the same way.\n\ntype InlineNodeAttrs = Readonly<Record<string, string | number | boolean>>;\n\ntype NodeFontSizeTarget =\n\t| { readonly kind: 'block'; readonly path: readonly BlockId[]; readonly attrs: BlockAttrs }\n\t| {\n\t\t\treadonly kind: 'inline';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly attrs: InlineNodeAttrs;\n\t };\n\nfunction specDeclaresFontSize(\n\tspec: { readonly attrs?: Readonly<Record<string, unknown>> } | undefined,\n): boolean {\n\treturn spec?.attrs?.fontSize !== undefined;\n}\n\n/**\n * Resolves the node the current selection targets for font sizing, when that\n * node's schema spec declares a `fontSize` attribute: a void/selectable block\n * under a NodeSelection, or a single atomic inline node under a width-1 text\n * selection. Returns null for ordinary text (which uses the fontSize mark).\n */\nfunction nodeFontSizeTarget(state: EditorState): NodeFontSizeTarget | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) {\n\t\tconst block = state.getBlock(sel.nodeId);\n\t\tif (!block || !specDeclaresFontSize(state.schema.getNodeSpec?.(block.type))) return null;\n\t\tconst path: readonly BlockId[] = state.getNodePath(sel.nodeId) ?? [sel.nodeId];\n\t\treturn { kind: 'block', path, attrs: block.attrs ?? {} };\n\t}\n\tconst inline = singleSelectedInlineNode(state);\n\tif (inline && specDeclaresFontSize(state.schema.getInlineNodeSpec?.(inline.node.inlineType))) {\n\t\treturn {\n\t\t\tkind: 'inline',\n\t\t\tblockId: inline.blockId,\n\t\t\toffset: inline.offset,\n\t\t\tattrs: inline.node.attrs,\n\t\t};\n\t}\n\treturn null;\n}\n\n/** Returns the single inline node a width-1 text selection covers, if any. */\nfunction singleSelectedInlineNode(\n\tstate: EditorState,\n): { readonly node: InlineNode; readonly blockId: BlockId; readonly offset: number } | null {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel) || isCollapsed(sel)) return null;\n\tif (sel.anchor.blockId !== sel.head.blockId) return null;\n\tconst from: number = Math.min(sel.anchor.offset, sel.head.offset);\n\tconst to: number = Math.max(sel.anchor.offset, sel.head.offset);\n\tif (to - from !== 1) return null;\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\tfor (const { child, from: childFrom } of walkInlineContent(getInlineChildren(block))) {\n\t\tif (childFrom === from && isInlineNode(child)) {\n\t\t\treturn { node: child, blockId: sel.anchor.blockId, offset: from };\n\t\t}\n\t}\n\treturn null;\n}\n\n/** Reads a fontSize attr value from raw attrs, or null when unset. */\nfunction readFontSize(attrs: BlockAttrs | InlineNodeAttrs | undefined): string | null {\n\tconst fontSize = attrs?.fontSize;\n\treturn typeof fontSize === 'string' && fontSize.length > 0 ? fontSize : null;\n}\n\n/** Merges a fontSize value ('' clears it) into existing attrs, preserving the rest. */\nfunction mergeFontSize(\n\tattrs: InlineNodeAttrs | undefined,\n\tsize: string,\n): Record<string, string | number | boolean>;\nfunction mergeFontSize(attrs: BlockAttrs | undefined, size: string): BlockAttrs;\nfunction mergeFontSize(attrs: BlockAttrs | InlineNodeAttrs | undefined, size: string): BlockAttrs {\n\treturn { ...(attrs ?? {}), fontSize: size };\n}\n\n/** The node's current fontSize value, or null when unset. */\nfunction nodeFontSizeValue(target: NodeFontSizeTarget): string | null {\n\treturn readFontSize(target.attrs);\n}\n\n/** Writes `size` (or '' to clear) onto a single target node's fontSize attr. */\nfunction dispatchNodeFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\ttarget: NodeFontSizeTarget,\n\tsize: string,\n): boolean {\n\tconst builder = state.transaction('command');\n\tif (target.kind === 'block') {\n\t\tbuilder.setNodeAttr(target.path, mergeFontSize(target.attrs, size));\n\t} else {\n\t\tbuilder.setInlineNodeAttr(target.blockId, target.offset, mergeFontSize(target.attrs, size));\n\t}\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n// --- Range carriers (text marks + font-size-aware nodes) ---\n//\n// A font-size operation over a selection range touches every \"carrier\" it spans:\n// text runs (which take the fontSize mark) and atomic font-size-aware nodes such\n// as formulas (which take the fontSize attr). This is what lets a select-all that\n// includes a formula resize the formula alongside the surrounding text.\n\nconst FONT_SIZE_TYPE: MarkTypeName = markType('fontSize');\n\ntype FontSizeCarrier =\n\t| {\n\t\t\treadonly kind: 'text';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly from: number;\n\t\t\treadonly to: number;\n\t\t\treadonly mark: Mark | undefined;\n\t }\n\t| { readonly kind: 'blockNode'; readonly path: readonly BlockId[]; readonly attrs: BlockAttrs }\n\t| {\n\t\t\treadonly kind: 'inlineNode';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly attrs: InlineNodeAttrs;\n\t };\n\n/** Enumerates the font-size carriers within the current (non-collapsed) text range. */\nfunction rangeCarriers(state: EditorState): FontSizeCarrier[] {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return [];\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst range = selectionRange(sel, blockOrder);\n\tconst fromIdx: number = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx: number = blockOrder.indexOf(range.to.blockId);\n\tconst carriers: FontSizeCarrier[] = [];\n\n\tfor (let i = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\t\tconst from: number = i === fromIdx ? range.from.offset : 0;\n\t\tconst to: number = i === toIdx ? range.to.offset : getBlockLength(block);\n\n\t\t// Atomic, font-size-aware block (e.g. a display formula): size the whole node.\n\t\tif (specDeclaresFontSize(state.schema.getNodeSpec?.(block.type))) {\n\t\t\tcarriers.push({\n\t\t\t\tkind: 'blockNode',\n\t\t\t\tpath: state.getNodePath(blockId) ?? [blockId],\n\t\t\t\tattrs: block.attrs ?? {},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (from === to) continue;\n\t\tcollectInlineCarriers(state, block, blockId, from, to, carriers);\n\t}\n\treturn carriers;\n}\n\n/** Adds a text carrier (when the slice holds text) plus any font-size-aware inline nodes. */\nfunction collectInlineCarriers(\n\tstate: EditorState,\n\tblock: BlockNode,\n\tblockId: BlockId,\n\tfrom: number,\n\tto: number,\n\tcarriers: FontSizeCarrier[],\n): void {\n\tlet pos = 0;\n\tlet hasText = false;\n\tlet textMark: Mark | undefined;\n\tfor (const child of getInlineChildren(block)) {\n\t\tif (isTextNode(child)) {\n\t\t\tconst end: number = pos + child.text.length;\n\t\t\tif (child.text.length > 0 && end > from && pos < to) {\n\t\t\t\thasText = true;\n\t\t\t\tif (!textMark) textMark = child.marks.find((m) => m.type === FONT_SIZE_TYPE);\n\t\t\t}\n\t\t\tpos = end;\n\t\t} else {\n\t\t\tif (\n\t\t\t\tpos >= from &&\n\t\t\t\tpos < to &&\n\t\t\t\tspecDeclaresFontSize(state.schema.getInlineNodeSpec?.(child.inlineType))\n\t\t\t) {\n\t\t\t\tcarriers.push({ kind: 'inlineNode', blockId, offset: pos, attrs: child.attrs });\n\t\t\t}\n\t\t\tpos += 1;\n\t\t}\n\t}\n\tif (hasText) carriers.push({ kind: 'text', blockId, from, to, mark: textMark });\n}\n\n/** Sizes every carrier in the range ('' clears). Returns false when nothing changed. */\nfunction dispatchRangeFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst carriers: FontSizeCarrier[] = rangeCarriers(state);\n\tif (carriers.length === 0) return false;\n\tconst builder = state.transaction('command');\n\tlet changed = false;\n\n\tfor (const carrier of carriers) {\n\t\tif (carrier.kind === 'text') {\n\t\t\tif (size === '') {\n\t\t\t\tif (carrier.mark) {\n\t\t\t\t\tbuilder.removeMark(carrier.blockId, carrier.from, carrier.to, carrier.mark);\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (carrier.mark)\n\t\t\t\t\tbuilder.removeMark(carrier.blockId, carrier.from, carrier.to, carrier.mark);\n\t\t\t\tbuilder.addMark(carrier.blockId, carrier.from, carrier.to, {\n\t\t\t\t\ttype: FONT_SIZE_TYPE,\n\t\t\t\t\tattrs: { size },\n\t\t\t\t});\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst current: string | null = readFontSize(carrier.attrs);\n\t\tif (size === current || (size === '' && current === null)) continue;\n\t\tif (carrier.kind === 'blockNode') {\n\t\t\tbuilder.setNodeAttr(carrier.path, mergeFontSize(carrier.attrs, size));\n\t\t} else {\n\t\t\tbuilder.setInlineNodeAttr(\n\t\t\t\tcarrier.blockId,\n\t\t\t\tcarrier.offset,\n\t\t\t\tmergeFontSize(carrier.attrs, size),\n\t\t\t);\n\t\t}\n\t\tchanged = true;\n\t}\n\n\tif (!changed) return false;\n\tbuilder.setSelection(state.selection);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** The set of fontSize values carried by font-size-aware nodes in the range, or null when none. */\nfunction rangeNodeSizes(state: EditorState): Set<string> | null {\n\tconst nodeAttrs: (BlockAttrs | InlineNodeAttrs)[] = rangeCarriers(state)\n\t\t.filter((carrier) => carrier.kind !== 'text')\n\t\t.map((carrier) => carrier.attrs);\n\tif (nodeAttrs.length === 0) return null;\n\treturn new Set(nodeAttrs.map((attrs) => readFontSize(attrs) ?? ''));\n}\n\n// --- State Queries ---\n\n/** The `fontSize` mark value of a pixel size, e.g. `18px`. */\nexport function pixelFontSize(size: number): string {\n\treturn `${size}px`;\n}\n\n/** Returns the raw fontSize CSS value at the current selection, or null. */\nexport function getActiveSize(state: EditorState): string | null {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return nodeFontSizeValue(target);\n\t// Additive: when a range spans font-size-aware nodes (e.g. a formula) that all\n\t// share one explicit size, report it; otherwise read the text mark as before.\n\tconst sizes = rangeNodeSizes(state);\n\tif (sizes && sizes.size === 1) {\n\t\tconst [only] = sizes;\n\t\tif (only) return only;\n\t}\n\treturn getMarkAttrAtSelection(state, 'fontSize', (m) => m.attrs.size ?? null);\n}\n\n/** Returns the active font size as a number, falling back to defaultSize. */\nexport function getActiveSizeNumeric(state: EditorState, defaultSize: number): number {\n\tconst raw: string | null = getActiveSize(state);\n\tif (!raw) return defaultSize;\n\tconst parsed: number = Number.parseInt(raw, 10);\n\treturn Number.isNaN(parsed) ? defaultSize : parsed;\n}\n\n/** Returns true when the selection carries a fontSize (mark or node attribute). */\nexport function isFontSizeActive(state: EditorState): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return nodeFontSizeValue(target) !== null;\n\tconst sizes = rangeNodeSizes(state);\n\tif (sizes && [...sizes].some((size) => size.length > 0)) return true;\n\treturn isAttributedMarkActive(state, 'fontSize');\n}\n\n// --- Commands ---\n\n/**\n * Applies the given CSS size to the selection: as a node `fontSize` attribute\n * when a font-size-aware node is selected (e.g. a formula), otherwise as a\n * fontSize mark on the selected text.\n */\nexport function applyFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) return dispatchNodeFontSize(context, state, target, size);\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tif (isCollapsed(sel)) {\n\t\tconst mark = { type: markType('fontSize'), attrs: { size } };\n\t\treturn dispatchIfPresent(context, applyAttributedMark(state, mark));\n\t}\n\treturn dispatchRangeFontSize(context, state, size);\n}\n\n/** Removes the fontSize (node attribute or mark) from the current selection. */\nexport function removeFontSize(context: PluginContext, state: EditorState): boolean {\n\tconst target = nodeFontSizeTarget(state);\n\tif (target) {\n\t\tif (nodeFontSizeValue(target) === null) return false;\n\t\treturn dispatchNodeFontSize(context, state, target, '');\n\t}\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tif (isCollapsed(sel)) {\n\t\treturn dispatchIfPresent(context, removeAttributedMark(state, markType('fontSize')));\n\t}\n\treturn dispatchRangeFontSize(context, state, '');\n}\n\n/** Steps the font size up or down through the preset list. */\nexport function stepFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n\tdefaultSize: number,\n): boolean {\n\tconst current: number = getActiveSizeNumeric(state, defaultSize);\n\tconst next: number | null = getNextPresetSize(current, direction, sizes);\n\tif (next === null) return false;\n\n\tif (next === defaultSize) {\n\t\treturn removeFontSize(context, state);\n\t}\n\treturn applyFontSize(context, state, pixelFontSize(next));\n}\n\n/**\n * Selects a specific font size: removes the mark when size equals the\n * default, otherwise applies the new size.\n */\nexport function selectSize(context: PluginContext, size: number, defaultSize: number): void {\n\tif (size === defaultSize) {\n\t\tcontext.executeCommand('removeFontSize');\n\t} else {\n\t\tapplyFontSize(context, context.getState(), pixelFontSize(size));\n\t}\n}\n\n// --- Helpers ---\n\n/** Finds the next preset size in the given direction, or null at boundaries. */\nexport function getNextPresetSize(\n\tcurrent: number,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n): number | null {\n\tif (direction === 'up') {\n\t\tfor (const size of sizes) {\n\t\t\tif (size > current) return size;\n\t\t}\n\t\treturn null;\n\t}\n\tfor (let i: number = sizes.length - 1; i >= 0; i--) {\n\t\tconst size: number | undefined = sizes[i];\n\t\tif (size !== undefined && size < current) return size;\n\t}\n\treturn null;\n}\n","/**\n * Renders the font-size picker popup with a custom numeric input\n * and an accessible preset list with keyboard navigation.\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport type { FontSizeLocale } from './FontSizeLocale.js';\nimport { getActiveSizeNumeric, selectSize } from './FontSizeOperations.js';\n\n// --- Constants ---\n\nconst MIN_CUSTOM_SIZE = 1;\nconst MAX_CUSTOM_SIZE = 400;\n\n// --- Config ---\n\nexport interface FontSizePopupConfig {\n\treadonly sizes: readonly number[];\n\treadonly defaultSize: number;\n\treadonly onClose: (options?: PopupCloseOptions) => void;\n\treadonly contentElement: HTMLElement;\n\treadonly locale: FontSizeLocale;\n}\n\n// --- Public Entry Point ---\n\n/** Builds the font-size picker DOM inside the given container. */\nexport function renderFontSizePopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tcontainer.classList.add('notectl-font-size-picker');\n\n\tconst currentSize: number = getActiveSizeNumeric(context.getState(), config.defaultSize);\n\n\tconst input: HTMLInputElement = buildCustomInput(currentSize, config);\n\tappendInputWrapper(container, input);\n\n\tconst { list, items } = buildSizeList(config.sizes, currentSize, context, config);\n\tcontainer.appendChild(list);\n\n\tscrollActiveIntoView(items, config.sizes, currentSize, list);\n\tattachKeyboardNavigation(input, list, items, context, config);\n}\n\n// --- Custom Input ---\n\nfunction buildCustomInput(currentSize: number, config: FontSizePopupConfig): HTMLInputElement {\n\tconst input: HTMLInputElement = document.createElement('input');\n\tinput.type = 'number';\n\tinput.className = 'notectl-font-size-picker__input';\n\tinput.min = String(MIN_CUSTOM_SIZE);\n\tinput.max = String(MAX_CUSTOM_SIZE);\n\tinput.value = String(currentSize);\n\tinput.setAttribute('aria-label', config.locale.customFontSizeAria);\n\treturn input;\n}\n\nfunction appendInputWrapper(container: HTMLElement, input: HTMLInputElement): void {\n\tconst wrapper: HTMLDivElement = document.createElement('div');\n\twrapper.className = 'notectl-font-size-picker__input-wrapper';\n\twrapper.appendChild(input);\n\tcontainer.appendChild(wrapper);\n}\n\n// --- Size List ---\n\ninterface SizeListResult {\n\treadonly list: HTMLDivElement;\n\treadonly items: HTMLButtonElement[];\n}\n\nfunction buildSizeList(\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): SizeListResult {\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-font-size-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', config.locale.fontSizesAria);\n\n\tconst items: HTMLButtonElement[] = [];\n\n\tfor (const size of sizes) {\n\t\tconst isActive: boolean = size === currentSize;\n\t\tconst item: HTMLButtonElement = buildSizeItem(size, isActive);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t});\n\t\titem.addEventListener('click', () => {\n\t\t\tselectSize(context, size, config.defaultSize);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t});\n\n\t\titems.push(item);\n\t\tlist.appendChild(item);\n\t}\n\n\treturn { list, items };\n}\n\nfunction buildSizeItem(size: number, isActive: boolean): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.id = `notectl-font-size-option-${size}`;\n\titem.className = 'notectl-font-size-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-font-size-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-font-size-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst label: HTMLSpanElement = document.createElement('span');\n\tlabel.className = 'notectl-font-size-picker__label';\n\tlabel.textContent = String(size);\n\titem.appendChild(label);\n\n\treturn item;\n}\n\n// --- Scroll ---\n\nfunction scrollActiveIntoView(\n\titems: HTMLButtonElement[],\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tlist: HTMLDivElement,\n): void {\n\tconst activeIdx: number = sizes.indexOf(currentSize);\n\tif (activeIdx < 0) return;\n\n\tconst activeItem: HTMLButtonElement | undefined = items[activeIdx];\n\tif (!activeItem) return;\n\n\trequestAnimationFrame(() => {\n\t\tactiveItem.scrollIntoView({ block: 'nearest' });\n\t});\n\tlist.setAttribute('aria-activedescendant', activeItem.id);\n}\n\n// --- Keyboard Navigation ---\n\nfunction attachKeyboardNavigation(\n\tinput: HTMLInputElement,\n\tlist: HTMLDivElement,\n\titems: HTMLButtonElement[],\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tlet focusedIndex = -1;\n\n\tconst setFocused = (idx: number): void => {\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length) {\n\t\t\titems[focusedIndex]?.classList.remove('notectl-font-size-picker__item--focused');\n\t\t}\n\t\tfocusedIndex = idx;\n\t\tconst el: HTMLButtonElement | undefined = items[focusedIndex];\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length && el) {\n\t\t\tel.classList.add('notectl-font-size-picker__item--focused');\n\t\t\tel.scrollIntoView({ block: 'nearest' });\n\t\t\tlist.setAttribute('aria-activedescendant', el.id);\n\t\t}\n\t};\n\n\t// As an editable combobox (input + listbox), this popup owns its keyboard\n\t// model. `consume` claims a handled key so the toolbar's generic popup\n\t// handler does not also act on it and advance focus a second time (#144).\n\tconst consume = (e: KeyboardEvent): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t};\n\n\tinput.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\tconsume(e);\n\t\t\tconst val: number = Number.parseInt(input.value, 10);\n\t\t\tif (!Number.isNaN(val) && val >= MIN_CUSTOM_SIZE && val <= MAX_CUSTOM_SIZE) {\n\t\t\t\tselectSize(context, val, config.defaultSize);\n\t\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t\t}\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\tconsume(e);\n\t\t\tsetFocused(0);\n\t\t\titems[0]?.focus();\n\t\t} else if (e.key === 'Escape') {\n\t\t\tconsume(e);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n\n\tlist.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'ArrowDown') {\n\t\t\tconsume(e);\n\t\t\tif (focusedIndex < items.length - 1) {\n\t\t\t\tsetFocused(focusedIndex + 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowUp') {\n\t\t\tconsume(e);\n\t\t\tif (focusedIndex > 0) {\n\t\t\t\tsetFocused(focusedIndex - 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t} else {\n\t\t\t\tsetFocused(-1);\n\t\t\t\tinput.focus();\n\t\t\t}\n\t\t} else if (e.key === 'Enter') {\n\t\t\tconsume(e);\n\t\t\titems[focusedIndex]?.click();\n\t\t} else if (e.key === 'Escape') {\n\t\t\tconsume(e);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n}\n","/**\n * FontSizePlugin: registers a fontSize mark with attrs, a combobox-style\n * toolbar selector with WCAG-accessible popup, and commands for\n * increasing / decreasing font size.\n */\n\nimport FONT_SIZE_SELECT_CSS from '../../editor/styles/font-size-select.css?inline';\nimport type { StyleClassNames } from '../../model/StyleClass.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isValidCSSFontSize } from '../shared/ColorValidation.js';\nimport {\n\ttype InlineStyleMarkConfig,\n\tcreateInlineStyleMarkSpec,\n\tstyleDeclaration,\n} from '../shared/InlineStyleMarkSpec.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { registerStyleClassNames } from '../shared/StyleClassNames.js';\nimport { FONT_SIZE_LOCALE_EN, type FontSizeLocale, loadFontSizeLocale } from './FontSizeLocale.js';\nimport {\n\tgetActiveSizeNumeric,\n\tisFontSizeActive,\n\tpixelFontSize,\n\tremoveFontSize,\n\tstepFontSize,\n} from './FontSizeOperations.js';\nimport { renderFontSizePopup } from './FontSizePopup.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfontSize: { size: string };\n\t}\n}\n\n// --- Constants ---\n\n/** Default preset sizes shown in the font size dropdown. */\nexport const DEFAULT_FONT_SIZES: readonly number[] = [\n\t8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96,\n];\n\nconst DEFAULT_FONT_SIZE = 16;\n\n// --- Configuration ---\n\nexport interface FontSizeConfig {\n\t/**\n\t * Preset sizes shown in the font size dropdown.\n\t * Must contain positive integers. Values are sorted and deduplicated automatically.\n\t * Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The base font size that text has when no fontSize mark is applied.\n\t * Shown as the initial value in the toolbar combo and used as the\n\t * \"neutral\" size — selecting it removes the mark instead of applying one.\n\t * Defaults to 16.\n\t */\n\treadonly defaultSize?: number;\n\t/**\n\t * Your own CSS class per font size in HTML content, keyed by pixel size, e.g.\n\t * `{ 14: 'text-sm', 18: 'text-lg' }`. Class-based export (`getContentHTML({ cssMode: 'classes' })`)\n\t * writes these classes instead of generated `notectl-s-*` names, and HTML import\n\t * and paste recognize them, so content round-trips with your stylesheet. Sizes\n\t * outside `sizes` may have a class too. Invalid keys or class names make editor\n\t * initialization fail with a `TypeError` that explains the fix.\n\t */\n\treadonly styleClasses?: StyleClassNames<number>;\n\treadonly locale?: FontSizeLocale;\n}\n\n/** The font size mark: one `font-size` declaration per text run. */\nconst FONT_SIZE_MARK: InlineStyleMarkConfig = {\n\ttype: 'fontSize',\n\trank: 4,\n\tvalueAttr: 'size',\n\tdomStyleProperty: 'fontSize',\n\tcssProperty: 'font-size',\n\tvalidate: isValidCSSFontSize,\n};\n\n/** A whole number of pixels without unit, as `styleClasses` keys are written. */\nconst PIXEL_SIZE_KEY: RegExp = /^[1-9]\\d*$/;\n\n// --- Plugin ---\n\nexport class FontSizePlugin implements Plugin {\n\treadonly id = 'fontSize';\n\treadonly name = 'Font Size';\n\treadonly priority = 21;\n\n\tprivate readonly config: FontSizeConfig;\n\tprivate readonly sizes: readonly number[];\n\tprivate readonly defaultSize: number;\n\tprivate locale!: FontSizeLocale;\n\n\tconstructor(config?: Partial<FontSizeConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.sizes = resolveSizes(config?.sizes);\n\t\tthis.defaultSize = resolveDefaultSize(config?.defaultSize);\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tFONT_SIZE_LOCALE_EN,\n\t\t\tloadFontSizeLocale,\n\t\t);\n\n\t\tcontext.registerStyleSheet(FONT_SIZE_SELECT_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerStyleClasses(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.applyDefaultSizeToContainer(context);\n\t}\n\n\tdestroy(): void {\n\t\t// no-op: nothing to clean up\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec(createInlineStyleMarkSpec(FONT_SIZE_MARK));\n\t}\n\n\tprivate registerStyleClasses(context: PluginContext): void {\n\t\tregisterStyleClassNames(context, 'FontSizePlugin', this.config.styleClasses, (key: string) =>\n\t\t\tstyleDeclaration(FONT_SIZE_MARK.cssProperty, pixelFontSize(pixelSizeKey(key))),\n\t\t);\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFontSize', () => {\n\t\t\treturn removeFontSize(context, context.getState());\n\t\t});\n\n\t\tcontext.registerCommand('setFontSize', () => {\n\t\t\treturn false;\n\t\t});\n\n\t\tcontext.registerCommand('increaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t});\n\n\t\tcontext.registerCommand('decreaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t});\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-+': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t\t'Mod-Shift-_': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'fontSize',\n\t\t\tgroup: 'format',\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFontSize',\n\t\t\tpopupType: 'combobox',\n\t\t\tgetLabel: (state: EditorState): string =>\n\t\t\t\tString(getActiveSizeNumeric(state, this.defaultSize)),\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderFontSizePopup(container, ctx, {\n\t\t\t\t\tsizes: this.sizes,\n\t\t\t\t\tdefaultSize: this.defaultSize,\n\t\t\t\t\tonClose,\n\t\t\t\t\tcontentElement: ctx.getContainer(),\n\t\t\t\t\tlocale: this.locale,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state) => isFontSizeActive(state),\n\t\t});\n\t}\n\n\t/**\n\t * Sets the configured default font size on the editor content container\n\t * so that unformatted text renders at the correct size instead of the\n\t * browser default (16px).\n\t */\n\tprivate applyDefaultSizeToContainer(context: PluginContext): void {\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tsetStyleProperty(container, 'fontSize', `${this.defaultSize}px`);\n\t}\n}\n\n// --- Helpers ---\n\nfunction resolveSizes(sizes: readonly number[] | undefined): readonly number[] {\n\tif (!sizes || sizes.length === 0) return DEFAULT_FONT_SIZES;\n\tconst unique: number[] = [...new Set(sizes)].filter((n) => Number.isInteger(n) && n > 0);\n\tunique.sort((a, b) => a - b);\n\treturn unique.length > 0 ? unique : DEFAULT_FONT_SIZES;\n}\n\nfunction resolveDefaultSize(size: number | undefined): number {\n\tif (size === undefined) return DEFAULT_FONT_SIZE;\n\treturn Number.isInteger(size) && size > 0 ? size : DEFAULT_FONT_SIZE;\n}\n\n/** Reads a `styleClasses` key as a pixel size. Throws a `TypeError` for anything else. */\nfunction pixelSizeKey(key: string): number {\n\tif (!PIXEL_SIZE_KEY.test(key)) {\n\t\tthrow new TypeError(`\"${key}\" is not a font size; use whole pixel numbers such as 18.`);\n\t}\n\treturn Number(key);\n}\n"],"mappings":"Y,ihBCeauB,EAAsC,CAClDC,MAAO,YACPC,QAAS,YACTC,mBAAoB,mBACpBC,cAAe,cAKVC,iBAAiDC,OAAAC,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAIvDC,eAAsBC,EAAmBC,GACxC,OAAOhB,EAAiBW,EAAeK,EAAMV,EAC9C,CCsBA,SAASW,EACRC,GAEA,YAAiC,IAA1BA,GAAMC,OAAOC,QACrB,CAQA,SAASC,EAAmBC,GAC3B,MAAMC,EAAMD,EAAME,UAClB,GAAIlC,EAAgBiC,GAAM,CACzB,MAAME,EAAQH,EAAMI,SAASH,EAAII,QACjC,OAAKF,GAAUR,EAAqBK,EAAMM,OAAOC,cAAcJ,EAAMK,OAE9D,CAAEC,KAAM,QAASC,KADSV,EAAMW,YAAYV,EAAII,SAAW,CAACJ,EAAII,QACzCR,MAAOM,EAAMN,OAAS,CAAC,GAF+B,IAGrF,CACA,MAAMe,EAaP,SACCZ,GAEA,MAAMC,EAAMD,EAAME,UAClB,IAAKjC,EAAgBgC,IAAQlC,EAAYkC,GAAM,OAAO,KACtD,GAAIA,EAAIY,OAAOC,UAAYb,EAAIc,KAAKD,QAAS,OAAO,KACpD,MAAME,EAAeC,KAAKC,IAAIjB,EAAIY,OAAOM,OAAQlB,EAAIc,KAAKI,QAE1D,GADmBF,KAAKG,IAAInB,EAAIY,OAAOM,OAAQlB,EAAIc,KAAKI,QAC/CH,IAAS,EAAG,OAAO,KAE5B,MAAMb,EAAQH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B,EAAOK,EAAMC,EAAOhI,EAASsF,EACvD,CC2IIiE,CAAoBjC,EAAWC,EAAK,CACnC1E,MAAO4C,KAAK5C,MACZF,YAAa8C,KAAK9C,YAClB6E,UACAc,eAAgBf,EAAIiC,eACpBjE,OAAQE,KAAKF,UAGfzB,SAAWhG,GF+Hd,SAAiCA,GAChC,MAAMgC,EAASjC,EAAmBC,GAClC,GAAIgC,EAAQ,OAAqC,OAA9BD,EAAkBC,GACrC,MAAM+C,EAAQT,EAAetE,GAC7B,SAAI+E,IAAS,IAAIA,GAAO4G,KAAM7J,GAASA,EAAKF,OAAS,KAC9CtD,EAAuB0B,EAAO,WACtC,CErIwB4L,CAAiB5L,IAExC,CAOA,2BAAA0I,CAAoCxG,GACnC,MAAMsH,EAAyBtH,EAAQwJ,eACvC/M,EAAiB6K,EAAW,WAAY,GAAG7B,KAAK9C,gBACjD,U"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{J as t,P as e,g as n,p as i,z as a}from"./Document-ssR6hBzG.mjs";import{c as r,d as o,f as l,i as s,n as c,u as p}from"./Selection-DC6AOGgF.mjs";import{a as u,r as d}from"./TypeBrands-Ch9856Gb.mjs";import{o as m}from"./BlockInsertion-CXfXqUZl.mjs";import{n as h}from"./HTMLSanitization-BRipXyhI.mjs";import{s as f,t as b}from"./LocaleLoader-DEpTFuVc.mjs";import{n as g}from"./SelectionReplacement-Cj4FLlPz.mjs";import{n as v}from"./DomUtils-Bf7JLFlx.mjs";import{t as x}from"./SelectionSync-8y0nbBHZ.mjs";import{a as y}from"./PopupPositioning-CIqgpqlW.mjs";import{i as w}from"./ColorValidation-ZBKZ_gTr.mjs";var L={"&":"&","<":"<",">":">"},k={"&":"&","<":"<",">":">",'"':"""};function S(t){return t.replace(/[&<>]/g,t=>L[t]??t)}function C(t){return t.replace(/[&<>"]/g,t=>k[t]??t)}function $(t){if(!t)return"";let e="";for(const[n,i]of Object.entries(t))!1!==i&&null!=i&&(e+=!0!==i?` ${n}="${C(String(i))}"`:` ${n}="true"`);return e}function A(t,e,n){return`<${t}${$(n)}>${e}</${t}>`}function z(t,e){return A("mi",S(t),e)}function _(t,e){return A("mn",S(t),e)}function E(t,e){return A("mo",S(t),e)}function B(t,e){return A("mtext",S(t),e)}function I(t){return function(t,e){return`<${t}${$(e)}></${t}>`}("mspace",t)}function O(t,e){return A("mrow",t,e)}function D(t){return 0===t.length?"":1===t.length?t[0]??"":O(t.join(""))}function N(t,e,n){return A("mfrac",`${t}${e}`,n)}function P(t,e,n){return A("mover",`${t}${e}`,n)}function F(t,e,n){return A("munder",`${t}${e}`,n)}function q(t){return A("mtd",t)}function R(t){return A("mtr",t.map(q).join(""))}var j={"&":"&","<":"<",">":">",""":'"',"'":"'","'":"'"};function T(t){const e=t.display?"block":"inline",n=t.alt?` alttext="${C(t.alt)}"`:"",i=void 0!==t.latex&&""!==t.latex,a=`<annotation encoding="application/x-tex">${S(t.latex??"")}</annotation>`;return`<math display="${e}"${n}>${i?`<semantics>${t.presentation}${a}</semantics>`:t.presentation}</math>`}function M(t){const e=t.match(/<annotation\b[^>]*\bencoding=["']application\/x-tex["'][^>]*>([\s\S]*?)<\/annotation>/i);var n;if(e&&void 0!==e[1])return(n=e[1],n.replace(/&(?:amp|lt|gt|quot|apos|#39);/g,t=>j[t]??t)).trim()}function H(t){return t.replace(/^(<math\b[^>]*?)\s+mathsize=(?:"[^"]*"|'[^']*')/i,"$1")}var G=/<math[\s>]/i;function U(t){return G.test(t.mathml)?function(t,e){const n=t.replace(/^(<math\b[^>]*?)\s+alttext=["'][^"']*["']/i,"$1");return e?n.replace(/^<math\b/i,`<math alttext="${C(e)}"`):n}(t.mathml,t.alt):""}function K(t,e){const n=U(e);n?t.innerHTML=n:t.textContent=e.latex||e.alt||"⊡"}function W(t,e){const n="string"==typeof e?.fontSize?e.fontSize:"";t.style.fontSize=n}function V(t){return{mathml:"string"==typeof t?.mathml?t.mathml:"",latex:"string"==typeof t?.latex?t.latex:"",alt:"string"==typeof t?.alt?t.alt:"",fontSize:"string"==typeof t?.fontSize?t.fontSize:""}}function Z(t){const e=U(t);return e?function(t,e){const n=H(t);return e?n.replace(/^<math\b/i,`<math mathsize="${C(e)}"`):n}(e,w(t.fontSize)?t.fontSize:""):e}function X(t){const e=t.getAttribute("mathsize")??"";return w(e)?e:""}function J(t,e){if("block"===t.getAttribute("display")!==e)return!1;const n=H(function(t){return t.replace(/^(<math\b[^>]*?)\s+data-block-id=(?:"[^"]*"|'[^']*')/i,"$1")}(t.outerHTML));return{mathml:n,latex:M(n)??"",alt:t.getAttribute("alttext")??"",fontSize:X(t)}}var Q="math_inline",Y="math_display",tt={insertInline:"Mod-Shift-E",insertDisplay:"Mod-Shift-M"},et=[12,16,20,24,32,40,48,64,96],nt={},it=["math","semantics","annotation","mrow","mi","mn","mo","mtext","ms","mspace","mfrac","msqrt","mroot","msup","msub","msubsup","mover","munder","munderover","mmultiscripts","mprescripts","none","mtable","mtr","mlabeledtr","mtd","mpadded","mphantom","mstyle","merror","menclose","mfenced","maction"],at=["display","encoding","mathvariant","mathsize","mathcolor","mathbackground","displaystyle","scriptlevel","scriptminsize","scriptsizemultiplier","stretchy","symmetric","largeop","movablelimits","accent","accentunder","form","fence","separator","lspace","rspace","voffset","minsize","maxsize","linethickness","columnalign","rowalign","columnspacing","rowspacing","columnlines","rowlines","columnspan","rowspan","align","open","close","separators","notation","alttext","depth","width","height"];function rt(t){const e=t.selection;if(!o(e))return null;const n=t.getBlock(e.nodeId);return n&&"math_display"===n.type?e.nodeId:null}function ot(t){return{mathml:t.mathml,latex:t.latex,alt:t.alt,fontSize:t.fontSize}}function lt(t,e){if(0===e.length||!l(t.selection))return null;const i=t.transaction("command"),a=g(t,i);let r=a.offset;for(const o of e)i.insertInlineNode(a.blockId,r,n(d(Q),ot(o))),r+=1;return i.setSelection(c(a.blockId,r)),i.build()}function st(t,e){if(0===e.length||p(t.selection))return null;const n=e.map(t=>i(u(Y),[],void 0,ot(t))),a=t.transaction("command"),r=g(t,a);if(!m(r.state,a,r.blockId,n))return null;const o=n[n.length-1];return o?(a.setSelection(s(o.id,[])),a.build()):null}function ct(t){return{mathml:t.mathml,latex:t.latex,alt:t.alt,fontSize:t.fontSize}}function pt(t,e,n){const i=ct(n);n.display?function(t,e){const n=function(t,e){return st(t,[e])}(t.getState(),e);!!n&&t.dispatch(n)}(t,i):function(t,e){const n=function(t,e){return lt(t,[e])}(t.getState(),e);!!n&&t.dispatch(n)}(t,i),t.announce(e.inserted)}function ut(t,e){return void 0===e?{node:t}:{node:t,kind:e}}function dt(t,e,n=!1){return{node:t,kind:e,bigOp:!0,intLike:n}}function mt(t,e){return Object.hasOwn(t,e)?t[e]:void 0}var ht=/* @__PURE__ */function(t){return t.Ordinary="ordinary",t.Binary="binary",t.Relation="relation",t.Arrow="arrow",t.Open="open",t.Close="close",t.Function="function",t.BigOp="bigop",t.Punct="punct",t}({});function ft(t,e){return{char:t,kind:e}}var bt="ordinary",gt="binary",vt="relation",xt="arrow",yt="function",wt="bigop",Lt="punct",kt={alpha:ft("α",bt),beta:ft("β",bt),gamma:ft("γ",bt),delta:ft("δ",bt),epsilon:ft("ϵ",bt),varepsilon:ft("ε",bt),zeta:ft("ζ",bt),eta:ft("η",bt),theta:ft("θ",bt),vartheta:ft("ϑ",bt),iota:ft("ι",bt),kappa:ft("κ",bt),lambda:ft("λ",bt),mu:ft("μ",bt),nu:ft("ν",bt),xi:ft("ξ",bt),omicron:ft("ο",bt),pi:ft("π",bt),varpi:ft("ϖ",bt),rho:ft("ρ",bt),varrho:ft("ϱ",bt),sigma:ft("σ",bt),varsigma:ft("ς",bt),tau:ft("τ",bt),upsilon:ft("υ",bt),phi:ft("ϕ",bt),varphi:ft("φ",bt),chi:ft("χ",bt),psi:ft("ψ",bt),omega:ft("ω",bt),Gamma:ft("Γ",bt),Delta:ft("Δ",bt),Theta:ft("Θ",bt),Lambda:ft("Λ",bt),Xi:ft("Ξ",bt),Pi:ft("Π",bt),Sigma:ft("Σ",bt),Upsilon:ft("Υ",bt),Phi:ft("Φ",bt),Psi:ft("Ψ",bt),Omega:ft("Ω",bt)},St={sin:ft("sin",yt),cos:ft("cos",yt),tan:ft("tan",yt),cot:ft("cot",yt),sec:ft("sec",yt),csc:ft("csc",yt),sinh:ft("sinh",yt),cosh:ft("cosh",yt),tanh:ft("tanh",yt),coth:ft("coth",yt),arcsin:ft("arcsin",yt),arccos:ft("arccos",yt),arctan:ft("arctan",yt),log:ft("log",yt),ln:ft("ln",yt),lg:ft("lg",yt),exp:ft("exp",yt),deg:ft("deg",yt),det:ft("det",yt),dim:ft("dim",yt),hom:ft("hom",yt),ker:ft("ker",yt),arg:ft("arg",yt),Pr:ft("Pr",yt)},Ct={sum:ft("∑",wt),prod:ft("∏",wt),coprod:ft("∐",wt),int:ft("∫",wt),iint:ft("∬",wt),iiint:ft("∭",wt),oint:ft("∮",wt),bigcup:ft("⋃",wt),bigcap:ft("⋂",wt),bigsqcup:ft("⨆",wt),bigvee:ft("⋁",wt),bigwedge:ft("⋀",wt),bigoplus:ft("⨁",wt),bigotimes:ft("⨂",wt),bigodot:ft("⨀",wt),biguplus:ft("⨄",wt),lim:ft("lim",wt),limsup:ft("lim sup",wt),liminf:ft("lim inf",wt),injlim:ft("inj lim",wt),projlim:ft("proj lim",wt),max:ft("max",wt),min:ft("min",wt),sup:ft("sup",wt),inf:ft("inf",wt),gcd:ft("gcd",wt)},$t={times:ft("×",gt),div:ft("÷",gt),pm:ft("±",gt),mp:ft("∓",gt),cdot:ft("⋅",gt),ast:ft("∗",gt),star:ft("⋆",gt),circ:ft("∘",gt),bullet:ft("∙",gt),oplus:ft("⊕",gt),ominus:ft("⊖",gt),otimes:ft("⊗",gt),oslash:ft("⊘",gt),odot:ft("⊙",gt),cap:ft("∩",gt),cup:ft("∪",gt),uplus:ft("⊎",gt),sqcap:ft("⊓",gt),sqcup:ft("⊔",gt),wedge:ft("∧",gt),land:ft("∧",gt),vee:ft("∨",gt),lor:ft("∨",gt),setminus:ft("∖",gt),wr:ft("≀",gt),diamond:ft("⋄",gt),bigtriangleup:ft("△",gt),bigtriangledown:ft("▽",gt),triangleleft:ft("◁",gt),triangleright:ft("▷",gt),amalg:ft("⨿",gt),dagger:ft("†",gt),ddagger:ft("‡",gt)},At={leq:ft("≤",vt),le:ft("≤",vt),geq:ft("≥",vt),ge:ft("≥",vt),neq:ft("≠",vt),ne:ft("≠",vt),equiv:ft("≡",vt),sim:ft("∼",vt),simeq:ft("≃",vt),cong:ft("≅",vt),approx:ft("≈",vt),propto:ft("∝",vt),prec:ft("≺",vt),succ:ft("≻",vt),preceq:ft("⪯",vt),succeq:ft("⪰",vt),ll:ft("≪",vt),gg:ft("≫",vt),lll:ft("⋘",vt),ggg:ft("⋙",vt),subset:ft("⊂",vt),supset:ft("⊃",vt),subseteq:ft("⊆",vt),supseteq:ft("⊇",vt),subsetneq:ft("⊊",vt),supsetneq:ft("⊋",vt),sqsubseteq:ft("⊑",vt),sqsupseteq:ft("⊒",vt),in:ft("∈",vt),ni:ft("∋",vt),notin:ft("∉",vt),mid:ft("∣",vt),parallel:ft("∥",vt),perp:ft("⊥",vt),models:ft("⊨",vt),vdash:ft("⊢",vt),dashv:ft("⊣",vt),doteq:ft("≐",vt),asymp:ft("≍",vt),bowtie:ft("⋈",vt),smile:ft("⌣",vt),frown:ft("⌢",vt)},zt={leftarrow:ft("←",xt),gets:ft("←",xt),rightarrow:ft("→",xt),to:ft("→",xt),leftrightarrow:ft("↔",xt),Leftarrow:ft("⇐",xt),Rightarrow:ft("⇒",xt),Leftrightarrow:ft("⇔",xt),mapsto:ft("↦",xt),longrightarrow:ft("⟶",xt),longleftarrow:ft("⟵",xt),longleftrightarrow:ft("⟷",xt),Longrightarrow:ft("⟹",xt),Longleftarrow:ft("⟸",xt),Longleftrightarrow:ft("⟺",xt),implies:ft("⟹",xt),iff:ft("⟺",xt),uparrow:ft("↑",xt),downarrow:ft("↓",xt),updownarrow:ft("↕",xt),nearrow:ft("↗",xt),searrow:ft("↘",xt),swarrow:ft("↙",xt),nwarrow:ft("↖",xt),hookleftarrow:ft("↩",xt),hookrightarrow:ft("↪",xt),rightharpoonup:ft("⇀",xt),rightharpoondown:ft("⇁",xt),leftharpoonup:ft("↼",xt),leftharpoondown:ft("↽",xt),nleftarrow:ft("↚",xt),nrightarrow:ft("↛",xt)},_t={langle:ft("⟨","open"),rangle:ft("⟩","close"),lceil:ft("⌈","open"),rceil:ft("⌉","close"),lfloor:ft("⌊","open"),rfloor:ft("⌋","close"),lbrace:ft("{","open"),rbrace:ft("}","close"),lbrack:ft("[","open"),rbrack:ft("]","close"),lvert:ft("|","open"),rvert:ft("|","close"),lVert:ft("‖","open"),rVert:ft("‖","close"),vert:ft("|","relation"),Vert:ft("‖","relation"),backslash:ft("\\",bt)},Et={infty:ft("∞",bt),partial:ft("∂",bt),nabla:ft("∇",bt),forall:ft("∀",bt),exists:ft("∃",bt),nexists:ft("∄",bt),emptyset:ft("∅",bt),varnothing:ft("∅",bt),aleph:ft("ℵ",bt),beth:ft("ℶ",bt),hbar:ft("ℏ",bt),ell:ft("ℓ",bt),Re:ft("ℜ",bt),Im:ft("ℑ",bt),wp:ft("℘",bt),prime:ft("′",bt),angle:ft("∠",bt),measuredangle:ft("∡",bt),triangle:ft("△",bt),neg:ft("¬",bt),lnot:ft("¬",bt),top:ft("⊤",bt),bot:ft("⊥",bt),flat:ft("♭",bt),natural:ft("♮",bt),sharp:ft("♯",bt),clubsuit:ft("♣",bt),diamondsuit:ft("♢",bt),heartsuit:ft("♡",bt),spadesuit:ft("♠",bt),surd:ft("√",bt),complement:ft("∁",bt),square:ft("□",bt),blacksquare:ft("■",bt),bigstar:ft("★",bt),checkmark:ft("✓",bt),degree:ft("°",bt),cdots:ft("⋯",bt),ldots:ft("…",bt),dots:ft("…",bt),dotsb:ft("⋯",bt),vdots:ft("⋮",bt),ddots:ft("⋱",bt)},Bt={colon:ft(":",Lt),cdotp:ft("·",Lt),ldotp:ft(".",Lt)},It={...kt,...St,...Ct,...$t,...At,...zt,..._t,...Et,...Bt},Ot={"(":ft("(","open"),")":ft(")","close"),"[":ft("[","open"),"]":ft("]","close"),"|":ft("|","relation"),"/":ft("/",bt)};function Dt(t){if("."===t)return ft("",bt);if(t.startsWith("\\")){const e=t.slice(1);return"{"===e?ft("{","open"):"}"===e?ft("}","close"):"|"===e?ft("‖","relation"):"\\"===e?ft("\\",bt):mt(_t,e)}return mt(Ot,t)}var Nt=/* @__PURE__ */function(t){return t.Command="command",t.GroupOpen="groupOpen",t.GroupClose="groupClose",t.Superscript="superscript",t.Subscript="subscript",t.Prime="prime",t.Ampersand="ampersand",t.RowBreak="rowBreak",t.NbSpace="nbSpace",t.Number="number",t.Char="char",t}({}),Pt=/* @__PURE__ */new Set(["{","}","%","$","#","&","_",",",":",";","!"," ","|","\\",".","/","'","~","^"]);function Ft(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function qt(t){return t>="0"&&t<="9"}function Rt(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function jt(t,e,n){return{type:t,value:e,position:n}}function Tt(t,e){const n=t[e+1];if(void 0!==n&&!Ft(n))return"\\"===n?jt("rowBreak","\\",e):jt("command",n,e);let i=e+1;for(;i<t.length;){const e=t[i];if(void 0===e||!Ft(e))break;i+=1}return jt("command",t.slice(e+1,i),e)}function Mt(t,e){let n=e;for(;n<t.length;){const e=t[n];if(void 0===e||!qt(e))break;n+=1}if("."===t[n]&&void 0!==t[n+1]&&qt(t[n+1]??""))for(n+=1;n<t.length;){const e=t[n];if(void 0===e||!qt(e))break;n+=1}return jt("number",t.slice(e,n),e)}function Ht(t,e){switch(t){case"{":return jt("groupOpen",t,e);case"}":return jt("groupClose",t,e);case"^":return jt("superscript",t,e);case"_":return jt("subscript",t,e);case"'":return jt("prime",t,e);case"&":return jt("ampersand",t,e);case"~":return jt("nbSpace",t,e);default:return jt("char",t,e)}}function Gt(t,e){return{glyph:t,under:!1,stretchy:e}}function Ut(t,e){return{glyph:t,under:!0,stretchy:e}}var Kt={hat:Gt("^",!1),widehat:Gt("^",!0),check:Gt("ˇ",!1),tilde:Gt("~",!1),widetilde:Gt("~",!0),bar:Gt("‾",!1),overline:Gt("‾",!0),vec:Gt("→",!1),overrightarrow:Gt("→",!0),overleftarrow:Gt("←",!0),overleftrightarrow:Gt("↔",!0),dot:Gt("˙",!1),ddot:Gt("¨",!1),dddot:Gt("⃛",!1),acute:Gt("´",!1),grave:Gt("`",!1),breve:Gt("˘",!1),mathring:Gt("˚",!1),overbrace:Gt("⏞",!0),underline:Ut("_",!0),underbrace:Ut("⏟",!0),underrightarrow:Ut("→",!0),underleftarrow:Ut("←",!0)},Wt={matrix:{open:"",close:""},pmatrix:{open:"(",close:")"},bmatrix:{open:"[",close:"]"},Bmatrix:{open:"{",close:"}"},vmatrix:{open:"|",close:"|"},Vmatrix:{open:"‖",close:"‖"},cases:{open:"{",close:"",columnalign:"left"},aligned:{open:"",close:"",columnalign:"right left"},align:{open:"",close:"",columnalign:"right left"},gathered:{open:"",close:"",columnalign:"center"},smallmatrix:{open:"",close:""}};function Vt(t){return t.type===Nt.Command&&"end"===t.value}function Zt(t){return t.type===Nt.Ampersand||t.type===Nt.RowBreak||t.type===Nt.Command&&"end"===t.value}var Xt={",":"0.167em",":":"0.222em",";":"0.278em","!":"-0.167em"," ":"0.25em",quad:"1em",qquad:"2em",thinspace:"0.167em",medspace:"0.222em",thickspace:"0.278em",negthinspace:"-0.167em",negmedspace:"-0.222em",negthickspace:"-0.278em",enspace:"0.5em"};function Jt(t){return Object.hasOwn(Xt,t)}function Qt(t){const e=mt(Xt,t);if(void 0!==e)return I({width:e})}function Yt(){return I({width:"0.25em"})}function te(t){const e=t.parseRawArgument();return n=e,Object.hasOwn(Wt,n)||"array"===n?function(t,e){"array"===t&&(e.parseOptionalArgument(),e.parseRawArgument());const n=function(t,e){const n=[];let i=[],a=[];const r=()=>{i.push(O(a.join(""))),a=[]},o=()=>{r(),n.push(i),i=[]};for(;;){const n=e.peek();if(void 0===n){e.error({message:`Unterminated environment \\begin{${t}}`});break}if(Vt(n)){e.next(),e.parseRawArgument();break}if(n.type===Nt.Ampersand){e.next(),r();continue}if(n.type===Nt.RowBreak){e.next(),o();continue}if(n.type===Nt.GroupClose){e.next(),e.error({message:"Unmatched brace",position:n.position});continue}const i=e.parseAtomsUntil(Zt);a.push(...i.map(t=>t.node))}return(a.length>0||i.length>0)&&o(),0===n.length&&n.push([""]),n}(t,e).map(t=>t.map(t=>t)),i=mt(Wt,t)??{open:"",close:""},a=(r=i.columnalign?{columnalign:i.columnalign}:void 0,A("mtable",n.map(R).join(""),r));var r;return i.open||i.close?ut(O(`${i.open?E(i.open,{stretchy:!0,fence:!0}):""}${a}${i.close?E(i.close,{stretchy:!0,fence:!0}):""}`)):ut(a)}(e,t):(t.error({message:"Unknown environment",command:e}),ut(A("merror",B(e))));var n}function ee(t){return t.type===Nt.Command&&"right"===t.value}function ne(t){const e=t.next();if(void 0===e)return{kind:"fence",markup:""};const n=e.type===Nt.Command?`\\${e.value}`:e.value,i=Dt(n);return void 0===i?(t.error({message:"Unknown delimiter",command:n,position:e.position}),{kind:"error",markup:A("merror",B(n))}):{kind:"fence",markup:ie(i)}}function ie(t){return""===t.char?"":E(t.char,{fence:!0,stretchy:!0})}var ae={},re={"double-struck":{upperBase:120120,lowerBase:120146,digitBase:120792,holes:{C:8450,H:8461,N:8469,P:8473,Q:8474,R:8477,Z:8484}},script:{upperBase:119964,lowerBase:119990,holes:{B:8492,E:8496,F:8497,H:8459,I:8464,L:8466,M:8499,R:8475,e:8495,g:8458,o:8500}},fraktur:{upperBase:120068,lowerBase:120094,holes:{C:8493,H:8460,I:8465,R:8476,Z:8488}},bold:{upperBase:119808,lowerBase:119834,digitBase:120782,holes:ae},italic:{upperBase:119860,lowerBase:119886,holes:{h:8462}},"sans-serif":{upperBase:120224,lowerBase:120250,digitBase:120802,holes:ae},monospace:{upperBase:120432,lowerBase:120458,digitBase:120822,holes:ae}};function oe(t,e){if(1!==t.length)return null;const n=re[e],i=n.holes[t];return void 0!==i?String.fromCodePoint(i):function(t){return t>="A"&&t<="Z"}(t)?String.fromCodePoint(n.upperBase+(t.charCodeAt(0)-65)):function(t){return t>="a"&&t<="z"}(t)?String.fromCodePoint(n.lowerBase+(t.charCodeAt(0)-97)):function(t){return t>="0"&&t<="9"}(t)&&void 0!==n.digitBase?String.fromCodePoint(n.digitBase+(t.charCodeAt(0)-48)):null}var le=/<(mi|mn)>([^<]*)<\/\1>/g,se=/<mi>([^<]*)<\/mi>/g;var ce={mathbb:"double-struck",mathcal:"script",mathscr:"script",mathfrak:"fraktur",mathbf:"bold",mathit:"italic",mathsf:"sans-serif",mathtt:"monospace"},pe={boldsymbol:"bold-italic",bm:"bold-italic"},ue={text:void 0,textnormal:"normal",textrm:"normal",textbf:"bold",textit:"italic",textsf:"sans-serif",texttt:"monospace",mbox:void 0};function de(t,e){if("operatorname"===t)return ut(z(e.parseRawArgument(),{mathvariant:"normal"}));if(Object.hasOwn(ue,t)){const n=mt(ue,t),i=e.parseRawArgument();return ut(n?B(i,{mathvariant:n}):B(i))}const n=mt(ce,t);if(void 0!==n)return ut((i=e.parseArgument(),a=n,i.replace(le,(t,e,n)=>{const i=function(t,e){let n="";for(const i of t)n+=oe(i,e)??i;return n}(n,a);return"mn"===e?_(i):z(i)})));var i,a;if("mathrm"===t)return ut(e.parseArgument().replace(se,(t,e)=>z(e,{mathvariant:"normal"})));const r=mt(pe,t),o=e.parseArgument();return ut(void 0===r?o:A("mstyle",o,{mathvariant:r}))}var me=/* @__PURE__ */new Set(["frac","dfrac","tfrac","cfrac"]),he=/* @__PURE__ */new Set(["binom","dbinom","tbinom","choose"]),fe=/* @__PURE__ */new Set(["overset","underset","stackrel"]);var be=/* @__PURE__ */new Set(["∫","∬","∭","∮"]);var ge=class{source;tokens;pos=0;depth=0;depthExceeded=!1;errors=[];display;constructor(t,e,n){this.source=t,this.tokens=e,this.display=n}get collectedErrors(){return this.errors}peek(){return this.tokens[this.pos]}next(){const t=this.tokens[this.pos];return void 0!==t&&(this.pos+=1),t}error(t){this.errors.push(t)}parseTopLevel(){const t=[];for(;;){const e=this.peek();if(void 0===e)break;if(e.type===Nt.GroupClose){this.next(),this.error({message:"Unmatched brace",position:e.position});continue}const n=this.parseAtomWithScripts();void 0!==n&&t.push(n)}return t}parseExpression(t){const e=[];for(;;){const n=this.peek();if(void 0===n||t(n))break;if(n.type===Nt.GroupClose)break;const i=this.parseAtomWithScripts();void 0!==i&&e.push(i)}return e}parseAtomsUntil(t){return this.parseExpression(t)}parseAtomWithScripts(){const t=this.parseBaseAtom();if(void 0!==t)return this.attachScripts(t)}attachScripts(t){let e,n,i,a="";for(;;){const t=this.peek();if(void 0===t)break;if(t.type!==Nt.Prime)if(t.type!==Nt.Command||"limits"!==t.value)if(t.type!==Nt.Command||"nolimits"!==t.value)if(t.type!==Nt.Superscript){if(t.type!==Nt.Subscript)break;this.next(),e=this.combineSub(e,this.parseArgument())}else this.next(),n=this.combineSup(n,this.parseArgument());else this.next(),i="nolimits";else this.next(),i="limits";else this.next(),a+="′"}return a&&(n=void 0===n?E(a):O(`${E(a)}${n}`)),void 0===e&&void 0===n?t:ut(this.buildScripts(t,e,n,i))}combineSup(t,e){return void 0===t?e:(this.error({message:"Double superscript"}),O(`${t}${e}`))}combineSub(t,e){return void 0===t?e:(this.error({message:"Double subscript"}),O(`${t}${e}`))}buildScripts(t,e,n,i){const a=!0===t.bigOp&&!0!==t.intLike&&this.display;if("limits"===i||"nolimits"!==i&&a){if(void 0!==e&&void 0!==n)return function(t,e,n){return A("munderover",`${t}${e}${n}`)}(t.node,e,n);if(void 0!==e)return F(t.node,e);if(void 0!==n)return P(t.node,n)}return void 0!==e&&void 0!==n?function(t,e,n){return A("msubsup",`${t}${e}${n}`)}(t.node,e,n):void 0!==e?function(t,e){return A("msub",`${t}${e}`)}(t.node,e):void 0!==n?function(t,e){return A("msup",`${t}${e}`)}(t.node,n):t.node}parseBaseAtom(){if(this.depth>=256)return this.bailDeepNesting();this.depth+=1;try{return this.parseBaseAtomInner()}finally{this.depth-=1}}bailDeepNesting(){const t=this.next();if(void 0!==t&&!this.depthExceeded)return this.depthExceeded=!0,this.error({message:"Maximum nesting depth exceeded",position:t.position}),ut(A("merror",B("⋯")))}parseBaseAtomInner(){const t=this.next();if(void 0!==t)switch(t.type){case Nt.Number:return ut(_(t.value));case Nt.Char:return this.parseChar(t.value);case Nt.GroupOpen:return this.parseGroup();case Nt.NbSpace:return ut(Yt());case Nt.Command:return this.parseCommand(t);case Nt.Superscript:case Nt.Subscript:case Nt.Prime:return this.pos-=1,this.attachScripts(ut(O("")));case Nt.Ampersand:case Nt.RowBreak:case Nt.GroupClose:default:return}}parseGroup(){const t=this.parseExpression(()=>!1);return this.expect(Nt.GroupClose),ut(D(t.map(t=>t.node)))}parseChar(t){const e=Dt(t);return!e||e.kind!==ht.Open&&e.kind!==ht.Close?ut("+"===t||"-"===t||"*"===t||"="===t||"/"===t||"|"===t||","===t||";"===t||"."===t||":"===t||"!"===t||"?"===t||"<"===t||">"===t?E(t):z(t)):ut(E(t,{fence:!0}),e.kind)}parseCommand(t){const e=t.value,n=function(t){return mt(It,t)}(e);if(n)return this.symbolAtom(n);if(1===(i=e).length&&Pt.has(i))return this.controlSymbolAtom(e);var i;const a=this.dispatchStructural(e);if(void 0!==a)return a;const r=this.dispatchSpecial(e,t);return void 0!==r?r:(this.error({message:"Unknown command",command:`\\${e}`,position:t.position}),ut(A("merror",B(`\\${e}`))))}dispatchStructural(t){if(function(t){return me.has(t)}(t))return ut(N((e=this).parseArgument(),e.parseArgument()));var e;if(function(t){return he.has(t)}(t))return function(t){const e=N(t.parseArgument(),t.parseArgument(),{linethickness:0});return ut(O(`${E("(",{fence:!0})}${e}${E(")",{fence:!0})}`))}(this);if("sqrt"===t)return function(t){const e=t.parseOptionalArgument(),n=t.parseArgument();return ut(void 0===e||""===e?function(t){return A("msqrt",t)}(n):function(t,e){return A("mroot",`${t}${e}`)}(n,e))}(this);if(function(t){return fe.has(t)}(t))return function(t,e){const n=e.parseArgument(),i=e.parseArgument();return ut("underset"===t?F(i,n):P(i,n))}(t,this);if(function(t){return Object.hasOwn(Kt,t)}(t))return function(t,e){const n=mt(Kt,t);if(!n)return ut("");const i=e.parseArgument(),a=E(n.glyph,{stretchy:n.stretchy}),r=n.under?{accentunder:!0}:{accent:!0};return ut(n.under?F(i,a,r):P(i,a,r))}(t,this);if(function(t){return Object.hasOwn(ce,t)||Object.hasOwn(pe,t)||Object.hasOwn(ue,t)||"mathrm"===t||"operatorname"===t}(t))return de(t,this);if(Jt(t)){const e=Qt(t);return void 0===e?void 0:ut(e)}}dispatchSpecial(t,e){return"left"===t?function(t){const e=ne(t),n=t.parseAtomsUntil(ee),i=t.peek();let a="";return void 0!==i&&ee(i)?(t.next(),a=ne(t).markup):t.error({message:"Unmatched \\left"}),ut(D([e.markup,...n.map(t=>t.node),a]))}(this):"begin"===t?te(this):"pmod"===t?function(t){const e=t.parseArgument(),n=E("(",{fence:!0}),i=E(")",{fence:!0});return ut(O(`${n}${B("mod")}${Yt()}${e}${i}`))}(this):"bmod"===t||"mod"===t?ut(E("mod",{lspace:"0.222em",rspace:"0.222em"})):"substack"===t?function(t){!function(t){const e=t.peek();void 0!==e&&e.type===Nt.GroupOpen&&t.next()}(t);const e=[];let n=[];for(;;){const i=t.peek();if(void 0===i||i.type===Nt.GroupClose)break;if(i.type===Nt.RowBreak){t.next(),e.push(D(n)),n=[];continue}const a=t.parseAtomsUntil(t=>t.type===Nt.RowBreak);n.push(...a.map(t=>t.node))}!function(t){const e=t.peek();void 0!==e&&e.type===Nt.GroupClose&&t.next()}(t),e.push(D(n));const i=e.map(t=>A("mtr",A("mtd",t))).join("");return ut(A("mtable",i))}(this):"right"===t?function(t,e){const n=ne(t);return t.error({message:"Unmatched \\right",position:e}),ut("error"===n.kind?n.markup:D([]))}(this,e.position):void 0}symbolAtom(t){switch(t.kind){case ht.Ordinary:return ut(z(t.char),t.kind);case ht.Function:return ut(z(t.char,{mathvariant:"normal"}),t.kind);case ht.BigOp:return this.bigOperator(t);case ht.Open:case ht.Close:return ut(E(t.char,{fence:!0}),t.kind);default:return ut(E(t.char),t.kind)}}bigOperator(t){if(/[a-z]/i.test(t.char))return dt(E(t.char,{movablelimits:!0}),t.kind);const e=be.has(t.char);return dt(E(t.char,{movablelimits:!0,largeop:!0}),t.kind,e)}controlSymbolAtom(t){if(Jt(t)){const e=Qt(t);return void 0===e?void 0:ut(e)}return"{"===t?ut(E("{",{fence:!0}),ht.Open):"}"===t?ut(E("}",{fence:!0}),ht.Close):ut("|"===t?E("‖"):"\\"===t?E("\\"):"/"===t?E("/"):"'"===t?E("′"):"."===t?E("."):B(t))}parseArgument(){return""===(t=this.parseBaseAtom()?.node??"")?O(""):t;var t}parseOptionalArgument(){const t=this.peek();if(void 0===t||t.type!==Nt.Char||"["!==t.value)return;this.next();const e=this.parseExpression(t=>t.type===Nt.Char&&"]"===t.value),n=this.peek();return void 0!==n&&n.type===Nt.Char&&"]"===n.value&&this.next(),D(e.map(t=>t.node))}parseRawArgument(){const t=this.peek();if(void 0===t)return"";if(t.type!==Nt.GroupOpen)return this.next(),t.value;const e=t.position;this.next();let n=1,i=this.source.length;for(;;){const t=this.next();if(void 0===t)break;if(t.type===Nt.GroupOpen)n+=1;else if(t.type===Nt.GroupClose&&(n-=1,0===n)){i=t.position;break}}return this.source.slice(e+1,i)}expect(t){const e=this.peek();void 0===e||e.type!==t?t===Nt.GroupClose&&this.error({message:"Unmatched brace"}):this.next()}},ve="<mrow></mrow>";function xe(t,e){const n=e?.display??!1;if(""===t.trim())return{presentation:ve,errors:[]};const{atoms:i,errors:a}=function(t,e){const n=new ge(t,function(t){const e=[];let n=0;for(;n<t.length;){const i=t[n]??"";if("\\"===i){const i=Tt(t,n);if(e.push(i),n+="rowBreak"===i.type?2:Math.max(1,i.value.length)+1,"command"===i.type&&Ft(i.value[0]??""))for(;n<t.length&&Rt(t[n]??"");)n+=1;continue}if(qt(i)){const i=Mt(t,n);e.push(i),n+=i.value.length;continue}if(Rt(i)){n+=1;continue}const a=Ht(i,n);a&&e.push(a),n+=1}return e}(t),e);return{atoms:n.parseTopLevel(),errors:n.collectedErrors}}(t,n);return{presentation:ye(i),errors:a}}function ye(t){if(0===t.length)return ve;if(1===t.length){const e=t[0];return e?e.node:ve}return O(t.map(t=>t.node).join(""))}var we=/(?<!\$)\$([^$\n\uFFFC]+)\$$/,Le=/\$\$([^$\n\uFFFC]+)\$\$$/;function ke(t,e){const n=t.getBlock(e);return void 0!==n&&"code_block"!==n.type}function Se(t,e){const n=t-e;return n<0?null:{from:n,to:t}}var Ce={insertInline:"Insert formula",insertInlineTooltip:"Insert inline formula",editFormula:"Edit formula",latexLabel:"LaTeX",latexPlaceholder:"e.g. \\frac{a}{b} + \\sqrt{x}",previewLabel:"Preview",insertButton:"Insert",updateButton:"Update",cancelButton:"Cancel",displayToggle:"Display (block) equation",sizeLabel:"Size",sizeDefault:"Default",altLabel:"Description",altPlaceholder:"Spoken description (optional)",paletteLabel:"Symbols and structures",emptyPreview:"Nothing to preview yet.",inserted:"Formula inserted.",updated:"Formula updated.",editing:"Editing formula.",selected:"Formula selected. Press Enter to edit.",unknownCommand:t=>`Unknown LaTeX command: ${t}`,groupFractions:"Fractions",groupScripts:"Scripts",groupRoots:"Roots",groupAccents:"Accents",groupOperators:"Operators",groupFunctions:"Functions",groupGreek:"Greek letters",groupRelations:"Relations",groupSets:"Sets",groupLogic:"Logic",groupArrows:"Arrows",groupDelimiters:"Brackets",groupDots:"Dots",groupMatrices:"Matrices"},$e=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-D1jFXqLJ.mjs"),"./locales/de.ts":()=>import("./de-DY3obIAF.mjs"),"./locales/es.ts":()=>import("./es-CtOtKQCP.mjs"),"./locales/fr.ts":()=>import("./fr-DjMZ-3K5.mjs"),"./locales/hi.ts":()=>import("./hi-4CiAKVjT.mjs"),"./locales/nl.ts":()=>import("./nl-Cr--x8bX.mjs"),"./locales/pt.ts":()=>import("./pt-BkpVtod-.mjs"),"./locales/ru.ts":()=>import("./ru-BotG0MFT.mjs"),"./locales/zh.ts":()=>import("./zh-CWGAPVei.mjs")});async function Ae(t){return b($e,t,Ce)}var ze=/^\s*\$\$([^\n]+?)\$\$\s*$/;function _e(t,e){const{presentation:n}=xe(t,{display:e});return{mathml:T({presentation:n,latex:t,display:e}),latex:t,alt:"",fontSize:""}}var Ee=class{root;buttons=[];activeIndex=0;constructor(t,e,n){this.root=document.createElement("div"),this.root.className="notectl-math-palette",this.root.setAttribute("role","toolbar"),this.root.setAttribute("aria-label",e);for(const i of t)this.root.appendChild(this.buildGroup(i,n));this.root.addEventListener("keydown",t=>this.onKeydown(t)),this.setActive(0)}focus(){this.buttons[this.activeIndex]?.focus()}activeButton(){return this.buttons[this.activeIndex]}buildGroup(t,e){const n=document.createElement("div");n.className="notectl-math-palette__group",n.setAttribute("role","group"),n.setAttribute("aria-label",t.label);for(const i of t.items){const t=document.createElement("button");t.type="button",t.className="notectl-math-palette__btn",t.textContent=i.label,t.setAttribute("aria-label",i.ariaLabel),t.tabIndex=-1,t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),t.addEventListener("click",()=>e(i.snippet)),this.buttons.push(t),n.appendChild(t)}return n}onKeydown(t){if("Enter"===t.key||" "===t.key)return t.preventDefault(),t.stopPropagation(),void this.buttons[this.activeIndex]?.click();const e=this.buttons.length-1;let n=this.activeIndex;switch(t.key){case"ArrowRight":case"ArrowDown":n=this.activeIndex>=e?0:this.activeIndex+1;break;case"ArrowLeft":case"ArrowUp":n=this.activeIndex<=0?e:this.activeIndex-1;break;case"Home":n=0;break;case"End":n=e;break;default:return}t.preventDefault(),t.stopPropagation(),this.setActive(n),this.buttons[n]?.focus()}setActive(t){const e=this.buttons[this.activeIndex];e&&(e.tabIndex=-1);const n=this.buttons[t];n&&(n.tabIndex=0),this.activeIndex=t}},Be=0,Ie=class{root;options;textarea;preview;previewEmpty;errorsList;altInput;commitBtn;palette=null;displayCheckbox=null;cancelBtn=null;fontSizeSelect=null;display;lastErrorKey="";constructor(t){this.options=t,this.display=t.initialDisplay??!1;const e=++Be;this.root=document.createElement("div"),this.root.className="notectl-formula-editor",this.root.setAttribute("role","group"),this.root.setAttribute("aria-label",t.locale.latexLabel),t.palette&&t.palette.length>0&&(this.palette=new Ee(t.palette,t.locale.paletteLabel,t=>this.insertSnippet(t)),this.root.appendChild(this.palette.root)),this.textarea=this.buildLatexField(e),this.preview=document.createElement("div"),this.previewEmpty=document.createElement("div"),this.errorsList=document.createElement("ul"),this.altInput=this.buildAltField(e),this.commitBtn=document.createElement("button"),this.root.appendChild(this.buildPreview()),this.root.appendChild(this.errorsList),this.root.appendChild(this.altInput.parentElement),t.fontSizes&&t.fontSizes.length>0&&this.root.appendChild(this.buildSizeField(e)),"insert"===t.mode&&this.root.appendChild(this.buildDisplayToggle(e)),this.root.appendChild(this.buildActions()),this.errorsList.className="notectl-formula-editor__errors",this.errorsList.id=`notectl-formula-errors-${e}`,this.errorsList.setAttribute("aria-live","polite"),this.textarea.setAttribute("aria-describedby",this.errorsList.id),this.root.addEventListener("keydown",t=>this.onRootKeydown(t)),this.update()}focus(){this.textarea.focus(),this.textarea.setSelectionRange(this.textarea.value.length,this.textarea.value.length)}onRootKeydown(t){if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void this.options.onCancel();"Tab"===t.key&&(t.preventDefault(),t.stopPropagation(),this.moveFocus(!t.shiftKey))}focusStops(){const t=[],e=this.palette?.activeButton();return e&&t.push(e),t.push(this.textarea,this.altInput),this.fontSizeSelect&&t.push(this.fontSizeSelect),this.displayCheckbox&&t.push(this.displayCheckbox),this.cancelBtn&&t.push(this.cancelBtn),t.push(this.commitBtn),t}moveFocus(t){const e=this.focusStops();if(0===e.length)return;const n=this.activeElement();let i=e.findIndex(t=>t===n);-1===i&&n&&this.palette?.root.contains(n)&&(i=0),-1===i&&(i=t?e.length-1:0),e[(i+(t?1:-1)+e.length)%e.length]?.focus()}activeElement(){let t=this.root.getRootNode().activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}getResult(){const t=this.textarea.value.trim(),e=this.altInput.value.trim(),{presentation:n}=xe(t,{display:this.display});return{latex:t,mathml:T({presentation:n,latex:t,display:this.display,alt:e||void 0}),alt:e,display:this.display,fontSize:this.fontSizeSelect?.value??""}}insertSnippet(t){const e=this.textarea.selectionStart??this.textarea.value.length,n=this.textarea.selectionEnd??e,i=t.indexOf("$0"),a=i>=0?t.replace("$0",""):t,r=i>=0?i:a.length,o=this.textarea.value;this.textarea.value=o.slice(0,e)+a+o.slice(n);const l=e+r;this.textarea.focus(),this.textarea.setSelectionRange(l,l),this.update()}buildLatexField(t){const e=document.createElement("div");e.className="notectl-formula-editor__field";const n=document.createElement("label");n.className="notectl-formula-editor__label",n.htmlFor=`notectl-formula-latex-${t}`,n.textContent=this.options.locale.latexLabel;const i=document.createElement("textarea");return i.id=`notectl-formula-latex-${t}`,i.className="notectl-formula-editor__input",i.placeholder=this.options.locale.latexPlaceholder,i.rows=2,i.spellcheck=!1,i.value=this.options.initialLatex??"",i.addEventListener("input",()=>this.update()),i.addEventListener("keydown",t=>this.onTextareaKeydown(t)),e.appendChild(n),e.appendChild(i),this.root.appendChild(e),i}buildPreview(){const t=document.createElement("div");t.className="notectl-formula-editor__field";const e=document.createElement("span");return e.className="notectl-formula-editor__label",e.textContent=this.options.locale.previewLabel,this.preview.className="notectl-formula-editor__preview",this.previewEmpty.className="notectl-formula-editor__preview-empty",this.previewEmpty.textContent=this.options.locale.emptyPreview,t.appendChild(e),t.appendChild(this.previewEmpty),t.appendChild(this.preview),t}buildAltField(t){const e=document.createElement("div");e.className="notectl-formula-editor__field";const n=document.createElement("label");n.className="notectl-formula-editor__label",n.htmlFor=`notectl-formula-alt-${t}`,n.textContent=this.options.locale.altLabel;const i=document.createElement("input");return i.id=`notectl-formula-alt-${t}`,i.type="text",i.className="notectl-formula-editor__alt",i.placeholder=this.options.locale.altPlaceholder,i.value=this.options.initialAlt??"",e.appendChild(n),e.appendChild(i),i}buildSizeField(t){const e=document.createElement("div");e.className="notectl-formula-editor__field";const n=document.createElement("label");n.className="notectl-formula-editor__label",n.htmlFor=`notectl-formula-size-${t}`,n.textContent=this.options.locale.sizeLabel;const i=document.createElement("select");i.id=`notectl-formula-size-${t}`,i.className="notectl-formula-editor__size";const a=this.options.initialFontSize??"";i.appendChild(this.buildSizeOption("",this.options.locale.sizeDefault));for(const r of this.options.fontSizes??[])i.appendChild(this.buildSizeOption(`${r}px`,String(r)));return a&&!Array.from(i.options).some(t=>t.value===a)&&i.appendChild(this.buildSizeOption(a,a.replace("px",""))),i.value=a,i.addEventListener("change",()=>this.applyPreviewFontSize()),this.fontSizeSelect=i,e.appendChild(n),e.appendChild(i),e}buildSizeOption(t,e){const n=document.createElement("option");return n.value=t,n.textContent=e,n}applyPreviewFontSize(){this.preview.style.fontSize=this.fontSizeSelect?.value||""}buildDisplayToggle(t){const e=document.createElement("label");e.className="notectl-formula-editor__toggle",e.htmlFor=`notectl-formula-display-${t}`;const n=document.createElement("input");n.id=`notectl-formula-display-${t}`,n.type="checkbox",n.checked=this.display,n.addEventListener("change",()=>{this.display=n.checked,this.update()}),this.displayCheckbox=n;const i=document.createElement("span");return i.textContent=this.options.locale.displayToggle,e.appendChild(n),e.appendChild(i),e}buildActions(){const t=document.createElement("div");t.className="notectl-formula-editor__actions";const e=document.createElement("button");return e.type="button",e.className="notectl-formula-editor__btn",e.textContent=this.options.locale.cancel,e.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),e.addEventListener("click",()=>this.options.onCancel()),this.cancelBtn=e,this.commitBtn.type="button",this.commitBtn.className="notectl-formula-editor__btn notectl-formula-editor__btn--primary",this.commitBtn.textContent="edit"===this.options.mode?this.options.locale.commitUpdate:this.options.locale.commitInsert,this.commitBtn.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),this.commitBtn.addEventListener("click",()=>this.commit()),t.appendChild(e),t.appendChild(this.commitBtn),t}onTextareaKeydown(t){"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.commit())}commit(){const t=this.getResult();t.latex?this.options.onCommit(t):this.options.onCancel()}update(){this.applyPreviewFontSize();const t=this.textarea.value.trim();if(!t)return this.preview.innerHTML="",this.previewEmpty.hidden=!1,void this.renderErrors([]);this.previewEmpty.hidden=!0;const{presentation:e,errors:n}=xe(t,{display:this.display});this.preview.innerHTML=T({presentation:e,display:this.display}),this.renderErrors(n.map(t=>t.command??t.message))}renderErrors(t){const e=t.join("");if(e!==this.lastErrorKey){this.lastErrorKey=e,this.errorsList.replaceChildren();for(const e of t){const t=document.createElement("li");t.textContent=e.startsWith("\\")?this.options.locale.unknownCommand(e):e,this.errorsList.appendChild(t)}}}};function Oe(t){return[{id:"fractions",label:(e={fractions:t.groupFractions,scripts:t.groupScripts,roots:t.groupRoots,accents:t.groupAccents,operators:t.groupOperators,functions:t.groupFunctions,greek:t.groupGreek,relations:t.groupRelations,sets:t.groupSets,logic:t.groupLogic,arrows:t.groupArrows,delimiters:t.groupDelimiters,dots:t.groupDots,matrices:t.groupMatrices}).fractions,items:[{label:"a╱b",ariaLabel:"Fraction",snippet:"\\frac{$0}{}"},{label:"⒞",ariaLabel:"Binomial coefficient",snippet:"\\binom{$0}{}"}]},{id:"scripts",label:e.scripts,items:[{label:"xⁿ",ariaLabel:"Superscript",snippet:"^{$0}"},{label:"xₙ",ariaLabel:"Subscript",snippet:"_{$0}"},{label:"xⁿₘ",ariaLabel:"Subscript and superscript",snippet:"_{$0}^{}"}]},{id:"roots",label:e.roots,items:[{label:"√",ariaLabel:"Square root",snippet:"\\sqrt{$0}"},{label:"ⁿ√",ariaLabel:"N-th root",snippet:"\\sqrt[$0]{}"}]},{id:"accents",label:e.accents,items:[{label:"→",ariaLabel:"Vector",snippet:"\\vec{$0}"},{label:"â",ariaLabel:"Hat",snippet:"\\hat{$0}"},{label:"ā",ariaLabel:"Overline",snippet:"\\overline{$0}"},{label:"ȧ",ariaLabel:"Dot above",snippet:"\\dot{$0}"},{label:"ã",ariaLabel:"Tilde",snippet:"\\tilde{$0}"}]},{id:"operators",label:e.operators,items:[{label:"∑",ariaLabel:"Sum with limits",snippet:"\\sum_{$0}^{}"},{label:"∏",ariaLabel:"Product with limits",snippet:"\\prod_{$0}^{}"},{label:"∫",ariaLabel:"Integral with limits",snippet:"\\int_{$0}^{}"},{label:"∬",ariaLabel:"Double integral",snippet:"\\iint "},{label:"∮",ariaLabel:"Contour integral",snippet:"\\oint "},{label:"lim",ariaLabel:"Limit",snippet:"\\lim_{$0}"},{label:"∂",ariaLabel:"Partial derivative",snippet:"\\partial "},{label:"∇",ariaLabel:"Nabla (del)",snippet:"\\nabla "},{label:"×",ariaLabel:"Times",snippet:"\\times "},{label:"·",ariaLabel:"Dot product",snippet:"\\cdot "},{label:"±",ariaLabel:"Plus or minus",snippet:"\\pm "},{label:"÷",ariaLabel:"Division",snippet:"\\div "},{label:"∞",ariaLabel:"Infinity",snippet:"\\infty "}]},{id:"functions",label:e.functions,items:[{label:"sin",ariaLabel:"Sine",snippet:"\\sin "},{label:"cos",ariaLabel:"Cosine",snippet:"\\cos "},{label:"tan",ariaLabel:"Tangent",snippet:"\\tan "},{label:"log",ariaLabel:"Logarithm",snippet:"\\log "},{label:"ln",ariaLabel:"Natural logarithm",snippet:"\\ln "},{label:"exp",ariaLabel:"Exponential function",snippet:"\\exp "}]},{id:"greek",label:e.greek,items:[{label:"α",ariaLabel:"Alpha",snippet:"\\alpha "},{label:"β",ariaLabel:"Beta",snippet:"\\beta "},{label:"γ",ariaLabel:"Gamma",snippet:"\\gamma "},{label:"δ",ariaLabel:"Delta",snippet:"\\delta "},{label:"ε",ariaLabel:"Epsilon",snippet:"\\varepsilon "},{label:"ζ",ariaLabel:"Zeta",snippet:"\\zeta "},{label:"η",ariaLabel:"Eta",snippet:"\\eta "},{label:"θ",ariaLabel:"Theta",snippet:"\\theta "},{label:"κ",ariaLabel:"Kappa",snippet:"\\kappa "},{label:"λ",ariaLabel:"Lambda",snippet:"\\lambda "},{label:"μ",ariaLabel:"Mu",snippet:"\\mu "},{label:"ν",ariaLabel:"Nu",snippet:"\\nu "},{label:"ξ",ariaLabel:"Xi",snippet:"\\xi "},{label:"π",ariaLabel:"Pi",snippet:"\\pi "},{label:"ρ",ariaLabel:"Rho",snippet:"\\rho "},{label:"σ",ariaLabel:"Sigma",snippet:"\\sigma "},{label:"τ",ariaLabel:"Tau",snippet:"\\tau "},{label:"φ",ariaLabel:"Phi",snippet:"\\varphi "},{label:"χ",ariaLabel:"Chi",snippet:"\\chi "},{label:"ψ",ariaLabel:"Psi",snippet:"\\psi "},{label:"ω",ariaLabel:"Omega",snippet:"\\omega "},{label:"Γ",ariaLabel:"Capital gamma",snippet:"\\Gamma "},{label:"Δ",ariaLabel:"Capital delta",snippet:"\\Delta "},{label:"Θ",ariaLabel:"Capital theta",snippet:"\\Theta "},{label:"Λ",ariaLabel:"Capital lambda",snippet:"\\Lambda "},{label:"Π",ariaLabel:"Capital pi",snippet:"\\Pi "},{label:"Σ",ariaLabel:"Capital sigma",snippet:"\\Sigma "},{label:"Φ",ariaLabel:"Capital phi",snippet:"\\Phi "},{label:"Ψ",ariaLabel:"Capital psi",snippet:"\\Psi "},{label:"Ω",ariaLabel:"Capital omega",snippet:"\\Omega "}]},{id:"relations",label:e.relations,items:[{label:"≤",ariaLabel:"Less than or equal to",snippet:"\\leq "},{label:"≥",ariaLabel:"Greater than or equal to",snippet:"\\geq "},{label:"≠",ariaLabel:"Not equal to",snippet:"\\neq "},{label:"≈",ariaLabel:"Approximately equal to",snippet:"\\approx "},{label:"≡",ariaLabel:"Equivalent to",snippet:"\\equiv "},{label:"∼",ariaLabel:"Similar to",snippet:"\\sim "},{label:"≅",ariaLabel:"Congruent to",snippet:"\\cong "},{label:"∝",ariaLabel:"Proportional to",snippet:"\\propto "}]},{id:"sets",label:e.sets,items:[{label:"∈",ariaLabel:"Element of",snippet:"\\in "},{label:"∉",ariaLabel:"Not an element of",snippet:"\\notin "},{label:"⊂",ariaLabel:"Subset of",snippet:"\\subset "},{label:"⊆",ariaLabel:"Subset of or equal to",snippet:"\\subseteq "},{label:"∪",ariaLabel:"Union",snippet:"\\cup "},{label:"∩",ariaLabel:"Intersection",snippet:"\\cap "},{label:"∅",ariaLabel:"Empty set",snippet:"\\emptyset "},{label:"ℝ",ariaLabel:"Real numbers",snippet:"\\mathbb{R}"},{label:"ℕ",ariaLabel:"Natural numbers",snippet:"\\mathbb{N}"},{label:"ℤ",ariaLabel:"Integers",snippet:"\\mathbb{Z}"},{label:"ℚ",ariaLabel:"Rational numbers",snippet:"\\mathbb{Q}"},{label:"ℂ",ariaLabel:"Complex numbers",snippet:"\\mathbb{C}"}]},{id:"logic",label:e.logic,items:[{label:"∀",ariaLabel:"For all",snippet:"\\forall "},{label:"∃",ariaLabel:"There exists",snippet:"\\exists "},{label:"¬",ariaLabel:"Logical not",snippet:"\\neg "},{label:"∧",ariaLabel:"Logical and",snippet:"\\land "},{label:"∨",ariaLabel:"Logical or",snippet:"\\lor "},{label:"⟹",ariaLabel:"Implies",snippet:"\\implies "},{label:"⟺",ariaLabel:"If and only if",snippet:"\\iff "}]},{id:"arrows",label:e.arrows,items:[{label:"→",ariaLabel:"Right arrow",snippet:"\\to "},{label:"⇒",ariaLabel:"Rightwards double arrow",snippet:"\\Rightarrow "},{label:"↔",ariaLabel:"Left-right arrow",snippet:"\\leftrightarrow "},{label:"↦",ariaLabel:"Maps to",snippet:"\\mapsto "}]},{id:"delimiters",label:e.delimiters,items:[{label:"( )",ariaLabel:"Auto-sized parentheses",snippet:"\\left($0\\right)"},{label:"[ ]",ariaLabel:"Auto-sized brackets",snippet:"\\left[$0\\right]"},{label:"{ }",ariaLabel:"Auto-sized braces",snippet:"\\left\\{$0\\right\\}"},{label:"|x|",ariaLabel:"Absolute value",snippet:"\\left|$0\\right|"},{label:"‖x‖",ariaLabel:"Norm",snippet:"\\left\\|$0\\right\\|"},{label:"⌊x⌋",ariaLabel:"Floor",snippet:"\\left\\lfloor $0\\right\\rfloor"},{label:"⌈x⌉",ariaLabel:"Ceiling",snippet:"\\left\\lceil $0\\right\\rceil"}]},{id:"dots",label:e.dots,items:[{label:"⋯",ariaLabel:"Centred ellipsis",snippet:"\\cdots "},{label:"…",ariaLabel:"Baseline ellipsis",snippet:"\\ldots "},{label:"⋮",ariaLabel:"Vertical ellipsis",snippet:"\\vdots "},{label:"⋱",ariaLabel:"Diagonal ellipsis",snippet:"\\ddots "}]},{id:"matrices",label:e.matrices,items:[{label:"[ ]",ariaLabel:"Bracket matrix",snippet:"\\begin{bmatrix} $0 & \\\\ & \\end{bmatrix}"},{label:"( )",ariaLabel:"Parenthesis matrix",snippet:"\\begin{pmatrix} $0 & \\\\ & \\end{pmatrix}"},{label:"{",ariaLabel:"Cases",snippet:"\\begin{cases} $0 & \\\\ & \\end{cases}"}]}];var e}function De(t,e){const n=new Ie({locale:(i=e.locale,{latexLabel:i.latexLabel,latexPlaceholder:i.latexPlaceholder,previewLabel:i.previewLabel,emptyPreview:i.emptyPreview,altLabel:i.altLabel,altPlaceholder:i.altPlaceholder,displayToggle:i.displayToggle,sizeLabel:i.sizeLabel,sizeDefault:i.sizeDefault,commitInsert:i.insertButton,commitUpdate:i.updateButton,cancel:i.cancelButton,paletteLabel:i.paletteLabel,unknownCommand:i.unknownCommand}),mode:e.mode,initialLatex:e.initialLatex,initialAlt:e.initialAlt,initialDisplay:e.initialDisplay,initialFontSize:e.initialFontSize,fontSizes:e.fontSizes,palette:Oe(e.locale),onCommit:e.onCommit,onCancel:e.onClose});var i;return t.appendChild(n.root),requestAnimationFrame(()=>n.focus()),n}var Ne=class{context;locale;fontSizes;panel=null;outsideHandler=null;constructor(t,e,n){this.context=t,this.locale=e,this.fontSizes=n}isOpen(){return null!==this.panel}openInsert(t){if(this.context.isReadOnly())return;const e=Pe();this.open({rect:e,mode:"insert",initialDisplay:t,onCommit:t=>{pt(this.context,this.locale,t),this.close(!0)}})}openEdit(t){this.context.isReadOnly()||(this.context.announce(this.locale.editing),this.open({rect:t.rect??Pe(),mode:"edit",initialLatex:t.latex,initialAlt:t.alt,initialDisplay:"display"===t.kind,initialFontSize:t.fontSize,onCommit:e=>{this.commitEdit(t,e),this.context.announce(this.locale.updated),this.close(!0)}}))}close(t){this.panel&&(this.outsideHandler&&(document.removeEventListener("mousedown",this.outsideHandler,!0),this.outsideHandler=null),this.panel.remove(),this.panel=null,t&&this.context.getContainer().focus())}commitEdit(t,e){const n=ct(e);"inline"===t.kind&&t.blockId&&void 0!==t.offset?function(t,e,n,i){const a=t.getState().transaction("command").setInlineNodeAttr(e,n,ot(i)).build();t.dispatch(a)}(this.context,t.blockId,t.offset,n):"display"===t.kind&&t.path&&function(t,e,n){const i=t.getState().transaction("command").setNodeAttr(e,ot(n)).build();t.dispatch(i)}(this.context,t.path,n)}open(t){this.close(!1);const e=document.createElement("div");e.className="notectl-formula-overlay",e.setAttribute("role","dialog"),e.setAttribute("aria-label","edit"===t.mode?this.locale.editFormula:this.locale.insertInline),this.panel=e,De(e,{context:this.context,locale:this.locale,mode:t.mode,initialLatex:t.initialLatex,initialAlt:t.initialAlt,initialDisplay:t.initialDisplay,initialFontSize:t.initialFontSize,fontSizes:this.fontSizes,onCommit:t.onCommit,onClose:()=>this.close(!0)}),this.context.getPluginContainer("top").appendChild(e),y(e),function(t,e){const n=e?e.bottom:window.innerHeight/3,i=e?e.left:window.innerWidth/3,a=t.offsetWidth||360,r=window.innerWidth-a-8,o=Math.max(8,Math.min(i,r)),l=window.innerHeight-t.offsetHeight-8,s=Math.min(n+8,Math.max(8,l));t.style.left=`${Math.round(o)}px`,t.style.top=`${Math.round(s)}px`}(e,t.rect),this.installOutsideHandler()}installOutsideHandler(){const t=t=>{this.panel&&!t.composedPath().includes(this.panel)&&this.close(!1)};this.outsideHandler=t,requestAnimationFrame(()=>{this.outsideHandler&&document.addEventListener("mousedown",t,!0)})}};function Pe(){const t=window.getSelection();if(!t||0===t.rangeCount)return null;const e=t.getRangeAt(0).getBoundingClientRect();return 0===e.width&&0===e.height&&0===e.top&&0===e.left?null:e}function Fe(t){const e=document.createElement("template");return e.innerHTML=t,e.content}function qe(t){const e=function(t){const e=h(t,{ALLOWED_TAGS:[...it],ALLOWED_ATTR:[...at]});return/<math[\s>]/i.test(e)?e:null}(t.outerHTML);if(!e)return null;const n=H(e);return{mathml:n,latex:M(n)??"",alt:"",fontSize:X(t)}}var Re=class{id="formula";name="Formula";priority=46;config;resolvedKeymap;fontSizes;locale=Ce;overlay=null;context=null;clickHandler=null;constructor(t){this.config={...nt,...t},this.resolvedKeymap={...tt,...t?.keymap},this.fontSizes=this.config.fontSizes??et}async init(t){var e;if(this.context=t,this.locale=await f(t,this.config.locale,Ce,Ae),t.registerStyleSheet(".notectl-math math{font-family:Notectl Math,math}.notectl-math--inline{vertical-align:middle;cursor:pointer;border-radius:3px;padding:0 1px;display:inline-block}.notectl-math--inline:hover{background:var(--notectl-highlight,#0000000f)}.notectl-math--inline:focus-visible{outline:2px solid var(--notectl-primary);outline-offset:1px}.notectl-math--inline math{font-size:1.15em}.notectl-math--display{text-align:center;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;margin:12px 0;display:block}.notectl-math--display math{font-size:1.35em;display:inline-block}.notectl-math--display.notectl-math--selected{outline:2px solid var(--notectl-primary);outline-offset:4px;border-radius:6px}.notectl-math__error,.notectl-math merror{color:var(--notectl-danger,#c0392b);background:var(--notectl-danger-bg,#c0392b1a);border-radius:3px;padding:0 2px}"),t.registerStyleSheet(".notectl-formula-editor{box-sizing:border-box;flex-direction:column;gap:8px;min-width:320px;max-width:460px;padding:10px;display:flex}.notectl-formula-editor__field{flex-direction:column;gap:4px;display:flex}.notectl-formula-editor__label{color:var(--notectl-fg-muted,#555);font-size:12px;font-weight:600}.notectl-formula-editor__input{box-sizing:border-box;resize:vertical;border:1px solid var(--notectl-border);background:var(--notectl-surface-overlay,#fff);width:100%;min-height:56px;color:var(--notectl-fg);border-radius:4px;padding:6px 8px;font-family:SF Mono,Fira Code,Menlo,Consolas,monospace;font-size:13px;line-height:1.5}.notectl-formula-editor__alt{box-sizing:border-box;border:1px solid var(--notectl-border);background:var(--notectl-surface-overlay,#fff);width:100%;color:var(--notectl-fg);border-radius:4px;padding:5px 8px;font-size:13px}.notectl-formula-editor__size{box-sizing:border-box;border:1px solid var(--notectl-border);background:var(--notectl-surface-overlay,#fff);color:var(--notectl-fg);cursor:pointer;border-radius:4px;padding:5px 8px;font-size:13px}.notectl-formula-editor__size:focus-visible{outline:2px solid var(--notectl-primary);outline-offset:1px}.notectl-formula-editor__preview{border:1px dashed var(--notectl-border);background:var(--notectl-surface-raised,#fafafa);text-align:center;border-radius:4px;min-height:44px;padding:8px;overflow-x:auto}.notectl-formula-editor__preview math{font-family:Notectl Math,math;font-size:1.3em}.notectl-formula-editor__preview-empty{color:var(--notectl-fg-muted,#888);font-size:13px}.notectl-formula-editor__errors{color:var(--notectl-danger,#c0392b);margin:0;padding-inline-start:16px;font-size:12px}.notectl-formula-editor__row{align-items:center;gap:8px;display:flex}.notectl-formula-editor__toggle{color:var(--notectl-fg);align-items:center;gap:6px;font-size:13px;display:flex}.notectl-formula-editor__actions{justify-content:flex-end;gap:8px;margin-top:2px;display:flex}.notectl-formula-editor__btn{border:1px solid var(--notectl-border);background:var(--notectl-surface-raised);color:var(--notectl-fg);cursor:pointer;border-radius:4px;padding:6px 14px;font-size:13px}.notectl-formula-editor__btn--primary{background:var(--notectl-primary);border-color:var(--notectl-primary);color:var(--notectl-primary-fg,#fff)}.notectl-formula-editor__btn:focus-visible{outline:2px solid var(--notectl-primary);outline-offset:2px}.notectl-formula-overlay{z-index:1000;border:1px solid var(--notectl-border);background:var(--notectl-surface-overlay,#fff);border-radius:8px;position:fixed;box-shadow:0 6px 24px #0000002e}.notectl-math-palette{border-bottom:1px solid var(--notectl-border);flex-wrap:wrap;gap:8px;max-height:216px;margin-bottom:2px;padding:2px 2px 8px;display:flex;overflow-y:auto}.notectl-math-palette__group{flex-wrap:wrap;gap:2px;display:flex}.notectl-math-palette__group+.notectl-math-palette__group{border-inline-start:1px solid var(--notectl-border);padding-inline-start:6px}.notectl-math-palette__btn{min-width:30px;height:30px;color:var(--notectl-fg);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:4px;padding:0 6px;font-size:15px;line-height:1}.notectl-math-palette__btn:hover{background:var(--notectl-surface-raised)}.notectl-math-palette__btn:focus-visible{outline:2px solid var(--notectl-primary);outline-offset:1px}"),this.config.mathFont&&t.registerStyleSheet(function(t){const e=(t.family.split(",")[0]??t.name).trim().replace(/['"]/g,"");return(t.fontFaces??[]).map(t=>{const n=[`font-family: '${e}'`,`src: ${t.src}`];return t.weight&&n.push(`font-weight: ${t.weight}`),t.style&&n.push(`font-style: ${t.style}`),n.push(`font-display: ${t.display??"swap"}`),`@font-face { ${n.join("; ")}; }`}).join("\n")}(this.config.mathFont)),t.registerInlineNodeSpec({type:Q,attrs:{mathml:{default:""},latex:{default:""},alt:{default:""},fontSize:{default:""}},toDOM(t){const e=document.createElement("span");return e.className="notectl-math notectl-math--inline",e.setAttribute("contenteditable","false"),e.setAttribute("data-inline-type",Q),K(e,V(t.attrs)),W(e,t.attrs),e},toHTMLString:t=>Z(V(t.attrs)),toMarkdown:t=>`$${String(t.attrs.latex??"")}$`,parseHTML:[{tag:"math",getAttrs:t=>J(t,!1)}],sanitize:{tags:[...it],attrs:[...at]}}),t.registerNodeSpec({type:Y,group:"block",isVoid:!0,selectable:!0,attrs:{mathml:{default:""},latex:{default:""},alt:{default:""},fontSize:{default:""}},toDOM(t){const e=v("div",t.id);return e.className="notectl-math notectl-math--display",e.setAttribute("data-void","true"),e.setAttribute("data-selectable","true"),K(e,V(t.attrs)),W(e,t.attrs),e},toHTML:t=>Z(V(t.attrs)),toMarkdown:t=>`$$\n${String(t.attrs?.latex??"")}\n$$`,parseHTML:[{tag:"math",getAttrs:t=>J(t,!0)}],sanitize:{tags:[...it],attrs:[...at]}}),this.overlay=new Ne(t,this.locale,this.fontSizes),t.registerNodeView(Y,(e={onEdit:(t,e)=>this.editDisplay(t,e),onSelect:()=>t.announce(this.locale.selected)},t=>{let n=t.id,i=!1;const a=v("div",t.id);return a.className="notectl-math notectl-math--display",a.setAttribute("data-void","true"),a.setAttribute("data-selectable","true"),K(a,V(t.attrs)),W(a,t.attrs),a.addEventListener("dblclick",t=>{t.preventDefault(),e.onEdit(n,a.getBoundingClientRect())}),{dom:a,contentDOM:null,update:t=>"math_display"===t.type&&(n=t.id,a.setAttribute("data-block-id",t.id),K(a,V(t.attrs)),W(a,t.attrs),!0),selectNode(){a.classList.add("notectl-math--selected"),i||(i=!0,e.onSelect())},deselectNode(){a.classList.remove("notectl-math--selected"),i=!1}}})),!1!==this.config.inputRule)for(const a of[{pattern:Le,handler(t,e){const n=t.selection;if(!l(n)||!r(n))return null;const a=(e[1]??"").trim();if(!a)return null;const o=n.anchor.blockId;if(!ke(t,o))return null;const c=Se(n.anchor.offset,e[0].length);if(!c)return null;const p=t.doc.children.findIndex(t=>t.id===o);if(-1===p)return null;const{presentation:d}=xe(a,{display:!0}),m=T({presentation:d,latex:a,display:!0}),h=t.transaction("input").deleteTextAt(o,c.from,c.to);return function(t,e,n){const a=i(u(Y),[],void 0,ot(n)),r=i(u("paragraph"));t.insertNode([],e,a).insertNode([],e+1,r).setSelection(s(a.id,[]))}(h,p+1,{mathml:m,latex:a,alt:"",fontSize:""}),h.build()}},{pattern:we,handler(t,e){const i=t.selection;if(!l(i)||!r(i))return null;const a=(e[1]??"").trim();if(!a)return null;const o=i.anchor.blockId;if(!ke(t,o))return null;const s=Se(i.anchor.offset,e[0].length);if(!s)return null;const{presentation:p}=xe(a,{display:!1}),u=T({presentation:p,latex:a,display:!1}),m=n(d(Q),{mathml:u,latex:a,alt:"",fontSize:""});return t.transaction("input").deleteTextAt(o,s.from,s.to).insertInlineNode(o,s.from,m).setSelection(c(o,s.from+1)).build()}}])t.registerInputRule(a);t.registerMarkdownSyntax({id:"formula",matchInline(t,e){if("$"!==t[e]||"$"===t[e+1])return null;const n=function(t,e){for(let n=e;n<t.length;n++){const e=t[n]??"";if("\n"===e)return-1;if("$"===e)return n}return-1}(t,e+1);if(-1===n)return null;const i=t.slice(e+1,n).trim();return""===i?null:{type:Q,attrs:{..._e(i,!1)},length:n-e+1}},matchBlock(t,e){const n=t[e]??"",i=n.match(ze);if(i?.[1]?.trim())return{type:Y,attrs:{..._e(i[1].trim(),!0)},linesConsumed:1};if("$$"!==n.trim())return null;const a=[];let r=e+1;for(;r<t.length&&"$$"!==(t[r]??"").trim();)a.push(t[r]??""),r++;if(r>=t.length)return null;const o=a.join("\n").trim();return{type:Y,attrs:{..._e(o,!0)},linesConsumed:r-e+1}}}),t.registerPasteInterceptor((t,e,n)=>{if(!function(t){if(!t)return!1;const e=Fe(t);if(!e.querySelector("math"))return!1;const n=e.cloneNode(!0);for(const i of Array.from(n.querySelectorAll('math, [aria-hidden="true"]')))i.remove();return""===(n.textContent??"").trim()}(e))return null;const i=function(t){if(!t)return[];const e=Fe(t);for(const n of Array.from(e.querySelectorAll('[aria-hidden="true"]')))n.remove();return Array.from(e.querySelectorAll("math"))}(e).map(qe).filter(t=>null!==t);return 0===i.length?null:i.every(t=>{return e=t.mathml,!/<math\b[^>]*\bdisplay=["']block["']/i.test(e);var e})?lt(n,i):st(n,i)},{name:"formula",priority:40}),this.registerCommands(t),this.registerKeymap(t),function(t,e,n){t.registerToolbarItem({id:"formula",group:"insert",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round"><path d="M18 5 H6 L12 12 L6 19 H18"/></svg>',label:e.insertInline,tooltip:e.insertInlineTooltip,command:"insertInlineFormula",popupType:"custom",renderPopup:(t,i,a)=>{De(t,{context:i,locale:e,mode:"insert",fontSizes:n,onClose:a,onCommit:t=>{pt(i,e,t),a(),i.getContainer().focus()}})}})}(t,this.locale,this.fontSizes),this.installClickToEdit(t)}destroy(){this.clickHandler&&this.context&&this.context.getContainer().removeEventListener("click",this.clickHandler),this.clickHandler=null,this.overlay?.close(!1),this.overlay=null,this.context=null}registerCommands(n){n.registerCommand("insertInlineFormula",()=>{const i=function(n){const i=n.selection;if(!l(i)||!r(i))return null;const o=i.anchor.blockId,s=n.getBlock(o);if(!s)return null;const c=i.anchor.offset;for(const{child:r,from:l,to:p}of t(e(s)))if(a(r)&&"math_inline"===r.inlineType&&(p===c||l===c)){const t=V(r.attrs);return{kind:"inline",blockId:o,offset:l,latex:t.latex,alt:t.alt,fontSize:t.fontSize,rect:null}}return null}(n.getState());return i?(this.overlay?.openEdit(i),!0):(this.overlay?.openInsert(!1),!0)}),n.registerCommand("insertDisplayFormula",()=>{const t=rt(n.getState());return t?(this.editDisplay(t,null),!0):(this.overlay?.openInsert(!0),!0)})}registerKeymap(t){const e={},n=this.resolvedKeymap.insertInline,i=this.resolvedKeymap.insertDisplay;n&&(e[n]=()=>t.executeCommand("insertInlineFormula")),i&&(e[i]=()=>t.executeCommand("insertDisplayFormula")),e.Enter=()=>{const e=rt(t.getState());return!!e&&(this.editDisplay(e,null),!0)},t.registerKeymap(e,{priority:"context"})}installClickToEdit(n){const i=n.getContainer(),r=r=>{if(n.isReadOnly())return;const o=r.target?.closest(".notectl-math--inline");if(!o)return;const l=function(n,i,r){const o=x(n,i,0);if(!o)return null;const l=function(n,i,r){const o=n.getBlock(i);if(!o)return null;for(const{child:l,from:s}of t(e(o)))if(s===r&&a(l)&&"math_inline"===l.inlineType)return V(l.attrs);return null}(r,o.blockId,o.offset);return l?{kind:"inline",blockId:o.blockId,offset:o.offset,latex:l.latex,alt:l.alt,fontSize:l.fontSize,rect:i.getBoundingClientRect()}:null}(i,o,n.getState());l&&(r.preventDefault(),this.overlay?.openEdit(l))};this.clickHandler=r,i.addEventListener("click",r)}editDisplay(t,e){if(!this.overlay||!this.context)return;const n=function(t,e,n){const i=t.getBlock(e);if(!i||"math_display"!==i.type)return null;const a=V(i.attrs);return{kind:"display",path:t.getNodePath(e)??[e],latex:a.latex,alt:a.alt,fontSize:a.fontSize,rect:n}}(this.context.getState(),t,e);n&&this.overlay.openEdit(n)}};export{at as a,T as c,xe as i,Ce as n,it as o,Ae as r,tt as s,Re as t};
|
|
2
|
+
//# sourceMappingURL=FormulaPlugin-20vW4Gge.mjs.map
|