@wrdagency/blockout 1.0.10 → 1.0.12
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/assets/index11.css +1 -1
- package/dist/assets/style13.css +1 -1
- package/dist/assets/style21.css +1 -1
- package/dist/components/controls/markdown-control/editor.d.ts +7 -3
- package/dist/components/controls/markdown-control/editor.js +194 -163
- package/dist/components/controls/markdown-control/index.d.ts +6 -2
- package/dist/components/controls/markdown-control/toolbar.d.ts +2 -2
- package/dist/components/controls/markdown-control/toolbar.js +1 -1
- package/dist/primitives/link/index.d.ts +5 -2
- package/dist/primitives/link/index.js +22 -17
- package/dist/{toolbar-j1SJvq8D.js → toolbar-CCiZ_PIy.js} +241 -237
- package/package.json +1 -1
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { jsx as C, jsxs as ge } from "react/jsx-runtime";
|
|
2
2
|
import { cn as ye } from "../../../utils/css.js";
|
|
3
|
-
import { r as T, w as ve, c as we, d as be, a as
|
|
4
|
-
import { $ as X, d as Le, T as Y, a as ee, s as Pe, g as Oe, b as
|
|
5
|
-
import { l as Re, c as
|
|
3
|
+
import { r as T, w as ve, c as we, d as be, a as W, h as S, b as F, p as Ie, E as Me, l as ke, e as Ee, f as Ce } from "../../../toolbar-CCiZ_PIy.js";
|
|
4
|
+
import { $ as X, d as Le, T as Y, a as ee, s as Pe, g as Oe, b as N, P as z, h as te, i as Te, j as Se, k as _e, l as Ae, m as De, M as Ne, n as je, o as ne, q as G, r as xe, I as Ue, S as Fe, t as Be, E as qe, e as ze, u as $e, v as He, w as Ke } from "../../../index-EPj3dCzl.js";
|
|
5
|
+
import { l as Re, c as We, g as Ge, w as Ve } from "../../../commands-IQnqt4xL.js";
|
|
6
6
|
import '../../../assets/prosemirror.css';/* empty css */
|
|
7
|
-
import { d as
|
|
8
|
-
import { P as
|
|
9
|
-
import "react";
|
|
10
|
-
import { useMentionsPlugin as
|
|
11
|
-
var
|
|
7
|
+
import { d as Je, M as Ze, a as Qe, u as Xe, b as Ye } from "../../../index-CwFPDtaz.js";
|
|
8
|
+
import { P as et } from "../../../base-jB1DIMnz.js";
|
|
9
|
+
import { useEffect as tt } from "react";
|
|
10
|
+
import { useMentionsPlugin as nt } from "./slash/mentions.js";
|
|
11
|
+
var rt = Object.defineProperty, V = Object.getOwnPropertySymbols, st = Object.prototype.hasOwnProperty, it = Object.prototype.propertyIsEnumerable, J = (n, e, t) => e in n ? rt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, ot = (n, e) => {
|
|
12
12
|
for (var t in e || (e = {}))
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
for (var t of
|
|
16
|
-
|
|
13
|
+
st.call(e, t) && J(n, t, e[t]);
|
|
14
|
+
if (V)
|
|
15
|
+
for (var t of V(e))
|
|
16
|
+
it.call(e, t) && J(n, t, e[t]);
|
|
17
17
|
return n;
|
|
18
18
|
};
|
|
19
19
|
function re(n, e) {
|
|
20
20
|
return Object.assign(n, {
|
|
21
|
-
meta:
|
|
21
|
+
meta: ot({
|
|
22
22
|
package: "@milkdown/components"
|
|
23
23
|
}, e)
|
|
24
24
|
}), n;
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const at = {
|
|
27
27
|
renderLabel: ({ label: n, listType: e, checked: t }) => t == null ? e === "bullet" ? "⦿" : n : t ? "☑" : "□"
|
|
28
|
-
},
|
|
29
|
-
|
|
28
|
+
}, j = X(
|
|
29
|
+
at,
|
|
30
30
|
"listItemBlockConfigCtx"
|
|
31
31
|
);
|
|
32
|
-
re(
|
|
32
|
+
re(j, {
|
|
33
33
|
displayName: "Config<list-item-block>",
|
|
34
34
|
group: "ListItemBlock"
|
|
35
35
|
});
|
|
@@ -39,7 +39,7 @@ function se({ icon: n, class: e, onClick: t }) {
|
|
|
39
39
|
{
|
|
40
40
|
class: F("milkdown-icon", e),
|
|
41
41
|
onPointerdown: t,
|
|
42
|
-
innerHTML: n ?
|
|
42
|
+
innerHTML: n ? Ie.sanitize(n.trim()) : void 0
|
|
43
43
|
}
|
|
44
44
|
);
|
|
45
45
|
}
|
|
@@ -57,7 +57,7 @@ se.props = {
|
|
|
57
57
|
required: !1
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
const
|
|
60
|
+
const lt = be({
|
|
61
61
|
props: {
|
|
62
62
|
label: {
|
|
63
63
|
type: Object,
|
|
@@ -102,16 +102,16 @@ const it = be({
|
|
|
102
102
|
onMount: o,
|
|
103
103
|
selected: l
|
|
104
104
|
}) {
|
|
105
|
-
const a = (
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
},
|
|
105
|
+
const a = (c) => {
|
|
106
|
+
c != null && c instanceof Element && o(c);
|
|
107
|
+
}, u = (c) => {
|
|
108
|
+
c.stopPropagation(), c.preventDefault(), e.value != null && i("checked", !e.value);
|
|
109
|
+
}, d = W(() => s.renderLabel({
|
|
110
110
|
label: n.value,
|
|
111
111
|
listType: t.value,
|
|
112
112
|
checked: e.value,
|
|
113
113
|
readonly: r.value
|
|
114
|
-
})), p =
|
|
114
|
+
})), p = W(() => e.value == null ? t.value === "bullet" ? "bullet" : "ordered" : e.value ? "checked" : "unchecked");
|
|
115
115
|
return () => /* @__PURE__ */ S(
|
|
116
116
|
"li",
|
|
117
117
|
{
|
|
@@ -124,7 +124,7 @@ const it = be({
|
|
|
124
124
|
"div",
|
|
125
125
|
{
|
|
126
126
|
class: "label-wrapper",
|
|
127
|
-
onPointerdown:
|
|
127
|
+
onPointerdown: u,
|
|
128
128
|
contenteditable: !1
|
|
129
129
|
},
|
|
130
130
|
/* @__PURE__ */ S(
|
|
@@ -135,7 +135,7 @@ const it = be({
|
|
|
135
135
|
r.value && "readonly",
|
|
136
136
|
p.value
|
|
137
137
|
),
|
|
138
|
-
icon:
|
|
138
|
+
icon: d.value
|
|
139
139
|
}
|
|
140
140
|
)
|
|
141
141
|
),
|
|
@@ -149,25 +149,25 @@ const it = be({
|
|
|
149
149
|
r.className = "milkdown-list-item-block";
|
|
150
150
|
const i = document.createElement("div");
|
|
151
151
|
i.setAttribute("data-content-dom", "true"), i.classList.add("content-dom");
|
|
152
|
-
const o = T(e.attrs.label), l = T(e.attrs.checked), a = T(e.attrs.listType),
|
|
152
|
+
const o = T(e.attrs.label), l = T(e.attrs.checked), a = T(e.attrs.listType), u = T(!t.editable), d = n.get(j.key), p = T(!1), c = (f, E) => {
|
|
153
153
|
if (!t.editable) return;
|
|
154
154
|
const w = s();
|
|
155
|
-
w != null && (t.hasFocus() || t.focus(), t.dispatch(t.state.tr.setNodeAttribute(w,
|
|
155
|
+
w != null && (t.hasFocus() || t.focus(), t.dispatch(t.state.tr.setNodeAttribute(w, f, E)));
|
|
156
156
|
}, h = ve(() => {
|
|
157
157
|
p.value ? r.classList.add("selected") : r.classList.remove("selected");
|
|
158
158
|
});
|
|
159
159
|
let g = 0;
|
|
160
|
-
const b = we(
|
|
160
|
+
const b = we(lt, {
|
|
161
161
|
label: o,
|
|
162
162
|
checked: l,
|
|
163
163
|
listType: a,
|
|
164
|
-
readonly:
|
|
165
|
-
config:
|
|
164
|
+
readonly: u,
|
|
165
|
+
config: d,
|
|
166
166
|
selected: p,
|
|
167
|
-
setAttr:
|
|
168
|
-
onMount: (
|
|
167
|
+
setAttr: c,
|
|
168
|
+
onMount: (f) => {
|
|
169
169
|
const { anchor: E, head: w } = t.state.selection;
|
|
170
|
-
|
|
170
|
+
f.appendChild(i);
|
|
171
171
|
const _ = t.state.doc.resolve(E), he = t.state.doc.resolve(w);
|
|
172
172
|
g = requestAnimationFrame(() => {
|
|
173
173
|
if (cancelAnimationFrame(g), !_.doc.eq(t.state.doc)) return;
|
|
@@ -177,16 +177,16 @@ const it = be({
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
b.mount(r);
|
|
180
|
-
const O = (
|
|
181
|
-
a.value =
|
|
180
|
+
const O = (f) => {
|
|
181
|
+
a.value = f.attrs.listType, o.value = f.attrs.label, l.value = f.attrs.checked, u.value = !t.editable;
|
|
182
182
|
};
|
|
183
183
|
O(e);
|
|
184
184
|
let k = e;
|
|
185
185
|
return {
|
|
186
186
|
dom: r,
|
|
187
187
|
contentDOM: i,
|
|
188
|
-
update: (
|
|
189
|
-
ignoreMutation: (
|
|
188
|
+
update: (f) => f.type !== e.type ? !1 : (f.sameMarkup(k) && f.content.eq(k.content) || (k = f, O(f)), !0),
|
|
189
|
+
ignoreMutation: (f) => !r || !i ? !0 : f.type === "selection" ? !1 : i === f.target && f.type === "attributes" ? !0 : !i.contains(f.target),
|
|
190
190
|
selectNode: () => {
|
|
191
191
|
p.value = !0;
|
|
192
192
|
},
|
|
@@ -203,8 +203,8 @@ re(ie, {
|
|
|
203
203
|
displayName: "NodeView<list-item-block>",
|
|
204
204
|
group: "ListItemBlock"
|
|
205
205
|
});
|
|
206
|
-
const
|
|
207
|
-
|
|
206
|
+
const pt = [
|
|
207
|
+
j,
|
|
208
208
|
ie
|
|
209
209
|
];
|
|
210
210
|
function B(n) {
|
|
@@ -214,7 +214,7 @@ function B(n) {
|
|
|
214
214
|
const e = n.content;
|
|
215
215
|
return e ? B(e) : n.type === "text";
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function ct(n, e) {
|
|
218
218
|
return Object.assign(n, {
|
|
219
219
|
meta: {
|
|
220
220
|
package: "@milkdown/plugin-clipboard",
|
|
@@ -228,7 +228,7 @@ const oe = ee((n) => {
|
|
|
228
228
|
...r,
|
|
229
229
|
editable: r.editable ?? (() => !0)
|
|
230
230
|
}));
|
|
231
|
-
const t = new
|
|
231
|
+
const t = new N("MILKDOWN_CLIPBOARD");
|
|
232
232
|
return new z({
|
|
233
233
|
key: t,
|
|
234
234
|
props: {
|
|
@@ -236,32 +236,32 @@ const oe = ee((n) => {
|
|
|
236
236
|
var O, k;
|
|
237
237
|
const o = n.get(Te), l = (k = (O = r.props).editable) == null ? void 0 : k.call(O, r.state), { clipboardData: a } = i;
|
|
238
238
|
if (!l || !a || r.state.selection.$from.node().type.spec.code) return !1;
|
|
239
|
-
const
|
|
239
|
+
const d = a.getData("text/plain"), p = a.getData("vscode-editor-data");
|
|
240
240
|
if (p) {
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
241
|
+
const f = JSON.parse(p), E = f == null ? void 0 : f.mode;
|
|
242
|
+
if (d && E) {
|
|
243
243
|
const { tr: w } = r.state, _ = Se("code_block", e);
|
|
244
244
|
return w.replaceSelectionWith(_.create({ language: E })).setSelection(
|
|
245
245
|
Y.near(
|
|
246
246
|
w.doc.resolve(Math.max(0, w.selection.from - 2))
|
|
247
247
|
)
|
|
248
|
-
).insertText(
|
|
248
|
+
).insertText(d.replace(/\r\n?/g, `
|
|
249
249
|
`)), r.dispatch(w), !0;
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
const
|
|
253
|
-
if (
|
|
252
|
+
const c = a.getData("text/html");
|
|
253
|
+
if (c.length === 0 && d.length === 0) return !1;
|
|
254
254
|
const h = _e.fromSchema(e);
|
|
255
255
|
let g;
|
|
256
|
-
if (
|
|
257
|
-
const
|
|
258
|
-
if (!
|
|
256
|
+
if (c.length === 0) {
|
|
257
|
+
const f = o(d);
|
|
258
|
+
if (!f || typeof f == "string") return !1;
|
|
259
259
|
g = Ae.fromSchema(e).serializeFragment(
|
|
260
|
-
|
|
260
|
+
f.content
|
|
261
261
|
);
|
|
262
262
|
} else {
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const f = document.createElement("template");
|
|
264
|
+
f.innerHTML = c, g = f.content.cloneNode(!0), f.remove();
|
|
265
265
|
}
|
|
266
266
|
const P = h.parseSlice(g), b = De(P);
|
|
267
267
|
if (b)
|
|
@@ -288,7 +288,7 @@ const oe = ee((n) => {
|
|
|
288
288
|
}
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
|
-
|
|
291
|
+
ct(oe, { displayName: "Prose<clipboard>" });
|
|
292
292
|
var D = 200, m = function() {
|
|
293
293
|
};
|
|
294
294
|
m.prototype.append = function(e) {
|
|
@@ -298,7 +298,7 @@ m.prototype.prepend = function(e) {
|
|
|
298
298
|
return e.length ? m.from(e).append(this) : this;
|
|
299
299
|
};
|
|
300
300
|
m.prototype.appendInner = function(e) {
|
|
301
|
-
return new
|
|
301
|
+
return new ut(this, e);
|
|
302
302
|
};
|
|
303
303
|
m.prototype.slice = function(e, t) {
|
|
304
304
|
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? m.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
|
|
@@ -353,7 +353,7 @@ var ae = /* @__PURE__ */ function(n) {
|
|
|
353
353
|
}, Object.defineProperties(e.prototype, t), e;
|
|
354
354
|
}(m);
|
|
355
355
|
m.empty = new ae([]);
|
|
356
|
-
var
|
|
356
|
+
var ut = /* @__PURE__ */ function(n) {
|
|
357
357
|
function e(t, s) {
|
|
358
358
|
n.call(this), this.left = t, this.right = s, this.length = t.length + s.length, this.depth = Math.max(t.depth, s.depth) + 1;
|
|
359
359
|
}
|
|
@@ -386,7 +386,7 @@ var lt = /* @__PURE__ */ function(n) {
|
|
|
386
386
|
return this.left.depth >= Math.max(this.right.depth, s.depth) + 1 ? new e(this.left, new e(this.right, s)) : new e(this, s);
|
|
387
387
|
}, e;
|
|
388
388
|
}(m);
|
|
389
|
-
const
|
|
389
|
+
const dt = 500;
|
|
390
390
|
class y {
|
|
391
391
|
constructor(e, t) {
|
|
392
392
|
this.items = e, this.eventCount = t;
|
|
@@ -404,34 +404,34 @@ class y {
|
|
|
404
404
|
}
|
|
405
405
|
let r, i;
|
|
406
406
|
t && (r = this.remapping(s, this.items.length), i = r.maps.length);
|
|
407
|
-
let o = e.tr, l, a,
|
|
408
|
-
return this.items.forEach((p,
|
|
407
|
+
let o = e.tr, l, a, u = [], d = [];
|
|
408
|
+
return this.items.forEach((p, c) => {
|
|
409
409
|
if (!p.step) {
|
|
410
|
-
r || (r = this.remapping(s,
|
|
410
|
+
r || (r = this.remapping(s, c + 1), i = r.maps.length), i--, d.push(p);
|
|
411
411
|
return;
|
|
412
412
|
}
|
|
413
413
|
if (r) {
|
|
414
|
-
|
|
414
|
+
d.push(new v(p.map));
|
|
415
415
|
let h = p.step.map(r.slice(i)), g;
|
|
416
|
-
h && o.maybeStep(h).doc && (g = o.mapping.maps[o.mapping.maps.length - 1],
|
|
416
|
+
h && o.maybeStep(h).doc && (g = o.mapping.maps[o.mapping.maps.length - 1], u.push(new v(g, void 0, void 0, u.length + d.length))), i--, g && r.appendMap(g, i);
|
|
417
417
|
} else
|
|
418
418
|
o.maybeStep(p.step);
|
|
419
419
|
if (p.selection)
|
|
420
|
-
return l = r ? p.selection.map(r.slice(i)) : p.selection, a = new y(this.items.slice(0, s).append(
|
|
420
|
+
return l = r ? p.selection.map(r.slice(i)) : p.selection, a = new y(this.items.slice(0, s).append(d.reverse().concat(u)), this.eventCount - 1), !1;
|
|
421
421
|
}, this.items.length, 0), { remaining: a, transform: o, selection: l };
|
|
422
422
|
}
|
|
423
423
|
// Create a new branch with the given transform added.
|
|
424
424
|
addTransform(e, t, s, r) {
|
|
425
425
|
let i = [], o = this.eventCount, l = this.items, a = !r && l.length ? l.get(l.length - 1) : null;
|
|
426
|
-
for (let
|
|
427
|
-
let p = e.steps[
|
|
428
|
-
(h = a && a.merge(
|
|
426
|
+
for (let d = 0; d < e.steps.length; d++) {
|
|
427
|
+
let p = e.steps[d].invert(e.docs[d]), c = new v(e.mapping.maps[d], p, t), h;
|
|
428
|
+
(h = a && a.merge(c)) && (c = h, d ? i.pop() : l = l.slice(0, l.length - 1)), i.push(c), t && (o++, t = void 0), r || (a = c);
|
|
429
429
|
}
|
|
430
|
-
let
|
|
431
|
-
return
|
|
430
|
+
let u = o - s.depth;
|
|
431
|
+
return u > ht && (l = ft(l, u), o -= u), new y(l.append(i), o);
|
|
432
432
|
}
|
|
433
433
|
remapping(e, t) {
|
|
434
|
-
let s = new
|
|
434
|
+
let s = new Ne();
|
|
435
435
|
return this.items.forEach((r, i) => {
|
|
436
436
|
let o = r.mirrorOffset != null && i - r.mirrorOffset >= e ? s.maps.length - r.mirrorOffset : void 0;
|
|
437
437
|
s.appendMap(r.map, o);
|
|
@@ -448,27 +448,27 @@ class y {
|
|
|
448
448
|
if (!this.eventCount)
|
|
449
449
|
return this;
|
|
450
450
|
let s = [], r = Math.max(0, this.items.length - t), i = e.mapping, o = e.steps.length, l = this.eventCount;
|
|
451
|
-
this.items.forEach((
|
|
452
|
-
|
|
451
|
+
this.items.forEach((c) => {
|
|
452
|
+
c.selection && l--;
|
|
453
453
|
}, r);
|
|
454
454
|
let a = t;
|
|
455
|
-
this.items.forEach((
|
|
455
|
+
this.items.forEach((c) => {
|
|
456
456
|
let h = i.getMirror(--a);
|
|
457
457
|
if (h == null)
|
|
458
458
|
return;
|
|
459
459
|
o = Math.min(o, h);
|
|
460
460
|
let g = i.maps[h];
|
|
461
|
-
if (
|
|
462
|
-
let P = e.steps[h].invert(e.docs[h]), b =
|
|
461
|
+
if (c.step) {
|
|
462
|
+
let P = e.steps[h].invert(e.docs[h]), b = c.selection && c.selection.map(i.slice(a + 1, h));
|
|
463
463
|
b && l++, s.push(new v(g, P, b));
|
|
464
464
|
} else
|
|
465
465
|
s.push(new v(g));
|
|
466
466
|
}, r);
|
|
467
|
-
let
|
|
468
|
-
for (let
|
|
469
|
-
|
|
470
|
-
let
|
|
471
|
-
return p.emptyItemCount() >
|
|
467
|
+
let u = [];
|
|
468
|
+
for (let c = t; c < o; c++)
|
|
469
|
+
u.push(new v(i.maps[c]));
|
|
470
|
+
let d = this.items.slice(0, r).append(u).append(s), p = new y(d, l);
|
|
471
|
+
return p.emptyItemCount() > dt && (p = p.compress(this.items.length - s.length)), p;
|
|
472
472
|
}
|
|
473
473
|
emptyItemCount() {
|
|
474
474
|
let e = 0;
|
|
@@ -488,19 +488,19 @@ class y {
|
|
|
488
488
|
if (l >= e)
|
|
489
489
|
r.push(o), o.selection && i++;
|
|
490
490
|
else if (o.step) {
|
|
491
|
-
let a = o.step.map(t.slice(s)),
|
|
492
|
-
if (s--,
|
|
493
|
-
let
|
|
494
|
-
|
|
495
|
-
let p = new v(
|
|
496
|
-
(
|
|
491
|
+
let a = o.step.map(t.slice(s)), u = a && a.getMap();
|
|
492
|
+
if (s--, u && t.appendMap(u, s), a) {
|
|
493
|
+
let d = o.selection && o.selection.map(t.slice(s));
|
|
494
|
+
d && i++;
|
|
495
|
+
let p = new v(u.invert(), a, d), c, h = r.length - 1;
|
|
496
|
+
(c = r.length && r[h].merge(p)) ? r[h] = c : r.push(p);
|
|
497
497
|
}
|
|
498
498
|
} else o.map && s--;
|
|
499
499
|
}, this.items.length, 0), new y(m.from(r.reverse()), i);
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
y.empty = new y(m.empty, 0);
|
|
503
|
-
function
|
|
503
|
+
function ft(n, e) {
|
|
504
504
|
let t;
|
|
505
505
|
return n.forEach((s, r) => {
|
|
506
506
|
if (s.selection && e-- == 0)
|
|
@@ -519,28 +519,28 @@ class v {
|
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
class
|
|
522
|
+
class I {
|
|
523
523
|
constructor(e, t, s, r, i) {
|
|
524
524
|
this.done = e, this.undone = t, this.prevRanges = s, this.prevTime = r, this.prevComposition = i;
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
-
const
|
|
528
|
-
function
|
|
529
|
-
let r = t.getMeta(
|
|
527
|
+
const ht = 20;
|
|
528
|
+
function mt(n, e, t, s) {
|
|
529
|
+
let r = t.getMeta(M), i;
|
|
530
530
|
if (r)
|
|
531
531
|
return r.historyState;
|
|
532
|
-
t.getMeta(
|
|
532
|
+
t.getMeta(vt) && (n = new I(n.done, n.undone, null, 0, -1));
|
|
533
533
|
let o = t.getMeta("appendedTransaction");
|
|
534
534
|
if (t.steps.length == 0)
|
|
535
535
|
return n;
|
|
536
|
-
if (o && o.getMeta(
|
|
537
|
-
return o.getMeta(
|
|
536
|
+
if (o && o.getMeta(M))
|
|
537
|
+
return o.getMeta(M).redo ? new I(n.done.addTransform(t, void 0, s, A(e)), n.undone, Z(t.mapping.maps), n.prevTime, n.prevComposition) : new I(n.done, n.undone.addTransform(t, void 0, s, A(e)), null, n.prevTime, n.prevComposition);
|
|
538
538
|
if (t.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
|
|
539
|
-
let l = t.getMeta("composition"), a = n.prevTime == 0 || !o && n.prevComposition != l && (n.prevTime < (t.time || 0) - s.newGroupDelay || !
|
|
540
|
-
return new
|
|
541
|
-
} else return (i = t.getMeta("rebased")) ? new
|
|
539
|
+
let l = t.getMeta("composition"), a = n.prevTime == 0 || !o && n.prevComposition != l && (n.prevTime < (t.time || 0) - s.newGroupDelay || !gt(t, n.prevRanges)), u = o ? x(n.prevRanges, t.mapping) : Z(t.mapping.maps);
|
|
540
|
+
return new I(n.done.addTransform(t, a ? e.selection.getBookmark() : void 0, s, A(e)), y.empty, u, t.time, l ?? n.prevComposition);
|
|
541
|
+
} else return (i = t.getMeta("rebased")) ? new I(n.done.rebased(t, i), n.undone.rebased(t, i), x(n.prevRanges, t.mapping), n.prevTime, n.prevComposition) : new I(n.done.addMaps(t.mapping.maps), n.undone.addMaps(t.mapping.maps), x(n.prevRanges, t.mapping), n.prevTime, n.prevComposition);
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function gt(n, e) {
|
|
544
544
|
if (!e)
|
|
545
545
|
return !1;
|
|
546
546
|
if (!n.docChanged)
|
|
@@ -567,12 +567,12 @@ function x(n, e) {
|
|
|
567
567
|
}
|
|
568
568
|
return t;
|
|
569
569
|
}
|
|
570
|
-
function
|
|
571
|
-
let s = A(e), r =
|
|
570
|
+
function yt(n, e, t) {
|
|
571
|
+
let s = A(e), r = M.get(e).spec.config, i = (t ? n.undone : n.done).popEvent(e, s);
|
|
572
572
|
if (!i)
|
|
573
573
|
return null;
|
|
574
|
-
let o = i.selection.resolve(i.transform.doc), l = (t ? n.done : n.undone).addTransform(i.transform, e.selection.getBookmark(), r, s), a = new
|
|
575
|
-
return i.transform.setSelection(o).setMeta(
|
|
574
|
+
let o = i.selection.resolve(i.transform.doc), l = (t ? n.done : n.undone).addTransform(i.transform, e.selection.getBookmark(), r, s), a = new I(t ? l : i.remaining, t ? i.remaining : l, null, 0, -1);
|
|
575
|
+
return i.transform.setSelection(o).setMeta(M, { redo: t, historyState: a });
|
|
576
576
|
}
|
|
577
577
|
let U = !1, Q = null;
|
|
578
578
|
function A(n) {
|
|
@@ -587,26 +587,26 @@ function A(n) {
|
|
|
587
587
|
}
|
|
588
588
|
return U;
|
|
589
589
|
}
|
|
590
|
-
const
|
|
591
|
-
function
|
|
590
|
+
const M = new N("history"), vt = new N("closeHistory");
|
|
591
|
+
function wt(n = {}) {
|
|
592
592
|
return n = {
|
|
593
593
|
depth: n.depth || 100,
|
|
594
594
|
newGroupDelay: n.newGroupDelay || 500
|
|
595
595
|
}, new z({
|
|
596
|
-
key:
|
|
596
|
+
key: M,
|
|
597
597
|
state: {
|
|
598
598
|
init() {
|
|
599
|
-
return new
|
|
599
|
+
return new I(y.empty, y.empty, null, 0, -1);
|
|
600
600
|
},
|
|
601
601
|
apply(e, t, s) {
|
|
602
|
-
return
|
|
602
|
+
return mt(t, s, e, n);
|
|
603
603
|
}
|
|
604
604
|
},
|
|
605
605
|
config: n,
|
|
606
606
|
props: {
|
|
607
607
|
handleDOMEvents: {
|
|
608
608
|
beforeinput(e, t) {
|
|
609
|
-
let s = t.inputType, r = s == "historyUndo" ? pe : s == "historyRedo" ?
|
|
609
|
+
let s = t.inputType, r = s == "historyUndo" ? pe : s == "historyRedo" ? ce : null;
|
|
610
610
|
return !r || !e.editable ? !1 : (t.preventDefault(), r(e.state, e.dispatch));
|
|
611
611
|
}
|
|
612
612
|
}
|
|
@@ -615,17 +615,17 @@ function gt(n = {}) {
|
|
|
615
615
|
}
|
|
616
616
|
function le(n, e) {
|
|
617
617
|
return (t, s) => {
|
|
618
|
-
let r =
|
|
618
|
+
let r = M.getState(t);
|
|
619
619
|
if (!r || (n ? r.undone : r.done).eventCount == 0)
|
|
620
620
|
return !1;
|
|
621
621
|
if (s) {
|
|
622
|
-
let i =
|
|
622
|
+
let i = yt(r, t, n);
|
|
623
623
|
i && s(e ? i.scrollIntoView() : i);
|
|
624
624
|
}
|
|
625
625
|
return !0;
|
|
626
626
|
};
|
|
627
627
|
}
|
|
628
|
-
const pe = le(!1, !0),
|
|
628
|
+
const pe = le(!1, !0), ce = le(!0, !0);
|
|
629
629
|
function L(n, e) {
|
|
630
630
|
return Object.assign(n, {
|
|
631
631
|
meta: {
|
|
@@ -634,52 +634,52 @@ function L(n, e) {
|
|
|
634
634
|
}
|
|
635
635
|
}), n;
|
|
636
636
|
}
|
|
637
|
-
const
|
|
638
|
-
L(
|
|
637
|
+
const $ = ne("Undo", () => () => pe);
|
|
638
|
+
L($, {
|
|
639
639
|
displayName: "Command<undo>"
|
|
640
640
|
});
|
|
641
|
-
const
|
|
642
|
-
L(
|
|
641
|
+
const H = ne("Redo", () => () => ce);
|
|
642
|
+
L(H, {
|
|
643
643
|
displayName: "Command<redo>"
|
|
644
644
|
});
|
|
645
|
-
const
|
|
646
|
-
L(
|
|
645
|
+
const K = X({}, "historyProviderConfig");
|
|
646
|
+
L(K, {
|
|
647
647
|
displayName: "Ctx<historyProviderConfig>"
|
|
648
648
|
});
|
|
649
|
-
const
|
|
650
|
-
(n) =>
|
|
649
|
+
const ue = ee(
|
|
650
|
+
(n) => wt(n.get(K.key))
|
|
651
651
|
);
|
|
652
|
-
L(
|
|
652
|
+
L(ue, {
|
|
653
653
|
displayName: "Ctx<historyProviderPlugin>"
|
|
654
654
|
});
|
|
655
|
-
const
|
|
655
|
+
const R = je("historyKeymap", {
|
|
656
656
|
Undo: {
|
|
657
657
|
shortcuts: "Mod-z",
|
|
658
658
|
command: (n) => {
|
|
659
|
-
const e = n.get(
|
|
660
|
-
return () => e.call(
|
|
659
|
+
const e = n.get(G);
|
|
660
|
+
return () => e.call($.key);
|
|
661
661
|
}
|
|
662
662
|
},
|
|
663
663
|
Redo: {
|
|
664
664
|
shortcuts: ["Mod-y", "Shift-Mod-z"],
|
|
665
665
|
command: (n) => {
|
|
666
|
-
const e = n.get(
|
|
667
|
-
return () => e.call(
|
|
666
|
+
const e = n.get(G);
|
|
667
|
+
return () => e.call(H.key);
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
});
|
|
671
|
-
L(
|
|
671
|
+
L(R.ctx, {
|
|
672
672
|
displayName: "KeymapCtx<history>"
|
|
673
673
|
});
|
|
674
|
-
L(
|
|
674
|
+
L(R.shortcuts, {
|
|
675
675
|
displayName: "Keymap<history>"
|
|
676
676
|
});
|
|
677
|
-
const
|
|
677
|
+
const bt = [
|
|
678
|
+
K,
|
|
679
|
+
ue,
|
|
678
680
|
R,
|
|
679
|
-
ce,
|
|
680
681
|
$,
|
|
681
|
-
H
|
|
682
|
-
K
|
|
682
|
+
H
|
|
683
683
|
].flat();
|
|
684
684
|
class de {
|
|
685
685
|
constructor() {
|
|
@@ -728,14 +728,14 @@ class de {
|
|
|
728
728
|
const q = xe(
|
|
729
729
|
new de(),
|
|
730
730
|
"listener"
|
|
731
|
-
),
|
|
731
|
+
), It = new N("MILKDOWN_LISTENER"), fe = (n) => (n.inject(q, new de()), async () => {
|
|
732
732
|
await n.wait(Ue);
|
|
733
733
|
const e = n.get(q), { listeners: t } = e;
|
|
734
734
|
t.beforeMount.forEach((a) => a(n)), await n.wait(Fe);
|
|
735
735
|
const s = n.get(te);
|
|
736
736
|
let r = null, i = null, o = null;
|
|
737
737
|
const l = new z({
|
|
738
|
-
key:
|
|
738
|
+
key: It,
|
|
739
739
|
view: () => ({
|
|
740
740
|
destroy: () => {
|
|
741
741
|
t.destroy.forEach((a) => a(n));
|
|
@@ -748,22 +748,22 @@ const q = xe(
|
|
|
748
748
|
}
|
|
749
749
|
},
|
|
750
750
|
state: {
|
|
751
|
-
init: (a,
|
|
752
|
-
r =
|
|
751
|
+
init: (a, u) => {
|
|
752
|
+
r = u.doc, i = s(u.doc);
|
|
753
753
|
},
|
|
754
754
|
apply: (a) => {
|
|
755
|
-
const
|
|
756
|
-
return (!o &&
|
|
757
|
-
p(n,
|
|
758
|
-
}), o =
|
|
755
|
+
const u = a.selection;
|
|
756
|
+
return (!o && u || o && !u.eq(o)) && (t.selectionUpdated.forEach((p) => {
|
|
757
|
+
p(n, u, o);
|
|
758
|
+
}), o = u), !(a.docChanged || a.storedMarksSet) || a.getMeta("addToHistory") === !1 ? void 0 : Je(() => {
|
|
759
759
|
const { doc: p } = a;
|
|
760
|
-
if (t.updated.length > 0 && r && !r.eq(p) && t.updated.forEach((
|
|
761
|
-
|
|
760
|
+
if (t.updated.length > 0 && r && !r.eq(p) && t.updated.forEach((c) => {
|
|
761
|
+
c(n, p, r);
|
|
762
762
|
}), t.markdownUpdated.length > 0 && r && !r.eq(p)) {
|
|
763
|
-
const
|
|
763
|
+
const c = s(p);
|
|
764
764
|
t.markdownUpdated.forEach((h) => {
|
|
765
|
-
h(n,
|
|
766
|
-
}), i =
|
|
765
|
+
h(n, c, i);
|
|
766
|
+
}), i = c;
|
|
767
767
|
}
|
|
768
768
|
r = p;
|
|
769
769
|
}, 200)();
|
|
@@ -776,32 +776,63 @@ fe.meta = {
|
|
|
776
776
|
package: "@milkdown/plugin-listener",
|
|
777
777
|
displayName: "Listener"
|
|
778
778
|
};
|
|
779
|
-
const
|
|
779
|
+
const Mt = ({
|
|
780
780
|
className: n,
|
|
781
781
|
value: e,
|
|
782
|
-
onChangeValue: t
|
|
782
|
+
onChangeValue: t,
|
|
783
|
+
children: s,
|
|
784
|
+
toolbar: r = "top",
|
|
785
|
+
milkdownRef: i
|
|
783
786
|
}) => {
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
(
|
|
787
|
-
|
|
788
|
-
t(
|
|
789
|
-
}),
|
|
787
|
+
const o = nt();
|
|
788
|
+
Qe(
|
|
789
|
+
(d) => $e.make().config((p) => {
|
|
790
|
+
p.set(He, d), p.set(Ke, e || ""), p.get(q).markdownUpdated((h, g) => {
|
|
791
|
+
t == null || t(g);
|
|
792
|
+
}), p.set(j.key, {
|
|
790
793
|
renderLabel: () => ""
|
|
791
|
-
}),
|
|
792
|
-
...
|
|
794
|
+
}), p.update(ke.key, (h) => ({
|
|
795
|
+
...h,
|
|
793
796
|
linkIcon: "",
|
|
794
797
|
editButton: "",
|
|
795
798
|
removeButton: "",
|
|
796
799
|
confirmButton: "",
|
|
797
800
|
inputPlaceholder: "Enter a URL..."
|
|
798
|
-
})),
|
|
799
|
-
}).use(fe).use(
|
|
800
|
-
)
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
},
|
|
801
|
+
})), o.config(p);
|
|
802
|
+
}).use(fe).use(We).use(Ge).use(oe).use(bt).use(pt).use(Ve).config(Ee).use(Ce).use(o.plugin)
|
|
803
|
+
);
|
|
804
|
+
const [l, a] = Xe();
|
|
805
|
+
tt(() => {
|
|
806
|
+
i && (i.current = a());
|
|
807
|
+
}, [l, a]);
|
|
808
|
+
const u = () => {
|
|
809
|
+
var d;
|
|
810
|
+
(d = a()) == null || d.action((p) => {
|
|
811
|
+
p.get(ze).focus();
|
|
812
|
+
});
|
|
813
|
+
};
|
|
814
|
+
return /* @__PURE__ */ ge(
|
|
815
|
+
"div",
|
|
816
|
+
{
|
|
817
|
+
className: ye(
|
|
818
|
+
"component-markdown-editor",
|
|
819
|
+
r && `component-markdown-editor--toolbar-${r}`,
|
|
820
|
+
n
|
|
821
|
+
),
|
|
822
|
+
children: [
|
|
823
|
+
r && /* @__PURE__ */ C(Me, { className: "component-markdown-editor__toolbar", children: s }),
|
|
824
|
+
/* @__PURE__ */ C(
|
|
825
|
+
"div",
|
|
826
|
+
{
|
|
827
|
+
className: "component-markdown-editor__content",
|
|
828
|
+
onClick: u,
|
|
829
|
+
children: /* @__PURE__ */ C(Ye, {})
|
|
830
|
+
}
|
|
831
|
+
)
|
|
832
|
+
]
|
|
833
|
+
}
|
|
834
|
+
);
|
|
835
|
+
}, Dt = (n) => /* @__PURE__ */ C(Ze, { children: /* @__PURE__ */ C(et, { children: /* @__PURE__ */ C(Mt, { ...n }) }) });
|
|
805
836
|
export {
|
|
806
|
-
|
|
837
|
+
Dt as MarkdownEditor
|
|
807
838
|
};
|