@milkdown/transformer
Advanced tools
Comparing version 7.2.0 to 7.2.1
@@ -1,42 +0,26 @@ | ||
var W = Object.defineProperty; | ||
var X = (o, n, t) => n in o ? W(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t; | ||
var h = (o, n, t) => (X(o, typeof n != "symbol" ? n + "" : n, t), t), K = (o, n, t) => { | ||
if (!n.has(o)) | ||
throw TypeError("Cannot " + t); | ||
}; | ||
var i = (o, n, t) => (K(o, n, "read from private field"), t ? t.call(o) : n.get(o)), c = (o, n, t) => { | ||
if (n.has(o)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
n instanceof WeakSet ? n.add(o) : n.set(o, t); | ||
}, m = (o, n, t, e) => (K(o, n, "write to private field"), e ? e.call(o, t) : n.set(o, t), t); | ||
import { stackOverFlow as L, parserMatchError as Y, createNodeInParserFail as Z, serializerMatchError as $ } from "@milkdown/exception"; | ||
import { Mark as T } from "@milkdown/prose/model"; | ||
class Q { | ||
import { stackOverFlow as G, parserMatchError as V, createNodeInParserFail as X, serializerMatchError as Y } from "@milkdown/exception"; | ||
import { Mark as v } from "@milkdown/prose/model"; | ||
class J { | ||
} | ||
class U { | ||
class q { | ||
constructor() { | ||
h(this, "elements", []); | ||
h(this, "size", () => this.elements.length); | ||
h(this, "top", () => this.elements.at(-1)); | ||
h(this, "push", (n) => { | ||
var t; | ||
(t = this.top()) == null || t.push(n); | ||
}); | ||
h(this, "open", (n) => { | ||
this.elements.push(n); | ||
}); | ||
h(this, "close", () => { | ||
const n = this.elements.pop(); | ||
if (!n) | ||
throw L(); | ||
return n; | ||
}); | ||
this.elements = [], this.size = () => this.elements.length, this.top = () => this.elements.at(-1), this.push = (t) => { | ||
var e; | ||
(e = this.top()) == null || e.push(t); | ||
}, this.open = (t) => { | ||
this.elements.push(t); | ||
}, this.close = () => { | ||
const t = this.elements.pop(); | ||
if (!t) | ||
throw G(); | ||
return t; | ||
}; | ||
} | ||
} | ||
class z extends Q { | ||
constructor(n, t, e) { | ||
super(), this.type = n, this.content = t, this.attrs = e; | ||
class R extends J { | ||
constructor(t, e, s) { | ||
super(), this.type = t, this.content = e, this.attrs = s; | ||
} | ||
push(n, ...t) { | ||
this.content.push(n, ...t); | ||
push(t, ...e) { | ||
this.content.push(t, ...e); | ||
} | ||
@@ -46,151 +30,141 @@ pop() { | ||
} | ||
static create(n, t, e) { | ||
return new z(n, t, e); | ||
static create(t, e, s) { | ||
return new R(t, e, s); | ||
} | ||
} | ||
var a, v, F, A, E, w, x; | ||
const B = class extends U { | ||
constructor(t) { | ||
super(); | ||
h(this, "schema"); | ||
c(this, a, T.none); | ||
c(this, v, (t) => t.isText); | ||
c(this, F, (t, e) => { | ||
if (i(this, v).call(this, t) && i(this, v).call(this, e) && T.sameSet(t.marks, e.marks)) | ||
var B = (r, t, e) => { | ||
if (!t.has(r)) | ||
throw TypeError("Cannot " + e); | ||
}, c = (r, t, e) => (B(r, t, "read from private field"), e ? e.call(r) : t.get(r)), d = (r, t, e) => { | ||
if (t.has(r)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
t instanceof WeakSet ? t.add(r) : t.set(r, e); | ||
}, E = (r, t, e, s) => (B(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), l, _, P, T, z, y, m; | ||
const H = class extends q { | ||
/// @internal | ||
constructor(r) { | ||
super(), d(this, l, v.none), d(this, _, (t) => t.isText), d(this, P, (t, e) => { | ||
if (c(this, _).call(this, t) && c(this, _).call(this, e) && v.sameSet(t.marks, e.marks)) | ||
return this.schema.text(t.text + e.text, t.marks); | ||
}); | ||
c(this, A, (t) => { | ||
}), d(this, T, (t) => { | ||
const e = Object.values({ ...this.schema.nodes, ...this.schema.marks }).find((s) => s.spec.parseMarkdown.match(t)); | ||
if (!e) | ||
throw Y(t); | ||
throw V(t); | ||
return e; | ||
}); | ||
c(this, E, (t) => { | ||
const e = i(this, A).call(this, t); | ||
}), d(this, z, (t) => { | ||
const e = c(this, T).call(this, t); | ||
e.spec.parseMarkdown.runner(this, t, e); | ||
}); | ||
h(this, "injectRoot", (t, e, s) => (this.openNode(e, s), this.next(t.children), this)); | ||
h(this, "openNode", (t, e) => (this.open(z.create(t, [], e)), this)); | ||
c(this, w, () => { | ||
m(this, a, T.none); | ||
}), this.injectRoot = (t, e, s) => (this.openNode(e, s), this.next(t.children), this), this.openNode = (t, e) => (this.open(R.create(t, [], e)), this), d(this, y, () => { | ||
E(this, l, v.none); | ||
const t = this.close(); | ||
return i(this, x).call(this, t.type, t.attrs, t.content); | ||
}); | ||
h(this, "closeNode", () => (i(this, w).call(this), this)); | ||
c(this, x, (t, e, s) => { | ||
const r = t.createAndFill(e, s, i(this, a)); | ||
if (!r) | ||
throw Z(t, e, s); | ||
return this.push(r), r; | ||
}); | ||
h(this, "addNode", (t, e, s) => (i(this, x).call(this, t, e, s), this)); | ||
h(this, "openMark", (t, e) => { | ||
return c(this, m).call(this, t.type, t.attrs, t.content); | ||
}), this.closeNode = () => (c(this, y).call(this), this), d(this, m, (t, e, s) => { | ||
const i = t.createAndFill(e, s, c(this, l)); | ||
if (!i) | ||
throw X(t, e, s); | ||
return this.push(i), i; | ||
}), this.addNode = (t, e, s) => (c(this, m).call(this, t, e, s), this), this.openMark = (t, e) => { | ||
const s = t.create(e); | ||
return m(this, a, s.addToSet(i(this, a))), this; | ||
}); | ||
h(this, "closeMark", (t) => (m(this, a, t.removeFromSet(i(this, a))), this)); | ||
h(this, "addText", (t) => { | ||
return E(this, l, s.addToSet(c(this, l))), this; | ||
}, this.closeMark = (t) => (E(this, l, t.removeFromSet(c(this, l))), this), this.addText = (t) => { | ||
const e = this.top(); | ||
if (!e) | ||
throw L(); | ||
const s = e.pop(), r = this.schema.text(t, i(this, a)); | ||
throw G(); | ||
const s = e.pop(), i = this.schema.text(t, c(this, l)); | ||
if (!s) | ||
return e.push(r), this; | ||
const p = i(this, F).call(this, s, r); | ||
return p ? (e.push(p), this) : (e.push(s, r), this); | ||
}); | ||
h(this, "build", () => { | ||
return e.push(i), this; | ||
const a = c(this, P).call(this, s, i); | ||
return a ? (e.push(a), this) : (e.push(s, i), this); | ||
}, this.build = () => { | ||
let t; | ||
do | ||
t = i(this, w).call(this); | ||
t = c(this, y).call(this); | ||
while (this.size()); | ||
return t; | ||
}); | ||
h(this, "next", (t = []) => ([t].flat().forEach((e) => i(this, E).call(this, e)), this)); | ||
h(this, "toDoc", () => this.build()); | ||
h(this, "run", (t, e) => { | ||
}, this.next = (t = []) => ([t].flat().forEach((e) => c(this, z).call(this, e)), this), this.toDoc = () => this.build(), this.run = (t, e) => { | ||
const s = t.runSync(t.parse(e), e); | ||
return this.next(s), this; | ||
}); | ||
this.schema = t; | ||
}, this.schema = r; | ||
} | ||
}; | ||
let S = B; | ||
a = new WeakMap(), v = new WeakMap(), F = new WeakMap(), A = new WeakMap(), E = new WeakMap(), w = new WeakMap(), x = new WeakMap(), h(S, "create", (t, e) => { | ||
const s = new B(t); | ||
return (r) => (s.run(e, r), s.toDoc()); | ||
}); | ||
const G = class extends Q { | ||
constructor(t, e, s, r = {}) { | ||
super(); | ||
h(this, "push", (t, ...e) => { | ||
this.children || (this.children = []), this.children.push(t, ...e); | ||
}); | ||
h(this, "pop", () => { | ||
var t; | ||
return (t = this.children) == null ? void 0 : t.pop(); | ||
}); | ||
this.type = t, this.children = e, this.value = s, this.props = r; | ||
let Z = H; | ||
l = /* @__PURE__ */ new WeakMap(); | ||
_ = /* @__PURE__ */ new WeakMap(); | ||
P = /* @__PURE__ */ new WeakMap(); | ||
T = /* @__PURE__ */ new WeakMap(); | ||
z = /* @__PURE__ */ new WeakMap(); | ||
y = /* @__PURE__ */ new WeakMap(); | ||
m = /* @__PURE__ */ new WeakMap(); | ||
Z.create = (r, t) => { | ||
const e = new H(r); | ||
return (s) => (e.run(t, s), e.toDoc()); | ||
}; | ||
const K = class extends J { | ||
constructor(r, t, e, s = {}) { | ||
super(), this.type = r, this.children = t, this.value = e, this.props = s, this.push = (i, ...a) => { | ||
this.children || (this.children = []), this.children.push(i, ...a); | ||
}, this.pop = () => { | ||
var i; | ||
return (i = this.children) == null ? void 0 : i.pop(); | ||
}; | ||
} | ||
}; | ||
let M = G; | ||
h(M, "create", (t, e, s, r = {}) => new G(t, e, s, r)); | ||
const _ = (o) => Object.prototype.hasOwnProperty.call(o, "size"); | ||
var d, g, j, R, P, C, b, D, y, I, J, O; | ||
const H = class extends U { | ||
constructor(t) { | ||
super(); | ||
c(this, d, T.none); | ||
h(this, "schema"); | ||
c(this, g, (t) => { | ||
let $ = K; | ||
$.create = (r, t, e, s = {}) => new K(r, t, e, s); | ||
var L = (r, t, e) => { | ||
if (!t.has(r)) | ||
throw TypeError("Cannot " + e); | ||
}, n = (r, t, e) => (L(r, t, "read from private field"), e ? e.call(r) : t.get(r)), o = (r, t, e) => { | ||
if (t.has(r)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
t instanceof WeakSet ? t.add(r) : t.set(r, e); | ||
}, D = (r, t, e, s) => (L(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), p, S, C, A, N, I, W, O, M, x, F, g; | ||
const j = (r) => Object.prototype.hasOwnProperty.call(r, "size"), Q = class extends q { | ||
/// @internal | ||
constructor(r) { | ||
super(), o(this, p, v.none), o(this, S, (t) => { | ||
const e = Object.values({ ...this.schema.nodes, ...this.schema.marks }).find((s) => s.spec.toMarkdown.match(t)); | ||
if (!e) | ||
throw $(t.type); | ||
throw Y(t.type); | ||
return e; | ||
}); | ||
c(this, j, (t) => i(this, g).call(this, t).spec.toMarkdown.runner(this, t)); | ||
c(this, R, (t, e) => i(this, g).call(this, t).spec.toMarkdown.runner(this, t, e)); | ||
c(this, P, (t) => { | ||
const { marks: e } = t, s = (u) => u.type.spec.priority ?? 50; | ||
[...e].sort((u, l) => s(u) - s(l)).every((u) => !i(this, R).call(this, u, t)) && i(this, j).call(this, t), e.forEach((u) => i(this, O).call(this, u)); | ||
}); | ||
c(this, C, (t, e) => { | ||
var l; | ||
if (t.type === e || ((l = t.children) == null ? void 0 : l.length) !== 1) | ||
}), o(this, C, (t) => n(this, S).call(this, t).spec.toMarkdown.runner(this, t)), o(this, A, (t, e) => n(this, S).call(this, t).spec.toMarkdown.runner(this, t, e)), o(this, N, (t) => { | ||
const { marks: e } = t, s = (h) => h.type.spec.priority ?? 50; | ||
[...e].sort((h, u) => s(h) - s(u)).every((h) => !n(this, A).call(this, h, t)) && n(this, C).call(this, t), e.forEach((h) => n(this, g).call(this, h)); | ||
}), o(this, I, (t, e) => { | ||
var u; | ||
if (t.type === e || ((u = t.children) == null ? void 0 : u.length) !== 1) | ||
return t; | ||
const s = (f) => { | ||
var k; | ||
var w; | ||
if (f.type === e) | ||
return f; | ||
if (((k = f.children) == null ? void 0 : k.length) !== 1) | ||
if (((w = f.children) == null ? void 0 : w.length) !== 1) | ||
return null; | ||
const [N] = f.children; | ||
return N ? s(N) : null; | ||
}, r = s(t); | ||
if (!r) | ||
const [k] = f.children; | ||
return k ? s(k) : null; | ||
}, i = s(t); | ||
if (!i) | ||
return t; | ||
const p = r.children ? [...r.children] : void 0, u = { ...t, children: p }; | ||
return u.children = p, r.children = [u], r; | ||
}); | ||
c(this, b, (t) => { | ||
const a = i.children ? [...i.children] : void 0, h = { ...t, children: a }; | ||
return h.children = a, i.children = [h], i; | ||
}), o(this, W, (t) => { | ||
const { children: e } = t; | ||
return e && (t.children = e.reduce((s, r, p) => { | ||
if (p === 0) | ||
return [r]; | ||
const u = s.at(-1); | ||
if (u && u.isMark && r.isMark) { | ||
r = i(this, C).call(this, r, u.type); | ||
const { children: l, ...f } = r, { children: N, ...k } = u; | ||
if (r.type === u.type && l && N && JSON.stringify(f) === JSON.stringify(k)) { | ||
const V = { | ||
...k, | ||
children: [...N, ...l] | ||
return e && (t.children = e.reduce((s, i, a) => { | ||
if (a === 0) | ||
return [i]; | ||
const h = s.at(-1); | ||
if (h && h.isMark && i.isMark) { | ||
i = n(this, I).call(this, i, h.type); | ||
const { children: u, ...f } = i, { children: k, ...w } = h; | ||
if (i.type === h.type && u && k && JSON.stringify(f) === JSON.stringify(w)) { | ||
const U = { | ||
...w, | ||
children: [...k, ...u] | ||
}; | ||
return s.slice(0, -1).concat(i(this, b).call(this, V)); | ||
return s.slice(0, -1).concat(n(this, W).call(this, U)); | ||
} | ||
} | ||
return s.concat(r); | ||
return s.concat(i); | ||
}, [])), t; | ||
}); | ||
c(this, D, (t) => { | ||
}), o(this, O, (t) => { | ||
const e = { | ||
@@ -201,46 +175,44 @@ ...t.props, | ||
return t.children && (e.children = t.children), t.value && (e.value = t.value), e; | ||
}); | ||
h(this, "openNode", (t, e, s) => (this.open(M.create(t, void 0, e, s)), this)); | ||
c(this, y, () => { | ||
}), this.openNode = (t, e, s) => (this.open($.create(t, void 0, e, s)), this), o(this, M, () => { | ||
const t = this.close(); | ||
return i(this, I).call(this, t.type, t.children, t.value, t.props); | ||
}); | ||
h(this, "closeNode", () => (i(this, y).call(this), this)); | ||
c(this, I, (t, e, s, r) => { | ||
const p = M.create(t, e, s, r), u = i(this, b).call(this, i(this, D).call(this, p)); | ||
return this.push(u), u; | ||
}); | ||
h(this, "addNode", (t, e, s, r) => (i(this, I).call(this, t, e, s, r), this)); | ||
c(this, J, (t, e, s, r) => t.isInSet(i(this, d)) ? this : (m(this, d, t.addToSet(i(this, d))), this.openNode(e, s, { ...r, isMark: !0 }))); | ||
c(this, O, (t) => { | ||
!t.isInSet(i(this, d)) || (m(this, d, t.type.removeFromSet(i(this, d))), i(this, y).call(this)); | ||
}); | ||
h(this, "withMark", (t, e, s, r) => (i(this, J).call(this, t, e, s, r), this)); | ||
h(this, "closeMark", (t) => (i(this, O).call(this, t), this)); | ||
h(this, "build", () => { | ||
return n(this, x).call(this, t.type, t.children, t.value, t.props); | ||
}), this.closeNode = () => (n(this, M).call(this), this), o(this, x, (t, e, s, i) => { | ||
const a = $.create(t, e, s, i), h = n(this, W).call(this, n(this, O).call(this, a)); | ||
return this.push(h), h; | ||
}), this.addNode = (t, e, s, i) => (n(this, x).call(this, t, e, s, i), this), o(this, F, (t, e, s, i) => t.isInSet(n(this, p)) ? this : (D(this, p, t.addToSet(n(this, p))), this.openNode(e, s, { ...i, isMark: !0 }))), o(this, g, (t) => { | ||
t.isInSet(n(this, p)) && (D(this, p, t.type.removeFromSet(n(this, p))), n(this, M).call(this)); | ||
}), this.withMark = (t, e, s, i) => (n(this, F).call(this, t, e, s, i), this), this.closeMark = (t) => (n(this, g).call(this, t), this), this.build = () => { | ||
let t = null; | ||
do | ||
t = i(this, y).call(this); | ||
t = n(this, M).call(this); | ||
while (this.size()); | ||
return t; | ||
}); | ||
h(this, "next", (t) => _(t) ? (t.forEach((e) => { | ||
i(this, P).call(this, e); | ||
}), this) : (i(this, P).call(this, t), this)); | ||
h(this, "toString", (t) => t.stringify(this.build())); | ||
h(this, "run", (t) => (this.next(t), this)); | ||
this.schema = t; | ||
}, this.next = (t) => j(t) ? (t.forEach((e) => { | ||
n(this, N).call(this, e); | ||
}), this) : (n(this, N).call(this, t), this), this.toString = (t) => t.stringify(this.build()), this.run = (t) => (this.next(t), this), this.schema = r; | ||
} | ||
}; | ||
let q = H; | ||
d = new WeakMap(), g = new WeakMap(), j = new WeakMap(), R = new WeakMap(), P = new WeakMap(), C = new WeakMap(), b = new WeakMap(), D = new WeakMap(), y = new WeakMap(), I = new WeakMap(), J = new WeakMap(), O = new WeakMap(), h(q, "create", (t, e) => { | ||
const s = new H(t); | ||
return (r) => (s.run(r), s.toString(e)); | ||
}); | ||
let b = Q; | ||
p = /* @__PURE__ */ new WeakMap(); | ||
S = /* @__PURE__ */ new WeakMap(); | ||
C = /* @__PURE__ */ new WeakMap(); | ||
A = /* @__PURE__ */ new WeakMap(); | ||
N = /* @__PURE__ */ new WeakMap(); | ||
I = /* @__PURE__ */ new WeakMap(); | ||
W = /* @__PURE__ */ new WeakMap(); | ||
O = /* @__PURE__ */ new WeakMap(); | ||
M = /* @__PURE__ */ new WeakMap(); | ||
x = /* @__PURE__ */ new WeakMap(); | ||
F = /* @__PURE__ */ new WeakMap(); | ||
g = /* @__PURE__ */ new WeakMap(); | ||
b.create = (r, t) => { | ||
const e = new Q(r); | ||
return (s) => (e.run(s), e.toString(t)); | ||
}; | ||
export { | ||
S as ParserState, | ||
q as SerializerState, | ||
U as Stack, | ||
Q as StackElement | ||
Z as ParserState, | ||
b as SerializerState, | ||
q as Stack, | ||
J as StackElement | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
@@ -1,42 +0,26 @@ | ||
var W = Object.defineProperty; | ||
var X = (o, n, t) => n in o ? W(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t; | ||
var h = (o, n, t) => (X(o, typeof n != "symbol" ? n + "" : n, t), t), K = (o, n, t) => { | ||
if (!n.has(o)) | ||
throw TypeError("Cannot " + t); | ||
}; | ||
var i = (o, n, t) => (K(o, n, "read from private field"), t ? t.call(o) : n.get(o)), c = (o, n, t) => { | ||
if (n.has(o)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
n instanceof WeakSet ? n.add(o) : n.set(o, t); | ||
}, m = (o, n, t, e) => (K(o, n, "write to private field"), e ? e.call(o, t) : n.set(o, t), t); | ||
import { stackOverFlow as L, parserMatchError as Y, createNodeInParserFail as Z, serializerMatchError as $ } from "@milkdown/exception"; | ||
import { Mark as T } from "@milkdown/prose/model"; | ||
class Q { | ||
import { stackOverFlow as G, parserMatchError as V, createNodeInParserFail as X, serializerMatchError as Y } from "@milkdown/exception"; | ||
import { Mark as v } from "@milkdown/prose/model"; | ||
class J { | ||
} | ||
class U { | ||
class q { | ||
constructor() { | ||
h(this, "elements", []); | ||
h(this, "size", () => this.elements.length); | ||
h(this, "top", () => this.elements.at(-1)); | ||
h(this, "push", (n) => { | ||
var t; | ||
(t = this.top()) == null || t.push(n); | ||
}); | ||
h(this, "open", (n) => { | ||
this.elements.push(n); | ||
}); | ||
h(this, "close", () => { | ||
const n = this.elements.pop(); | ||
if (!n) | ||
throw L(); | ||
return n; | ||
}); | ||
this.elements = [], this.size = () => this.elements.length, this.top = () => this.elements.at(-1), this.push = (t) => { | ||
var e; | ||
(e = this.top()) == null || e.push(t); | ||
}, this.open = (t) => { | ||
this.elements.push(t); | ||
}, this.close = () => { | ||
const t = this.elements.pop(); | ||
if (!t) | ||
throw G(); | ||
return t; | ||
}; | ||
} | ||
} | ||
class z extends Q { | ||
constructor(n, t, e) { | ||
super(), this.type = n, this.content = t, this.attrs = e; | ||
class R extends J { | ||
constructor(t, e, s) { | ||
super(), this.type = t, this.content = e, this.attrs = s; | ||
} | ||
push(n, ...t) { | ||
this.content.push(n, ...t); | ||
push(t, ...e) { | ||
this.content.push(t, ...e); | ||
} | ||
@@ -46,151 +30,141 @@ pop() { | ||
} | ||
static create(n, t, e) { | ||
return new z(n, t, e); | ||
static create(t, e, s) { | ||
return new R(t, e, s); | ||
} | ||
} | ||
var a, v, F, A, E, w, x; | ||
const B = class extends U { | ||
constructor(t) { | ||
super(); | ||
h(this, "schema"); | ||
c(this, a, T.none); | ||
c(this, v, (t) => t.isText); | ||
c(this, F, (t, e) => { | ||
if (i(this, v).call(this, t) && i(this, v).call(this, e) && T.sameSet(t.marks, e.marks)) | ||
var B = (r, t, e) => { | ||
if (!t.has(r)) | ||
throw TypeError("Cannot " + e); | ||
}, c = (r, t, e) => (B(r, t, "read from private field"), e ? e.call(r) : t.get(r)), d = (r, t, e) => { | ||
if (t.has(r)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
t instanceof WeakSet ? t.add(r) : t.set(r, e); | ||
}, E = (r, t, e, s) => (B(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), l, _, P, T, z, y, m; | ||
const H = class extends q { | ||
/// @internal | ||
constructor(r) { | ||
super(), d(this, l, v.none), d(this, _, (t) => t.isText), d(this, P, (t, e) => { | ||
if (c(this, _).call(this, t) && c(this, _).call(this, e) && v.sameSet(t.marks, e.marks)) | ||
return this.schema.text(t.text + e.text, t.marks); | ||
}); | ||
c(this, A, (t) => { | ||
}), d(this, T, (t) => { | ||
const e = Object.values({ ...this.schema.nodes, ...this.schema.marks }).find((s) => s.spec.parseMarkdown.match(t)); | ||
if (!e) | ||
throw Y(t); | ||
throw V(t); | ||
return e; | ||
}); | ||
c(this, E, (t) => { | ||
const e = i(this, A).call(this, t); | ||
}), d(this, z, (t) => { | ||
const e = c(this, T).call(this, t); | ||
e.spec.parseMarkdown.runner(this, t, e); | ||
}); | ||
h(this, "injectRoot", (t, e, s) => (this.openNode(e, s), this.next(t.children), this)); | ||
h(this, "openNode", (t, e) => (this.open(z.create(t, [], e)), this)); | ||
c(this, w, () => { | ||
m(this, a, T.none); | ||
}), this.injectRoot = (t, e, s) => (this.openNode(e, s), this.next(t.children), this), this.openNode = (t, e) => (this.open(R.create(t, [], e)), this), d(this, y, () => { | ||
E(this, l, v.none); | ||
const t = this.close(); | ||
return i(this, x).call(this, t.type, t.attrs, t.content); | ||
}); | ||
h(this, "closeNode", () => (i(this, w).call(this), this)); | ||
c(this, x, (t, e, s) => { | ||
const r = t.createAndFill(e, s, i(this, a)); | ||
if (!r) | ||
throw Z(t, e, s); | ||
return this.push(r), r; | ||
}); | ||
h(this, "addNode", (t, e, s) => (i(this, x).call(this, t, e, s), this)); | ||
h(this, "openMark", (t, e) => { | ||
return c(this, m).call(this, t.type, t.attrs, t.content); | ||
}), this.closeNode = () => (c(this, y).call(this), this), d(this, m, (t, e, s) => { | ||
const i = t.createAndFill(e, s, c(this, l)); | ||
if (!i) | ||
throw X(t, e, s); | ||
return this.push(i), i; | ||
}), this.addNode = (t, e, s) => (c(this, m).call(this, t, e, s), this), this.openMark = (t, e) => { | ||
const s = t.create(e); | ||
return m(this, a, s.addToSet(i(this, a))), this; | ||
}); | ||
h(this, "closeMark", (t) => (m(this, a, t.removeFromSet(i(this, a))), this)); | ||
h(this, "addText", (t) => { | ||
return E(this, l, s.addToSet(c(this, l))), this; | ||
}, this.closeMark = (t) => (E(this, l, t.removeFromSet(c(this, l))), this), this.addText = (t) => { | ||
const e = this.top(); | ||
if (!e) | ||
throw L(); | ||
const s = e.pop(), r = this.schema.text(t, i(this, a)); | ||
throw G(); | ||
const s = e.pop(), i = this.schema.text(t, c(this, l)); | ||
if (!s) | ||
return e.push(r), this; | ||
const p = i(this, F).call(this, s, r); | ||
return p ? (e.push(p), this) : (e.push(s, r), this); | ||
}); | ||
h(this, "build", () => { | ||
return e.push(i), this; | ||
const a = c(this, P).call(this, s, i); | ||
return a ? (e.push(a), this) : (e.push(s, i), this); | ||
}, this.build = () => { | ||
let t; | ||
do | ||
t = i(this, w).call(this); | ||
t = c(this, y).call(this); | ||
while (this.size()); | ||
return t; | ||
}); | ||
h(this, "next", (t = []) => ([t].flat().forEach((e) => i(this, E).call(this, e)), this)); | ||
h(this, "toDoc", () => this.build()); | ||
h(this, "run", (t, e) => { | ||
}, this.next = (t = []) => ([t].flat().forEach((e) => c(this, z).call(this, e)), this), this.toDoc = () => this.build(), this.run = (t, e) => { | ||
const s = t.runSync(t.parse(e), e); | ||
return this.next(s), this; | ||
}); | ||
this.schema = t; | ||
}, this.schema = r; | ||
} | ||
}; | ||
let S = B; | ||
a = new WeakMap(), v = new WeakMap(), F = new WeakMap(), A = new WeakMap(), E = new WeakMap(), w = new WeakMap(), x = new WeakMap(), h(S, "create", (t, e) => { | ||
const s = new B(t); | ||
return (r) => (s.run(e, r), s.toDoc()); | ||
}); | ||
const G = class extends Q { | ||
constructor(t, e, s, r = {}) { | ||
super(); | ||
h(this, "push", (t, ...e) => { | ||
this.children || (this.children = []), this.children.push(t, ...e); | ||
}); | ||
h(this, "pop", () => { | ||
var t; | ||
return (t = this.children) == null ? void 0 : t.pop(); | ||
}); | ||
this.type = t, this.children = e, this.value = s, this.props = r; | ||
let Z = H; | ||
l = /* @__PURE__ */ new WeakMap(); | ||
_ = /* @__PURE__ */ new WeakMap(); | ||
P = /* @__PURE__ */ new WeakMap(); | ||
T = /* @__PURE__ */ new WeakMap(); | ||
z = /* @__PURE__ */ new WeakMap(); | ||
y = /* @__PURE__ */ new WeakMap(); | ||
m = /* @__PURE__ */ new WeakMap(); | ||
Z.create = (r, t) => { | ||
const e = new H(r); | ||
return (s) => (e.run(t, s), e.toDoc()); | ||
}; | ||
const K = class extends J { | ||
constructor(r, t, e, s = {}) { | ||
super(), this.type = r, this.children = t, this.value = e, this.props = s, this.push = (i, ...a) => { | ||
this.children || (this.children = []), this.children.push(i, ...a); | ||
}, this.pop = () => { | ||
var i; | ||
return (i = this.children) == null ? void 0 : i.pop(); | ||
}; | ||
} | ||
}; | ||
let M = G; | ||
h(M, "create", (t, e, s, r = {}) => new G(t, e, s, r)); | ||
const _ = (o) => Object.prototype.hasOwnProperty.call(o, "size"); | ||
var d, g, j, R, P, C, b, D, y, I, J, O; | ||
const H = class extends U { | ||
constructor(t) { | ||
super(); | ||
c(this, d, T.none); | ||
h(this, "schema"); | ||
c(this, g, (t) => { | ||
let $ = K; | ||
$.create = (r, t, e, s = {}) => new K(r, t, e, s); | ||
var L = (r, t, e) => { | ||
if (!t.has(r)) | ||
throw TypeError("Cannot " + e); | ||
}, n = (r, t, e) => (L(r, t, "read from private field"), e ? e.call(r) : t.get(r)), o = (r, t, e) => { | ||
if (t.has(r)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
t instanceof WeakSet ? t.add(r) : t.set(r, e); | ||
}, D = (r, t, e, s) => (L(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), p, S, C, A, N, I, W, O, M, x, F, g; | ||
const j = (r) => Object.prototype.hasOwnProperty.call(r, "size"), Q = class extends q { | ||
/// @internal | ||
constructor(r) { | ||
super(), o(this, p, v.none), o(this, S, (t) => { | ||
const e = Object.values({ ...this.schema.nodes, ...this.schema.marks }).find((s) => s.spec.toMarkdown.match(t)); | ||
if (!e) | ||
throw $(t.type); | ||
throw Y(t.type); | ||
return e; | ||
}); | ||
c(this, j, (t) => i(this, g).call(this, t).spec.toMarkdown.runner(this, t)); | ||
c(this, R, (t, e) => i(this, g).call(this, t).spec.toMarkdown.runner(this, t, e)); | ||
c(this, P, (t) => { | ||
const { marks: e } = t, s = (u) => u.type.spec.priority ?? 50; | ||
[...e].sort((u, l) => s(u) - s(l)).every((u) => !i(this, R).call(this, u, t)) && i(this, j).call(this, t), e.forEach((u) => i(this, O).call(this, u)); | ||
}); | ||
c(this, C, (t, e) => { | ||
var l; | ||
if (t.type === e || ((l = t.children) == null ? void 0 : l.length) !== 1) | ||
}), o(this, C, (t) => n(this, S).call(this, t).spec.toMarkdown.runner(this, t)), o(this, A, (t, e) => n(this, S).call(this, t).spec.toMarkdown.runner(this, t, e)), o(this, N, (t) => { | ||
const { marks: e } = t, s = (h) => h.type.spec.priority ?? 50; | ||
[...e].sort((h, u) => s(h) - s(u)).every((h) => !n(this, A).call(this, h, t)) && n(this, C).call(this, t), e.forEach((h) => n(this, g).call(this, h)); | ||
}), o(this, I, (t, e) => { | ||
var u; | ||
if (t.type === e || ((u = t.children) == null ? void 0 : u.length) !== 1) | ||
return t; | ||
const s = (f) => { | ||
var k; | ||
var w; | ||
if (f.type === e) | ||
return f; | ||
if (((k = f.children) == null ? void 0 : k.length) !== 1) | ||
if (((w = f.children) == null ? void 0 : w.length) !== 1) | ||
return null; | ||
const [N] = f.children; | ||
return N ? s(N) : null; | ||
}, r = s(t); | ||
if (!r) | ||
const [k] = f.children; | ||
return k ? s(k) : null; | ||
}, i = s(t); | ||
if (!i) | ||
return t; | ||
const p = r.children ? [...r.children] : void 0, u = { ...t, children: p }; | ||
return u.children = p, r.children = [u], r; | ||
}); | ||
c(this, b, (t) => { | ||
const a = i.children ? [...i.children] : void 0, h = { ...t, children: a }; | ||
return h.children = a, i.children = [h], i; | ||
}), o(this, W, (t) => { | ||
const { children: e } = t; | ||
return e && (t.children = e.reduce((s, r, p) => { | ||
if (p === 0) | ||
return [r]; | ||
const u = s.at(-1); | ||
if (u && u.isMark && r.isMark) { | ||
r = i(this, C).call(this, r, u.type); | ||
const { children: l, ...f } = r, { children: N, ...k } = u; | ||
if (r.type === u.type && l && N && JSON.stringify(f) === JSON.stringify(k)) { | ||
const V = { | ||
...k, | ||
children: [...N, ...l] | ||
return e && (t.children = e.reduce((s, i, a) => { | ||
if (a === 0) | ||
return [i]; | ||
const h = s.at(-1); | ||
if (h && h.isMark && i.isMark) { | ||
i = n(this, I).call(this, i, h.type); | ||
const { children: u, ...f } = i, { children: k, ...w } = h; | ||
if (i.type === h.type && u && k && JSON.stringify(f) === JSON.stringify(w)) { | ||
const U = { | ||
...w, | ||
children: [...k, ...u] | ||
}; | ||
return s.slice(0, -1).concat(i(this, b).call(this, V)); | ||
return s.slice(0, -1).concat(n(this, W).call(this, U)); | ||
} | ||
} | ||
return s.concat(r); | ||
return s.concat(i); | ||
}, [])), t; | ||
}); | ||
c(this, D, (t) => { | ||
}), o(this, O, (t) => { | ||
const e = { | ||
@@ -201,46 +175,44 @@ ...t.props, | ||
return t.children && (e.children = t.children), t.value && (e.value = t.value), e; | ||
}); | ||
h(this, "openNode", (t, e, s) => (this.open(M.create(t, void 0, e, s)), this)); | ||
c(this, y, () => { | ||
}), this.openNode = (t, e, s) => (this.open($.create(t, void 0, e, s)), this), o(this, M, () => { | ||
const t = this.close(); | ||
return i(this, I).call(this, t.type, t.children, t.value, t.props); | ||
}); | ||
h(this, "closeNode", () => (i(this, y).call(this), this)); | ||
c(this, I, (t, e, s, r) => { | ||
const p = M.create(t, e, s, r), u = i(this, b).call(this, i(this, D).call(this, p)); | ||
return this.push(u), u; | ||
}); | ||
h(this, "addNode", (t, e, s, r) => (i(this, I).call(this, t, e, s, r), this)); | ||
c(this, J, (t, e, s, r) => t.isInSet(i(this, d)) ? this : (m(this, d, t.addToSet(i(this, d))), this.openNode(e, s, { ...r, isMark: !0 }))); | ||
c(this, O, (t) => { | ||
!t.isInSet(i(this, d)) || (m(this, d, t.type.removeFromSet(i(this, d))), i(this, y).call(this)); | ||
}); | ||
h(this, "withMark", (t, e, s, r) => (i(this, J).call(this, t, e, s, r), this)); | ||
h(this, "closeMark", (t) => (i(this, O).call(this, t), this)); | ||
h(this, "build", () => { | ||
return n(this, x).call(this, t.type, t.children, t.value, t.props); | ||
}), this.closeNode = () => (n(this, M).call(this), this), o(this, x, (t, e, s, i) => { | ||
const a = $.create(t, e, s, i), h = n(this, W).call(this, n(this, O).call(this, a)); | ||
return this.push(h), h; | ||
}), this.addNode = (t, e, s, i) => (n(this, x).call(this, t, e, s, i), this), o(this, F, (t, e, s, i) => t.isInSet(n(this, p)) ? this : (D(this, p, t.addToSet(n(this, p))), this.openNode(e, s, { ...i, isMark: !0 }))), o(this, g, (t) => { | ||
t.isInSet(n(this, p)) && (D(this, p, t.type.removeFromSet(n(this, p))), n(this, M).call(this)); | ||
}), this.withMark = (t, e, s, i) => (n(this, F).call(this, t, e, s, i), this), this.closeMark = (t) => (n(this, g).call(this, t), this), this.build = () => { | ||
let t = null; | ||
do | ||
t = i(this, y).call(this); | ||
t = n(this, M).call(this); | ||
while (this.size()); | ||
return t; | ||
}); | ||
h(this, "next", (t) => _(t) ? (t.forEach((e) => { | ||
i(this, P).call(this, e); | ||
}), this) : (i(this, P).call(this, t), this)); | ||
h(this, "toString", (t) => t.stringify(this.build())); | ||
h(this, "run", (t) => (this.next(t), this)); | ||
this.schema = t; | ||
}, this.next = (t) => j(t) ? (t.forEach((e) => { | ||
n(this, N).call(this, e); | ||
}), this) : (n(this, N).call(this, t), this), this.toString = (t) => t.stringify(this.build()), this.run = (t) => (this.next(t), this), this.schema = r; | ||
} | ||
}; | ||
let q = H; | ||
d = new WeakMap(), g = new WeakMap(), j = new WeakMap(), R = new WeakMap(), P = new WeakMap(), C = new WeakMap(), b = new WeakMap(), D = new WeakMap(), y = new WeakMap(), I = new WeakMap(), J = new WeakMap(), O = new WeakMap(), h(q, "create", (t, e) => { | ||
const s = new H(t); | ||
return (r) => (s.run(r), s.toString(e)); | ||
}); | ||
let b = Q; | ||
p = /* @__PURE__ */ new WeakMap(); | ||
S = /* @__PURE__ */ new WeakMap(); | ||
C = /* @__PURE__ */ new WeakMap(); | ||
A = /* @__PURE__ */ new WeakMap(); | ||
N = /* @__PURE__ */ new WeakMap(); | ||
I = /* @__PURE__ */ new WeakMap(); | ||
W = /* @__PURE__ */ new WeakMap(); | ||
O = /* @__PURE__ */ new WeakMap(); | ||
M = /* @__PURE__ */ new WeakMap(); | ||
x = /* @__PURE__ */ new WeakMap(); | ||
F = /* @__PURE__ */ new WeakMap(); | ||
g = /* @__PURE__ */ new WeakMap(); | ||
b.create = (r, t) => { | ||
const e = new Q(r); | ||
return (s) => (e.run(s), e.toString(t)); | ||
}; | ||
export { | ||
S as ParserState, | ||
q as SerializerState, | ||
U as Stack, | ||
Q as StackElement | ||
Z as ParserState, | ||
b as SerializerState, | ||
q as Stack, | ||
J as StackElement | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
{ | ||
"name": "@milkdown/transformer", | ||
"type": "module", | ||
"version": "7.2.0", | ||
"version": "7.2.1", | ||
"license": "MIT", | ||
@@ -35,6 +35,6 @@ "repository": { | ||
"unified": "^10.1.0", | ||
"@milkdown/exception": "7.2.0" | ||
"@milkdown/exception": "7.2.1" | ||
}, | ||
"devDependencies": { | ||
"@milkdown/prose": "7.2.0" | ||
"@milkdown/prose": "7.2.1" | ||
}, | ||
@@ -41,0 +41,0 @@ "nx": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92399
1596
+ Added@milkdown/exception@7.2.1(transitive)
- Removed@milkdown/exception@7.2.0(transitive)
Updated@milkdown/exception@7.2.1