@notectl/core 2.4.0 → 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/README.md +1 -1
- package/dist/chunks/AlignmentPlugin-C26pIVcw.mjs +2 -0
- package/dist/chunks/AlignmentPlugin-C26pIVcw.mjs.map +1 -0
- package/dist/chunks/AttrRegistry-Di936wMv.mjs.map +1 -1
- package/dist/chunks/AttributedMarkCommands-DKHuhZA7.mjs.map +1 -1
- package/dist/chunks/BidiIsolationPlugin-nWd1NEF-.mjs +2 -0
- package/dist/chunks/BidiIsolationPlugin-nWd1NEF-.mjs.map +1 -0
- package/dist/chunks/BlockAlignment-BqyBQ4uV.mjs.map +1 -1
- package/dist/chunks/BlockInsertion-CXfXqUZl.mjs +2 -0
- package/dist/chunks/BlockInsertion-CXfXqUZl.mjs.map +1 -0
- package/dist/chunks/BlockTypePickerRegistry-BTET9jM-.mjs.map +1 -1
- package/dist/chunks/BlockquotePlugin-Bag42Zc0.mjs +2 -0
- package/dist/chunks/BlockquotePlugin-Bag42Zc0.mjs.map +1 -0
- package/dist/chunks/CSSValueEquivalence-DeyUKPQ7.mjs.map +1 -1
- package/dist/chunks/CaretNavigationPlugin-DUAoHygg.mjs +2 -0
- package/dist/chunks/CaretNavigationPlugin-DUAoHygg.mjs.map +1 -0
- package/dist/chunks/CodeBlockPlugin-Dk_J8NAl.mjs +2 -0
- package/dist/chunks/CodeBlockPlugin-Dk_J8NAl.mjs.map +1 -0
- package/dist/chunks/ColorGrid-DAs0--ty.mjs.map +1 -1
- package/dist/chunks/ColorPickerPopup-B6340f3p.mjs.map +1 -1
- package/dist/chunks/ColorValidation-ZBKZ_gTr.mjs.map +1 -1
- package/dist/chunks/Commands-vqbwh6Ic.mjs +2 -0
- package/dist/chunks/Commands-vqbwh6Ic.mjs.map +1 -0
- package/dist/chunks/ContentModel-dkGOh3N7.mjs +2 -0
- package/dist/chunks/ContentModel-dkGOh3N7.mjs.map +1 -0
- package/dist/chunks/CursorMarks-CqHLzGNI.mjs.map +1 -1
- package/dist/chunks/Decoration-BoFcdSXk.mjs.map +1 -1
- package/dist/chunks/DirectionDetection-a-1iksmh.mjs.map +1 -1
- package/dist/chunks/DirectionIcons-Bbawl9ei.mjs.map +1 -1
- package/dist/chunks/Document-ssR6hBzG.mjs.map +1 -1
- package/dist/chunks/DocumentParser-D4g5npEi.mjs +2 -0
- package/dist/chunks/DocumentParser-D4g5npEi.mjs.map +1 -0
- package/dist/chunks/DomUtils-Bf7JLFlx.mjs.map +1 -1
- package/dist/chunks/EditorEventBoundary-zpYRxryo.mjs.map +1 -1
- 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-Bzlluh1_.mjs.map +1 -0
- package/dist/chunks/FontSizePlugin-kv3zHG0f.mjs +2 -0
- package/dist/chunks/FontSizePlugin-kv3zHG0f.mjs.map +1 -0
- package/dist/chunks/FormulaPlugin-20vW4Gge.mjs +2 -0
- package/dist/chunks/FormulaPlugin-20vW4Gge.mjs.map +1 -0
- package/dist/chunks/GapCursorPlugin-BPyNXY4H.mjs +2 -0
- package/dist/chunks/GapCursorPlugin-BPyNXY4H.mjs.map +1 -0
- package/dist/chunks/HTMLSanitization-BRipXyhI.mjs +2 -0
- package/dist/chunks/HTMLSanitization-BRipXyhI.mjs.map +1 -0
- package/dist/chunks/HTMLUtils-DTpsjZyK.mjs.map +1 -1
- package/dist/chunks/{HardBreakPlugin-svNnJ9Xj.mjs → HardBreakPlugin-lo8Mcg9G.mjs} +2 -2
- package/dist/chunks/HardBreakPlugin-lo8Mcg9G.mjs.map +1 -0
- package/dist/chunks/HeadingPlugin-CEZF5DBM.mjs +2 -0
- package/dist/chunks/HeadingPlugin-CEZF5DBM.mjs.map +1 -0
- package/dist/chunks/HighlightPlugin-yH44UWoe.mjs +2 -0
- package/dist/chunks/HighlightPlugin-yH44UWoe.mjs.map +1 -0
- package/dist/chunks/HorizontalRulePlugin-SNNum-9V.mjs +2 -0
- package/dist/chunks/HorizontalRulePlugin-SNNum-9V.mjs.map +1 -0
- package/dist/chunks/ImagePlugin-aeqHr5zx.mjs +2 -0
- package/dist/chunks/ImagePlugin-aeqHr5zx.mjs.map +1 -0
- package/dist/chunks/InlineCodePlugin-CIks06ti.mjs +2 -0
- package/dist/chunks/InlineCodePlugin-CIks06ti.mjs.map +1 -0
- package/dist/chunks/InlineStyleMarkSpec-BhfGgfH9.mjs.map +1 -1
- package/dist/chunks/KeyboardNav-D0my3wuy.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-ZNEx8pvk.mjs.map +1 -0
- package/dist/chunks/LocaleLoader-DEpTFuVc.mjs +2 -0
- package/dist/chunks/LocaleLoader-DEpTFuVc.mjs.map +1 -0
- package/dist/chunks/MarkCommands-C0ps9h0z.mjs.map +1 -1
- package/dist/chunks/MarkInputRule-DNneF2gp.mjs.map +1 -1
- package/dist/chunks/{MarkdownHTMLRegistry-BunUDiza.mjs → MarkdownHTMLRegistry-Cj7N2wqs.mjs} +2 -2
- package/dist/chunks/MarkdownHTMLRegistry-Cj7N2wqs.mjs.map +1 -0
- package/dist/chunks/{MarkdownParser-CvYOvU3d.mjs → MarkdownParser-JOfPSvGv.mjs} +2 -2
- package/dist/chunks/MarkdownParser-JOfPSvGv.mjs.map +1 -0
- package/dist/chunks/{MarkdownSerializer-CdUBWWGI.mjs → MarkdownSerializer-Y6saYClE.mjs} +2 -2
- package/dist/chunks/MarkdownSerializer-Y6saYClE.mjs.map +1 -0
- package/dist/chunks/MathFont-BS8IwYh2.mjs.map +1 -1
- package/dist/chunks/NavigationQueries-CaKfccu7.mjs.map +1 -1
- package/dist/chunks/NodeResolver-F4RtpoEd.mjs.map +1 -1
- package/dist/chunks/{NodeSelectionCommands-B0Sb4ux4.mjs → NodeSelectionCommands-CAqIHW_6.mjs} +2 -2
- package/dist/chunks/NodeSelectionCommands-CAqIHW_6.mjs.map +1 -0
- package/dist/chunks/NodeSpecPatching-BrjPAbqe.mjs.map +1 -1
- package/dist/chunks/Platform-ByobkiCc.mjs.map +1 -1
- package/dist/chunks/PopupKeyboardPatterns-BcwdDxRq.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-CYkdUy-m.mjs.map +1 -0
- package/dist/chunks/RangeIterator-sJ_c9MNr.mjs.map +1 -1
- package/dist/chunks/Schema-BSM4YLNT.mjs.map +1 -1
- package/dist/chunks/{SchemaRegistry-Cs7rxafF.mjs → SchemaRegistry-CT3T7S1i.mjs} +2 -2
- package/dist/chunks/SchemaRegistry-CT3T7S1i.mjs.map +1 -0
- package/dist/chunks/Selection-DC6AOGgF.mjs.map +1 -1
- package/dist/chunks/SelectionReplacement-Cj4FLlPz.mjs +2 -0
- package/dist/chunks/SelectionReplacement-Cj4FLlPz.mjs.map +1 -0
- package/dist/chunks/{SelectionSync-BkjCwGp-.mjs → SelectionSync-8y0nbBHZ.mjs} +2 -2
- package/dist/chunks/SelectionSync-8y0nbBHZ.mjs.map +1 -0
- package/dist/chunks/SelectionTransactions-mQ1NfMEg.mjs.map +1 -1
- package/dist/chunks/ShortcutFormatting-TwiufqeV.mjs.map +1 -1
- package/dist/chunks/SimpleMark-DPTsIl9w.mjs +2 -0
- package/dist/chunks/SimpleMark-DPTsIl9w.mjs.map +1 -0
- package/dist/chunks/SmartPastePlugin-BSMHDDQ2.mjs +2 -0
- package/dist/chunks/SmartPastePlugin-BSMHDDQ2.mjs.map +1 -0
- package/dist/chunks/StarterFonts-BDQPg-cu.mjs.map +1 -1
- package/dist/chunks/StrikethroughPlugin-CqqIF3Zk.mjs +2 -0
- package/dist/chunks/StrikethroughPlugin-CqqIF3Zk.mjs.map +1 -0
- package/dist/chunks/StyleClassNames-BsAx7k5T.mjs.map +1 -1
- package/dist/chunks/StyleRuntime-C0RSqKzG.mjs.map +1 -1
- package/dist/chunks/SuperSubPlugin-5ZFM6wdU.mjs +2 -0
- package/dist/chunks/SuperSubPlugin-5ZFM6wdU.mjs.map +1 -0
- package/dist/chunks/SyntaxTokenTypes-BUCOMtL8.mjs.map +1 -1
- package/dist/chunks/{TableDimensions-BSEOEox2.mjs → TableDimensions-B-OWjTuW.mjs} +2 -2
- package/dist/chunks/TableDimensions-B-OWjTuW.mjs.map +1 -0
- 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-Dwp7eW7F.mjs.map +1 -0
- package/dist/chunks/{TextDirectionAutoPlugin-DOH5cfyy.mjs → TextDirectionAutoPlugin-CkIETM5n.mjs} +2 -2
- package/dist/chunks/TextDirectionAutoPlugin-CkIETM5n.mjs.map +1 -0
- package/dist/chunks/TextDirectionPlugin-DAcPR5Qc.mjs +2 -0
- package/dist/chunks/TextDirectionPlugin-DAcPR5Qc.mjs.map +1 -0
- package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +2 -0
- package/dist/chunks/TextDirectionService-OFOU6r_s.mjs.map +1 -0
- package/dist/chunks/TextFormattingPlugin-vml-lduV.mjs +2 -0
- package/dist/chunks/TextFormattingPlugin-vml-lduV.mjs.map +1 -0
- package/dist/chunks/ThemeEngine-kIXtSRkI.mjs.map +1 -1
- package/dist/chunks/ToolbarPlugin-Cxmb0MFr.mjs +2 -0
- package/dist/chunks/ToolbarPlugin-Cxmb0MFr.mjs.map +1 -0
- package/dist/chunks/TypeBrands-Ch9856Gb.mjs.map +1 -1
- package/dist/chunks/TypedKeys-CA4bfw9O.mjs.map +1 -1
- package/dist/chunks/VideoPlugin-lZCBlIon.mjs +2 -0
- package/dist/chunks/VideoPlugin-lZCBlIon.mjs.map +1 -0
- package/dist/chunks/XmlPatterns-RN32-0ob.mjs.map +1 -1
- package/dist/chunks/XmlSupport-3Za6SIqF.mjs.map +1 -1
- package/dist/chunks/ar--Isa9OHJ.mjs.map +1 -1
- package/dist/chunks/ar--O0A9OTR.mjs.map +1 -1
- package/dist/chunks/ar-0g2bmXTn.mjs.map +1 -1
- package/dist/chunks/ar-4b8e2YSc.mjs.map +1 -1
- package/dist/chunks/ar-B03uY4xr.mjs.map +1 -1
- package/dist/chunks/ar-BAfInw85.mjs.map +1 -1
- package/dist/chunks/ar-BRX5E_Pw.mjs.map +1 -1
- package/dist/chunks/ar-BWOue6jG.mjs.map +1 -1
- package/dist/chunks/ar-Bdmunk5h.mjs.map +1 -1
- package/dist/chunks/ar-BwaoCUVN.mjs.map +1 -1
- package/dist/chunks/ar-BzqAYGER.mjs.map +1 -1
- package/dist/chunks/ar-C9lO1jsY.mjs.map +1 -1
- package/dist/chunks/ar-CMXjVzFx.mjs.map +1 -1
- package/dist/chunks/ar-CR6UdFL9.mjs.map +1 -1
- package/dist/chunks/ar-CrOb0jL2.mjs.map +1 -1
- package/dist/chunks/ar-Cy_77yRf.mjs.map +1 -1
- package/dist/chunks/ar-D1jFXqLJ.mjs.map +1 -1
- package/dist/chunks/ar-DahJwMI9.mjs.map +1 -1
- package/dist/chunks/ar-Dcl3kgtd.mjs.map +1 -1
- package/dist/chunks/ar-Dg9PdDet.mjs.map +1 -1
- package/dist/chunks/ar-Dp1oBWyG.mjs +2 -0
- package/dist/chunks/ar-Dp1oBWyG.mjs.map +1 -0
- package/dist/chunks/ar-Dx2lO0Nm.mjs.map +1 -1
- package/dist/chunks/ar-NV_puwI2.mjs.map +1 -1
- package/dist/chunks/ar-Uzo1Azdw.mjs.map +1 -1
- package/dist/chunks/ar-XmSFrtmd.mjs.map +1 -1
- package/dist/chunks/ar-eOA3UmiE.mjs.map +1 -1
- package/dist/chunks/ar-sGZ-oZqB.mjs.map +1 -1
- package/dist/chunks/color-picker-D6HrTsDM.mjs.map +1 -1
- package/dist/chunks/de-B8-w9gPi.mjs.map +1 -1
- package/dist/chunks/de-B9zSHWqY.mjs.map +1 -1
- package/dist/chunks/de-BX4y4PlH.mjs.map +1 -1
- package/dist/chunks/de-BXQBXxFJ.mjs.map +1 -1
- package/dist/chunks/de-BcPntcnr.mjs.map +1 -1
- package/dist/chunks/de-BdD3DpUB.mjs.map +1 -1
- package/dist/chunks/de-Bwxlcuee.mjs.map +1 -1
- package/dist/chunks/de-BxQIt_1Y.mjs.map +1 -1
- package/dist/chunks/de-C-Yf378-.mjs.map +1 -1
- package/dist/chunks/de-C7uehgMu.mjs.map +1 -1
- package/dist/chunks/de-C9ZhDqPi.mjs.map +1 -1
- package/dist/chunks/de-CHcv_Vmf.mjs.map +1 -1
- package/dist/chunks/de-CTzAMkXC.mjs.map +1 -1
- package/dist/chunks/de-CaeEIyzV.mjs.map +1 -1
- package/dist/chunks/de-D3J8XPCR.mjs +2 -0
- package/dist/chunks/de-D3J8XPCR.mjs.map +1 -0
- package/dist/chunks/de-DHs9i4af.mjs.map +1 -1
- package/dist/chunks/de-DJ5EkXQo.mjs.map +1 -1
- package/dist/chunks/de-DRbhnS4T.mjs.map +1 -1
- package/dist/chunks/de-DViI26lG.mjs.map +1 -1
- package/dist/chunks/de-DY3obIAF.mjs.map +1 -1
- package/dist/chunks/de-DcMhfRBu.mjs.map +1 -1
- package/dist/chunks/de-DiPz7abS.mjs.map +1 -1
- package/dist/chunks/de-Dl4QFHMa.mjs.map +1 -1
- package/dist/chunks/de-XCCpWyg0.mjs.map +1 -1
- package/dist/chunks/de-e6J6nvAD.mjs.map +1 -1
- package/dist/chunks/de-i95F9SDy.mjs.map +1 -1
- package/dist/chunks/de-uKR7koQe.mjs.map +1 -1
- package/dist/chunks/es-B0Za939C.mjs.map +1 -1
- package/dist/chunks/es-B8K3Yvf3.mjs.map +1 -1
- package/dist/chunks/es-BIXm2Coj.mjs.map +1 -1
- package/dist/chunks/es-BJHF95J_.mjs.map +1 -1
- package/dist/chunks/es-BMm9kqjC.mjs.map +1 -1
- package/dist/chunks/es-BQ9dox_E.mjs.map +1 -1
- package/dist/chunks/es-BQweZX6P.mjs.map +1 -1
- package/dist/chunks/es-Bbz885DZ.mjs +2 -0
- package/dist/chunks/es-Bbz885DZ.mjs.map +1 -0
- package/dist/chunks/es-BdpTTRuX.mjs.map +1 -1
- package/dist/chunks/es-C7uVqFYr.mjs.map +1 -1
- package/dist/chunks/es-CCQFu1t1.mjs.map +1 -1
- package/dist/chunks/es-CEAJj7aB.mjs.map +1 -1
- package/dist/chunks/es-CUKJujcb.mjs.map +1 -1
- package/dist/chunks/es-CXuMz87y.mjs.map +1 -1
- package/dist/chunks/es-CgMfhkJJ.mjs.map +1 -1
- package/dist/chunks/es-CtOtKQCP.mjs.map +1 -1
- package/dist/chunks/es-DD01rZ6N.mjs.map +1 -1
- package/dist/chunks/es-DDoqchUq.mjs.map +1 -1
- package/dist/chunks/es-DFokqQst.mjs.map +1 -1
- package/dist/chunks/es-DHxdoEzR.mjs.map +1 -1
- package/dist/chunks/es-DehVGwQ8.mjs.map +1 -1
- package/dist/chunks/es-DrJyl38L.mjs.map +1 -1
- package/dist/chunks/es-fTW0TkYV.mjs.map +1 -1
- package/dist/chunks/es-kfKiqpyD.mjs.map +1 -1
- package/dist/chunks/es-nRLq7bgP.mjs.map +1 -1
- package/dist/chunks/es-paXY7HFt.mjs.map +1 -1
- package/dist/chunks/es-xuahrvJN.mjs.map +1 -1
- package/dist/chunks/fr-0qEo3bRP.mjs.map +1 -1
- package/dist/chunks/fr-5HkMazAf.mjs.map +1 -1
- package/dist/chunks/fr-B9pBLaVx.mjs.map +1 -1
- package/dist/chunks/fr-BRXUnq3R.mjs.map +1 -1
- package/dist/chunks/fr-BSUKEtTk.mjs.map +1 -1
- package/dist/chunks/fr-BeRlON1t.mjs.map +1 -1
- package/dist/chunks/fr-Bg937iAy.mjs.map +1 -1
- package/dist/chunks/fr-BwWrFThE.mjs.map +1 -1
- package/dist/chunks/fr-C3EKRThN.mjs.map +1 -1
- package/dist/chunks/fr-CKjH6tJI.mjs.map +1 -1
- package/dist/chunks/fr-CQs0-pNX.mjs.map +1 -1
- package/dist/chunks/fr-CfhyYN-t.mjs.map +1 -1
- package/dist/chunks/fr-D0MDdoir.mjs.map +1 -1
- package/dist/chunks/fr-D5ulA3Z6.mjs.map +1 -1
- package/dist/chunks/fr-DEZ_oxzS.mjs.map +1 -1
- package/dist/chunks/fr-DciSEykY.mjs.map +1 -1
- package/dist/chunks/fr-DhWQzZy3.mjs.map +1 -1
- package/dist/chunks/fr-DiDhVhyV.mjs.map +1 -1
- package/dist/chunks/fr-DjMZ-3K5.mjs.map +1 -1
- package/dist/chunks/fr-F2ZrfVaF.mjs.map +1 -1
- package/dist/chunks/fr-GEgM1j3w.mjs +2 -0
- package/dist/chunks/fr-GEgM1j3w.mjs.map +1 -0
- package/dist/chunks/fr-KXmbys88.mjs.map +1 -1
- package/dist/chunks/fr-NVOinLyF.mjs.map +1 -1
- package/dist/chunks/fr-SbpHNrQ-.mjs.map +1 -1
- package/dist/chunks/fr-ZsRdLuys.mjs.map +1 -1
- package/dist/chunks/fr-eC0UdAPu.mjs.map +1 -1
- package/dist/chunks/fr-fshsDD66.mjs.map +1 -1
- package/dist/chunks/full-wDTdOuGt.mjs +2 -0
- package/dist/chunks/full-wDTdOuGt.mjs.map +1 -0
- package/dist/chunks/hi-4CiAKVjT.mjs.map +1 -1
- package/dist/chunks/hi-B-ZuX4aN.mjs.map +1 -1
- package/dist/chunks/hi-B2YB3Bo4.mjs.map +1 -1
- package/dist/chunks/hi-B2uhiPCN.mjs.map +1 -1
- package/dist/chunks/hi-B5cl8TWK.mjs.map +1 -1
- package/dist/chunks/hi-BNJIGWQQ.mjs.map +1 -1
- package/dist/chunks/hi-BOMkDPqC.mjs.map +1 -1
- package/dist/chunks/hi-Bl-yeeOI.mjs.map +1 -1
- package/dist/chunks/hi-BsZzSMfL.mjs.map +1 -1
- package/dist/chunks/hi-By8YwVIX.mjs.map +1 -1
- package/dist/chunks/hi-BzbMD_cP.mjs.map +1 -1
- package/dist/chunks/hi-C2jEsf8v.mjs.map +1 -1
- package/dist/chunks/hi-CKg8i4Mm.mjs +2 -0
- package/dist/chunks/hi-CKg8i4Mm.mjs.map +1 -0
- package/dist/chunks/hi-CTWubxLY.mjs.map +1 -1
- package/dist/chunks/hi-CoclKAUM.mjs.map +1 -1
- package/dist/chunks/hi-CrmakMVj.mjs.map +1 -1
- package/dist/chunks/hi-DWX6k5ZD.mjs.map +1 -1
- package/dist/chunks/hi-DY55FuDK.mjs.map +1 -1
- package/dist/chunks/hi-DrC2H81d.mjs.map +1 -1
- package/dist/chunks/hi-DsdXcOB6.mjs.map +1 -1
- package/dist/chunks/hi-Dt89SxNy.mjs.map +1 -1
- package/dist/chunks/hi-J8ErB5nB.mjs.map +1 -1
- package/dist/chunks/hi-L6pJxZam.mjs.map +1 -1
- package/dist/chunks/hi-SECtQQzq.mjs.map +1 -1
- package/dist/chunks/hi-j3TDLMYd.mjs.map +1 -1
- package/dist/chunks/hi-l6DA-aOw.mjs.map +1 -1
- package/dist/chunks/hi-uACJUw53.mjs.map +1 -1
- package/dist/chunks/minimal-FfmHwMGU.mjs +2 -0
- package/dist/chunks/minimal-FfmHwMGU.mjs.map +1 -0
- 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-5VeuNDd2.mjs.map +1 -1
- package/dist/chunks/pt-BCXgUDiU.mjs.map +1 -1
- package/dist/chunks/pt-BDam9cDu.mjs.map +1 -1
- package/dist/chunks/pt-Bb908r0n.mjs.map +1 -1
- package/dist/chunks/pt-BkpVtod-.mjs.map +1 -1
- package/dist/chunks/pt-BlFAJZo7.mjs.map +1 -1
- package/dist/chunks/pt-Bu7Mbz67.mjs.map +1 -1
- package/dist/chunks/pt-BuZ7acHF.mjs.map +1 -1
- package/dist/chunks/pt-C8sOyw0V.mjs.map +1 -1
- package/dist/chunks/pt-CEUgbrii.mjs.map +1 -1
- package/dist/chunks/pt-CFrcl1v_.mjs.map +1 -1
- package/dist/chunks/pt-CMrFpUWS.mjs.map +1 -1
- package/dist/chunks/pt-CMx2wPPY.mjs.map +1 -1
- package/dist/chunks/pt-CR4j8gtE.mjs.map +1 -1
- package/dist/chunks/pt-Cc4zysaT.mjs.map +1 -1
- package/dist/chunks/pt-Cv6q7x5x.mjs.map +1 -1
- package/dist/chunks/pt-DFKJVh7k.mjs.map +1 -1
- package/dist/chunks/pt-DP5c76Vo.mjs +2 -0
- package/dist/chunks/pt-DP5c76Vo.mjs.map +1 -0
- package/dist/chunks/pt-DYMyMgKQ.mjs.map +1 -1
- package/dist/chunks/pt-D__tcM2T.mjs.map +1 -1
- package/dist/chunks/pt-Dg2ctkug.mjs.map +1 -1
- package/dist/chunks/pt-DgfMoLWR.mjs.map +1 -1
- package/dist/chunks/pt-OXa_IR4Q.mjs.map +1 -1
- package/dist/chunks/pt-UPF7DBlz.mjs.map +1 -1
- package/dist/chunks/pt-_qxIe7zX.mjs.map +1 -1
- package/dist/chunks/pt-paXY7HFt.mjs.map +1 -1
- package/dist/chunks/pt-zMHcNGPk.mjs.map +1 -1
- 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/ru-B1m8J9dl.mjs.map +1 -1
- package/dist/chunks/ru-BNPUT-3S.mjs.map +1 -1
- package/dist/chunks/ru-BotG0MFT.mjs.map +1 -1
- package/dist/chunks/ru-C-APN_dm.mjs.map +1 -1
- package/dist/chunks/ru-C9yFslEG.mjs.map +1 -1
- package/dist/chunks/ru-CkG_bpfo.mjs.map +1 -1
- package/dist/chunks/ru-Cs8KCNyq.mjs.map +1 -1
- package/dist/chunks/ru-CsP6mLxp.mjs.map +1 -1
- package/dist/chunks/ru-CvDl-yEd.mjs.map +1 -1
- package/dist/chunks/ru-CwyPz2Va.mjs.map +1 -1
- package/dist/chunks/ru-D53d-_UB.mjs.map +1 -1
- package/dist/chunks/ru-DJMpeuey.mjs.map +1 -1
- package/dist/chunks/ru-DSRv3_Rg.mjs.map +1 -1
- package/dist/chunks/ru-DV-lgEtM.mjs.map +1 -1
- package/dist/chunks/ru-DiwQV30V.mjs.map +1 -1
- package/dist/chunks/ru-DkW9XZFy.mjs.map +1 -1
- package/dist/chunks/ru-DyCTlhjg.mjs.map +1 -1
- package/dist/chunks/ru-QGX8lOTs.mjs.map +1 -1
- package/dist/chunks/ru-QcTo2yoL.mjs.map +1 -1
- package/dist/chunks/ru-Y11wuxOB.mjs.map +1 -1
- package/dist/chunks/ru-Yngw7nFP.mjs.map +1 -1
- package/dist/chunks/ru-d68SZpEe.mjs.map +1 -1
- package/dist/chunks/ru-gxbzqLL8.mjs.map +1 -1
- package/dist/chunks/ru-k7o3Qks3.mjs.map +1 -1
- package/dist/chunks/ru-l73diFXn.mjs.map +1 -1
- package/dist/chunks/ru-q8kz-237.mjs.map +1 -1
- package/dist/chunks/src-DDkRstYh.mjs +2 -0
- package/dist/chunks/src-DDkRstYh.mjs.map +1 -0
- package/dist/chunks/xml-BsV44TrJ.mjs.map +1 -1
- package/dist/chunks/zh-BFZOM3lF.mjs.map +1 -1
- package/dist/chunks/zh-BGYJXxVl.mjs.map +1 -1
- package/dist/chunks/zh-BP97XjlS.mjs.map +1 -1
- package/dist/chunks/zh-BQ73oqxc.mjs.map +1 -1
- package/dist/chunks/zh-BQqf3wJZ.mjs.map +1 -1
- package/dist/chunks/zh-Baxh6v0j.mjs.map +1 -1
- package/dist/chunks/zh-BvuAbM2S.mjs.map +1 -1
- package/dist/chunks/zh-C-wHnDo5.mjs.map +1 -1
- package/dist/chunks/zh-C7iCgCRP.mjs.map +1 -1
- package/dist/chunks/zh-CRsDvfPR.mjs.map +1 -1
- package/dist/chunks/zh-CWGAPVei.mjs.map +1 -1
- package/dist/chunks/zh-CWIzJcXi.mjs.map +1 -1
- package/dist/chunks/zh-CYV-db-K.mjs.map +1 -1
- package/dist/chunks/zh-CiIyOm6U.mjs.map +1 -1
- package/dist/chunks/zh-CnW44JEw.mjs.map +1 -1
- package/dist/chunks/zh-D1HSmSOf.mjs.map +1 -1
- package/dist/chunks/zh-DUS7JduA.mjs +2 -0
- package/dist/chunks/zh-DUS7JduA.mjs.map +1 -0
- package/dist/chunks/zh-DWN1Jqn3.mjs.map +1 -1
- package/dist/chunks/zh-DYD476c5.mjs.map +1 -1
- package/dist/chunks/zh-DdzgYD7k.mjs.map +1 -1
- package/dist/chunks/zh-DgSmvLyw.mjs.map +1 -1
- package/dist/chunks/zh-DlVfQn4z.mjs.map +1 -1
- package/dist/chunks/zh-Oj-qSUEp.mjs.map +1 -1
- package/dist/chunks/zh-YfuE_m2y.mjs.map +1 -1
- package/dist/chunks/zh-dGSDBBzb.mjs.map +1 -1
- package/dist/chunks/zh-ikm3rSTR.mjs.map +1 -1
- package/dist/chunks/zh-oZl1P_p0.mjs.map +1 -1
- package/dist/commands/BlockInsertion.d.ts +15 -19
- package/dist/commands/BlockInsertion.d.ts.map +1 -1
- 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/commands/PasteCommand.d.ts.map +1 -1
- package/dist/commands/SelectionDeletion.d.ts +7 -5
- package/dist/commands/SelectionDeletion.d.ts.map +1 -1
- package/dist/commands/SelectionReplacement.d.ts +42 -0
- package/dist/commands/SelectionReplacement.d.ts.map +1 -0
- package/dist/editor/BlockIdentity.d.ts +16 -0
- package/dist/editor/BlockIdentity.d.ts.map +1 -0
- package/dist/editor/ContentSerializer.d.ts +13 -11
- package/dist/editor/ContentSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +6 -5
- package/dist/editor/NotectlEditor.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 +3 -0
- package/dist/editor/styles/link.d.ts.map +1 -0
- package/dist/fonts/math.mjs +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/index.d.ts +1 -1
- package/dist/index.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/input/PasteHandler.d.ts.map +1 -1
- package/dist/input/PasteRichBlockHandler.d.ts +10 -17
- package/dist/input/PasteRichBlockHandler.d.ts.map +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/model/ContentModel.d.ts +6 -1
- package/dist/model/ContentModel.d.ts.map +1 -1
- package/dist/model/FileHandlerDispatcher.d.ts +3 -1
- package/dist/model/FileHandlerDispatcher.d.ts.map +1 -1
- package/dist/model/FileHandlerRegistry.d.ts +11 -2
- package/dist/model/FileHandlerRegistry.d.ts.map +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/CodeBlockSchema.d.ts.map +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/FormulaCommands.d.ts +6 -4
- package/dist/plugins/formula/FormulaCommands.d.ts.map +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/ImageCommands.d.ts +15 -3
- package/dist/plugins/image/ImageCommands.d.ts.map +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +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/LinkBubble.d.ts +31 -0
- 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 +40 -0
- package/dist/plugins/link/LinkInteractionController.d.ts.map +1 -0
- package/dist/plugins/link/LinkLocale.d.ts +10 -1
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -1
- package/dist/plugins/link/LinkNavigation.d.ts +12 -0
- package/dist/plugins/link/LinkNavigation.d.ts.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +4 -5
- 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 +20 -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/SmartPastePlugin.d.ts +0 -1
- package/dist/plugins/smart-paste/SmartPastePlugin.d.ts.map +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/History.d.ts.map +1 -1
- package/dist/state/RangeMapping.d.ts +10 -0
- package/dist/state/RangeMapping.d.ts.map +1 -0
- package/dist/state/StepApplication.d.ts.map +1 -1
- package/dist/state/Steps.d.ts +3 -0
- package/dist/state/Steps.d.ts.map +1 -1
- package/dist/state/StructuralPositions.d.ts +15 -0
- package/dist/state/StructuralPositions.d.ts.map +1 -0
- package/dist/state/TransactionBuilder.d.ts +6 -14
- package/dist/state/TransactionBuilder.d.ts.map +1 -1
- package/dist/test/TestUtils.d.ts.map +1 -1
- 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/EditorViewEvents.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 +12 -8
- package/dist/chunks/AlignmentPlugin-Cp7HYGaH.mjs +0 -2
- package/dist/chunks/AlignmentPlugin-Cp7HYGaH.mjs.map +0 -1
- package/dist/chunks/BidiIsolationPlugin-GWukKdgJ.mjs +0 -2
- package/dist/chunks/BidiIsolationPlugin-GWukKdgJ.mjs.map +0 -1
- package/dist/chunks/BlockInsertion-CxKdCKJd.mjs +0 -2
- package/dist/chunks/BlockInsertion-CxKdCKJd.mjs.map +0 -1
- package/dist/chunks/BlockquotePlugin-CSL_7Yit.mjs +0 -2
- package/dist/chunks/BlockquotePlugin-CSL_7Yit.mjs.map +0 -1
- package/dist/chunks/CaretNavigationPlugin-BxWjR7SN.mjs +0 -2
- package/dist/chunks/CaretNavigationPlugin-BxWjR7SN.mjs.map +0 -1
- package/dist/chunks/CodeBlockPlugin-BIrkK4ER.mjs +0 -2
- package/dist/chunks/CodeBlockPlugin-BIrkK4ER.mjs.map +0 -1
- package/dist/chunks/Commands-DBBCAYBn.mjs +0 -2
- package/dist/chunks/Commands-DBBCAYBn.mjs.map +0 -1
- package/dist/chunks/ContentModel-BLC3Tez8.mjs +0 -2
- package/dist/chunks/ContentModel-BLC3Tez8.mjs.map +0 -1
- package/dist/chunks/DocumentParser-BKUrtgw1.mjs +0 -2
- package/dist/chunks/DocumentParser-BKUrtgw1.mjs.map +0 -1
- package/dist/chunks/FontPlugin-BcXNFqqO.mjs +0 -2
- package/dist/chunks/FontPlugin-BcXNFqqO.mjs.map +0 -1
- package/dist/chunks/FontSizePlugin-BQ9Aj8cT.mjs +0 -2
- package/dist/chunks/FontSizePlugin-BQ9Aj8cT.mjs.map +0 -1
- package/dist/chunks/FormulaPlugin-Bw_sO_lq.mjs +0 -2
- package/dist/chunks/FormulaPlugin-Bw_sO_lq.mjs.map +0 -1
- package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs +0 -2
- package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs.map +0 -1
- package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs +0 -2
- package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs.map +0 -1
- package/dist/chunks/HardBreakPlugin-svNnJ9Xj.mjs.map +0 -1
- package/dist/chunks/HeadingPlugin-B7EfynaH.mjs +0 -2
- package/dist/chunks/HeadingPlugin-B7EfynaH.mjs.map +0 -1
- package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs +0 -2
- package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs.map +0 -1
- package/dist/chunks/HorizontalRulePlugin-CQ5NT2Mo.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-CQ5NT2Mo.mjs.map +0 -1
- package/dist/chunks/ImagePlugin-BzLvPXGo.mjs +0 -2
- package/dist/chunks/ImagePlugin-BzLvPXGo.mjs.map +0 -1
- package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs +0 -2
- package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs.map +0 -1
- package/dist/chunks/LinkPlugin-BuzrXo2c.mjs +0 -2
- package/dist/chunks/LinkPlugin-BuzrXo2c.mjs.map +0 -1
- package/dist/chunks/ListPlugin-DTgpvBEt.mjs +0 -2
- package/dist/chunks/ListPlugin-DTgpvBEt.mjs.map +0 -1
- package/dist/chunks/MarkdownHTMLRegistry-BunUDiza.mjs.map +0 -1
- package/dist/chunks/MarkdownParser-CvYOvU3d.mjs.map +0 -1
- package/dist/chunks/MarkdownSerializer-CdUBWWGI.mjs.map +0 -1
- package/dist/chunks/NodeSelectionCommands-B0Sb4ux4.mjs.map +0 -1
- package/dist/chunks/PluginHelpers-B3gk3VB3.mjs +0 -2
- package/dist/chunks/PluginHelpers-B3gk3VB3.mjs.map +0 -1
- package/dist/chunks/PopupManager-Jz5JrUdC.mjs +0 -2
- package/dist/chunks/PopupManager-Jz5JrUdC.mjs.map +0 -1
- package/dist/chunks/PrintPlugin-BxNlFk2c.mjs +0 -2
- package/dist/chunks/PrintPlugin-BxNlFk2c.mjs.map +0 -1
- package/dist/chunks/SchemaRegistry-Cs7rxafF.mjs.map +0 -1
- package/dist/chunks/SelectionSync-BkjCwGp-.mjs.map +0 -1
- package/dist/chunks/SimpleMark-D6vz3Nfd.mjs +0 -2
- package/dist/chunks/SimpleMark-D6vz3Nfd.mjs.map +0 -1
- package/dist/chunks/SmartPastePlugin-C3SVKkWK.mjs +0 -2
- package/dist/chunks/SmartPastePlugin-C3SVKkWK.mjs.map +0 -1
- package/dist/chunks/StrikethroughPlugin-v-VJZzUZ.mjs +0 -2
- package/dist/chunks/StrikethroughPlugin-v-VJZzUZ.mjs.map +0 -1
- package/dist/chunks/SuperSubPlugin-x1iPnZyt.mjs +0 -2
- package/dist/chunks/SuperSubPlugin-x1iPnZyt.mjs.map +0 -1
- package/dist/chunks/TableDimensions-BSEOEox2.mjs.map +0 -1
- package/dist/chunks/TablePlugin-WPwp902E.mjs +0 -2
- package/dist/chunks/TablePlugin-WPwp902E.mjs.map +0 -1
- package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs +0 -2
- package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs.map +0 -1
- package/dist/chunks/TextDirectionAutoPlugin-DOH5cfyy.mjs.map +0 -1
- package/dist/chunks/TextDirectionPlugin-JwlR-R-b.mjs +0 -2
- package/dist/chunks/TextDirectionPlugin-JwlR-R-b.mjs.map +0 -1
- package/dist/chunks/TextDirectionService-BcX07mw2.mjs +0 -2
- package/dist/chunks/TextDirectionService-BcX07mw2.mjs.map +0 -1
- package/dist/chunks/TextFormattingPlugin-Kc_UNoOz.mjs +0 -2
- package/dist/chunks/TextFormattingPlugin-Kc_UNoOz.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-DmVI7MN9.mjs +0 -2
- package/dist/chunks/ToolbarPlugin-DmVI7MN9.mjs.map +0 -1
- package/dist/chunks/VideoPlugin-D3zGQ6QV.mjs +0 -2
- package/dist/chunks/VideoPlugin-D3zGQ6QV.mjs.map +0 -1
- package/dist/chunks/ar-Ctrv6cIi.mjs +0 -2
- package/dist/chunks/ar-Ctrv6cIi.mjs.map +0 -1
- package/dist/chunks/de-JhGflzS5.mjs +0 -2
- package/dist/chunks/de-JhGflzS5.mjs.map +0 -1
- package/dist/chunks/es-Bv7bDbMp.mjs +0 -2
- package/dist/chunks/es-Bv7bDbMp.mjs.map +0 -1
- package/dist/chunks/fr-DtzIu6tU.mjs +0 -2
- package/dist/chunks/fr-DtzIu6tU.mjs.map +0 -1
- package/dist/chunks/full-BiQ93ERr.mjs +0 -2
- package/dist/chunks/full-BiQ93ERr.mjs.map +0 -1
- package/dist/chunks/hi-Bu799xIO.mjs +0 -2
- package/dist/chunks/hi-Bu799xIO.mjs.map +0 -1
- package/dist/chunks/minimal-DO7LiFTa.mjs +0 -2
- package/dist/chunks/minimal-DO7LiFTa.mjs.map +0 -1
- package/dist/chunks/pt-DmN9u3NX.mjs +0 -2
- package/dist/chunks/pt-DmN9u3NX.mjs.map +0 -1
- package/dist/chunks/register-Cb1YTAN4.mjs +0 -3
- package/dist/chunks/register-Cb1YTAN4.mjs.map +0 -1
- package/dist/chunks/ru-BxySx7an.mjs +0 -2
- package/dist/chunks/ru-BxySx7an.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-DuucmOns.mjs +0 -2
- package/dist/chunks/zh-DuucmOns.mjs.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{B as t,P as n,R as e,_ as o,p as r}from"./Document-ssR6hBzG.mjs";import{a as s}from"./TypeBrands-Ch9856Gb.mjs";function c(t,n,e){const o=t.getNodeSpec(n);if(!o?.content)return!0;const r=t.getNodeSpec(e)?.group;for(const s of o.content.allow){if(s===e)return!0;if("text"!==s&&r&&s===r)return!0}return!1}function i(t,n,e){const o=t.getNodeSpec(n);if(!o?.content)return!0;const{min:r=0,max:s=Number.POSITIVE_INFINITY}=o.content,i=e.filter(t=>"text"!==t);if(i.length<r||i.length>s)return!1;for(const f of i)if(!c(t,n,f))return!1;return!0}function f(t,n){const e=[];let o=!1;for(const r of t.children){const{node:t,hoisted:s}=u(r,n);(t!==r||s.length>0)&&(o=!0),e.push(t,...s)}return o?{children:e}:t}function u(i,f){if(t(i))return{node:i,hoisted:[]};const d=[],p=[];let a=!1;const h=t=>{c(f,i.type,t.type)?d.push(t):(p.push(t),a=!0)};for(const t of i.children){if(!e(t)){d.push(t);continue}const n=u(t,f);n.node!==t&&(a=!0),h(n.node);for(const t of n.hoisted)h(t)}if(!a)return{node:i,hoisted:[]};const l=function(t,c,i){const f=(i.getNodeSpec(t.type)?.content?.allow)?.includes("text")??!1;if(0===c.length)return f?[o("")]:[r(s("paragraph"),[o("")])];const u=1===c.length?c[0]:void 0;if(f&&u&&e(u)&&"paragraph"===u.type&&!u.attrs&&!u.htmlId){const t=n(u);return t.length>0?[...t]:[o("")]}return c}(i,d,f);return{node:r(i.type,l,i.id,i.attrs,i.htmlId),hoisted:p}}export{f as n,i as r,c as t};
|
|
2
|
-
//# sourceMappingURL=ContentModel-BLC3Tez8.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentModel-BLC3Tez8.mjs","names":[],"sources":["../../src/model/ContentModel.ts"],"sourcesContent":["/**\n * Content model validation for nested document structures.\n * Validates whether a parent node type can contain given child types.\n */\n\nimport type { BlockNode, ChildNode, Document } from './Document.js';\nimport {\n\tcreateBlockNode,\n\tcreateTextNode,\n\tgetInlineChildren,\n\tisBlockNode,\n\tisLeafBlock,\n} from './Document.js';\nimport type { SchemaRegistry } from './SchemaRegistry.js';\nimport { nodeType } from './TypeBrands.js';\n\n/**\n * Checks if a parent node type can contain a child node type,\n * using the content rules and group system from NodeSpec.\n */\nexport function canContain(\n\tregistry: SchemaRegistry,\n\tparentType: string,\n\tchildType: string,\n): boolean {\n\tconst parentSpec = registry.getNodeSpec(parentType);\n\tif (!parentSpec?.content) return true; // No content rule = anything allowed\n\n\tconst childSpec = registry.getNodeSpec(childType);\n\tconst childGroup = childSpec?.group;\n\n\tfor (const allowed of parentSpec.content.allow) {\n\t\tif (allowed === childType) return true;\n\t\tif (allowed === 'text') continue; // 'text' refers to TextNodes, not BlockNodes\n\t\tif (childGroup && allowed === childGroup) return true;\n\t}\n\n\treturn false;\n}\n\n/**\n * Validates whether the given children types are valid for a parent node type.\n * Checks allow list, min/max constraints.\n */\nexport function validateContent(\n\tregistry: SchemaRegistry,\n\tparentType: string,\n\tchildTypes: readonly string[],\n): boolean {\n\tconst parentSpec = registry.getNodeSpec(parentType);\n\tif (!parentSpec?.content) return true;\n\n\tconst { min = 0, max = Number.POSITIVE_INFINITY } = parentSpec.content;\n\n\t// Check count constraints (only for block children, not text)\n\tconst blockChildTypes = childTypes.filter((t) => t !== 'text');\n\tif (blockChildTypes.length < min || blockChildTypes.length > max) return false;\n\n\t// Check each child is allowed\n\tfor (const childType of blockChildTypes) {\n\t\tif (!canContain(registry, parentType, childType)) return false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Repairs a parsed document so no container holds a block its content rule\n * forbids. A disallowed block (e.g. a `table` a Markdown/HTML importer nested\n * under a `list_item`, whose flat-with-indent model cannot hold it, #194)\n * bubbles up to the nearest ancestor that allows it, and to the document root\n * otherwise — the root imposes no content rule, so relocation is always\n * lossless. Order is preserved: a hoisted block lands immediately after the\n * subtree it escaped from. Runs only with a registry; identity is preserved when\n * nothing moves so callers can skip needless work.\n */\nexport function hoistDisallowedBlocks(doc: Document, registry: SchemaRegistry): Document {\n\tconst children: BlockNode[] = [];\n\tlet changed = false;\n\tfor (const block of doc.children) {\n\t\tconst { node, hoisted } = repairContainer(block, registry);\n\t\tif (node !== block || hoisted.length > 0) changed = true;\n\t\tchildren.push(node, ...hoisted);\n\t}\n\treturn changed ? { children } : doc;\n}\n\n/**\n * Repairs one block's subtree, returning the repaired node and any descendant\n * blocks that could not be placed within it (to be hoisted by the caller).\n */\nfunction repairContainer(\n\tblock: BlockNode,\n\tregistry: SchemaRegistry,\n): { readonly node: BlockNode; readonly hoisted: readonly BlockNode[] } {\n\tif (isLeafBlock(block)) return { node: block, hoisted: [] };\n\n\tconst kept: ChildNode[] = [];\n\tconst hoisted: BlockNode[] = [];\n\tlet changed = false;\n\n\tconst place = (candidate: BlockNode): void => {\n\t\tif (canContain(registry, block.type, candidate.type)) {\n\t\t\tkept.push(candidate);\n\t\t} else {\n\t\t\thoisted.push(candidate);\n\t\t\tchanged = true;\n\t\t}\n\t};\n\n\tfor (const child of block.children) {\n\t\tif (!isBlockNode(child)) {\n\t\t\tkept.push(child);\n\t\t\tcontinue;\n\t\t}\n\t\tconst repaired = repairContainer(child, registry);\n\t\tif (repaired.node !== child) changed = true;\n\t\tplace(repaired.node);\n\t\tfor (const bubbled of repaired.hoisted) place(bubbled);\n\t}\n\n\tif (!changed) return { node: block, hoisted: [] };\n\n\tconst finalChildren: readonly ChildNode[] = resolveRepairedChildren(block, kept, registry);\n\treturn {\n\t\tnode: createBlockNode(block.type, finalChildren, block.id, block.attrs, block.htmlId),\n\t\thoisted,\n\t};\n}\n\n/**\n * Settles a repaired container's children: an emptied container gets a valid\n * placeholder, and a hybrid (leaf-capable) container reduced to a single plain\n * paragraph collapses back to the canonical leaf shape — mirroring how the\n * importers keep a lone single-paragraph item a leaf (#194).\n */\nfunction resolveRepairedChildren(\n\tblock: BlockNode,\n\tkept: readonly ChildNode[],\n\tregistry: SchemaRegistry,\n): readonly ChildNode[] {\n\tconst allow: readonly string[] | undefined = registry.getNodeSpec(block.type)?.content?.allow;\n\tconst leafCapable: boolean = allow?.includes('text') ?? false;\n\n\tif (kept.length === 0) {\n\t\treturn leafCapable\n\t\t\t? [createTextNode('')]\n\t\t\t: [createBlockNode(nodeType('paragraph'), [createTextNode('')])];\n\t}\n\n\tconst only: ChildNode | undefined = kept.length === 1 ? kept[0] : undefined;\n\tif (\n\t\tleafCapable &&\n\t\tonly &&\n\t\tisBlockNode(only) &&\n\t\tonly.type === 'paragraph' &&\n\t\t!only.attrs &&\n\t\t!only.htmlId\n\t) {\n\t\tconst inline = getInlineChildren(only);\n\t\treturn inline.length > 0 ? [...inline] : [createTextNode('')];\n\t}\n\treturn kept;\n}\n"],"mappings":"sHAoBA,SAAgB,EACf,EACA,EACA,GAEA,MAAM,EAAa,EAAS,YAAY,GACxC,IAAK,GAAY,QAAS,OAAO,EAGjC,MAAM,EADY,EAAS,YAAY,IACT,MAE9B,IAAK,MAAM,KAAW,EAAW,Q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,EACA,GAGA,MAAM,GADuC,EAAS,YAAY,EAAM,OAAO,SAAS,QACpD,SAAS,UAAW,EAExD,GAAoB,IAAhB,EAAK,OACR,OAAO,EACJ,CAAC,EAAe,KAChB,CAAC,EAAgB,EAAS,aAAc,CAAC,EAAe,OAG5D,MAAM,EAA8C,IAAhB,EAAK,OAAe,EAAK,QAAK,EAClE,GACC,GACA,GACA,EAAY,IACE,cAAd,EAAK,OACJ,EAAK,QACL,EAAK,OACL,CACD,MAAM,EAAS,EAAkB,GACjC,OAAO,EAAO,OAAS,EAAI,IAAI,GAAU,CAAC,EAAe,IAC1D,CACA,OAAO,CACR,CAxC6C,CAAwB,EAAO,EAAM,GACjF,MAAO,CACN,KAAM,EAAgB,EAAM,KAAM,EAAe,EAAM,GAAI,EAAM,MAAO,EAAM,QAC9E,UAEF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as t,n as e}from"./HTMLUtils-DTpsjZyK.mjs";import{P as n,_ as o,g as r,m as s,p as a,z as i}from"./Document-ssR6hBzG.mjs";import{a as c,i as l,r as u}from"./TypeBrands-Ch9856Gb.mjs";import{n as f}from"./ContentModel-BLC3Tez8.mjs";import{C as d,S as p,T as h,c as g,f as m,g as y,h as N,n as T,o as E,r as A,s as b,t as L}from"./TableDimensions-BSEOEox2.mjs";import{n as k,t as w}from"./HTMLSanitization-Ce9dVT1q.mjs";var O=/* @__PURE__ */new Set(["p","div","ul","ol","table","blockquote"]);function D(t,e){const n=t.tagName.toLowerCase();for(const{rule:o,type:r}of e){if(o.tag!==n)continue;const e=o.getAttrs?.(t);if(!1!==e)return{type:r,...e?{attrs:e}:{}}}return null}function v(t,e,n){const o=t.tagName.toLowerCase(),r=[...e];for(const{rule:s,type:a}of n){if(s.tag!==o||r.some(t=>t.type===a))continue;const e=s.getAttrs?.(t);!1!==e&&r.push({type:l(a),...e&&Object.keys(e).length>0?{attrs:e}:{}})}return r}function C(t,e,n,o=O){return!D(t,n)&&(o.has(t.tagName.toLowerCase())||null!==D(t,e))}function _(t,e,n,o=O){return R(e,n,o)(t)}function R(t,e,n=O){const o=/* @__PURE__ */new WeakMap,r=s=>{const a=o.get(s);if(void 0!==a)return a;const i=!D(s,e)&&Array.from(s.children).some(o=>{const s=o;return C(s,t,e,n)||r(s)});return o.set(s,i),i};return r}var M=/[ \t\n\r\f]+/g,I=/* @__PURE__ */new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","UL","OL","LI","TABLE","THEAD","TBODY","TFOOT","TR","TD","TH","HR","FIGURE","FIGCAPTION","SECTION","ARTICLE","HEADER","FOOTER","MAIN","ASIDE","NAV","DL","DT","DD"]),x=/* @__PURE__ */new Set(["PRE","TEXTAREA"]),S=/* @__PURE__ */new Set(["pre","pre-wrap","pre-line","break-spaces"]);function H(t){P(t)}function P(t){const e={lastTextNode:null,collapsePending:!0};for(const n of Array.from(t.childNodes))j(n,e);B(e.lastTextNode)}function j(t,e){if(t.nodeType===Node.TEXT_NODE)return void function(t,e){let n=t.data.replace(M," ");e.collapsePending&&n.startsWith(" ")&&(n=n.slice(1)),t.data=n,0!==n.length&&(e.collapsePending=n.endsWith(" "),e.lastTextNode=t)}(t,e);if(t.nodeType!==Node.ELEMENT_NODE)return;const n=t;if(function(t){if(x.has(t.tagName))return!0;const e=(t.style?.whiteSpace??"").toLowerCase();return S.has(e)}(n))W(e);else{if(function(t){return I.has(t.tagName)}(n))return W(e),void P(n);for(const t of Array.from(n.childNodes))j(t,e)}}function W(t){B(t.lastTextNode),t.lastTextNode=null,t.collapsePending=!0}function B(t){t?.data.endsWith(" ")&&(t.data=t.data.slice(0,-1))}function X(t,e){!function(t){for(const e of Array.from(t.querySelectorAll("[style]"))){const t=q(e);if(!t||t.length>0)continue;const n=e.getAttribute("style")??"";p(n).length>256||(t.cssText=n)}}(t),y(t,e,256)}function q(t){return t.style}function F(t,n,o){const r=n?n.getAllowedTags():["p","br","div","span"],a=n?n.getAllowedAttrs():["style","dir","id"];a.includes("data-block-id")||a.push("data-block-id"),o?.styleMap&&!a.includes("class")&&a.push("class");const i=document.createElement("template");i.innerHTML=k(t,{ALLOWED_TAGS:r,ALLOWED_ATTR:a,ALLOWED_URI_REGEXP:e,...w()},n);const c=i.content;X(c,N(n,o?.styleMap)),H(c);const l=function(t){const e=t?.getBlockParseRules()??[],n=t?.getInlineParseRules()??[],o=t?.getMarkParseRules()??[],r=/* @__PURE__ */new WeakMap,s=t=>{const e=r.get(t);if(e)return e;const n=t.parentElement,a=v(t,n?s(n):[],o);return r.set(t,a),a};return{registry:t,blockRules:e,inlineRules:n,markRules:o,adoptedIds:/* @__PURE__ */new Set,hasBlockDescendants:R(e,n),ancestorMarks:t=>t.parentElement?s(t.parentElement):[]}}(n),u=[];for(const e of Array.from(c.childNodes))U(e,u,l);if(0===u.length)return s();const d=s(u);return n?f(d,n):d}function U(t,e,n){const{adoptedIds:r,registry:s}=n;if(t.nodeType===Node.ELEMENT_NODE){const i=t,l=i.tagName.toLowerCase();if("ul"===l||"ol"===l){const t="ol"===l?"ordered":"bullet",o=i.getAttribute("dir");return void G(i,t,0,e,n,o&&m.has(o)?o:void 0)}if("table"===l)return void function(t,e,n){const{adoptedIds:o,registry:r}=n,s=[],i=function(t){const e=[];for(const n of Array.from(t.children)){const t=n.tagName.toLowerCase();if("col"===t){z(n,void 0,e);continue}if("colgroup"!==t)continue;const o=n,r=Q(o),s=Array.from(o.children).filter(t=>"col"===t.tagName.toLowerCase());if(0!==s.length)for(const n of s)z(n,r,e);else K(r,b(o.getAttribute("span")),e)}return E(e)}(t),l=!r||!!r.getNodeSpec("table_cell")?.attrs?.align,u=function(t){const e=[];for(const n of Array.from(t.children)){const t=n.tagName.toLowerCase();if("tr"===t)e.push(n);else if("thead"===t||"tbody"===t||"tfoot"===t)for(const o of Array.from(n.children))"tr"===o.tagName.toLowerCase()&&e.push(o)}return e}(t);for(const f of u){const t=[];for(const r of Array.from(f.children)){const e=r.tagName.toLowerCase();if("td"!==e&&"th"!==e)continue;const s=r,i=$(s,n),u={};Z(s,u),l&&ct(s,u);const f=a(c("table_cell"),i,d(s,o),Object.keys(u).length>0?u:void 0,it(s));t.push(f)}const e={};Y(f,e),s.push(a(c("table_row"),t,d(f,o),Object.keys(e).length>0?e:void 0,it(f)))}if(s.length>0){const n={};!function(t,e){const n=t.getAttribute("style")??"",o=J.exec(n);o?.[1]&&(e.borderColor="transparent"===o[1]?"none":o[1])}(t,n),i&&(n.columnWidthsPx=i),e.push(a(c("table"),s,d(t,o),Object.keys(n).length>0?n:void 0,it(t)))}}(i,e,n);if("blockquote"===l)return void function(t,e,n){const r=tt(t,n);0===r.length&&r.push(a(c("paragraph"),[o("")]));const s={};ct(t,s),at(t,s),e.push(a(c("blockquote"),r,d(t,n.adoptedIds),Object.keys(s).length>0?s:void 0,it(t)))}(i,e,n);const u=D(i,n.blockRules);if("paragraph"===(u?.type??"paragraph")&&n.hasBlockDescendants(i))return void function(t,e,n){const o={};ct(t,o),at(t,o);const r=tt(t,n);for(const s of r)e.push(nt(s,o,n.registry))}(i,e,n);const f=u?s?.getNodeSpec(u.type):void 0,p=f?.isVoid?[o("")]:ot(i,n),h={...u?.attrs};u&&!f?.attrs?.align||ct(i,h),u&&!f?.attrs?.dir||at(i,h),e.push(a(c(u?.type??"paragraph"),p,d(i,r),Object.keys(h).length>0?h:void 0,it(i)))}else t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()&&e.push(a(c("paragraph"),[o(t.textContent.trim())]))}function G(t,e,n,o,r,s){for(const a of Array.from(t.children)){const t=a.tagName.toLowerCase();if("li"===t){const t=a,i=t.querySelector(':scope > input[type="checkbox"]'),c={listType:null!==i?"checklist":e,indent:n,checked:i?.hasAttribute("checked")??!1},l=t.getAttribute("dir"),u=l&&m.has(l)?l:s;u&&(c.dir=u),o.push(V(t,c,i,r));for(const e of Array.from(t.children)){const t=e.tagName.toLowerCase();if("ul"===t||"ol"===t){const s="ol"===t?"ordered":"bullet",a=e.getAttribute("dir");G(e,s,n+1,o,r,a&&m.has(a)?a:u)}}}else if("ul"===t||"ol"===t){const e="ol"===t?"ordered":"bullet",i=a.getAttribute("dir");G(a,e,n+1,o,r,i&&m.has(i)?i:s)}}}function V(t,e,r,s){const{adoptedIds:i}=s,l=it(t),u=t=>{if(t.nodeType!==Node.ELEMENT_NODE)return!1;const e=t.tagName.toLowerCase();return"ul"===e||"ol"===e};if(!Array.from(t.childNodes).some(t=>!u(t)&&et(t,s))){const n=ot(t,s,!0);return a(c("list_item"),n,d(t,i),e,l)}const f=tt(t,s,t=>u(t)||t===r),p=1===f.length?f[0]:void 0;return!p||"paragraph"!==p.type||p.attrs||p.htmlId?0===f.length?a(c("list_item"),[o("")],d(t,i),e,l):a(c("list_item"),f,d(t,i),e,l):a(c("list_item"),n(p),d(t,i),e,l)}function z(t,e,n){K(Q(t)??e,b(t.getAttribute("span")),n)}function K(t,e,n){const o=L-n.length,r=Math.min(e,Math.max(0,o));for(let s=0;s<r;s++)n.push(t??null)}function Q(t){return g(t,T,["width"],"width")}function Y(t,e){const n=g(t,A,["min-height","height"],"height");void 0!==n&&(e.minHeightPx=n)}var J=/--ntbl-bc:\s*(#[0-9a-fA-F]{3,8}|transparent)/;function Z(t,e){const n=t.getAttribute("colspan");if(n){const t=b(n);t>1&&(e.colspan=t)}const o=t.getAttribute("rowspan");if(o){const t=b(o);t>1&&(e.rowspan=t)}}function $(t,e){const n=tt(t,e);return 0===n.length&&n.push(a(c("paragraph"),[o("")])),n}function tt(t,e,n){const o=[];let r=[];const s=()=>{(function(t){for(const e of t){if(e.nodeType===Node.ELEMENT_NODE)return!0;if(e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())return!0}return!1})(r)&&o.push(a(c("paragraph"),rt(r,e))),r=[]};for(const a of Array.from(t.childNodes))n?.(a)||(et(a,e)?(s(),U(a,o,e)):r.push(a));return s(),o}function et(t,e){if(t.nodeType!==Node.ELEMENT_NODE)return!1;const n=t;return C(n,e.blockRules,e.inlineRules)||e.hasBlockDescendants(n)}function nt(t,e,n){const o=n?.getNodeSpec(t.type),r={...t.attrs};let s=!1;for(const[a,i]of Object.entries(e))void 0===r[a]&&(n&&!o?.attrs?.[a]||(r[a]=i,s=!0));return s?a(t.type,t.children,t.id,r,t.htmlId):t}function ot(t,e,n){return rt([t],e,n)}function rt(t,e,n){const r=[];for(const o of t)st(o,e.ancestorMarks(o),r,e.markRules,e.inlineRules,n);return 1===r.length&&i(r[0])&&"hard_break"===r[0].inlineType?[o("")]:r.length>0?r:[o("")]}function st(t,e,n,s,a,i){if(t.nodeType===Node.TEXT_NODE){const r=t.textContent??"";return void(r&&n.push(o(r,[...e])))}if(t.nodeType!==Node.ELEMENT_NODE)return;const c=t,l=c.tagName.toLowerCase();if(i&&("ul"===l||"ol"===l))return;if(i&&"input"===l&&"checkbox"===c.getAttribute("type"))return;const f=D(c,a);if(f)return void n.push(r(u(f.type),f.attrs,e));const d=v(c,e,s);for(const o of Array.from(c.childNodes))st(o,d,n,s,a,i)}function at(t,e){const n=t.getAttribute("dir");if(n&&m.has(n))return void(e.dir=n);const o=t.style?.direction??"";o&&m.has(o)&&(e.dir=o)}function it(e){return t(e.getAttribute("id"))}function ct(t,e){const n=h(t);n&&(e.align=n)}export{_ as a,v as c,R as i,X as n,C as o,H as r,D as s,F as t};
|
|
2
|
-
//# sourceMappingURL=DocumentParser-BKUrtgw1.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentParser-BKUrtgw1.mjs","names":[],"sources":["../../src/serialization/HTMLParseRules.ts","../../src/serialization/HTMLParseSession.ts","../../src/serialization/HTMLWhitespace.ts","../../src/serialization/StyleRehydration.ts","../../src/serialization/DocumentParser.ts"],"sourcesContent":["import type { Mark } from '../model/Document.js';\nimport type { ParseRule } from '../model/ParseRule.js';\nimport { markType } from '../model/TypeBrands.js';\n\n/** Parse rules with the node, mark or inline type they produce, in priority order. */\nexport type ParseRules = readonly { readonly rule: ParseRule; readonly type: string }[];\n\n/** Structural tags handled by the document parser independently of schema rules. */\nconst BLOCK_TAGS: ReadonlySet<string> = new Set(['p', 'div', 'ul', 'ol', 'table', 'blockquote']);\n\n/** Returns the first accepting rule in priority order, including its parsed attributes. */\nexport function matchHTMLParseRule(\n\telement: HTMLElement,\n\trules: ParseRules,\n): { readonly type: string; readonly attrs?: Record<string, unknown> } | null {\n\tconst tag: string = element.tagName.toLowerCase();\n\tfor (const { rule, type } of rules) {\n\t\tif (rule.tag !== tag) continue;\n\t\tconst attrs = rule.getAttrs?.(element);\n\t\tif (attrs !== false) return { type, ...(attrs ? { attrs } : {}) };\n\t}\n\treturn null;\n}\n\n/** Reads the element's own marks, shared by the inline walker and wrappers. */\nexport function parseHTMLMarks(\n\tel: HTMLElement,\n\tcurrentMarks: readonly Mark[],\n\tmarkRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n): Mark[] {\n\tconst tag: string = el.tagName.toLowerCase();\n\tconst marks: Mark[] = [...currentMarks];\n\n\tfor (const { rule, type } of markRules) {\n\t\tif (rule.tag !== tag || marks.some((mark) => mark.type === type)) continue;\n\t\tconst attrs = rule.getAttrs?.(el);\n\t\tif (attrs === false) continue;\n\t\tmarks.push({\n\t\t\ttype: markType(type),\n\t\t\t...(attrs && Object.keys(attrs).length > 0 ? { attrs } : {}),\n\t\t} as Mark);\n\t}\n\n\treturn marks;\n}\n\n/** Inline node rules take precedence, just as they do when parsing inline content. */\nexport function isHTMLBlockElement(\n\telement: HTMLElement,\n\tblockRules: ParseRules,\n\tinlineRules: ParseRules,\n\tblockTags: ReadonlySet<string> = BLOCK_TAGS,\n): boolean {\n\tif (matchHTMLParseRule(element, inlineRules)) return false;\n\treturn (\n\t\tblockTags.has(element.tagName.toLowerCase()) || matchHTMLParseRule(element, blockRules) !== null\n\t);\n}\n\n/**\n * Looks through transparent intermediate wrappers for block content. Atomic\n * inline nodes own their markup, so their descendants must never be unwrapped.\n */\nexport function hasHTMLBlockDescendants(\n\telement: HTMLElement,\n\tblockRules: ParseRules,\n\tinlineRules: ParseRules,\n\tblockTags: ReadonlySet<string> = BLOCK_TAGS,\n): boolean {\n\treturn createBlockDescendantCheck(blockRules, inlineRules, blockTags)(element);\n}\n\n/**\n * Creates a {@link hasHTMLBlockDescendants} check that remembers every\n * element's answer. Parsers ask it for each level of nested wrappers, so\n * without the memo a deep wrapper chain rescans the same subtree at every\n * level (#263). Use one check per parse, while the DOM does not change.\n */\nexport function createBlockDescendantCheck(\n\tblockRules: ParseRules,\n\tinlineRules: ParseRules,\n\tblockTags: ReadonlySet<string> = BLOCK_TAGS,\n): (element: HTMLElement) => boolean {\n\tconst known = new WeakMap<Element, boolean>();\n\tconst check = (element: HTMLElement): boolean => {\n\t\tconst cached: boolean | undefined = known.get(element);\n\t\tif (cached !== undefined) return cached;\n\t\tconst result: boolean =\n\t\t\t!matchHTMLParseRule(element, inlineRules) &&\n\t\t\tArray.from(element.children).some((child) => {\n\t\t\t\tconst el = child as HTMLElement;\n\t\t\t\treturn isHTMLBlockElement(el, blockRules, inlineRules, blockTags) || check(el);\n\t\t\t});\n\t\tknown.set(element, result);\n\t\treturn result;\n\t};\n\treturn check;\n}\n","/**\n * State shared by one HTML import: the registry's parse rules, read once, the\n * block ids adopted so far, and per-element answers the parser needs again and\n * again. Transparent wrappers (#223) make the parser ask about the same\n * elements at every nesting level, so each answer is computed once per element\n * instead of once per level (#263).\n */\n\nimport type { Mark } from '../model/Document.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { type ParseRules, createBlockDescendantCheck, parseHTMLMarks } from './HTMLParseRules.js';\n\nexport interface HTMLParseSession {\n\treadonly registry?: SchemaRegistry;\n\treadonly blockRules: ParseRules;\n\treadonly inlineRules: ParseRules;\n\treadonly markRules: ParseRules;\n\t/** HTML block ids adopted so far, so a repeated id gets a fresh one. */\n\treadonly adoptedIds: Set<string>;\n\t/** Whether `element` wraps block-level content, looking through transparent wrappers. */\n\thasBlockDescendants(element: HTMLElement): boolean;\n\t/** The marks the ancestors of `node` apply to it, such as a wrapper's link or color. */\n\tancestorMarks(node: Node): readonly Mark[];\n}\n\n/**\n * Creates the session for one parse. The DOM must not change while it is in\n * use, because answers are remembered per element.\n */\nexport function createHTMLParseSession(registry?: SchemaRegistry): HTMLParseSession {\n\tconst blockRules: ParseRules = registry?.getBlockParseRules() ?? [];\n\tconst inlineRules: ParseRules = registry?.getInlineParseRules() ?? [];\n\tconst markRules: ParseRules = registry?.getMarkParseRules() ?? [];\n\tconst ownMarks = new WeakMap<Element, readonly Mark[]>();\n\n\tconst marksOf = (element: HTMLElement): readonly Mark[] => {\n\t\tconst cached: readonly Mark[] | undefined = ownMarks.get(element);\n\t\tif (cached) return cached;\n\t\tconst parent: HTMLElement | null = element.parentElement;\n\t\tconst marks: readonly Mark[] = parseHTMLMarks(\n\t\t\telement,\n\t\t\tparent ? marksOf(parent) : [],\n\t\t\tmarkRules,\n\t\t);\n\t\townMarks.set(element, marks);\n\t\treturn marks;\n\t};\n\n\treturn {\n\t\tregistry,\n\t\tblockRules,\n\t\tinlineRules,\n\t\tmarkRules,\n\t\tadoptedIds: new Set<string>(),\n\t\thasBlockDescendants: createBlockDescendantCheck(blockRules, inlineRules),\n\t\tancestorMarks: (node: Node): readonly Mark[] =>\n\t\t\tnode.parentElement ? marksOf(node.parentElement) : [],\n\t};\n}\n","/**\n * HTML whitespace normalization, shared by the paste parser (`HTMLParser`) and the\n * `setContentHTML` parser (`DocumentParser`).\n *\n * Per the CSS Text / HTML whitespace processing model for `white-space: normal`,\n * whitespace in normal flow content is *insignificant*: runs of ASCII whitespace\n * (space, tab, line feed, carriage return, form feed) collapse to a single space,\n * and whitespace at the edges of a block collapses away entirely. Only `<br>` is a\n * real line break. Source-formatted HTML (server-rendered, hand-indented, or\n * hard-wrapped by a browser's clipboard serializer) therefore carries newlines and\n * indentation that must NOT survive parsing.\n *\n * This pass rewrites text-node data in place so both parsers can walk a tree whose\n * whitespace already matches what a browser would render. It only touches\n * `Text.data`; marks, block ids, and attributes are left untouched.\n */\n\n/**\n * ASCII whitespace per the HTML spec. Deliberately NOT `\\s`: `\\s` also matches\n * non-breaking space (` `) and other Unicode spaces, which are significant\n * content and must be preserved verbatim.\n */\nconst COLLAPSIBLE_WHITESPACE: RegExp = /[ \\t\\n\\r\\f]+/g;\n\n/**\n * Tags that establish a block formatting context in normal flow. Each starts a\n * fresh inline run whose leading/trailing whitespace is trimmed independently.\n * Self-contained (not coupled to the parsers' tag sets); unknown tags are treated\n * as inline.\n */\nconst FLOW_BLOCK_TAGS: ReadonlySet<string> = new Set([\n\t'P',\n\t'DIV',\n\t'H1',\n\t'H2',\n\t'H3',\n\t'H4',\n\t'H5',\n\t'H6',\n\t'BLOCKQUOTE',\n\t'UL',\n\t'OL',\n\t'LI',\n\t'TABLE',\n\t'THEAD',\n\t'TBODY',\n\t'TFOOT',\n\t'TR',\n\t'TD',\n\t'TH',\n\t'HR',\n\t'FIGURE',\n\t'FIGCAPTION',\n\t'SECTION',\n\t'ARTICLE',\n\t'HEADER',\n\t'FOOTER',\n\t'MAIN',\n\t'ASIDE',\n\t'NAV',\n\t'DL',\n\t'DT',\n\t'DD',\n]);\n\n/** Tags whose descendant whitespace is significant and must be preserved verbatim. */\nconst PRESERVE_TAGS: ReadonlySet<string> = new Set(['PRE', 'TEXTAREA']);\n\n/** `white-space` values that preserve whitespace (the `pre*` family). */\nconst PRESERVE_WHITESPACE_VALUES: ReadonlySet<string> = new Set([\n\t'pre',\n\t'pre-wrap',\n\t'pre-line',\n\t'break-spaces',\n]);\n\n/** Mutable state threaded through a single inline formatting context. */\ninterface CollapseState {\n\t/** Most recent non-empty text node in this context, for trailing-space trimming. */\n\tlastTextNode: Text | null;\n\t/**\n\t * Whether a leading space on the next text node should be dropped. True at the\n\t * start of a context and after any text node that ended with a space.\n\t */\n\tcollapsePending: boolean;\n}\n\n/**\n * Collapses insignificant HTML whitespace throughout `root`, mutating text-node\n * data in place. Call once on a (disposable) parsed fragment before walking it.\n */\nexport function normalizeHTMLWhitespace(root: DocumentFragment | HTMLElement): void {\n\tnormalizeContext(root);\n}\n\n/** Processes one inline formatting context, then trims its trailing whitespace. */\nfunction normalizeContext(container: DocumentFragment | HTMLElement): void {\n\tconst state: CollapseState = { lastTextNode: null, collapsePending: true };\n\tfor (const child of Array.from(container.childNodes)) {\n\t\tprocessNode(child, state);\n\t}\n\ttrimTrailingSpace(state.lastTextNode);\n}\n\nfunction processNode(node: ChildNode, state: CollapseState): void {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\tcollapseTextNode(node as Text, state);\n\t\treturn;\n\t}\n\tif (node.nodeType !== Node.ELEMENT_NODE) return;\n\n\tconst el = node as HTMLElement;\n\n\t// Whitespace-preserving subtree (code blocks etc.): end the current inline run\n\t// and leave the subtree untouched.\n\tif (isPreserveElement(el)) {\n\t\tendInlineRun(state);\n\t\treturn;\n\t}\n\n\t// Block element: the current inline run ends here; recurse as a fresh context.\n\tif (isFlowBlockElement(el)) {\n\t\tendInlineRun(state);\n\t\tnormalizeContext(el);\n\t\treturn;\n\t}\n\n\t// Inline element: keep collapsing within the same context.\n\tfor (const child of Array.from(el.childNodes)) {\n\t\tprocessNode(child, state);\n\t}\n}\n\n/** Collapses whitespace runs in a text node and drops a leading space when pending. */\nfunction collapseTextNode(text: Text, state: CollapseState): void {\n\tlet data: string = text.data.replace(COLLAPSIBLE_WHITESPACE, ' ');\n\tif (state.collapsePending && data.startsWith(' ')) {\n\t\tdata = data.slice(1);\n\t}\n\ttext.data = data;\n\n\t// Fully collapsed away (e.g. a whitespace-only node): leave `collapsePending` as\n\t// is so a later node still drops its leading space.\n\tif (data.length === 0) return;\n\n\tstate.collapsePending = data.endsWith(' ');\n\tstate.lastTextNode = text;\n}\n\n/** Ends the current inline run at a block/preserve boundary and resets state. */\nfunction endInlineRun(state: CollapseState): void {\n\ttrimTrailingSpace(state.lastTextNode);\n\tstate.lastTextNode = null;\n\tstate.collapsePending = true;\n}\n\n/** Removes the single (already-collapsed) trailing space from a text node, if any. */\nfunction trimTrailingSpace(node: Text | null): void {\n\tif (node?.data.endsWith(' ')) {\n\t\tnode.data = node.data.slice(0, -1);\n\t}\n}\n\nfunction isFlowBlockElement(el: HTMLElement): boolean {\n\treturn FLOW_BLOCK_TAGS.has(el.tagName);\n}\n\nfunction isPreserveElement(el: HTMLElement): boolean {\n\tif (PRESERVE_TAGS.has(el.tagName)) return true;\n\tconst whiteSpace: string = (el.style?.whiteSpace ?? '').toLowerCase();\n\treturn PRESERVE_WHITESPACE_VALUES.has(whiteSpace);\n}\n","/**\n * Style rehydration for HTML import and paste: before the parse rules run,\n * every style the HTML gives an element becomes readable through the CSSOM\n * (`el.style`), which is where the rules read it. Import and both paste routes\n * share this one step, so they read styles alike on every page.\n */\n\nimport { splitDeclarations } from '../model/StyleClass.js';\nimport { type ClassDeclarationResolver, rehydrateStyleClasses } from './StyleClassHTML.js';\n\n/**\n * The most declarations rehydrated on one element, from its `style` attribute\n * and from its classes each. Formatting needs far fewer. Input with more is not\n * formatting, and Chromium applies many distinct custom properties through the\n * CSSOM in superlinear time, so such an element keeps those styles unapplied\n * (#274).\n */\nexport const MAX_REHYDRATED_DECLARATIONS = 256;\n\n/**\n * Rehydrates the styles of parsed content HTML in cascade order: first each\n * element's own `style` attribute, then the declarations its classes stand for,\n * which only fill properties the element does not set inline (#269).\n */\nexport function rehydrateStyles(root: ParentNode, resolveClass: ClassDeclarationResolver): void {\n\trestoreInlineStyles(root);\n\trehydrateStyleClasses(root, resolveClass, MAX_REHYDRATED_DECLARATIONS);\n}\n\n/**\n * Applies `style` attributes the browser kept out of the CSSOM. Under a strict\n * CSP (`style-src-attr 'none'`) Chromium keeps the attribute text but leaves\n * `el.style` empty, even in inert template content (#272), while CSSOM writes\n * stay allowed. Without such a policy the CSSOM already holds the declarations,\n * so only an attribute the browser rejected entirely is parsed again, which\n * yields no declarations either. Afterwards the attribute holds the browser's\n * serialization, so code that needs the raw text reads it before this step.\n */\nfunction restoreInlineStyles(root: ParentNode): void {\n\tfor (const element of Array.from(root.querySelectorAll('[style]'))) {\n\t\tconst style: CSSStyleDeclaration | undefined = inlineStyleOf(element);\n\t\tif (!style || style.length > 0) continue;\n\t\tconst text: string = element.getAttribute('style') ?? '';\n\t\tif (splitDeclarations(text).length > MAX_REHYDRATED_DECLARATIONS) continue;\n\t\t// One write through the browser's own CSS parser, which reads priorities,\n\t\t// shorthands and comments as it reads the attribute on a page without a CSP.\n\t\tstyle.cssText = text;\n\t}\n}\n\n/** The CSSOM declaration of an element, unless its namespace has none. */\nfunction inlineStyleOf(element: Element): CSSStyleDeclaration | undefined {\n\treturn (element as Partial<ElementCSSInlineStyle>).style;\n}\n","/**\n * DocumentParser: converts sanitized HTML strings into immutable Document instances.\n * Pure functions — no class state, no DOM mutation beyond a temporary `<template>`.\n */\n\nimport type { BlockAlignment } from '../model/BlockAlignment.js';\nimport { hoistDisallowedBlocks } from '../model/ContentModel.js';\nimport type {\n\tBlockAttrValue,\n\tBlockNode,\n\tDocument,\n\tInlineNode,\n\tMark,\n\tTextNode,\n} from '../model/Document.js';\nimport {\n\tcreateBlockNode,\n\tcreateDocument,\n\tcreateInlineNode,\n\tcreateTextNode,\n\tgetInlineChildren,\n\tisInlineNode,\n} from '../model/Document.js';\nimport { SAFE_URI_REGEXP, normalizeHTMLId } from '../model/HTMLUtils.js';\nimport type { ParseRule } from '../model/ParseRule.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport { type InlineTypeName, inlineType, nodeType } from '../model/TypeBrands.js';\nimport { readElementAlignment } from './AlignmentHTML.js';\nimport { adoptBlockId } from './BlockIdHTML.js';\nimport { VALID_DIRECTIONS } from './DocumentSerializer.js';\nimport { isHTMLBlockElement, matchHTMLParseRule, parseHTMLMarks } from './HTMLParseRules.js';\nimport { type HTMLParseSession, createHTMLParseSession } from './HTMLParseSession.js';\nimport { preserveHTMLIdSanitizeConfig, sanitizeHTML } from './HTMLSanitization.js';\nimport { normalizeHTMLWhitespace } from './HTMLWhitespace.js';\nimport { createClassDeclarationResolver } from './StyleClassHTML.js';\nimport { rehydrateStyles } from './StyleRehydration.js';\nimport {\n\tMAX_SERIALIZED_TABLE_COLUMNS,\n\tTABLE_COLUMN_WIDTH_DATA_ATTRIBUTE,\n\tTABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE,\n\tnormalizeTableColumnWidthsPx,\n\tparseTableColumnSpan,\n\treadTableDimensionPx,\n} from './TableDimensions.js';\n\n/** Options for `parseHTMLToDocument` when importing class-based HTML. */\nexport interface ParseHTMLOptions {\n\t/**\n\t * Style map from a previous `getContentHTML({ cssMode: 'classes' })` call.\n\t * Used to rehydrate class-based HTML back into styled content. Registered\n\t * style classes and notectl's alignment classes need no style map.\n\t */\n\treadonly styleMap?: ReadonlyMap<string, string>;\n}\n\n/** Parses an HTML string into a Document, applying sanitization and schema parse rules. */\nexport function parseHTMLToDocument(\n\thtml: string,\n\tregistry?: SchemaRegistry,\n\toptions?: ParseHTMLOptions,\n): Document {\n\tconst allowedTags: string[] = registry ? registry.getAllowedTags() : ['p', 'br', 'div', 'span'];\n\tconst allowedAttrs: string[] = registry ? registry.getAllowedAttrs() : ['style', 'dir', 'id'];\n\n\t// `data-block-id` carries block identity across `setContentHTML(getContentHTML())`.\n\t// Whitelist it through DOMPurify so the adoption logic below sees it.\n\tif (!allowedAttrs.includes('data-block-id')) {\n\t\tallowedAttrs.push('data-block-id');\n\t}\n\n\t// When a styleMap is provided, also allow `class` through DOMPurify\n\t// so we can read class names and rehydrate styles before parsing.\n\tif (options?.styleMap && !allowedAttrs.includes('class')) {\n\t\tallowedAttrs.push('class');\n\t}\n\n\tconst template = document.createElement('template');\n\ttemplate.innerHTML = sanitizeHTML(\n\t\thtml,\n\t\t{\n\t\t\tALLOWED_TAGS: allowedTags,\n\t\t\tALLOWED_ATTR: allowedAttrs,\n\t\t\tALLOWED_URI_REGEXP: SAFE_URI_REGEXP,\n\t\t\t...preserveHTMLIdSanitizeConfig(),\n\t\t},\n\t\tregistry,\n\t);\n\tconst root: DocumentFragment = template.content;\n\n\t// Make inline styles and classes readable through the CSSOM, where parse rules read them.\n\trehydrateStyles(root, createClassDeclarationResolver(registry, options?.styleMap));\n\n\t// Collapse insignificant HTML whitespace so source-formatted/indented input does\n\t// not leave stray newlines and indentation inside block text content.\n\tnormalizeHTMLWhitespace(root);\n\n\tconst session: HTMLParseSession = createHTMLParseSession(registry);\n\tconst blocks: BlockNode[] = [];\n\n\tfor (const child of Array.from(root.childNodes)) {\n\t\tparseChildNode(child, blocks, session);\n\t}\n\n\tif (blocks.length === 0) return createDocument();\n\tconst doc: Document = createDocument(blocks);\n\t// Repair schema-invalid nesting an importer may have produced (e.g. a `<table>`\n\t// inside an `<li>` builds `list_item > table`, which the flat-with-indent item\n\t// model forbids): the disallowed block is hoisted to a valid ancestor (#194).\n\treturn registry ? hoistDisallowedBlocks(doc, registry) : doc;\n}\n\n/**\n * Parses a single child node into block(s), handling all supported block types:\n * lists, tables, block parse rules (headings, blockquotes, code blocks, images, hr),\n * and fallback paragraphs. Used by both top-level parsing and table cell content parsing.\n */\nfunction parseChildNode(child: ChildNode, blocks: BlockNode[], session: HTMLParseSession): void {\n\tconst { adoptedIds, registry } = session;\n\tif (child.nodeType === Node.ELEMENT_NODE) {\n\t\tconst el = child as HTMLElement;\n\t\tconst tag: string = el.tagName.toLowerCase();\n\n\t\t// Lists need cross-element logic — handle before parse rules\n\t\tif (tag === 'ul' || tag === 'ol') {\n\t\t\tconst listType: string = tag === 'ol' ? 'ordered' : 'bullet';\n\t\t\tconst listDir: string | null = el.getAttribute('dir');\n\t\t\tconst parentDir: string | undefined =\n\t\t\t\tlistDir && VALID_DIRECTIONS.has(listDir) ? listDir : undefined;\n\t\t\tparseListElement(el, listType, 0, blocks, session, parentDir);\n\t\t\treturn;\n\t\t}\n\n\t\t// Tables produce nested block structure: table > table_row > table_cell > paragraph\n\t\tif (tag === 'table') {\n\t\t\tparseTableElement(el, blocks, session);\n\t\t\treturn;\n\t\t}\n\n\t\t// Blockquotes are container blocks (issue #136): parse their children\n\t\t// recursively into block nodes instead of flattening to inline content.\n\t\tif (tag === 'blockquote') {\n\t\t\tparseBlockquoteElement(el, blocks, session);\n\t\t\treturn;\n\t\t}\n\n\t\t// Try block parse rules\n\t\tconst match = matchHTMLParseRule(el, session.blockRules);\n\n\t\t// A paragraph cannot hold blocks. An element that resolves to `paragraph`\n\t\t// (the generic `<div>` rule or the fallback below) but wraps block-level\n\t\t// children is a transparent wrapper, the shape web pages, Google Docs and\n\t\t// Word put around their content: its children become sibling blocks\n\t\t// instead of being flattened into one inline run (#223).\n\t\tif ((match?.type ?? 'paragraph') === 'paragraph' && session.hasBlockDescendants(el)) {\n\t\t\tparseWrapperElement(el, blocks, session);\n\t\t\treturn;\n\t\t}\n\n\t\tconst spec = match ? registry?.getNodeSpec(match.type) : undefined;\n\t\tconst children: (TextNode | InlineNode)[] = spec?.isVoid\n\t\t\t? [createTextNode('')]\n\t\t\t: parseElementToInlineContent(el, session);\n\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t...(match?.attrs as Record<string, string | number | boolean> | undefined),\n\t\t};\n\t\t// Known block types only accept declared attributes. The paragraph\n\t\t// fallback retains the permissive behavior of registry-free import.\n\t\tif (!match || spec?.attrs?.align) extractAlignment(el, attrs);\n\t\tif (!match || spec?.attrs?.dir) extractDirection(el, attrs);\n\t\tblocks.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType(match?.type ?? 'paragraph'),\n\t\t\t\tchildren,\n\t\t\t\tadoptBlockId(el, adoptedIds),\n\t\t\t\tObject.keys(attrs).length > 0 ? attrs : undefined,\n\t\t\t\textractHTMLId(el),\n\t\t\t),\n\t\t);\n\t} else if (child.nodeType === Node.TEXT_NODE && child.textContent?.trim()) {\n\t\tblocks.push(createBlockNode(nodeType('paragraph'), [createTextNode(child.textContent.trim())]));\n\t}\n}\n\n/**\n * Recursively parses a list element (`<ul>` or `<ol>`), creating list_item blocks\n * with correct indent depth. Handles nested lists inside `<li>` elements.\n */\nfunction parseListElement(\n\tlistEl: Element,\n\tlistType: string,\n\tdepth: number,\n\tblocks: BlockNode[],\n\tsession: HTMLParseSession,\n\tparentDir?: string,\n): void {\n\tfor (const child of Array.from(listEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\n\t\tif (tag === 'li') {\n\t\t\tconst li: HTMLElement = child as HTMLElement;\n\n\t\t\t// Check for checklist: <input type=\"checkbox\">\n\t\t\tconst checkbox: HTMLInputElement | null = li.querySelector(':scope > input[type=\"checkbox\"]');\n\t\t\tconst isChecklist: boolean = checkbox !== null;\n\t\t\tconst checked: boolean = checkbox?.hasAttribute('checked') ?? false;\n\n\t\t\tconst resolvedType: string = isChecklist ? 'checklist' : listType;\n\n\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\tlistType: resolvedType,\n\t\t\t\tindent: depth,\n\t\t\t\tchecked,\n\t\t\t};\n\n\t\t\t// Propagate direction: item's own dir > parent list dir\n\t\t\tconst liDir: string | null = li.getAttribute('dir');\n\t\t\tconst effectiveDir: string | undefined =\n\t\t\t\tliDir && VALID_DIRECTIONS.has(liDir) ? liDir : parentDir;\n\t\t\tif (effectiveDir) {\n\t\t\t\tattrs.dir = effectiveDir;\n\t\t\t}\n\n\t\t\tblocks.push(parseListItemBlock(li, attrs, checkbox, session));\n\n\t\t\t// Check for nested lists inside this <li>\n\t\t\tfor (const liChild of Array.from(li.children)) {\n\t\t\t\tconst liChildTag: string = liChild.tagName.toLowerCase();\n\t\t\t\tif (liChildTag === 'ul' || liChildTag === 'ol') {\n\t\t\t\t\tconst nestedType: string = liChildTag === 'ol' ? 'ordered' : 'bullet';\n\t\t\t\t\tconst nestedDir: string | null = liChild.getAttribute('dir');\n\t\t\t\t\tconst nestedEffectiveDir: string | undefined =\n\t\t\t\t\t\tnestedDir && VALID_DIRECTIONS.has(nestedDir) ? nestedDir : effectiveDir;\n\t\t\t\t\tparseListElement(liChild, nestedType, depth + 1, blocks, session, nestedEffectiveDir);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (tag === 'ul' || tag === 'ol') {\n\t\t\t// Direct nested list without wrapping <li> — increment depth\n\t\t\tconst nestedType: string = tag === 'ol' ? 'ordered' : 'bullet';\n\t\t\tconst nestedDir: string | null = child.getAttribute('dir');\n\t\t\tconst nestedEffectiveDir: string | undefined =\n\t\t\t\tnestedDir && VALID_DIRECTIONS.has(nestedDir) ? nestedDir : parentDir;\n\t\t\tparseListElement(child, nestedType, depth + 1, blocks, session, nestedEffectiveDir);\n\t\t}\n\t}\n}\n\n/**\n * Parses one `<li>` into its `list_item` block (#194). An item whose children\n * are inline-only stays a leaf; block-level children other than nested lists\n * (a second paragraph, code, a quote, a heading) make it a container with\n * block children. Nested `<ul>`/`<ol>` are excluded here — the caller hoists\n * them into flat siblings one indent deeper. A lone plain paragraph unwraps\n * back to a leaf so the common tight/loose single-paragraph item keeps its\n * inline shape.\n */\nfunction parseListItemBlock(\n\tli: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n\tcheckbox: HTMLInputElement | null,\n\tsession: HTMLParseSession,\n): BlockNode {\n\tconst { adoptedIds } = session;\n\tconst htmlId: string | undefined = extractHTMLId(li);\n\tconst isHoistedList = (node: ChildNode): boolean => {\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) return false;\n\t\tconst tag: string = (node as Element).tagName.toLowerCase();\n\t\treturn tag === 'ul' || tag === 'ol';\n\t};\n\tconst hasBlockContent: boolean = Array.from(li.childNodes).some(\n\t\t(node) => !isHoistedList(node) && isBlockLevelChild(node, session),\n\t);\n\n\tif (!hasBlockContent) {\n\t\tconst inlineContent = parseElementToInlineContent(li, session, true);\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\tinlineContent,\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\tconst skip = (node: ChildNode): boolean => isHoistedList(node) || node === checkbox;\n\tconst innerBlocks: BlockNode[] = parseBlockContainerChildren(li, session, skip);\n\n\t// A lone attribute-less paragraph is the leaf shape in disguise.\n\tconst only: BlockNode | undefined = innerBlocks.length === 1 ? innerBlocks[0] : undefined;\n\tif (only && only.type === 'paragraph' && !only.attrs && !only.htmlId) {\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\tgetInlineChildren(only),\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\tif (innerBlocks.length === 0) {\n\t\treturn createBlockNode(\n\t\t\tnodeType('list_item'),\n\t\t\t[createTextNode('')],\n\t\t\tadoptBlockId(li, adoptedIds),\n\t\t\tattrs,\n\t\t\thtmlId,\n\t\t);\n\t}\n\n\treturn createBlockNode(\n\t\tnodeType('list_item'),\n\t\tinnerBlocks,\n\t\tadoptBlockId(li, adoptedIds),\n\t\tattrs,\n\t\thtmlId,\n\t);\n}\n\n/**\n * Parses a `<table>` element into nested block structure:\n * table > table_row > table_cell > paragraph.\n * Handles `<thead>`, `<tbody>`, `<tfoot>` transparently.\n */\nfunction parseTableElement(tableEl: Element, blocks: BlockNode[], session: HTMLParseSession): void {\n\tconst { adoptedIds, registry } = session;\n\tconst rows: BlockNode[] = [];\n\tconst columnWidthsPx: readonly (number | null)[] | undefined =\n\t\textractTableColumnWidthsPx(tableEl);\n\t// Like every other block, a cell takes alignment only when its spec declares it.\n\tconst cellsAlign: boolean = !registry || !!registry.getNodeSpec('table_cell')?.attrs?.align;\n\n\t// Collect <tr> elements, handling <thead>/<tbody>/<tfoot> wrappers\n\tconst rowElements: Element[] = collectTableRows(tableEl);\n\n\tfor (const trEl of rowElements) {\n\t\tconst cells: BlockNode[] = [];\n\n\t\tfor (const cellChild of Array.from(trEl.children)) {\n\t\t\tconst cellTag: string = cellChild.tagName.toLowerCase();\n\t\t\tif (cellTag !== 'td' && cellTag !== 'th') continue;\n\n\t\t\tconst cellEl: HTMLElement = cellChild as HTMLElement;\n\t\t\tconst cellContent: BlockNode[] = parseTableCellContent(cellEl, session);\n\t\t\tconst cellAttrs: Record<string, string | number | boolean> = {};\n\t\t\textractCellSpanAttrs(cellEl, cellAttrs);\n\t\t\tif (cellsAlign) extractAlignment(cellEl, cellAttrs);\n\t\t\tconst cellBlock: BlockNode = createBlockNode(\n\t\t\t\tnodeType('table_cell'),\n\t\t\t\tcellContent,\n\t\t\t\tadoptBlockId(cellEl, adoptedIds),\n\t\t\t\tObject.keys(cellAttrs).length > 0 ? cellAttrs : undefined,\n\t\t\t\textractHTMLId(cellEl),\n\t\t\t);\n\t\t\tcells.push(cellBlock);\n\t\t}\n\n\t\tconst rowAttrs: Record<string, string | number | boolean> = {};\n\t\textractTableRowMinHeight(trEl as HTMLElement, rowAttrs);\n\t\t// Preserve empty rows. Besides retaining authored table structure, an empty\n\t\t// `<tr>` may carry the canonical minimum-height metadata by itself.\n\t\trows.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType('table_row'),\n\t\t\t\tcells,\n\t\t\t\tadoptBlockId(trEl, adoptedIds),\n\t\t\t\tObject.keys(rowAttrs).length > 0 ? rowAttrs : undefined,\n\t\t\t\textractHTMLId(trEl as HTMLElement),\n\t\t\t),\n\t\t);\n\t}\n\n\tif (rows.length > 0) {\n\t\tconst tableAttrs: Record<string, BlockAttrValue> = {};\n\t\textractTableBorderColor(tableEl as HTMLElement, tableAttrs);\n\t\tif (columnWidthsPx) tableAttrs.columnWidthsPx = columnWidthsPx;\n\t\tblocks.push(\n\t\t\tcreateBlockNode(\n\t\t\t\tnodeType('table'),\n\t\t\t\trows,\n\t\t\t\tadoptBlockId(tableEl, adoptedIds),\n\t\t\t\tObject.keys(tableAttrs).length > 0 ? tableAttrs : undefined,\n\t\t\t\textractHTMLId(tableEl as HTMLElement),\n\t\t\t),\n\t\t);\n\t}\n}\n\n/** Collects canonical logical column widths from direct `<colgroup>/<col>` children. */\nfunction extractTableColumnWidthsPx(tableEl: Element): readonly (number | null)[] | undefined {\n\tconst widths: (number | null)[] = [];\n\n\tfor (const child of Array.from(tableEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\t\tif (tag === 'col') {\n\t\t\tappendColumnElementWidths(child as HTMLElement, undefined, widths);\n\t\t\tcontinue;\n\t\t}\n\t\tif (tag !== 'colgroup') continue;\n\n\t\tconst groupEl: HTMLElement = child as HTMLElement;\n\t\tconst groupWidth: number | undefined = readTableColumnWidthPx(groupEl);\n\t\tconst columns: HTMLElement[] = Array.from(groupEl.children).filter(\n\t\t\t(element): element is HTMLElement => element.tagName.toLowerCase() === 'col',\n\t\t);\n\t\tif (columns.length === 0) {\n\t\t\tappendRepeatedWidth(groupWidth, parseTableColumnSpan(groupEl.getAttribute('span')), widths);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const column of columns) appendColumnElementWidths(column, groupWidth, widths);\n\t}\n\n\treturn normalizeTableColumnWidthsPx(widths);\n}\n\nfunction appendColumnElementWidths(\n\tcolumn: HTMLElement,\n\tinheritedWidth: number | undefined,\n\twidths: (number | null)[],\n): void {\n\tconst width: number | undefined = readTableColumnWidthPx(column) ?? inheritedWidth;\n\tappendRepeatedWidth(width, parseTableColumnSpan(column.getAttribute('span')), widths);\n}\n\nfunction appendRepeatedWidth(\n\twidth: number | undefined,\n\tspan: number,\n\twidths: (number | null)[],\n): void {\n\tconst remaining: number = MAX_SERIALIZED_TABLE_COLUMNS - widths.length;\n\tconst count: number = Math.min(span, Math.max(0, remaining));\n\tfor (let index = 0; index < count; index++) widths.push(width ?? null);\n}\n\nfunction readTableColumnWidthPx(element: HTMLElement): number | undefined {\n\treturn readTableDimensionPx(element, TABLE_COLUMN_WIDTH_DATA_ATTRIBUTE, ['width'], 'width');\n}\n\n/** Extracts one row's validated minimum height from canonical or conventional HTML. */\nfunction extractTableRowMinHeight(\n\trow: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n): void {\n\tconst minHeightPx: number | undefined = readTableDimensionPx(\n\t\trow,\n\t\tTABLE_ROW_MIN_HEIGHT_DATA_ATTRIBUTE,\n\t\t['min-height', 'height'],\n\t\t'height',\n\t);\n\tif (minHeightPx !== undefined) attrs.minHeightPx = minHeightPx;\n}\n\n/** Collects `<tr>` elements from a table, traversing through `<thead>`/`<tbody>`/`<tfoot>`. */\nfunction collectTableRows(tableEl: Element): Element[] {\n\tconst rows: Element[] = [];\n\tfor (const child of Array.from(tableEl.children)) {\n\t\tconst tag: string = child.tagName.toLowerCase();\n\t\tif (tag === 'tr') {\n\t\t\trows.push(child);\n\t\t} else if (tag === 'thead' || tag === 'tbody' || tag === 'tfoot') {\n\t\t\tfor (const nested of Array.from(child.children)) {\n\t\t\t\tif (nested.tagName.toLowerCase() === 'tr') {\n\t\t\t\t\trows.push(nested);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn rows;\n}\n\n/** Regex to extract the `--ntbl-bc` CSS custom property from inline styles. */\nconst BORDER_COLOR_RE = /--ntbl-bc:\\s*(#[0-9a-fA-F]{3,8}|transparent)/;\n\n/** Extracts `borderColor` from a table element's inline style (`--ntbl-bc` CSS variable). */\nfunction extractTableBorderColor(el: HTMLElement, attrs: Record<string, BlockAttrValue>): void {\n\tconst style: string = el.getAttribute('style') ?? '';\n\tconst match: RegExpMatchArray | null = BORDER_COLOR_RE.exec(style);\n\tif (!match?.[1]) return;\n\tattrs.borderColor = match[1] === 'transparent' ? 'none' : match[1];\n}\n\n/** Extracts `colspan` and `rowspan` attributes from a table cell element. */\nfunction extractCellSpanAttrs(\n\tel: HTMLElement,\n\tattrs: Record<string, string | number | boolean>,\n): void {\n\tconst colspan: string | null = el.getAttribute('colspan');\n\tif (colspan) {\n\t\tconst value: number = parseTableColumnSpan(colspan);\n\t\tif (value > 1) attrs.colspan = value;\n\t}\n\tconst rowspan: string | null = el.getAttribute('rowspan');\n\tif (rowspan) {\n\t\tconst value: number = parseTableColumnSpan(rowspan);\n\t\tif (value > 1) attrs.rowspan = value;\n\t}\n}\n\n/**\n * Parses a `<blockquote>` into a container block whose children are block nodes\n * (issue #136). Block-level children (lists, paragraphs, headings, nested quotes)\n * are parsed recursively; a quote holding only inline content becomes a single\n * paragraph child so the container invariant (block children only) always holds.\n */\nfunction parseBlockquoteElement(\n\tel: HTMLElement,\n\tblocks: BlockNode[],\n\tsession: HTMLParseSession,\n): void {\n\tconst innerBlocks: BlockNode[] = parseBlockContainerChildren(el, session);\n\n\t// Empty or whitespace-only blockquote: keep a single empty paragraph so the\n\t// container always holds editable content.\n\tif (innerBlocks.length === 0) {\n\t\tinnerBlocks.push(createBlockNode(nodeType('paragraph'), [createTextNode('')]));\n\t}\n\n\t// Preserve direction/alignment on the container so the HTML round-trip is stable.\n\tconst attrs: Record<string, string | number | boolean> = {};\n\textractAlignment(el, attrs);\n\textractDirection(el, attrs);\n\n\tblocks.push(\n\t\tcreateBlockNode(\n\t\t\tnodeType('blockquote'),\n\t\t\tinnerBlocks,\n\t\t\tadoptBlockId(el, session.adoptedIds),\n\t\t\tObject.keys(attrs).length > 0 ? attrs : undefined,\n\t\t\textractHTMLId(el),\n\t\t),\n\t);\n}\n\n/** Parses a table cell's content into blocks, supporting all block types (lists, quotes, etc.). */\nfunction parseTableCellContent(cellEl: HTMLElement, session: HTMLParseSession): BlockNode[] {\n\tconst cellBlocks: BlockNode[] = parseBlockContainerChildren(cellEl, session);\n\n\t// No blocks produced: treat the cell as one empty paragraph.\n\tif (cellBlocks.length === 0) {\n\t\tcellBlocks.push(createBlockNode(nodeType('paragraph'), [createTextNode('')]));\n\t}\n\n\treturn cellBlocks;\n}\n\n/**\n * Parses the children of a block container (blockquote, table cell, multi-block\n * list item, transparent wrapper) into block nodes. Consecutive inline content\n * (text nodes and inline elements such as\n * `<em>`, `<strong>`, `<a>`) is coalesced into a single paragraph with its marks\n * intact, while genuine block children (paragraphs, headings, lists, tables,\n * nested blockquotes) are parsed recursively. This preserves the common quote\n * shape that mixes text with inline marks as one paragraph (issue #141).\n */\nfunction parseBlockContainerChildren(\n\tel: HTMLElement,\n\tsession: HTMLParseSession,\n\tskip?: (node: ChildNode) => boolean,\n): BlockNode[] {\n\tconst blocks: BlockNode[] = [];\n\tlet inlineRun: ChildNode[] = [];\n\n\tconst flushInlineRun = (): void => {\n\t\tif (inlineRunHasContent(inlineRun)) {\n\t\t\tblocks.push(\n\t\t\t\tcreateBlockNode(nodeType('paragraph'), parseNodesToInlineContent(inlineRun, session)),\n\t\t\t);\n\t\t}\n\t\tinlineRun = [];\n\t};\n\n\tfor (const child of Array.from(el.childNodes)) {\n\t\tif (skip?.(child)) continue;\n\t\tif (isBlockLevelChild(child, session)) {\n\t\t\tflushInlineRun();\n\t\t\tparseChildNode(child, blocks, session);\n\t\t} else {\n\t\t\tinlineRun.push(child);\n\t\t}\n\t}\n\tflushInlineRun();\n\n\treturn blocks;\n}\n\n/**\n * Both blocks and transparent wrappers around blocks end an inline run.\n * Ordinary inline elements and atomic inline nodes stay inside that run.\n */\nfunction isBlockLevelChild(node: ChildNode, session: HTMLParseSession): boolean {\n\tif (node.nodeType !== Node.ELEMENT_NODE) return false;\n\tconst el = node as HTMLElement;\n\treturn (\n\t\tisHTMLBlockElement(el, session.blockRules, session.inlineRules) ||\n\t\tsession.hasBlockDescendants(el)\n\t);\n}\n\n/**\n * Parses a transparent wrapper (a `<div>` or an unknown element around\n * block-level children) into the blocks it wraps (#223). The wrapper itself\n * yields no block, so its `id` is not adopted as an `htmlId` (wrapper-only\n * elements never own one). Its `dir` and `text-align`, which CSS inherits into\n * every child, are carried onto child blocks that accept the attribute but do\n * not set their own.\n */\nfunction parseWrapperElement(\n\tel: HTMLElement,\n\tblocks: BlockNode[],\n\tsession: HTMLParseSession,\n): void {\n\tconst inherited: Record<string, string | number | boolean> = {};\n\textractAlignment(el, inherited);\n\textractDirection(el, inherited);\n\n\tconst innerBlocks: BlockNode[] = parseBlockContainerChildren(el, session);\n\tfor (const block of innerBlocks) {\n\t\tblocks.push(inheritBlockAttrs(block, inherited, session.registry));\n\t}\n}\n\n/**\n * Returns the block extended with every inherited attribute it accepts but does\n * not set itself. With a registry, a block accepts an attribute only when its\n * NodeSpec declares it (mirroring the block parse rule path); without one, all\n * attributes are accepted (mirroring the paragraph fallback path).\n */\nfunction inheritBlockAttrs(\n\tblock: BlockNode,\n\tinherited: Record<string, string | number | boolean>,\n\tregistry?: SchemaRegistry,\n): BlockNode {\n\tconst spec = registry?.getNodeSpec(block.type);\n\tconst attrs: Record<string, BlockAttrValue> = { ...block.attrs };\n\tlet changed = false;\n\tfor (const [name, value] of Object.entries(inherited)) {\n\t\tif (attrs[name] !== undefined) continue;\n\t\tif (registry && !spec?.attrs?.[name]) continue;\n\t\tattrs[name] = value;\n\t\tchanged = true;\n\t}\n\tif (!changed) return block;\n\treturn createBlockNode(block.type, block.children, block.id, attrs, block.htmlId);\n}\n\n/** Whether an inline run carries meaningful content (non-whitespace text or any element). */\nfunction inlineRunHasContent(nodes: readonly ChildNode[]): boolean {\n\tfor (const node of nodes) {\n\t\tif (node.nodeType === Node.ELEMENT_NODE) return true;\n\t\tif (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) return true;\n\t}\n\treturn false;\n}\n\n/**\n * Parses an HTML element's inline children into (TextNode | InlineNode)[].\n * Applies mark parse rules and inline node parse rules.\n */\nfunction parseElementToInlineContent(\n\tel: HTMLElement,\n\tsession: HTMLParseSession,\n\tskipNestedLists?: boolean,\n): (TextNode | InlineNode)[] {\n\treturn parseNodesToInlineContent([el], session, skipNestedLists);\n}\n\n/**\n * Walks a list of sibling DOM nodes into inline content, applying mark and\n * inline-node parse rules. DOM ancestors retain the formatting of transparent\n * wrappers even after those wrappers cease to be model blocks. Mixed text and\n * inline elements still coalesce into one sequence with their own marks intact.\n */\nfunction parseNodesToInlineContent(\n\tnodes: readonly ChildNode[],\n\tsession: HTMLParseSession,\n\tskipNestedLists?: boolean,\n): (TextNode | InlineNode)[] {\n\tconst result: (TextNode | InlineNode)[] = [];\n\tfor (const node of nodes) {\n\t\twalkElement(\n\t\t\tnode,\n\t\t\tsession.ancestorMarks(node),\n\t\t\tresult,\n\t\t\tsession.markRules,\n\t\t\tsession.inlineRules,\n\t\t\tskipNestedLists,\n\t\t);\n\t}\n\n\t// A lone <br> as the only content of a block is a placeholder for an empty\n\t// paragraph (e.g. `<p><br></p>`), not a real hard break. Normalize to empty text.\n\tif (result.length === 1 && isInlineNode(result[0]) && result[0].inlineType === 'hard_break') {\n\t\treturn [createTextNode('')];\n\t}\n\n\treturn result.length > 0 ? result : [createTextNode('')];\n}\n\n/**\n * Recursively walks DOM nodes, collecting marks from parse rules,\n * matching inline node parse rules, and producing TextNodes/InlineNodes.\n */\nfunction walkElement(\n\tnode: Node,\n\tcurrentMarks: readonly Mark[],\n\tresult: (TextNode | InlineNode)[],\n\tmarkRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n\tinlineRules: readonly { readonly rule: ParseRule; readonly type: string }[],\n\tskipNestedLists?: boolean,\n): void {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\tconst text: string = node.textContent ?? '';\n\t\tif (text) {\n\t\t\tresult.push(createTextNode(text, [...currentMarks]));\n\t\t}\n\t\treturn;\n\t}\n\n\tif (node.nodeType !== Node.ELEMENT_NODE) return;\n\n\tconst el = node as HTMLElement;\n\tconst tag: string = el.tagName.toLowerCase();\n\n\t// Skip nested lists inside <li> (handled by parseListElement)\n\tif (skipNestedLists && (tag === 'ul' || tag === 'ol')) return;\n\n\t// Skip checkbox inputs inside list items (already handled by parseListElement)\n\tif (skipNestedLists && tag === 'input' && el.getAttribute('type') === 'checkbox') return;\n\n\t// Inline nodes are atomic and take precedence over descendant markup.\n\tconst inlineMatch = matchHTMLParseRule(el, inlineRules);\n\tif (inlineMatch) {\n\t\tresult.push(\n\t\t\tcreateInlineNode(\n\t\t\t\tinlineType(inlineMatch.type) as InlineTypeName,\n\t\t\t\tinlineMatch.attrs as Readonly<Record<string, string | number | boolean>> | undefined,\n\t\t\t\tcurrentMarks,\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\n\tconst marks: Mark[] = parseHTMLMarks(el, currentMarks, markRules);\n\tfor (const child of Array.from(el.childNodes)) {\n\t\twalkElement(child, marks, result, markRules, inlineRules, skipNestedLists);\n\t}\n}\n\n/** Extracts a validated `dir` attribute or inline `direction` style from an element. */\nfunction extractDirection(el: HTMLElement, attrs: Record<string, string | number | boolean>): void {\n\tconst dir: string | null = el.getAttribute('dir');\n\tif (dir && VALID_DIRECTIONS.has(dir)) {\n\t\tattrs.dir = dir;\n\t\treturn;\n\t}\n\n\t// Fallback: check inline style `direction: rtl/ltr` (common in paste from Word/Docs)\n\tconst styleDir: string = el.style?.direction ?? '';\n\tif (styleDir && VALID_DIRECTIONS.has(styleDir)) {\n\t\tattrs.dir = styleDir;\n\t}\n}\n\n/** Reads a conforming document-local HTML target from a block element. */\nfunction extractHTMLId(el: HTMLElement): string | undefined {\n\treturn normalizeHTMLId(el.getAttribute('id'));\n}\n\n/**\n * Adds the element's validated alignment to attrs: its inline `text-align`,\n * which rehydration also derives from alignment classes.\n */\nfunction extractAlignment(el: HTMLElement, attrs: Record<string, string | number | boolean>): void {\n\tconst align: BlockAlignment | undefined = readElementAlignment(el);\n\tif (align) attrs.align = align;\n}\n"],"mappings":"0aAQA,IAAM,iBAAkC,IAAI,IAAI,CAAC,IAAK,MAAO,KAAM,KAAM,QAAS,eAGlF,SAAgB,EACf,EACA,GAEA,MAAM,EAAc,EAAQ,QAAQ,cACpC,IAAK,MAAM,KAAE,EAAA,KAAM,KAAU,EAAO,CACnC,GAAI,EAAK,MAAQ,EAAK,SACtB,MAAM,EAAQ,EAAK,WAAW,GAC9B,IAAc,IAAV,EAAiB,MAAO,CAAE,UAAU,EAAQ,CAAE,SAAU,CAAC,EAC9D,CACA,OAAO,IACR,CAGA,SAAgB,EACf,EACA,EACA,GAEA,MAAM,EAAc,EAAG,QAAQ,cACzB,EAAgB,IAAI,GAE1B,IAAK,MAAM,KAAE,EAAA,KAAM,KAAU,EAAW,CACvC,GAAI,EAAK,MAAQ,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B,GAAI,IAA4B,OAAR,GAAwB,OAAR,GAAe,OAGvD,GAAI,GAA2B,UAAR,GAA+C,aAA5B,EAAG,aAAa,QAAwB,OAGlF,MAAM,EAAc,EAAmB,EAAI,GAC3C,GAAI,EAQH,YAPA,EAAO,KACN,EACC,EAAW,EAAY,MACvB,EAAY,MACZ,IAMH,MAAM,EAAgB,EAAe,EAAI,EAAc,GACvD,IAAK,MAAM,KAAS,MAAM,KAAK,EAAG,YACjC,GAAY,EAAO,EAAO,EAAQ,EAAW,EAAa,EAE5D,CAGA,SAAS,GAAiB,EAAiB,GAC1C,MAAM,EAAqB,EAAG,aAAa,OAC3C,GAAI,GAAO,EAAiB,IAAI,GAE/B,YADA,EAAM,IAAM,GAKb,MAAM,EAAmB,EAAG,OAAO,WAAa,GAC5C,GAAY,EAAiB,IAAI,KACpC,EAAM,IAAM,EAEd,CAGA,SAAS,GAAc,GACtB,OAAO,EAAgB,EAAG,aAAa,MACxC,CAMA,SAAS,GAAiB,EAAiB,GAC1C,MAAM,EAAoC,EAAqB,GAC3D,IAAO,EAAM,MAAQ,EAC1B"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as t}from"./TypeBrands-Ch9856Gb.mjs";import{i as e,n as o,r as n,t as i}from"./AttributedMarkCommands-DKHuhZA7.mjs";import{c as s,n as r,o as a}from"./PluginHelpers-B3gk3VB3.mjs";import{c as l,n as c}from"./StyleRuntime-C0RSqKzG.mjs";import{r as m}from"./ColorValidation-ZBKZ_gTr.mjs";import{n as f,t as p}from"./InlineStyleMarkSpec-BhfGgfH9.mjs";import{t as d}from"./StyleClassNames-BsAx7k5T.mjs";var h={label:"Font",tooltip:"Font Family"},g=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-DahJwMI9.mjs"),"./locales/de.ts":()=>import("./de-DiPz7abS.mjs"),"./locales/es.ts":()=>import("./es-CCQFu1t1.mjs"),"./locales/fr.ts":()=>import("./fr-BwWrFThE.mjs"),"./locales/hi.ts":()=>import("./hi-B-ZuX4aN.mjs"),"./locales/pt.ts":()=>import("./pt-Dg2ctkug.mjs"),"./locales/ru.ts":()=>import("./ru-DJMpeuey.mjs"),"./locales/zh.ts":()=>import("./zh-CRsDvfPR.mjs")});async function u(t){return s(g,t,h)}var y={type:"font",rank:6,valueAttr:"family",domStyleProperty:"fontFamily",cssProperty:"font-family",validate:m,transformParsed:t=>t.replace(/"/g,"'")},v=class{id="font";name="Font";priority=22;config;locale;injectedStyleElement=null;context=null;constructor(t){this.config=t}async init(t){this.locale=await a(t,this.config.locale,h,u),t.registerStyleSheet(".notectl-toolbar-btn--font{min-width:100px;max-width:160px}.notectl-font-picker{min-width:200px;max-height:320px;overflow-y:auto}.notectl-font-picker__list{padding:4px 0}.notectl-font-picker__item{cursor:pointer;width:100%;color:var(--notectl-fg);text-align:start;white-space:nowrap;background:0 0;border:none;align-items:center;gap:8px;padding:7px 12px;font-family:inherit;font-size:14px;line-height:1.4;transition:background .1s;display:flex}@media (hover:hover){.notectl-font-picker__item:hover{background:var(--notectl-hover-bg)}}.notectl-font-picker__item--active{background:var(--notectl-active-bg);color:var(--notectl-accent-fg)}@media (hover:hover){.notectl-font-picker__item--active:hover{background:var(--notectl-active-bg)}}.notectl-font-picker__check{width:16px;color:var(--notectl-accent-fg);flex-shrink:0;justify-content:center;align-items:center;font-size:13px;font-weight:600;display:inline-flex}.notectl-font-picker__label{flex:1}.notectl-font-picker__separator{background:var(--notectl-border);height:1px;margin:4px 8px}"),this.context=t,this.registerMarkSpec(t),this.registerStyleClasses(t),this.registerCommands(t),this.config.fonts.length>0&&this.registerToolbarItem(t),this.injectFontFaces()}destroy(){this.injectedStyleElement?.remove(),this.injectedStyleElement=null,this.context=null}registerMarkSpec(t){const e=this.config.fonts.map(t=>t.family);t.registerMarkSpec(p({...y,knownValues:e}))}registerStyleClasses(t){d(t,"FontPlugin",this.config.styleClasses,t=>f(y.cssProperty,this.familyOf(t)))}familyOf(t){const e=this.config.fonts.find(e=>e.name===t);if(e)return e.family;const o=this.config.fonts.map(t=>`"${t.name}"`).join(", ")||"none";throw new TypeError(`"${t}" is not the name of a configured font; configured: ${o}.`)}registerCommands(t){t.registerCommand("removeFont",()=>{const e=t.getState();return this.removeFont(t,e)}),t.registerCommand("setFont",()=>!1)}get defaultFont(){if(this.config.defaultFont){const t=this.config.fonts.find(t=>t.name===this.config.defaultFont);if(t)return t}return this.config.fonts[0]}registerToolbarItem(t){t.registerToolbarItem({id:"font",group:"format",label:this.locale.label,tooltip:this.locale.tooltip,command:"removeFont",popupType:"combobox",getLabel:t=>this.resolveFontName(this.getActiveFont(t)),renderPopup:(t,e,o)=>{this.renderFontPopup(t,e,o)},isActive:t=>this.isFontActive(t)})}resolveFontName(t){return t?this.config.fonts.find(e=>e.family===t)?.name??(t.split(",")[0]??"").trim().replace(/['"]/g,""):this.defaultFont?.name??this.locale.label}isFontActive(t){return n(t,"font")}getActiveFont(t){return o(t,"font",t=>t.attrs.family??null)}applyFont(e,o,n){const s={type:t("font"),attrs:{family:n}};return r(e,i(o,s))}removeFont(o,n){return r(o,e(n,t("font")))}injectFontFaces(){const t=[];for(const n of this.config.fonts)if(n.fontFaces?.length)for(const e of n.fontFaces){const o=[`font-family: '${(n.family.split(",")[0]??"").trim().replace(/['"]/g,"")}'`,`src: ${e.src}`];e.weight&&o.push(`font-weight: ${e.weight}`),e.style&&o.push(`font-style: ${e.style}`),o.push(`font-display: ${e.display??"swap"}`),t.push(`@font-face {\n\t${o.join(";\n\t")};\n}`)}if(0===t.length)return;const e=document.createElement("style");e.setAttribute("data-notectl-fonts","");const o=this.context?c(this.context.getContainer()):void 0;o&&e.setAttribute("nonce",o),e.textContent=t.join("\n\n"),document.head.appendChild(e),this.injectedStyleElement=e}renderFontPopup(t,e,o){t.classList.add("notectl-font-picker");const n=e.getState(),i=this.getActiveFont(n),s=this.defaultFont?.family,r=e.getContainer(),a=document.createElement("div");a.className="notectl-font-picker__list",a.setAttribute("role","listbox"),a.setAttribute("aria-label",this.locale.label);for(const l of this.config.fonts){const t=void 0!==s&&l.family===s,n=t&&!i||i===l.family,c=this.createFontItem(l.name,l.family,n,()=>{t?e.executeCommand("removeFont"):this.applyFont(e,e.getState(),l.family),o({restoreFocusTo:r})});l.category&&c.setAttribute("data-category",l.category),a.appendChild(c)}t.appendChild(a)}createFontItem(t,e,o,n){const i=document.createElement("button");i.type="button",i.className="notectl-font-picker__item",i.setAttribute("role","option"),i.setAttribute("aria-selected",String(o)),o&&i.classList.add("notectl-font-picker__item--active");const s=document.createElement("span");s.className="notectl-font-picker__check",s.textContent=o?"✓":"",i.appendChild(s);const r=document.createElement("span");return r.className="notectl-font-picker__label",r.textContent=t,e&&l(r,"fontFamily",e),i.appendChild(r),i.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),i.addEventListener("click",n),i}};export{h as n,u as r,v as t};
|
|
2
|
-
//# sourceMappingURL=FontPlugin-BcXNFqqO.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FontPlugin-BcXNFqqO.mjs","names":[],"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":"2ZCaa,EAA6B,CACzC,MAAO,OACP,QAAS,eAKJ,iBAA6C,OAAA,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,uBAInD,eAAsB,EAAe,GACpC,OAAO,EAAiB,EAAe,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IpB,MAAM,EAAyB,SAAS,cAAc,QACtD,EAAM,UAAY,6BAClB,EAAM,YAAc,EAAW,IAAW,GAC1C,EAAK,YAAY,GAGjB,MAAM,EAAyB,SAAS,cAAc,QAatD,OAZA,EAAM,UAAY,6BAClB,EAAM,YAAc,EAChB,GACH,EAAiB,EAAO,aAAc,GAEvC,EAAK,YAAY,GAEjB,EAAK,iBAAiB,YAAc,IACnC,EAAE,iBACF,EAAE,oBAEH,EAAK,iBAAiB,QAAS,GACxB,CACR"}
|
|
@@ -1,2 +0,0 @@
|
|
|
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{c as m,n as h,o as k}from"./PluginHelpers-B3gk3VB3.mjs";import{c as g}from"./StyleRuntime-C0RSqKzG.mjs";import{i as z}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/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 m(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 N(t){const e=t?.fontSize;return"string"==typeof e&&e.length>0?e:null}function C(t,e){return{...t??{},fontSize:e}}function A(t){return N(t.attrs)}function j(t,e,n,o){const i=e.transaction("command");return"block"===n.kind?i.setNodeAttr(n.path,C(n.attrs,o)):i.setInlineNodeAttr(n.blockId,n.offset,C(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=N(s.attrs);n===t||""===n&&null===t||("blockNode"===s.kind?i.setNodeAttr(s.path,C(s.attrs,n)):i.setInlineNodeAttr(s.blockId,s.offset,C(s.attrs,n)),r=!0)}return!!r&&(i.setSelection(e.selection),t.dispatch(i.build()),!0)}function P(t){const e=F(t).filter(t=>"text"!==t.kind).map(t=>t.attrs);return 0===e.length?null:new Set(e.map(t=>N(t)??""))}function L(t){return`${t}px`}function D(t,e){const n=function(t){const e=I(t);if(e)return A(e);const n=P(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 B(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 h(t,p(e,o))}return M(t,e,n)}function O(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)?h(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?O(t,e):B(t,e,L(r)))}function V(t,e,n){e===n?t.executeCommand("removeFontSize"):B(t,t.getState(),L(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],H={type:"fontSize",rank:4,valueAttr:"size",domStyleProperty:"fontSize",cssProperty:"font-size",validate:z},J=/^[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 k(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(H))}registerStyleClasses(t){v(t,"FontSizePlugin",this.config.styleClasses,t=>b(H.cssProperty,L(function(t){if(!J.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",()=>O(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=P(t);return!(!n||![...n].some(t=>t.length>0))||d(t,"fontSize")}(t)})}applyDefaultSizeToContainer(t){const e=t.getContainer();g(e,"fontSize",`${this.defaultSize}px`)}};export{x as n,_ as r,R as t};
|
|
2
|
-
//# sourceMappingURL=FontSizePlugin-BQ9Aj8cT.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FontSizePlugin-BQ9Aj8cT.mjs","names":[],"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":"8hBCea,EAAsC,CAClD,MAAO,YACP,QAAS,YACT,mBAAoB,mBACpB,cAAe,cAKV,iBAAiD,OAAA,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,uBAIvD,eAAsB,EAAmB,GACxC,OAAO,EAAiB,EAAe,EAAM,EAC9C,CCsBA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AAO,QAAQ,CAAE,eAAgB,EAAO,mBAG3C,CAtLC,CAAyB,EAAO,EAAM,EAAO,EAAS,EACvD,CC2II,CAAoB,EAAW,EAAK,CACnC,MAAO,KAAK,MACZ,YAAa,KAAK,YAClB,UACA,eAAgB,EAAI,eACpB,OAAQ,KAAK,UAGf,SAAW,GF+Hd,SAAiC,GAChC,MAAM,EAAS,EAAmB,GAClC,GAAI,EAAQ,OAAqC,OAA9B,EAAkB,GACrC,MAAM,EAAQ,EAAe,GAC7B,SAAI,IAAS,IAAI,GAAO,KAAM,GAAS,EAAK,OAAS,KAC9C,EAAuB,EAAO,WACtC,CErIwB,CAAiB,IAExC,CAOA,2BAAA,CAAoC,GACnC,MAAM,EAAyB,EAAQ,eACvC,EAAiB,EAAW,WAAY,GAAG,KAAK,gBACjD"}
|
|
@@ -1,2 +0,0 @@
|
|
|
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}from"./Selection-DC6AOGgF.mjs";import{a as p,r as u}from"./TypeBrands-Ch9856Gb.mjs";import{c as d,w as m}from"./BlockInsertion-CxKdCKJd.mjs";import{t as h}from"./Commands-DBBCAYBn.mjs";import{n as f}from"./HTMLSanitization-Ce9dVT1q.mjs";import{c as b,i as g,o as v}from"./PluginHelpers-B3gk3VB3.mjs";import{n as x}from"./DomUtils-Bf7JLFlx.mjs";import{t as y}from"./SelectionSync-BkjCwGp-.mjs";import{a as w}from"./PopupPositioning-CIqgpqlW.mjs";import{i as L}from"./ColorValidation-ZBKZ_gTr.mjs";var k={"&":"&","<":"<",">":">"},S={"&":"&","<":"<",">":">",'"':"""};function C(t){return t.replace(/[&<>]/g,t=>k[t]??t)}function $(t){return t.replace(/[&<>"]/g,t=>S[t]??t)}function A(t){if(!t)return"";let e="";for(const[n,i]of Object.entries(t))!1!==i&&null!=i&&(e+=!0!==i?` ${n}="${$(String(i))}"`:` ${n}="true"`);return e}function z(t,e,n){return`<${t}${A(n)}>${e}</${t}>`}function _(t,e){return z("mi",C(t),e)}function E(t,e){return z("mn",C(t),e)}function B(t,e){return z("mo",C(t),e)}function I(t,e){return z("mtext",C(t),e)}function O(t){return function(t,e){return`<${t}${A(e)}></${t}>`}("mspace",t)}function P(t,e){return z("mrow",t,e)}function D(t){return 0===t.length?"":1===t.length?t[0]??"":P(t.join(""))}function N(t,e,n){return z("mfrac",`${t}${e}`,n)}function F(t,e,n){return z("mover",`${t}${e}`,n)}function q(t,e,n){return z("munder",`${t}${e}`,n)}function R(t){return z("mtd",t)}function T(t){return z("mtr",t.map(R).join(""))}var j={"&":"&","<":"<",">":">",""":'"',"'":"'","'":"'"};function M(t){const e=t.display?"block":"inline",n=t.alt?` alttext="${$(t.alt)}"`:"",i=void 0!==t.latex&&""!==t.latex,a=`<annotation encoding="application/x-tex">${C(t.latex??"")}</annotation>`;return`<math display="${e}"${n}>${i?`<semantics>${t.presentation}${a}</semantics>`:t.presentation}</math>`}function H(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 G(t){return t.replace(/^(<math\b[^>]*?)\s+mathsize=(?:"[^"]*"|'[^']*')/i,"$1")}var U=/<math[\s>]/i;function K(t){return U.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="${$(e)}"`):n}(t.mathml,t.alt):""}function W(t,e){const n=K(e);n?t.innerHTML=n:t.textContent=e.latex||e.alt||"⊡"}function V(t,e){const n="string"==typeof e?.fontSize?e.fontSize:"";t.style.fontSize=n}function Z(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 X(t){const e=K(t);return e?function(t,e){const n=G(t);return e?n.replace(/^<math\b/i,`<math mathsize="${$(e)}"`):n}(e,L(t.fontSize)?t.fontSize:""):e}function Q(t){const e=t.getAttribute("mathsize")??"";return L(e)?e:""}function J(t,e){if("block"===t.getAttribute("display")!==e)return!1;const n=G(function(t){return t.replace(/^(<math\b[^>]*?)\s+data-block-id=(?:"[^"]*"|'[^']*')/i,"$1")}(t.outerHTML));return{mathml:n,latex:H(n)??"",alt:t.getAttribute("alttext")??"",fontSize:Q(t)}}var Y="math_inline",tt="math_display",et={insertInline:"Mod-Shift-E",insertDisplay:"Mod-Shift-M"},nt=[12,16,20,24,32,40,48,64,96],it={},at=["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"],rt=["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 ot(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 lt(t){return{mathml:t.mathml,latex:t.latex,alt:t.alt,fontSize:t.fontSize}}function st(t,e){const i=t.selection;if(0===e.length||!l(i))return null;const a=t.transaction("command"),o=r(i)?void 0:h(t,a);let s,p;if(o)s=o,p=0;else{const e=m(i,t.getBlockOrder());s=e.blockId,p=e.offset}for(const r of e)a.insertInlineNode(s,p,n(u(Y),lt(r))),p+=1;return a.setSelection(c(s,p)),a.build()}function ct(t,e){const n=g(t);if(0===e.length||!n)return null;const a=e.map(t=>i(p(tt),[],void 0,lt(t))),r=t.transaction("command");if(!d(t,r,n,a))return null;const o=a[a.length-1];return o?(r.setSelection(s(o.id,[])),r.build()):null}function pt(t){return{mathml:t.mathml,latex:t.latex,alt:t.alt,fontSize:t.fontSize}}function ut(t,e,n){const i=pt(n);n.display?function(t,e){const n=function(t,e){return ct(t,[e])}(t.getState(),e);!!n&&t.dispatch(n)}(t,i):function(t,e){const n=function(t,e){return st(t,[e])}(t.getState(),e);!!n&&t.dispatch(n)}(t,i),t.announce(e.inserted)}function dt(t,e){return void 0===e?{node:t}:{node:t,kind:e}}function mt(t,e,n=!1){return{node:t,kind:e,bigOp:!0,intLike:n}}function ht(t,e){return Object.hasOwn(t,e)?t[e]:void 0}var ft=/* @__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 bt(t,e){return{char:t,kind:e}}var gt="ordinary",vt="binary",xt="relation",yt="arrow",wt="function",Lt="bigop",kt="punct",St={alpha:bt("α",gt),beta:bt("β",gt),gamma:bt("γ",gt),delta:bt("δ",gt),epsilon:bt("ϵ",gt),varepsilon:bt("ε",gt),zeta:bt("ζ",gt),eta:bt("η",gt),theta:bt("θ",gt),vartheta:bt("ϑ",gt),iota:bt("ι",gt),kappa:bt("κ",gt),lambda:bt("λ",gt),mu:bt("μ",gt),nu:bt("ν",gt),xi:bt("ξ",gt),omicron:bt("ο",gt),pi:bt("π",gt),varpi:bt("ϖ",gt),rho:bt("ρ",gt),varrho:bt("ϱ",gt),sigma:bt("σ",gt),varsigma:bt("ς",gt),tau:bt("τ",gt),upsilon:bt("υ",gt),phi:bt("ϕ",gt),varphi:bt("φ",gt),chi:bt("χ",gt),psi:bt("ψ",gt),omega:bt("ω",gt),Gamma:bt("Γ",gt),Delta:bt("Δ",gt),Theta:bt("Θ",gt),Lambda:bt("Λ",gt),Xi:bt("Ξ",gt),Pi:bt("Π",gt),Sigma:bt("Σ",gt),Upsilon:bt("Υ",gt),Phi:bt("Φ",gt),Psi:bt("Ψ",gt),Omega:bt("Ω",gt)},Ct={sin:bt("sin",wt),cos:bt("cos",wt),tan:bt("tan",wt),cot:bt("cot",wt),sec:bt("sec",wt),csc:bt("csc",wt),sinh:bt("sinh",wt),cosh:bt("cosh",wt),tanh:bt("tanh",wt),coth:bt("coth",wt),arcsin:bt("arcsin",wt),arccos:bt("arccos",wt),arctan:bt("arctan",wt),log:bt("log",wt),ln:bt("ln",wt),lg:bt("lg",wt),exp:bt("exp",wt),deg:bt("deg",wt),det:bt("det",wt),dim:bt("dim",wt),hom:bt("hom",wt),ker:bt("ker",wt),arg:bt("arg",wt),Pr:bt("Pr",wt)},$t={sum:bt("∑",Lt),prod:bt("∏",Lt),coprod:bt("∐",Lt),int:bt("∫",Lt),iint:bt("∬",Lt),iiint:bt("∭",Lt),oint:bt("∮",Lt),bigcup:bt("⋃",Lt),bigcap:bt("⋂",Lt),bigsqcup:bt("⨆",Lt),bigvee:bt("⋁",Lt),bigwedge:bt("⋀",Lt),bigoplus:bt("⨁",Lt),bigotimes:bt("⨂",Lt),bigodot:bt("⨀",Lt),biguplus:bt("⨄",Lt),lim:bt("lim",Lt),limsup:bt("lim sup",Lt),liminf:bt("lim inf",Lt),injlim:bt("inj lim",Lt),projlim:bt("proj lim",Lt),max:bt("max",Lt),min:bt("min",Lt),sup:bt("sup",Lt),inf:bt("inf",Lt),gcd:bt("gcd",Lt)},At={times:bt("×",vt),div:bt("÷",vt),pm:bt("±",vt),mp:bt("∓",vt),cdot:bt("⋅",vt),ast:bt("∗",vt),star:bt("⋆",vt),circ:bt("∘",vt),bullet:bt("∙",vt),oplus:bt("⊕",vt),ominus:bt("⊖",vt),otimes:bt("⊗",vt),oslash:bt("⊘",vt),odot:bt("⊙",vt),cap:bt("∩",vt),cup:bt("∪",vt),uplus:bt("⊎",vt),sqcap:bt("⊓",vt),sqcup:bt("⊔",vt),wedge:bt("∧",vt),land:bt("∧",vt),vee:bt("∨",vt),lor:bt("∨",vt),setminus:bt("∖",vt),wr:bt("≀",vt),diamond:bt("⋄",vt),bigtriangleup:bt("△",vt),bigtriangledown:bt("▽",vt),triangleleft:bt("◁",vt),triangleright:bt("▷",vt),amalg:bt("⨿",vt),dagger:bt("†",vt),ddagger:bt("‡",vt)},zt={leq:bt("≤",xt),le:bt("≤",xt),geq:bt("≥",xt),ge:bt("≥",xt),neq:bt("≠",xt),ne:bt("≠",xt),equiv:bt("≡",xt),sim:bt("∼",xt),simeq:bt("≃",xt),cong:bt("≅",xt),approx:bt("≈",xt),propto:bt("∝",xt),prec:bt("≺",xt),succ:bt("≻",xt),preceq:bt("⪯",xt),succeq:bt("⪰",xt),ll:bt("≪",xt),gg:bt("≫",xt),lll:bt("⋘",xt),ggg:bt("⋙",xt),subset:bt("⊂",xt),supset:bt("⊃",xt),subseteq:bt("⊆",xt),supseteq:bt("⊇",xt),subsetneq:bt("⊊",xt),supsetneq:bt("⊋",xt),sqsubseteq:bt("⊑",xt),sqsupseteq:bt("⊒",xt),in:bt("∈",xt),ni:bt("∋",xt),notin:bt("∉",xt),mid:bt("∣",xt),parallel:bt("∥",xt),perp:bt("⊥",xt),models:bt("⊨",xt),vdash:bt("⊢",xt),dashv:bt("⊣",xt),doteq:bt("≐",xt),asymp:bt("≍",xt),bowtie:bt("⋈",xt),smile:bt("⌣",xt),frown:bt("⌢",xt)},_t={leftarrow:bt("←",yt),gets:bt("←",yt),rightarrow:bt("→",yt),to:bt("→",yt),leftrightarrow:bt("↔",yt),Leftarrow:bt("⇐",yt),Rightarrow:bt("⇒",yt),Leftrightarrow:bt("⇔",yt),mapsto:bt("↦",yt),longrightarrow:bt("⟶",yt),longleftarrow:bt("⟵",yt),longleftrightarrow:bt("⟷",yt),Longrightarrow:bt("⟹",yt),Longleftarrow:bt("⟸",yt),Longleftrightarrow:bt("⟺",yt),implies:bt("⟹",yt),iff:bt("⟺",yt),uparrow:bt("↑",yt),downarrow:bt("↓",yt),updownarrow:bt("↕",yt),nearrow:bt("↗",yt),searrow:bt("↘",yt),swarrow:bt("↙",yt),nwarrow:bt("↖",yt),hookleftarrow:bt("↩",yt),hookrightarrow:bt("↪",yt),rightharpoonup:bt("⇀",yt),rightharpoondown:bt("⇁",yt),leftharpoonup:bt("↼",yt),leftharpoondown:bt("↽",yt),nleftarrow:bt("↚",yt),nrightarrow:bt("↛",yt)},Et={langle:bt("⟨","open"),rangle:bt("⟩","close"),lceil:bt("⌈","open"),rceil:bt("⌉","close"),lfloor:bt("⌊","open"),rfloor:bt("⌋","close"),lbrace:bt("{","open"),rbrace:bt("}","close"),lbrack:bt("[","open"),rbrack:bt("]","close"),lvert:bt("|","open"),rvert:bt("|","close"),lVert:bt("‖","open"),rVert:bt("‖","close"),vert:bt("|","relation"),Vert:bt("‖","relation"),backslash:bt("\\",gt)},Bt={infty:bt("∞",gt),partial:bt("∂",gt),nabla:bt("∇",gt),forall:bt("∀",gt),exists:bt("∃",gt),nexists:bt("∄",gt),emptyset:bt("∅",gt),varnothing:bt("∅",gt),aleph:bt("ℵ",gt),beth:bt("ℶ",gt),hbar:bt("ℏ",gt),ell:bt("ℓ",gt),Re:bt("ℜ",gt),Im:bt("ℑ",gt),wp:bt("℘",gt),prime:bt("′",gt),angle:bt("∠",gt),measuredangle:bt("∡",gt),triangle:bt("△",gt),neg:bt("¬",gt),lnot:bt("¬",gt),top:bt("⊤",gt),bot:bt("⊥",gt),flat:bt("♭",gt),natural:bt("♮",gt),sharp:bt("♯",gt),clubsuit:bt("♣",gt),diamondsuit:bt("♢",gt),heartsuit:bt("♡",gt),spadesuit:bt("♠",gt),surd:bt("√",gt),complement:bt("∁",gt),square:bt("□",gt),blacksquare:bt("■",gt),bigstar:bt("★",gt),checkmark:bt("✓",gt),degree:bt("°",gt),cdots:bt("⋯",gt),ldots:bt("…",gt),dots:bt("…",gt),dotsb:bt("⋯",gt),vdots:bt("⋮",gt),ddots:bt("⋱",gt)},It={colon:bt(":",kt),cdotp:bt("·",kt),ldotp:bt(".",kt)},Ot={...St,...Ct,...$t,...At,...zt,..._t,...Et,...Bt,...It},Pt={"(":bt("(","open"),")":bt(")","close"),"[":bt("[","open"),"]":bt("]","close"),"|":bt("|","relation"),"/":bt("/",gt)};function Dt(t){if("."===t)return bt("",gt);if(t.startsWith("\\")){const e=t.slice(1);return"{"===e?bt("{","open"):"}"===e?bt("}","close"):"|"===e?bt("‖","relation"):"\\"===e?bt("\\",gt):ht(Et,e)}return ht(Pt,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}({}),Ft=/* @__PURE__ */new Set(["{","}","%","$","#","&","_",",",":",";","!"," ","|","\\",".","/","'","~","^"]);function qt(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function Rt(t){return t>="0"&&t<="9"}function Tt(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function jt(t,e,n){return{type:t,value:e,position:n}}function Mt(t,e){const n=t[e+1];if(void 0!==n&&!qt(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||!qt(e))break;i+=1}return jt("command",t.slice(e+1,i),e)}function Ht(t,e){let n=e;for(;n<t.length;){const e=t[n];if(void 0===e||!Rt(e))break;n+=1}if("."===t[n]&&void 0!==t[n+1]&&Rt(t[n+1]??""))for(n+=1;n<t.length;){const e=t[n];if(void 0===e||!Rt(e))break;n+=1}return jt("number",t.slice(e,n),e)}function Gt(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 Ut(t,e){return{glyph:t,under:!1,stretchy:e}}function Kt(t,e){return{glyph:t,under:!0,stretchy:e}}var Wt={hat:Ut("^",!1),widehat:Ut("^",!0),check:Ut("ˇ",!1),tilde:Ut("~",!1),widetilde:Ut("~",!0),bar:Ut("‾",!1),overline:Ut("‾",!0),vec:Ut("→",!1),overrightarrow:Ut("→",!0),overleftarrow:Ut("←",!0),overleftrightarrow:Ut("↔",!0),dot:Ut("˙",!1),ddot:Ut("¨",!1),dddot:Ut("⃛",!1),acute:Ut("´",!1),grave:Ut("`",!1),breve:Ut("˘",!1),mathring:Ut("˚",!1),overbrace:Ut("⏞",!0),underline:Kt("_",!0),underbrace:Kt("⏟",!0),underrightarrow:Kt("→",!0),underleftarrow:Kt("←",!0)},Vt={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 Zt(t){return t.type===Nt.Command&&"end"===t.value}function Xt(t){return t.type===Nt.Ampersand||t.type===Nt.RowBreak||t.type===Nt.Command&&"end"===t.value}var Qt={",":"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(Qt,t)}function Yt(t){const e=ht(Qt,t);if(void 0!==e)return O({width:e})}function te(){return O({width:"0.25em"})}function ee(t){const e=t.parseRawArgument();return n=e,Object.hasOwn(Vt,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(P(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(Zt(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(Xt);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=ht(Vt,t)??{open:"",close:""},a=(r=i.columnalign?{columnalign:i.columnalign}:void 0,z("mtable",n.map(T).join(""),r));var r;return i.open||i.close?dt(P(`${i.open?B(i.open,{stretchy:!0,fence:!0}):""}${a}${i.close?B(i.close,{stretchy:!0,fence:!0}):""}`)):dt(a)}(e,t):(t.error({message:"Unknown environment",command:e}),dt(z("merror",I(e))));var n}function ne(t){return t.type===Nt.Command&&"right"===t.value}function ie(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:z("merror",I(n))}):{kind:"fence",markup:ae(i)}}function ae(t){return""===t.char?"":B(t.char,{fence:!0,stretchy:!0})}var re={},oe={"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:re},italic:{upperBase:119860,lowerBase:119886,holes:{h:8462}},"sans-serif":{upperBase:120224,lowerBase:120250,digitBase:120802,holes:re},monospace:{upperBase:120432,lowerBase:120458,digitBase:120822,holes:re}};function le(t,e){if(1!==t.length)return null;const n=oe[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 se=/<(mi|mn)>([^<]*)<\/\1>/g,ce=/<mi>([^<]*)<\/mi>/g;var pe={mathbb:"double-struck",mathcal:"script",mathscr:"script",mathfrak:"fraktur",mathbf:"bold",mathit:"italic",mathsf:"sans-serif",mathtt:"monospace"},ue={boldsymbol:"bold-italic",bm:"bold-italic"},de={text:void 0,textnormal:"normal",textrm:"normal",textbf:"bold",textit:"italic",textsf:"sans-serif",texttt:"monospace",mbox:void 0};function me(t,e){if("operatorname"===t)return dt(_(e.parseRawArgument(),{mathvariant:"normal"}));if(Object.hasOwn(de,t)){const n=ht(de,t),i=e.parseRawArgument();return dt(n?I(i,{mathvariant:n}):I(i))}const n=ht(pe,t);if(void 0!==n)return dt((i=e.parseArgument(),a=n,i.replace(se,(t,e,n)=>{const i=function(t,e){let n="";for(const i of t)n+=le(i,e)??i;return n}(n,a);return"mn"===e?E(i):_(i)})));var i,a;if("mathrm"===t)return dt(e.parseArgument().replace(ce,(t,e)=>_(e,{mathvariant:"normal"})));const r=ht(ue,t),o=e.parseArgument();return dt(void 0===r?o:z("mstyle",o,{mathvariant:r}))}var he=/* @__PURE__ */new Set(["frac","dfrac","tfrac","cfrac"]),fe=/* @__PURE__ */new Set(["binom","dbinom","tbinom","choose"]),be=/* @__PURE__ */new Set(["overset","underset","stackrel"]);var ge=/* @__PURE__ */new Set(["∫","∬","∭","∮"]);var ve=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?B(a):P(`${B(a)}${n}`)),void 0===e&&void 0===n?t:dt(this.buildScripts(t,e,n,i))}combineSup(t,e){return void 0===t?e:(this.error({message:"Double superscript"}),P(`${t}${e}`))}combineSub(t,e){return void 0===t?e:(this.error({message:"Double subscript"}),P(`${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 z("munderover",`${t}${e}${n}`)}(t.node,e,n);if(void 0!==e)return q(t.node,e);if(void 0!==n)return F(t.node,n)}return void 0!==e&&void 0!==n?function(t,e,n){return z("msubsup",`${t}${e}${n}`)}(t.node,e,n):void 0!==e?function(t,e){return z("msub",`${t}${e}`)}(t.node,e):void 0!==n?function(t,e){return z("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}),dt(z("merror",I("⋯")))}parseBaseAtomInner(){const t=this.next();if(void 0!==t)switch(t.type){case Nt.Number:return dt(E(t.value));case Nt.Char:return this.parseChar(t.value);case Nt.GroupOpen:return this.parseGroup();case Nt.NbSpace:return dt(te());case Nt.Command:return this.parseCommand(t);case Nt.Superscript:case Nt.Subscript:case Nt.Prime:return this.pos-=1,this.attachScripts(dt(P("")));case Nt.Ampersand:case Nt.RowBreak:case Nt.GroupClose:default:return}}parseGroup(){const t=this.parseExpression(()=>!1);return this.expect(Nt.GroupClose),dt(D(t.map(t=>t.node)))}parseChar(t){const e=Dt(t);return!e||e.kind!==ft.Open&&e.kind!==ft.Close?dt("+"===t||"-"===t||"*"===t||"="===t||"/"===t||"|"===t||","===t||";"===t||"."===t||":"===t||"!"===t||"?"===t||"<"===t||">"===t?B(t):_(t)):dt(B(t,{fence:!0}),e.kind)}parseCommand(t){const e=t.value,n=function(t){return ht(Ot,t)}(e);if(n)return this.symbolAtom(n);if(1===(i=e).length&&Ft.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}),dt(z("merror",I(`\\${e}`))))}dispatchStructural(t){if(function(t){return he.has(t)}(t))return dt(N((e=this).parseArgument(),e.parseArgument()));var e;if(function(t){return fe.has(t)}(t))return function(t){const e=N(t.parseArgument(),t.parseArgument(),{linethickness:0});return dt(P(`${B("(",{fence:!0})}${e}${B(")",{fence:!0})}`))}(this);if("sqrt"===t)return function(t){const e=t.parseOptionalArgument(),n=t.parseArgument();return dt(void 0===e||""===e?function(t){return z("msqrt",t)}(n):function(t,e){return z("mroot",`${t}${e}`)}(n,e))}(this);if(function(t){return be.has(t)}(t))return function(t,e){const n=e.parseArgument(),i=e.parseArgument();return dt("underset"===t?q(i,n):F(i,n))}(t,this);if(function(t){return Object.hasOwn(Wt,t)}(t))return function(t,e){const n=ht(Wt,t);if(!n)return dt("");const i=e.parseArgument(),a=B(n.glyph,{stretchy:n.stretchy}),r=n.under?{accentunder:!0}:{accent:!0};return dt(n.under?q(i,a,r):F(i,a,r))}(t,this);if(function(t){return Object.hasOwn(pe,t)||Object.hasOwn(ue,t)||Object.hasOwn(de,t)||"mathrm"===t||"operatorname"===t}(t))return me(t,this);if(Jt(t)){const e=Yt(t);return void 0===e?void 0:dt(e)}}dispatchSpecial(t,e){return"left"===t?function(t){const e=ie(t),n=t.parseAtomsUntil(ne),i=t.peek();let a="";return void 0!==i&&ne(i)?(t.next(),a=ie(t).markup):t.error({message:"Unmatched \\left"}),dt(D([e.markup,...n.map(t=>t.node),a]))}(this):"begin"===t?ee(this):"pmod"===t?function(t){const e=t.parseArgument(),n=B("(",{fence:!0}),i=B(")",{fence:!0});return dt(P(`${n}${I("mod")}${te()}${e}${i}`))}(this):"bmod"===t||"mod"===t?dt(B("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=>z("mtr",z("mtd",t))).join("");return dt(z("mtable",i))}(this):"right"===t?function(t,e){const n=ie(t);return t.error({message:"Unmatched \\right",position:e}),dt("error"===n.kind?n.markup:D([]))}(this,e.position):void 0}symbolAtom(t){switch(t.kind){case ft.Ordinary:return dt(_(t.char),t.kind);case ft.Function:return dt(_(t.char,{mathvariant:"normal"}),t.kind);case ft.BigOp:return this.bigOperator(t);case ft.Open:case ft.Close:return dt(B(t.char,{fence:!0}),t.kind);default:return dt(B(t.char),t.kind)}}bigOperator(t){if(/[a-z]/i.test(t.char))return mt(B(t.char,{movablelimits:!0}),t.kind);const e=ge.has(t.char);return mt(B(t.char,{movablelimits:!0,largeop:!0}),t.kind,e)}controlSymbolAtom(t){if(Jt(t)){const e=Yt(t);return void 0===e?void 0:dt(e)}return"{"===t?dt(B("{",{fence:!0}),ft.Open):"}"===t?dt(B("}",{fence:!0}),ft.Close):dt("|"===t?B("‖"):"\\"===t?B("\\"):"/"===t?B("/"):"'"===t?B("′"):"."===t?B("."):I(t))}parseArgument(){return""===(t=this.parseBaseAtom()?.node??"")?P(""):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()}},xe="<mrow></mrow>";function ye(t,e){const n=e?.display??!1;if(""===t.trim())return{presentation:xe,errors:[]};const{atoms:i,errors:a}=function(t,e){const n=new ve(t,function(t){const e=[];let n=0;for(;n<t.length;){const i=t[n]??"";if("\\"===i){const i=Mt(t,n);if(e.push(i),n+="rowBreak"===i.type?2:Math.max(1,i.value.length)+1,"command"===i.type&&qt(i.value[0]??""))for(;n<t.length&&Tt(t[n]??"");)n+=1;continue}if(Rt(i)){const i=Ht(t,n);e.push(i),n+=i.value.length;continue}if(Tt(i)){n+=1;continue}const a=Gt(i,n);a&&e.push(a),n+=1}return e}(t),e);return{atoms:n.parseTopLevel(),errors:n.collectedErrors}}(t,n);return{presentation:we(i),errors:a}}function we(t){if(0===t.length)return xe;if(1===t.length){const e=t[0];return e?e.node:xe}return P(t.map(t=>t.node).join(""))}var Le=/(?<!\$)\$([^$\n\uFFFC]+)\$$/,ke=/\$\$([^$\n\uFFFC]+)\$\$$/;function Se(t,e){const n=t.getBlock(e);return void 0!==n&&"code_block"!==n.type}function Ce(t,e){const n=t-e;return n<0?null:{from:n,to:t}}var $e={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"},Ae=/* #__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/pt.ts":()=>import("./pt-BkpVtod-.mjs"),"./locales/ru.ts":()=>import("./ru-BotG0MFT.mjs"),"./locales/zh.ts":()=>import("./zh-CWGAPVei.mjs")});async function ze(t){return b(Ae,t,$e)}var _e=/^\s*\$\$([^\n]+?)\$\$\s*$/;function Ee(t,e){const{presentation:n}=ye(t,{display:e});return{mathml:M({presentation:n,latex:t,display:e}),latex:t,alt:"",fontSize:""}}var Be=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}},Ie=0,Oe=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=++Ie;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 Be(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}=ye(t,{display:this.display});return{latex:t,mathml:M({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}=ye(t,{display:this.display});this.preview.innerHTML=M({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 Pe(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 Oe({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:Pe(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=Fe();this.open({rect:e,mode:"insert",initialDisplay:t,onCommit:t=>{ut(this.context,this.locale,t),this.close(!0)}})}openEdit(t){this.context.isReadOnly()||(this.context.announce(this.locale.editing),this.open({rect:t.rect??Fe(),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=pt(e);"inline"===t.kind&&t.blockId&&void 0!==t.offset?function(t,e,n,i){const a=t.getState().transaction("command").setInlineNodeAttr(e,n,lt(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,lt(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),w(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 Fe(){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 qe(t){const e=document.createElement("template");return e.innerHTML=t,e.content}function Re(t){const e=function(t){const e=f(t,{ALLOWED_TAGS:[...at],ALLOWED_ATTR:[...rt]});return/<math[\s>]/i.test(e)?e:null}(t.outerHTML);if(!e)return null;const n=G(e);return{mathml:n,latex:H(n)??"",alt:"",fontSize:Q(t)}}var Te=class{id="formula";name="Formula";priority=46;config;resolvedKeymap;fontSizes;locale=$e;overlay=null;context=null;clickHandler=null;constructor(t){this.config={...it,...t},this.resolvedKeymap={...et,...t?.keymap},this.fontSizes=this.config.fontSizes??nt}async init(t){var e;if(this.context=t,this.locale=await v(t,this.config.locale,$e,ze),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:Y,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",Y),W(e,Z(t.attrs)),V(e,t.attrs),e},toHTMLString:t=>X(Z(t.attrs)),toMarkdown:t=>`$${String(t.attrs.latex??"")}$`,parseHTML:[{tag:"math",getAttrs:t=>J(t,!1)}],sanitize:{tags:[...at],attrs:[...rt]}}),t.registerNodeSpec({type:tt,group:"block",isVoid:!0,selectable:!0,attrs:{mathml:{default:""},latex:{default:""},alt:{default:""},fontSize:{default:""}},toDOM(t){const e=x("div",t.id);return e.className="notectl-math notectl-math--display",e.setAttribute("data-void","true"),e.setAttribute("data-selectable","true"),W(e,Z(t.attrs)),V(e,t.attrs),e},toHTML:t=>X(Z(t.attrs)),toMarkdown:t=>`$$\n${String(t.attrs?.latex??"")}\n$$`,parseHTML:[{tag:"math",getAttrs:t=>J(t,!0)}],sanitize:{tags:[...at],attrs:[...rt]}}),this.overlay=new Ne(t,this.locale,this.fontSizes),t.registerNodeView(tt,(e={onEdit:(t,e)=>this.editDisplay(t,e),onSelect:()=>t.announce(this.locale.selected)},t=>{let n=t.id,i=!1;const a=x("div",t.id);return a.className="notectl-math notectl-math--display",a.setAttribute("data-void","true"),a.setAttribute("data-selectable","true"),W(a,Z(t.attrs)),V(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),W(a,Z(t.attrs)),V(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:ke,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(!Se(t,o))return null;const c=Ce(n.anchor.offset,e[0].length);if(!c)return null;const u=t.doc.children.findIndex(t=>t.id===o);if(-1===u)return null;const{presentation:d}=ye(a,{display:!0}),m=M({presentation:d,latex:a,display:!0}),h=t.transaction("input").deleteTextAt(o,c.from,c.to);return function(t,e,n){const a=i(p(tt),[],void 0,lt(n)),r=i(p("paragraph"));t.insertNode([],e,a).insertNode([],e+1,r).setSelection(s(a.id,[]))}(h,u+1,{mathml:m,latex:a,alt:"",fontSize:""}),h.build()}},{pattern:Le,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(!Se(t,o))return null;const s=Ce(i.anchor.offset,e[0].length);if(!s)return null;const{presentation:p}=ye(a,{display:!1}),d=M({presentation:p,latex:a,display:!1}),m=n(u(Y),{mathml:d,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:Y,attrs:{...Ee(i,!1)},length:n-e+1}},matchBlock(t,e){const n=t[e]??"",i=n.match(_e);if(i?.[1]?.trim())return{type:tt,attrs:{...Ee(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:tt,attrs:{...Ee(o,!0)},linesConsumed:r-e+1}}}),t.registerPasteInterceptor((t,e,n)=>{if(!function(t){if(!t)return!1;const e=qe(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=qe(t);for(const n of Array.from(e.querySelectorAll('[aria-hidden="true"]')))n.remove();return Array.from(e.querySelectorAll("math"))}(e).map(Re).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})?st(n,i):ct(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=>{ut(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=Z(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=ot(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=ot(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=y(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 Z(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=Z(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{rt as a,M as c,ye as i,$e as n,at as o,ze as r,et as s,Te as t};
|
|
2
|
-
//# sourceMappingURL=FormulaPlugin-Bw_sO_lq.mjs.map
|