zt-react-milkdown 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +149 -0
  2. package/dist/commands-CDrea4WB.cjs +1 -0
  3. package/dist/commands-DoqeX5uJ.js +36 -0
  4. package/dist/debounce-Bqj_3iJs.cjs +1 -0
  5. package/dist/debounce-Cuk3VGPr.js +118 -0
  6. package/dist/dist-BCCSKc3M.cjs +5 -0
  7. package/dist/dist-C0PSMrs7.cjs +37 -0
  8. package/dist/dist-CPVooDwj.cjs +2 -0
  9. package/dist/dist-CxZn1qUo.js +1584 -0
  10. package/dist/dist-Cxaq2crg.js +409 -0
  11. package/dist/dist-DaM7GJv6.js +3499 -0
  12. package/dist/dist-Dhukmh4L.js +7562 -0
  13. package/dist/dist-mOpTMw1E.cjs +1 -0
  14. package/dist/floating-ui.dom-CKbcbmJV.js +883 -0
  15. package/dist/floating-ui.dom-VaZZ2gzS.cjs +1 -0
  16. package/dist/index.browser-5LtNN9G9.cjs +1 -0
  17. package/dist/index.browser-D2DmEB8o.js +26 -0
  18. package/dist/index.cjs +393 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.mjs +43325 -0
  21. package/dist/lib-38nxOnTd.cjs +4 -0
  22. package/dist/lib-8Tr6mAln.cjs +1 -0
  23. package/dist/lib-B0rHJ9lJ.js +28 -0
  24. package/dist/lib-BJgvZywM.cjs +3 -0
  25. package/dist/lib-BNOSyYeU.cjs +3 -0
  26. package/dist/lib-C5AzmhNY.cjs +5 -0
  27. package/dist/lib-C8xOD1Bp.cjs +1 -0
  28. package/dist/lib-CCUU16r8.js +1081 -0
  29. package/dist/lib-CK9MEMX-.js +73 -0
  30. package/dist/lib-D4HMdvmK.cjs +1 -0
  31. package/dist/lib-DWZA8C0h.cjs +1 -0
  32. package/dist/lib-Dbe-cVjv.js +367 -0
  33. package/dist/lib-DkE7Uq2b.js +1886 -0
  34. package/dist/lib-DzK_kn7a.js +21 -0
  35. package/dist/lib-IahjxPWM.cjs +3 -0
  36. package/dist/lib-m8lKZKxK.js +80 -0
  37. package/dist/lib-r5eNG0sa.js +754 -0
  38. package/dist/lib-wmHesNI0.js +2223 -0
  39. package/dist/rolldown-runtime-CerMd-t8.cjs +1 -0
  40. package/dist/rolldown-runtime-DnwLefa7.js +23 -0
  41. package/dist/schema-list-DSdBEAWW.js +171 -0
  42. package/dist/schema-list-bL8FNes5.cjs +1 -0
  43. package/dist/src/components/ui/button.d.ts +16 -0
  44. package/dist/src/components/ui/button.d.ts.map +1 -0
  45. package/dist/src/components/ui/dialog.d.ts +36 -0
  46. package/dist/src/components/ui/dialog.d.ts.map +1 -0
  47. package/dist/src/components/ui/popover.d.ts +14 -0
  48. package/dist/src/components/ui/popover.d.ts.map +1 -0
  49. package/dist/src/core/commands.d.ts +7 -0
  50. package/dist/src/core/commands.d.ts.map +1 -0
  51. package/dist/src/core/createEditor.d.ts +6 -0
  52. package/dist/src/core/createEditor.d.ts.map +1 -0
  53. package/dist/src/core/schema.d.ts +8 -0
  54. package/dist/src/core/schema.d.ts.map +1 -0
  55. package/dist/src/index.d.ts +4 -0
  56. package/dist/src/index.d.ts.map +1 -0
  57. package/dist/src/lib/editor-overlay-position.d.ts +83 -0
  58. package/dist/src/lib/editor-overlay-position.d.ts.map +1 -0
  59. package/dist/src/lib/global-scroll-listener.d.ts +9 -0
  60. package/dist/src/lib/global-scroll-listener.d.ts.map +1 -0
  61. package/dist/src/lib/utils.d.ts +6 -0
  62. package/dist/src/lib/utils.d.ts.map +1 -0
  63. package/dist/src/local/en-US.d.ts +6 -0
  64. package/dist/src/local/en-US.d.ts.map +1 -0
  65. package/dist/src/local/i18n.d.ts +10 -0
  66. package/dist/src/local/i18n.d.ts.map +1 -0
  67. package/dist/src/local/zh-CN.d.ts +6 -0
  68. package/dist/src/local/zh-CN.d.ts.map +1 -0
  69. package/dist/src/plugins/custom/blockquote/blockquote-backspace-lift.d.ts +5 -0
  70. package/dist/src/plugins/custom/blockquote/blockquote-backspace-lift.d.ts.map +1 -0
  71. package/dist/src/plugins/custom/blockquote/index.d.ts +3 -0
  72. package/dist/src/plugins/custom/blockquote/index.d.ts.map +1 -0
  73. package/dist/src/plugins/custom/code-block/code-block-editable.d.ts +7 -0
  74. package/dist/src/plugins/custom/code-block/code-block-editable.d.ts.map +1 -0
  75. package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts +7 -0
  76. package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts.map +1 -0
  77. package/dist/src/plugins/custom/code-block/code-block-mod-a-select.d.ts +5 -0
  78. package/dist/src/plugins/custom/code-block/code-block-mod-a-select.d.ts.map +1 -0
  79. package/dist/src/plugins/custom/code-block/code-block-prism.d.ts +5 -0
  80. package/dist/src/plugins/custom/code-block/code-block-prism.d.ts.map +1 -0
  81. package/dist/src/plugins/custom/code-block/index.d.ts +9 -0
  82. package/dist/src/plugins/custom/code-block/index.d.ts.map +1 -0
  83. package/dist/src/plugins/custom/cursor/drop-cursor.d.ts +5 -0
  84. package/dist/src/plugins/custom/cursor/drop-cursor.d.ts.map +1 -0
  85. package/dist/src/plugins/custom/cursor/gap-cursor.d.ts +5 -0
  86. package/dist/src/plugins/custom/cursor/gap-cursor.d.ts.map +1 -0
  87. package/dist/src/plugins/custom/cursor/index.d.ts +5 -0
  88. package/dist/src/plugins/custom/cursor/index.d.ts.map +1 -0
  89. package/dist/src/plugins/custom/image/image-editable.d.ts +7 -0
  90. package/dist/src/plugins/custom/image/image-editable.d.ts.map +1 -0
  91. package/dist/src/plugins/custom/image/image-resizable-schema.d.ts +41 -0
  92. package/dist/src/plugins/custom/image/image-resizable-schema.d.ts.map +1 -0
  93. package/dist/src/plugins/custom/image/image-upload-dialog/ImageUploadDialog.d.ts +31 -0
  94. package/dist/src/plugins/custom/image/image-upload-dialog/ImageUploadDialog.d.ts.map +1 -0
  95. package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts +20 -0
  96. package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts.map +1 -0
  97. package/dist/src/plugins/custom/image/index.d.ts +7 -0
  98. package/dist/src/plugins/custom/image/index.d.ts.map +1 -0
  99. package/dist/src/plugins/custom/indent/index.d.ts +3 -0
  100. package/dist/src/plugins/custom/indent/index.d.ts.map +1 -0
  101. package/dist/src/plugins/custom/indent/tab-space-indent.d.ts +5 -0
  102. package/dist/src/plugins/custom/indent/tab-space-indent.d.ts.map +1 -0
  103. package/dist/src/plugins/custom/list/index.d.ts +3 -0
  104. package/dist/src/plugins/custom/list/index.d.ts.map +1 -0
  105. package/dist/src/plugins/custom/list/task-list-toggle.d.ts +5 -0
  106. package/dist/src/plugins/custom/list/task-list-toggle.d.ts.map +1 -0
  107. package/dist/src/plugins/custom/math/index.d.ts +7 -0
  108. package/dist/src/plugins/custom/math/index.d.ts.map +1 -0
  109. package/dist/src/plugins/custom/math/math-backspace-entry.d.ts +5 -0
  110. package/dist/src/plugins/custom/math/math-backspace-entry.d.ts.map +1 -0
  111. package/dist/src/plugins/custom/math/math-block-editable.d.ts +7 -0
  112. package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -0
  113. package/dist/src/plugins/custom/math/math-plugin.d.ts +47 -0
  114. package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -0
  115. package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +7 -0
  116. package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -0
  117. package/dist/src/plugins/custom/selection-tooltip/index.d.ts +7 -0
  118. package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -0
  119. package/dist/src/plugins/custom/selection-tooltip/mark-logic.d.ts +25 -0
  120. package/dist/src/plugins/custom/selection-tooltip/mark-logic.d.ts.map +1 -0
  121. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +21 -0
  122. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -0
  123. package/dist/src/plugins/custom/selection-tooltip/types.d.ts +58 -0
  124. package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -0
  125. package/dist/src/plugins/custom/slash-menu/index.d.ts +9 -0
  126. package/dist/src/plugins/custom/slash-menu/index.d.ts.map +1 -0
  127. package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts +6 -0
  128. package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -0
  129. package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +23 -0
  130. package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -0
  131. package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts +50 -0
  132. package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -0
  133. package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts +15 -0
  134. package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -0
  135. package/dist/src/plugins/custom/table/index.d.ts +13 -0
  136. package/dist/src/plugins/custom/table/index.d.ts.map +1 -0
  137. package/dist/src/plugins/custom/table/table-arrow-entry.d.ts +5 -0
  138. package/dist/src/plugins/custom/table/table-arrow-entry.d.ts.map +1 -0
  139. package/dist/src/plugins/custom/table/table-deletion-actions.d.ts +10 -0
  140. package/dist/src/plugins/custom/table/table-deletion-actions.d.ts.map +1 -0
  141. package/dist/src/plugins/custom/table/table-focus-actions.d.ts +7 -0
  142. package/dist/src/plugins/custom/table/table-focus-actions.d.ts.map +1 -0
  143. package/dist/src/plugins/custom/table/table-more-actions.d.ts +37 -0
  144. package/dist/src/plugins/custom/table/table-more-actions.d.ts.map +1 -0
  145. package/dist/src/plugins/custom/table/table-row-insertion.d.ts +35 -0
  146. package/dist/src/plugins/custom/table/table-row-insertion.d.ts.map +1 -0
  147. package/dist/src/plugins/custom/table/table-selection.d.ts +30 -0
  148. package/dist/src/plugins/custom/table/table-selection.d.ts.map +1 -0
  149. package/dist/src/plugins/preset-common.d.ts +56 -0
  150. package/dist/src/plugins/preset-common.d.ts.map +1 -0
  151. package/dist/src/react/components/MilkdownEditor.d.ts +7 -0
  152. package/dist/src/react/components/MilkdownEditor.d.ts.map +1 -0
  153. package/dist/src/react/components/index.d.ts +2 -0
  154. package/dist/src/react/components/index.d.ts.map +1 -0
  155. package/dist/src/react/context/EditorContext.d.ts +16 -0
  156. package/dist/src/react/context/EditorContext.d.ts.map +1 -0
  157. package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts +5 -0
  158. package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts.map +1 -0
  159. package/dist/src/react/hooks/useControlledState.d.ts +9 -0
  160. package/dist/src/react/hooks/useControlledState.d.ts.map +1 -0
  161. package/dist/src/react/hooks/useMilkdownEditor.d.ts +35 -0
  162. package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -0
  163. package/dist/src/types/editor.d.ts +233 -0
  164. package/dist/src/types/editor.d.ts.map +1 -0
  165. package/dist/src/types/plugin.d.ts +10 -0
  166. package/dist/src/types/plugin.d.ts.map +1 -0
  167. package/dist/src/utils/guard.d.ts +5 -0
  168. package/dist/src/utils/guard.d.ts.map +1 -0
  169. package/dist/src/utils/markdown.d.ts +9 -0
  170. package/dist/src/utils/markdown.d.ts.map +1 -0
  171. package/dist/state-CHAiIqOA.cjs +1 -0
  172. package/dist/state-DNxqltZl.js +16 -0
  173. package/dist/style.css +3 -0
  174. package/package.json +89 -0
@@ -0,0 +1,21 @@
1
+ import { a as e, i as t } from "./dist-DaM7GJv6.js";
2
+ import { n, u as r } from "./lib-Dbe-cVjv.js";
3
+ //#region node_modules/.pnpm/@milkdown+plugin-slash@7.20.0/node_modules/@milkdown/plugin-slash/lib/index.js
4
+ function i(i) {
5
+ let a = n({}, `${i}_SLASH_SPEC`), o = r((n) => {
6
+ let r = n.get(a.key);
7
+ return new t({
8
+ key: new e(`${i}_SLASH`),
9
+ ...r
10
+ });
11
+ }), s = [a, o];
12
+ return s.key = a.key, s.pluginKey = o.key, a.meta = {
13
+ package: "@milkdown/plugin-slash",
14
+ displayName: `Ctx<slashSpec>|${i}`
15
+ }, o.meta = {
16
+ package: "@milkdown/plugin-slash",
17
+ displayName: `Prose<slash>|${i}`
18
+ }, s;
19
+ }
20
+ //#endregion
21
+ export { i as slashFactory };
@@ -0,0 +1,3 @@
1
+ const e=require(`./rolldown-runtime-CerMd-t8.cjs`),t=require(`./dist-BCCSKc3M.cjs`),n=require(`./dist-C0PSMrs7.cjs`),r=require(`./dist-CPVooDwj.cjs`);var i=function(e){return e.docTypeError=`docTypeError`,e.contextNotFound=`contextNotFound`,e.timerNotFound=`timerNotFound`,e.ctxCallOutOfScope=`ctxCallOutOfScope`,e.createNodeInParserFail=`createNodeInParserFail`,e.stackOverFlow=`stackOverFlow`,e.parserMatchError=`parserMatchError`,e.serializerMatchError=`serializerMatchError`,e.getAtomFromSchemaFail=`getAtomFromSchemaFail`,e.expectDomTypeError=`expectDomTypeError`,e.callCommandBeforeEditorView=`callCommandBeforeEditorView`,e.missingRootElement=`missingRootElement`,e.missingNodeInSchema=`missingNodeInSchema`,e.missingMarkInSchema=`missingMarkInSchema`,e.ctxNotBind=`ctxNotBind`,e.missingYjsDoc=`missingYjsDoc`,e}({}),a=class extends Error{constructor(e,t){super(t),this.name=`MilkdownError`,this.code=e}},o=(e,t)=>typeof t==`function`?`[Function]`:t,s=e=>JSON.stringify(e,o);function c(e){return new a(i.docTypeError,`Doc type error, unsupported type: ${s(e)}`)}function l(e){return new a(i.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}function u(e){return new a(i.timerNotFound,`Timer "${e}" not found, do you forget to record it?`)}function d(){return new a(i.ctxCallOutOfScope,`Should not call a context out of the plugin.`)}function f(e,t,n){let r=`Cannot create node for ${`name`in e?e.name:e}`,o=e=>{if(e==null)return`null`;if(Array.isArray(e))return`[${e.map(o).join(`, `)}]`;if(typeof e==`object`)return`toJSON`in e&&typeof e.toJSON==`function`?JSON.stringify(e.toJSON()):`spec`in e?JSON.stringify(e.spec):JSON.stringify(e);if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;try{return String(e)}catch{return`[Unserializable]`}},s=[[`[Description]`,r],[`[Attributes]`,t],[`[Content]`,(n??[]).map(e=>e?typeof e==`object`&&`type`in e?`${e}`:o(e):`null`)]].reduce((e,[t,n])=>{let r=`${t}: ${o(n)}.`;return e.concat(r)},[]);return new a(i.createNodeInParserFail,s.join(`
2
+ `))}function p(){return new a(i.stackOverFlow,`Stack over flow, cannot pop on an empty stack.`)}function ee(e){return new a(i.parserMatchError,`Cannot match target parser for node: ${s(e)}.`)}function te(e){return new a(i.serializerMatchError,`Cannot match target serializer for node: ${s(e)}.`)}function ne(e){return new a(i.expectDomTypeError,`Expect to be a dom, but get: ${s(e)}.`)}function re(){return new a(i.callCommandBeforeEditorView,`You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized`)}function ie(e){return new a(i.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function ae(e){return new a(i.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`)}var oe=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw l(typeof e==`string`?e:e.name);return t},this.remove=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>typeof e==`string`?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},se=class{#e=[];#t;#n=()=>{this.#e.forEach(e=>e(this.#t))};constructor(e,t,n){this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},ce=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw d()}}create(e,t=this._defaultValue){return new se(e,t,this)}},m=(e,t)=>new ce(e,t),le=class{#e;#t;#n;#r=new Set;#i=new Set;#a=new Map;#o=new Map;constructor(e,t,n){this.read=()=>({metadata:this.#e,injectedSlices:[...this.#r].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),consumedSlices:[...this.#i].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),recordedTimers:[...this.#a].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)})),waitTimers:[...this.#o].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)}))}),this.onRecord=e=>{this.#a.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#a.delete(e)},this.onDone=e=>{let t=this.#a.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#o.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#r.add(e)},this.onRemove=e=>{this.#r.delete(e)},this.onUse=e=>{this.#i.add(e)},this.#t=e,this.#n=t,this.#e=n}#s=e=>this.#t.get(e).get();#c=e=>this.#n.get(e).status},ue=class e{#e;#t;#n;#r;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#e,this.#t,{...t}):this,this.inject=(e,t)=>{let n=e.create(this.#e.sliceMap);return t!=null&&n.set(t),this.#r?.onInject(e),this},this.remove=e=>(this.#e.remove(e),this.#r?.onRemove(e),this),this.record=e=>(e.create(this.#t.store),this.#r?.onRecord(e),this),this.clearTimer=e=>(this.#t.remove(e),this.#r?.onClear(e),this),this.isInjected=e=>this.#e.has(e),this.isRecorded=e=>this.#t.has(e),this.use=e=>(this.#r?.onUse(e),this.#e.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#t.get(e),this.done=e=>{this.timer(e).done(),this.#r?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#r?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#e=t,this.#t=n,this.#n=r,r&&(this.#r=new le(t,n,r))}get meta(){return this.#n}get inspector(){return this.#r}},de=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t)throw u(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},fe=class{#e=null;#t=null;#n;#r=`pending`;constructor(e,t){this.start=()=>(this.#e??=new Promise((e,t)=>{this.#t=t=>{t instanceof CustomEvent&&t.detail.id===this.#n&&(this.#r=`resolved`,this.#i(),t.stopImmediatePropagation(),e())},this.#a(()=>{this.#r===`pending`&&(this.#r=`rejected`),this.#i(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#r=`pending`,addEventListener(this.type.name,this.#t)}),this.#e),this.done=()=>{let e=new CustomEvent(this.type.name,{detail:{id:this.#n}});dispatchEvent(e)},this.#n=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#r}#i=()=>{this.#t&&removeEventListener(this.type.name,this.#t)};#a=e=>{setTimeout(()=>{e()},this.type.timeout)}},pe=class{constructor(e,t=3e3){this.create=e=>new fe(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},h=(e,t=3e3)=>new pe(e,t),g=typeof navigator<`u`?navigator:null,me=typeof document<`u`?document:null,_=g&&g.userAgent||``,he=/Edge\/(\d+)/.exec(_),ge=/MSIE \d/.exec(_),_e=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(_),ve=!!(ge||_e||he);ge?document.documentMode:_e?+_e[1]:he&&+he[1],!ve&&/gecko\/(\d+)/i.test(_)&&+(/Firefox\/(\d+)/.exec(_)||[0,0])[1];var ye=!ve&&/Chrome\/(\d+)/.exec(_),be=!!ye;ye&&+ye[1],!ve&&g&&/Apple Computer/.test(g.vendor)&&(/Mobile\/\w+/.test(_)||g&&g.maxTouchPoints>2)||g&&/Mac/.test(g.platform);var xe=/Android \d/.test(_);me&&`webkitFontSmoothing`in me.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function Se(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t);if(s.parent.type.spec.code)return!1;let c=s.parent.textBetween(Math.max(0,s.parentOffset-500),s.parentOffset,void 0,``)+r;for(let s of i){let i=s,l=i.match.exec(c),u=l&&l[0]&&i.handler(o,l,t-(l[0].length-r.length),n);if(u)return i.undoable!==!1&&u.setMeta(a,{transform:u,from:t,to:n,text:r}),e.dispatch(u),!0}return!1}var Ce=new t.a(`MILKDOWN_CUSTOM_INPUTRULES`);function we({rules:e}){let n=new t.i({key:Ce,isInputRules:!0,state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(t,r,i,a){return Se(t,r,i,a,e,n)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Se(t,r.pos,r.pos,``,e,n)}),!1),keydown:(e,t)=>!(xe&&be&&t.key===`Enter`)||e.composing?!1:e.someProp(`handleKeyDown`,n=>n(e,t))?(t.preventDefault(),!0):!1},handleKeyDown(t,r){if(r.key!==`Enter`)return!1;let{$cursor:i}=t.state.selection;return i?Se(t,i.pos,i.pos,`
3
+ `,e,n):!1}}});return n}function Te(e,t,r={}){return new n.o(e,(e,n,i,a)=>{var o;let{tr:s}=e,c=n[n.length-1],l=n[0],u=[],d,f={group:c,fullMatch:l,start:i,end:a},p=r.updateCaptured?.call(r,f);if(Object.assign(f,p),{group:c,fullMatch:l,start:i,end:a}=f,l===null||c?.trim()===``)return null;if(c){let e=l.search(/\S/),f=i+l.indexOf(c),p=f+c.length;u=s.storedMarks??[],p<a&&s.delete(p,a),f>i&&s.delete(i+e,f),d=i+e+c.length;let ee=r.getAttr?.call(r,n);s.addMark(i,d,t.create(ee)),s.setStoredMarks(u),(o=r.beforeDispatch)==null||o.call(r,{match:n,start:i,end:a,tr:s})}return s})}function Ee(e,t,r={}){return new n.o(e,(e,n,i,a)=>{var o;let{tr:s}=e,c=n[1],l=n[0],u={group:c,fullMatch:l,start:i,end:a},d=r.updateCaptured?.call(r,u);if(Object.assign(u,d),{group:c,fullMatch:l,start:i,end:a}=u,l===null||!c||c.trim()===``)return null;let f=r.getAttr?.call(r,n),p=t.createAndFill(f);return p&&(s.replaceRangeWith(t.isBlock?s.doc.resolve(i).before():i,a,p),(o=r.beforeDispatch)==null||o.call(r,{match:[l,c],start:i,end:a,tr:s})),s})}function De(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function Oe(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}function ke(e){if(e.content.childCount===1){let t=e.content.firstChild;if(t?.type.name===`text`&&t.marks.length===0)return t;if(t?.type.name===`paragraph`&&t.childCount===1){let e=t.firstChild;if(e?.type.name===`text`&&e.marks.length===0)return e}}return!1}function Ae(e,t=!0){let n=[];return e.descendants((e,r)=>{if(n.push({node:e,pos:r}),!t)return!1}),n}function je(e){return(t,n)=>Ae(t,n).filter(t=>e(t.node))}function Me(e){return t=>{for(let n=t.depth;n>0;--n){let r=t.node(n);if(e(r))return{from:t.before(n),to:t.after(n),node:r}}}}function Ne(e,t){return Me(e=>e.type===t)(e)}function Pe(e){return t=>{for(let n=t.depth;n>0;n--){let r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}function Fe(e,n){if(!(e instanceof t.r))return;let{node:r,$from:i}=e;if(Oe(n,r))return{node:r,pos:i.pos,start:i.start(i.depth),depth:i.depth}}var Ie=(e,n)=>{let{selection:r,doc:i}=e;if(r instanceof t.r)return{hasNode:r.node.type===n,pos:r.from,target:r.node};let{from:a,to:o}=r,s=!1,c=-1,l=null;return i.nodesBetween(a,o,(e,t)=>l?!1:e.type===n?(s=!0,c=t,l=e,!1):!0),{hasNode:s,pos:c,target:l}},Le=class{},Re=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw p();return e}}},ze=class e extends Le{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},Be=class extends Re{#e=t.w.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(ze.create(e,[],t)),this),this.closeNode=()=>{try{this.#a()}catch(e){console.error(e)}return this},this.addNode=(e,t,n)=>{try{this.#o(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>(this.#e=e.create(t).addToSet(this.#e),this),this.closeMark=e=>(this.#e=e.removeFromSet(this.#e),this),this.addText=e=>{try{let t=this.top();if(!t)throw p();let n=t.pop(),r=this.schema.text(e,this.#e);if(!n)return t.push(r),this;let i=this.#n(n,r);return i?(t.push(i),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=this.#a();while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#i(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#t=e=>e.isText;#n=(e,n)=>{if(this.#t(e)&&this.#t(n)&&t.w.sameSet(e.marks,n.marks))return this.schema.text(e.text+n.text,e.marks)};#r=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw ee(e);return t};#i=e=>{let t=this.#r(e);t.spec.parseMarkdown.runner(this,e,t)};#a=()=>{this.#e=t.w.none;let e=this.close();return this.#o(e.type,e.attrs,e.content)};#o=(e,t,n)=>{let r=e.createAndFill(t,n,this.#e);if(!r)throw f(e,t,n);return this.push(r),r}},Ve=class e extends Le{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||=[],this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,i={})=>new e(t,n,r,i)}},He=e=>Object.prototype.hasOwnProperty.call(e,`size`),Ue=class extends Re{#e=t.w.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.openNode=(e,t,n)=>(this.open(Ve.create(e,void 0,t,n)),this),this.closeNode=()=>(this.#l(),this),this.addNode=(e,t,n,r)=>(this.#u(e,t,n,r),this),this.withMark=(e,t,n,r)=>(this.#d(e,t,n,r),this),this.closeMark=e=>(this.#f(e),this),this.build=()=>{let e=null;do e=this.#l();while(this.size());return e},this.next=e=>He(e)?(e.forEach(e=>{this.#i(e)}),this):(this.#i(e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#t=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw te(e.type);return t};#n=e=>this.#t(e).spec.toMarkdown.runner(this,e);#r=(e,t)=>this.#t(e).spec.toMarkdown.runner(this,e,t);#i=e=>{let{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#r(t,e))&&this.#n(e),t.forEach(e=>this.#f(e))};#a=(e,t)=>{if(e.type===t||e.children?.length!==1)return e;let n=e=>{if(e.type===t)return e.value==null?e:null;if(e.children?.length!==1)return null;let[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;let i=r.children?[...r.children]:void 0,a={...e,children:i};return a.children=i,r.children=[a],r};#o=e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(n===0)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){t=this.#a(t,r.type);let{children:n,...i}=t,{children:a,...o}=r;if(t.type===r.type&&n&&a&&JSON.stringify(i)===JSON.stringify(o)){let t={...o,children:[...a,...n]};return e.slice(0,-1).concat(this.#o(t))}}return e.concat(t)},[])),e};#s=e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t};#c=(e,t)=>{let n=``,r=``,i=e.children,a=-1,o=-1,s=e=>{e&&e.forEach((e,t)=>{e.type===`text`&&e.value&&(a<0&&(a=t),o=t)})};if(i){s(i);let e=i?.[o],t=i?.[a];if(e&&e.value.endsWith(` `)){let t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(` `)){let e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}n.length&&this.#u(`text`,void 0,n);let c=t();return r.length&&this.#u(`text`,void 0,r),c};#l=(e=!1)=>{let t=this.close(),n=()=>this.#u(t.type,t.children,t.value,t.props);return e?this.#c(t,n):n()};#u=(e,t,n,r)=>{let i=Ve.create(e,t,n,r),a=this.#o(this.#s(i));return this.push(a),a};#d=(e,t,n,r)=>e.isInSet(this.#e)?this:(this.#e=e.addToSet(this.#e),this.openNode(t,n,{...r,isMark:!0}));#f=e=>{e.isInSet(this.#e)&&(this.#e=e.type.removeFromSet(this.#e),this.#l(!0))}},We=e.n({CommandManager:()=>Ze,CommandsReady:()=>L,ConfigReady:()=>k,Editor:()=>Ct,EditorStateReady:()=>K,EditorStatus:()=>$,EditorViewReady:()=>X,InitReady:()=>A,KeymapManager:()=>nt,KeymapReady:()=>z,ParserReady:()=>B,PasteRulesReady:()=>Y,SchemaReady:()=>j,SerializerReady:()=>H,commands:()=>et,commandsCtx:()=>$e,commandsTimerCtx:()=>I,config:()=>qe,createCmdKey:()=>Qe,defaultValueCtx:()=>dt,editorCtx:()=>Ke,editorState:()=>mt,editorStateCtx:()=>b,editorStateOptionsCtx:()=>W,editorStateTimerCtx:()=>G,editorView:()=>St,editorViewCtx:()=>y,editorViewOptionsCtx:()=>gt,editorViewTimerCtx:()=>Z,getDoc:()=>ft,init:()=>Je,initTimerCtx:()=>x,inputRulesCtx:()=>S,keymap:()=>it,keymapCtx:()=>R,keymapTimerCtx:()=>rt,markViewCtx:()=>E,marksCtx:()=>F,nodeViewCtx:()=>T,nodesCtx:()=>P,parser:()=>st,parserCtx:()=>V,parserTimerCtx:()=>ot,pasteRule:()=>ht,pasteRulesCtx:()=>q,pasteRulesTimerCtx:()=>J,prosePluginsCtx:()=>C,remarkCtx:()=>D,remarkPluginsCtx:()=>w,remarkStringifyOptionsCtx:()=>O,rootAttrsCtx:()=>Q,rootCtx:()=>_t,rootDOMCtx:()=>vt,schema:()=>Xe,schemaCtx:()=>N,schemaTimerCtx:()=>M,serializer:()=>ut,serializerCtx:()=>U,serializerTimerCtx:()=>ct});function v(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var Ge={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},y=m({},`editorView`),b=m({},`editorState`),x=m([],`initTimer`),Ke=m({},`editor`),S=m([],`inputRules`),C=m([],`prosePlugins`),w=m([],`remarkPlugins`),T=m([],`nodeView`),E=m([],`markView`),D=m(n.u().use(n.y).use(n.f),`remark`),O=m({handlers:Ge,encode:[]},`remarkStringifyOptions`),k=h(`ConfigReady`);function qe(e){let t=t=>(t.record(k),async()=>(await e(t),t.done(k),()=>{t.clearTimer(k)}));return v(t,{displayName:`Config`}),t}var A=h(`InitReady`);function Je(e){let t=t=>(t.inject(Ke,e).inject(C,[]).inject(w,[]).inject(S,[]).inject(T,[]).inject(E,[]).inject(O,{handlers:Ge,encode:[]}).inject(D,n.u().use(n.y).use(n.f)).inject(x,[k]).record(A),async()=>{await t.waitTimers(x);let e=t.get(O);return t.set(D,n.u().use(n.y).use(n.f,e)),t.done(A),()=>{t.remove(Ke).remove(C).remove(w).remove(S).remove(T).remove(E).remove(O).remove(D).remove(x).clearTimer(A)}});return v(t,{displayName:`Init`}),t}var j=h(`SchemaReady`),M=m([],`schemaTimer`),N=m({},`schema`),P=m([],`nodes`),F=m([],`marks`);function Ye(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var Xe=e=>(e.inject(N,{}).inject(P,[]).inject(F,[]).inject(M,[A]).record(j),async()=>{await e.waitTimers(M);let n=e.get(D),r=e.get(w).reduce((e,t)=>e.use(t.plugin,t.options),n);e.set(D,r);let i=new t.O({nodes:Object.fromEntries(e.get(P).map(([e,t])=>[e,Ye(t)])),marks:Object.fromEntries(e.get(F).map(([e,t])=>[e,Ye(t)]))});return e.set(N,i),e.done(j),()=>{e.remove(N).remove(P).remove(F).remove(M).clearTimer(j)}});v(Xe,{displayName:`Schema`});var Ze=class{constructor(){this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw re();let e=this.#t,t=[],n=this.get.bind(this),i={run:()=>{let n=r.r(...t),i=e.get(y);return n(i.state,i.dispatch,i)},inline:e=>(t.push(e),i),pipe:a.bind(this)};function a(e,r){let a=n(e);return t.push(a(r)),i}return i}}#e=new oe;#t=null;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw re();let n=this.get(e)(t),r=this.#t.get(y);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw re();let t=this.#t.get(y);return e(t.state,t.dispatch,t)}};function Qe(e=`cmdKey`){return m((()=>()=>!1),e)}var $e=m(new Ze,`commands`),I=m([j],`commandsTimer`),L=h(`CommandsReady`),et=e=>{let t=new Ze;return t.setCtx(e),e.inject($e,t).inject(I,[j]).record(L),async()=>(await e.waitTimers(I),e.done(L),()=>{e.remove($e).remove(I).clearTimer(L)})};v(et,{displayName:`Commands`});function tt(e){return e.Backspace=r.r(n.c,r.a,r.u,r.y),e}var nt=class{constructor(){this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=tt(r.n);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,i)=>{let a=this.#e;if(a==null)throw d();return r.r(...n.map(e=>e.onRun(a)))(e,t,i)}]}))}}#e=null;#t=[];get ctx(){return this.#e}},R=m(new nt,`keymap`),rt=m([j],`keymapTimer`),z=h(`KeymapReady`),it=e=>{let t=new nt;return t.setCtx(e),e.inject(R,t).inject(rt,[j]).record(z),async()=>(await e.waitTimers(rt),e.done(z),()=>{e.remove(R).remove(rt).clearTimer(z)})},B=h(`ParserReady`),at=(()=>{throw d()}),V=m(at,`parser`),ot=m([],`parserTimer`),st=e=>(e.inject(V,at).inject(ot,[j]).record(B),async()=>{await e.waitTimers(ot);let t=e.get(D),n=e.get(N);return e.set(V,Be.create(n,t)),e.done(B),()=>{e.remove(V).remove(ot).clearTimer(B)}});v(st,{displayName:`Parser`});var H=h(`SerializerReady`),ct=m([],`serializerTimer`),lt=(()=>{throw d()}),U=m(lt,`serializer`),ut=e=>(e.inject(U,lt).inject(ct,[j]).record(H),async()=>{await e.waitTimers(ct);let t=e.get(D),n=e.get(N);return e.set(U,Ue.create(n,t)),e.done(H),()=>{e.remove(U).remove(ct).clearTimer(H)}});v(ut,{displayName:`Serializer`});var dt=m(``,`defaultValue`),W=m(e=>e,`stateOptions`),G=m([],`editorStateTimer`),K=h(`EditorStateReady`);function ft(e,n,r){if(typeof e==`string`)return n(e);if(e.type===`html`)return t.x.fromSchema(r).parse(e.dom);if(e.type===`json`)return t.T.fromJSON(r,e.value);throw c(e)}var pt=new t.a(`MILKDOWN_STATE_TRACKER`),mt=e=>(e.inject(dt,``).inject(b,{}).inject(W,e=>e).inject(G,[B,H,L,z]).record(K),async()=>{await e.waitTimers(G);let r=e.get(N),i=e.get(V),a=e.get(S),o=e.get(W),s=e.get(C),c=ft(e.get(dt),i,r),l=e.get(R),u=l.addBaseKeymap(),d=[...s,new t.i({key:pt,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(b,i)}}}),we({rules:a}),n.a(l.build())];e.set(C,d);let f=o({schema:r,doc:c,plugins:d}),p=t.n.create(f);return e.set(b,p),e.done(K),()=>{u(),e.remove(dt).remove(b).remove(W).remove(G).clearTimer(K)}});v(mt,{displayName:`EditorState`});var q=m([],`pasteRule`),J=m([j],`pasteRuleTimer`),Y=h(`PasteRuleReady`),ht=e=>(e.inject(q,[]).inject(J,[j]).record(Y),async()=>(await e.waitTimers(J),e.done(Y),()=>{e.remove(q).remove(J).clearTimer(Y)}));v(ht,{displayName:`PasteRule`});var X=h(`EditorViewReady`),Z=m([],`editorViewTimer`),gt=m({},`editorViewOptions`),_t=m(null,`root`),vt=m(null,`rootDOM`),Q=m({},`rootAttrs`);function yt(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set(vt,n);let r=t.get(Q);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function bt(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var xt=new t.a(`MILKDOWN_VIEW_CLEAR`),St=e=>(e.inject(_t,document.body).inject(y,{}).inject(gt,{}).inject(vt,null).inject(Q,{}).inject(Z,[K,Y]).record(X),async()=>{await e.wait(A);let r=e.get(_t)||document.body,i=typeof r==`string`?document.querySelector(r):r;e.update(C,n=>[new t.i({key:xt,view:t=>{let n=i?yt(i,e):void 0;return(()=>{if(n&&i){let e=t.dom;i.replaceChild(n,e),n.appendChild(e)}})(),{destroy:()=>{n?.parentNode&&n?.parentNode.replaceChild(t.dom,n),n?.remove()}}}}),...n]),await e.waitTimers(Z);let a=e.get(b),o=e.get(gt),s=new n.r(i,{state:a,nodeViews:Object.fromEntries(e.get(T)),markViews:Object.fromEntries(e.get(E)),transformPasted:(t,n,r)=>(e.get(q).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});return bt(s.dom),e.set(y,s),e.done(X),()=>{s?.destroy(),e.remove(_t).remove(y).remove(gt).remove(vt).remove(Q).remove(Z).clearTimer(X)}});v(St,{displayName:`EditorView`});var $=function(e){return e.Idle=`Idle`,e.OnCreate=`OnCreate`,e.Created=`Created`,e.OnDestroy=`OnDestroy`,e.Destroyed=`Destroyed`,e}({}),Ct=class e{constructor(){this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===$.Created&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===$.OnCreate?(console.warn(`[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code.`),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>this.#t===$.OnCreate?this:(this.#t===$.Created&&await this.destroy(),this.#p($.OnCreate),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p($.Created),this),this.destroy=async(e=!1)=>this.#t===$.Destroyed||this.#t===$.OnDestroy?this:this.#t===$.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p($.OnDestroy),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p($.Destroyed),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#e=!1;#t=$.Idle;#n=[];#r=()=>void 0;#i=new oe;#a=new de;#o=new Map;#s=new Map;#c=new ue(this.#i,this.#a);#l=()=>{let e=qe(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[Xe,st,ut,et,it,ht,mt,St,Je(this),e];this.#u(t,this.#s)};#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})};#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n}));#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()};#p=e=>{this.#t=e,this.#r(e)};#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})});get ctx(){return this.#c}get status(){return this.#t}};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,`B`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,`H`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`U`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`V`,{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`z`,{enumerable:!0,get:function(){return m}});
@@ -0,0 +1,80 @@
1
+ import { a as e, i as t } from "./dist-DaM7GJv6.js";
2
+ import { k as n, n as r, o as i, r as a, w as o, z as s } from "./lib-CCUU16r8.js";
3
+ import { t as c } from "./debounce-Cuk3VGPr.js";
4
+ //#region node_modules/.pnpm/@milkdown+plugin-listener@7.20.0/node_modules/@milkdown/plugin-listener/lib/index.js
5
+ var l = class {
6
+ constructor() {
7
+ this.beforeMountedListeners = [], this.mountedListeners = [], this.updatedListeners = [], this.selectionUpdatedListeners = [], this.markdownUpdatedListeners = [], this.blurListeners = [], this.focusListeners = [], this.destroyListeners = [], this.beforeMount = (e) => (this.beforeMountedListeners.push(e), this), this.mounted = (e) => (this.mountedListeners.push(e), this), this.updated = (e) => (this.updatedListeners.push(e), this);
8
+ }
9
+ get listeners() {
10
+ return {
11
+ beforeMount: this.beforeMountedListeners,
12
+ mounted: this.mountedListeners,
13
+ updated: this.updatedListeners,
14
+ markdownUpdated: this.markdownUpdatedListeners,
15
+ blur: this.blurListeners,
16
+ focus: this.focusListeners,
17
+ destroy: this.destroyListeners,
18
+ selectionUpdated: this.selectionUpdatedListeners
19
+ };
20
+ }
21
+ markdownUpdated(e) {
22
+ return this.markdownUpdatedListeners.push(e), this;
23
+ }
24
+ blur(e) {
25
+ return this.blurListeners.push(e), this;
26
+ }
27
+ focus(e) {
28
+ return this.focusListeners.push(e), this;
29
+ }
30
+ destroy(e) {
31
+ return this.destroyListeners.push(e), this;
32
+ }
33
+ selectionUpdated(e) {
34
+ return this.selectionUpdatedListeners.push(e), this;
35
+ }
36
+ }, u = s(new l(), "listener"), d = new e("MILKDOWN_LISTENER"), f = (e) => (e.inject(u, new l()), async () => {
37
+ await e.wait(a);
38
+ let { listeners: s } = e.get(u);
39
+ s.beforeMount.forEach((t) => t(e)), await e.wait(i);
40
+ let l = e.get(n), f = null, p = null, m = null, h = null, g = c(() => {
41
+ if (!h) return;
42
+ let { doc: t } = h;
43
+ if (s.updated.length > 0 && f && !f.eq(t) && s.updated.forEach((n) => {
44
+ n(e, t, f);
45
+ }), s.markdownUpdated.length > 0 && f && !f.eq(t)) {
46
+ let n = l(t);
47
+ s.markdownUpdated.forEach((t) => {
48
+ t(e, n, p);
49
+ }), p = n;
50
+ }
51
+ f = t, h = null;
52
+ }, 200), _ = new t({
53
+ key: d,
54
+ view: () => ({ destroy: () => {
55
+ s.destroy.forEach((t) => t(e));
56
+ } }),
57
+ props: { handleDOMEvents: {
58
+ focus: () => (s.focus.forEach((t) => t(e)), !1),
59
+ blur: () => (s.blur.forEach((t) => t(e)), !1)
60
+ } },
61
+ state: {
62
+ init: (e, t) => {
63
+ f = t.doc, p = l(t.doc);
64
+ },
65
+ apply: (t) => {
66
+ let n = t.selection;
67
+ (!m && n || m && !n.eq(m)) && (s.selectionUpdated.forEach((t) => {
68
+ t(e, n, m);
69
+ }), m = n), !(!(t.docChanged || t.storedMarksSet) || t.getMeta("addToHistory") === !1) && (h = t, g());
70
+ }
71
+ }
72
+ });
73
+ e.update(o, (e) => e.concat(_)), await e.wait(r), s.mounted.forEach((t) => t(e));
74
+ });
75
+ f.meta = {
76
+ package: "@milkdown/plugin-listener",
77
+ displayName: "Listener"
78
+ };
79
+ //#endregion
80
+ export { l as ListenerManager, d as key, f as listener, u as listenerCtx };