@milkdown/core
Advanced tools
Comparing version 7.5.9 to 7.6.0
@@ -5,3 +5,3 @@ var ve = (e) => { | ||
var ke = (e, t, r) => t.has(e) || ve("Cannot " + r); | ||
var s = (e, t, r) => (ke(e, t, "read from private field"), r ? r.call(e) : t.get(e)), d = (e, t, r) => t.has(e) ? ve("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), c = (e, t, r, i) => (ke(e, t, "write to private field"), i ? i.call(e, r) : t.set(e, r), r); | ||
var n = (e, t, r) => (ke(e, t, "read from private field"), r ? r.call(e) : t.get(e)), d = (e, t, r) => t.has(e) ? ve("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), c = (e, t, r, s) => (ke(e, t, "write to private field"), s ? s.call(e, r) : t.set(e, r), r); | ||
import { createSlice as o, createTimer as v, Container as Pe, Clock as Ye, Ctx as $e } from "@milkdown/ctx"; | ||
@@ -11,3 +11,3 @@ import { Schema as qe, DOMParser as He, Node as Je } from "@milkdown/prose/model"; | ||
import he from "remark-stringify"; | ||
import { unified as le } from "unified"; | ||
import { unified as ue } from "unified"; | ||
import { callCommandBeforeEditorView as Fe, ctxCallOutOfScope as Re, docTypeError as Ge } from "@milkdown/exception"; | ||
@@ -17,5 +17,5 @@ import { ParserState as Qe, SerializerState as Ue } from "@milkdown/transformer"; | ||
import { chainCommands as Ze, deleteSelection as xe, joinBackward as et, selectNodeBackward as tt, baseKeymap as rt } from "@milkdown/prose/commands"; | ||
import { undoInputRule as st } from "@milkdown/prose/inputrules"; | ||
import { keymap as it } from "@milkdown/prose/keymap"; | ||
import { PluginKey as be, Plugin as De, EditorState as nt } from "@milkdown/prose/state"; | ||
import { undoInputRule as nt } from "@milkdown/prose/inputrules"; | ||
import { keymap as st } from "@milkdown/prose/keymap"; | ||
import { PluginKey as be, Plugin as De, EditorState as it } from "@milkdown/prose/state"; | ||
import { EditorView as ot } from "@milkdown/prose/view"; | ||
@@ -30,29 +30,29 @@ function k(e, t) { | ||
const Ee = { | ||
strong: (e, t, r, i) => { | ||
const n = e.marker || r.options.strong || "*", a = r.enter("strong"), h = r.createTracker(i); | ||
let m = h.move(n + n); | ||
strong: (e, t, r, s) => { | ||
const i = e.marker || r.options.strong || "*", a = r.enter("strong"), h = r.createTracker(s); | ||
let m = h.move(i + i); | ||
return m += h.move( | ||
r.containerPhrasing(e, { | ||
before: m, | ||
after: n, | ||
after: i, | ||
...h.current() | ||
}) | ||
), m += h.move(n + n), a(), m; | ||
), m += h.move(i + i), a(), m; | ||
}, | ||
emphasis: (e, t, r, i) => { | ||
const n = e.marker || r.options.emphasis || "*", a = r.enter("emphasis"), h = r.createTracker(i); | ||
let m = h.move(n); | ||
emphasis: (e, t, r, s) => { | ||
const i = e.marker || r.options.emphasis || "*", a = r.enter("emphasis"), h = r.createTracker(s); | ||
let m = h.move(i); | ||
return m += h.move( | ||
r.containerPhrasing(e, { | ||
before: m, | ||
after: n, | ||
after: i, | ||
...h.current() | ||
}) | ||
), m += h.move(n), a(), m; | ||
), m += h.move(i), a(), m; | ||
} | ||
}, L = o({}, "editorView"), V = o({}, "editorState"), G = o([], "initTimer"), Te = o({}, "editor"), ue = o([], "inputRules"), N = o([], "prosePlugins"), pe = o( | ||
}, L = o({}, "editorView"), V = o({}, "editorState"), G = o([], "initTimer"), Te = o({}, "editor"), le = o([], "inputRules"), N = o([], "prosePlugins"), pe = o( | ||
[], | ||
"remarkPlugins" | ||
), fe = o([], "nodeView"), ye = o([], "markView"), P = o( | ||
le().use(de).use(he), | ||
ue().use(de).use(he), | ||
"remark" | ||
@@ -75,12 +75,12 @@ ), Q = o( | ||
function ct(e) { | ||
const t = (r) => (r.inject(Te, e).inject(N, []).inject(pe, []).inject(ue, []).inject(fe, []).inject(ye, []).inject(Q, { | ||
const t = (r) => (r.inject(Te, e).inject(N, []).inject(pe, []).inject(le, []).inject(fe, []).inject(ye, []).inject(Q, { | ||
handlers: Ee | ||
}).inject(P, le().use(de).use(he)).inject(G, [W]).record(M), async () => { | ||
}).inject(P, ue().use(de).use(he)).inject(G, [W]).record(M), async () => { | ||
await r.waitTimers(G); | ||
const i = r.get(Q); | ||
const s = r.get(Q); | ||
return r.set( | ||
P, | ||
le().use(de).use(he, i) | ||
ue().use(de).use(he, s) | ||
), r.done(M), () => { | ||
r.remove(Te).remove(N).remove(pe).remove(ue).remove(fe).remove(ye).remove(Q).remove(P).remove(G).clearTimer(M); | ||
r.remove(Te).remove(N).remove(pe).remove(le).remove(fe).remove(ye).remove(Q).remove(P).remove(G).clearTimer(M); | ||
}; | ||
@@ -102,12 +102,12 @@ }); | ||
await e.waitTimers(U); | ||
const t = e.get(P), i = e.get(pe).reduce( | ||
const t = e.get(P), s = e.get(pe).reduce( | ||
(m, f) => m.use(f.plugin, f.options), | ||
t | ||
); | ||
e.set(P, i); | ||
const n = Object.fromEntries( | ||
e.set(P, s); | ||
const i = Object.fromEntries( | ||
e.get(X).map(([m, f]) => [m, je(f)]) | ||
), a = Object.fromEntries( | ||
e.get(Z).map(([m, f]) => [m, je(f)]) | ||
), h = new qe({ nodes: n, marks: a }); | ||
), h = new qe({ nodes: i, marks: a }); | ||
return e.set(b, h), e.done(R), () => { | ||
@@ -130,19 +130,19 @@ e.remove(b).remove(X).remove(Z).remove(U).clearTimer(R); | ||
get ctx() { | ||
return s(this, g); | ||
return n(this, g); | ||
} | ||
/// Register a command into the manager. | ||
create(t, r) { | ||
const i = t.create(s(this, T).sliceMap); | ||
return i.set(r), i; | ||
const s = t.create(n(this, T).sliceMap); | ||
return s.set(r), s; | ||
} | ||
get(t) { | ||
return s(this, T).get(t).get(); | ||
return n(this, T).get(t).get(); | ||
} | ||
remove(t) { | ||
return s(this, T).remove(t); | ||
return n(this, T).remove(t); | ||
} | ||
call(t, r) { | ||
if (s(this, g) == null) throw Fe(); | ||
const n = this.get(t)(r), a = s(this, g).get(L); | ||
return n(a.state, a.dispatch, a); | ||
if (n(this, g) == null) throw Fe(); | ||
const i = this.get(t)(r), a = n(this, g).get(L); | ||
return i(a.state, a.dispatch, a); | ||
} | ||
@@ -193,6 +193,6 @@ } | ||
}); | ||
const se = o("", "defaultValue"), ie = o( | ||
const ne = o("", "defaultValue"), se = o( | ||
(e) => e, | ||
"stateOptions" | ||
), ne = o( | ||
), ie = o( | ||
[], | ||
@@ -212,3 +212,3 @@ "editorStateTimer" | ||
const t = Ze( | ||
st, | ||
nt, | ||
xe, | ||
@@ -220,5 +220,5 @@ et, | ||
} | ||
const Ae = (e) => (e.inject(se, "").inject(V, {}).inject(ie, (t) => t).inject(ne, [$, H, Y]).record(J), async () => { | ||
await e.waitTimers(ne); | ||
const t = e.get(b), r = e.get(q), i = e.get(ue), n = e.get(ie), a = e.get(N), h = e.get(se), m = mt(h, r, t), f = [ | ||
const Ae = (e) => (e.inject(ne, "").inject(V, {}).inject(se, (t) => t).inject(ie, [$, H, Y]).record(J), async () => { | ||
await e.waitTimers(ie); | ||
const t = e.get(b), r = e.get(q), s = e.get(le), i = e.get(se), a = e.get(N), h = e.get(ne), m = mt(h, r, t), f = [ | ||
...a, | ||
@@ -235,13 +235,13 @@ new De({ | ||
}), | ||
Xe({ rules: i }), | ||
it(ht(rt)) | ||
Xe({ rules: s }), | ||
st(ht(rt)) | ||
]; | ||
e.set(N, f); | ||
const B = n({ | ||
const B = i({ | ||
schema: t, | ||
doc: m, | ||
plugins: f | ||
}), l = nt.create(B); | ||
return e.set(V, l), e.done(J), () => { | ||
e.remove(se).remove(V).remove(ie).remove(ne).clearTimer(J); | ||
}), u = it.create(B); | ||
return e.set(V, u), e.done(J), () => { | ||
e.remove(ne).remove(V).remove(se).remove(ie).clearTimer(J); | ||
}; | ||
@@ -262,11 +262,11 @@ }); | ||
); | ||
function lt(e, t) { | ||
function ut(e, t) { | ||
const r = document.createElement("div"); | ||
r.className = "milkdown", e.appendChild(r), t.set(we, r); | ||
const i = t.get(ge); | ||
return Object.entries(i).forEach( | ||
([n, a]) => r.setAttribute(n, a) | ||
const s = t.get(ge); | ||
return Object.entries(s).forEach( | ||
([i, a]) => r.setAttribute(i, a) | ||
), r; | ||
} | ||
function ut(e) { | ||
function lt(e) { | ||
e.classList.add("editor"), e.setAttribute("role", "textbox"); | ||
@@ -281,11 +281,11 @@ } | ||
view: (B) => { | ||
const l = r ? lt(r, e) : void 0; | ||
const u = r ? ut(r, e) : void 0; | ||
return (() => { | ||
if (l && r) { | ||
if (u && r) { | ||
const F = B.dom; | ||
r.replaceChild(l, F), l.appendChild(F); | ||
r.replaceChild(u, F), u.appendChild(F); | ||
} | ||
})(), { | ||
destroy: () => { | ||
l != null && l.parentNode && (l == null || l.parentNode.replaceChild(B.dom, l)), l == null || l.remove(); | ||
u != null && u.parentNode && (u == null || u.parentNode.replaceChild(B.dom, u)), u == null || u.remove(); | ||
} | ||
@@ -297,9 +297,9 @@ }; | ||
]), await e.waitTimers(ae); | ||
const i = e.get(V), n = e.get(ce), a = Object.fromEntries(e.get(fe)), h = Object.fromEntries(e.get(ye)), m = new ot(r, { | ||
state: i, | ||
const s = e.get(V), i = e.get(ce), a = Object.fromEntries(e.get(fe)), h = Object.fromEntries(e.get(ye)), m = new ot(r, { | ||
state: s, | ||
nodeViews: a, | ||
markViews: h, | ||
...n | ||
...i | ||
}); | ||
return ut(m.dom), e.set(L, m), e.done(oe), () => { | ||
return lt(m.dom), e.set(L, m), e.done(oe), () => { | ||
m == null || m.destroy(), e.remove(me).remove(L).remove(ce).remove(we).remove(ge).remove(ae).clearTimer(oe); | ||
@@ -311,3 +311,3 @@ }; | ||
}); | ||
var ft = /* @__PURE__ */ ((e) => (e.Idle = "Idle", e.OnCreate = "OnCreate", e.Created = "Created", e.OnDestroy = "OnDestroy", e.Destroyed = "Destroyed", e))(ft || {}), j, p, y, D, _, z, u, w, O, K, S, E, A, C, I; | ||
var ft = /* @__PURE__ */ ((e) => (e.Idle = "Idle", e.OnCreate = "OnCreate", e.Created = "Created", e.OnDestroy = "OnDestroy", e.Destroyed = "Destroyed", e))(ft || {}), j, p, y, D, _, z, l, w, O, K, S, E, A, C, I; | ||
const Ce = class Ce { | ||
@@ -321,3 +321,3 @@ constructor() { | ||
d(this, z); | ||
d(this, u); | ||
d(this, l); | ||
d(this, w); | ||
@@ -332,5 +332,5 @@ d(this, O); | ||
c(this, j, !1), c(this, p, "Idle"), c(this, y, []), c(this, D, () => { | ||
}), c(this, _, new Pe()), c(this, z, new Ye()), c(this, u, /* @__PURE__ */ new Map()), c(this, w, /* @__PURE__ */ new Map()), c(this, O, new $e(s(this, _), s(this, z))), c(this, K, () => { | ||
const t = at(async (i) => { | ||
await Promise.all(s(this, y).map((n) => n(i))); | ||
}), c(this, _, new Pe()), c(this, z, new Ye()), c(this, l, /* @__PURE__ */ new Map()), c(this, w, /* @__PURE__ */ new Map()), c(this, O, new $e(n(this, _), n(this, z))), c(this, K, () => { | ||
const t = at(async (s) => { | ||
await Promise.all(n(this, y).map((i) => i(s))); | ||
}), r = [ | ||
@@ -346,14 +346,14 @@ Ie, | ||
]; | ||
s(this, S).call(this, r, s(this, w)); | ||
n(this, S).call(this, r, n(this, w)); | ||
}), c(this, S, (t, r) => { | ||
t.forEach((i) => { | ||
const n = s(this, O).produce( | ||
s(this, j) ? i.meta : void 0 | ||
), a = i(n); | ||
r.set(i, { ctx: n, handler: a, cleanup: void 0 }); | ||
t.forEach((s) => { | ||
const i = n(this, O).produce( | ||
n(this, j) ? s.meta : void 0 | ||
), a = s(i); | ||
r.set(s, { ctx: i, handler: a, cleanup: void 0 }); | ||
}); | ||
}), c(this, E, (t, r = !1) => Promise.all( | ||
[t].flat().map((i) => { | ||
const n = s(this, u).get(i), a = n == null ? void 0 : n.cleanup; | ||
return r ? s(this, u).delete(i) : s(this, u).set(i, { | ||
[t].flat().map((s) => { | ||
const i = n(this, l).get(s), a = i == null ? void 0 : i.cleanup; | ||
return r ? n(this, l).delete(s) : n(this, l).set(s, { | ||
ctx: void 0, | ||
@@ -366,15 +366,15 @@ handler: void 0, | ||
await Promise.all( | ||
[...s(this, w).entries()].map(([t, { cleanup: r }]) => typeof r == "function" ? r() : r) | ||
), s(this, w).clear(); | ||
[...n(this, w).entries()].map(([t, { cleanup: r }]) => typeof r == "function" ? r() : r) | ||
), n(this, w).clear(); | ||
}), c(this, C, (t) => { | ||
c(this, p, t), s(this, D).call(this, t); | ||
}), c(this, I, (t) => [...t.entries()].map(async ([r, i]) => { | ||
const { ctx: n, handler: a } = i; | ||
c(this, p, t), n(this, D).call(this, t); | ||
}), c(this, I, (t) => [...t.entries()].map(async ([r, s]) => { | ||
const { ctx: i, handler: a } = s; | ||
if (!a) return; | ||
const h = await a(); | ||
t.set(r, { ctx: n, handler: a, cleanup: h }); | ||
})), this.enableInspector = (t = !0) => (c(this, j, t), this), this.onStatusChange = (t) => (c(this, D, t), this), this.config = (t) => (s(this, y).push(t), this), this.removeConfig = (t) => (c(this, y, s(this, y).filter((r) => r !== t)), this), this.use = (t) => { | ||
t.set(r, { ctx: i, handler: a, cleanup: h }); | ||
})), this.enableInspector = (t = !0) => (c(this, j, t), this), this.onStatusChange = (t) => (c(this, D, t), this), this.config = (t) => (n(this, y).push(t), this), this.removeConfig = (t) => (c(this, y, n(this, y).filter((r) => r !== t)), this), this.use = (t) => { | ||
const r = [t].flat(); | ||
return r.flat().forEach((i) => { | ||
s(this, u).set(i, { | ||
return r.flat().forEach((s) => { | ||
n(this, l).set(s, { | ||
ctx: void 0, | ||
@@ -384,4 +384,4 @@ handler: void 0, | ||
}); | ||
}), s(this, p) === "Created" && s(this, S).call(this, r, s(this, u)), this; | ||
}, this.remove = async (t) => s(this, p) === "OnCreate" ? (console.warn( | ||
}), n(this, p) === "Created" && n(this, S).call(this, r, n(this, l)), this; | ||
}, this.remove = async (t) => n(this, p) === "OnCreate" ? (console.warn( | ||
"[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code." | ||
@@ -392,12 +392,12 @@ ), new Promise((r) => { | ||
}, 50); | ||
})) : (await s(this, E).call(this, [t].flat(), !0), this), this.create = async () => s(this, p) === "OnCreate" ? this : (s(this, p) === "Created" && await this.destroy(), s(this, C).call(this, "OnCreate"), s(this, K).call(this), s(this, S).call(this, [...s(this, u).keys()], s(this, u)), await Promise.all( | ||
})) : (await n(this, E).call(this, [t].flat(), !0), this), this.create = async () => n(this, p) === "OnCreate" ? this : (n(this, p) === "Created" && await this.destroy(), n(this, C).call(this, "OnCreate"), n(this, K).call(this), n(this, S).call(this, [...n(this, l).keys()], n(this, l)), await Promise.all( | ||
[ | ||
s(this, I).call(this, s(this, w)), | ||
s(this, I).call(this, s(this, u)) | ||
n(this, I).call(this, n(this, w)), | ||
n(this, I).call(this, n(this, l)) | ||
].flat() | ||
), s(this, C).call(this, "Created"), this), this.destroy = async (t = !1) => s(this, p) === "Destroyed" || s(this, p) === "OnDestroy" ? this : s(this, p) === "OnCreate" ? new Promise((r) => { | ||
), n(this, C).call(this, "Created"), this), this.destroy = async (t = !1) => n(this, p) === "Destroyed" || n(this, p) === "OnDestroy" ? this : n(this, p) === "OnCreate" ? new Promise((r) => { | ||
setTimeout(() => { | ||
r(this.destroy(t)); | ||
}, 50); | ||
}) : (t && c(this, y, []), s(this, C).call(this, "OnDestroy"), await s(this, E).call(this, [...s(this, u).keys()], t), await s(this, A).call(this), s(this, C).call(this, "Destroyed"), this), this.action = (t) => t(s(this, O)), this.inspect = () => s(this, j) ? [...s(this, w).values(), ...s(this, u).values()].map(({ ctx: t }) => { | ||
}) : (t && c(this, y, []), n(this, C).call(this, "OnDestroy"), await n(this, E).call(this, [...n(this, l).keys()], t), await n(this, A).call(this), n(this, C).call(this, "Destroyed"), this), this.action = (t) => t(n(this, O)), this.inspect = () => n(this, j) ? [...n(this, w).values(), ...n(this, l).values()].map(({ ctx: t }) => { | ||
var r; | ||
@@ -415,10 +415,10 @@ return (r = t == null ? void 0 : t.inspector) == null ? void 0 : r.read(); | ||
get ctx() { | ||
return s(this, O); | ||
return n(this, O); | ||
} | ||
/// Get the status of the editor. | ||
get status() { | ||
return s(this, p); | ||
return n(this, p); | ||
} | ||
}; | ||
j = new WeakMap(), p = new WeakMap(), y = new WeakMap(), D = new WeakMap(), _ = new WeakMap(), z = new WeakMap(), u = new WeakMap(), w = new WeakMap(), O = new WeakMap(), K = new WeakMap(), S = new WeakMap(), E = new WeakMap(), A = new WeakMap(), C = new WeakMap(), I = new WeakMap(); | ||
j = new WeakMap(), p = new WeakMap(), y = new WeakMap(), D = new WeakMap(), _ = new WeakMap(), z = new WeakMap(), l = new WeakMap(), w = new WeakMap(), O = new WeakMap(), K = new WeakMap(), S = new WeakMap(), E = new WeakMap(), A = new WeakMap(), C = new WeakMap(), I = new WeakMap(); | ||
let Se = Ce; | ||
@@ -442,8 +442,8 @@ export { | ||
It as createCmdKey, | ||
se as defaultValueCtx, | ||
ne as defaultValueCtx, | ||
Te as editorCtx, | ||
Ae as editorState, | ||
V as editorStateCtx, | ||
ie as editorStateOptionsCtx, | ||
ne as editorStateTimerCtx, | ||
se as editorStateOptionsCtx, | ||
ie as editorStateTimerCtx, | ||
Be as editorView, | ||
@@ -456,3 +456,3 @@ L as editorViewCtx, | ||
G as initTimerCtx, | ||
ue as inputRulesCtx, | ||
le as inputRulesCtx, | ||
ye as markViewCtx, | ||
@@ -459,0 +459,0 @@ Z as marksCtx, |
{ | ||
"name": "@milkdown/core", | ||
"type": "module", | ||
"version": "7.5.9", | ||
"version": "7.6.0", | ||
"license": "MIT", | ||
@@ -40,10 +40,10 @@ "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/ctx": "7.5.9", | ||
"@milkdown/transformer": "7.5.9", | ||
"@milkdown/prose": "7.5.9" | ||
"@milkdown/ctx": "7.6.0", | ||
"@milkdown/prose": "7.6.0", | ||
"@milkdown/transformer": "7.6.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "nx": { |
Sorry, the diff of this file is not supported yet
120235
+ Added@milkdown/exception@7.6.0(transitive)
- Removed@milkdown/exception@7.5.9(transitive)
Updated@milkdown/exception@7.6.0
Updatedtslib@^2.8.1