@ai-matrx/rich-content 0.2.78 → 0.2.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.79
|
|
4
|
+
### Unreleased
|
|
5
|
+
|
|
6
|
+
- **A mermaid `<artifact type="mermaid">` prints as a drawn diagram.** `printMessage` drew mermaid
|
|
7
|
+
FENCES only, so an artifact-wrapped diagram printed as source. It now draws both through the same
|
|
8
|
+
path (`drawMermaidForPrint(markdown, extraBodies)`; `mermaidSourceOf` strips a fence around the
|
|
9
|
+
body). No consumer action.
|
|
10
|
+
|
|
3
11
|
## 0.2.78
|
|
4
12
|
|
|
5
13
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
14
|
`git diff npm/rich-content/v0.2.77..npm/rich-content/v0.2.78 -- apps/shared/rich-content`).
|
|
7
15
|
No source changes intended and no consumer action required.
|
|
8
16
|
|
|
17
|
+
## 0.2.77
|
|
18
|
+
|
|
19
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
20
|
+
`git diff npm/rich-content/v0.2.76..npm/rich-content/v0.2.77 -- apps/shared/rich-content`).
|
|
21
|
+
No source changes intended and no consumer action required.
|
|
22
|
+
|
|
23
|
+
## 0.2.76
|
|
24
|
+
|
|
25
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
26
|
+
`git diff npm/rich-content/v0.2.75..npm/rich-content/v0.2.76 -- apps/shared/rich-content`).
|
|
27
|
+
No source changes intended and no consumer action required.
|
|
28
|
+
|
|
29
|
+
## 0.2.75
|
|
30
|
+
|
|
31
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
32
|
+
`git diff npm/rich-content/v0.2.74..npm/rich-content/v0.2.75 -- apps/shared/rich-content`).
|
|
33
|
+
No source changes intended and no consumer action required.
|
|
34
|
+
|
|
9
35
|
## 0.2.74
|
|
10
36
|
|
|
11
37
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
@@ -23,14 +23,18 @@ async function printMessage(markdown, options = {}) {
|
|
|
23
23
|
return printer?.toPrintHtml ? printer : null;
|
|
24
24
|
};
|
|
25
25
|
const blocks = listPrintBlocks(markdown, skin);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
26
|
+
const mermaidBlocks = blocks.filter((block) => block.type === "mermaid");
|
|
27
|
+
const hasMermaid = mermaidBlocks.length > 0;
|
|
28
|
+
const adapted = blocks.filter((block) => block.type !== "mermaid" && adapterFor(block) !== null);
|
|
28
29
|
if (!hasMermaid && adapted.length === 0) return printMarkdown(markdown, { skin, title });
|
|
29
30
|
let drawing = null;
|
|
30
31
|
const drawAll = () => drawing ??= (async () => {
|
|
31
32
|
try {
|
|
32
33
|
const { drawMermaidForPrint } = await import("../mermaid/print-render.js");
|
|
33
|
-
const { pictures, failed } = await drawMermaidForPrint(
|
|
34
|
+
const { pictures, failed } = await drawMermaidForPrint(
|
|
35
|
+
markdown,
|
|
36
|
+
mermaidBlocks.filter((block) => block.source !== "fence").map((block) => block.body)
|
|
37
|
+
);
|
|
34
38
|
if (failed > 0) {
|
|
35
39
|
notice("warning", `${failed} diagram${failed === 1 ? "" : "s"} could not be drawn and print${failed === 1 ? "s" : ""} as source.`);
|
|
36
40
|
}
|
|
@@ -45,7 +49,7 @@ async function printMessage(markdown, options = {}) {
|
|
|
45
49
|
skin,
|
|
46
50
|
title,
|
|
47
51
|
renderBlock: async (block) => {
|
|
48
|
-
if (block.
|
|
52
|
+
if (block.type === "mermaid") {
|
|
49
53
|
const svg = (await drawAll())?.get(block.body);
|
|
50
54
|
return svg ? { svg, alt: "Diagram" } : null;
|
|
51
55
|
}
|
|
@@ -6,4 +6,6 @@ export interface PrintedDiagrams {
|
|
|
6
6
|
/** Fences that could not be drawn (they print as source). */
|
|
7
7
|
failed: number;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
/** A mermaid `<artifact>` body may wrap its source in a fence; draw the diagram source itself. */
|
|
10
|
+
export declare function mermaidSourceOf(body: string): string;
|
|
11
|
+
export declare function drawMermaidForPrint(markdown: string, extraBodies?: readonly string[]): Promise<PrintedDiagrams>;
|
|
@@ -20,12 +20,17 @@ function mermaidFenceSources(markdown) {
|
|
|
20
20
|
}
|
|
21
21
|
return out;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
function mermaidSourceOf(body) {
|
|
24
|
+
const fenced = /^\s*(`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?\s*\1\s*$/.exec(body);
|
|
25
|
+
return (fenced ? fenced[2] : body).trim();
|
|
26
|
+
}
|
|
27
|
+
async function drawMermaidForPrint(markdown, extraBodies = []) {
|
|
24
28
|
const pictures = /* @__PURE__ */ new Map();
|
|
25
29
|
let failed = 0;
|
|
26
|
-
|
|
30
|
+
const sources = /* @__PURE__ */ new Set([...mermaidFenceSources(markdown), ...extraBodies]);
|
|
31
|
+
for (const source of sources) {
|
|
27
32
|
try {
|
|
28
|
-
const { svg } = await renderMermaid(source, PRINT_OPTIONS);
|
|
33
|
+
const { svg } = await renderMermaid(mermaidSourceOf(source), PRINT_OPTIONS);
|
|
29
34
|
pictures.set(source, svg);
|
|
30
35
|
} catch {
|
|
31
36
|
failed++;
|
|
@@ -35,5 +40,6 @@ async function drawMermaidForPrint(markdown) {
|
|
|
35
40
|
}
|
|
36
41
|
export {
|
|
37
42
|
drawMermaidForPrint,
|
|
38
|
-
mermaidFenceSources
|
|
43
|
+
mermaidFenceSources,
|
|
44
|
+
mermaidSourceOf
|
|
39
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/rich-content",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.79",
|
|
4
4
|
"description": "The AI Matrx formatted-text engine: the one markdown renderer, streaming markdown, the block splitter and renderer, the generic blocks, <RichContent> levels, the rich-document action registry and menus, copy, and the selection toolbar — as portable React.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -130,20 +130,20 @@
|
|
|
130
130
|
"unist-util-visit": "^5.1.0",
|
|
131
131
|
"unist-util-visit-parents": "^6.0.2",
|
|
132
132
|
"yaml": "^2.9.1",
|
|
133
|
-
"@ai-matrx/
|
|
133
|
+
"@ai-matrx/alchemy": "latest",
|
|
134
134
|
"@ai-matrx/canvas": "latest",
|
|
135
135
|
"@ai-matrx/content-ir": "latest",
|
|
136
|
-
"@ai-matrx/
|
|
136
|
+
"@ai-matrx/content-ir-react": "latest",
|
|
137
137
|
"@ai-matrx/data": "latest",
|
|
138
|
-
"@ai-matrx/
|
|
138
|
+
"@ai-matrx/agents": "latest",
|
|
139
139
|
"@ai-matrx/design-system": "latest",
|
|
140
|
+
"@ai-matrx/diff": "latest",
|
|
140
141
|
"@ai-matrx/icons": "latest",
|
|
141
142
|
"@ai-matrx/kit": "latest",
|
|
142
143
|
"@ai-matrx/media": "latest",
|
|
143
|
-
"@ai-matrx/print": "latest",
|
|
144
144
|
"@ai-matrx/records": "latest",
|
|
145
145
|
"@ai-matrx/records-ui": "latest",
|
|
146
|
-
"@ai-matrx/
|
|
146
|
+
"@ai-matrx/print": "latest"
|
|
147
147
|
},
|
|
148
148
|
"peerDependencies": {
|
|
149
149
|
"react": ">=19.0.0",
|
|
@@ -204,5 +204,5 @@
|
|
|
204
204
|
"verify:modules-tarball": "node ./scripts/verify-modules-tarball.mjs",
|
|
205
205
|
"verify:tarball": "node ./scripts/verify-tarball.mjs"
|
|
206
206
|
},
|
|
207
|
-
"gitHead": "
|
|
207
|
+
"gitHead": "beef2ffa0187b314e351134e7f905eb2d6a8ec33"
|
|
208
208
|
}
|