Your Name 1912bcd25b
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
chore: sync all remaining local workspace changes
2026-05-08 11:26:57 +08:00

1224 lines
40 KiB
JavaScript

/*
* Extracted from browser-delivered Turbopack chunk: 2a4e4dccbc3fdacb.bc4b655d5c.js
* Module id: 589430
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
var t = e.i(673654);
e.i(608469);
var n = e.i(111092),
r = e.i(545773);
class i {
constructor(e, t) {
var n;
(this.editorView = e),
(this.cursorPos = null),
(this.element = null),
(this.timeout = -1),
(this.width = null != (n = t.width) ? n : 1),
(this.color = !1 === t.color ? void 0 : t.color || "black"),
(this.class = t.class),
(this.handlers = ["dragover", "dragend", "drop", "dragleave"].map(
(t) => {
let n = (e) => {
this[t](e);
};
return e.dom.addEventListener(t, n), { name: t, handler: n };
},
));
}
destroy() {
this.handlers.forEach(({ name: e, handler: t }) =>
this.editorView.dom.removeEventListener(e, t),
);
}
update(e, t) {
null != this.cursorPos &&
t.doc != e.state.doc &&
(this.cursorPos > e.state.doc.content.size
? this.setCursor(null)
: this.updateOverlay());
}
setCursor(e) {
e != this.cursorPos &&
((this.cursorPos = e),
null == e
? (this.element.parentNode.removeChild(this.element),
(this.element = null))
: this.updateOverlay());
}
updateOverlay() {
let e,
t,
n = this.editorView.state.doc.resolve(this.cursorPos),
r = !n.parent.inlineContent,
i,
o = this.editorView.dom,
s = o.getBoundingClientRect(),
l = s.width / o.offsetWidth,
a = s.height / o.offsetHeight;
if (r) {
let e = n.nodeBefore,
t = n.nodeAfter;
if (e || t) {
let n = this.editorView.nodeDOM(
this.cursorPos - (e ? e.nodeSize : 0),
);
if (n) {
let r = n.getBoundingClientRect(),
o = e ? r.bottom : r.top;
e &&
t &&
(o =
(o +
this.editorView
.nodeDOM(this.cursorPos)
.getBoundingClientRect().top) /
2);
let s = (this.width / 2) * a;
i = { left: r.left, right: r.right, top: o - s, bottom: o + s };
}
}
}
if (!i) {
let e = this.editorView.coordsAtPos(this.cursorPos),
t = (this.width / 2) * l;
i = {
left: e.left - t,
right: e.left + t,
top: e.top,
bottom: e.bottom,
};
}
let d = this.editorView.dom.offsetParent;
if (
(!this.element &&
((this.element = d.appendChild(document.createElement("div"))),
this.class && (this.element.className = this.class),
(this.element.style.cssText =
"position: absolute; z-index: 50; pointer-events: none;"),
this.color && (this.element.style.backgroundColor = this.color)),
this.element.classList.toggle("prosemirror-dropcursor-block", r),
this.element.classList.toggle("prosemirror-dropcursor-inline", !r),
d && (d != document.body || "static" != getComputedStyle(d).position))
) {
let n = d.getBoundingClientRect(),
r = n.width / d.offsetWidth,
i = n.height / d.offsetHeight;
(e = n.left - d.scrollLeft * r), (t = n.top - d.scrollTop * i);
} else (e = -pageXOffset), (t = -pageYOffset);
(this.element.style.left = (i.left - e) / l + "px"),
(this.element.style.top = (i.top - t) / a + "px"),
(this.element.style.width = (i.right - i.left) / l + "px"),
(this.element.style.height = (i.bottom - i.top) / a + "px");
}
scheduleRemoval(e) {
clearTimeout(this.timeout),
(this.timeout = setTimeout(() => this.setCursor(null), e));
}
dragover(e) {
if (!this.editorView.editable) return;
let t = this.editorView.posAtCoords({
left: e.clientX,
top: e.clientY,
}),
n = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside),
i = n && n.type.spec.disableDropCursor,
o = "function" == typeof i ? i(this.editorView, t, e) : i;
if (t && !o) {
let e = t.pos;
if (this.editorView.dragging && this.editorView.dragging.slice) {
let t = (0, r.dropPoint)(
this.editorView.state.doc,
e,
this.editorView.dragging.slice,
);
null != t && (e = t);
}
this.setCursor(e), this.scheduleRemoval(5e3);
}
}
dragend() {
this.scheduleRemoval(20);
}
drop() {
this.scheduleRemoval(20);
}
dragleave(e) {
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
}
}
e.i(979748);
var o = e.i(675993),
s = e.i(202008),
l = n,
a = e.i(47091);
class d extends l.Selection {
constructor(e) {
super(e, e);
}
map(e, t) {
let n = e.resolve(t.map(this.head));
return d.valid(n) ? new d(n) : l.Selection.near(n);
}
content() {
return a.Slice.empty;
}
eq(e) {
return e instanceof d && e.head == this.head;
}
toJSON() {
return { type: "gapcursor", pos: this.head };
}
static fromJSON(e, t) {
if ("number" != typeof t.pos)
throw RangeError("Invalid input for GapCursor.fromJSON");
return new d(e.resolve(t.pos));
}
getBookmark() {
return new c(this.anchor);
}
static valid(e) {
let t = e.parent;
if (
t.isTextblock ||
!(function (e) {
for (let t = e.depth; t >= 0; t--) {
let n = e.index(t),
r = e.node(t);
if (0 == n) {
if (r.type.spec.isolating) return !0;
continue;
}
for (let e = r.child(n - 1); ; e = e.lastChild) {
if ((0 == e.childCount && !e.inlineContent) || h(e.type))
return !0;
if (e.inlineContent) return !1;
}
}
return !0;
})(e) ||
!(function (e) {
for (let t = e.depth; t >= 0; t--) {
let n = e.indexAfter(t),
r = e.node(t);
if (n == r.childCount) {
if (r.type.spec.isolating) return !0;
continue;
}
for (let e = r.child(n); ; e = e.firstChild) {
if ((0 == e.childCount && !e.inlineContent) || h(e.type))
return !0;
if (e.inlineContent) return !1;
}
}
return !0;
})(e)
)
return !1;
let n = t.type.spec.allowGapCursor;
if (null != n) return n;
let r = t.contentMatchAt(e.index()).defaultType;
return r && r.isTextblock;
}
static findGapCursorFrom(e, t, n = !1) {
r: for (;;) {
if (!n && d.valid(e)) return e;
let r = e.pos,
i = null;
for (let n = e.depth; ; n--) {
let o = e.node(n);
if (t > 0 ? e.indexAfter(n) < o.childCount : e.index(n) > 0) {
i = o.child(t > 0 ? e.indexAfter(n) : e.index(n) - 1);
break;
}
if (0 == n) return null;
r += t;
let s = e.doc.resolve(r);
if (d.valid(s)) return s;
}
for (;;) {
let o = t > 0 ? i.firstChild : i.lastChild;
if (!o) {
if (i.isAtom && !i.isText && !l.NodeSelection.isSelectable(i)) {
(e = e.doc.resolve(r + i.nodeSize * t)), (n = !1);
continue r;
}
break;
}
(i = o), (r += t);
let s = e.doc.resolve(r);
if (d.valid(s)) return s;
}
return null;
}
}
}
(d.prototype.visible = !1),
(d.findFrom = d.findGapCursorFrom),
l.Selection.jsonID("gapcursor", d);
class c {
constructor(e) {
this.pos = e;
}
map(e) {
return new c(e.map(this.pos));
}
resolve(e) {
let t = e.resolve(this.pos);
return d.valid(t) ? new d(t) : l.Selection.near(t);
}
}
function h(e) {
return e.isAtom || e.spec.isolating || e.spec.createGapCursor;
}
let p = (0, s.keydownHandler)({
ArrowLeft: u("horiz", -1),
ArrowRight: u("horiz", 1),
ArrowUp: u("vert", -1),
ArrowDown: u("vert", 1),
});
function u(e, t) {
let n = "vert" == e ? (t > 0 ? "down" : "up") : t > 0 ? "right" : "left";
return function (e, r, i) {
let o = e.selection,
s = t > 0 ? o.$to : o.$from,
a = o.empty;
if (o instanceof l.TextSelection) {
if (!i.endOfTextblock(n) || 0 == s.depth) return !1;
(a = !1), (s = e.doc.resolve(t > 0 ? s.after() : s.before()));
}
let c = d.findGapCursorFrom(s, t, a);
return !!c && (r && r(e.tr.setSelection(new d(c))), !0);
};
}
function f(e, t, n) {
if (!e || !e.editable) return !1;
let r = e.state.doc.resolve(t);
if (!d.valid(r)) return !1;
let i = e.posAtCoords({ left: n.clientX, top: n.clientY });
return (
!(
i &&
i.inside > -1 &&
l.NodeSelection.isSelectable(e.state.doc.nodeAt(i.inside))
) && (e.dispatch(e.state.tr.setSelection(new d(r))), !0)
);
}
function m(e, t) {
if (
"insertCompositionText" != t.inputType ||
!(e.state.selection instanceof d)
)
return !1;
let { $from: n } = e.state.selection,
r = n.parent
.contentMatchAt(n.index())
.findWrapping(e.state.schema.nodes.text);
if (!r) return !1;
let i = a.Fragment.empty;
for (let e = r.length - 1; e >= 0; e--)
i = a.Fragment.from(r[e].createAndFill(null, i));
let o = e.state.tr.replace(n.pos, n.pos, new a.Slice(i, 0, 0));
return (
o.setSelection(l.TextSelection.near(o.doc.resolve(n.pos + 1))),
e.dispatch(o),
!1
);
}
function g(e) {
if (!(e.selection instanceof d)) return null;
let t = document.createElement("div");
return (
(t.className = "ProseMirror-gapcursor"),
o.DecorationSet.create(e.doc, [
o.Decoration.widget(e.selection.head, t, { key: "gapcursor" }),
])
);
}
var y = function () {};
(y.prototype.append = function (e) {
return e.length
? ((e = y.from(e)),
(!this.length && e) ||
(e.length < 200 && this.leafAppend(e)) ||
(this.length < 200 && e.leafPrepend(this)) ||
this.appendInner(e))
: this;
}),
(y.prototype.prepend = function (e) {
return e.length ? y.from(e).append(this) : this;
}),
(y.prototype.appendInner = function (e) {
return new k(this, e);
}),
(y.prototype.slice = function (e, t) {
return (void 0 === e && (e = 0),
void 0 === t && (t = this.length),
e >= t)
? y.empty
: this.sliceInner(Math.max(0, e), Math.min(this.length, t));
}),
(y.prototype.get = function (e) {
if (!(e < 0) && !(e >= this.length)) return this.getInner(e);
}),
(y.prototype.forEach = function (e, t, n) {
void 0 === t && (t = 0),
void 0 === n && (n = this.length),
t <= n
? this.forEachInner(e, t, n, 0)
: this.forEachInvertedInner(e, t, n, 0);
}),
(y.prototype.map = function (e, t, n) {
void 0 === t && (t = 0), void 0 === n && (n = this.length);
var r = [];
return (
this.forEach(
function (t, n) {
return r.push(e(t, n));
},
t,
n,
),
r
);
}),
(y.from = function (e) {
return e instanceof y ? e : e && e.length ? new b(e) : y.empty;
});
var b = (function (e) {
function t(t) {
e.call(this), (this.values = t);
}
(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 0 == e && 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 (!1 === e(this.values[i], r + i)) return !1;
}),
(t.prototype.forEachInvertedInner = function (e, t, n, r) {
for (var i = t - 1; i >= n; i--)
if (!1 === e(this.values[i], r + i)) return !1;
}),
(t.prototype.leafAppend = function (e) {
if (this.length + e.length <= 200)
return new t(this.values.concat(e.flatten()));
}),
(t.prototype.leafPrepend = function (e) {
if (this.length + e.length <= 200)
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
);
})(y);
y.empty = new b([]);
var k = (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 (
(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 && !1 === this.left.forEachInner(e, t, Math.min(n, i), r)) ||
(n > i &&
!1 ===
this.right.forEachInner(
e,
Math.max(t - i, 0),
Math.min(this.length, n) - i,
r + i,
))
)
return !1;
}),
(t.prototype.forEachInvertedInner = function (e, t, n, r) {
var i = this.left.length;
if (
(t > i &&
!1 ===
this.right.forEachInvertedInner(
e,
t - i,
Math.max(n, i) - i,
r + i,
)) ||
(n < i &&
!1 === this.left.forEachInvertedInner(e, Math.min(t, i), n, r))
)
return !1;
}),
(t.prototype.sliceInner = function (e, t) {
if (0 == e && 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
);
})(y);
class v {
constructor(e, t) {
(this.items = e), (this.eventCount = t);
}
popEvent(e, t) {
let n, r, i, o;
if (0 == this.eventCount) return null;
let s = this.items.length;
for (; ; s--)
if (this.items.get(s - 1).selection) {
--s;
break;
}
t && (r = (n = this.remapping(s, this.items.length)).maps.length);
let l = e.tr,
a = [],
d = [];
return (
this.items.forEach(
(e, t) => {
if (!e.step) {
n || (r = (n = this.remapping(s, t + 1)).maps.length),
r--,
d.push(e);
return;
}
if (n) {
d.push(new w(e.map));
let t = e.step.map(n.slice(r)),
i;
t &&
l.maybeStep(t).doc &&
((i = l.mapping.maps[l.mapping.maps.length - 1]),
a.push(new w(i, void 0, void 0, a.length + d.length))),
r--,
i && n.appendMap(i, r);
} else l.maybeStep(e.step);
if (e.selection)
return (
(i = n ? e.selection.map(n.slice(r)) : e.selection),
(o = new v(
this.items.slice(0, s).append(d.reverse().concat(a)),
this.eventCount - 1,
)),
!1
);
},
this.items.length,
0,
),
{ remaining: o, transform: l, selection: i }
);
}
addTransform(e, t, n, r) {
var i, o;
let s,
l = [],
a = this.eventCount,
d = this.items,
c = !r && d.length ? d.get(d.length - 1) : null;
for (let n = 0; n < e.steps.length; n++) {
let i = e.steps[n].invert(e.docs[n]),
o = new w(e.mapping.maps[n], i, t),
s;
(s = c && c.merge(o)) &&
((o = s), n ? l.pop() : (d = d.slice(0, d.length - 1))),
l.push(o),
t && (a++, (t = void 0)),
r || (c = o);
}
let h = a - n.depth;
return (
h > x &&
((i = d),
(o = h),
i.forEach((e, t) => {
if (e.selection && 0 == o--) return (s = t), !1;
}),
(d = i.slice(s)),
(a -= h)),
new v(d.append(l), a)
);
}
remapping(e, t) {
let n = new r.Mapping();
return (
this.items.forEach(
(t, r) => {
let i =
null != t.mirrorOffset && r - t.mirrorOffset >= e
? n.maps.length - t.mirrorOffset
: void 0;
n.appendMap(t.map, i);
},
e,
t,
),
n
);
}
addMaps(e) {
return 0 == this.eventCount
? this
: new v(this.items.append(e.map((e) => new w(e))), this.eventCount);
}
rebased(e, t) {
if (!this.eventCount) return this;
let n = [],
r = Math.max(0, this.items.length - t),
i = e.mapping,
o = e.steps.length,
s = this.eventCount;
this.items.forEach((e) => {
e.selection && s--;
}, r);
let l = t;
this.items.forEach((t) => {
let r = i.getMirror(--l);
if (null == r) return;
o = Math.min(o, r);
let a = i.maps[r];
if (t.step) {
let o = e.steps[r].invert(e.docs[r]),
d = t.selection && t.selection.map(i.slice(l + 1, r));
d && s++, n.push(new w(a, o, d));
} else n.push(new w(a));
}, r);
let a = [];
for (let e = t; e < o; e++) a.push(new w(i.maps[e]));
let d = new v(this.items.slice(0, r).append(a).append(n), s);
return (
d.emptyItemCount() > 500 &&
(d = d.compress(this.items.length - n.length)),
d
);
}
emptyItemCount() {
let e = 0;
return (
this.items.forEach((t) => {
!t.step && e++;
}),
e
);
}
compress(e = this.items.length) {
let t = this.remapping(0, e),
n = t.maps.length,
r = [],
i = 0;
return (
this.items.forEach(
(o, s) => {
if (s >= e) r.push(o), o.selection && i++;
else if (o.step) {
let e = o.step.map(t.slice(n)),
s = e && e.getMap();
if ((n--, s && t.appendMap(s, n), e)) {
let l = o.selection && o.selection.map(t.slice(n));
l && i++;
let a = new w(s.invert(), e, l),
d,
c = r.length - 1;
(d = r.length && r[c].merge(a)) ? (r[c] = d) : r.push(a);
}
} else o.map && n--;
},
this.items.length,
0,
),
new v(y.from(r.reverse()), i)
);
}
}
v.empty = new v(y.empty, 0);
class w {
constructor(e, t, n, r) {
(this.map = e),
(this.step = t),
(this.selection = n),
(this.mirrorOffset = r);
}
merge(e) {
if (this.step && e.step && !e.selection) {
let t = e.step.merge(this.step);
if (t) return new w(t.getMap().invert(), t, this.selection);
}
}
}
class S {
constructor(e, t, n, r, i) {
(this.done = e),
(this.undone = t),
(this.prevRanges = n),
(this.prevTime = r),
(this.prevComposition = i);
}
}
let x = 20;
function M(e) {
let t = [];
for (let n = e.length - 1; n >= 0 && 0 == t.length; n--)
e[n].forEach((e, n, r, i) => t.push(r, i));
return t;
}
function C(e, t) {
if (!e) return null;
let n = [];
for (let r = 0; r < e.length; r += 2) {
let i = t.map(e[r], 1),
o = t.map(e[r + 1], -1);
i <= o && n.push(i, o);
}
return n;
}
let T = !1,
N = null;
function E(e) {
let t = e.plugins;
if (N != t) {
(T = !1), (N = t);
for (let e = 0; e < t.length; e++)
if (t[e].spec.historyPreserveItems) {
T = !0;
break;
}
}
return T;
}
let O = new n.PluginKey("history"),
A = new n.PluginKey("closeHistory");
function D(e, t) {
return (n, r) => {
let i = O.getState(n);
if (!i || 0 == (e ? i.undone : i.done).eventCount) return !1;
if (r) {
let o = (function (e, t, n) {
let r = E(t),
i = O.get(t).spec.config,
o = (n ? e.undone : e.done).popEvent(t, r);
if (!o) return null;
let s = o.selection.resolve(o.transform.doc),
l = (n ? e.done : e.undone).addTransform(
o.transform,
t.selection.getBookmark(),
i,
r,
),
a = new S(n ? l : o.remaining, n ? o.remaining : l, null, 0, -1);
return o.transform
.setSelection(s)
.setMeta(O, { redo: n, historyState: a });
})(i, n, e);
o && r(t ? o.scrollIntoView() : o);
}
return !0;
};
}
let R = D(!1, !0),
I = D(!0, !0);
D(!1, !1),
D(!0, !1),
t.Extension.create({
name: "characterCount",
addOptions: () => ({
limit: null,
mode: "textSize",
textCounter: (e) => e.length,
wordCounter: (e) => e.split(" ").filter((e) => "" !== e).length,
}),
addStorage: () => ({ characters: () => 0, words: () => 0 }),
onBeforeCreate() {
(this.storage.characters = (e) => {
let t = (null == e ? void 0 : e.node) || this.editor.state.doc;
if (
"textSize" ===
((null == e ? void 0 : e.mode) || this.options.mode)
) {
let e = t.textBetween(0, t.content.size, void 0, " ");
return this.options.textCounter(e);
}
return t.nodeSize;
}),
(this.storage.words = (e) => {
let t = (null == e ? void 0 : e.node) || this.editor.state.doc,
n = t.textBetween(0, t.content.size, " ", " ");
return this.options.wordCounter(n);
});
},
addProseMirrorPlugins() {
let e = !1;
return [
new n.Plugin({
key: new n.PluginKey("characterCount"),
appendTransaction: (t, n, r) => {
if (e) return;
let i = this.options.limit;
if (null == i || 0 === i) {
e = !0;
return;
}
let o = this.storage.characters({ node: r.doc });
if (o > i) {
console.warn(
`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`,
);
let t = r.tr.deleteRange(0, o - i);
return (e = !0), t;
}
e = !0;
},
filterTransaction: (e, t) => {
let n = this.options.limit;
if (!e.docChanged || 0 === n || null == n) return !0;
let r = this.storage.characters({ node: t.doc }),
i = this.storage.characters({ node: e.doc });
if (i <= n || (r > n && i > n && i <= r)) return !0;
if ((r > n && i > n && i > r) || !e.getMeta("paste")) return !1;
let o = e.selection.$head.pos;
return (
e.deleteRange(o - (i - n), o),
!(this.storage.characters({ node: e.doc }) > n)
);
},
}),
];
},
});
var P = t.Extension.create({
name: "dropCursor",
addOptions: () => ({ color: "currentColor", width: 1, class: void 0 }),
addProseMirrorPlugins() {
return [
(function (e = {}) {
return new n.Plugin({ view: (t) => new i(t, e) });
})(this.options),
];
},
});
t.Extension.create({
name: "focus",
addOptions: () => ({ className: "has-focus", mode: "all" }),
addProseMirrorPlugins() {
return [
new n.Plugin({
key: new n.PluginKey("focus"),
props: {
decorations: ({ doc: e, selection: t }) => {
let { isEditable: n, isFocused: r } = this.editor,
{ anchor: i } = t,
s = [];
if (!n || !r) return o.DecorationSet.create(e, []);
let l = 0;
"deepest" === this.options.mode &&
e.descendants((e, t) => {
if (!e.isText) {
if (!(i >= t && i <= t + e.nodeSize - 1)) return !1;
l += 1;
}
});
let a = 0;
return (
e.descendants(
(e, t) =>
!e.isText &&
!!(i >= t && i <= t + e.nodeSize - 1) &&
(((a += 1),
("deepest" === this.options.mode && l - a > 0) ||
("shallowest" === this.options.mode && a > 1))
? "deepest" === this.options.mode
: void s.push(
o.Decoration.node(t, t + e.nodeSize, {
class: this.options.className,
}),
)),
),
o.DecorationSet.create(e, s)
);
},
},
}),
];
},
});
var L = t.Extension.create({
name: "gapCursor",
addProseMirrorPlugins: () => [
new l.Plugin({
props: {
decorations: g,
createSelectionBetween: (e, t, n) =>
t.pos == n.pos && d.valid(n) ? new d(n) : null,
handleClick: f,
handleKeyDown: p,
handleDOMEvents: { beforeinput: m },
},
}),
],
extendNodeSchema(e) {
var n;
let r = { name: e.name, options: e.options, storage: e.storage };
return {
allowGapCursor:
null !=
(n = (0, t.callOrReturn)(
(0, t.getExtensionField)(e, "allowGapCursor", r),
))
? n
: null,
};
},
}),
z = "placeholder",
B = t.Extension.create({
name: "placeholder",
addOptions: () => ({
emptyEditorClass: "is-editor-empty",
emptyNodeClass: "is-empty",
dataAttribute: z,
placeholder: "Write something …",
showOnlyWhenEditable: !0,
showOnlyCurrent: !0,
includeChildren: !1,
}),
addProseMirrorPlugins() {
let e = this.options.dataAttribute
? `data-${this.options.dataAttribute
.replace(/\s+/g, "-")
.replace(/[^a-zA-Z0-9-]/g, "")
.replace(/^[0-9-]+/, "")
.replace(/^-+/, "")
.toLowerCase()}`
: `data-${z}`;
return [
new n.Plugin({
key: new n.PluginKey("placeholder"),
props: {
decorations: ({ doc: n, selection: r }) => {
let i =
this.editor.isEditable ||
!this.options.showOnlyWhenEditable,
{ anchor: s } = r,
l = [];
if (!i) return null;
let a = this.editor.isEmpty;
return (
n.descendants((n, r) => {
let i = s >= r && s <= r + n.nodeSize,
d = !n.isLeaf && (0, t.isNodeEmpty)(n);
if ((i || !this.options.showOnlyCurrent) && d) {
let t = [this.options.emptyNodeClass];
a && t.push(this.options.emptyEditorClass);
let s = o.Decoration.node(r, r + n.nodeSize, {
class: t.join(" "),
[e]:
"function" == typeof this.options.placeholder
? this.options.placeholder({
editor: this.editor,
node: n,
pos: r,
hasAnchor: i,
})
: this.options.placeholder,
});
l.push(s);
}
return this.options.includeChildren;
}),
o.DecorationSet.create(n, l)
);
},
},
}),
];
},
});
function $({ types: e, node: t }) {
return (
(t && Array.isArray(e) && e.includes(t.type)) ||
(null == t ? void 0 : t.type) === e
);
}
t.Extension.create({
name: "selection",
addOptions: () => ({ className: "selection" }),
addProseMirrorPlugins() {
let { editor: e, options: r } = this;
return [
new n.Plugin({
key: new n.PluginKey("selection"),
props: {
decorations: (n) =>
n.selection.empty ||
e.isFocused ||
!e.isEditable ||
(0, t.isNodeSelection)(n.selection) ||
e.view.dragging
? null
: o.DecorationSet.create(n.doc, [
o.Decoration.inline(n.selection.from, n.selection.to, {
class: r.className,
}),
]),
},
}),
];
},
});
var j = t.Extension.create({
name: "trailingNode",
addOptions: () => ({ node: void 0, notAfter: [] }),
addProseMirrorPlugins() {
var e;
let t = new n.PluginKey(this.name),
r =
this.options.node ||
(null ==
(e = this.editor.schema.topNodeType.contentMatch.defaultType)
? void 0
: e.name) ||
"paragraph",
i = Object.entries(this.editor.schema.nodes)
.map(([, e]) => e)
.filter((e) =>
(this.options.notAfter || []).concat(r).includes(e.name),
);
return [
new n.Plugin({
key: t,
appendTransaction: (e, n, i) => {
let { doc: o, tr: s, schema: l } = i,
a = t.getState(i),
d = o.content.size,
c = l.nodes[r];
if (a) return s.insert(d, c.create());
},
state: {
init: (e, t) => !$({ node: t.tr.doc.lastChild, types: i }),
apply: (e, t) =>
!e.docChanged || e.getMeta("__uniqueIDTransaction")
? t
: !$({ node: e.doc.lastChild, types: i }),
},
}),
];
},
}),
F = t.Extension.create({
name: "undoRedo",
addOptions: () => ({ depth: 100, newGroupDelay: 500 }),
addCommands: () => ({
undo:
() =>
({ state: e, dispatch: t }) =>
R(e, t),
redo:
() =>
({ state: e, dispatch: t }) =>
I(e, t),
}),
addProseMirrorPlugins() {
return [
(function (e = {}) {
return (
(e = {
depth: e.depth || 100,
newGroupDelay: e.newGroupDelay || 500,
}),
new n.Plugin({
key: O,
state: {
init: () => new S(v.empty, v.empty, null, 0, -1),
apply: (t, n, r) =>
(function (e, t, n, r) {
let i = n.getMeta(O),
o;
if (i) return i.historyState;
n.getMeta(A) &&
(e = new S(e.done, e.undone, null, 0, -1));
let s = n.getMeta("appendedTransaction");
if (0 == n.steps.length) return e;
if (s && s.getMeta(O))
if (s.getMeta(O).redo)
return new S(
e.done.addTransform(n, void 0, r, E(t)),
e.undone,
M(n.mapping.maps),
e.prevTime,
e.prevComposition,
);
else
return new S(
e.done,
e.undone.addTransform(n, void 0, r, E(t)),
null,
e.prevTime,
e.prevComposition,
);
if (
!1 === n.getMeta("addToHistory") ||
(s && !1 === s.getMeta("addToHistory"))
)
if ((o = n.getMeta("rebased")))
return new S(
e.done.rebased(n, o),
e.undone.rebased(n, o),
C(e.prevRanges, n.mapping),
e.prevTime,
e.prevComposition,
);
else
return new S(
e.done.addMaps(n.mapping.maps),
e.undone.addMaps(n.mapping.maps),
C(e.prevRanges, n.mapping),
e.prevTime,
e.prevComposition,
);
{
let i = n.getMeta("composition"),
o =
0 == e.prevTime ||
(!s &&
e.prevComposition != i &&
(e.prevTime < (n.time || 0) - r.newGroupDelay ||
!(function (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
);
})(n, e.prevRanges))),
l = s
? C(e.prevRanges, n.mapping)
: M(n.mapping.maps);
return new S(
e.done.addTransform(
n,
o ? t.selection.getBookmark() : void 0,
r,
E(t),
),
v.empty,
l,
n.time,
null == i ? e.prevComposition : i,
);
}
})(n, r, t, e),
},
config: e,
props: {
handleDOMEvents: {
beforeinput(e, t) {
let n = t.inputType,
r =
"historyUndo" == n
? R
: "historyRedo" == n
? I
: null;
return (
!!r &&
!!e.editable &&
(t.preventDefault(), r(e.state, e.dispatch))
);
},
},
},
})
);
})(this.options),
];
},
addKeyboardShortcuts() {
return {
"Mod-z": () => this.editor.commands.undo(),
"Shift-Mod-z": () => this.editor.commands.redo(),
"Mod-y": () => this.editor.commands.redo(),
"Mod-я": () => this.editor.commands.undo(),
"Shift-Mod-я": () => this.editor.commands.redo(),
};
},
});
e.s(
[
"Dropcursor",
() => P,
"Gapcursor",
() => L,
"Placeholder",
() => B,
"TrailingNode",
() => j,
"UndoRedo",
() => F,
],
589430,
),
e.s(["default", () => B], 853025);
};
export default moduleFactory;