@notectl/core 2.4.0 → 2.4.2
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-Cp7HYGaH.mjs.map +1 -1
- package/dist/chunks/AttrRegistry-Di936wMv.mjs.map +1 -1
- package/dist/chunks/AttributedMarkCommands-DKHuhZA7.mjs.map +1 -1
- package/dist/chunks/BidiIsolationPlugin-GWukKdgJ.mjs.map +1 -1
- 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-CSL_7Yit.mjs.map +1 -1
- package/dist/chunks/CSSValueEquivalence-DeyUKPQ7.mjs.map +1 -1
- package/dist/chunks/{CaretNavigationPlugin-BxWjR7SN.mjs → CaretNavigationPlugin-BQPqqK4n.mjs} +2 -2
- package/dist/chunks/CaretNavigationPlugin-BQPqqK4n.mjs.map +1 -0
- package/dist/chunks/CodeBlockPlugin-B4AcDJRK.mjs +2 -0
- package/dist/chunks/CodeBlockPlugin-B4AcDJRK.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-Bk7Cl1nH.mjs +2 -0
- package/dist/chunks/Commands-Bk7Cl1nH.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-BKUrtgw1.mjs → DocumentParser-C99N0MWF.mjs} +2 -2
- package/dist/chunks/DocumentParser-C99N0MWF.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/FontPlugin-BcXNFqqO.mjs.map +1 -1
- package/dist/chunks/{FontSizePlugin-BQ9Aj8cT.mjs → FontSizePlugin-Dswra3oU.mjs} +2 -2
- package/dist/chunks/FontSizePlugin-Dswra3oU.mjs.map +1 -0
- package/dist/chunks/FormulaPlugin-DVpLaKi5.mjs +2 -0
- package/dist/chunks/FormulaPlugin-DVpLaKi5.mjs.map +1 -0
- package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs.map +1 -1
- package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs.map +1 -1
- package/dist/chunks/HTMLUtils-DTpsjZyK.mjs.map +1 -1
- package/dist/chunks/{HardBreakPlugin-svNnJ9Xj.mjs → HardBreakPlugin-gjCq8prD.mjs} +2 -2
- package/dist/chunks/HardBreakPlugin-gjCq8prD.mjs.map +1 -0
- package/dist/chunks/HeadingPlugin-B7EfynaH.mjs.map +1 -1
- package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs.map +1 -1
- package/dist/chunks/{HorizontalRulePlugin-CQ5NT2Mo.mjs → HorizontalRulePlugin-YywXVZYr.mjs} +2 -2
- package/dist/chunks/HorizontalRulePlugin-YywXVZYr.mjs.map +1 -0
- package/dist/chunks/ImagePlugin-BAhZuVdE.mjs +2 -0
- package/dist/chunks/ImagePlugin-BAhZuVdE.mjs.map +1 -0
- package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs.map +1 -1
- package/dist/chunks/InlineStyleMarkSpec-BhfGgfH9.mjs.map +1 -1
- package/dist/chunks/KeyboardNav-D0my3wuy.mjs.map +1 -1
- package/dist/chunks/LinkPlugin-CAUaWW5-.mjs +2 -0
- package/dist/chunks/LinkPlugin-CAUaWW5-.mjs.map +1 -0
- package/dist/chunks/{ListPlugin-DTgpvBEt.mjs → ListPlugin-U1r4p_fE.mjs} +2 -2
- package/dist/chunks/ListPlugin-U1r4p_fE.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.map +1 -1
- package/dist/chunks/{MarkdownParser-CvYOvU3d.mjs → MarkdownParser-uX1p_GQk.mjs} +2 -2
- package/dist/chunks/MarkdownParser-uX1p_GQk.mjs.map +1 -0
- package/dist/chunks/{MarkdownSerializer-CdUBWWGI.mjs → MarkdownSerializer--MrgJTdJ.mjs} +2 -2
- package/dist/chunks/MarkdownSerializer--MrgJTdJ.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/PluginHelpers-B3gk3VB3.mjs.map +1 -1
- package/dist/chunks/PopupKeyboardPatterns-BcwdDxRq.mjs.map +1 -1
- package/dist/chunks/PopupManager-Dxv0OVMo.mjs +2 -0
- package/dist/chunks/PopupManager-Dxv0OVMo.mjs.map +1 -0
- package/dist/chunks/PopupPositioning-CIqgpqlW.mjs.map +1 -1
- package/dist/chunks/{PrintPlugin-BxNlFk2c.mjs → PrintPlugin-DAEiEyKQ.mjs} +2 -2
- package/dist/chunks/PrintPlugin-DAEiEyKQ.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.map +1 -1
- package/dist/chunks/Selection-DC6AOGgF.mjs.map +1 -1
- package/dist/chunks/SelectionReplacement-vC1xhFS0.mjs +2 -0
- package/dist/chunks/SelectionReplacement-vC1xhFS0.mjs.map +1 -0
- package/dist/chunks/SelectionSync-BkjCwGp-.mjs.map +1 -1
- package/dist/chunks/SelectionTransactions-mQ1NfMEg.mjs.map +1 -1
- package/dist/chunks/ShortcutFormatting-TwiufqeV.mjs.map +1 -1
- package/dist/chunks/SimpleMark-D6vz3Nfd.mjs.map +1 -1
- package/dist/chunks/SmartPastePlugin-BHsYKbgd.mjs +2 -0
- package/dist/chunks/SmartPastePlugin-BHsYKbgd.mjs.map +1 -0
- package/dist/chunks/StarterFonts-BDQPg-cu.mjs.map +1 -1
- package/dist/chunks/StrikethroughPlugin-v-VJZzUZ.mjs.map +1 -1
- package/dist/chunks/StyleClassNames-BsAx7k5T.mjs.map +1 -1
- package/dist/chunks/StyleRuntime-C0RSqKzG.mjs.map +1 -1
- package/dist/chunks/SuperSubPlugin-x1iPnZyt.mjs.map +1 -1
- package/dist/chunks/SyntaxTokenTypes-BUCOMtL8.mjs.map +1 -1
- package/dist/chunks/TableDimensions-BSEOEox2.mjs.map +1 -1
- package/dist/chunks/{TablePlugin-WPwp902E.mjs → TablePlugin-CjKThPug.mjs} +2 -2
- package/dist/chunks/TablePlugin-CjKThPug.mjs.map +1 -0
- package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs.map +1 -1
- package/dist/chunks/TextDirectionAutoPlugin-DOH5cfyy.mjs.map +1 -1
- package/dist/chunks/TextDirectionPlugin-JwlR-R-b.mjs.map +1 -1
- package/dist/chunks/TextDirectionService-BcX07mw2.mjs.map +1 -1
- package/dist/chunks/TextFormattingPlugin-Kc_UNoOz.mjs.map +1 -1
- package/dist/chunks/ThemeEngine-kIXtSRkI.mjs.map +1 -1
- package/dist/chunks/{ToolbarPlugin-DmVI7MN9.mjs → ToolbarPlugin-CgZA2hz8.mjs} +2 -2
- package/dist/chunks/ToolbarPlugin-CgZA2hz8.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-D3zGQ6QV.mjs → VideoPlugin-DJXfuNA9.mjs} +2 -2
- package/dist/chunks/VideoPlugin-DJXfuNA9.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-DhwCFHql.mjs +2 -0
- package/dist/chunks/ar-DhwCFHql.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-CjLUbQmg.mjs +2 -0
- package/dist/chunks/de-CjLUbQmg.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-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-CMSzvjOT.mjs +2 -0
- package/dist/chunks/es-CMSzvjOT.mjs.map +1 -0
- 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-DB_OvHWH.mjs +2 -0
- package/dist/chunks/fr-DB_OvHWH.mjs.map +1 -0
- 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-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-BsWAZr1w.mjs +2 -0
- package/dist/chunks/full-BsWAZr1w.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-CTWubxLY.mjs.map +1 -1
- package/dist/chunks/hi-ChNQZZ1z.mjs +2 -0
- package/dist/chunks/hi-ChNQZZ1z.mjs.map +1 -0
- 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-DO7LiFTa.mjs.map +1 -1
- 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-CI8t6oul.mjs +2 -0
- package/dist/chunks/pt-CI8t6oul.mjs.map +1 -0
- 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-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-DXLu8Njp.mjs +3 -0
- package/dist/chunks/register-DXLu8Njp.mjs.map +1 -0
- package/dist/chunks/ru-9WtNGZtl.mjs +2 -0
- package/dist/chunks/ru-9WtNGZtl.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-5GKFQ2mQ.mjs.map +1 -1
- 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-BrqJ4ywP.mjs +2 -0
- package/dist/chunks/zh-BrqJ4ywP.mjs.map +1 -0
- 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-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/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/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/full.mjs +1 -1
- package/dist/html.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -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/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockSchema.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font-size.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.mjs +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- 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.mjs +1 -1
- package/dist/plugins/link/LinkInteractionController.d.ts +26 -0
- package/dist/plugins/link/LinkInteractionController.d.ts.map +1 -0
- package/dist/plugins/link/LinkLocale.d.ts +7 -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 -4
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link/LinkPreview.d.ts +28 -0
- package/dist/plugins/link/LinkPreview.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/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.mjs +1 -1
- package/dist/plugins/print.mjs +1 -1
- package/dist/plugins/shared/PopupManager.d.ts +5 -0
- package/dist/plugins/shared/PopupManager.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.mjs +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-direction.mjs +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/plugins/video.mjs +1 -1
- package/dist/presets/full.mjs +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/register.mjs +1 -1
- package/dist/state/History.d.ts.map +1 -1
- 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/view/EditorViewEvents.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunks/BlockInsertion-CxKdCKJd.mjs +0 -2
- package/dist/chunks/BlockInsertion-CxKdCKJd.mjs.map +0 -1
- 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.map +0 -1
- 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/HardBreakPlugin-svNnJ9Xj.mjs.map +0 -1
- 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/LinkPlugin-BuzrXo2c.mjs +0 -2
- package/dist/chunks/LinkPlugin-BuzrXo2c.mjs.map +0 -1
- package/dist/chunks/ListPlugin-DTgpvBEt.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/PopupManager-Jz5JrUdC.mjs +0 -2
- package/dist/chunks/PopupManager-Jz5JrUdC.mjs.map +0 -1
- package/dist/chunks/PrintPlugin-BxNlFk2c.mjs.map +0 -1
- package/dist/chunks/SmartPastePlugin-C3SVKkWK.mjs +0 -2
- package/dist/chunks/SmartPastePlugin-C3SVKkWK.mjs.map +0 -1
- package/dist/chunks/TablePlugin-WPwp902E.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-DmVI7MN9.mjs.map +0 -1
- 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/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/zh-DuucmOns.mjs +0 -2
- package/dist/chunks/zh-DuucmOns.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionSync-BkjCwGp-.mjs","names":[],"sources":["../../src/view/InlineContentDOM.ts","../../src/view/SelectionSync.ts"],"sourcesContent":["/**\n * Classification of the DOM that renders a block's inline content.\n *\n * Shared by selection mapping and rendered-text reading so both agree on\n * which DOM nodes are document content: text nodes count their length, inline\n * node elements count one position, and view chrome counts nothing.\n */\n\n/** Attribute marking the temporary IME cursor wrapper (see `CursorWrapper`). */\nexport const CURSOR_WRAPPER_ATTR = 'data-cursor-wrapper';\n\n/** Zero-width space the cursor wrapper holds so the browser can compose into it. */\nexport const ZERO_WIDTH_SPACE = '';\n\n/**\n * True when `node` is an InlineNode element — rendered `contenteditable=\"false\"`\n * and counted as width 1 in state offset space.\n */\nexport function isInlineNodeEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.getAttribute('contenteditable') === 'false';\n}\n\n/**\n * True when `node` is a view-chrome widget (`data-widget`), such as the checklist\n * checkbox marker. Widgets are rendered into the editable DOM for accessibility\n * but are not document content, so they count as zero width in offset space.\n */\nexport function isWidgetEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute('data-widget');\n}\n\n/** True when `node` is the temporary IME cursor wrapper element. */\nexport function isCursorWrapperEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute(CURSOR_WRAPPER_ATTR);\n}\n\n/**\n * Resolves the content root for inline content walking.\n * If the block element has a contentDOM (marked with data-content-dom),\n * returns it so the walker skips NodeView structural elements (headers, etc.).\n */\nexport function resolveContentRoot(blockEl: Element): Element {\n\tconst contentDOM: Element | null = blockEl.querySelector('[data-content-dom]');\n\treturn contentDOM ?? blockEl;\n}\n\nexport interface InlineContentWalkerOptions {\n\t/**\n\t * Descend into the IME cursor wrapper instead of skipping it. Selection\n\t * mapping skips it because its zero-width space is not content; reading\n\t * composed text needs it because the browser composes inside it.\n\t */\n\treadonly includeCursorWrapper?: boolean;\n}\n\n/**\n * Creates a TreeWalker that visits text nodes and contentEditable=\"false\"\n * inline elements within a block, skipping mark wrappers and nested blocks.\n */\nexport function createInlineContentWalker(\n\tblockEl: Element,\n\toptions: InlineContentWalkerOptions = {},\n): TreeWalker {\n\tconst includeCursorWrapper: boolean = options.includeCursorWrapper ?? false;\n\treturn document.createTreeWalker(blockEl, NodeFilter.SHOW_ALL, {\n\t\tacceptNode: (n: Node) => {\n\t\t\t// The cursor wrapper holds a ZWS for stored marks during IME composition\n\t\t\tif (isCursorWrapperEl(n)) {\n\t\t\t\treturn includeCursorWrapper ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Skip view-chrome widgets (e.g. the checklist checkbox marker). They are\n\t\t\t// contentEditable=\"false\" but not document content, so they carry zero\n\t\t\t// width in offset space and must never become a caret position.\n\t\t\tif (isWidgetEl(n)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip anything inside an inline element (contentEditable=\"false\")\n\t\t\tif (isInsideInlineElement(n, blockEl)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip nested block elements and their descendants\n\t\t\tif (n instanceof HTMLElement && n.hasAttribute('data-block-id') && n !== blockEl) {\n\t\t\t\treturn NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Accept text nodes\n\t\t\tif (n.nodeType === Node.TEXT_NODE) return NodeFilter.FILTER_ACCEPT;\n\t\t\t// Accept inline elements (contentEditable=\"false\")\n\t\t\tif (isInlineNodeEl(n)) {\n\t\t\t\treturn NodeFilter.FILTER_ACCEPT;\n\t\t\t}\n\t\t\t// Skip other elements (mark wrappers, decoration wrappers) — descend\n\t\t\treturn NodeFilter.FILTER_SKIP;\n\t\t},\n\t});\n}\n\n/** Checks if a node is inside a contentEditable=\"false\" inline element. */\nfunction isInsideInlineElement(node: Node, root: Element): boolean {\n\tlet parent: Node | null = node.parentNode;\n\twhile (parent && parent !== root) {\n\t\tif (isInlineNodeEl(parent)) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = parent.parentNode;\n\t}\n\treturn false;\n}\n","/**\n * Selection synchronization between editor state and DOM.\n */\n\nimport type { EditorSelection, Position, Selection } from '../model/Selection.js';\nimport {\n\tcreatePosition,\n\tcreateSelection,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../model/Selection.js';\nimport { blockId as toBlockId } from '../model/TypeBrands.js';\nimport { buildBlockPath, findBlockAncestor } from './DomUtils.js';\nimport {\n\tcreateInlineContentWalker,\n\tisInlineNodeEl,\n\tisWidgetEl,\n\tresolveContentRoot,\n} from './InlineContentDOM.js';\n\ninterface DOMPosition {\n\tnode: Node;\n\toffset: number;\n}\n\n/**\n * Returns the lone `<br>` placeholder of an empty block, ignoring view-chrome\n * widgets. Returns null when the block holds real inline content.\n */\nfunction findPlaceholderBr(contentEl: Element): Node | null {\n\tlet br: Node | null = null;\n\tfor (const child of Array.from(contentEl.childNodes)) {\n\t\tif (isWidgetEl(child)) continue;\n\t\tif (br) return null;\n\t\tif (child.nodeName === 'BR') {\n\t\t\tbr = child;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn br;\n}\n\n/** Gets the selection object for writing (collapse, setBaseAndExtent). */\nexport function getSelection(): globalThis.Selection | null {\n\treturn window.getSelection();\n}\n\n/**\n * Endpoints returned by reading selection via getComposedRanges().\n * Used to correctly read selection inside Shadow DOM on Safari 17+,\n * Chrome 137+, and Firefox 142+.\n */\nexport interface SelectionEndpoints {\n\tanchorNode: Node;\n\tanchorOffset: number;\n\tfocusNode: Node;\n\tfocusOffset: number;\n}\n\n/**\n * Reads the selection endpoints using getComposedRanges() when inside a\n * Shadow DOM. Returns null if not in a shadow root or the API is unavailable.\n *\n * Handles two call signatures:\n * - Modern (Chrome 137+, Firefox 142+): sel.getComposedRanges({ shadowRoots: [root] })\n * - Legacy (Safari 17+): sel.getComposedRanges(root)\n *\n * StaticRange always uses document order. When `Selection.direction` is\n * `\"backward\"`, anchor/focus are swapped to reconstruct the correct\n * directional endpoints. When direction is `\"none\"` or absent the\n * forward (document-order) mapping is used.\n *\n * Note: Safari 17–18 supports getComposedRanges but not\n * Selection.direction — backward selections will be read as forward.\n */\nexport function readComposedSelection(\n\tcontainer: HTMLElement,\n\tsel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst root = container.getRootNode();\n\tif (!(root instanceof ShadowRoot)) return null;\n\tif (!('getComposedRanges' in sel)) return null;\n\n\tlet ranges: StaticRange[];\n\ttry {\n\t\t// Modern syntax (Chrome 137+, Firefox 142+)\n\t\tranges = (\n\t\t\tsel as unknown as {\n\t\t\t\tgetComposedRanges(opts: { shadowRoots: ShadowRoot[] }): StaticRange[];\n\t\t\t}\n\t\t).getComposedRanges({ shadowRoots: [root] });\n\t} catch {\n\t\ttry {\n\t\t\t// Legacy syntax (Safari 17+)\n\t\t\tranges = (\n\t\t\t\tsel as unknown as {\n\t\t\t\t\tgetComposedRanges(...roots: ShadowRoot[]): StaticRange[];\n\t\t\t\t}\n\t\t\t).getComposedRanges(root);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst range = ranges[0];\n\tif (!range) return null;\n\n\tconst isBackward: boolean =\n\t\t'direction' in sel && (sel as unknown as { direction: string }).direction === 'backward';\n\n\treturn {\n\t\tanchorNode: isBackward ? range.endContainer : range.startContainer,\n\t\tanchorOffset: isBackward ? range.endOffset : range.startOffset,\n\t\tfocusNode: isBackward ? range.startContainer : range.endContainer,\n\t\tfocusOffset: isBackward ? range.startOffset : range.endOffset,\n\t};\n}\n\n/**\n * Reads the DOM selection endpoints, preferring `getComposedRanges()` when\n * the container is inside a Shadow DOM.\n *\n * Returns `null` when `anchorNode` is unavailable (no selection).\n *\n * In Shadow DOM mode the endpoints come from a `StaticRange` which uses\n * document order. `Selection.direction` is used to reconstruct anchor/focus\n * for backward selections.\n */\nexport function readDOMSelectionEndpoints(\n\tcontainer: HTMLElement,\n\tdomSel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst composed: SelectionEndpoints | null = readComposedSelection(container, domSel);\n\tif (composed) return composed;\n\n\tconst anchorNode: Node | null = domSel.anchorNode;\n\tif (!anchorNode) return null;\n\tconst focusNode: Node | null = domSel.focusNode;\n\tif (!focusNode) return null;\n\n\treturn {\n\t\tanchorNode,\n\t\tanchorOffset: domSel.anchorOffset,\n\t\tfocusNode,\n\t\tfocusOffset: domSel.focusOffset,\n\t};\n}\n\n/** Syncs the editor state selection to the DOM. */\nexport function syncSelectionToDOM(container: HTMLElement, selection: EditorSelection): void {\n\tconst domSel = getSelection();\n\tif (!domSel) return;\n\n\t// GapCursor: clear browser selection (gap cursor has no DOM equivalent)\n\tif (isGapCursor(selection)) {\n\t\tdomSel.removeAllRanges();\n\t\treturn;\n\t}\n\n\t// NodeSelection: select the entire block element\n\tif (isNodeSelection(selection)) {\n\t\tconst blockEl = container.querySelector(`[data-block-id=\"${selection.nodeId}\"]`);\n\t\tif (!blockEl) return;\n\t\tconst parent = blockEl.parentNode;\n\t\tif (!parent) return;\n\t\tconst childIdx = childIndexOf(parent, blockEl);\n\t\ttry {\n\t\t\tdomSel.setBaseAndExtent(parent, childIdx, parent, childIdx + 1);\n\t\t} catch {\n\t\t\t// Selection may fail if DOM is not yet rendered\n\t\t}\n\t\treturn;\n\t}\n\n\tconst anchorPos = statePositionToDOM(container, selection.anchor);\n\tconst headPos = statePositionToDOM(container, selection.head);\n\n\tif (!anchorPos || !headPos) return;\n\n\ttry {\n\t\tdomSel.setBaseAndExtent(anchorPos.node, anchorPos.offset, headPos.node, headPos.offset);\n\t} catch {\n\t\t// Selection may fail if DOM is not yet rendered\n\t}\n}\n\n/** Reads the current DOM selection and converts it to a state selection. */\nexport function readSelectionFromDOM(container: HTMLElement): Selection | null {\n\tconst domSel = getSelection();\n\tif (!domSel || domSel.rangeCount === 0) return null;\n\n\tconst endpoints: SelectionEndpoints | null = readDOMSelectionEndpoints(container, domSel);\n\tif (!endpoints) return null;\n\n\tif (!container.contains(endpoints.anchorNode) || !container.contains(endpoints.focusNode)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, endpoints.anchorNode, endpoints.anchorOffset);\n\tconst head = domPositionToState(container, endpoints.focusNode, endpoints.focusOffset);\n\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/**\n * Converts a DOM range (e.g. a `StaticRange` from `InputEvent.getTargetRanges()`)\n * to a state selection. Returns `null` when either endpoint lies outside the\n * container or cannot be mapped to a block position.\n */\nexport function domRangeToState(container: HTMLElement, range: AbstractRange): Selection | null {\n\tif (!container.contains(range.startContainer) || !container.contains(range.endContainer)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, range.startContainer, range.startOffset);\n\tconst head = domPositionToState(container, range.endContainer, range.endOffset);\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/** Converts a state position (blockId + offset) to a DOM position (node + offset). */\nfunction statePositionToDOM(container: HTMLElement, pos: Position): DOMPosition | null {\n\t// If path is available, navigate directly to the leaf block\n\tlet blockEl: Element | null = null;\n\tif (pos.path && pos.path.length > 0) {\n\t\tlet current: Element = container;\n\t\tfor (const id of pos.path) {\n\t\t\tconst found = current.querySelector(`:scope [data-block-id=\"${id}\"]`);\n\t\t\tif (!found) break;\n\t\t\tcurrent = found;\n\t\t}\n\t\tif (current !== container && current.getAttribute('data-block-id') === pos.blockId) {\n\t\t\tblockEl = current;\n\t\t}\n\t}\n\tblockEl ??= container.querySelector(`[data-block-id=\"${pos.blockId}\"]`);\n\tif (!blockEl) return null;\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle empty blocks rendered as a single <br> placeholder. View-chrome\n\t// widgets (e.g. the checklist marker) are ignored, so the caret lands after\n\t// the widget and before the <br> rather than at the very start of the block.\n\tconst placeholderBr = findPlaceholderBr(contentEl);\n\tif (placeholderBr) {\n\t\treturn { node: contentEl, offset: childIndexOf(contentEl, placeholderBr) };\n\t}\n\n\t// Walk through text nodes and inline elements to find the correct position\n\tlet remaining = pos.offset;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet current = walker.nextNode();\n\twhile (current) {\n\t\tif (current.nodeType === Node.TEXT_NODE) {\n\t\t\tconst len = current.textContent?.length ?? 0;\n\t\t\tif (remaining <= len) {\n\t\t\t\treturn { node: current, offset: remaining };\n\t\t\t}\n\t\t\tremaining -= len;\n\t\t} else if (isInlineNodeEl(current)) {\n\t\t\t// InlineNode element — width 1 in state offset space\n\t\t\tif (remaining === 0) {\n\t\t\t\t// Position before this inline element\n\t\t\t\tconst parent = current.parentNode;\n\t\t\t\tif (parent) {\n\t\t\t\t\tconst childIndex = childIndexOf(parent, current);\n\t\t\t\t\treturn { node: parent, offset: childIndex };\n\t\t\t\t}\n\t\t\t}\n\t\t\tremaining -= 1;\n\t\t}\n\t\tcurrent = walker.nextNode();\n\t}\n\n\t// Fallback: position at end of block\n\tconst lastChild = contentEl.lastChild;\n\tif (lastChild) {\n\t\tif (lastChild.nodeType === Node.TEXT_NODE) {\n\t\t\treturn { node: lastChild, offset: lastChild.textContent?.length ?? 0 };\n\t\t}\n\t\treturn { node: contentEl, offset: contentEl.childNodes.length };\n\t}\n\n\treturn { node: contentEl, offset: 0 };\n}\n\n/** Converts a DOM position to a state position, including nested path. */\nexport function domPositionToState(\n\tcontainer: HTMLElement,\n\tnode: Node,\n\tdomOffset: number,\n): Position | null {\n\t// Find the innermost block element\n\tconst blockEl = findBlockAncestor(container, node);\n\tif (!blockEl) return null;\n\n\tconst rawBlockId = blockEl.getAttribute('data-block-id');\n\tif (!rawBlockId) return null;\n\tconst bid = toBlockId(rawBlockId);\n\n\t// Build path by collecting all data-block-id ancestors from leaf to root\n\tconst path = buildBlockPath(container, blockEl);\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle clicks on the block or content element itself (e.g. empty paragraph with <br>)\n\tif (node === blockEl || node === contentEl) {\n\t\tconst targetEl: Element = node === contentEl ? contentEl : blockEl;\n\t\tlet childOffset = 0;\n\t\tlet childIdx = 0;\n\t\tfor (const child of Array.from(targetEl.childNodes)) {\n\t\t\tif (childIdx >= domOffset) break;\n\t\t\tchildOffset += inlineContentWidth(child);\n\t\t\tchildIdx++;\n\t\t}\n\t\treturn createPosition(bid, childOffset, path.length > 1 ? path : undefined);\n\t}\n\n\t// If node is outside the contentDOM (e.g. in NodeView header), map to offset 0\n\tif (contentEl !== blockEl && !contentEl.contains(node)) {\n\t\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n\t}\n\n\t// Calculate offset by walking text nodes and inline elements\n\tlet offset = 0;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet walkerNode = walker.nextNode();\n\twhile (walkerNode) {\n\t\tif (walkerNode === node) {\n\t\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\t\treturn createPosition(bid, offset + domOffset, path.length > 1 ? path : undefined);\n\t\t\t}\n\t\t\t// Node is an inline element — return offset at its start\n\t\t\treturn createPosition(bid, offset, path.length > 1 ? path : undefined);\n\t\t}\n\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\toffset += walkerNode.textContent?.length ?? 0;\n\t\t} else if (isInlineNodeEl(walkerNode)) {\n\t\t\toffset += 1;\n\t\t}\n\t\twalkerNode = walker.nextNode();\n\t}\n\n\t// If the node is not a text node, try to find the offset from element context\n\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\tconst childOffset = inlineOffsetForChildIndex(node, domOffset);\n\t\tconst offsetBeforeNode = inlineOffsetBeforeNode(contentEl, node);\n\t\tconst totalOffset = offsetBeforeNode === null ? childOffset : offsetBeforeNode + childOffset;\n\t\treturn createPosition(bid, totalOffset, path.length > 1 ? path : undefined);\n\t}\n\n\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n}\n\n/** Counts inline width for the first `childIndex` children of an element. */\nfunction inlineOffsetForChildIndex(node: Node, childIndex: number): number {\n\tlet childOffset = 0;\n\tlet childIdx = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\tif (childIdx >= childIndex) break;\n\t\tchildOffset += inlineContentWidth(child);\n\t\tchildIdx++;\n\t}\n\treturn childOffset;\n}\n\n/** Returns the inline offset from `root` to the start of `node`, or null when unrelated. */\nfunction inlineOffsetBeforeNode(root: Element, node: Node): number | null {\n\tlet offset = 0;\n\tlet current: Node | null = node;\n\n\twhile (current && current !== root) {\n\t\tconst parent: Node | null = current.parentNode;\n\t\tif (!parent) return null;\n\n\t\tfor (const sibling of Array.from(parent.childNodes) as Node[]) {\n\t\t\tif (sibling === current) break;\n\t\t\toffset += inlineContentWidth(sibling);\n\t\t}\n\n\t\tcurrent = parent;\n\t}\n\n\treturn current === root ? offset : null;\n}\n\n/** Returns the child index of a node within its parent. */\nfunction childIndexOf(parent: Node, child: Node): number {\n\tlet idx = 0;\n\tfor (const c of Array.from(parent.childNodes)) {\n\t\tif (c === child) return idx;\n\t\tidx++;\n\t}\n\treturn idx;\n}\n\n/** Counts the inline content width of a DOM node (text length + 1 per inline element). */\nfunction inlineContentWidth(node: Node): number {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\treturn node.textContent?.length ?? 0;\n\t}\n\t// View-chrome widgets (e.g. the checklist marker) are not document content.\n\tif (isWidgetEl(node)) {\n\t\treturn 0;\n\t}\n\tif (isInlineNodeEl(node)) {\n\t\treturn 1;\n\t}\n\t// Mark wrapper or other element — sum children\n\tlet width = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\twidth += inlineContentWidth(child);\n\t}\n\treturn width;\n}\n"],"mappings":"mKASA,IAAa,EAAsB,sBASnC,SAAgB,EAAe,GAC9B,OAAO,aAAgB,aAAwD,UAAzC,EAAK,aAAa,kBACzD,CAOA,SAAgB,EAAW,GAC1B,OAAO,aAAgB,aAAe,EAAK,aAAa,cACzD,CAGA,SAAgB,EAAkB,GACjC,OAAO,aAAgB,aAAe,EAAK,aAA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AI,EAAS,EACT,EAAuB,EAE3B,KAAO,GAAW,IAAY,GAAM,CACnC,MAAM,EAAsB,EAAQ,WACpC,IAAK,EAAQ,OAAO,KAEpB,IAAK,MAAM,KAAW,MAAM,KAAK,EAAO,YAAuB,CAC9D,GAAI,IAAY,EAAS,MACzB,GAAU,EAAmB,EAC9B,CAEA,EAAU,CACX,CAEA,OAAO,IAAY,EAAO,EAAS,IACpC,CAtC2B,CAAuB,EAAW,GAE3D,OAAO,EAAe,EADmB,OAArB,EAA4B,EAAc,EAAmB,EACzC,EAAK,OAAS,EAAI,OAAO,EAClE,CAEA,OAAO,EAAe,EAAK,EAAG,EAAK,OAAS,EAAI,OAAO,EACxD,CAmCA,SAAS,EAAa,EAAc,GACnC,IAAI,EAAM,EACV,IAAK,MAAM,KAAK,MAAM,KAAK,EAAO,YAAa,CAC9C,GAAI,IAAM,EAAO,OAAO,EACxB,GACD,CACA,OAAO,CACR,CAGA,SAAS,EAAmB,GAC3B,GAAI,EAAK,WAAa,KAAK,UAC1B,OAAO,EAAK,aAAa,QAAU,EAGpC,GAAI,EAAW,GACd,OAAO,EAER,GAAI,EAAe,GAClB,OAAO,EAGR,IAAI,EAAQ,EACZ,IAAK,MAAM,KAAS,MAAM,KAAK,EAAK,YACnC,GAAS,EAAmB,GAE7B,OAAO,CACR"}
|
|
1
|
+
{"version":3,"file":"SelectionSync-BkjCwGp-.mjs","names":["toBlockId","createPosition","isNodeSelection","createSelection","isGapCursor","blockId","findBlockAncestor","buildBlockPath","CURSOR_WRAPPER_ATTR","isInlineNodeEl","node","HTMLElement","getAttribute","isWidgetEl","hasAttribute","isCursorWrapperEl","resolveContentRoot","blockEl","querySelector","createInlineContentWalker","options","includeCursorWrapper","document","createTreeWalker","NodeFilter","SHOW_ALL","acceptNode","n","FILTER_SKIP","FILTER_REJECT","root","parent","parentNode","isInsideInlineElement","nodeType","Node","TEXT_NODE","FILTER_ACCEPT","getSelection","window","readComposedSelection","container","sel","getRootNode","ShadowRoot","ranges","getComposedRanges","shadowRoots","range","isBackward","direction","anchorNode","endContainer","startContainer","anchorOffset","endOffset","startOffset","focusNode","focusOffset","readDOMSelectionEndpoints","domSel","composed","syncSelectionToDOM","selection","removeAllRanges","nodeId","childIdx","childIndexOf","setBaseAndExtent","anchorPos","statePositionToDOM","anchor","headPos","head","offset","readSelectionFromDOM","rangeCount","endpoints","contains","domPositionToState","domRangeToState","pos","path","length","current","id","found","contentEl","placeholderBr","br","child","Array","from","childNodes","nodeName","findPlaceholderBr","remaining","walker","nextNode","len","textContent","lastChild","domOffset","rawBlockId","bid","targetEl","childOffset","inlineContentWidth","walkerNode","ELEMENT_NODE","childIndex","inlineOffsetForChildIndex","offsetBeforeNode","sibling","inlineOffsetBeforeNode","idx","c","width"],"sources":["../../src/view/InlineContentDOM.ts","../../src/view/SelectionSync.ts"],"sourcesContent":["/**\n * Classification of the DOM that renders a block's inline content.\n *\n * Shared by selection mapping and rendered-text reading so both agree on\n * which DOM nodes are document content: text nodes count their length, inline\n * node elements count one position, and view chrome counts nothing.\n */\n\n/** Attribute marking the temporary IME cursor wrapper (see `CursorWrapper`). */\nexport const CURSOR_WRAPPER_ATTR = 'data-cursor-wrapper';\n\n/** Zero-width space the cursor wrapper holds so the browser can compose into it. */\nexport const ZERO_WIDTH_SPACE = '';\n\n/**\n * True when `node` is an InlineNode element — rendered `contenteditable=\"false\"`\n * and counted as width 1 in state offset space.\n */\nexport function isInlineNodeEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.getAttribute('contenteditable') === 'false';\n}\n\n/**\n * True when `node` is a view-chrome widget (`data-widget`), such as the checklist\n * checkbox marker. Widgets are rendered into the editable DOM for accessibility\n * but are not document content, so they count as zero width in offset space.\n */\nexport function isWidgetEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute('data-widget');\n}\n\n/** True when `node` is the temporary IME cursor wrapper element. */\nexport function isCursorWrapperEl(node: Node | null | undefined): node is HTMLElement {\n\treturn node instanceof HTMLElement && node.hasAttribute(CURSOR_WRAPPER_ATTR);\n}\n\n/**\n * Resolves the content root for inline content walking.\n * If the block element has a contentDOM (marked with data-content-dom),\n * returns it so the walker skips NodeView structural elements (headers, etc.).\n */\nexport function resolveContentRoot(blockEl: Element): Element {\n\tconst contentDOM: Element | null = blockEl.querySelector('[data-content-dom]');\n\treturn contentDOM ?? blockEl;\n}\n\nexport interface InlineContentWalkerOptions {\n\t/**\n\t * Descend into the IME cursor wrapper instead of skipping it. Selection\n\t * mapping skips it because its zero-width space is not content; reading\n\t * composed text needs it because the browser composes inside it.\n\t */\n\treadonly includeCursorWrapper?: boolean;\n}\n\n/**\n * Creates a TreeWalker that visits text nodes and contentEditable=\"false\"\n * inline elements within a block, skipping mark wrappers and nested blocks.\n */\nexport function createInlineContentWalker(\n\tblockEl: Element,\n\toptions: InlineContentWalkerOptions = {},\n): TreeWalker {\n\tconst includeCursorWrapper: boolean = options.includeCursorWrapper ?? false;\n\treturn document.createTreeWalker(blockEl, NodeFilter.SHOW_ALL, {\n\t\tacceptNode: (n: Node) => {\n\t\t\t// The cursor wrapper holds a ZWS for stored marks during IME composition\n\t\t\tif (isCursorWrapperEl(n)) {\n\t\t\t\treturn includeCursorWrapper ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Skip view-chrome widgets (e.g. the checklist checkbox marker). They are\n\t\t\t// contentEditable=\"false\" but not document content, so they carry zero\n\t\t\t// width in offset space and must never become a caret position.\n\t\t\tif (isWidgetEl(n)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip anything inside an inline element (contentEditable=\"false\")\n\t\t\tif (isInsideInlineElement(n, blockEl)) return NodeFilter.FILTER_REJECT;\n\t\t\t// Skip nested block elements and their descendants\n\t\t\tif (n instanceof HTMLElement && n.hasAttribute('data-block-id') && n !== blockEl) {\n\t\t\t\treturn NodeFilter.FILTER_REJECT;\n\t\t\t}\n\t\t\t// Accept text nodes\n\t\t\tif (n.nodeType === Node.TEXT_NODE) return NodeFilter.FILTER_ACCEPT;\n\t\t\t// Accept inline elements (contentEditable=\"false\")\n\t\t\tif (isInlineNodeEl(n)) {\n\t\t\t\treturn NodeFilter.FILTER_ACCEPT;\n\t\t\t}\n\t\t\t// Skip other elements (mark wrappers, decoration wrappers) — descend\n\t\t\treturn NodeFilter.FILTER_SKIP;\n\t\t},\n\t});\n}\n\n/** Checks if a node is inside a contentEditable=\"false\" inline element. */\nfunction isInsideInlineElement(node: Node, root: Element): boolean {\n\tlet parent: Node | null = node.parentNode;\n\twhile (parent && parent !== root) {\n\t\tif (isInlineNodeEl(parent)) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = parent.parentNode;\n\t}\n\treturn false;\n}\n","/**\n * Selection synchronization between editor state and DOM.\n */\n\nimport type { EditorSelection, Position, Selection } from '../model/Selection.js';\nimport {\n\tcreatePosition,\n\tcreateSelection,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../model/Selection.js';\nimport { blockId as toBlockId } from '../model/TypeBrands.js';\nimport { buildBlockPath, findBlockAncestor } from './DomUtils.js';\nimport {\n\tcreateInlineContentWalker,\n\tisInlineNodeEl,\n\tisWidgetEl,\n\tresolveContentRoot,\n} from './InlineContentDOM.js';\n\ninterface DOMPosition {\n\tnode: Node;\n\toffset: number;\n}\n\n/**\n * Returns the lone `<br>` placeholder of an empty block, ignoring view-chrome\n * widgets. Returns null when the block holds real inline content.\n */\nfunction findPlaceholderBr(contentEl: Element): Node | null {\n\tlet br: Node | null = null;\n\tfor (const child of Array.from(contentEl.childNodes)) {\n\t\tif (isWidgetEl(child)) continue;\n\t\tif (br) return null;\n\t\tif (child.nodeName === 'BR') {\n\t\t\tbr = child;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn br;\n}\n\n/** Gets the selection object for writing (collapse, setBaseAndExtent). */\nexport function getSelection(): globalThis.Selection | null {\n\treturn window.getSelection();\n}\n\n/**\n * Endpoints returned by reading selection via getComposedRanges().\n * Used to correctly read selection inside Shadow DOM on Safari 17+,\n * Chrome 137+, and Firefox 142+.\n */\nexport interface SelectionEndpoints {\n\tanchorNode: Node;\n\tanchorOffset: number;\n\tfocusNode: Node;\n\tfocusOffset: number;\n}\n\n/**\n * Reads the selection endpoints using getComposedRanges() when inside a\n * Shadow DOM. Returns null if not in a shadow root or the API is unavailable.\n *\n * Handles two call signatures:\n * - Modern (Chrome 137+, Firefox 142+): sel.getComposedRanges({ shadowRoots: [root] })\n * - Legacy (Safari 17+): sel.getComposedRanges(root)\n *\n * StaticRange always uses document order. When `Selection.direction` is\n * `\"backward\"`, anchor/focus are swapped to reconstruct the correct\n * directional endpoints. When direction is `\"none\"` or absent the\n * forward (document-order) mapping is used.\n *\n * Note: Safari 17–18 supports getComposedRanges but not\n * Selection.direction — backward selections will be read as forward.\n */\nexport function readComposedSelection(\n\tcontainer: HTMLElement,\n\tsel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst root = container.getRootNode();\n\tif (!(root instanceof ShadowRoot)) return null;\n\tif (!('getComposedRanges' in sel)) return null;\n\n\tlet ranges: StaticRange[];\n\ttry {\n\t\t// Modern syntax (Chrome 137+, Firefox 142+)\n\t\tranges = (\n\t\t\tsel as unknown as {\n\t\t\t\tgetComposedRanges(opts: { shadowRoots: ShadowRoot[] }): StaticRange[];\n\t\t\t}\n\t\t).getComposedRanges({ shadowRoots: [root] });\n\t} catch {\n\t\ttry {\n\t\t\t// Legacy syntax (Safari 17+)\n\t\t\tranges = (\n\t\t\t\tsel as unknown as {\n\t\t\t\t\tgetComposedRanges(...roots: ShadowRoot[]): StaticRange[];\n\t\t\t\t}\n\t\t\t).getComposedRanges(root);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst range = ranges[0];\n\tif (!range) return null;\n\n\tconst isBackward: boolean =\n\t\t'direction' in sel && (sel as unknown as { direction: string }).direction === 'backward';\n\n\treturn {\n\t\tanchorNode: isBackward ? range.endContainer : range.startContainer,\n\t\tanchorOffset: isBackward ? range.endOffset : range.startOffset,\n\t\tfocusNode: isBackward ? range.startContainer : range.endContainer,\n\t\tfocusOffset: isBackward ? range.startOffset : range.endOffset,\n\t};\n}\n\n/**\n * Reads the DOM selection endpoints, preferring `getComposedRanges()` when\n * the container is inside a Shadow DOM.\n *\n * Returns `null` when `anchorNode` is unavailable (no selection).\n *\n * In Shadow DOM mode the endpoints come from a `StaticRange` which uses\n * document order. `Selection.direction` is used to reconstruct anchor/focus\n * for backward selections.\n */\nexport function readDOMSelectionEndpoints(\n\tcontainer: HTMLElement,\n\tdomSel: globalThis.Selection,\n): SelectionEndpoints | null {\n\tconst composed: SelectionEndpoints | null = readComposedSelection(container, domSel);\n\tif (composed) return composed;\n\n\tconst anchorNode: Node | null = domSel.anchorNode;\n\tif (!anchorNode) return null;\n\tconst focusNode: Node | null = domSel.focusNode;\n\tif (!focusNode) return null;\n\n\treturn {\n\t\tanchorNode,\n\t\tanchorOffset: domSel.anchorOffset,\n\t\tfocusNode,\n\t\tfocusOffset: domSel.focusOffset,\n\t};\n}\n\n/** Syncs the editor state selection to the DOM. */\nexport function syncSelectionToDOM(container: HTMLElement, selection: EditorSelection): void {\n\tconst domSel = getSelection();\n\tif (!domSel) return;\n\n\t// GapCursor: clear browser selection (gap cursor has no DOM equivalent)\n\tif (isGapCursor(selection)) {\n\t\tdomSel.removeAllRanges();\n\t\treturn;\n\t}\n\n\t// NodeSelection: select the entire block element\n\tif (isNodeSelection(selection)) {\n\t\tconst blockEl = container.querySelector(`[data-block-id=\"${selection.nodeId}\"]`);\n\t\tif (!blockEl) return;\n\t\tconst parent = blockEl.parentNode;\n\t\tif (!parent) return;\n\t\tconst childIdx = childIndexOf(parent, blockEl);\n\t\ttry {\n\t\t\tdomSel.setBaseAndExtent(parent, childIdx, parent, childIdx + 1);\n\t\t} catch {\n\t\t\t// Selection may fail if DOM is not yet rendered\n\t\t}\n\t\treturn;\n\t}\n\n\tconst anchorPos = statePositionToDOM(container, selection.anchor);\n\tconst headPos = statePositionToDOM(container, selection.head);\n\n\tif (!anchorPos || !headPos) return;\n\n\ttry {\n\t\tdomSel.setBaseAndExtent(anchorPos.node, anchorPos.offset, headPos.node, headPos.offset);\n\t} catch {\n\t\t// Selection may fail if DOM is not yet rendered\n\t}\n}\n\n/** Reads the current DOM selection and converts it to a state selection. */\nexport function readSelectionFromDOM(container: HTMLElement): Selection | null {\n\tconst domSel = getSelection();\n\tif (!domSel || domSel.rangeCount === 0) return null;\n\n\tconst endpoints: SelectionEndpoints | null = readDOMSelectionEndpoints(container, domSel);\n\tif (!endpoints) return null;\n\n\tif (!container.contains(endpoints.anchorNode) || !container.contains(endpoints.focusNode)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, endpoints.anchorNode, endpoints.anchorOffset);\n\tconst head = domPositionToState(container, endpoints.focusNode, endpoints.focusOffset);\n\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/**\n * Converts a DOM range (e.g. a `StaticRange` from `InputEvent.getTargetRanges()`)\n * to a state selection. Returns `null` when either endpoint lies outside the\n * container or cannot be mapped to a block position.\n */\nexport function domRangeToState(container: HTMLElement, range: AbstractRange): Selection | null {\n\tif (!container.contains(range.startContainer) || !container.contains(range.endContainer)) {\n\t\treturn null;\n\t}\n\n\tconst anchor = domPositionToState(container, range.startContainer, range.startOffset);\n\tconst head = domPositionToState(container, range.endContainer, range.endOffset);\n\tif (!anchor || !head) return null;\n\n\treturn createSelection(anchor, head);\n}\n\n/** Converts a state position (blockId + offset) to a DOM position (node + offset). */\nfunction statePositionToDOM(container: HTMLElement, pos: Position): DOMPosition | null {\n\t// If path is available, navigate directly to the leaf block\n\tlet blockEl: Element | null = null;\n\tif (pos.path && pos.path.length > 0) {\n\t\tlet current: Element = container;\n\t\tfor (const id of pos.path) {\n\t\t\tconst found = current.querySelector(`:scope [data-block-id=\"${id}\"]`);\n\t\t\tif (!found) break;\n\t\t\tcurrent = found;\n\t\t}\n\t\tif (current !== container && current.getAttribute('data-block-id') === pos.blockId) {\n\t\t\tblockEl = current;\n\t\t}\n\t}\n\tblockEl ??= container.querySelector(`[data-block-id=\"${pos.blockId}\"]`);\n\tif (!blockEl) return null;\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle empty blocks rendered as a single <br> placeholder. View-chrome\n\t// widgets (e.g. the checklist marker) are ignored, so the caret lands after\n\t// the widget and before the <br> rather than at the very start of the block.\n\tconst placeholderBr = findPlaceholderBr(contentEl);\n\tif (placeholderBr) {\n\t\treturn { node: contentEl, offset: childIndexOf(contentEl, placeholderBr) };\n\t}\n\n\t// Walk through text nodes and inline elements to find the correct position\n\tlet remaining = pos.offset;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet current = walker.nextNode();\n\twhile (current) {\n\t\tif (current.nodeType === Node.TEXT_NODE) {\n\t\t\tconst len = current.textContent?.length ?? 0;\n\t\t\tif (remaining <= len) {\n\t\t\t\treturn { node: current, offset: remaining };\n\t\t\t}\n\t\t\tremaining -= len;\n\t\t} else if (isInlineNodeEl(current)) {\n\t\t\t// InlineNode element — width 1 in state offset space\n\t\t\tif (remaining === 0) {\n\t\t\t\t// Position before this inline element\n\t\t\t\tconst parent = current.parentNode;\n\t\t\t\tif (parent) {\n\t\t\t\t\tconst childIndex = childIndexOf(parent, current);\n\t\t\t\t\treturn { node: parent, offset: childIndex };\n\t\t\t\t}\n\t\t\t}\n\t\t\tremaining -= 1;\n\t\t}\n\t\tcurrent = walker.nextNode();\n\t}\n\n\t// Fallback: position at end of block\n\tconst lastChild = contentEl.lastChild;\n\tif (lastChild) {\n\t\tif (lastChild.nodeType === Node.TEXT_NODE) {\n\t\t\treturn { node: lastChild, offset: lastChild.textContent?.length ?? 0 };\n\t\t}\n\t\treturn { node: contentEl, offset: contentEl.childNodes.length };\n\t}\n\n\treturn { node: contentEl, offset: 0 };\n}\n\n/** Converts a DOM position to a state position, including nested path. */\nexport function domPositionToState(\n\tcontainer: HTMLElement,\n\tnode: Node,\n\tdomOffset: number,\n): Position | null {\n\t// Find the innermost block element\n\tconst blockEl = findBlockAncestor(container, node);\n\tif (!blockEl) return null;\n\n\tconst rawBlockId = blockEl.getAttribute('data-block-id');\n\tif (!rawBlockId) return null;\n\tconst bid = toBlockId(rawBlockId);\n\n\t// Build path by collecting all data-block-id ancestors from leaf to root\n\tconst path = buildBlockPath(container, blockEl);\n\n\t// Use contentDOM if available (NodeView blocks like code_block)\n\tconst contentEl: Element = resolveContentRoot(blockEl);\n\n\t// Handle clicks on the block or content element itself (e.g. empty paragraph with <br>)\n\tif (node === blockEl || node === contentEl) {\n\t\tconst targetEl: Element = node === contentEl ? contentEl : blockEl;\n\t\tlet childOffset = 0;\n\t\tlet childIdx = 0;\n\t\tfor (const child of Array.from(targetEl.childNodes)) {\n\t\t\tif (childIdx >= domOffset) break;\n\t\t\tchildOffset += inlineContentWidth(child);\n\t\t\tchildIdx++;\n\t\t}\n\t\treturn createPosition(bid, childOffset, path.length > 1 ? path : undefined);\n\t}\n\n\t// If node is outside the contentDOM (e.g. in NodeView header), map to offset 0\n\tif (contentEl !== blockEl && !contentEl.contains(node)) {\n\t\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n\t}\n\n\t// Calculate offset by walking text nodes and inline elements\n\tlet offset = 0;\n\tconst walker = createInlineContentWalker(contentEl);\n\n\tlet walkerNode = walker.nextNode();\n\twhile (walkerNode) {\n\t\tif (walkerNode === node) {\n\t\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\t\treturn createPosition(bid, offset + domOffset, path.length > 1 ? path : undefined);\n\t\t\t}\n\t\t\t// Node is an inline element — return offset at its start\n\t\t\treturn createPosition(bid, offset, path.length > 1 ? path : undefined);\n\t\t}\n\t\tif (walkerNode.nodeType === Node.TEXT_NODE) {\n\t\t\toffset += walkerNode.textContent?.length ?? 0;\n\t\t} else if (isInlineNodeEl(walkerNode)) {\n\t\t\toffset += 1;\n\t\t}\n\t\twalkerNode = walker.nextNode();\n\t}\n\n\t// If the node is not a text node, try to find the offset from element context\n\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\tconst childOffset = inlineOffsetForChildIndex(node, domOffset);\n\t\tconst offsetBeforeNode = inlineOffsetBeforeNode(contentEl, node);\n\t\tconst totalOffset = offsetBeforeNode === null ? childOffset : offsetBeforeNode + childOffset;\n\t\treturn createPosition(bid, totalOffset, path.length > 1 ? path : undefined);\n\t}\n\n\treturn createPosition(bid, 0, path.length > 1 ? path : undefined);\n}\n\n/** Counts inline width for the first `childIndex` children of an element. */\nfunction inlineOffsetForChildIndex(node: Node, childIndex: number): number {\n\tlet childOffset = 0;\n\tlet childIdx = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\tif (childIdx >= childIndex) break;\n\t\tchildOffset += inlineContentWidth(child);\n\t\tchildIdx++;\n\t}\n\treturn childOffset;\n}\n\n/** Returns the inline offset from `root` to the start of `node`, or null when unrelated. */\nfunction inlineOffsetBeforeNode(root: Element, node: Node): number | null {\n\tlet offset = 0;\n\tlet current: Node | null = node;\n\n\twhile (current && current !== root) {\n\t\tconst parent: Node | null = current.parentNode;\n\t\tif (!parent) return null;\n\n\t\tfor (const sibling of Array.from(parent.childNodes) as Node[]) {\n\t\t\tif (sibling === current) break;\n\t\t\toffset += inlineContentWidth(sibling);\n\t\t}\n\n\t\tcurrent = parent;\n\t}\n\n\treturn current === root ? offset : null;\n}\n\n/** Returns the child index of a node within its parent. */\nfunction childIndexOf(parent: Node, child: Node): number {\n\tlet idx = 0;\n\tfor (const c of Array.from(parent.childNodes)) {\n\t\tif (c === child) return idx;\n\t\tidx++;\n\t}\n\treturn idx;\n}\n\n/** Counts the inline content width of a DOM node (text length + 1 per inline element). */\nfunction inlineContentWidth(node: Node): number {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\treturn node.textContent?.length ?? 0;\n\t}\n\t// View-chrome widgets (e.g. the checklist marker) are not document content.\n\tif (isWidgetEl(node)) {\n\t\treturn 0;\n\t}\n\tif (isInlineNodeEl(node)) {\n\t\treturn 1;\n\t}\n\t// Mark wrapper or other element — sum children\n\tlet width = 0;\n\tfor (const child of Array.from(node.childNodes)) {\n\t\twidth += inlineContentWidth(child);\n\t}\n\treturn width;\n}\n"],"mappings":"Y,uJASA,IAAaQ,EAAsB,sBASnC,SAAgBC,EAAeC,GAC9B,OAAOA,aAAgBC,aAAwD,UAAzCD,EAAKE,aAAa,kBACzD,CAOA,SAAgBC,EAAWH,GAC1B,OAAOA,aAAgBC,aAAeD,EAAKI,aAAa,cACzD,CAGA,SAAgBC,EAAkBL,GACjC,OAAOA,aAAgBC,aAAeD,EAAKI,aAAA,sBAC5C,CAOA,SAAgBE,EAAmBC,GAElC,OADmCA,EAAQC,cAAc,uBACpCD,CACtB,CAeA,SAAgBE,EACfF,EACAG,EAAsC,CAAC,GAEvC,MAAMC,EAAgCD,EAAQC,uBAAwB,EACtE,OAAOC,SAASC,iBAAiBN,EAASO,WAAWC,SAAU,CAC9DC,WAAaC,GAERZ,EAAkBY,GACdN,EAAuBG,WAAWI,YAAcJ,WAAWK,cAK/DhB,EAAWc,IAoBlB,SAA+BjB,EAAYoB,GAC1C,IAAIC,EAAsBrB,EAAKsB,WAC/B,KAAOD,GAAUA,IAAWD,GAAM,CACjC,GAAIrB,EAAesB,GAClB,OAAO,EAERA,EAASA,EAAOC,UACjB,CACA,OAAO,CACR,CA3BOC,CAAsBN,EAAGV,IAEzBU,aAAahB,aAAegB,EAAEb,aAAa,kBAAoBa,IAAMV,EAJ/CO,WAAWK,cAQjCF,EAAEO,WAAaC,KAAKC,WAEpB3B,EAAekB,GAFuBH,WAAWa,cAM9Cb,WAAWI,aAGrB,CC9CA,SAAgBU,IACf,OAAOC,OAAOD,cACf,CA8BA,SAAgBE,EACfC,EACAC,GAEA,MAAMZ,EAAOW,EAAUE,cACvB,KAAMb,aAAgBc,YAAa,OAAO,KAC1C,KAAM,sBAAu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4F,GAC9CU,EAqBR,SAAgClF,EAAepB,GAC9C,IAAIgE,EAAS,EACTU,EAAuB1E,EAE3B,KAAO0E,GAAWA,IAAYtD,GAAM,CACnC,MAAMC,EAAsBqD,EAAQpD,WACpC,IAAKD,EAAQ,OAAO,KAEpB,IAAK,MAAMkF,KAAWtB,MAAMC,KAAK7D,EAAO8D,YAAuB,CAC9D,GAAIoB,IAAY7B,EAAS,MACzBV,GAAUiC,EAAmBM,EAC9B,CAEA7B,EAAUrD,CACX,CAEA,OAAOqD,IAAYtD,EAAO4C,EAAS,IACpC,CAtC2BwC,CAAuB3B,EAAW7E,GAE3D,OAAOT,EAAeuG,EADmB,OAArBQ,EAA4BN,EAAcM,EAAmBN,EACzCxB,EAAKC,OAAS,EAAID,OAAO,EAClE,CAEA,OAAOjF,EAAeuG,EAAK,EAAGtB,EAAKC,OAAS,EAAID,OAAO,EACxD,CAmCA,SAASf,EAAapC,EAAc2D,GACnC,IAAIyB,EAAM,EACV,IAAK,MAAMC,KAAKzB,MAAMC,KAAK7D,EAAO8D,YAAa,CAC9C,GAAIuB,IAAM1B,EAAO,OAAOyB,EACxBA,GACD,CACA,OAAOA,CACR,CAGA,SAASR,EAAmBjG,GAC3B,GAAIA,EAAKwB,WAAaC,KAAKC,UAC1B,OAAO1B,EAAK0F,aAAajB,QAAU,EAGpC,GAAItE,EAAWH,GACd,OAAO,EAER,GAAID,EAAeC,GAClB,OAAO,EAGR,IAAI2G,EAAQ,EACZ,IAAK,MAAM3B,KAASC,MAAMC,KAAKlF,EAAKmF,YACnCwB,GAASV,EAAmBjB,GAE7B,OAAO2B,CACR,Q"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionTransactions-mQ1NfMEg.mjs","names":[],"sources":["../../src/state/SelectionTransactions.ts"],"sourcesContent":["/**\n * Shared transaction builders for cursor and selection movement.\n *\n * These helpers encapsulate the common pattern of building a transaction\n * that sets a new selection and clears storedMarks.\n */\n\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n} from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from './EditorState.js';\nimport type { Transaction } from './Transaction.js';\n\n/** Builds a collapsed-cursor transaction that clears storedMarks. */\nexport function moveTx(state: EditorState, blockId: BlockId, offset: number): Transaction {\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createCollapsedSelection(blockId, offset))\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n\n/** Builds a NodeSelection transaction that clears storedMarks. */\nexport function nodeSelTx(state: EditorState, targetId: BlockId): Transaction {\n\tconst path: BlockId[] = (findNodePath(state.doc, targetId) ?? []) as BlockId[];\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createNodeSelection(targetId, path))\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n\n/** Builds a range-selection transaction that clears storedMarks. */\nexport function extendTx(\n\tstate: EditorState,\n\tanchorBlockId: BlockId,\n\tanchorOffset: number,\n\theadBlockId: BlockId,\n\theadOffset: number,\n): Transaction {\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(\n\t\t\tcreateSelection(\n\t\t\t\t{ blockId: anchorBlockId, offset: anchorOffset },\n\t\t\t\t{ blockId: headBlockId, offset: headOffset },\n\t\t\t),\n\t\t)\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectionTransactions-mQ1NfMEg.mjs","names":["findNodePath","createNodeSelection","createCollapsedSelection","createSelection","moveTx","state","blockId","offset","transaction","setSelection","setStoredMarks","storedMarks","build","nodeSelTx","targetId","path","doc","extendTx","anchorBlockId","anchorOffset","headBlockId","headOffset"],"sources":["../../src/state/SelectionTransactions.ts"],"sourcesContent":["/**\n * Shared transaction builders for cursor and selection movement.\n *\n * These helpers encapsulate the common pattern of building a transaction\n * that sets a new selection and clears storedMarks.\n */\n\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n} from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from './EditorState.js';\nimport type { Transaction } from './Transaction.js';\n\n/** Builds a collapsed-cursor transaction that clears storedMarks. */\nexport function moveTx(state: EditorState, blockId: BlockId, offset: number): Transaction {\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createCollapsedSelection(blockId, offset))\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n\n/** Builds a NodeSelection transaction that clears storedMarks. */\nexport function nodeSelTx(state: EditorState, targetId: BlockId): Transaction {\n\tconst path: BlockId[] = (findNodePath(state.doc, targetId) ?? []) as BlockId[];\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createNodeSelection(targetId, path))\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n\n/** Builds a range-selection transaction that clears storedMarks. */\nexport function extendTx(\n\tstate: EditorState,\n\tanchorBlockId: BlockId,\n\tanchorOffset: number,\n\theadBlockId: BlockId,\n\theadOffset: number,\n): Transaction {\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(\n\t\t\tcreateSelection(\n\t\t\t\t{ blockId: anchorBlockId, offset: anchorOffset },\n\t\t\t\t{ blockId: headBlockId, offset: headOffset },\n\t\t\t),\n\t\t)\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n"],"mappings":"Y,+FAkBA,SAAgBI,EAAOC,EAAoBC,EAAkBC,GAC5D,OAAOF,EACLG,YAAY,SACZC,aAAaP,EAAyBI,EAASC,IAC/CG,eAAe,KAAML,EAAMM,aAC3BC,OACH,CAGA,SAAgBC,EAAUR,EAAoBS,GAC7C,MAAMC,EAAmBf,EAAaK,EAAMW,IAAKF,IAAa,GAC9D,OAAOT,EACLG,YAAY,SACZC,aAAaR,EAAoBa,EAAUC,IAC3CL,eAAe,KAAML,EAAMM,aAC3BC,OACH,CAGA,SAAgBK,EACfZ,EACAa,EACAC,EACAC,EACAC,GAEA,OAAOhB,EACLG,YAAY,SACZC,aACAN,EACC,CAAEG,QAASY,EAAeX,OAAQY,GAClC,CAAEb,QAASc,EAAab,OAAQc,KAGjCX,eAAe,KAAML,EAAMM,aAC3BC,OACH,Q"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShortcutFormatting-TwiufqeV.mjs","names":[],"sources":["../../src/plugins/shared/ShortcutFormatting.ts"],"sourcesContent":["import { isMac } from '../../platform/Platform.js';\n\n/**\n * Formats a keymap binding string into a human-readable shortcut,\n * using platform-appropriate modifier symbols (⌘ on Mac, Ctrl on others).\n *\n * @example formatShortcut('Mod-B') → \"Ctrl+B\" or \"⌘B\"\n * @example formatShortcut('Mod-Shift-X') → \"Ctrl+Shift+X\" or \"⌘⇧X\"\n */\nexport function formatShortcut(binding: string): string {\n\tif (isMac()) {\n\t\treturn binding\n\t\t\t.replace(/Mod/g, '⌘')\n\t\t\t.replace(/Shift/g, '⇧')\n\t\t\t.replace(/Alt/g, '⌥')\n\t\t\t.replace(/-/g, '');\n\t}\n\treturn binding.replace(/Mod/g, 'Ctrl').replace(/-/g, '+');\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ShortcutFormatting-TwiufqeV.mjs","names":["isMac","formatShortcut","binding","replace"],"sources":["../../src/plugins/shared/ShortcutFormatting.ts"],"sourcesContent":["import { isMac } from '../../platform/Platform.js';\n\n/**\n * Formats a keymap binding string into a human-readable shortcut,\n * using platform-appropriate modifier symbols (⌘ on Mac, Ctrl on others).\n *\n * @example formatShortcut('Mod-B') → \"Ctrl+B\" or \"⌘B\"\n * @example formatShortcut('Mod-Shift-X') → \"Ctrl+Shift+X\" or \"⌘⇧X\"\n */\nexport function formatShortcut(binding: string): string {\n\tif (isMac()) {\n\t\treturn binding\n\t\t\t.replace(/Mod/g, '⌘')\n\t\t\t.replace(/Shift/g, '⇧')\n\t\t\t.replace(/Alt/g, '⌥')\n\t\t\t.replace(/-/g, '');\n\t}\n\treturn binding.replace(/Mod/g, 'Ctrl').replace(/-/g, '+');\n}\n"],"mappings":"Y,gCASA,SAAgBC,EAAeC,GAC9B,OAAIF,IACIE,EACLC,QAAQ,OAAQ,KAChBA,QAAQ,SAAU,KAClBA,QAAQ,OAAQ,KAChBA,QAAQ,KAAM,IAEVD,EAAQC,QAAQ,OAAQ,QAAQA,QAAQ,KAAM,IACtD,Q"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleMark-D6vz3Nfd.mjs","names":[],"sources":["../../src/plugins/shared/SimpleMark.ts"],"sourcesContent":["/**\n * Registers the common core of a simple toggle mark: its MarkSpec, a toggle\n * command, an optional keyboard shortcut, and an optional toolbar button.\n *\n * Plugins that need more (input rules, exclusivity middleware, config-driven\n * variants) layer those on top after calling this — it deliberately models only\n * the shared core, not every mark plugin.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport type { MarkSpec } from '../../model/MarkSpec.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent } from './PluginHelpers.js';\n\nexport interface SimpleMarkToolbar {\n\treadonly id: string;\n\treadonly group: string;\n\treadonly icon: string;\n\treadonly label: string;\n\treadonly tooltip: string;\n}\n\nexport interface SimpleMarkDefinition {\n\t/** The mark spec to register (defines DOM/HTML rendering and parsing). */\n\treadonly markSpec: MarkSpec;\n\t/** Toggle command name, e.g. `'toggleStrikethrough'`. */\n\treadonly command: string;\n\t/** Keyboard shortcut bound to the command; omit or `null` to skip. */\n\treadonly keyBinding?: string | null;\n\t/** Toolbar button; omit to skip. */\n\treadonly toolbar?: SimpleMarkToolbar;\n}\n\n/** Registers a simple toggle mark's spec, command, keymap, and toolbar item. */\nexport function registerSimpleMark(context: PluginContext, def: SimpleMarkDefinition): void {\n\tconst type = markType(def.markSpec.type);\n\n\tcontext.registerMarkSpec(def.markSpec);\n\n\tcontext.registerCommand(def.command, () =>\n\t\tdispatchIfPresent(context, toggleMark(context.getState(), type)),\n\t);\n\n\tif (def.keyBinding) {\n\t\tcontext.registerKeymap({ [def.keyBinding]: () => context.executeCommand(def.command) });\n\t}\n\n\tif (def.toolbar) {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: def.toolbar.id,\n\t\t\tgroup: def.toolbar.group,\n\t\t\ticon: def.toolbar.icon,\n\t\t\tlabel: def.toolbar.label,\n\t\t\ttooltip: def.toolbar.tooltip,\n\t\t\tcommand: def.command,\n\t\t\tisActive: (state) => isMarkActive(state, type),\n\t\t});\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SimpleMark-D6vz3Nfd.mjs","names":["markType","toggleMark","isMarkActive","dispatchIfPresent","registerSimpleMark","context","def","type","markSpec","registerMarkSpec","registerCommand","command","getState","keyBinding","registerKeymap","executeCommand","toolbar","registerToolbarItem","id","group","icon","label","tooltip","isActive","state"],"sources":["../../src/plugins/shared/SimpleMark.ts"],"sourcesContent":["/**\n * Registers the common core of a simple toggle mark: its MarkSpec, a toggle\n * command, an optional keyboard shortcut, and an optional toolbar button.\n *\n * Plugins that need more (input rules, exclusivity middleware, config-driven\n * variants) layer those on top after calling this — it deliberately models only\n * the shared core, not every mark plugin.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport type { MarkSpec } from '../../model/MarkSpec.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent } from './PluginHelpers.js';\n\nexport interface SimpleMarkToolbar {\n\treadonly id: string;\n\treadonly group: string;\n\treadonly icon: string;\n\treadonly label: string;\n\treadonly tooltip: string;\n}\n\nexport interface SimpleMarkDefinition {\n\t/** The mark spec to register (defines DOM/HTML rendering and parsing). */\n\treadonly markSpec: MarkSpec;\n\t/** Toggle command name, e.g. `'toggleStrikethrough'`. */\n\treadonly command: string;\n\t/** Keyboard shortcut bound to the command; omit or `null` to skip. */\n\treadonly keyBinding?: string | null;\n\t/** Toolbar button; omit to skip. */\n\treadonly toolbar?: SimpleMarkToolbar;\n}\n\n/** Registers a simple toggle mark's spec, command, keymap, and toolbar item. */\nexport function registerSimpleMark(context: PluginContext, def: SimpleMarkDefinition): void {\n\tconst type = markType(def.markSpec.type);\n\n\tcontext.registerMarkSpec(def.markSpec);\n\n\tcontext.registerCommand(def.command, () =>\n\t\tdispatchIfPresent(context, toggleMark(context.getState(), type)),\n\t);\n\n\tif (def.keyBinding) {\n\t\tcontext.registerKeymap({ [def.keyBinding]: () => context.executeCommand(def.command) });\n\t}\n\n\tif (def.toolbar) {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: def.toolbar.id,\n\t\t\tgroup: def.toolbar.group,\n\t\t\ticon: def.toolbar.icon,\n\t\t\tlabel: def.toolbar.label,\n\t\t\ttooltip: def.toolbar.tooltip,\n\t\t\tcommand: def.command,\n\t\t\tisActive: (state) => isMarkActive(state, type),\n\t\t});\n\t}\n}\n"],"mappings":"Y,0IAmCA,SAAgBI,EAAmBC,EAAwBC,GAC1D,MAAMC,EAAOP,EAASM,EAAIE,SAASD,MAEnCF,EAAQI,iBAAiBH,EAAIE,UAE7BH,EAAQK,gBAAgBJ,EAAIK,QAAA,IAC3BR,EAAkBE,EAASJ,EAAWI,EAAQO,WAAYL,KAGvDD,EAAIO,YACPR,EAAQS,eAAe,CAAA,CAAGR,EAAIO,YAAA,IAAmBR,EAAQU,eAAeT,EAAIK,WAGzEL,EAAIU,SACPX,EAAQY,oBAAoB,CAC3BC,GAAIZ,EAAIU,QAAQE,GAChBC,MAAOb,EAAIU,QAAQG,MACnBC,KAAMd,EAAIU,QAAQI,KAClBC,MAAOf,EAAIU,QAAQK,MACnBC,QAAShB,EAAIU,QAAQM,QACrBX,QAASL,EAAIK,QACbY,SAAWC,GAAUtB,EAAasB,EAAOjB,IAG5C,Q"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{E as t,_ as e,k as n,p as o}from"./Document-ssR6hBzG.mjs";import{n as s}from"./Selection-DC6AOGgF.mjs";import{a as c}from"./TypeBrands-Ch9856Gb.mjs";import{s as i}from"./BlockInsertion-CXfXqUZl.mjs";import{n as r}from"./TypedKeys-CA4bfw9O.mjs";import{c as a,o as l}from"./PluginHelpers-B3gk3VB3.mjs";import{n as d,t as u}from"./SelectionReplacement-vC1xhFS0.mjs";import{o as h}from"./xml-BsV44TrJ.mjs";import{i as m,o as g,r as f,t as p}from"./XmlSupport-3Za6SIqF.mjs";var x=/\n(?:[ \t]*\n)+/;function k(t,e){return!t.detection&&!e.detection||!(!t.detection||!e.detection)&&t.detection.language===e.detection.language}function j(t,e){const n=`${t.text}\n\n${e.text}`;if(!t.detection&&!e.detection)return{text:n,detection:null};const o=t.detection,s=e.detection;return{text:n,detection:{language:o.language,formattedText:`${o.formattedText}\n\n${s.formattedText}`,confidence:Math.max(o.confidence,s.confidence)}}}var b={detectedAsCodeBlock:t=>`Pasted as ${t} code block with syntax highlighting.`,detectedMixedContent:(t,e,n)=>{const o=[];if(t>0&&o.push(`${t} paragraph${t>1?"s":""}`),e>0){const t=n.join(", ");o.push(`${e} code block${e>1?"s":""} (${t})`)}return`Pasted as ${o.join(" and ")}.`}},C=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BWOue6jG.mjs"),"./locales/de.ts":()=>import("./de-CTzAMkXC.mjs"),"./locales/es.ts":()=>import("./es-DDoqchUq.mjs"),"./locales/fr.ts":()=>import("./fr-eC0UdAPu.mjs"),"./locales/hi.ts":()=>import("./hi-DY55FuDK.mjs"),"./locales/pt.ts":()=>import("./pt-Bu7Mbz67.mjs"),"./locales/ru.ts":()=>import("./ru-DyCTlhjg.mjs"),"./locales/zh.ts":()=>import("./zh-D1HSmSOf.mjs")});async function B(t){return a(C,t,b)}var S=new r("smartPaste"),y=[g,m,f,p],P=class{id="smart-paste";name="Smart Paste";dependencies=["code-block"];config;detectors=[];context=null;locale=b;constructor(t){this.config={...t}}async init(t){this.context=t,this.locale=await l(t,this.config.locale,b,B);const e=t.getService(h);if(e){for(const t of y){const n=e.get(t.id);e.register(n?{...n,detection:t.detection}:t)}e.onRegister(t=>{t.detection&&this.detectors.push(t.detection)})}if(this.config.detectors)for(const n of this.config.detectors)this.detectors.push(n);t.registerPasteInterceptor(this.handlePaste,{name:"smart-paste",priority:50}),t.registerService(S,{registerDetector:t=>{this.detectors.push(t)}})}destroy(){this.context=null,this.detectors.length=0}handlePaste=(t,e,n)=>{const o=function(t,e){const n=t.split(x).map(t=>t.trim()).filter(t=>t.length>0);if(0===n.length)return null;let o=!1;const s=n.map(t=>{const n=function(t,e){let n=null;for(const o of e){const e=o.detect(t);e&&(null===n||e.confidence>n.confidence||e.confidence===n.confidence&&e.language<n.language)&&(n=e)}return n}(t,e);return n&&(o=!0),{text:t,detection:n}});return o?function(t){if(t.length<=1)return t;const e=[t[0]];for(let n=1;n<t.length;n++){const o=t[n],s=e[e.length-1];k(s,o)?e[e.length-1]=j(s,o):e.push(o)}return e}(s):null}(t,this.detectors);if(!o)return null;const s=n.transaction("paste"),c=d(n,s);if("code_block"===u(c)?.type)return null;const i={builder:s,target:c,selection:n.selection};return 1===o.length&&o[0]?.detection?this.handleSingleCodeBlock(i,o[0].detection):this.handleMixedContent(i,o)};handleSingleCodeBlock(t,e){const n=this.buildCodeBlockTransaction(t,e);return n&&this.context&&this.context.announce(this.locale.detectedAsCodeBlock(e.language)),n}buildCodeBlockTransaction(t,e){const{builder:n,target:o,selection:c}=t,r=this.createCodeBlockNode(e);return i(o.state,n,o.blockId,[r],c,this.context?.getSchemaRegistry())?(n.setSelection(s(r.id,e.formattedText.length)),n.build()):null}handleMixedContent(t,e){const n=this.buildMultiBlockTransaction(t,e);return n&&this.context&&this.announceMixedContent(e),n}buildMultiBlockTransaction(t,e){const{builder:o,selection:c}=t,{state:r,blockId:a}=t.target,l=e.map(t=>t.detection?this.createCodeBlockNode(t.detection):this.createParagraphNode(t.text));if(!i(r,o,a,l,c,this.context?.getSchemaRegistry()))return null;const d=l[l.length-1];return d&&o.setSelection(s(d.id,n(d))),o.build()}createCodeBlockNode(n){return o(c("code_block"),[e(n.formattedText)],t(),{language:n.language,backgroundColor:""})}createParagraphNode(n){return o(c("paragraph"),[e(n)],t())}announceMixedContent(t){let e=0,n=0;const o=[];for(const s of t)s.detection?(n++,o.includes(s.detection.language)||o.push(s.detection.language)):e++;this.context?.announce(this.locale.detectedMixedContent(e,n,o))}};export{B as i,S as n,b as r,P as t};
|
|
2
|
+
//# sourceMappingURL=SmartPastePlugin-BHsYKbgd.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartPastePlugin-BHsYKbgd.mjs","names":["generateBlockId","createTextNode","getBlockLength","createBlockNode","createCollapsedSelection","nodeType","insertBlocksAfterAnchor","ServiceKey","loadLocaleModule","resolveLocale","resolveReplacementTarget","getReceivingBlock","LANGUAGE_REGISTRY_SERVICE_KEY","JSON_SUPPORT","JAVA_SUPPORT","TYPESCRIPT_SUPPORT","XML_SUPPORT","BLANK_LINE_SPLIT","canMerge","a","b","detection","language","merge","joinedText","text","detA","detB","formattedText","confidence","Math","max","SMART_PASTE_LOCALE_EN","detectedAsCodeBlock","detectedMixedContent","textCount","codeCount","languages","parts","push","langList","join","localeModules","Object","assign","async","loadSmartPasteLocale","lang","SMART_PASTE_SERVICE_KEY","BUILTIN_LANGUAGE_SUPPORTS","SmartPastePlugin","id","name","dependencies","config","detectors","context","locale","constructor","this","init","registry","getService","support","existing","get","register","onRegister","detector","registerPasteInterceptor","handlePaste","priority","registerService","registerDetector","destroy","length","plainText","_html","state","segments","trimmed","split","map","s","trim","filter","hasCode","segmentText","best","result","detect","detectBest","merged","i","current","previous","mergeAdjacentSegments","splitAndClassify","builder","transaction","target","type","paste","selection","handleSingleCodeBlock","handleMixedContent","tr","buildCodeBlockTransaction","announce","codeBlock","createCodeBlockNode","blockId","getSchemaRegistry","setSelection","build","buildMultiBlockTransaction","announceMixedContent","working","anchorBlockId","blocks","segment","createParagraphNode","lastBlock","backgroundColor","includes"],"sources":["../../src/plugins/smart-paste/ContentSplitter.ts","../../src/plugins/smart-paste/SmartPasteLocale.ts","../../src/plugins/smart-paste/SmartPasteTypes.ts","../../src/plugins/smart-paste/SmartPastePlugin.ts"],"sourcesContent":["/**\n * Splits pasted text at blank-line boundaries and classifies each segment\n * using content detectors. Adjacent segments of the same type are merged.\n */\n\nimport type { ContentDetector, DetectionResult, PasteSegment } from './SmartPasteTypes.js';\n\n/** Pattern matching one or more consecutive blank lines (may contain whitespace). */\nconst BLANK_LINE_SPLIT: RegExp = /\\n(?:[ \\t]*\\n)+/;\n\n/**\n * Splits text at blank-line boundaries and classifies each segment\n * using the provided detectors. Returns null if no code is detected\n * in any segment (the paste should fall through to default handling).\n */\nexport function splitAndClassify(\n\ttext: string,\n\tdetectors: readonly ContentDetector[],\n): readonly PasteSegment[] | null {\n\tconst rawSegments: readonly string[] = text.split(BLANK_LINE_SPLIT);\n\tconst trimmed: readonly string[] = rawSegments\n\t\t.map((s: string) => s.trim())\n\t\t.filter((s: string) => s.length > 0);\n\n\tif (trimmed.length === 0) return null;\n\n\tlet hasCode = false;\n\tconst segments: PasteSegment[] = trimmed.map((segmentText: string): PasteSegment => {\n\t\tconst detection: DetectionResult | null = detectBest(segmentText, detectors);\n\t\tif (detection) hasCode = true;\n\t\treturn { text: segmentText, detection };\n\t});\n\n\tif (!hasCode) return null;\n\n\treturn mergeAdjacentSegments(segments);\n}\n\n/**\n * Merges adjacent segments that share the same classification:\n * consecutive text segments become one paragraph, consecutive code\n * segments of the same language become one code block.\n */\nexport function mergeAdjacentSegments(segments: readonly PasteSegment[]): readonly PasteSegment[] {\n\tif (segments.length <= 1) return segments;\n\n\tconst merged: PasteSegment[] = [segments[0] as PasteSegment];\n\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tconst current: PasteSegment = segments[i] as PasteSegment;\n\t\tconst previous: PasteSegment = merged[merged.length - 1] as PasteSegment;\n\n\t\tif (canMerge(previous, current)) {\n\t\t\tmerged[merged.length - 1] = merge(previous, current);\n\t\t} else {\n\t\t\tmerged.push(current);\n\t\t}\n\t}\n\n\treturn merged;\n}\n\n/**\n * Picks the highest-confidence detection result from all detectors.\n * Ties are broken deterministically by lexicographic language id so the\n * outcome does not depend on detector registration order.\n */\nfunction detectBest(text: string, detectors: readonly ContentDetector[]): DetectionResult | null {\n\tlet best: DetectionResult | null = null;\n\n\tfor (const detector of detectors) {\n\t\tconst result: DetectionResult | null = detector.detect(text);\n\t\tif (!result) continue;\n\t\tif (\n\t\t\tbest === null ||\n\t\t\tresult.confidence > best.confidence ||\n\t\t\t(result.confidence === best.confidence && result.language < best.language)\n\t\t) {\n\t\t\tbest = result;\n\t\t}\n\t}\n\n\treturn best;\n}\n\n/** Two segments can merge if both are text or both are code of the same language. */\nfunction canMerge(a: PasteSegment, b: PasteSegment): boolean {\n\tif (!a.detection && !b.detection) return true;\n\tif (a.detection && b.detection) return a.detection.language === b.detection.language;\n\treturn false;\n}\n\n/** Merges two compatible segments into one. */\nfunction merge(a: PasteSegment, b: PasteSegment): PasteSegment {\n\tconst joinedText: string = `${a.text}\\n\\n${b.text}`;\n\n\tif (!a.detection && !b.detection) {\n\t\treturn { text: joinedText, detection: null };\n\t}\n\n\tconst detA: DetectionResult = a.detection as DetectionResult;\n\tconst detB: DetectionResult = b.detection as DetectionResult;\n\n\treturn {\n\t\ttext: joinedText,\n\t\tdetection: {\n\t\t\tlanguage: detA.language,\n\t\t\tformattedText: `${detA.formattedText}\\n\\n${detB.formattedText}`,\n\t\t\tconfidence: Math.max(detA.confidence, detB.confidence),\n\t\t},\n\t};\n}\n","/** Locale interface and default English locale for the SmartPastePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\nexport interface SmartPasteLocale {\n\treadonly detectedAsCodeBlock: (language: string) => string;\n\treadonly detectedMixedContent: (\n\t\ttextCount: number,\n\t\tcodeCount: number,\n\t\tlanguages: readonly string[],\n\t) => string;\n}\n\nexport const SMART_PASTE_LOCALE_EN: SmartPasteLocale = {\n\tdetectedAsCodeBlock: (language: string) =>\n\t\t`Pasted as ${language} code block with syntax highlighting.`,\n\tdetectedMixedContent: (textCount: number, codeCount: number, languages: readonly string[]) => {\n\t\tconst parts: string[] = [];\n\t\tif (textCount > 0) {\n\t\t\tparts.push(`${textCount} paragraph${textCount > 1 ? 's' : ''}`);\n\t\t}\n\t\tif (codeCount > 0) {\n\t\t\tconst langList: string = languages.join(', ');\n\t\t\tparts.push(`${codeCount} code block${codeCount > 1 ? 's' : ''} (${langList})`);\n\t\t}\n\t\treturn `Pasted as ${parts.join(' and ')}.`;\n\t},\n};\n\nconst localeModules: LocaleModuleMap<SmartPasteLocale> = import.meta.glob<{\n\tdefault: SmartPasteLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadSmartPasteLocale(lang: string): Promise<SmartPasteLocale> {\n\treturn loadLocaleModule(localeModules, lang, SMART_PASTE_LOCALE_EN);\n}\n","/**\n * Types for the smart paste plugin — content detection and formatting.\n */\n\nimport { ServiceKey } from '../Plugin.js';\nimport type { SmartPasteLocale } from './SmartPasteLocale.js';\n\n/** Result of detecting structured content in pasted text. */\nexport interface DetectionResult {\n\treadonly language: string;\n\treadonly formattedText: string;\n\treadonly confidence: number;\n}\n\n/** A classified segment of pasted text — either plain text or detected code. */\nexport interface PasteSegment {\n\treadonly text: string;\n\treadonly detection: DetectionResult | null;\n}\n\n/** Interface for content detectors that identify and format pasted text. */\nexport interface ContentDetector {\n\treadonly id: string;\n\tdetect(text: string): DetectionResult | null;\n}\n\n/** Configuration for the SmartPastePlugin. */\nexport interface SmartPasteConfig {\n\treadonly detectors?: readonly ContentDetector[];\n\treadonly locale?: SmartPasteLocale;\n}\n\n/** Public service for registering additional content detectors at runtime. */\nexport interface SmartPasteService {\n\tregisterDetector(detector: ContentDetector): void;\n}\n\nexport const SMART_PASTE_SERVICE_KEY = new ServiceKey<SmartPasteService>('smartPaste');\n","/**\n * SmartPastePlugin: detects structured content in clipboard text\n * and inserts it as formatted code blocks with syntax highlighting.\n * Mixed content (text + code) is split into separate blocks.\n */\n\nimport { insertBlocksAfterAnchor } from '../../commands/BlockInsertion.js';\nimport {\n\ttype ReplacementTarget,\n\tgetReceivingBlock,\n\tresolveReplacementTarget,\n} from '../../commands/SelectionReplacement.js';\nimport {\n\ttype BlockNode,\n\tcreateBlockNode,\n\tcreateTextNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n} from '../../model/Document.js';\nimport { type EditorSelection, createCollapsedSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction, TransactionBuilder } from '../../state/Transaction.js';\nimport type { PasteInterceptor, Plugin, PluginContext } from '../Plugin.js';\nimport { LANGUAGE_REGISTRY_SERVICE_KEY } from '../language/LanguageTypes.js';\nimport {\n\tJAVA_SUPPORT,\n\tJSON_SUPPORT,\n\tTYPESCRIPT_SUPPORT,\n\tXML_SUPPORT,\n} from '../language/bundles/index.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { splitAndClassify } from './ContentSplitter.js';\nimport {\n\tSMART_PASTE_LOCALE_EN,\n\ttype SmartPasteLocale,\n\tloadSmartPasteLocale,\n} from './SmartPasteLocale.js';\nimport type {\n\tContentDetector,\n\tDetectionResult,\n\tPasteSegment,\n\tSmartPasteConfig,\n} from './SmartPasteTypes.js';\nimport { SMART_PASTE_SERVICE_KEY } from './SmartPasteTypes.js';\n\nconst BUILTIN_LANGUAGE_SUPPORTS = [\n\tJAVA_SUPPORT,\n\tJSON_SUPPORT,\n\tTYPESCRIPT_SUPPORT,\n\tXML_SUPPORT,\n] as const;\n\n/** A paste whose selection deletion is already recorded in `builder`. */\ninterface ReplacementPaste {\n\treadonly builder: TransactionBuilder;\n\treadonly target: ReplacementTarget;\n\treadonly selection: EditorSelection;\n}\n\nexport class SmartPastePlugin implements Plugin {\n\treadonly id = 'smart-paste';\n\treadonly name = 'Smart Paste';\n\treadonly dependencies = ['code-block'] as const;\n\n\tprivate readonly config: SmartPasteConfig;\n\tprivate readonly detectors: ContentDetector[] = [];\n\tprivate context: PluginContext | null = null;\n\tprivate locale: SmartPasteLocale = SMART_PASTE_LOCALE_EN;\n\n\tconstructor(config?: Partial<SmartPasteConfig>) {\n\t\tthis.config = { ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.context = context;\n\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSMART_PASTE_LOCALE_EN,\n\t\t\tloadSmartPasteLocale,\n\t\t);\n\n\t\t// Detection belongs to Smart Paste, while Code Block contributes only\n\t\t// highlighting. Preserve those existing capabilities when adding detectors.\n\t\tconst registry = context.getService(LANGUAGE_REGISTRY_SERVICE_KEY);\n\t\tif (registry) {\n\t\t\tfor (const support of BUILTIN_LANGUAGE_SUPPORTS) {\n\t\t\t\tconst existing = registry.get(support.id);\n\t\t\t\tregistry.register(existing ? { ...existing, detection: support.detection } : support);\n\t\t\t}\n\t\t\tregistry.onRegister((support) => {\n\t\t\t\tif (support.detection) {\n\t\t\t\t\tthis.detectors.push(support.detection);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// Register config-provided detectors\n\t\tif (this.config.detectors) {\n\t\t\tfor (const detector of this.config.detectors) {\n\t\t\t\tthis.detectors.push(detector);\n\t\t\t}\n\t\t}\n\n\t\t// Register paste interceptor\n\t\tcontext.registerPasteInterceptor(this.handlePaste, { name: 'smart-paste', priority: 50 });\n\n\t\t// Register service for external detector registration\n\t\tcontext.registerService(SMART_PASTE_SERVICE_KEY, {\n\t\t\tregisterDetector: (detector: ContentDetector) => {\n\t\t\t\tthis.detectors.push(detector);\n\t\t\t},\n\t\t});\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t\tthis.detectors.length = 0;\n\t}\n\n\t// --- Paste Interceptor ---\n\n\tprivate readonly handlePaste: PasteInterceptor = (\n\t\tplainText: string,\n\t\t_html: string,\n\t\tstate: EditorState,\n\t): Transaction | null => {\n\t\tconst segments: readonly PasteSegment[] | null = splitAndClassify(plainText, this.detectors);\n\t\tif (!segments) return null;\n\n\t\t// Text that lands in a code block is pasted literally by the code block.\n\t\tconst builder: TransactionBuilder = state.transaction('paste');\n\t\tconst target: ReplacementTarget = resolveReplacementTarget(state, builder);\n\t\tif (getReceivingBlock(target)?.type === 'code_block') return null;\n\n\t\tconst paste: ReplacementPaste = { builder, target, selection: state.selection };\n\n\t\t// Single code-only segment: use existing fast path\n\t\tif (segments.length === 1 && segments[0]?.detection) {\n\t\t\treturn this.handleSingleCodeBlock(paste, segments[0].detection);\n\t\t}\n\n\t\t// Mixed content: create multiple blocks\n\t\treturn this.handleMixedContent(paste, segments);\n\t};\n\n\t// --- Single Code Block (existing behavior) ---\n\n\tprivate handleSingleCodeBlock(\n\t\tpaste: ReplacementPaste,\n\t\tdetection: DetectionResult,\n\t): Transaction | null {\n\t\tconst tr: Transaction | null = this.buildCodeBlockTransaction(paste, detection);\n\t\tif (tr && this.context) {\n\t\t\tthis.context.announce(this.locale.detectedAsCodeBlock(detection.language));\n\t\t}\n\t\treturn tr;\n\t}\n\n\tprivate buildCodeBlockTransaction(\n\t\tpaste: ReplacementPaste,\n\t\tdetection: DetectionResult,\n\t): Transaction | null {\n\t\tconst { builder, target, selection } = paste;\n\n\t\t// Create the code block node\n\t\tconst codeBlock: BlockNode = this.createCodeBlockNode(detection);\n\n\t\t// Insert at cursor (actual parent or root escape, empty anchor removal)\n\t\tif (\n\t\t\t!insertBlocksAfterAnchor(\n\t\t\t\ttarget.state,\n\t\t\t\tbuilder,\n\t\t\t\ttarget.blockId,\n\t\t\t\t[codeBlock],\n\t\t\t\tselection,\n\t\t\t\tthis.context?.getSchemaRegistry(),\n\t\t\t)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tbuilder.setSelection(createCollapsedSelection(codeBlock.id, detection.formattedText.length));\n\n\t\treturn builder.build();\n\t}\n\n\t// --- Mixed Content (multiple blocks) ---\n\n\tprivate handleMixedContent(\n\t\tpaste: ReplacementPaste,\n\t\tsegments: readonly PasteSegment[],\n\t): Transaction | null {\n\t\tconst tr: Transaction | null = this.buildMultiBlockTransaction(paste, segments);\n\t\tif (tr && this.context) {\n\t\t\tthis.announceMixedContent(segments);\n\t\t}\n\t\treturn tr;\n\t}\n\n\tprivate buildMultiBlockTransaction(\n\t\tpaste: ReplacementPaste,\n\t\tsegments: readonly PasteSegment[],\n\t): Transaction | null {\n\t\tconst { builder, selection } = paste;\n\t\tconst { state: working, blockId: anchorBlockId } = paste.target;\n\t\tconst blocks: readonly BlockNode[] = segments.map((segment) =>\n\t\t\tsegment.detection\n\t\t\t\t? this.createCodeBlockNode(segment.detection)\n\t\t\t\t: this.createParagraphNode(segment.text),\n\t\t);\n\t\tif (\n\t\t\t!insertBlocksAfterAnchor(\n\t\t\t\tworking,\n\t\t\t\tbuilder,\n\t\t\t\tanchorBlockId,\n\t\t\t\tblocks,\n\t\t\t\tselection,\n\t\t\t\tthis.context?.getSchemaRegistry(),\n\t\t\t)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst lastBlock = blocks[blocks.length - 1];\n\t\tif (lastBlock) {\n\t\t\tbuilder.setSelection(createCollapsedSelection(lastBlock.id, getBlockLength(lastBlock)));\n\t\t}\n\n\t\treturn builder.build();\n\t}\n\n\tprivate createCodeBlockNode(detection: DetectionResult): BlockNode {\n\t\treturn createBlockNode(\n\t\t\tnodeType('code_block'),\n\t\t\t[createTextNode(detection.formattedText)],\n\t\t\tgenerateBlockId(),\n\t\t\t{ language: detection.language, backgroundColor: '' },\n\t\t);\n\t}\n\n\tprivate createParagraphNode(text: string): BlockNode {\n\t\treturn createBlockNode(nodeType('paragraph'), [createTextNode(text)], generateBlockId());\n\t}\n\n\tprivate announceMixedContent(segments: readonly PasteSegment[]): void {\n\t\tlet textCount = 0;\n\t\tlet codeCount = 0;\n\t\tconst languages: string[] = [];\n\n\t\tfor (const segment of segments) {\n\t\t\tif (segment.detection) {\n\t\t\t\tcodeCount++;\n\t\t\t\tif (!languages.includes(segment.detection.language)) {\n\t\t\t\t\tlanguages.push(segment.detection.language);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttextCount++;\n\t\t\t}\n\t\t}\n\n\t\tthis.context?.announce(this.locale.detectedMixedContent(textCount, codeCount, languages));\n\t}\n}\n"],"mappings":"Y,gdAQA,IAAMiB,EAA2B,kBA8EjC,SAASC,EAASC,EAAiBC,GAClC,OAAKD,EAAEE,YAAcD,EAAEC,cACnBF,EAAEE,YAAaD,EAAEC,YAAkBF,EAAEE,UAAUC,WAAaF,EAAEC,UAAUC,QAE7E,CAGA,SAASC,EAAMJ,EAAiBC,GAC/B,MAAMI,EAAqB,GAAGL,EAAEM,WAAWL,EAAEK,OAE7C,IAAKN,EAAEE,YAAcD,EAAEC,UACtB,MAAO,CAAEI,KAAMD,EAAYH,UAAW,MAGvC,MAAMK,EAAwBP,EAAEE,UAC1BM,EAAwBP,EAAEC,UAEhC,MAAO,CACNI,KAAMD,EACNH,UAAW,CACVC,SAAUI,EAAKJ,SACfM,cAAe,GAAGF,EAAKE,oBAAoBD,EAAKC,gBAChDC,WAAYC,KAAKC,IAAIL,EAAKG,WAAYF,EAAKE,aAG9C,CClGA,IAAaG,EAA0C,CACtDC,oBAAsBX,GACrB,aAAaA,yCACdY,qBAAA,CAAuBC,EAAmBC,EAAmBC,KAC5D,MAAMC,EAAkB,GAIxB,GAHIH,EAAY,GACfG,EAAMC,KAAK,GAAGJ,cAAsBA,EAAY,EAAI,IAAM,MAEvDC,EAAY,EAAG,CAClB,MAAMI,EAAmBH,EAAUI,KAAK,MACxCH,EAAMC,KAAK,GAAGH,eAAuBA,EAAY,EAAI,IAAM,OAAOI,KACnE,CACA,MAAO,aAAaF,EAAMG,KAAK,cAI3B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AyBsH,EAAUvE,GAAIjD,EAAewH,KAGrExB,EAAQgB,OAChB,CAEA,mBAAAJ,CAA4BzF,GAC3B,OAAOlB,EACNE,EAAS,cACT,CAACJ,EAAeoB,EAAUO,gBAC1B5B,IACA,CAAEsB,SAAUD,EAAUC,SAAUqG,gBAAiB,IAEnD,CAEA,mBAAAF,CAA4BhG,GAC3B,OAAOtB,EAAgBE,EAAS,aAAc,CAACJ,EAAewB,IAAQzB,IACvE,CAEA,oBAAAoH,CAA6BrC,GAC5B,IAAI5C,EAAY,EACZC,EAAY,EAChB,MAAMC,EAAsB,GAE5B,IAAK,MAAMmF,KAAWzC,EACjByC,EAAQnG,WACXe,IACKC,EAAUuF,SAASJ,EAAQnG,UAAUC,WACzCe,EAAUE,KAAKiF,EAAQnG,UAAUC,WAGlCa,IAIFwB,KAAKH,SAASoD,SAASjD,KAAKF,OAAOvB,qBAAqBC,EAAWC,EAAWC,GAC/E,U"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StarterFonts-BDQPg-cu.mjs","names":[],"sources":["../../src/plugins/font/StarterFonts.ts"],"sourcesContent":[null],"mappings":"AAQA,
|
|
1
|
+
{"version":3,"file":"StarterFonts-BDQPg-cu.mjs","names":["FIRA_CODE","name","family","category","fontFaces","src","weight","style","FIRA_SANS","STARTER_FONTS"],"sources":["../../src/plugins/font/StarterFonts.ts"],"sourcesContent":[null],"mappings":"AAQA,IAOaA,EAA4B,CACxCC,KAAM,YACNC,OAAQ,yBACRC,SAAU,YACVC,UAAW,CACV,CACCC,IAAK,u+sIACLC,OAAQ,MACRC,MAAO,YAMGC,EAA4B,CACxCP,KAAM,YACNC,OAAQ,0BACRC,SAAU,aACVC,UAAW,CACV,CACCC,IAAK,+rgLACLC,OAAQ,MACRC,MAAO,YAMGE,EAA2C,CAACD,EAAWR,U"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StrikethroughPlugin-v-VJZzUZ.mjs","names":[],"sources":["../../src/plugins/strikethrough/StrikethroughLocale.ts","../../src/plugins/strikethrough/StrikethroughPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the StrikethroughPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface StrikethroughLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const STRIKETHROUGH_LOCALE_EN: StrikethroughLocale = {\n\tlabel: 'Strikethrough',\n\ttooltip: (shortcut: string) => `Strikethrough (${shortcut})`,\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<StrikethroughLocale> = import.meta.glob<{\n\tdefault: StrikethroughLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadStrikethroughLocale(lang: string): Promise<StrikethroughLocale> {\n\treturn loadLocaleModule(localeModules, lang, STRIKETHROUGH_LOCALE_EN);\n}\n","/**\n * StrikethroughPlugin: registers a strikethrough inline mark with MarkSpec,\n * toggle command, keyboard shortcut (Mod-Shift-X), and a toolbar button.\n */\n\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { createMarkInputRule } from '../shared/MarkInputRule.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { formatShortcut } from '../shared/ShortcutFormatting.js';\nimport { registerSimpleMark } from '../shared/SimpleMark.js';\nimport {\n\tSTRIKETHROUGH_LOCALE_EN,\n\ttype StrikethroughLocale,\n\tloadStrikethroughLocale,\n} from './StrikethroughLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tstrikethrough: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\nexport interface StrikethroughConfig {\n\t/** Live Markdown shortcut: `~~x~~` to strikethrough. Default true. */\n\treadonly inputRule?: boolean;\n\treadonly locale?: StrikethroughLocale;\n}\n\nconst DEFAULT_CONFIG: StrikethroughConfig = {};\n\n// --- Plugin ---\n\nexport class StrikethroughPlugin implements Plugin {\n\treadonly id = 'strikethrough';\n\treadonly name = 'Strikethrough';\n\treadonly priority = 22;\n\n\tprivate readonly config: StrikethroughConfig;\n\tprivate locale!: StrikethroughLocale;\n\n\tconstructor(config?: Partial<StrikethroughConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSTRIKETHROUGH_LOCALE_EN,\n\t\t\tloadStrikethroughLocale,\n\t\t);\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z\"/></svg>';\n\n\t\tregisterSimpleMark(context, {\n\t\t\tmarkSpec: {\n\t\t\t\ttype: 'strikethrough',\n\t\t\t\trank: 3,\n\t\t\t\ttoDOM() {\n\t\t\t\t\treturn document.createElement('s');\n\t\t\t\t},\n\t\t\t\ttoHTMLString: (_mark, content) => `<s>${content}</s>`,\n\t\t\t\tparseHTML: [\n\t\t\t\t\t{ tag: 's' },\n\t\t\t\t\t{ tag: 'strike' },\n\t\t\t\t\t{ tag: 'del' },\n\t\t\t\t\t{\n\t\t\t\t\t\ttag: 'span',\n\t\t\t\t\t\tgetAttrs: (el: HTMLElement) => {\n\t\t\t\t\t\t\treturn el.style.textDecoration.includes('line-through') ? {} : false;\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tsanitize: { tags: ['s'] },\n\t\t\t},\n\t\t\tcommand: 'toggleStrikethrough',\n\t\t\tkeyBinding: 'Mod-Shift-X',\n\t\t\ttoolbar: {\n\t\t\t\tid: 'strikethrough',\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon,\n\t\t\t\tlabel: this.locale.label,\n\t\t\t\ttooltip: this.locale.tooltip(formatShortcut('Mod-Shift-X')),\n\t\t\t},\n\t\t});\n\n\t\tif (this.config.inputRule !== false) {\n\t\t\tcontext.registerInputRule(createMarkInputRule('strikethrough', '~~'));\n\t\t}\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"StrikethroughPlugin-v-VJZzUZ.mjs","names":["loadLocaleModule","resolveLocale","createMarkInputRule","formatShortcut","registerSimpleMark","STRIKETHROUGH_LOCALE_EN","label","tooltip","shortcut","localeModules","Object","assign","async","loadStrikethroughLocale","lang","DEFAULT_CONFIG","StrikethroughPlugin","id","name","priority","config","locale","constructor","this","init","context","markSpec","type","rank","toDOM","document","createElement","toHTMLString","_mark","content","parseHTML","tag","getAttrs","el","style","textDecoration","includes","sanitize","tags","command","keyBinding","toolbar","group","icon","inputRule","registerInputRule"],"sources":["../../src/plugins/strikethrough/StrikethroughLocale.ts","../../src/plugins/strikethrough/StrikethroughPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the StrikethroughPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface StrikethroughLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const STRIKETHROUGH_LOCALE_EN: StrikethroughLocale = {\n\tlabel: 'Strikethrough',\n\ttooltip: (shortcut: string) => `Strikethrough (${shortcut})`,\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<StrikethroughLocale> = import.meta.glob<{\n\tdefault: StrikethroughLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadStrikethroughLocale(lang: string): Promise<StrikethroughLocale> {\n\treturn loadLocaleModule(localeModules, lang, STRIKETHROUGH_LOCALE_EN);\n}\n","/**\n * StrikethroughPlugin: registers a strikethrough inline mark with MarkSpec,\n * toggle command, keyboard shortcut (Mod-Shift-X), and a toolbar button.\n */\n\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { createMarkInputRule } from '../shared/MarkInputRule.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { formatShortcut } from '../shared/ShortcutFormatting.js';\nimport { registerSimpleMark } from '../shared/SimpleMark.js';\nimport {\n\tSTRIKETHROUGH_LOCALE_EN,\n\ttype StrikethroughLocale,\n\tloadStrikethroughLocale,\n} from './StrikethroughLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tstrikethrough: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\nexport interface StrikethroughConfig {\n\t/** Live Markdown shortcut: `~~x~~` to strikethrough. Default true. */\n\treadonly inputRule?: boolean;\n\treadonly locale?: StrikethroughLocale;\n}\n\nconst DEFAULT_CONFIG: StrikethroughConfig = {};\n\n// --- Plugin ---\n\nexport class StrikethroughPlugin implements Plugin {\n\treadonly id = 'strikethrough';\n\treadonly name = 'Strikethrough';\n\treadonly priority = 22;\n\n\tprivate readonly config: StrikethroughConfig;\n\tprivate locale!: StrikethroughLocale;\n\n\tconstructor(config?: Partial<StrikethroughConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSTRIKETHROUGH_LOCALE_EN,\n\t\t\tloadStrikethroughLocale,\n\t\t);\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z\"/></svg>';\n\n\t\tregisterSimpleMark(context, {\n\t\t\tmarkSpec: {\n\t\t\t\ttype: 'strikethrough',\n\t\t\t\trank: 3,\n\t\t\t\ttoDOM() {\n\t\t\t\t\treturn document.createElement('s');\n\t\t\t\t},\n\t\t\t\ttoHTMLString: (_mark, content) => `<s>${content}</s>`,\n\t\t\t\tparseHTML: [\n\t\t\t\t\t{ tag: 's' },\n\t\t\t\t\t{ tag: 'strike' },\n\t\t\t\t\t{ tag: 'del' },\n\t\t\t\t\t{\n\t\t\t\t\t\ttag: 'span',\n\t\t\t\t\t\tgetAttrs: (el: HTMLElement) => {\n\t\t\t\t\t\t\treturn el.style.textDecoration.includes('line-through') ? {} : false;\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tsanitize: { tags: ['s'] },\n\t\t\t},\n\t\t\tcommand: 'toggleStrikethrough',\n\t\t\tkeyBinding: 'Mod-Shift-X',\n\t\t\ttoolbar: {\n\t\t\t\tid: 'strikethrough',\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon,\n\t\t\t\tlabel: this.locale.label,\n\t\t\t\ttooltip: this.locale.tooltip(formatShortcut('Mod-Shift-X')),\n\t\t\t},\n\t\t});\n\n\t\tif (this.config.inputRule !== false) {\n\t\t\tcontext.registerInputRule(createMarkInputRule('strikethrough', '~~'));\n\t\t}\n\t}\n}\n"],"mappings":"Y,iMAeA,IAAaK,EAA+C,CAC3DC,MAAO,gBACPC,QAAUC,GAAqB,kBAAkBA,MAK5CC,iBAAsDC,OAAAC,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAI5DC,eAAsBC,EAAwBC,GAC7C,OAAOd,EAAiBS,EAAeK,EAAMT,EAC9C,CCIA,IAAMU,EAAsC,CAAC,EAIhCC,EAAb,MACCC,GAAc,gBACdC,KAAgB,gBAChBC,SAAoB,GAEpBC,OACAC,OAEA,WAAAC,CAAYF,GACXG,KAAKH,OAAS,IAAKL,KAAmBK,EACvC,CAEA,UAAMI,CAAKC,GACVF,KAAKF,aAAepB,EACnBwB,EACAF,KAAKH,OAAOC,OACZhB,EACAQ,GAKDT,EAAmBqB,EAAS,CAC3BC,SAAU,CACTC,KAAM,gBACNC,KAAM,EACNC,MAAA,IACQC,SAASC,cAAc,KAE/BC,aAAA,CAAeC,EAAOC,IAAY,MAAMA,QACxCC,UAAW,CACV,CAAEC,IAAK,KACP,CAAEA,IAAK,UACP,CAAEA,IAAK,OACP,CACCA,IAAK,OACLC,SAAWC,KACHA,EAAGC,MAAMC,eAAeC,SAAS,iBAAkB,CAAC,IAI9DC,SAAU,CAAEC,KAAM,CAAC,OAEpBC,QAAS,sBACTC,WAAY,cACZC,QAAS,CACR7B,GAAI,gBACJ8B,MAAO,SACPC,KAAA,uIACA1C,MAAOiB,KAAKF,OAAOf,MACnBC,QAASgB,KAAKF,OAAOd,QAAQJ,EAAe,oBAIhB,IAA1BoB,KAAKH,OAAO6B,WACfxB,EAAQyB,kBAAkBhD,EAAoB,gBAAiB,MAEjE,U"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyleClassNames-BsAx7k5T.mjs","names":[],"sources":["../../src/plugins/shared/StyleClassNames.ts"],"sourcesContent":["/**\n * The `styleClasses` option of formatting plugins (#269): application CSS\n * classes keyed by the plugin's own values, registered as one style class per\n * entry. Kept out of `PluginHelpers` so only plugins that offer the option load it.\n */\n\nimport type { StyleClassNames } from '../../model/StyleClass.js';\nimport type { PluginContext } from '../Plugin.js';\n\n/**\n * Registers a plugin's `styleClasses` option. `declarationFor` turns a key into\n * the declaration the plugin exports for that value, with the same function\n * its export uses, and throws a `TypeError` for a key that is not a valid value.\n * Errors name the plugin, so a misconfiguration fails `init()` with a clear fix.\n */\nexport function registerStyleClassNames(\n\tcontext: PluginContext,\n\towner: string,\n\tstyleClasses: StyleClassNames<PropertyKey> | undefined,\n\tdeclarationFor: (key: string) => string,\n): void {\n\tif (!styleClasses) return;\n\tfor (const [key, className] of Object.entries(styleClasses)) {\n\t\tif (className === undefined) continue;\n\t\ttry {\n\t\t\tcontext.registerStyleClass({ className, declaration: declarationFor(key) });\n\t\t} catch (error: unknown) {\n\t\t\tif (!(error instanceof TypeError)) throw error;\n\t\t\tthrow new TypeError(`${owner} styleClasses: ${error.message}`);\n\t\t}\n\t}\n}\n"],"mappings":"AAeA,
|
|
1
|
+
{"version":3,"file":"StyleClassNames-BsAx7k5T.mjs","names":["registerStyleClassNames","context","owner","styleClasses","declarationFor","key","className","Object","entries","registerStyleClass","declaration","error","TypeError","message"],"sources":["../../src/plugins/shared/StyleClassNames.ts"],"sourcesContent":["/**\n * The `styleClasses` option of formatting plugins (#269): application CSS\n * classes keyed by the plugin's own values, registered as one style class per\n * entry. Kept out of `PluginHelpers` so only plugins that offer the option load it.\n */\n\nimport type { StyleClassNames } from '../../model/StyleClass.js';\nimport type { PluginContext } from '../Plugin.js';\n\n/**\n * Registers a plugin's `styleClasses` option. `declarationFor` turns a key into\n * the declaration the plugin exports for that value, with the same function\n * its export uses, and throws a `TypeError` for a key that is not a valid value.\n * Errors name the plugin, so a misconfiguration fails `init()` with a clear fix.\n */\nexport function registerStyleClassNames(\n\tcontext: PluginContext,\n\towner: string,\n\tstyleClasses: StyleClassNames<PropertyKey> | undefined,\n\tdeclarationFor: (key: string) => string,\n): void {\n\tif (!styleClasses) return;\n\tfor (const [key, className] of Object.entries(styleClasses)) {\n\t\tif (className === undefined) continue;\n\t\ttry {\n\t\t\tcontext.registerStyleClass({ className, declaration: declarationFor(key) });\n\t\t} catch (error: unknown) {\n\t\t\tif (!(error instanceof TypeError)) throw error;\n\t\t\tthrow new TypeError(`${owner} styleClasses: ${error.message}`);\n\t\t}\n\t}\n}\n"],"mappings":"AAeA,SAAgBA,EACfC,EACAC,EACAC,EACAC,GAEA,GAAKD,EACL,IAAK,MAAOE,EAAKC,KAAcC,OAAOC,QAAQL,GAC7C,QAAkB,IAAdG,EACJ,IACCL,EAAQQ,mBAAmB,CAAEH,YAAWI,YAAaN,EAAeC,IACrE,CAAA,MAASM,GACR,KAAMA,aAAiBC,WAAY,MAAMD,EACzC,MAAM,IAAIC,UAAU,GAAGV,mBAAuBS,EAAME,UACrD,CAEF,Q"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyleRuntime-C0RSqKzG.mjs","names":[],"sources":["../../src/style/StyleRuntime.ts"],"sourcesContent":["/**\n * Runtime style abstraction.\n *\n * Writes no inline styles and instead assigns token attributes\n * backed by dynamic CSS rules in a stylesheet.\n * Elements outside a registered root fall back to inline styles.\n */\n\nexport interface StyleRootOptions {\n\treadonly nonce?: string;\n\treadonly sheet?: CSSStyleSheet | null;\n}\n\ntype StyleRoot = ShadowRoot | Document;\n\ninterface RootConfig {\n\treadonly nonce?: string;\n\treadonly sheet: CSSStyleSheet | null;\n}\n\nconst STYLE_TOKEN_ATTR = 'data-notectl-style-token';\nconst STYLE_ELEMENT_ATTR = 'data-notectl-runtime-styles';\n\nconst rootConfigs: WeakMap<StyleRoot, RootConfig> = new WeakMap();\nconst strictEngines: WeakMap<StyleRoot, StrictStyleEngine> = new WeakMap();\nconst runtimeSheets: WeakSet<CSSStyleSheet> = new WeakSet();\n\n/**\n * True when the sheet holds runtime style-token rules, i.e. element styling\n * that would be inline `style` attributes outside strict-CSP mode. Consumers\n * (e.g. print) can use this to treat such rules as content styling rather\n * than editor base styles.\n */\nexport function isRuntimeStyleSheet(sheet: CSSStyleSheet): boolean {\n\treturn runtimeSheets.has(sheet);\n}\n\n/** Creates a constructable stylesheet when the environment supports it. */\nexport function createRuntimeStyleSheet(): CSSStyleSheet | null {\n\tif (typeof CSSStyleSheet === 'undefined') return null;\n\ttry {\n\t\tconst sheet = new CSSStyleSheet();\n\t\truntimeSheets.add(sheet);\n\t\treturn sheet;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** Registers styling mode for a root (shadow root or document). */\nexport function registerStyleRoot(root: StyleRoot, options: StyleRootOptions): void {\n\tconst previous = strictEngines.get(root);\n\tif (previous) {\n\t\tprevious.destroy();\n\t\tstrictEngines.delete(root);\n\t}\n\tif (options.sheet) {\n\t\truntimeSheets.add(options.sheet);\n\t}\n\trootConfigs.set(root, {\n\t\tnonce: options.nonce,\n\t\tsheet: options.sheet ?? null,\n\t});\n}\n\n/** Unregisters root styling and tears down strict runtime state if present. */\nexport function unregisterStyleRoot(root: StyleRoot): void {\n\tconst engine = strictEngines.get(root);\n\tif (engine) {\n\t\tengine.destroy();\n\t\tstrictEngines.delete(root);\n\t}\n\trootConfigs.delete(root);\n}\n\n/** Sets a single style property. Empty value removes the property. */\nexport function setStyleProperty(el: HTMLElement, property: string, value: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tsetInlineProperty(el, property, value);\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setProperty(el, property, value);\n}\n\n/** Removes a single style property. */\nexport function removeStyleProperty(el: HTMLElement, property: string): void {\n\tsetStyleProperty(el, property, '');\n}\n\n/** Sets multiple style properties in one call. */\nexport function setStyleProperties(\n\tel: HTMLElement,\n\tproperties: Readonly<Record<string, string | undefined | null>>,\n): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tfor (const [property, value] of Object.entries(properties)) {\n\t\t\tsetInlineProperty(el, property, value ?? '');\n\t\t}\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setProperties(el, properties);\n}\n\n/** Replaces the element style text. */\nexport function setStyleText(el: HTMLElement, cssText: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tel.style.cssText = cssText;\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setStyleText(el, cssText);\n}\n\n/** Merges a cssText fragment into current element styles. */\nexport function appendStyleText(el: HTMLElement, cssText: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tconst current = el.style.cssText;\n\t\tel.style.cssText = current ? `${current}; ${cssText}` : cssText;\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).appendStyleText(el, cssText);\n}\n\n/** Returns serialized styles for an element. */\nexport function getStyleText(el: HTMLElement): string {\n\tconst config = resolveConfig(el);\n\tif (!config) return el.style.cssText;\n\treturn getStrictEngine(config.root, config.settings).getStyleText(el);\n}\n\n/** Returns the configured CSP nonce for the node's style root (if any). */\nexport function getStyleNonceForNode(node: Node): string | undefined {\n\tconst root = resolveStyleRootFromNode(node);\n\tif (!root) return undefined;\n\treturn rootConfigs.get(root)?.nonce;\n}\n\nfunction setInlineProperty(el: HTMLElement, property: string, value: string): void {\n\tif (property.startsWith('--')) {\n\t\tif (value) {\n\t\t\tel.style.setProperty(property, value);\n\t\t} else {\n\t\t\tel.style.removeProperty(property);\n\t\t}\n\t\treturn;\n\t}\n\tif (property.includes('-')) {\n\t\tif (value) {\n\t\t\tel.style.setProperty(property, value);\n\t\t} else {\n\t\t\tel.style.removeProperty(property);\n\t\t}\n\t\treturn;\n\t}\n\t(el.style as CSSStyleDeclaration & Record<string, string>)[property] = value;\n}\n\nfunction resolveConfig(el: HTMLElement): { root: StyleRoot; settings: RootConfig } | null {\n\tconst root = resolveStyleRoot(el);\n\tif (!root) return null;\n\tconst settings = rootConfigs.get(root);\n\tif (!settings) return null;\n\treturn { root, settings };\n}\n\nfunction resolveStyleRoot(el: HTMLElement): StyleRoot | null {\n\treturn resolveStyleRootFromNode(el);\n}\n\nfunction getStrictEngine(root: StyleRoot, config: RootConfig): StrictStyleEngine {\n\tconst cached = strictEngines.get(root);\n\tif (cached) return cached;\n\tconst engine = new StrictStyleEngine(root, config);\n\tstrictEngines.set(root, engine);\n\treturn engine;\n}\n\nfunction isShadowRoot(value: unknown): value is ShadowRoot {\n\treturn typeof ShadowRoot !== 'undefined' && value instanceof ShadowRoot;\n}\n\nfunction isDocument(value: unknown): value is Document {\n\treturn typeof Document !== 'undefined' && value instanceof Document;\n}\n\nfunction resolveStyleRootFromNode(node: Node): StyleRoot | null {\n\tconst rootNode: Node = isShadowRoot(node) || isDocument(node) ? node : node.getRootNode();\n\tif (isShadowRoot(rootNode)) return rootNode;\n\tif (isDocument(rootNode)) return rootNode;\n\tif (typeof document !== 'undefined') return document;\n\treturn null;\n}\n\nclass StrictStyleEngine {\n\tprivate readonly declarationByElement: WeakMap<HTMLElement, Map<string, string>> = new WeakMap();\n\tprivate readonly tokenByDeclaration: Map<string, string> = new Map();\n\tprivate readonly declarationByToken: Map<string, string> = new Map();\n\tprivate readonly tokenRefCount: Map<string, number> = new Map();\n\tprivate readonly tokenByElement: WeakMap<HTMLElement, string> = new WeakMap();\n\tprivate tokenCounter = 0;\n\tprivate readonly root: StyleRoot;\n\tprivate readonly nonce?: string;\n\tprivate sheet: CSSStyleSheet | null;\n\tprivate fallbackStyleElement: HTMLStyleElement | null = null;\n\tprivate ownsAdoptedSheet = false;\n\n\tconstructor(root: StyleRoot, config: RootConfig) {\n\t\tthis.root = root;\n\t\tthis.nonce = config.nonce;\n\t\tthis.sheet = config.sheet ?? null;\n\t}\n\n\tdestroy(): void {\n\t\tthis.clearRuntimeRules();\n\t\tif (this.ownsAdoptedSheet && this.sheet && 'adoptedStyleSheets' in this.root) {\n\t\t\tthis.root.adoptedStyleSheets = this.root.adoptedStyleSheets.filter(\n\t\t\t\t(adoptedSheet: CSSStyleSheet): boolean => adoptedSheet !== this.sheet,\n\t\t\t);\n\t\t}\n\t\tthis.fallbackStyleElement?.remove();\n\t\tthis.fallbackStyleElement = null;\n\t\tthis.sheet = null;\n\t\tthis.ownsAdoptedSheet = false;\n\t\tthis.tokenByDeclaration.clear();\n\t\tthis.declarationByToken.clear();\n\t\tthis.tokenRefCount.clear();\n\t\tthis.tokenCounter = 0;\n\t}\n\n\tsetProperty(el: HTMLElement, property: string, value: string): void {\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tconst name = normalizePropertyName(property);\n\t\tremoveInlineProperty(el, name);\n\t\tif (!value) {\n\t\t\tdeclarations.delete(name);\n\t\t} else {\n\t\t\tdeclarations.set(name, value);\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tsetProperties(\n\t\tel: HTMLElement,\n\t\tproperties: Readonly<Record<string, string | undefined | null>>,\n\t): void {\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tfor (const [property, value] of Object.entries(properties)) {\n\t\t\tconst name = normalizePropertyName(property);\n\t\t\tremoveInlineProperty(el, name);\n\t\t\tif (!value) {\n\t\t\t\tdeclarations.delete(name);\n\t\t\t} else {\n\t\t\t\tdeclarations.set(name, value);\n\t\t\t}\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tsetStyleText(el: HTMLElement, cssText: string): void {\n\t\tconst declarations = parseStyleText(cssText);\n\t\tel.removeAttribute('style');\n\t\tif (declarations.size === 0) {\n\t\t\tthis.clearElementStyles(el);\n\t\t\treturn;\n\t\t}\n\t\tthis.declarationByElement.set(el, declarations);\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tappendStyleText(el: HTMLElement, cssText: string): void {\n\t\tconst parsed = parseStyleText(cssText);\n\t\tif (parsed.size === 0) return;\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tfor (const [property, value] of parsed) {\n\t\t\tremoveInlineProperty(el, property);\n\t\t\tdeclarations.set(property, value);\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tgetStyleText(el: HTMLElement): string {\n\t\tconst declarations = this.declarationByElement.get(el);\n\t\tif (!declarations || declarations.size === 0) return '';\n\t\treturn serializeDeclarations(declarations);\n\t}\n\n\tprivate getOrCreateDeclarations(el: HTMLElement): Map<string, string> {\n\t\tconst existing = this.declarationByElement.get(el);\n\t\tif (existing) return existing;\n\t\tconst created = new Map<string, string>();\n\t\tthis.declarationByElement.set(el, created);\n\t\treturn created;\n\t}\n\n\tprivate syncElementToken(el: HTMLElement, declarations: Map<string, string>): void {\n\t\tconst previousToken = this.tokenByElement.get(el);\n\t\tif (declarations.size === 0) {\n\t\t\tthis.clearElementStyles(el);\n\t\t\treturn;\n\t\t}\n\n\t\tconst declarationText = serializeDeclarations(declarations);\n\t\tlet token = this.tokenByDeclaration.get(declarationText);\n\t\tif (!token) {\n\t\t\ttoken = `s${this.tokenCounter.toString(36)}`;\n\t\t\tthis.tokenCounter += 1;\n\t\t\tthis.tokenByDeclaration.set(declarationText, token);\n\t\t\tthis.declarationByToken.set(token, declarationText);\n\t\t\tthis.insertRule(token, declarationText);\n\t\t}\n\t\tif (previousToken !== token) {\n\t\t\tthis.retainToken(token);\n\t\t\tif (previousToken) {\n\t\t\t\tthis.releaseToken(previousToken);\n\t\t\t}\n\t\t\tthis.tokenByElement.set(el, token);\n\t\t}\n\t\tel.setAttribute(STYLE_TOKEN_ATTR, token);\n\t}\n\n\tprivate insertRule(token: string, declarationText: string): void {\n\t\tconst rule = `${buildTokenSelector(token)} { ${declarationText}; }`;\n\t\tconst sheet = this.ensureSheet();\n\t\tif (!sheet) return;\n\t\ttry {\n\t\t\tsheet.insertRule(rule, sheet.cssRules.length);\n\t\t} catch {\n\t\t\t// Ignore malformed declarations from third-party plugin attrs.\n\t\t}\n\t}\n\n\tprivate ensureSheet(): CSSStyleSheet | null {\n\t\tif (this.sheet) return this.sheet;\n\n\t\tif (typeof CSSStyleSheet !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tconst sheet = new CSSStyleSheet();\n\t\t\t\tif ('adoptedStyleSheets' in this.root) {\n\t\t\t\t\tconst adopted = this.root.adoptedStyleSheets;\n\t\t\t\t\tthis.root.adoptedStyleSheets = [...adopted, sheet];\n\t\t\t\t\truntimeSheets.add(sheet);\n\t\t\t\t\tthis.sheet = sheet;\n\t\t\t\t\tthis.ownsAdoptedSheet = true;\n\t\t\t\t\treturn sheet;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Fall through to style element fallback.\n\t\t\t}\n\t\t}\n\n\t\tconst style = this.ensureFallbackStyleElement();\n\t\tthis.sheet = (style.sheet as CSSStyleSheet | null) ?? null;\n\t\tif (this.sheet) {\n\t\t\truntimeSheets.add(this.sheet);\n\t\t}\n\t\treturn this.sheet;\n\t}\n\n\tprivate clearElementStyles(el: HTMLElement): void {\n\t\tthis.declarationByElement.delete(el);\n\t\tconst token = this.tokenByElement.get(el);\n\t\tif (token) {\n\t\t\tthis.tokenByElement.delete(el);\n\t\t\tthis.releaseToken(token);\n\t\t}\n\t\tel.removeAttribute(STYLE_TOKEN_ATTR);\n\t}\n\n\tprivate retainToken(token: string): void {\n\t\tconst current = this.tokenRefCount.get(token) ?? 0;\n\t\tthis.tokenRefCount.set(token, current + 1);\n\t}\n\n\tprivate releaseToken(token: string): void {\n\t\tconst current = this.tokenRefCount.get(token);\n\t\tif (!current) return;\n\t\tif (current > 1) {\n\t\t\tthis.tokenRefCount.set(token, current - 1);\n\t\t\treturn;\n\t\t}\n\t\tthis.tokenRefCount.delete(token);\n\t\tconst declaration = this.declarationByToken.get(token);\n\t\tif (declaration) {\n\t\t\tthis.declarationByToken.delete(token);\n\t\t\tthis.tokenByDeclaration.delete(declaration);\n\t\t}\n\t\tthis.deleteRule(token);\n\t}\n\n\tprivate deleteRule(token: string): void {\n\t\tconst sheet = this.sheet;\n\t\tif (!sheet) return;\n\t\tconst selector = buildTokenSelector(token);\n\t\tfor (let index = sheet.cssRules.length - 1; index >= 0; index -= 1) {\n\t\t\tconst rule = sheet.cssRules[index];\n\t\t\tif (!rule || !isTokenSelectorMatch(rule, selector)) continue;\n\t\t\ttry {\n\t\t\t\tsheet.deleteRule(index);\n\t\t\t} catch {\n\t\t\t\t// Ignore parser/runtime discrepancies in unsupported environments.\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate clearRuntimeRules(): void {\n\t\tconst sheet = this.sheet;\n\t\tif (!sheet) return;\n\t\tfor (let index = sheet.cssRules.length - 1; index >= 0; index -= 1) {\n\t\t\tconst rule = sheet.cssRules[index];\n\t\t\tif (!rule || !rule.cssText.includes(`[${STYLE_TOKEN_ATTR}=\"`)) continue;\n\t\t\ttry {\n\t\t\t\tsheet.deleteRule(index);\n\t\t\t} catch {\n\t\t\t\t// Ignore parser/runtime discrepancies in unsupported environments.\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureFallbackStyleElement(): HTMLStyleElement {\n\t\tif (this.fallbackStyleElement) return this.fallbackStyleElement;\n\t\tconst style: HTMLStyleElement = document.createElement('style');\n\t\tstyle.setAttribute(STYLE_ELEMENT_ATTR, '');\n\t\tif (this.nonce) {\n\t\t\tstyle.setAttribute('nonce', this.nonce);\n\t\t}\n\t\tif (isShadowRoot(this.root)) {\n\t\t\tthis.root.appendChild(style);\n\t\t} else {\n\t\t\tconst host = this.root.head ?? this.root.documentElement;\n\t\t\thost.appendChild(style);\n\t\t}\n\t\tthis.fallbackStyleElement = style;\n\t\treturn style;\n\t}\n}\n\nfunction parseStyleText(styleText: string): Map<string, string> {\n\tconst declarations = new Map<string, string>();\n\tfor (const rawPart of styleText.split(';')) {\n\t\tconst part = rawPart.trim();\n\t\tif (!part) continue;\n\t\tconst separator = part.indexOf(':');\n\t\tif (separator <= 0) continue;\n\t\tconst property = normalizePropertyName(part.slice(0, separator));\n\t\tconst value = part.slice(separator + 1).trim();\n\t\tif (!value) {\n\t\t\tdeclarations.delete(property);\n\t\t} else {\n\t\t\tdeclarations.set(property, value);\n\t\t}\n\t}\n\treturn declarations;\n}\n\nfunction serializeDeclarations(declarations: Map<string, string>): string {\n\tconst ordered: [string, string][] = Array.from(declarations.entries()).sort(([a], [b]) =>\n\t\ta.localeCompare(b),\n\t);\n\treturn ordered.map(([property, value]) => `${property}: ${value}`).join('; ');\n}\n\nfunction normalizePropertyName(property: string): string {\n\tconst trimmed = property.trim();\n\tif (!trimmed) return '';\n\tif (trimmed.startsWith('--')) return trimmed;\n\tif (trimmed.includes('-')) return trimmed.toLowerCase();\n\treturn trimmed.replace(/[A-Z]/g, (char: string) => `-${char.toLowerCase()}`).toLowerCase();\n}\n\nfunction removeInlineProperty(el: HTMLElement, property: string): void {\n\tif (!property) return;\n\tel.style.removeProperty(property);\n\tif (el.getAttribute('style') === '') el.removeAttribute('style');\n}\n\nfunction buildTokenSelector(token: string): string {\n\treturn `[${STYLE_TOKEN_ATTR}=\"${token}\"]`;\n}\n\nfunction isTokenSelectorMatch(rule: CSSRule, selector: string): boolean {\n\tif (typeof CSSStyleRule !== 'undefined' && rule instanceof CSSStyleRule) {\n\t\treturn rule.selectorText === selector;\n\t}\n\treturn rule.cssText.includes(selector);\n}\n"],"mappings":"AAoBA,IAAM,EAAmB,2BAGnB,iBAA8C,IAAI,QAClD,iBAAuD,IAAI,QAC3D,iBAAwC,IAAI,QAQlD,SAAgB,EAAoB,GACnC,OAAO,EAAc,IAAI,EAC1B,CAGA,SAAgB,IACf,GAA6B,oBAAlB,cAA+B,OAAO,KACjD,IACC,MAAM,EAAQ,IAAI,cAElB,OADA,EAAc,IAAI,GACX,CACR,CAAA,MACC,OAAO,IACR,CACD,CAGA,SAAgB,EAAkB,EAAiB,GAClD,MAAM,EAAW,EAAc,IAAI,GAC/B,IACH,EAAS,UACT,EAAc,OAAO,IAElB,EAAQ,OACX,EAAc,IAAI,EAAQ,OAE3B,EAAY,IAAI,EAAM,CACrB,MAAO,EAAQ,MACf,MAAO,EAAQ,OAAS,MAE1B,CAGA,SAAgB,EAAoB,GACnC,MAAM,EAAS,EAAc,IAAI,GAC7B,IACH,EAAO,UACP,EAAc,OAAO,IAEtB,EAAY,OAAO,EACpB,CAGA,SAAgB,EAAiB,EAAiB,EAAkB,GACnE,MAAM,EAAS,EAAc,GACxB,EAIL,EAAgB,EAAO,KAAM,EAAO,UAAU,YAAY,EAAI,EAAU,GAHvE,EAAkB,EAAI,EAAU,EAIlC,CAGA,SAAgB,EAAoB,EAAiB,GACpD,EAAiB,EAAI,EAAU,GAChC,CAGA,SAAgB,EACf,EACA,GAEA,MAAM,EAAS,EAAc,GAC7B,GAAK,EAML,EAAgB,EAAO,KAAM,EAAO,UAAU,cAAc,EAAI,QAL/D,IAAK,MAAO,EAAU,KAAU,OAAO,QAAQ,GAC9C,EAAkB,E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AAK,eAAiB,EAEvB,EAAK,QAAQ,SAAS,EAC9B"}
|
|
1
|
+
{"version":3,"file":"StyleRuntime-C0RSqKzG.mjs","names":["STYLE_TOKEN_ATTR","rootConfigs","WeakMap","strictEngines","runtimeSheets","WeakSet","isRuntimeStyleSheet","sheet","has","createRuntimeStyleSheet","CSSStyleSheet","add","registerStyleRoot","root","options","previous","get","destroy","delete","set","nonce","unregisterStyleRoot","engine","setStyleProperty","el","property","value","config","resolveConfig","getStrictEngine","settings","setProperty","setInlineProperty","removeStyleProperty","setStyleProperties","properties","setProperties","Object","entries","setStyleText","cssText","style","getStyleText","getStyleNonceForNode","node","resolveStyleRootFromNode","startsWith","includes","removeProperty","resolveStyleRoot","cached","StrictStyleEngine","isShadowRoot","ShadowRoot","isDocument","Document","rootNode","getRootNode","document","declarationByElement","tokenByDeclaration","Map","declarationByToken","tokenRefCount","tokenByElement","tokenCounter","fallbackStyleElement","ownsAdoptedSheet","constructor","this","clearRuntimeRules","adoptedStyleSheets","filter","adoptedSheet","remove","clear","declarations","getOrCreateDeclarations","name","normalizePropertyName","removeInlineProperty","syncElementToken","parseStyleText","removeAttribute","size","clearElementStyles","appendStyleText","parsed","serializeDeclarations","existing","created","previousToken","declarationText","token","toString","insertRule","retainToken","releaseToken","setAttribute","rule","buildTokenSelector","ensureSheet","cssRules","length","adopted","ensureFallbackStyleElement","current","declaration","deleteRule","selector","index","isTokenSelectorMatch","createElement","appendChild","head","documentElement","styleText","rawPart","split","part","trim","separator","indexOf","slice","Array","from","sort","a","b","localeCompare","map","join","trimmed","toLowerCase","replace","char","getAttribute","CSSStyleRule","selectorText"],"sources":["../../src/style/StyleRuntime.ts"],"sourcesContent":["/**\n * Runtime style abstraction.\n *\n * Writes no inline styles and instead assigns token attributes\n * backed by dynamic CSS rules in a stylesheet.\n * Elements outside a registered root fall back to inline styles.\n */\n\nexport interface StyleRootOptions {\n\treadonly nonce?: string;\n\treadonly sheet?: CSSStyleSheet | null;\n}\n\ntype StyleRoot = ShadowRoot | Document;\n\ninterface RootConfig {\n\treadonly nonce?: string;\n\treadonly sheet: CSSStyleSheet | null;\n}\n\nconst STYLE_TOKEN_ATTR = 'data-notectl-style-token';\nconst STYLE_ELEMENT_ATTR = 'data-notectl-runtime-styles';\n\nconst rootConfigs: WeakMap<StyleRoot, RootConfig> = new WeakMap();\nconst strictEngines: WeakMap<StyleRoot, StrictStyleEngine> = new WeakMap();\nconst runtimeSheets: WeakSet<CSSStyleSheet> = new WeakSet();\n\n/**\n * True when the sheet holds runtime style-token rules, i.e. element styling\n * that would be inline `style` attributes outside strict-CSP mode. Consumers\n * (e.g. print) can use this to treat such rules as content styling rather\n * than editor base styles.\n */\nexport function isRuntimeStyleSheet(sheet: CSSStyleSheet): boolean {\n\treturn runtimeSheets.has(sheet);\n}\n\n/** Creates a constructable stylesheet when the environment supports it. */\nexport function createRuntimeStyleSheet(): CSSStyleSheet | null {\n\tif (typeof CSSStyleSheet === 'undefined') return null;\n\ttry {\n\t\tconst sheet = new CSSStyleSheet();\n\t\truntimeSheets.add(sheet);\n\t\treturn sheet;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** Registers styling mode for a root (shadow root or document). */\nexport function registerStyleRoot(root: StyleRoot, options: StyleRootOptions): void {\n\tconst previous = strictEngines.get(root);\n\tif (previous) {\n\t\tprevious.destroy();\n\t\tstrictEngines.delete(root);\n\t}\n\tif (options.sheet) {\n\t\truntimeSheets.add(options.sheet);\n\t}\n\trootConfigs.set(root, {\n\t\tnonce: options.nonce,\n\t\tsheet: options.sheet ?? null,\n\t});\n}\n\n/** Unregisters root styling and tears down strict runtime state if present. */\nexport function unregisterStyleRoot(root: StyleRoot): void {\n\tconst engine = strictEngines.get(root);\n\tif (engine) {\n\t\tengine.destroy();\n\t\tstrictEngines.delete(root);\n\t}\n\trootConfigs.delete(root);\n}\n\n/** Sets a single style property. Empty value removes the property. */\nexport function setStyleProperty(el: HTMLElement, property: string, value: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tsetInlineProperty(el, property, value);\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setProperty(el, property, value);\n}\n\n/** Removes a single style property. */\nexport function removeStyleProperty(el: HTMLElement, property: string): void {\n\tsetStyleProperty(el, property, '');\n}\n\n/** Sets multiple style properties in one call. */\nexport function setStyleProperties(\n\tel: HTMLElement,\n\tproperties: Readonly<Record<string, string | undefined | null>>,\n): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tfor (const [property, value] of Object.entries(properties)) {\n\t\t\tsetInlineProperty(el, property, value ?? '');\n\t\t}\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setProperties(el, properties);\n}\n\n/** Replaces the element style text. */\nexport function setStyleText(el: HTMLElement, cssText: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tel.style.cssText = cssText;\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setStyleText(el, cssText);\n}\n\n/** Merges a cssText fragment into current element styles. */\nexport function appendStyleText(el: HTMLElement, cssText: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tconst current = el.style.cssText;\n\t\tel.style.cssText = current ? `${current}; ${cssText}` : cssText;\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).appendStyleText(el, cssText);\n}\n\n/** Returns serialized styles for an element. */\nexport function getStyleText(el: HTMLElement): string {\n\tconst config = resolveConfig(el);\n\tif (!config) return el.style.cssText;\n\treturn getStrictEngine(config.root, config.settings).getStyleText(el);\n}\n\n/** Returns the configured CSP nonce for the node's style root (if any). */\nexport function getStyleNonceForNode(node: Node): string | undefined {\n\tconst root = resolveStyleRootFromNode(node);\n\tif (!root) return undefined;\n\treturn rootConfigs.get(root)?.nonce;\n}\n\nfunction setInlineProperty(el: HTMLElement, property: string, value: string): void {\n\tif (property.startsWith('--')) {\n\t\tif (value) {\n\t\t\tel.style.setProperty(property, value);\n\t\t} else {\n\t\t\tel.style.removeProperty(property);\n\t\t}\n\t\treturn;\n\t}\n\tif (property.includes('-')) {\n\t\tif (value) {\n\t\t\tel.style.setProperty(property, value);\n\t\t} else {\n\t\t\tel.style.removeProperty(property);\n\t\t}\n\t\treturn;\n\t}\n\t(el.style as CSSStyleDeclaration & Record<string, string>)[property] = value;\n}\n\nfunction resolveConfig(el: HTMLElement): { root: StyleRoot; settings: RootConfig } | null {\n\tconst root = resolveStyleRoot(el);\n\tif (!root) return null;\n\tconst settings = rootConfigs.get(root);\n\tif (!settings) return null;\n\treturn { root, settings };\n}\n\nfunction resolveStyleRoot(el: HTMLElement): StyleRoot | null {\n\treturn resolveStyleRootFromNode(el);\n}\n\nfunction getStrictEngine(root: StyleRoot, config: RootConfig): StrictStyleEngine {\n\tconst cached = strictEngines.get(root);\n\tif (cached) return cached;\n\tconst engine = new StrictStyleEngine(root, config);\n\tstrictEngines.set(root, engine);\n\treturn engine;\n}\n\nfunction isShadowRoot(value: unknown): value is ShadowRoot {\n\treturn typeof ShadowRoot !== 'undefined' && value instanceof ShadowRoot;\n}\n\nfunction isDocument(value: unknown): value is Document {\n\treturn typeof Document !== 'undefined' && value instanceof Document;\n}\n\nfunction resolveStyleRootFromNode(node: Node): StyleRoot | null {\n\tconst rootNode: Node = isShadowRoot(node) || isDocument(node) ? node : node.getRootNode();\n\tif (isShadowRoot(rootNode)) return rootNode;\n\tif (isDocument(rootNode)) return rootNode;\n\tif (typeof document !== 'undefined') return document;\n\treturn null;\n}\n\nclass StrictStyleEngine {\n\tprivate readonly declarationByElement: WeakMap<HTMLElement, Map<string, string>> = new WeakMap();\n\tprivate readonly tokenByDeclaration: Map<string, string> = new Map();\n\tprivate readonly declarationByToken: Map<string, string> = new Map();\n\tprivate readonly tokenRefCount: Map<string, number> = new Map();\n\tprivate readonly tokenByElement: WeakMap<HTMLElement, string> = new WeakMap();\n\tprivate tokenCounter = 0;\n\tprivate readonly root: StyleRoot;\n\tprivate readonly nonce?: string;\n\tprivate sheet: CSSStyleSheet | null;\n\tprivate fallbackStyleElement: HTMLStyleElement | null = null;\n\tprivate ownsAdoptedSheet = false;\n\n\tconstructor(root: StyleRoot, config: RootConfig) {\n\t\tthis.root = root;\n\t\tthis.nonce = config.nonce;\n\t\tthis.sheet = config.sheet ?? null;\n\t}\n\n\tdestroy(): void {\n\t\tthis.clearRuntimeRules();\n\t\tif (this.ownsAdoptedSheet && this.sheet && 'adoptedStyleSheets' in this.root) {\n\t\t\tthis.root.adoptedStyleSheets = this.root.adoptedStyleSheets.filter(\n\t\t\t\t(adoptedSheet: CSSStyleSheet): boolean => adoptedSheet !== this.sheet,\n\t\t\t);\n\t\t}\n\t\tthis.fallbackStyleElement?.remove();\n\t\tthis.fallbackStyleElement = null;\n\t\tthis.sheet = null;\n\t\tthis.ownsAdoptedSheet = false;\n\t\tthis.tokenByDeclaration.clear();\n\t\tthis.declarationByToken.clear();\n\t\tthis.tokenRefCount.clear();\n\t\tthis.tokenCounter = 0;\n\t}\n\n\tsetProperty(el: HTMLElement, property: string, value: string): void {\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tconst name = normalizePropertyName(property);\n\t\tremoveInlineProperty(el, name);\n\t\tif (!value) {\n\t\t\tdeclarations.delete(name);\n\t\t} else {\n\t\t\tdeclarations.set(name, value);\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tsetProperties(\n\t\tel: HTMLElement,\n\t\tproperties: Readonly<Record<string, string | undefined | null>>,\n\t): void {\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tfor (const [property, value] of Object.entries(properties)) {\n\t\t\tconst name = normalizePropertyName(property);\n\t\t\tremoveInlineProperty(el, name);\n\t\t\tif (!value) {\n\t\t\t\tdeclarations.delete(name);\n\t\t\t} else {\n\t\t\t\tdeclarations.set(name, value);\n\t\t\t}\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tsetStyleText(el: HTMLElement, cssText: string): void {\n\t\tconst declarations = parseStyleText(cssText);\n\t\tel.removeAttribute('style');\n\t\tif (declarations.size === 0) {\n\t\t\tthis.clearElementStyles(el);\n\t\t\treturn;\n\t\t}\n\t\tthis.declarationByElement.set(el, declarations);\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tappendStyleText(el: HTMLElement, cssText: string): void {\n\t\tconst parsed = parseStyleText(cssText);\n\t\tif (parsed.size === 0) return;\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tfor (const [property, value] of parsed) {\n\t\t\tremoveInlineProperty(el, property);\n\t\t\tdeclarations.set(property, value);\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tgetStyleText(el: HTMLElement): string {\n\t\tconst declarations = this.declarationByElement.get(el);\n\t\tif (!declarations || declarations.size === 0) return '';\n\t\treturn serializeDeclarations(declarations);\n\t}\n\n\tprivate getOrCreateDeclarations(el: HTMLElement): Map<string, string> {\n\t\tconst existing = this.declarationByElement.get(el);\n\t\tif (existing) return existing;\n\t\tconst created = new Map<string, string>();\n\t\tthis.declarationByElement.set(el, created);\n\t\treturn created;\n\t}\n\n\tprivate syncElementToken(el: HTMLElement, declarations: Map<string, string>): void {\n\t\tconst previousToken = this.tokenByElement.get(el);\n\t\tif (declarations.size === 0) {\n\t\t\tthis.clearElementStyles(el);\n\t\t\treturn;\n\t\t}\n\n\t\tconst declarationText = serializeDeclarations(declarations);\n\t\tlet token = this.tokenByDeclaration.get(declarationText);\n\t\tif (!token) {\n\t\t\ttoken = `s${this.tokenCounter.toString(36)}`;\n\t\t\tthis.tokenCounter += 1;\n\t\t\tthis.tokenByDeclaration.set(declarationText, token);\n\t\t\tthis.declarationByToken.set(token, declarationText);\n\t\t\tthis.insertRule(token, declarationText);\n\t\t}\n\t\tif (previousToken !== token) {\n\t\t\tthis.retainToken(token);\n\t\t\tif (previousToken) {\n\t\t\t\tthis.releaseToken(previousToken);\n\t\t\t}\n\t\t\tthis.tokenByElement.set(el, token);\n\t\t}\n\t\tel.setAttribute(STYLE_TOKEN_ATTR, token);\n\t}\n\n\tprivate insertRule(token: string, declarationText: string): void {\n\t\tconst rule = `${buildTokenSelector(token)} { ${declarationText}; }`;\n\t\tconst sheet = this.ensureSheet();\n\t\tif (!sheet) return;\n\t\ttry {\n\t\t\tsheet.insertRule(rule, sheet.cssRules.length);\n\t\t} catch {\n\t\t\t// Ignore malformed declarations from third-party plugin attrs.\n\t\t}\n\t}\n\n\tprivate ensureSheet(): CSSStyleSheet | null {\n\t\tif (this.sheet) return this.sheet;\n\n\t\tif (typeof CSSStyleSheet !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tconst sheet = new CSSStyleSheet();\n\t\t\t\tif ('adoptedStyleSheets' in this.root) {\n\t\t\t\t\tconst adopted = this.root.adoptedStyleSheets;\n\t\t\t\t\tthis.root.adoptedStyleSheets = [...adopted, sheet];\n\t\t\t\t\truntimeSheets.add(sheet);\n\t\t\t\t\tthis.sheet = sheet;\n\t\t\t\t\tthis.ownsAdoptedSheet = true;\n\t\t\t\t\treturn sheet;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Fall through to style element fallback.\n\t\t\t}\n\t\t}\n\n\t\tconst style = this.ensureFallbackStyleElement();\n\t\tthis.sheet = (style.sheet as CSSStyleSheet | null) ?? null;\n\t\tif (this.sheet) {\n\t\t\truntimeSheets.add(this.sheet);\n\t\t}\n\t\treturn this.sheet;\n\t}\n\n\tprivate clearElementStyles(el: HTMLElement): void {\n\t\tthis.declarationByElement.delete(el);\n\t\tconst token = this.tokenByElement.get(el);\n\t\tif (token) {\n\t\t\tthis.tokenByElement.delete(el);\n\t\t\tthis.releaseToken(token);\n\t\t}\n\t\tel.removeAttribute(STYLE_TOKEN_ATTR);\n\t}\n\n\tprivate retainToken(token: string): void {\n\t\tconst current = this.tokenRefCount.get(token) ?? 0;\n\t\tthis.tokenRefCount.set(token, current + 1);\n\t}\n\n\tprivate releaseToken(token: string): void {\n\t\tconst current = this.tokenRefCount.get(token);\n\t\tif (!current) return;\n\t\tif (current > 1) {\n\t\t\tthis.tokenRefCount.set(token, current - 1);\n\t\t\treturn;\n\t\t}\n\t\tthis.tokenRefCount.delete(token);\n\t\tconst declaration = this.declarationByToken.get(token);\n\t\tif (declaration) {\n\t\t\tthis.declarationByToken.delete(token);\n\t\t\tthis.tokenByDeclaration.delete(declaration);\n\t\t}\n\t\tthis.deleteRule(token);\n\t}\n\n\tprivate deleteRule(token: string): void {\n\t\tconst sheet = this.sheet;\n\t\tif (!sheet) return;\n\t\tconst selector = buildTokenSelector(token);\n\t\tfor (let index = sheet.cssRules.length - 1; index >= 0; index -= 1) {\n\t\t\tconst rule = sheet.cssRules[index];\n\t\t\tif (!rule || !isTokenSelectorMatch(rule, selector)) continue;\n\t\t\ttry {\n\t\t\t\tsheet.deleteRule(index);\n\t\t\t} catch {\n\t\t\t\t// Ignore parser/runtime discrepancies in unsupported environments.\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate clearRuntimeRules(): void {\n\t\tconst sheet = this.sheet;\n\t\tif (!sheet) return;\n\t\tfor (let index = sheet.cssRules.length - 1; index >= 0; index -= 1) {\n\t\t\tconst rule = sheet.cssRules[index];\n\t\t\tif (!rule || !rule.cssText.includes(`[${STYLE_TOKEN_ATTR}=\"`)) continue;\n\t\t\ttry {\n\t\t\t\tsheet.deleteRule(index);\n\t\t\t} catch {\n\t\t\t\t// Ignore parser/runtime discrepancies in unsupported environments.\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureFallbackStyleElement(): HTMLStyleElement {\n\t\tif (this.fallbackStyleElement) return this.fallbackStyleElement;\n\t\tconst style: HTMLStyleElement = document.createElement('style');\n\t\tstyle.setAttribute(STYLE_ELEMENT_ATTR, '');\n\t\tif (this.nonce) {\n\t\t\tstyle.setAttribute('nonce', this.nonce);\n\t\t}\n\t\tif (isShadowRoot(this.root)) {\n\t\t\tthis.root.appendChild(style);\n\t\t} else {\n\t\t\tconst host = this.root.head ?? this.root.documentElement;\n\t\t\thost.appendChild(style);\n\t\t}\n\t\tthis.fallbackStyleElement = style;\n\t\treturn style;\n\t}\n}\n\nfunction parseStyleText(styleText: string): Map<string, string> {\n\tconst declarations = new Map<string, string>();\n\tfor (const rawPart of styleText.split(';')) {\n\t\tconst part = rawPart.trim();\n\t\tif (!part) continue;\n\t\tconst separator = part.indexOf(':');\n\t\tif (separator <= 0) continue;\n\t\tconst property = normalizePropertyName(part.slice(0, separator));\n\t\tconst value = part.slice(separator + 1).trim();\n\t\tif (!value) {\n\t\t\tdeclarations.delete(property);\n\t\t} else {\n\t\t\tdeclarations.set(property, value);\n\t\t}\n\t}\n\treturn declarations;\n}\n\nfunction serializeDeclarations(declarations: Map<string, string>): string {\n\tconst ordered: [string, string][] = Array.from(declarations.entries()).sort(([a], [b]) =>\n\t\ta.localeCompare(b),\n\t);\n\treturn ordered.map(([property, value]) => `${property}: ${value}`).join('; ');\n}\n\nfunction normalizePropertyName(property: string): string {\n\tconst trimmed = property.trim();\n\tif (!trimmed) return '';\n\tif (trimmed.startsWith('--')) return trimmed;\n\tif (trimmed.includes('-')) return trimmed.toLowerCase();\n\treturn trimmed.replace(/[A-Z]/g, (char: string) => `-${char.toLowerCase()}`).toLowerCase();\n}\n\nfunction removeInlineProperty(el: HTMLElement, property: string): void {\n\tif (!property) return;\n\tel.style.removeProperty(property);\n\tif (el.getAttribute('style') === '') el.removeAttribute('style');\n}\n\nfunction buildTokenSelector(token: string): string {\n\treturn `[${STYLE_TOKEN_ATTR}=\"${token}\"]`;\n}\n\nfunction isTokenSelectorMatch(rule: CSSRule, selector: string): boolean {\n\tif (typeof CSSStyleRule !== 'undefined' && rule instanceof CSSStyleRule) {\n\t\treturn rule.selectorText === selector;\n\t}\n\treturn rule.cssText.includes(selector);\n}\n"],"mappings":"AAoBA,IAAMA,EAAmB,2BAGnBC,iBAA8C,IAAIC,QAClDC,iBAAuD,IAAID,QAC3DE,iBAAwC,IAAIC,QAQlD,SAAgBC,EAAoBC,GACnC,OAAOH,EAAcI,IAAID,EAC1B,C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AMC,EAAOF,EAAQG,OACrB,IAAKD,EAAM,SACX,MAAME,EAAYF,EAAKG,QAAQ,KAC/B,GAAID,GAAa,EAAG,SACpB,MAAMhG,EAAWsD,EAAsBwC,EAAKI,MAAM,EAAGF,IAC/C/F,EAAQ6F,EAAKI,MAAMF,EAAY,GAAGD,OACnC9F,EAGJkD,EAAazD,IAAIM,EAAUC,GAF3BkD,EAAa1D,OAAOO,EAItB,CACA,OAAOmD,CACR,CAEA,SAASY,EAAsBZ,GAI9B,OAHoCgD,MAAMC,KAAKjD,EAAatC,WAAWwF,KAAA,EAAOC,IAAKC,KAClFD,EAAEE,cAAcD,IAEFE,IAAA,EAAMzG,EAAUC,KAAW,GAAGD,MAAaC,KAASyG,KAAK,KACzE,CAEA,SAASpD,EAAsBtD,GAC9B,MAAM2G,EAAU3G,EAAS+F,OACzB,OAAKY,EACDA,EAAQtF,WAAW,MAAcsF,EACjCA,EAAQrF,SAAS,KAAaqF,EAAQC,cACnCD,EAAQE,QAAQ,SAAWC,GAAiB,IAAIA,EAAKF,iBAAiBA,cAHxD,EAItB,CAEA,SAASrD,EAAqBxD,EAAiBC,GACzCA,IACLD,EAAGiB,MAAMO,eAAevB,GACS,KAA7BD,EAAGgH,aAAa,UAAiBhH,EAAG2D,gBAAgB,SACzD,CAEA,SAASiB,EAAmBP,GAC3B,MAAO,IAAI7F,MAAqB6F,KACjC,CAEA,SAASkB,EAAqBZ,EAAeU,GAC5C,MAA4B,oBAAjB4B,cAAgCtC,aAAgBsC,aACnDtC,EAAKuC,eAAiB7B,EAEvBV,EAAK3D,QAAQO,SAAS8D,EAC9B,Q"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuperSubPlugin-x1iPnZyt.mjs","names":[],"sources":["../../src/plugins/super-sub/SuperSubLocale.ts","../../src/plugins/super-sub/SuperSubPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the SuperSubPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface SuperSubLocale {\n\treadonly superscriptLabel: string;\n\treadonly superscriptTooltip: (shortcut: string) => string;\n\treadonly subscriptLabel: string;\n\treadonly subscriptTooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const SUPER_SUB_LOCALE_EN: SuperSubLocale = {\n\tsuperscriptLabel: 'Superscript',\n\tsuperscriptTooltip: (shortcut: string) => `Superscript (${shortcut})`,\n\tsubscriptLabel: 'Subscript',\n\tsubscriptTooltip: (shortcut: string) => `Subscript (${shortcut})`,\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<SuperSubLocale> = import.meta.glob<{\n\tdefault: SuperSubLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadSuperSubLocale(lang: string): Promise<SuperSubLocale> {\n\treturn loadLocaleModule(localeModules, lang, SUPER_SUB_LOCALE_EN);\n}\n","/**\n * SuperSubPlugin: registers superscript and subscript inline marks with\n * MarkSpecs, toggle commands, keyboard shortcuts, toolbar buttons, and\n * a middleware that enforces mutual exclusivity between the two marks.\n *\n * Data-driven — each mark type is defined declaratively and all\n * registrations are derived from the same definition table.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport type { Mark } from '../../model/Document.js';\nimport type { ParseRule } from '../../model/ParseRule.js';\nimport type { SanitizeConfig } from '../../model/SanitizeConfig.js';\nimport { markType as mkType } from '../../model/TypeBrands.js';\nimport type { RemoveMarkStep, Step } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent, resolveLocale, toCommandName } from '../shared/PluginHelpers.js';\nimport { formatShortcut } from '../shared/ShortcutFormatting.js';\nimport { SUPER_SUB_LOCALE_EN, type SuperSubLocale, loadSuperSubLocale } from './SuperSubLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tsuperscript: Record<string, never>;\n\t\tsubscript: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\n/** Controls toolbar button visibility per mark. */\nexport interface SuperSubToolbarConfig {\n\treadonly superscript?: boolean;\n\treadonly subscript?: boolean;\n}\n\n/** Controls which marks are enabled and which toolbar buttons are shown. */\nexport interface SuperSubConfig {\n\treadonly superscript: boolean;\n\treadonly subscript: boolean;\n\treadonly toolbar?: SuperSubToolbarConfig;\n\treadonly locale?: SuperSubLocale;\n}\n\nconst DEFAULT_CONFIG: SuperSubConfig = {\n\tsuperscript: true,\n\tsubscript: true,\n};\n\n// --- Mark Definitions ---\n\ninterface MarkDefinition {\n\treadonly type: 'superscript' | 'subscript';\n\treadonly opposite: 'superscript' | 'subscript';\n\treadonly configKey: keyof Omit<SuperSubConfig, 'toolbar' | 'locale'>;\n\treadonly rank: number;\n\treadonly tag: string;\n\treadonly icon: string;\n\treadonly keyBinding: string;\n\treadonly toHTMLString: (content: string) => string;\n\treadonly parseHTML: readonly ParseRule[];\n\treadonly sanitize: SanitizeConfig;\n}\n\nconst SUPERSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M16 7.41L11.41 12 16 16.59 14.59 18l-6-6 6-6z\"',\n\t' fill=\"none\"/>',\n\t'<path d=\"M9.64 7.64c.23-.5.36-1.05.36-1.64',\n\t' 0-2.21-1.79-4-4-4H2v14h4.36c2.34 0 4.24-1.9',\n\t' 4.24-4.24 0-1.6-.89-2.99-2.2-3.71zM4.5 4.5H6c.83',\n\t' 0 1.5.67 1.5 1.5S6.83 7.5 6 7.5H4.5v-3zm2 9H4.5v-3H6.5c.83',\n\t' 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\" fill=\"none\"/>',\n\t'<path d=\"M15.97 3.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42C19.36.77 18.45.44 17.5.44c-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 20h2.66l3.4-5.42L15.3 20h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 6h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst SUBSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M15.97 16.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42-.7-.58-1.61-.91-2.56-.91-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 18h2.66l3.4-5.42L15.3 18h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 4h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst MARK_DEFINITIONS: readonly MarkDefinition[] = [\n\t{\n\t\ttype: 'superscript',\n\t\topposite: 'subscript',\n\t\tconfigKey: 'superscript',\n\t\trank: 4,\n\t\ttag: 'sup',\n\t\ticon: SUPERSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-.',\n\t\ttoHTMLString: (content) => `<sup>${content}</sup>`,\n\t\tparseHTML: [{ tag: 'sup' }],\n\t\tsanitize: { tags: ['sup'] },\n\t},\n\t{\n\t\ttype: 'subscript',\n\t\topposite: 'superscript',\n\t\tconfigKey: 'subscript',\n\t\trank: 4,\n\t\ttag: 'sub',\n\t\ticon: SUBSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-,',\n\t\ttoHTMLString: (content) => `<sub>${content}</sub>`,\n\t\tparseHTML: [{ tag: 'sub' }],\n\t\tsanitize: { tags: ['sub'] },\n\t},\n];\n\n// --- Plugin ---\n\nexport class SuperSubPlugin implements Plugin {\n\treadonly id = 'super-sub';\n\treadonly name = 'Superscript & Subscript';\n\treadonly priority = 23;\n\n\tprivate readonly config: SuperSubConfig;\n\tprivate locale!: SuperSubLocale;\n\n\tconstructor(config?: Partial<SuperSubConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSUPER_SUB_LOCALE_EN,\n\t\t\tloadSuperSubLocale,\n\t\t);\n\n\t\tconst enabledMarks: MarkDefinition[] = MARK_DEFINITIONS.filter(\n\t\t\t(def) => this.config[def.configKey],\n\t\t);\n\n\t\tfor (const def of enabledMarks) {\n\t\t\tthis.registerMark(context, def);\n\t\t}\n\n\t\tthis.registerKeymaps(context, enabledMarks);\n\t\tthis.registerExclusivityMiddleware(context, enabledMarks);\n\t\tthis.registerDisabledToolbarItems(context);\n\t}\n\n\tprivate registerMark(context: PluginContext, def: MarkDefinition): void {\n\t\tconst commandName: string = toCommandName(def.type);\n\t\tconst toolbarVisible: boolean = this.isToolbarVisible(def.configKey);\n\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: def.type,\n\t\t\trank: def.rank,\n\t\t\ttoDOM() {\n\t\t\t\treturn document.createElement(def.tag);\n\t\t\t},\n\t\t\ttoHTMLString: (_mark, content) => def.toHTMLString(content),\n\t\t\tparseHTML: def.parseHTML,\n\t\t\tsanitize: def.sanitize,\n\t\t});\n\n\t\tcontext.registerCommand(commandName, () =>\n\t\t\tdispatchIfPresent(context, toggleMark(context.getState(), mkType(def.type))),\n\t\t);\n\n\t\tif (toolbarVisible) {\n\t\t\tconst label: string =\n\t\t\t\tdef.type === 'superscript' ? this.locale.superscriptLabel : this.locale.subscriptLabel;\n\t\t\tconst tooltip: string =\n\t\t\t\tdef.type === 'superscript'\n\t\t\t\t\t? this.locale.superscriptTooltip(formatShortcut(def.keyBinding))\n\t\t\t\t\t: this.locale.subscriptTooltip(formatShortcut(def.keyBinding));\n\t\t\tcontext.registerToolbarItem({\n\t\t\t\tid: def.type,\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon: def.icon,\n\t\t\t\tlabel,\n\t\t\t\ttooltip,\n\t\t\t\tcommand: commandName,\n\t\t\t\tisActive: (state) => isMarkActive(state, mkType(def.type)),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate registerKeymaps(context: PluginContext, marks: readonly MarkDefinition[]): void {\n\t\tconst keymap: Record<string, () => boolean> = {};\n\t\tfor (const def of marks) {\n\t\t\tconst commandName: string = toCommandName(def.type);\n\t\t\tkeymap[def.keyBinding] = () => context.executeCommand(commandName);\n\t\t}\n\t\tif (Object.keys(keymap).length > 0) {\n\t\t\tcontext.registerKeymap(keymap);\n\t\t}\n\t}\n\n\t/**\n\t * Ensures superscript and subscript are mutually exclusive.\n\t * When an addMark step for one type is found, a removeMark step\n\t * for the opposite type is injected. For stored marks, the opposite\n\t * mark is filtered out.\n\t */\n\tprivate registerExclusivityMiddleware(\n\t\tcontext: PluginContext,\n\t\tenabledMarks: readonly MarkDefinition[],\n\t): void {\n\t\tconst bothEnabled: boolean =\n\t\t\tenabledMarks.some((d) => d.type === 'superscript') &&\n\t\t\tenabledMarks.some((d) => d.type === 'subscript');\n\n\t\tif (!bothEnabled) return;\n\n\t\tcontext.registerMiddleware(\n\t\t\t(tr, _state, next) => {\n\t\t\t\tlet patched = false;\n\n\t\t\t\t// Handle addMark steps: inject removeMark for the opposite type\n\t\t\t\tconst patchedSteps: Step[] = [];\n\t\t\t\tfor (const step of tr.steps) {\n\t\t\t\t\tif (step.type !== 'addMark') {\n\t\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst markName: string = step.mark.type;\n\t\t\t\t\tconst def: MarkDefinition | undefined = MARK_DEFINITIONS.find((d) => d.type === markName);\n\t\t\t\t\tif (!def) {\n\t\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tpatched = true;\n\t\t\t\t\tconst removeStep: RemoveMarkStep = {\n\t\t\t\t\t\ttype: 'removeMark',\n\t\t\t\t\t\tblockId: step.blockId,\n\t\t\t\t\t\tfrom: step.from,\n\t\t\t\t\t\tto: step.to,\n\t\t\t\t\t\tmark: { type: mkType(def.opposite) },\n\t\t\t\t\t\t...(step.path ? { path: step.path } : {}),\n\t\t\t\t\t};\n\t\t\t\t\tpatchedSteps.push(removeStep, step);\n\t\t\t\t}\n\n\t\t\t\t// Handle stored marks: remove the opposite mark\n\t\t\t\tlet storedMarksAfter: readonly Mark[] | null = tr.storedMarksAfter;\n\t\t\t\tif (storedMarksAfter) {\n\t\t\t\t\tconst hasSup: boolean = storedMarksAfter.some((m) => m.type === 'superscript');\n\t\t\t\t\tconst hasSub: boolean = storedMarksAfter.some((m) => m.type === 'subscript');\n\n\t\t\t\t\tif (hasSup && hasSub) {\n\t\t\t\t\t\t// Keep the one that was most recently added (last in array)\n\t\t\t\t\t\tconst lastSupIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t\t(m) => m.type === 'superscript',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst lastSubIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t\t(m) => m.type === 'subscript',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst removeType: string = lastSupIdx > lastSubIdx ? 'subscript' : 'superscript';\n\n\t\t\t\t\t\tstoredMarksAfter = storedMarksAfter.filter((m) => m.type !== removeType);\n\t\t\t\t\t\tpatched = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnext(patched ? { ...tr, steps: patchedSteps, storedMarksAfter } : tr);\n\t\t\t},\n\t\t\t{ name: 'super-sub:exclusivity' },\n\t\t);\n\t}\n\n\t/**\n\t * Registers disabled toolbar buttons for marks whose feature is disabled\n\t * but whose toolbar button is explicitly requested.\n\t */\n\tprivate registerDisabledToolbarItems(context: PluginContext): void {\n\t\tif (!this.config.toolbar) return;\n\n\t\tfor (const def of MARK_DEFINITIONS) {\n\t\t\tconst featureEnabled: boolean = this.config[def.configKey];\n\t\t\tconst toolbarVisible: boolean = this.config.toolbar[def.configKey] ?? true;\n\n\t\t\tif (!featureEnabled && toolbarVisible) {\n\t\t\t\tconst label: string =\n\t\t\t\t\tdef.type === 'superscript' ? this.locale.superscriptLabel : this.locale.subscriptLabel;\n\t\t\t\tcontext.registerToolbarItem({\n\t\t\t\t\tid: def.type,\n\t\t\t\t\tgroup: 'format',\n\t\t\t\t\ticon: def.icon,\n\t\t\t\t\tlabel,\n\t\t\t\t\tcommand: toCommandName(def.type),\n\t\t\t\t\tisEnabled: () => false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate isToolbarVisible(configKey: keyof Omit<SuperSubConfig, 'toolbar' | 'locale'>): boolean {\n\t\tif (!this.config.toolbar) return true;\n\t\treturn this.config.toolbar[configKey] ?? true;\n\t}\n}\n"],"mappings":"4NAiBA,IAAa,EAAsC,CAClD,iBAAkB,cAClB,mBAAqB,GAAqB,gBAAgB,KAC1D,eAAgB,YAChB,iBAAmB,GAAqB,cAAc,MAKjD,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,CCaA,IAAM,EAAiC,CACtC,aAAa,EACb,WAAW,GA2DN,EAA8C,CACnD,CACC,KAAM,cACN,SAAU,YACV,UAAW,cACX,KAAM,EACN,IAAK,MACL,KAhD+B,CAChC,+DACA,0DACA,iBACA,6CACA,+CACA,oDACA,8DACA,qDACA,yDACA,yDACA,yDACA,uDACA,yEACA,yEACA,0EACA,2EACA,2EACA,mBACA,0DACA,uDACA,UACC,KAAK,IA2BL,WAAY,QACZ,aAAe,GAAY,QAAQ,UACnC,UAAW,CAAC,CAAE,IAAK,QACnB,SAAU,CAAE,KAAM,CAAC,SAEpB,CACC,KAAM,YACN,SAAU,cACV,UAAW,YACX,KAAM,EACN,IAAK,MACL,KApC6B,CAC9B,+DACA,0DACA,yDACA,uDACA,uDACA,yEACA,yEACA,0EACA,2EACA,2EACA,mBACA,0DACA,uDACA,UACC,KAAK,IAsBL,WAAY,QACZ,aAAe,GAAY,QAAQ,UACnC,UAAW,CAAC,CAAE,IAAK,Q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0B,KAAK,OAAO,QAAQ,EAAI,aAAc,EAEtE,IAAK,GAAkB,EAAgB,CACtC,MAAM,EACQ,gBAAb,EAAI,KAAyB,KAAK,OAAO,iBAAmB,KAAK,OAAO,eACzE,EAAQ,oBAAoB,CAC3B,GAAI,EAAI,KACR,MAAO,SACP,KAAM,EAAI,KACV,QACA,QAAS,EAAc,EAAI,MAC3B,UAAA,KAAiB,GAEnB,CACD,CACD,CAEA,gBAAA,CAAyB,GACxB,OAAK,KAAK,OAAO,UACV,KAAK,OAAO,QAAQ,KAAc,EAC1C"}
|
|
1
|
+
{"version":3,"file":"SuperSubPlugin-x1iPnZyt.mjs","names":["mkType","markType","toggleMark","isMarkActive","loadLocaleModule","dispatchIfPresent","resolveLocale","toCommandName","formatShortcut","SUPER_SUB_LOCALE_EN","superscriptLabel","superscriptTooltip","shortcut","subscriptLabel","subscriptTooltip","localeModules","Object","assign","async","loadSuperSubLocale","lang","DEFAULT_CONFIG","superscript","subscript","MARK_DEFINITIONS","type","opposite","configKey","rank","tag","icon","join","keyBinding","toHTMLString","content","parseHTML","sanitize","tags","SuperSubPlugin","id","name","priority","config","locale","constructor","this","init","context","enabledMarks","filter","def","registerMark","registerKeymaps","registerExclusivityMiddleware","registerDisabledToolbarItems","commandName","toolbarVisible","isToolbarVisible","registerMarkSpec","toDOM","document","createElement","_mark","registerCommand","getState","label","tooltip","registerToolbarItem","group","command","isActive","state","marks","keymap","executeCommand","keys","length","registerKeymap","some","d","registerMiddleware","tr","_state","next","patched","patchedSteps","step","steps","push","markName","mark","find","removeStep","blockId","from","to","path","storedMarksAfter","hasSup","m","hasSub","removeType","findLastIndex","toolbar","featureEnabled","isEnabled"],"sources":["../../src/plugins/super-sub/SuperSubLocale.ts","../../src/plugins/super-sub/SuperSubPlugin.ts"],"sourcesContent":["/**\n * Locale interface and default English locale for the SuperSubPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface SuperSubLocale {\n\treadonly superscriptLabel: string;\n\treadonly superscriptTooltip: (shortcut: string) => string;\n\treadonly subscriptLabel: string;\n\treadonly subscriptTooltip: (shortcut: string) => string;\n}\n\n// --- Default English Locale ---\n\nexport const SUPER_SUB_LOCALE_EN: SuperSubLocale = {\n\tsuperscriptLabel: 'Superscript',\n\tsuperscriptTooltip: (shortcut: string) => `Superscript (${shortcut})`,\n\tsubscriptLabel: 'Subscript',\n\tsubscriptTooltip: (shortcut: string) => `Subscript (${shortcut})`,\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<SuperSubLocale> = import.meta.glob<{\n\tdefault: SuperSubLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadSuperSubLocale(lang: string): Promise<SuperSubLocale> {\n\treturn loadLocaleModule(localeModules, lang, SUPER_SUB_LOCALE_EN);\n}\n","/**\n * SuperSubPlugin: registers superscript and subscript inline marks with\n * MarkSpecs, toggle commands, keyboard shortcuts, toolbar buttons, and\n * a middleware that enforces mutual exclusivity between the two marks.\n *\n * Data-driven — each mark type is defined declaratively and all\n * registrations are derived from the same definition table.\n */\n\nimport { isMarkActive, toggleMark } from '../../commands/Commands.js';\nimport type { Mark } from '../../model/Document.js';\nimport type { ParseRule } from '../../model/ParseRule.js';\nimport type { SanitizeConfig } from '../../model/SanitizeConfig.js';\nimport { markType as mkType } from '../../model/TypeBrands.js';\nimport type { RemoveMarkStep, Step } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { dispatchIfPresent, resolveLocale, toCommandName } from '../shared/PluginHelpers.js';\nimport { formatShortcut } from '../shared/ShortcutFormatting.js';\nimport { SUPER_SUB_LOCALE_EN, type SuperSubLocale, loadSuperSubLocale } from './SuperSubLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tsuperscript: Record<string, never>;\n\t\tsubscript: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\n/** Controls toolbar button visibility per mark. */\nexport interface SuperSubToolbarConfig {\n\treadonly superscript?: boolean;\n\treadonly subscript?: boolean;\n}\n\n/** Controls which marks are enabled and which toolbar buttons are shown. */\nexport interface SuperSubConfig {\n\treadonly superscript: boolean;\n\treadonly subscript: boolean;\n\treadonly toolbar?: SuperSubToolbarConfig;\n\treadonly locale?: SuperSubLocale;\n}\n\nconst DEFAULT_CONFIG: SuperSubConfig = {\n\tsuperscript: true,\n\tsubscript: true,\n};\n\n// --- Mark Definitions ---\n\ninterface MarkDefinition {\n\treadonly type: 'superscript' | 'subscript';\n\treadonly opposite: 'superscript' | 'subscript';\n\treadonly configKey: keyof Omit<SuperSubConfig, 'toolbar' | 'locale'>;\n\treadonly rank: number;\n\treadonly tag: string;\n\treadonly icon: string;\n\treadonly keyBinding: string;\n\treadonly toHTMLString: (content: string) => string;\n\treadonly parseHTML: readonly ParseRule[];\n\treadonly sanitize: SanitizeConfig;\n}\n\nconst SUPERSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M16 7.41L11.41 12 16 16.59 14.59 18l-6-6 6-6z\"',\n\t' fill=\"none\"/>',\n\t'<path d=\"M9.64 7.64c.23-.5.36-1.05.36-1.64',\n\t' 0-2.21-1.79-4-4-4H2v14h4.36c2.34 0 4.24-1.9',\n\t' 4.24-4.24 0-1.6-.89-2.99-2.2-3.71zM4.5 4.5H6c.83',\n\t' 0 1.5.67 1.5 1.5S6.83 7.5 6 7.5H4.5v-3zm2 9H4.5v-3H6.5c.83',\n\t' 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\" fill=\"none\"/>',\n\t'<path d=\"M15.97 3.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42C19.36.77 18.45.44 17.5.44c-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 20h2.66l3.4-5.42L15.3 20h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 6h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst SUBSCRIPT_ICON: string = [\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">',\n\t'<path d=\"M15.97 16.84c0-.47.19-.91.53-1.21.34-.31.8-.49',\n\t' 1.3-.49.5 0 .95.18 1.28.48.32.3.5.7.51 1.15h1.59c-.02',\n\t'-.96-.43-1.83-1.13-2.42-.7-.58-1.61-.91-2.56-.91-.88',\n\t' 0-1.74.28-2.39.8-.67.53-1.06 1.28-1.06 2.1 0 .76.34',\n\t' 1.47.93 1.97.59.49 1.41.84 2.32 1.15.7.24 1.26.5 1.62.8.35.3.53.64.53',\n\t' 1.02 0 .48-.2.93-.55 1.24-.36.3-.84.48-1.37.48-.55 0-1.04-.2-1.39-.54',\n\t'-.34-.33-.53-.8-.53-1.32h-1.58c.01 1.02.43 1.95 1.16 2.57.72.62 1.67.96',\n\t' 2.67.96.92 0 1.81-.3 2.46-.84.67-.56 1.04-1.33 1.04-2.18 0-.81-.36-1.56',\n\t'-.99-2.08-.62-.51-1.48-.88-2.43-1.2-.67-.23-1.2-.47-1.52-.75-.32-.27-.46',\n\t'-.59-.46-.94z\"/>',\n\t'<path d=\"M5.88 18h2.66l3.4-5.42L15.3 18h2.67l-4.73-7.38',\n\t' 4.37-6.62h-2.6l-3.07 4.98L8.92 4h-2.6l4.26 6.58z\"/>',\n\t'</svg>',\n].join('');\n\nconst MARK_DEFINITIONS: readonly MarkDefinition[] = [\n\t{\n\t\ttype: 'superscript',\n\t\topposite: 'subscript',\n\t\tconfigKey: 'superscript',\n\t\trank: 4,\n\t\ttag: 'sup',\n\t\ticon: SUPERSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-.',\n\t\ttoHTMLString: (content) => `<sup>${content}</sup>`,\n\t\tparseHTML: [{ tag: 'sup' }],\n\t\tsanitize: { tags: ['sup'] },\n\t},\n\t{\n\t\ttype: 'subscript',\n\t\topposite: 'superscript',\n\t\tconfigKey: 'subscript',\n\t\trank: 4,\n\t\ttag: 'sub',\n\t\ticon: SUBSCRIPT_ICON,\n\t\tkeyBinding: 'Mod-,',\n\t\ttoHTMLString: (content) => `<sub>${content}</sub>`,\n\t\tparseHTML: [{ tag: 'sub' }],\n\t\tsanitize: { tags: ['sub'] },\n\t},\n];\n\n// --- Plugin ---\n\nexport class SuperSubPlugin implements Plugin {\n\treadonly id = 'super-sub';\n\treadonly name = 'Superscript & Subscript';\n\treadonly priority = 23;\n\n\tprivate readonly config: SuperSubConfig;\n\tprivate locale!: SuperSubLocale;\n\n\tconstructor(config?: Partial<SuperSubConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSUPER_SUB_LOCALE_EN,\n\t\t\tloadSuperSubLocale,\n\t\t);\n\n\t\tconst enabledMarks: MarkDefinition[] = MARK_DEFINITIONS.filter(\n\t\t\t(def) => this.config[def.configKey],\n\t\t);\n\n\t\tfor (const def of enabledMarks) {\n\t\t\tthis.registerMark(context, def);\n\t\t}\n\n\t\tthis.registerKeymaps(context, enabledMarks);\n\t\tthis.registerExclusivityMiddleware(context, enabledMarks);\n\t\tthis.registerDisabledToolbarItems(context);\n\t}\n\n\tprivate registerMark(context: PluginContext, def: MarkDefinition): void {\n\t\tconst commandName: string = toCommandName(def.type);\n\t\tconst toolbarVisible: boolean = this.isToolbarVisible(def.configKey);\n\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: def.type,\n\t\t\trank: def.rank,\n\t\t\ttoDOM() {\n\t\t\t\treturn document.createElement(def.tag);\n\t\t\t},\n\t\t\ttoHTMLString: (_mark, content) => def.toHTMLString(content),\n\t\t\tparseHTML: def.parseHTML,\n\t\t\tsanitize: def.sanitize,\n\t\t});\n\n\t\tcontext.registerCommand(commandName, () =>\n\t\t\tdispatchIfPresent(context, toggleMark(context.getState(), mkType(def.type))),\n\t\t);\n\n\t\tif (toolbarVisible) {\n\t\t\tconst label: string =\n\t\t\t\tdef.type === 'superscript' ? this.locale.superscriptLabel : this.locale.subscriptLabel;\n\t\t\tconst tooltip: string =\n\t\t\t\tdef.type === 'superscript'\n\t\t\t\t\t? this.locale.superscriptTooltip(formatShortcut(def.keyBinding))\n\t\t\t\t\t: this.locale.subscriptTooltip(formatShortcut(def.keyBinding));\n\t\t\tcontext.registerToolbarItem({\n\t\t\t\tid: def.type,\n\t\t\t\tgroup: 'format',\n\t\t\t\ticon: def.icon,\n\t\t\t\tlabel,\n\t\t\t\ttooltip,\n\t\t\t\tcommand: commandName,\n\t\t\t\tisActive: (state) => isMarkActive(state, mkType(def.type)),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate registerKeymaps(context: PluginContext, marks: readonly MarkDefinition[]): void {\n\t\tconst keymap: Record<string, () => boolean> = {};\n\t\tfor (const def of marks) {\n\t\t\tconst commandName: string = toCommandName(def.type);\n\t\t\tkeymap[def.keyBinding] = () => context.executeCommand(commandName);\n\t\t}\n\t\tif (Object.keys(keymap).length > 0) {\n\t\t\tcontext.registerKeymap(keymap);\n\t\t}\n\t}\n\n\t/**\n\t * Ensures superscript and subscript are mutually exclusive.\n\t * When an addMark step for one type is found, a removeMark step\n\t * for the opposite type is injected. For stored marks, the opposite\n\t * mark is filtered out.\n\t */\n\tprivate registerExclusivityMiddleware(\n\t\tcontext: PluginContext,\n\t\tenabledMarks: readonly MarkDefinition[],\n\t): void {\n\t\tconst bothEnabled: boolean =\n\t\t\tenabledMarks.some((d) => d.type === 'superscript') &&\n\t\t\tenabledMarks.some((d) => d.type === 'subscript');\n\n\t\tif (!bothEnabled) return;\n\n\t\tcontext.registerMiddleware(\n\t\t\t(tr, _state, next) => {\n\t\t\t\tlet patched = false;\n\n\t\t\t\t// Handle addMark steps: inject removeMark for the opposite type\n\t\t\t\tconst patchedSteps: Step[] = [];\n\t\t\t\tfor (const step of tr.steps) {\n\t\t\t\t\tif (step.type !== 'addMark') {\n\t\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst markName: string = step.mark.type;\n\t\t\t\t\tconst def: MarkDefinition | undefined = MARK_DEFINITIONS.find((d) => d.type === markName);\n\t\t\t\t\tif (!def) {\n\t\t\t\t\t\tpatchedSteps.push(step);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tpatched = true;\n\t\t\t\t\tconst removeStep: RemoveMarkStep = {\n\t\t\t\t\t\ttype: 'removeMark',\n\t\t\t\t\t\tblockId: step.blockId,\n\t\t\t\t\t\tfrom: step.from,\n\t\t\t\t\t\tto: step.to,\n\t\t\t\t\t\tmark: { type: mkType(def.opposite) },\n\t\t\t\t\t\t...(step.path ? { path: step.path } : {}),\n\t\t\t\t\t};\n\t\t\t\t\tpatchedSteps.push(removeStep, step);\n\t\t\t\t}\n\n\t\t\t\t// Handle stored marks: remove the opposite mark\n\t\t\t\tlet storedMarksAfter: readonly Mark[] | null = tr.storedMarksAfter;\n\t\t\t\tif (storedMarksAfter) {\n\t\t\t\t\tconst hasSup: boolean = storedMarksAfter.some((m) => m.type === 'superscript');\n\t\t\t\t\tconst hasSub: boolean = storedMarksAfter.some((m) => m.type === 'subscript');\n\n\t\t\t\t\tif (hasSup && hasSub) {\n\t\t\t\t\t\t// Keep the one that was most recently added (last in array)\n\t\t\t\t\t\tconst lastSupIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t\t(m) => m.type === 'superscript',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst lastSubIdx: number = storedMarksAfter.findLastIndex(\n\t\t\t\t\t\t\t(m) => m.type === 'subscript',\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst removeType: string = lastSupIdx > lastSubIdx ? 'subscript' : 'superscript';\n\n\t\t\t\t\t\tstoredMarksAfter = storedMarksAfter.filter((m) => m.type !== removeType);\n\t\t\t\t\t\tpatched = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnext(patched ? { ...tr, steps: patchedSteps, storedMarksAfter } : tr);\n\t\t\t},\n\t\t\t{ name: 'super-sub:exclusivity' },\n\t\t);\n\t}\n\n\t/**\n\t * Registers disabled toolbar buttons for marks whose feature is disabled\n\t * but whose toolbar button is explicitly requested.\n\t */\n\tprivate registerDisabledToolbarItems(context: PluginContext): void {\n\t\tif (!this.config.toolbar) return;\n\n\t\tfor (const def of MARK_DEFINITIONS) {\n\t\t\tconst featureEnabled: boolean = this.config[def.configKey];\n\t\t\tconst toolbarVisible: boolean = this.config.toolbar[def.configKey] ?? true;\n\n\t\t\tif (!featureEnabled && toolbarVisible) {\n\t\t\t\tconst label: string =\n\t\t\t\t\tdef.type === 'superscript' ? this.locale.superscriptLabel : this.locale.subscriptLabel;\n\t\t\t\tcontext.registerToolbarItem({\n\t\t\t\t\tid: def.type,\n\t\t\t\t\tgroup: 'format',\n\t\t\t\t\ticon: def.icon,\n\t\t\t\t\tlabel,\n\t\t\t\t\tcommand: toCommandName(def.type),\n\t\t\t\t\tisEnabled: () => false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate isToolbarVisible(configKey: keyof Omit<SuperSubConfig, 'toolbar' | 'locale'>): boolean {\n\t\tif (!this.config.toolbar) return true;\n\t\treturn this.config.toolbar[configKey] ?? true;\n\t}\n}\n"],"mappings":"Y,gNAiBA,IAAaS,EAAsC,CAClDC,iBAAkB,cAClBC,mBAAqBC,GAAqB,gBAAgBA,KAC1DC,eAAgB,YAChBC,iBAAmBF,GAAqB,cAAcA,MAKjDG,iBAAiDC,OAAAC,OAAA,CAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,qBAAA,kBAAA,WAAA,uBAIvDC,eAAsBC,EAAmBC,GACxC,OAAOhB,EAAiBW,EAAeK,EAAMX,EAC9C,CCaA,IAAMY,EAAiC,CACtCC,aAAa,EACbC,WAAW,GA2DNC,EAA8C,CACnD,CACCC,KAAM,cACNC,SAAU,YACVC,UAAW,cACXC,KAAM,EACNC,IAAK,MACLC,KAhD+B,CAChC,+DACA,0DACA,iBACA,6CACA,+CACA,oDACA,8DACA,qDACA,yDACA,yDACA,yDACA,uDACA,yEACA,yEACA,0EACA,2EACA,2EACA,mBACA,0DACA,uDACA,UACCC,KAAK,IA2BLC,WAAY,QACZC,aAAeC,GAAY,QAAQA,UACnCC,UAAW,CAAC,CAAEN,IAAK,QACnBO,SAAU,CAAEC,KAAM,CAAC,SAEpB,CACCZ,KAAM,YACNC,SAAU,cACVC,UAAW,YACXC,KAAM,EACNC,IAAK,MACLC,KApC6B,CAC9B,+DACA,0DACA,yDACA,uDACA,uDACA,yEACA,yEACA,0EACA,2EACA,2EACA,mBACA,0DACA,uDACA,UACCC,KAAK,IAsBLC,WAAY,QACZC,aAAeC,GAAY,QAAQA,UACnCC,UAAW,CA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KAAMqB,GAAiB,cAAXA,EAAE1E,MAEvD,GAAIyE,GAAUE,EAAQ,CAQrB,MAAMC,EANqBJ,EAAiBK,cAC1CH,GAAiB,gBAAXA,EAAE1E,MAEiBwE,EAAiBK,cAC1CH,GAAiB,cAAXA,EAAE1E,MAE2C,YAAc,cAEnEwE,EAAmBA,EAAiBhD,OAAQkD,GAAMA,EAAE1E,OAAS4E,GAC7DjB,GAAU,CACX,CACD,CAEAD,EAAKC,EAAU,IAAKH,EAAIM,MAAOF,EAAcY,oBAAqBhB,IAEnE,CAAEzC,KAAM,yBAEV,CAMA,4BAAAc,CAAqCP,GACpC,GAAKF,KAAKH,OAAO6D,QAEjB,IAAK,MAAMrD,KAAO1B,EAAkB,CACnC,MAAMgF,EAA0B3D,KAAKH,OAAOQ,EAAIvB,WAC1C6B,EAA0BX,KAAKH,OAAO6D,QAAQrD,EAAIvB,aAAc,EAEtE,IAAK6E,GAAkBhD,EAAgB,CACtC,MAAMS,EACQ,gBAAbf,EAAIzB,KAAyBoB,KAAKF,OAAOjC,iBAAmBmC,KAAKF,OAAO9B,eACzEkC,EAAQoB,oBAAoB,CAC3B5B,GAAIW,EAAIzB,KACR2C,MAAO,SACPtC,KAAMoB,EAAIpB,KACVmC,QACAI,QAAS9D,EAAc2C,EAAIzB,MAC3BgF,UAAA,KAAiB,GAEnB,CACD,CACD,CAEA,gBAAAhD,CAAyB9B,GACxB,OAAKkB,KAAKH,OAAO6D,UACV1D,KAAKH,OAAO6D,QAAQ5E,KAAc,EAC1C,U"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyntaxTokenTypes-BUCOMtL8.mjs","names":[],"sources":["../../src/editor/theme/SyntaxTokenTypes.ts"],"sourcesContent":["/**\n * Canonical syntax token type list and style resolution utilities.\n *\n * Single source of truth for all syntax highlighting token types.\n * Adding a new token type here automatically propagates to themes,\n * CSS variables, and token CSS classes.\n */\n\n/** All supported syntax token types. */\nexport const SYNTAX_TOKEN_TYPES = [\n\t'keyword',\n\t'string',\n\t'comment',\n\t'number',\n\t'function',\n\t'operator',\n\t'punctuation',\n\t'boolean',\n\t'null',\n\t'property',\n\t'type',\n\t'annotation',\n\t'tag',\n\t'attribute',\n\t'constant',\n\t'regex',\n] as const;\n\n/** A syntax token type from the canonical list. */\nexport type SyntaxTokenType = (typeof SYNTAX_TOKEN_TYPES)[number];\n\n/** Per-token style: color plus optional font weight and style. */\nexport interface TokenStyle {\n\treadonly color: string;\n\treadonly fontWeight?: 'normal' | 'bold';\n\treadonly fontStyle?: 'normal' | 'italic';\n}\n\n/** A token style value is either a plain color string or a full TokenStyle object. */\nexport type TokenStyleValue = string | TokenStyle;\n\n/** Extracts the color from a TokenStyleValue. */\nexport function resolveTokenColor(value: TokenStyleValue): string {\n\treturn typeof value === 'string' ? value : value.color;\n}\n\n/** Extracts the font-style from a TokenStyleValue, or undefined if not set. */\nexport function resolveTokenFontStyle(value: TokenStyleValue): string | undefined {\n\treturn typeof value === 'object' ? value.fontStyle : undefined;\n}\n\n/** Extracts the font-weight from a TokenStyleValue, or undefined if not set. */\nexport function resolveTokenFontWeight(value: TokenStyleValue): string | undefined {\n\treturn typeof value === 'object' ? value.fontWeight : undefined;\n}\n"],"mappings":"AASA,
|
|
1
|
+
{"version":3,"file":"SyntaxTokenTypes-BUCOMtL8.mjs","names":["SYNTAX_TOKEN_TYPES","resolveTokenColor","value","color","resolveTokenFontStyle","fontStyle","resolveTokenFontWeight","fontWeight"],"sources":["../../src/editor/theme/SyntaxTokenTypes.ts"],"sourcesContent":["/**\n * Canonical syntax token type list and style resolution utilities.\n *\n * Single source of truth for all syntax highlighting token types.\n * Adding a new token type here automatically propagates to themes,\n * CSS variables, and token CSS classes.\n */\n\n/** All supported syntax token types. */\nexport const SYNTAX_TOKEN_TYPES = [\n\t'keyword',\n\t'string',\n\t'comment',\n\t'number',\n\t'function',\n\t'operator',\n\t'punctuation',\n\t'boolean',\n\t'null',\n\t'property',\n\t'type',\n\t'annotation',\n\t'tag',\n\t'attribute',\n\t'constant',\n\t'regex',\n] as const;\n\n/** A syntax token type from the canonical list. */\nexport type SyntaxTokenType = (typeof SYNTAX_TOKEN_TYPES)[number];\n\n/** Per-token style: color plus optional font weight and style. */\nexport interface TokenStyle {\n\treadonly color: string;\n\treadonly fontWeight?: 'normal' | 'bold';\n\treadonly fontStyle?: 'normal' | 'italic';\n}\n\n/** A token style value is either a plain color string or a full TokenStyle object. */\nexport type TokenStyleValue = string | TokenStyle;\n\n/** Extracts the color from a TokenStyleValue. */\nexport function resolveTokenColor(value: TokenStyleValue): string {\n\treturn typeof value === 'string' ? value : value.color;\n}\n\n/** Extracts the font-style from a TokenStyleValue, or undefined if not set. */\nexport function resolveTokenFontStyle(value: TokenStyleValue): string | undefined {\n\treturn typeof value === 'object' ? value.fontStyle : undefined;\n}\n\n/** Extracts the font-weight from a TokenStyleValue, or undefined if not set. */\nexport function resolveTokenFontWeight(value: TokenStyleValue): string | undefined {\n\treturn typeof value === 'object' ? value.fontWeight : undefined;\n}\n"],"mappings":"AASA,IAAaA,EAAqB,CACjC,UACA,SACA,UACA,SACA,WACA,WACA,cACA,UACA,OACA,WACA,OACA,aACA,MACA,YACA,WACA,SAiBD,SAAgBC,EAAkBC,GACjC,MAAwB,iBAAVA,EAAqBA,EAAQA,EAAMC,KAClD,CAGA,SAAgBC,EAAsBF,GACrC,MAAwB,iBAAVA,EAAqBA,EAAMG,eAAY,CACtD,CAGA,SAAgBC,EAAuBJ,GACtC,MAAwB,iBAAVA,EAAqBA,EAAMK,gBAAa,CACvD,Q"}
|