zt-react-milkdown 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +4 -0
  2. package/dist/index.cjs +88 -36
  3. package/dist/index.mjs +24647 -4893
  4. package/dist/src/core/createEditor.d.ts +44 -3
  5. package/dist/src/core/createEditor.d.ts.map +1 -1
  6. package/dist/src/index.d.ts +1 -1
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/plugins/custom/block-transform/block-transform.d.ts.map +1 -1
  9. package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts.map +1 -1
  10. package/dist/src/plugins/custom/image/image-resizable-schema.d.ts.map +1 -1
  11. package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts.map +1 -1
  12. package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -1
  13. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +2 -0
  14. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -1
  15. package/dist/src/plugins/custom/selection-tooltip/types.d.ts +2 -0
  16. package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -1
  17. package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -1
  18. package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts +1 -1
  19. package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -1
  20. package/dist/src/plugins/custom/table/table-focus-actions.d.ts.map +1 -1
  21. package/dist/src/plugins/custom/table/table-more-actions.d.ts +2 -0
  22. package/dist/src/plugins/custom/table/table-more-actions.d.ts.map +1 -1
  23. package/dist/src/react/components/MilkdownEditor.d.ts.map +1 -1
  24. package/dist/src/react/hooks/useMilkdownEditor.d.ts +3 -3
  25. package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -1
  26. package/dist/src/types/editor.d.ts +0 -34
  27. package/dist/src/types/editor.d.ts.map +1 -1
  28. package/dist/style.css +1 -1
  29. package/package.json +1 -1
  30. package/dist/commands-BJpevWrH.js +0 -409
  31. package/dist/commands-BmZHd6RL.js +0 -2
  32. package/dist/commands-CM7IuhpT.cjs +0 -2
  33. package/dist/commands-f4yOm8DQ.cjs +0 -1
  34. package/dist/debounce-C_TNzOFT.cjs +0 -1
  35. package/dist/debounce-Z8-khnlZ.js +0 -118
  36. package/dist/dist-BjfIurm0.js +0 -1584
  37. package/dist/dist-CLTsQjPD.js +0 -3500
  38. package/dist/dist-D7LE16E1.cjs +0 -1
  39. package/dist/dist-DQnWlYyo.cjs +0 -5
  40. package/dist/floating-ui.dom-B_oXwL6O.cjs +0 -1
  41. package/dist/floating-ui.dom-Cm9Ov61_.js +0 -883
  42. package/dist/lib-5lx86j_L.js +0 -21
  43. package/dist/lib-72N1aRae.js +0 -1884
  44. package/dist/lib-BIxqp3lX.js +0 -387
  45. package/dist/lib-BLTQkf4j.cjs +0 -39
  46. package/dist/lib-BzlEyehQ.cjs +0 -5
  47. package/dist/lib-C61-3fwS.cjs +0 -1
  48. package/dist/lib-C82poHMJ.cjs +0 -1
  49. package/dist/lib-CDhjYvDm.js +0 -74
  50. package/dist/lib-CHQUpMrL.cjs +0 -3
  51. package/dist/lib-CYWwNE4c.js +0 -8673
  52. package/dist/lib-Cixz93sP.js +0 -2222
  53. package/dist/lib-CqJFV3ME.cjs +0 -1
  54. package/dist/lib-D7VWCO2M.cjs +0 -4
  55. package/dist/lib-DaPs62nF.js +0 -28
  56. package/dist/lib-Dka_BhhQ.cjs +0 -1
  57. package/dist/lib-DrllUeuK.cjs +0 -1
  58. package/dist/lib-wpjVX5Vf.js +0 -80
  59. package/dist/lib-z6CKD87x.js +0 -331
  60. package/dist/schema-list-CFEw5DQ8.cjs +0 -1
  61. package/dist/schema-list-CiFfAlj-.js +0 -110
  62. package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts +0 -5
  63. package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts.map +0 -1
  64. package/dist/state-BC1dqWPQ.cjs +0 -1
  65. package/dist/state-BvRk9kiK.cjs +0 -0
  66. package/dist/state-BvRk9kiK.js +0 -0
  67. package/dist/state-rTW_1XVf.js +0 -3
