@notectl/core 2.3.1 → 2.3.3

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.
Files changed (197) hide show
  1. package/README.md +1 -1
  2. package/THIRD-PARTY-NOTICES.md +129 -0
  3. package/dist/chunks/{AlignmentPlugin--xAFlRqE.mjs → AlignmentPlugin-C9Rr_R-g.mjs} +2 -2
  4. package/dist/chunks/{AlignmentPlugin--xAFlRqE.mjs.map → AlignmentPlugin-C9Rr_R-g.mjs.map} +1 -1
  5. package/dist/chunks/{AttributedMarkCommands-bagbH8Qt.mjs → AttributedMarkCommands-BCvmqeFZ.mjs} +2 -2
  6. package/dist/chunks/{AttributedMarkCommands-bagbH8Qt.mjs.map → AttributedMarkCommands-BCvmqeFZ.mjs.map} +1 -1
  7. package/dist/chunks/{BidiIsolationPlugin-DBXyXpgm.mjs → BidiIsolationPlugin-Cw2KMk-H.mjs} +2 -2
  8. package/dist/chunks/{BidiIsolationPlugin-DBXyXpgm.mjs.map → BidiIsolationPlugin-Cw2KMk-H.mjs.map} +1 -1
  9. package/dist/chunks/{BlockInsertion-CJusvrDL.mjs → BlockInsertion-CYH2gRkY.mjs} +2 -2
  10. package/dist/chunks/{BlockInsertion-CJusvrDL.mjs.map → BlockInsertion-CYH2gRkY.mjs.map} +1 -1
  11. package/dist/chunks/{BlockquotePlugin-Bz2glHwX.mjs → BlockquotePlugin-0bZSbkyo.mjs} +2 -2
  12. package/dist/chunks/{BlockquotePlugin-Bz2glHwX.mjs.map → BlockquotePlugin-0bZSbkyo.mjs.map} +1 -1
  13. package/dist/chunks/CaretNavigationPlugin-BPZ9b6XR.mjs +2 -0
  14. package/dist/chunks/CaretNavigationPlugin-BPZ9b6XR.mjs.map +1 -0
  15. package/dist/chunks/CodeBlockPlugin-BCJ3faXx.mjs +2 -0
  16. package/dist/chunks/{CodeBlockPlugin-C1hrdbSZ.mjs.map → CodeBlockPlugin-BCJ3faXx.mjs.map} +1 -1
  17. package/dist/chunks/{ColorGrid-C9RQoEWF.mjs → ColorGrid-DQEkJ-0y.mjs} +2 -2
  18. package/dist/chunks/{ColorGrid-C9RQoEWF.mjs.map → ColorGrid-DQEkJ-0y.mjs.map} +1 -1
  19. package/dist/chunks/ColorPickerPopup-CyF26zIU.mjs +2 -0
  20. package/dist/chunks/{ColorPickerPopup-DiA68Pzz.mjs.map → ColorPickerPopup-CyF26zIU.mjs.map} +1 -1
  21. package/dist/chunks/Commands-D5ND50PQ.mjs +2 -0
  22. package/dist/chunks/{Commands-1dFFldi7.mjs.map → Commands-D5ND50PQ.mjs.map} +1 -1
  23. package/dist/chunks/{Decoration-BpoEOANl.mjs → Decoration-BOP1TAUd.mjs} +2 -2
  24. package/dist/chunks/{Decoration-BpoEOANl.mjs.map → Decoration-BOP1TAUd.mjs.map} +1 -1
  25. package/dist/chunks/{FontPlugin-By-TGrQo.mjs → FontPlugin-D041tiLe.mjs} +2 -2
  26. package/dist/chunks/{FontPlugin-By-TGrQo.mjs.map → FontPlugin-D041tiLe.mjs.map} +1 -1
  27. package/dist/chunks/{FontSizePlugin-Dln-tYXV.mjs → FontSizePlugin-8CAvj1RD.mjs} +2 -2
  28. package/dist/chunks/{FontSizePlugin-Dln-tYXV.mjs.map → FontSizePlugin-8CAvj1RD.mjs.map} +1 -1
  29. package/dist/chunks/{FormulaPlugin-By1befrR.mjs → FormulaPlugin-DJ39BtqV.mjs} +2 -2
  30. package/dist/chunks/FormulaPlugin-DJ39BtqV.mjs.map +1 -0
  31. package/dist/chunks/GapCursorNavigation-DCWOmopl.mjs +2 -0
  32. package/dist/chunks/{GapCursorNavigation-BuXngVu-.mjs.map → GapCursorNavigation-DCWOmopl.mjs.map} +1 -1
  33. package/dist/chunks/GapCursorPlugin-2iR6506y.mjs +2 -0
  34. package/dist/chunks/{GapCursorPlugin-DAxVzXRs.mjs.map → GapCursorPlugin-2iR6506y.mjs.map} +1 -1
  35. package/dist/chunks/{HardBreakPlugin-DlbSlrdq.mjs → HardBreakPlugin-vniSvTgq.mjs} +2 -2
  36. package/dist/chunks/{HardBreakPlugin-DlbSlrdq.mjs.map → HardBreakPlugin-vniSvTgq.mjs.map} +1 -1
  37. package/dist/chunks/{HeadingPlugin-uMAjPOk5.mjs → HeadingPlugin-DUKsLuMd.mjs} +2 -2
  38. package/dist/chunks/{HeadingPlugin-uMAjPOk5.mjs.map → HeadingPlugin-DUKsLuMd.mjs.map} +1 -1
  39. package/dist/chunks/{HighlightPlugin-Bj7FPkIQ.mjs → HighlightPlugin-DRTAE1N5.mjs} +2 -2
  40. package/dist/chunks/{HighlightPlugin-Bj7FPkIQ.mjs.map → HighlightPlugin-DRTAE1N5.mjs.map} +1 -1
  41. package/dist/chunks/HorizontalRulePlugin-B9OvwrKB.mjs +2 -0
  42. package/dist/chunks/{HorizontalRulePlugin-DUVmTQpX.mjs.map → HorizontalRulePlugin-B9OvwrKB.mjs.map} +1 -1
  43. package/dist/chunks/{ImagePlugin-FToCOjd5.mjs → ImagePlugin-CwxTRr6d.mjs} +2 -2
  44. package/dist/chunks/{ImagePlugin-FToCOjd5.mjs.map → ImagePlugin-CwxTRr6d.mjs.map} +1 -1
  45. package/dist/chunks/{InlineCodePlugin-pISIoGQE.mjs → InlineCodePlugin-uxgMUX_E.mjs} +2 -2
  46. package/dist/chunks/{InlineCodePlugin-pISIoGQE.mjs.map → InlineCodePlugin-uxgMUX_E.mjs.map} +1 -1
  47. package/dist/chunks/{LinkPlugin-Ct5Z180S.mjs → LinkPlugin-CvWHbSkb.mjs} +2 -2
  48. package/dist/chunks/{LinkPlugin-Ct5Z180S.mjs.map → LinkPlugin-CvWHbSkb.mjs.map} +1 -1
  49. package/dist/chunks/{ListPlugin-DAY5ezNs.mjs → ListPlugin-BchSFWVn.mjs} +2 -2
  50. package/dist/chunks/{ListPlugin-DAY5ezNs.mjs.map → ListPlugin-BchSFWVn.mjs.map} +1 -1
  51. package/dist/chunks/{MarkdownHTMLRegistry-CKEx7LkR.mjs → MarkdownHTMLRegistry-Q7l0d6Ma.mjs} +2 -2
  52. package/dist/chunks/{MarkdownHTMLRegistry-CKEx7LkR.mjs.map → MarkdownHTMLRegistry-Q7l0d6Ma.mjs.map} +1 -1
  53. package/dist/chunks/{MarkdownParser-CWt3M6jR.mjs → MarkdownParser-Dp62mfUq.mjs} +2 -2
  54. package/dist/chunks/{MarkdownParser-CWt3M6jR.mjs.map → MarkdownParser-Dp62mfUq.mjs.map} +1 -1
  55. package/dist/chunks/{MarkdownSerializer-J-i28out.mjs → MarkdownSerializer-DBELFAeo.mjs} +2 -2
  56. package/dist/chunks/{MarkdownSerializer-J-i28out.mjs.map → MarkdownSerializer-DBELFAeo.mjs.map} +1 -1
  57. package/dist/chunks/MathFont-BS8IwYh2.mjs +2 -0
  58. package/dist/chunks/MathFont-BS8IwYh2.mjs.map +1 -0
  59. package/dist/chunks/NodeSelectionCommands-WH5snxr_.mjs +2 -0
  60. package/dist/chunks/{NodeSelectionCommands-1PjwUDTJ.mjs.map → NodeSelectionCommands-WH5snxr_.mjs.map} +1 -1
  61. package/dist/chunks/PluginHelpers-KDuTlmXm.mjs +2 -0
  62. package/dist/chunks/{PluginHelpers-Dx_0hfDe.mjs.map → PluginHelpers-KDuTlmXm.mjs.map} +1 -1
  63. package/dist/chunks/{PopupManager-CT-fMZJn.mjs → PopupManager-Cj86uDEB.mjs} +2 -2
  64. package/dist/chunks/{PopupManager-CT-fMZJn.mjs.map → PopupManager-Cj86uDEB.mjs.map} +1 -1
  65. package/dist/chunks/PrintPlugin-D2javl_d.mjs +2 -0
  66. package/dist/chunks/{PrintPlugin-7zz9mhhU.mjs.map → PrintPlugin-D2javl_d.mjs.map} +1 -1
  67. package/dist/chunks/SimpleMark-gTQaSJcO.mjs +2 -0
  68. package/dist/chunks/{SimpleMark-7CQcA4RK.mjs.map → SimpleMark-gTQaSJcO.mjs.map} +1 -1
  69. package/dist/chunks/SmartPastePlugin-BvJQ-fOz.mjs +2 -0
  70. package/dist/chunks/SmartPastePlugin-BvJQ-fOz.mjs.map +1 -0
  71. package/dist/chunks/StarterFonts-BDQPg-cu.mjs +2 -0
  72. package/dist/chunks/StarterFonts-BDQPg-cu.mjs.map +1 -0
  73. package/dist/chunks/{StrikethroughPlugin-C2oWvGc3.mjs → StrikethroughPlugin-BdrG1TTY.mjs} +2 -2
  74. package/dist/chunks/{StrikethroughPlugin-C2oWvGc3.mjs.map → StrikethroughPlugin-BdrG1TTY.mjs.map} +1 -1
  75. package/dist/chunks/{SuperSubPlugin-D1xaKrSu.mjs → SuperSubPlugin-DTZB0Y3D.mjs} +2 -2
  76. package/dist/chunks/{SuperSubPlugin-D1xaKrSu.mjs.map → SuperSubPlugin-DTZB0Y3D.mjs.map} +1 -1
  77. package/dist/chunks/{TablePlugin-PJe3zwr-.mjs → TablePlugin-CPvg9YZS.mjs} +2 -2
  78. package/dist/chunks/{TablePlugin-PJe3zwr-.mjs.map → TablePlugin-CPvg9YZS.mjs.map} +1 -1
  79. package/dist/chunks/{TextColorPlugin-CTd9tfeG.mjs → TextColorPlugin-Ckg3KWvb.mjs} +2 -2
  80. package/dist/chunks/{TextColorPlugin-CTd9tfeG.mjs.map → TextColorPlugin-Ckg3KWvb.mjs.map} +1 -1
  81. package/dist/chunks/{TextDirectionAutoPlugin-CPnKVVuI.mjs → TextDirectionAutoPlugin-DRGbgTlx.mjs} +2 -2
  82. package/dist/chunks/{TextDirectionAutoPlugin-CPnKVVuI.mjs.map → TextDirectionAutoPlugin-DRGbgTlx.mjs.map} +1 -1
  83. package/dist/chunks/TextDirectionPlugin-BCeYyJHo.mjs +2 -0
  84. package/dist/chunks/{TextDirectionPlugin-Bns_03vL.mjs.map → TextDirectionPlugin-BCeYyJHo.mjs.map} +1 -1
  85. package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +2 -0
  86. package/dist/chunks/{TextDirectionService-BcX07mw2.mjs.map → TextDirectionService-OFOU6r_s.mjs.map} +1 -1
  87. package/dist/chunks/TextFormattingPlugin-BhRxSC8q.mjs +2 -0
  88. package/dist/chunks/{TextFormattingPlugin-DBVlePqj.mjs.map → TextFormattingPlugin-BhRxSC8q.mjs.map} +1 -1
  89. package/dist/chunks/ThemeEngine-BUVo_zaT.mjs +3 -0
  90. package/dist/chunks/ThemeEngine-BUVo_zaT.mjs.map +1 -0
  91. package/dist/chunks/ToolbarPlugin-dmTj1jIz.mjs +2 -0
  92. package/dist/chunks/{ToolbarPlugin-DtfGTO_V.mjs.map → ToolbarPlugin-dmTj1jIz.mjs.map} +1 -1
  93. package/dist/chunks/{VideoPlugin-BrR8g6Rz.mjs → VideoPlugin-BugkI7-m.mjs} +2 -2
  94. package/dist/chunks/{VideoPlugin-BrR8g6Rz.mjs.map → VideoPlugin-BugkI7-m.mjs.map} +1 -1
  95. package/dist/chunks/XmlSupport-DIXH5on9.mjs +2 -0
  96. package/dist/chunks/XmlSupport-DIXH5on9.mjs.map +1 -0
  97. package/dist/chunks/full-JM0-SwWy.mjs +2 -0
  98. package/dist/chunks/{full-DSWM4cKQ.mjs.map → full-JM0-SwWy.mjs.map} +1 -1
  99. package/dist/chunks/minimal-DSlR2A27.mjs +2 -0
  100. package/dist/chunks/{minimal-CFkkPXef.mjs.map → minimal-DSlR2A27.mjs.map} +1 -1
  101. package/dist/chunks/register-BjsdJ3Aq.mjs +2 -0
  102. package/dist/chunks/register-BjsdJ3Aq.mjs.map +1 -0
  103. package/dist/chunks/src-5GKFQ2mQ.mjs +2 -0
  104. package/dist/chunks/src-5GKFQ2mQ.mjs.map +1 -0
  105. package/dist/chunks/xml-BsV44TrJ.mjs +2 -0
  106. package/dist/chunks/xml-BsV44TrJ.mjs.map +1 -0
  107. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  108. package/dist/fonts/math.d.ts +3 -0
  109. package/dist/fonts/math.d.ts.map +1 -0
  110. package/dist/fonts/math.mjs +1 -0
  111. package/dist/fonts/starter.d.ts +3 -0
  112. package/dist/fonts/starter.d.ts.map +1 -0
  113. package/dist/fonts/starter.mjs +1 -0
  114. package/dist/fonts.d.ts +4 -4
  115. package/dist/fonts.mjs +1 -1
  116. package/dist/full.d.ts +1 -1
  117. package/dist/full.mjs +1 -1
  118. package/dist/index.d.ts +2 -1
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/markdown.mjs +1 -1
  121. package/dist/notectl-core.mjs +1 -1
  122. package/dist/notectl-core.umd.js +1 -1
  123. package/dist/notectl-core.umd.js.map +1 -1
  124. package/dist/plugins/alignment.mjs +1 -1
  125. package/dist/plugins/bidi-isolation.mjs +1 -1
  126. package/dist/plugins/blockquote.mjs +1 -1
  127. package/dist/plugins/caret-navigation.mjs +1 -1
  128. package/dist/plugins/code-block/CodeBlockHighlighting.d.ts.map +1 -1
  129. package/dist/plugins/code-block.mjs +1 -1
  130. package/dist/plugins/font-size.mjs +1 -1
  131. package/dist/plugins/font.mjs +1 -1
  132. package/dist/plugins/formula/FormulaTypes.d.ts +1 -1
  133. package/dist/plugins/formula.mjs +1 -1
  134. package/dist/plugins/gap-cursor.mjs +1 -1
  135. package/dist/plugins/hard-break.mjs +1 -1
  136. package/dist/plugins/heading.mjs +1 -1
  137. package/dist/plugins/highlight.mjs +1 -1
  138. package/dist/plugins/horizontal-rule.mjs +1 -1
  139. package/dist/plugins/image.mjs +1 -1
  140. package/dist/plugins/inline-code.mjs +1 -1
  141. package/dist/plugins/language.mjs +1 -1
  142. package/dist/plugins/link.mjs +1 -1
  143. package/dist/plugins/list.mjs +1 -1
  144. package/dist/plugins/print.mjs +1 -1
  145. package/dist/plugins/shared.mjs +1 -1
  146. package/dist/plugins/smart-paste/SmartPastePlugin.d.ts.map +1 -1
  147. package/dist/plugins/smart-paste.mjs +1 -1
  148. package/dist/plugins/strikethrough.mjs +1 -1
  149. package/dist/plugins/super-sub.mjs +1 -1
  150. package/dist/plugins/table.mjs +1 -1
  151. package/dist/plugins/text-color.mjs +1 -1
  152. package/dist/plugins/text-direction-auto.mjs +1 -1
  153. package/dist/plugins/text-direction.mjs +1 -1
  154. package/dist/plugins/text-formatting.mjs +1 -1
  155. package/dist/plugins/toolbar.mjs +1 -1
  156. package/dist/plugins/video.mjs +1 -1
  157. package/dist/presets/full.d.ts +1 -1
  158. package/dist/presets/full.mjs +1 -1
  159. package/dist/presets/minimal.d.ts +1 -1
  160. package/dist/presets/minimal.mjs +1 -1
  161. package/dist/presets.d.ts +1 -1
  162. package/dist/presets.mjs +1 -1
  163. package/dist/register.d.ts +3 -0
  164. package/dist/register.d.ts.map +1 -0
  165. package/dist/register.mjs +1 -0
  166. package/package.json +24 -223
  167. package/dist/chunks/CaretNavigationPlugin-CNsT0eb4.mjs +0 -2
  168. package/dist/chunks/CaretNavigationPlugin-CNsT0eb4.mjs.map +0 -1
  169. package/dist/chunks/CodeBlockPlugin-C1hrdbSZ.mjs +0 -2
  170. package/dist/chunks/ColorPickerPopup-DiA68Pzz.mjs +0 -2
  171. package/dist/chunks/Commands-1dFFldi7.mjs +0 -2
  172. package/dist/chunks/FormulaPlugin-By1befrR.mjs.map +0 -1
  173. package/dist/chunks/GapCursorNavigation-BuXngVu-.mjs +0 -2
  174. package/dist/chunks/GapCursorPlugin-DAxVzXRs.mjs +0 -2
  175. package/dist/chunks/HorizontalRulePlugin-DUVmTQpX.mjs +0 -2
  176. package/dist/chunks/NodeSelectionCommands-1PjwUDTJ.mjs +0 -2
  177. package/dist/chunks/PluginHelpers-Dx_0hfDe.mjs +0 -2
  178. package/dist/chunks/PrintPlugin-7zz9mhhU.mjs +0 -2
  179. package/dist/chunks/PrintTypes-CxU69qu3.mjs +0 -3
  180. package/dist/chunks/PrintTypes-CxU69qu3.mjs.map +0 -1
  181. package/dist/chunks/SimpleMark-7CQcA4RK.mjs +0 -2
  182. package/dist/chunks/SmartPastePlugin-CYa_nD9v.mjs +0 -2
  183. package/dist/chunks/SmartPastePlugin-CYa_nD9v.mjs.map +0 -1
  184. package/dist/chunks/TextDirectionPlugin-Bns_03vL.mjs +0 -2
  185. package/dist/chunks/TextDirectionService-BcX07mw2.mjs +0 -2
  186. package/dist/chunks/TextFormattingPlugin-DBVlePqj.mjs +0 -2
  187. package/dist/chunks/ToolbarPlugin-DtfGTO_V.mjs +0 -2
  188. package/dist/chunks/XmlDetector-D7TQpw-e.mjs +0 -2
  189. package/dist/chunks/XmlDetector-D7TQpw-e.mjs.map +0 -1
  190. package/dist/chunks/XmlSupport-BYiRwlkK.mjs +0 -2
  191. package/dist/chunks/XmlSupport-BYiRwlkK.mjs.map +0 -1
  192. package/dist/chunks/fonts-DQC6Uj4r.mjs +0 -2
  193. package/dist/chunks/fonts-DQC6Uj4r.mjs.map +0 -1
  194. package/dist/chunks/full-DSWM4cKQ.mjs +0 -2
  195. package/dist/chunks/minimal-CFkkPXef.mjs +0 -2
  196. package/dist/chunks/src-DiAOfuOT.mjs +0 -2
  197. package/dist/chunks/src-DiAOfuOT.mjs.map +0 -1
