@notectl/core 2.0.7 → 2.0.9
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-D1wmhWE6.mjs +2 -0
- package/dist/chunks/AlignmentPlugin-D1wmhWE6.mjs.map +1 -0
- package/dist/chunks/{AttributedMarkCommands-D_PYkbBt.mjs → AttributedMarkCommands-35jTbVRg.mjs} +2 -2
- package/dist/chunks/{AttributedMarkCommands-D_PYkbBt.mjs.map → AttributedMarkCommands-35jTbVRg.mjs.map} +1 -1
- package/dist/chunks/{BlockInsertion-DaG_4D31.mjs → BlockInsertion-DsnHLcvM.mjs} +2 -2
- package/dist/chunks/{BlockInsertion-DaG_4D31.mjs.map → BlockInsertion-DsnHLcvM.mjs.map} +1 -1
- package/dist/chunks/BlockquotePlugin-Bwny0CP6.mjs +2 -0
- package/dist/chunks/BlockquotePlugin-Bwny0CP6.mjs.map +1 -0
- package/dist/chunks/CaretNavigationPlugin-C-rCDbu0.mjs +2 -0
- package/dist/chunks/CaretNavigationPlugin-C-rCDbu0.mjs.map +1 -0
- package/dist/chunks/CodeBlockPlugin-CNC290_q.mjs +2 -0
- package/dist/chunks/CodeBlockPlugin-CNC290_q.mjs.map +1 -0
- package/dist/chunks/{ColorGrid-BNDaG3b2.mjs → ColorGrid-BUSIBKZH.mjs} +1 -1
- package/dist/chunks/{ColorGrid-BNDaG3b2.mjs.map → ColorGrid-BUSIBKZH.mjs.map} +1 -1
- package/dist/chunks/{ColorPickerPopup-BwU_WZHh.mjs → ColorPickerPopup-CvE90IAu.mjs} +2 -2
- package/dist/chunks/{ColorPickerPopup-BwU_WZHh.mjs.map → ColorPickerPopup-CvE90IAu.mjs.map} +1 -1
- package/dist/chunks/{CommandHelpers-BoRO1KfE.mjs → CommandHelpers-DTlQcGv5.mjs} +2 -2
- package/dist/chunks/{CommandHelpers-BoRO1KfE.mjs.map → CommandHelpers-DTlQcGv5.mjs.map} +1 -1
- package/dist/chunks/Commands-BuYF23lf.mjs +2 -0
- package/dist/chunks/Commands-BuYF23lf.mjs.map +1 -0
- package/dist/chunks/FontPlugin-z0QF1M5q.mjs +2 -0
- package/dist/chunks/FontPlugin-z0QF1M5q.mjs.map +1 -0
- package/dist/chunks/FontSizePlugin-DYKvhu9w.mjs +2 -0
- package/dist/chunks/FontSizePlugin-DYKvhu9w.mjs.map +1 -0
- package/dist/chunks/{GapCursorNavigation-PhJeqELx.mjs → GapCursorNavigation-BaXDnjFf.mjs} +2 -2
- package/dist/chunks/{GapCursorNavigation-PhJeqELx.mjs.map → GapCursorNavigation-BaXDnjFf.mjs.map} +1 -1
- package/dist/chunks/GapCursorPlugin-uxw7W7vj.mjs +2 -0
- package/dist/chunks/GapCursorPlugin-uxw7W7vj.mjs.map +1 -0
- package/dist/chunks/{HardBreakPlugin-BzAU3DoJ.mjs → HardBreakPlugin-BpXipf8h.mjs} +2 -2
- package/dist/chunks/{HardBreakPlugin-BzAU3DoJ.mjs.map → HardBreakPlugin-BpXipf8h.mjs.map} +1 -1
- package/dist/chunks/HeadingPlugin-CUN746aD.mjs +2 -0
- package/dist/chunks/{HeadingPlugin-1BVn57NF.mjs.map → HeadingPlugin-CUN746aD.mjs.map} +1 -1
- package/dist/chunks/HighlightPlugin-bbAi6W6k.mjs +2 -0
- package/dist/chunks/HighlightPlugin-bbAi6W6k.mjs.map +1 -0
- package/dist/chunks/HorizontalRulePlugin-D8w6paMa.mjs +2 -0
- package/dist/chunks/HorizontalRulePlugin-D8w6paMa.mjs.map +1 -0
- package/dist/chunks/ImagePlugin-De7lWcZ7.mjs +2 -0
- package/dist/chunks/ImagePlugin-De7lWcZ7.mjs.map +1 -0
- package/dist/chunks/InlineCodePlugin-DKQIYhTb.mjs +2 -0
- package/dist/chunks/InlineCodePlugin-DKQIYhTb.mjs.map +1 -0
- package/dist/chunks/LinkPlugin-BD7mcRHS.mjs +2 -0
- package/dist/chunks/LinkPlugin-BD7mcRHS.mjs.map +1 -0
- package/dist/chunks/ListPlugin-DbixSqMH.mjs +2 -0
- package/dist/chunks/{ListPlugin-Datp4nPR.mjs.map → ListPlugin-DbixSqMH.mjs.map} +1 -1
- package/dist/chunks/{NavigationQueries-_xQtPALX.mjs → NavigationQueries-CgYPG6oY.mjs} +1 -1
- package/dist/chunks/{NavigationQueries-_xQtPALX.mjs.map → NavigationQueries-CgYPG6oY.mjs.map} +1 -1
- package/dist/chunks/NodeSelectionCommands-Ddxu5Qck.mjs +2 -0
- package/dist/chunks/NodeSelectionCommands-Ddxu5Qck.mjs.map +1 -0
- package/dist/chunks/PluginHelpers-D1QF-YaF.mjs +2 -0
- package/dist/chunks/PluginHelpers-D1QF-YaF.mjs.map +1 -0
- package/dist/chunks/{shared-BLU27F7-.mjs → PopupKeyboardPatterns-DhcUe29m.mjs} +1 -1
- package/dist/chunks/PopupKeyboardPatterns-DhcUe29m.mjs.map +1 -0
- package/dist/chunks/PrintPlugin-DVRybXSN.mjs +2 -0
- package/dist/chunks/PrintPlugin-DVRybXSN.mjs.map +1 -0
- package/dist/chunks/{RangeIterator-CVUeIB4P.mjs → RangeIterator-DytL1lUT.mjs} +1 -1
- package/dist/chunks/{RangeIterator-CVUeIB4P.mjs.map → RangeIterator-DytL1lUT.mjs.map} +1 -1
- package/dist/chunks/SmartPastePlugin-i96yAnXZ.mjs +2 -0
- package/dist/chunks/SmartPastePlugin-i96yAnXZ.mjs.map +1 -0
- package/dist/chunks/StrikethroughPlugin-RGZATXUZ.mjs +2 -0
- package/dist/chunks/StrikethroughPlugin-RGZATXUZ.mjs.map +1 -0
- package/dist/chunks/SuperSubPlugin-BOWFP1Kr.mjs +2 -0
- package/dist/chunks/SuperSubPlugin-BOWFP1Kr.mjs.map +1 -0
- package/dist/chunks/TablePlugin-DZTMBkyu.mjs +2 -0
- package/dist/chunks/TablePlugin-DZTMBkyu.mjs.map +1 -0
- package/dist/chunks/TextColorPlugin-CB3RpTSQ.mjs +2 -0
- package/dist/chunks/TextColorPlugin-CB3RpTSQ.mjs.map +1 -0
- package/dist/chunks/{TextDirectionCorePlugin-CXCxX532.mjs → TextDirectionCorePlugin-tNecTcrX.mjs} +2 -2
- package/dist/chunks/{TextDirectionCorePlugin-CXCxX532.mjs.map → TextDirectionCorePlugin-tNecTcrX.mjs.map} +1 -1
- package/dist/chunks/TextDirectionLocale-_AUfZu9j.mjs +2 -0
- package/dist/chunks/{TextDirectionLocale-Kh3r4XQS.mjs.map → TextDirectionLocale-_AUfZu9j.mjs.map} +1 -1
- package/dist/chunks/TextFormattingPlugin-CZ6D-luc.mjs +2 -0
- package/dist/chunks/TextFormattingPlugin-CZ6D-luc.mjs.map +1 -0
- package/dist/chunks/ToolbarPlugin-2K96zYut.mjs +2 -0
- package/dist/chunks/ToolbarPlugin-2K96zYut.mjs.map +1 -0
- package/dist/chunks/WordBoundary-BE2u997Q.mjs +2 -0
- package/dist/chunks/WordBoundary-BE2u997Q.mjs.map +1 -0
- package/dist/chunks/XmlSupport-DG8PEZhO.mjs +2 -0
- package/dist/chunks/XmlSupport-DG8PEZhO.mjs.map +1 -0
- package/dist/chunks/ar--dzNQRg4.mjs +2 -0
- package/dist/chunks/{ar-DLxmSv7R.mjs.map → ar--dzNQRg4.mjs.map} +1 -1
- package/dist/chunks/{color-picker-D4Vi72Z_.mjs → color-picker-ChYYdC-r.mjs} +1 -1
- package/dist/chunks/{color-picker-D4Vi72Z_.mjs.map → color-picker-ChYYdC-r.mjs.map} +1 -1
- package/dist/chunks/de-C7Grl0t1.mjs +2 -0
- package/dist/chunks/de-C7Grl0t1.mjs.map +1 -0
- package/dist/chunks/{es-BL7KuLOg.mjs → es-BwmzRdDZ.mjs} +2 -2
- package/dist/chunks/es-BwmzRdDZ.mjs.map +1 -0
- package/dist/chunks/{fonts-B3hiRKxQ.mjs → fonts-CG_dDwvT.mjs} +1 -1
- package/dist/chunks/{fonts-B3hiRKxQ.mjs.map → fonts-CG_dDwvT.mjs.map} +1 -1
- package/dist/chunks/fr-CC7TYK5K.mjs +2 -0
- package/dist/chunks/{fr-GSoPohxY.mjs.map → fr-CC7TYK5K.mjs.map} +1 -1
- package/dist/chunks/full-B9IqlP6u.mjs +2 -0
- package/dist/chunks/{full-DCZ8MMpe.mjs.map → full-B9IqlP6u.mjs.map} +1 -1
- package/dist/chunks/{hi-CTb2tu17.mjs → hi-BtN2T9la.mjs} +2 -2
- package/dist/chunks/{hi-CTb2tu17.mjs.map → hi-BtN2T9la.mjs.map} +1 -1
- package/dist/chunks/minimal-J-u7e_pr.mjs +2 -0
- package/dist/chunks/{minimal-DmYfqOxb.mjs.map → minimal-J-u7e_pr.mjs.map} +1 -1
- package/dist/chunks/{pt-BattAVOq.mjs → pt-B59gJzMS.mjs} +2 -2
- package/dist/chunks/pt-B59gJzMS.mjs.map +1 -0
- package/dist/chunks/{ru-U-UhwubV.mjs → ru-KBX9Y7TT.mjs} +2 -2
- package/dist/chunks/{ru-U-UhwubV.mjs.map → ru-KBX9Y7TT.mjs.map} +1 -1
- package/dist/chunks/src-DPhUQ25M.mjs +2 -0
- package/dist/chunks/src-DPhUQ25M.mjs.map +1 -0
- package/dist/chunks/{text-direction-advanced-CkFu0K_I.mjs → text-direction-advanced-S4MgVMLX.mjs} +2 -2
- package/dist/chunks/{text-direction-advanced-CkFu0K_I.mjs.map → text-direction-advanced-S4MgVMLX.mjs.map} +1 -1
- package/dist/chunks/{zh-TXVgSc3H.mjs → zh-D4eu30KQ.mjs} +2 -2
- package/dist/chunks/{zh-TXVgSc3H.mjs.map → zh-D4eu30KQ.mjs.map} +1 -1
- package/dist/commands/CommandHelpers.d.ts +13 -0
- package/dist/commands/CommandHelpers.d.ts.map +1 -1
- package/dist/commands/DeleteCommands.d.ts.map +1 -1
- package/dist/editor/EditorConfig.d.ts +7 -0
- package/dist/editor/EditorConfig.d.ts.map +1 -1
- package/dist/editor/EditorLocale.d.ts.map +1 -1
- package/dist/editor/styles/code-block.d.ts.map +1 -1
- package/dist/fonts.mjs +1 -1
- package/dist/full.mjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.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/CommandRegistry.d.ts +3 -0
- package/dist/plugins/CommandRegistry.d.ts.map +1 -1
- package/dist/plugins/EventBus.d.ts +3 -0
- package/dist/plugins/EventBus.d.ts.map +1 -1
- package/dist/plugins/Logger.d.ts +50 -0
- package/dist/plugins/Logger.d.ts.map +1 -0
- package/dist/plugins/MiddlewareChain.d.ts +3 -0
- package/dist/plugins/MiddlewareChain.d.ts.map +1 -1
- package/dist/plugins/PluginContextFactory.d.ts +2 -0
- package/dist/plugins/PluginContextFactory.d.ts.map +1 -1
- package/dist/plugins/PluginLifecycle.d.ts +3 -1
- package/dist/plugins/PluginLifecycle.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +14 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation/CaretNavigationLocale.d.ts.map +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockLocale.d.ts +4 -0
- package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts +13 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockService.d.ts +2 -2
- package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -1
- package/dist/plugins/code-block/LanguagePicker.d.ts +14 -0
- package/dist/plugins/code-block/LanguagePicker.d.ts.map +1 -0
- package/dist/plugins/code-block/highlighter/RegexTokenizer.d.ts.map +1 -1
- package/dist/plugins/code-block/highlighter/TokenizerTypes.d.ts +1 -1
- package/dist/plugins/code-block/highlighter/TokenizerTypes.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/ar.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/de.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/es.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/fr.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/hi.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/pt.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/ru.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/zh.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font/FontLocale.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/gap-cursor/GapCursorLocale.d.ts.map +1 -1
- package/dist/plugins/gap-cursor.mjs +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImageLocale.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/inline-code/InlineCodeLocale.d.ts.map +1 -1
- package/dist/plugins/inline-code.mjs +1 -1
- package/dist/plugins/language.mjs +1 -1
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/ListLocale.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print/PrintLocale.d.ts.map +1 -1
- package/dist/plugins/print.mjs +1 -1
- package/dist/plugins/shared/LocaleLoader.d.ts +49 -0
- package/dist/plugins/shared/LocaleLoader.d.ts.map +1 -0
- package/dist/plugins/shared/index.d.ts +1 -0
- package/dist/plugins/shared/index.d.ts.map +1 -1
- package/dist/plugins/shared.mjs +1 -1
- package/dist/plugins/smart-paste/SmartPasteLocale.d.ts.map +1 -1
- package/dist/plugins/smart-paste.mjs +1 -1
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableLocale.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-direction/TextDirectionLocale.d.ts.map +1 -1
- package/dist/plugins/text-direction-advanced.mjs +1 -1
- package/dist/plugins/text-direction.mjs +1 -1
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/presets/full.mjs +1 -1
- package/dist/presets/minimal.mjs +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/state/EditorState.d.ts +2 -0
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts +11 -1
- package/dist/view/EditorView.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/chunks/AlignmentPlugin-CD11uRY3.mjs +0 -2
- package/dist/chunks/AlignmentPlugin-CD11uRY3.mjs.map +0 -1
- package/dist/chunks/BlockquotePlugin-DpMA33pk.mjs +0 -2
- package/dist/chunks/BlockquotePlugin-DpMA33pk.mjs.map +0 -1
- package/dist/chunks/CaretNavigationPlugin-BxU2lMwX.mjs +0 -2
- package/dist/chunks/CaretNavigationPlugin-BxU2lMwX.mjs.map +0 -1
- package/dist/chunks/CodeBlockPlugin-CSb6Fxce.mjs +0 -2
- package/dist/chunks/CodeBlockPlugin-CSb6Fxce.mjs.map +0 -1
- package/dist/chunks/Commands-C7zBYmhA.mjs +0 -2
- package/dist/chunks/Commands-C7zBYmhA.mjs.map +0 -1
- package/dist/chunks/FontPlugin-CUVcS-40.mjs +0 -2
- package/dist/chunks/FontPlugin-CUVcS-40.mjs.map +0 -1
- package/dist/chunks/FontSizePlugin-a8YyFsjf.mjs +0 -2
- package/dist/chunks/FontSizePlugin-a8YyFsjf.mjs.map +0 -1
- package/dist/chunks/GapCursorPlugin-9V0Ne0Sw.mjs +0 -2
- package/dist/chunks/GapCursorPlugin-9V0Ne0Sw.mjs.map +0 -1
- package/dist/chunks/HeadingPlugin-1BVn57NF.mjs +0 -2
- package/dist/chunks/HighlightPlugin-7S6Y_IFY.mjs +0 -2
- package/dist/chunks/HighlightPlugin-7S6Y_IFY.mjs.map +0 -1
- package/dist/chunks/HorizontalRulePlugin-bZ4nat7E.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-bZ4nat7E.mjs.map +0 -1
- package/dist/chunks/ImagePlugin-wz0SBhFQ.mjs +0 -2
- package/dist/chunks/ImagePlugin-wz0SBhFQ.mjs.map +0 -1
- package/dist/chunks/InlineCodePlugin-DW5_oiac.mjs +0 -2
- package/dist/chunks/InlineCodePlugin-DW5_oiac.mjs.map +0 -1
- package/dist/chunks/LinkPlugin-pWzPs-dS.mjs +0 -2
- package/dist/chunks/LinkPlugin-pWzPs-dS.mjs.map +0 -1
- package/dist/chunks/ListPlugin-Datp4nPR.mjs +0 -2
- package/dist/chunks/NodeSelectionCommands-BFHLrE5I.mjs +0 -2
- package/dist/chunks/NodeSelectionCommands-BFHLrE5I.mjs.map +0 -1
- package/dist/chunks/PluginHelpers-Db50-BRE.mjs +0 -2
- package/dist/chunks/PluginHelpers-Db50-BRE.mjs.map +0 -1
- package/dist/chunks/PrintPlugin-Dv8_E40e.mjs +0 -2
- package/dist/chunks/PrintPlugin-Dv8_E40e.mjs.map +0 -1
- package/dist/chunks/SmartPastePlugin-PCLFN5yA.mjs +0 -2
- package/dist/chunks/SmartPastePlugin-PCLFN5yA.mjs.map +0 -1
- package/dist/chunks/StrikethroughPlugin-J5eDn_sY.mjs +0 -2
- package/dist/chunks/StrikethroughPlugin-J5eDn_sY.mjs.map +0 -1
- package/dist/chunks/SuperSubPlugin-uSLscUwN.mjs +0 -2
- package/dist/chunks/SuperSubPlugin-uSLscUwN.mjs.map +0 -1
- package/dist/chunks/TablePlugin-DJHHWTD2.mjs +0 -2
- package/dist/chunks/TablePlugin-DJHHWTD2.mjs.map +0 -1
- package/dist/chunks/TextColorPlugin-CawTv5pV.mjs +0 -2
- package/dist/chunks/TextColorPlugin-CawTv5pV.mjs.map +0 -1
- package/dist/chunks/TextDirectionLocale-Kh3r4XQS.mjs +0 -2
- package/dist/chunks/TextFormattingPlugin-DKgwX4Gy.mjs +0 -2
- package/dist/chunks/TextFormattingPlugin-DKgwX4Gy.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-BipA0zez.mjs +0 -2
- package/dist/chunks/ToolbarPlugin-BipA0zez.mjs.map +0 -1
- package/dist/chunks/WordBoundary-DI0G6Wk2.mjs +0 -2
- package/dist/chunks/WordBoundary-DI0G6Wk2.mjs.map +0 -1
- package/dist/chunks/XmlSupport-UA-iNWTl.mjs +0 -2
- package/dist/chunks/XmlSupport-UA-iNWTl.mjs.map +0 -1
- package/dist/chunks/ar-DLxmSv7R.mjs +0 -2
- package/dist/chunks/de-BnhP65y3.mjs +0 -2
- package/dist/chunks/de-BnhP65y3.mjs.map +0 -1
- package/dist/chunks/es-BL7KuLOg.mjs.map +0 -1
- package/dist/chunks/fr-GSoPohxY.mjs +0 -2
- package/dist/chunks/full-DCZ8MMpe.mjs +0 -2
- package/dist/chunks/minimal-DmYfqOxb.mjs +0 -2
- package/dist/chunks/pt-BattAVOq.mjs.map +0 -1
- package/dist/chunks/shared-BLU27F7-.mjs.map +0 -1
- package/dist/chunks/src-CgbuJfYr.mjs +0 -2
- package/dist/chunks/src-CgbuJfYr.mjs.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{C as e,S as t,T as n,a as s,b as i,c as r,d as o,f as a,g as c,h as l,i as h,l as d,m as p,p as u,r as g,s as m,t as f,u as y,w as k,x as S,y as w}from"./Document-_qdGR4vh.mjs";import{C as v,D as b,E as R,O as C,S as I,T as x,b as T,t as P,v as E,w as M,x as A,y as N}from"./CaretNavigationPlugin-BxU2lMwX.mjs";import{a as B,c as O,d as D,f as L,i as H,l as z,o as _,r as F,t as K,u as V}from"./Selection-aeiSsvhe.mjs";import{C as $,S as j,b as U,c as q,d as W,f as G,i as Q,l as J,m as X,n as Y,o as Z,p as ee,r as te,s as ne,t as se,u as ie,w as re,x as oe,y as ae}from"./Commands-C7zBYmhA.mjs";import{a as ce,i as le,t as he}from"./TypeBrands-BZDKMjR-.mjs";import{n as de,t as pe}from"./DomUtils-RKbAVBQz.mjs";import{i as ue,t as ge}from"./HTMLUtils-B8xj8Z1x.mjs";import{i as me,n as fe,t as ye}from"./NodeResolver-DVPpO5nC.mjs";import{t as ke}from"./GapCursorNavigation-PhJeqELx.mjs";import{a as Se,i as we,n as ve,o as be,s as Re}from"./CommandHelpers-BoRO1KfE.mjs";import{i as Ce,t as Ie}from"./NodeSelectionCommands-BFHLrE5I.mjs";import{t as xe}from"./Platform-D9TRT4Mn.mjs";import{a as Te,i as Pe,o as Ee,s as Me,t as Ae}from"./DocumentParser-Cq_bFYAS.mjs";import{c as Ne,i as Be,l as Oe,n as De,r as Le,s as He,t as ze,u as _e}from"./BlockInsertion-DaG_4D31.mjs";import{c as Fe,i as Ke,l as Ve,n as $e,s as je,t as Ue}from"./StyleRuntime-D3d1XFFe.mjs";import{n as qe,t as We}from"./Decoration-oeHDjWWq.mjs";import{t as Ge}from"./BlockTypePickerRegistry-C_jLddOz.mjs";import{o as Qe,t as Je}from"./ToolbarPlugin-BipA0zez.mjs";import{_ as Xe,a as Ye,f as Ze,h as et,i as tt,l as nt,n as st,o as it,u as rt}from"./PrintTypes-DTV3-mSe.mjs";import{o as ot,s as at}from"./PluginHelpers-Db50-BRE.mjs";import{t as ct}from"./GapCursorPlugin-9V0Ne0Sw.mjs";import{t as lt}from"./TextFormattingPlugin-DKgwX4Gy.mjs";import ht from"dompurify";var dt=class{_nodeSpecs=/* @__PURE__ */new Map;_markSpecs=/* @__PURE__ */new Map;_inlineNodeSpecs=/* @__PURE__ */new Map;registerNodeSpec(e){if(this._nodeSpecs.has(e.type))throw new Error(`NodeSpec for type "${e.type}" is already registered.`);this._nodeSpecs.set(e.type,e)}getNodeSpec(e){return this._nodeSpecs.get(e)}removeNodeSpec(e){this._nodeSpecs.delete(e)}getNodeTypes(){return[...this._nodeSpecs.keys()]}registerMarkSpec(e){if(this._markSpecs.has(e.type))throw new Error(`MarkSpec for type "${e.type}" is already registered.`);this._markSpecs.set(e.type,e)}getMarkSpec(e){return this._markSpecs.get(e)}removeMarkSpec(e){this._markSpecs.delete(e)}getMarkTypes(){return[...this._markSpecs.keys()]}registerInlineNodeSpec(e){if(this._inlineNodeSpecs.has(e.type))throw new Error(`InlineNodeSpec for type "${e.type}" is already registered.`);this._inlineNodeSpecs.set(e.type,e)}getInlineNodeSpec(e){return this._inlineNodeSpecs.get(e)}removeInlineNodeSpec(e){this._inlineNodeSpecs.delete(e)}getInlineNodeTypes(){return[...this._inlineNodeSpecs.keys()]}getBlockParseRules(){return this.collectParseRules(this._nodeSpecs)}getInlineParseRules(){return this.collectParseRules(this._inlineNodeSpecs)}getMarkParseRules(){return this.collectParseRules(this._markSpecs)}getAllowedTags(){return[...this.collectSanitizeValues(new Set(["p","br","div","span"]),e=>e.sanitize?.tags)]}getAllowedAttrs(){return[...this.collectSanitizeValues(new Set(["style","dir"]),e=>e.sanitize?.attrs)]}collectParseRules(e){const t=[];for(const[n,s]of e)if(s.parseHTML)for(const e of s.parseHTML)t.push({rule:e,type:n});return t.sort((e,t)=>(t.rule.priority??50)-(e.rule.priority??50))}collectSanitizeValues(e,t){const n=[this._nodeSpecs,this._inlineNodeSpecs,this._markSpecs];for(const s of n)for(const n of s.values()){const s=t(n);if(s)for(const t of s)e.add(t)}return e}clear(){this._nodeSpecs.clear(),this._markSpecs.clear(),this._inlineNodeSpecs.clear()}};function pt(e,t,n){const s=e.getNodeSpec(t);if(!s?.content)return!0;const i=e.getNodeSpec(n)?.group;for(const r of s.content.allow){if(r===n)return!0;if("text"!==r&&i&&r===i)return!0}return!1}function ut(e,t,n){const s=e.getNodeSpec(t);if(!s?.content)return!0;const{min:i=0,max:r=Number.POSITIVE_INFINITY}=s.content,o=n.filter(e=>"text"!==e);if(o.length<i||o.length>r)return!1;for(const a of o)if(!pt(e,t,a))return!1;return!0}function gt(e){e.registerNodeSpec({type:"paragraph",group:"block",content:{allow:["text"]},toDOM:e=>de("p",e.id),toHTML:(e,t)=>`<p>${t||"<br>"}</p>`,parseHTML:[{tag:"p"},{tag:"div",priority:10}],sanitize:{tags:["p"]}})}function mt(e,t,n){return{children:ft(e.children,t,n)}}function ft(e,t,n){return e.map(e=>{if(!w(e))return e;if(e.id===t)return n(e);const s=ft(e.children,t,n);return s===e.children?e:{...e,children:s}})}function yt(e,t,n){if(0===t.length)return e;const s=t[0];return s?{children:e.children.map(e=>w(e)&&e.id===s?1===t.length?n(e):kt(e,t,1,n):e)}:e}function kt(e,t,n,s){const i=t[n];if(!i)return e;const r=e.children.map(e=>w(e)&&e.id===i?n===t.length-1?s(e):kt(e,t,n+1,s):e);return{...e,children:r}}function St(e,t,n){if(t(e))return n(e);let s=!1;const i=e.map(e=>{if(!w(e))return e;const i=St(e.children,t,n);return i?(s=!0,{...e,children:i}):e});return s?i:null}function wt(e,t,n){const s=[];let r=0,o=!1;for(const a of e){if(i(a)){o||t!==r||(s.push(...n()),o=!0),s.push(a),r+=1;continue}const e=r+a.text.length;if(!o&&t>=r&&t<=e){const e=t-r,i=a.text.slice(0,e),c=a.text.slice(e);i&&s.push(m(i,a.marks)),s.push(...n()),c&&s.push(m(c,a.marks)),o=!0}else s.push(a);r=e}return o||s.push(...n()),s}function vt(e,t,n){const s=[];let r=0;for(const o of e){if(i(o)){const e=r+1;e>t&&r<n&&s.push(o),r=e;continue}const e=r+o.text.length;if(e<=t||r>=n);else{const e=Math.max(0,t-r),i=Math.min(o.text.length,n-r),a=o.text.slice(e,i);a.length>0&&s.push(m(a,o.marks))}r=e}return 0===s.length&&s.push(m("")),s}function bt(e,t,s,r,o){const a=[];let c=0;for(const l of e){if(i(l)){a.push(l),c+=1;continue}const e=c+l.text.length;if(e<=t||c>=s)a.push(l);else if(c>=t&&e<=s){const e=o?f(l.marks,r):n(l.marks,r.type);a.push(m(l.text,e))}else{const e=Math.max(0,t-c),i=Math.min(l.text.length,s-c),h=l.text.slice(0,e),d=l.text.slice(e,i),p=l.text.slice(i);if(h&&a.push(m(h,l.marks)),d){const e=o?f(l.marks,r):n(l.marks,r.type);a.push(m(d,e))}p&&a.push(m(p,l.marks))}c=e}return a}function Rt(e,n){if(e.every(e=>t(e)||i(e)))return n;const s=e.filter(e=>!t(e)&&!i(e));return[...n,...s]}function Ct(e,t){switch(t.type){case"insertText":return function(e,t){return It(e,t.blockId,e=>{return t.segments?(n=e,s=t.offset,i=t.segments,wt(n,s,()=>i.map(e=>m(e.text,e.marks)))):function(e,t,n,s){return wt(e,t,()=>[m(n,s)])}(e,t.offset,t.text,t.marks);var n,s,i})}(e,t);case"deleteText":return function(e,t){return It(e,t.blockId,e=>function(e,t,n){const s=[];let r=0;for(const o of e){if(i(o)){const e=r+1;(e<=t||r>=n)&&s.push(o),r=e;continue}const e=r+o.text.length;if(e<=t||r>=n)s.push(o);else{const e=Math.max(0,t-r),i=Math.min(o.text.length,n-r),a=o.text.slice(0,e)+o.text.slice(i);a.length>0&&s.push(m(a,o.marks))}r=e}return s}(e,t.from,t.to))}(e,t);case"splitBlock":return function(e,t){const n=St(e.children,e=>e.some(e=>w(e)&&e.id===t.blockId),e=>{const n=e.findIndex(e=>w(e)&&e.id===t.blockId);if(-1===n)return e;const s=e[n],i=c(s),r=o(s),a=vt(i,0,t.offset),l=vt(i,t.offset,r),h={...s,children:k(a)},d=g(s.type,k(l),t.newBlockId,s.attrs),p=[...e];return p.splice(n,1,h,d),p});return n?{children:n}:e}(e,t);case"mergeBlocks":return function(e,t){const n=St(e.children,e=>e.some(e=>w(e)&&e.id===t.targetBlockId)&&e.some(e=>w(e)&&e.id===t.sourceBlockId),e=>{const n=e.findIndex(e=>w(e)&&e.id===t.targetBlockId),s=e.findIndex(e=>w(e)&&e.id===t.sourceBlockId);if(-1===n||-1===s)return e;const i=e[n],r=e[s],o=c(i),a=c(r),l=k([...o,...a]),h={...i,children:l};return e.filter(e=>!w(e)||e.id!==t.sourceBlockId).map(e=>w(e)&&e.id===t.targetBlockId?h:e)});return n?{children:n}:e}(e,t);case"addMark":return function(e,t){return It(e,t.blockId,e=>bt(e,t.from,t.to,t.mark,!0))}(e,t);case"removeMark":return function(e,t){return It(e,t.blockId,e=>bt(e,t.from,t.to,t.mark,!1))}(e,t);case"setStoredMarks":return e;case"setBlockType":return function(e,t){return mt(e,t.blockId,e=>{const{attrs:n,...s}=e;return{...s,type:t.nodeType,...t.attrs?{attrs:t.attrs}:{}}})}(e,t);case"insertNode":return function(e,t){if(0===t.parentPath.length){const n=[...e.children];return n.splice(t.index,0,t.node),{children:n}}return yt(e,t.parentPath,e=>{const n=[...e.children];return n.splice(t.index,0,t.node),{...e,children:n}})}(e,t);case"removeNode":return function(e,t){if(0===t.parentPath.length){const n=[...e.children];return n.splice(t.index,1),{children:n}}return yt(e,t.parentPath,e=>{const n=[...e.children];return n.splice(t.index,1),{...e,children:n}})}(e,t);case"setNodeAttr":return function(e,t){const n=t.path[t.path.length-1];return n?mt(e,n,e=>({...e,attrs:t.attrs})):e}(e,t);case"insertInlineNode":return function(e,t){return It(e,t.blockId,e=>function(e,t,n){const s=[];let r=0,o=!1;for(const a of e){if(i(a)){o||t!==r||(s.push(n),o=!0),s.push(a),r+=1;continue}const e=r+a.text.length;if(!o&&t>=r&&t<=e){const e=t-r,i=a.text.slice(0,e),c=a.text.slice(e);i&&s.push(m(i,a.marks)),s.push(n),c&&s.push(m(c,a.marks)),o=!0}else s.push(a);r=e}return o||s.push(n),s}(e,t.offset,t.node))}(e,t);case"removeInlineNode":return function(e,t){return It(e,t.blockId,e=>function(e,t){const n=[];let s=0;for(const r of e)i(r)?(s!==t&&n.push(r),s+=1):(n.push(r),s+=r.text.length);return n}(e,t.offset))}(e,t);case"setInlineNodeAttr":return function(e,t){return It(e,t.blockId,e=>function(e,t,n){const s=[];let r=0;for(const o of e)i(o)?(r===t?s.push({...o,attrs:n}):s.push(o),r+=1):(s.push(o),r+=o.text.length);return s}(e,t.offset,t.attrs),!1)}(e,t)}}function It(e,t,n,s=!0){return mt(e,t,e=>{const t=n(c(e));return{...e,children:Rt(e.children,s?k(t):t)}})}function xt(e){return e.path?{path:e.path}:{}}function Tt(e){switch(e.type){case"insertText":return{type:"deleteText",blockId:e.blockId,from:e.offset,to:e.offset+e.text.length,deletedText:e.text,deletedMarks:e.marks,deletedSegments:e.segments??[{text:e.text,marks:[...e.marks]}],...xt(e)};case"deleteText":return{type:"insertText",blockId:e.blockId,offset:e.from,text:e.deletedText,marks:e.deletedMarks,segments:e.deletedSegments,...xt(e)};case"splitBlock":return{type:"mergeBlocks",targetBlockId:e.blockId,sourceBlockId:e.newBlockId,targetLengthBefore:e.offset,...xt(e)};case"mergeBlocks":return{type:"splitBlock",blockId:e.targetBlockId,offset:e.targetLengthBefore,newBlockId:e.sourceBlockId,...xt(e)};case"addMark":return{type:"removeMark",blockId:e.blockId,from:e.from,to:e.to,mark:e.mark,...xt(e)};case"removeMark":return{type:"addMark",blockId:e.blockId,from:e.from,to:e.to,mark:e.mark,...xt(e)};case"setStoredMarks":return{type:"setStoredMarks",marks:e.previousMarks,previousMarks:e.marks};case"setBlockType":return{type:"setBlockType",blockId:e.blockId,nodeType:e.previousNodeType,attrs:e.previousAttrs,previousNodeType:e.nodeType,previousAttrs:e.attrs,...xt(e)};case"insertNode":return{type:"removeNode",parentPath:e.parentPath,index:e.index,removedNode:e.node};case"removeNode":return{type:"insertNode",parentPath:e.parentPath,index:e.index,node:e.removedNode};case"setNodeAttr":return{type:"setNodeAttr",path:e.path,attrs:e.previousAttrs,previousAttrs:e.attrs};case"insertInlineNode":return{type:"removeInlineNode",blockId:e.blockId,offset:e.offset,removedNode:e.node,...xt(e)};case"removeInlineNode":return{type:"insertInlineNode",blockId:e.blockId,offset:e.offset,node:e.removedNode,...xt(e)};case"setInlineNodeAttr":return{type:"setInlineNodeAttr",blockId:e.blockId,offset:e.offset,attrs:e.previousAttrs,previousAttrs:e.attrs,...xt(e)}}}function Pt(e){for(const t of e.steps)if("setStoredMarks"===t.type)return t.previousMarks;return e.storedMarksAfter}function Et(e){return{steps:e.steps.map(Tt).reverse(),selectionBefore:e.selectionAfter,selectionAfter:e.selectionBefore,storedMarksAfter:Pt(e),metadata:{origin:"history",timestamp:Date.now()}}}var Mt=class{steps=[];selection;storedMarks;selectionBefore;origin;workingDoc;_readonlyAllowed=!1;constructor(e,t,n="api",s){this.selection=e,this.selectionBefore=e,this.storedMarks=t,this.origin=n,this.workingDoc=s??null}insertText(e,t,n,s,i){const r={type:"insertText",blockId:e,offset:t,text:n,marks:s,...i?{segments:i}:{}};return this.steps.push(r),this.advanceDoc(r),this}deleteText(e,t,n,s,i,r){let o;if(r)o=r;else if(this.workingDoc){const r=ye(this.workingDoc,e);o=r?u(r,t,n):[{text:s,marks:[...i]}]}else o=[{text:s,marks:[...i]}];const a={type:"deleteText",blockId:e,from:t,to:n,deletedText:s,deletedMarks:i,deletedSegments:o};return this.steps.push(a),this.advanceDoc(a),this}deleteTextAt(e,t,n){const s=this.requireDoc("deleteTextAt"),i=this.requireBlock(s,e),r=p(i).slice(t,n),o=a(i,t),c=u(i,t,n);return this.deleteText(e,t,n,r,o,c)}splitBlock(e,t,n){const s={type:"splitBlock",blockId:e,offset:t,newBlockId:n};return this.steps.push(s),this.advanceDoc(s),this}mergeBlocks(e,t,n){const s={type:"mergeBlocks",targetBlockId:e,sourceBlockId:t,targetLengthBefore:n};return this.steps.push(s),this.advanceDoc(s),this}mergeBlocksAt(e,t){const n=this.requireDoc("mergeBlocksAt"),s=o(this.requireBlock(n,e));return this.mergeBlocks(e,t,s)}addMark(e,t,n,s){const i={type:"addMark",blockId:e,from:t,to:n,mark:s};return this.steps.push(i),this.advanceDoc(i),this}removeMark(e,t,n,s){const i={type:"removeMark",blockId:e,from:t,to:n,mark:s};return this.steps.push(i),this.advanceDoc(i),this}setBlockType(e,t,n){const s=this.requireDoc("setBlockType"),i=this.requireBlock(s,e),r={type:"setBlockType",blockId:e,nodeType:t,...n?{attrs:n}:{},previousNodeType:i.type,...i.attrs?{previousAttrs:i.attrs}:{}};return this.steps.push(r),this.advanceDoc(r),this}insertNode(e,t,n){const s={type:"insertNode",parentPath:e,index:t,node:n};return this.steps.push(s),this.advanceDoc(s),this}removeNode(e,t){const n=function(e,t,n){if(0===t.length){const t=e.children[n];return t&&w(t)?t:void 0}const s=me(e,t);if(!s)return;const i=s.children[n];return i&&w(i)?i:void 0}(this.requireDoc("removeNode"),e,t);if(!n)throw new Error(`Node at index ${t} not found under parent path [${e.join(", ")}].`);const s={type:"removeNode",parentPath:e,index:t,removedNode:n};return this.steps.push(s),this.advanceDoc(s),this}setNodeAttr(e,t){const n=me(this.requireDoc("setNodeAttr"),e);if(!n)throw new Error(`Node not found at path [${e.join(", ")}].`);const s={type:"setNodeAttr",path:e,attrs:t,...n.attrs?{previousAttrs:n.attrs}:{}};return this.steps.push(s),this.advanceDoc(s),this}insertInlineNode(e,t,n){const s={type:"insertInlineNode",blockId:e,offset:t,node:n};return this.steps.push(s),this.advanceDoc(s),this}removeInlineNode(e,t){const n=this.requireDoc("removeInlineNode"),s=l(this.requireBlock(n,e),t);if(!s||"inline"!==s.kind)throw new Error(`No InlineNode at offset ${t} in block "${e}".`);const i={type:"removeInlineNode",blockId:e,offset:t,removedNode:s.node};return this.steps.push(i),this.advanceDoc(i),this}setInlineNodeAttr(e,t,n){const s=this.requireDoc("setInlineNodeAttr"),r=c(this.requireBlock(s,e));let o=0;for(const a of r){if(i(a)&&o===t){const s={type:"setInlineNodeAttr",blockId:e,offset:t,attrs:n,previousAttrs:a.attrs};return this.steps.push(s),this.advanceDoc(s),this}o+=i(a)?1:a.text.length}throw new Error(`No InlineNode at offset ${t} in block "${e}".`)}readonlyAllowed(){return this._readonlyAllowed=!0,this}setSelection(e){return this.selection=e,this}setNodeSelection(e,t){return this.selection=F(e,t),this}setStoredMarks(e,t){return this.steps.push({type:"setStoredMarks",marks:e,previousMarks:t}),this.storedMarks=e,this}build(){return{steps:[...this.steps],selectionBefore:this.selectionBefore,selectionAfter:this.selection,storedMarksAfter:this.storedMarks,metadata:{origin:this.origin,timestamp:Date.now(),...this._readonlyAllowed?{readonlyAllowed:!0}:{}}}}requireDoc(e){if(!this.workingDoc)throw new Error(`${e} requires a document. Use state.transaction() or provide doc to constructor.`);return this.workingDoc}requireBlock(e,t){const n=ye(e,t);if(!n)throw new Error(`Block "${t}" not found in working document.`);return n}advanceDoc(e){this.workingDoc&&(this.workingDoc=Ct(this.workingDoc,e))}},At=class e{doc;selection;storedMarks;schema;_blockMap=null;_blockOrder=null;constructor(e,t,n,s){this.doc=e,this.selection=t,this.storedMarks=n,this.schema=s}static create(t){const n=t?.schema??oe(),s=t?.doc??h(),i=Ot(s.children);return new e(s,t?.selection??K(i?i.id:he(""),0),null,n)}transaction(e="api"){return new Mt(this.selection,this.storedMarks,e,this.doc)}apply(t){let n=this.doc;for(const e of t.steps)n=Ct(n,e);const s=function(e,t){if(z(t))return ye(e,t.nodeId)?t:Bt(e,t);if(O(t))return ye(e,t.blockId)?t:Bt(e,t);const n=Nt(e,t.anchor),s=Nt(e,t.head);return n===t.anchor&&s===t.head?t:B(n,s)}(n,t.selectionAfter);return new e(n,s,t.storedMarksAfter,this.schema)}getBlock(e){return this._blockMap??=function(e){const t=/* @__PURE__ */new Map;return function e(n){for(const s of n)w(s)&&(t.set(s.id,s),e(s.children))}(e.children),t}(this.doc),this._blockMap.get(e)}getBlockOrder(){return this._blockOrder??=function(e){const t=[];return function e(n){for(const s of n)w(s)&&(S(s)?t.push(s.id):e(s.children))}(e.children),t}(this.doc),this._blockOrder}getNodePath(e){return fe(this.doc,e)}getParent(e){const t=fe(this.doc,e);if(!t||t.length<=1)return;const n=t[t.length-2];return n?ye(this.doc,n):void 0}toJSON(){return{doc:this.doc,selection:this.selection}}static fromJSON(t,n){return new e(t.doc,t.selection,null,n??oe())}};function Nt(e,t){const n=ye(e,t.blockId);if(n){const e=o(n);return t.offset>e?H(t.blockId,e,t.path):t}const s=e.children[0];return s?H(s.id,0):t}function Bt(e,t){const n=Ot(e.children);return n?K(n.id,0):t}function Ot(e){for(const t of e){if(!w(t))continue;if(S(t))return t;const e=Ot(t.children);if(e)return e}return null}function Dt(e){for(const t of e.steps)if("setStoredMarks"!==t.type)return!1;return!0}function Lt(e){return!!e.metadata.readonlyAllowed||Dt(e)}var Ht=class{undoStack=[];redoStack=[];groupTimeoutMs;maxDepth;lastOrigin=null;constructor(e){this.groupTimeoutMs=e?.groupTimeoutMs??500,this.maxDepth=e?.maxDepth??100}push(e){if("history"===e.metadata.origin)return;if(!e.steps.some(e=>"setStoredMarks"!==e.type))return void(this.lastOrigin=null);const t=e.metadata.timestamp,n=this.undoStack[this.undoStack.length-1];for(n&&"input"===e.metadata.origin&&"input"===this.lastOrigin&&t-n.timestamp<this.groupTimeoutMs&&this.isSameInputType(n.transactions,e)&&n?this.undoStack[this.undoStack.length-1]={transactions:[...n.transactions,e],timestamp:t}:this.undoStack.push({transactions:[e],timestamp:t}),this.lastOrigin=e.metadata.origin,this.redoStack=[];this.undoStack.length>this.maxDepth;)this.undoStack.shift()}undo(e){const t=this.undoStack.pop();if(!t)return null;let n=e;const s=[];for(let i=t.transactions.length-1;i>=0;i--){const e=t.transactions[i];if(!e)continue;const r=Et(e);n=n.apply(r),s.push(...r.steps)}return this.redoStack.push({transactions:t.transactions,timestamp:Date.now()}),this.lastOrigin=null,{state:n,transaction:{steps:s,selectionBefore:e.selection,selectionAfter:n.selection,storedMarksAfter:n.storedMarks,metadata:{origin:"history",timestamp:Date.now(),historyDirection:"undo"}}}}redo(e){const t=this.redoStack.pop();if(!t)return null;let n=e;const s=[];for(const i of t.transactions)n=n.apply(i),s.push(...i.steps);return this.undoStack.push({transactions:t.transactions,timestamp:Date.now()}),this.lastOrigin=null,{state:n,transaction:{steps:s,selectionBefore:e.selection,selectionAfter:n.selection,storedMarksAfter:n.storedMarks,metadata:{origin:"history",timestamp:Date.now(),historyDirection:"redo"}}}}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[],this.lastOrigin=null}isSameInputType(e,t){const n=e[e.length-1];return!!n&&n.steps[0]?.type===t.steps[0]?.type}},zt=class{getState;dispatch;undo;redo;keymapRegistry;isReadOnly;compositionTracker;getTextDirectionFn;navigateFromGapCursorFn;handleKeydown;constructor(e,t){this.element=e,this.getState=t.getState,this.dispatch=t.dispatch,this.undo=t.undo,this.redo=t.redo,this.keymapRegistry=t.keymapRegistry,this.isReadOnly=t.isReadOnly??(()=>!1),this.compositionTracker=t.compositionTracker,this.getTextDirectionFn=t.getTextDirection??(()=>"ltr"),this.navigateFromGapCursorFn=t.navigateFromGapCursor,this.handleKeydown=this.onKeydown.bind(this),e.addEventListener("keydown",this.handleKeydown)}onKeydown(e){if(this.compositionTracker?.isComposing)return;if(this.handleNodeSelectionKeys(e))return;if(this.handleGapCursorKeys(e))return;if(this.isReadOnly()){if(this.keymapRegistry){const t=_t(e),n=this.keymapRegistry.getKeymapsByPriority().navigation;for(let s=n.length-1;s>=0;s--){const i=n[s]?.[t];if(i?.())return void e.preventDefault()}}return void this.handleEscape(e)}if(this.keymapRegistry){const t=_t(e),n=this.keymapRegistry.getKeymapsByPriority();for(const s of[n.context,n.navigation,n.default])for(let n=s.length-1;n>=0;n--){const i=s[n]?.[t];if(i?.())return void e.preventDefault()}}if(this.handleGapCursorArrowFallback(e))return;if(this.handleTab(e))return;if(this.handleEscape(e))return;if(!e.metaKey&&!e.ctrlKey)return;const t=e.key.toLowerCase(),n=this.getState();let s=null;return"z"!==t||e.shiftKey?"z"===t&&e.shiftKey||"y"===t&&!e.shiftKey?(e.preventDefault(),void this.redo()):("a"!==t||e.shiftKey||(e.preventDefault(),s=Z(n)),void(s&&this.dispatch(s))):(e.preventDefault(),void this.undo())}handleNodeSelectionKeys(e){const t=this.getState(),n=t.selection;if(!z(n))return!1;const s=e.key;if(!("ArrowLeft"!==s&&"ArrowUp"!==s&&"ArrowRight"!==s&&"ArrowDown"!==s||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)){const i=Ce(t,"ArrowLeft"===s?"left":"ArrowRight"===s?"right":"ArrowUp"===s?"up":"down",this.isSelectedBlockRtl(n.nodeId));return!!i&&(e.preventDefault(),this.dispatch(i),!0)}if("Backspace"===s||"Delete"===s){if(this.isReadOnly())return e.preventDefault(),!0;e.preventDefault();const s=Ie(t,n);return s&&this.dispatch(s),!0}if("Enter"===s){if(this.isReadOnly())return e.preventDefault(),!0;e.preventDefault();const n=ne(t);return n&&this.dispatch(n),!0}if("Escape"===s){e.preventDefault();const n=Ce(t,"right");return n&&this.dispatch(n),!0}return!1}handleGapCursorKeys(e){const t=this.getState(),n=t.selection;if(!O(n))return!1;const s=e.key;if("ArrowLeft"===s||"ArrowRight"===s||"ArrowUp"===s||"ArrowDown"===s)return!1;if("Escape"===s||"Tab"===s)return!1;if(e.ctrlKey||e.metaKey||e.altKey)return!1;if("Enter"===s){if(this.isReadOnly())return e.preventDefault(),!0;e.preventDefault();const n=ne(t);return n&&this.dispatch(n),!0}if("Backspace"===s){if(this.isReadOnly())return e.preventDefault(),!0;e.preventDefault();const s=ae(t,n);return s&&this.dispatch(s),!0}if("Delete"===s){if(this.isReadOnly())return e.preventDefault(),!0;e.preventDefault();const s=U(t,n);return s&&this.dispatch(s),!0}if(1===s.length){if(this.isReadOnly())return e.preventDefault(),!0;e.preventDefault();const n=Q(t,s);return this.dispatch(n),!0}return!1}handleGapCursorArrowFallback(e){const t=this.getState(),n=t.selection;if(!O(n))return!1;const s=e.key;if("ArrowLeft"!==s&&"ArrowRight"!==s&&"ArrowUp"!==s&&"ArrowDown"!==s)return!1;const i="ArrowLeft"===s?"left":"ArrowRight"===s?"right":"ArrowUp"===s?"up":"down";if(!this.navigateFromGapCursorFn)return!1;const r=this.navigateFromGapCursorFn(t,i,this.element);return!(!r||L(r.selectionAfter,n)||(e.preventDefault(),this.dispatch(r),0))}handleTab(e){if("Tab"!==e.key)return!1;if(e.metaKey||e.ctrlKey||e.altKey)return!1;if(e.preventDefault(),e.shiftKey)return!0;const t=Q(this.getState(),"\t");return this.dispatch(t),!0}handleEscape(e){return"Escape"===e.key&&(this.element.blur(),!0)}isSelectedBlockRtl(e){const t=this.element.querySelector(`[data-block-id="${e}"]`);return t instanceof HTMLElement&&"rtl"===this.getTextDirectionFn(t)}destroy(){this.element.removeEventListener("keydown",this.handleKeydown)}};function _t(e){const t=[];(e.metaKey||e.ctrlKey)&&t.push("Mod"),e.shiftKey&&t.push("Shift"),e.altKey&&t.push("Alt");let n=e.key;return" "===n?n="Space":1===n.length&&(n=n.toUpperCase()),t.push(n),t.join("-")}function Ft(e,t){if(S(e))return t.selectedLeafIds.has(e.id)?function(e,t){const n=o(e),s=e.id===t.firstBlockId?t.firstOffset:0,i=e.id===t.lastBlockId?t.lastOffset:n;if(0===s&&i===n)return e;const r=k(y(e,s,i).map(e=>"inline"===e.kind?e.node:m(e.text,e.marks)));return{...e,children:r}}(e,t):null;const n=d(e),s=[];let i=n.length!==e.children.length;for(const r of n){const e=Ft(r,t);e?(s.push(e),e!==r&&(i=!0)):i=!0}return 0===s.length?null:i?{...e,children:s}:e}var Kt=class{getState;dispatch;schemaRegistry;syncSelection;isReadOnly;handleCopy;handleCut;constructor(e,t){this.element=e,this.getState=t.getState,this.dispatch=t.dispatch,this.schemaRegistry=t.schemaRegistry,this.syncSelection=t.syncSelection,this.isReadOnly=t.isReadOnly??(()=>!1),this.handleCopy=this.onCopy.bind(this),this.handleCut=this.onCut.bind(this),e.addEventListener("copy",this.handleCopy),e.addEventListener("cut",this.handleCut)}onCopy(e){this.syncSelection?.();const t=this.getState(),n=t.selection;if(O(n))return;if(V(n)&&_(n))return;e.preventDefault();const s=e.clipboardData;s&&(z(n)?this.writeNodeSelectionToClipboard(s,t):this.writeTextSelectionToClipboard(s,t))}onCut(e){if(this.isReadOnly())return;this.syncSelection?.();const t=this.getState(),n=t.selection;if(O(n))return;if(V(n)&&_(n))return;e.preventDefault();const s=e.clipboardData;if(s)if(z(n)){this.writeNodeSelectionToClipboard(s,t);const e=Ie(t,n);e&&this.dispatch(e)}else{this.writeTextSelectionToClipboard(s,t);const e=Y(t);e&&this.dispatch(e)}}writeNodeSelectionToClipboard(e,t){const n=t.selection;if(!z(n))return;const s=t.getBlock(n.nodeId);if(!s)return;const i={type:s.type,...s.attrs?{attrs:{...s.attrs}}:{}};e.setData("application/x-notectl-block",JSON.stringify(i));const r=this.schemaRegistry?.getNodeSpec(s.type);r?.toHTML&&e.setData("text/html",r.toHTML(s,""));const o=s.attrs,a="string"==typeof o?.alt?o.alt:"";e.setData("text/plain",a)}writeTextSelectionToClipboard(e,t){const n=t.selection;if(z(n))return;if(O(n))return;if(_(n))return;if(this.selectionRequiresDocumentSerializer(t))return void this.writeCompositeSelectionToClipboard(e,t);const s=t.getBlockOrder(),i=D(n,s),r=s.indexOf(i.from.blockId),a=s.indexOf(i.to.blockId),c=[],l=[],h=[];for(let p=r;p<=a;p++){const e=s[p];if(!e)continue;const n=t.getBlock(e);if(!n)continue;const d=o(n),u=p===r?i.from.offset:0,g=p===a?i.to.offset:d,m=this.extractSegmentsForRange(n,u,g),f=this.plainTextFromSegments(m);c.push(f),h.push({block:n,start:u,end:g}),l.push({type:n.type,text:f,...n.attrs?{attrs:{...n.attrs}}:{},...m.length>0?{segments:m}:{}})}const d=c.join("\n");if(e.setData("text/plain",d),this.schemaRegistry){const n=Ee(this.schemaRegistry),o=r!==a,c=l.some(e=>void 0!==e.type&&"paragraph"!==e.type);if(o||this.containsInlineSegments(l)||c){const t=this.serializeBlocksToClipboardHTML(h,n,l);e.setData("text/html",t)}else{const o=s[r],a=o?t.getBlock(o):void 0;if(a){const t=this.serializeBlockRangeToHTML(a,i.from.offset,i.to.offset,n);e.setData("text/html",t)}}}}selectionRequiresDocumentSerializer(e){const t=this.getTextSelection(e);if(!t||_(t))return!1;const n=D(t,e.getBlockOrder()),s=fe(e.doc,n.from.blockId),i=fe(e.doc,n.to.blockId);if(!s||!i)return!1;if(s[0]===i[0]){const t=e.doc.children.find(e=>e.id===s[0]);return!(!t||S(t))}const r=e.doc.children.findIndex(e=>e.id===s[0]),o=e.doc.children.findIndex(e=>e.id===i[0]);for(let a=r;a<=o;a++){const t=e.doc.children[a];if(t){if(!S(t))return!0;if((this.schemaRegistry?.getNodeSpec(t.type))?.isVoid)return!0}}return!1}getTextSelection(e){const t=e.selection;if(V(t))return t}extractPlainTextForRange(e,t,n){return this.plainTextFromSegments(this.extractSegmentsForRange(e,t,n))}plainTextFromSegments(e){return e.map(e=>"inline"===e.kind?"":e.text).join("")}writeCompositeSelectionToClipboard(e,t){const n=this.getTextSelection(t);if(!n)return;const s=t.getBlockOrder(),i=D(n,s),r=s.indexOf(i.from.blockId),a=s.indexOf(i.to.blockId),c=[];for(let l=r;l<=a;l++){const e=s[l];if(!e)continue;const n=t.getBlock(e);if(!n)continue;const h=l===r?i.from.offset:0,d=l===a?i.to.offset:o(n);c.push(this.extractPlainTextForRange(n,h,d))}if(e.setData("text/plain",c.join("\n")),this.schemaRegistry){const s=function(e,t){const n=e.getBlockOrder(),s=D(t,n),i=n.indexOf(s.from.blockId),r=n.indexOf(s.to.blockId);if(-1===i||-1===r||i>r)return{children:[]};const o=e.getNodePath(s.from.blockId),a=e.getNodePath(s.to.blockId),c=o?.[0],l=a?.[0];if(!c||!l)return{children:[]};const h=e.doc.children.findIndex(e=>e.id===c),d=e.doc.children.findIndex(e=>e.id===l);if(-1===h||-1===d||h>d)return{children:[]};const p={firstBlockId:s.from.blockId,firstOffset:s.from.offset,lastBlockId:s.to.blockId,lastOffset:s.to.offset,selectedLeafIds:new Set(n.slice(i,r+1))},u=[];for(let g=h;g<=d;g++){const t=e.doc.children[g];if(!t)continue;const n=Ft(t,p);n&&u.push(n)}return{children:u}}(t,n);if(s.children.length>0){const t=Te(s,this.schemaRegistry);e.setData("text/html",t)}}}serializeBlockRangeToHTML(e,n,s,r){const o=c(e),a=[];let l=0;for(const c of o){const e=l+(i(c)?1:c.text.length);if(e<=n||l>=s)l=e;else{if(t(c)){const e=Math.max(0,n-l),t=Math.min(c.text.length,s-l),i=c.text.slice(e,t);i.length>0&&this.schemaRegistry&&a.push(Me(i,c.marks,this.schemaRegistry,r))}else if(i(c)){const e=this.schemaRegistry?.getInlineNodeSpec(c.inlineType);e?.toHTMLString&&a.push(e.toHTMLString(c))}l=e}}return a.join("")}extractSegmentsForRange(e,n,s){const r=c(e),o=[];let a=0;for(const c of r){const e=a+(i(c)?1:c.text.length);if(e<=n||a>=s)a=e;else{if(t(c)){const e=Math.max(0,n-a),t=Math.min(c.text.length,s-a),i=c.text.slice(e,t);if(i.length>0){const e=c.marks.map(e=>({type:e.type,...e.attrs?{attrs:{...e.attrs}}:{}}));o.push({text:i,marks:e})}}else i(c)&&o.push({kind:"inline",inlineType:c.inlineType,...Object.keys(c.attrs).length>0?{attrs:{...c.attrs}}:{}});a=e}}return o}containsInlineSegments(e){return e.some(e=>e.segments?.some(e=>"inline"===e.kind))}serializeBlocksToClipboardHTML(e,t,n){const s=[];let i,r=[];const o=()=>{r.length>0&&i&&(s.push(`<${i}>${r.join("")}</${i}>`),r=[],i=void 0)};for(const c of e){const{block:e,start:n,end:a}=c,l=this.serializeBlockRangeToHTML(e,n,a,t),h=this.schemaRegistry?.getNodeSpec(e.type);if(h?.wrapper){const t=h.wrapper(e).tag;i!==t&&(o(),i=t),h.toHTML?r.push(h.toHTML(e,l)):r.push(`<li>${l}</li>`)}else o(),h?.toHTML?s.push(h.toHTML(e,l)):s.push(`<p>${l}</p>`)}o();const a=JSON.stringify(n).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""");return s.push(`<span data-notectl-rich="${a}" hidden></span>`),s.join("")}destroy(){this.element.removeEventListener("copy",this.handleCopy),this.element.removeEventListener("cut",this.handleCut)}},Vt=class{_composing=!1;_activeBlockId=null;get isComposing(){return this._composing}get activeBlockId(){return this._activeBlockId}start(e){this._composing=!0,this._activeBlockId=e}end(){this._composing=!1,this._activeBlockId=null}},$t=class{getState;dispatch;syncSelection;inputRuleRegistry;isReadOnly;compositionTracker;compositionCommitHandled=!1;handleBeforeInput;handleCompositionStart;handleCompositionEnd;constructor(e,t){this.element=e,this.getState=t.getState,this.dispatch=t.dispatch,this.syncSelection=t.syncSelection,this.inputRuleRegistry=t.inputRuleRegistry,this.isReadOnly=t.isReadOnly??(()=>!1),this.compositionTracker=t.compositionTracker??new Vt,this.handleBeforeInput=this.onBeforeInput.bind(this),this.handleCompositionStart=this.onCompositionStart.bind(this),this.handleCompositionEnd=this.onCompositionEnd.bind(this),e.addEventListener("beforeinput",this.handleBeforeInput),e.addEventListener("compositionstart",this.handleCompositionStart),e.addEventListener("compositionend",this.handleCompositionEnd)}onBeforeInput(e){if(this.isReadOnly())return;if(this.compositionTracker.isComposing&&"insertCompositionText"===e.inputType)return;if(!function(e){switch(e){case"insertText":case"insertReplacementText":case"insertFromComposition":case"insertParagraph":case"insertLineBreak":case"deleteContentBackward":case"deleteContentForward":case"deleteWordBackward":case"deleteWordForward":case"deleteSoftLineBackward":case"deleteSoftLineForward":case"deleteByCut":case"insertFromPaste":case"insertFromDrop":case"formatBold":case"formatItalic":case"formatUnderline":case"historyUndo":case"historyRedo":return!0;default:return!1}}(e.inputType))return;"insertText"!==e.inputType&&"insertCompositionText"!==e.inputType&&"insertFromComposition"!==e.inputType&&this.syncSelection(),e.preventDefault();const t=this.getState();let n=null;switch(e.inputType){case"insertText":case"insertReplacementText":e.data&&(n=Q(t,e.data,"input"));break;case"insertFromComposition":e.data&&(this.compositionCommitHandled=!0,n=Q(t,e.data,"input"));break;case"insertParagraph":n=ne(t);break;case"insertLineBreak":n=te(t);break;case"deleteContentBackward":n=q(t);break;case"deleteContentForward":n=J(t);break;case"deleteWordBackward":n=G(t);break;case"deleteWordForward":n=ee(t);break;case"deleteSoftLineBackward":n=ie(t);break;case"deleteSoftLineForward":n=W(t)}n&&(this.dispatch(n),"insertText"!==e.inputType&&"insertReplacementText"!==e.inputType||this.checkInputRules())}onCompositionStart(e){const t=this.getState();V(t.selection)&&(this.compositionCommitHandled=!1,this.compositionTracker.start(t.selection.anchor.blockId))}onCompositionEnd(e){if(this.compositionTracker.end(),this.isReadOnly())return;if(this.compositionCommitHandled)return void(this.compositionCommitHandled=!1);const t=e.data;if(!t)return;const n=Q(this.getState(),t,"input");this.dispatch(n)}checkInputRules(){if(!this.inputRuleRegistry)return;const e=this.inputRuleRegistry.getInputRules();if(0===e.length)return;const t=this.getState();if(!V(t.selection))return;const{anchor:n}=t.selection,s=t.getBlock(n.blockId);if(!s)return;const i=p(s).slice(0,n.offset);for(const r of e){const e=r.pattern.exec(i);if(e){const n=e.index,s=n+e[0].length,i=r.handler(t,e,n,s);if(i)return void this.dispatch(i)}}}destroy(){this.element.removeEventListener("beforeinput",this.handleBeforeInput),this.element.removeEventListener("compositionstart",this.handleCompositionStart),this.element.removeEventListener("compositionend",this.handleCompositionEnd)}};function jt(e){return e.reduce((e,t)=>e+t.text,"")}function Ut(e){return e.reduce((e,t)=>e+t.text.length,0)}function qt(e,t){if(0===t.blocks.length)return e.transaction("paste").setSelection(e.selection).build();const n=t.blocks[0];return n?1===t.blocks.length&&n.type===ce("paragraph")?function(e,t){const n=e.selection;if(z(n))return e.transaction("paste").setSelection(n).build();if(O(n))return function(e,t,n){const s=Wt(e,t);if(!s)return e.transaction("paste").setSelection(t).build();const i=r(),o=jt(n),a=Ut(n),c=e.transaction("paste");return c.insertNode(s.parentPath,s.insertIndex,g(ce("paragraph"),[m("")],i)),o.length>0&&c.insertText(i,0,o,[],n),c.setSelection(K(i,a)),c.build()}(e,n,t);const s=e.transaction("paste");_(n)||se(e,s);const{blockId:i,offset:o}=Re(n,e.getBlockOrder()),a=Ut(t),c=jt(t);return s.insertText(i,o,c,[],t),s.setSelection(K(i,o+a)),s.build()}(e,n.segments):1===t.blocks.length?function(e,t){const n=e.selection;if(z(n))return e.transaction("paste").setSelection(n).build();if(O(n))return Gt(e,n,[t]);const s=e.transaction("paste");_(n)||se(e,s);const{blockId:i,offset:r}=Re(n,e.getBlockOrder()),o=Ut(t.segments),a=jt(t.segments);return s.setBlockType(i,t.type,t.attrs),s.insertText(i,r,a,[],t.segments),s.setSelection(K(i,r+o)),s.build()}(e,n):function(e,t){const n=e.selection;if(z(n))return e.transaction("paste").setSelection(n).build();if(O(n))return Gt(e,n,t.blocks);const s=e.transaction("paste");_(n)||se(e,s);const i=e.getBlockOrder(),{blockId:o,offset:a}=Re(n,i),c=i.indexOf(o),l=t.blocks[0],h=t.blocks[t.blocks.length-1];if(!l||!h)return s.build();const d=t.blocks.slice(1,-1),p=Ut(l.segments);l.segments.length>0&&p>0&&s.insertText(o,a,jt(l.segments),[],l.segments),l.type!==ce("paragraph")&&s.setBlockType(o,l.type,l.attrs);const u=a+p,f=r();s.splitBlock(o,u,f);let y=c+1;for(const S of d){const e=S.segments.map(e=>m(e.text,[...e.marks])),t=g(S.type,e.length>0?e:void 0,r(),S.attrs);s.insertNode([],y,t),y++}const k=Ut(h.segments);return h.segments.length>0&&k>0&&s.insertText(f,0,jt(h.segments),[],h.segments),h.type!==ce("paragraph")&&s.setBlockType(f,h.type,h.attrs),s.setSelection(K(f,k)),s.build()}(e,t):e.transaction("paste").setSelection(e.selection).build()}function Wt(e,t){const n=fe(e.doc,t.blockId);if(!n)return null;const s=ve(n),i=Se(be(e,s),t.blockId);return i<0?null:{parentPath:s,insertIndex:"before"===t.side?i:i+1}}function Gt(e,t,n){const s=Wt(e,t);if(!s)return e.transaction("paste").setSelection(t).build();const i=e.transaction("paste");let o,a=s.insertIndex,c=0;for(const l of n){const e=r(),t=jt(l.segments),n=l.segments.map(e=>m(e.text,[...e.marks])),h=g(l.type,n.length>0?n:[m("")],e,l.attrs);i.insertNode(s.parentPath,a,h),a++,o=e,c=t.length}return o&&i.setSelection(K(o,c)),i.build()}var Qt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","UL","OL","LI","HR","PRE","TABLE","THEAD","TBODY","TR"]),Jt=new Set(["STRONG","B","EM","I","U","S","STRIKE","DEL","A","SPAN","BR","SUB","SUP","CODE"]),Xt=/^H([1-6])$/;function Yt(e){const t=e.style.fontWeight,n=Number.parseInt(t,10);return!("normal"===t||!Number.isNaN(n)&&n<700)&&{}}var Zt=new Map([["STRONG",{markName:"bold",getAttrs:Yt}],["B",{markName:"bold",getAttrs:Yt}],["EM",{markName:"italic"}],["I",{markName:"italic"}],["U",{markName:"underline"}],["S",{markName:"strikethrough"}],["STRIKE",{markName:"strikethrough"}],["DEL",{markName:"strikethrough"}],["A",{markName:"link",getAttrs:function(e){return{href:e.getAttribute("href")??""}}}]]),en=class{schema;blockParseRules;markParseRules;blockTagHandlers;constructor(e){this.schema=e.schema,this.blockParseRules=e.schemaRegistry?.getBlockParseRules()??[],this.markParseRules=e.schemaRegistry?.getMarkParseRules()??[],this.blockTagHandlers=this.buildBlockTagHandlers()}parse(e){const t=this.parseContainer(e);return 0===t.length?{blocks:[{type:this.resolveBlockType(ce("paragraph")),segments:[{text:"",marks:[]}]}]}:{blocks:t}}buildBlockTagHandlers(){const e=e=>this.parseBlockWithLineBreaks(e,this.resolveBlockType(ce("paragraph"))),t=e=>this.parseTableAsParagraphs(e);return new Map([["P",e],["DIV",e],["BLOCKQUOTE",e=>this.parseBlockquote(e)],["UL",e=>this.parseList(e,"bullet",0)],["OL",e=>this.parseList(e,"ordered",0)],["LI",e=>this.parseListItem(e,"bullet",0)],["HR",()=>[{type:this.resolveBlockType(ce("horizontal_rule")),segments:[]}]],["PRE",e=>[{type:this.resolveBlockType(ce("paragraph")),segments:this.ensureSegments(this.parsePreContent(e))}]],["TABLE",t],["THEAD",t],["TBODY",t],["TR",t]])}parseContainer(e){const t=[];let n=[];for(const s of Array.from(e.childNodes))if(s.nodeType===Node.ELEMENT_NODE){const e=s;this.isBlockElement(e)?(this.flushPendingSegments(t,n),n=[],t.push(...this.parseBlockElement(e))):e.children.length>0&&this.containsBlockDescendants(e)?(this.flushPendingSegments(t,n),n=[],t.push(...this.parseContainerWithMarks(e,this.marksFromElement(e)))):n.push(...this.parseInlineNode(s,[]))}else if(s.nodeType===Node.TEXT_NODE){const e=s.textContent??"";e&&n.push({text:e,marks:[]})}return this.flushPendingSegments(t,n),t}parseBlockElement(e){const t=Xt.exec(e.tagName);if(t)return this.parseHeading(e,Number(t[1]));const n=this.blockTagHandlers.get(e.tagName);return n?n(e):this.parseUnknownBlock(e)}parseHeading(e,t){const n=this.resolveBlockType(ce("heading"));return[{type:n,...n===ce("heading")?{attrs:{level:t}}:{},segments:this.ensureSegments(this.parseInlineChildren(e,[]))}]}parseUnknownBlock(e){const t=this.matchBlockRule(e);return t?[{type:t.type,...t.attrs?{attrs:t.attrs}:{},segments:this.ensureSegments(this.parseInlineChildren(e,[]))}]:[{type:this.resolveBlockType(ce("paragraph")),segments:this.ensureSegments(this.parseInlineChildren(e,[]))}]}parseBlockquote(e){const t=this.resolveBlockType(ce("blockquote"));return Array.from(e.childNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&this.isBlockElement(e))?this.parseContainer(e).map(e=>({type:t,segments:e.segments})):[{type:t,segments:this.ensureSegments(this.parseInlineChildren(e,[]))}]}parseList(e,t,n){const s=[];for(const i of Array.from(e.children)){const e=i;"LI"===e.tagName?s.push(...this.parseListItem(e,t,n)):"UL"===e.tagName?s.push(...this.parseList(e,"bullet",n+1)):"OL"===e.tagName&&s.push(...this.parseList(e,"ordered",n+1))}return s}parseListItem(e,t,n){const s=[],i=this.resolveBlockType(ce("list_item")),r=this.hasCheckbox(e),o=r?"checklist":t,a=!!r&&this.isCheckboxChecked(e),c=[],l=[];for(const h of Array.from(e.childNodes))if(h.nodeType===Node.ELEMENT_NODE){const e=h;"UL"===e.tagName||"OL"===e.tagName?l.push(e):"INPUT"===e.tagName&&"checkbox"===e.getAttribute("type")||(this.isBlockElement(e)?c.push(...this.parseInlineChildren(e,[])):c.push(...this.parseInlineNode(h,[])))}else if(h.nodeType===Node.TEXT_NODE){const e=h.textContent??"";e&&c.push({text:e,marks:[]})}s.push({type:i,attrs:{listType:o,indent:n,..."checklist"===o?{checked:a}:{}},segments:this.ensureSegments(this.normalizeSegments(c))});for(const h of l){const e="OL"===h.tagName?"ordered":"bullet";s.push(...this.parseList(h,e,n+1))}return s}parseInlineChildren(e,t){const n=[];for(const s of Array.from(e.childNodes))n.push(...this.parseInlineNode(s,t));return this.normalizeSegments(n)}parseInlineNode(e,t){if(e.nodeType===Node.TEXT_NODE){const n=e.textContent??"";return n?[{text:n,marks:this.resolveMarks(t)}]:[]}if(e.nodeType!==Node.ELEMENT_NODE)return[];const n=e,s=n.tagName;if("BR"===s)return[{text:"\n",marks:this.resolveMarks(t)}];if(this.isBlockElement(n)&&!Jt.has(s))return this.parseInlineChildren(n,t);const i=this.mergeMarks(t,this.marksFromElement(n));return this.parseInlineChildren(n,i)}parsePreContent(e){const t=e.textContent??"";return t?[{text:t,marks:[]}]:[]}parseTableAsParagraphs(e){const t=[],n=e.querySelectorAll("td, th");for(const s of Array.from(n)){const e=this.parseInlineChildren(s,[]);e.length>0&&e.some(e=>e.text.length>0)&&t.push({type:this.resolveBlockType(ce("paragraph")),segments:this.ensureSegments(e)})}return t}marksFromElement(e){return this.matchMarkRules(e)||this.fallbackMarksFromElement(e)}matchMarkRules(e){if(0===this.markParseRules.length)return null;const t=e.tagName.toLowerCase(),n=[],s=/* @__PURE__ */new Set;for(const i of this.markParseRules)if(i.rule.tag===t&&!s.has(i.type)){if(i.rule.getAttrs){const t=i.rule.getAttrs(e);if(!1===t)continue;n.push({type:le(i.type),...Object.keys(t).length>0?{attrs:t}:{}})}else n.push({type:le(i.type)});s.add(i.type)}return s.size>0?n:null}fallbackMarksFromElement(e){const t=Zt.get(e.tagName);if(!t)return[];if(t.getAttrs){const n=t.getAttrs(e);return!1===n?[]:Object.keys(n).length>0?[{type:le(t.markName),attrs:n}]:[{type:le(t.markName)}]}return[{type:le(t.markName)}]}mergeMarks(e,t){const n=[...e];for(const s of t)n.some(e=>e.type===s.type)||n.push(s);return n}resolveMarks(e){return e.filter(e=>j(this.schema,e.type))}resolveBlockType(e){return $(this.schema,e)?e:ce("paragraph")}normalizeSegments(t){if(0===t.length)return[];const n=[];for(const s of t){const t=n[n.length-1];t&&e(t.marks,s.marks)?n[n.length-1]={text:t.text+s.text,marks:t.marks}:s.text.length>0&&n.push(s)}return n}ensureSegments(e){return 0===e.length?[{text:"",marks:[]}]:e}matchBlockRule(e){const t=e.tagName.toLowerCase();for(const n of this.blockParseRules)if(n.rule.tag===t){if(n.rule.getAttrs){const t=n.rule.getAttrs(e);if(!1===t)continue;return{type:ce(n.type),attrs:t}}return{type:ce(n.type)}}return null}isBlockElement(e){if(Qt.has(e.tagName))return!0;const t=e.tagName.toLowerCase();return this.blockParseRules.some(e=>e.rule.tag===t)}hasCheckbox(e){return null!==e.querySelector('input[type="checkbox"]')}isCheckboxChecked(e){return e.querySelector('input[type="checkbox"]')?.hasAttribute("checked")??!1}containsBlockDescendants(e){for(const t of Array.from(e.children)){if(this.isBlockElement(t))return!0;if(this.containsBlockDescendants(t))return!0}return!1}parseContainerWithMarks(e,t){const n=this.parseContainer(e);return 0===t.length?n:n.map(e=>({...e,segments:this.prependMarks(e.segments,t)}))}prependMarks(e,t){return e.map(e=>({text:e.text,marks:this.mergeMarks(t,e.marks)}))}parseBlockWithLineBreaks(e,t){const n=this.parseInlineChildren(e,[]);if(!n.some(e=>e.text.includes("\n")))return[{type:t,segments:this.ensureSegments(n)}];const s=[];let i=[];for(const r of n){const e=r.text.split("\n");for(let n=0;n<e.length;n++){n>0&&(s.push({type:t,segments:this.ensureSegments(this.normalizeSegments(i))}),i=[]);const o=e[n]??"";o&&i.push({text:o,marks:r.marks})}}return s.push({type:t,segments:this.ensureSegments(this.normalizeSegments(i))}),s}flushPendingSegments(e,t){const n=this.normalizeSegments(t);0!==n.length&&(n.every(e=>""===e.text.trim())||e.push({type:this.resolveBlockType(ce("paragraph")),segments:n}))}},tn={1:"x-small",2:"small",3:"medium",4:"large",5:"x-large",6:"xx-large",7:"xxx-large"};function nn(e){return e.toLowerCase().includes("font-size")}function sn(e,t){for(;e.firstChild;)t.appendChild(e.firstChild)}function rn(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}var on=["script","style","iframe","object","embed","form","noscript"],an=class{constructor(e,t,n,s){this.getState=e,this.dispatch=t,this.schemaRegistry=n,this.tryRichPasteFromJson=s}handleHTMLOrTextPaste(e,t){const n=this.getState(),s=e.getData("text/html");if(s)this.handleHTML(s,n);else if(t){const e=function(e){const t=e.split(/\r?\n/).map(e=>({type:ce("paragraph"),segments:[{text:e,marks:[]}]}));return{blocks:t.length>0?t:[{type:ce("paragraph"),segments:[{text:"",marks:[]}]}]}}(t);this.dispatch(qt(this.getState(),e))}}handleHTML(e,t){const n=ht.sanitize(e,{FORBID_TAGS:on,ALLOWED_URI_REGEXP:ge}),s=this.extractRichData(n);if(s&&this.tryRichPasteFromJson(s))return;const i=document.createElement("template");i.innerHTML=n,function(e){const t=Array.from(e.querySelectorAll("font"));for(const n of t){const e=n.getAttribute("color"),t=n.getAttribute("face"),s=n.getAttribute("size"),i=n.getAttribute("style")??"";if(!(null!==e||null!==t||null!==s||i.length>0)){rn(n);continue}const r=document.createElement("span"),o=[];if(i&&o.push(i.endsWith(";")?i:`${i};`),e&&o.push(`color: ${e};`),t&&o.push(`font-family: ${t};`),s&&!nn(i)){const e=tn[s];e&&o.push(`font-size: ${e};`)}Fe(r,o.join(" ")),sn(n,r),n.parentNode?.replaceChild(r,n)}}(i.content);const r=i.innerHTML,o=this.schemaRegistry?this.schemaRegistry.getAllowedTags():["strong","em","u","b","i","p","br","div","span"],a=this.schemaRegistry?this.schemaRegistry.getAllowedAttrs():[],c=ht.sanitize(r,{ALLOWED_TAGS:o,ALLOWED_ATTR:a,ALLOWED_URI_REGEXP:ge});if(this.schemaRegistry){const e=document.createElement("template");if(e.innerHTML=c,this.requiresDocumentParser(c,e.content))return void this.handleDocumentPaste(c,t);const n=new en({schema:re(this.schemaRegistry),schemaRegistry:this.schemaRegistry}).parse(e.content);this.dispatch(qt(t,n))}else{const e=this.extractTextFromHTML(c);e&&this.dispatch(Q(t,e,"paste"))}}extractRichData(e){const t=document.createElement("template");t.innerHTML=e;const n=t.content.querySelector("[data-notectl-rich]")?.getAttribute("data-notectl-rich");if(n)return this.decodeHTMLEntities(n)}decodeHTMLEntities(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}requiresDocumentParser(e,t){return!!/<table[\s>]/i.test(e)||this.containsVoidBlockElements(t)}containsVoidBlockElements(e){if(!this.schemaRegistry)return!1;const t=this.schemaRegistry.getBlockParseRules();for(const n of t){if(!this.schemaRegistry.getNodeSpec(n.type)?.isVoid)continue;const t=e.querySelectorAll(n.rule.tag);for(const e of Array.from(t)){if(!n.rule.getAttrs)return!0;if(!1!==n.rule.getAttrs(e))return!0}}return!1}handleDocumentPaste(e,t){if(!this.schemaRegistry)return;const n=Ae(e,this.schemaRegistry);if(0===n.children.length)return;const s=t.selection,i=t.transaction("paste");let o;V(s)&&!_(s)&&(o=se(t,i));const a=Ne(t,o??(z(s)?s.nodeId:O(s)?s.blockId:s.anchor.blockId),this.schemaRegistry);if(!a)return;const c=O(s)&&"before"===s.side?0:1;let l,h,d=a.anchorIndex+c;for(const p of n.children){const e=ze(p,r());i.insertNode(a.parentPath,d,e),d++,l=we(e),h=e}if(a.isAnchorEmpty&&!O(s)&&i.removeNode(a.parentPath,a.anchorIndex),l&&h){const e=Le(h,l),t=e?p(e).length:0;i.setSelection(K(l,t))}this.dispatch(i.build())}extractTextFromHTML(e){const t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}},cn=class{constructor(e,t,n){this.getState=e,this.dispatch=t,this.schemaRegistry=n}handleBlockPaste(e){let t;try{t=JSON.parse(e)}catch{return}const n=t.type;if(!n)return;const s=this.schemaRegistry?.getNodeSpec(n);if(this.schemaRegistry&&!s)return;const i=this.getState(),o=i.selection,a=z(o)?o.nodeId:O(o)?o.blockId:o.anchor.blockId,c=r(),l=Oe(t.attrs,s?.attrs),h=g(ce(n),void 0,c,l),d=Be(i,a);if(d){const e=He(i,a,d,this.schemaRegistry);if(!e)return;const t=i.getBlock(d);if(!t)return;const n=i.transaction("paste");return n.insertNode(e.parentPath,t.children.length,h),n.setSelection(F(c,[...e.parentPath,c])),void this.dispatch(n.build())}const p=Ne(i,a,this.schemaRegistry);if(!p)return;const u=O(o)&&"before"===o.side?0:1,m=i.transaction("paste");m.insertNode(p.parentPath,p.anchorIndex+u,h),m.setSelection(F(c,[...p.parentPath,c])),this.dispatch(m.build())}handleRichPasteFromJson(e){let t;try{t=JSON.parse(e)}catch{return!1}return!(!Array.isArray(t)||0===t.length)&&this.handleRichPaste(t)}handleRichPaste(e){if(0===e.length)return!1;if(!e.some(e=>void 0!==e.type&&"paragraph"!==e.type||e.segments?.some(e=>"inline"===e.kind))&&e.length<=1)return!1;let t=this.getState();const n=t.selection;if(V(n)&&!_(n)){const n=t.transaction("paste"),s=se(t,n),i=n.build();if(this.dispatch(i),t=t.apply(i),s)return this.resolveAndInsertRichBlocks(e,t,s)}const s=z(n)?n.nodeId:O(n)?n.blockId:n.anchor.blockId;return this.resolveAndInsertRichBlocks(e,t,s)}resolveAndInsertRichBlocks(e,t,n){const s=t.selection,i=Be(t,n);if(i){const s=He(t,n,i,this.schemaRegistry);if(!s)return!1;const r=t.getBlock(i),o=s.anchorIndex>=0?s.anchorIndex+1:r?.children.length??0;return this.insertRichBlocks(e,t,s,o,!0)}const r=Ne(t,n,this.schemaRegistry);if(!r)return!1;const o=O(s)&&"before"===s.side?0:1;return this.insertRichBlocks(e,t,r,r.anchorIndex+o,!O(s))}insertRichBlocks(e,t,n,s,i){const r=t.transaction("paste");let o,a=s,c=0;for(const l of e){const e=_e(l,this.schemaRegistry);if(!e)continue;const t=De(e);r.insertNode(n.parentPath,a,t),a++,o=t.id,c=(e.text??"").length}return i&&n.isAnchorEmpty&&n.anchorIndex>=0&&r.removeNode(n.parentPath,n.anchorIndex),o&&r.setSelection(K(o,c)),this.dispatch(r.build()),!0}},ln=class{getState;dispatch;fileHandlerRegistry;isReadOnly;getPasteInterceptors;handlePaste;htmlHandler;richBlockHandler;constructor(e,t){this.element=e,this.getState=t.getState,this.dispatch=t.dispatch,this.fileHandlerRegistry=t.fileHandlerRegistry,this.isReadOnly=t.isReadOnly??(()=>!1),this.getPasteInterceptors=t.getPasteInterceptors??(()=>[]),this.richBlockHandler=new cn(t.getState,t.dispatch,t.schemaRegistry),this.htmlHandler=new an(t.getState,t.dispatch,t.schemaRegistry,e=>this.richBlockHandler.handleRichPasteFromJson(e)),this.handlePaste=this.onPaste.bind(this),e.addEventListener("paste",this.handlePaste)}onPaste(e){if(e.preventDefault(),this.isReadOnly())return;const t=e.clipboardData;if(!t)return;const n=t.getData("application/x-notectl-block");if(n)return void this.richBlockHandler.handleBlockPaste(n);if(this.handleFilePaste(t))return;const s=t.getData("text/plain"),i=t.getData("text/html");s&&this.tryPasteInterceptors(s,i)||this.htmlHandler.handleHTMLOrTextPaste(t,s)}tryPasteInterceptors(e,t){const n=this.getPasteInterceptors(),s=this.getState();for(const i of n){const n=i.interceptor(e,t,s);if(n)return this.dispatch(n),!0}return!1}handleFilePaste(e){if(!this.fileHandlerRegistry)return!1;const t=Array.from(e.files);if(0===t.length)for(let s=0;s<e.items.length;s++){const n=e.items[s];if(n&&"file"===n.kind){const e=n.getAsFile();e&&t.push(e)}}if(0===t.length)return!1;let n=!1;for(const s of t){const e=this.fileHandlerRegistry.matchFileHandlers(s.type);for(const t of e){const e=t(s,null);if(!0===e||e instanceof Promise){n=!0;break}}}return n}destroy(){this.element.removeEventListener("paste",this.handlePaste)}},hn=class{compositionTracker;inputHandler;keyboardHandler;pasteHandler;clipboardHandler;constructor(e,t){this.compositionTracker=new Vt,this.inputHandler=new $t(e,{getState:t.getState,dispatch:t.dispatch,syncSelection:t.syncSelection,inputRuleRegistry:t.inputRuleRegistry,isReadOnly:t.isReadOnly,compositionTracker:this.compositionTracker}),this.keyboardHandler=new zt(e,{getState:t.getState,dispatch:t.dispatch,undo:t.undo,redo:t.redo,keymapRegistry:t.keymapRegistry,isReadOnly:t.isReadOnly,compositionTracker:this.compositionTracker,getTextDirection:t.getTextDirection,navigateFromGapCursor:t.navigateFromGapCursor}),this.pasteHandler=new ln(e,{getState:t.getState,dispatch:t.dispatch,schemaRegistry:t.schemaRegistry,fileHandlerRegistry:t.fileHandlerRegistry,isReadOnly:t.isReadOnly,getPasteInterceptors:t.getPasteInterceptors}),this.clipboardHandler=new Kt(e,{getState:t.getState,dispatch:t.dispatch,schemaRegistry:t.schemaRegistry,syncSelection:t.syncSelection,isReadOnly:t.isReadOnly})}destroy(){this.inputHandler.destroy(),this.keyboardHandler.destroy(),this.pasteHandler.destroy(),this.clipboardHandler.destroy()}},dn=class{_contextKeymaps=[];_navigationKeymaps=[];_defaultKeymaps=[];registerKeymap(e,t){const n=t?.priority??"default";this.keymapArrayForPriority(n).push(e)}getKeymaps(){return[...this._contextKeymaps,...this._navigationKeymaps,...this._defaultKeymaps]}getKeymapsByPriority(){return{context:[...this._contextKeymaps],navigation:[...this._navigationKeymaps],default:[...this._defaultKeymaps]}}removeKeymap(e){for(const t of[this._contextKeymaps,this._navigationKeymaps,this._defaultKeymaps]){const n=t.indexOf(e);if(-1!==n)return void t.splice(n,1)}}clear(){this._contextKeymaps.length=0,this._navigationKeymaps.length=0,this._defaultKeymaps.length=0}keymapArrayForPriority(e){switch(e){case"context":return this._contextKeymaps;case"navigation":return this._navigationKeymaps;case"default":return this._defaultKeymaps}}},pn=class{_inputRules=[];registerInputRule(e){this._inputRules.push(e)}getInputRules(){return this._inputRules}removeInputRule(e){const t=this._inputRules.indexOf(e);-1!==t&&this._inputRules.splice(t,1)}clear(){this._inputRules.length=0}},un=class{_fileHandlers=[];registerFileHandler(e,t){this._fileHandlers.push({pattern:e,handler:t})}getFileHandlers(){return this._fileHandlers}matchFileHandlers(e){const t=[];for(const n of this._fileHandlers)gn(n.pattern,e)&&t.push(n.handler);return t}removeFileHandler(e){const t=this._fileHandlers.findIndex(t=>t.handler===e);-1!==t&&this._fileHandlers.splice(t,1)}clear(){this._fileHandlers.length=0}};function gn(e,t){if("*"===e||"*/*"===e)return!0;if(e===t)return!0;if(e.endsWith("/*")){const n=e.slice(0,-1);return t.startsWith(n)}return!1}var mn=class{_nodeViews=/* @__PURE__ */new Map;registerNodeView(e,t){if(this._nodeViews.has(e))throw new Error(`NodeView for type "${e}" is already registered.`);this._nodeViews.set(e,t)}getNodeViewFactory(e){return this._nodeViews.get(e)}removeNodeView(e){this._nodeViews.delete(e)}clear(){this._nodeViews.clear()}};function fn(e,t){if(t){const n=t.getMarkSpec(e.type);if(n)return n.rank??100}switch(e.type){case"bold":return 0;case"italic":return 1;case"underline":return 2;default:return 100}}function yn(e,t,n){if(0===t.length)return e;const s=[...t].sort((e,t)=>fn(e,n)-fn(t,n));let i=e;for(let r=s.length-1;r>=0;r--){const e=s[r];if(!e)continue;const t=kn(e,n);t.appendChild(i),i=t}return i}function kn(e,t){if(t){const n=t.getMarkSpec(e.type);if(n)return n.toDOM(e)}switch(e.type){case"bold":return document.createElement("strong");case"italic":return document.createElement("em");case"underline":return document.createElement("u");default:return document.createElement("span")}}var Sn=class{wrapperElement=null;container;registry;constructor(e,t){this.container=e,this.registry=t}get isActive(){return null!==this.wrapperElement}onCompositionStart(e){this.cleanup();const t=e.storedMarks;if(!t||0===t.length)return;const n=e.selection;if(!V(n))return;if(!_(n))return;const s=document.createElement("span");s.setAttribute("data-cursor-wrapper","");const i=document.createTextNode(""),r=yn(i,t,this.registry);s.appendChild(r);const o=M();if(!o||0===o.rangeCount)return;let a;const c=x(this.container,o);if(c){const e=document.createRange();try{e.setStart(c.anchorNode,c.anchorOffset),e.setEnd(c.focusNode,c.focusOffset)}catch{return}a=e}else a=o.getRangeAt(0);a.insertNode(s);try{o.collapse(i,i.length)}catch{}this.wrapperElement=s}cleanup(){this.wrapperElement&&(this.wrapperElement.remove(),this.wrapperElement=null)}},wn=class{listeners=/* @__PURE__ */new Map;emit(e,t){const n=this.listeners.get(e.id);if(n)for(const i of n)try{i(t)}catch(s){console.error(`[EventBus] Listener error on "${e.id}":`,s)}}on(e,t){const n=e.id;this.listeners.has(n)||this.listeners.set(n,/* @__PURE__ */new Set);const s=this.listeners.get(n)??/* @__PURE__ */new Set;return s.add(t),()=>{s.delete(t),0===s.size&&this.listeners.delete(n)}}off(e,t){const n=this.listeners.get(e.id);n&&(n.delete(t),0===n.size&&this.listeners.delete(e.id))}clear(){this.listeners.clear()}},vn=class{commands=/* @__PURE__ */new Map;readonlyBypassActive=!1;register(e,t,n,s){if(this.commands.has(e)){const t=this.commands.get(e);throw new Error(`Command "${e}" is already registered by plugin "${t?.pluginId}".`)}const i=s?.readonlyAllowed??!1;this.commands.set(e,{name:e,handler:t,pluginId:n,readonlyAllowed:i})}canExecute(e,t){const n=this.commands.get(e);return!(!n||t&&!n.readonlyAllowed)}execute(e,t){const n=this.commands.get(e);if(!n)return!1;if(t&&!n.readonlyAllowed)return!1;const s=t&&n.readonlyAllowed;s&&(this.readonlyBypassActive=!0);try{return n.handler()}catch(i){return console.error(`[PluginManager] Command "${e}" error:`,i),!1}finally{s&&(this.readonlyBypassActive=!1)}}isReadonlyBypassed(){return this.readonlyBypassActive}has(e){return this.commands.has(e)}remove(e){this.commands.delete(e)}clear(){this.commands.clear(),this.readonlyBypassActive=!1}get rawMap(){return this.commands}},bn=class{middlewares=[];middlewareSorted=null;pasteInterceptors=[];pasteInterceptorsSorted=null;addMiddleware(e){this.middlewares.push(e),this.middlewareSorted=null}removeMiddleware(e){const t=this.middlewares.indexOf(e);-1!==t&&this.middlewares.splice(t,1),this.middlewareSorted=null}invalidateMiddlewareSort(){this.middlewareSorted=null}dispatch(e,t,n){if(0===this.middlewares.length)return void n(e);const s=this.getSortedMiddleware();let i=0,r=!1;const o=e=>{if(i<s.length){const n=s[i++];if(!n)return;let r=!1;const c=e=>{r||(r=!0,o(e))};try{n.middleware(e,t,c)}catch(a){console.error(`[PluginManager] Middleware "${n.name}" error:`,a),c(e)}}else r||(r=!0,n(e))};o(e)}getChain(){return this.getSortedMiddleware().map(e=>({name:e.name,priority:e.priority,pluginId:e.pluginId}))}addPasteInterceptor(e){this.pasteInterceptors.push(e),this.pasteInterceptorsSorted=null}removePasteInterceptor(e){const t=this.pasteInterceptors.indexOf(e);-1!==t&&this.pasteInterceptors.splice(t,1),this.pasteInterceptorsSorted=null}invalidatePasteSort(){this.pasteInterceptorsSorted=null}getPasteInterceptors(){return this.getSortedPasteInterceptors()}get rawMiddlewares(){return this.middlewares}get rawPasteInterceptors(){return this.pasteInterceptors}clear(){this.middlewares.length=0,this.middlewareSorted=null,this.pasteInterceptors.length=0,this.pasteInterceptorsSorted=null}getSortedMiddleware(){return this.middlewareSorted||(this.middlewareSorted=[...this.middlewares].sort((e,t)=>e.priority-t.priority)),this.middlewareSorted}getSortedPasteInterceptors(){return this.pasteInterceptorsSorted||(this.pasteInterceptorsSorted=[...this.pasteInterceptors].sort((e,t)=>e.priority-t.priority)),this.pasteInterceptorsSorted}};function Rn(e,t,n,s){return{registerCommand:(s,i,r)=>{if(t.has(s)){const e=t.get(s);throw new Error(`Command "${s}" is already registered by plugin "${e?.pluginId}".`)}const o=r?.readonlyAllowed??!1;t.set(s,{name:s,handler:i,pluginId:e,readonlyAllowed:o}),n.commands.push(s)},executeCommand:s}}function Cn(e,t){return{registerService:(n,s)=>{if(e.has(n.id))throw new Error(`Service "${n.id}" is already registered by another plugin.`);e.set(n.id,s),t.services.push(n.id)},getService:t=>e.get(t.id)}}function In(e,t,n,s,i,r){return{registerMiddleware:(n,r)=>{const o={name:r?.name??(n.name||"anonymous"),pluginId:e,middleware:n,priority:r?.priority??100};t.push(o),s.middlewares.push(o),i()},registerPasteInterceptor:(t,i)=>{const o={name:i?.name??"anonymous",pluginId:e,interceptor:t,priority:i?.priority??100};n.push(o),s.pasteInterceptors.push(o),r()}}}function xn(e,t){return{registerNodeSpec:n=>{e.registerNodeSpec(n),t.nodeSpecs.push(n.type)},registerMarkSpec:n=>{e.registerMarkSpec(n),t.markSpecs.push(n.type)},registerInlineNodeSpec:n=>{e.registerInlineNodeSpec(n),t.inlineNodeSpecs.push(n.type)}}}function Tn(e,t,n){return{registerNodeView:(e,s)=>{t.nodeViewRegistry.registerNodeView(e,s),n.nodeViews.push(e)},registerKeymap:(e,s)=>{t.keymapRegistry.registerKeymap(e,s),n.keymaps.push(e)},registerInputRule:e=>{t.inputRuleRegistry.registerInputRule(e),n.inputRules.push(e)},registerToolbarItem:s=>{t.toolbarRegistry.registerToolbarItem(s,e),n.toolbarItems.push(s.id)},registerBlockTypePickerEntry:e=>{t.blockTypePickerRegistry.registerBlockTypePickerEntry(e),n.blockTypePickerEntries.push(e.id)},registerFileHandler:(e,s)=>{t.fileHandlerRegistry.registerFileHandler(e,s),n.fileHandlers.push(s)},registerStyleSheet:e=>{const s=new CSSStyleSheet;s.replaceSync(e),t.pluginStyleSheets.push(s),n.stylesheets.push(s)}}}function Pn(e){return{getSchemaRegistry:()=>e.schemaRegistry,getKeymapRegistry:()=>e.keymapRegistry,getInputRuleRegistry:()=>e.inputRuleRegistry,getFileHandlerRegistry:()=>e.fileHandlerRegistry,getNodeViewRegistry:()=>e.nodeViewRegistry,getToolbarRegistry:()=>e.toolbarRegistry,getBlockTypePickerRegistry:()=>e.blockTypePickerRegistry}}var En=class{plugins=/* @__PURE__ */new Map;initOrder=[];startedInitOrder=[];initialized=!1;initializing=!1;readOnly=!1;constructor(e){this.tracker=e}register(e){if(this.initialized||this.initializing)throw new Error(`Cannot register plugin "${e.id}" after initialization.`);if(this.plugins.has(e.id))throw new Error(`Plugin "${e.id}" is already registered.`);this.plugins.set(e.id,e)}get(e){return this.plugins.get(e)}getPluginIds(){return[...this.plugins.keys()]}async init(e,t){if(!this.initialized&&!this.initializing){this.initializing=!0;try{this.initOrder=this.resolveOrder();for(const s of this.initOrder){if(e.isCancelled?.())return;const i=this.plugins.get(s);if(!i)continue;this.startedInitOrder.push(s);const r=t(s,e);try{await i.init(r)}catch(n){throw await this.rollbackStartedPlugins(),n}}if(e.isCancelled?.())return;if(e.onBeforeReady&&await e.onBeforeReady(),e.isCancelled?.())return;for(const t of this.initOrder){if(e.isCancelled?.())return;const s=this.plugins.get(t);if(s?.onReady)try{await s.onReady()}catch(n){console.error(`[PluginManager] Plugin "${t}" error in onReady:`,n)}}this.initialized=!0}finally{this.initializing=!1}}}async destroy(){const e=[...this.startedInitOrder].reverse();for(const t of e)await this.destroyPlugin(t);this.plugins.clear(),this.initOrder=[],this.startedInitOrder=[],this.initialized=!1,this.initializing=!1}notifyStateChange(e,t,n){for(const i of this.initOrder){const r=this.plugins.get(i);if(r?.onStateChange)try{r.onStateChange(e,t,n)}catch(s){console.error(`[PluginManager] Plugin "${i}" error in onStateChange:`,s)}}}collectDecorations(e,t){let n=We.empty;for(const i of this.initOrder){const r=this.plugins.get(i);if(r?.decorations)try{const s=r.decorations(e,t);s.isEmpty||(n=n.merge(s))}catch(s){console.error(`[PluginManager] Plugin "${i}" error in decorations():`,s)}}return n}configurePlugin(e,t){const n=this.plugins.get(e);if(!n)throw new Error(`Plugin "${e}" not found.`);if(n.onConfigure)try{n.onConfigure(t)}catch(s){console.error(`[PluginManager] Plugin "${e}" error in onConfigure:`,s)}}isReadOnly(){return this.readOnly}setReadOnly(e){if(this.readOnly!==e){this.readOnly=e;for(const n of this.initOrder){const s=this.plugins.get(n);if(s?.onReadOnlyChange)try{s.onReadOnlyChange(e)}catch(t){console.error(`[PluginManager] Plugin "${n}" error in onReadOnlyChange:`,t)}}}}get rawPlugins(){return this.plugins}get isInitialized(){return this.initialized}async destroyPlugin(e){const t=this.plugins.get(e);if(t?.destroy)try{await t.destroy()}catch(n){console.error(`[PluginManager] Plugin "${e}" error in destroy:`,n)}this.tracker.cleanup(e)}async rollbackStartedPlugins(){const e=[...this.startedInitOrder].reverse();for(const t of e)await this.destroyPlugin(t);this.startedInitOrder=[],this.initOrder=[],this.initialized=!1}resolveOrder(){const e=[...this.plugins.keys()];for(const r of e){const e=this.plugins.get(r);if(e)for(const t of e.dependencies??[])if(!this.plugins.has(t))throw new Error(`Plugin "${r}" depends on "${t}", which is not registered.`)}const t=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map;for(const r of e)t.set(r,0),n.set(r,[]);for(const r of e){const e=this.plugins.get(r)?.dependencies??[];t.set(r,e.length);for(const t of e){const e=n.get(t);e&&e.push(r)}}const s=[];for(const[r,o]of t)0===o&&s.push(r);const i=[];for(;s.length>0;){s.sort((e,t)=>(this.plugins.get(e)?.priority??100)-(this.plugins.get(t)?.priority??100));const e=s.shift();if(!e)break;i.push(e);for(const i of n.get(e)??[]){const e=(t.get(i)??0)-1;t.set(i,e),0===e&&s.push(i)}}if(i.length!==e.length){const t=e.filter(e=>!i.includes(e));throw new Error(`Circular dependency detected among plugins: ${t.join(", ")}`)}return i}},Mn=class{registrations=/* @__PURE__ */new Map;pluginStyleSheets=[];constructor(e){this.deps=e}track(e,t){this.registrations.set(e,t)}cleanup(e){const t=this.registrations.get(e);if(t){for(const e of t.commands)this.deps.commandRegistry.remove(e);for(const e of t.services)this.deps.serviceRegistry.remove(e);for(const e of t.middlewares)this.deps.middlewareChain.removeMiddleware(e);for(const e of t.pasteInterceptors)this.deps.middlewareChain.removePasteInterceptor(e);for(const e of t.unsubscribers)e();for(const e of t.nodeSpecs)this.deps.schemaRegistry.removeNodeSpec(e);for(const e of t.markSpecs)this.deps.schemaRegistry.removeMarkSpec(e);for(const e of t.inlineNodeSpecs)this.deps.schemaRegistry.removeInlineNodeSpec(e);for(const e of t.nodeViews)this.deps.nodeViewRegistry.removeNodeView(e);for(const e of t.keymaps)this.deps.keymapRegistry.removeKeymap(e);for(const e of t.inputRules)this.deps.inputRuleRegistry.removeInputRule(e);for(const e of t.toolbarItems)this.deps.toolbarRegistry.removeToolbarItem(e);for(const e of t.fileHandlers)this.deps.fileHandlerRegistry.removeFileHandler(e);for(const e of t.blockTypePickerEntries)this.deps.blockTypePickerRegistry.removeBlockTypePickerEntry(e);for(const e of t.stylesheets){const t=this.pluginStyleSheets.indexOf(e);-1!==t&&this.pluginStyleSheets.splice(t,1)}this.registrations.delete(e)}}clear(){this.registrations.clear(),this.pluginStyleSheets.length=0}get rawStyleSheets(){return this.pluginStyleSheets}},An=class{services=/* @__PURE__ */new Map;register(e,t){if(this.services.has(e.id))throw new Error(`Service "${e.id}" is already registered.`);this.services.set(e.id,t)}get(e){return this.services.get(e.id)}has(e){return this.services.has(e)}remove(e){this.services.delete(e)}clear(){this.services.clear()}get rawMap(){return this.services}},Nn=class{schemaRegistry=new dt;keymapRegistry=new dn;inputRuleRegistry=new pn;fileHandlerRegistry=new un;nodeViewRegistry=new mn;toolbarRegistry=new Qe;blockTypePickerRegistry=new Ge;commandRegistry=new vn;serviceRegistry=new An;middlewareChain=new bn;eventBus=new wn;registrationTracker;lifecycle;constructor(){this.registrationTracker=new Mn({commandRegistry:this.commandRegistry,serviceRegistry:this.serviceRegistry,middlewareChain:this.middlewareChain,schemaRegistry:this.schemaRegistry,keymapRegistry:this.keymapRegistry,inputRuleRegistry:this.inputRuleRegistry,nodeViewRegistry:this.nodeViewRegistry,toolbarRegistry:this.toolbarRegistry,fileHandlerRegistry:this.fileHandlerRegistry,blockTypePickerRegistry:this.blockTypePickerRegistry}),this.lifecycle=new En(this.registrationTracker)}registerService(e,t){this.serviceRegistry.register(e,t)}register(e){this.lifecycle.register(e)}async init(e){return this.lifecycle.init(e,(e,t)=>this.createContext(e,t))}notifyStateChange(e,t,n){this.lifecycle.notifyStateChange(e,t,n)}collectDecorations(e,t){return this.lifecycle.collectDecorations(e,t)}dispatchWithMiddleware(e,t,n){this.middlewareChain.dispatch(e,t,n)}canExecuteCommand(e){return this.commandRegistry.canExecute(e,this.lifecycle.isReadOnly())}executeCommand(e){return this.commandRegistry.execute(e,this.lifecycle.isReadOnly())}isReadonlyBypassed(){return this.commandRegistry.isReadonlyBypassed()}configurePlugin(e,t){this.lifecycle.configurePlugin(e,t)}isReadOnly(){return this.lifecycle.isReadOnly()}setReadOnly(e){this.lifecycle.setReadOnly(e)}getPluginIds(){return this.lifecycle.getPluginIds()}getMiddlewareChain(){return this.middlewareChain.getChain()}getPasteInterceptors(){return this.middlewareChain.getPasteInterceptors()}get(e){return this.lifecycle.get(e)}getService(e){return this.serviceRegistry.get(e)}onEvent(e,t){return this.eventBus.on(e,t)}getPluginStyleSheets(){return this.registrationTracker.rawStyleSheets}async destroy(){await this.lifecycle.destroy(),this.commandRegistry.clear(),this.serviceRegistry.clear(),this.middlewareChain.clear(),this.registrationTracker.clear(),this.eventBus.clear(),this.schemaRegistry.clear(),this.keymapRegistry.clear(),this.inputRuleRegistry.clear(),this.fileHandlerRegistry.clear(),this.nodeViewRegistry.clear(),this.toolbarRegistry.clear(),this.blockTypePickerRegistry.clear()}createContext(e,t){const{context:n,registrations:s}=function(e){const t={commands:[],services:[],middlewares:[],pasteInterceptors:[],unsubscribers:[],nodeSpecs:[],markSpecs:[],inlineNodeSpecs:[],nodeViews:[],keymaps:[],inputRules:[],toolbarItems:[],fileHandlers:[],blockTypePickerEntries:[],stylesheets:[]},n=function(e,t){return{emit:(t,n)=>e.emit(t,n),on:(n,s)=>{const i=e.on(n,s);return t.unsubscribers.push(i),i},off:(t,n)=>e.off(t,n)}}(e.eventBus,t);return{context:{getState:e.getState,dispatch:e.dispatch,getContainer:e.getContainer,getPluginContainer:e.getPluginContainer,isReadOnly:e.isReadOnly,getEventBus:()=>n,...Rn(e.pluginId,e.commands,t,e.executeCommand),...Cn(e.services,t),...In(e.pluginId,e.middlewares,e.pasteInterceptors,t,e.invalidateMiddlewareSort,e.invalidatePasteSort),...xn(e.schemaRegistry,t),...Tn(e.pluginId,e,t),...Pn(e),updateConfig:t=>{const n=e.plugins.get(e.pluginId);if(n?.onConfigure)try{n.onConfigure(t)}catch(s){console.error(`[PluginManager] Plugin "${e.pluginId}" error in onConfigure:`,s)}},announce:t=>{e.announce?.(t)},hasAnnouncement:()=>e.hasAnnouncement?.()??!1},registrations:t}}({pluginId:e,getState:t.getState,dispatch:t.dispatch,getContainer:t.getContainer,getPluginContainer:t.getPluginContainer,announce:t.announce,hasAnnouncement:t.hasAnnouncement,commands:this.commandRegistry.rawMap,services:this.serviceRegistry.rawMap,middlewares:this.middlewareChain.rawMiddlewares,pasteInterceptors:this.middlewareChain.rawPasteInterceptors,pluginStyleSheets:this.registrationTracker.rawStyleSheets,plugins:this.lifecycle.rawPlugins,eventBus:this.eventBus,schemaRegistry:this.schemaRegistry,keymapRegistry:this.keymapRegistry,inputRuleRegistry:this.inputRuleRegistry,toolbarRegistry:this.toolbarRegistry,blockTypePickerRegistry:this.blockTypePickerRegistry,fileHandlerRegistry:this.fileHandlerRegistry,nodeViewRegistry:this.nodeViewRegistry,isReadOnly:()=>this.lifecycle.isReadOnly(),invalidateMiddlewareSort:()=>this.middlewareChain.invalidateMiddlewareSort(),invalidatePasteSort:()=>this.middlewareChain.invalidatePasteSort(),executeCommand:e=>this.executeCommand(e)});return this.registrationTracker.track(e,s),n}},Bn={EN:"en",DE:"de",ES:"es",FR:"fr",ZH:"zh",RU:"ru",AR:"ar",HI:"hi",PT:"pt",BROWSER:"browser"},On={paragraph:"Paragraph",heading:"Heading",code_block:"Code Block",blockquote:"Block Quote",list_item:"List Item",horizontal_rule:"Horizontal Rule",image:"Image",table:"Table"};function Dn(e,t){return"heading"===e&&t?.level?`Heading ${t.level}`:On[e]??e}function Ln(e,t){const n=t?.document??globalThis.document,s=t?.container??n.head;if(t?.id){const s=n.getElementById(t.id);if(s instanceof HTMLStyleElement)return s.textContent=e,t.nonce&&s.setAttribute("nonce",t.nonce),s}const i=n.createElement("style");return i.textContent=e,t?.id&&(i.id=t.id),t?.nonce&&i.setAttribute("nonce",t.nonce),s.appendChild(i),i}function Hn(e,t){const n=(t??globalThis.document).getElementById(e);n&&n.remove()}var zn=/* @__PURE__ */new WeakSet;function _n(e,t){const n=t?.target??globalThis.document,s=new CSSStyleSheet;return s.replaceSync(e),zn.add(s),t?.replace&&(n.adoptedStyleSheets=n.adoptedStyleSheets.filter(e=>!zn.has(e))),n.adoptedStyleSheets=[...n.adoptedStyleSheets,s],s}function Fn(e,t){const n=t??globalThis.document;n.adoptedStyleSheets=n.adoptedStyleSheets.filter(t=>t!==e)}function Kn(e,t,n){const s=t?function(e,t){return{children:e.children.map(e=>Vn(e,t))}}(e,t):e,i=t?re(t):void 0;n(At.create({doc:s,schema:i}))}function Vn(e,n){const s=n.getNodeSpec(e.type);if(!s?.content||!((r=s.content).allow.length>0)||r.allow.includes("text"))return e;var r;if(S(e)){const t=e.children.length>0?e.children:void 0,n=g(ce("paragraph"),t);return g(e.type,[n],e.id,e.attrs)}const o=e.children.map(e=>t(e)||i(e)?e:Vn(e,n));return g(e.type,o,e.id,e.attrs)}function $n(e){if(!e)return!0;if(0===e.children.length)return!0;if(e.children.length>1)return!1;const t=e.children[0];return!t||"paragraph"===t.type&&""===p(t)}var jn=class{config={};getConfig(){return this.config}setConfig(e){this.config=e}mergeConfig(e){this.config={...this.config,...e}}applyAttribute(e,t,n){if("placeholder"===e){const e=t??void 0;this.config={...this.config,placeholder:e},this.applyPlaceholder(e,n.contentElement)}if("readonly"===e){const e=null!==t;this.applyReadonly(e,n.contentElement,n.pluginManager),this.config={...this.config,readonly:e}}if("theme"===e){const e=t??void 0;this.config={...this.config,theme:e},n.themeController?.apply(e??et.Light)}"paper-size"===e&&(null===t?(n.applyPaperSize(void 0),this.config={...this.config,paperSize:void 0}):rt(t)&&(n.applyPaperSize(t),this.config={...this.config,paperSize:t})),"dir"===e&&this.applyDir("ltr"===t||"rtl"===t?t:void 0,n.contentElement,n.editorWrapper)}applyRuntimeConfig(e,t){void 0!==e.placeholder&&this.applyPlaceholder(e.placeholder,t.contentElement),void 0!==e.readonly&&this.applyReadonly(e.readonly,t.contentElement,t.pluginManager),"paperSize"in e&&t.applyPaperSize(e.paperSize),"dir"in e&&this.applyDir(e.dir,t.contentElement,t.editorWrapper),this.config={...this.config,...e}}applyTheme(e,t){this.config={...this.config,theme:e},t?.apply(e)}getTheme(){return this.config.theme??et.Light}get isReadOnly(){return this.config.readonly??!1}getPaperSize(){return this.config.paperSize}applyPlaceholder(e,t){if(!t)return;const n=t.getAttribute("data-default-placeholder")??"";t.setAttribute("data-placeholder",e??n)}applyReadonly(e,t,n){t&&(t.contentEditable=e?"false":"true",e?t.setAttribute("aria-readonly","true"):t.removeAttribute("aria-readonly"),n?.setReadOnly(e))}applyDir(e,t,n){t&&(e?(n?.setAttribute("dir",e),t.setAttribute("dir",e)):(n?.removeAttribute("dir"),t.removeAttribute("dir")))}},Un=class{listeners=/* @__PURE__ */new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,/* @__PURE__ */new Set),this.listeners.get(e)?.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,t){const n=this.listeners.get(e);if(n)for(const s of n)s(t)}clear(){this.listeners.clear()}},qn=class{deps;handleSelectionChange;handleMousedown;handleDragover;handleDrop;handleCompositionStart;handleCompositionEnd;pendingNodeSelectionClear=!1;pendingGapCursorClear=!1;constructor(e){this.deps=e,this.handleCompositionStart=()=>{e.cursorWrapper.onCompositionStart(e.getState())},this.handleCompositionEnd=()=>{e.cursorWrapper.cleanup()},e.contentElement.addEventListener("compositionstart",this.handleCompositionStart),e.contentElement.addEventListener("compositionend",this.handleCompositionEnd),this.handleSelectionChange=this.onSelectionChange.bind(this),document.addEventListener("selectionchange",this.handleSelectionChange),this.handleMousedown=this.onMousedown.bind(this),e.contentElement.addEventListener("mousedown",this.handleMousedown),this.handleDragover=this.onDragover.bind(this),e.contentElement.addEventListener("dragover",this.handleDragover),this.handleDrop=this.onDrop.bind(this),e.contentElement.addEventListener("drop",this.handleDrop)}syncSelectionFromDOM(){if(this.deps.compositionState.isComposing)return;this.deps.cursorWrapper.isActive&&this.deps.cursorWrapper.cleanup();const e=this.deps.getState();if(z(e.selection)&&!this.pendingNodeSelectionClear)return;if(O(e.selection)&&!this.pendingGapCursorClear)return;this.pendingNodeSelectionClear=!1,this.pendingGapCursorClear=!1;const t=R(this.deps.contentElement);if(!t)return;if(L(t,e.selection))return;const n=e.transaction("input").setSelection(t).setStoredMarks(null,e.storedMarks).build(),s=e.apply(n);this.deps.applyUpdate(s,n,!0)}destroy(){const e=this.deps.contentElement;e.removeEventListener("compositionstart",this.handleCompositionStart),e.removeEventListener("compositionend",this.handleCompositionEnd),document.removeEventListener("selectionchange",this.handleSelectionChange),e.removeEventListener("mousedown",this.handleMousedown),e.removeEventListener("dragover",this.handleDragover),e.removeEventListener("drop",this.handleDrop)}onSelectionChange(){if(this.deps.isUpdating())return;const e=this.deps.contentElement.getRootNode(),t="activeElement"in e?e.activeElement:document.activeElement;(this.deps.contentElement.contains(t)||t===this.deps.contentElement)&&this.syncSelectionFromDOM()}onMousedown(e){if(this.deps.isUpdating())return;this.deps.onMousedown?.();const t=e.target;if(!(t instanceof HTMLElement))return;const n=t.closest("[data-block-id]");if(!(n instanceof HTMLElement&&this.deps.contentElement.contains(n)))return void((this.deps.contentElement.contains(t)||t===this.deps.contentElement)&&this.handleClickBelowContent(e));if(!n.hasAttribute("data-void")&&!n.hasAttribute("data-selectable"))return void this.markPendingSelectionClear();if(n.querySelector("[data-content-dom]")?.contains(t))return void this.markPendingSelectionClear();e.preventDefault(),this.deps.contentElement.focus();const s=F(he(n.getAttribute("data-block-id")??""),pe(this.deps.contentElement,n)),i=this.deps.getState(),r=i.transaction("input").setSelection(s).setStoredMarks(null,i.storedMarks).build(),o=i.apply(r);this.deps.applyUpdate(o,r)}handleClickBelowContent(e){if(this.deps.isReadOnly())return;const t=this.deps.getState(),n=t.doc.children[t.doc.children.length-1];if(!n)return;const i=n.id,a=this.deps.contentElement.querySelector(`[data-block-id="${i}"]`);if(!a)return;const c=a.getBoundingClientRect();if(e.clientY<=c.bottom)return;const l=t.getBlock(i);if("paragraph"===l?.type&&0===o(l)){const n=t.transaction("input").setSelection(K(i,0)).build();return this.deps.dispatch(n),void e.preventDefault()}e.preventDefault(),this.deps.contentElement.focus();const h=r(),d=t.transaction("input").insertNode([],t.doc.children.length,s(h)).setSelection(K(h,0)).build();this.deps.dispatch(d)}onDragover(e){this.deps.fileHandlerRegistry&&e.dataTransfer&&e.dataTransfer.types.includes("Files")&&e.preventDefault()}onDrop(e){if(this.deps.isReadOnly())return;if(!this.deps.fileHandlerRegistry)return;if(!e.dataTransfer)return;const t=Array.from(e.dataTransfer.files);if(0===t.length)return;const n=this.getPositionFromPoint(e.clientX,e.clientY);let s=!1;for(const i of t){const e=this.deps.fileHandlerRegistry.matchFileHandlers(i.type);for(const t of e){const e=t(i,n);if(!0===e||e instanceof Promise){s=!0;break}}}s&&e.preventDefault()}getPositionFromPoint(e,t){const n=C(this.deps.contentElement.getRootNode(),e,t);return n&&this.deps.contentElement.contains(n.node)?v(this.deps.contentElement,n.node,n.offset):null}markPendingSelectionClear(){const e=this.deps.getState();z(e.selection)&&(this.pendingNodeSelectionClear=!0),O(e.selection)&&(this.pendingGapCursorClear=!0)}},Wn=class{deps;navigationKeymap=null;goalColumn=null;preserveGoalColumn=!1;constructor(e){this.deps=e,this.registerKeymaps()}resetAfterUpdate(){this.preserveGoalColumn||(this.goalColumn=null)}clearGoalColumn(){this.goalColumn=null}destroy(){this.navigationKeymap&&this.deps.keymapRegistry&&(this.deps.keymapRegistry.removeKeymap(this.navigationKeymap),this.navigationKeymap=null)}registerKeymaps(){if(!this.deps.keymapRegistry)return;const e={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"},t={};for(const[n,s]of Object.entries(e))t[n]=()=>this.handleArrow(s);this.navigationKeymap=t,this.deps.keymapRegistry.registerKeymap(t,{priority:"navigation"})}handleArrow(e){const t=this.deps.getState();return!z(t.selection)&&!O(t.selection)&&!!_(t.selection)&&("left"===e||"right"===e?this.handleHorizontalArrow(e):this.handleVerticalArrow(e))}handleHorizontalArrow(e){this.goalColumn=null;const t=this.deps.getState(),n=this.resolveLogicalDirection(t,e),s=I(t,n);if(s)return this.deps.dispatch(s),this.validateSelectionAfterInlineSkip(),!0;if(!E(this.deps.contentElement,t,e))return!1;const i=T(t,n);return!!i&&(this.deps.dispatch(i),!0)}resolveLogicalDirection(e,t){const n=e.selection;if(!V(n))return t;const s=this.deps.contentElement.querySelector(`[data-block-id="${n.anchor.blockId}"]`);return s instanceof HTMLElement&&"rtl"===xe(s)?"left"===t?"right":"left":t}handleVerticalArrow(e){const t=this.deps.getState(),n=this.deps.contentElement.ownerDocument.getSelection?.()??null,s=n?N(n,this.deps.contentElement):null;if(!E(this.deps.contentElement,t,e,s))return!1;null===this.goalColumn&&s&&(this.goalColumn=s.left),this.preserveGoalColumn=!0;const i=A(this.deps.contentElement,t,e,this.goalColumn);return i?(this.deps.dispatch(i),this.preserveGoalColumn=!1,!0):(this.preserveGoalColumn=!1,!1)}validateSelectionAfterInlineSkip(){const e=this.deps.getState(),t=R(this.deps.contentElement);t&&L(t,e.selection)||b(this.deps.contentElement,e.selection)}};function Gn(e,t){const n=[];let s=null,i=[];for(const r of e){const e=t.getNodeSpec(r.type)?.wrapper?.(r);e&&s&&e.key===s.key?i.push(r.id):e?(s&&i.length>0&&n.push({spec:s,blockIds:i}),s=e,i=[r.id]):(s&&i.length>0&&n.push({spec:s,blockIds:i}),s=null,i=[])}return s&&i.length>0&&n.push({spec:s,blockIds:i}),n}function Qn(e,t){if(t.className&&e.className!==t.className&&(e.className=t.className),t.attrs)for(const[n,s]of Object.entries(t.attrs))e.getAttribute(n)!==s&&e.setAttribute(n,s)}function Jn(e){const t=document.createElement(e.tag);if(t.setAttribute("data-block-wrapper",e.key),e.className&&(t.className=e.className),e.attrs)for(const[n,s]of Object.entries(e.attrs))t.setAttribute(n,s);return t}function Xn(e,t,n){t!==(n?n.nextSibling:e.firstChild)&&(n||t.parentNode!==e||t!==e.firstChild)&&(n?n.after(t):e.insertBefore(t,e.firstChild))}function Yn(e,t,n){for(let i=0;i<t.length;i++){const s=t[i];if(!s)continue;const r=n.querySelector(`[data-block-id="${s}"]`);if(!r)continue;const o=e.children[i]??null;r!==o&&(o?e.insertBefore(r,o):e.appendChild(r))}const s=new Set(t);for(const i of Array.from(e.children)){const t=i.getAttribute("data-block-id");t&&!s.has(t)&&n.insertBefore(i,e)}}function Zn(e,t,n){if(!n)return;const s=Gn(t,n);for(const i of s){const t=e.querySelector(`[data-block-id="${i.blockIds[0]}"]`);if(!t)continue;const n=Jn(i.spec);t.before(n);for(const s of i.blockIds){const t=e.querySelector(`[data-block-id="${s}"]`);t&&n.appendChild(t)}}}function es(e){e.parentElement?.removeChild(e)}function ts(e,t,n){const s=e.parentElement;s?s.replaceChild(t,e):n.replaceChild(t,e)}function ns(e,t,n){if(t?.parentElement){const e=t.parentElement;return void(t.nextSibling?e.insertBefore(n,t.nextSibling):e.appendChild(n))}e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}function ss(e,t){if(t){const n=t.getInlineNodeSpec(e.inlineType);if(n){const t=n.toDOM(e);return t.setAttribute("contenteditable","false"),t}}const n=document.createElement("span");return n.setAttribute("data-inline-type",e.inlineType),n.setAttribute("contenteditable","false"),n}function is(e){let t=e.replace(/ {2}/g," ");return t.endsWith(" ")&&(t=`${t.slice(0,-1)} `),t.startsWith(" ")&&(t=` ${t.slice(1)}`),t}function rs(e){const t=e.nodeName??"span",n=document.createElement(t);if(n.setAttribute("data-decoration","true"),e.class)for(const s of e.class.split(" "))s&&n.classList.add(s);e.style&&Fe(n,e.style);for(const[s,i]of Object.entries(e))"class"!==s&&"style"!==s&&"nodeName"!==s&&void 0!==i&&n.setAttribute(s,i);return n}function os(e,t,n){const s=n?.decorations?.findNode(t);if(s&&0!==s.length)for(const i of s){if(i.attrs.class)for(const t of i.attrs.class.split(" "))t&&e.classList.add(t);i.attrs.style&&Ue(e,i.attrs.style)}}function as(e,t,n,s){const i=s?.decorations?.findInline(e.id),r=s?.nodeViewRegistry;if(r&&t&&n&&s?.getState&&s?.dispatch){const o=r.getNodeViewFactory(e.type);if(o){const r=o(e,s.getState,s.dispatch);n.set(e.id,r);const a=t.getNodeSpec(e.type);if(a?.isVoid&&r.dom.setAttribute("data-void","true"),a?.selectable&&r.dom.setAttribute("data-selectable","true"),r.contentDOM&&r.contentDOM!==r.dom&&r.contentDOM.setAttribute("data-content-dom","true"),S(e)&&r.contentDOM)cs(r.contentDOM,e,t,i);else{const i=d(e),o=/* @__PURE__ */new Map;for(const e of i){const i=r.getContentDOM?.(e.id)??r.contentDOM;if(i){const r=as(e,t,n,s);i.appendChild(r);let a=o.get(i);a||(a=[],o.set(i,a)),a.push(e)}}for(const[e,n]of o)Zn(e,n,t)}return r.dom.setAttribute("data-block-type",e.type),os(r.dom,e.id,s),r.dom}}if(t){const r=t.getNodeSpec(e.type);if(r){const o=r.toDOM(e);if(r.isVoid&&o.setAttribute("data-void","true"),r.selectable&&o.setAttribute("data-selectable","true"),!r.isVoid)if(S(e))cs(o,e,t,i);else{const i=d(e);for(const e of i){const i=as(e,t,n,s);o.appendChild(i)}Zn(o,i,t)}return o.setAttribute("data-block-type",e.type),os(o,e.id,s),o}}return function(e,t,n){const s=de("p",e.id);return s.setAttribute("data-block-type",e.type),cs(s,e,t,n),s}(e,t,i)}function cs(e,n,s,r){for(const t of e.querySelectorAll("[data-cursor-wrapper]"))t.remove();const o=c(n);if(1===o.length&&t(o[0])&&""===o[0].text)return void e.appendChild(document.createElement("br"));if(r&&0!==r.length)!function(e,t,n,s){let r=0;for(const o of t){if(i(o)){e.appendChild(ss(o,s)),r+=1;continue}const t=r,a=r+o.text.length;if(0===o.text.length){r=a;continue}const c=/* @__PURE__ */new Set;c.add(t),c.add(a);for(const e of n){const n=Math.max(t,e.from),s=Math.min(a,e.to);n>t&&n<a&&c.add(n),s>t&&s<a&&c.add(s)}const l=[...c].sort((e,t)=>e-t);for(let i=0;i<l.length-1;i++){const r=l[i],a=l[i+1];if(void 0===r||void 0===a||r>=a)continue;const c=r-t,h=a-t,d=o.text.slice(c,h),p=[];for(const e of n)e.from<=r&&e.to>=a&&p.push(e);let u=yn(document.createTextNode(is(d)),o.marks,s);for(const e of p){const t=rs(e.attrs);t.appendChild(u),u=t}e.appendChild(u)}r=a}}(e,o,r,s);else for(const i of o)t(i)?e.appendChild(ls(i,s)):e.appendChild(ss(i,s));const a=o[o.length-1];a&&i(a)&&"hard_break"===a.inlineType&&e.appendChild(document.createElement("br"))}function ls(e,t){return""===e.text?document.createTextNode(""):yn(document.createTextNode(is(e.text)),e.marks,t)}function hs(e,t,n,s){const i=t?.doc.children??[],r=n.doc.children,o=s?.registry,a=s?.nodeViews,c=null!=s?.compositionBlockId,l=/* @__PURE__ */new Map;for(const m of function(e){const t=[];for(const n of Array.from(e.children))if(n instanceof HTMLElement)if(n.hasAttribute("data-block-id"))t.push(n);else if(n.hasAttribute("data-block-wrapper"))for(const e of Array.from(n.children))e instanceof HTMLElement&&e.hasAttribute("data-block-id")&&t.push(e);return t}(e)){const e=m.getAttribute("data-block-id");e&&l.set(he(e),m)}const h=new Set(r.map(e=>e.id));for(const[m,f]of l)if(!h.has(m)){es(f),l.delete(m);const e=a?.get(m);e&&(e.destroy?.(),a?.delete(m))}const d=/* @__PURE__ */new Map;for(const m of i)d.set(m.id,m);let p=null;const u=s?.selectedNodeId,g=s?.previousSelectedNodeId;for(const m of r){const t=l.get(m.id),n=d.get(m.id);if(s?.compositionBlockId===m.id&&t){p=t;continue}const i=s?.oldDecorations?.find(m.id),r=s?.decorations?.find(m.id);if(t&&n&&!ds(n,m,i,r))p=t;else if(t){const n=a?.get(m.id);if(n){if(n.update?.(m)){if(S(m)&&n.contentDOM){n.contentDOM.textContent="";const e=s?.decorations?.findInline(m.id);cs(n.contentDOM,m,o,e)}p=n.dom;continue}n.destroy?.(),a?.delete(m.id)}const i=as(m,o,a,s);ts(t,i,e),p=i}else{const t=as(m,o,a,s);ns(e,p,t),p=t}if(u===m.id){const e=a?.get(m.id);if(e)e.selectNode?.();else{const e=l.get(m.id)??p;e instanceof HTMLElement&&e.classList.add("notectl-node-selected")}}else if(g===m.id){const e=a?.get(m.id);if(e)e.deselectNode?.();else{const e=l.get(m.id)??p;e instanceof HTMLElement&&e.classList.remove("notectl-node-selected")}}}if(g&&g!==u){const e=a?.get(g);e&&!h.has(g)&&e.deselectNode?.()}if(u&&!h.has(u)){const e=a?.get(u);e&&e.selectNode?.()}!c&&o&&function(e,t,n){const s=Gn(t,n),i=function(e,t){const n=[],s=/* @__PURE__ */new Set;for(const r of t)for(const e of r.blockIds)s.add(e);let i=0;for(const r of e){if(!s.has(r.id)){n.push({type:"bare",blockId:r.id});continue}const e=t[i];e&&e.blockIds[0]===r.id&&(n.push({type:"wrapper",key:e.spec.key,blockIds:e.blockIds}),i++)}return n}(t,s),r=function(e){const t=[];for(const n of Array.from(e.children))if(n instanceof HTMLElement)if(n.hasAttribute("data-block-wrapper")){const e=n.getAttribute("data-block-wrapper")??"",s=[];for(const t of Array.from(n.children)){if(!(t instanceof HTMLElement))continue;const e=t.getAttribute("data-block-id");e&&s.push(he(e))}t.push({type:"wrapper",element:n,key:e,blockIds:s})}else if(n.hasAttribute("data-block-id")){const e=n.getAttribute("data-block-id")??"";t.push({type:"bare",element:n,blockId:he(e)})}return t}(e);if(function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],i=t[n];if(!s||!i)return!1;if(s.type!==i.type)return!1;if("bare"===s.type&&"bare"===i.type){if(s.blockId!==i.blockId)return!1}else if("wrapper"===s.type&&"wrapper"===i.type){if(s.key!==i.key)return!1;if(s.blockIds.length!==i.blockIds.length)return!1;for(let e=0;e<s.blockIds.length;e++)if(s.blockIds[e]!==i.blockIds[e])return!1}}return!0}(i,r)){let e=0;for(const t of r)if("wrapper"===t.type){const n=s[e];n&&Qn(t.element,n.spec),e++}return}const o=/* @__PURE__ */new Map;for(const h of r){if("wrapper"!==h.type)continue;let e=o.get(h.key);e||(e=[],o.set(h.key,e)),e.push(h.element)}const a=/* @__PURE__ */new Set;let c=null,l=0;for(const h of i){if("bare"===h.type){const t=e.querySelector(`[data-block-id="${h.blockId}"]`);if(!t)continue;t.parentNode!==e?c?c.after(t):e.insertBefore(t,e.firstChild):Xn(e,t,c),c=t;continue}const t=s[l];if(!t)continue;l++;const n=o.get(h.key);let i=null;if(n&&n.length>0){const e=n.shift();e&&(i=e.tagName.toLowerCase()===t.spec.tag?e:Jn(t.spec))}i||(i=Jn(t.spec)),a.add(i),Qn(i,t.spec),i.parentNode!==e?c?c.after(i):e.insertBefore(i,e.firstChild):Xn(e,i,c),Yn(i,h.blockIds,e),c=i}for(const h of r)if("wrapper"===h.type&&!a.has(h.element)){for(;h.element.firstChild;)e.insertBefore(h.element.firstChild,h.element);h.element.remove()}}(e,r,o)}function ds(n,s,r,o){if(n.type!==s.type)return!0;if(n.children.length!==s.children.length)return!0;const a=n.attrs,c=s.attrs;if(a!==c){if(!a||!c)return!0;const e=Object.keys(a),t=Object.keys(c);if(e.length!==t.length)return!0;for(const n of e)if(a[n]!==c[n])return!0}for(let d=0;d<n.children.length;d++){const r=n.children[d],o=s.children[d];if(!r||!o)return!0;if(t(r)&&t(o)){if(r.text!==o.text)return!0;if(!e(r.marks,o.marks))return!0}else if(i(r)&&i(o)){if(r.inlineType!==o.inlineType)return!0;if(!ps(r.attrs,o.attrs))return!0}else{if(t(r)||t(o)||i(r)||i(o))return!0;if(ds(r,o))return!0}}const l=r??[],h=o??[];return l!==h&&!qe(l,h)}function ps(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const i of n)if(e[i]!==t[i])return!1;return!0}var us=class{state;contentElement;history;stateChangeCallbacks=[];isUpdating=!1;schemaRegistry;nodeViewRegistry;nodeViews=/* @__PURE__ */new Map;decorations=We.empty;getDecorations;isReadOnly;compositionState;cursorWrapper;navigation;events;constructor(e,t){this.state=t.state,this.contentElement=e,this.schemaRegistry=t.schemaRegistry,this.nodeViewRegistry=t.nodeViewRegistry,this.getDecorations=t.getDecorations,this.isReadOnly=t.isReadOnly??(()=>!1),this.compositionState=t.compositionState??{isComposing:!1,activeBlockId:null},this.history=new Ht({maxDepth:t.maxHistoryDepth??100}),t.onStateChange&&this.stateChangeCallbacks.push(t.onStateChange),this.cursorWrapper=new Sn(e,this.schemaRegistry),this.navigation=new Wn({contentElement:e,getState:()=>this.state,dispatch:e=>this.dispatch(e),keymapRegistry:t.keymapRegistry}),this.events=new qn({contentElement:e,getState:()=>this.state,dispatch:e=>this.dispatch(e),applyUpdate:(e,t,n)=>this.applyUpdate(e,t,{skipSelectionSync:n}),isUpdating:()=>this.isUpdating,compositionState:this.compositionState,cursorWrapper:this.cursorWrapper,isReadOnly:this.isReadOnly,fileHandlerRegistry:t.fileHandlerRegistry,onMousedown:()=>this.navigation.clearGoalColumn()}),this.decorations=this.getDecorations?.(this.state)??We.empty,hs(e,null,this.state,{...this.reconcileOptions(),decorations:this.decorations}),b(e,this.state.selection)}getState(){return this.state}applyUpdate(e,t,n){if(!this.isUpdating){this.isUpdating=!0;try{const s=this.state;this.state=e,this.cursorWrapper.isActive&&!e.storedMarks?.length&&this.cursorWrapper.cleanup(),(n?.pushHistory&&"history"!==t.metadata.origin||Dt(t))&&this.history.push(t);const i=this.getDecorations?.(e,t)??We.empty;this.reconcileAndSync(s,e,i,n?.skipSelectionSync);for(const n of this.stateChangeCallbacks)n(s,e,t);this.navigation.resetAfterUpdate()}finally{this.isUpdating=!1}}}dispatch(e){const t=this.state.apply(e);this.applyUpdate(t,e,{pushHistory:!0})}undo(){if(this.isUpdating||this.isReadOnly())return;const e=this.history.undo(this.state);e&&this.applyUpdate(e.state,e.transaction)}redo(){if(this.isUpdating||this.isReadOnly())return;const e=this.history.redo(this.state);e&&this.applyUpdate(e.state,e.transaction)}onStateChange(e){return this.stateChangeCallbacks.push(e),()=>{const t=this.stateChangeCallbacks.indexOf(e);-1!==t&&this.stateChangeCallbacks.splice(t,1)}}replaceState(e){if(!this.isUpdating){this.isUpdating=!0;try{const t=this.state;this.state=e,this.history.clear(),this.cursorWrapper.isActive&&!e.storedMarks?.length&&this.cursorWrapper.cleanup();const n={steps:[],selectionBefore:t.selection,selectionAfter:e.selection,storedMarksAfter:e.storedMarks,metadata:{origin:"api",timestamp:Date.now()}},s=this.getDecorations?.(e,n)??We.empty;this.reconcileAndSync(t,e,s);for(const i of this.stateChangeCallbacks)i(t,e,n);this.navigation.resetAfterUpdate()}finally{this.isUpdating=!1}}}syncSelection(){this.events.syncSelectionFromDOM()}reconcileAndSync(e,t,n,s){const i=this.decorations;this.decorations=n,hs(this.contentElement,e,t,{...this.reconcileOptions(e.selection),decorations:n,oldDecorations:i,compositionBlockId:this.compositionState.isComposing?this.compositionState.activeBlockId??void 0:void 0}),this.compositionState.isComposing||s||b(this.contentElement,t.selection)}reconcileOptions(e){const t=z(this.state.selection)?this.state.selection.nodeId:void 0,n=e&&z(e)?e.nodeId:void 0;return{registry:this.schemaRegistry,nodeViewRegistry:this.nodeViewRegistry,nodeViews:this.nodeViews,getState:()=>this.state,dispatch:e=>this.dispatch(e),selectedNodeId:t,previousSelectedNodeId:n}}destroy(){this.cursorWrapper.cleanup(),this.events.destroy(),this.navigation.destroy();for(const e of this.nodeViews.values())e.destroy?.();this.nodeViews.clear()}},gs={ariaLabel:"Rich text editor",ariaDescription:"Press Escape to exit the editor",defaultPlaceholder:"Start typing..."},ms=/* @__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-B-n_gMXb.mjs"),"./locales/de.ts":()=>import("./de-BjNoeX05.mjs"),"./locales/es.ts":()=>import("./es-CYKm6CQM.mjs"),"./locales/fr.ts":()=>import("./fr-DnP_hh5Q.mjs"),"./locales/hi.ts":()=>import("./hi-C9hGhR9D.mjs"),"./locales/pt.ts":()=>import("./pt-CDBahjbg.mjs"),"./locales/ru.ts":()=>import("./ru-ClE-ByL-.mjs"),"./locales/zh.ts":()=>import("./zh-CfCQsLZa.mjs")}),fs=["\n:host {\n\tdisplay: block;\n\tfont-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n\tfont-size: 16px;\n\tline-height: 1.6;\n\tcolor: var(--notectl-fg);\n}\n\n.notectl-editor {\n\tdisplay: flex;\n\tflex-direction: column;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: var(--notectl-border-radius, 6px);\n\toverflow: hidden;\n\tbackground: var(--notectl-bg);\n}\n\n.notectl-editor:focus-within {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* Content Area */\n.notectl-content {\n\tflex: 1;\n\tpadding: 12px 16px;\n\toutline: none;\n\tmin-height: var(--notectl-content-min-height, 400px);\n\tcursor: text;\n\tposition: relative;\n\twhite-space: pre-wrap;\n\tword-wrap: break-word;\n\t-webkit-user-select: text;\n\tuser-select: text;\n\t-moz-tab-size: 4;\n\ttab-size: 4;\n}\n\n.notectl-content p {\n\tmargin: 0;\n\tpadding: 2px 0;\n\tmin-height: 1.6em;\n}\n\n.notectl-content p + p {\n\tmargin-top: 0;\n}\n\n/* Horizontal Rule */\n.notectl-content hr {\n\tborder: none;\n\tborder-top: 1px solid var(--notectl-border);\n\tmargin: 8px 0;\n\tpadding: 0;\n\tcursor: default;\n\tuser-select: none;\n}\n\n/* Placeholder */\n.notectl-content.notectl-content--empty::before {\n\tcontent: attr(data-placeholder);\n\tcolor: var(--notectl-fg-muted);\n\tpointer-events: none;\n\tposition: absolute;\n\ttop: 12px;\n\tinset-inline-start: 16px;\n}\n\n/* Plugin container bottom */\n.notectl-plugin-container--bottom {\n\tborder-top: 1px solid var(--notectl-border);\n}\n\n/* Screen reader announcements */\n.notectl-sr-only {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tmargin: -1px;\n\tpadding: 0;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n/* Node selection */\n.notectl-node-selected {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n","\n@media (prefers-reduced-motion: reduce) {\n\t.notectl-toolbar-btn,\n\t.notectl-image__resize-handle,\n\t.notectl-image__size-indicator,\n\t.notectl-color-picker__swatch,\n\t.notectl-font-picker__item,\n\t.notectl-heading-picker__item,\n\t.notectl-font-size-picker__item,\n\t.ntbl-handle,\n\t.ntbl-handle-delete,\n\t.ntbl-insert-line,\n\t.ntbl-insert-btn,\n\t.ntbl-add-zone,\n\t.ntbl-add-icon,\n\t.ntbl-col-bar,\n\t.ntbl-row-bar,\n\t.ntbl-delete-table-btn,\n\t.notectl-code-block__copy {\n\t\ttransition: none !important;\n\t}\n}\n",'\n/* Paper viewport: scroll container with centered gray background */\n.notectl-paper-viewport {\n\tflex: 1;\n\toverflow-y: auto;\n\toverflow-x: hidden;\n\tbackground: var(--notectl-paper-viewport-bg, #e8e8e8);\n\tpadding: 24px 0;\n}\n\n/* Paper surface: white page with shadow, centered */\n.notectl-paper-surface {\n\tmargin: 0 auto;\n\tbackground: var(--notectl-bg);\n\tborder-radius: 2px;\n\tbox-shadow: 0 2px 8px var(--notectl-shadow, rgba(0, 0, 0, 0.15));\n\ttransform-origin: top center;\n\ttransition: transform 0.15s ease-out;\n}\n\n/* Content overrides in paper mode: wider document margins */\n.notectl-editor[data-paper-mode] .notectl-content {\n\tflex: none;\n\tpadding: 48px 56px;\n\tmin-height: auto;\n}\n\n/* Placeholder position override for paper mode */\n.notectl-editor[data-paper-mode] .notectl-content.notectl-content--empty::before {\n\ttop: 48px;\n\tinset-inline-start: 56px;\n}\n\n/* Dark mode: darker viewport background */\n:host([theme="dark"]) .notectl-paper-viewport {\n\t--notectl-paper-viewport-bg: #181825;\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.notectl-paper-surface {\n\t\ttransition: none !important;\n\t}\n}\n'].join("\n"),ys=null,ks=class{themeStyleSheet=new CSSStyleSheet;systemThemeQuery=null;systemThemeHandler=null;pluginSheets=[];runtimeSheets=[];shadow;constructor(e){this.shadow=e}apply(e){if(this.cleanupSystemThemeListener(),e===et.System){this.setupSystemThemeListener();const e=Xe(this.getSystemTheme());this.setThemeStyleSheet(e)}else this.setThemeStyleSheet(Xe(e))}setPluginStyleSheets(e){this.pluginSheets=e,this.refreshAdoptedStyleSheets()}setRuntimeStyleSheets(e){this.runtimeSheets=e,this.refreshAdoptedStyleSheets()}destroy(){this.cleanupSystemThemeListener()}setThemeStyleSheet(e){this.themeStyleSheet.replaceSync(Ze(e)),this.refreshAdoptedStyleSheets()}refreshAdoptedStyleSheets(){this.shadow.adoptedStyleSheets=[this.themeStyleSheet,(ys||(ys=new CSSStyleSheet).replaceSync(fs),ys),...this.pluginSheets,...this.runtimeSheets]}setupSystemThemeListener(){this.systemThemeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.systemThemeHandler=e=>{const t=Xe(this.getSystemTheme());this.setThemeStyleSheet(t)},this.systemThemeQuery.addEventListener("change",this.systemThemeHandler)}cleanupSystemThemeListener(){this.systemThemeQuery&&this.systemThemeHandler&&this.systemThemeQuery.removeEventListener("change",this.systemThemeHandler),this.systemThemeQuery=null,this.systemThemeHandler=null}getSystemTheme(){return(this.systemThemeQuery??window.matchMedia("(prefers-color-scheme: dark)")).matches?et.Dark:et.Light}},Ss=class{wrapper;content;viewport=null;surface=null;viewportObserver=null;surfaceObserver=null;currentSize=null;currentPaperWidthPx=0;currentPaperHeightPx=0;currentScale=1;compensationFrameId=null;constructor(e,t){this.wrapper=e,this.content=t}apply(e){if(null===e)return void this.disable();const t=nt(e);this.currentPaperWidthPx=t.widthPx,this.currentPaperHeightPx=t.heightPx,this.currentSize=e,this.viewport||this.enable(),this.updateSurfaceDimensions(),this.wrapper.setAttribute("data-paper-mode",e)}destroy(){this.disable()}getPaperSize(){return this.currentSize}enable(){this.viewport=document.createElement("div"),this.viewport.className="notectl-paper-viewport",this.surface=document.createElement("div"),this.surface.className="notectl-paper-surface",this.wrapper.removeChild(this.content),this.surface.appendChild(this.content),this.viewport.appendChild(this.surface);const e=this.wrapper.querySelector(".notectl-plugin-container--bottom");e?this.wrapper.insertBefore(this.viewport,e):this.wrapper.appendChild(this.viewport),this.viewportObserver=new ResizeObserver(e=>{for(const t of e)this.onViewportResize(t.contentRect.width)}),this.viewportObserver.observe(this.viewport),this.surfaceObserver=new ResizeObserver(e=>{for(const t of e)this.onSurfaceResize(t.contentRect.height)}),this.surfaceObserver.observe(this.surface)}disable(){if(null!==this.compensationFrameId&&(cancelAnimationFrame(this.compensationFrameId),this.compensationFrameId=null),this.viewportObserver?.disconnect(),this.viewportObserver=null,this.surfaceObserver?.disconnect(),this.surfaceObserver=null,this.viewport&&this.surface){this.surface.removeChild(this.content);const e=this.wrapper.querySelector(".notectl-plugin-container--bottom");e?this.wrapper.insertBefore(this.content,e):this.wrapper.appendChild(this.content),this.wrapper.removeChild(this.viewport)}this.viewport=null,this.surface=null,this.currentSize=null,this.currentPaperWidthPx=0,this.currentPaperHeightPx=0,this.currentScale=1,this.wrapper.removeAttribute("data-paper-mode")}updateSurfaceDimensions(){this.surface&&(je(this.surface,"width",`${this.currentPaperWidthPx}px`),je(this.surface,"minHeight",`${this.currentPaperHeightPx}px`))}onViewportResize(e){if(!this.surface||0===this.currentPaperWidthPx)return;const t=e-48,n=Math.min(1,t/this.currentPaperWidthPx);this.currentScale=n,je(this.surface,"transform",n<1?`scale(${n})`:""),this.scheduleHeightCompensation(n)}onSurfaceResize(e){this.surface&&this.viewport&&this.scheduleHeightCompensation(this.currentScale)}scheduleHeightCompensation(e){null!==this.compensationFrameId&&cancelAnimationFrame(this.compensationFrameId),this.compensationFrameId=requestAnimationFrame(()=>{this.compensationFrameId=null,this.updateHeightCompensation(e)})}updateHeightCompensation(e){if(!this.surface)return;if(e>=1)return void je(this.surface,"marginBottom","");const t=this.surface.scrollHeight,n=t*e-t;je(this.surface,"marginBottom",`${n}px`)}};function ws(e){return!Array.isArray(e)}var vs=class{cfg;themeController=null;domElements=null;paperLayout=null;pluginManager=null;inputManager=null;view=null;cleanedUp=!1;constructor(e){this.deps=e,this.cfg=e.config}async run(){try{if(this.setupTheme(),this.isCancelled())return this.abort();const e=await async function(e){const t=new ot(e.locale??"browser").getLocale();return"en"===t?gs:await async function(e){if("en"===e)return gs;const t=ms[`./locales/${e}.ts`];if(!t)return gs;try{return(await t()).default}catch{return gs}}(t)}(this.cfg);if(this.isCancelled())return this.abort();if(this.setupDOM(e),this.setupPlugins(),await this.initPluginsAndView(),this.isCancelled()||!this.view||!this.inputManager||!this.pluginManager||!this.domElements||!this.themeController)return this.abort();const t=this.view,n=this.inputManager,s=this.pluginManager,i=this.domElements,r=this.themeController;return this.finalizeSetup(s,i),{view:t,inputManager:n,pluginManager:s,domElements:i,themeController:r,paperLayout:this.paperLayout,release:()=>{this.view=null}}}catch(e){throw await this.cleanup(),e}}setupTheme(){this.themeController=new ks(this.deps.shadow),this.deps.styleCoordinator.setup(this.deps.shadow,this.cfg.styleNonce,this.themeController),this.themeController.apply(this.cfg.theme??et.Light)}setupDOM(e){this.domElements=function(e){const t=e.locale??gs,n=t.defaultPlaceholder,s=document.createElement("div");s.className="notectl-editor";const i=document.createElement("div");i.className="notectl-plugin-container--top",i.setAttribute("data-notectl-no-print","");const r=document.createElement("div");r.className="notectl-content",r.contentEditable=e.readonly?"false":"true",r.setAttribute("role","textbox"),r.setAttribute("aria-multiline","true"),r.setAttribute("aria-label",t.ariaLabel),e.readonly&&r.setAttribute("aria-readonly","true"),r.setAttribute("aria-description",t.ariaDescription),r.setAttribute("data-default-placeholder",n),r.setAttribute("data-placeholder",e.placeholder??n),e.dir&&(s.setAttribute("dir",e.dir),r.setAttribute("dir",e.dir));const o=document.createElement("div");o.className="notectl-plugin-container--bottom",o.setAttribute("data-notectl-no-print","");const a=document.createElement("div");return a.className="notectl-sr-only",a.setAttribute("data-notectl-no-print",""),a.setAttribute("aria-live","polite"),a.setAttribute("aria-atomic","true"),s.appendChild(i),s.appendChild(r),s.appendChild(o),s.appendChild(a),{wrapper:s,content:r,topPluginContainer:i,bottomPluginContainer:o,announcer:a}}({readonly:this.cfg.readonly,placeholder:this.cfg.placeholder,dir:this.cfg.dir??this.deps.hostDir,locale:e}),this.deps.shadow.appendChild(this.domElements.wrapper),this.cfg.paperSize&&(this.paperLayout=new Ss(this.domElements.wrapper,this.domElements.content),this.paperLayout.apply(this.cfg.paperSize))}setupPlugins(){if(this.domElements){this.pluginManager=new Nn,this.pluginManager.registerService(at,new ot(this.cfg.locale??"browser")),gt(this.pluginManager.schemaRegistry),function(e,t){if(!t)return;const n=ws(t)?t.groups:t,s=ws(t)?t.overflow:void 0,i=[];for(const o of n){const t=[];for(const n of o)t.push(n.id),e.register(n);i.push(t)}const r={groups:i,overflow:s};e.register(new Je(r))}(this.pluginManager,this.cfg.toolbar);for(const e of this.cfg.plugins??[])this.pluginManager.register(e);for(const e of this.deps.preInitPlugins)this.pluginManager.register(e);e=this.pluginManager,t=this.cfg.features,function(e,t){if(void 0!==e.get("text-formatting"))return;const n={bold:t?.bold??!0,italic:t?.italic??!0,underline:t?.underline??!0};e.register(new lt(n))}(e,t),function(e){void 0===e.get("caret-navigation")&&e.register(new P)}(e),function(e){void 0===e.get("gap-cursor")&&e.register(new ct)}(e),this.domElements.content.addEventListener("focus",()=>this.deps.events.emit("focus",void 0)),this.domElements.content.addEventListener("blur",()=>this.deps.events.emit("blur",void 0))}var e,t}async initPluginsAndView(){if(!this.pluginManager||!this.domElements||!this.themeController)return;const e=this.domElements,t=this.pluginManager,n=this.themeController;await t.init({isCancelled:()=>this.isCancelled(),getState:()=>{if(!this.view)throw new Error("View not initialized");return this.view.getState()},dispatch:e=>this.dispatch(e),getContainer:()=>e.content,getPluginContainer:t=>"top"===t?e.topPluginContainer:e.bottomPluginContainer,announce:t=>{e.announcer&&(e.announcer.textContent=t)},hasAnnouncement:()=>!!e.announcer?.textContent,onBeforeReady:()=>this.createInputAndView(e,t,n)})}createInputAndView(e,t,n){if(this.isCancelled()||!this.pluginManager||!this.themeController)return;const s=re(t.schemaRegistry),i=At.create({schema:s});this.inputManager=new hn(e.content,{getState:()=>{if(!this.view)throw new Error("View not initialized");return this.view.getState()},dispatch:e=>this.dispatch(e),syncSelection:()=>this.view?.syncSelection(),undo:()=>this.view?.undo(),redo:()=>this.view?.redo(),schemaRegistry:t.schemaRegistry,keymapRegistry:t.keymapRegistry,inputRuleRegistry:t.inputRuleRegistry,fileHandlerRegistry:t.fileHandlerRegistry,isReadOnly:()=>this.deps.configController.isReadOnly,getPasteInterceptors:()=>t.getPasteInterceptors(),getTextDirection:xe,navigateFromGapCursor:ke}),this.view=new us(e.content,{state:i,schemaRegistry:t.schemaRegistry,keymapRegistry:t.keymapRegistry,fileHandlerRegistry:t.fileHandlerRegistry,nodeViewRegistry:t.nodeViewRegistry,maxHistoryDepth:this.cfg.maxHistoryDepth,getDecorations:(e,n)=>t.collectDecorations(e,n)??We.empty,onStateChange:(n,s,i)=>{!function(e,t,n,s,i,r){const o=s.announcer;if(o&&(o.textContent=""),i.notifyStateChange(e,t,n),bs(s.content,t.doc),r.emit("stateChange",{oldState:e,newState:t,transaction:n}),L(e.selection,t.selection)||r.emit("selectionChange",{selection:t.selection}),!o?.textContent){const s=function(e,t,n){if("undo"===n.metadata.historyDirection)return"Undo";if("redo"===n.metadata.historyDirection)return"Redo";for(const s of n.steps)if("setBlockType"===s.type)return Dn(s.nodeType,s.attrs);for(const s of t.schema.markTypes){const n=le(s),i=X(e,n),r=X(t,n);if(i!==r)return`${s} ${r?"on":"off"}`}return null}(e,t,n);s&&o&&(o.textContent=s)}}(n,s,i,e,t,this.deps.events)},isReadOnly:()=>this.deps.configController.isReadOnly,compositionState:this.inputManager.compositionTracker}),bs(e.content,this.view.getState().doc);const r=t.getPluginStyleSheets();r.length>0&&n.setPluginStyleSheets(r)}finalizeSetup(e,t){if(this.cfg.readonly&&e.setReadOnly(!0),e.onEvent(st,e=>{!e.options.paperSize&&this.deps.configController.getPaperSize()&&(e.options={...e.options,paperSize:this.deps.configController.getPaperSize()})}),this.cfg.autofocus){const e=t.content;requestAnimationFrame(()=>e.focus())}}dispatch(e){this.view&&this.pluginManager&&(!this.deps.configController.isReadOnly||Lt(e)||this.pluginManager.isReadonlyBypassed())&&this.pluginManager.dispatchWithMiddleware(e,this.view.getState(),e=>this.view?.dispatch(e))}isCancelled(){return this.deps.isCancelled?.()??!1}async abort(){return await this.cleanup(),null}async cleanup(){if(this.cleanedUp)return;this.cleanedUp=!0;const e=this.view;this.view=null,this.paperLayout?.destroy(),this.paperLayout=null,this.deps.styleCoordinator.teardown(this.deps.shadow,this.themeController),this.themeController?.destroy(),this.themeController=null,this.inputManager?.destroy(),this.inputManager=null,e?.destroy();const t=this.pluginManager;this.pluginManager=null,await(t?.destroy()),this.domElements?.wrapper.remove(),this.domElements=null}};function bs(e,t){e.classList.toggle("notectl-content--empty",$n(t))}var Rs=class{state="idle";readyPromiseResolve=null;readyPromiseReject=null;readyPromise;preInitPlugins=[];constructor(){this.readyPromise=this.createReadyPromise()}isInitialized(){return"initializing"===this.state||"ready"===this.state}markInitialized(){return"initializing"!==this.state&&"ready"!==this.state&&("failed"===this.state&&(this.readyPromise=this.createReadyPromise()),this.state="initializing",!0)}whenReady(){return this.readyPromise}resolveReady(){"initializing"===this.state&&(this.state="ready",this.readyPromiseResolve?.(),this.readyPromiseResolve=null,this.readyPromiseReject=null)}failReady(e){"initializing"===this.state&&(this.state="failed",this.readyPromiseReject?.(e),this.readyPromiseResolve=null,this.readyPromiseReject=null)}registerPreInitPlugin(e){if("initializing"===this.state||"ready"===this.state)throw new Error("Cannot register plugins after initialization. Register before calling init() or adding to DOM.");this.preInitPlugins.push(e)}consumePreInitPlugins(){const e=this.preInitPlugins;return this.preInitPlugins=[],e}restorePreInitPlugins(e){0!==e.length&&(this.preInitPlugins=[...e,...this.preInitPlugins])}reset(){this.state="idle",this.preInitPlugins=[],this.readyPromise=this.createReadyPromise()}createReadyPromise(){const e=new Promise((e,t)=>{this.readyPromiseResolve=e,this.readyPromiseReject=t});return e.catch(()=>{}),e}},Cs=class{runtimeStyleSheet=null;setup(e,t,n){Ve(e),this.runtimeStyleSheet=$e(),n?.setRuntimeStyleSheets(this.runtimeStyleSheet?[this.runtimeStyleSheet]:[]),Ke(e,{nonce:t,sheet:this.runtimeStyleSheet})}teardown(e,t){e&&Ve(e),this.runtimeStyleSheet=null,t?.setRuntimeStyleSheets([])}},Is=class extends HTMLElement{view=null;inputManager=null;pluginManager=null;domElements=null;configController=new jn;events=new Un;lifecycle=new Rs;styleCoordinator=new Cs;themeController=null;paperLayout=null;pendingInitPromise=null;cancelPendingInit=null;autoInitToken=0;autoInitQueued=!1;initVersion=0;releaseInit=null;constructor(){super(),this.attachShadow({mode:"open"})}static get observedAttributes(){return["placeholder","readonly","theme","paper-size","dir"]}connectedCallback(){this.lifecycle.isInitialized()||this.scheduleAutoInit()}disconnectedCallback(){setTimeout(()=>{this.isConnected||this.destroy()},0)}attributeChangedCallback(e,t,n){this.configController.applyAttribute(e,n,this.getConfigDeps())}registerPlugin(e){this.lifecycle.registerPreInitPlugin(e)}async init(e){if(this.cancelAutoInit(),!this.lifecycle.markInitialized())return;e&&this.configController.setConfig(e);const t=this.shadowRoot;if(!t){const e=/* @__PURE__ */new Error("Editor shadow root not available.");throw this.lifecycle.failReady(e),e}const n=++this.initVersion;let s=!1;this.cancelPendingInit=()=>{s=!0};const i=this.lifecycle.consumePreInitPlugins(),r=async function(e){return new vs(e).run()}({shadow:t,config:this.configController.getConfig(),hostDir:this.getAttribute("dir")??void 0,configController:this.configController,styleCoordinator:this.styleCoordinator,events:this.events,preInitPlugins:i,isCancelled:()=>s||n!==this.initVersion});this.pendingInitPromise=r;try{const e=await r;if(!e){if(s||n!==this.initVersion)return;throw new Error("Editor initialization completed without a result.")}if(n!==this.initVersion)return;this.view=e.view,this.inputManager=e.inputManager,this.pluginManager=e.pluginManager,this.domElements=e.domElements,this.themeController=e.themeController,this.paperLayout=e.paperLayout,this.releaseInit=e.release,this.lifecycle.resolveReady(),this.events.emit("ready",void 0)}catch(o){throw n===this.initVersion&&(this.lifecycle.restorePreInitPlugins(i),this.lifecycle.failReady(o)),o}finally{this.pendingInitPromise===r&&(this.pendingInitPromise=null,this.cancelPendingInit=null)}}get isReadOnly(){return this.configController.isReadOnly}getJSON(){if(!this.view)throw new Error("Editor not initialized");return this.view.getState().doc}setJSON(e){this.assertInitialized(),Kn(e,this.pluginManager?.schemaRegistry,e=>this.replaceState(e))}async getContentHTML(e){if(!this.view)throw new Error("Editor not initialized");return function(e,t,n){const s=e.doc;if("classes"===n?.cssMode){const e=Pe(s,t);return n.pretty?{html:ue(e.html),css:e.css,styleMap:e.styleMap}:e}const i=Te(s,t);return n?.pretty?ue(i):i}(this.view.getState(),this.pluginManager?.schemaRegistry,e)}async setContentHTML(e,t){return this.assertInitialized(),function(e,t,n,s){Kn(Ae(e,t,s),t,n)}(e,this.pluginManager?.schemaRegistry,e=>this.replaceState(e),t)}getText(){if(!this.view)throw new Error("Editor not initialized");return this.view.getState().doc.children.map(e=>p(e)).join("\n")}isEmpty(){return!this.view||$n(this.view.getState().doc)}commands={toggleBold:()=>this.executeCommand("toggleBold"),toggleItalic:()=>this.executeCommand("toggleItalic"),toggleUnderline:()=>this.executeCommand("toggleUnderline"),undo:()=>{this.configController.isReadOnly||this.view?.undo()},redo:()=>{this.configController.isReadOnly||this.view?.redo()},selectAll:()=>{if(!this.view)return;const e=Z(this.view.getState());this.dispatch(e)}};can(){const e=this.view?.getState().schema,t=this.configController.isReadOnly;return{toggleBold:()=>!t&&!!e&&j(e,"bold"),toggleItalic:()=>!t&&!!e&&j(e,"italic"),toggleUnderline:()=>!t&&!!e&&j(e,"underline"),undo:()=>!t&&(this.view?.history.canUndo()??!1),redo:()=>!t&&(this.view?.history.canRedo()??!1),selectAll:()=>this.canExecuteCommand("selectAll")}}canExecuteCommand(e){return this.pluginManager?.canExecuteCommand(e)??!1}executeCommand(e){return this.pluginManager?.executeCommand(e)??!1}configurePlugin(e,t){this.pluginManager?.configurePlugin(e,t)}getService(e){return this.pluginManager?.getService(e)}onPluginEvent(e,t){return this.pluginManager?.onEvent(e,t)??(()=>{})}getState(){if(!this.view)throw new Error("Editor not initialized");return this.view.getState()}dispatch(e){this.view&&this.pluginManager&&(!this.configController.isReadOnly||Lt(e)||this.pluginManager.isReadonlyBypassed())&&this.pluginManager.dispatchWithMiddleware(e,this.view.getState(),e=>this.view?.dispatch(e))}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}whenReady(){return this.lifecycle.whenReady()}configure(e){this.configController.applyRuntimeConfig(e,this.getConfigDeps())}setTheme(e){this.configController.applyTheme(e,this.themeController)}getTheme(){return this.configController.getTheme()}getPaperSize(){return this.configController.getPaperSize()}destroy(){this.cancelAutoInit(),this.initVersion++,this.cancelPendingInit?.(),this.cancelPendingInit=null;const e=this.pendingInitPromise?.then(()=>{},()=>{})??Promise.resolve();this.pendingInitPromise=null,this.releaseInit?.(),this.releaseInit=null,this.paperLayout?.destroy(),this.paperLayout=null,this.styleCoordinator.teardown(this.shadowRoot,this.themeController),this.themeController?.destroy(),this.themeController=null,this.inputManager?.destroy(),this.inputManager=null,this.view?.destroy();const t=this.pluginManager?.destroy()??Promise.resolve();return this.view=null,this.pluginManager=null,this.lifecycle.reset(),this.events.clear(),this.domElements?.wrapper.remove(),this.domElements=null,Promise.all([t,e]).then(()=>{})}getConfigDeps(){return{contentElement:this.domElements?.content??null,editorWrapper:this.domElements?.wrapper??null,pluginManager:this.pluginManager,themeController:this.themeController,applyPaperSize:e=>this.applyPaperSize(e)}}scheduleAutoInit(){const e=++this.autoInitToken;this.autoInitQueued=!0,queueMicrotask(()=>{this.isConnected&&this.autoInitQueued&&this.autoInitToken===e&&(this.autoInitQueued=!1,this.lifecycle.isInitialized()||this.init().catch(()=>{}))})}cancelAutoInit(){this.autoInitToken++,this.autoInitQueued=!1}applyPaperSize(e){this.domElements&&(e?(this.paperLayout||(this.paperLayout=new Ss(this.domElements.wrapper,this.domElements.content)),this.paperLayout.apply(e)):this.paperLayout?.apply(null))}replaceState(e){this.view&&this.view.replaceState(e)}assertInitialized(){if(!this.view)throw new Error("Editor not initialized")}};async function xs(e){const t=document.createElement("notectl-editor");return await t.init(e),t}"undefined"==typeof customElements||customElements.get("notectl-editor")||customElements.define("notectl-editor",Is);export{ut as A,At as C,Ct as D,Et as E,gt as O,Dt as S,Tt as T,Vt as _,Fn as a,Ht as b,Bn as c,Sn as d,mn as f,hn as g,dn as h,Ln as i,dt as j,pt as k,Nn as l,pn as m,xs as n,Hn as o,un as p,_n as r,Dn as s,Is as t,wn as u,Kt as v,Mt as w,Lt as x,_t as y};
|
|
2
|
-
//# sourceMappingURL=src-CgbuJfYr.mjs.map
|