@milkdown/transformer
Advanced tools
Comparing version 7.5.9 to 7.6.0
var H = (p) => { | ||
throw TypeError(p); | ||
}; | ||
var K = (p, h, n) => h.has(p) || H("Cannot " + n); | ||
var i = (p, h, n) => (K(p, h, "read from private field"), n ? n.call(p) : h.get(p)), u = (p, h, n) => h.has(p) ? H("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(p) : h.set(p, n), o = (p, h, n, t) => (K(p, h, "write to private field"), t ? t.call(p, n) : h.set(p, n), n); | ||
var K = (p, n, h) => n.has(p) || H("Cannot " + h); | ||
var i = (p, n, h) => (K(p, n, "read from private field"), h ? h.call(p) : n.get(p)), u = (p, n, h) => n.has(p) ? H("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(p) : n.set(p, h), c = (p, n, h, t) => (K(p, n, "write to private field"), t ? t.call(p, h) : n.set(p, h), h); | ||
import { stackOverFlow as U, parserMatchError as Y, createNodeInParserFail as Z, serializerMatchError as _ } from "@milkdown/exception"; | ||
@@ -12,11 +12,11 @@ import { Mark as J } from "@milkdown/prose/model"; | ||
constructor() { | ||
this.elements = [], this.size = () => this.elements.length, this.top = () => this.elements.at(-1), this.push = (h) => { | ||
var n; | ||
(n = this.top()) == null || n.push(h); | ||
}, this.open = (h) => { | ||
this.elements.push(h); | ||
this.elements = [], this.size = () => this.elements.length, this.top = () => this.elements.at(-1), this.push = (n) => { | ||
var h; | ||
(h = this.top()) == null || h.push(n); | ||
}, this.open = (n) => { | ||
this.elements.push(n); | ||
}, this.close = () => { | ||
const h = this.elements.pop(); | ||
if (!h) throw U(); | ||
return h; | ||
const n = this.elements.pop(); | ||
if (!n) throw U(); | ||
return n; | ||
}; | ||
@@ -26,7 +26,7 @@ } | ||
class B extends V { | ||
constructor(h, n, t) { | ||
super(), this.type = h, this.content = n, this.attrs = t; | ||
constructor(n, h, t) { | ||
super(), this.type = n, this.content = h, this.attrs = t; | ||
} | ||
push(h, ...n) { | ||
this.content.push(h, ...n); | ||
push(n, ...h) { | ||
this.content.push(n, ...h); | ||
} | ||
@@ -36,4 +36,4 @@ pop() { | ||
} | ||
static create(h, n, t) { | ||
return new B(h, n, t); | ||
static create(n, h, t) { | ||
return new B(n, h, t); | ||
} | ||
@@ -44,3 +44,3 @@ } | ||
/// @internal | ||
constructor(n) { | ||
constructor(h) { | ||
super(); | ||
@@ -54,6 +54,6 @@ u(this, d); | ||
u(this, g); | ||
o(this, d, J.none), o(this, M, (t) => t.isText), o(this, O, (t, s) => { | ||
c(this, d, J.none), c(this, M, (t) => t.isText), c(this, O, (t, s) => { | ||
if (i(this, M).call(this, t) && i(this, M).call(this, s) && J.sameSet(t.marks, s.marks)) | ||
return this.schema.text(t.text + s.text, t.marks); | ||
}), o(this, T, (t) => { | ||
}), c(this, T, (t) => { | ||
const s = Object.values({ | ||
@@ -65,10 +65,10 @@ ...this.schema.nodes, | ||
return s; | ||
}), o(this, F, (t) => { | ||
}), c(this, F, (t) => { | ||
const s = i(this, T).call(this, t); | ||
s.spec.parseMarkdown.runner(this, t, s); | ||
}), this.injectRoot = (t, s, e) => (this.openNode(s, e), this.next(t.children), this), this.openNode = (t, s) => (this.open(B.create(t, [], s)), this), o(this, w, () => { | ||
o(this, d, J.none); | ||
}), this.injectRoot = (t, s, e) => (this.openNode(s, e), this.next(t.children), this), this.openNode = (t, s) => (this.open(B.create(t, [], s)), this), c(this, w, () => { | ||
c(this, d, J.none); | ||
const t = this.close(); | ||
return i(this, g).call(this, t.type, t.attrs, t.content); | ||
}), this.closeNode = () => (i(this, w).call(this), this), o(this, g, (t, s, e) => { | ||
}), this.closeNode = () => (i(this, w).call(this), this), c(this, g, (t, s, e) => { | ||
const r = t.createAndFill(s, e, i(this, d)); | ||
@@ -79,4 +79,4 @@ if (!r) throw Z(t, s, e); | ||
const e = t.create(s); | ||
return o(this, d, e.addToSet(i(this, d))), this; | ||
}, this.closeMark = (t) => (o(this, d, t.removeFromSet(i(this, d))), this), this.addText = (t) => { | ||
return c(this, d, e.addToSet(i(this, d))), this; | ||
}, this.closeMark = (t) => (c(this, d, t.removeFromSet(i(this, d))), this), this.addText = (t) => { | ||
const s = this.top(); | ||
@@ -101,7 +101,7 @@ if (!s) throw U(); | ||
return this.next(e), this; | ||
}, this.schema = n; | ||
}, this.schema = h; | ||
} | ||
}; | ||
d = new WeakMap(), M = new WeakMap(), O = new WeakMap(), T = new WeakMap(), F = new WeakMap(), w = new WeakMap(), g = new WeakMap(), $.create = (n, t) => { | ||
const s = new $(n); | ||
d = new WeakMap(), M = new WeakMap(), O = new WeakMap(), T = new WeakMap(), F = new WeakMap(), w = new WeakMap(), g = new WeakMap(), $.create = (h, t) => { | ||
const s = new $(h); | ||
return (e) => (s.run(t, e), s.toDoc()); | ||
@@ -111,4 +111,4 @@ }; | ||
const q = class q extends V { | ||
constructor(h, n, t, s = {}) { | ||
super(), this.type = h, this.children = n, this.value = t, this.props = s, this.push = (e, ...r) => { | ||
constructor(n, h, t, s = {}) { | ||
super(), this.type = n, this.children = h, this.value = t, this.props = s, this.push = (e, ...r) => { | ||
this.children || (this.children = []), this.children.push(e, ...r); | ||
@@ -121,11 +121,11 @@ }, this.pop = () => { | ||
}; | ||
q.create = (h, n, t, s = {}) => new q(h, n, t, s); | ||
q.create = (n, h, t, s = {}) => new q(n, h, t, s); | ||
let W = q; | ||
const tt = (p) => Object.prototype.hasOwnProperty.call(p, "size"); | ||
var v, P, A, S, I, j, b, C, R, x, N, D, E; | ||
var y, P, A, S, I, j, b, C, R, x, N, D, E; | ||
const z = class z extends X { | ||
/// @internal | ||
constructor(n) { | ||
constructor(h) { | ||
super(); | ||
u(this, v); | ||
u(this, y); | ||
u(this, P); | ||
@@ -143,3 +143,3 @@ u(this, A); | ||
u(this, E); | ||
o(this, v, J.none), o(this, P, (t) => { | ||
c(this, y, J.none), c(this, P, (t) => { | ||
const s = Object.values({ | ||
@@ -151,27 +151,27 @@ ...this.schema.nodes, | ||
return s; | ||
}), o(this, A, (t) => i(this, P).call(this, t).spec.toMarkdown.runner(this, t)), o(this, S, (t, s) => i(this, P).call(this, t).spec.toMarkdown.runner(this, t, s)), o(this, I, (t) => { | ||
const { marks: s } = t, e = (c) => c.type.spec.priority ?? 50; | ||
[...s].sort((c, f) => e(c) - e(f)).every((c) => !i(this, S).call(this, c, t)) && i(this, A).call(this, t), s.forEach((c) => i(this, E).call(this, c)); | ||
}), o(this, j, (t, s) => { | ||
}), c(this, A, (t) => i(this, P).call(this, t).spec.toMarkdown.runner(this, t)), c(this, S, (t, s) => i(this, P).call(this, t).spec.toMarkdown.runner(this, t, s)), c(this, I, (t) => { | ||
const { marks: s } = t, e = (o) => o.type.spec.priority ?? 50; | ||
[...s].sort((o, f) => e(o) - e(f)).every((o) => !i(this, S).call(this, o, t)) && i(this, A).call(this, t), s.forEach((o) => i(this, E).call(this, o)); | ||
}), c(this, j, (t, s) => { | ||
var f; | ||
if (t.type === s || ((f = t.children) == null ? void 0 : f.length) !== 1) return t; | ||
const e = (y) => { | ||
const e = (v) => { | ||
var l; | ||
if (y.type === s) return y; | ||
if (((l = y.children) == null ? void 0 : l.length) !== 1) return null; | ||
const [k] = y.children; | ||
if (v.type === s) return v; | ||
if (((l = v.children) == null ? void 0 : l.length) !== 1) return null; | ||
const [k] = v.children; | ||
return k ? e(k) : null; | ||
}, r = e(t); | ||
if (!r) return t; | ||
const a = r.children ? [...r.children] : void 0, c = { ...t, children: a }; | ||
return c.children = a, r.children = [c], r; | ||
}), o(this, b, (t) => { | ||
const a = r.children ? [...r.children] : void 0, o = { ...t, children: a }; | ||
return o.children = a, r.children = [o], r; | ||
}), c(this, b, (t) => { | ||
const { children: s } = t; | ||
return s && (t.children = s.reduce((e, r, a) => { | ||
if (a === 0) return [r]; | ||
const c = e.at(-1); | ||
if (c && c.isMark && r.isMark) { | ||
r = i(this, j).call(this, r, c.type); | ||
const { children: f, ...y } = r, { children: k, ...l } = c; | ||
if (r.type === c.type && f && k && JSON.stringify(y) === JSON.stringify(l)) { | ||
const o = e.at(-1); | ||
if (o && o.isMark && r.isMark) { | ||
r = i(this, j).call(this, r, o.type); | ||
const { children: f, ...v } = r, { children: k, ...l } = o; | ||
if (r.type === o.type && f && k && JSON.stringify(v) === JSON.stringify(l)) { | ||
const m = { | ||
@@ -186,3 +186,3 @@ ...l, | ||
}, [])), t; | ||
}), o(this, C, (t) => { | ||
}), c(this, C, (t) => { | ||
const s = { | ||
@@ -193,14 +193,14 @@ ...t.props, | ||
return t.children && (s.children = t.children), t.value && (s.value = t.value), s; | ||
}), this.openNode = (t, s, e) => (this.open(W.create(t, void 0, s, e)), this), o(this, R, (t, s) => { | ||
}), this.openNode = (t, s, e) => (this.open(W.create(t, void 0, s, e)), this), c(this, R, (t, s) => { | ||
let e = "", r = ""; | ||
const a = t.children; | ||
let c = -1, f = -1; | ||
const y = (l) => { | ||
let o = -1, f = -1; | ||
const v = (l) => { | ||
l && l.forEach((m, G) => { | ||
m.type === "text" && m.value && (c < 0 && (c = G), f = G); | ||
m.type === "text" && m.value && (o < 0 && (o = G), f = G); | ||
}); | ||
}; | ||
if (a) { | ||
y(a); | ||
const l = a == null ? void 0 : a[f], m = a == null ? void 0 : a[c]; | ||
v(a); | ||
const l = a == null ? void 0 : a[f], m = a == null ? void 0 : a[o]; | ||
l && l.value.endsWith(" ") && (r = l.value.match(/ +$/)[0], l.value = l.value.trimEnd()), m && m.value.startsWith(" ") && (e = m.value.match(/^ +/)[0], m.value = m.value.trimStart()); | ||
@@ -211,10 +211,10 @@ } | ||
return r.length && i(this, N).call(this, "text", void 0, r), k; | ||
}), o(this, x, (t = !1) => { | ||
}), c(this, x, (t = !1) => { | ||
const s = this.close(), e = () => i(this, N).call(this, s.type, s.children, s.value, s.props); | ||
return t ? i(this, R).call(this, s, e) : e(); | ||
}), this.closeNode = () => (i(this, x).call(this), this), o(this, N, (t, s, e, r) => { | ||
const a = W.create(t, s, e, r), c = i(this, b).call(this, i(this, C).call(this, a)); | ||
return this.push(c), c; | ||
}), this.addNode = (t, s, e, r) => (i(this, N).call(this, t, s, e, r), this), o(this, D, (t, s, e, r) => t.isInSet(i(this, v)) ? this : (o(this, v, t.addToSet(i(this, v))), this.openNode(s, e, { ...r, isMark: !0 }))), o(this, E, (t) => { | ||
t.isInSet(i(this, v)) && (o(this, v, t.type.removeFromSet(i(this, v))), i(this, x).call(this, !0)); | ||
}), this.closeNode = () => (i(this, x).call(this), this), c(this, N, (t, s, e, r) => { | ||
const a = W.create(t, s, e, r), o = i(this, b).call(this, i(this, C).call(this, a)); | ||
return this.push(o), o; | ||
}), this.addNode = (t, s, e, r) => (i(this, N).call(this, t, s, e, r), this), c(this, D, (t, s, e, r) => t.isInSet(i(this, y)) ? this : (c(this, y, t.addToSet(i(this, y))), this.openNode(s, e, { ...r, isMark: !0 }))), c(this, E, (t) => { | ||
t.isInSet(i(this, y)) && (c(this, y, t.type.removeFromSet(i(this, y))), i(this, x).call(this, !0)); | ||
}), this.withMark = (t, s, e, r) => (i(this, D).call(this, t, s, e, r), this), this.closeMark = (t) => (i(this, E).call(this, t), this), this.build = () => { | ||
@@ -228,7 +228,7 @@ let t = null; | ||
i(this, I).call(this, s); | ||
}), this) : (i(this, I).call(this, t), this), this.toString = (t) => t.stringify(this.build()), this.run = (t) => (this.next(t), this), this.schema = n; | ||
}), this) : (i(this, I).call(this, t), this), this.toString = (t) => t.stringify(this.build()), this.run = (t) => (this.next(t), this), this.schema = h; | ||
} | ||
}; | ||
v = new WeakMap(), P = new WeakMap(), A = new WeakMap(), S = new WeakMap(), I = new WeakMap(), j = new WeakMap(), b = new WeakMap(), C = new WeakMap(), R = new WeakMap(), x = new WeakMap(), N = new WeakMap(), D = new WeakMap(), E = new WeakMap(), z.create = (n, t) => { | ||
const s = new z(n); | ||
y = new WeakMap(), P = new WeakMap(), A = new WeakMap(), S = new WeakMap(), I = new WeakMap(), j = new WeakMap(), b = new WeakMap(), C = new WeakMap(), R = new WeakMap(), x = new WeakMap(), N = new WeakMap(), D = new WeakMap(), E = new WeakMap(), z.create = (h, t) => { | ||
const s = new z(h); | ||
return (e) => (s.run(e), s.toString(t)); | ||
@@ -235,0 +235,0 @@ }; |
{ | ||
"name": "@milkdown/transformer", | ||
"type": "module", | ||
"version": "7.5.9", | ||
"version": "7.6.0", | ||
"license": "MIT", | ||
@@ -36,8 +36,8 @@ "repository": { | ||
"remark-stringify": "^11.0.0", | ||
"tslib": "^2.5.0", | ||
"tslib": "^2.8.1", | ||
"unified": "^11.0.3", | ||
"@milkdown/exception": "7.5.9" | ||
"@milkdown/exception": "7.6.0" | ||
}, | ||
"devDependencies": { | ||
"@milkdown/prose": "7.5.9" | ||
"@milkdown/prose": "7.6.0" | ||
}, | ||
@@ -44,0 +44,0 @@ "nx": { |
+ Added@milkdown/exception@7.6.0(transitive)
- Removed@milkdown/exception@7.5.9(transitive)
Updated@milkdown/exception@7.6.0
Updatedtslib@^2.8.1