Socket
Socket
Sign inDemoInstall

@milkdown/utils

Package Overview
Dependencies
74
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.2.4 to 7.3.0

lib/composable/composed/$remark.d.ts

442

./lib/index.es.js

@@ -1,254 +0,247 @@

import { createCmdKey as R, commandsTimerCtx as D, CommandsReady as E, commandsCtx as y, editorStateTimerCtx as b, SchemaReady as l, inputRulesCtx as C, schemaCtx as f, schemaTimerCtx as O, marksCtx as w, nodesCtx as h, prosePluginsCtx as p, InitReady as M, remarkPluginsCtx as $, editorViewTimerCtx as N, nodeViewCtx as v, markViewCtx as A, editorViewCtx as g, serializerCtx as H, parserCtx as j, editorStateOptionsCtx as L } from "@milkdown/core";
import { createCmdKey as O, commandsTimerCtx as I, CommandsReady as R, commandsCtx as d, editorStateTimerCtx as A, SchemaReady as l, inputRulesCtx as C, schemaCtx as f, schemaTimerCtx as E, marksCtx as w, nodesCtx as k, prosePluginsCtx as p, editorViewTimerCtx as D, nodeViewCtx as v, markViewCtx as $, InitReady as N, remarkPluginsCtx as b, editorViewCtx as y, serializerCtx as H, parserCtx as M, editorStateOptionsCtx as L } from "@milkdown/core";
import { createTimer as F, createSlice as U } from "@milkdown/ctx";
import { customAlphabet as q } from "nanoid";
import { missingMarkInSchema as z, missingNodeInSchema as K } from "@milkdown/exception";
import { keymap as P } from "@milkdown/prose/keymap";
import { NodeType as T, DOMSerializer as B, Slice as V } from "@milkdown/prose/model";
import { missingMarkInSchema as P, missingNodeInSchema as j } from "@milkdown/exception";
import { keymap as z } from "@milkdown/prose/keymap";
import { NodeType as T, DOMSerializer as B, Slice as K } from "@milkdown/prose/model";
import { EditorState as G } from "@milkdown/prose/state";
const J = q("abcedfghicklmn", 10), d = (r, s, n) => {
const t = F(n || J());
const J = q("abcedfghicklmn", 10), g = (n, a, r) => {
const t = F(r || J());
let e = !1;
const a = (o) => (o.record(t), o.update(s, (c) => c.concat(t)), async () => {
const u = await r(o, a, () => {
const s = (o) => (o.record(t), o.update(a, (c) => c.concat(t)), async () => {
const u = await n(o, s, () => {
o.done(t), e = !0;
});
return e || o.done(t), () => {
o.update(s, (i) => i.filter((m) => m !== t)), o.clearTimer(t), u == null || u();
o.update(a, (i) => i.filter((m) => m !== t)), o.clearTimer(t), u == null || u();
};
});
return a.timer = t, a;
}, re = (r, s) => {
const n = R(r), t = (e) => async () => {
t.key = n, await e.wait(E);
const a = s(e);
return e.get(y).create(n, a), t.run = (o) => e.get(y).call(r, o), () => {
e.get(y).remove(n);
return s.timer = t, s;
}, re = (n, a) => {
const r = O(n), t = (e) => async () => {
t.key = r, await e.wait(R);
const s = a(e);
return e.get(d).create(r, s), t.run = (o) => e.get(d).call(n, o), () => {
e.get(d).remove(r);
};
};
return t;
}, ae = (r, s, n) => {
const t = R(r);
return d(
async (e, a) => {
await e.wait(E);
const o = await s(e);
return e.get(y).create(t, o), a.run = (c) => e.get(y).call(r, c), a.key = t, () => {
e.get(y).remove(t);
}, se = (n, a, r) => {
const t = O(n);
return g(
async (e, s) => {
await e.wait(R);
const o = await a(e);
return e.get(d).create(t, o), s.run = (c) => e.get(d).call(n, c), s.key = t, () => {
e.get(d).remove(t);
};
},
D,
n
I,
r
);
}, se = (r) => {
const s = (n) => async () => {
await n.wait(l);
const t = r(n);
return n.update(C, (e) => [...e, t]), s.inputRule = t, () => {
n.update(C, (e) => e.filter((a) => a !== t));
}, ae = (n) => {
const a = (r) => async () => {
await r.wait(l);
const t = n(r);
return r.update(C, (e) => [...e, t]), a.inputRule = t, () => {
r.update(C, (e) => e.filter((s) => s !== t));
};
};
return s;
}, oe = (r, s) => d(
async (n, t) => {
await n.wait(l);
const e = await r(n);
return n.update(C, (a) => [...a, e]), t.inputRule = e, () => {
n.update(C, (a) => a.filter((o) => o !== e));
return a;
}, oe = (n, a) => g(
async (r, t) => {
await r.wait(l);
const e = await n(r);
return r.update(C, (s) => [...s, e]), t.inputRule = e, () => {
r.update(C, (s) => s.filter((o) => o !== e));
};
},
b,
s
), Q = (r, s) => {
const n = (t) => async () => {
const e = s(t);
return t.update(w, (a) => [...a.filter((o) => o[0] !== r), [r, e]]), n.id = r, n.schema = e, () => {
t.update(w, (a) => a.filter(([o]) => o !== r));
A,
a
), Q = (n, a) => {
const r = (t) => async () => {
const e = a(t);
return t.update(w, (s) => [...s.filter((o) => o[0] !== n), [n, e]]), r.id = n, r.schema = e, () => {
t.update(w, (s) => s.filter(([o]) => o !== n));
};
};
return n.type = (t) => {
const e = t.get(f).marks[r];
return r.type = (t) => {
const e = t.get(f).marks[n];
if (!e)
throw z(r);
throw P(n);
return e;
}, n;
}, ce = (r, s, n) => {
const t = d(
async (e, a, o) => {
const c = await s(e);
return e.update(w, (u) => [...u.filter((i) => i[0] !== r), [r, c]]), a.id = r, a.schema = c, o(), () => {
e.update(w, (u) => u.filter(([i]) => i !== r));
}, r;
}, ce = (n, a, r) => {
const t = g(
async (e, s, o) => {
const c = await a(e);
return e.update(w, (u) => [...u.filter((i) => i[0] !== n), [n, c]]), s.id = n, s.schema = c, o(), () => {
e.update(w, (u) => u.filter(([i]) => i !== n));
};
},
O,
n
E,
r
);
return t.type = (e) => {
const a = e.get(f).marks[r];
if (!a)
throw z(r);
return a;
const s = e.get(f).marks[n];
if (!s)
throw P(n);
return s;
}, t;
}, W = (r, s) => {
const n = (t) => async () => {
const e = s(t);
return t.update(h, (a) => [...a.filter((o) => o[0] !== r), [r, e]]), n.id = r, n.schema = e, () => {
t.update(h, (a) => a.filter(([o]) => o !== r));
}, W = (n, a) => {
const r = (t) => async () => {
const e = a(t);
return t.update(k, (s) => [...s.filter((o) => o[0] !== n), [n, e]]), r.id = n, r.schema = e, () => {
t.update(k, (s) => s.filter(([o]) => o !== n));
};
};
return n.type = (t) => {
const e = t.get(f).nodes[r];
return r.type = (t) => {
const e = t.get(f).nodes[n];
if (!e)
throw K(r);
throw j(n);
return e;
}, n;
}, ie = (r, s, n) => {
const t = d(
async (e, a, o) => {
const c = await s(e);
return e.update(h, (u) => [...u.filter((i) => i[0] !== r), [r, c]]), a.id = r, a.schema = c, o(), () => {
e.update(h, (u) => u.filter(([i]) => i !== r));
}, r;
}, ie = (n, a, r) => {
const t = g(
async (e, s, o) => {
const c = await a(e);
return e.update(k, (u) => [...u.filter((i) => i[0] !== n), [n, c]]), s.id = n, s.schema = c, o(), () => {
e.update(k, (u) => u.filter(([i]) => i !== n));
};
},
O,
n
E,
r
);
return t.type = (e) => {
const a = e.get(f).nodes[r];
if (!a)
throw K(r);
return a;
const s = e.get(f).nodes[n];
if (!s)
throw j(n);
return s;
}, t;
}, ue = (r) => {
let s;
const n = (t) => async () => (await t.wait(l), s = r(t), t.update(p, (e) => [...e, s]), () => {
t.update(p, (e) => e.filter((a) => a !== s));
}, ue = (n) => {
let a;
const r = (t) => async () => (await t.wait(l), a = n(t), t.update(p, (e) => [...e, a]), () => {
t.update(p, (e) => e.filter((s) => s !== a));
});
return n.plugin = () => s, n.key = () => s.spec.key, n;
}, me = (r, s) => {
let n;
const t = d(
async (e) => (await e.wait(l), n = await r(e), e.update(p, (a) => [...a, n]), () => {
e.update(p, (a) => a.filter((o) => o !== n));
return r.plugin = () => a, r.key = () => a.spec.key, r;
}, me = (n, a) => {
let r;
const t = g(
async (e) => (await e.wait(l), r = await n(e), e.update(p, (s) => [...s, r]), () => {
e.update(p, (s) => s.filter((o) => o !== r));
}),
b,
s
A,
a
);
return t.plugin = () => n, t.key = () => n.spec.key, t;
}, pe = (r) => {
const s = (n) => async () => {
await n.wait(M);
const t = r(n);
return n.update($, (e) => [...e, t]), s.plugin = t, () => {
n.update($, (e) => e.filter((a) => a !== t));
return t.plugin = () => r, t.key = () => r.spec.key, t;
}, X = (n) => {
const a = (r) => async () => {
await r.wait(l);
const t = n(r), e = z(t);
return r.update(p, (s) => [...s, e]), a.keymap = t, () => {
r.update(p, (s) => s.filter((o) => o !== e));
};
};
return s;
}, le = (r, s) => d(
async (n, t) => {
await n.wait(M);
const e = await r(n);
return n.update($, (a) => [...a, e]), t.plugin = e, () => {
n.update($, (a) => a.filter((o) => o !== e));
return a;
}, pe = (n, a) => g(
async (r, t) => {
await r.wait(l);
const e = await n(r), s = z(e);
return r.update(p, (o) => [...o, s]), t.keymap = e, () => {
r.update(p, (o) => o.filter((c) => c !== s));
};
},
O,
s
), X = (r) => {
const s = (n) => async () => {
await n.wait(l);
const t = r(n), e = P(t);
return n.update(p, (a) => [...a, e]), s.keymap = t, () => {
n.update(p, (a) => a.filter((o) => o !== e));
};
};
return s;
}, de = (r, s) => d(
async (n, t) => {
await n.wait(l);
const e = await r(n), a = P(e);
return n.update(p, (o) => [...o, a]), t.keymap = e, () => {
n.update(p, (o) => o.filter((c) => c !== a));
};
},
b,
s
), ye = (r, s) => {
const n = (t) => async () => {
A,
a
), le = (n, a) => {
const r = (t) => async () => {
await t.wait(l);
const e = s(t);
return r.type(t) instanceof T ? t.update(v, (a) => [...a, [r.id, e]]) : t.update(A, (a) => [...a, [r.id, e]]), n.view = e, n.type = r, () => {
r.type(t) instanceof T ? t.update(v, (a) => a.filter((o) => o[0] !== r.id)) : t.update(A, (a) => a.filter((o) => o[0] !== r.id));
const e = a(t);
return n.type(t) instanceof T ? t.update(v, (s) => [...s, [n.id, e]]) : t.update($, (s) => [...s, [n.id, e]]), r.view = e, r.type = n, () => {
n.type(t) instanceof T ? t.update(v, (s) => s.filter((o) => o[0] !== n.id)) : t.update($, (s) => s.filter((o) => o[0] !== n.id));
};
};
return n;
}, ge = (r, s, n) => d(
return r;
}, de = (n, a, r) => g(
async (t, e) => {
await t.wait(l);
const a = await s(t);
return r.type(t) instanceof T ? t.update(v, (o) => [...o, [r.id, a]]) : t.update(A, (o) => [...o, [r.id, a]]), e.view = a, e.type = r, () => {
r.type(t) instanceof T ? t.update(v, (o) => o.filter((c) => c[0] !== r.id)) : t.update(A, (o) => o.filter((c) => c[0] !== r.id));
const s = await a(t);
return n.type(t) instanceof T ? t.update(v, (o) => [...o, [n.id, s]]) : t.update($, (o) => [...o, [n.id, s]]), e.view = s, e.type = n, () => {
n.type(t) instanceof T ? t.update(v, (o) => o.filter((c) => c[0] !== n.id)) : t.update($, (o) => o.filter((c) => c[0] !== n.id));
};
},
N,
n
), k = (r, s) => {
const n = U(r, s), t = (e) => (e.inject(n), () => () => {
e.remove(n);
D,
r
), h = (n, a) => {
const r = U(n, a), t = (e) => (e.inject(r), () => () => {
e.remove(r);
});
return t.key = n, t;
}, fe = (r, s) => {
const n = k(s, r), t = W(r, (a) => a.get(n.key)(a)), e = [n, t];
return e.id = t.id, e.node = t, e.type = (a) => t.type(a), e.schema = t.schema, e.ctx = n, e.key = n.key, e.extendSchema = (a) => (o) => () => {
const c = o.get(n.key), i = a(c)(o);
o.update(h, (m) => [...m.filter((S) => S[0] !== r), [r, i]]), e.schema = i;
return t.key = r, t;
}, ye = (n, a) => {
const r = h(a, n), t = W(n, (s) => s.get(r.key)(s)), e = [r, t];
return e.id = t.id, e.node = t, e.type = (s) => t.type(s), e.schema = t.schema, e.ctx = r, e.key = r.key, e.extendSchema = (s) => (o) => () => {
const c = o.get(r.key), i = s(c)(o);
o.update(k, (m) => [...m.filter((S) => S[0] !== n), [n, i]]), e.schema = i;
}, e;
}, we = (r, s) => {
const n = k(s, r), t = Q(r, (a) => a.get(n.key)(a)), e = [n, t];
return e.id = t.id, e.mark = t, e.type = t.type, e.schema = t.schema, e.ctx = n, e.key = n.key, e.extendSchema = (a) => (o) => () => {
const c = o.get(n.key), i = a(c)(o);
o.update(w, (m) => [...m.filter((S) => S[0] !== r), [r, i]]), e.schema = i;
}, ge = (n, a) => {
const r = h(a, n), t = Q(n, (s) => s.get(r.key)(s)), e = [r, t];
return e.id = t.id, e.mark = t, e.type = t.type, e.schema = t.schema, e.ctx = r, e.key = r.key, e.extendSchema = (s) => (o) => () => {
const c = o.get(r.key), i = s(c)(o);
o.update(w, (m) => [...m.filter((S) => S[0] !== n), [n, i]]), e.schema = i;
}, e;
}, he = (r, s) => {
const n = Object.fromEntries(Object.entries(s).map(([o, { shortcuts: c }]) => [o, c])), t = k(n, `${r}Keymap`), e = X((o) => {
const c = o.get(t.key), u = Object.entries(s).flatMap(([i, { command: m }]) => [c[i]].flat().map((I) => [I, m(o)]));
}, fe = (n, a) => {
const r = Object.fromEntries(Object.entries(a).map(([o, { shortcuts: c }]) => [o, c])), t = h(r, `${n}Keymap`), e = X((o) => {
const c = o.get(t.key), u = Object.entries(a).flatMap(([i, { command: m }]) => [c[i]].flat().map((V) => [V, m(o)]));
return Object.fromEntries(u);
}), a = [t, e];
return a.ctx = t, a.shortcuts = e, a.key = t.key, a.keymap = e.keymap, a;
}, ke = (r, s = () => ({})) => k(s, `${r}Attr`), Se = (r, s = () => ({})) => k(s, `${r}Attr`);
function Ce(r, s) {
return (n) => n.get(y).call(r, s);
}), s = [t, e];
return s.ctx = t, s.shortcuts = e, s.key = t.key, s.keymap = e.keymap, s;
}, he = (n, a = () => ({})) => h(a, `${n}Attr`), we = (n, a = () => ({})) => h(a, `${n}Attr`), ke = (n, a, r) => {
const t = h(r ?? {}, n), e = (o) => async () => {
await o.wait(N);
const u = {
plugin: a(o),
options: o.get(t.key)
};
return o.update(b, (i) => [...i, u]), () => {
o.update(b, (i) => i.filter((m) => m !== u));
};
}, s = [t, e];
return s.id = n, s.plugin = e, s.options = t, s;
};
function Se(n, a) {
return (r) => r.get(d).call(n, a);
}
const $e = () => (r) => {
const s = r.get(g), { tr: n } = s.state, t = Object.assign(Object.create(n), n).setTime(Date.now());
return s.dispatch(t);
}, ve = () => (r) => {
const s = document.createElement("div"), n = r.get(f), t = r.get(g), e = B.fromSchema(n).serializeFragment(t.state.doc.content);
return s.appendChild(e), s.innerHTML;
}, Ae = () => (r) => {
const s = r.get(g);
return r.get(H)(s.state.doc);
}, Te = (r) => (s) => {
const n = s.get(g), e = s.get(j)(r);
const Ce = () => (n) => {
const a = n.get(y), { tr: r } = a.state, t = Object.assign(Object.create(r), r).setTime(Date.now());
return a.dispatch(t);
}, ve = () => (n) => {
const a = document.createElement("div"), r = n.get(f), t = n.get(y), e = B.fromSchema(r).serializeFragment(t.state.doc.content);
return a.appendChild(e), a.innerHTML;
}, $e = () => (n) => {
const a = n.get(y);
return n.get(H)(a.state.doc);
}, Te = (n) => (a) => {
const r = a.get(y), e = a.get(M)(n);
if (!e)
return;
const a = n.state.selection.content();
return n.dispatch(
n.state.tr.replaceSelection(new V(e.content, a.openStart, a.openEnd)).scrollIntoView()
const s = r.state.selection.content();
return r.dispatch(
r.state.tr.replaceSelection(new K(e.content, s.openStart, s.openEnd)).scrollIntoView()
);
}, be = () => (r) => {
const s = r.get(g), n = [];
return s.state.doc.descendants((e) => {
e.type.name === "heading" && e.attrs.level && n.push({ text: e.textContent, level: e.attrs.level, id: e.attrs.id });
}), n;
}, Oe = (r, s = !1) => (n) => {
const t = n.get(g), a = n.get(j)(r);
if (!a)
}, Ae = () => (n) => {
const a = n.get(y), r = [];
return a.state.doc.descendants((e) => {
e.type.name === "heading" && e.attrs.level && r.push({ text: e.textContent, level: e.attrs.level, id: e.attrs.id });
}), r;
}, be = (n, a = !1) => (r) => {
const t = r.get(y), s = r.get(M)(n);
if (!s)
return;
if (!s) {
if (!a) {
const { state: m } = t;
return t.dispatch(m.tr.replace(0, m.doc.content.size, new V(a.content, 0, 0)));
return t.dispatch(m.tr.replace(0, m.doc.content.size, new K(s.content, 0, 0)));
}
const o = n.get(f), c = n.get(L), u = n.get(p), i = G.create({
const o = r.get(f), c = r.get(L), u = r.get(p), i = G.create({
schema: o,
doc: a,
doc: s,
plugins: u,

@@ -258,19 +251,19 @@ ...c

t.updateState(i);
}, Re = (r, s) => (n) => {
const t = n.get(g), { tr: e } = t.state, a = e.doc.nodeAt(r);
if (!a)
}, Oe = (n, a) => (r) => {
const t = r.get(y), { tr: e } = t.state, s = e.doc.nodeAt(n);
if (!s)
return;
const o = s(a.attrs);
return t.dispatch(e.setNodeMarkup(r, void 0, o));
}, Ee = (...r) => {
const s = r.length;
let n = s;
for (; n--; )
if (typeof r[n] != "function")
const o = a(s.attrs);
return t.dispatch(e.setNodeMarkup(n, void 0, o));
}, Re = (...n) => {
const a = n.length;
let r = a;
for (; r--; )
if (typeof n[r] != "function")
throw new TypeError("Expected a function");
return (...t) => {
let e = 0, a = s ? r[e](...t) : t[0];
for (; ++e < s; )
a = r[e](a);
return a;
let e = 0, s = a ? n[e](...t) : t[0];
for (; ++e < a; )
s = n[e](s);
return s;
};

@@ -280,35 +273,34 @@ };

re as $command,
ae as $commandAsync,
k as $ctx,
se as $inputRule,
se as $commandAsync,
h as $ctx,
ae as $inputRule,
oe as $inputRuleAsync,
Q as $mark,
ce as $markAsync,
Se as $markAttr,
we as $markSchema,
we as $markAttr,
ge as $markSchema,
W as $node,
ie as $nodeAsync,
ke as $nodeAttr,
fe as $nodeSchema,
he as $nodeAttr,
ye as $nodeSchema,
ue as $prose,
me as $proseAsync,
pe as $remark,
le as $remarkAsync,
ke as $remark,
X as $shortcut,
de as $shortcutAsync,
he as $useKeymap,
ye as $view,
ge as $viewAsync,
d as addTimer,
Ce as callCommand,
$e as forceUpdate,
pe as $shortcutAsync,
fe as $useKeymap,
le as $view,
de as $viewAsync,
g as addTimer,
Se as callCommand,
Ce as forceUpdate,
ve as getHTML,
Ae as getMarkdown,
$e as getMarkdown,
Te as insert,
J as nanoid,
be as outline,
Ee as pipe,
Oe as replaceAll,
Re as setAttr
Ae as outline,
Re as pipe,
be as replaceAll,
Oe as setAttr
};
//# sourceMappingURL=index.es.js.map

@@ -5,2 +5,3 @@ export * from './$node-schema';

export * from './$attr';
export * from './$remark';
//# sourceMappingURL=index.d.ts.map

@@ -6,3 +6,2 @@ export * from './$command';

export * from './$prose';
export * from './$remark';
export * from './$shortcut';

@@ -9,0 +8,0 @@ export * from './$view';

@@ -1,254 +0,247 @@

import { createCmdKey as R, commandsTimerCtx as D, CommandsReady as E, commandsCtx as y, editorStateTimerCtx as b, SchemaReady as l, inputRulesCtx as C, schemaCtx as f, schemaTimerCtx as O, marksCtx as w, nodesCtx as h, prosePluginsCtx as p, InitReady as M, remarkPluginsCtx as $, editorViewTimerCtx as N, nodeViewCtx as v, markViewCtx as A, editorViewCtx as g, serializerCtx as H, parserCtx as j, editorStateOptionsCtx as L } from "@milkdown/core";
import { createCmdKey as O, commandsTimerCtx as I, CommandsReady as R, commandsCtx as d, editorStateTimerCtx as A, SchemaReady as l, inputRulesCtx as C, schemaCtx as f, schemaTimerCtx as E, marksCtx as w, nodesCtx as k, prosePluginsCtx as p, editorViewTimerCtx as D, nodeViewCtx as v, markViewCtx as $, InitReady as N, remarkPluginsCtx as b, editorViewCtx as y, serializerCtx as H, parserCtx as M, editorStateOptionsCtx as L } from "@milkdown/core";
import { createTimer as F, createSlice as U } from "@milkdown/ctx";
import { customAlphabet as q } from "nanoid";
import { missingMarkInSchema as z, missingNodeInSchema as K } from "@milkdown/exception";
import { keymap as P } from "@milkdown/prose/keymap";
import { NodeType as T, DOMSerializer as B, Slice as V } from "@milkdown/prose/model";
import { missingMarkInSchema as P, missingNodeInSchema as j } from "@milkdown/exception";
import { keymap as z } from "@milkdown/prose/keymap";
import { NodeType as T, DOMSerializer as B, Slice as K } from "@milkdown/prose/model";
import { EditorState as G } from "@milkdown/prose/state";
const J = q("abcedfghicklmn", 10), d = (r, s, n) => {
const t = F(n || J());
const J = q("abcedfghicklmn", 10), g = (n, a, r) => {
const t = F(r || J());
let e = !1;
const a = (o) => (o.record(t), o.update(s, (c) => c.concat(t)), async () => {
const u = await r(o, a, () => {
const s = (o) => (o.record(t), o.update(a, (c) => c.concat(t)), async () => {
const u = await n(o, s, () => {
o.done(t), e = !0;
});
return e || o.done(t), () => {
o.update(s, (i) => i.filter((m) => m !== t)), o.clearTimer(t), u == null || u();
o.update(a, (i) => i.filter((m) => m !== t)), o.clearTimer(t), u == null || u();
};
});
return a.timer = t, a;
}, re = (r, s) => {
const n = R(r), t = (e) => async () => {
t.key = n, await e.wait(E);
const a = s(e);
return e.get(y).create(n, a), t.run = (o) => e.get(y).call(r, o), () => {
e.get(y).remove(n);
return s.timer = t, s;
}, re = (n, a) => {
const r = O(n), t = (e) => async () => {
t.key = r, await e.wait(R);
const s = a(e);
return e.get(d).create(r, s), t.run = (o) => e.get(d).call(n, o), () => {
e.get(d).remove(r);
};
};
return t;
}, ae = (r, s, n) => {
const t = R(r);
return d(
async (e, a) => {
await e.wait(E);
const o = await s(e);
return e.get(y).create(t, o), a.run = (c) => e.get(y).call(r, c), a.key = t, () => {
e.get(y).remove(t);
}, se = (n, a, r) => {
const t = O(n);
return g(
async (e, s) => {
await e.wait(R);
const o = await a(e);
return e.get(d).create(t, o), s.run = (c) => e.get(d).call(n, c), s.key = t, () => {
e.get(d).remove(t);
};
},
D,
n
I,
r
);
}, se = (r) => {
const s = (n) => async () => {
await n.wait(l);
const t = r(n);
return n.update(C, (e) => [...e, t]), s.inputRule = t, () => {
n.update(C, (e) => e.filter((a) => a !== t));
}, ae = (n) => {
const a = (r) => async () => {
await r.wait(l);
const t = n(r);
return r.update(C, (e) => [...e, t]), a.inputRule = t, () => {
r.update(C, (e) => e.filter((s) => s !== t));
};
};
return s;
}, oe = (r, s) => d(
async (n, t) => {
await n.wait(l);
const e = await r(n);
return n.update(C, (a) => [...a, e]), t.inputRule = e, () => {
n.update(C, (a) => a.filter((o) => o !== e));
return a;
}, oe = (n, a) => g(
async (r, t) => {
await r.wait(l);
const e = await n(r);
return r.update(C, (s) => [...s, e]), t.inputRule = e, () => {
r.update(C, (s) => s.filter((o) => o !== e));
};
},
b,
s
), Q = (r, s) => {
const n = (t) => async () => {
const e = s(t);
return t.update(w, (a) => [...a.filter((o) => o[0] !== r), [r, e]]), n.id = r, n.schema = e, () => {
t.update(w, (a) => a.filter(([o]) => o !== r));
A,
a
), Q = (n, a) => {
const r = (t) => async () => {
const e = a(t);
return t.update(w, (s) => [...s.filter((o) => o[0] !== n), [n, e]]), r.id = n, r.schema = e, () => {
t.update(w, (s) => s.filter(([o]) => o !== n));
};
};
return n.type = (t) => {
const e = t.get(f).marks[r];
return r.type = (t) => {
const e = t.get(f).marks[n];
if (!e)
throw z(r);
throw P(n);
return e;
}, n;
}, ce = (r, s, n) => {
const t = d(
async (e, a, o) => {
const c = await s(e);
return e.update(w, (u) => [...u.filter((i) => i[0] !== r), [r, c]]), a.id = r, a.schema = c, o(), () => {
e.update(w, (u) => u.filter(([i]) => i !== r));
}, r;
}, ce = (n, a, r) => {
const t = g(
async (e, s, o) => {
const c = await a(e);
return e.update(w, (u) => [...u.filter((i) => i[0] !== n), [n, c]]), s.id = n, s.schema = c, o(), () => {
e.update(w, (u) => u.filter(([i]) => i !== n));
};
},
O,
n
E,
r
);
return t.type = (e) => {
const a = e.get(f).marks[r];
if (!a)
throw z(r);
return a;
const s = e.get(f).marks[n];
if (!s)
throw P(n);
return s;
}, t;
}, W = (r, s) => {
const n = (t) => async () => {
const e = s(t);
return t.update(h, (a) => [...a.filter((o) => o[0] !== r), [r, e]]), n.id = r, n.schema = e, () => {
t.update(h, (a) => a.filter(([o]) => o !== r));
}, W = (n, a) => {
const r = (t) => async () => {
const e = a(t);
return t.update(k, (s) => [...s.filter((o) => o[0] !== n), [n, e]]), r.id = n, r.schema = e, () => {
t.update(k, (s) => s.filter(([o]) => o !== n));
};
};
return n.type = (t) => {
const e = t.get(f).nodes[r];
return r.type = (t) => {
const e = t.get(f).nodes[n];
if (!e)
throw K(r);
throw j(n);
return e;
}, n;
}, ie = (r, s, n) => {
const t = d(
async (e, a, o) => {
const c = await s(e);
return e.update(h, (u) => [...u.filter((i) => i[0] !== r), [r, c]]), a.id = r, a.schema = c, o(), () => {
e.update(h, (u) => u.filter(([i]) => i !== r));
}, r;
}, ie = (n, a, r) => {
const t = g(
async (e, s, o) => {
const c = await a(e);
return e.update(k, (u) => [...u.filter((i) => i[0] !== n), [n, c]]), s.id = n, s.schema = c, o(), () => {
e.update(k, (u) => u.filter(([i]) => i !== n));
};
},
O,
n
E,
r
);
return t.type = (e) => {
const a = e.get(f).nodes[r];
if (!a)
throw K(r);
return a;
const s = e.get(f).nodes[n];
if (!s)
throw j(n);
return s;
}, t;
}, ue = (r) => {
let s;
const n = (t) => async () => (await t.wait(l), s = r(t), t.update(p, (e) => [...e, s]), () => {
t.update(p, (e) => e.filter((a) => a !== s));
}, ue = (n) => {
let a;
const r = (t) => async () => (await t.wait(l), a = n(t), t.update(p, (e) => [...e, a]), () => {
t.update(p, (e) => e.filter((s) => s !== a));
});
return n.plugin = () => s, n.key = () => s.spec.key, n;
}, me = (r, s) => {
let n;
const t = d(
async (e) => (await e.wait(l), n = await r(e), e.update(p, (a) => [...a, n]), () => {
e.update(p, (a) => a.filter((o) => o !== n));
return r.plugin = () => a, r.key = () => a.spec.key, r;
}, me = (n, a) => {
let r;
const t = g(
async (e) => (await e.wait(l), r = await n(e), e.update(p, (s) => [...s, r]), () => {
e.update(p, (s) => s.filter((o) => o !== r));
}),
b,
s
A,
a
);
return t.plugin = () => n, t.key = () => n.spec.key, t;
}, pe = (r) => {
const s = (n) => async () => {
await n.wait(M);
const t = r(n);
return n.update($, (e) => [...e, t]), s.plugin = t, () => {
n.update($, (e) => e.filter((a) => a !== t));
return t.plugin = () => r, t.key = () => r.spec.key, t;
}, X = (n) => {
const a = (r) => async () => {
await r.wait(l);
const t = n(r), e = z(t);
return r.update(p, (s) => [...s, e]), a.keymap = t, () => {
r.update(p, (s) => s.filter((o) => o !== e));
};
};
return s;
}, le = (r, s) => d(
async (n, t) => {
await n.wait(M);
const e = await r(n);
return n.update($, (a) => [...a, e]), t.plugin = e, () => {
n.update($, (a) => a.filter((o) => o !== e));
return a;
}, pe = (n, a) => g(
async (r, t) => {
await r.wait(l);
const e = await n(r), s = z(e);
return r.update(p, (o) => [...o, s]), t.keymap = e, () => {
r.update(p, (o) => o.filter((c) => c !== s));
};
},
O,
s
), X = (r) => {
const s = (n) => async () => {
await n.wait(l);
const t = r(n), e = P(t);
return n.update(p, (a) => [...a, e]), s.keymap = t, () => {
n.update(p, (a) => a.filter((o) => o !== e));
};
};
return s;
}, de = (r, s) => d(
async (n, t) => {
await n.wait(l);
const e = await r(n), a = P(e);
return n.update(p, (o) => [...o, a]), t.keymap = e, () => {
n.update(p, (o) => o.filter((c) => c !== a));
};
},
b,
s
), ye = (r, s) => {
const n = (t) => async () => {
A,
a
), le = (n, a) => {
const r = (t) => async () => {
await t.wait(l);
const e = s(t);
return r.type(t) instanceof T ? t.update(v, (a) => [...a, [r.id, e]]) : t.update(A, (a) => [...a, [r.id, e]]), n.view = e, n.type = r, () => {
r.type(t) instanceof T ? t.update(v, (a) => a.filter((o) => o[0] !== r.id)) : t.update(A, (a) => a.filter((o) => o[0] !== r.id));
const e = a(t);
return n.type(t) instanceof T ? t.update(v, (s) => [...s, [n.id, e]]) : t.update($, (s) => [...s, [n.id, e]]), r.view = e, r.type = n, () => {
n.type(t) instanceof T ? t.update(v, (s) => s.filter((o) => o[0] !== n.id)) : t.update($, (s) => s.filter((o) => o[0] !== n.id));
};
};
return n;
}, ge = (r, s, n) => d(
return r;
}, de = (n, a, r) => g(
async (t, e) => {
await t.wait(l);
const a = await s(t);
return r.type(t) instanceof T ? t.update(v, (o) => [...o, [r.id, a]]) : t.update(A, (o) => [...o, [r.id, a]]), e.view = a, e.type = r, () => {
r.type(t) instanceof T ? t.update(v, (o) => o.filter((c) => c[0] !== r.id)) : t.update(A, (o) => o.filter((c) => c[0] !== r.id));
const s = await a(t);
return n.type(t) instanceof T ? t.update(v, (o) => [...o, [n.id, s]]) : t.update($, (o) => [...o, [n.id, s]]), e.view = s, e.type = n, () => {
n.type(t) instanceof T ? t.update(v, (o) => o.filter((c) => c[0] !== n.id)) : t.update($, (o) => o.filter((c) => c[0] !== n.id));
};
},
N,
n
), k = (r, s) => {
const n = U(r, s), t = (e) => (e.inject(n), () => () => {
e.remove(n);
D,
r
), h = (n, a) => {
const r = U(n, a), t = (e) => (e.inject(r), () => () => {
e.remove(r);
});
return t.key = n, t;
}, fe = (r, s) => {
const n = k(s, r), t = W(r, (a) => a.get(n.key)(a)), e = [n, t];
return e.id = t.id, e.node = t, e.type = (a) => t.type(a), e.schema = t.schema, e.ctx = n, e.key = n.key, e.extendSchema = (a) => (o) => () => {
const c = o.get(n.key), i = a(c)(o);
o.update(h, (m) => [...m.filter((S) => S[0] !== r), [r, i]]), e.schema = i;
return t.key = r, t;
}, ye = (n, a) => {
const r = h(a, n), t = W(n, (s) => s.get(r.key)(s)), e = [r, t];
return e.id = t.id, e.node = t, e.type = (s) => t.type(s), e.schema = t.schema, e.ctx = r, e.key = r.key, e.extendSchema = (s) => (o) => () => {
const c = o.get(r.key), i = s(c)(o);
o.update(k, (m) => [...m.filter((S) => S[0] !== n), [n, i]]), e.schema = i;
}, e;
}, we = (r, s) => {
const n = k(s, r), t = Q(r, (a) => a.get(n.key)(a)), e = [n, t];
return e.id = t.id, e.mark = t, e.type = t.type, e.schema = t.schema, e.ctx = n, e.key = n.key, e.extendSchema = (a) => (o) => () => {
const c = o.get(n.key), i = a(c)(o);
o.update(w, (m) => [...m.filter((S) => S[0] !== r), [r, i]]), e.schema = i;
}, ge = (n, a) => {
const r = h(a, n), t = Q(n, (s) => s.get(r.key)(s)), e = [r, t];
return e.id = t.id, e.mark = t, e.type = t.type, e.schema = t.schema, e.ctx = r, e.key = r.key, e.extendSchema = (s) => (o) => () => {
const c = o.get(r.key), i = s(c)(o);
o.update(w, (m) => [...m.filter((S) => S[0] !== n), [n, i]]), e.schema = i;
}, e;
}, he = (r, s) => {
const n = Object.fromEntries(Object.entries(s).map(([o, { shortcuts: c }]) => [o, c])), t = k(n, `${r}Keymap`), e = X((o) => {
const c = o.get(t.key), u = Object.entries(s).flatMap(([i, { command: m }]) => [c[i]].flat().map((I) => [I, m(o)]));
}, fe = (n, a) => {
const r = Object.fromEntries(Object.entries(a).map(([o, { shortcuts: c }]) => [o, c])), t = h(r, `${n}Keymap`), e = X((o) => {
const c = o.get(t.key), u = Object.entries(a).flatMap(([i, { command: m }]) => [c[i]].flat().map((V) => [V, m(o)]));
return Object.fromEntries(u);
}), a = [t, e];
return a.ctx = t, a.shortcuts = e, a.key = t.key, a.keymap = e.keymap, a;
}, ke = (r, s = () => ({})) => k(s, `${r}Attr`), Se = (r, s = () => ({})) => k(s, `${r}Attr`);
function Ce(r, s) {
return (n) => n.get(y).call(r, s);
}), s = [t, e];
return s.ctx = t, s.shortcuts = e, s.key = t.key, s.keymap = e.keymap, s;
}, he = (n, a = () => ({})) => h(a, `${n}Attr`), we = (n, a = () => ({})) => h(a, `${n}Attr`), ke = (n, a, r) => {
const t = h(r ?? {}, n), e = (o) => async () => {
await o.wait(N);
const u = {
plugin: a(o),
options: o.get(t.key)
};
return o.update(b, (i) => [...i, u]), () => {
o.update(b, (i) => i.filter((m) => m !== u));
};
}, s = [t, e];
return s.id = n, s.plugin = e, s.options = t, s;
};
function Se(n, a) {
return (r) => r.get(d).call(n, a);
}
const $e = () => (r) => {
const s = r.get(g), { tr: n } = s.state, t = Object.assign(Object.create(n), n).setTime(Date.now());
return s.dispatch(t);
}, ve = () => (r) => {
const s = document.createElement("div"), n = r.get(f), t = r.get(g), e = B.fromSchema(n).serializeFragment(t.state.doc.content);
return s.appendChild(e), s.innerHTML;
}, Ae = () => (r) => {
const s = r.get(g);
return r.get(H)(s.state.doc);
}, Te = (r) => (s) => {
const n = s.get(g), e = s.get(j)(r);
const Ce = () => (n) => {
const a = n.get(y), { tr: r } = a.state, t = Object.assign(Object.create(r), r).setTime(Date.now());
return a.dispatch(t);
}, ve = () => (n) => {
const a = document.createElement("div"), r = n.get(f), t = n.get(y), e = B.fromSchema(r).serializeFragment(t.state.doc.content);
return a.appendChild(e), a.innerHTML;
}, $e = () => (n) => {
const a = n.get(y);
return n.get(H)(a.state.doc);
}, Te = (n) => (a) => {
const r = a.get(y), e = a.get(M)(n);
if (!e)
return;
const a = n.state.selection.content();
return n.dispatch(
n.state.tr.replaceSelection(new V(e.content, a.openStart, a.openEnd)).scrollIntoView()
const s = r.state.selection.content();
return r.dispatch(
r.state.tr.replaceSelection(new K(e.content, s.openStart, s.openEnd)).scrollIntoView()
);
}, be = () => (r) => {
const s = r.get(g), n = [];
return s.state.doc.descendants((e) => {
e.type.name === "heading" && e.attrs.level && n.push({ text: e.textContent, level: e.attrs.level, id: e.attrs.id });
}), n;
}, Oe = (r, s = !1) => (n) => {
const t = n.get(g), a = n.get(j)(r);
if (!a)
}, Ae = () => (n) => {
const a = n.get(y), r = [];
return a.state.doc.descendants((e) => {
e.type.name === "heading" && e.attrs.level && r.push({ text: e.textContent, level: e.attrs.level, id: e.attrs.id });
}), r;
}, be = (n, a = !1) => (r) => {
const t = r.get(y), s = r.get(M)(n);
if (!s)
return;
if (!s) {
if (!a) {
const { state: m } = t;
return t.dispatch(m.tr.replace(0, m.doc.content.size, new V(a.content, 0, 0)));
return t.dispatch(m.tr.replace(0, m.doc.content.size, new K(s.content, 0, 0)));
}
const o = n.get(f), c = n.get(L), u = n.get(p), i = G.create({
const o = r.get(f), c = r.get(L), u = r.get(p), i = G.create({
schema: o,
doc: a,
doc: s,
plugins: u,

@@ -258,19 +251,19 @@ ...c

t.updateState(i);
}, Re = (r, s) => (n) => {
const t = n.get(g), { tr: e } = t.state, a = e.doc.nodeAt(r);
if (!a)
}, Oe = (n, a) => (r) => {
const t = r.get(y), { tr: e } = t.state, s = e.doc.nodeAt(n);
if (!s)
return;
const o = s(a.attrs);
return t.dispatch(e.setNodeMarkup(r, void 0, o));
}, Ee = (...r) => {
const s = r.length;
let n = s;
for (; n--; )
if (typeof r[n] != "function")
const o = a(s.attrs);
return t.dispatch(e.setNodeMarkup(n, void 0, o));
}, Re = (...n) => {
const a = n.length;
let r = a;
for (; r--; )
if (typeof n[r] != "function")
throw new TypeError("Expected a function");
return (...t) => {
let e = 0, a = s ? r[e](...t) : t[0];
for (; ++e < s; )
a = r[e](a);
return a;
let e = 0, s = a ? n[e](...t) : t[0];
for (; ++e < a; )
s = n[e](s);
return s;
};

@@ -280,35 +273,34 @@ };

re as $command,
ae as $commandAsync,
k as $ctx,
se as $inputRule,
se as $commandAsync,
h as $ctx,
ae as $inputRule,
oe as $inputRuleAsync,
Q as $mark,
ce as $markAsync,
Se as $markAttr,
we as $markSchema,
we as $markAttr,
ge as $markSchema,
W as $node,
ie as $nodeAsync,
ke as $nodeAttr,
fe as $nodeSchema,
he as $nodeAttr,
ye as $nodeSchema,
ue as $prose,
me as $proseAsync,
pe as $remark,
le as $remarkAsync,
ke as $remark,
X as $shortcut,
de as $shortcutAsync,
he as $useKeymap,
ye as $view,
ge as $viewAsync,
d as addTimer,
Ce as callCommand,
$e as forceUpdate,
pe as $shortcutAsync,
fe as $useKeymap,
le as $view,
de as $viewAsync,
g as addTimer,
Se as callCommand,
Ce as forceUpdate,
ve as getHTML,
Ae as getMarkdown,
$e as getMarkdown,
Te as insert,
J as nanoid,
be as outline,
Ee as pipe,
Oe as replaceAll,
Re as setAttr
Ae as outline,
Re as pipe,
be as replaceAll,
Oe as setAttr
};
//# sourceMappingURL=index.es.js.map
{
"name": "@milkdown/utils",
"type": "module",
"version": "7.2.4",
"version": "7.3.0",
"license": "MIT",

@@ -27,9 +27,9 @@ "repository": {

"tslib": "^2.5.0",
"@milkdown/exception": "7.2.4"
"@milkdown/exception": "7.3.0"
},
"devDependencies": {
"@milkdown/core": "7.2.4",
"@milkdown/ctx": "7.2.4",
"@milkdown/prose": "7.2.4",
"@milkdown/transformer": "7.2.4"
"@milkdown/core": "7.3.0",
"@milkdown/ctx": "7.3.0",
"@milkdown/prose": "7.3.0",
"@milkdown/transformer": "7.3.0"
},

@@ -36,0 +36,0 @@ "nx": {

@@ -6,1 +6,2 @@ /* Copyright 2021, Milkdown by Mirone. */

export * from './$attr'
export * from './$remark'

@@ -8,3 +8,2 @@ /* Copyright 2021, Milkdown by Mirone. */

export * from './$prose'
export * from './$remark'
export * from './$shortcut'

@@ -11,0 +10,0 @@ export * from './$view'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc