@aglyn/plugins-mui 1.0.0-beta.144 → 1.0.0-beta.146
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-mui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.146",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-ui-theme": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-util-vendor": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.146",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.0.0-beta.146",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.146",
|
|
31
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.146",
|
|
32
|
+
"@aglyn/shared-ui-theme": "1.0.0-beta.146",
|
|
33
|
+
"@aglyn/shared-util-vendor": "1.0.0-beta.146",
|
|
34
34
|
"@swc/helpers": "0.5.23",
|
|
35
35
|
"mobx": "^6.16.1",
|
|
36
36
|
"mobx-react-lite": "^4.1.1"
|
|
@@ -48,9 +48,23 @@ export const TABLE_OF_CONTENTS_ID = 'tableOfContents';
|
|
|
48
48
|
* different from one built by hand next to it — which is how the legal pages
|
|
49
49
|
* ended up hand-assembled from hundreds of Typography nodes in the first
|
|
50
50
|
* place.
|
|
51
|
+
*
|
|
52
|
+
* ⚑ `inherit`, not `text.primary` (AGL-3210). The colour is still
|
|
53
|
+
* `text.primary` — {@link BODY_COLOUR_SX} puts it on the element's own root,
|
|
54
|
+
* where an authored `color` can replace it. Repeating the token on every
|
|
55
|
+
* block instead made the author's colour unreachable: it landed on the root
|
|
56
|
+
* and every child overrode it, so a card with a fixed light background kept
|
|
57
|
+
* dark mode's near-white body text and read as blank.
|
|
51
58
|
*/ const BODY_SX = {
|
|
52
59
|
fontSize: 17,
|
|
53
60
|
lineHeight: 1.75,
|
|
61
|
+
color: 'inherit'
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The element's own colour, applied to its root BEFORE the authored `sx`
|
|
65
|
+
* (AGL-3210), so it is a default the Styles panel can replace rather than a
|
|
66
|
+
* floor every block re-asserts. Inside the element everything inherits it.
|
|
67
|
+
*/ const BODY_COLOUR_SX = {
|
|
54
68
|
color: 'text.primary'
|
|
55
69
|
};
|
|
56
70
|
/**
|
|
@@ -220,9 +234,14 @@ export const TABLE_OF_CONTENTS_ID = 'tableOfContents';
|
|
|
220
234
|
}));
|
|
221
235
|
}
|
|
222
236
|
return /*#__PURE__*/ _jsx(Box, _extends({
|
|
223
|
-
ref: ref
|
|
224
|
-
sx: sx
|
|
237
|
+
ref: ref
|
|
225
238
|
}, rest, {
|
|
239
|
+
sx: [
|
|
240
|
+
BODY_COLOUR_SX,
|
|
241
|
+
...Array.isArray(sx) ? sx : sx ? [
|
|
242
|
+
sx
|
|
243
|
+
] : []
|
|
244
|
+
],
|
|
226
245
|
children: blocks.map((block, index)=>{
|
|
227
246
|
if (block.type === 'heading') {
|
|
228
247
|
return /*#__PURE__*/ _jsx(Typography, {
|
|
@@ -233,7 +252,9 @@ export const TABLE_OF_CONTENTS_ID = 'tableOfContents';
|
|
|
233
252
|
id: slugs[index],
|
|
234
253
|
component: block.level === 2 ? 'h2' : 'h3',
|
|
235
254
|
sx: _extends({}, HEADING_SX[block.level], {
|
|
236
|
-
|
|
255
|
+
// See BODY_SX: the token lives on the root, not on every
|
|
256
|
+
// block, so an authored colour reaches the words (AGL-3210).
|
|
257
|
+
color: 'inherit',
|
|
237
258
|
scrollMarginTop: `${ANCHOR_SCROLL_MARGIN}px`,
|
|
238
259
|
mt: block.level === 2 ? 5 : 3.5,
|
|
239
260
|
mb: 1.5,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/markdown.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { mdiLanguageMarkdown, mdiTableOfContents } from '@aglyn/shared-data-mdi'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport {\n scrollOverflowFadeKeyframes,\n scrollOverflowFadeTimeline,\n scrollRegionProps,\n scrollableTableSx,\n scrollableTableWrapperSx,\n} from '@aglyn/shared-ui-jsx/utils/scroll-overflow'\nimport Box, { type BoxProps } from '@mui/material/Box'\nimport MuiLink from '@mui/material/Link'\nimport type { Theme } from '@mui/material/styles'\nimport Typography from '@mui/material/Typography'\nimport { observer } from 'mobx-react-lite'\nimport type { MouseEvent, ReactNode } from 'react'\nimport { forwardRef, useContext, useMemo } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { dropClearedProps } from '../utils/drop-cleared-props'\nimport { generatePresetId } from '../utils/generate-preset-id'\n\n// Component ids are persisted in screen documents; never rename.\nexport const MARKDOWN_ID: Aglyn.ComponentId = 'markdown'\n/** A compose-time token the tenant has not substituted — never a document. */\nconst UNRESOLVED_TOKEN = /^\\{\\{[^}]+\\}\\}$/\n/**\n * What a screen reader announces on reaching a table's scroll box.\n *\n * The plain word, not the table's own heading: the name has to come from\n * something every document has, and a markdown table carries no caption.\n */\nconst TABLE_REGION_LABEL = 'Table'\nexport const TABLE_OF_CONTENTS_ID: Aglyn.ComponentId = 'tableOfContents'\n\n/**\n * A long document's body type, which is NOT MUI's `body1` (AGL-1162).\n *\n * A privacy policy is read, not skimmed: the house measure for running prose\n * is 17px on a 1.75 leading, in `text.primary` rather than the softened\n * secondary a caption uses. MUI's default 16/1.5 sets the same words tighter\n * and lighter, and a page built from Typography defaults reads visibly\n * different from one built by hand next to it — which is how the legal pages\n * ended up hand-assembled from hundreds of Typography nodes in the first\n * place.\n */\nconst BODY_SX = {\n fontSize: 17,\n lineHeight: 1.75,\n color: 'text.primary',\n} as const\n\n/**\n * Heading ramp (AGL-1162). Sizes step across `{xs, sm, md}` and the tracking\n * steps WITH them: tracking is a function of size, so a single letterSpacing\n * that looks right at the desktop size is visibly loose on a phone. Negative\n * throughout — display sizes need the letters pulled together, which is the\n * opposite of the positive tracking small uppercase labels take.\n */\nconst HEADING_SX = {\n 2: {\n fontSize: { xs: 26, sm: 30, md: 34 },\n letterSpacing: { xs: '-0.3px', sm: '-0.4px', md: '-0.5px' },\n lineHeight: 1.25,\n fontWeight: 700,\n },\n 3: {\n fontSize: { xs: 19, sm: 20, md: 22 },\n letterSpacing: { xs: '-0.1px', sm: '-0.15px', md: '-0.2px' },\n lineHeight: 1.35,\n fontWeight: 700,\n },\n} as const\n\n/**\n * Breathing room a heading keeps above it when an anchor lands on it. Sites\n * built here usually have a sticky app bar, and without this the browser\n * scrolls the heading to y=0 — underneath the bar — so a working link looks\n * like a broken one.\n */\nconst ANCHOR_SCROLL_MARGIN = Aglyn.HEADING_ANCHOR_SCROLL_MARGIN\n\n/**\n * Inline runs as elements (AGL-1162), following the entry-body renderer:\n * internal links route through AppLink for client-side navigation, external\n * ones stay plain anchors, and editing surfaces render the link look without\n * an href so clicking never leaves the canvas.\n *\n * Which of those a link is — and whether it is a link at all — is\n * `resolveMarkdownLink`'s to say (AGL-3118), so a target named by reference\n * resolves through the same routing map an element link does, and one whose\n * target is gone renders as its words rather than as `href=\"entry:…\"`.\n */\nconst renderInlines = (\n inlines: Aglyn.MarkdownInline[],\n links: { suppressNavigation?: boolean; screens?: Aglyn.ScreenRouteMap },\n): ReactNode[] =>\n inlines.map((inline, index) => {\n if (inline.type === 'bold') return <strong key={index}>{inline.text}</strong>\n if (inline.type === 'italic') return <em key={index}>{inline.text}</em>\n if (inline.type === 'link') {\n const link = Aglyn.resolveMarkdownLink(inline.href, links)\n if (link.kind === 'text') return <span key={index}>{inline.text}</span>\n if (link.kind === 'inert') {\n return (\n <MuiLink key={index} component=\"span\" sx={{ cursor: 'default' }}>\n {inline.text}\n </MuiLink>\n )\n }\n return link.kind === 'internal' ? (\n <AppLink key={index} href={link.href}>\n {inline.text}\n </AppLink>\n ) : (\n <MuiLink key={index} href={link.href}>\n {inline.text}\n </MuiLink>\n )\n }\n return <span key={index}>{inline.text}</span>\n })\n\nexport interface MarkdownProps extends BoxProps {\n /** The document, as markdown-lite source. */\n content?: string\n /**\n * The pixel pair of each library image this document names, keyed by the\n * target as the document writes it, stamped by the composition from the\n * assets' DAM records (AGL-3149) — never set by hand.\n *\n * An image with no entry here renders exactly as it did before this prop\n * existed: see `mediaBodyImageAttributes` for why a partial answer is worse\n * than none.\n */\n intrinsicSizes?: Record<string, { width: number; height: number }>\n}\n\n/**\n * A whole document authored as markdown (AGL-1162).\n *\n * The elements that made a legal or policy page before this were hundreds of\n * Typography nodes, one per paragraph — which meant the page could not be\n * pasted from, or back into, the markdown file in Drive that is its actual\n * source. Here the source IS the element's content, so updating the page is\n * one paste.\n *\n * Rendered through the shared markdown-lite parser, which emits plain data\n * blocks and never an HTML string — so there is no `dangerouslySetInnerHTML`\n * anywhere on this path and nothing to sanitize. Parsing is pure, so the full\n * document server-renders and the text is in the crawled HTML.\n *\n * Child NODES are never rendered, in either branch (AGL-1388). The document\n * is the `content` prop; there is no position in a parsed block list that a\n * dropped element could occupy, so the schema turns dropping off and\n * `nodeAcceptsChildren` now honors that — a drop lands as a sibling instead.\n * `children` is destructured away rather than left in `rest` because the\n * empty-content branch spreads `rest` onto a childless Box: without this, a\n * Markdown element rendered exactly the child nodes it had swallowed a\n * moment earlier as soon as its content was cleared.\n */\nconst Markdown = forwardRef<HTMLDivElement, MarkdownProps>((props, ref) => {\n const { content, intrinsicSizes, sx, children: _children, ...rest } = props\n // The routing map travels with the suppression flag: both decide what a\n // link in this document renders as (AGL-3118).\n const { suppressNavigation, screens } = useContext(Aglyn.ScreenLinkContext)\n const links = useMemo(\n () => ({ suppressNavigation, screens }),\n [suppressNavigation, screens],\n )\n /**\n * The site being rendered, for image blocks (AGL-1686). Read once here\n * rather than per block: hooks cannot run inside the `blocks.map` below,\n * and a document may hold any number of images.\n */\n const { hostId } = Aglyn.useSite()\n const source = (content ?? '').trim()\n const blocks = useMemo(\n () => (source ? Aglyn.parseMarkdownLite(source) : []),\n [source],\n )\n // Slugs are derived rather than stored (see collectMarkdownHeadings), and\n // keyed by block index so the ids land on the right headings even when two\n // of them carry the same words. The map is built in `markdown-lite` now,\n // because every renderer needs exactly this and five of the six were not\n // getting it (AGL-1162).\n const slugs = useMemo(() => Aglyn.markdownHeadingSlugs(blocks), [blocks])\n\n if (!source) {\n // Editing surfaces get somewhere to click; the published page renders\n // nothing rather than a placeholder nobody meant to publish.\n if (!suppressNavigation) return <Box ref={ref} sx={sx} {...rest} />\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n p: 2,\n border: '1px dashed',\n borderColor: 'divider',\n color: 'text.secondary',\n fontSize: 12,\n },\n ...(Array.isArray(sx) ? sx : sx ? [sx] : []),\n ]}\n >\n {'Markdown — paste the document into the Content attribute'}\n </Box>\n )\n }\n\n return (\n <Box ref={ref} sx={sx} {...rest}>\n {blocks.map((block, index) => {\n if (block.type === 'heading') {\n return (\n <Typography\n key={index}\n // The anchor a table of contents links to. `component` is set\n // explicitly because a Typography with only an `sx` fontSize\n // still renders a <p>: the page would screenshot correctly and\n // have no headings in it at all.\n id={slugs[index]}\n component={block.level === 2 ? 'h2' : 'h3'}\n sx={{\n ...HEADING_SX[block.level],\n color: 'text.primary',\n scrollMarginTop: `${ANCHOR_SCROLL_MARGIN}px`,\n mt: block.level === 2 ? 5 : 3.5,\n mb: 1.5,\n '&:first-of-type': { mt: 0 },\n }}\n >\n {renderInlines(block.inlines, links)}\n </Typography>\n )\n }\n if (block.type === 'image') {\n return (\n <Box\n key={index}\n component=\"img\"\n // Resolved, exactly as `image.tsx` resolves its `src` prop\n // (AGL-1686). A document records WHICH ASSET; turning that into\n // a URL is the renderer's business, so the `/api/media/cdn/…`\n // route shape never has to be baked into a published document.\n // Every other value — a legacy storage URL, a legacy CDN path,\n // an author-typed hotlink — passes through untouched.\n //\n // The resolve now comes back with the WebP candidate list and\n // the intrinsic pair beside it, when the composition could read\n // the asset's record (AGL-3149). Shared with the entry body and\n // with `image.tsx`'s own srcSet so a body image cannot drift\n // away from the element again.\n {...Aglyn.mediaBodyImageAttributes({\n src: block.src,\n hostId,\n size: intrinsicSizes?.[block.src],\n })}\n alt={block.alt}\n // `height: 'auto'` is load-bearing beside the pair above, not\n // tidiness: the pair's `height` arrives as a presentational hint\n // too, and a hint that survives the `maxWidth` cap squashes the\n // picture instead of scaling it. It is what `auto` already\n // resolved to before the pair existed, so this changes nothing\n // for an image the composition could not measure.\n sx={{ maxWidth: '100%', height: 'auto', borderRadius: 1, my: 2 }}\n // `lazy` alone until AGL-2486. A markdown image is by\n // definition inside prose the reader scrolls through, so it\n // belongs in the same deferred rank as everything else that is\n // not the lead image.\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n )\n }\n if (block.type === 'list') {\n return (\n <Box\n key={index}\n component=\"ul\"\n sx={{ ...BODY_SX, my: 2, pl: 3, '& li': { mb: 1 } }}\n >\n {block.items.map((item, itemIndex) => (\n <li key={itemIndex}>\n {renderInlines(item, links)}\n </li>\n ))}\n </Box>\n )\n }\n // A numbered list (AGL-1320): the same measure as the bullet list,\n // as a real `<ol>` carrying `start` — a legal document's enumerated\n // elements are the reason this block exists.\n if (block.type === 'orderedList') {\n return (\n <Box\n key={index}\n component=\"ol\"\n start={block.start}\n sx={{ ...BODY_SX, my: 2, pl: 3, '& li': { mb: 1 } }}\n >\n {block.items.map((item, itemIndex) => (\n <li key={itemIndex}>\n {renderInlines(item, links)}\n </li>\n ))}\n </Box>\n )\n }\n // Code and tables scroll rather than wrap, like every other\n // markdown-lite renderer here (AGL-974): a wrapped command line\n // reads as two commands, and a squeezed table column loses the\n // structure that made it a table.\n if (block.type === 'code') {\n return (\n <Box\n key={index}\n component=\"pre\"\n sx={{\n my: 2,\n p: 2,\n overflowX: 'auto',\n borderRadius: 1,\n bgcolor: 'action.hover',\n fontFamily: 'monospace',\n fontSize: 14,\n }}\n >\n <code>{block.text}</code>\n </Box>\n )\n }\n if (block.type === 'table') {\n return (\n <Box\n key={index}\n {...scrollRegionProps(TABLE_REGION_LABEL)}\n sx={{ my: 2, ...scrollableTableWrapperSx }}\n >\n <Box\n component=\"table\"\n sx={{\n ...BODY_SX,\n fontSize: 16,\n borderCollapse: 'collapse',\n ...scrollableTableSx,\n '& th, & td': {\n border: '1px solid',\n borderColor: 'divider',\n px: 1.5,\n py: 1,\n },\n '& th': { bgcolor: 'action.hover', fontWeight: 600 },\n }}\n >\n <thead>\n <tr>\n {block.header.map((cell, cellIndex) => (\n <th\n key={cellIndex}\n style={{ textAlign: block.align[cellIndex] ?? 'left' }}\n >\n {renderInlines(cell, links)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {block.rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <td\n key={cellIndex}\n style={{\n textAlign: block.align[cellIndex] ?? 'left',\n }}\n >\n {renderInlines(cell, links)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </Box>\n </Box>\n )\n }\n // A pull-quote (AGL-1315): the document's body measure, one size up\n // and italic, behind a left accent — palette tokens keep it right in\n // both modes.\n if (block.type === 'quote') {\n return (\n <Typography\n key={index}\n component=\"blockquote\"\n sx={{\n ...BODY_SX,\n my: 3,\n mx: 0,\n pl: 2.5,\n borderLeft: '3px solid',\n borderColor: 'primary.main',\n fontStyle: 'italic',\n fontSize: 21,\n lineHeight: 1.6,\n }}\n >\n {renderInlines(block.inlines, links)}\n </Typography>\n )\n }\n return (\n <Typography key={index} component=\"p\" sx={{ ...BODY_SX, my: 2 }}>\n {renderInlines(block.inlines, links)}\n </Typography>\n )\n })}\n </Box>\n )\n})\nMarkdown.displayName = 'AglynMarkdown'\n\n/* ── Table of contents ──────────────────────────────────────────────────── */\n\nexport interface TableOfContentsProps extends BoxProps {\n /**\n * The Markdown element this lists the headings of. Empty means \"the first\n * Markdown element on the screen\", which is the answer on every page that\n * has exactly one — see {@link resolveMarkdownSource}.\n */\n forNodeId?: string\n /** Aside heading; an empty string renders no heading at all. */\n heading?: string\n /** Deepest heading level listed: `'2'` for top level only. */\n depth?: '2' | '3'\n}\n\n/**\n * Which Markdown element a table of contents speaks for (AGL-1162).\n *\n * Resolved through the NODE TREE, never the DOM: the besigner canvas renders\n * inside a closed shadow root, so a `document.querySelector` from a component\n * finds nothing there and the aside would be empty in the one place it is\n * being authored.\n *\n * The tree is walked from the root in document order, so \"the first Markdown\n * element\" means the first one a reader meets — not the first key of a node\n * map, whose order is storage detail.\n *\n * An explicit `forNodeId` wins, compared with `leafIdsMatch` because the\n * stored id is the raw canvas id while a composed tree namespaces layout and\n * reusable-component grafts (AGL-573/1229). A pick that no longer resolves —\n * the element was deleted and re-added, which is exactly what re-pasting a\n * document looks like — falls back to the first Markdown element rather than\n * leaving a published page with an empty aside.\n */\nexport function resolveMarkdownSource(\n root: Aglyn.NodeSchema | undefined,\n forNodeId?: string,\n): string {\n const found: Array<{ $id: string; content: string }> = []\n const walk = (node: Aglyn.NodeSchema | undefined): void => {\n if (!node) return\n // Two element types hold a markdown-lite document, and an aside beside a\n // blog article is the case this issue was opened for (AGL-1162): the\n // Collection Entry Body carries the post, under `markdown` rather than\n // `content`, and used to be invisible here — so \"On this page\" on an\n // article template rendered its authoring affordance forever.\n const source =\n node.componentId === MARKDOWN_ID\n ? 'content'\n : node.componentId === Aglyn.COLLECTION_ENTRY_BODY_COMPONENT_ID\n ? 'markdown'\n : undefined\n if (source) {\n const props = (node.resolvedProps ?? node.props ?? {}) as Record<\n string,\n unknown\n >\n const content = String(props[source] ?? '')\n // An entry body on an unresolved surface is the literal\n // `{{entry.body}}` token. It is not a document, and treating it as one\n // would let it win over a real Markdown element further down the page\n // and empty the aside on the canvas.\n if (!UNRESOLVED_TOKEN.test(content.trim())) {\n found.push({ $id: node.$id, content })\n }\n }\n for (const child of node.children ?? []) walk(child)\n }\n walk(root)\n if (forNodeId) {\n const picked = found.find((entry) => Aglyn.leafIdsMatch(entry.$id, forNodeId))\n if (picked) return picked.content\n }\n return found[0]?.content ?? ''\n}\n\n/**\n * Scrolls to a heading in the cases the browser cannot reach, and ONLY those\n * (AGL-1162). Returns whether it handled the click.\n *\n * In `document` it deliberately does nothing and lets the plain `#slug`\n * anchor work: native fragment navigation updates the address bar, adds a\n * history entry the back button understands, and honours the site's CSS\n * `scroll-behavior` — none of which a hand-rolled `scrollIntoView` gives\n * back. It is also the only version that works with JavaScript off.\n *\n * (`behavior: 'smooth'` was the first attempt at the whole job, and it is\n * exactly the wrong shape: a browser that declines to animate — a background\n * tab, reduced-motion — leaves the click prevented and the page unmoved, so\n * a working link reads as a broken one.)\n *\n * The besigner canvas renders inside a CLOSED shadow root, where the heading\n * is not in `document` at all and a fragment navigation finds nothing. There\n * the link's own `getRootNode()` is the shadow root holding both ends, and\n * `ShadowRoot.getElementById` finds the heading.\n */\nexport function scrollToHeading(anchor: Element, slug: string): boolean {\n const root = anchor.getRootNode()\n if (root === anchor.ownerDocument || !(root as ShadowRoot).getElementById) {\n return false\n }\n const target = (root as ShadowRoot).getElementById(slug)\n if (!target) return false\n // No explicit `behavior`: 'auto' follows the scrolling box's CSS\n // `scroll-behavior`, so a site that asked for smooth still gets it.\n target.scrollIntoView({ block: 'start' })\n return true\n}\n\n/**\n * What the sidebar's chrome costs, above and below the list (AGL-2486).\n *\n * The list's bound is `100dvh` MINUS this, so it is a function of the window\n * rather than a height somebody picked. Measured on the live\n * `/legal/marketplace-publisher-agreement` sidebar, which is the shape every\n * legal page uses: the card is `position: sticky; top: 96px` under the app\n * bar, then 24px of card padding and 31px of \"ON THIS PAGE\" label sit above\n * the list and 31px of padding below it — 182px of chrome. 200 leaves the\n * card's bottom BORDER inside the window rather than flush against it, so\n * the card reads as a card and not as a page that ran out.\n *\n * It is an allowance, not a contract: this component renders inside whatever\n * the author built around it, and it cannot read that card's `top` offset.\n * Being a MAX height, an allowance a little too generous only means a few\n * pixels of the card sit below the fold; one a little too tight only means\n * the scroll box starts a line sooner. Both are recoverable, which is the\n * whole reason this is a `max-height` and not a `height`.\n */\nconst TOC_VIEWPORT_ALLOWANCE = '200px'\n\n/**\n * The list is its own scroll box once it outgrows the window (AGL-2486).\n *\n * The bug: nothing here was bounded, and the card the author wraps this in is\n * `position: sticky`. A sticky box taller than the viewport does not scroll\n * into view — it pins at its `top` offset and everything past the window's\n * bottom edge is simply unreachable. Measured on the Marketplace Publisher\n * Agreement (14 `h2`s) in a 1100x480 window: the card stood 502px tall from\n * `top: 96px` and overhung the fold by 118px, entry 11 was cut through the\n * middle of its own text at the window edge, and 12 to 14 could not be\n * reached by any scroll — `ol.scrollTop` stayed 0, because the list was not a\n * scroll box at all. Which row gets cut moves with the window height and the\n * browser zoom; the reported sighting was entry 8. Either way it did not read\n * as \"there is more\", it read as a document with fewer sections than it has.\n *\n * Three things this deliberately is NOT:\n *\n * - NOT a `height`. A `max-height` is inert until the content exceeds it, so\n * the four-item TOCs (`/legal/dmca`, `/legal/subprocessors`) keep their\n * exact present box: no scroll region, no reserved gutter, no dead space.\n * That is also why `overflow-y` is `auto` and never `scroll`.\n *\n * - NOT applied below `md`. The bound only makes sense for a sidebar. In the\n * stacked narrow layout the TOC is a full-width block in the page flow, and\n * bounding it there would plant a scroll trap in the middle of an article\n * to solve a clipping problem that layout does not have.\n *\n * - NOT silent, and the FADE is the part that carries that. A scroll box a\n * reader cannot see is the same bug wearing a scrollbar: measured in Chrome\n * on macOS, `offsetWidth - clientWidth` on this list is 0 even with\n * `scrollbar-color` set — the platform draws an OVERLAY scrollbar, which is\n * invisible until you have already guessed to scroll. So the thumb styling\n * is the secondary cue, for the platforms that draw one at rest, and the\n * primary cue is a bottom fade: the cut stops being a slice through the\n * middle of a word and becomes an edge that visibly continues.\n *\n * The fade rides a scroll-driven animation on purpose: a `scroll()` timeline\n * on a box with nothing to scroll is INACTIVE, so its animation applies no\n * styles at all. That is the only way to say \"fade only when overflowing\" in\n * CSS with no measuring and no JavaScript, and it degrades to plain\n * unfaded-but-scrollable in a browser that lacks it. Verified both ways at\n * 1100x480: the 14-entry list fades and scrolls, the 4-entry\n * `/legal/subprocessors` list computes `mask-image: none` and does not.\n *\n * NO new attribute goes with this, deliberately. The three the element has —\n * `forNodeId`, `heading`, `depth` — all answer \"which headings does this\n * list\", and a \"list height\" field would hand the author back the very\n * decision this bug is made of. The right answer is \"as much of the window as\n * there is\", which is a thing CSS can work out and an author cannot type.\n */\nconst TABLE_OF_CONTENTS_LIST_SX = (theme: Theme) => ({\n listStyle: 'none',\n m: 0,\n p: 0,\n [theme.breakpoints.up('md')]: {\n maxHeight: `calc(100vh - ${TOC_VIEWPORT_ALLOWANCE})`,\n // `dvh` over `vh` where it exists: `vh` is the LARGEST viewport, so a\n // window with a visible toolbar gets a bound taller than the space it\n // has — which is the bug again, in miniature.\n '@supports (height: 100dvh)': {\n maxHeight: `calc(100dvh - ${TOC_VIEWPORT_ALLOWANCE})`,\n },\n overflowY: 'auto',\n // Reaching the end of the list must not then throw the page down a\n // screen — the reader was navigating the sidebar, not the document.\n overscrollBehavior: 'contain',\n scrollbarWidth: 'thin',\n // `text.disabled`, not `divider`: a 12%-black thumb is one you have to\n // already know is there. `3px` is QUOTED because a bare 3 is a theme\n // radius STEP and lands as 12px on a 6px-wide thumb.\n scrollbarColor: `${theme.palette.text.disabled} transparent`,\n '&::-webkit-scrollbar': { width: 6 },\n '&::-webkit-scrollbar-thumb': {\n backgroundColor: theme.palette.text.disabled,\n borderRadius: '3px',\n },\n ...scrollOverflowFadeTimeline('block'),\n },\n ...scrollOverflowFadeKeyframes('block'),\n})\n\n/**\n * \"On this page\" (AGL-1162) — the headings of a Markdown element on the same\n * screen, as working anchor links.\n *\n * A mobx `observer` because it reads ANOTHER node's props: the renderer's\n * Leaf re-renders on changes to the node it is rendering, and nothing else,\n * so without this the aside in the besigner would keep listing the headings\n * of the document as it was when the aside mounted.\n */\nconst TableOfContents = observer(\n forwardRef<HTMLElement, TableOfContentsProps>((props, ref) => {\n const { forNodeId, heading, depth, sx, ...rawRest } = props\n /**\n * The cleared-prop guard, applied to the props that LEAVE this\n * component rather than to all of them (AGL-1451).\n *\n * A props-wide `dropClearedProps` would be wrong here, and this is the\n * component that shows why the wrapper is not a reflex: `heading` reads\n * an EMPTY value as a real author choice — \"clear it to render no\n * label\", which is what its help text promises and what the `heading\n * === undefined ? 'On this page' : heading` line below implements. A\n * guard over the whole props object would strip the cleared heading and\n * put the default label back, i.e. eat the choice the author made. So\n * `heading` and `depth` are read as authored, and the guard covers only\n * what is spread onto the Box.\n */\n const rest = dropClearedProps(rawRest)\n const { suppressNavigation } = useContext(Aglyn.ScreenLinkContext)\n const source = resolveMarkdownSource(Aglyn.canvas.rootNode, forNodeId)\n const entries = useMemo(() => {\n const headings = Aglyn.collectMarkdownHeadings(\n Aglyn.parseMarkdownLite(source),\n )\n return depth === '2'\n ? headings.filter((entry) => entry.level === 2)\n : headings\n }, [source, depth])\n const title = heading === undefined ? 'On this page' : heading\n\n if (!entries.length) {\n // Same split as the Markdown element: an affordance while authoring,\n // nothing at all on the published page — and no empty `nav` landmark.\n if (!suppressNavigation) return <Box ref={ref} sx={sx} {...rest} />\n return (\n <Box\n ref={ref}\n component=\"nav\"\n sx={[\n {\n p: 2,\n border: '1px dashed',\n borderColor: 'divider',\n color: 'text.secondary',\n fontSize: 12,\n },\n ...(Array.isArray(sx) ? sx : sx ? [sx] : []),\n ]}\n {...rest}\n >\n {'Table of contents — add ## headings to the Markdown element'}\n </Box>\n )\n }\n\n return (\n <Box\n ref={ref}\n component=\"nav\"\n aria-label={title || 'Table of contents'}\n sx={sx}\n {...rest}\n >\n {title ? (\n <Typography\n component=\"p\"\n sx={{\n fontSize: 12,\n fontWeight: 700,\n // Positive tracking here, unlike the document headings: this is\n // a small uppercase label, where the letters need pushing apart\n // rather than pulling together.\n letterSpacing: '0.8px',\n textTransform: 'uppercase',\n color: 'text.secondary',\n mb: 1.5,\n }}\n >\n {title}\n </Typography>\n ) : null}\n <Box component=\"ol\" sx={TABLE_OF_CONTENTS_LIST_SX}>\n {entries.map((entry) => (\n <Box component=\"li\" key={entry.slug} sx={{ mb: 0.75 }}>\n <MuiLink\n // A real href, so the entry is a link to a crawler, works\n // with no JavaScript, and can be copied out of the page.\n href={`#${entry.slug}`}\n underline=\"hover\"\n color=\"text.secondary\"\n onClick={(event: MouseEvent<HTMLAnchorElement>) => {\n // Prevented ONLY when this actually moved the page — on a\n // published page it does nothing and the anchor works the\n // way anchors do.\n if (scrollToHeading(event.currentTarget, entry.slug)) {\n event.preventDefault()\n }\n }}\n sx={{\n display: 'block',\n fontSize: 15,\n lineHeight: 1.5,\n // Sub-headings indent; nothing else distinguishes them, so\n // a flat list of both levels reads as one long list.\n pl: entry.level === 3 ? 2 : 0,\n '&:hover': { color: 'text.primary' },\n }}\n >\n {entry.text}\n </MuiLink>\n </Box>\n ))}\n </Box>\n </Box>\n )\n }),\n)\nTableOfContents.displayName = 'AglynTableOfContents'\n\nexport const markdownSchema: Aglyn.ComponentSchema<MarkdownProps> = {\n $id: MARKDOWN_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Markdown',\n description:\n 'A whole document written as markdown. It takes no child elements.',\n category: Aglyn.ComponentCategory.TEXT,\n icon: { path: mdiLanguageMarkdown.path, sx: { color: '#455a64' } },\n flags: {\n // The document is the `content` attribute; dropping elements inside a\n // rendered document would put them somewhere the markdown cannot say.\n dropping: Aglyn.FEATURE_FLAG.DISABLED,\n },\n attributes: [\n {\n name: 'content',\n label: 'Content',\n description:\n 'The document, as markdown. Headings (## and ###), paragraphs, ' +\n 'bold/italic, links, bullet and 1. numbered lists, images, fenced ' +\n 'code, pipe tables and > quotes. Paste the whole source file — a ' +\n 'Table of contents element on the same screen lists the ## and ### ' +\n 'headings automatically.',\n // The WYSIWYG rather than a raw textarea (AGL-1616): this attribute is\n // a whole document — the published Privacy Policy body is one of them —\n // and editing it as raw markdown-lite meant a 13 KB paste (AGL-1594).\n // The stored value is unchanged, so every renderer is untouched.\n component: Aglyn.FieldComponentType.MARKDOWN,\n },\n ],\n}\n\nexport const tableOfContentsSchema: Aglyn.ComponentSchema<TableOfContentsProps> =\n {\n $id: TABLE_OF_CONTENTS_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Table of Contents',\n description:\n \"An on-this-page list linking to a Markdown element's headings.\",\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiTableOfContents.path, sx: { color: '#455a64' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'forNodeId',\n label: 'Markdown element',\n description:\n 'The Markdown element to list the headings of. Leave empty on a ' +\n 'page with one Markdown element — the first one on the screen is ' +\n 'used, and a pick that no longer exists falls back to it too.',\n component: Aglyn.FieldComponentType.NODE_SELECT,\n },\n {\n name: 'heading',\n label: 'Heading',\n description: 'Label above the list. Clear it to render no label.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'depth',\n label: 'Levels',\n description: 'How deep the list goes.',\n component: Aglyn.FieldComponentType.SELECT,\n // `depth` never reaches MUI — it is read here, as `depth === '2'`.\n // So the `''` was not a rendering defect; it was an option that\n // could not survive a save (AGL-1191), which meant an author who\n // set \"## headings only\" and then changed their mind could not put\n // it back. `'3'` states the same thing as a real, persistable\n // value — and is what `TableOfContentsProps.depth` has declared\n // all along, so the option list was the half that had drifted.\n // Both levels remain what an unset field means (AGL-1451).\n options: [\n { value: '3', label: '## and ### headings' },\n { value: '2', label: '## headings only' },\n ],\n },\n ],\n }\n\nexport const markdownPresets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(MARKDOWN_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Markdown',\n pluginId: BUNDLE_ID,\n description: 'A whole document, authored as markdown',\n category: Aglyn.ComponentCategory.TEXT,\n icon: { path: mdiLanguageMarkdown.path, sx: { color: '#455a64' } },\n data: {\n $id: null,\n componentId: MARKDOWN_ID,\n pluginId: BUNDLE_ID,\n props: {\n content:\n '## First section\\n\\nReplace this with your document. Paste ' +\n 'markdown straight from the source file.\\n\\n' +\n '### A sub-section\\n\\nHeadings become anchors, and a Table of ' +\n 'contents element on the same screen links to them.',\n },\n },\n },\n {\n $id: generatePresetId(TABLE_OF_CONTENTS_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Table of Contents',\n pluginId: BUNDLE_ID,\n description: 'On this page — links to a Markdown element’s headings',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiTableOfContents.path, sx: { color: '#455a64' } },\n data: {\n $id: null,\n componentId: TABLE_OF_CONTENTS_ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n },\n]\n\nexport { Markdown, TableOfContents }\nexport default Markdown\n"],"names":["Aglyn","mdiLanguageMarkdown","mdiTableOfContents","AppLink","scrollOverflowFadeKeyframes","scrollOverflowFadeTimeline","scrollRegionProps","scrollableTableSx","scrollableTableWrapperSx","Box","MuiLink","Typography","observer","forwardRef","useContext","useMemo","BUNDLE_ID","dropClearedProps","generatePresetId","MARKDOWN_ID","UNRESOLVED_TOKEN","TABLE_REGION_LABEL","TABLE_OF_CONTENTS_ID","BODY_SX","fontSize","lineHeight","color","HEADING_SX","xs","sm","md","letterSpacing","fontWeight","ANCHOR_SCROLL_MARGIN","HEADING_ANCHOR_SCROLL_MARGIN","renderInlines","inlines","links","map","inline","index","type","strong","text","em","link","resolveMarkdownLink","href","kind","span","component","sx","cursor","Markdown","props","ref","content","intrinsicSizes","children","_children","rest","suppressNavigation","screens","ScreenLinkContext","hostId","useSite","source","trim","blocks","parseMarkdownLite","slugs","markdownHeadingSlugs","p","border","borderColor","Array","isArray","block","id","level","scrollMarginTop","mt","mb","mediaBodyImageAttributes","src","size","alt","maxWidth","height","borderRadius","my","DEFERRED_IMAGE_ATTRIBUTES","pl","items","item","itemIndex","li","start","overflowX","bgcolor","fontFamily","code","borderCollapse","px","py","thead","tr","header","cell","cellIndex","th","style","textAlign","align","tbody","rows","row","rowIndex","td","mx","borderLeft","fontStyle","displayName","resolveMarkdownSource","root","forNodeId","found","walk","node","componentId","COLLECTION_ENTRY_BODY_COMPONENT_ID","undefined","resolvedProps","String","test","push","$id","child","picked","find","entry","leafIdsMatch","scrollToHeading","anchor","slug","getRootNode","ownerDocument","getElementById","target","scrollIntoView","TOC_VIEWPORT_ALLOWANCE","TABLE_OF_CONTENTS_LIST_SX","theme","listStyle","m","breakpoints","up","maxHeight","overflowY","overscrollBehavior","scrollbarWidth","scrollbarColor","palette","disabled","width","backgroundColor","TableOfContents","heading","depth","rawRest","canvas","rootNode","entries","headings","collectMarkdownHeadings","filter","title","length","aria-label","textTransform","underline","onClick","event","currentTarget","preventDefault","display","markdownSchema","pluginId","description","category","ComponentCategory","TEXT","icon","path","flags","dropping","FEATURE_FLAG","DISABLED","attributes","name","label","FieldComponentType","MARKDOWN","tableOfContentsSchema","NAVIGATION","selfClosing","ENABLED","NODE_SELECT","TEXT_FIELD","SELECT","options","value","markdownPresets","NodeType","P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H,OAAO,MAAMY,kBAAwC;IACnD;QACE5E,KAAKtH,iBAAiBC;QACtBsB,MAAMzC,MAAMqN,QAAQ,CAACC,MAAM;QAC3B5F,aAAa;QACbiE,UAAU3K;QACV4K,aAAa;QACbC,UAAU7L,MAAM8L,iBAAiB,CAACC,IAAI;QACtCC,MAAM;YAAEC,MAAMhM,oBAAoBgM,IAAI;YAAE9I,IAAI;gBAAEzB,OAAO;YAAU;QAAE;QACjE6L,MAAM;YACJ/E,KAAK;YACLP,aAAa9G;YACbwK,UAAU3K;YACVsC,OAAO;gBACLE,SACE,gEACA,gDACA,kEACA;YACJ;QACF;IACF;IACA;QACEgF,KAAKtH,iBAAiBI;QACtBmB,MAAMzC,MAAMqN,QAAQ,CAACC,MAAM;QAC3B5F,aAAa;QACbiE,UAAU3K;QACV4K,aAAa;QACbC,UAAU7L,MAAM8L,iBAAiB,CAACc,UAAU;QAC5CZ,MAAM;YAAEC,MAAM/L,mBAAmB+L,IAAI;YAAE9I,IAAI;gBAAEzB,OAAO;YAAU;QAAE;QAChE6L,MAAM;YACJ/E,KAAK;YACLP,aAAa3G;YACbqK,UAAU3K;YACVsC,OAAO,CAAC;QACV;IACF;CACD,CAAA;AAED,SAASD,QAAQ,EAAEiH,eAAe,GAAE;AACpC,eAAejH,SAAQ"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/markdown.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { mdiLanguageMarkdown, mdiTableOfContents } from '@aglyn/shared-data-mdi'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport {\n scrollOverflowFadeKeyframes,\n scrollOverflowFadeTimeline,\n scrollRegionProps,\n scrollableTableSx,\n scrollableTableWrapperSx,\n} from '@aglyn/shared-ui-jsx/utils/scroll-overflow'\nimport Box, { type BoxProps } from '@mui/material/Box'\nimport MuiLink from '@mui/material/Link'\nimport type { Theme } from '@mui/material/styles'\nimport Typography from '@mui/material/Typography'\nimport { observer } from 'mobx-react-lite'\nimport type { MouseEvent, ReactNode } from 'react'\nimport { forwardRef, useContext, useMemo } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { dropClearedProps } from '../utils/drop-cleared-props'\nimport { generatePresetId } from '../utils/generate-preset-id'\n\n// Component ids are persisted in screen documents; never rename.\nexport const MARKDOWN_ID: Aglyn.ComponentId = 'markdown'\n/** A compose-time token the tenant has not substituted — never a document. */\nconst UNRESOLVED_TOKEN = /^\\{\\{[^}]+\\}\\}$/\n/**\n * What a screen reader announces on reaching a table's scroll box.\n *\n * The plain word, not the table's own heading: the name has to come from\n * something every document has, and a markdown table carries no caption.\n */\nconst TABLE_REGION_LABEL = 'Table'\nexport const TABLE_OF_CONTENTS_ID: Aglyn.ComponentId = 'tableOfContents'\n\n/**\n * A long document's body type, which is NOT MUI's `body1` (AGL-1162).\n *\n * A privacy policy is read, not skimmed: the house measure for running prose\n * is 17px on a 1.75 leading, in `text.primary` rather than the softened\n * secondary a caption uses. MUI's default 16/1.5 sets the same words tighter\n * and lighter, and a page built from Typography defaults reads visibly\n * different from one built by hand next to it — which is how the legal pages\n * ended up hand-assembled from hundreds of Typography nodes in the first\n * place.\n *\n * ⚑ `inherit`, not `text.primary` (AGL-3210). The colour is still\n * `text.primary` — {@link BODY_COLOUR_SX} puts it on the element's own root,\n * where an authored `color` can replace it. Repeating the token on every\n * block instead made the author's colour unreachable: it landed on the root\n * and every child overrode it, so a card with a fixed light background kept\n * dark mode's near-white body text and read as blank.\n */\nconst BODY_SX = {\n fontSize: 17,\n lineHeight: 1.75,\n color: 'inherit',\n} as const\n\n/**\n * The element's own colour, applied to its root BEFORE the authored `sx`\n * (AGL-3210), so it is a default the Styles panel can replace rather than a\n * floor every block re-asserts. Inside the element everything inherits it.\n */\nconst BODY_COLOUR_SX = { color: 'text.primary' } as const\n\n/**\n * Heading ramp (AGL-1162). Sizes step across `{xs, sm, md}` and the tracking\n * steps WITH them: tracking is a function of size, so a single letterSpacing\n * that looks right at the desktop size is visibly loose on a phone. Negative\n * throughout — display sizes need the letters pulled together, which is the\n * opposite of the positive tracking small uppercase labels take.\n */\nconst HEADING_SX = {\n 2: {\n fontSize: { xs: 26, sm: 30, md: 34 },\n letterSpacing: { xs: '-0.3px', sm: '-0.4px', md: '-0.5px' },\n lineHeight: 1.25,\n fontWeight: 700,\n },\n 3: {\n fontSize: { xs: 19, sm: 20, md: 22 },\n letterSpacing: { xs: '-0.1px', sm: '-0.15px', md: '-0.2px' },\n lineHeight: 1.35,\n fontWeight: 700,\n },\n} as const\n\n/**\n * Breathing room a heading keeps above it when an anchor lands on it. Sites\n * built here usually have a sticky app bar, and without this the browser\n * scrolls the heading to y=0 — underneath the bar — so a working link looks\n * like a broken one.\n */\nconst ANCHOR_SCROLL_MARGIN = Aglyn.HEADING_ANCHOR_SCROLL_MARGIN\n\n/**\n * Inline runs as elements (AGL-1162), following the entry-body renderer:\n * internal links route through AppLink for client-side navigation, external\n * ones stay plain anchors, and editing surfaces render the link look without\n * an href so clicking never leaves the canvas.\n *\n * Which of those a link is — and whether it is a link at all — is\n * `resolveMarkdownLink`'s to say (AGL-3118), so a target named by reference\n * resolves through the same routing map an element link does, and one whose\n * target is gone renders as its words rather than as `href=\"entry:…\"`.\n */\nconst renderInlines = (\n inlines: Aglyn.MarkdownInline[],\n links: { suppressNavigation?: boolean; screens?: Aglyn.ScreenRouteMap },\n): ReactNode[] =>\n inlines.map((inline, index) => {\n if (inline.type === 'bold') return <strong key={index}>{inline.text}</strong>\n if (inline.type === 'italic') return <em key={index}>{inline.text}</em>\n if (inline.type === 'link') {\n const link = Aglyn.resolveMarkdownLink(inline.href, links)\n if (link.kind === 'text') return <span key={index}>{inline.text}</span>\n if (link.kind === 'inert') {\n return (\n <MuiLink key={index} component=\"span\" sx={{ cursor: 'default' }}>\n {inline.text}\n </MuiLink>\n )\n }\n return link.kind === 'internal' ? (\n <AppLink key={index} href={link.href}>\n {inline.text}\n </AppLink>\n ) : (\n <MuiLink key={index} href={link.href}>\n {inline.text}\n </MuiLink>\n )\n }\n return <span key={index}>{inline.text}</span>\n })\n\nexport interface MarkdownProps extends BoxProps {\n /** The document, as markdown-lite source. */\n content?: string\n /**\n * The pixel pair of each library image this document names, keyed by the\n * target as the document writes it, stamped by the composition from the\n * assets' DAM records (AGL-3149) — never set by hand.\n *\n * An image with no entry here renders exactly as it did before this prop\n * existed: see `mediaBodyImageAttributes` for why a partial answer is worse\n * than none.\n */\n intrinsicSizes?: Record<string, { width: number; height: number }>\n}\n\n/**\n * A whole document authored as markdown (AGL-1162).\n *\n * The elements that made a legal or policy page before this were hundreds of\n * Typography nodes, one per paragraph — which meant the page could not be\n * pasted from, or back into, the markdown file in Drive that is its actual\n * source. Here the source IS the element's content, so updating the page is\n * one paste.\n *\n * Rendered through the shared markdown-lite parser, which emits plain data\n * blocks and never an HTML string — so there is no `dangerouslySetInnerHTML`\n * anywhere on this path and nothing to sanitize. Parsing is pure, so the full\n * document server-renders and the text is in the crawled HTML.\n *\n * Child NODES are never rendered, in either branch (AGL-1388). The document\n * is the `content` prop; there is no position in a parsed block list that a\n * dropped element could occupy, so the schema turns dropping off and\n * `nodeAcceptsChildren` now honors that — a drop lands as a sibling instead.\n * `children` is destructured away rather than left in `rest` because the\n * empty-content branch spreads `rest` onto a childless Box: without this, a\n * Markdown element rendered exactly the child nodes it had swallowed a\n * moment earlier as soon as its content was cleared.\n */\nconst Markdown = forwardRef<HTMLDivElement, MarkdownProps>((props, ref) => {\n const { content, intrinsicSizes, sx, children: _children, ...rest } = props\n // The routing map travels with the suppression flag: both decide what a\n // link in this document renders as (AGL-3118).\n const { suppressNavigation, screens } = useContext(Aglyn.ScreenLinkContext)\n const links = useMemo(\n () => ({ suppressNavigation, screens }),\n [suppressNavigation, screens],\n )\n /**\n * The site being rendered, for image blocks (AGL-1686). Read once here\n * rather than per block: hooks cannot run inside the `blocks.map` below,\n * and a document may hold any number of images.\n */\n const { hostId } = Aglyn.useSite()\n const source = (content ?? '').trim()\n const blocks = useMemo(\n () => (source ? Aglyn.parseMarkdownLite(source) : []),\n [source],\n )\n // Slugs are derived rather than stored (see collectMarkdownHeadings), and\n // keyed by block index so the ids land on the right headings even when two\n // of them carry the same words. The map is built in `markdown-lite` now,\n // because every renderer needs exactly this and five of the six were not\n // getting it (AGL-1162).\n const slugs = useMemo(() => Aglyn.markdownHeadingSlugs(blocks), [blocks])\n\n if (!source) {\n // Editing surfaces get somewhere to click; the published page renders\n // nothing rather than a placeholder nobody meant to publish.\n if (!suppressNavigation) return <Box ref={ref} sx={sx} {...rest} />\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n p: 2,\n border: '1px dashed',\n borderColor: 'divider',\n color: 'text.secondary',\n fontSize: 12,\n },\n ...(Array.isArray(sx) ? sx : sx ? [sx] : []),\n ]}\n >\n {'Markdown — paste the document into the Content attribute'}\n </Box>\n )\n }\n\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[BODY_COLOUR_SX, ...(Array.isArray(sx) ? sx : sx ? [sx] : [])]}\n >\n {blocks.map((block, index) => {\n if (block.type === 'heading') {\n return (\n <Typography\n key={index}\n // The anchor a table of contents links to. `component` is set\n // explicitly because a Typography with only an `sx` fontSize\n // still renders a <p>: the page would screenshot correctly and\n // have no headings in it at all.\n id={slugs[index]}\n component={block.level === 2 ? 'h2' : 'h3'}\n sx={{\n ...HEADING_SX[block.level],\n // See BODY_SX: the token lives on the root, not on every\n // block, so an authored colour reaches the words (AGL-3210).\n color: 'inherit',\n scrollMarginTop: `${ANCHOR_SCROLL_MARGIN}px`,\n mt: block.level === 2 ? 5 : 3.5,\n mb: 1.5,\n '&:first-of-type': { mt: 0 },\n }}\n >\n {renderInlines(block.inlines, links)}\n </Typography>\n )\n }\n if (block.type === 'image') {\n return (\n <Box\n key={index}\n component=\"img\"\n // Resolved, exactly as `image.tsx` resolves its `src` prop\n // (AGL-1686). A document records WHICH ASSET; turning that into\n // a URL is the renderer's business, so the `/api/media/cdn/…`\n // route shape never has to be baked into a published document.\n // Every other value — a legacy storage URL, a legacy CDN path,\n // an author-typed hotlink — passes through untouched.\n //\n // The resolve now comes back with the WebP candidate list and\n // the intrinsic pair beside it, when the composition could read\n // the asset's record (AGL-3149). Shared with the entry body and\n // with `image.tsx`'s own srcSet so a body image cannot drift\n // away from the element again.\n {...Aglyn.mediaBodyImageAttributes({\n src: block.src,\n hostId,\n size: intrinsicSizes?.[block.src],\n })}\n alt={block.alt}\n // `height: 'auto'` is load-bearing beside the pair above, not\n // tidiness: the pair's `height` arrives as a presentational hint\n // too, and a hint that survives the `maxWidth` cap squashes the\n // picture instead of scaling it. It is what `auto` already\n // resolved to before the pair existed, so this changes nothing\n // for an image the composition could not measure.\n sx={{ maxWidth: '100%', height: 'auto', borderRadius: 1, my: 2 }}\n // `lazy` alone until AGL-2486. A markdown image is by\n // definition inside prose the reader scrolls through, so it\n // belongs in the same deferred rank as everything else that is\n // not the lead image.\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n )\n }\n if (block.type === 'list') {\n return (\n <Box\n key={index}\n component=\"ul\"\n sx={{ ...BODY_SX, my: 2, pl: 3, '& li': { mb: 1 } }}\n >\n {block.items.map((item, itemIndex) => (\n <li key={itemIndex}>\n {renderInlines(item, links)}\n </li>\n ))}\n </Box>\n )\n }\n // A numbered list (AGL-1320): the same measure as the bullet list,\n // as a real `<ol>` carrying `start` — a legal document's enumerated\n // elements are the reason this block exists.\n if (block.type === 'orderedList') {\n return (\n <Box\n key={index}\n component=\"ol\"\n start={block.start}\n sx={{ ...BODY_SX, my: 2, pl: 3, '& li': { mb: 1 } }}\n >\n {block.items.map((item, itemIndex) => (\n <li key={itemIndex}>\n {renderInlines(item, links)}\n </li>\n ))}\n </Box>\n )\n }\n // Code and tables scroll rather than wrap, like every other\n // markdown-lite renderer here (AGL-974): a wrapped command line\n // reads as two commands, and a squeezed table column loses the\n // structure that made it a table.\n if (block.type === 'code') {\n return (\n <Box\n key={index}\n component=\"pre\"\n sx={{\n my: 2,\n p: 2,\n overflowX: 'auto',\n borderRadius: 1,\n bgcolor: 'action.hover',\n fontFamily: 'monospace',\n fontSize: 14,\n }}\n >\n <code>{block.text}</code>\n </Box>\n )\n }\n if (block.type === 'table') {\n return (\n <Box\n key={index}\n {...scrollRegionProps(TABLE_REGION_LABEL)}\n sx={{ my: 2, ...scrollableTableWrapperSx }}\n >\n <Box\n component=\"table\"\n sx={{\n ...BODY_SX,\n fontSize: 16,\n borderCollapse: 'collapse',\n ...scrollableTableSx,\n '& th, & td': {\n border: '1px solid',\n borderColor: 'divider',\n px: 1.5,\n py: 1,\n },\n '& th': { bgcolor: 'action.hover', fontWeight: 600 },\n }}\n >\n <thead>\n <tr>\n {block.header.map((cell, cellIndex) => (\n <th\n key={cellIndex}\n style={{ textAlign: block.align[cellIndex] ?? 'left' }}\n >\n {renderInlines(cell, links)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {block.rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <td\n key={cellIndex}\n style={{\n textAlign: block.align[cellIndex] ?? 'left',\n }}\n >\n {renderInlines(cell, links)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </Box>\n </Box>\n )\n }\n // A pull-quote (AGL-1315): the document's body measure, one size up\n // and italic, behind a left accent — palette tokens keep it right in\n // both modes.\n if (block.type === 'quote') {\n return (\n <Typography\n key={index}\n component=\"blockquote\"\n sx={{\n ...BODY_SX,\n my: 3,\n mx: 0,\n pl: 2.5,\n borderLeft: '3px solid',\n borderColor: 'primary.main',\n fontStyle: 'italic',\n fontSize: 21,\n lineHeight: 1.6,\n }}\n >\n {renderInlines(block.inlines, links)}\n </Typography>\n )\n }\n return (\n <Typography key={index} component=\"p\" sx={{ ...BODY_SX, my: 2 }}>\n {renderInlines(block.inlines, links)}\n </Typography>\n )\n })}\n </Box>\n )\n})\nMarkdown.displayName = 'AglynMarkdown'\n\n/* ── Table of contents ──────────────────────────────────────────────────── */\n\nexport interface TableOfContentsProps extends BoxProps {\n /**\n * The Markdown element this lists the headings of. Empty means \"the first\n * Markdown element on the screen\", which is the answer on every page that\n * has exactly one — see {@link resolveMarkdownSource}.\n */\n forNodeId?: string\n /** Aside heading; an empty string renders no heading at all. */\n heading?: string\n /** Deepest heading level listed: `'2'` for top level only. */\n depth?: '2' | '3'\n}\n\n/**\n * Which Markdown element a table of contents speaks for (AGL-1162).\n *\n * Resolved through the NODE TREE, never the DOM: the besigner canvas renders\n * inside a closed shadow root, so a `document.querySelector` from a component\n * finds nothing there and the aside would be empty in the one place it is\n * being authored.\n *\n * The tree is walked from the root in document order, so \"the first Markdown\n * element\" means the first one a reader meets — not the first key of a node\n * map, whose order is storage detail.\n *\n * An explicit `forNodeId` wins, compared with `leafIdsMatch` because the\n * stored id is the raw canvas id while a composed tree namespaces layout and\n * reusable-component grafts (AGL-573/1229). A pick that no longer resolves —\n * the element was deleted and re-added, which is exactly what re-pasting a\n * document looks like — falls back to the first Markdown element rather than\n * leaving a published page with an empty aside.\n */\nexport function resolveMarkdownSource(\n root: Aglyn.NodeSchema | undefined,\n forNodeId?: string,\n): string {\n const found: Array<{ $id: string; content: string }> = []\n const walk = (node: Aglyn.NodeSchema | undefined): void => {\n if (!node) return\n // Two element types hold a markdown-lite document, and an aside beside a\n // blog article is the case this issue was opened for (AGL-1162): the\n // Collection Entry Body carries the post, under `markdown` rather than\n // `content`, and used to be invisible here — so \"On this page\" on an\n // article template rendered its authoring affordance forever.\n const source =\n node.componentId === MARKDOWN_ID\n ? 'content'\n : node.componentId === Aglyn.COLLECTION_ENTRY_BODY_COMPONENT_ID\n ? 'markdown'\n : undefined\n if (source) {\n const props = (node.resolvedProps ?? node.props ?? {}) as Record<\n string,\n unknown\n >\n const content = String(props[source] ?? '')\n // An entry body on an unresolved surface is the literal\n // `{{entry.body}}` token. It is not a document, and treating it as one\n // would let it win over a real Markdown element further down the page\n // and empty the aside on the canvas.\n if (!UNRESOLVED_TOKEN.test(content.trim())) {\n found.push({ $id: node.$id, content })\n }\n }\n for (const child of node.children ?? []) walk(child)\n }\n walk(root)\n if (forNodeId) {\n const picked = found.find((entry) => Aglyn.leafIdsMatch(entry.$id, forNodeId))\n if (picked) return picked.content\n }\n return found[0]?.content ?? ''\n}\n\n/**\n * Scrolls to a heading in the cases the browser cannot reach, and ONLY those\n * (AGL-1162). Returns whether it handled the click.\n *\n * In `document` it deliberately does nothing and lets the plain `#slug`\n * anchor work: native fragment navigation updates the address bar, adds a\n * history entry the back button understands, and honours the site's CSS\n * `scroll-behavior` — none of which a hand-rolled `scrollIntoView` gives\n * back. It is also the only version that works with JavaScript off.\n *\n * (`behavior: 'smooth'` was the first attempt at the whole job, and it is\n * exactly the wrong shape: a browser that declines to animate — a background\n * tab, reduced-motion — leaves the click prevented and the page unmoved, so\n * a working link reads as a broken one.)\n *\n * The besigner canvas renders inside a CLOSED shadow root, where the heading\n * is not in `document` at all and a fragment navigation finds nothing. There\n * the link's own `getRootNode()` is the shadow root holding both ends, and\n * `ShadowRoot.getElementById` finds the heading.\n */\nexport function scrollToHeading(anchor: Element, slug: string): boolean {\n const root = anchor.getRootNode()\n if (root === anchor.ownerDocument || !(root as ShadowRoot).getElementById) {\n return false\n }\n const target = (root as ShadowRoot).getElementById(slug)\n if (!target) return false\n // No explicit `behavior`: 'auto' follows the scrolling box's CSS\n // `scroll-behavior`, so a site that asked for smooth still gets it.\n target.scrollIntoView({ block: 'start' })\n return true\n}\n\n/**\n * What the sidebar's chrome costs, above and below the list (AGL-2486).\n *\n * The list's bound is `100dvh` MINUS this, so it is a function of the window\n * rather than a height somebody picked. Measured on the live\n * `/legal/marketplace-publisher-agreement` sidebar, which is the shape every\n * legal page uses: the card is `position: sticky; top: 96px` under the app\n * bar, then 24px of card padding and 31px of \"ON THIS PAGE\" label sit above\n * the list and 31px of padding below it — 182px of chrome. 200 leaves the\n * card's bottom BORDER inside the window rather than flush against it, so\n * the card reads as a card and not as a page that ran out.\n *\n * It is an allowance, not a contract: this component renders inside whatever\n * the author built around it, and it cannot read that card's `top` offset.\n * Being a MAX height, an allowance a little too generous only means a few\n * pixels of the card sit below the fold; one a little too tight only means\n * the scroll box starts a line sooner. Both are recoverable, which is the\n * whole reason this is a `max-height` and not a `height`.\n */\nconst TOC_VIEWPORT_ALLOWANCE = '200px'\n\n/**\n * The list is its own scroll box once it outgrows the window (AGL-2486).\n *\n * The bug: nothing here was bounded, and the card the author wraps this in is\n * `position: sticky`. A sticky box taller than the viewport does not scroll\n * into view — it pins at its `top` offset and everything past the window's\n * bottom edge is simply unreachable. Measured on the Marketplace Publisher\n * Agreement (14 `h2`s) in a 1100x480 window: the card stood 502px tall from\n * `top: 96px` and overhung the fold by 118px, entry 11 was cut through the\n * middle of its own text at the window edge, and 12 to 14 could not be\n * reached by any scroll — `ol.scrollTop` stayed 0, because the list was not a\n * scroll box at all. Which row gets cut moves with the window height and the\n * browser zoom; the reported sighting was entry 8. Either way it did not read\n * as \"there is more\", it read as a document with fewer sections than it has.\n *\n * Three things this deliberately is NOT:\n *\n * - NOT a `height`. A `max-height` is inert until the content exceeds it, so\n * the four-item TOCs (`/legal/dmca`, `/legal/subprocessors`) keep their\n * exact present box: no scroll region, no reserved gutter, no dead space.\n * That is also why `overflow-y` is `auto` and never `scroll`.\n *\n * - NOT applied below `md`. The bound only makes sense for a sidebar. In the\n * stacked narrow layout the TOC is a full-width block in the page flow, and\n * bounding it there would plant a scroll trap in the middle of an article\n * to solve a clipping problem that layout does not have.\n *\n * - NOT silent, and the FADE is the part that carries that. A scroll box a\n * reader cannot see is the same bug wearing a scrollbar: measured in Chrome\n * on macOS, `offsetWidth - clientWidth` on this list is 0 even with\n * `scrollbar-color` set — the platform draws an OVERLAY scrollbar, which is\n * invisible until you have already guessed to scroll. So the thumb styling\n * is the secondary cue, for the platforms that draw one at rest, and the\n * primary cue is a bottom fade: the cut stops being a slice through the\n * middle of a word and becomes an edge that visibly continues.\n *\n * The fade rides a scroll-driven animation on purpose: a `scroll()` timeline\n * on a box with nothing to scroll is INACTIVE, so its animation applies no\n * styles at all. That is the only way to say \"fade only when overflowing\" in\n * CSS with no measuring and no JavaScript, and it degrades to plain\n * unfaded-but-scrollable in a browser that lacks it. Verified both ways at\n * 1100x480: the 14-entry list fades and scrolls, the 4-entry\n * `/legal/subprocessors` list computes `mask-image: none` and does not.\n *\n * NO new attribute goes with this, deliberately. The three the element has —\n * `forNodeId`, `heading`, `depth` — all answer \"which headings does this\n * list\", and a \"list height\" field would hand the author back the very\n * decision this bug is made of. The right answer is \"as much of the window as\n * there is\", which is a thing CSS can work out and an author cannot type.\n */\nconst TABLE_OF_CONTENTS_LIST_SX = (theme: Theme) => ({\n listStyle: 'none',\n m: 0,\n p: 0,\n [theme.breakpoints.up('md')]: {\n maxHeight: `calc(100vh - ${TOC_VIEWPORT_ALLOWANCE})`,\n // `dvh` over `vh` where it exists: `vh` is the LARGEST viewport, so a\n // window with a visible toolbar gets a bound taller than the space it\n // has — which is the bug again, in miniature.\n '@supports (height: 100dvh)': {\n maxHeight: `calc(100dvh - ${TOC_VIEWPORT_ALLOWANCE})`,\n },\n overflowY: 'auto',\n // Reaching the end of the list must not then throw the page down a\n // screen — the reader was navigating the sidebar, not the document.\n overscrollBehavior: 'contain',\n scrollbarWidth: 'thin',\n // `text.disabled`, not `divider`: a 12%-black thumb is one you have to\n // already know is there. `3px` is QUOTED because a bare 3 is a theme\n // radius STEP and lands as 12px on a 6px-wide thumb.\n scrollbarColor: `${theme.palette.text.disabled} transparent`,\n '&::-webkit-scrollbar': { width: 6 },\n '&::-webkit-scrollbar-thumb': {\n backgroundColor: theme.palette.text.disabled,\n borderRadius: '3px',\n },\n ...scrollOverflowFadeTimeline('block'),\n },\n ...scrollOverflowFadeKeyframes('block'),\n})\n\n/**\n * \"On this page\" (AGL-1162) — the headings of a Markdown element on the same\n * screen, as working anchor links.\n *\n * A mobx `observer` because it reads ANOTHER node's props: the renderer's\n * Leaf re-renders on changes to the node it is rendering, and nothing else,\n * so without this the aside in the besigner would keep listing the headings\n * of the document as it was when the aside mounted.\n */\nconst TableOfContents = observer(\n forwardRef<HTMLElement, TableOfContentsProps>((props, ref) => {\n const { forNodeId, heading, depth, sx, ...rawRest } = props\n /**\n * The cleared-prop guard, applied to the props that LEAVE this\n * component rather than to all of them (AGL-1451).\n *\n * A props-wide `dropClearedProps` would be wrong here, and this is the\n * component that shows why the wrapper is not a reflex: `heading` reads\n * an EMPTY value as a real author choice — \"clear it to render no\n * label\", which is what its help text promises and what the `heading\n * === undefined ? 'On this page' : heading` line below implements. A\n * guard over the whole props object would strip the cleared heading and\n * put the default label back, i.e. eat the choice the author made. So\n * `heading` and `depth` are read as authored, and the guard covers only\n * what is spread onto the Box.\n */\n const rest = dropClearedProps(rawRest)\n const { suppressNavigation } = useContext(Aglyn.ScreenLinkContext)\n const source = resolveMarkdownSource(Aglyn.canvas.rootNode, forNodeId)\n const entries = useMemo(() => {\n const headings = Aglyn.collectMarkdownHeadings(\n Aglyn.parseMarkdownLite(source),\n )\n return depth === '2'\n ? headings.filter((entry) => entry.level === 2)\n : headings\n }, [source, depth])\n const title = heading === undefined ? 'On this page' : heading\n\n if (!entries.length) {\n // Same split as the Markdown element: an affordance while authoring,\n // nothing at all on the published page — and no empty `nav` landmark.\n if (!suppressNavigation) return <Box ref={ref} sx={sx} {...rest} />\n return (\n <Box\n ref={ref}\n component=\"nav\"\n sx={[\n {\n p: 2,\n border: '1px dashed',\n borderColor: 'divider',\n color: 'text.secondary',\n fontSize: 12,\n },\n ...(Array.isArray(sx) ? sx : sx ? [sx] : []),\n ]}\n {...rest}\n >\n {'Table of contents — add ## headings to the Markdown element'}\n </Box>\n )\n }\n\n return (\n <Box\n ref={ref}\n component=\"nav\"\n aria-label={title || 'Table of contents'}\n sx={sx}\n {...rest}\n >\n {title ? (\n <Typography\n component=\"p\"\n sx={{\n fontSize: 12,\n fontWeight: 700,\n // Positive tracking here, unlike the document headings: this is\n // a small uppercase label, where the letters need pushing apart\n // rather than pulling together.\n letterSpacing: '0.8px',\n textTransform: 'uppercase',\n color: 'text.secondary',\n mb: 1.5,\n }}\n >\n {title}\n </Typography>\n ) : null}\n <Box component=\"ol\" sx={TABLE_OF_CONTENTS_LIST_SX}>\n {entries.map((entry) => (\n <Box component=\"li\" key={entry.slug} sx={{ mb: 0.75 }}>\n <MuiLink\n // A real href, so the entry is a link to a crawler, works\n // with no JavaScript, and can be copied out of the page.\n href={`#${entry.slug}`}\n underline=\"hover\"\n color=\"text.secondary\"\n onClick={(event: MouseEvent<HTMLAnchorElement>) => {\n // Prevented ONLY when this actually moved the page — on a\n // published page it does nothing and the anchor works the\n // way anchors do.\n if (scrollToHeading(event.currentTarget, entry.slug)) {\n event.preventDefault()\n }\n }}\n sx={{\n display: 'block',\n fontSize: 15,\n lineHeight: 1.5,\n // Sub-headings indent; nothing else distinguishes them, so\n // a flat list of both levels reads as one long list.\n pl: entry.level === 3 ? 2 : 0,\n '&:hover': { color: 'text.primary' },\n }}\n >\n {entry.text}\n </MuiLink>\n </Box>\n ))}\n </Box>\n </Box>\n )\n }),\n)\nTableOfContents.displayName = 'AglynTableOfContents'\n\nexport const markdownSchema: Aglyn.ComponentSchema<MarkdownProps> = {\n $id: MARKDOWN_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Markdown',\n description:\n 'A whole document written as markdown. It takes no child elements.',\n category: Aglyn.ComponentCategory.TEXT,\n icon: { path: mdiLanguageMarkdown.path, sx: { color: '#455a64' } },\n flags: {\n // The document is the `content` attribute; dropping elements inside a\n // rendered document would put them somewhere the markdown cannot say.\n dropping: Aglyn.FEATURE_FLAG.DISABLED,\n },\n attributes: [\n {\n name: 'content',\n label: 'Content',\n description:\n 'The document, as markdown. Headings (## and ###), paragraphs, ' +\n 'bold/italic, links, bullet and 1. numbered lists, images, fenced ' +\n 'code, pipe tables and > quotes. Paste the whole source file — a ' +\n 'Table of contents element on the same screen lists the ## and ### ' +\n 'headings automatically.',\n // The WYSIWYG rather than a raw textarea (AGL-1616): this attribute is\n // a whole document — the published Privacy Policy body is one of them —\n // and editing it as raw markdown-lite meant a 13 KB paste (AGL-1594).\n // The stored value is unchanged, so every renderer is untouched.\n component: Aglyn.FieldComponentType.MARKDOWN,\n },\n ],\n}\n\nexport const tableOfContentsSchema: Aglyn.ComponentSchema<TableOfContentsProps> =\n {\n $id: TABLE_OF_CONTENTS_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Table of Contents',\n description:\n \"An on-this-page list linking to a Markdown element's headings.\",\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiTableOfContents.path, sx: { color: '#455a64' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'forNodeId',\n label: 'Markdown element',\n description:\n 'The Markdown element to list the headings of. Leave empty on a ' +\n 'page with one Markdown element — the first one on the screen is ' +\n 'used, and a pick that no longer exists falls back to it too.',\n component: Aglyn.FieldComponentType.NODE_SELECT,\n },\n {\n name: 'heading',\n label: 'Heading',\n description: 'Label above the list. Clear it to render no label.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'depth',\n label: 'Levels',\n description: 'How deep the list goes.',\n component: Aglyn.FieldComponentType.SELECT,\n // `depth` never reaches MUI — it is read here, as `depth === '2'`.\n // So the `''` was not a rendering defect; it was an option that\n // could not survive a save (AGL-1191), which meant an author who\n // set \"## headings only\" and then changed their mind could not put\n // it back. `'3'` states the same thing as a real, persistable\n // value — and is what `TableOfContentsProps.depth` has declared\n // all along, so the option list was the half that had drifted.\n // Both levels remain what an unset field means (AGL-1451).\n options: [\n { value: '3', label: '## and ### headings' },\n { value: '2', label: '## headings only' },\n ],\n },\n ],\n }\n\nexport const markdownPresets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(MARKDOWN_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Markdown',\n pluginId: BUNDLE_ID,\n description: 'A whole document, authored as markdown',\n category: Aglyn.ComponentCategory.TEXT,\n icon: { path: mdiLanguageMarkdown.path, sx: { color: '#455a64' } },\n data: {\n $id: null,\n componentId: MARKDOWN_ID,\n pluginId: BUNDLE_ID,\n props: {\n content:\n '## First section\\n\\nReplace this with your document. Paste ' +\n 'markdown straight from the source file.\\n\\n' +\n '### A sub-section\\n\\nHeadings become anchors, and a Table of ' +\n 'contents element on the same screen links to them.',\n },\n },\n },\n {\n $id: generatePresetId(TABLE_OF_CONTENTS_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Table of Contents',\n pluginId: BUNDLE_ID,\n description: 'On this page — links to a Markdown element’s headings',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiTableOfContents.path, sx: { color: '#455a64' } },\n data: {\n $id: null,\n componentId: TABLE_OF_CONTENTS_ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n },\n]\n\nexport { Markdown, TableOfContents }\nexport default Markdown\n"],"names":["Aglyn","mdiLanguageMarkdown","mdiTableOfContents","AppLink","scrollOverflowFadeKeyframes","scrollOverflowFadeTimeline","scrollRegionProps","scrollableTableSx","scrollableTableWrapperSx","Box","MuiLink","Typography","observer","forwardRef","useContext","useMemo","BUNDLE_ID","dropClearedProps","generatePresetId","MARKDOWN_ID","UNRESOLVED_TOKEN","TABLE_REGION_LABEL","TABLE_OF_CONTENTS_ID","BODY_SX","fontSize","lineHeight","color","BODY_COLOUR_SX","HEADING_SX","xs","sm","md","letterSpacing","fontWeight","ANCHOR_SCROLL_MARGIN","HEADING_ANCHOR_SCROLL_MARGIN","renderInlines","inlines","links","map","inline","index","type","strong","text","em","link","resolveMarkdownLink","href","kind","span","component","sx","cursor","Markdown","props","ref","content","intrinsicSizes","children","_children","rest","suppressNavigation","screens","ScreenLinkContext","hostId","useSite","source","trim","blocks","parseMarkdownLite","slugs","markdownHeadingSlugs","p","border","borderColor","Array","isArray","block","id","level","scrollMarginTop","mt","mb","mediaBodyImageAttributes","src","size","alt","maxWidth","height","borderRadius","my","DEFERRED_IMAGE_ATTRIBUTES","pl","items","item","itemIndex","li","start","overflowX","bgcolor","fontFamily","code","borderCollapse","px","py","thead","tr","header","cell","cellIndex","th","style","textAlign","align","tbody","rows","row","rowIndex","td","mx","borderLeft","fontStyle","displayName","resolveMarkdownSource","root","forNodeId","found","walk","node","componentId","COLLECTION_ENTRY_BODY_COMPONENT_ID","undefined","resolvedProps","String","test","push","$id","child","picked","find","entry","leafIdsMatch","scrollToHeading","anchor","slug","getRootNode","ownerDocument","getElementById","target","scrollIntoView","TOC_VIEWPORT_ALLOWANCE","TABLE_OF_CONTENTS_LIST_SX","theme","listStyle","m","breakpoints","up","maxHeight","overflowY","overscrollBehavior","scrollbarWidth","scrollbarColor","palette","disabled","width","backgroundColor","TableOfContents","heading","depth","rawRest","canvas","rootNode","entries","headings","collectMarkdownHeadings","filter","title","length","aria-label","textTransform","underline","onClick","event","currentTarget","preventDefault","display","markdownSchema","pluginId","description","category","ComponentCategory","TEXT","icon","path","flags","dropping","FEATURE_FLAG","DISABLED","attributes","name","label","FieldComponentType","MARKDOWN","tableOfContentsSchema","NAVIGATION","selfClosing","ENABLED","NODE_SELECT","TEXT_FIELD","SELECT","options","value","markdownPresets","NodeType","PRESET","data"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ,yBAAwB;AAChF,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SACEC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,iBAA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