@@ -1,2 +0,0 @@
1
- import{h as t}from"./Document-827l3P80.mjs";import{a as r,c as e,r as n,t as o}from"./Selection-HYoVFpAx.mjs";import{r as s}from"./NodeResolver-Dleih-8R.mjs";import{i}from"./NavigationQueries-Bt4zZ17v.mjs";import{t as l}from"./Platform-ByobkiCc.mjs";function u(t,r,e){return t.transaction("input").setSelection(o(r,e)).setStoredMarks(null,t.storedMarks).build()}function c(t,r){const e=s(t.doc,r)??[];return t.transaction("input").setSelection(n(r,e)).setStoredMarks(null,t.storedMarks).build()}function a(t,e,n,o,s){return t.transaction("input").setSelection(r({blockId:e,offset:n},{blockId:o,offset:s})).setStoredMarks(null,t.storedMarks).build()}function f(r,n,o){const s=r.selection;if(!e(s))return null;const a=r.getBlockOrder(),f=a.indexOf(s.blockId);if(f<0)return null;const d=function(t,r,e){if(!e)return t;if("left"!==t&&"right"!==t)return t;const n=e.querySelector(`[data-block-id="${r}"]`);return n instanceof HTMLElement?"rtl"!==l(n)?t:"left"===t?"right":"left":t}(n,s.blockId,o);if("before"===s.side&&("right"===d||"down"===d)||"after"===s.side&&("left"===d||"up"===d))return c(r,s.blockId);const m="before"===s.side?f-1:f+1;if(m<0||m>=a.length)return null;const k=a[m];if(!k)return null;if(i(r,k))return c(r,k);const b=r.getBlock(k);return b?u(r,k,"left"===d||"up"===d?t(b):0):null}export{c as i,a as n,u as r,f as t};
2
- //# sourceMappingURL=GapCursorNavigation-BuXngVu-.mjs.map
@@ -1,2 +0,0 @@
1
- import{c as t}from"./Selection-HYoVFpAx.mjs";import{t as e}from"./GapCursorNavigation-BuXngVu-.mjs";import{c as n,o}from"./PluginHelpers-Dx_0hfDe.mjs";var r={gapCursorActive:"Gap cursor active. Type to insert new paragraph."},s=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-CR6UdFL9.mjs"),"./locales/de.ts":()=>import("./de-CHcv_Vmf.mjs"),"./locales/es.ts":()=>import("./es-BIXm2Coj.mjs"),"./locales/fr.ts":()=>import("./fr-Bg937iAy.mjs"),"./locales/hi.ts":()=>import("./hi-B5cl8TWK.mjs"),"./locales/pt.ts":()=>import("./pt-UPF7DBlz.mjs"),"./locales/ru.ts":()=>import("./ru-CkG_bpfo.mjs"),"./locales/zh.ts":()=>import("./zh-CWIzJcXi.mjs")});async function i(t){return n(s,t,r)}var a=class{id="gap-cursor";name="Gap Cursor";priority=5;context=null;activeCursorBlockId=null;activeCursorSide=null;locale=r;async init(n){this.locale=await o(n,void 0,r,i),this.context=n,n.registerStyleSheet("\n.notectl-gap-cursor--before,\n.notectl-gap-cursor--after {\n\tposition: relative;\n}\n.notectl-gap-cursor--before::before {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(-50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n.notectl-gap-cursor--after::after {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\tbottom: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n\t.notectl-gap-cursor--before::before,\n\t.notectl-gap-cursor--after::after {\n\t\tanimation: none;\n\t}\n}\n@keyframes notectl-gap-blink {\n\t50% { opacity: 0; }\n}\n");const s={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"},a={};for(const[o,r]of Object.entries(s))a[o]=()=>{const o=n.getState();if(!t(o.selection))return!1;const s=e(o,r,n.getContainer());return!!s&&(n.dispatch(s),!0)};n.registerKeymap(a,{priority:"navigation"})}onReady(){this.context&&this.syncCursorClass(this.context.getState())}onStateChange(e,n,o){this.context&&(this.syncCursorClass(n),!t(e.selection)&&t(n.selection)&&this.context.announce(this.locale.gapCursorActive))}destroy(){this.clearCursorClass(),this.context=null}syncCursorClass(e){if(this.clearCursorClass(),!t(e.selection)||!this.context)return;const n="before"===e.selection.side?"notectl-gap-cursor--before":"notectl-gap-cursor--after",o=this.context.getContainer().querySelector(`[data-block-id="${e.selection.blockId}"]`);o instanceof HTMLElement&&(o.classList.add(n),this.activeCursorBlockId=e.selection.blockId,this.activeCursorSide=e.selection.side)}clearCursorClass(){if(!this.context||!this.activeCursorBlockId||!this.activeCursorSide)return;const t=this.context.getContainer().querySelector(`[data-block-id="${this.activeCursorBlockId}"]`);t instanceof HTMLElement&&t.classList.remove("notectl-gap-cursor--before","notectl-gap-cursor--after"),this.activeCursorBlockId=null,this.activeCursorSide=null}};export{a as t};
2
- //# sourceMappingURL=GapCursorPlugin-DAxVzXRs.mjs.map
@@ -1,2 +0,0 @@
1
- import{o as t}from"./Document-827l3P80.mjs";import{o,t as e,u as r}from"./Selection-HYoVFpAx.mjs";import{a as i}from"./TypeBrands-Ch9856Gb.mjs";import{n as s}from"./DomUtils-Bf7JLFlx.mjs";import{s as l}from"./BlockInsertion-CJusvrDL.mjs";import{c as n,i as a,o as c}from"./PluginHelpers-Dx_0hfDe.mjs";import{t as m}from"./ShortcutFormatting-TwiufqeV.mjs";var p={label:"Horizontal Rule",tooltip:t=>`Horizontal Rule (${t})`},u=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-CrOb0jL2.mjs"),"./locales/de.ts":()=>import("./de-C7uehgMu.mjs"),"./locales/es.ts":()=>import("./es-xuahrvJN.mjs"),"./locales/fr.ts":()=>import("./fr-B9pBLaVx.mjs"),"./locales/hi.ts":()=>import("./hi-DWX6k5ZD.mjs"),"./locales/pt.ts":()=>import("./pt-DFKJVh7k.mjs"),"./locales/ru.ts":()=>import("./ru-q8kz-237.mjs"),"./locales/zh.ts":()=>import("./zh-BGYJXxVl.mjs")});async function h(t){return n(u,t,p)}var d={},g=class{id="horizontal-rule";name="Horizontal Rule";priority=40;config;locale;constructor(t){this.config={...d,...t}}async init(t){this.locale=await c(t,this.config.locale,p,h),this.registerNodeSpec(t),this.registerCommands(t),this.registerKeymap(t),!1!==this.config.inputRule&&this.registerInputRule(t),this.registerToolbarItem(t)}registerNodeSpec(t){t.registerNodeSpec({type:"horizontal_rule",group:"block",isVoid:!0,toDOM:t=>s("hr",t.id),toHTML:()=>"<hr>",parseHTML:[{tag:"hr"}],sanitize:{tags:["hr"]}})}registerCommands(t){t.registerCommand("insertHorizontalRule",()=>this.insertHorizontalRule(t))}registerKeymap(t){t.registerKeymap({"Mod-Shift-H":()=>t.executeCommand("insertHorizontalRule")})}registerInputRule(s){s.registerInputRule({pattern:/^-{3,} $/,handler(s,l,n,a){const c=s.selection;if(!r(c))return null;if(!o(c))return null;const m=s.getBlock(c.anchor.blockId);if(!m||"paragraph"!==m.type)return null;const p=function(t){const o=t.selection;return r(o)?t.doc.children.findIndex(t=>t.id===o.anchor.blockId):-1}(s);if(-1===p)return null;const u=t(i("paragraph"));return s.transaction("input").deleteTextAt(c.anchor.blockId,0,a).setBlockType(c.anchor.blockId,i("horizontal_rule")).insertNode([],p+1,u).setSelection(e(u.id,0)).build()}})}registerToolbarItem(t){t.registerToolbarItem({id:"horizontal-rule",group:"block",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11h16v2H4z"/></svg>',label:this.locale.label,tooltip:this.locale.tooltip(m("Mod-Shift-H")),command:"insertHorizontalRule",isActive:()=>!1})}insertHorizontalRule(o){const r=o.getState(),s=a(r);if(!s)return!1;const n=r.transaction("command"),c=l(r,n,s,t(i("horizontal_rule")));return!!c&&(n.setSelection(e(c.id,0)),o.dispatch(n.build()),!0)}};export{p as n,h as r,g as t};
2
- //# sourceMappingURL=HorizontalRulePlugin-DUVmTQpX.mjs.map
@@ -1,2 +0,0 @@
1
- import{c as t,f as n,h as e,w as i}from"./Document-827l3P80.mjs";import{c as o,l as r,n as s,o as c,r as l,t as u}from"./Selection-HYoVFpAx.mjs";import{r as a}from"./NodeResolver-Dleih-8R.mjs";import{i as d}from"./NavigationQueries-Bt4zZ17v.mjs";import{T as f,_ as b,l as p}from"./BlockInsertion-CJusvrDL.mjs";function h(e,o){const{parentPath:r,siblings:s,index:c}=f(e,o.nodeId);if(c<0)return null;const l=e.transaction("input");if(1===s.length){const e=n();return l.insertNode(r,0,t(e)),l.removeNode(r,1),l.setSelection(u(e,0)),l.build()}l.removeNode(r,c);const a=s[c-1];if(a&&i(a)){const t=b(e,a.id,"end");if(t)return l.setSelection(t),l.build()}const d=s[c+1];if(d&&i(d)){const t=b(e,d.id,"start");if(t)return l.setSelection(t),l.build()}return null}function m(t,n){if(n<0)return;const e=t[n+1];return e&&i(e)&&p(e)?e:void 0}function g(e,i){const{parentPath:o,siblings:r,index:s}=f(e,i.nodeId);if(s<0)return null;const c=m(r,s);if(c)return e.transaction("input").setSelection(u(c.id,0)).build();const l=n(),a=e.transaction("input");return a.insertNode(o,s+1,t(l)),a.setSelection(u(l,0)),a.build()}function S(e,i,o,r){const{parentPath:s,siblings:c,index:l}=f(e,i.nodeId),a=e.transaction(r),d=m(c,l);if(d)return a.insertText(d.id,0,o,[]),a.setSelection(u(d.id,o.length)),a.build();const b=n(),p=l>=0?l+1:c.length;return a.insertNode(s,p,t(b)),a.insertText(b,0,o,[]),a.setSelection(u(b,o.length)),a.build()}function I(t,n,i){const f=t.selection,b=t.getBlockOrder(),p=!i||"left"!==n&&"right"!==n?n:"left"===n?"right":"left";return r(f)?function(t,n,i,o){const r=o.indexOf(n.nodeId),c=a(t.doc,n.nodeId)??[];if("left"===i||"up"===i){if(r>0){const i=o[r-1];if(!i)return null;if(d(t,i))return t.transaction("input").setSelection(s(n.nodeId,"before",c)).build();const l=t.getBlock(i),a=l?e(l):0;return t.transaction("input").setSelection(u(i,a)).build()}return t.transaction("input").setSelection(s(n.nodeId,"before",c)).build()}if(r<o.length-1){const e=o[r+1];return e?d(t,e)?t.transaction("input").setSelection(s(n.nodeId,"after",c)).build():t.transaction("input").setSelection(u(e,0)).build():null}return t.transaction("input").setSelection(s(n.nodeId,"after",c)).build()}(t,f,p,b):o(f)?null:c(f)?function(t,n,i,o){const r=o.indexOf(n.anchor.blockId),s=t.getBlock(n.anchor.blockId);if(!s)return null;const c=e(s);if(("right"===i||"down"===i)&&n.anchor.offset===c&&r<o.length-1){const n=o[r+1];if(n&&d(t,n)){const e=a(t.doc,n)??[];return t.transaction("input").setSelection(l(n,e)).build()}}if(("left"===i||"up"===i)&&0===n.anchor.offset&&r>0){const n=o[r-1];if(n&&d(t,n)){const e=a(t.doc,n)??[];return t.transaction("input").setSelection(l(n,e)).build()}}return null}(t,f,p,b):null}export{I as i,g as n,S as r,h as t};
2
- //# sourceMappingURL=NodeSelectionCommands-1PjwUDTJ.mjs.map
@@ -1,2 +0,0 @@
1
- import{l as e,u as n}from"./Selection-HYoVFpAx.mjs";import{n as t}from"./TypedKeys-CA4bfw9O.mjs";var r=class{resolvedLocale;constructor(e){this.resolvedLocale="browser"===e?"undefined"!=typeof navigator?navigator.language.split("-")[0]??"en":"en":e}getLocale(){return this.resolvedLocale}},o=new t("locale");async function c(e,n,t){if("en"===n)return t;const r=e[`./locales/${n}.ts`];if(!r)return t;try{return(await r()).default}catch{return t}}function s(e,n){return!!n&&(e.dispatch(n),!0)}function a(e){return e.charAt(0).toUpperCase()+e.slice(1)}function i(e){return`toggle${a(e)}`}async function l(e,n,t,r){if(n)return n;const c=e.getService(o)?.getLocale()??"en";return"en"===c?t:r(c)}function u(t){const r=t.selection;return e(r)?t.getBlock(r.nodeId):n(r)?t.getBlock(r.anchor.blockId):void 0}function d(t){const r=t.selection;return e(r)?r.nodeId:n(r)?r.anchor.blockId:void 0}function f(t){const r=t.selection;if(e(r))return[r.nodeId];if(!n(r))return[];const o=r.anchor.blockId,c=r.head.blockId;if(o===c)return[o];const s=t.getBlockOrder(),a=s.indexOf(o),i=s.indexOf(c);if(-1===a||-1===i)return[];const l=Math.min(a,i),u=Math.max(a,i);return s.slice(l,u+1)}export{f as a,c,d as i,r as l,s as n,l as o,u as r,i as s,a as t,o as u};
2
- //# sourceMappingURL=PluginHelpers-Dx_0hfDe.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as t,n as e,r as n}from"./HTMLUtils-Bhg3_P8B.mjs";import{i as o,l as r,r as s,s as i}from"./StyleRuntime-DW6omotc.mjs";import{_ as a,c,d as l,h as u,i as d,n as p,r as f,s as h,t as m}from"./PrintTypes-CxU69qu3.mjs";import{c as g,o as y}from"./PluginHelpers-Dx_0hfDe.mjs";import{t as b}from"./ShortcutFormatting-TwiufqeV.mjs";import v from"dompurify";var $={label:"Print",tooltip:t=>`Print (${t})`,printingAnnouncement:"Printing"},S=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-Uzo1Azdw.mjs"),"./locales/de.ts":()=>import("./de-DcMhfRBu.mjs"),"./locales/es.ts":()=>import("./es-BJHF95J_.mjs"),"./locales/fr.ts":()=>import("./fr-KXmbys88.mjs"),"./locales/hi.ts":()=>import("./hi-l6DA-aOw.mjs"),"./locales/pt.ts":()=>import("./pt-C8sOyw0V.mjs"),"./locales/ru.ts":()=>import("./ru-B1m8J9dl.mjs"),"./locales/zh.ts":()=>import("./zh-dGSDBBzb.mjs")});async function w(t){return g(S,t,$)}var k=["h1","h2","h3","h4","h5","h6","p","div","span","br","hr","strong","b","em","i","u","s","sub","sup","small","ul","ol","li","table","thead","tbody","tr","th","td","img"],T=["style","class","src","alt","width","height","colspan","rowspan"];function C(t){const e="function"==typeof t?t():t;return v.sanitize(e,{ALLOWED_TAGS:[...k],ALLOWED_ATTR:[...T]})}var j=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),A=new Set(["TABLE","THEAD","TBODY","TFOOT","TR"]),L=new Set(["AUDIO","CANVAS","EMBED","IFRAME","IMG","INPUT","METER","OBJECT","PROGRESS","SELECT","TEXTAREA","VIDEO"]);function x(t,e){let n;do{n=`${t}-${crypto.randomUUID()}`}while(e.has(n));return e.add(n),n}function E(t){const e=/* @__PURE__ */new Map;t.matches("[data-block-id][id]")&&""!==t.id&&e.set(t.id,t);for(const n of t.querySelectorAll("[data-block-id][id]")){const t=n.id;""===t||e.has(t)||e.set(t,n)}return e}function M(e,n){for(const o of t(n)){const t=e.get(o);if(t)return t}}function R(t,e,n,o){const r=x("notectl-print-destination",n),s=x("notectl-print-destination-slot",o),i=e.createElement("slot");i.name=s,i.setAttribute("data-notectl-print-destination-slot",""),function(t,e){if(j.has(t.tagName)||L.has(t.tagName))t.before(e);else{if(A.has(t.tagName)){const n=t.querySelector("th, td");if(n)return void n.insertBefore(e,n.firstChild);const o=t.closest("table");if(o?.parentNode)return void o.before(e)}t.insertBefore(e,t.firstChild)}}(t,i);const a=e.createElement("a");return a.id=r,a.setAttribute("href",`#${r}`),a.slot=s,a.tabIndex=-1,a.setAttribute("aria-hidden","true"),a.setAttribute("data-notectl-print-destination",""),function(t){for(const[e,n]of Object.entries({all:"initial",display:"block",position:"absolute",width:"0",height:"0",margin:"0",padding:"0",border:"0",overflow:"hidden","pointer-events":"none","font-size":"0","line-height":"0",color:"transparent",background:"transparent"}))t.style.setProperty(e,n,"important")}(a),{id:r,marker:a}}var N="notectl-host";function B(t){const e=Array.from(t.styleSheets),n=t.adoptedStyleSheets;return n&&e.push(...n),e}function H(t,e){const n=t[e]??'"';let o=e+1;for(;o<t.length;){const e=t[o]??"";if("\\"!==e){if(e===n)return o+1;o++}else o+=2}return t.length}function z(t,e){if("url("!==t.slice(e,e+4).toLowerCase())return!1;const n=e>0?t[e-1]??"":"";return!/[\w-]/.test(n)}function P(t,e){let n=e+4;for(;n<t.length&&/\s/.test(t[n]??"");)n++;const o=t[n]??"";let r;if('"'===o||"'"===o){const e=H(t,n);r=t.slice(n+1,e-1),n=e}else{const e=t.indexOf(")",n);if(-1===e)return null;r=t.slice(n,e).trim(),n=e}for(;n<t.length&&/\s/.test(t[n]??"");)n++;return")"!==t[n]?null:{end:n+1,url:(s=r,s.replace(/\\([0-9a-f]{1,6}\s?|[\s\S])/gi,(t,e)=>{const n=e.trim();if(/^[0-9a-f]{1,6}$/i.test(n)){const t=Number.parseInt(n,16);return t>0&&t<=1114111?String.fromCodePoint(t):"�"}return e}))};var s}function q(t,e,n){if(!e||!function(t){return!t.startsWith("#")&&!t.startsWith("//")&&!/^[a-z][a-z0-9+.-]*:/i.test(t)}(e))return t;try{return`url("${new URL(e,n).href}")`}catch{return t}}function D(t,e){if(!t.toLowerCase().includes("url("))return t;let n="",o=0;for(;o<t.length;){const r=t[o]??"";if('"'===r||"'"===r){const e=H(t,o);n+=t.slice(o,e),o=e;continue}if(z(t,o)){const r=P(t,o);if(r){n+=q(t.slice(o,r.end),r.url,e),o=r.end;continue}}n+=r,o++}return n}function O(t){return t.anonymousLayerCount+=1,`notectl-anonymous-${t.anonymousLayerCount}`}var I={media:[],layers:[],supports:[]};function U(t,e,n,o){const r=e.trim(),s=o?.trim()??"";return{media:r&&"all"!==r?[...t.media,r]:t.media,layers:null===n?t.layers:[...t.layers,""===n?null:n],supports:s?[...t.supports,s]:t.supports}}function W(t,e,n){const o=[N];for(const c of n.layers)o.push(c??O(t));const r=0===(s=n.supports).length?"":1===s.length?` supports(${s[0]})`:` supports(${s.map(t=>`(${t})`).join(" and ")})`;var s;const i=n.media.length?` ${n.media.join(" and ")}`:"";var a;t.segments.push({kind:"import",statement:`@import url("${a=e,a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}") layer(${o.join(".")})${r}${i};`})}function V(t,e){const n=e.trim();return n&&"all"!==n?`@media ${n} {\n${t}\n}`:t}function G(t,e){if(e.seen.has(t))return;if(e.seen.add(t),t.disabled)return;const n=U(I,t.media.mediaText,null,null);let o;try{o=t.cssRules}catch{return void(t.href&&W(e,t.href,n))}const r=t.href??e.baseURL,s=[];for(const a of o)3!==a.type?s.push(D(a.cssText,r)):F(a,e,s,n);const i=s.join("\n");i&&function(t,e){const n=t.segments[t.segments.length-1];"rules"!==n?.kind?t.segments.push({kind:"rules",css:e}):t.segments[t.segments.length-1]={kind:"rules",css:`${n.css}\n${e}`}}(e,V(i,t.media.mediaText))}function F(t,e,n,o){const r=t.layerName??null,s=t.supportsText??null,i=U(o,t.media.mediaText,r,s),a=t.styleSheet;if(a&&!e.seen.has(a)){let o;try{o=a.cssRules}catch{o=null}if(o){e.seen.add(a);const c=a.href??e.baseURL,l=[];for(const t of o)3!==t.type?l.push(D(t.cssText,c)):F(t,e,l,i);let u=l.join("\n");return void(u&&(null!==r&&(u=""===r?`@layer {\n${u}\n}`:`@layer ${r} {\n${u}\n}`),s?.trim()&&(u=`@supports (${s.trim()}) {\n${u}\n}`),n.push(V(u,t.media.mediaText))))}}const c=a?.href??t.href;c&&W(e,c,i)}var K="notectl-print",_="notectl-custom";function Y(t){return t.replace(/;$/gm," !important;")}function J(t){return Y(u(a).replace(":host {",`${t} {`))}function X(t,e){const n=getComputedStyle(t),o=[];for(let r=0;r<n.length;r++){const t=n[r]??"";if(t.startsWith("--notectl-")){const e=n.getPropertyValue(t).trim();e&&o.push(` ${t}: ${e};`)}}return 0===o.length?"":`${e} {\n${o.join("\n")}\n}`}var Q=["","transparent","rgba(0, 0, 0, 0)"];function Z(t){let e=t;for(;e;){const t=getComputedStyle(e).getPropertyValue("background-color").trim();if(!Q.includes(t))return t;const n=e.getRootNode();e=e.parentElement??(n instanceof ShadowRoot?n.host:null)}return"#ffffff"}function tt(t,e,n="#ffffff",o="body"){const r=getComputedStyle(t),s=["font-family","font-size","font-weight","line-height","letter-spacing","word-spacing","color"],i=[" margin: 0;",` background: ${n};`];for(const a of s){if("color"===a&&e){i.push(` color: ${e};`);continue}const t=r.getPropertyValue(a).trim();t&&i.push(` ${a}: ${t};`)}return`${o} {\n${i.join("\n")}\n}`}var et=["display: block","position: static","inset: auto","width: auto","height: auto","min-width: 0","min-height: 0","max-width: none","max-height: none","margin: 0","padding: 0","border: none","border-radius: 0","outline: none","box-shadow: none","background: transparent","overflow: visible","transform: none","filter: none","opacity: 1","contain: none","float: none","visibility: visible","clip: auto","clip-path: none","content-visibility: visible"],nt=["display: block","visibility: visible","opacity: 1","position: static","height: auto","min-height: 0","max-height: none","overflow: visible","transform: none","filter: none","contain: none","clip: auto","clip-path: none","content-visibility: visible"];function ot(t){return[`${t} {`,...et.map(t=>` ${t} !important;`),"}"].join("\n")}function rt(t,e,n){const o=t.tagName.toLowerCase(),r=[],s=!1!==n.forceLightTheme,i=[ot(o),["html, body {",...nt.map(t=>` ${t} !important;`),"}"].join("\n")];if(s&&i.push(J(`:root, ${o}`)),!1!==n.printBackground&&i.push("* {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n}"),r.push(`@layer ${K} {\n${i.join("\n\n")}\n}`),!s){const e=X(t,`:root, ${o}`);e&&r.push(e)}const c=s?a.primitives.foreground:void 0,u=s?"#ffffff":Z(e);r.push(tt(t,c,u));const d=function(t){const e=[];if(t.margin?e.push(` margin: ${t.margin};`):t.paperSize&&e.push(" margin: 0;"),t.paperSize||t.orientation){const n=[t.paperSize?l(t.paperSize):"A4"];t.orientation&&n.push(t.orientation),e.push(` size: ${n.join(" ")};`)}return 0===e.length?"":`@page {\n${e.join("\n")}\n}`}(n);return d&&r.push(d),n.customCSS&&(r.push(n.customCSS),r.push(`@layer ${_} {\n${n.customCSS}\n}`)),r.join("\n\n")}function st(t,e,n,o){const r=`${t.tagName.toLowerCase()}[${o}]`,s=!1!==n.forceLightTheme,i=[ot(r)];s&&i.push(J(r)),!1!==n.printBackground&&i.push(`${r}, ${r} * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n}`);const c=s?a.primitives.foreground:void 0,l=s?"#ffffff":Z(e);i.push(Y(tt(t,c,l,r)));const u=[`@layer ${K} {\n${i.join("\n\n")}\n}`];if(!s){const e=X(t,r);e&&u.push(e)}return u.join("\n\n")}var it="data-notectl-print-fallback",at=["(function () {"," var head = document.head;"," if (head && head.querySelector('meta[name=\"notectl-print-export\"]')) {"," var bundles = document.querySelectorAll('template[data-notectl-print-styles]');"," for (var b = 0; b < bundles.length; b++) {"," if (bundles[b].content) head.appendChild(bundles[b].content);"," bundles[b].parentNode.removeChild(bundles[b]);"," }"," }"," var statics = document.querySelectorAll('[data-notectl-static]');"," for (var i = 0; i < statics.length; i++) {"," var host = statics[i];"," if (!host.shadowRoot && host.attachShadow) {"," for (var j = 0; j < host.children.length; j++) {"," var child = host.children[j];"," if (child.tagName !== 'TEMPLATE') continue;"," if (!child.getAttribute('shadowrootmode') || !child.content) continue;"," host.attachShadow({ mode: 'open' }).appendChild(child.content);"," host.removeChild(child);"," break;"," }"," }"," if (!host.shadowRoot) continue;"," var fallbacks = host.querySelectorAll('[data-notectl-print-fallback]');"," for (var k = 0; k < fallbacks.length; k++) {"," fallbacks[k].parentNode.removeChild(fallbacks[k]);"," }"," }","})();"].join("\n");function ct(t){return t.replace(/<\//g,"<\\/")}function lt(t,n){const o=[];for(const r of Array.from(t.attributes))n(r.name)&&o.push(""===r.value?r.name:`${r.name}="${e(r.value)}"`);return o.length>0?` ${o.join(" ")}`:""}function ut(t){return t?lt(t,t=>"class"===t||t.startsWith("data-")):""}function dt(t){const n=function(t){if(!(t instanceof HTMLElement))return"";const e=[];for(let n=0;n<t.style.length;n++){const o=t.style[n]??"";if(!o.startsWith("--notectl-"))continue;const r=t.style.getPropertyValue(o).trim();r&&e.push(`${o}: ${r}`)}return e.join("; ")}(t);return n?` style="${e(n)}"`:""}function pt(t){const o=t.host.ownerDocument,r=t.host.tagName.toLowerCase(),s="export"===t.variant,i=s?["style","id",d]:["style",d],a=(c=t.host,l=i,lt(c,t=>!l.includes(t)));var c,l;const u=t.carryThemeContext?dt(t.host):"",p=t.carryThemeContext?ut(o.documentElement)+dt(o.documentElement):"",f=t.carryThemeContext?ut(o.body)+dt(o.body):"",h=t.styleNonce?` nonce="${e(t.styleNonce)}"`:"",m=['<meta charset="utf-8">',`<title>${n(t.title)}</title>`];s&&m.push('<meta name="notectl-print-export">'),m.push(`<style${h}>@layer ${_}, ${K}, ${N};</style>`),m.push(`<style${h}>${ct(t.documentCSS)}</style>`);const g=t.hostSegments.map(t=>`<style${h}>${ct("import"===t.kind?t.statement:`@layer ${N} {\n${t.css}\n}`)}</style>`);s||m.push(...g);const y=s?`<template data-notectl-print-styles><style>${ct(t.standaloneCSS)}</style>${g.join("")}</template>`:"",b=s?`<div ${it}><style>@scope ([${it}]) {\n${ct(t.shadowCSS)}\n}</style>${t.fallbackContentHTML}</div>`:"",v=s?`<script>${at}<\/script>`:"",$=[`<${r}${a}${u} ${d}>`,'<template shadowrootmode="open">',`<style${h}>${ct(t.shadowCSS)}</style>`,t.contentHTML,"</template>",...b?[b]:[],...t.destinationMarkersHTML?[t.destinationMarkersHTML]:[],`</${r}>`,...y?[y]:[],...v?[v]:[]];return["<!DOCTYPE html>",`<html lang="${e(t.lang)}"${p}>`,"<head>",...m,"</head>",`<body${f}>`,...$,"</body>","</html>"].join("\n")}function ft(t,e,n,a){const c=/* @__PURE__ */new Set;function l(t){return t??{}}function u(r){const s={options:r,cancelled:!1};if(a.emit(p,s),s.cancelled)return null;const c=s.options,l=function(t,e){const n=[],r=function(t){const e=[],n=[];for(const r of t.adoptedStyleSheets){const t=o(r)?n:e;for(const e of r.cssRules)t.push(e.cssText)}return{base:e.join("\n"),runtime:n.join("\n")}}(t);r.base&&n.push(`@layer notectl-base {\n${r.base}\n}`),r.runtime&&n.push(r.runtime);const s=function(t){const e=[];e.push(".notectl-content { height: auto !important; max-height: none !important; min-height: 0 !important; overflow: visible !important; }"),t.paperSize&&e.push(".notectl-content { padding: 48px 56px !important; }");const n=[];return n.push("[data-notectl-no-print] { display: none !important; }"),n.push(".notectl-code-block { white-space: pre-wrap !important; word-break: break-all !important; page-break-inside: avoid; }"),n.push("img { page-break-inside: avoid; }"),n.push(".notectl-table { break-inside: avoid; }"),!1!==t.printBackground&&n.push("* { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }"),e.push(`@media print {\n ${n.join("\n ")}\n}`),e.join("\n\n")}(e);return s&&n.push(s),e.customCSS&&n.push(e.customCSS),n.join("\n\n")}(t,c),u=function(t){const e={segments:[],seen:/* @__PURE__ */new Set,baseURL:t.ownerDocument.baseURI??"",anonymousLayerCount:0};for(const n of function(t){const e=[];let n=t.getRootNode();for(;n instanceof ShadowRoot;)e.push(n),n=n.host.getRootNode();return e.push(t.ownerDocument),e.reverse()}(t))for(const t of B(n))G(t,e);return e.segments}(e),f=function(t,e){const n=function(t){return(t.querySelector(".notectl-content")??t).cloneNode(!0)}(t);return function(t){t.removeAttribute("contenteditable");for(const e of["notectl-node-selected","notectl-content--empty","notectl-table-cell--selected"]){t.classList.remove(e);for(const n of t.querySelectorAll(`.${e}`))n.classList.remove(e)}t.removeAttribute("data-placeholder")}(n),function(t,e){if(e.excludeBlockTypes)for(const n of e.excludeBlockTypes){const e=t.querySelectorAll(`[data-block-type="${n}"]`);for(const t of e)t.remove()}if(e.pageBreakBefore)for(const n of e.pageBreakBefore){const e=t.querySelectorAll(`[data-block-type="${n}"]`);for(const t of e)i(t,{breakBefore:"page",pageBreakBefore:"always"})}}(n,e),function(t,e){if(e.header){const n=document.createElement("div");n.className="notectl-print-header",n.innerHTML=C(e.header),t.insertBefore(n,t.firstChild)}if(e.footer){const n=document.createElement("div");n.className="notectl-print-footer",n.innerHTML=C(e.footer),t.appendChild(n)}}(n,e),n}(n,c),h=f.cloneNode(!0);!function(t){const e=E(t);if(0===e.size)return;const n=/* @__PURE__ */new Set;""!==t.id&&n.add(t.id);for(const r of t.querySelectorAll("[id]"))n.add(r.id);const o=/* @__PURE__ */new Map;for(const r of function(t){const e=[];return t.matches("[data-block-id][id]")&&""!==t.id&&e.push(t),e.push(...t.querySelectorAll("[data-block-id][id]")),e}(t)){const t=x("notectl-print-fallback-destination",n);o.set(r,t),r.id=t}for(const r of t.querySelectorAll("a[href]")){const t=M(e,r.getAttribute("href")??""),n=t?o.get(t):void 0;n&&r.setAttribute("href",`#${n}`)}}(h);const g=h.outerHTML,y=function(t){const e=E(t);if(0===e.size)return{markers:[]};const n=t.ownerDocument,o=/* @__PURE__ */new Set;""!==t.id&&o.add(t.id);for(const a of t.querySelectorAll("[id]"))o.add(a.id);const r=/* @__PURE__ */new Set;for(const a of t.querySelectorAll("slot[name]"))r.add(a.name);const s=/* @__PURE__ */new Map,i=[];for(const a of t.querySelectorAll("a[href]")){const t=a.getAttribute("href")??"";if(!t.startsWith("#"))continue;const c=M(e,t);if(!c)continue;let l=s.get(c);l||(l=R(c,n,o,r),s.set(c,l),i.push(l.marker)),a.setAttribute("href",`#${l.id}`)}return{markers:i}}(f),b=f.outerHTML,v=y.markers.map(t=>t.outerHTML).join(""),$=c.title??"",S=e.ownerDocument,w=e.closest("[lang]")?.getAttribute("lang")??(S.documentElement.lang||"en"),k={documentCSS:st(e,n,c,d),standaloneCSS:rt(e,n,c),hostSegments:u,shadowCSS:l,host:e,contentHTML:b,fallbackContentHTML:g,destinationMarkersHTML:v,title:$,lang:w,carryThemeContext:!1===c.forceLightTheme,variant:"export"},T=pt(k),j={html:T};return a.emit(m,j),{html:T,input:k}}return{print(t){const e=u(l(t));if(!e)return;const o=pt({...e.input,documentCSS:e.input.standaloneCSS,variant:"internal",styleNonce:s(n)}),i=document.createElement("iframe");r(i,"position:fixed;left:-9999px;width:0;height:0;border:none"),document.body.appendChild(i);const a=i.contentDocument,d=i.contentWindow;if(!a||!d)return void document.body.removeChild(i);a.open(),a.write(o),a.close();const p=()=>{i.remove()},f=()=>{d.addEventListener("afterprint",p,{once:!0}),d.print()};if("complete"===a.readyState)return void f();let h=!1;const m=()=>{h||(h=!0,c.delete(g),window.clearTimeout(y),f())},g=()=>{h=!0,window.clearTimeout(y),d.removeEventListener("load",m),i.remove()},y=window.setTimeout(m,4e3);c.add(g),d.addEventListener("load",m,{once:!0})},toHTML:t=>u(l(t))?.html??"",dispose(){for(const t of c)t();c.clear()}}}var ht={print(){},toHTML:()=>"",dispose(){}},mt=class{id="print";name="Print";config;service=null;locale;constructor(t){this.config=t??{}}async init(t){this.locale=await y(t,this.config.locale,$,w);const e=t.getContainer(),n=e.getRootNode();if(n instanceof ShadowRoot){const o=n.host,r=t.getEventBus();this.service=ft(n,o,e,r)}else this.service=ht;t.registerService(f,this.service);const o=this.config.defaults??{},r=this.service,s=this.locale;t.registerCommand("print",()=>(t.announce(s.printingAnnouncement),r.print(o),!0));const i=this.config.keyBinding??"Mod-P";if(t.registerKeymap({[i]:()=>(t.executeCommand("print"),!0)}),!1!==this.config.showToolbarItem){const e=b(i);t.registerToolbarItem({id:"print",group:"actions",label:this.locale.label,tooltip:this.locale.tooltip(e),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"/></svg>',command:"print"})}}destroy(){this.service?.dispose(),this.service=null}};export{$ as n,w as r,mt as t};
2
- //# sourceMappingURL=PrintPlugin-7zz9mhhU.mjs.map
@@ -1,3 +0,0 @@
1
- import{n as e,t as o}from"./TypedKeys-CA4bfw9O.mjs";import{i as t,n as r,r as n,t as a}from"./SyntaxTokenTypes-BUCOMtL8.mjs";var c={Light:"light",Dark:"dark",System:"system"},i={name:"light",primitives:{background:"#ffffff",foreground:"#1a1a1a",mutedForeground:"#666666",border:"#d0d0d0",borderFocus:"#4a90d9",primary:"#4a90d9",primaryForeground:"#1a5fa0",primaryMuted:"#d0e0f0",surfaceRaised:"#f8f8f8",surfaceOverlay:"#ffffff",hoverBackground:"#e8e8e8",activeBackground:"#d0e0f0",danger:"#dc2626",dangerMuted:"#fee2e2",success:"#1a8c1a",shadow:"rgba(0, 0, 0, 0.15)",focusRing:"rgba(74, 144, 217, 0.2)"},inlineCode:{background:"#edf0f5",foreground:"#334155"},codeBlock:{background:"#f8fafc",foreground:"#334155",headerBackground:"#f1f5f9",headerForeground:"#64748b",headerBorder:"#e2e8f0",syntax:{keyword:"#d73a49",string:"#032f62",comment:{color:"#6a737d",fontStyle:"italic"},number:"#005cc5",function:"#6f42c1",operator:"#d73a49",punctuation:"#24292e",boolean:"#005cc5",null:"#005cc5",property:"#005cc5",type:"#e36209",annotation:"#6f42c1",tag:"#22863a",attribute:"#6f42c1",constant:"#005cc5",regex:"#032f62"}},tooltip:{background:"#1a1a1a",foreground:"#ffffff"}},d={name:"dark",primitives:{background:"#1e1e2e",foreground:"#cdd6f4",mutedForeground:"#7f849c",border:"#45475a",borderFocus:"#89b4fa",primary:"#89b4fa",primaryForeground:"#89b4fa",primaryMuted:"rgba(137, 180, 250, 0.15)",surfaceRaised:"#313244",surfaceOverlay:"#313244",hoverBackground:"#45475a",activeBackground:"rgba(137, 180, 250, 0.15)",danger:"#f38ba8",dangerMuted:"rgba(243, 139, 168, 0.15)",success:"#a6e3a1",shadow:"rgba(0, 0, 0, 0.4)",focusRing:"rgba(137, 180, 250, 0.25)"},inlineCode:{background:"#313244",foreground:"#cdd6f4"},codeBlock:{background:"#313244",foreground:"#cdd6f4",headerBackground:"#45475a",headerForeground:"#bac2de",headerBorder:"#585b70",syntax:{keyword:"#cba6f7",string:"#a6e3a1",comment:{color:"#9399b2",fontStyle:"italic"},number:"#fab387",function:"#89b4fa",operator:"#89dceb",punctuation:"#bac2de",boolean:"#fab387",null:"#f38ba8",property:"#89b4fa",type:"#fab387",annotation:"#cba6f7",tag:"#a6e3a1",attribute:"#89b4fa",constant:"#f9e2af",regex:"#a6e3a1"}},tooltip:{background:"#585b70",foreground:"#cdd6f4"}};function l(e,o){return{name:o.name,primitives:{...e.primitives,...o.primitives},toolbar:o.toolbar?{...e.toolbar,...o.toolbar}:e.toolbar,inlineCode:o.inlineCode?{...e.inlineCode,...o.inlineCode}:e.inlineCode,codeBlock:o.codeBlock?{...e.codeBlock,...o.codeBlock,syntax:o.codeBlock?.syntax?e.codeBlock?.syntax?{...e.codeBlock.syntax,...o.codeBlock.syntax}:void 0:e.codeBlock?.syntax}:e.codeBlock,tooltip:o.tooltip?{...e.tooltip,...o.tooltip}:e.tooltip}}function s(e){if("object"==typeof e)return e;switch(e){case c.Light:return i;case c.Dark:return d;default:return i}}var f=[["primitives.background","--notectl-bg"],["primitives.foreground","--notectl-fg"],["primitives.mutedForeground","--notectl-fg-muted"],["primitives.border","--notectl-border"],["primitives.borderFocus","--notectl-border-focus"],["primitives.primary","--notectl-primary"],["primitives.primaryForeground","--notectl-primary-fg"],["primitives.primaryMuted","--notectl-primary-muted"],["primitives.surfaceRaised","--notectl-surface-raised"],["primitives.surfaceOverlay","--notectl-surface-overlay"],["primitives.hoverBackground","--notectl-hover-bg"],["primitives.activeBackground","--notectl-active-bg"],["primitives.danger","--notectl-danger"],["primitives.dangerMuted","--notectl-danger-muted"],["primitives.success","--notectl-success"],["primitives.shadow","--notectl-shadow"],["primitives.focusRing","--notectl-focus-ring"],["toolbar.background","--notectl-toolbar-bg"],["toolbar.borderColor","--notectl-toolbar-border"],["inlineCode.background","--notectl-code-bg"],["inlineCode.foreground","--notectl-code-color"],["codeBlock.background","--notectl-code-block-bg"],["codeBlock.foreground","--notectl-code-block-color"],["codeBlock.headerBackground","--notectl-code-block-header-bg"],["codeBlock.headerForeground","--notectl-code-block-header-color"],["codeBlock.headerBorder","--notectl-code-block-header-border"],["tooltip.background","--notectl-tooltip-bg"],["tooltip.foreground","--notectl-tooltip-fg"],...a.map(e=>[`codeBlock.syntax.${e}`,`--notectl-code-token-${e}`])],u=a.map(e=>[`--notectl-code-token-${e}`,"var(--notectl-code-block-color)"]),g=new Map([["--notectl-toolbar-bg","var(--notectl-surface-raised)"],["--notectl-toolbar-border","var(--notectl-border)"],["--notectl-code-bg","var(--notectl-surface-raised)"],["--notectl-code-color","var(--notectl-fg)"],["--notectl-code-block-bg","var(--notectl-surface-raised)"],["--notectl-code-block-color","var(--notectl-fg)"],["--notectl-code-block-header-bg","var(--notectl-surface-raised)"],["--notectl-code-block-header-color","var(--notectl-fg-muted)"],["--notectl-code-block-header-border","var(--notectl-border)"],["--notectl-tooltip-bg","var(--notectl-fg)"],["--notectl-tooltip-fg","var(--notectl-bg)"],...u]);function b(e,o){const t=o.split(".");let n=e;for(const r of t){if(null==n)return;if("object"!=typeof n)return;n=n[r]}return"string"==typeof n?n:"object"==typeof n&&null!==n&&"color"in n?r(n):void 0}function p(e){const o=[":host {"];for(const[t,r]of f){const n=b(e,t);if(void 0!==n)o.push(`\t${r}: ${n};`);else{const e=g.get(r);e&&o.push(`\t${r}: ${e};`)}}return e.codeBlock?.syntax&&function(e,o){for(const r of a){const a=e[r];if("object"!=typeof a)continue;const c=n(a);c&&o.push(`\t--notectl-code-token-${r}-font-style: ${c};`);const i=t(a);i&&o.push(`\t--notectl-code-token-${r}-font-weight: ${i};`)}}(e.codeBlock.syntax,o),o.push("}"),o.join("\n")}function m(e){const o=new CSSStyleSheet;return o.replaceSync(p(e)),o}var h=96/25.4,k={DINA4:"din-a4",DINA5:"din-a5",USLetter:"us-letter",USLegal:"us-legal"};function v(e){return Math.round(e*h)}var y=new Map([[k.DINA4,{widthMm:210,heightMm:297,widthPx:v(210),heightPx:v(297)}],[k.DINA5,{widthMm:148,heightMm:210,widthPx:v(148),heightPx:v(210)}],[k.USLetter,{widthMm:215.9,heightMm:279.4,widthPx:v(215.9),heightPx:v(279.4)}],[k.USLegal,{widthMm:215.9,heightMm:355.6,widthPx:v(215.9),heightPx:v(355.6)}]]),B=new Map([[k.DINA4,"A4"],[k.DINA5,"A5"],[k.USLetter,"letter"],[k.USLegal,"legal"]]);function w(e){const o=y.get(e);if(!o)throw new Error(`Unknown paper size: ${e}`);return o}var x=48,M=56,S=24;function $(e){return Object.values(k).includes(e)}function C(e){const o=B.get(e);if(!o)throw new Error(`Unknown paper size: ${e}`);return o}var F="data-notectl-static";function A(e){return e.hasAttribute(F)}function j(){/* @__PURE__ */
2
- return new Error("Cannot initialize a static print replica (data-notectl-static). Remove the marker and its shadow content to reuse the element as an editor.")}var D=new e("print"),L=new o("print:before"),P=new o("print:after");export{i as _,j as a,s as b,x as c,C as d,w as f,d as g,p as h,F as i,S as l,m,L as n,A as o,$ as p,D as r,M as s,P as t,k as u,c as v,l as y};
3
- //# sourceMappingURL=PrintTypes-CxU69qu3.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrintTypes-CxU69qu3.mjs","names":[],"sources":["../../src/editor/theme/ThemeTokens.ts","../../src/editor/theme/ThemeEngine.ts","../../src/model/PaperSize.ts","../../src/plugins/print/StaticHostMarker.ts","../../src/plugins/print/PrintTypes.ts"],"sourcesContent":["/**\n * Theme token types, built-in themes, and theme creation helpers.\n */\n\nimport type { SyntaxTokenType, TokenStyleValue } from './SyntaxTokenTypes.js';\nimport { resolveTokenColor } from './SyntaxTokenTypes.js';\n\n/** Primitive color palette a theme defines. */\nexport interface ThemePrimitives {\n\treadonly background: string;\n\treadonly foreground: string;\n\treadonly mutedForeground: string;\n\treadonly border: string;\n\treadonly borderFocus: string;\n\treadonly primary: string;\n\treadonly primaryForeground: string;\n\treadonly primaryMuted: string;\n\treadonly surfaceRaised: string;\n\treadonly surfaceOverlay: string;\n\treadonly hoverBackground: string;\n\treadonly activeBackground: string;\n\treadonly danger: string;\n\treadonly dangerMuted: string;\n\treadonly success: string;\n\treadonly shadow: string;\n\treadonly focusRing: string;\n}\n\n/** Component-level toolbar overrides. */\nexport interface ThemeToolbar {\n\treadonly background: string;\n\treadonly borderColor: string;\n}\n\n/** Syntax highlighting token styles — one entry per canonical token type. */\nexport type ThemeSyntax = { readonly [K in SyntaxTokenType]: TokenStyleValue };\n\n/** Component-level code block overrides. */\nexport interface ThemeCodeBlock {\n\treadonly background: string;\n\treadonly foreground: string;\n\treadonly headerBackground: string;\n\treadonly headerForeground: string;\n\treadonly headerBorder: string;\n\treadonly syntax?: ThemeSyntax;\n}\n\n/** Component-level inline code overrides. */\nexport interface ThemeInlineCode {\n\treadonly background: string;\n\treadonly foreground: string;\n}\n\n/** Component-level tooltip overrides. */\nexport interface ThemeTooltip {\n\treadonly background: string;\n\treadonly foreground: string;\n}\n\n/** Full theme definition. */\nexport interface Theme {\n\treadonly name: string;\n\treadonly primitives: ThemePrimitives;\n\treadonly toolbar?: Partial<ThemeToolbar>;\n\treadonly inlineCode?: Partial<ThemeInlineCode>;\n\treadonly codeBlock?: Partial<ThemeCodeBlock>;\n\treadonly tooltip?: Partial<ThemeTooltip>;\n}\n\n/** Partial custom theme — deeply partial for creating overrides. */\nexport interface PartialTheme {\n\treadonly name: string;\n\treadonly primitives?: Partial<ThemePrimitives>;\n\treadonly toolbar?: Partial<ThemeToolbar>;\n\treadonly inlineCode?: Partial<ThemeInlineCode>;\n\treadonly codeBlock?: Partial<Omit<ThemeCodeBlock, 'syntax'>> & {\n\t\treadonly syntax?: Partial<ThemeSyntax>;\n\t};\n\treadonly tooltip?: Partial<ThemeTooltip>;\n}\n\n/** Built-in theme presets. */\nexport const ThemePreset = {\n\tLight: 'light',\n\tDark: 'dark',\n\tSystem: 'system',\n} as const;\nexport type ThemePreset = (typeof ThemePreset)[keyof typeof ThemePreset];\n\n/** Built-in light theme. */\nexport const LIGHT_THEME: Theme = {\n\tname: 'light',\n\tprimitives: {\n\t\tbackground: '#ffffff',\n\t\tforeground: '#1a1a1a',\n\t\tmutedForeground: '#666666',\n\t\tborder: '#d0d0d0',\n\t\tborderFocus: '#4a90d9',\n\t\tprimary: '#4a90d9',\n\t\tprimaryForeground: '#1a5fa0',\n\t\tprimaryMuted: '#d0e0f0',\n\t\tsurfaceRaised: '#f8f8f8',\n\t\tsurfaceOverlay: '#ffffff',\n\t\thoverBackground: '#e8e8e8',\n\t\tactiveBackground: '#d0e0f0',\n\t\tdanger: '#dc2626',\n\t\tdangerMuted: '#fee2e2',\n\t\tsuccess: '#1a8c1a',\n\t\tshadow: 'rgba(0, 0, 0, 0.15)',\n\t\tfocusRing: 'rgba(74, 144, 217, 0.2)',\n\t},\n\tinlineCode: {\n\t\tbackground: '#edf0f5',\n\t\tforeground: '#334155',\n\t},\n\tcodeBlock: {\n\t\tbackground: '#f8fafc',\n\t\tforeground: '#334155',\n\t\theaderBackground: '#f1f5f9',\n\t\theaderForeground: '#64748b',\n\t\theaderBorder: '#e2e8f0',\n\t\tsyntax: {\n\t\t\tkeyword: '#d73a49',\n\t\t\tstring: '#032f62',\n\t\t\tcomment: { color: '#6a737d', fontStyle: 'italic' },\n\t\t\tnumber: '#005cc5',\n\t\t\tfunction: '#6f42c1',\n\t\t\toperator: '#d73a49',\n\t\t\tpunctuation: '#24292e',\n\t\t\tboolean: '#005cc5',\n\t\t\tnull: '#005cc5',\n\t\t\tproperty: '#005cc5',\n\t\t\ttype: '#e36209',\n\t\t\tannotation: '#6f42c1',\n\t\t\ttag: '#22863a',\n\t\t\tattribute: '#6f42c1',\n\t\t\tconstant: '#005cc5',\n\t\t\tregex: '#032f62',\n\t\t},\n\t},\n\ttooltip: {\n\t\tbackground: '#1a1a1a',\n\t\tforeground: '#ffffff',\n\t},\n};\n\n/** Built-in dark theme. */\nexport const DARK_THEME: Theme = {\n\tname: 'dark',\n\tprimitives: {\n\t\tbackground: '#1e1e2e',\n\t\tforeground: '#cdd6f4',\n\t\tmutedForeground: '#7f849c',\n\t\tborder: '#45475a',\n\t\tborderFocus: '#89b4fa',\n\t\tprimary: '#89b4fa',\n\t\tprimaryForeground: '#89b4fa',\n\t\tprimaryMuted: 'rgba(137, 180, 250, 0.15)',\n\t\tsurfaceRaised: '#313244',\n\t\tsurfaceOverlay: '#313244',\n\t\thoverBackground: '#45475a',\n\t\tactiveBackground: 'rgba(137, 180, 250, 0.15)',\n\t\tdanger: '#f38ba8',\n\t\tdangerMuted: 'rgba(243, 139, 168, 0.15)',\n\t\tsuccess: '#a6e3a1',\n\t\tshadow: 'rgba(0, 0, 0, 0.4)',\n\t\tfocusRing: 'rgba(137, 180, 250, 0.25)',\n\t},\n\tinlineCode: {\n\t\tbackground: '#313244',\n\t\tforeground: '#cdd6f4',\n\t},\n\tcodeBlock: {\n\t\tbackground: '#313244',\n\t\tforeground: '#cdd6f4',\n\t\theaderBackground: '#45475a',\n\t\theaderForeground: '#bac2de',\n\t\theaderBorder: '#585b70',\n\t\tsyntax: {\n\t\t\tkeyword: '#cba6f7',\n\t\t\tstring: '#a6e3a1',\n\t\t\tcomment: { color: '#9399b2', fontStyle: 'italic' },\n\t\t\tnumber: '#fab387',\n\t\t\tfunction: '#89b4fa',\n\t\t\toperator: '#89dceb',\n\t\t\tpunctuation: '#bac2de',\n\t\t\tboolean: '#fab387',\n\t\t\tnull: '#f38ba8',\n\t\t\tproperty: '#89b4fa',\n\t\t\ttype: '#fab387',\n\t\t\tannotation: '#cba6f7',\n\t\t\ttag: '#a6e3a1',\n\t\t\tattribute: '#89b4fa',\n\t\t\tconstant: '#f9e2af',\n\t\t\tregex: '#a6e3a1',\n\t\t},\n\t},\n\ttooltip: {\n\t\tbackground: '#585b70',\n\t\tforeground: '#cdd6f4',\n\t},\n};\n\n/** Creates a custom theme by extending a base theme with partial overrides. */\nexport function createTheme(base: Theme, overrides: PartialTheme): Theme {\n\tconst mergeSyntax = (): ThemeSyntax | undefined => {\n\t\tif (!overrides.codeBlock?.syntax) return base.codeBlock?.syntax;\n\t\tif (!base.codeBlock?.syntax) return undefined;\n\t\treturn { ...base.codeBlock.syntax, ...overrides.codeBlock.syntax } as ThemeSyntax;\n\t};\n\n\treturn {\n\t\tname: overrides.name,\n\t\tprimitives: { ...base.primitives, ...overrides.primitives },\n\t\ttoolbar: overrides.toolbar ? { ...base.toolbar, ...overrides.toolbar } : base.toolbar,\n\t\tinlineCode: overrides.inlineCode\n\t\t\t? { ...base.inlineCode, ...overrides.inlineCode }\n\t\t\t: base.inlineCode,\n\t\tcodeBlock: overrides.codeBlock\n\t\t\t? {\n\t\t\t\t\t...base.codeBlock,\n\t\t\t\t\t...overrides.codeBlock,\n\t\t\t\t\tsyntax: mergeSyntax(),\n\t\t\t\t}\n\t\t\t: base.codeBlock,\n\t\ttooltip: overrides.tooltip ? { ...base.tooltip, ...overrides.tooltip } : base.tooltip,\n\t};\n}\n\n// Re-export for convenience — avoids extra imports in consumer code.\nexport { resolveTokenColor };\n\n/** Resolves a ThemePreset string or Theme object to a full Theme. */\nexport function resolveTheme(theme: ThemePreset | Theme): Theme {\n\tif (typeof theme === 'object') return theme;\n\tswitch (theme) {\n\t\tcase ThemePreset.Light:\n\t\t\treturn LIGHT_THEME;\n\t\tcase ThemePreset.Dark:\n\t\t\treturn DARK_THEME;\n\t\tcase ThemePreset.System:\n\t\t\t// System is resolved externally via matchMedia; default to light.\n\t\t\treturn LIGHT_THEME;\n\t\tdefault:\n\t\t\treturn LIGHT_THEME;\n\t}\n}\n","/**\n * Theme engine — converts a Theme object into CSS custom properties.\n */\n\nimport {\n\tSYNTAX_TOKEN_TYPES,\n\tresolveTokenColor,\n\tresolveTokenFontStyle,\n\tresolveTokenFontWeight,\n} from './SyntaxTokenTypes.js';\nimport type { TokenStyleValue } from './SyntaxTokenTypes.js';\nimport type { Theme, ThemeSyntax } from './ThemeTokens.js';\n\n// --- Static entries (non-syntax) ---\n\nconst STATIC_ENTRIES: ReadonlyArray<readonly [string, string]> = [\n\t// Primitives\n\t['primitives.background', '--notectl-bg'],\n\t['primitives.foreground', '--notectl-fg'],\n\t['primitives.mutedForeground', '--notectl-fg-muted'],\n\t['primitives.border', '--notectl-border'],\n\t['primitives.borderFocus', '--notectl-border-focus'],\n\t['primitives.primary', '--notectl-primary'],\n\t['primitives.primaryForeground', '--notectl-primary-fg'],\n\t['primitives.primaryMuted', '--notectl-primary-muted'],\n\t['primitives.surfaceRaised', '--notectl-surface-raised'],\n\t['primitives.surfaceOverlay', '--notectl-surface-overlay'],\n\t['primitives.hoverBackground', '--notectl-hover-bg'],\n\t['primitives.activeBackground', '--notectl-active-bg'],\n\t['primitives.danger', '--notectl-danger'],\n\t['primitives.dangerMuted', '--notectl-danger-muted'],\n\t['primitives.success', '--notectl-success'],\n\t['primitives.shadow', '--notectl-shadow'],\n\t['primitives.focusRing', '--notectl-focus-ring'],\n\t// Component: toolbar\n\t['toolbar.background', '--notectl-toolbar-bg'],\n\t['toolbar.borderColor', '--notectl-toolbar-border'],\n\t// Component: inlineCode\n\t['inlineCode.background', '--notectl-code-bg'],\n\t['inlineCode.foreground', '--notectl-code-color'],\n\t// Component: codeBlock (non-syntax)\n\t['codeBlock.background', '--notectl-code-block-bg'],\n\t['codeBlock.foreground', '--notectl-code-block-color'],\n\t['codeBlock.headerBackground', '--notectl-code-block-header-bg'],\n\t['codeBlock.headerForeground', '--notectl-code-block-header-color'],\n\t['codeBlock.headerBorder', '--notectl-code-block-header-border'],\n\t// Component: tooltip\n\t['tooltip.background', '--notectl-tooltip-bg'],\n\t['tooltip.foreground', '--notectl-tooltip-fg'],\n];\n\n// --- Generated syntax variable map (derived from SYNTAX_TOKEN_TYPES) ---\n\nconst SYNTAX_VARIABLE_MAP: ReadonlyArray<readonly [string, string]> = SYNTAX_TOKEN_TYPES.map(\n\t(type) => [`codeBlock.syntax.${type}`, `--notectl-code-token-${type}`] as const,\n);\n\n/** Full variable map: static entries + syntax entries. */\nconst VARIABLE_MAP: ReadonlyArray<readonly [string, string]> = [\n\t...STATIC_ENTRIES,\n\t...SYNTAX_VARIABLE_MAP,\n];\n\n// --- Static fallbacks (non-syntax) ---\n\nconst STATIC_FALLBACKS: ReadonlyArray<readonly [string, string]> = [\n\t['--notectl-toolbar-bg', 'var(--notectl-surface-raised)'],\n\t['--notectl-toolbar-border', 'var(--notectl-border)'],\n\t['--notectl-code-bg', 'var(--notectl-surface-raised)'],\n\t['--notectl-code-color', 'var(--notectl-fg)'],\n\t['--notectl-code-block-bg', 'var(--notectl-surface-raised)'],\n\t['--notectl-code-block-color', 'var(--notectl-fg)'],\n\t['--notectl-code-block-header-bg', 'var(--notectl-surface-raised)'],\n\t['--notectl-code-block-header-color', 'var(--notectl-fg-muted)'],\n\t['--notectl-code-block-header-border', 'var(--notectl-border)'],\n\t['--notectl-tooltip-bg', 'var(--notectl-fg)'],\n\t['--notectl-tooltip-fg', 'var(--notectl-bg)'],\n];\n\n// --- Generated syntax fallbacks (derived from SYNTAX_TOKEN_TYPES) ---\n\nconst SYNTAX_FALLBACKS: ReadonlyArray<readonly [string, string]> = SYNTAX_TOKEN_TYPES.map(\n\t(type) => [`--notectl-code-token-${type}`, 'var(--notectl-code-block-color)'] as const,\n);\n\n/** Fallbacks for component tokens when not explicitly set. */\nconst COMPONENT_FALLBACKS: ReadonlyMap<string, string> = new Map([\n\t...STATIC_FALLBACKS,\n\t...SYNTAX_FALLBACKS,\n]);\n\n/** Resolves a dotted path like 'primitives.background' from a Theme. */\nfunction resolvePath(theme: Theme, path: string): string | undefined {\n\tconst parts: string[] = path.split('.');\n\tlet current: unknown = theme;\n\tfor (const part of parts) {\n\t\tif (current === undefined || current === null) return undefined;\n\t\tif (typeof current !== 'object') return undefined;\n\t\tcurrent = (current as Record<string, unknown>)[part];\n\t}\n\tif (typeof current === 'string') return current;\n\tif (typeof current === 'object' && current !== null && 'color' in current) {\n\t\treturn resolveTokenColor(current as TokenStyleValue);\n\t}\n\treturn undefined;\n}\n\n/** Emits font-style/font-weight CSS vars for syntax tokens that use TokenStyle objects. */\nfunction emitTokenStyleVars(syntax: ThemeSyntax, lines: string[]): void {\n\tfor (const type of SYNTAX_TOKEN_TYPES) {\n\t\tconst value: TokenStyleValue = syntax[type];\n\t\tif (typeof value !== 'object') continue;\n\n\t\tconst fontStyle: string | undefined = resolveTokenFontStyle(value);\n\t\tif (fontStyle) {\n\t\t\tlines.push(`\\t--notectl-code-token-${type}-font-style: ${fontStyle};`);\n\t\t}\n\t\tconst fontWeight: string | undefined = resolveTokenFontWeight(value);\n\t\tif (fontWeight) {\n\t\t\tlines.push(`\\t--notectl-code-token-${type}-font-weight: ${fontWeight};`);\n\t\t}\n\t}\n}\n\n/** Generates CSS text with all theme custom properties on :host. */\nexport function generateThemeCSS(theme: Theme): string {\n\tconst lines: string[] = [':host {'];\n\n\tfor (const [path, cssVar] of VARIABLE_MAP) {\n\t\tconst value: string | undefined = resolvePath(theme, path);\n\t\tif (value !== undefined) {\n\t\t\tlines.push(`\\t${cssVar}: ${value};`);\n\t\t} else {\n\t\t\tconst fallback: string | undefined = COMPONENT_FALLBACKS.get(cssVar);\n\t\t\tif (fallback) {\n\t\t\t\tlines.push(`\\t${cssVar}: ${fallback};`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Emit font-style / font-weight vars for TokenStyle entries\n\tif (theme.codeBlock?.syntax) {\n\t\temitTokenStyleVars(theme.codeBlock.syntax, lines);\n\t}\n\n\tlines.push('}');\n\treturn lines.join('\\n');\n}\n\n/** Creates a CSSStyleSheet populated with theme CSS variables. */\nexport function createThemeStyleSheet(theme: Theme): CSSStyleSheet {\n\tconst sheet: CSSStyleSheet = new CSSStyleSheet();\n\tsheet.replaceSync(generateThemeCSS(theme));\n\treturn sheet;\n}\n","/**\n * Paper size definitions and dimension helpers.\n * Used by PaperLayoutController for WYSIWYG page layout\n * and by PrintStyleCollector for @page CSS rules.\n */\n\n/** Conversion factor: 1mm = 96/25.4 px at CSS reference pixel (96 DPI). */\nconst MM_TO_PX: number = 96 / 25.4;\n\n/** Physical dimensions of a paper size. */\nexport interface PaperDimensions {\n\treadonly widthMm: number;\n\treadonly heightMm: number;\n\treadonly widthPx: number;\n\treadonly heightPx: number;\n}\n\n/** Available paper size presets. */\nexport const PaperSize = {\n\tDINA4: 'din-a4',\n\tDINA5: 'din-a5',\n\tUSLetter: 'us-letter',\n\tUSLegal: 'us-legal',\n} as const;\nexport type PaperSize = (typeof PaperSize)[keyof typeof PaperSize];\n\n/** Rounds to nearest integer for pixel dimensions. */\nfunction mmToPx(mm: number): number {\n\treturn Math.round(mm * MM_TO_PX);\n}\n\n/** Lookup table for paper dimensions. */\nconst PAPER_DIMENSIONS: ReadonlyMap<PaperSize, PaperDimensions> = new Map<\n\tPaperSize,\n\tPaperDimensions\n>([\n\t[PaperSize.DINA4, { widthMm: 210, heightMm: 297, widthPx: mmToPx(210), heightPx: mmToPx(297) }],\n\t[PaperSize.DINA5, { widthMm: 148, heightMm: 210, widthPx: mmToPx(148), heightPx: mmToPx(210) }],\n\t[\n\t\tPaperSize.USLetter,\n\t\t{ widthMm: 215.9, heightMm: 279.4, widthPx: mmToPx(215.9), heightPx: mmToPx(279.4) },\n\t],\n\t[\n\t\tPaperSize.USLegal,\n\t\t{ widthMm: 215.9, heightMm: 355.6, widthPx: mmToPx(215.9), heightPx: mmToPx(355.6) },\n\t],\n]);\n\n/** CSS @page size keywords for each paper size. */\nconst CSS_SIZE_KEYWORDS: ReadonlyMap<PaperSize, string> = new Map<PaperSize, string>([\n\t[PaperSize.DINA4, 'A4'],\n\t[PaperSize.DINA5, 'A5'],\n\t[PaperSize.USLetter, 'letter'],\n\t[PaperSize.USLegal, 'legal'],\n]);\n\n/** Returns the physical and pixel dimensions for a paper size. */\nexport function getPaperDimensions(size: PaperSize): PaperDimensions {\n\tconst dims: PaperDimensions | undefined = PAPER_DIMENSIONS.get(size);\n\tif (!dims) {\n\t\tthrow new Error(`Unknown paper size: ${size}`);\n\t}\n\treturn dims;\n}\n\n/**\n * Document margin constants for paper mode (in px).\n * These define the content padding inside the paper surface in the editor,\n * and become @page margins in print output to ensure WYSIWYG fidelity.\n */\nexport const PAPER_MARGIN_TOP_PX: number = 48;\nexport const PAPER_MARGIN_HORIZONTAL_PX: number = 56;\nexport const PAPER_VIEWPORT_PADDING_PX: number = 24;\n\n/** Type guard: returns true if the value is a valid PaperSize string. */\nexport function isValidPaperSize(value: string): value is PaperSize {\n\treturn (Object.values(PaperSize) as string[]).includes(value);\n}\n\n/** Returns the CSS @page size keyword (e.g. 'A4', 'letter') for a paper size. */\nexport function getPaperCSSSize(size: PaperSize): string {\n\tconst keyword: string | undefined = CSS_SIZE_KEYWORDS.get(size);\n\tif (!keyword) {\n\t\tthrow new Error(`Unknown paper size: ${size}`);\n\t}\n\treturn keyword;\n}\n","/**\n * Marker attribute for static host replicas.\n *\n * Print output replicates the editor host element (tag and attributes) so\n * host-page `::part()` rules keep matching in the print document. When that\n * markup is injected into a page where `<notectl-editor>` is registered, the\n * replica must stay static markup: upgrading it into a live editor would\n * replace the replicated shadow content with a fresh editor instance.\n *\n * The print plugin writes the marker; `NotectlEditor` honors it by refusing\n * to boot on marked hosts.\n */\nexport const STATIC_HOST_ATTRIBUTE = 'data-notectl-static';\n\n/** True when the element is a static replica that must not boot an editor. */\nexport function isStaticHostReplica(el: Element): boolean {\n\treturn el.hasAttribute(STATIC_HOST_ATTRIBUTE);\n}\n\n/** Error raised when editor lifecycle APIs are used on a static replica. */\nexport function createStaticReplicaError(): Error {\n\treturn new Error(\n\t\t'Cannot initialize a static print replica (data-notectl-static). ' +\n\t\t\t'Remove the marker and its shadow content to reuse the element as an editor.',\n\t);\n}\n","/**\n * Type definitions, service keys, and event keys for the PrintPlugin.\n */\n\nimport type { PaperSize } from '../../model/PaperSize.js';\nimport type { NodeTypeName } from '../../model/TypeBrands.js';\nimport { EventKey, ServiceKey } from '../Plugin.js';\n\n// --- Print Options ---\n\nexport interface PrintOptions {\n\t/** Page title shown in the browser print header. */\n\treadonly title?: string;\n\n\t/** Additional CSS appended to the print stylesheet. */\n\treadonly customCSS?: string;\n\n\t/**\n\t * Header HTML inserted once at the top of the print document.\n\t * For repeating per-page headers, use toHTML() with server-side PDF generation.\n\t */\n\treadonly header?: string | (() => string);\n\n\t/**\n\t * Footer HTML inserted once at the bottom of the print document.\n\t * For repeating per-page footers, use toHTML() with server-side PDF generation.\n\t */\n\treadonly footer?: string | (() => string);\n\n\t/** Page margins as CSS value (e.g. '2cm'). */\n\treadonly margin?: string;\n\n\t/** Force page break before these block types. */\n\treadonly pageBreakBefore?: readonly NodeTypeName[];\n\n\t/** Exclude these block types from print output. */\n\treadonly excludeBlockTypes?: readonly NodeTypeName[];\n\n\t/**\n\t * Whether to preserve background colors and images in print output.\n\t * Defaults to `true` (WYSIWYG). Set to `false` to let the browser strip\n\t * backgrounds (e.g. to save ink).\n\t */\n\treadonly printBackground?: boolean;\n\n\t/**\n\t * Force light theme tokens in print output for readability on paper.\n\t * Defaults to `true`. Set to `false` to print with the current editor theme.\n\t */\n\treadonly forceLightTheme?: boolean;\n\n\t/** Page orientation. */\n\treadonly orientation?: 'portrait' | 'landscape';\n\n\t/** Paper size for @page CSS rule. When set, overrides the default A4 page size. */\n\treadonly paperSize?: PaperSize;\n}\n\n// --- Plugin Configuration ---\n\nexport interface PrintPluginConfig {\n\t/** Default options applied to every print() call. */\n\treadonly defaults?: PrintOptions;\n\n\t/** Keyboard shortcut (default: 'Mod-P'). */\n\treadonly keyBinding?: string;\n\n\t/** Show toolbar button (default: true). */\n\treadonly showToolbarItem?: boolean;\n\n\t/** Locale override for user-facing strings. */\n\treadonly locale?: import('./PrintLocale.js').PrintLocale;\n}\n\n// --- Service Interface ---\n\nexport interface PrintService {\n\t/** Prints the editor content with optional configuration. */\n\tprint(options?: PrintOptions): void;\n\n\t/** Generates print-ready HTML as a complete document string. */\n\ttoHTML(options?: PrintOptions): string;\n}\n\n// --- Service & Event Keys ---\n\nexport const PRINT_SERVICE_KEY: ServiceKey<PrintService> = new ServiceKey<PrintService>('print');\n\nexport const BEFORE_PRINT: EventKey<BeforePrintEvent> = new EventKey<BeforePrintEvent>(\n\t'print:before',\n);\n\nexport const AFTER_PRINT: EventKey<AfterPrintEvent> = new EventKey<AfterPrintEvent>('print:after');\n\n// --- Event Payloads ---\n\nexport interface BeforePrintEvent {\n\t/** Options can be mutated — EventBus passes by reference. */\n\toptions: PrintOptions;\n\t/** Set to true to cancel the print. */\n\tcancelled: boolean;\n}\n\nexport interface AfterPrintEvent {\n\t/** The generated HTML (read-only). */\n\treadonly html: string;\n}\n"],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- import{_ as o,m as r}from"./Commands-1dFFldi7.mjs";import{i as e}from"./TypeBrands-Ch9856Gb.mjs";import{n as m}from"./PluginHelpers-Dx_0hfDe.mjs";function t(t,a){const i=e(a.markSpec.type);t.registerMarkSpec(a.markSpec),t.registerCommand(a.command,()=>m(t,o(t.getState(),i))),a.keyBinding&&t.registerKeymap({[a.keyBinding]:()=>t.executeCommand(a.command)}),a.toolbar&&t.registerToolbarItem({id:a.toolbar.id,group:a.toolbar.group,icon:a.toolbar.icon,label:a.toolbar.label,tooltip:a.toolbar.tooltip,command:a.command,isActive:o=>r(o,i)})}export{t};
2
- //# sourceMappingURL=SimpleMark-7CQcA4RK.mjs.map
@@ -1,2 +0,0 @@
1
- import{f as t,o as e,u as n}from"./Document-827l3P80.mjs";import{c as o,o as s,t as c,u as r}from"./Selection-HYoVFpAx.mjs";import{t as a}from"./Commands-1dFFldi7.mjs";import{a as i}from"./TypeBrands-Ch9856Gb.mjs";import{a as l,d,o as u,p as h,u as m}from"./BlockInsertion-CJusvrDL.mjs";import{n as g}from"./TypedKeys-CA4bfw9O.mjs";import{c as f,o as p}from"./PluginHelpers-Dx_0hfDe.mjs";import{l as x}from"./XmlDetector-D7TQpw-e.mjs";var k=/\n(?:[ \t]*\n)+/;function C(t,e){return!t.detection&&!e.detection||!(!t.detection||!e.detection)&&t.detection.language===e.detection.language}function b(t,e){const n=`${t.text}\n\n${e.text}`;if(!t.detection&&!e.detection)return{text:n,detection:null};const o=t.detection,s=e.detection;return{text:n,detection:{language:o.language,formattedText:`${o.formattedText}\n\n${s.formattedText}`,confidence:Math.max(o.confidence,s.confidence)}}}var j={detectedAsCodeBlock:t=>`Pasted as ${t} code block with syntax highlighting.`,detectedMixedContent:(t,e,n)=>{const o=[];if(t>0&&o.push(`${t} paragraph${t>1?"s":""}`),e>0){const t=n.join(", ");o.push(`${e} code block${e>1?"s":""} (${t})`)}return`Pasted as ${o.join(" and ")}.`}},B=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BWOue6jG.mjs"),"./locales/de.ts":()=>import("./de-CTzAMkXC.mjs"),"./locales/es.ts":()=>import("./es-DDoqchUq.mjs"),"./locales/fr.ts":()=>import("./fr-eC0UdAPu.mjs"),"./locales/hi.ts":()=>import("./hi-DY55FuDK.mjs"),"./locales/pt.ts":()=>import("./pt-Bu7Mbz67.mjs"),"./locales/ru.ts":()=>import("./ru-DyCTlhjg.mjs"),"./locales/zh.ts":()=>import("./zh-D1HSmSOf.mjs")});async function y(t){return f(B,t,j)}var P=new g("smartPaste"),T=class{id="smart-paste";name="Smart Paste";dependencies=["code-block"];config;detectors=[];context=null;locale=j;constructor(t){this.config={...t}}async init(t){this.context=t,this.locale=await p(t,this.config.locale,j,y);const e=t.getService(x);if(e&&e.onRegister(t=>{t.detection&&this.detectors.push(t.detection)}),this.config.detectors)for(const n of this.config.detectors)this.detectors.push(n);t.registerPasteInterceptor(this.handlePaste,{name:"smart-paste",priority:50}),t.registerService(P,{registerDetector:t=>{this.detectors.push(t)}})}destroy(){this.context=null,this.detectors.length=0}handlePaste=(t,e,n)=>{if(this.isCursorInCodeBlock(n))return null;const o=function(t,e){const n=t.split(k).map(t=>t.trim()).filter(t=>t.length>0);if(0===n.length)return null;let o=!1;const s=n.map(t=>{const n=function(t,e){let n=null;for(const o of e){const e=o.detect(t);e&&(null===n||e.confidence>n.confidence||e.confidence===n.confidence&&e.language<n.language)&&(n=e)}return n}(t,e);return n&&(o=!0),{text:t,detection:n}});return o?function(t){if(t.length<=1)return t;const e=[t[0]];for(let n=1;n<t.length;n++){const o=t[n],s=e[e.length-1];C(s,o)?e[e.length-1]=b(s,o):e.push(o)}return e}(s):null}(t,this.detectors);return o?1===o.length&&o[0]?.detection?this.handleSingleCodeBlock(n,o[0].detection):this.handleMixedContent(n,o):null};isCursorInCodeBlock(t){const e=t.selection;return!!r(e)&&"code_block"===t.getBlock(e.anchor.blockId)?.type}handleSingleCodeBlock(t,e){const n=this.buildCodeBlockTransaction(t,e);return n&&this.context&&this.context.announce(this.locale.detectedAsCodeBlock(e.language)),n}buildCodeBlockTransaction(o,l){const d=o.selection,h=o.transaction("paste");let g;g=r(d)&&!s(d)?a(o,h)??d.anchor.blockId:m(d);const f=t(),p=e(i("code_block"),[n(l.formattedText)],f,{language:l.language,backgroundColor:""});return u(o,h,g,p,d,this.context?.getSchemaRegistry())?(h.setSelection(c(f,l.formattedText.length)),h.build()):null}handleMixedContent(t,e){const n=this.buildMultiBlockTransaction(t,e);return n&&this.context&&this.announceMixedContent(e),n}buildMultiBlockTransaction(t,e){const n=t.selection,i=t.transaction("paste");let u;u=r(n)&&!s(n)?a(t,i)??n.anchor.blockId:m(n);const g=l(t,u),f=this.context?.getSchemaRegistry(),p=g?d(t,u,g,f):h(t,u,f);if(!p)return null;const x=!g&&o(n)&&"before"===n.side?0:1;let k,C=p.anchorIndex+x,b=0;for(const o of e){const t=o.detection?this.createCodeBlockNode(o.detection):this.createParagraphNode(o.text);i.insertNode(p.parentPath,C,t),C++,k=t.id,b=o.detection?o.detection.formattedText.length:o.text.length}return(g?p.isAnchorEmpty&&p.anchorIndex>=0:p.isAnchorEmpty&&!o(n))&&i.removeNode(p.parentPath,p.anchorIndex),k&&i.setSelection(c(k,b)),i.build()}createCodeBlockNode(o){return e(i("code_block"),[n(o.formattedText)],t(),{language:o.language,backgroundColor:""})}createParagraphNode(o){return e(i("paragraph"),[n(o)],t())}announceMixedContent(t){let e=0,n=0;const o=[];for(const s of t)s.detection?(n++,o.includes(s.detection.language)||o.push(s.detection.language)):e++;this.context?.announce(this.locale.detectedMixedContent(e,n,o))}};export{y as i,P as n,j as r,T as t};
2
- //# sourceMappingURL=SmartPastePlugin-CYa_nD9v.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SmartPastePlugin-CYa_nD9v.mjs","names":[],"sources":["../../src/plugins/smart-paste/ContentSplitter.ts","../../src/plugins/smart-paste/SmartPasteLocale.ts","../../src/plugins/smart-paste/SmartPasteTypes.ts","../../src/plugins/smart-paste/SmartPastePlugin.ts"],"sourcesContent":["/**\n * Splits pasted text at blank-line boundaries and classifies each segment\n * using content detectors. Adjacent segments of the same type are merged.\n */\n\nimport type { ContentDetector, DetectionResult, PasteSegment } from './SmartPasteTypes.js';\n\n/** Pattern matching one or more consecutive blank lines (may contain whitespace). */\nconst BLANK_LINE_SPLIT: RegExp = /\\n(?:[ \\t]*\\n)+/;\n\n/**\n * Splits text at blank-line boundaries and classifies each segment\n * using the provided detectors. Returns null if no code is detected\n * in any segment (the paste should fall through to default handling).\n */\nexport function splitAndClassify(\n\ttext: string,\n\tdetectors: readonly ContentDetector[],\n): readonly PasteSegment[] | null {\n\tconst rawSegments: readonly string[] = text.split(BLANK_LINE_SPLIT);\n\tconst trimmed: readonly string[] = rawSegments\n\t\t.map((s: string) => s.trim())\n\t\t.filter((s: string) => s.length > 0);\n\n\tif (trimmed.length === 0) return null;\n\n\tlet hasCode = false;\n\tconst segments: PasteSegment[] = trimmed.map((segmentText: string): PasteSegment => {\n\t\tconst detection: DetectionResult | null = detectBest(segmentText, detectors);\n\t\tif (detection) hasCode = true;\n\t\treturn { text: segmentText, detection };\n\t});\n\n\tif (!hasCode) return null;\n\n\treturn mergeAdjacentSegments(segments);\n}\n\n/**\n * Merges adjacent segments that share the same classification:\n * consecutive text segments become one paragraph, consecutive code\n * segments of the same language become one code block.\n */\nexport function mergeAdjacentSegments(segments: readonly PasteSegment[]): readonly PasteSegment[] {\n\tif (segments.length <= 1) return segments;\n\n\tconst merged: PasteSegment[] = [segments[0] as PasteSegment];\n\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tconst current: PasteSegment = segments[i] as PasteSegment;\n\t\tconst previous: PasteSegment = merged[merged.length - 1] as PasteSegment;\n\n\t\tif (canMerge(previous, current)) {\n\t\t\tmerged[merged.length - 1] = merge(previous, current);\n\t\t} else {\n\t\t\tmerged.push(current);\n\t\t}\n\t}\n\n\treturn merged;\n}\n\n/**\n * Picks the highest-confidence detection result from all detectors.\n * Ties are broken deterministically by lexicographic language id so the\n * outcome does not depend on detector registration order.\n */\nfunction detectBest(text: string, detectors: readonly ContentDetector[]): DetectionResult | null {\n\tlet best: DetectionResult | null = null;\n\n\tfor (const detector of detectors) {\n\t\tconst result: DetectionResult | null = detector.detect(text);\n\t\tif (!result) continue;\n\t\tif (\n\t\t\tbest === null ||\n\t\t\tresult.confidence > best.confidence ||\n\t\t\t(result.confidence === best.confidence && result.language < best.language)\n\t\t) {\n\t\t\tbest = result;\n\t\t}\n\t}\n\n\treturn best;\n}\n\n/** Two segments can merge if both are text or both are code of the same language. */\nfunction canMerge(a: PasteSegment, b: PasteSegment): boolean {\n\tif (!a.detection && !b.detection) return true;\n\tif (a.detection && b.detection) return a.detection.language === b.detection.language;\n\treturn false;\n}\n\n/** Merges two compatible segments into one. */\nfunction merge(a: PasteSegment, b: PasteSegment): PasteSegment {\n\tconst joinedText: string = `${a.text}\\n\\n${b.text}`;\n\n\tif (!a.detection && !b.detection) {\n\t\treturn { text: joinedText, detection: null };\n\t}\n\n\tconst detA: DetectionResult = a.detection as DetectionResult;\n\tconst detB: DetectionResult = b.detection as DetectionResult;\n\n\treturn {\n\t\ttext: joinedText,\n\t\tdetection: {\n\t\t\tlanguage: detA.language,\n\t\t\tformattedText: `${detA.formattedText}\\n\\n${detB.formattedText}`,\n\t\t\tconfidence: Math.max(detA.confidence, detB.confidence),\n\t\t},\n\t};\n}\n","/** Locale interface and default English locale for the SmartPastePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\nexport interface SmartPasteLocale {\n\treadonly detectedAsCodeBlock: (language: string) => string;\n\treadonly detectedMixedContent: (\n\t\ttextCount: number,\n\t\tcodeCount: number,\n\t\tlanguages: readonly string[],\n\t) => string;\n}\n\nexport const SMART_PASTE_LOCALE_EN: SmartPasteLocale = {\n\tdetectedAsCodeBlock: (language: string) =>\n\t\t`Pasted as ${language} code block with syntax highlighting.`,\n\tdetectedMixedContent: (textCount: number, codeCount: number, languages: readonly string[]) => {\n\t\tconst parts: string[] = [];\n\t\tif (textCount > 0) {\n\t\t\tparts.push(`${textCount} paragraph${textCount > 1 ? 's' : ''}`);\n\t\t}\n\t\tif (codeCount > 0) {\n\t\t\tconst langList: string = languages.join(', ');\n\t\t\tparts.push(`${codeCount} code block${codeCount > 1 ? 's' : ''} (${langList})`);\n\t\t}\n\t\treturn `Pasted as ${parts.join(' and ')}.`;\n\t},\n};\n\nconst localeModules: LocaleModuleMap<SmartPasteLocale> = import.meta.glob<{\n\tdefault: SmartPasteLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadSmartPasteLocale(lang: string): Promise<SmartPasteLocale> {\n\treturn loadLocaleModule(localeModules, lang, SMART_PASTE_LOCALE_EN);\n}\n","/**\n * Types for the smart paste plugin — content detection and formatting.\n */\n\nimport { ServiceKey } from '../Plugin.js';\nimport type { SmartPasteLocale } from './SmartPasteLocale.js';\n\n/** Result of detecting structured content in pasted text. */\nexport interface DetectionResult {\n\treadonly language: string;\n\treadonly formattedText: string;\n\treadonly confidence: number;\n}\n\n/** A classified segment of pasted text — either plain text or detected code. */\nexport interface PasteSegment {\n\treadonly text: string;\n\treadonly detection: DetectionResult | null;\n}\n\n/** Interface for content detectors that identify and format pasted text. */\nexport interface ContentDetector {\n\treadonly id: string;\n\tdetect(text: string): DetectionResult | null;\n}\n\n/** Configuration for the SmartPastePlugin. */\nexport interface SmartPasteConfig {\n\treadonly detectors?: readonly ContentDetector[];\n\treadonly locale?: SmartPasteLocale;\n}\n\n/** Public service for registering additional content detectors at runtime. */\nexport interface SmartPasteService {\n\tregisterDetector(detector: ContentDetector): void;\n}\n\nexport const SMART_PASTE_SERVICE_KEY = new ServiceKey<SmartPasteService>('smartPaste');\n","/**\n * SmartPastePlugin: detects structured content in clipboard text\n * and inserts it as formatted code blocks with syntax highlighting.\n * Mixed content (text + code) is split into separate blocks.\n */\n\nimport {\n\ttype InsertionContext,\n\tfindTableCellAncestor,\n\tinsertBlockAfterAnchor,\n\tresolveAnchorBlockId,\n\tresolveCellInsertionContext,\n\tresolveRootInsertionContext,\n} from '../../commands/BlockInsertion.js';\nimport { addDeleteSelectionSteps } from '../../commands/Commands.js';\nimport {\n\ttype BlockNode,\n\tcreateBlockNode,\n\tcreateTextNode,\n\tgenerateBlockId,\n} from '../../model/Document.js';\nimport {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisTextSelection,\n} from '../../model/Selection.js';\nimport type { BlockId, NodeTypeName } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { PasteInterceptor, Plugin, PluginContext } from '../Plugin.js';\nimport { LANGUAGE_REGISTRY_SERVICE_KEY } from '../language/LanguageTypes.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { splitAndClassify } from './ContentSplitter.js';\nimport {\n\tSMART_PASTE_LOCALE_EN,\n\ttype SmartPasteLocale,\n\tloadSmartPasteLocale,\n} from './SmartPasteLocale.js';\nimport type {\n\tContentDetector,\n\tDetectionResult,\n\tPasteSegment,\n\tSmartPasteConfig,\n} from './SmartPasteTypes.js';\nimport { SMART_PASTE_SERVICE_KEY } from './SmartPasteTypes.js';\n\nexport class SmartPastePlugin implements Plugin {\n\treadonly id = 'smart-paste';\n\treadonly name = 'Smart Paste';\n\treadonly dependencies = ['code-block'] as const;\n\n\tprivate readonly config: SmartPasteConfig;\n\tprivate readonly detectors: ContentDetector[] = [];\n\tprivate context: PluginContext | null = null;\n\tprivate locale: SmartPasteLocale = SMART_PASTE_LOCALE_EN;\n\n\tconstructor(config?: Partial<SmartPasteConfig>) {\n\t\tthis.config = { ...config };\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.context = context;\n\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tSMART_PASTE_LOCALE_EN,\n\t\t\tloadSmartPasteLocale,\n\t\t);\n\n\t\t// Subscribe to language registry for detectors (replay provides built-ins)\n\t\tconst registry = context.getService(LANGUAGE_REGISTRY_SERVICE_KEY);\n\t\tif (registry) {\n\t\t\tregistry.onRegister((support) => {\n\t\t\t\tif (support.detection) {\n\t\t\t\t\tthis.detectors.push(support.detection);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// Register config-provided detectors\n\t\tif (this.config.detectors) {\n\t\t\tfor (const detector of this.config.detectors) {\n\t\t\t\tthis.detectors.push(detector);\n\t\t\t}\n\t\t}\n\n\t\t// Register paste interceptor\n\t\tcontext.registerPasteInterceptor(this.handlePaste, { name: 'smart-paste', priority: 50 });\n\n\t\t// Register service for external detector registration\n\t\tcontext.registerService(SMART_PASTE_SERVICE_KEY, {\n\t\t\tregisterDetector: (detector: ContentDetector) => {\n\t\t\t\tthis.detectors.push(detector);\n\t\t\t},\n\t\t});\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t\tthis.detectors.length = 0;\n\t}\n\n\t// --- Paste Interceptor ---\n\n\tprivate readonly handlePaste: PasteInterceptor = (\n\t\tplainText: string,\n\t\t_html: string,\n\t\tstate: EditorState,\n\t): Transaction | null => {\n\t\tif (this.isCursorInCodeBlock(state)) return null;\n\n\t\tconst segments: readonly PasteSegment[] | null = splitAndClassify(plainText, this.detectors);\n\t\tif (!segments) return null;\n\n\t\t// Single code-only segment: use existing fast path\n\t\tif (segments.length === 1 && segments[0]?.detection) {\n\t\t\treturn this.handleSingleCodeBlock(state, segments[0].detection);\n\t\t}\n\n\t\t// Mixed content: create multiple blocks\n\t\treturn this.handleMixedContent(state, segments);\n\t};\n\n\tprivate isCursorInCodeBlock(state: EditorState): boolean {\n\t\tconst sel = state.selection;\n\t\tif (!isTextSelection(sel)) return false;\n\n\t\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\t\treturn block?.type === 'code_block';\n\t}\n\n\t// --- Single Code Block (existing behavior) ---\n\n\tprivate handleSingleCodeBlock(\n\t\tstate: EditorState,\n\t\tdetection: DetectionResult,\n\t): Transaction | null {\n\t\tconst tr: Transaction | null = this.buildCodeBlockTransaction(state, detection);\n\t\tif (tr && this.context) {\n\t\t\tthis.context.announce(this.locale.detectedAsCodeBlock(detection.language));\n\t\t}\n\t\treturn tr;\n\t}\n\n\tprivate buildCodeBlockTransaction(\n\t\tstate: EditorState,\n\t\tdetection: DetectionResult,\n\t): Transaction | null {\n\t\tconst sel = state.selection;\n\t\tconst builder = state.transaction('paste');\n\n\t\t// Delete selection if range-selected\n\t\tlet anchorBlockId: BlockId;\n\t\tif (isTextSelection(sel) && !isCollapsed(sel)) {\n\t\t\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\t\t\tanchorBlockId = landingId ?? sel.anchor.blockId;\n\t\t} else {\n\t\t\tanchorBlockId = resolveAnchorBlockId(sel);\n\t\t}\n\n\t\t// Create the code block node\n\t\tconst newBlockId: BlockId = generateBlockId();\n\t\tconst codeBlock: BlockNode = createBlockNode(\n\t\t\tnodeType('code_block') as NodeTypeName,\n\t\t\t[createTextNode(detection.formattedText)],\n\t\t\tnewBlockId,\n\t\t\t{ language: detection.language, backgroundColor: '' },\n\t\t);\n\n\t\t// Insert at cursor (handles cell vs root, empty anchor removal)\n\t\tconst inserted: boolean = insertBlockAfterAnchor(\n\t\t\tstate,\n\t\t\tbuilder,\n\t\t\tanchorBlockId,\n\t\t\tcodeBlock,\n\t\t\tsel,\n\t\t\tthis.context?.getSchemaRegistry(),\n\t\t);\n\t\tif (!inserted) return null;\n\n\t\tbuilder.setSelection(createCollapsedSelection(newBlockId, detection.formattedText.length));\n\n\t\treturn builder.build();\n\t}\n\n\t// --- Mixed Content (multiple blocks) ---\n\n\tprivate handleMixedContent(\n\t\tstate: EditorState,\n\t\tsegments: readonly PasteSegment[],\n\t): Transaction | null {\n\t\tconst tr: Transaction | null = this.buildMultiBlockTransaction(state, segments);\n\t\tif (tr && this.context) {\n\t\t\tthis.announceMixedContent(segments);\n\t\t}\n\t\treturn tr;\n\t}\n\n\tprivate buildMultiBlockTransaction(\n\t\tstate: EditorState,\n\t\tsegments: readonly PasteSegment[],\n\t): Transaction | null {\n\t\tconst sel = state.selection;\n\t\tconst builder = state.transaction('paste');\n\n\t\tlet anchorBlockId: BlockId;\n\t\tif (isTextSelection(sel) && !isCollapsed(sel)) {\n\t\t\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\t\t\tanchorBlockId = landingId ?? sel.anchor.blockId;\n\t\t} else {\n\t\t\tanchorBlockId = resolveAnchorBlockId(sel);\n\t\t}\n\n\t\tconst cellId: BlockId | undefined = findTableCellAncestor(state, anchorBlockId);\n\t\tconst schemaRegistry = this.context?.getSchemaRegistry();\n\n\t\tconst ctx: InsertionContext | undefined = cellId\n\t\t\t? resolveCellInsertionContext(state, anchorBlockId, cellId, schemaRegistry)\n\t\t\t: resolveRootInsertionContext(state, anchorBlockId, schemaRegistry);\n\t\tif (!ctx) return null;\n\n\t\tconst insertOffset: number = !cellId && isGapCursor(sel) && sel.side === 'before' ? 0 : 1;\n\t\tlet insertIndex: number = ctx.anchorIndex + insertOffset;\n\t\tlet lastBlockId: BlockId | undefined;\n\t\tlet lastBlockTextLen = 0;\n\n\t\tfor (const segment of segments) {\n\t\t\tconst block: BlockNode = segment.detection\n\t\t\t\t? this.createCodeBlockNode(segment.detection)\n\t\t\t\t: this.createParagraphNode(segment.text);\n\n\t\t\tbuilder.insertNode(ctx.parentPath, insertIndex, block);\n\t\t\tinsertIndex++;\n\t\t\tlastBlockId = block.id;\n\t\t\tlastBlockTextLen = segment.detection\n\t\t\t\t? segment.detection.formattedText.length\n\t\t\t\t: segment.text.length;\n\t\t}\n\n\t\tconst shouldRemoveAnchor: boolean = cellId\n\t\t\t? ctx.isAnchorEmpty && ctx.anchorIndex >= 0\n\t\t\t: ctx.isAnchorEmpty && !isGapCursor(sel);\n\n\t\tif (shouldRemoveAnchor) {\n\t\t\tbuilder.removeNode(ctx.parentPath, ctx.anchorIndex);\n\t\t}\n\n\t\tif (lastBlockId) {\n\t\t\tbuilder.setSelection(createCollapsedSelection(lastBlockId, lastBlockTextLen));\n\t\t}\n\n\t\treturn builder.build();\n\t}\n\n\tprivate createCodeBlockNode(detection: DetectionResult): BlockNode {\n\t\treturn createBlockNode(\n\t\t\tnodeType('code_block') as NodeTypeName,\n\t\t\t[createTextNode(detection.formattedText)],\n\t\t\tgenerateBlockId(),\n\t\t\t{ language: detection.language, backgroundColor: '' },\n\t\t);\n\t}\n\n\tprivate createParagraphNode(text: string): BlockNode {\n\t\treturn createBlockNode(\n\t\t\tnodeType('paragraph') as NodeTypeName,\n\t\t\t[createTextNode(text)],\n\t\t\tgenerateBlockId(),\n\t\t);\n\t}\n\n\tprivate announceMixedContent(segments: readonly PasteSegment[]): void {\n\t\tlet textCount = 0;\n\t\tlet codeCount = 0;\n\t\tconst languages: string[] = [];\n\n\t\tfor (const segment of segments) {\n\t\t\tif (segment.detection) {\n\t\t\t\tcodeCount++;\n\t\t\t\tif (!languages.includes(segment.detection.language)) {\n\t\t\t\t\tlanguages.push(segment.detection.language);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttextCount++;\n\t\t\t}\n\t\t}\n\n\t\tthis.context?.announce(this.locale.detectedMixedContent(textCount, codeCount, languages));\n\t}\n}\n"],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- import{r as t}from"./Platform-ByobkiCc.mjs";import{a as e,c as i,n as o,o as r,r as s}from"./PluginHelpers-Dx_0hfDe.mjs";import{t as n}from"./ShortcutFormatting-TwiufqeV.mjs";import{t as a}from"./NodeSpecPatching-B_yLknTl.mjs";import{t as c}from"./DirectionIcons-Bbawl9ei.mjs";import{t as l}from"./TextDirectionService-BcX07mw2.mjs";import{r as h}from"./DirectionDetection-CDVSEWQ6.mjs";var u=class{context;pendingDir=null;container=null;constructor(t){this.context=t}attach(t){this.container=t,t.addEventListener("keydown",this.onKeydown),t.addEventListener("keyup",this.onKeyup)}detach(){this.container&&(this.container.removeEventListener("keydown",this.onKeydown),this.container.removeEventListener("keyup",this.onKeyup),this.container=null)}onKeydown=t=>{"Shift"!==t.key||!t.ctrlKey||t.altKey||t.metaKey?this.pendingDir=null:"ShiftLeft"===t.code?this.pendingDir="ltr":"ShiftRight"===t.code&&(this.pendingDir="rtl")};onKeyup=t=>{if("Shift"!==t.key||!this.pendingDir)return;const e=this.pendingDir;this.pendingDir=null;const i="ltr"===e?"setDirectionLTR":"setDirectionRTL";this.context.executeCommand(i)}},m={ltr:"Left to Right",rtl:"Right to Left",auto:"Auto",toolbarLabel:"Text Direction",toolbarTooltip:"Text Direction",announceLTR:"Text direction set to left-to-right",announceRTL:"Text direction set to right-to-left",announceAuto:"Text direction set to automatic"},d=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-BwaoCUVN.mjs"),"./locales/de.ts":()=>import("./de-BdD3DpUB.mjs"),"./locales/es.ts":()=>import("./es-kfKiqpyD.mjs"),"./locales/fr.ts":()=>import("./fr-BSUKEtTk.mjs"),"./locales/hi.ts":()=>import("./hi-Dt89SxNy.mjs"),"./locales/pt.ts":()=>import("./pt-CMrFpUWS.mjs"),"./locales/ru.ts":()=>import("./ru-C9yFslEG.mjs"),"./locales/zh.ts":()=>import("./zh-CnW44JEw.mjs")});async function p(t){return i(d,t,m)}var g={directableTypes:["paragraph","heading","title","subtitle","table_cell","blockquote","list_item"]},D=["ltr","rtl","auto"],f=class{id="text-direction";name="Text Direction";priority=91;config;locale;directableTypes;shiftDirHandler=null;constructor(t){this.config={...g,...t}}async init(e){this.locale=await r(e,this.config.locale,m,p),this.directableTypes=new Set(this.config.directableTypes),this.patchNodeSpecs(e),this.registerCommands(e),this.registerKeymaps(e),this.registerToolbarItem(e),this.registerService(e),t()||(this.shiftDirHandler=new u(e),this.shiftDirHandler.attach(e.getContainer()))}destroy(){this.shiftDirHandler?.detach(),this.shiftDirHandler=null}registerService(t){const e={directableTypes:this.directableTypes,getBlockDir:h};t.registerService(l,e)}patchNodeSpecs(t){a(t.getSchemaRegistry(),this.config.directableTypes,{attrName:"dir",getDefault:()=>"auto",applyToDOM:y})}registerCommands(t){t.registerCommand("setDirectionLTR",()=>{const e=this.setDirection(t,"ltr");return e&&t.announce(this.locale.announceLTR),e}),t.registerCommand("setDirectionRTL",()=>{const e=this.setDirection(t,"rtl");return e&&t.announce(this.locale.announceRTL),e}),t.registerCommand("setDirectionAuto",()=>{const e=this.setDirection(t,"auto");return e&&t.announce(this.locale.announceAuto),e}),t.registerCommand("toggleDirection",()=>{const e=s(t.getState());if(!e||!this.directableTypes.has(e.type))return!1;const i=h(e),o="auto"===i?"rtl":"rtl"===i?"ltr":"auto";return this.setDirection(t,o)})}registerKeymaps(t){t.registerKeymap({"Mod-Shift-D":()=>t.executeCommand("toggleDirection")})}registerToolbarItem(t){const e={ltr:"setDirectionLTR",rtl:"setDirectionRTL",auto:"setDirectionAuto"},i=D.map(t=>({label:this.getDirectionLabel(t),command:e[t],icon:c[t]}));t.registerToolbarItem({id:"text-direction",group:"block",icon:c.auto,label:this.locale.toolbarLabel,tooltip:`${this.locale.toolbarTooltip} (${n("Mod-Shift-D")})`,command:"setDirectionAuto",popupType:"dropdown",popupConfig:{items:i},isActive:t=>this.isNonDefaultDirection(t),isEnabled:t=>this.isDirectable(t),getIcon:t=>{const e=s(t);return e?c[h(e)]??c.auto:c.auto}})}getDirectionLabel(t){return"ltr"===t?this.locale.ltr:"rtl"===t?this.locale.rtl:this.locale.auto}setDirection(t,i){const r=t.getState(),s=e(r);if(0===s.length)return!1;const n=r.transaction("command");let a=!1;for(const e of s){const t=r.getBlock(e);if(!t||!this.directableTypes.has(t.type))continue;const o=r.getNodePath(e);o&&(n.setNodeAttr(o,{...t.attrs,dir:i}),a=!0)}return!!a&&o(t,n.setSelection(r.selection).build())}isNonDefaultDirection(t){const e=s(t);if(!e||!this.directableTypes.has(e.type))return!1;const i=e.attrs?.dir;return null!=i&&"auto"!==i}isDirectable(t){const e=s(t);return null!=e&&this.directableTypes.has(e.type)}};function y(t,e){const i=e.attrs?.dir;"ltr"!==i&&"rtl"!==i&&"auto"!==i||t.setAttribute("dir",i)}export{m as n,p as r,f as t};
2
- //# sourceMappingURL=TextDirectionPlugin-Bns_03vL.mjs.map
@@ -1,2 +0,0 @@
1
- import{n as e}from"./TypedKeys-CA4bfw9O.mjs";var r=new e("textDirection");export{r as t};
2
- //# sourceMappingURL=TextDirectionService-BcX07mw2.mjs.map
@@ -1,2 +0,0 @@
1
- import{_ as t,m as e}from"./Commands-1dFFldi7.mjs";import{i}from"./TypeBrands-Ch9856Gb.mjs";import{c as s,n as o,o as r,s as n}from"./PluginHelpers-Dx_0hfDe.mjs";import{t as a}from"./MarkInputRule-Bdi8KPus.mjs";import{t as l}from"./ShortcutFormatting-TwiufqeV.mjs";var g={boldLabel:"Bold",italicLabel:"Italic",underlineLabel:"Underline"},c=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-Dx2lO0Nm.mjs"),"./locales/de.ts":()=>import("./de-BcPntcnr.mjs"),"./locales/es.ts":()=>import("./es-nRLq7bgP.mjs"),"./locales/fr.ts":()=>import("./fr-DiDhVhyV.mjs"),"./locales/hi.ts":()=>import("./hi-BNJIGWQQ.mjs"),"./locales/pt.ts":()=>import("./pt-D__tcM2T.mjs"),"./locales/ru.ts":()=>import("./ru-CvDl-yEd.mjs"),"./locales/zh.ts":()=>import("./zh-C-wHnDo5.mjs")});async function m(t){return s(c,t,g)}var p={bold:!0,italic:!0,underline:!0},f=[{type:"bold",configKey:"bold",rank:0,tag:"strong",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/></svg>',keyBinding:"Mod-B",toHTMLString:t=>`<strong>${t}</strong>`,parseHTML:[{tag:"strong"},{tag:"b",getAttrs:t=>{const e=t.style.fontWeight;return"normal"!==e&&"400"!==e&&{}}},{tag:"span",getAttrs:t=>{const e=t.style.fontWeight;if(!e)return!1;if("bold"===e)return{};const i=Number.parseInt(e,10);return!Number.isNaN(i)&&i>=700&&{}}}],sanitize:{tags:["strong","b"]}},{type:"italic",configKey:"italic",rank:1,tag:"em",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/></svg>',keyBinding:"Mod-I",toHTMLString:t=>`<em>${t}</em>`,parseHTML:[{tag:"em"},{tag:"i"},{tag:"span",getAttrs:t=>"italic"===t.style.fontStyle&&{}}],sanitize:{tags:["em","i"]}},{type:"underline",configKey:"underline",rank:2,tag:"u",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/></svg>',keyBinding:"Mod-U",toHTMLString:t=>`<u>${t}</u>`,parseHTML:[{tag:"u"},{tag:"span",getAttrs:t=>!!t.style.textDecoration.includes("underline")&&{}}],sanitize:{tags:["u"]}}],h=class{id="text-formatting";name="Text Formatting";priority=20;config;locale;constructor(t){this.config={...p,...t}}async init(t){this.locale=await r(t,this.config.locale,g,m);const e=f.filter(t=>this.config[t.configKey]);for(const i of e)this.registerMark(t,i);this.registerKeymaps(t,e),this.registerInputRules(t),this.registerDisabledToolbarItems(t)}registerMark(s,r){const a=n(r.type),g=this.isToolbarVisible(r.configKey);if(s.registerMarkSpec({type:r.type,rank:r.rank,toDOM:()=>document.createElement(r.tag),toHTMLString:(t,e)=>r.toHTMLString(e),parseHTML:r.parseHTML,sanitize:r.sanitize}),s.registerCommand(a,()=>o(s,t(s.getState(),i(r.type)))),g){const t=this.getMarkLabel(r.type);s.registerToolbarItem({id:r.type,group:"format",icon:r.icon,label:t,tooltip:`${t} (${l(r.keyBinding)})`,command:a,isActive:t=>e(t,i(r.type))})}}registerKeymaps(t,e){const i={};for(const s of e){const e=n(s.type);i[s.keyBinding]=()=>t.executeCommand(e)}Object.keys(i).length>0&&t.registerKeymap(i)}registerInputRules(t){!1!==this.config.inputRule&&(this.config.bold&&t.registerInputRule(a("bold","**")),this.config.italic&&t.registerInputRule(a("italic","*")))}registerDisabledToolbarItems(t){if(this.config.toolbar)for(const e of f){const i=this.config[e.configKey],s=this.config.toolbar[e.configKey]??!0;!i&&s&&t.registerToolbarItem({id:e.type,group:"format",icon:e.icon,label:this.getMarkLabel(e.type),command:n(e.type),isEnabled:()=>!1})}}getMarkLabel(t){const e=`${t}Label`;return this.locale[e]}isToolbarVisible(t){return!this.config.toolbar||(this.config.toolbar[t]??!0)}};export{g as n,m as r,h as t};
2
- //# sourceMappingURL=TextFormattingPlugin-DBVlePqj.mjs.map
@@ -1,2 +0,0 @@
1
- import{i as t}from"./Platform-ByobkiCc.mjs";import{c as e,s as o}from"./StyleRuntime-DW6omotc.mjs";import{n}from"./TypedKeys-CA4bfw9O.mjs";import{c as r,o as i}from"./PluginHelpers-Dx_0hfDe.mjs";import{n as l,r as s,t as a}from"./KeyboardNav-D0my3wuy.mjs";import{i as c,r as d,t as p}from"./PopupPositioning-BFh6Ed1D.mjs";import{n as u,t as h}from"./PopupManager-CT-fMZJn.mjs";var b=class{_toolbarItems=/* @__PURE__ */new Map;_toolbarItemPluginMap=/* @__PURE__ */new Map;registerToolbarItem(t,e){if(this._toolbarItems.has(t.id))throw new Error(`ToolbarItem with id "${t.id}" is already registered.`);if(this._toolbarItems.set(t.id,t),e){const o=this._toolbarItemPluginMap.get(e)??[];o.push(t.id),this._toolbarItemPluginMap.set(e,o)}}getToolbarItemsByPlugin(t){const e=this._toolbarItemPluginMap.get(t)??[],o=[];for(const n of e){const t=this._toolbarItems.get(n);t&&o.push(t)}return o}getToolbarItem(t){return this._toolbarItems.get(t)}getToolbarItems(){return[...this._toolbarItems.values()]}removeToolbarItem(t){this._toolbarItems.delete(t);for(const[e,o]of this._toolbarItemPluginMap){const n=o.indexOf(t);if(-1!==n){o.splice(n,1),0===o.length&&this._toolbarItemPluginMap.delete(e);break}}}clear(){this._toolbarItems.clear(),this._toolbarItemPluginMap.clear()}};function m(t){for(let e=0;e<t.length;e++)if(!t[e]?.disabled)return e;return-1}var f={formattingOptionsAria:"Formatting options",moreToolsAria:"More tools",gridPickerLabel:(t,e)=>`${t} x ${e}`},v=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-C9lO1jsY.mjs"),"./locales/de.ts":()=>import("./de-BXQBXxFJ.mjs"),"./locales/es.ts":()=>import("./es-CXuMz87y.mjs"),"./locales/fr.ts":()=>import("./fr-fshsDD66.mjs"),"./locales/hi.ts":()=>import("./hi-BOMkDPqC.mjs"),"./locales/pt.ts":()=>import("./pt-Cc4zysaT.mjs"),"./locales/ru.ts":()=>import("./ru-CwyPz2Va.mjs"),"./locales/zh.ts":()=>import("./zh-DgSmvLyw.mjs")});async function g(t){return r(v,t,f)}var w={BurgerMenu:"burger-menu",Flow:"flow",None:"none"},x="notectl-toolbar-btn--overflow-hidden",y="notectl-toolbar-separator--overflow-hidden",A="notectl-toolbar-group--overflow-hidden",E="notectl-toolbar-group",_="notectl-toolbar-separator",k=class{toolbar;context;onOverflowChange;onItemActivated;getActiveElement;ariaLabel;popupManager;entries=[];overflowButton=null;overflowDropdown=null;overflowHandle=null;overflowEntries=[];resizeObserver=null;closeHandler=null;closeHandlerTimer=null;closeHandlerAttached=!1;constructor(t){this.toolbar=t.toolbar,this.ariaLabel=t.ariaLabel,this.context=t.context,this.onOverflowChange=t.onOverflowChange,this.onItemActivated=t.onItemActivated,this.getActiveElement=t.getActiveElement,this.popupManager=t.popupManager??null,this.resizeObserver=new ResizeObserver(()=>this.recalculate()),this.resizeObserver.observe(this.toolbar)}update(t){this.entries=t.map(t=>({element:t.element,item:t.item})),this.recalculate()}recalculate(){if(0===this.entries.length)return;this.closeDropdown(),this.resetVisibility(),this.ensureOverflowButton(),this.setOverflowButtonVisible(!1);const t=this.measureAvailableWidth(),e=Array.from(this.toolbar.children),o=this.measureChildWidths(e),n=t-34-2;let r=0,i=!1;const l=[];for(const s of e){if(s===this.overflowButton)continue;if(s.classList.contains(_)){const t=(o.get(s)??0)+2;i||r+t>n?(i=!0,s.classList.add(y)):r+=t;continue}if(s.classList.contains(E)){const t=(o.get(s)??0)+2,e=this.entriesInside(s);i||r+t>n?(i=!0,this.hideGroup(s,e,l)):r+=t;continue}const t=this.entries.find(t=>t.element===s);if(!t)continue;const e=(o.get(s)??0)+2;i||r+e>n?(i=!0,t.element.classList.add(x),l.push(t)):r+=e}this.overflowEntries=l,this.hideTrailingSeparators(),this.setOverflowButtonVisible(l.length>0),this.notifyChange()}hideGroup(t,e,o){t.classList.add(A);for(const n of e)n.element.classList.add(x),o.push(n)}entriesInside(t){const e=[];for(const o of this.entries)t.contains(o.element)&&e.push(o);return e}updateItemStates(t){if(!this.overflowDropdown)return;const e=Array.from(this.overflowDropdown.querySelectorAll(".notectl-dropdown__item"));for(const o of e){const e=o.getAttribute("data-toolbar-item"),n=this.overflowEntries.find(t=>t.item.id===e);if(!n)continue;const r=n.item.isActive?.(t)??!1,i=n.item.isEnabled?.(t)??!0;if(o.classList.toggle("notectl-dropdown__item--active",r),o.disabled=!i,"combobox"===n.item.popupType){const e=o.querySelector(".notectl-dropdown__item-label");e&&(e.textContent=n.item.getLabel(t))}if(n.item.getIcon){const e=n.item.getIcon(t),r=o.querySelector(".notectl-dropdown__item-icon");r&&r.innerHTML!==e&&(r.innerHTML=e)}}}destroy(){this.resizeObserver?.disconnect(),this.resizeObserver=null,this.closeDropdown(),this.overflowButton?.remove(),this.overflowButton=null,this.entries=[],this.overflowEntries=[]}measureChildWidths(t){const e=/* @__PURE__ */new Map;for(const o of t)o!==this.overflowButton&&e.set(o,o.offsetWidth);return e}measureAvailableWidth(){const t=getComputedStyle(this.toolbar),e=Number.parseFloat(t.paddingLeft)||0,o=Number.parseFloat(t.paddingRight)||0;return this.toolbar.clientWidth-e-o}resetVisibility(){for(const o of this.entries)o.element.classList.remove(x);const t=Array.from(this.toolbar.querySelectorAll(`.${_}`));for(const o of t)o.classList.remove(y);const e=Array.from(this.toolbar.querySelectorAll(`.${E}`));for(const o of e)o.classList.remove(A)}setOverflowButtonVisible(t){this.overflowButton&&(this.overflowButton.classList.toggle("notectl-toolbar-overflow-btn--hidden",!t),t||this.overflowButton.removeAttribute("tabindex"))}ensureOverflowButton(){if(this.overflowButton)return;const t=document.createElement("button");t.type="button",t.className="notectl-toolbar-overflow-btn",t.setAttribute("aria-label",this.ariaLabel),t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded","false"),t.setAttribute("part","toolbar-button toolbar-overflow-button"),t.innerHTML='<svg viewBox="0 0 16 16" width="16" height="16"><circle cx="3" cy="8" r="1.5" fill="currentColor"/><circle cx="8" cy="8" r="1.5" fill="currentColor"/><circle cx="13" cy="8" r="1.5" fill="currentColor"/></svg>',t.addEventListener("mousedown",t=>{t.preventDefault(),this.toggleDropdown()}),this.toolbar.appendChild(t),this.overflowButton=t}toggleDropdown(){this.overflowDropdown?this.closeDropdown():this.openDropdown()}openDropdown(){if(!this.overflowButton||0===this.overflowEntries.length)return;const t=document.createElement("div");t.className="notectl-toolbar-popup notectl-dropdown",t.setAttribute("role","menu"),this.renderDropdownItems(t,this.context.getState()),this.popupManager?(this.overflowHandle=this.popupManager.open({anchor:this.overflowButton,className:"notectl-toolbar-popup notectl-dropdown",ariaRole:"menu",position:"below-end",referenceNode:this.overflowButton,restoreFocusTo:this.overflowButton,onClose:()=>{this.overflowHandle=null,this.overflowDropdown=null,this.overflowButton&&this.overflowButton.setAttribute("aria-expanded","false")},content:t=>{this.renderDropdownItems(t,this.context.getState()),this.overflowDropdown=t,t.addEventListener("keydown",t=>this.handleDropdownKeydown(t))}}),this.overflowButton.setAttribute("aria-expanded","true")):(this.positionDropdown(t),p(t,this.overflowButton),this.overflowDropdown=t,this.overflowButton.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{t.querySelector('[role="menuitem"]')?.focus()}),t.addEventListener("keydown",t=>this.handleDropdownKeydown(t)),this.registerCloseHandler())}renderDropdownItems(t,e){let o=null;for(const n of this.overflowEntries){if(null!==o&&n.item.group!==o){const e=document.createElement("div");e.className="notectl-dropdown__separator",e.setAttribute("role","separator"),t.appendChild(e)}o=n.item.group;const r=document.createElement("button");r.type="button",r.className="notectl-dropdown__item",r.setAttribute("role","menuitem"),r.setAttribute("tabindex","-1"),r.setAttribute("data-toolbar-item",n.item.id);const i=document.createElement("span");i.className="notectl-dropdown__item-icon","combobox"!==n.item.popupType&&(i.innerHTML=n.item.icon),r.appendChild(i);const l=document.createElement("span");l.className="notectl-dropdown__item-label",l.textContent="combobox"===n.item.popupType?n.item.getLabel(e):n.item.tooltip??n.item.label,r.appendChild(l),r.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),this.activateOverflowItem(n)}),t.appendChild(r)}}positionDropdown(e){if(!this.overflowButton)return;const o=this.overflowButton.getBoundingClientRect(),n=t(this.toolbar);c(e,o,{position:n?"below-start":"below-end",isRtl:n})}registerCloseHandler(){this.closeHandler=t=>{const e=t.composedPath();this.overflowDropdown&&!e.includes(this.overflowDropdown)&&this.overflowButton&&!e.includes(this.overflowButton)&&this.closeDropdown()},this.closeHandlerTimer=setTimeout(()=>{this.closeHandlerTimer=null,this.closeHandler&&this.overflowDropdown&&(document.addEventListener("mousedown",this.closeHandler),this.closeHandlerAttached=!0)},0)}closeDropdown(){if(this.overflowHandle){const t=this.overflowHandle;return this.overflowHandle=null,this.overflowDropdown=null,t.close(),void(this.overflowButton&&this.overflowButton.setAttribute("aria-expanded","false"))}this.overflowDropdown&&(this.overflowDropdown.remove(),this.overflowDropdown=null),this.overflowButton&&this.overflowButton.setAttribute("aria-expanded","false"),this.closeHandler&&(null!==this.closeHandlerTimer&&(clearTimeout(this.closeHandlerTimer),this.closeHandlerTimer=null),this.closeHandlerAttached&&(document.removeEventListener("mousedown",this.closeHandler),this.closeHandlerAttached=!1),this.closeHandler=null)}activateOverflowItem(t){this.closeDropdown(),t.item.popupType&&this.overflowButton?this.onItemActivated(this.overflowButton,t.item):this.context.executeCommand(t.item.command)}handleDropdownKeydown(t){if(!this.overflowDropdown)return;if("Escape"===t.key||"Tab"===t.key)return t.preventDefault(),t.stopPropagation(),this.closeDropdown(),void this.overflowButton?.focus();const e=Array.from(this.overflowDropdown.querySelectorAll('[role="menuitem"]')),o=e.indexOf(this.getActiveElement());switch(t.key){case"ArrowDown":t.preventDefault(),e[l(e,o,1)]?.focus();break;case"ArrowUp":t.preventDefault(),e[l(e,o,-1)]?.focus();break;case"Enter":case" ":{t.preventDefault();const n=e[o];if(!n)break;const r=n.getAttribute("data-toolbar-item"),i=this.overflowEntries.find(t=>t.item.id===r);i&&this.activateOverflowItem(i);break}}}hideTrailingSeparators(){const t=Array.from(this.toolbar.children);for(let e=t.length-1;e>=0;e--){const o=t[e];if(!o||o===this.overflowButton)continue;if(o.classList.contains(_)){o.classList.contains(y)||o.classList.add(y);continue}const n=o.classList.contains(E)&&o.classList.contains(A),r=o.classList.contains("notectl-toolbar-btn")&&o.classList.contains(x);if(!n&&!r)break}}notifyChange(){const t=this.entries.filter(t=>!t.element.classList.contains(x)).map(t=>t.element);this.onOverflowChange(t,this.overflowEntries.length>0?this.overflowButton:null)}};function C(t,e,o){const n=t.querySelectorAll(".notectl-grid-picker__cell");for(const r of n){const t=Number(r.getAttribute("data-row")),n=Number(r.getAttribute("data-col"));r.classList.toggle("notectl-grid-picker__cell--highlighted",t<=e&&n<=o)}}function B(){const t=document.createElement("span");return t.className="notectl-toolbar-separator",t.setAttribute("role","separator"),t.setAttribute("part","toolbar-divider"),t}var L=class{activePopup=null;activePopupButton=null;activeHandle=null;getActiveElement;locale;popupManager=null;constructor(t,e=f){this.getActiveElement=t,this.locale=e}setPopupManager(t){this.popupManager=t}isOpen(){return null!==this.activePopup}toggle(t,e,o){this.activePopup?this.close():this.openViaManager(t,e,o)}close(){if(this.activeHandle){const t=this.activeHandle;return this.activeHandle=null,this.clearButtonState(),void t.close()}this.clearButtonState(),this.activePopup&&(this.activePopup.remove(),this.activePopup=null)}closeAndRestoreFocus(){const t=this.activePopupButton;this.close(),t?.focus()}destroy(){this.close()}openViaManager(t,e,o){this.popupManager&&(this.activePopupButton=t,t.classList.add("notectl-toolbar-btn--popup-open"),t.setAttribute("aria-expanded","true"),this.activeHandle=this.popupManager.open({anchor:t,className:"notectl-toolbar-popup",referenceNode:t,restoreFocusTo:t,position:"below-start",onClose:()=>{this.activeHandle=null,this.clearButtonState(),this.activePopup=null},content:(t,n)=>{this.activePopup=t,this.renderPopupContent(t,e,o,n),t.addEventListener("keydown",t=>this.handlePopupKeydown(t))}}))}renderPopupContent(t,e,n,r){const i=()=>{r({restoreFocusTo:null}),n.getContainer().focus()};switch(e.popupType){case"gridPicker":!function(t,e,n,r=f){t.className+=" notectl-grid-picker";const i=document.createElement("div");i.className="notectl-grid-picker__grid",i.setAttribute("role","grid"),o(i,{display:"grid",gridTemplateColumns:`repeat(${e.maxCols}, 1fr)`,gap:"2px",padding:"8px"});const l=document.createElement("div");l.className="notectl-grid-picker__label",l.textContent=r.gridPickerLabel(1,1),o(l,{textAlign:"center",padding:"4px",fontSize:"12px"}),l.setAttribute("aria-live","polite");for(let s=1;s<=e.maxRows;s++)for(let t=1;t<=e.maxCols;t++){const a=document.createElement("div");a.className="notectl-grid-picker__cell",a.setAttribute("role","gridcell"),a.setAttribute("tabindex","-1"),a.setAttribute("aria-label",r.gridPickerLabel(s,t)),o(a,{width:"20px",height:"20px",border:"1px solid #ccc",cursor:"pointer"}),a.setAttribute("data-row",String(s)),a.setAttribute("data-col",String(t)),a.addEventListener("mouseenter",()=>{C(i,s,t),l.textContent=r.gridPickerLabel(s,t)}),a.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),a.addEventListener("click",()=>{e.onSelect(s,t),n()}),i.appendChild(a)}t.appendChild(i),t.appendChild(l)}(t,e.popupConfig,i,this.locale);break;case"dropdown":!function(t,e,o,r){t.classList.add("notectl-dropdown"),t.setAttribute("role","menu");for(const i of e.items){const e=document.createElement("button");if(e.type="button",e.className="notectl-dropdown__item",e.setAttribute("role","menuitem"),e.setAttribute("tabindex","-1"),i.icon){const t=document.createElement("span");t.className="notectl-dropdown__item-icon",t.innerHTML=i.icon,e.appendChild(t)}const o=document.createElement("span");o.className="notectl-dropdown__item-label",o.textContent=i.label,e.appendChild(o),e.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation()}),e.addEventListener("click",()=>{var t;t=i.command,n.executeCommand(t),r()}),t.appendChild(e)}}(t,e.popupConfig,0,i);break;case"custom":case"combobox":e.renderPopup(t,n,r)}}clearButtonState(){this.activePopupButton&&(this.activePopupButton.classList.remove("notectl-toolbar-btn--popup-open"),this.activePopupButton.setAttribute("aria-expanded","false"),this.activePopupButton=null)}handlePopupKeydown(t){if(!this.activePopup)return;if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void this.closeAndRestoreFocus();if("Tab"===t.key)return t.preventDefault(),void this.closeAndRestoreFocus();const e=this.activePopup.querySelectorAll('[role="menuitem"]');e.length>0?this.handleDropdownKeydown(t,e):null===this.activePopup.querySelector(".notectl-grid-picker__cell")?this.handleCustomPopupKeydown(t):this.handleGridKeydown(t)}handleDropdownKeydown(t,e){const o=Array.from(e),n=o.indexOf(this.getActiveElement());switch(t.key){case"ArrowDown":t.preventDefault(),o[l(o,n,1)]?.focus();break;case"ArrowUp":t.preventDefault(),o[l(o,n,-1)]?.focus();break;case"Enter":case" ":{t.preventDefault();const e=o[n];e&&e.click();break}}}handleGridKeydown(e){const o=this.getActiveElement(),n=Number(o?.getAttribute("data-row")??1),r=Number(o?.getAttribute("data-col")??1),i=this.activePopup?.querySelector(".notectl-grid-picker__grid")??null;if(!i)return;const l=i.querySelector(".notectl-grid-picker__cell:last-child"),a=Number(l?.getAttribute("data-col")??1),c=Number(l?.getAttribute("data-row")??1);if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)){e.preventDefault();const[o,l]=s(n,r,c,a,e.key,!!this.activePopup&&t(this.activePopup));i.querySelector(`.notectl-grid-picker__cell[data-row="${o}"][data-col="${l}"]`)?.focus(),C(i,o,l);const d=this.activePopup?.querySelector(".notectl-grid-picker__label")??null;d&&(d.textContent=this.locale.gridPickerLabel(o,l))}"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o?.click())}handleCustomPopupKeydown(t){if(!this.activePopup)return;const e=Array.from(this.activePopup.querySelectorAll("button"));if(0===e.length)return;const o=this.getActiveElement(),n=e.indexOf(o);switch(t.key){case"ArrowDown":t.preventDefault(),e[l(e,n,1)]?.focus();break;case"ArrowUp":t.preventDefault(),e[l(e,n,-1)]?.focus();break;case"Enter":case" ":t.preventDefault(),o&&((r=o).dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),r.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),r.click())}var r}},I=class t{element;timer=null;target=null;isPopupActive;static TOOLTIP_ID="notectl-toolbar-tooltip";constructor(o){this.isPopupActive=o,this.element=document.createElement("div"),this.element.className="notectl-toolbar-tooltip",this.element.id=t.TOOLTIP_ID,this.element.setAttribute("role","tooltip"),e(this.element,"display","none")}show(n){if(this.hide(),this.isPopupActive()||n.disabled)return;const r=n.getAttribute("data-tooltip");r&&(this.target=n,this.timer=setTimeout(()=>{if(this.isPopupActive())return;this.element.textContent=r,e(this.element,"display","");const i=n.getRootNode();i instanceof ShadowRoot&&!this.element.parentNode?i.appendChild(this.element):i instanceof ShadowRoot||this.element.parentNode||document.body.appendChild(this.element),n.setAttribute("aria-describedby",t.TOOLTIP_ID);const l=n.getBoundingClientRect();e(this.element,"position","fixed");const s=d(this.element);o(this.element,{top:l.bottom+6-s.y+"px",left:l.left+l.width/2-s.x+"px",transform:"translateX(-50%)"})},500))}hide(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.target&&(this.target.removeAttribute("aria-describedby"),this.target=null),e(this.element,"display","none")}destroy(){this.hide(),this.element.remove()}};function P(t){if(Array.isArray(t))return{plugins:t,label:void 0};const e=t;return{plugins:e.plugins,label:e.label}}var D=new n("toolbar"),T=class{id="toolbar";name="Toolbar";priority=10;context=null;toolbarElement=null;buttons=[];hiddenItems=/* @__PURE__ */new Set;layoutConfig;overflowBehavior;focusedIndex=0;tooltip=null;popupController=null;popupManager=null;overflowController=null;visibleElements=[];locale;constructor(t){this.layoutConfig=t??null,this.overflowBehavior=t?.overflow??w.BurgerMenu}async init(t){this.locale=await i(t,void 0,f,g),t.registerStyleSheet('\n/* Toolbar */\n.notectl-plugin-container--top {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\tborder-bottom: 1px solid var(--notectl-border);\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n\tmin-height: 40px;\n\tflex-shrink: 0;\n}\n\n.notectl-toolbar {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n\tflex: 1;\n\tmin-width: 0;\n\tgap: 2px;\n\tpadding: 4px 8px;\n}\n\n.notectl-toolbar[hidden] {\n\tdisplay: none;\n}\n\n/* Group wrapper — real flex container so consumers can style it via ::part(toolbar-group)\n with padding/background/border directly. Group gap mirrors the toolbar gap so the\n visual rhythm between buttons stays uniform whether or not a group boundary lies between them. */\n.notectl-toolbar-group {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 2px;\n}\n\n.notectl-toolbar-group--overflow-hidden {\n\tdisplay: none;\n}\n\n.notectl-toolbar-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-toolbar-button-bg, transparent);\n\tcursor: pointer;\n\tcolor: var(--notectl-toolbar-button-fg, var(--notectl-fg));\n\tfont-size: 14px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn:hover {\n\t\tbackground: var(--notectl-toolbar-button-hover-bg, var(--notectl-hover-bg));\n\t\tborder-color: var(--notectl-border);\n\t}\n}\n\n.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-toolbar-button-active-bg, var(--notectl-active-bg));\n\tborder-color: var(--notectl-primary-muted);\n\tcolor: var(--notectl-toolbar-button-active-fg, var(--notectl-primary-fg));\n}\n\n.notectl-toolbar-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn:disabled:hover {\n\t\tbackground: transparent;\n\t\tborder-color: transparent;\n\t}\n}\n\n.notectl-toolbar-btn__icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n\tdisplay: block;\n\twidth: 18px;\n\theight: 18px;\n\tfill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n\tpadding: 4px 8px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 10001;\n\tline-height: 1.4;\n\tletter-spacing: 0.01em;\n\tfont-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n\tdisplay: inline-block;\n\twidth: 1px;\n\theight: 20px;\n\tbackground: var(--notectl-border);\n\tmargin: 0 4px;\n\tvertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\toverflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-grid-picker__cell--highlighted {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n}\n\n/* Dropdown */\n.notectl-dropdown {\n\tmin-width: 160px;\n\tpadding: 4px 0;\n}\n\n.notectl-dropdown__item {\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: start;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\tfont-family: inherit;\n\twhite-space: nowrap;\n}\n\n@media (hover: hover) {\n\t.notectl-dropdown__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-dropdown__item:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n\toutline: none;\n}\n\n.notectl-dropdown__item-icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-fg-muted);\n\tflex-shrink: 0;\n}\n\n.notectl-dropdown__item-label {\n\tflex: 1;\n}\n\n/* Overflow behavior: flow mode — toolbar wraps to additional rows */\n.notectl-toolbar[data-overflow="flow"] {\n\tflex-wrap: wrap;\n\toverflow: visible;\n}\n\n/* Overflow behavior: none — toolbar clips without any responsive behavior */\n.notectl-toolbar[data-overflow="none"] {\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n}\n\n/* Overflow: hidden items (burger-menu mode) */\n.notectl-toolbar-btn--overflow-hidden,\n.notectl-toolbar-separator--overflow-hidden {\n\tdisplay: none;\n}\n\n/* Overflow "more" button */\n.notectl-toolbar-overflow-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 16px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\tmargin-inline-start: auto;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-overflow-btn:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t\tborder-color: var(--notectl-border);\n\t}\n}\n\n.notectl-toolbar-overflow-btn--hidden {\n\tdisplay: none;\n}\n\n.notectl-toolbar-overflow-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n/* Dropdown item states shared by all dropdown menus (including overflow) */\n.notectl-dropdown__item:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n@media (hover: hover) {\n\t.notectl-dropdown__item:disabled:hover {\n\t\tbackground: none;\n\t}\n}\n\n.notectl-dropdown__item--active {\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-dropdown__item-icon svg {\n\tdisplay: block;\n\twidth: 16px;\n\theight: 16px;\n\tfill: currentColor;\n}\n\n.notectl-dropdown__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 0;\n}\n\n/* Combobox-style toolbar buttons (shared base for font, fontSize, heading, etc.) */\n.notectl-toolbar-btn[role="combobox"] {\n\twidth: auto;\n\tpadding: 0 8px;\n\tgap: 4px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n}\n\n@media (hover: hover) {\n\t.notectl-toolbar-btn[role="combobox"]:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t\tborder-color: var(--notectl-fg-muted);\n\t}\n}\n\n.notectl-toolbar-btn[role="combobox"].notectl-toolbar-btn--active {\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n\tborder-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-combobox__label {\n\tflex: 1;\n\tfont-size: 13px;\n\tfont-weight: 500;\n\tcolor: var(--notectl-fg);\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\ttext-align: start;\n\tline-height: 30px;\n}\n\n.notectl-toolbar-combobox__arrow {\n\tflex-shrink: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tline-height: 30px;\n}\n\n/* Link Popup */\n.notectl-link-popup {\n\tpadding: 8px;\n\tmin-width: 200px;\n}\n\n.notectl-link-popup__input {\n\twidth: 100%;\n\tpadding: 4px;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n}\n\n.notectl-link-popup__input:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-link-popup__button {\n\twidth: 100%;\n\tpadding: 6px 12px;\n\tcursor: pointer;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-surface-overlay);\n\tcolor: var(--notectl-fg);\n\tfont-size: 13px;\n}\n\n.notectl-link-popup__button--apply {\n\tmargin-top: 4px;\n}\n\n@media (hover: hover) {\n\t.notectl-link-popup__button:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-link-popup__button:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n'),this.context=t,this.popupManager=new h(t.getContainer()),t.registerService(u,this.popupManager),this.popupController=new L(()=>this.getActiveElement(),this.locale),this.popupController.setPopupManager(this.popupManager),this.tooltip=new I(()=>this.popupController?.isOpen()??!1),t.registerService(D,{refresh:()=>this.updateButtonStates(t.getState()),closePopup:()=>this.popupController?.close()}),this.createToolbarElement()}getOverflowBehavior(){return this.overflowBehavior}setOverflowBehavior(t){t!==this.overflowBehavior&&(this.overflowBehavior=t,this.applyOverflowBehavior(),this.renderItems())}onReady(){this.renderItems()}destroy(){this.overflowController?.destroy(),this.overflowController=null,this.popupController?.destroy(),this.popupController=null,this.popupManager?.destroy(),this.popupManager=null,this.tooltip?.destroy(),this.tooltip=null,this.toolbarElement&&(this.toolbarElement.remove(),this.toolbarElement=null),this.buttons=[],this.visibleElements=[],this.context=null}onStateChange(t,e,o){this.updateButtonStates(e)}onReadOnlyChange(t){this.toolbarElement&&(this.toolbarElement.hidden=t)}onConfigure(t){for(const[e,o]of Object.entries(t))!1===o?this.hiddenItems.add(e):this.hiddenItems.delete(e);this.renderItems()}createToolbarElement(){if(!this.context)return;this.toolbarElement&&this.toolbarElement.remove(),this.buttons=[];const t=this.context.getPluginContainer("top");this.toolbarElement=document.createElement("div"),this.toolbarElement.setAttribute("role","toolbar"),this.toolbarElement.setAttribute("aria-label",this.locale.formattingOptionsAria),this.toolbarElement.setAttribute("data-notectl-no-print",""),this.toolbarElement.setAttribute("part","toolbar"),this.toolbarElement.className="notectl-toolbar",this.toolbarElement.addEventListener("keydown",t=>this.handleToolbarKeydown(t)),this.applyOverflowBehavior(),t.appendChild(this.toolbarElement)}applyOverflowBehavior(){this.toolbarElement&&this.context&&(this.overflowController?.destroy(),this.overflowController=null,this.toolbarElement.setAttribute("data-overflow",this.overflowBehavior),this.overflowBehavior===w.BurgerMenu?this.overflowController=new k({toolbar:this.toolbarElement,ariaLabel:this.locale.moreToolsAria,context:this.context,popupManager:this.popupManager??void 0,onOverflowChange:(t,e)=>{this.visibleElements=e?[...t,e]:[...t],this.initRovingTabindex()},onItemActivated:(t,e)=>{this.activateButton(t,e)},getActiveElement:()=>this.getActiveElement()}):this.visibleElements=[])}renderItems(){if(this.context&&this.toolbarElement){for(const t of this.buttons)t.element.remove();this.buttons=[];for(const t of this.toolbarElement.querySelectorAll(".notectl-toolbar-separator"))t.remove();for(const t of this.toolbarElement.querySelectorAll(".notectl-toolbar-group"))t.remove();this.layoutConfig?this.renderItemsByLayout():this.renderItemsByGroup(),this.buttons.length>0&&!this.toolbarElement.parentElement&&this.context.getPluginContainer("top").appendChild(this.toolbarElement),this.overflowController?.update(this.buttons),this.initRovingTabindex(),this.updateButtonStates(this.context.getState())}}createGroupWrapper(t){const e=document.createElement("div");return e.className="notectl-toolbar-group",e.setAttribute("part","toolbar-group"),void 0!==t&&(e.setAttribute("role","group"),e.setAttribute("aria-label",t)),e}getTabElements(){return this.visibleElements.length>0?this.visibleElements:this.buttons.map(t=>t.element)}initRovingTabindex(){const t=this.getTabElements(),e=m(t);this.focusedIndex=e>=0?e:0,a(t,this.focusedIndex)}setRovingFocus(t){const e=this.getTabElements();t<0||t>=e.length||(this.focusedIndex=t,a(e,t),e[t]?.focus())}getActiveElement(){const t=this.toolbarElement?.getRootNode();return t instanceof ShadowRoot?t.activeElement:document.activeElement}syncFocusedIndex(){const t=this.getActiveElement(),e=this.getTabElements().findIndex(e=>e===t);e>=0&&(this.focusedIndex=e)}handleToolbarKeydown(e){const o=this.getTabElements();var n;if(0!==o.length)switch(this.syncFocusedIndex(),e.key){case"ArrowRight":case"ArrowLeft":{e.preventDefault();const r=(n=!!this.toolbarElement&&t(this.toolbarElement),"ArrowRight"===e.key?n?-1:1:n?1:-1),i=function(t,e,o){const n=t.length;if(0===n)return-1;let r=e;for(let i=0;i<n;i++)if(r=(r+o+n)%n,!t[r]?.disabled)return r;return e}(o,this.focusedIndex,r);this.setRovingFocus(i);break}case"Home":{e.preventDefault();const t=m(o);t>=0&&this.setRovingFocus(t);break}case"End":{e.preventDefault();const t=function(t){for(let e=t.length-1;e>=0;e--)if(!t[e]?.disabled)return e;return-1}(o);t>=0&&this.setRovingFocus(t);break}case"Enter":case" ":{e.preventDefault();const t=o[this.focusedIndex],n=this.buttons.find(e=>e.element===t);n&&this.activateButton(n.element,n.item);break}}}activateButton(t,e){this.tooltip?.hide(),e.popupType&&this.context?this.popupController?.toggle(t,e,this.context):this.context?.executeCommand(e.command)}renderItemsByLayout(){if(!this.context||!this.toolbarElement||!this.layoutConfig)return;const t=this.context.getToolbarRegistry();let e=!0;for(const o of this.layoutConfig.groups){const{plugins:n,label:r}=P(o),i=[];for(const e of n){const o=t.getToolbarItemsByPlugin(e).filter(t=>!this.hiddenItems.has(t.id));i.push(...o)}if(0===i.length)continue;e||this.toolbarElement.appendChild(B()),e=!1;const l=this.createGroupWrapper(r);for(const t of i){const e=this.createButton(t);l.appendChild(e.element),this.buttons.push(e)}this.toolbarElement.appendChild(l)}0===this.buttons.length&&this.toolbarElement.remove()}renderItemsByGroup(){if(!this.context||!this.toolbarElement)return;const t=this.context.getToolbarRegistry().getToolbarItems().filter(t=>!this.hiddenItems.has(t.id));if(0===t.length)return void this.toolbarElement.remove();const e=/* @__PURE__ */new Map;for(const n of t){const t=e.get(n.group)??[];t.push(n),e.set(n.group,t)}let o=!0;for(const[,n]of e){o||this.toolbarElement.appendChild(B()),o=!1;const t=this.createGroupWrapper(void 0);for(const e of n){const o=this.createButton(e);t.appendChild(o.element),this.buttons.push(o)}this.toolbarElement.appendChild(t)}}createButton(t){const e=document.createElement("button");e.type="button",e.className=`notectl-toolbar-btn notectl-toolbar-btn--${t.id}`,e.setAttribute("aria-pressed","false"),e.setAttribute("aria-label",t.label),e.setAttribute("data-toolbar-item",t.id),e.setAttribute("data-tooltip",t.tooltip??t.label),e.setAttribute("part","toolbar-button");let o=null;if("combobox"===t.popupType){e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-expanded","false");const n=document.createElement("span");n.className="notectl-toolbar-combobox__label";const r=this.context?.getState();r&&(n.textContent=t.getLabel(r)),e.appendChild(n),o=n;const i=document.createElement("span");i.className="notectl-toolbar-combobox__arrow",i.setAttribute("aria-hidden","true"),i.textContent="▾",e.appendChild(i)}else{t.popupType&&(e.setAttribute("aria-haspopup","true"),e.setAttribute("aria-expanded","false"));const o=document.createElement("span");o.className="notectl-toolbar-btn__icon",o.innerHTML=t.icon,e.appendChild(o)}return e.addEventListener("mousedown",o=>{o.preventDefault(),this.activateButton(e,t)}),e.addEventListener("mouseenter",()=>this.tooltip?.show(e)),e.addEventListener("mouseleave",()=>this.tooltip?.hide()),e.addEventListener("focus",()=>this.tooltip?.show(e)),e.addEventListener("blur",()=>this.tooltip?.hide()),{element:e,item:t,comboLabelEl:o}}updateButtonStates(t){for(const e of this.buttons){const o=e.item.isActive?.(t)??!1,n=e.item.isEnabled?.(t)??!0;if(e.element.setAttribute("aria-pressed",String(o)),e.element.classList.toggle("notectl-toolbar-btn--active",o),e.element.setAttribute("part",o?"toolbar-button toolbar-button-active":"toolbar-button"),e.element.disabled=!n,n?e.element.removeAttribute("aria-disabled"):e.element.setAttribute("aria-disabled","true"),e.comboLabelEl&&"combobox"===e.item.popupType&&(e.comboLabelEl.textContent=e.item.getLabel(t)),e.item.getIcon){const o=e.item.getIcon(t),n=e.element.querySelector(".notectl-toolbar-btn__icon");n&&n.innerHTML!==o&&(n.innerHTML=o)}}this.overflowController?.updateItemStates(t)}};export{g as a,f as i,D as n,b as o,w as r,T as t};
2
- //# sourceMappingURL=ToolbarPlugin-DtfGTO_V.mjs.map
@@ -1,2 +0,0 @@
1
- import{n as t}from"./TypedKeys-CA4bfw9O.mjs";import{n,t as e}from"./XmlPatterns-RN32-0ob.mjs";var s=new t("languageRegistry");function*o(t,n){let e=0;for(;e<t.length;){let s=!1;for(const o of n.patterns){o.pattern.lastIndex=e;const n=o.pattern.exec(t);if(n&&n.index===e&&n[0].length>0){const t=n[0].length;yield{type:o.type,from:e,to:e+t},e+=t,s=!0;break}}s||e++}}var r={keyword:1,function:.9,type:1,annotation:1.5,property:1.2,tag:1.5,attribute:1.5,constant:.8,string:.4,number:.4,boolean:.6,null:.6,regex:.8,comment:.3,operator:.1,punctuation:.1},i=1.5;function a(t,n,e=r){const s=t.length;if(0===s)return{totalBytes:0,nonWhitespaceBytes:0,recognizedBytes:0,unknownBytes:0,tokenCount:0,weightedScore:0};const i=e.punctuation??0;let a=0,c=0,u=0;for(const r of o(t,n)){const t=r.to-r.from;a+=t,u++,c+=t*(e[r.type]??i)}return{totalBytes:s,nonWhitespaceBytes:l(t),recognizedBytes:a,unknownBytes:s-a,tokenCount:u,weightedScore:c}}function l(t){let n=0;for(let e=0;e<t.length;e++){const s=t.charCodeAt(e);32!==s&&9!==s&&10!==s&&13!==s&&n++}return n}function c(t){if(0===t.nonWhitespaceBytes)return 0;return n=.7*(t.recognizedBytes/t.nonWhitespaceBytes)+.3*(t.weightedScore/t.nonWhitespaceBytes/1.5),Math.max(0,Math.min(1,n));var n}var u=class{language;options;id;constructor(t,n={}){this.language=t,this.options=n,this.id=t.name}detect(t){const n=this.options.maxLength??1e5;if(t.length>n)return null;const e=t.trim(),s=this.options.minLines??2;if(e.split("\n").filter(t=>t.trim().length>0).length<s)return null;const o=c(a(e,this.language,this.options.weights)),r=this.matchesAnySignature(e)?this.options.signatureBonus??.3:0,i=Math.min(1,o+r);return i<(this.options.minConfidence??.35)?null:{language:this.language.name,formattedText:e,confidence:i}}matchesAnySignature(t){const n=this.options.signatures??[];for(const e of n)if(e.test(t))return!0;return!1}},h=class{id="json";detect(t){const n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;try{const t=JSON.parse(n);if("object"!=typeof t||null===t)return null;const e=JSON.stringify(t,null,2);return e.length<=5?null:{language:"json",formattedText:e,confidence:.9}}catch{return null}}},g=/^(<\?[\s\S]*?\?>\s*)+/,p=new RegExp(`^<${n}${e}\\/?>`),f=new RegExp(["<\\?[^?]*\\?>","\x3c!--[\\s\\S]*?--\x3e","<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",`<\\/(${n})>`,`<(${n})${e}\\/>`,`<(${n})${e}>`].join("|"),"g"),m=new RegExp(`<\\/${n}>\\s*$`),d=class{id="xml";detect(t){const n=t.trim();if(!n.startsWith("<"))return null;const e=n.replace(g,"");if(!p.test(e))return null;if(!this.isWellFormed(n))return null;const s=this.formatXml(n);return s.length<=10?null:{language:"xml",formattedText:s,confidence:.85}}isWellFormed(t){const n=[];let e=!1;f.lastIndex=0;let s=f.exec(t);for(;s;){const o=s[1],r=s[2],i=s[3];if(o){if(0===n.length||n[n.length-1]!==o)return!1;n.pop(),e=!0}else r?e=!0:i&&(n.push(i),e=!0);s=f.exec(t)}return e&&0===n.length}formatXml(t){const n=this.splitIntoTokens(t),e=[];let s=0;for(const o of n){const t=y[x(o)];"decrease"===t&&(s=Math.max(0,s-1)),e.push(" ".repeat(2*s)+o),"increase"===t&&s++}return e.join("\n")}splitIntoTokens(t){return t.replace(/>\s*</g,">\n<").split("\n").map(t=>t.trim()).filter(t=>t.length>0)}},y={pi:"none",comment:"none",cdata:"none",closing:"decrease",selfClosing:"none",inline:"none",opening:"increase",text:"none"};function x(t){return t.startsWith("<?")?"pi":t.startsWith("\x3c!--")?"comment":t.startsWith("<![CDATA[")?"cdata":t.startsWith("</")?"closing":t.endsWith("/>")?"selfClosing":t.startsWith("<")&&m.test(t)?"inline":t.startsWith("<")?"opening":"text"}export{r as a,o as c,c as i,s as l,h as n,i as o,u as r,a as s,d as t};
2
- //# sourceMappingURL=XmlDetector-D7TQpw-e.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"XmlDetector-D7TQpw-e.mjs","names":[],"sources":["../../src/plugins/language/LanguageTypes.ts","../../src/plugins/code-block/highlighter/TokenIteration.ts","../../src/plugins/smart-paste/detectors/TokenStats.ts","../../src/plugins/smart-paste/detectors/DetectionScorer.ts","../../src/plugins/smart-paste/detectors/LexerDetector.ts","../../src/plugins/smart-paste/detectors/JsonDetector.ts","../../src/plugins/smart-paste/detectors/XmlDetector.ts"],"sourcesContent":["/**\n * Unified language support types for programming language registration.\n *\n * Bundles syntax highlighting and paste detection into a single\n * registration unit so that all artifacts for one language live together.\n */\n\nimport { ServiceKey } from '../Plugin.js';\nimport type { LanguageDefinition } from '../code-block/highlighter/TokenizerTypes.js';\nimport type { ContentDetector } from '../smart-paste/SmartPasteTypes.js';\n\n/**\n * Unified language support bundle grouping all artifacts for one\n * programming language: syntax highlighting, paste detection, and\n * (optionally) code formatting.\n *\n * Pass to `LanguageRegistryService.register()` to make a language\n * available across all participating plugins in a single call.\n */\nexport interface LanguageSupport {\n\t/** Canonical lowercase identifier (e.g. `'java'`, `'python'`). */\n\treadonly id: string;\n\n\t/** Human-readable name shown in the language picker (e.g. `'Java'`). */\n\treadonly displayName: string;\n\n\t/** Alternative names accepted as aliases (e.g. `['py', 'py3']`). */\n\treadonly aliases?: readonly string[];\n\n\t/** Syntax highlighting token patterns for the RegexTokenizer. */\n\treadonly highlighting?: LanguageDefinition;\n\n\t/** Smart-paste detector for auto-detecting this language in pasted text. */\n\treadonly detection?: ContentDetector;\n\n\t/**\n\t * Code formatter for reformatting code block content on demand.\n\t * @experimental Not yet consumed by any built-in plugin.\n\t */\n\treadonly formatter?: CodeFormatter;\n}\n\n/**\n * Formatter that can reformat source code.\n * @experimental Reserved for future use.\n */\nexport interface CodeFormatter {\n\tformat(code: string): string | Promise<string>;\n}\n\n/** Service for registering and querying language support bundles. */\nexport interface LanguageRegistryService {\n\t/** Registers a language bundle. Re-registering the same `id` overwrites. */\n\tregister(support: LanguageSupport): void;\n\n\t/**\n\t * Subscribes to language registrations with replay semantics.\n\t * The listener is immediately called for all already-registered\n\t * bundles, then called for each future registration.\n\t */\n\tonRegister(listener: LanguageRegistryListener): void;\n\n\t/** Returns the bundle for the given language id, or `undefined`. */\n\tget(id: string): LanguageSupport | undefined;\n\n\t/** Returns all registered language support bundles. */\n\tgetAll(): readonly LanguageSupport[];\n}\n\n/** Internal listener type for registry change notifications. */\nexport type LanguageRegistryListener = (support: LanguageSupport) => void;\n\nexport const LANGUAGE_REGISTRY_SERVICE_KEY = new ServiceKey<LanguageRegistryService>(\n\t'languageRegistry',\n);\n","/**\n * Shared low-level iteration over tokenized regions of source code.\n *\n * Used by both the `RegexTokenizer` (for syntax highlighting) and the\n * smart-paste `LexerDetector` (for language detection) so both consumers\n * see exactly the same tokenization for a given language definition.\n */\n\nimport type { LanguageDefinition } from './TokenizerTypes.js';\n\n/** A successfully matched token region produced by `iterateTokens`. */\nexport interface IteratedToken {\n\treadonly type: string;\n\treadonly from: number;\n\treadonly to: number;\n}\n\n/**\n * Iterates tokens of `code` according to the language's sticky-regex patterns.\n *\n * Walks left-to-right; at each position emits the first matching pattern's\n * token and advances past it. Positions where no pattern matches are silently\n * skipped one byte at a time and never appear in the output — a consumer\n * that needs unknown-byte counts can derive them from `code.length` minus the\n * sum of yielded token widths.\n */\nexport function* iterateTokens(\n\tcode: string,\n\tlanguage: LanguageDefinition,\n): Generator<IteratedToken> {\n\tlet pos = 0;\n\twhile (pos < code.length) {\n\t\tlet matched = false;\n\t\tfor (const pattern of language.patterns) {\n\t\t\tpattern.pattern.lastIndex = pos;\n\t\t\tconst match: RegExpExecArray | null = pattern.pattern.exec(code);\n\t\t\tif (match && match.index === pos && match[0].length > 0) {\n\t\t\t\tconst len: number = match[0].length;\n\t\t\t\tyield { type: pattern.type, from: pos, to: pos + len };\n\t\t\t\tpos += len;\n\t\t\t\tmatched = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!matched) {\n\t\t\tpos++;\n\t\t}\n\t}\n}\n","/**\n * Tokenization statistics used by the lexer-based content detector to\n * derive a calibrated, discriminative confidence score per language.\n *\n * The same `LanguageDefinition` that powers syntax highlighting is run\n * over the candidate text, and the token stream is reduced to four\n * aggregate measures: how much of the input was recognized, how many\n * tokens were emitted, and the relevance-weighted byte score that\n * favours language-specific tokens (keywords, decorators, tags) over\n * universal ones (punctuation, operators).\n */\n\nimport { iterateTokens } from '../../code-block/highlighter/TokenIteration.js';\nimport type { LanguageDefinition } from '../../code-block/highlighter/TokenizerTypes.js';\n\n/**\n * Per-token-type relevance weights.\n *\n * Higher weights indicate a matched token of that type contributes more\n * evidence that the input is in the corresponding language. Tokens that\n * appear in many languages (punctuation, operators) are weighted low;\n * tokens whose patterns encode language-specific identifiers (keywords,\n * annotations, tags) are weighted high.\n */\nexport type RelevanceWeights = Readonly<Record<string, number>>;\n\n/**\n * Default relevance weights spanning the canonical syntax token types.\n * Values were chosen so that keyword-rich code (typical for general\n * programming languages) and tag/attribute-rich code (markup) reach\n * scores comparable to one another while pure punctuation falls off.\n */\nexport const DEFAULT_RELEVANCE_WEIGHTS: RelevanceWeights = {\n\tkeyword: 1.0,\n\tfunction: 0.9,\n\ttype: 1.0,\n\tannotation: 1.5,\n\tproperty: 1.2,\n\ttag: 1.5,\n\tattribute: 1.5,\n\tconstant: 0.8,\n\tstring: 0.4,\n\tnumber: 0.4,\n\tboolean: 0.6,\n\tnull: 0.6,\n\tregex: 0.8,\n\tcomment: 0.3,\n\toperator: 0.1,\n\tpunctuation: 0.1,\n};\n\n/**\n * Maximum value present in `DEFAULT_RELEVANCE_WEIGHTS`.\n * Used as the normalization upper bound when computing density —\n * a stream consisting entirely of maximally-weighted tokens has\n * density 1.0.\n */\nexport const MAX_RELEVANCE_WEIGHT = 1.5;\n\n/** Aggregate statistics describing one tokenization pass. */\nexport interface TokenStats {\n\treadonly totalBytes: number;\n\treadonly nonWhitespaceBytes: number;\n\treadonly recognizedBytes: number;\n\treadonly unknownBytes: number;\n\treadonly tokenCount: number;\n\treadonly weightedScore: number;\n}\n\n/**\n * Tokenizes `code` with `language` and returns aggregate statistics\n * suitable for confidence scoring across competing language candidates.\n *\n * Whitespace is counted separately from `unknownBytes` so the scorer can\n * normalize against the meaningful (non-whitespace) input length without\n * unfairly penalizing indentation or vertical spacing.\n */\nexport function computeTokenStats(\n\tcode: string,\n\tlanguage: LanguageDefinition,\n\tweights: RelevanceWeights = DEFAULT_RELEVANCE_WEIGHTS,\n): TokenStats {\n\tconst totalBytes: number = code.length;\n\tif (totalBytes === 0) {\n\t\treturn {\n\t\t\ttotalBytes: 0,\n\t\t\tnonWhitespaceBytes: 0,\n\t\t\trecognizedBytes: 0,\n\t\t\tunknownBytes: 0,\n\t\t\ttokenCount: 0,\n\t\t\tweightedScore: 0,\n\t\t};\n\t}\n\n\tconst fallbackWeight: number = weights.punctuation ?? 0;\n\n\tlet recognizedBytes = 0;\n\tlet weightedScore = 0;\n\tlet tokenCount = 0;\n\n\tfor (const token of iterateTokens(code, language)) {\n\t\tconst len: number = token.to - token.from;\n\t\trecognizedBytes += len;\n\t\ttokenCount++;\n\t\tconst weight: number = weights[token.type] ?? fallbackWeight;\n\t\tweightedScore += len * weight;\n\t}\n\n\tconst nonWhitespaceBytes: number = countNonWhitespaceBytes(code);\n\n\treturn {\n\t\ttotalBytes,\n\t\tnonWhitespaceBytes,\n\t\trecognizedBytes,\n\t\tunknownBytes: totalBytes - recognizedBytes,\n\t\ttokenCount,\n\t\tweightedScore,\n\t};\n}\n\nfunction countNonWhitespaceBytes(text: string): number {\n\tlet count = 0;\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst c: number = text.charCodeAt(i);\n\t\tif (c !== 32 && c !== 9 && c !== 10 && c !== 13) count++;\n\t}\n\treturn count;\n}\n","/**\n * Pure scoring function that maps tokenization statistics to a\n * discriminative confidence value in `[0, 1]`.\n *\n * The score combines two independent signals:\n * - **Coverage** — fraction of input bytes recognized by the language's\n * patterns. Low coverage means many bytes fell through with no rule\n * matching, which is strong evidence the text is not in this language.\n * - **Density** — average per-byte weight of recognized tokens, normalized\n * against the maximum possible weight. High density means the recognized\n * tokens are themselves discriminative (keywords, annotations) rather\n * than universally-shared syntax (punctuation, operators).\n *\n * Coverage and density are equally weighted: a language that recognizes\n * lots of low-information punctuation is no more credible than one that\n * recognizes a few highly-specific keywords surrounded by unknown bytes,\n * and only the union of both signals sums to high confidence.\n */\n\nimport { MAX_RELEVANCE_WEIGHT, type TokenStats } from './TokenStats.js';\n\n/**\n * Weight of the byte-coverage signal in the combined confidence.\n *\n * Coverage dominates because failure to recognize most non-whitespace\n * bytes is the strongest evidence that the input is not in this language.\n * Relevance is a secondary refinement: among languages with comparable\n * coverage, the one whose recognized tokens are more discriminative\n * (keywords / annotations / tags rather than punctuation) wins.\n */\nconst COVERAGE_WEIGHT = 0.7;\n/** Weight of the relevance-density signal in the combined confidence. */\nconst RELEVANCE_WEIGHT = 0.3;\n\n/**\n * Maps tokenization statistics to a confidence value in `[0, 1]`.\n *\n * Both axes normalize against `nonWhitespaceBytes` so the score scales\n * linearly with the size of the meaningful input and is unaffected by\n * indentation:\n *\n * - **Coverage** = recognized bytes / non-whitespace bytes. Measures how\n * *much* of the meaningful input the lexer matched.\n * - **Relevance** = weighted score / non-whitespace bytes / max weight.\n * Measures how *rich* the matched tokens are on average — a sparse run\n * of keywords amid mostly-unknown text scores low here even though the\n * recognized bytes alone would look high-weight.\n */\nexport function scoreFromStats(stats: TokenStats): number {\n\tif (stats.nonWhitespaceBytes === 0) return 0;\n\n\tconst coverage: number = stats.recognizedBytes / stats.nonWhitespaceBytes;\n\tconst relevance: number = stats.weightedScore / stats.nonWhitespaceBytes / MAX_RELEVANCE_WEIGHT;\n\n\treturn clamp01(COVERAGE_WEIGHT * coverage + RELEVANCE_WEIGHT * relevance);\n}\n\nfunction clamp01(value: number): number {\n\treturn Math.max(0, Math.min(1, value));\n}\n","/**\n * Generic, lexer-driven content detector.\n *\n * Re-uses the `LanguageDefinition` from the syntax highlighter as the\n * authoritative grammar for detection — anything the highlighter learns\n * to tokenize, the detector learns to recognize, with no parallel\n * heuristic to maintain.\n *\n * Detection strategy:\n * 1. **Lexer probe** — tokenize the candidate text with the language's\n * patterns. Coverage and weighted density jointly form a calibrated\n * confidence in `[0, 1]` (see `DetectionScorer`).\n * 2. **Smoking-gun signatures** — when present, language-specific regexes\n * that confirm a plausible interpretation. A signature match adds a\n * fixed bonus to the lexer-derived confidence (capped at 1.0); without\n * signatures the lexer score stands on its own.\n *\n * Signatures must be definitionally specific to the target language —\n * patterns that are syntactically impossible in any competing language\n * the detector will be matched against. They are intentionally additive,\n * not gating: a signature on a near-zero lexer score still produces a\n * low overall confidence and is rejected by the minimum threshold.\n */\n\nimport type { LanguageDefinition } from '../../code-block/highlighter/TokenizerTypes.js';\nimport type { ContentDetector, DetectionResult } from '../SmartPasteTypes.js';\nimport { scoreFromStats } from './DetectionScorer.js';\nimport { type RelevanceWeights, type TokenStats, computeTokenStats } from './TokenStats.js';\n\n/** Configuration options for the lexer-based content detector. */\nexport interface LexerDetectorOptions {\n\t/** Minimum number of non-empty lines required before detection runs. */\n\treadonly minLines?: number;\n\n\t/** Maximum input length analyzed (DoS guard). */\n\treadonly maxLength?: number;\n\n\t/** Minimum confidence value required to accept the detection. */\n\treadonly minConfidence?: number;\n\n\t/**\n\t * Language-specific \"smoking-gun\" patterns. If any pattern matches,\n\t * `signatureBonus` is added to the lexer-derived confidence (capped\n\t * at 1.0). Patterns must be effectively impossible in any competing\n\t * language the detector will be matched against.\n\t */\n\treadonly signatures?: readonly RegExp[];\n\n\t/** Confidence bonus added on signature match. Defaults to `0.3`. */\n\treadonly signatureBonus?: number;\n\n\t/** Custom per-token-type relevance weights. Defaults to the canonical set. */\n\treadonly weights?: RelevanceWeights;\n}\n\nconst DEFAULT_MIN_LINES = 2;\nconst DEFAULT_MAX_LENGTH = 100_000;\nconst DEFAULT_MIN_CONFIDENCE = 0.35;\nconst DEFAULT_SIGNATURE_BONUS = 0.3;\n\n/**\n * Content detector that classifies pasted text using the same\n * `LanguageDefinition` employed for syntax highlighting.\n */\nexport class LexerDetector implements ContentDetector {\n\treadonly id: string;\n\n\tconstructor(\n\t\tprivate readonly language: LanguageDefinition,\n\t\tprivate readonly options: LexerDetectorOptions = {},\n\t) {\n\t\tthis.id = language.name;\n\t}\n\n\tdetect(text: string): DetectionResult | null {\n\t\tconst maxLength: number = this.options.maxLength ?? DEFAULT_MAX_LENGTH;\n\t\tif (text.length > maxLength) return null;\n\n\t\tconst trimmed: string = text.trim();\n\t\tconst minLines: number = this.options.minLines ?? DEFAULT_MIN_LINES;\n\t\tconst lines: string[] = trimmed.split('\\n').filter((l: string) => l.trim().length > 0);\n\t\tif (lines.length < minLines) return null;\n\n\t\tconst stats: TokenStats = computeTokenStats(trimmed, this.language, this.options.weights);\n\t\tconst lexerConfidence: number = scoreFromStats(stats);\n\n\t\tconst bonus: number = this.matchesAnySignature(trimmed)\n\t\t\t? (this.options.signatureBonus ?? DEFAULT_SIGNATURE_BONUS)\n\t\t\t: 0;\n\t\tconst confidence: number = Math.min(1, lexerConfidence + bonus);\n\n\t\tconst minConfidence: number = this.options.minConfidence ?? DEFAULT_MIN_CONFIDENCE;\n\t\tif (confidence < minConfidence) return null;\n\n\t\treturn { language: this.language.name, formattedText: trimmed, confidence };\n\t}\n\n\tprivate matchesAnySignature(text: string): boolean {\n\t\tconst signatures: readonly RegExp[] = this.options.signatures ?? [];\n\t\tfor (const signature of signatures) {\n\t\t\tif (signature.test(text)) return true;\n\t\t}\n\t\treturn false;\n\t}\n}\n","/**\n * JSON content detector — validates and formats JSON for code block insertion.\n */\n\nimport type { ContentDetector, DetectionResult } from '../SmartPasteTypes.js';\n\n/** Minimum length for formatted JSON to be considered meaningful. */\nconst MIN_FORMATTED_LENGTH = 5;\n\n/** Confidence score for valid JSON detected via JSON.parse. */\nconst JSON_CONFIDENCE = 0.9;\n\nexport class JsonDetector implements ContentDetector {\n\treadonly id = 'json';\n\n\tdetect(text: string): DetectionResult | null {\n\t\tconst trimmed: string = text.trim();\n\t\tif (!trimmed.startsWith('{') && !trimmed.startsWith('[')) return null;\n\n\t\ttry {\n\t\t\tconst parsed: unknown = JSON.parse(trimmed);\n\t\t\tif (typeof parsed !== 'object' || parsed === null) return null;\n\n\t\t\tconst formatted: string = JSON.stringify(parsed, null, 2);\n\t\t\tif (formatted.length <= MIN_FORMATTED_LENGTH) return null;\n\n\t\t\treturn { language: 'json', formattedText: formatted, confidence: JSON_CONFIDENCE };\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n","/**\n * XML content detector — validates and formats XML for code block insertion.\n */\n\nimport { XML_ATTRS, XML_TAG_NAME } from '../../shared/XmlPatterns.js';\nimport type { ContentDetector, DetectionResult } from '../SmartPasteTypes.js';\n\n/** Minimum length for formatted XML to be considered meaningful. */\nconst MIN_FORMATTED_LENGTH = 10;\n\n/** Confidence score for valid XML detected via structural analysis. */\nconst XML_CONFIDENCE = 0.85;\n\n/** Matches any leading processing instructions like <?xml ...?> or <?xml-stylesheet ...?> */\nconst LEADING_PIS_PATTERN = /^(<\\?[\\s\\S]*?\\?>\\s*)+/;\n\n/** Matches an opening tag like <root> or <ns:tag attr=\"val\"> */\nconst OPENING_TAG_PATTERN = new RegExp(`^<${XML_TAG_NAME}${XML_ATTRS}\\\\/?>`);\n\n// --- Well-formedness regex (decomposed for readability) ---\n\nconst PI_FRAGMENT = '<\\\\?[^?]*\\\\?>';\nconst COMMENT_FRAGMENT = '<!--[\\\\s\\\\S]*?-->';\nconst CDATA_FRAGMENT = '<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?\\\\]\\\\]>';\nconst CLOSING_TAG_FRAGMENT = `<\\\\/(${XML_TAG_NAME})>`;\nconst SELF_CLOSING_TAG_FRAGMENT = `<(${XML_TAG_NAME})${XML_ATTRS}\\\\/>`;\nconst OPENING_TAG_FRAGMENT = `<(${XML_TAG_NAME})${XML_ATTRS}>`;\n\nconst WELL_FORMED_TAG_PATTERN = new RegExp(\n\t[\n\t\tPI_FRAGMENT,\n\t\tCOMMENT_FRAGMENT,\n\t\tCDATA_FRAGMENT,\n\t\tCLOSING_TAG_FRAGMENT,\n\t\tSELF_CLOSING_TAG_FRAGMENT,\n\t\tOPENING_TAG_FRAGMENT,\n\t].join('|'),\n\t'g',\n);\n\n/** Matches an inline element where open + close tag appear on the same token. */\nconst INLINE_ELEMENT_PATTERN = new RegExp(`<\\\\/${XML_TAG_NAME}>\\\\s*$`);\n\n/**\n * Detects well-formed XML content and formats it with proper indentation.\n *\n * Detection strategy:\n * 1. Text must start with `<` (after trimming)\n * 2. Must begin with an XML declaration, processing instruction, or opening tag\n * 3. All opened tags must be properly closed (basic well-formedness check)\n * 4. Must contain at least one tag pair or self-closing tag\n */\nexport class XmlDetector implements ContentDetector {\n\treadonly id = 'xml';\n\n\tdetect(text: string): DetectionResult | null {\n\t\tconst trimmed: string = text.trim();\n\t\tif (!trimmed.startsWith('<')) return null;\n\n\t\t// Quick structural check: strip leading PIs, then must start with an opening tag\n\t\tconst remainder: string = trimmed.replace(LEADING_PIS_PATTERN, '');\n\t\tif (!OPENING_TAG_PATTERN.test(remainder)) return null;\n\n\t\t// Validate well-formedness via tag balancing\n\t\tif (!this.isWellFormed(trimmed)) return null;\n\n\t\tconst formatted: string = this.formatXml(trimmed);\n\t\tif (formatted.length <= MIN_FORMATTED_LENGTH) return null;\n\n\t\treturn { language: 'xml', formattedText: formatted, confidence: XML_CONFIDENCE };\n\t}\n\n\t/**\n\t * Checks basic XML well-formedness by verifying that all opened tags\n\t * are properly closed in the correct nesting order.\n\t */\n\tprivate isWellFormed(xml: string): boolean {\n\t\tconst tagStack: string[] = [];\n\t\tlet foundTag = false;\n\n\t\t// Reset lastIndex — RegExp with 'g' flag is stateful\n\t\tWELL_FORMED_TAG_PATTERN.lastIndex = 0;\n\t\tlet match: RegExpExecArray | null = WELL_FORMED_TAG_PATTERN.exec(xml);\n\n\t\twhile (match) {\n\t\t\tconst closingTag: string | undefined = match[1];\n\t\t\tconst selfClosingTag: string | undefined = match[2];\n\t\t\tconst openingTag: string | undefined = match[3];\n\n\t\t\tif (closingTag) {\n\t\t\t\tif (tagStack.length === 0 || tagStack[tagStack.length - 1] !== closingTag) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\ttagStack.pop();\n\t\t\t\tfoundTag = true;\n\t\t\t} else if (selfClosingTag) {\n\t\t\t\tfoundTag = true;\n\t\t\t} else if (openingTag) {\n\t\t\t\ttagStack.push(openingTag);\n\t\t\t\tfoundTag = true;\n\t\t\t}\n\n\t\t\tmatch = WELL_FORMED_TAG_PATTERN.exec(xml);\n\t\t}\n\n\t\treturn foundTag && tagStack.length === 0;\n\t}\n\n\t/**\n\t * Formats XML with consistent 2-space indentation.\n\t */\n\tprivate formatXml(xml: string): string {\n\t\tconst tokens: string[] = this.splitIntoTokens(xml);\n\t\tconst parts: string[] = [];\n\t\tlet indent = 0;\n\t\tconst INDENT_STEP = 2;\n\n\t\tfor (const token of tokens) {\n\t\t\tconst kind: XmlTokenKind = classifyXmlToken(token);\n\t\t\tconst indentChange: IndentChange = INDENT_BEHAVIOR[kind];\n\n\t\t\tif (indentChange === 'decrease') {\n\t\t\t\tindent = Math.max(0, indent - 1);\n\t\t\t}\n\n\t\t\tparts.push(' '.repeat(indent * INDENT_STEP) + token);\n\n\t\t\tif (indentChange === 'increase') {\n\t\t\t\tindent++;\n\t\t\t}\n\t\t}\n\n\t\treturn parts.join('\\n');\n\t}\n\n\t/** Splits XML into line-level tokens by breaking between adjacent tags. */\n\tprivate splitIntoTokens(xml: string): string[] {\n\t\treturn xml\n\t\t\t.replace(/>\\s*</g, '>\\n<')\n\t\t\t.split('\\n')\n\t\t\t.map((line: string) => line.trim())\n\t\t\t.filter((line: string) => line.length > 0);\n\t}\n}\n\n// --- Token Classification ---\n\ntype XmlTokenKind =\n\t| 'pi'\n\t| 'comment'\n\t| 'cdata'\n\t| 'closing'\n\t| 'selfClosing'\n\t| 'inline'\n\t| 'opening'\n\t| 'text';\ntype IndentChange = 'increase' | 'decrease' | 'none';\n\nconst INDENT_BEHAVIOR: Readonly<Record<XmlTokenKind, IndentChange>> = {\n\tpi: 'none',\n\tcomment: 'none',\n\tcdata: 'none',\n\tclosing: 'decrease',\n\tselfClosing: 'none',\n\tinline: 'none',\n\topening: 'increase',\n\ttext: 'none',\n};\n\nfunction classifyXmlToken(token: string): XmlTokenKind {\n\tif (token.startsWith('<?')) return 'pi';\n\tif (token.startsWith('<!--')) return 'comment';\n\tif (token.startsWith('<![CDATA[')) return 'cdata';\n\tif (token.startsWith('</')) return 'closing';\n\tif (token.endsWith('/>')) return 'selfClosing';\n\tif (token.startsWith('<') && INLINE_ELEMENT_PATTERN.test(token)) return 'inline';\n\tif (token.startsWith('<')) return 'opening';\n\treturn 'text';\n}\n"],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- import{n as t,r as e,t as n}from"./XmlDetector-D7TQpw-e.mjs";import{n as a}from"./XmlPatterns-RN32-0ob.mjs";var s={name:"java",aliases:[],patterns:[{type:"comment",pattern:/\/\*[\s\S]*?\*\//y},{type:"comment",pattern:/\/\/[^\n]*/y},{type:"string",pattern:/"""[\s\S]*?"""/y},{type:"string",pattern:/"(?:[^"\\]|\\.)*"/y},{type:"string",pattern:/'(?:[^'\\]|\\.)*'/y},{type:"annotation",pattern:/@[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*/y},{type:"keyword",pattern:new RegExp(`(?:${["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","exports","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","module","native","new","non-sealed","open","opens","package","permits","private","protected","provides","public","record","requires","return","sealed","short","static","strictfp","super","switch","synchronized","this","throw","throws","to","transient","transitive","try","uses","var","void","volatile","when","while","with","yield"].join("|")})\\b`,"y")},{type:"boolean",pattern:/(?:true|false)\b/y},{type:"null",pattern:/null\b/y},{type:"number",pattern:/0[xX][\da-fA-F](?:_*[\da-fA-F])*[lL]?/y},{type:"number",pattern:/0[bB][01](?:_*[01])*[lL]?/y},{type:"number",pattern:/\d(?:_*\d)*(?:\.(?:\d(?:_*\d)*)?)?(?:[eE][+-]?\d(?:_*\d)*)?[fFdDlL]?/y},{type:"function",pattern:/[a-zA-Z_]\w*(?=\s*\()/y},{type:"operator",pattern:/(?:>>>=?|>>=?|<<=?|->|::|\+\+|--|&&|\|\||[+\-*/%&|^~!=<>]=?|\?|:)/y},{type:"punctuation",pattern:/[{}[\]();.,]/y}]},r={id:"java",displayName:"Java",highlighting:s,detection:new e(s,{signatures:[/^[ \t]*package\s+[\w.]+\s*;/m,/^[ \t]*import\s+(?:static\s+)?[\w.]+(?:\.\*)?\s*;/m,/\bSystem\s*\.\s*(?:out|err)\s*\.\s*\w+\s*\(/,/\bpublic\s+static\s+void\s+main\s*\(\s*String\s*\[\s*\]/]})},p={name:"json",aliases:["jsonc"],patterns:[{type:"property",pattern:/"(?:[^"\\]|\\.)*"(?=\s*:)/y},{type:"string",pattern:/"(?:[^"\\]|\\.)*"/y},{type:"number",pattern:/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y},{type:"boolean",pattern:/(?:true|false)\b/y},{type:"null",pattern:/null\b/y},{type:"punctuation",pattern:/[{}[\]:,]/y}]},i={id:"json",displayName:"JSON",aliases:["jsonc"],highlighting:p,detection:new t},o={name:"typescript",aliases:["ts","tsx"],patterns:[{type:"comment",pattern:/\/\*[\s\S]*?\*\//y},{type:"comment",pattern:/\/\/[^\n]*/y},{type:"string",pattern:/`(?:[^`\\$]|\\.|\$(?!\{)|\$\{[^}]*\})*`/y},{type:"string",pattern:/"(?:[^"\\]|\\.)*"/y},{type:"string",pattern:/'(?:[^'\\]|\\.)*'/y},{type:"annotation",pattern:/@[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/y},{type:"keyword",pattern:new RegExp(`(?:${["abstract","any","as","asserts","async","await","bigint","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","finally","for","from","function","get","global","if","implements","import","in","infer","instanceof","interface","is","keyof","let","module","namespace","never","new","number","object","of","out","override","package","private","protected","public","readonly","require","return","satisfies","set","static","string","super","switch","symbol","this","throw","try","type","typeof","unique","unknown","using","var","void","while","with","yield"].join("|")})\\b`,"y")},{type:"boolean",pattern:/(?:true|false)\b/y},{type:"null",pattern:/(?:null|undefined)\b/y},{type:"number",pattern:/0[xX][\da-fA-F](?:_*[\da-fA-F])*n?/y},{type:"number",pattern:/0[bB][01](?:_*[01])*n?/y},{type:"number",pattern:/0[oO][0-7](?:_*[0-7])*n?/y},{type:"number",pattern:/\d(?:_*\d)*(?:\.(?:\d(?:_*\d)*)?)?(?:[eE][+-]?\d(?:_*\d)*)?n?/y},{type:"function",pattern:/[a-zA-Z_$][\w$]*(?=\s*\()/y},{type:"operator",pattern:/(?:>>>=?|>>=?|<<=?|\*\*=?|\?\?=?|\|\|=?|&&=?|===?|!==?|=>|\?\.|\.\.\.|\+\+|--|[+\-*/%&|^~!=<>]=?|\?|:)/y},{type:"punctuation",pattern:/[{}[\]();.,]/y}]},y={id:"typescript",displayName:"TypeScript",aliases:["ts","tsx"],highlighting:o,detection:new e(o,{signatures:[/^[ \t]*import\b[^;\n]*?\bfrom\s+['"]/m,/^[ \t]*(?:export\s+)?type\s+\w+(?:\s*<[^=>]*>)?\s*=/m,/^[ \t]*declare\s+(?:const|let|var|function|class|namespace|module|global)\b/m,/[\w$\])]\??\s*:\s*(?:string|number|boolean|void|any|unknown|never|bigint|symbol|object|null|undefined)\b/,/^[ \t]*export\s+(?:default\s+|const\s+|let\s+|var\s+|function\s+|async\s+function\b|class\s+|interface\s+|enum\s+|namespace\s+|abstract\s+class\b|\*\s+from\b|\{)/m]})},l={name:"xml",aliases:["html","xhtml","svg","xsl"],patterns:[{type:"comment",pattern:/<!--[\s\S]*?-->/y},{type:"keyword",pattern:/<!\[CDATA\[[\s\S]*?\]\]>/y},{type:"keyword",pattern:/<\?[\s\S]*?\?>/y},{type:"tag",pattern:new RegExp(`<\\/${a}`,"y")},{type:"tag",pattern:new RegExp(`<${a}`,"y")},{type:"punctuation",pattern:/\/>|>|=/y},{type:"attribute",pattern:new RegExp(`${a}(?=\\s*=)`,"y")},{type:"string",pattern:/"[^"]*"/y},{type:"string",pattern:/'[^']*'/y}]},c={id:"xml",displayName:"XML",aliases:["html","xhtml","svg","xsl"],highlighting:l,detection:new n};export{i as a,s as c,o as i,l as n,p as o,y as r,r as s,c as t};
2
- //# sourceMappingURL=XmlSupport-BYiRwlkK.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"XmlSupport-BYiRwlkK.mjs","names":[],"sources":["../../src/plugins/code-block/highlighter/languages/java.ts","../../src/plugins/language/bundles/JavaSupport.ts","../../src/plugins/code-block/highlighter/languages/json.ts","../../src/plugins/language/bundles/JsonSupport.ts","../../src/plugins/code-block/highlighter/languages/typescript.ts","../../src/plugins/language/bundles/TypeScriptSupport.ts","../../src/plugins/code-block/highlighter/languages/xml.ts","../../src/plugins/language/bundles/XmlSupport.ts"],"sourcesContent":["/**\n * Java language definition for regex-based syntax highlighting.\n *\n * Covers Java 21 syntax including sealed classes, records, pattern matching,\n * modules, text blocks, and switch expressions.\n *\n * Token type mapping:\n * - `comment` - line `//`, block, and Javadoc comments\n * - `string` - double-quoted strings, text blocks, char literals\n * - `annotation` - annotations `@Name`, `@java.lang.Override`\n * - `keyword` - Java 21 keywords (including contextual: sealed, record, var, yield, when)\n * - `boolean` - `true`, `false`\n * - `null` - `null`\n * - `number` - decimal, hex, binary, float, scientific, with underscores\n * - `function` - method/function names (identifier followed by `(`)\n * - `operator` - all Java operators including `->`, `::`, `>>>=`\n * - `punctuation` - delimiters `{}[]();.,`\n */\n\nimport type { LanguageDefinition } from '../TokenizerTypes.js';\n\nconst JAVA_KEYWORDS: readonly string[] = [\n\t'abstract',\n\t'assert',\n\t'boolean',\n\t'break',\n\t'byte',\n\t'case',\n\t'catch',\n\t'char',\n\t'class',\n\t'const',\n\t'continue',\n\t'default',\n\t'do',\n\t'double',\n\t'else',\n\t'enum',\n\t'exports',\n\t'extends',\n\t'final',\n\t'finally',\n\t'float',\n\t'for',\n\t'goto',\n\t'if',\n\t'implements',\n\t'import',\n\t'instanceof',\n\t'int',\n\t'interface',\n\t'long',\n\t'module',\n\t'native',\n\t'new',\n\t'non-sealed',\n\t'open',\n\t'opens',\n\t'package',\n\t'permits',\n\t'private',\n\t'protected',\n\t'provides',\n\t'public',\n\t'record',\n\t'requires',\n\t'return',\n\t'sealed',\n\t'short',\n\t'static',\n\t'strictfp',\n\t'super',\n\t'switch',\n\t'synchronized',\n\t'this',\n\t'throw',\n\t'throws',\n\t'to',\n\t'transient',\n\t'transitive',\n\t'try',\n\t'uses',\n\t'var',\n\t'void',\n\t'volatile',\n\t'when',\n\t'while',\n\t'with',\n\t'yield',\n];\n\nconst KEYWORD_PATTERN: RegExp = new RegExp(`(?:${JAVA_KEYWORDS.join('|')})\\\\b`, 'y');\n\nexport const JAVA_LANGUAGE: LanguageDefinition = {\n\tname: 'java',\n\taliases: [],\n\tpatterns: [\n\t\t// 1. Block/Javadoc comments — before `/` operator\n\t\t{ type: 'comment', pattern: /\\/\\*[\\s\\S]*?\\*\\//y },\n\t\t// 2. Line comments — before `/` operator\n\t\t{ type: 'comment', pattern: /\\/\\/[^\\n]*/y },\n\t\t// 3. Text blocks `\"\"\"...\"\"\"` — before empty string `\"\"`\n\t\t{ type: 'string', pattern: /\"\"\"[\\s\\S]*?\"\"\"/y },\n\t\t// 4. Double-quoted strings — escape-aware\n\t\t{ type: 'string', pattern: /\"(?:[^\"\\\\]|\\\\.)*\"/y },\n\t\t// 5. Char literals — escape-aware\n\t\t{ type: 'string', pattern: /'(?:[^'\\\\]|\\\\.)*'/y },\n\t\t// 6. Annotations — before operators (captures `@`)\n\t\t{ type: 'annotation', pattern: /@[a-zA-Z_]\\w*(?:\\.[a-zA-Z_]\\w*)*/y },\n\t\t// 7. Keywords — before functions (`if(` = keyword, not function)\n\t\t{ type: 'keyword', pattern: KEYWORD_PATTERN },\n\t\t// 8. Booleans\n\t\t{ type: 'boolean', pattern: /(?:true|false)\\b/y },\n\t\t// 9. Null\n\t\t{ type: 'null', pattern: /null\\b/y },\n\t\t// 10. Hex numbers — before decimal (both can start with `0`)\n\t\t{ type: 'number', pattern: /0[xX][\\da-fA-F](?:_*[\\da-fA-F])*[lL]?/y },\n\t\t// 11. Binary numbers — before decimal\n\t\t{ type: 'number', pattern: /0[bB][01](?:_*[01])*[lL]?/y },\n\t\t// 12. Decimal/float/scientific numbers — with underscore and suffix support\n\t\t{\n\t\t\ttype: 'number',\n\t\t\tpattern: /\\d(?:_*\\d)*(?:\\.(?:\\d(?:_*\\d)*)?)?(?:[eE][+-]?\\d(?:_*\\d)*)?[fFdDlL]?/y,\n\t\t},\n\t\t// 13. Function/method names — identifier followed by `(`\n\t\t{ type: 'function', pattern: /[a-zA-Z_]\\w*(?=\\s*\\()/y },\n\t\t// 14. Operators\n\t\t{\n\t\t\ttype: 'operator',\n\t\t\tpattern: /(?:>>>=?|>>=?|<<=?|->|::|\\+\\+|--|&&|\\|\\||[+\\-*/%&|^~!=<>]=?|\\?|:)/y,\n\t\t},\n\t\t// 15. Punctuation — catch-all delimiters\n\t\t{ type: 'punctuation', pattern: /[{}[\\]();.,]/y },\n\t],\n};\n","/**\n * Built-in Java language support bundle.\n * Includes syntax highlighting (Java 21) and lexer-based smart-paste detection.\n *\n * Detection re-uses the same `JAVA_LANGUAGE` token definition that powers\n * highlighting — see `LexerDetector` for the algorithm. Smoking-gun\n * signatures encode constructs that are syntactically impossible outside\n * Java: dotted-path imports terminated by `;`, file-leading `package`\n * declarations, the canonical `main(String[] args)` entry point, and\n * `System.out` / `System.err` calls.\n */\n\nimport { JAVA_LANGUAGE } from '../../code-block/highlighter/languages/java.js';\nimport { LexerDetector } from '../../smart-paste/detectors/LexerDetector.js';\nimport type { LanguageSupport } from '../LanguageTypes.js';\n\nconst JAVA_SIGNATURES: readonly RegExp[] = [\n\t/^[ \\t]*package\\s+[\\w.]+\\s*;/m,\n\t/^[ \\t]*import\\s+(?:static\\s+)?[\\w.]+(?:\\.\\*)?\\s*;/m,\n\t/\\bSystem\\s*\\.\\s*(?:out|err)\\s*\\.\\s*\\w+\\s*\\(/,\n\t/\\bpublic\\s+static\\s+void\\s+main\\s*\\(\\s*String\\s*\\[\\s*\\]/,\n];\n\nexport const JAVA_SUPPORT: LanguageSupport = {\n\tid: 'java',\n\tdisplayName: 'Java',\n\thighlighting: JAVA_LANGUAGE,\n\tdetection: new LexerDetector(JAVA_LANGUAGE, { signatures: JAVA_SIGNATURES }),\n};\n","/**\n * JSON language definition for regex-based syntax highlighting.\n */\n\nimport type { LanguageDefinition } from '../TokenizerTypes.js';\n\nexport const JSON_LANGUAGE: LanguageDefinition = {\n\tname: 'json',\n\taliases: ['jsonc'],\n\tpatterns: [\n\t\t{ type: 'property', pattern: /\"(?:[^\"\\\\]|\\\\.)*\"(?=\\s*:)/y },\n\t\t{ type: 'string', pattern: /\"(?:[^\"\\\\]|\\\\.)*\"/y },\n\t\t{ type: 'number', pattern: /-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?/y },\n\t\t{ type: 'boolean', pattern: /(?:true|false)\\b/y },\n\t\t{ type: 'null', pattern: /null\\b/y },\n\t\t{ type: 'punctuation', pattern: /[{}[\\]:,]/y },\n\t],\n};\n","/**\n * Built-in JSON language support bundle.\n * Includes syntax highlighting and smart-paste detection.\n */\n\nimport { JSON_LANGUAGE } from '../../code-block/highlighter/languages/json.js';\nimport { JsonDetector } from '../../smart-paste/detectors/JsonDetector.js';\nimport type { LanguageSupport } from '../LanguageTypes.js';\n\nexport const JSON_SUPPORT: LanguageSupport = {\n\tid: 'json',\n\tdisplayName: 'JSON',\n\taliases: ['jsonc'],\n\thighlighting: JSON_LANGUAGE,\n\tdetection: new JsonDetector(),\n};\n","/**\n * TypeScript language definition for regex-based syntax highlighting.\n *\n * Covers modern TypeScript syntax including interfaces, type aliases, enums,\n * generics, decorators, async/await, optional chaining, nullish coalescing,\n * template literals, and JSX-friendly punctuation.\n *\n * Token type mapping:\n * - `comment` - line `//`, block, and JSDoc comments\n * - `string` - double/single-quoted strings, template literals\n * - `annotation` - decorators `@Name`, `@module.Name`\n * - `keyword` - JS/TS keywords (control flow, declarations, modifiers)\n * - `boolean` - `true`, `false`\n * - `null` - `null`, `undefined`\n * - `number` - decimal, hex, octal, binary, BigInt, scientific, with separators\n * - `function` - function/method names (identifier followed by `(` or `<...>(`)\n * - `operator` - all TS operators including `=>`, `??`, `?.`, `**`, `>>>=`\n * - `punctuation` - delimiters `{}[]();.,`\n *\n * Aliases: `ts`, `tsx`.\n */\n\nimport type { LanguageDefinition } from '../TokenizerTypes.js';\n\nconst TYPESCRIPT_KEYWORDS: readonly string[] = [\n\t'abstract',\n\t'any',\n\t'as',\n\t'asserts',\n\t'async',\n\t'await',\n\t'bigint',\n\t'boolean',\n\t'break',\n\t'case',\n\t'catch',\n\t'class',\n\t'const',\n\t'constructor',\n\t'continue',\n\t'debugger',\n\t'declare',\n\t'default',\n\t'delete',\n\t'do',\n\t'else',\n\t'enum',\n\t'export',\n\t'extends',\n\t'finally',\n\t'for',\n\t'from',\n\t'function',\n\t'get',\n\t'global',\n\t'if',\n\t'implements',\n\t'import',\n\t'in',\n\t'infer',\n\t'instanceof',\n\t'interface',\n\t'is',\n\t'keyof',\n\t'let',\n\t'module',\n\t'namespace',\n\t'never',\n\t'new',\n\t'number',\n\t'object',\n\t'of',\n\t'out',\n\t'override',\n\t'package',\n\t'private',\n\t'protected',\n\t'public',\n\t'readonly',\n\t'require',\n\t'return',\n\t'satisfies',\n\t'set',\n\t'static',\n\t'string',\n\t'super',\n\t'switch',\n\t'symbol',\n\t'this',\n\t'throw',\n\t'try',\n\t'type',\n\t'typeof',\n\t'unique',\n\t'unknown',\n\t'using',\n\t'var',\n\t'void',\n\t'while',\n\t'with',\n\t'yield',\n];\n\nconst KEYWORD_PATTERN: RegExp = new RegExp(`(?:${TYPESCRIPT_KEYWORDS.join('|')})\\\\b`, 'y');\n\nexport const TYPESCRIPT_LANGUAGE: LanguageDefinition = {\n\tname: 'typescript',\n\taliases: ['ts', 'tsx'],\n\tpatterns: [\n\t\t// 1. Block/JSDoc comments — before `/` operator\n\t\t{ type: 'comment', pattern: /\\/\\*[\\s\\S]*?\\*\\//y },\n\t\t// 2. Line comments — before `/` operator\n\t\t{ type: 'comment', pattern: /\\/\\/[^\\n]*/y },\n\t\t// 3. Template literals (no nested ${} parsing) — escape-aware\n\t\t{ type: 'string', pattern: /`(?:[^`\\\\$]|\\\\.|\\$(?!\\{)|\\$\\{[^}]*\\})*`/y },\n\t\t// 4. Double-quoted strings — escape-aware\n\t\t{ type: 'string', pattern: /\"(?:[^\"\\\\]|\\\\.)*\"/y },\n\t\t// 5. Single-quoted strings — escape-aware\n\t\t{ type: 'string', pattern: /'(?:[^'\\\\]|\\\\.)*'/y },\n\t\t// 6. Decorators — before operators\n\t\t{ type: 'annotation', pattern: /@[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*/y },\n\t\t// 7. Keywords — before functions (`if(` = keyword, not function)\n\t\t{ type: 'keyword', pattern: KEYWORD_PATTERN },\n\t\t// 8. Booleans\n\t\t{ type: 'boolean', pattern: /(?:true|false)\\b/y },\n\t\t// 9. Null/undefined\n\t\t{ type: 'null', pattern: /(?:null|undefined)\\b/y },\n\t\t// 10. Hex numbers (with optional BigInt suffix) — before decimal\n\t\t{ type: 'number', pattern: /0[xX][\\da-fA-F](?:_*[\\da-fA-F])*n?/y },\n\t\t// 11. Binary numbers — before decimal\n\t\t{ type: 'number', pattern: /0[bB][01](?:_*[01])*n?/y },\n\t\t// 12. Octal numbers — before decimal\n\t\t{ type: 'number', pattern: /0[oO][0-7](?:_*[0-7])*n?/y },\n\t\t// 13. Decimal/float/scientific/BigInt — with numeric separator support\n\t\t{\n\t\t\ttype: 'number',\n\t\t\tpattern: /\\d(?:_*\\d)*(?:\\.(?:\\d(?:_*\\d)*)?)?(?:[eE][+-]?\\d(?:_*\\d)*)?n?/y,\n\t\t},\n\t\t// 14. Function/method names — identifier followed by `(`\n\t\t{ type: 'function', pattern: /[a-zA-Z_$][\\w$]*(?=\\s*\\()/y },\n\t\t// 15. Operators — longer alternatives first (alternation picks first match, not longest)\n\t\t{\n\t\t\ttype: 'operator',\n\t\t\tpattern:\n\t\t\t\t/(?:>>>=?|>>=?|<<=?|\\*\\*=?|\\?\\?=?|\\|\\|=?|&&=?|===?|!==?|=>|\\?\\.|\\.\\.\\.|\\+\\+|--|[+\\-*/%&|^~!=<>]=?|\\?|:)/y,\n\t\t},\n\t\t// 16. Punctuation — catch-all delimiters\n\t\t{ type: 'punctuation', pattern: /[{}[\\]();.,]/y },\n\t],\n};\n","/**\n * Built-in TypeScript language support bundle.\n * Includes syntax highlighting (modern TS) and lexer-based smart-paste detection.\n *\n * Aliases `ts` and `tsx` are accepted for the language picker and code-block fences.\n *\n * Detection re-uses the same `TYPESCRIPT_LANGUAGE` token definition that\n * powers highlighting — see `LexerDetector` for the algorithm. Smoking-gun\n * signatures encode constructs that are syntactically impossible in Java:\n * `import … from '…'`, `type X = …` aliases, `declare …` ambients,\n * `: <lowercase-primitive>` type annotations, and the `export` statement\n * starter for declarations.\n */\n\nimport { TYPESCRIPT_LANGUAGE } from '../../code-block/highlighter/languages/typescript.js';\nimport { LexerDetector } from '../../smart-paste/detectors/LexerDetector.js';\nimport type { LanguageSupport } from '../LanguageTypes.js';\n\nconst TYPESCRIPT_SIGNATURES: readonly RegExp[] = [\n\t/^[ \\t]*import\\b[^;\\n]*?\\bfrom\\s+['\"]/m,\n\t/^[ \\t]*(?:export\\s+)?type\\s+\\w+(?:\\s*<[^=>]*>)?\\s*=/m,\n\t/^[ \\t]*declare\\s+(?:const|let|var|function|class|namespace|module|global)\\b/m,\n\t/[\\w$\\])]\\??\\s*:\\s*(?:string|number|boolean|void|any|unknown|never|bigint|symbol|object|null|undefined)\\b/,\n\t/^[ \\t]*export\\s+(?:default\\s+|const\\s+|let\\s+|var\\s+|function\\s+|async\\s+function\\b|class\\s+|interface\\s+|enum\\s+|namespace\\s+|abstract\\s+class\\b|\\*\\s+from\\b|\\{)/m,\n];\n\nexport const TYPESCRIPT_SUPPORT: LanguageSupport = {\n\tid: 'typescript',\n\tdisplayName: 'TypeScript',\n\taliases: ['ts', 'tsx'],\n\thighlighting: TYPESCRIPT_LANGUAGE,\n\tdetection: new LexerDetector(TYPESCRIPT_LANGUAGE, { signatures: TYPESCRIPT_SIGNATURES }),\n};\n","/**\n * XML language definition for regex-based syntax highlighting.\n *\n * Token type mapping:\n * - `comment` — XML comments `<!-- ... -->`\n * - `keyword` — processing instructions, CDATA sections\n * - `tag` — tag names (consumed with `<`/`</` prefix)\n * - `attribute` — attribute names (identifier followed by `=`)\n * - `string` — attribute values (double or single quoted)\n * - `punctuation` — delimiters `/>`, `>`, `=`\n *\n * Tag names are combined with their `<` or `</` prefix into a single `tag` token\n * to prevent text content between tags from being incorrectly highlighted.\n */\n\nimport { XML_TAG_NAME } from '../../../shared/XmlPatterns.js';\nimport type { LanguageDefinition } from '../TokenizerTypes.js';\n\nexport const XML_LANGUAGE: LanguageDefinition = {\n\tname: 'xml',\n\taliases: ['html', 'xhtml', 'svg', 'xsl'],\n\tpatterns: [\n\t\t{ type: 'comment', pattern: /<!--[\\s\\S]*?-->/y },\n\t\t{ type: 'keyword', pattern: /<!\\[CDATA\\[[\\s\\S]*?\\]\\]>/y },\n\t\t{ type: 'keyword', pattern: /<\\?[\\s\\S]*?\\?>/y },\n\t\t{ type: 'tag', pattern: new RegExp(`<\\\\/${XML_TAG_NAME}`, 'y') },\n\t\t{ type: 'tag', pattern: new RegExp(`<${XML_TAG_NAME}`, 'y') },\n\t\t{ type: 'punctuation', pattern: /\\/>|>|=/y },\n\t\t{ type: 'attribute', pattern: new RegExp(`${XML_TAG_NAME}(?=\\\\s*=)`, 'y') },\n\t\t{ type: 'string', pattern: /\"[^\"]*\"/y },\n\t\t{ type: 'string', pattern: /'[^']*'/y },\n\t],\n};\n","/**\n * Built-in XML language support bundle.\n * Includes syntax highlighting and smart-paste detection.\n */\n\nimport { XML_LANGUAGE } from '../../code-block/highlighter/languages/xml.js';\nimport { XmlDetector } from '../../smart-paste/detectors/XmlDetector.js';\nimport type { LanguageSupport } from '../LanguageTypes.js';\n\nexport const XML_SUPPORT: LanguageSupport = {\n\tid: 'xml',\n\tdisplayName: 'XML',\n\taliases: ['html', 'xhtml', 'svg', 'xsl'],\n\thighlighting: XML_LANGUAGE,\n\tdetection: new XmlDetector(),\n};\n"],"mappings":"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"}