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.
Files changed (100) hide show
  1. package/dist/{dist-Cxaq2crg.js → commands-BJpevWrH.js} +123 -123
  2. package/dist/commands-BmZHd6RL.js +2 -0
  3. package/dist/{dist-CPVooDwj.cjs → commands-CM7IuhpT.cjs} +2 -2
  4. package/dist/commands-f4yOm8DQ.cjs +1 -0
  5. package/dist/{debounce-Bqj_3iJs.cjs → debounce-C_TNzOFT.cjs} +1 -1
  6. package/dist/{dist-DaM7GJv6.js → dist-CLTsQjPD.js} +319 -318
  7. package/dist/{dist-CxZn1qUo.js → dist-CZTw9GLV.js} +198 -198
  8. package/dist/dist-DQnWlYyo.cjs +5 -0
  9. package/dist/dist-ZPtYoqTI.cjs +1 -0
  10. package/dist/floating-ui.dom-CV-TLBRq.cjs +1 -0
  11. package/dist/floating-ui.dom-CoOubeUs.js +762 -0
  12. package/dist/index.cjs +25 -149
  13. package/dist/index.mjs +6235 -15737
  14. package/dist/{lib-C8xOD1Bp.cjs → lib-5pUyY-Tl.cjs} +1 -1
  15. package/dist/{lib-DkE7Uq2b.js → lib-Bhr5EVOu.js} +110 -112
  16. package/dist/lib-BmAQCwSQ.cjs +1 -0
  17. package/dist/{lib-wmHesNI0.js → lib-C1A-pN4b.js} +574 -575
  18. package/dist/lib-CVebEyb8.cjs +4 -0
  19. package/dist/lib-ChwoE6v5.js +331 -0
  20. package/dist/lib-DIx8C5AZ.cjs +1 -0
  21. package/dist/lib-DVE2k9i1.js +387 -0
  22. package/dist/{lib-DzK_kn7a.js → lib-D_0WAhKU.js} +3 -3
  23. package/dist/{lib-m8lKZKxK.js → lib-Dd20rlmV.js} +28 -28
  24. package/dist/lib-De0djIEV.cjs +5 -0
  25. package/dist/{lib-D4HMdvmK.cjs → lib-DgEwQN1U.cjs} +1 -1
  26. package/dist/{dist-Dhukmh4L.js → lib-DmD940Fq.js} +2849 -1735
  27. package/dist/lib-Dplx6t-N.cjs +3 -0
  28. package/dist/lib-DzY83R_P.cjs +39 -0
  29. package/dist/lib-F08NY8fk.cjs +1 -0
  30. package/dist/{lib-B0rHJ9lJ.js → lib-_NDReOAt.js} +3 -3
  31. package/dist/{lib-CK9MEMX-.js → lib-bsXGz3fj.js} +28 -27
  32. package/dist/schema-list-D9Q6QKgo.cjs +1 -0
  33. package/dist/schema-list-DooYP5HM.js +110 -0
  34. package/dist/src/core/createEditor.d.ts.map +1 -1
  35. package/dist/src/local/en-US.d.ts.map +1 -1
  36. package/dist/src/local/zh-CN.d.ts.map +1 -1
  37. package/dist/src/plugins/custom/block-transform/block-transform.d.ts +15 -0
  38. package/dist/src/plugins/custom/block-transform/block-transform.d.ts.map +1 -0
  39. package/dist/src/plugins/custom/block-transform/index.d.ts +2 -0
  40. package/dist/src/plugins/custom/block-transform/index.d.ts.map +1 -0
  41. package/dist/src/plugins/custom/math/index.d.ts +6 -0
  42. package/dist/src/plugins/custom/math/index.d.ts.map +1 -1
  43. package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -1
  44. package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts +5 -0
  45. package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts.map +1 -0
  46. package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts +29 -0
  47. package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts.map +1 -0
  48. package/dist/src/plugins/custom/math/math-inline-editable.d.ts +7 -0
  49. package/dist/src/plugins/custom/math/math-inline-editable.d.ts.map +1 -0
  50. package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -1
  51. package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +5 -1
  52. package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -1
  53. package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -1
  54. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +34 -3
  55. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -1
  56. package/dist/src/plugins/custom/selection-tooltip/types.d.ts +16 -1
  57. package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -1
  58. package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -1
  59. package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +4 -0
  60. package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -1
  61. package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -1
  62. package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -1
  63. package/dist/src/plugins/preset-common.d.ts +6 -0
  64. package/dist/src/plugins/preset-common.d.ts.map +1 -1
  65. package/dist/src/react/hooks/useMilkdownEditor.d.ts +2 -2
  66. package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -1
  67. package/dist/src/types/editor.d.ts +35 -5
  68. package/dist/src/types/editor.d.ts.map +1 -1
  69. package/dist/state-BC1dqWPQ.cjs +1 -0
  70. package/dist/state-BvRk9kiK.cjs +0 -0
  71. package/dist/state-BvRk9kiK.js +0 -0
  72. package/dist/state-rTW_1XVf.js +3 -0
  73. package/dist/style.css +2 -2
  74. package/package.json +1 -1
  75. package/dist/commands-CDrea4WB.cjs +0 -1
  76. package/dist/commands-DoqeX5uJ.js +0 -36
  77. package/dist/dist-BCCSKc3M.cjs +0 -5
  78. package/dist/dist-C0PSMrs7.cjs +0 -37
  79. package/dist/dist-mOpTMw1E.cjs +0 -1
  80. package/dist/floating-ui.dom-CKbcbmJV.js +0 -883
  81. package/dist/floating-ui.dom-VaZZ2gzS.cjs +0 -1
  82. package/dist/index.browser-5LtNN9G9.cjs +0 -1
  83. package/dist/index.browser-D2DmEB8o.js +0 -26
  84. package/dist/lib-38nxOnTd.cjs +0 -4
  85. package/dist/lib-8Tr6mAln.cjs +0 -1
  86. package/dist/lib-BJgvZywM.cjs +0 -3
  87. package/dist/lib-BNOSyYeU.cjs +0 -3
  88. package/dist/lib-C5AzmhNY.cjs +0 -5
  89. package/dist/lib-CCUU16r8.js +0 -1081
  90. package/dist/lib-DWZA8C0h.cjs +0 -1
  91. package/dist/lib-Dbe-cVjv.js +0 -367
  92. package/dist/lib-IahjxPWM.cjs +0 -3
  93. package/dist/lib-r5eNG0sa.js +0 -754
  94. package/dist/rolldown-runtime-CerMd-t8.cjs +0 -1
  95. package/dist/rolldown-runtime-DnwLefa7.js +0 -23
  96. package/dist/schema-list-DSdBEAWW.js +0 -171
  97. package/dist/schema-list-bL8FNes5.cjs +0 -1
  98. package/dist/state-CHAiIqOA.cjs +0 -1
  99. package/dist/state-DNxqltZl.js +0 -16
  100. /package/dist/{debounce-Cuk3VGPr.js → debounce-Z8-khnlZ.js} +0 -0
@@ -0,0 +1,4 @@
1
+ const e=require("./lib-DzY83R_P.cjs"),t=require("./dist-DQnWlYyo.cjs"),n=require("./lib-DIx8C5AZ.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;
@@ -0,0 +1,331 @@
1
+ import { s as e } from "./lib-DmD940Fq.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-DVE2k9i1.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 };
@@ -0,0 +1 @@
1
+ const e=require("./lib-DzY83R_P.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.St({$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}});