@milkdown/plugin-diagram
Advanced tools
Comparing version 7.2.3 to 7.2.4
@@ -11,8 +11,8 @@ import { expectDomTypeError as f } from "@milkdown/exception"; | ||
value: e | ||
}), R = (e) => M(e, "code", (t, a, i) => { | ||
const { lang: r, value: m } = t; | ||
}), R = (e) => M(e, "code", (t, i, a) => { | ||
const { lang: r, value: s } = t; | ||
if (r !== "mermaid") | ||
return t; | ||
const g = w(m); | ||
return i && a != null && i.children.splice(a, 1, g), t; | ||
const m = w(s); | ||
return a && i != null && a.children.splice(i, 1, m), t; | ||
}), I = () => { | ||
@@ -23,3 +23,3 @@ function e(t) { | ||
return e; | ||
}, T = $("abcdefg", 8), s = (e) => { | ||
}, T = $("abcdefg", 8), c = (e) => { | ||
var t; | ||
@@ -32,8 +32,8 @@ return ((t = e == null ? void 0 : e.attrs) == null ? void 0 : t.identity) || T(); | ||
} | ||
}), e), c = k({ startOnLoad: !1 }, "mermaidConfig"); | ||
n(c, { | ||
}), e), l = k({ startOnLoad: !1 }, "mermaidConfig"); | ||
n(l, { | ||
displayName: "Ctx<mermaidConfig>" | ||
}); | ||
const o = "diagram", d = h(o, (e) => (D.initialize({ | ||
...e.get(c.key) | ||
...e.get(l.key) | ||
}), { | ||
@@ -69,10 +69,10 @@ content: "text*", | ||
toDOM: (t) => { | ||
const a = s(t), i = t.attrs.value, r = document.createElement("div"); | ||
return r.dataset.type = o, r.dataset.id = a, r.dataset.value = i, r.textContent = i, r; | ||
const i = c(t), a = t.attrs.value, r = document.createElement("div"); | ||
return r.dataset.type = o, r.dataset.id = i, r.dataset.value = a, r.textContent = a, r; | ||
}, | ||
parseMarkdown: { | ||
match: ({ type: t }) => t === o, | ||
runner: (t, a, i) => { | ||
const r = a.value; | ||
t.addNode(i, { value: r, identity: s() }); | ||
runner: (t, i, a) => { | ||
const r = i.value; | ||
t.addNode(a, { value: r, identity: c() }); | ||
} | ||
@@ -82,4 +82,4 @@ }, | ||
match: (t) => t.type.name === o, | ||
runner: (t, a) => { | ||
t.addNode("code", void 0, a.attrs.value || "", { lang: "mermaid" }); | ||
runner: (t, i) => { | ||
t.addNode("code", void 0, i.attrs.value || "", { lang: "mermaid" }); | ||
} | ||
@@ -94,26 +94,26 @@ } | ||
}); | ||
const l = C(() => new v(/^```mermaid$/, (e, t, a, i) => { | ||
const r = d.type(), m = e.doc.resolve(a); | ||
return m.node(-1).canReplaceWith(m.index(-1), m.indexAfter(-1), r) ? e.tr.delete(a, i).setBlockType(a, a, r, { identity: s() }) : null; | ||
const u = C((e) => new v(/^```mermaid$/, (t, i, a, r) => { | ||
const s = d.type(e), m = t.doc.resolve(a); | ||
return m.node(-1).canReplaceWith(m.index(-1), m.indexAfter(-1), s) ? t.tr.delete(a, r).setBlockType(a, a, s, { identity: c() }) : null; | ||
})); | ||
n(l, { | ||
n(u, { | ||
displayName: "InputRule<insertDiagramInputRules>" | ||
}); | ||
const u = N(() => I); | ||
n(u, { | ||
const p = N(() => I); | ||
n(p, { | ||
displayName: "Remark<diagram>" | ||
}); | ||
const p = x("InsertDiagramCommand", () => () => y(d.type(), { identity: s() })); | ||
n(p, { | ||
const g = x("InsertDiagramCommand", (e) => () => y(d.type(e), { identity: c() })); | ||
n(g, { | ||
displayName: "Command<insertDiagramCommand>" | ||
}); | ||
const W = [u, c, d, p, l].flat(); | ||
const W = [p, l, d, g, u].flat(); | ||
export { | ||
W as diagram, | ||
d as diagramSchema, | ||
p as insertDiagramCommand, | ||
l as insertDiagramInputRules, | ||
c as mermaidConfigCtx, | ||
u as remarkDiagramPlugin | ||
g as insertDiagramCommand, | ||
u as insertDiagramInputRules, | ||
l as mermaidConfigCtx, | ||
p as remarkDiagramPlugin | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
@@ -11,8 +11,8 @@ import { expectDomTypeError as f } from "@milkdown/exception"; | ||
value: e | ||
}), R = (e) => M(e, "code", (t, a, i) => { | ||
const { lang: r, value: m } = t; | ||
}), R = (e) => M(e, "code", (t, i, a) => { | ||
const { lang: r, value: s } = t; | ||
if (r !== "mermaid") | ||
return t; | ||
const g = w(m); | ||
return i && a != null && i.children.splice(a, 1, g), t; | ||
const m = w(s); | ||
return a && i != null && a.children.splice(i, 1, m), t; | ||
}), I = () => { | ||
@@ -23,3 +23,3 @@ function e(t) { | ||
return e; | ||
}, T = $("abcdefg", 8), s = (e) => { | ||
}, T = $("abcdefg", 8), c = (e) => { | ||
var t; | ||
@@ -32,8 +32,8 @@ return ((t = e == null ? void 0 : e.attrs) == null ? void 0 : t.identity) || T(); | ||
} | ||
}), e), c = k({ startOnLoad: !1 }, "mermaidConfig"); | ||
n(c, { | ||
}), e), l = k({ startOnLoad: !1 }, "mermaidConfig"); | ||
n(l, { | ||
displayName: "Ctx<mermaidConfig>" | ||
}); | ||
const o = "diagram", d = h(o, (e) => (D.initialize({ | ||
...e.get(c.key) | ||
...e.get(l.key) | ||
}), { | ||
@@ -69,10 +69,10 @@ content: "text*", | ||
toDOM: (t) => { | ||
const a = s(t), i = t.attrs.value, r = document.createElement("div"); | ||
return r.dataset.type = o, r.dataset.id = a, r.dataset.value = i, r.textContent = i, r; | ||
const i = c(t), a = t.attrs.value, r = document.createElement("div"); | ||
return r.dataset.type = o, r.dataset.id = i, r.dataset.value = a, r.textContent = a, r; | ||
}, | ||
parseMarkdown: { | ||
match: ({ type: t }) => t === o, | ||
runner: (t, a, i) => { | ||
const r = a.value; | ||
t.addNode(i, { value: r, identity: s() }); | ||
runner: (t, i, a) => { | ||
const r = i.value; | ||
t.addNode(a, { value: r, identity: c() }); | ||
} | ||
@@ -82,4 +82,4 @@ }, | ||
match: (t) => t.type.name === o, | ||
runner: (t, a) => { | ||
t.addNode("code", void 0, a.attrs.value || "", { lang: "mermaid" }); | ||
runner: (t, i) => { | ||
t.addNode("code", void 0, i.attrs.value || "", { lang: "mermaid" }); | ||
} | ||
@@ -94,26 +94,26 @@ } | ||
}); | ||
const l = C(() => new v(/^```mermaid$/, (e, t, a, i) => { | ||
const r = d.type(), m = e.doc.resolve(a); | ||
return m.node(-1).canReplaceWith(m.index(-1), m.indexAfter(-1), r) ? e.tr.delete(a, i).setBlockType(a, a, r, { identity: s() }) : null; | ||
const u = C((e) => new v(/^```mermaid$/, (t, i, a, r) => { | ||
const s = d.type(e), m = t.doc.resolve(a); | ||
return m.node(-1).canReplaceWith(m.index(-1), m.indexAfter(-1), s) ? t.tr.delete(a, r).setBlockType(a, a, s, { identity: c() }) : null; | ||
})); | ||
n(l, { | ||
n(u, { | ||
displayName: "InputRule<insertDiagramInputRules>" | ||
}); | ||
const u = N(() => I); | ||
n(u, { | ||
const p = N(() => I); | ||
n(p, { | ||
displayName: "Remark<diagram>" | ||
}); | ||
const p = x("InsertDiagramCommand", () => () => y(d.type(), { identity: s() })); | ||
n(p, { | ||
const g = x("InsertDiagramCommand", (e) => () => y(d.type(e), { identity: c() })); | ||
n(g, { | ||
displayName: "Command<insertDiagramCommand>" | ||
}); | ||
const W = [u, c, d, p, l].flat(); | ||
const W = [p, l, d, g, u].flat(); | ||
export { | ||
W as diagram, | ||
d as diagramSchema, | ||
p as insertDiagramCommand, | ||
l as insertDiagramInputRules, | ||
c as mermaidConfigCtx, | ||
u as remarkDiagramPlugin | ||
g as insertDiagramCommand, | ||
u as insertDiagramInputRules, | ||
l as mermaidConfigCtx, | ||
p as remarkDiagramPlugin | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
{ | ||
"name": "@milkdown/plugin-diagram", | ||
"type": "module", | ||
"version": "7.2.3", | ||
"version": "7.2.4", | ||
"license": "MIT", | ||
@@ -35,4 +35,4 @@ "repository": { | ||
"unist-util-visit": "^4.0.0", | ||
"@milkdown/exception": "7.2.3", | ||
"@milkdown/utils": "7.2.3" | ||
"@milkdown/exception": "7.2.4", | ||
"@milkdown/utils": "7.2.4" | ||
}, | ||
@@ -42,5 +42,5 @@ "devDependencies": { | ||
"@types/unist": "^2.0.6", | ||
"@milkdown/core": "7.2.3", | ||
"@milkdown/ctx": "7.2.3", | ||
"@milkdown/prose": "7.2.3" | ||
"@milkdown/core": "7.2.4", | ||
"@milkdown/ctx": "7.2.4", | ||
"@milkdown/prose": "7.2.4" | ||
}, | ||
@@ -47,0 +47,0 @@ "nx": { |
@@ -101,5 +101,5 @@ /* Copyright 2021, Milkdown by Mirone. */ | ||
/// A input rule that will insert a diagram node when you type ` ```mermaid `. | ||
export const insertDiagramInputRules = $inputRule(() => | ||
export const insertDiagramInputRules = $inputRule(ctx => | ||
new InputRule(/^```mermaid$/, (state, _match, start, end) => { | ||
const nodeType = diagramSchema.type() | ||
const nodeType = diagramSchema.type(ctx) | ||
const $start = state.doc.resolve(start) | ||
@@ -123,3 +123,3 @@ if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) | ||
/// A command that will insert a diagram node. | ||
export const insertDiagramCommand = $command('InsertDiagramCommand', () => () => setBlockType(diagramSchema.type(), { identity: getId() })) | ||
export const insertDiagramCommand = $command('InsertDiagramCommand', ctx => () => setBlockType(diagramSchema.type(ctx), { identity: getId() })) | ||
@@ -126,0 +126,0 @@ withMeta(insertDiagramCommand, { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26103
+ Added@milkdown/exception@7.2.4(transitive)
+ Added@milkdown/utils@7.2.4(transitive)
- Removed@milkdown/exception@7.2.3(transitive)
- Removed@milkdown/utils@7.2.3(transitive)
Updated@milkdown/exception@7.2.4
Updated@milkdown/utils@7.2.4