zt-react-milkdown 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dist-Cxaq2crg.js → commands-BJpevWrH.js} +123 -123
- package/dist/commands-BmZHd6RL.js +2 -0
- package/dist/{dist-CPVooDwj.cjs → commands-CM7IuhpT.cjs} +2 -2
- package/dist/commands-f4yOm8DQ.cjs +1 -0
- package/dist/{debounce-Bqj_3iJs.cjs → debounce-C_TNzOFT.cjs} +1 -1
- package/dist/{dist-DaM7GJv6.js → dist-CLTsQjPD.js} +319 -318
- package/dist/{dist-CxZn1qUo.js → dist-CZTw9GLV.js} +198 -198
- package/dist/dist-DQnWlYyo.cjs +5 -0
- package/dist/dist-ZPtYoqTI.cjs +1 -0
- package/dist/floating-ui.dom-CV-TLBRq.cjs +1 -0
- package/dist/floating-ui.dom-CoOubeUs.js +762 -0
- package/dist/index.cjs +25 -149
- package/dist/index.mjs +6235 -15737
- package/dist/{lib-C8xOD1Bp.cjs → lib-5pUyY-Tl.cjs} +1 -1
- package/dist/{lib-DkE7Uq2b.js → lib-Bhr5EVOu.js} +110 -112
- package/dist/lib-BmAQCwSQ.cjs +1 -0
- package/dist/{lib-wmHesNI0.js → lib-C1A-pN4b.js} +574 -575
- package/dist/lib-CVebEyb8.cjs +4 -0
- package/dist/lib-ChwoE6v5.js +331 -0
- package/dist/lib-DIx8C5AZ.cjs +1 -0
- package/dist/lib-DVE2k9i1.js +387 -0
- package/dist/{lib-DzK_kn7a.js → lib-D_0WAhKU.js} +3 -3
- package/dist/{lib-m8lKZKxK.js → lib-Dd20rlmV.js} +28 -28
- package/dist/lib-De0djIEV.cjs +5 -0
- package/dist/{lib-D4HMdvmK.cjs → lib-DgEwQN1U.cjs} +1 -1
- package/dist/{dist-Dhukmh4L.js → lib-DmD940Fq.js} +2849 -1735
- package/dist/lib-Dplx6t-N.cjs +3 -0
- package/dist/lib-DzY83R_P.cjs +39 -0
- package/dist/lib-F08NY8fk.cjs +1 -0
- package/dist/{lib-B0rHJ9lJ.js → lib-_NDReOAt.js} +3 -3
- package/dist/{lib-CK9MEMX-.js → lib-bsXGz3fj.js} +28 -27
- package/dist/schema-list-D9Q6QKgo.cjs +1 -0
- package/dist/schema-list-DooYP5HM.js +110 -0
- package/dist/src/core/createEditor.d.ts.map +1 -1
- package/dist/src/local/en-US.d.ts.map +1 -1
- package/dist/src/local/zh-CN.d.ts.map +1 -1
- package/dist/src/plugins/custom/block-transform/block-transform.d.ts +15 -0
- package/dist/src/plugins/custom/block-transform/block-transform.d.ts.map +1 -0
- package/dist/src/plugins/custom/block-transform/index.d.ts +2 -0
- package/dist/src/plugins/custom/block-transform/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/index.d.ts +6 -0
- package/dist/src/plugins/custom/math/index.d.ts.map +1 -1
- package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -1
- package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts +5 -0
- package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts +29 -0
- package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-inline-editable.d.ts +7 -0
- package/dist/src/plugins/custom/math/math-inline-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +5 -1
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +34 -3
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts +16 -1
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +4 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -1
- package/dist/src/plugins/preset-common.d.ts +6 -0
- package/dist/src/plugins/preset-common.d.ts.map +1 -1
- package/dist/src/react/hooks/useMilkdownEditor.d.ts +2 -2
- package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -1
- package/dist/src/types/editor.d.ts +35 -5
- package/dist/src/types/editor.d.ts.map +1 -1
- package/dist/state-BC1dqWPQ.cjs +1 -0
- package/dist/state-BvRk9kiK.cjs +0 -0
- package/dist/state-BvRk9kiK.js +0 -0
- package/dist/state-rTW_1XVf.js +3 -0
- package/dist/style.css +2 -2
- package/package.json +1 -1
- package/dist/commands-CDrea4WB.cjs +0 -1
- package/dist/commands-DoqeX5uJ.js +0 -36
- package/dist/dist-BCCSKc3M.cjs +0 -5
- package/dist/dist-C0PSMrs7.cjs +0 -37
- package/dist/dist-mOpTMw1E.cjs +0 -1
- package/dist/floating-ui.dom-CKbcbmJV.js +0 -883
- package/dist/floating-ui.dom-VaZZ2gzS.cjs +0 -1
- package/dist/index.browser-5LtNN9G9.cjs +0 -1
- package/dist/index.browser-D2DmEB8o.js +0 -26
- package/dist/lib-38nxOnTd.cjs +0 -4
- package/dist/lib-8Tr6mAln.cjs +0 -1
- package/dist/lib-BJgvZywM.cjs +0 -3
- package/dist/lib-BNOSyYeU.cjs +0 -3
- package/dist/lib-C5AzmhNY.cjs +0 -5
- package/dist/lib-CCUU16r8.js +0 -1081
- package/dist/lib-DWZA8C0h.cjs +0 -1
- package/dist/lib-Dbe-cVjv.js +0 -367
- package/dist/lib-IahjxPWM.cjs +0 -3
- package/dist/lib-r5eNG0sa.js +0 -754
- package/dist/rolldown-runtime-CerMd-t8.cjs +0 -1
- package/dist/rolldown-runtime-DnwLefa7.js +0 -23
- package/dist/schema-list-DSdBEAWW.js +0 -171
- package/dist/schema-list-bL8FNes5.cjs +0 -1
- package/dist/state-CHAiIqOA.cjs +0 -1
- package/dist/state-DNxqltZl.js +0 -16
- /package/dist/{debounce-Cuk3VGPr.js → debounce-Z8-khnlZ.js} +0 -0
package/dist/lib-DWZA8C0h.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./rolldown-runtime-CerMd-t8.cjs`),t=require(`./dist-BCCSKc3M.cjs`),n=require(`./lib-IahjxPWM.cjs`),r=require(`./index.browser-5LtNN9G9.cjs`);var i=e.n({$command:()=>s,$commandAsync:()=>c,$ctx:()=>C,$inputRule:()=>l,$inputRuleAsync:()=>u,$mark:()=>p,$markAsync:()=>m,$markAttr:()=>O,$markSchema:()=>T,$node:()=>h,$nodeAsync:()=>g,$nodeAttr:()=>D,$nodeSchema:()=>w,$pasteRule:()=>d,$pasteRuleAsync:()=>f,$prose:()=>_,$proseAsync:()=>v,$remark:()=>k,$shortcut:()=>y,$shortcutAsync:()=>b,$useKeymap:()=>E,$view:()=>x,$viewAsync:()=>S,addTimer:()=>o,callCommand:()=>A,forceUpdate:()=>j,getHTML:()=>M,getMarkdown:()=>N,insert:()=>P,insertPos:()=>z,markdownToSlice:()=>R,nanoid:()=>a,outline:()=>F,pipe:()=>V,replaceAll:()=>I,replaceRange:()=>B,setAttr:()=>L}),a=r.t(`abcedfghicklmn`,10);function o(e,t,r){let i=n.B(r||a()),o=!1,s=n=>(n.record(i),n.update(t,e=>e.concat(i)),async()=>{let r=await e(n,s,()=>{n.done(i),o=!0});return o||n.done(i),()=>{if(n.update(t,e=>e.filter(e=>e!==i)),n.clearTimer(i),r){let e=r();e&&`then`in e&&e.catch(console.error)}}});return s.timer=i,s}function s(e,t){let r=n.l(e),i=a=>async()=>{i.key=r,await a.wait(n.t);let o=t(a);return a.get(n.s).create(r,o),i.run=t=>a.get(n.s).call(e,t),()=>{a.get(n.s).remove(r)}};return i}function c(e,t,r){let i=n.l(e);return o(async(r,a)=>{await r.wait(n.t);let o=await t(r);return r.get(n.s).create(i,o),a.run=t=>r.get(n.s).call(e,t),a.key=i,()=>{r.get(n.s).remove(i)}},n.c,r)}function l(e){let t=r=>async()=>{await r.wait(n.a);let i=e(r);return r.update(n.m,e=>[...e,i]),t.inputRule=i,()=>{r.update(n.m,e=>e.filter(e=>e!==i))}};return t}function u(e,t){return o(async(t,r)=>{await t.wait(n.a);let i=await e(t);return t.update(n.m,e=>[...e,i]),r.inputRule=i,()=>{t.update(n.m,e=>e.filter(e=>e!==i))}},n.d,t)}function d(e){let t=r=>async()=>{await r.wait(n.a);let i=e(r);return r.update(n.S,e=>[...e,i]),t.pasteRule=i,()=>{r.update(n.S,e=>e.filter(e=>e!==i))}};return t}function f(e,t){return o(async(t,r)=>{await t.wait(n.a);let i=await e(t);return t.update(n.S,e=>[...e,i]),r.pasteRule=i,()=>{t.update(n.S,e=>e.filter(e=>e!==i))}},n.C,t)}function p(e,t){let r=i=>async()=>{let a=t(i);return i.update(n.v,t=>[...t.filter(t=>t[0]!==e),[e,a]]),r.id=e,r.schema=a,()=>{i.update(n.v,t=>t.filter(([t])=>t!==e))}};return r.type=t=>{let r=t.get(n.D).marks[e];if(!r)throw n.H(e);return r},r}function m(e,t,r){let i=o(async(r,i,a)=>{let o=await t(r);return r.update(n.v,t=>[...t.filter(t=>t[0]!==e),[e,o]]),i.id=e,i.schema=o,a(),()=>{r.update(n.v,t=>t.filter(([t])=>t!==e))}},n.O,r);return i.type=t=>{let r=t.get(n.D).marks[e];if(!r)throw n.H(e);return r},i}function h(e,t){let r=i=>async()=>{let a=t(i);return i.update(n.b,t=>[...t.filter(t=>t[0]!==e),[e,a]]),r.id=e,r.schema=a,()=>{i.update(n.b,t=>t.filter(([t])=>t!==e))}};return r.type=t=>{let r=t.get(n.D).nodes[e];if(!r)throw n.U(e);return r},r}function g(e,t,r){let i=o(async(r,i,a)=>{let o=await t(r);return r.update(n.b,t=>[...t.filter(t=>t[0]!==e),[e,o]]),i.id=e,i.schema=o,a(),()=>{r.update(n.b,t=>t.filter(([t])=>t!==e))}},n.O,r);return i.type=t=>{let r=t.get(n.D).nodes[e];if(!r)throw n.U(e);return r},i}function _(e){let t,r=r=>async()=>(await r.wait(n.a),t=e(r),r.update(n.w,e=>[...e,t]),()=>{r.update(n.w,e=>e.filter(e=>e!==t))});return r.plugin=()=>t,r.key=()=>t.spec.key,r}function v(e,t){let r,i=o(async t=>(await t.wait(n.a),r=await e(t),t.update(n.w,e=>[...e,r]),()=>{t.update(n.w,e=>e.filter(e=>e!==r))}),n.d,t);return i.plugin=()=>r,i.key=()=>r.spec.key,i}function y(e){let t=r=>async()=>{await r.wait(n.i);let i=r.get(n.h),a=e(r),o=i.addObjectKeymap(a);return t.keymap=a,()=>{o()}};return t}function b(e,t){return o(async(t,r)=>{await t.wait(n.i);let i=t.get(n.h),a=await e(t),o=i.addObjectKeymap(a);return r.keymap=a,()=>{o()}},n.d,t)}function x(e,r){let i=a=>async()=>{await a.wait(n.a);let o=r(a);return e.type(a)instanceof t.D?a.update(n.y,t=>[...t,[e.id,o]]):a.update(n._,t=>[...t,[e.id,o]]),i.view=o,i.type=e,()=>{e.type(a)instanceof t.D?a.update(n.y,t=>t.filter(t=>t[0]!==e.id)):a.update(n._,t=>t.filter(t=>t[0]!==e.id))}};return i}function S(e,r,i){return o(async(i,a)=>{await i.wait(n.a);let o=await r(i);return e.type(i)instanceof t.D?i.update(n.y,t=>[...t,[e.id,o]]):i.update(n._,t=>[...t,[e.id,o]]),a.view=o,a.type=e,()=>{e.type(i)instanceof t.D?i.update(n.y,t=>t.filter(t=>t[0]!==e.id)):i.update(n._,t=>t.filter(t=>t[0]!==e.id))}},n.p,i)}function C(e,t){let r=n.z(e,t),i=e=>(e.inject(r),()=>()=>{e.remove(r)});return i.key=r,i}function w(e,t){let n=C(t,e),r=h(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>w(e,n(t)),i}function T(e,t){let n=C(t,e),r=p(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.mark=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>T(e,n(t)),i}function E(e,t){let n=C(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=y(e=>{let r=e.get(n.key),i=Object.entries(t).flatMap(([e,{command:t}])=>{let n=r[e],i=[n.shortcuts].flat(),a=n.priority;return i.map(e=>[e,{key:e,onRun:t,priority:a}])});return Object.fromEntries(i)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}var D=(e,t=()=>({}))=>C(t,`${e}Attr`),O=(e,t=()=>({}))=>C(t,`${e}Attr`);function k(e,t,r){let i=C(r??{},e),a=e=>async()=>{await e.wait(n.r);let r={plugin:t(e),options:e.get(i.key)};return e.update(n.T,e=>[...e,r]),()=>{e.update(n.T,e=>e.filter(e=>e!==r))}},o=[i,a];return o.id=e,o.plugin=a,o.options=i,o}function A(e,t){return r=>r.get(n.s).call(e,t)}function j(){return e=>{let t=e.get(n.f),{tr:r}=t.state,i=Object.assign(Object.create(r),r).setTime(Date.now());return t.dispatch(i)}}function M(){return e=>{let r=document.createElement(`div`),i=e.get(n.D),a=e.get(n.f),o=t.S.fromSchema(i).serializeFragment(a.state.doc.content);return r.appendChild(o),r.innerHTML}}function N(e){return t=>{let r=t.get(n.f),i=t.get(n.D),a=t.get(n.k);if(!e)return a(r.state.doc);let o=r.state.doc.slice(e.from,e.to,!0),s=i.topNodeType.createAndFill(null,o.content);return s?a(s):(console.error(`No document found`),``)}}function P(e,r=!1){return i=>{let a=i.get(n.f),o=i.get(n.x)(e);if(!o)return;if(!r){let e=a.state.selection.content();return a.dispatch(a.state.tr.replaceSelection(new t.k(o.content,e.openStart,e.openEnd)).scrollIntoView())}let s=i.get(n.D),c=t.S.fromSchema(s).serializeFragment(o.content),l=t.x.fromSchema(s).parseSlice(c),u=n.I(l);if(u){a.dispatch(a.state.tr.replaceSelectionWith(u,!0));return}a.dispatch(a.state.tr.replaceSelection(l))}}function F(){return e=>{let t=e.get(n.f),r=[];return t.state.doc.descendants(e=>{e.type.name===`heading`&&e.attrs.level&&r.push({text:e.textContent,level:e.attrs.level,id:e.attrs.id})}),r}}function I(e,r=!1){return i=>{let a=i.get(n.f),o=i.get(n.x)(e);if(!o)return;if(!r){let{state:e}=a;return a.dispatch(e.tr.replace(0,e.doc.content.size,new t.k(o.content,0,0)))}let s=i.get(n.D),c=i.get(n.u)({schema:s,doc:o,plugins:i.get(n.w)}),l=t.n.create(c);a.updateState(l)}}function L(e,t){return r=>{let i=r.get(n.f),{tr:a}=i.state,o=a.doc.nodeAt(e);if(!o)return;let s=t(o.attrs);return i.dispatch(a.setNodeMarkup(e,void 0,s))}}function R(e){return r=>{let i=r.get(n.x)(e),a=r.get(n.D),o=t.S.fromSchema(a).serializeFragment(i.content);return t.x.fromSchema(a).parseSlice(o)}}function z(e,t,r=!1){return i=>{let a=R(e)(i),o=i.get(n.f),s=o.state.doc.resolve(t),c=o.state.doc.content.size,l=r?s.pos:s.after(s.depth-1),u=Math.min(Math.max(l,0),c);o.dispatch(o.state.tr.replace(l,u,a))}}function B(e,t){return r=>{let i=r.get(n.f),a=R(e)(r);i.dispatch(i.state.tr.replace(t.from,t.to,a))}}var V=(...e)=>{let t=e.length,n=t;for(;n--;)if(typeof e[n]!=`function`)throw TypeError(`Expected a function`);return(...n)=>{let r=0,i=t?e[r](...n):n[0];for(;++r<t;)i=e[r](i);return i}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return _}});
|
package/dist/lib-Dbe-cVjv.js
DELETED
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import { n as e } from "./rolldown-runtime-DnwLefa7.js";
|
|
2
|
-
import { D as t, S as n, k as r, n as i, x as a } from "./dist-DaM7GJv6.js";
|
|
3
|
-
import { B as o, C as s, D as c, H as l, I as u, O as d, S as f, T as p, U as m, _ as h, a as g, b as _, c as ee, d as v, f as y, h as b, i as x, k as te, l as S, m as C, p as ne, r as re, s as w, t as T, u as E, v as D, w as O, x as k, y as A, z as ie } from "./lib-CCUU16r8.js";
|
|
4
|
-
import { t as j } from "./index.browser-D2DmEB8o.js";
|
|
5
|
-
//#region node_modules/.pnpm/@milkdown+utils@7.20.0/node_modules/@milkdown/utils/lib/index.js
|
|
6
|
-
var M = /* @__PURE__ */ e({
|
|
7
|
-
$command: () => F,
|
|
8
|
-
$commandAsync: () => ae,
|
|
9
|
-
$ctx: () => G,
|
|
10
|
-
$inputRule: () => I,
|
|
11
|
-
$inputRuleAsync: () => oe,
|
|
12
|
-
$mark: () => R,
|
|
13
|
-
$markAsync: () => ce,
|
|
14
|
-
$markAttr: () => X,
|
|
15
|
-
$markSchema: () => q,
|
|
16
|
-
$node: () => z,
|
|
17
|
-
$nodeAsync: () => B,
|
|
18
|
-
$nodeAttr: () => Y,
|
|
19
|
-
$nodeSchema: () => K,
|
|
20
|
-
$pasteRule: () => L,
|
|
21
|
-
$pasteRuleAsync: () => se,
|
|
22
|
-
$prose: () => V,
|
|
23
|
-
$proseAsync: () => H,
|
|
24
|
-
$remark: () => Z,
|
|
25
|
-
$shortcut: () => U,
|
|
26
|
-
$shortcutAsync: () => W,
|
|
27
|
-
$useKeymap: () => J,
|
|
28
|
-
$view: () => le,
|
|
29
|
-
$viewAsync: () => ue,
|
|
30
|
-
addTimer: () => P,
|
|
31
|
-
callCommand: () => de,
|
|
32
|
-
forceUpdate: () => fe,
|
|
33
|
-
getHTML: () => pe,
|
|
34
|
-
getMarkdown: () => me,
|
|
35
|
-
insert: () => Q,
|
|
36
|
-
insertPos: () => ve,
|
|
37
|
-
markdownToSlice: () => $,
|
|
38
|
-
nanoid: () => N,
|
|
39
|
-
outline: () => he,
|
|
40
|
-
pipe: () => be,
|
|
41
|
-
replaceAll: () => ge,
|
|
42
|
-
replaceRange: () => ye,
|
|
43
|
-
setAttr: () => _e
|
|
44
|
-
}), N = j("abcedfghicklmn", 10);
|
|
45
|
-
function P(e, t, n) {
|
|
46
|
-
let r = o(n || N()), i = !1, a = (n) => (n.record(r), n.update(t, (e) => e.concat(r)), async () => {
|
|
47
|
-
let o = await e(n, a, () => {
|
|
48
|
-
n.done(r), i = !0;
|
|
49
|
-
});
|
|
50
|
-
return i || n.done(r), () => {
|
|
51
|
-
if (n.update(t, (e) => e.filter((e) => e !== r)), n.clearTimer(r), o) {
|
|
52
|
-
let e = o();
|
|
53
|
-
e && "then" in e && e.catch(console.error);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
return a.timer = r, a;
|
|
58
|
-
}
|
|
59
|
-
function F(e, t) {
|
|
60
|
-
let n = S(e), r = (i) => async () => {
|
|
61
|
-
r.key = n, await i.wait(T);
|
|
62
|
-
let a = t(i);
|
|
63
|
-
return i.get(w).create(n, a), r.run = (t) => i.get(w).call(e, t), () => {
|
|
64
|
-
i.get(w).remove(n);
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
return r;
|
|
68
|
-
}
|
|
69
|
-
function ae(e, t, n) {
|
|
70
|
-
let r = S(e);
|
|
71
|
-
return P(async (n, i) => {
|
|
72
|
-
await n.wait(T);
|
|
73
|
-
let a = await t(n);
|
|
74
|
-
return n.get(w).create(r, a), i.run = (t) => n.get(w).call(e, t), i.key = r, () => {
|
|
75
|
-
n.get(w).remove(r);
|
|
76
|
-
};
|
|
77
|
-
}, ee, n);
|
|
78
|
-
}
|
|
79
|
-
function I(e) {
|
|
80
|
-
let t = (n) => async () => {
|
|
81
|
-
await n.wait(g);
|
|
82
|
-
let r = e(n);
|
|
83
|
-
return n.update(C, (e) => [...e, r]), t.inputRule = r, () => {
|
|
84
|
-
n.update(C, (e) => e.filter((e) => e !== r));
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
return t;
|
|
88
|
-
}
|
|
89
|
-
function oe(e, t) {
|
|
90
|
-
return P(async (t, n) => {
|
|
91
|
-
await t.wait(g);
|
|
92
|
-
let r = await e(t);
|
|
93
|
-
return t.update(C, (e) => [...e, r]), n.inputRule = r, () => {
|
|
94
|
-
t.update(C, (e) => e.filter((e) => e !== r));
|
|
95
|
-
};
|
|
96
|
-
}, v, t);
|
|
97
|
-
}
|
|
98
|
-
function L(e) {
|
|
99
|
-
let t = (n) => async () => {
|
|
100
|
-
await n.wait(g);
|
|
101
|
-
let r = e(n);
|
|
102
|
-
return n.update(f, (e) => [...e, r]), t.pasteRule = r, () => {
|
|
103
|
-
n.update(f, (e) => e.filter((e) => e !== r));
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
return t;
|
|
107
|
-
}
|
|
108
|
-
function se(e, t) {
|
|
109
|
-
return P(async (t, n) => {
|
|
110
|
-
await t.wait(g);
|
|
111
|
-
let r = await e(t);
|
|
112
|
-
return t.update(f, (e) => [...e, r]), n.pasteRule = r, () => {
|
|
113
|
-
t.update(f, (e) => e.filter((e) => e !== r));
|
|
114
|
-
};
|
|
115
|
-
}, s, t);
|
|
116
|
-
}
|
|
117
|
-
function R(e, t) {
|
|
118
|
-
let n = (r) => async () => {
|
|
119
|
-
let i = t(r);
|
|
120
|
-
return r.update(D, (t) => [...t.filter((t) => t[0] !== e), [e, i]]), n.id = e, n.schema = i, () => {
|
|
121
|
-
r.update(D, (t) => t.filter(([t]) => t !== e));
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
return n.type = (t) => {
|
|
125
|
-
let n = t.get(c).marks[e];
|
|
126
|
-
if (!n) throw l(e);
|
|
127
|
-
return n;
|
|
128
|
-
}, n;
|
|
129
|
-
}
|
|
130
|
-
function ce(e, t, n) {
|
|
131
|
-
let r = P(async (n, r, i) => {
|
|
132
|
-
let a = await t(n);
|
|
133
|
-
return n.update(D, (t) => [...t.filter((t) => t[0] !== e), [e, a]]), r.id = e, r.schema = a, i(), () => {
|
|
134
|
-
n.update(D, (t) => t.filter(([t]) => t !== e));
|
|
135
|
-
};
|
|
136
|
-
}, d, n);
|
|
137
|
-
return r.type = (t) => {
|
|
138
|
-
let n = t.get(c).marks[e];
|
|
139
|
-
if (!n) throw l(e);
|
|
140
|
-
return n;
|
|
141
|
-
}, r;
|
|
142
|
-
}
|
|
143
|
-
function z(e, t) {
|
|
144
|
-
let n = (r) => async () => {
|
|
145
|
-
let i = t(r);
|
|
146
|
-
return r.update(_, (t) => [...t.filter((t) => t[0] !== e), [e, i]]), n.id = e, n.schema = i, () => {
|
|
147
|
-
r.update(_, (t) => t.filter(([t]) => t !== e));
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
return n.type = (t) => {
|
|
151
|
-
let n = t.get(c).nodes[e];
|
|
152
|
-
if (!n) throw m(e);
|
|
153
|
-
return n;
|
|
154
|
-
}, n;
|
|
155
|
-
}
|
|
156
|
-
function B(e, t, n) {
|
|
157
|
-
let r = P(async (n, r, i) => {
|
|
158
|
-
let a = await t(n);
|
|
159
|
-
return n.update(_, (t) => [...t.filter((t) => t[0] !== e), [e, a]]), r.id = e, r.schema = a, i(), () => {
|
|
160
|
-
n.update(_, (t) => t.filter(([t]) => t !== e));
|
|
161
|
-
};
|
|
162
|
-
}, d, n);
|
|
163
|
-
return r.type = (t) => {
|
|
164
|
-
let n = t.get(c).nodes[e];
|
|
165
|
-
if (!n) throw m(e);
|
|
166
|
-
return n;
|
|
167
|
-
}, r;
|
|
168
|
-
}
|
|
169
|
-
function V(e) {
|
|
170
|
-
let t, n = (n) => async () => (await n.wait(g), t = e(n), n.update(O, (e) => [...e, t]), () => {
|
|
171
|
-
n.update(O, (e) => e.filter((e) => e !== t));
|
|
172
|
-
});
|
|
173
|
-
return n.plugin = () => t, n.key = () => t.spec.key, n;
|
|
174
|
-
}
|
|
175
|
-
function H(e, t) {
|
|
176
|
-
let n, r = P(async (t) => (await t.wait(g), n = await e(t), t.update(O, (e) => [...e, n]), () => {
|
|
177
|
-
t.update(O, (e) => e.filter((e) => e !== n));
|
|
178
|
-
}), v, t);
|
|
179
|
-
return r.plugin = () => n, r.key = () => n.spec.key, r;
|
|
180
|
-
}
|
|
181
|
-
function U(e) {
|
|
182
|
-
let t = (n) => async () => {
|
|
183
|
-
await n.wait(x);
|
|
184
|
-
let r = n.get(b), i = e(n), a = r.addObjectKeymap(i);
|
|
185
|
-
return t.keymap = i, () => {
|
|
186
|
-
a();
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
return t;
|
|
190
|
-
}
|
|
191
|
-
function W(e, t) {
|
|
192
|
-
return P(async (t, n) => {
|
|
193
|
-
await t.wait(x);
|
|
194
|
-
let r = t.get(b), i = await e(t), a = r.addObjectKeymap(i);
|
|
195
|
-
return n.keymap = i, () => {
|
|
196
|
-
a();
|
|
197
|
-
};
|
|
198
|
-
}, v, t);
|
|
199
|
-
}
|
|
200
|
-
function le(e, n) {
|
|
201
|
-
let r = (i) => async () => {
|
|
202
|
-
await i.wait(g);
|
|
203
|
-
let a = n(i);
|
|
204
|
-
return e.type(i) instanceof t ? i.update(A, (t) => [...t, [e.id, a]]) : i.update(h, (t) => [...t, [e.id, a]]), r.view = a, r.type = e, () => {
|
|
205
|
-
e.type(i) instanceof t ? i.update(A, (t) => t.filter((t) => t[0] !== e.id)) : i.update(h, (t) => t.filter((t) => t[0] !== e.id));
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
return r;
|
|
209
|
-
}
|
|
210
|
-
function ue(e, n, r) {
|
|
211
|
-
return P(async (r, i) => {
|
|
212
|
-
await r.wait(g);
|
|
213
|
-
let a = await n(r);
|
|
214
|
-
return e.type(r) instanceof t ? r.update(A, (t) => [...t, [e.id, a]]) : r.update(h, (t) => [...t, [e.id, a]]), i.view = a, i.type = e, () => {
|
|
215
|
-
e.type(r) instanceof t ? r.update(A, (t) => t.filter((t) => t[0] !== e.id)) : r.update(h, (t) => t.filter((t) => t[0] !== e.id));
|
|
216
|
-
};
|
|
217
|
-
}, ne, r);
|
|
218
|
-
}
|
|
219
|
-
function G(e, t) {
|
|
220
|
-
let n = ie(e, t), r = (e) => (e.inject(n), () => () => {
|
|
221
|
-
e.remove(n);
|
|
222
|
-
});
|
|
223
|
-
return r.key = n, r;
|
|
224
|
-
}
|
|
225
|
-
function K(e, t) {
|
|
226
|
-
let n = G(t, e), r = z(e, (e) => e.get(n.key)(e)), i = [n, r];
|
|
227
|
-
return i.id = r.id, i.node = r, i.type = (e) => r.type(e), i.ctx = n, i.key = n.key, i.extendSchema = (n) => K(e, n(t)), i;
|
|
228
|
-
}
|
|
229
|
-
function q(e, t) {
|
|
230
|
-
let n = G(t, e), r = R(e, (e) => e.get(n.key)(e)), i = [n, r];
|
|
231
|
-
return i.id = r.id, i.mark = r, i.type = (e) => r.type(e), i.ctx = n, i.key = n.key, i.extendSchema = (n) => q(e, n(t)), i;
|
|
232
|
-
}
|
|
233
|
-
function J(e, t) {
|
|
234
|
-
let n = G(Object.fromEntries(Object.entries(t).map(([e, { shortcuts: t, priority: n }]) => [e, {
|
|
235
|
-
shortcuts: t,
|
|
236
|
-
priority: n
|
|
237
|
-
}])), `${e}Keymap`), r = U((e) => {
|
|
238
|
-
let r = e.get(n.key), i = Object.entries(t).flatMap(([e, { command: t }]) => {
|
|
239
|
-
let n = r[e], i = [n.shortcuts].flat(), a = n.priority;
|
|
240
|
-
return i.map((e) => [e, {
|
|
241
|
-
key: e,
|
|
242
|
-
onRun: t,
|
|
243
|
-
priority: a
|
|
244
|
-
}]);
|
|
245
|
-
});
|
|
246
|
-
return Object.fromEntries(i);
|
|
247
|
-
}), i = [n, r];
|
|
248
|
-
return i.ctx = n, i.shortcuts = r, i.key = n.key, i.keymap = r.keymap, i;
|
|
249
|
-
}
|
|
250
|
-
var Y = (e, t = () => ({})) => G(t, `${e}Attr`), X = (e, t = () => ({})) => G(t, `${e}Attr`);
|
|
251
|
-
function Z(e, t, n) {
|
|
252
|
-
let r = G(n ?? {}, e), i = (e) => async () => {
|
|
253
|
-
await e.wait(re);
|
|
254
|
-
let n = {
|
|
255
|
-
plugin: t(e),
|
|
256
|
-
options: e.get(r.key)
|
|
257
|
-
};
|
|
258
|
-
return e.update(p, (e) => [...e, n]), () => {
|
|
259
|
-
e.update(p, (e) => e.filter((e) => e !== n));
|
|
260
|
-
};
|
|
261
|
-
}, a = [r, i];
|
|
262
|
-
return a.id = e, a.plugin = i, a.options = r, a;
|
|
263
|
-
}
|
|
264
|
-
function de(e, t) {
|
|
265
|
-
return (n) => n.get(w).call(e, t);
|
|
266
|
-
}
|
|
267
|
-
function fe() {
|
|
268
|
-
return (e) => {
|
|
269
|
-
let t = e.get(y), { tr: n } = t.state, r = Object.assign(Object.create(n), n).setTime(Date.now());
|
|
270
|
-
return t.dispatch(r);
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
function pe() {
|
|
274
|
-
return (e) => {
|
|
275
|
-
let t = document.createElement("div"), r = e.get(c), i = e.get(y), a = n.fromSchema(r).serializeFragment(i.state.doc.content);
|
|
276
|
-
return t.appendChild(a), t.innerHTML;
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function me(e) {
|
|
280
|
-
return (t) => {
|
|
281
|
-
let n = t.get(y), r = t.get(c), i = t.get(te);
|
|
282
|
-
if (!e) return i(n.state.doc);
|
|
283
|
-
let a = n.state.doc.slice(e.from, e.to, !0), o = r.topNodeType.createAndFill(null, a.content);
|
|
284
|
-
return o ? i(o) : (console.error("No document found"), "");
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
function Q(e, t = !1) {
|
|
288
|
-
return (i) => {
|
|
289
|
-
let o = i.get(y), s = i.get(k)(e);
|
|
290
|
-
if (!s) return;
|
|
291
|
-
if (!t) {
|
|
292
|
-
let e = o.state.selection.content();
|
|
293
|
-
return o.dispatch(o.state.tr.replaceSelection(new r(s.content, e.openStart, e.openEnd)).scrollIntoView());
|
|
294
|
-
}
|
|
295
|
-
let l = i.get(c), d = n.fromSchema(l).serializeFragment(s.content), f = a.fromSchema(l).parseSlice(d), p = u(f);
|
|
296
|
-
if (p) {
|
|
297
|
-
o.dispatch(o.state.tr.replaceSelectionWith(p, !0));
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
o.dispatch(o.state.tr.replaceSelection(f));
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
function he() {
|
|
304
|
-
return (e) => {
|
|
305
|
-
let t = e.get(y), n = [];
|
|
306
|
-
return t.state.doc.descendants((e) => {
|
|
307
|
-
e.type.name === "heading" && e.attrs.level && n.push({
|
|
308
|
-
text: e.textContent,
|
|
309
|
-
level: e.attrs.level,
|
|
310
|
-
id: e.attrs.id
|
|
311
|
-
});
|
|
312
|
-
}), n;
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
function ge(e, t = !1) {
|
|
316
|
-
return (n) => {
|
|
317
|
-
let a = n.get(y), o = n.get(k)(e);
|
|
318
|
-
if (!o) return;
|
|
319
|
-
if (!t) {
|
|
320
|
-
let { state: e } = a;
|
|
321
|
-
return a.dispatch(e.tr.replace(0, e.doc.content.size, new r(o.content, 0, 0)));
|
|
322
|
-
}
|
|
323
|
-
let s = n.get(c), l = n.get(E)({
|
|
324
|
-
schema: s,
|
|
325
|
-
doc: o,
|
|
326
|
-
plugins: n.get(O)
|
|
327
|
-
}), u = i.create(l);
|
|
328
|
-
a.updateState(u);
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
function _e(e, t) {
|
|
332
|
-
return (n) => {
|
|
333
|
-
let r = n.get(y), { tr: i } = r.state, a = i.doc.nodeAt(e);
|
|
334
|
-
if (!a) return;
|
|
335
|
-
let o = t(a.attrs);
|
|
336
|
-
return r.dispatch(i.setNodeMarkup(e, void 0, o));
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
function $(e) {
|
|
340
|
-
return (t) => {
|
|
341
|
-
let r = t.get(k)(e), i = t.get(c), o = n.fromSchema(i).serializeFragment(r.content);
|
|
342
|
-
return a.fromSchema(i).parseSlice(o);
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
function ve(e, t, n = !1) {
|
|
346
|
-
return (r) => {
|
|
347
|
-
let i = $(e)(r), a = r.get(y), o = a.state.doc.resolve(t), s = a.state.doc.content.size, c = n ? o.pos : o.after(o.depth - 1), l = Math.min(Math.max(c, 0), s);
|
|
348
|
-
a.dispatch(a.state.tr.replace(c, l, i));
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
function ye(e, t) {
|
|
352
|
-
return (n) => {
|
|
353
|
-
let r = n.get(y), i = $(e)(n);
|
|
354
|
-
r.dispatch(r.state.tr.replace(t.from, t.to, i));
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
var be = (...e) => {
|
|
358
|
-
let t = e.length, n = t;
|
|
359
|
-
for (; n--;) if (typeof e[n] != "function") throw TypeError("Expected a function");
|
|
360
|
-
return (...n) => {
|
|
361
|
-
let r = 0, i = t ? e[r](...n) : n[0];
|
|
362
|
-
for (; ++r < t;) i = e[r](i);
|
|
363
|
-
return i;
|
|
364
|
-
};
|
|
365
|
-
};
|
|
366
|
-
//#endregion
|
|
367
|
-
export { q as a, K as c, Z as d, J as f, X as i, L as l, G as n, z as o, M as p, I as r, Y as s, F as t, V as u };
|
package/dist/lib-IahjxPWM.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
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}});
|