@@ -1 +0,0 @@
1
- const e=require("./lib-BLTQkf4j.cjs"),t=require("./dist-DQnWlYyo.cjs");var n=e=>crypto.getRandomValues(new Uint8Array(e)),r=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(1.6*256*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}},i=(e,t=21)=>r(e,t|0,n),a=e.xt({$command:()=>c,$commandAsync:()=>l,$ctx:()=>w,$inputRule:()=>u,$inputRuleAsync:()=>d,$mark:()=>m,$markAsync:()=>h,$markAttr:()=>k,$markSchema:()=>E,$node:()=>g,$nodeAsync:()=>_,$nodeAttr:()=>O,$nodeSchema:()=>T,$pasteRule:()=>f,$pasteRuleAsync:()=>p,$prose:()=>v,$proseAsync:()=>y,$remark:()=>A,$shortcut:()=>b,$shortcutAsync:()=>x,$useKeymap:()=>D,$view:()=>S,$viewAsync:()=>C,addTimer:()=>s,callCommand:()=>j,forceUpdate:()=>M,getHTML:()=>N,getMarkdown:()=>P,insert:()=>F,insertPos:()=>B,markdownToSlice:()=>z,nanoid:()=>o,outline:()=>I,pipe:()=>H,replaceAll:()=>L,replaceRange:()=>V,setAttr:()=>R}),o=i(`abcedfghicklmn`,10);function s(t,n,r){let i=e._t(r||o()),a=!1,s=e=>(e.record(i),e.update(n,e=>e.concat(i)),async()=>{let r=await t(e,s,()=>{e.done(i),a=!0});return a||e.done(i),()=>{if(e.update(n,e=>e.filter(e=>e!==i)),e.clearTimer(i),r){let e=r();e&&`then`in e&&e.catch(console.error)}}});return s.timer=i,s}function c(t,n){let r=e.l(t),i=a=>async()=>{i.key=r,await a.wait(e.t);let o=n(a);return a.get(e.s).create(r,o),i.run=n=>a.get(e.s).call(t,n),()=>{a.get(e.s).remove(r)}};return i}function l(t,n,r){let i=e.l(t);return s(async(r,a)=>{await r.wait(e.t);let o=await n(r);return r.get(e.s).create(i,o),a.run=n=>r.get(e.s).call(t,n),a.key=i,()=>{r.get(e.s).remove(i)}},e.c,r)}function u(t){let n=r=>async()=>{await r.wait(e.a);let i=t(r);return r.update(e.h,e=>[...e,i]),n.inputRule=i,()=>{r.update(e.h,e=>e.filter(e=>e!==i))}};return n}function d(t,n){return s(async(n,r)=>{await n.wait(e.a);let i=await t(n);return n.update(e.h,e=>[...e,i]),r.inputRule=i,()=>{n.update(e.h,e=>e.filter(e=>e!==i))}},e.d,n)}function f(t){let n=r=>async()=>{await r.wait(e.a);let i=t(r);return r.update(e.C,e=>[...e,i]),n.pasteRule=i,()=>{r.update(e.C,e=>e.filter(e=>e!==i))}};return n}function p(t,n){return s(async(n,r)=>{await n.wait(e.a);let i=await t(n);return n.update(e.C,e=>[...e,i]),r.pasteRule=i,()=>{n.update(e.C,e=>e.filter(e=>e!==i))}},e.w,n)}function m(t,n){let r=i=>async()=>{let a=n(i);return i.update(e.y,e=>[...e.filter(e=>e[0]!==t),[t,a]]),r.id=t,r.schema=a,()=>{i.update(e.y,e=>e.filter(([e])=>e!==t))}};return r.type=n=>{let r=n.get(e.O).marks[t];if(!r)throw e.yt(t);return r},r}function h(t,n,r){let i=s(async(r,i,a)=>{let o=await n(r);return r.update(e.y,e=>[...e.filter(e=>e[0]!==t),[t,o]]),i.id=t,i.schema=o,a(),()=>{r.update(e.y,e=>e.filter(([e])=>e!==t))}},e.k,r);return i.type=n=>{let r=n.get(e.O).marks[t];if(!r)throw e.yt(t);return r},i}function g(t,n){let r=i=>async()=>{let a=n(i);return i.update(e.x,e=>[...e.filter(e=>e[0]!==t),[t,a]]),r.id=t,r.schema=a,()=>{i.update(e.x,e=>e.filter(([e])=>e!==t))}};return r.type=n=>{let r=n.get(e.O).nodes[t];if(!r)throw e.bt(t);return r},r}function _(t,n,r){let i=s(async(r,i,a)=>{let o=await n(r);return r.update(e.x,e=>[...e.filter(e=>e[0]!==t),[t,o]]),i.id=t,i.schema=o,a(),()=>{r.update(e.x,e=>e.filter(([e])=>e!==t))}},e.k,r);return i.type=n=>{let r=n.get(e.O).nodes[t];if(!r)throw e.bt(t);return r},i}function v(t){let n,r=r=>async()=>(await r.wait(e.a),n=t(r),r.update(e.T,e=>[...e,n]),()=>{r.update(e.T,e=>e.filter(e=>e!==n))});return r.plugin=()=>n,r.key=()=>n.spec.key,r}function y(t,n){let r,i=s(async n=>(await n.wait(e.a),r=await t(n),n.update(e.T,e=>[...e,r]),()=>{n.update(e.T,e=>e.filter(e=>e!==r))}),e.d,n);return i.plugin=()=>r,i.key=()=>r.spec.key,i}function b(t){let n=r=>async()=>{await r.wait(e.i);let i=r.get(e.g),a=t(r),o=i.addObjectKeymap(a);return n.keymap=a,()=>{o()}};return n}function x(t,n){return s(async(n,r)=>{await n.wait(e.i);let i=n.get(e.g),a=await t(n),o=i.addObjectKeymap(a);return r.keymap=a,()=>{o()}},e.d,n)}function S(n,r){let i=a=>async()=>{await a.wait(e.a);let o=r(a);return n.type(a)instanceof t.O?a.update(e.b,e=>[...e,[n.id,o]]):a.update(e.v,e=>[...e,[n.id,o]]),i.view=o,i.type=n,()=>{n.type(a)instanceof t.O?a.update(e.b,e=>e.filter(e=>e[0]!==n.id)):a.update(e.v,e=>e.filter(e=>e[0]!==n.id))}};return i}function C(n,r,i){return s(async(i,a)=>{await i.wait(e.a);let o=await r(i);return n.type(i)instanceof t.O?i.update(e.b,e=>[...e,[n.id,o]]):i.update(e.v,e=>[...e,[n.id,o]]),a.view=o,a.type=n,()=>{n.type(i)instanceof t.O?i.update(e.b,e=>e.filter(e=>e[0]!==n.id)):i.update(e.v,e=>e.filter(e=>e[0]!==n.id))}},e.m,i)}function w(t,n){let r=e.gt(t,n),i=e=>(e.inject(r),()=>()=>{e.remove(r)});return i.key=r,i}function T(e,t){let n=w(t,e),r=g(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=>T(e,n(t)),i}function E(e,t){let n=w(t,e),r=m(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=>E(e,n(t)),i}function D(e,t){let n=w(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=b(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 O=(e,t=()=>({}))=>w(t,`${e}Attr`),k=(e,t=()=>({}))=>w(t,`${e}Attr`);function A(t,n,r){let i=w(r??{},t),a=t=>async()=>{await t.wait(e.r);let r={plugin:n(t),options:t.get(i.key)};return t.update(e.E,e=>[...e,r]),()=>{t.update(e.E,e=>e.filter(e=>e!==r))}},o=[i,a];return o.id=t,o.plugin=a,o.options=i,o}function j(t,n){return r=>r.get(e.s).call(t,n)}function M(){return t=>{let n=t.get(e.f),{tr:r}=n.state,i=Object.assign(Object.create(r),r).setTime(Date.now());return n.dispatch(i)}}function N(){return n=>{let r=document.createElement(`div`),i=n.get(e.O),a=n.get(e.f),o=t.C.fromSchema(i).serializeFragment(a.state.doc.content);return r.appendChild(o),r.innerHTML}}function P(t){return n=>{let r=n.get(e.f),i=n.get(e.O),a=n.get(e.A);if(!t)return a(r.state.doc);let o=r.state.doc.slice(t.from,t.to,!0),s=i.topNodeType.createAndFill(null,o.content);return s?a(s):(console.error(`No document found`),``)}}function F(n,r=!1){return i=>{let a=i.get(e.f),o=i.get(e.S)(n);if(!o)return;if(!r){let e=a.state.selection.content();return a.dispatch(a.state.tr.replaceSelection(new t.A(o.content,e.openStart,e.openEnd)).scrollIntoView())}let s=i.get(e.O),c=t.C.fromSchema(s).serializeFragment(o.content),l=t.S.fromSchema(s).parseSlice(c),u=e.V(l);if(u){a.dispatch(a.state.tr.replaceSelectionWith(u,!0));return}a.dispatch(a.state.tr.replaceSelection(l))}}function I(){return t=>{let n=t.get(e.f),r=[];return n.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 L(n,r=!1){return i=>{let a=i.get(e.f),o=i.get(e.S)(n);if(!o)return;if(!r){let{state:e}=a;return a.dispatch(e.tr.replace(0,e.doc.content.size,new t.A(o.content,0,0)))}let s=i.get(e.O),c=i.get(e.u)({schema:s,doc:o,plugins:i.get(e.T)}),l=t.n.create(c);a.updateState(l)}}function R(t,n){return r=>{let i=r.get(e.f),{tr:a}=i.state,o=a.doc.nodeAt(t);if(!o)return;let s=n(o.attrs);return i.dispatch(a.setNodeMarkup(t,void 0,s))}}function z(n){return r=>{let i=r.get(e.S)(n),a=r.get(e.O),o=t.C.fromSchema(a).serializeFragment(i.content);return t.S.fromSchema(a).parseSlice(o)}}function B(t,n,r=!1){return i=>{let a=z(t)(i),o=i.get(e.f),s=o.state.doc.resolve(n),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 V(t,n){return r=>{let i=r.get(e.f),a=z(t)(r);i.dispatch(i.state.tr.replace(n.from,n.to,a))}}var H=(...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 E}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return v}});
@@ -1,4 +0,0 @@
1
- const e=require("./lib-BLTQkf4j.cjs"),t=require("./dist-DQnWlYyo.cjs"),n=require("./lib-CqJFV3ME.cjs");function r(e){if(!e)return!1;if(Array.isArray(e))return e.length>1?!1:r(e[0]);let t=e.content;return t?r(t):e.type===`text`}function i(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-clipboard`,...t}}),e}function a(t,n){let r=e.V(n);if(r)return t.dispatch(t.state.tr.replaceSelectionWith(r,!0)),!0;try{return t.dispatch(t.state.tr.replaceSelection(n)),!0}catch{return!1}}var o=n.u(n=>{let i=n.get(e.O);return n.update(e.p,e=>({...e,editable:e.editable??(()=>!0),transformPastedHTML:(t,n)=>{let r=e.transformPastedHTML;return r&&(t=r(t,n)),t.includes(`docs-internal-guid`)&&(t=t.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,`$1`),t=t.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,`$1`)),t}})),new t.i({key:new t.a(`MILKDOWN_CLIPBOARD`),props:{handlePaste:(r,o,s)=>{let c=n.get(e.S),l=r.props.editable?.(r.state),{clipboardData:u}=o;if(!l||!u||r.state.selection.$from.node().type.spec.code)return!1;let d=u.getData(`text/plain`),f=u.getData(`vscode-editor-data`);if(f){let n=JSON.parse(f)?.mode;if(d&&n){let{tr:a}=r.state,o=e.B(`code_block`,i);return a.replaceSelectionWith(o.create({language:n})).setSelection(t.c.near(a.doc.resolve(Math.max(0,a.selection.from-2)))).insertText(d.replace(/\r\n?/g,`
2
- `)),r.dispatch(a),!0}}let p=u.getData(`text/html`);if(p.length===0&&d.length===0)return!1;if(p.length>0&&s)return a(r,s);let m=t.S.fromSchema(i),h;if(p.length===0){let e=c(d);if(!e||typeof e==`string`)return!1;h=t.C.fromSchema(i).serializeFragment(e.content)}else{let e=document.createElement(`template`);e.innerHTML=p,h=e.content.cloneNode(!0),e.remove()}return a(r,m.parseSlice(h))},clipboardTextSerializer:t=>{let a=n.get(e.A);if(r(t.content.toJSON()))return t.content.textBetween(0,t.content.size,`
3
-
4
- `);let o=i.topNodeType.createAndFill(void 0,t.content);return o?a(o):``}}})});i(o,{displayName:`Prose<clipboard>`}),exports.clipboard=o;
@@ -1,28 +0,0 @@
1
- import { c as e, t } from "./dist-CLTsQjPD.js";
2
- import { f as n, n as r } from "./lib-BIxqp3lX.js";
3
- //#region node_modules/.pnpm/@milkdown+plugin-indent@7.21.1/node_modules/@milkdown/plugin-indent/lib/index.js
4
- function i(n, r) {
5
- let { doc: i, selection: a } = n;
6
- if (!i || !a || !(a instanceof e || a instanceof t)) return n;
7
- let { to: o } = a, s = r.type === "space" ? Array(r.size).fill(" ").join("") : " ";
8
- return n.insertText(s, o);
9
- }
10
- var a = r({
11
- type: "space",
12
- size: 2
13
- }, "indentConfig");
14
- a.meta = {
15
- package: "@milkdown/plugin-indent",
16
- displayName: "Ctx<indentConfig>"
17
- };
18
- var o = n((e) => ({ Tab: (t, n) => {
19
- let r = e.get(a.key), { tr: o } = t, s = i(o, r);
20
- return s.docChanged ? (n?.(s), !0) : !1;
21
- } }));
22
- o.meta = {
23
- package: "@milkdown/plugin-indent",
24
- displayName: "Shortcut<indent>"
25
- };
26
- var s = [a, o];
27
- //#endregion
28
- export { s as indent, a as indentConfig, o as indentPlugin };
@@ -1 +0,0 @@
1
- const e=require("./dist-DQnWlYyo.cjs"),t=require("./lib-CqJFV3ME.cjs");function n(n){let r=t.n({},`${n}_SLASH_SPEC`),i=t.u(t=>{let i=t.get(r.key);return new e.i({key:new e.a(`${n}_SLASH`),...i})}),a=[r,i];return a.key=r.key,a.pluginKey=i.key,r.meta={package:`@milkdown/plugin-slash`,displayName:`Ctx<slashSpec>|${n}`},i.meta={package:`@milkdown/plugin-slash`,displayName:`Prose<slash>|${n}`},a}exports.slashFactory=n;
@@ -1 +0,0 @@
1
- const e=require("./lib-BLTQkf4j.cjs"),t=require("./dist-DQnWlYyo.cjs"),n=require("./lib-CqJFV3ME.cjs");var r=200,i=function(){};i.prototype.append=function(e){return e.length?(e=i.from(e),!this.length&&e||e.length<r&&this.leafAppend(e)||this.length<r&&e.leafPrepend(this)||this.appendInner(e)):this},i.prototype.prepend=function(e){return e.length?i.from(e).append(this):this},i.prototype.appendInner=function(e){return new o(this,e)},i.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?i.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},i.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},i.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},i.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},i.from=function(e){return e instanceof i?e:e&&e.length?new a(e):i.empty};var a=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=r)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=r)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(i);i.empty=new a([]);var o=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(i),s=500,c=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],d=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,d.push(t);return}if(i){d.push(new u(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new u(n,void 0,void 0,l.length+d.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(d.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new u(t.mapping.maps[e],r,n),d;(d=c&&c.merge(l))&&(l=d,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let d=o-r.depth;return d>f&&(s=l(s,d),o-=d),new e(s.append(a),o)}remapping(e,n){let r=new t.d;return this.items.forEach((t,n)=>{let i=t.mirrorOffset!=null&&n-t.mirrorOffset>=e?r.maps.length-t.mirrorOffset:void 0;r.appendMap(t.map,i)},e,n),r}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new u(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,c=this.eventCount;this.items.forEach(e=>{e.selection&&c--},i);let l=n;this.items.forEach(e=>{let n=a.getMirror(--l);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),s=e.selection&&e.selection.map(a.slice(l+1,n));s&&c++,r.push(new u(i,o,s))}else r.push(new u(i))},i);let d=[];for(let e=n;e<o;e++)d.push(new u(a.maps[e]));let f=new e(this.items.slice(0,i).append(d).append(r),c);return f.emptyItemCount()>s&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,a=[],o=0;return this.items.forEach((e,i)=>{if(i>=t)a.push(e),e.selection&&o++;else if(e.step){let t=e.step.map(n.slice(r)),i=t&&t.getMap();if(r--,i&&n.appendMap(i,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&o++;let c=new u(i.invert(),t,s),l,d=a.length-1;(l=a.length&&a[d].merge(c))?a[d]=l:a.push(c)}}else e.map&&r--},this.items.length,0),new e(i.from(a.reverse()),o)}};c.empty=new c(i.empty,0);function l(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var u=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},d=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},f=20;function p(e,t,n,r){let i=n.getMeta(x),a;if(i)return i.historyState;n.getMeta(S)&&(e=new d(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(x))return o.getMeta(x).redo?new d(e.done.addTransform(n,void 0,r,b(t)),e.undone,h(n.mapping.maps),e.prevTime,e.prevComposition):new d(e.done,e.undone.addTransform(n,void 0,r,b(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!m(n,e.prevRanges)),s=o?g(e.prevRanges,n.mapping):h(n.mapping.maps);return new d(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,b(t)),c.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new d(e.done.rebased(n,a),e.undone.rebased(n,a),g(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new d(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),g(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function m(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function h(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function g(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function _(e,t,n){let r=b(t),i=x.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new d(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(x,{redo:n,historyState:c})}var v=!1,y=null;function b(e){let t=e.plugins;if(y!=t){v=!1,y=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){v=!0;break}}return v}var x=new t.a(`history`),S=new t.a(`closeHistory`);function C(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new t.i({key:x,state:{init(){return new d(c.empty,c.empty,null,0,-1)},apply(t,n,r){return p(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?T:n==`historyRedo`?E:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function w(e,t){return(n,r)=>{let i=x.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=_(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var T=w(!1,!0),E=w(!0,!0);function D(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-history`,...t}}),e}var O=n.t(`Undo`,()=>()=>T);D(O,{displayName:`Command<undo>`});var k=n.t(`Redo`,()=>()=>E);D(k,{displayName:`Command<redo>`});var A=n.n({},`historyProviderConfig`);D(A,{displayName:`Ctx<historyProviderConfig>`});var j=n.u(e=>C(e.get(A.key)));D(j,{displayName:`Ctx<historyProviderPlugin>`});var M=n.p(`historyKeymap`,{Undo:{shortcuts:`Mod-z`,command:t=>{let n=t.get(e.s);return()=>n.call(O.key)}},Redo:{shortcuts:[`Mod-y`,`Shift-Mod-z`],command:t=>{let n=t.get(e.s);return()=>n.call(k.key)}}});D(M.ctx,{displayName:`KeymapCtx<history>`}),D(M.shortcuts,{displayName:`Keymap<history>`});var N=[A,j,M,O,k].flat();exports.history=N,exports.historyKeymap=M,exports.historyProviderConfig=A,exports.historyProviderPlugin=j,exports.redoCommand=k,exports.undoCommand=O;
@@ -1,80 +0,0 @@
1
- import { A as e, T as t, gt as n, n as r, o as i, r as a } from "./lib-CYWwNE4c.js";
2
- import { a as o, i as s } from "./dist-CLTsQjPD.js";
3
- import { t as c } from "./debounce-Z8-khnlZ.js";
4
- //#region node_modules/.pnpm/@milkdown+plugin-listener@7.21.1/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 = n(new l(), "listener"), d = new o("MILKDOWN_LISTENER"), f = (n) => (n.inject(u, new l()), async () => {
37
- await n.wait(a);
38
- let { listeners: o } = n.get(u);
39
- o.beforeMount.forEach((e) => e(n)), await n.wait(i);
40
- let l = n.get(e), f = null, p = null, m = null, h = null, g = c(() => {
41
- if (!h) return;
42
- let { doc: e } = h;
43
- if (o.updated.length > 0 && f && !f.eq(e) && o.updated.forEach((t) => {
44
- t(n, e, f);
45
- }), o.markdownUpdated.length > 0 && f && !f.eq(e)) {
46
- let t = l(e);
47
- o.markdownUpdated.forEach((e) => {
48
- e(n, t, p);
49
- }), p = t;
50
- }
51
- f = e, h = null;
52
- }, 200), _ = new s({
53
- key: d,
54
- view: () => ({ destroy: () => {
55
- o.destroy.forEach((e) => e(n));
56
- } }),
57
- props: { handleDOMEvents: {
58
- focus: () => (o.focus.forEach((e) => e(n)), !1),
59
- blur: () => (o.blur.forEach((e) => e(n)), !1)
60
- } },
61
- state: {
62
- init: (e, t) => {
63
- f = t.doc, p = l(t.doc);
64
- },
65
- apply: (e) => {
66
- let t = e.selection;
67
- (!m && t || m && !t.eq(m)) && (o.selectionUpdated.forEach((e) => {
68
- e(n, t, m);
69
- }), m = t), !(!(e.docChanged || e.storedMarksSet) || e.getMeta("addToHistory") === !1) && (h = e, g());
70
- }
71
- }
72
- });
73
- n.update(t, (e) => e.concat(_)), await n.wait(r), o.mounted.forEach((e) => e(n));
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 };
@@ -1,331 +0,0 @@
1
- import { s as e } from "./lib-CYWwNE4c.js";
2
- import { a as t, d as n, i as r } from "./dist-CLTsQjPD.js";
3
- import { n as i, p as a, t as o, u as s } from "./lib-BIxqp3lX.js";
4
- //#region node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.js
5
- var c = 200, l = function() {};
6
- l.prototype.append = function(e) {
7
- return e.length ? (e = l.from(e), !this.length && e || e.length < c && this.leafAppend(e) || this.length < c && e.leafPrepend(this) || this.appendInner(e)) : this;
8
- }, l.prototype.prepend = function(e) {
9
- return e.length ? l.from(e).append(this) : this;
10
- }, l.prototype.appendInner = function(e) {
11
- return new d(this, e);
12
- }, l.prototype.slice = function(e, t) {
13
- return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? l.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
14
- }, l.prototype.get = function(e) {
15
- if (!(e < 0 || e >= this.length)) return this.getInner(e);
16
- }, l.prototype.forEach = function(e, t, n) {
17
- t === void 0 && (t = 0), n === void 0 && (n = this.length), t <= n ? this.forEachInner(e, t, n, 0) : this.forEachInvertedInner(e, t, n, 0);
18
- }, l.prototype.map = function(e, t, n) {
19
- t === void 0 && (t = 0), n === void 0 && (n = this.length);
20
- var r = [];
21
- return this.forEach(function(t, n) {
22
- return r.push(e(t, n));
23
- }, t, n), r;
24
- }, l.from = function(e) {
25
- return e instanceof l ? e : e && e.length ? new u(e) : l.empty;
26
- };
27
- var u = /* @__PURE__ */ function(e) {
28
- function t(t) {
29
- e.call(this), this.values = t;
30
- }
31
- e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t;
32
- var n = {
33
- length: { configurable: !0 },
34
- depth: { configurable: !0 }
35
- };
36
- return t.prototype.flatten = function() {
37
- return this.values;
38
- }, t.prototype.sliceInner = function(e, n) {
39
- return e == 0 && n == this.length ? this : new t(this.values.slice(e, n));
40
- }, t.prototype.getInner = function(e) {
41
- return this.values[e];
42
- }, t.prototype.forEachInner = function(e, t, n, r) {
43
- for (var i = t; i < n; i++) if (e(this.values[i], r + i) === !1) return !1;
44
- }, t.prototype.forEachInvertedInner = function(e, t, n, r) {
45
- for (var i = t - 1; i >= n; i--) if (e(this.values[i], r + i) === !1) return !1;
46
- }, t.prototype.leafAppend = function(e) {
47
- if (this.length + e.length <= c) return new t(this.values.concat(e.flatten()));
48
- }, t.prototype.leafPrepend = function(e) {
49
- if (this.length + e.length <= c) return new t(e.flatten().concat(this.values));
50
- }, n.length.get = function() {
51
- return this.values.length;
52
- }, n.depth.get = function() {
53
- return 0;
54
- }, Object.defineProperties(t.prototype, n), t;
55
- }(l);
56
- l.empty = new u([]);
57
- var d = /* @__PURE__ */ function(e) {
58
- function t(t, n) {
59
- e.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1;
60
- }
61
- return e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t, t.prototype.flatten = function() {
62
- return this.left.flatten().concat(this.right.flatten());
63
- }, t.prototype.getInner = function(e) {
64
- return e < this.left.length ? this.left.get(e) : this.right.get(e - this.left.length);
65
- }, t.prototype.forEachInner = function(e, t, n, r) {
66
- var i = this.left.length;
67
- if (t < i && this.left.forEachInner(e, t, Math.min(n, i), r) === !1 || n > i && this.right.forEachInner(e, Math.max(t - i, 0), Math.min(this.length, n) - i, r + i) === !1) return !1;
68
- }, t.prototype.forEachInvertedInner = function(e, t, n, r) {
69
- var i = this.left.length;
70
- if (t > i && this.right.forEachInvertedInner(e, t - i, Math.max(n, i) - i, r + i) === !1 || n < i && this.left.forEachInvertedInner(e, Math.min(t, i), n, r) === !1) return !1;
71
- }, t.prototype.sliceInner = function(e, t) {
72
- if (e == 0 && t == this.length) return this;
73
- var n = this.left.length;
74
- return t <= n ? this.left.slice(e, t) : e >= n ? this.right.slice(e - n, t - n) : this.left.slice(e, n).append(this.right.slice(0, t - n));
75
- }, t.prototype.leafAppend = function(e) {
76
- var n = this.right.leafAppend(e);
77
- if (n) return new t(this.left, n);
78
- }, t.prototype.leafPrepend = function(e) {
79
- var n = this.left.leafPrepend(e);
80
- if (n) return new t(n, this.right);
81
- }, t.prototype.appendInner = function(e) {
82
- return this.left.depth >= Math.max(this.right.depth, e.depth) + 1 ? new t(this.left, new t(this.right, e)) : new t(this, e);
83
- }, t;
84
- }(l), f = 500, p = class e {
85
- constructor(e, t) {
86
- this.items = e, this.eventCount = t;
87
- }
88
- popEvent(t, n) {
89
- if (this.eventCount == 0) return null;
90
- let r = this.items.length;
91
- for (;; r--) if (this.items.get(r - 1).selection) {
92
- --r;
93
- break;
94
- }
95
- let i, a;
96
- n && (i = this.remapping(r, this.items.length), a = i.maps.length);
97
- let o = t.tr, s, c, l = [], u = [];
98
- return this.items.forEach((t, n) => {
99
- if (!t.step) {
100
- i || (i = this.remapping(r, n + 1), a = i.maps.length), a--, u.push(t);
101
- return;
102
- }
103
- if (i) {
104
- u.push(new h(t.map));
105
- let e = t.step.map(i.slice(a)), n;
106
- e && o.maybeStep(e).doc && (n = o.mapping.maps[o.mapping.maps.length - 1], l.push(new h(n, void 0, void 0, l.length + u.length))), a--, n && i.appendMap(n, a);
107
- } else o.maybeStep(t.step);
108
- if (t.selection) return s = i ? t.selection.map(i.slice(a)) : t.selection, c = new e(this.items.slice(0, r).append(u.reverse().concat(l)), this.eventCount - 1), !1;
109
- }, this.items.length, 0), {
110
- remaining: c,
111
- transform: o,
112
- selection: s
113
- };
114
- }
115
- addTransform(t, n, r, i) {
116
- let a = [], o = this.eventCount, s = this.items, c = !i && s.length ? s.get(s.length - 1) : null;
117
- for (let e = 0; e < t.steps.length; e++) {
118
- let r = t.steps[e].invert(t.docs[e]), l = new h(t.mapping.maps[e], r, n), u;
119
- (u = c && c.merge(l)) && (l = u, e ? a.pop() : s = s.slice(0, s.length - 1)), a.push(l), n &&= (o++, void 0), i || (c = l);
120
- }
121
- let l = o - r.depth;
122
- return l > _ && (s = m(s, l), o -= l), new e(s.append(a), o);
123
- }
124
- remapping(e, t) {
125
- let r = new n();
126
- return this.items.forEach((t, n) => {
127
- let i = t.mirrorOffset != null && n - t.mirrorOffset >= e ? r.maps.length - t.mirrorOffset : void 0;
128
- r.appendMap(t.map, i);
129
- }, e, t), r;
130
- }
131
- addMaps(t) {
132
- return this.eventCount == 0 ? this : new e(this.items.append(t.map((e) => new h(e))), this.eventCount);
133
- }
134
- rebased(t, n) {
135
- if (!this.eventCount) return this;
136
- let r = [], i = Math.max(0, this.items.length - n), a = t.mapping, o = t.steps.length, s = this.eventCount;
137
- this.items.forEach((e) => {
138
- e.selection && s--;
139
- }, i);
140
- let c = n;
141
- this.items.forEach((e) => {
142
- let n = a.getMirror(--c);
143
- if (n == null) return;
144
- o = Math.min(o, n);
145
- let i = a.maps[n];
146
- if (e.step) {
147
- let o = t.steps[n].invert(t.docs[n]), l = e.selection && e.selection.map(a.slice(c + 1, n));
148
- l && s++, r.push(new h(i, o, l));
149
- } else r.push(new h(i));
150
- }, i);
151
- let l = [];
152
- for (let e = n; e < o; e++) l.push(new h(a.maps[e]));
153
- let u = new e(this.items.slice(0, i).append(l).append(r), s);
154
- return u.emptyItemCount() > f && (u = u.compress(this.items.length - r.length)), u;
155
- }
156
- emptyItemCount() {
157
- let e = 0;
158
- return this.items.forEach((t) => {
159
- t.step || e++;
160
- }), e;
161
- }
162
- compress(t = this.items.length) {
163
- let n = this.remapping(0, t), r = n.maps.length, i = [], a = 0;
164
- return this.items.forEach((e, o) => {
165
- if (o >= t) i.push(e), e.selection && a++;
166
- else if (e.step) {
167
- let t = e.step.map(n.slice(r)), o = t && t.getMap();
168
- if (r--, o && n.appendMap(o, r), t) {
169
- let s = e.selection && e.selection.map(n.slice(r));
170
- s && a++;
171
- let c = new h(o.invert(), t, s), l, u = i.length - 1;
172
- (l = i.length && i[u].merge(c)) ? i[u] = l : i.push(c);
173
- }
174
- } else e.map && r--;
175
- }, this.items.length, 0), new e(l.from(i.reverse()), a);
176
- }
177
- };
178
- p.empty = new p(l.empty, 0);
179
- function m(e, t) {
180
- let n;
181
- return e.forEach((e, r) => {
182
- if (e.selection && t-- == 0) return n = r, !1;
183
- }), e.slice(n);
184
- }
185
- var h = class e {
186
- constructor(e, t, n, r) {
187
- this.map = e, this.step = t, this.selection = n, this.mirrorOffset = r;
188
- }
189
- merge(t) {
190
- if (this.step && t.step && !t.selection) {
191
- let n = t.step.merge(this.step);
192
- if (n) return new e(n.getMap().invert(), n, this.selection);
193
- }
194
- }
195
- }, g = class {
196
- constructor(e, t, n, r, i) {
197
- this.done = e, this.undone = t, this.prevRanges = n, this.prevTime = r, this.prevComposition = i;
198
- }
199
- }, _ = 20;
200
- function v(e, t, n, r) {
201
- let i = n.getMeta(E), a;
202
- if (i) return i.historyState;
203
- n.getMeta(D) && (e = new g(e.done, e.undone, null, 0, -1));
204
- let o = n.getMeta("appendedTransaction");
205
- if (n.steps.length == 0) return e;
206
- if (o && o.getMeta(E)) return o.getMeta(E).redo ? new g(e.done.addTransform(n, void 0, r, T(t)), e.undone, b(n.mapping.maps), e.prevTime, e.prevComposition) : new g(e.done, e.undone.addTransform(n, void 0, r, T(t)), null, e.prevTime, e.prevComposition);
207
- if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
208
- let i = n.getMeta("composition"), a = e.prevTime == 0 || !o && e.prevComposition != i && (e.prevTime < (n.time || 0) - r.newGroupDelay || !y(n, e.prevRanges)), s = o ? x(e.prevRanges, n.mapping) : b(n.mapping.maps);
209
- return new g(e.done.addTransform(n, a ? t.selection.getBookmark() : void 0, r, T(t)), p.empty, s, n.time, i ?? e.prevComposition);
210
- } else if (a = n.getMeta("rebased")) return new g(e.done.rebased(n, a), e.undone.rebased(n, a), x(e.prevRanges, n.mapping), e.prevTime, e.prevComposition);
211
- else return new g(e.done.addMaps(n.mapping.maps), e.undone.addMaps(n.mapping.maps), x(e.prevRanges, n.mapping), e.prevTime, e.prevComposition);
212
- }
213
- function y(e, t) {
214
- if (!t) return !1;
215
- if (!e.docChanged) return !0;
216
- let n = !1;
217
- return e.mapping.maps[0].forEach((e, r) => {
218
- for (let i = 0; i < t.length; i += 2) e <= t[i + 1] && r >= t[i] && (n = !0);
219
- }), n;
220
- }
221
- function b(e) {
222
- let t = [];
223
- for (let n = e.length - 1; n >= 0 && t.length == 0; n--) e[n].forEach((e, n, r, i) => t.push(r, i));
224
- return t;
225
- }
226
- function x(e, t) {
227
- if (!e) return null;
228
- let n = [];
229
- for (let r = 0; r < e.length; r += 2) {
230
- let i = t.map(e[r], 1), a = t.map(e[r + 1], -1);
231
- i <= a && n.push(i, a);
232
- }
233
- return n;
234
- }
235
- function S(e, t, n) {
236
- let r = T(t), i = E.get(t).spec.config, a = (n ? e.undone : e.done).popEvent(t, r);
237
- if (!a) return null;
238
- let o = a.selection.resolve(a.transform.doc), s = (n ? e.done : e.undone).addTransform(a.transform, t.selection.getBookmark(), i, r), c = new g(n ? s : a.remaining, n ? a.remaining : s, null, 0, -1);
239
- return a.transform.setSelection(o).setMeta(E, {
240
- redo: n,
241
- historyState: c
242
- });
243
- }
244
- var C = !1, w = null;
245
- function T(e) {
246
- let t = e.plugins;
247
- if (w != t) {
248
- C = !1, w = t;
249
- for (let e = 0; e < t.length; e++) if (t[e].spec.historyPreserveItems) {
250
- C = !0;
251
- break;
252
- }
253
- }
254
- return C;
255
- }
256
- var E = new t("history"), D = new t("closeHistory");
257
- function O(e = {}) {
258
- return e = {
259
- depth: e.depth || 100,
260
- newGroupDelay: e.newGroupDelay || 500
261
- }, new r({
262
- key: E,
263
- state: {
264
- init() {
265
- return new g(p.empty, p.empty, null, 0, -1);
266
- },
267
- apply(t, n, r) {
268
- return v(n, r, t, e);
269
- }
270
- },
271
- config: e,
272
- props: { handleDOMEvents: { beforeinput(e, t) {
273
- let n = t.inputType, r = n == "historyUndo" ? A : n == "historyRedo" ? j : null;
274
- return !r || !e.editable ? !1 : (t.preventDefault(), r(e.state, e.dispatch));
275
- } } }
276
- });
277
- }
278
- function k(e, t) {
279
- return (n, r) => {
280
- let i = E.getState(n);
281
- if (!i || (e ? i.undone : i.done).eventCount == 0) return !1;
282
- if (r) {
283
- let a = S(i, n, e);
284
- a && r(t ? a.scrollIntoView() : a);
285
- }
286
- return !0;
287
- };
288
- }
289
- var A = k(!1, !0), j = k(!0, !0);
290
- //#endregion
291
- //#region node_modules/.pnpm/@milkdown+plugin-history@7.21.1/node_modules/@milkdown/plugin-history/lib/index.js
292
- function M(e, t) {
293
- return Object.assign(e, { meta: {
294
- package: "@milkdown/plugin-history",
295
- ...t
296
- } }), e;
297
- }
298
- var N = o("Undo", () => () => A);
299
- M(N, { displayName: "Command<undo>" });
300
- var P = o("Redo", () => () => j);
301
- M(P, { displayName: "Command<redo>" });
302
- var F = i({}, "historyProviderConfig");
303
- M(F, { displayName: "Ctx<historyProviderConfig>" });
304
- var I = s((e) => O(e.get(F.key)));
305
- M(I, { displayName: "Ctx<historyProviderPlugin>" });
306
- var L = a("historyKeymap", {
307
- Undo: {
308
- shortcuts: "Mod-z",
309
- command: (t) => {
310
- let n = t.get(e);
311
- return () => n.call(N.key);
312
- }
313
- },
314
- Redo: {
315
- shortcuts: ["Mod-y", "Shift-Mod-z"],
316
- command: (t) => {
317
- let n = t.get(e);
318
- return () => n.call(P.key);
319
- }
320
- }
321
- });
322
- M(L.ctx, { displayName: "KeymapCtx<history>" }), M(L.shortcuts, { displayName: "Keymap<history>" });
323
- var R = [
324
- F,
325
- I,
326
- L,
327
- N,
328
- P
329
- ].flat();
330
- //#endregion
331
- export { R as history, L as historyKeymap, F as historyProviderConfig, I as historyProviderPlugin, P as redoCommand, N as undoCommand };
@@ -1 +0,0 @@
1
- const e=require("./lib-BLTQkf4j.cjs"),t=require("./dist-DQnWlYyo.cjs");function n(e,t=null){return function(n,i){let{$from:a,$to:o}=n.selection,s=a.blockRange(o);if(!s)return!1;let c=i?n.tr:null;return r(c,s,e,t)?(i&&i(c.scrollIntoView()),!0):!1}}function r(e,n,r,a=null){let o=!1,s=n,c=n.$from.doc;if(n.depth>=2&&n.$from.node(n.depth-1).type.compatibleContent(r)&&n.startIndex==0){if(n.$from.index(n.depth-1)==0)return!1;let e=c.resolve(n.start-2);s=new t.D(e,e,n.depth),n.endIndex<n.parent.childCount&&(n=new t.D(n.$from,c.resolve(n.$to.end(n.depth)),n.depth)),o=!0}let l=t.v(s,r,a,n);return l?(e&&i(e,n,l,o,r),!0):!1}function i(e,n,r,i,a){let o=t.w.empty;for(let e=r.length-1;e>=0;e--)o=t.w.from(r[e].type.create(r[e].attrs,o));e.step(new t.f(n.start-(i?2:0),n.end,n.start,n.end,new t.A(o,0,0),r.length,!0));let s=0;for(let e=0;e<r.length;e++)r[e].type==a&&(s=e+1);let c=r.length-s,l=n.start+r.length-(i?2:0),u=n.parent;for(let r=n.startIndex,i=n.endIndex,a=!0;r<i;r++,a=!1)!a&&t.g(e.doc,l,c)&&(e.split(l,c),l+=2*c),l+=u.child(r).nodeSize;return e}function a(e,n){return function(r,i){let{$from:a,$to:o,node:s}=r.selection;if(s&&s.isBlock||a.depth<2||!a.sameParent(o))return!1;let c=a.node(-1);if(c.type!=e)return!1;if(a.parent.content.size==0&&a.node(-1).childCount==a.indexAfter(-1)){if(a.depth==3||a.node(-3).type!=e||a.index(-2)!=a.node(-2).childCount-1)return!1;if(i){let n=t.w.empty,o=a.index(-1)?1:a.index(-2)?2:3;for(let e=a.depth-o;e>=a.depth-3;e--)n=t.w.from(a.node(e).copy(n));let s=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3;n=n.append(t.w.from(e.createAndFill()));let c=a.before(a.depth-(o-1)),l=r.tr.replace(c,a.after(-s),new t.A(n,4-o,0)),u=-1;l.doc.nodesBetween(c,l.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size==0&&(u=t+1)}),u>-1&&l.setSelection(t.o.near(l.doc.resolve(u))),i(l.scrollIntoView())}return!0}let l=o.pos==a.end()?c.contentMatchAt(0).defaultType:null,u=r.tr.delete(a.pos,o.pos),d=l?[n?{type:e,attrs:n}:null,{type:l}]:void 0;return t.g(u.doc,a.pos,2,d)?(i&&i(u.split(a.pos,2,d).scrollIntoView()),!0):!1}}function o(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?s(t,n,e,a):c(t,n,a):!0:!1}}function s(e,n,r,i){let a=e.tr,o=i.end,s=i.$to.end(i.depth);o<s&&(a.step(new t.f(o-1,s,o,s,new t.A(t.w.from(r.create(null,i.parent.copy())),1,0),1,!0)),i=new t.D(a.doc.resolve(i.$from.pos),a.doc.resolve(s),i.depth));let c=t.b(i);if(c==null)return!1;a.lift(i,c);let l=a.doc.resolve(a.mapping.map(o,-1)-1);return t.h(a.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&a.join(l.pos),n(a.scrollIntoView()),!0}function c(e,n,r){let i=e.tr,a=r.parent;for(let e=r.end,t=r.endIndex-1,n=r.startIndex;t>n;t--)e-=a.child(t).nodeSize,i.delete(e-1,e+1);let o=i.doc.resolve(r.start),s=o.nodeAfter;if(i.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let c=r.startIndex==0,l=r.endIndex==a.childCount,u=o.node(-1),d=o.index(-1);if(!u.canReplace(d+ +!c,d+1,s.content.append(l?t.w.empty:t.w.from(a))))return!1;let f=o.pos,p=f+s.nodeSize;return i.step(new t.f(f-+!!c,p+ +!!l,f+1,p-1,new t.A((c?t.w.empty:t.w.from(a.copy(t.w.empty))).append(l?t.w.empty:t.w.from(a.copy(t.w.empty))),+!c,+!l),+!c)),n(i.scrollIntoView()),!0}function l(e){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a,t=>t.childCount>0&&t.firstChild.type==e);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let c=o.parent,l=c.child(s-1);if(l.type!=e)return!1;if(r){let i=l.lastChild&&l.lastChild.type==c.type,a=t.w.from(i?e.create():null),s=new t.A(t.w.from(e.create(null,t.w.from(c.type.create(null,a)))),i?3:1,0),u=o.start,d=o.end;r(n.tr.step(new t.f(u-(i?3:1),d,u,d,s,1,!0)).scrollIntoView())}return!0}}var u=e.xt({liftListItem:()=>o,sinkListItem:()=>l,splitListItem:()=>a,wrapInList:()=>n,wrapRangeInList:()=>r});Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
@@ -1,110 +0,0 @@
1
- import { xt as e } from "./lib-CYWwNE4c.js";
2
- import { A as t, D as n, b as r, f as i, g as a, h as o, o as s, v as c, w as l } from "./dist-CLTsQjPD.js";
3
- //#region node_modules/.pnpm/prosemirror-schema-list@1.5.1/node_modules/prosemirror-schema-list/dist/index.js
4
- function u(e, t = null) {
5
- return function(n, r) {
6
- let { $from: i, $to: a } = n.selection, o = i.blockRange(a);
7
- if (!o) return !1;
8
- let s = r ? n.tr : null;
9
- return d(s, o, e, t) ? (r && r(s.scrollIntoView()), !0) : !1;
10
- };
11
- }
12
- function d(e, t, r, i = null) {
13
- let a = !1, o = t, s = t.$from.doc;
14
- if (t.depth >= 2 && t.$from.node(t.depth - 1).type.compatibleContent(r) && t.startIndex == 0) {
15
- if (t.$from.index(t.depth - 1) == 0) return !1;
16
- let e = s.resolve(t.start - 2);
17
- o = new n(e, e, t.depth), t.endIndex < t.parent.childCount && (t = new n(t.$from, s.resolve(t.$to.end(t.depth)), t.depth)), a = !0;
18
- }
19
- let l = c(o, r, i, t);
20
- return l ? (e && f(e, t, l, a, r), !0) : !1;
21
- }
22
- function f(e, n, r, o, s) {
23
- let c = l.empty;
24
- for (let e = r.length - 1; e >= 0; e--) c = l.from(r[e].type.create(r[e].attrs, c));
25
- e.step(new i(n.start - (o ? 2 : 0), n.end, n.start, n.end, new t(c, 0, 0), r.length, !0));
26
- let u = 0;
27
- for (let e = 0; e < r.length; e++) r[e].type == s && (u = e + 1);
28
- let d = r.length - u, f = n.start + r.length - (o ? 2 : 0), p = n.parent;
29
- for (let t = n.startIndex, r = n.endIndex, i = !0; t < r; t++, i = !1) !i && a(e.doc, f, d) && (e.split(f, d), f += 2 * d), f += p.child(t).nodeSize;
30
- return e;
31
- }
32
- function p(e, n) {
33
- return function(r, i) {
34
- let { $from: o, $to: c, node: u } = r.selection;
35
- if (u && u.isBlock || o.depth < 2 || !o.sameParent(c)) return !1;
36
- let d = o.node(-1);
37
- if (d.type != e) return !1;
38
- if (o.parent.content.size == 0 && o.node(-1).childCount == o.indexAfter(-1)) {
39
- if (o.depth == 3 || o.node(-3).type != e || o.index(-2) != o.node(-2).childCount - 1) return !1;
40
- if (i) {
41
- let n = l.empty, a = o.index(-1) ? 1 : o.index(-2) ? 2 : 3;
42
- for (let e = o.depth - a; e >= o.depth - 3; e--) n = l.from(o.node(e).copy(n));
43
- let c = o.indexAfter(-1) < o.node(-2).childCount ? 1 : o.indexAfter(-2) < o.node(-3).childCount ? 2 : 3;
44
- n = n.append(l.from(e.createAndFill()));
45
- let u = o.before(o.depth - (a - 1)), d = r.tr.replace(u, o.after(-c), new t(n, 4 - a, 0)), f = -1;
46
- d.doc.nodesBetween(u, d.doc.content.size, (e, t) => {
47
- if (f > -1) return !1;
48
- e.isTextblock && e.content.size == 0 && (f = t + 1);
49
- }), f > -1 && d.setSelection(s.near(d.doc.resolve(f))), i(d.scrollIntoView());
50
- }
51
- return !0;
52
- }
53
- let f = c.pos == o.end() ? d.contentMatchAt(0).defaultType : null, p = r.tr.delete(o.pos, c.pos), m = f ? [n ? {
54
- type: e,
55
- attrs: n
56
- } : null, { type: f }] : void 0;
57
- return a(p.doc, o.pos, 2, m) ? (i && i(p.split(o.pos, 2, m).scrollIntoView()), !0) : !1;
58
- };
59
- }
60
- function m(e) {
61
- return function(t, n) {
62
- let { $from: r, $to: i } = t.selection, a = r.blockRange(i, (t) => t.childCount > 0 && t.firstChild.type == e);
63
- return a ? n ? r.node(a.depth - 1).type == e ? h(t, n, e, a) : g(t, n, a) : !0 : !1;
64
- };
65
- }
66
- function h(e, a, s, c) {
67
- let u = e.tr, d = c.end, f = c.$to.end(c.depth);
68
- d < f && (u.step(new i(d - 1, f, d, f, new t(l.from(s.create(null, c.parent.copy())), 1, 0), 1, !0)), c = new n(u.doc.resolve(c.$from.pos), u.doc.resolve(f), c.depth));
69
- let p = r(c);
70
- if (p == null) return !1;
71
- u.lift(c, p);
72
- let m = u.doc.resolve(u.mapping.map(d, -1) - 1);
73
- return o(u.doc, m.pos) && m.nodeBefore.type == m.nodeAfter.type && u.join(m.pos), a(u.scrollIntoView()), !0;
74
- }
75
- function g(e, n, r) {
76
- let a = e.tr, o = r.parent;
77
- for (let e = r.end, t = r.endIndex - 1, n = r.startIndex; t > n; t--) e -= o.child(t).nodeSize, a.delete(e - 1, e + 1);
78
- let s = a.doc.resolve(r.start), c = s.nodeAfter;
79
- if (a.mapping.map(r.end) != r.start + s.nodeAfter.nodeSize) return !1;
80
- let u = r.startIndex == 0, d = r.endIndex == o.childCount, f = s.node(-1), p = s.index(-1);
81
- if (!f.canReplace(p + +!u, p + 1, c.content.append(d ? l.empty : l.from(o)))) return !1;
82
- let m = s.pos, h = m + c.nodeSize;
83
- return a.step(new i(m - +!!u, h + +!!d, m + 1, h - 1, new t((u ? l.empty : l.from(o.copy(l.empty))).append(d ? l.empty : l.from(o.copy(l.empty))), +!u, +!d), +!u)), n(a.scrollIntoView()), !0;
84
- }
85
- function _(e) {
86
- return function(n, r) {
87
- let { $from: a, $to: o } = n.selection, s = a.blockRange(o, (t) => t.childCount > 0 && t.firstChild.type == e);
88
- if (!s) return !1;
89
- let c = s.startIndex;
90
- if (c == 0) return !1;
91
- let u = s.parent, d = u.child(c - 1);
92
- if (d.type != e) return !1;
93
- if (r) {
94
- let a = d.lastChild && d.lastChild.type == u.type, o = l.from(a ? e.create() : null), c = new t(l.from(e.create(null, l.from(u.type.create(null, o)))), a ? 3 : 1, 0), f = s.start, p = s.end;
95
- r(n.tr.step(new i(f - (a ? 3 : 1), p, f, p, c, 1, !0)).scrollIntoView());
96
- }
97
- return !0;
98
- };
99
- }
100
- //#endregion
101
- //#region node_modules/.pnpm/@milkdown+prose@7.21.1/node_modules/@milkdown/prose/lib/schema-list.js
102
- var v = /* @__PURE__ */ e({
103
- liftListItem: () => m,
104
- sinkListItem: () => _,
105
- splitListItem: () => p,
106
- wrapInList: () => u,
107
- wrapRangeInList: () => d
108
- });
109
- //#endregion
110
- export { p as i, m as n, _ as r, v as t };
@@ -1,5 +0,0 @@
1
- /**
2
- * 在启用时订阅全局滚动并触发关闭回调。
3
- */
4
- export declare const useCloseOnGlobalScroll: (enabled: boolean, onClose: () => void, shouldIgnoreScroll?: (event: Event) => boolean) => void;
5
- //# sourceMappingURL=useCloseOnGlobalScroll.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCloseOnGlobalScroll.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/useCloseOnGlobalScroll.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,EAChB,SAAS,MAAM,IAAI,EACnB,qBAAqB,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,KAC7C,IAgCF,CAAC"}
@@ -1 +0,0 @@
1
- const e=require("./dist-DQnWlYyo.cjs");require("./state-BvRk9kiK.cjs"),exports.AllSelection=e.t,exports.EditorState=e.n,exports.NodeSelection=e.r,exports.Plugin=e.i,exports.PluginKey=e.a,exports.Selection=e.o,exports.SelectionRange=e.s,exports.TextSelection=e.c,exports.Transaction=e.l;
File without changes
File without changes
@@ -1,3 +0,0 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./dist-CLTsQjPD.js";
2
- import "./state-BvRk9kiK.js";
3
- export { c as AllSelection, i as EditorState, o as NodeSelection, n as Plugin, e as PluginKey, a as Selection, s as SelectionRange, t as TextSelection, r as Transaction };