concept-atlas-dense-explain 4.0.0 → 4.1.1
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/package.json +1 -1
- package/packaged-skill/SKILL.md +8 -23
- package/packaged-skill/references/components.md +26 -0
- package/packaged-skill/references/diagnostics.md +15 -0
- package/template/src/components/MDXComponents.jsx +159 -23
- package/template/src/components/index.js +1 -1
- package/template/src/main.jsx +14 -14
- package/template/src/styles/core.css +126 -34
package/package.json
CHANGED
package/packaged-skill/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: concept-atlas-dense-explain
|
|
3
|
-
description: Turn a topic or
|
|
3
|
+
description: Turn a topic or existing document into an interactive Concept Atlas explainer — AI-editable MDX compiled to standalone HTML with concept nodes, relation graphs, math, charts, figures, citations, and reading aids. Use for technical explanations, concept maps, layered knowledge pages, dense explainers, or interactive teaching pages; also 概念图 / 知识地图 / 分层讲解.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Concept Atlas Dense Explain
|
|
@@ -20,9 +20,7 @@ This is the only runner — there is nothing to look for. Do not search for a lo
|
|
|
20
20
|
## Workflow
|
|
21
21
|
|
|
22
22
|
1. Choose one page shell: `atlas` (concept graph with node navigation) or `scroll` (continuous document). Recommend `atlas` when the reader drills into concepts or follows relations, `scroll` for linear argument, tutorials, and reports. The library is shared. If an `.mdx` already exists, detect its shell and work with it.
|
|
23
|
-
2. **Learn the components
|
|
24
|
-
- `references/atlas-guide.mdx` (atlas) or `references/scroll-guide.mdx` (scroll)
|
|
25
|
-
It is real, compilable MDX showing that shell's components and their exact props; search it for a component name instead of guessing, and do not look for component documentation anywhere else. Do not run `guide` for this.
|
|
23
|
+
2. **Learn the components before authoring.** `references/components.md` is the catalogue — search it by component name for props and shapes rather than guessing. `references/atlas-guide.mdx` (atlas) or `references/scroll-guide.mdx` (scroll) is real, compilable MDX showing how that shell's components compose into a page. Do not look for component documentation anywhere else, and do not run `guide` for this.
|
|
26
24
|
Run `npx concept-atlas-dense-explain guide --mode <mode> -o <file>` only when you specifically need a project-local copy to compile beside the page, and delete that copy when done.
|
|
27
25
|
3. Start from a skeleton when useful: `npx concept-atlas-dense-explain create <file>.mdx --mode atlas|scroll` (`--mode` defaults to `scroll`). `create` and `guide` overwrite their output, so never point them at a file you want to keep.
|
|
28
26
|
4. Write the semantic MDX into the user's `.mdx` file (see Authoring rules).
|
|
@@ -44,15 +42,9 @@ This is the only runner — there is nothing to look for. Do not search for a lo
|
|
|
44
42
|
- The browser tab comes from the shell, not the build flags: `ExplainPage title` (atlas) or `ScrollHeader title` (scroll) becomes the `<title>`, so give it a real, specific name — never a placeholder like "主题名称". Every page uses a fixed 📃 favicon.
|
|
45
43
|
- Never make one MDX file both shells. When switching shells, convert only the outer structure.
|
|
46
44
|
|
|
47
|
-
## Component
|
|
45
|
+
## Component and prop reference
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
- Argument and evidence: `Evidence`, `Invariant`, `FailureMode`, `Tradeoff`, `Checklist`, `LearningObjectives`, `KeyQuestion`
|
|
51
|
-
- Learning loop and provenance: `WorkedExample` + `Step`, `Quiz`, `KeyTakeaways`, `Source`, `Confidence`, `LastReviewed`, `Term`
|
|
52
|
-
- Information models: `Flow`, `Timeline`, `Compare`, `DecisionMatrix`, `FrameworkModel`, `MatrixModel`, `FormulaModel`, `PyramidModel`, `FunnelModel`
|
|
53
|
-
- Data and behaviour: `DataTable`, `Metric`, `PropertyList`, `TreeView`, `StateMachine`, `DecisionTree`, `FeedbackLoop`, `CodeDiff`
|
|
54
|
-
- Reading and layout: `Insight`, `Callout`, `Details`, `Quote`, `NoteGrid`, `Tabs`, `Columns`, `Stack`, `Grid`, `Split`, `ScrollGrid`, `ScrollPair`, `ScrollToc`
|
|
55
|
-
- Graphics and extensions: `Mermaid`, `RelationMap`, `RelationPath`, `Math`, `MathBlock`, `Chart`, `CodeTabs`, `AnnotatedCode`, `Figure` (alias `Image`), `FigureRef`, `Cite`, `References`
|
|
47
|
+
The component catalogue, every prop shape, and the syntax traps are in `references/components.md`. Read it before authoring, and search it by component name whenever a tag is new to this page — prop names and shapes are not guessable. Charts, the learning loop, provenance, data/behaviour and structure components are documented there in full; only the rules that must hold on every page are repeated below.
|
|
56
48
|
|
|
57
49
|
## Authoring rules
|
|
58
50
|
|
|
@@ -62,21 +54,14 @@ This is the only runner — there is nothing to look for. Do not search for a lo
|
|
|
62
54
|
- Array props are arrays of objects: `Flow steps={[{title, description}]}`, `Timeline events={[{label, content}]}`, `MatrixModel cells={[{title, description, tone}]}`, `DecisionMatrix headers={[...]} rows={[[...]]}`, `Chart data={[{label, value}]}`, `References items={[{id, authors, year, title, url, source}]}`. The validator warns (`PROP_EXPECTS_ARRAY`) when an array prop gets a string or non-array.
|
|
63
55
|
- `Relation type` must be one of `prerequisite`, `causes`, `produces`, `uses`, `implements`, `contrasts`, `depends-on`, `exception-of`, `precedes`, and each `Relation` needs a `label`. Parent/child hierarchy is implicit (via `parent` and `Children`/`ConceptRef`) — do not express it with a `Relation`.
|
|
64
56
|
- **Math**: MDX parses `{ ... }` in children as expressions, so pass LaTeX with braces or backslashes through `formula`: `<Math formula="r_{\text{ann}} = (1 + r)^{12} - 1" />`, `<MathBlock formula="I(x) = -\log_2 p(x)" variables={[{symbol, description}]} />`. Brace-free children such as `<Math>\log_2 N</Math>` are fine. The validator warns (`MATH_CHILDREN_BRACES`).
|
|
65
|
-
- **
|
|
66
|
-
- **
|
|
67
|
-
- **
|
|
68
|
-
- **Provenance**: `Source kind="spec|rfc|implementation|experiment|experience|reference" label href` marks one claim's origin inline (`reference` is the default); `Confidence level="high|medium|low" basis` wraps a claim with how strongly it is established; `Term name` (or children as the definition) gives an inline hover definition.
|
|
69
|
-
- **Data and behaviour**: `DataTable headers={[...]} rows={[[...]]}` is the neutral table (no comparative stance). `Metric label value unit delta trend note` is one headline number — compose several with `Grid`/`ScrollGrid`. `StateMachine states={[{id,label,terminal}]} transitions={[{from,to,event,guard}]}` expresses cycles and guards. `DecisionTree branches={[{condition,outcome,tone,branches}]}` nests branches. `FeedbackLoop type="reinforcing|balancing" nodes={[{label,description}]}` closes a loop. `CodeDiff before after language` shows a change.
|
|
70
|
-
- **Structure and code extensions**: `Quote author source href` attributes a quotation. `Checklist title items={[{text,status:'pass'|'fail'|'unknown'|'todo',note}]}` is a verification list. `PropertyList title items={[{name,value,note}]}` is a name/value spec ledger. `TreeView title items={[{label,description,children:[…]}]}` nests a hierarchy. `CodeTabs items={[{label,language,code}]} title caption lineNumbers` gives one collapsible listing per variant. `AnnotatedCode code language title notes={[{line,text}]}` numbers a listing and calls out specific lines. `LastReviewed date by note` is a review stamp.
|
|
71
|
-
- **Figure**: a relative `src` (`./assets/diagram.png`) stays a relative link by default; compile with `--inline-assets` to bake every local image in as base64, or set `inline={true}` / `inline={false}` on one figure to override (precedence: per-figure prop > global flag > link). `http(s)` URLs stay links and warn (`ASSET_REMOTE`). Always set `alt`; a missing relative file warns (`ASSET_MISSING`) and shows a placeholder. Readers can click a figure to open it full-screen (zoom, drag, `Esc`) — mention it for diagram-heavy pages.
|
|
72
|
-
- **Figure numbering**: give a figure an `id` and reference it with `<FigureRef id="..." />` to render "图 N". Numbering follows document order (per node in `atlas`, whole document in `scroll`) and reflows automatically, so never hand-write "图 1"; an explicit `label` still wins. A ref with no matching `id` warns (`FIGURE_REF_UNRESOLVED`).
|
|
73
|
-
- **Figure size & cost**: linking keeps the HTML small but requires the output to sit beside the MDX's `assets/` (the CLI warns when `-o` points elsewhere). Inlining is what makes a screenshot-heavy page large (a page with no heavy renderers otherwise lands near 250KB), and an inlined asset over 512KB warns (`ASSET_LARGE`). Decide the trade-off with the user instead of choosing silently.
|
|
74
|
-
- **Cite/References**: `<Cite id="..." />` renders `[n]` from the matching item's position in `<References items={...} />`. In `scroll`, `References` can sit anywhere. In `atlas`, keep the cites and the `References` block in the same node, because node content only renders when that node is open.
|
|
57
|
+
- **Code**: pass code as a string via `code` (or as children) wrapped in a template literal, so MDX does not read it as expressions: `<CodeBlock language="bash" lineNumbers>{`npm run validate`}</CodeBlock>`. Badges, captions and wrapping are documented in `references/components.md`.
|
|
58
|
+
- **Figures**: always set `alt`; number with an `id` plus `<FigureRef>`, never hand-write "图 N"; relative links versus `--inline-assets` is a size trade-off — decide it with the user instead of choosing silently.
|
|
59
|
+
- **Cite/References**: `<Cite id="..." />` renders `[n]` from the matching item's position in `<References items={...} />`. In `atlas`, keep the cites and the `References` block in the same node, because node content only renders when that node is open.
|
|
75
60
|
- Continuous reading is configured on the shell, not with manual CSS: `spacing="compact|comfortable|airy"` for rhythm, `fontSize="compact|normal|large|xlarge"` (or numeric `scale`/`lineHeight`) for text size.
|
|
76
61
|
|
|
77
62
|
## Validation diagnostics
|
|
78
63
|
|
|
79
|
-
`validate` and the build print `CODE line:column message`. Fix
|
|
64
|
+
`validate` and the build print `CODE line:column message`. Fix every `error` before building; `references/diagnostics.md` lists the codes you may meet and separates errors from warnings. `NO_ROOT_LEVEL`, `MULTIPLE_ROOT_LEVEL`, `MECHANISM_KIND_UNVERIFIED` and `FAILURE_KIND_UNSTRUCTURED` are warnings that `--strict` promotes to errors.
|
|
80
65
|
|
|
81
66
|
## Before you report
|
|
82
67
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Component and prop reference
|
|
2
|
+
|
|
3
|
+
Search this file by component name before writing a tag the page has not used yet. Props are shown in their real shapes; anything not listed here does not exist. The rules that hold for every page — semantic MDX, `kind` contracts, relation types, array-prop shape, math braces, figure numbering, cite scoping — are in `SKILL.md`; this file adds the per-component detail.
|
|
4
|
+
|
|
5
|
+
## Families
|
|
6
|
+
|
|
7
|
+
- Node semantics: `Overview`, `Definition`, `Mechanism`, `Implementation`, `CodeBlock`, `Boundary`, `Example`, `Counterexample`, `Prerequisite`, `Input`, `Output`, `Glossary`
|
|
8
|
+
- Argument and evidence: `Evidence`, `Invariant`, `FailureMode`, `Tradeoff`, `Checklist`, `LearningObjectives`, `KeyQuestion`
|
|
9
|
+
- Learning loop and provenance: `WorkedExample` + `Step`, `Quiz`, `KeyTakeaways`, `Source`, `Confidence`, `LastReviewed`, `Term`
|
|
10
|
+
- Information models: `Flow`, `Timeline`, `Compare`, `DecisionMatrix`, `FrameworkModel`, `MatrixModel`, `FormulaModel`, `PyramidModel`, `FunnelModel`
|
|
11
|
+
- Data and behaviour: `DataTable`, `Metric`, `PropertyList`, `TreeView`, `StateMachine`, `DecisionTree`, `FeedbackLoop`, `CodeDiff`
|
|
12
|
+
- Reading and layout: `Insight`, `Callout`, `Details`, `Quote`, `NoteGrid`, `Tabs`, `Columns`, `Stack`, `Grid`, `Split`, `ScrollGrid`, `ScrollPair`, `ScrollToc`
|
|
13
|
+
- Graphics and extensions: `Mermaid`, `RelationMap`, `RelationPath`, `Math`, `MathBlock`, `Chart`, `CodeTabs`, `AnnotatedCode`, `Figure` (alias `Image`), `FigureRef`, `Cite`, `References`
|
|
14
|
+
|
|
15
|
+
## Props and usage
|
|
16
|
+
|
|
17
|
+
- **CodeBlock**: a general code block usable anywhere; `Implementation` is the node-bound variant. Pass the code as a string via `code` (or as children) wrapped in a template literal so MDX does not read it as expressions: `<CodeBlock language="bash" title="..." lineNumbers>{`npm run validate`}</CodeBlock>`. `language` adds the badge, `title`/`caption` add labels, `lineNumbers` and `wrap` are booleans.
|
|
18
|
+
- **Chart**: `type` is `bar` | `line` | `pie`; use `data` for bar/pie and `labels` + `series={[{name, values}]}` for line. Charts follow theme colors.
|
|
19
|
+
- **Learning loop**: `WorkedExample` holds `Step` children; give each step a `reason` (the justification) so it teaches reasoning, not just the result. `Quiz question answer` reveals the answer on click with children as the explanation. `KeyTakeaways items={[...]}` closes a section.
|
|
20
|
+
- **Provenance**: `Source kind="spec|rfc|implementation|experiment|experience|reference" label href` marks one claim's origin inline (`reference` is the default); `Confidence level="high|medium|low" basis` wraps a claim with how strongly it is established; `Term name` (or children as the definition) gives an inline hover definition.
|
|
21
|
+
- **Data and behaviour**: `DataTable headers={[...]} rows={[[...]]}` is the neutral table (no comparative stance). `Metric label value unit delta trend note` is one headline number — compose several with `Grid`/`ScrollGrid`. `StateMachine states={[{id,label,terminal}]} transitions={[{from,to,event,guard}]}` expresses cycles and guards. `DecisionTree branches={[{condition,outcome,tone,branches}]}` nests branches. `FeedbackLoop type="reinforcing|balancing" nodes={[{label,description}]}` closes a loop. `CodeDiff before after language` shows a change.
|
|
22
|
+
- **Structure and code extensions**: `Quote author source href` attributes a quotation. `Checklist title items={[{text,status:'pass'|'fail'|'unknown'|'todo',note}]}` is a verification list. `PropertyList title items={[{name,value,note}]}` is a name/value spec ledger. `TreeView title items={[{label,description,children:[…]}]}` nests a hierarchy. `CodeTabs items={[{label,language,code}]} title caption lineNumbers` gives one collapsible listing per variant. `AnnotatedCode code language title notes={[{line,text}]}` numbers a listing and calls out specific lines. `LastReviewed date by note` is a review stamp.
|
|
23
|
+
- **Figure**: a relative `src` (`./assets/diagram.png`) stays a relative link by default; compile with `--inline-assets` to bake every local image in as base64, or set `inline={true}` / `inline={false}` on one figure to override (precedence: per-figure prop > global flag > link). `http(s)` URLs stay links and warn (`ASSET_REMOTE`). Always set `alt`; a missing relative file warns (`ASSET_MISSING`) and shows a placeholder. Readers can click a figure to open it full-screen (zoom, drag, `Esc`) — mention it for diagram-heavy pages.
|
|
24
|
+
- **Figure numbering**: give a figure an `id` and reference it with `<FigureRef id="..." />` to render "图 N". Numbering follows document order (per node in `atlas`, whole document in `scroll`) and reflows automatically, so never hand-write "图 1"; an explicit `label` still wins. A ref with no matching `id` warns (`FIGURE_REF_UNRESOLVED`).
|
|
25
|
+
- **Figure size & cost**: linking keeps the HTML small but requires the output to sit beside the MDX's `assets/` (the CLI warns when `-o` points elsewhere). Inlining is what makes a screenshot-heavy page large (a page with no heavy renderers otherwise lands near 250KB), and an inlined asset over 512KB warns (`ASSET_LARGE`). Decide the trade-off with the user instead of choosing silently.
|
|
26
|
+
- **Cite/References**: `<Cite id="..." />` renders `[n]` from the matching item's position in `<References items={...} />`. In `scroll`, `References` can sit anywhere. In `atlas`, keep the cites and the `References` block in the same node, because node content only renders when that node is open.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Validation diagnostics
|
|
2
|
+
|
|
3
|
+
`validate` and the build print `CODE line:column message`. The message names the offending node or prop; this file is the checklist of codes you may meet.
|
|
4
|
+
|
|
5
|
+
## Errors — fix before building
|
|
6
|
+
|
|
7
|
+
`UNKNOWN_COMPONENT`, `CARRIER_MISSING`, `CARRIER_CONFLICT`, `CARRIER_MODE_MISMATCH`, `NODE_MISSING_ID`, `DUPLICATE_NODE_ID`, `NODE_MISSING_TITLE`, `MISSING_PARENT`, `GRAPH_ROOT_UNRESOLVED`, `REF_MISSING_ID`, `REF_UNRESOLVED`, `RELATION_FROM_UNRESOLVED`, `RELATION_TO_UNRESOLVED`.
|
|
8
|
+
|
|
9
|
+
## Warnings — fix when cheap
|
|
10
|
+
|
|
11
|
+
`NODE_MISSING_SUMMARY`, `NODE_NO_CORE_CONTENT`, `UNKNOWN_LEVEL`, `UNKNOWN_KIND`, `MECHANISM_KIND_UNVERIFIED`, `FAILURE_KIND_UNSTRUCTURED`, `FAILURE_MODE_EMPTY`, `UNKNOWN_RELATION_TYPE`, `RELATION_MISSING_LABEL`, `RELATION_SELF`, `PROP_EXPECTS_ARRAY`, `MATH_CHILDREN_BRACES`, `PROSE_EXPRESSION`, `FRONTMATTER_UNSUPPORTED`, `GRAPH_MISSING_ROOT`, `FIGURE_MISSING_SRC`, `ASSET_MISSING`, `ASSET_REMOTE`, `ASSET_LARGE`, `FIGURE_REF_UNRESOLVED`, `FIGURE_REF_MISSING_ID`, `FIGURE_DUPLICATE_ID`, `REF_SELF`.
|
|
12
|
+
|
|
13
|
+
## Promoted by `--strict`
|
|
14
|
+
|
|
15
|
+
`NO_ROOT_LEVEL`, `MULTIPLE_ROOT_LEVEL`, `MECHANISM_KIND_UNVERIFIED` and `FAILURE_KIND_UNSTRUCTURED` are warnings that `--strict` turns into errors.
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { render as renderPele } from 'pele';
|
|
4
4
|
import katex from 'katex';
|
|
5
|
-
import { ZoomIn } from 'lucide-react';
|
|
5
|
+
import { ZoomIn, X } from 'lucide-react';
|
|
6
6
|
import 'katex/dist/katex.min.css';
|
|
7
7
|
import { registerReferences, subscribeReferences, getReferenceIndex } from '../model/citations.js';
|
|
8
8
|
import { registerFigure, subscribeFigures, getFigureNumber } from '../model/figures.js';
|
|
@@ -1123,7 +1123,7 @@ function ReadingProgress() {
|
|
|
1123
1123
|
);
|
|
1124
1124
|
}
|
|
1125
1125
|
|
|
1126
|
-
export function ScrollToc({ items = [], activeId = null, title = '目录' }) {
|
|
1126
|
+
export function ScrollToc({ items = [], activeId = null, title = '目录', onNavigate }) {
|
|
1127
1127
|
if (items.length < 2) return null;
|
|
1128
1128
|
return (
|
|
1129
1129
|
<nav className="scroll-toc" aria-label="目录">
|
|
@@ -1131,7 +1131,9 @@ export function ScrollToc({ items = [], activeId = null, title = '目录' }) {
|
|
|
1131
1131
|
<ol className="scroll-toc-list">
|
|
1132
1132
|
{items.map(item => (
|
|
1133
1133
|
<li key={item.id} className={item.id === activeId ? 'active' : undefined}>
|
|
1134
|
-
<a href={`#${item.id}`}
|
|
1134
|
+
<a href={`#${item.id}`} onClick={onNavigate}>
|
|
1135
|
+
{item.title}
|
|
1136
|
+
</a>
|
|
1135
1137
|
</li>
|
|
1136
1138
|
))}
|
|
1137
1139
|
</ol>
|
|
@@ -1196,6 +1198,64 @@ export function ScrollDocument({
|
|
|
1196
1198
|
|
|
1197
1199
|
const showToc = toc && items.length >= 2;
|
|
1198
1200
|
|
|
1201
|
+
const [tocOpen, setTocOpen] = React.useState(false);
|
|
1202
|
+
const tocTriggerRef = React.useRef(null);
|
|
1203
|
+
const tocPanelRef = React.useRef(null);
|
|
1204
|
+
const closeTimer = React.useRef(0);
|
|
1205
|
+
|
|
1206
|
+
// The outline is a hover panel, not a button you click: parking the pointer on
|
|
1207
|
+
// the edge tab (or moving into the panel) keeps it open, leaving lets it fall
|
|
1208
|
+
// away. Touch and keyboard still get there through tap, focus and Escape.
|
|
1209
|
+
const cancelClose = React.useCallback(() => {
|
|
1210
|
+
window.clearTimeout(closeTimer.current);
|
|
1211
|
+
}, []);
|
|
1212
|
+
|
|
1213
|
+
const openToc = React.useCallback(() => {
|
|
1214
|
+
cancelClose();
|
|
1215
|
+
setTocOpen(true);
|
|
1216
|
+
}, [cancelClose]);
|
|
1217
|
+
|
|
1218
|
+
const scheduleClose = React.useCallback(() => {
|
|
1219
|
+
cancelClose();
|
|
1220
|
+
closeTimer.current = window.setTimeout(() => setTocOpen(false), 340);
|
|
1221
|
+
}, [cancelClose]);
|
|
1222
|
+
|
|
1223
|
+
const closeToc = React.useCallback(() => {
|
|
1224
|
+
cancelClose();
|
|
1225
|
+
setTocOpen(false);
|
|
1226
|
+
}, [cancelClose]);
|
|
1227
|
+
|
|
1228
|
+
React.useEffect(() => cancelClose, [cancelClose]);
|
|
1229
|
+
|
|
1230
|
+
// The panel stays mounted so it can slide both ways; `inert` keeps the hidden
|
|
1231
|
+
// outline out of the tab order and the accessibility tree.
|
|
1232
|
+
React.useEffect(() => {
|
|
1233
|
+
if (tocPanelRef.current) tocPanelRef.current.inert = !tocOpen;
|
|
1234
|
+
}, [tocOpen]);
|
|
1235
|
+
|
|
1236
|
+
React.useEffect(() => {
|
|
1237
|
+
if (!tocOpen) return undefined;
|
|
1238
|
+
const onKeyDown = event => {
|
|
1239
|
+
if (event.key === 'Escape') {
|
|
1240
|
+
closeToc();
|
|
1241
|
+
tocTriggerRef.current?.focus();
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
// A tap outside the panel dismisses it on touch screens, where there is no
|
|
1245
|
+
// pointerleave to rely on.
|
|
1246
|
+
const onPointerDown = event => {
|
|
1247
|
+
if (tocPanelRef.current?.contains(event.target)) return;
|
|
1248
|
+
if (tocTriggerRef.current?.contains(event.target)) return;
|
|
1249
|
+
closeToc();
|
|
1250
|
+
};
|
|
1251
|
+
window.addEventListener('keydown', onKeyDown);
|
|
1252
|
+
document.addEventListener('pointerdown', onPointerDown);
|
|
1253
|
+
return () => {
|
|
1254
|
+
window.removeEventListener('keydown', onKeyDown);
|
|
1255
|
+
document.removeEventListener('pointerdown', onPointerDown);
|
|
1256
|
+
};
|
|
1257
|
+
}, [tocOpen, closeToc]);
|
|
1258
|
+
|
|
1199
1259
|
return (
|
|
1200
1260
|
<article
|
|
1201
1261
|
className={`continuous-document continuous-spacing-${safeSpacing}${showToc ? ' has-toc' : ''}`}
|
|
@@ -1204,7 +1264,42 @@ export function ScrollDocument({
|
|
|
1204
1264
|
>
|
|
1205
1265
|
{progress && <ReadingProgress />}
|
|
1206
1266
|
<ScrollOutlineContext.Provider value={outline}>
|
|
1207
|
-
{showToc &&
|
|
1267
|
+
{showToc && (
|
|
1268
|
+
<>
|
|
1269
|
+
<button
|
|
1270
|
+
ref={tocTriggerRef}
|
|
1271
|
+
type="button"
|
|
1272
|
+
className="scroll-toc-trigger"
|
|
1273
|
+
aria-expanded={tocOpen}
|
|
1274
|
+
aria-controls="scroll-toc-panel"
|
|
1275
|
+
aria-label="目录"
|
|
1276
|
+
onPointerEnter={openToc}
|
|
1277
|
+
onPointerLeave={scheduleClose}
|
|
1278
|
+
onFocus={openToc}
|
|
1279
|
+
onClick={openToc}
|
|
1280
|
+
>
|
|
1281
|
+
目录
|
|
1282
|
+
</button>
|
|
1283
|
+
<div
|
|
1284
|
+
id="scroll-toc-panel"
|
|
1285
|
+
className={`scroll-toc-panel${tocOpen ? ' is-open' : ''}`}
|
|
1286
|
+
ref={tocPanelRef}
|
|
1287
|
+
aria-hidden={!tocOpen}
|
|
1288
|
+
onPointerEnter={cancelClose}
|
|
1289
|
+
onPointerLeave={scheduleClose}
|
|
1290
|
+
>
|
|
1291
|
+
<button
|
|
1292
|
+
type="button"
|
|
1293
|
+
className="scroll-toc-close"
|
|
1294
|
+
onClick={closeToc}
|
|
1295
|
+
aria-label="关闭目录"
|
|
1296
|
+
>
|
|
1297
|
+
<X size={15} aria-hidden="true" />
|
|
1298
|
+
</button>
|
|
1299
|
+
<ScrollToc items={items} activeId={activeId} onNavigate={closeToc} />
|
|
1300
|
+
</div>
|
|
1301
|
+
</>
|
|
1302
|
+
)}
|
|
1208
1303
|
<div className="continuous-content">{children}</div>
|
|
1209
1304
|
</ScrollOutlineContext.Provider>
|
|
1210
1305
|
</article>
|
|
@@ -1300,15 +1395,18 @@ export function Tabs({ items = [], children }) {
|
|
|
1300
1395
|
Tabs.displayName = 'Tabs';
|
|
1301
1396
|
|
|
1302
1397
|
/**
|
|
1303
|
-
*
|
|
1304
|
-
*
|
|
1305
|
-
*
|
|
1398
|
+
* The drawing inside the full-size reader. A diagram is a vector, so enlarging
|
|
1399
|
+
* it has to change its layout size: a CSS `scale()` on the wrapper only
|
|
1400
|
+
* stretches the layer the browser already rasterised, which is what makes a
|
|
1401
|
+
* chart look like a blurry bitmap while it grows. The SVG therefore carries its
|
|
1402
|
+
* own viewBox size (`--diagram-w`, `--diagram-ratio`) and the reader multiplies
|
|
1403
|
+
* that width by the current zoom; panning still rides a transform, because a
|
|
1404
|
+
* translation never resamples.
|
|
1306
1405
|
*/
|
|
1307
|
-
function
|
|
1406
|
+
function DiagramCanvas({ chart, zoom, onError }) {
|
|
1308
1407
|
const ref = React.useRef(null);
|
|
1309
|
-
const [error, setError] = React.useState('');
|
|
1310
1408
|
|
|
1311
|
-
React.
|
|
1409
|
+
React.useLayoutEffect(() => {
|
|
1312
1410
|
if (!ref.current) return;
|
|
1313
1411
|
const source = chart.trim();
|
|
1314
1412
|
if (!source) return;
|
|
@@ -1319,19 +1417,40 @@ function MermaidZoom({ chart, title, onClose }) {
|
|
|
1319
1417
|
responsive: false
|
|
1320
1418
|
});
|
|
1321
1419
|
ref.current.innerHTML = svg;
|
|
1322
|
-
|
|
1420
|
+
const el = ref.current.querySelector('svg');
|
|
1421
|
+
const box = el?.viewBox?.baseVal;
|
|
1422
|
+
const width = box?.width || Number(el?.getAttribute('width')) || 0;
|
|
1423
|
+
const height = box?.height || Number(el?.getAttribute('height')) || 0;
|
|
1424
|
+
if (el && width > 0 && height > 0) {
|
|
1425
|
+
el.style.setProperty('--diagram-w', `${width}px`);
|
|
1426
|
+
el.style.setProperty('--diagram-ratio', String(width / height));
|
|
1427
|
+
}
|
|
1428
|
+
onError('');
|
|
1323
1429
|
} catch (err) {
|
|
1324
|
-
|
|
1430
|
+
onError(err.message || '图表语法错误');
|
|
1325
1431
|
}
|
|
1326
|
-
}, [chart]);
|
|
1432
|
+
}, [chart, onError]);
|
|
1433
|
+
|
|
1434
|
+
return <div className="mermaid-zoom-canvas" ref={ref} style={{ '--zoom': zoom }} />;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* Enlarged reader for a diagram. It re-renders the chart under a fresh id so
|
|
1439
|
+
* the full-size copy never collides with the inline SVG, then hands the result
|
|
1440
|
+
* to the shared zoom overlay (wheel zoom, drag to pan, Esc to close).
|
|
1441
|
+
*/
|
|
1442
|
+
function MermaidZoom({ chart, title, onClose }) {
|
|
1443
|
+
const [error, setError] = React.useState('');
|
|
1327
1444
|
|
|
1328
1445
|
return (
|
|
1329
|
-
<ZoomOverlay title={title || '关系草图'} caption={title} onClose={onClose}>
|
|
1330
|
-
{
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1446
|
+
<ZoomOverlay title={title || '关系草图'} caption={title} onClose={onClose} vector>
|
|
1447
|
+
{scale =>
|
|
1448
|
+
error ? (
|
|
1449
|
+
<pre className="mermaid-error">{error}</pre>
|
|
1450
|
+
) : (
|
|
1451
|
+
<DiagramCanvas chart={chart} zoom={scale} onError={setError} />
|
|
1452
|
+
)
|
|
1453
|
+
}
|
|
1335
1454
|
</ZoomOverlay>
|
|
1336
1455
|
);
|
|
1337
1456
|
}
|
|
@@ -1866,7 +1985,7 @@ const clampScale = value => Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, +value.toFixed
|
|
|
1866
1985
|
* fixed` would otherwise be contained by them). Supports wheel zoom, drag to
|
|
1867
1986
|
* pan, double-click to toggle 1x/2x, and Escape to close.
|
|
1868
1987
|
*/
|
|
1869
|
-
function ZoomOverlay({ title, caption, label, onClose, children }) {
|
|
1988
|
+
function ZoomOverlay({ title, caption, label, onClose, children, vector = false }) {
|
|
1870
1989
|
const [scale, setScale] = React.useState(1);
|
|
1871
1990
|
const [offset, setOffset] = React.useState({ x: 0, y: 0 });
|
|
1872
1991
|
const [dragging, setDragging] = React.useState(false);
|
|
@@ -1876,6 +1995,9 @@ function ZoomOverlay({ title, caption, label, onClose, children }) {
|
|
|
1876
1995
|
const movedRef = React.useRef(false);
|
|
1877
1996
|
const scaleRef = React.useRef(scale);
|
|
1878
1997
|
scaleRef.current = scale;
|
|
1998
|
+
// A vector target (a rendered diagram) receives the zoom as a number and
|
|
1999
|
+
// resizes itself; only a raster target (an image) is scaled as a layer.
|
|
2000
|
+
const content = typeof children === 'function' ? children(scale) : children;
|
|
1879
2001
|
|
|
1880
2002
|
const zoomBy = React.useCallback(delta => setScale(value => clampScale(value + delta)), []);
|
|
1881
2003
|
const reset = React.useCallback(() => {
|
|
@@ -1985,9 +2107,13 @@ function ZoomOverlay({ title, caption, label, onClose, children }) {
|
|
|
1985
2107
|
>
|
|
1986
2108
|
<div
|
|
1987
2109
|
className="image-zoom-target"
|
|
1988
|
-
style={
|
|
2110
|
+
style={
|
|
2111
|
+
vector
|
|
2112
|
+
? { transform: `translate(${offset.x}px, ${offset.y}px)` }
|
|
2113
|
+
: { transform: `translate(${offset.x}px, ${offset.y}px) scale(${scale})` }
|
|
2114
|
+
}
|
|
1989
2115
|
>
|
|
1990
|
-
{
|
|
2116
|
+
{content}
|
|
1991
2117
|
</div>
|
|
1992
2118
|
</div>
|
|
1993
2119
|
{title && (
|
|
@@ -2024,9 +2150,19 @@ function ZoomOverlay({ title, caption, label, onClose, children }) {
|
|
|
2024
2150
|
|
|
2025
2151
|
function ImageZoom({ src, alt, caption, label, onClose }) {
|
|
2026
2152
|
const title = alt || caption || '图片';
|
|
2153
|
+
const imgRef = React.useRef(null);
|
|
2154
|
+
// An SVG authored without width/height has no intrinsic width, so `width:auto`
|
|
2155
|
+
// inside the shrink-to-fit stage resolves to 0 and the reader opens empty.
|
|
2156
|
+
// Such an image gets the viewer's width instead; a bitmap keeps its own.
|
|
2157
|
+
const sizeSizelessImage = () => {
|
|
2158
|
+
const img = imgRef.current;
|
|
2159
|
+
if (!img || !img.complete || !img.naturalWidth) return;
|
|
2160
|
+
if (img.getBoundingClientRect().width > 0) return;
|
|
2161
|
+
img.style.width = 'min(94vw, 1800px)';
|
|
2162
|
+
};
|
|
2027
2163
|
return (
|
|
2028
2164
|
<ZoomOverlay title={title} caption={caption || alt} label={label} onClose={onClose}>
|
|
2029
|
-
<img src={src} alt={alt || ''} draggable="false" />
|
|
2165
|
+
<img ref={imgRef} src={src} alt={alt || ''} draggable="false" onLoad={sizeSizelessImage} />
|
|
2030
2166
|
</ZoomOverlay>
|
|
2031
2167
|
);
|
|
2032
2168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './MDXComponents.jsx';
|
|
1
|
+
export * from './MDXComponents.jsx';
|
package/template/src/main.jsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
import { App } from './app/App.jsx';
|
|
4
|
-
import * as Components from './components/index.js';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import { App } from './app/App.jsx';
|
|
4
|
+
import * as Components from './components/index.js';
|
|
5
5
|
import UserDocument from '@concept-atlas/content';
|
|
6
|
-
|
|
7
|
-
// Mount MDX application to DOM
|
|
8
|
-
const rootElement = document.getElementById('root') || document.getElementById('app');
|
|
9
|
-
if (rootElement) {
|
|
10
|
-
const root = ReactDOM.createRoot(rootElement);
|
|
11
|
-
root.render(
|
|
12
|
-
<React.StrictMode>
|
|
6
|
+
|
|
7
|
+
// Mount MDX application to DOM
|
|
8
|
+
const rootElement = document.getElementById('root') || document.getElementById('app');
|
|
9
|
+
if (rootElement) {
|
|
10
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
11
|
+
root.render(
|
|
12
|
+
<React.StrictMode>
|
|
13
13
|
<App mdxContent={<UserDocument components={Components} />} />
|
|
14
|
-
</React.StrictMode>
|
|
15
|
-
);
|
|
16
|
-
}
|
|
14
|
+
</React.StrictMode>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -3170,7 +3170,11 @@ html[data-carrier='scroll'] #root {
|
|
|
3170
3170
|
}
|
|
3171
3171
|
|
|
3172
3172
|
.continuous-document {
|
|
3173
|
-
|
|
3173
|
+
/* One centred column. The reading carrier used to be 1120px wide with the
|
|
3174
|
+
prose inset from it, which left the title, headings, text and wide blocks
|
|
3175
|
+
on different axes. Everything now shares this single measure, so a section
|
|
3176
|
+
rule, its heading, its paragraphs and its cards line up. */
|
|
3177
|
+
width: min(880px, 100%);
|
|
3174
3178
|
margin: 0 auto;
|
|
3175
3179
|
--scroll-block-gap: 18px;
|
|
3176
3180
|
--scroll-grid-gap: 16px;
|
|
@@ -3181,7 +3185,6 @@ html[data-carrier='scroll'] #root {
|
|
|
3181
3185
|
.continuous-spacing-airy { --scroll-block-gap: 28px; --scroll-grid-gap: 24px; }
|
|
3182
3186
|
|
|
3183
3187
|
.continuous-header {
|
|
3184
|
-
max-width: 820px;
|
|
3185
3188
|
margin: 0 0 56px;
|
|
3186
3189
|
padding: 0 0 24px;
|
|
3187
3190
|
border-bottom: 2px solid var(--primary);
|
|
@@ -3207,7 +3210,6 @@ html[data-carrier='scroll'] #root {
|
|
|
3207
3210
|
}
|
|
3208
3211
|
|
|
3209
3212
|
.continuous-header > div {
|
|
3210
|
-
max-width: 72ch;
|
|
3211
3213
|
color: var(--text-secondary);
|
|
3212
3214
|
font-size: 16px;
|
|
3213
3215
|
line-height: 1.7;
|
|
@@ -3238,8 +3240,7 @@ html[data-carrier='scroll'] #root {
|
|
|
3238
3240
|
}
|
|
3239
3241
|
|
|
3240
3242
|
.continuous-prose {
|
|
3241
|
-
|
|
3242
|
-
margin-bottom: 18px;
|
|
3243
|
+
margin: 0 0 18px;
|
|
3243
3244
|
color: var(--text-secondary);
|
|
3244
3245
|
font-size: 14px;
|
|
3245
3246
|
line-height: 1.72;
|
|
@@ -3475,7 +3476,6 @@ html[data-carrier='scroll'] #root {
|
|
|
3475
3476
|
|
|
3476
3477
|
/* Later rules intentionally override the fixed sizes above. */
|
|
3477
3478
|
.continuous-prose {
|
|
3478
|
-
max-width: 72ch;
|
|
3479
3479
|
font-size: calc(var(--reading-base) * var(--reading-scale));
|
|
3480
3480
|
line-height: var(--reading-line-height);
|
|
3481
3481
|
}
|
|
@@ -3536,38 +3536,121 @@ html[data-carrier='scroll'] #root {
|
|
|
3536
3536
|
transition: transform 80ms linear;
|
|
3537
3537
|
}
|
|
3538
3538
|
|
|
3539
|
-
/* ---- Table of contents (
|
|
3539
|
+
/* ---- Table of contents (hover panel) ----
|
|
3540
|
+
|
|
3541
|
+
The reading column stays centred at every width, so the outline no longer
|
|
3542
|
+
occupies a gutter. It lives in a slim tab pinned to the left edge: hovering
|
|
3543
|
+
(or focusing, or tapping) the tab slides the full outline out, and leaving
|
|
3544
|
+
both the tab and the panel lets it fall away. No permanent chrome, no scrim
|
|
3545
|
+
competing with the page. */
|
|
3540
3546
|
|
|
3541
3547
|
.continuous-content {
|
|
3542
3548
|
min-width: 0;
|
|
3543
3549
|
}
|
|
3544
3550
|
|
|
3545
|
-
.scroll-toc {
|
|
3546
|
-
|
|
3551
|
+
.scroll-toc-trigger {
|
|
3552
|
+
position: fixed;
|
|
3553
|
+
top: 50%;
|
|
3554
|
+
left: 0;
|
|
3555
|
+
z-index: 69;
|
|
3556
|
+
display: grid;
|
|
3557
|
+
width: 20px;
|
|
3558
|
+
height: 76px;
|
|
3559
|
+
margin-top: -38px;
|
|
3560
|
+
padding: 0;
|
|
3561
|
+
place-items: center;
|
|
3562
|
+
border: 1px solid var(--border-medium);
|
|
3563
|
+
border-left: 0;
|
|
3564
|
+
border-radius: 0 var(--radius-2) var(--radius-2) 0;
|
|
3565
|
+
background: var(--bg-surface);
|
|
3566
|
+
color: var(--text-muted);
|
|
3567
|
+
box-shadow: var(--shadow-card);
|
|
3568
|
+
font-family: var(--font-sans);
|
|
3569
|
+
font-size: 11px;
|
|
3570
|
+
font-weight: 600;
|
|
3571
|
+
letter-spacing: 0.24em;
|
|
3572
|
+
writing-mode: vertical-rl;
|
|
3573
|
+
opacity: 0.5;
|
|
3574
|
+
transition:
|
|
3575
|
+
opacity var(--motion-base) var(--ease-standard),
|
|
3576
|
+
color var(--motion-base) var(--ease-standard),
|
|
3577
|
+
transform 240ms var(--ease-out);
|
|
3547
3578
|
}
|
|
3548
3579
|
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
}
|
|
3580
|
+
/* The tab is 20px wide; the hover/focus target around it is not. */
|
|
3581
|
+
.scroll-toc-trigger::before {
|
|
3582
|
+
content: '';
|
|
3583
|
+
position: absolute;
|
|
3584
|
+
inset: -30px -12px -30px -2px;
|
|
3585
|
+
}
|
|
3556
3586
|
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
padding-right: 6px;
|
|
3566
|
-
}
|
|
3587
|
+
.scroll-toc-trigger:hover,
|
|
3588
|
+
.scroll-toc-trigger:focus-visible,
|
|
3589
|
+
.scroll-toc-trigger[aria-expanded='true'] {
|
|
3590
|
+
opacity: 1;
|
|
3591
|
+
color: var(--text-accent);
|
|
3592
|
+
border-color: var(--border-strong);
|
|
3593
|
+
transform: translateX(2px);
|
|
3594
|
+
}
|
|
3567
3595
|
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3596
|
+
.scroll-toc-panel {
|
|
3597
|
+
position: fixed;
|
|
3598
|
+
top: 0;
|
|
3599
|
+
bottom: 0;
|
|
3600
|
+
left: 0;
|
|
3601
|
+
z-index: 71;
|
|
3602
|
+
/* Keep the panel inside the page margin whenever there is one, so opening it
|
|
3603
|
+
never cuts into the reading column. */
|
|
3604
|
+
width: min(320px, max(240px, calc((100vw - 880px) / 2)));
|
|
3605
|
+
padding: 20px 20px 32px;
|
|
3606
|
+
overflow-y: auto;
|
|
3607
|
+
overscroll-behavior: contain;
|
|
3608
|
+
border-right: 1px solid var(--border-medium);
|
|
3609
|
+
background: var(--bg-surface);
|
|
3610
|
+
box-shadow: var(--shadow-card);
|
|
3611
|
+
/* Stays mounted in both directions so the outline slides out and back in
|
|
3612
|
+
instead of snapping: ease-out travel on the way in, a slower symmetric
|
|
3613
|
+
ease on the way out, and visibility held until the exit finishes. */
|
|
3614
|
+
visibility: hidden;
|
|
3615
|
+
opacity: 0;
|
|
3616
|
+
transform: translateX(-100%);
|
|
3617
|
+
transition:
|
|
3618
|
+
transform 460ms var(--ease-standard),
|
|
3619
|
+
opacity 320ms var(--ease-standard),
|
|
3620
|
+
visibility 0s linear 460ms;
|
|
3621
|
+
will-change: transform;
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
.scroll-toc-panel.is-open {
|
|
3625
|
+
visibility: visible;
|
|
3626
|
+
opacity: 1;
|
|
3627
|
+
transform: translateX(0);
|
|
3628
|
+
transition:
|
|
3629
|
+
transform 300ms var(--ease-out),
|
|
3630
|
+
opacity 180ms var(--ease-standard),
|
|
3631
|
+
visibility 0s;
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
.scroll-toc-panel:focus { outline: none; }
|
|
3635
|
+
|
|
3636
|
+
.scroll-toc-close {
|
|
3637
|
+
position: absolute;
|
|
3638
|
+
top: 14px;
|
|
3639
|
+
right: 14px;
|
|
3640
|
+
display: grid;
|
|
3641
|
+
width: 26px;
|
|
3642
|
+
height: 26px;
|
|
3643
|
+
place-items: center;
|
|
3644
|
+
border: 1px solid transparent;
|
|
3645
|
+
border-radius: var(--radius-2);
|
|
3646
|
+
background: transparent;
|
|
3647
|
+
color: var(--text-muted);
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
.scroll-toc-close:hover {
|
|
3651
|
+
border-color: var(--border-subtle);
|
|
3652
|
+
background: var(--bg-card);
|
|
3653
|
+
color: var(--text-primary);
|
|
3571
3654
|
}
|
|
3572
3655
|
|
|
3573
3656
|
.scroll-toc-title {
|
|
@@ -3802,6 +3885,9 @@ html[data-carrier='scroll'] #root {
|
|
|
3802
3885
|
display: grid;
|
|
3803
3886
|
place-items: center;
|
|
3804
3887
|
padding: 28px;
|
|
3888
|
+
/* How much of the viewport a full-size diagram may fill; the reader's fit
|
|
3889
|
+
math and the small-screen override both read it. */
|
|
3890
|
+
--zoom-fit-h: 84vh;
|
|
3805
3891
|
background: var(--overlay-scrim);
|
|
3806
3892
|
/* Clip at the viewport, not at the media box: the zoom transform does not
|
|
3807
3893
|
change layout size, so a stage-sized clip would only ever reveal what the
|
|
@@ -3845,12 +3931,19 @@ html[data-carrier='scroll'] #root {
|
|
|
3845
3931
|
.image-zoom-stage.is-dragging .image-zoom-target { transition: none; }
|
|
3846
3932
|
|
|
3847
3933
|
/* A diagram keeps its natural aspect inside the viewer and paints on the
|
|
3848
|
-
diagram canvas tone, so labels stay legible over the dark scrim.
|
|
3934
|
+
diagram canvas tone, so labels stay legible over the dark scrim. It is a
|
|
3935
|
+
vector: the reader multiplies its layout width by `--zoom` (a number handed
|
|
3936
|
+
down by ZoomOverlay) instead of scaling a rasterised layer, so every step of
|
|
3937
|
+
the zoom re-renders sharp. `--diagram-w` / `--diagram-ratio` come from the
|
|
3938
|
+
SVG's own viewBox: the fit fills the viewport, never past twice the natural
|
|
3939
|
+
width, and a tall chart is bounded by the height instead — so opening a
|
|
3940
|
+
narrow chart no longer paints a wide empty slab. */
|
|
3849
3941
|
.mermaid-zoom-canvas svg {
|
|
3850
3942
|
display: block;
|
|
3851
|
-
width: min(94vw, 1800px);
|
|
3943
|
+
width: calc(min(94vw, calc(var(--diagram-w, 1800px) * 2), calc(var(--zoom-fit-h, 84vh) * var(--diagram-ratio, 1.78))) * var(--zoom, 1));
|
|
3852
3944
|
height: auto;
|
|
3853
|
-
max-
|
|
3945
|
+
max-width: none;
|
|
3946
|
+
max-height: none;
|
|
3854
3947
|
border-radius: var(--radius-3);
|
|
3855
3948
|
background: var(--pele-bg);
|
|
3856
3949
|
box-shadow: var(--shadow-modal);
|
|
@@ -3917,9 +4010,8 @@ html[data-carrier='scroll'] #root {
|
|
|
3917
4010
|
}
|
|
3918
4011
|
|
|
3919
4012
|
@media (max-width: 760px) {
|
|
3920
|
-
.image-zoom-overlay { padding: 12px; }
|
|
4013
|
+
.image-zoom-overlay { padding: 12px; --zoom-fit-h: 74vh; }
|
|
3921
4014
|
.image-zoom-stage img { max-height: 74vh; }
|
|
3922
|
-
.mermaid-zoom-canvas svg { max-height: 74vh; }
|
|
3923
4015
|
.image-zoom-caption { top: 10px; font-size: 12px; }
|
|
3924
4016
|
}
|
|
3925
4017
|
|