payload-canvas 0.2.0 → 0.4.0

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.
Files changed (170) hide show
  1. package/README.md +500 -25
  2. package/dist/admin/diff/changes.js +8 -0
  3. package/dist/admin/editor/Inspector.js +49 -4
  4. package/dist/admin/editor/Outline.js +12 -10
  5. package/dist/admin/editor/actions.d.ts +9 -1
  6. package/dist/admin/editor/actions.js +38 -3
  7. package/dist/admin/editor/empty/EmptyStart.js +29 -3
  8. package/dist/admin/editor/fields/GroupField.d.ts +5 -2
  9. package/dist/admin/editor/fields/GroupField.js +6 -2
  10. package/dist/admin/editor/fields/WhereField.d.ts +17 -0
  11. package/dist/admin/editor/fields/WhereField.js +67 -0
  12. package/dist/admin/editor/fields/fields.scss +89 -0
  13. package/dist/admin/editor/fields/whereRows.d.ts +28 -0
  14. package/dist/admin/editor/fields/whereRows.js +118 -0
  15. package/dist/admin/editor/icons.d.ts +1 -0
  16. package/dist/admin/editor/icons.js +2 -0
  17. package/dist/admin/editor/locale/LocaleField.d.ts +1 -1
  18. package/dist/admin/editor/locale/LocaleField.js +3 -1
  19. package/dist/admin/editor/menu/blockMenu.js +5 -1
  20. package/dist/admin/editor/motion/MotionPanel.js +1 -1
  21. package/dist/admin/editor/motion/model.js +2 -2
  22. package/dist/admin/editor/renderField.d.ts +3 -1
  23. package/dist/admin/editor/renderField.js +13 -4
  24. package/dist/admin/editor/runtime.js +1 -0
  25. package/dist/admin/editor/styles/SiteClasses.d.ts +9 -0
  26. package/dist/admin/editor/styles/SiteClasses.js +31 -0
  27. package/dist/admin/editor/styles/StylesPanel.d.ts +3 -1
  28. package/dist/admin/editor/styles/StylesPanel.js +9 -6
  29. package/dist/admin/editor/styles/context.d.ts +9 -2
  30. package/dist/admin/editor/styles/context.js +14 -9
  31. package/dist/admin/editor/styles/controls.js +2 -2
  32. package/dist/admin/editor/styles/sections.js +1 -1
  33. package/dist/admin/editor/styles/styles.scss +54 -0
  34. package/dist/admin/editor/templates/Bindable.d.ts +13 -5
  35. package/dist/admin/editor/templates/Bindable.js +73 -17
  36. package/dist/admin/editor/templates/binding.d.ts +11 -4
  37. package/dist/admin/editor/templates/binding.js +23 -3
  38. package/dist/ai/prompt.js +8 -2
  39. package/dist/ai/tools.js +11 -2
  40. package/dist/blocks/builtins/carousel.d.ts +32 -0
  41. package/dist/blocks/builtins/carousel.js +122 -0
  42. package/dist/blocks/builtins/disclosure.d.ts +13 -0
  43. package/dist/blocks/builtins/disclosure.js +107 -0
  44. package/dist/blocks/builtins/faq.d.ts +17 -0
  45. package/dist/blocks/builtins/faq.js +88 -0
  46. package/dist/blocks/builtins/filterLink.d.ts +22 -0
  47. package/dist/blocks/builtins/filterLink.js +76 -0
  48. package/dist/blocks/builtins/headingId.d.ts +15 -0
  49. package/dist/blocks/builtins/headingId.js +36 -0
  50. package/dist/blocks/builtins/icon.d.ts +8 -0
  51. package/dist/blocks/builtins/icon.js +45 -0
  52. package/dist/blocks/builtins/index.d.ts +35 -0
  53. package/dist/blocks/builtins/index.js +50 -0
  54. package/dist/blocks/builtins/lightbox.d.ts +43 -0
  55. package/dist/blocks/builtins/lightbox.js +93 -0
  56. package/dist/blocks/builtins/mediaBackdrop.d.ts +11 -0
  57. package/dist/blocks/builtins/mediaBackdrop.js +79 -0
  58. package/dist/blocks/builtins/sectionRef.d.ts +26 -0
  59. package/dist/blocks/builtins/sectionRef.js +78 -0
  60. package/dist/blocks/builtins/shared.d.ts +33 -0
  61. package/dist/blocks/builtins/shared.js +70 -0
  62. package/dist/blocks/builtins/tableOfContents.d.ts +3 -0
  63. package/dist/blocks/builtins/tableOfContents.js +44 -0
  64. package/dist/blocks/defaults.d.ts +19 -1
  65. package/dist/blocks/defaults.js +413 -20
  66. package/dist/blocks/index.d.ts +4 -2
  67. package/dist/blocks/index.js +3 -1
  68. package/dist/core/attrs.d.ts +27 -0
  69. package/dist/core/attrs.js +132 -0
  70. package/dist/core/bindings.d.ts +122 -11
  71. package/dist/core/bindings.js +504 -19
  72. package/dist/core/blocks.d.ts +46 -1
  73. package/dist/core/blocks.js +136 -0
  74. package/dist/core/classes.d.ts +10 -2
  75. package/dist/core/classes.js +34 -5
  76. package/dist/core/headings.d.ts +21 -0
  77. package/dist/core/headings.js +47 -0
  78. package/dist/core/index.d.ts +4 -2
  79. package/dist/core/index.js +4 -2
  80. package/dist/core/motion.d.ts +18 -9
  81. package/dist/core/motion.js +20 -12
  82. package/dist/core/operations.js +59 -2
  83. package/dist/core/payloadBlocks.js +3 -1
  84. package/dist/core/schema.js +20 -0
  85. package/dist/core/tree.js +24 -1
  86. package/dist/core/types.d.ts +87 -0
  87. package/dist/core/validate.js +29 -4
  88. package/dist/css/tokens.d.ts +6 -3
  89. package/dist/css/tokens.js +48 -2
  90. package/dist/index.d.ts +3 -3
  91. package/dist/index.js +2 -2
  92. package/dist/mcp/index.d.ts +2 -0
  93. package/dist/mcp/index.js +50 -13
  94. package/dist/mcp/shared.d.ts +3 -0
  95. package/dist/mcp/shared.js +23 -8
  96. package/dist/plugin/index.d.ts +8 -0
  97. package/dist/plugin/index.js +26 -8
  98. package/dist/plugin/listCollections.d.ts +17 -2
  99. package/dist/plugin/listCollections.js +44 -7
  100. package/dist/plugin/references.d.ts +5 -0
  101. package/dist/plugin/references.js +1 -1
  102. package/dist/plugin/templates.d.ts +4 -0
  103. package/dist/plugin/templates.js +23 -4
  104. package/dist/protocol/index.d.ts +2 -0
  105. package/dist/react/canvas/BuilderCanvas.js +5 -3
  106. package/dist/react/canvas/fetchDocs.d.ts +16 -2
  107. package/dist/react/canvas/fetchDocs.js +42 -9
  108. package/dist/react/canvas/measure.d.ts +3 -1
  109. package/dist/react/canvas/measure.js +26 -2
  110. package/dist/react/canvas/resolveLayout.d.ts +1 -1
  111. package/dist/react/canvas/resolveLayout.js +17 -6
  112. package/dist/react/canvas/serverBlocks.d.ts +11 -0
  113. package/dist/react/canvas/serverBlocks.js +28 -1
  114. package/dist/react/components/Button.d.ts +11 -2
  115. package/dist/react/components/Button.js +43 -6
  116. package/dist/react/components/CollectionList.d.ts +6 -3
  117. package/dist/react/components/CollectionList.js +21 -7
  118. package/dist/react/components/Container.js +4 -1
  119. package/dist/react/components/Field.js +13 -2
  120. package/dist/react/components/Heading.js +9 -2
  121. package/dist/react/components/Image.d.ts +9 -0
  122. package/dist/react/components/Image.js +16 -1
  123. package/dist/react/components/List.d.ts +1 -0
  124. package/dist/react/components/List.js +6 -0
  125. package/dist/react/components/Menu.d.ts +16 -0
  126. package/dist/react/components/Menu.js +83 -19
  127. package/dist/react/components/RichText.d.ts +8 -3
  128. package/dist/react/components/RichText.js +25 -4
  129. package/dist/react/components/builtins/Accordion.d.ts +9 -0
  130. package/dist/react/components/builtins/Accordion.js +37 -0
  131. package/dist/react/components/builtins/BackdropVideo.d.ts +13 -0
  132. package/dist/react/components/builtins/BackdropVideo.js +16 -0
  133. package/dist/react/components/builtins/Carousel.d.ts +13 -0
  134. package/dist/react/components/builtins/Carousel.js +134 -0
  135. package/dist/react/components/builtins/Disclosure.d.ts +7 -0
  136. package/dist/react/components/builtins/Disclosure.js +13 -0
  137. package/dist/react/components/builtins/FilterLink.d.ts +8 -0
  138. package/dist/react/components/builtins/FilterLink.js +30 -0
  139. package/dist/react/components/builtins/Icon.d.ts +14 -0
  140. package/dist/react/components/builtins/Icon.js +28 -0
  141. package/dist/react/components/builtins/Lightbox.d.ts +45 -0
  142. package/dist/react/components/builtins/Lightbox.js +252 -0
  143. package/dist/react/components/builtins/MediaBackdrop.d.ts +14 -0
  144. package/dist/react/components/builtins/MediaBackdrop.js +61 -0
  145. package/dist/react/components/builtins/SectionRef.d.ts +7 -0
  146. package/dist/react/components/builtins/SectionRef.js +17 -0
  147. package/dist/react/components/builtins/TableOfContents.d.ts +7 -0
  148. package/dist/react/components/builtins/TableOfContents.js +21 -0
  149. package/dist/react/components/builtins/glyphs.d.ts +8 -0
  150. package/dist/react/components/builtins/glyphs.js +7 -0
  151. package/dist/react/components/builtins/index.d.ts +32 -0
  152. package/dist/react/components/builtins/index.js +36 -0
  153. package/dist/react/components/index.js +2 -0
  154. package/dist/react/index.d.ts +3 -1
  155. package/dist/react/index.js +3 -1
  156. package/dist/react/motion/runtime.js +10 -6
  157. package/dist/react/render/RenderLayout.d.ts +1 -1
  158. package/dist/react/render/RenderLayout.js +76 -23
  159. package/dist/react/render/lists.d.ts +107 -5
  160. package/dist/react/render/lists.js +284 -9
  161. package/dist/react/render/resolve.d.ts +22 -2
  162. package/dist/react/render/resolve.js +45 -22
  163. package/dist/react/render/sections.d.ts +9 -0
  164. package/dist/react/render/sections.js +51 -0
  165. package/dist/react/render/types.d.ts +6 -1
  166. package/dist/react/server.d.ts +3 -1
  167. package/dist/react/server.js +53 -2
  168. package/dist/react/theme/ThemeStyle.d.ts +13 -2
  169. package/dist/react/theme/ThemeStyle.js +12 -2
  170. package/package.json +1 -1
@@ -5,4 +5,4 @@ import { type ResolveLink } from '../index.js';
5
5
  * collection lists loaded, and upload and relationship IDs replaced with documents (over REST).
6
6
  * Documents load in `locale` (the editor's locale), as the site loads them in the page's locale.
7
7
  */
8
- export declare function resolveCanvasLayout(layout: Layout, context: TemplateContext | null, api: string, definitions: BlockDefinition[], resolveLink: ResolveLink, locale?: string | null): Promise<Layout>;
8
+ export declare function resolveCanvasLayout(layout: Layout, context: TemplateContext | null, api: string, definitions: BlockDefinition[], resolveLink: ResolveLink, locale?: string | null, relations?: Record<string, Record<string, string>> | null): Promise<Layout>;
@@ -1,15 +1,26 @@
1
1
  import { resolveBindings } from '../../core/index.js';
2
2
  import { attachListItems, listQueries, resolveLayoutData, urlResolver } from '../index.js';
3
- import { createRestFetchDocs, fetchListItems } from './fetchDocs.js';
3
+ import { pageLinks, withPageParams } from '../render/lists.js';
4
+ import { attachSections } from '../render/sections.js';
5
+ import { createRestFetchDocs, fetchListPage } from './fetchDocs.js';
6
+ /** One shuffle per canvas: `$random` lists keep their order while someone edits. */
7
+ const CANVAS_SEED = Math.floor(Math.random() * 4_294_967_296);
4
8
  /**
5
9
  * The layout as the canvas renders it: bound to the template's document (when there is one),
6
10
  * collection lists loaded, and upload and relationship IDs replaced with documents (over REST).
7
11
  * Documents load in `locale` (the editor's locale), as the site loads them in the page's locale.
8
12
  */
9
- export async function resolveCanvasLayout(layout, context, api, definitions, resolveLink, locale) {
10
- const bound = context ? resolveBindings(layout, context, definitions, { url: urlResolver(resolveLink) }) : layout;
13
+ export async function resolveCanvasLayout(layout, context, api, definitions, resolveLink, locale, relations) {
14
+ const fetchDocs = createRestFetchDocs(api, locale);
15
+ // Live saved sections: their current blocks, shown as repeats (not editable here).
16
+ const withSections = await attachSections(layout, definitions, fetchDocs);
17
+ const bound = context
18
+ ? resolveBindings(withSections, context, definitions, { url: urlResolver(resolveLink), ...(relations ? { relations } : {}) })
19
+ : withSections;
11
20
  const queries = listQueries(bound, context);
12
- const lists = await Promise.all(queries.map((query) => fetchListItems(api, query, locale)));
13
- const withItems = attachListItems(bound, new Map(queries.map((query, i) => [query.blockId, lists[i]])));
14
- return resolveLayoutData(withItems, definitions, createRestFetchDocs(api, locale));
21
+ const lists = await Promise.all(queries.map((query) => fetchListPage(api, query, locale, CANVAS_SEED)));
22
+ // A paginated list shows page 1 with its page links.
23
+ const pages = new Map(queries.flatMap((query, i) => (query.page ? [[query.blockId, pageLinks(null, query.page, lists[i].totalPages, query.pageParam)]] : [])));
24
+ const withItems = withPageParams(attachListItems(bound, new Map(queries.map((query, i) => [query.blockId, lists[i].docs])), pages), queries);
25
+ return resolveLayoutData(withItems, definitions, fetchDocs);
15
26
  }
@@ -21,6 +21,11 @@ export type ServerBlocks = {
21
21
  subscribe(key: string, listener: () => void): () => void;
22
22
  /** A mounted block needs the render of this stored block. Returns the release function. */
23
23
  want(key: string, block: Block): () => void;
24
+ /**
25
+ * Data the server output may read changed (a document saved in the editor): forget every
26
+ * result and ask again for the mounted blocks. They keep their output on screen meanwhile.
27
+ */
28
+ refresh(): void;
24
29
  setScope(scope: CanvasScope): void;
25
30
  scope(): CanvasScope;
26
31
  /** Loads the page data for the current scope. */
@@ -42,6 +47,12 @@ export type ServerBlocksOptions = {
42
47
  label?: (type: string) => string;
43
48
  onError?: (message: string) => void;
44
49
  };
50
+ /**
51
+ * A block subtree without its animation settings, at every depth. The server preview never
52
+ * renders them (the canvas puts them on the output itself), so a change in the Motion tab does
53
+ * not ask the server again.
54
+ */
55
+ export declare function withoutMotion(block: Block): Block;
45
56
  export declare function createServerBlocks(server: CanvasServer, options?: ServerBlocksOptions): ServerBlocks;
46
57
  /** The server's result as an entry. */
47
58
  export declare function entryOf(result: {
@@ -5,6 +5,17 @@
5
5
  export const SERVER_BLOCK_ATTRIBUTE = 'data-builder-server-block';
6
6
  const message = (error) => (error instanceof Error ? error.message : String(error));
7
7
  const EMPTY_SCOPE = { document: null, context: null };
8
+ /**
9
+ * A block subtree without its animation settings, at every depth. The server preview never
10
+ * renders them (the canvas puts them on the output itself), so a change in the Motion tab does
11
+ * not ask the server again.
12
+ */
13
+ export function withoutMotion(block) {
14
+ const { motion: _motion, slots, ...rest } = block;
15
+ if (!slots)
16
+ return rest;
17
+ return { ...rest, slots: Object.fromEntries(Object.entries(slots).map(([name, list]) => [name, list.map(withoutMotion)])) };
18
+ }
8
19
  export function createServerBlocks(server, options = {}) {
9
20
  const debounceMs = options.debounceMs ?? 250;
10
21
  const maxWaitMs = options.maxWaitMs ?? 1000;
@@ -107,7 +118,7 @@ export function createServerBlocks(server, options = {}) {
107
118
  keyOf(block) {
108
119
  let subtree = subtreeKeys.get(block);
109
120
  if (subtree === undefined) {
110
- subtree = JSON.stringify(block);
121
+ subtree = JSON.stringify(withoutMotion(block));
111
122
  subtreeKeys.set(block, subtree);
112
123
  }
113
124
  return `${scopeKey}\u0000${subtree}`;
@@ -145,6 +156,22 @@ export function createServerBlocks(server, options = {}) {
145
156
  wanted.set(key, { ...now, count: now.count - 1 });
146
157
  };
147
158
  },
159
+ refresh() {
160
+ for (const key of entries.keys()) {
161
+ if (entries.get(key)?.status !== 'pending')
162
+ entries.delete(key);
163
+ }
164
+ // A key already on its way is asked again after its answer: that answer may predate the change.
165
+ for (const key of wanted.keys()) {
166
+ queue.add(key);
167
+ if (entries.has(key))
168
+ continue;
169
+ entries.set(key, { status: 'pending' });
170
+ notify(key);
171
+ }
172
+ if (queue.size > 0)
173
+ schedule();
174
+ },
148
175
  setScope(next) {
149
176
  const nextKey = JSON.stringify(next);
150
177
  if (nextKey === scopeKey)
@@ -1,3 +1,12 @@
1
+ import { type ComponentType } from 'react';
1
2
  import type { BlockComponentProps } from '../render/types.js';
2
- /** An `<a>` when the link resolves to an href, otherwise a `<span>`. */
3
- export declare function Button({ props, className, attributes, mode }: BlockComponentProps): import("react").JSX.Element | null;
3
+ import type { IconMap } from './builtins/Icon.js';
4
+ /** An `<a>` when the link resolves to an href, otherwise a `<span>`. Icon props are ignored. */
5
+ export declare function Button(props: BlockComponentProps): import("react").JSX.Element | null;
6
+ /**
7
+ * The `button` block's component for a site with an icon set: the `icon` prop
8
+ * (`defaultBlocks({ icons })`) draws that icon before or after the label (`iconPosition`), with
9
+ * the `iconClassName` classes. The icon is decoration: the label names the button.
10
+ * `builtinComponents({ icons })` includes it. One component per map.
11
+ */
12
+ export declare function buttonComponent(icons: IconMap): ComponentType<BlockComponentProps>;
@@ -1,16 +1,53 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createElement } from 'react';
2
3
  import { editableText } from '../render/editable.js';
3
4
  import { linkAttributes } from '../render/link.js';
4
5
  import { asText, PlaceholderText } from './placeholder.js';
5
- /** An `<a>` when the link resolves to an href, otherwise a `<span>`. */
6
- export function Button({ props, className, attributes, mode }) {
6
+ /** An `<a>` when the link resolves to an href, otherwise a `<span>`. Icon props are ignored. */
7
+ export function Button(props) {
8
+ return renderButton(props);
9
+ }
10
+ function renderButton({ props, className, attributes, mode }, icons) {
7
11
  const label = asText(props.label);
8
12
  if (!label && mode !== 'canvas')
9
13
  return null;
10
- const content = label || _jsx(PlaceholderText, { children: "Button" });
14
+ const text = label || _jsx(PlaceholderText, { children: "Button" });
11
15
  const link = linkAttributes(props.link);
16
+ const name = asText(props.icon);
17
+ const glyph = icons && name && Object.hasOwn(icons, name) ? icons[name] : undefined;
18
+ // Without an icon the label is the element's only content, as in 0.3.0. With one, the label
19
+ // gets its own span, so inline editing on the canvas edits the text and not the icon.
20
+ let content = text;
21
+ let editable = editableText(mode, 'label');
22
+ if (glyph) {
23
+ const icon = createElement(glyph, {
24
+ 'aria-hidden': true,
25
+ focusable: 'false',
26
+ className: asText(props.iconClassName) || undefined,
27
+ });
28
+ const labelSpan = _jsx("span", { ...editable, children: text });
29
+ content = props.iconPosition === 'start' ? _jsxs(_Fragment, { children: [icon, labelSpan] }) : _jsxs(_Fragment, { children: [labelSpan, icon] });
30
+ editable = {};
31
+ }
12
32
  if (!link) {
13
- return (_jsx("span", { ...attributes, ...editableText(mode, 'label'), className: className, children: content }));
33
+ return (_jsx("span", { ...attributes, ...editable, className: className, children: content }));
34
+ }
35
+ return (_jsx("a", { ...attributes, ...editable, ...link, className: className, children: content }));
36
+ }
37
+ const byMap = new WeakMap();
38
+ /**
39
+ * The `button` block's component for a site with an icon set: the `icon` prop
40
+ * (`defaultBlocks({ icons })`) draws that icon before or after the label (`iconPosition`), with
41
+ * the `iconClassName` classes. The icon is decoration: the label names the button.
42
+ * `builtinComponents({ icons })` includes it. One component per map.
43
+ */
44
+ export function buttonComponent(icons) {
45
+ const known = byMap.get(icons);
46
+ if (known)
47
+ return known;
48
+ function IconButton(props) {
49
+ return renderButton(props, icons);
14
50
  }
15
- return (_jsx("a", { ...attributes, ...editableText(mode, 'label'), ...link, className: className, children: content }));
51
+ byMap.set(icons, IconButton);
52
+ return IconButton;
16
53
  }
@@ -1,6 +1,9 @@
1
1
  import type { BlockComponentProps } from '../render/types.js';
2
2
  /**
3
- * The collection list block. RenderLayout renders the `item` slot once per document; this
4
- * component only wraps the items. Nothing on the site when the list is empty.
3
+ * The collection list and repeat blocks. RenderLayout renders the `item` slot once per document or
4
+ * row; this component only wraps the items. A collection list without documents shows its `empty`
5
+ * slot instead. Nothing on the site when both are empty. A repeat with `as: 'none'` has no wrapper:
6
+ * its rows sit in the parent. The canvas keeps an element with `display: contents` there, so the
7
+ * editor can still find and measure the repeat.
5
8
  */
6
- export declare function CollectionList({ className, attributes, slots, slotAttributes, mode }: BlockComponentProps): import("react").JSX.Element | null;
9
+ export declare function CollectionList({ block, props, className, attributes, slots, slotAttributes, mode }: BlockComponentProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
@@ -1,12 +1,26 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { LIST_ITEM_SLOT } from '../../core/index.js';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createElement, Fragment } from 'react';
3
+ import { LIST_EMPTY_SLOT, LIST_ITEM_SLOT, REPEAT_BLOCK } from '../../core/index.js';
4
+ import { LIST_PAGES_PROP } from '../render/lists.js';
5
+ import { asText } from './placeholder.js';
6
+ const CONTENTS = { display: 'contents' };
3
7
  /**
4
- * The collection list block. RenderLayout renders the `item` slot once per document; this
5
- * component only wraps the items. Nothing on the site when the list is empty.
8
+ * The collection list and repeat blocks. RenderLayout renders the `item` slot once per document or
9
+ * row; this component only wraps the items. A collection list without documents shows its `empty`
10
+ * slot instead. Nothing on the site when both are empty. A repeat with `as: 'none'` has no wrapper:
11
+ * its rows sit in the parent. The canvas keeps an element with `display: contents` there, so the
12
+ * editor can still find and measure the repeat.
6
13
  */
7
- export function CollectionList({ className, attributes, slots, slotAttributes, mode }) {
14
+ export function CollectionList({ block, props, className, attributes, slots, slotAttributes, mode }) {
8
15
  const items = slots[LIST_ITEM_SLOT];
9
- if (!items && mode !== 'canvas')
16
+ const empty = slots[LIST_EMPTY_SLOT];
17
+ if (!items && !empty && mode !== 'canvas')
10
18
  return null;
11
- return (_jsx("div", { ...attributes, ...slotAttributes[LIST_ITEM_SLOT], className: className, children: items }));
19
+ if (block.type === REPEAT_BLOCK && props.as === 'none') {
20
+ if (mode !== 'canvas')
21
+ return items;
22
+ return createElement('div', { ...attributes, ...slotAttributes[LIST_ITEM_SLOT], style: CONTENTS }, items);
23
+ }
24
+ const pages = props[LIST_PAGES_PROP];
25
+ return (_jsxs("div", { ...attributes, ...slotAttributes[LIST_ITEM_SLOT], className: className, children: [items, empty && _jsx("div", { ...slotAttributes[LIST_EMPTY_SLOT], children: empty }), pages && pages.links.length > 1 && (_jsx("nav", { "aria-label": asText(props.pagerLabel).trim() || 'Pages', className: typeof props.pagerClassName === 'string' ? props.pagerClassName : undefined, children: pages.links.map((link) => (_jsxs(Fragment, { children: [link.gapBefore && _jsx("span", { "data-page-gap": "", "aria-hidden": "true", children: "\u2026" }), _jsx("a", { href: link.href, "aria-current": link.current ? 'page' : undefined, className: typeof props.pageLinkClassName === 'string' ? props.pageLinkClassName : undefined, children: link.page })] }, link.page))) }))] }));
12
26
  }
@@ -1,5 +1,8 @@
1
1
  import { createElement } from 'react';
2
- const TAGS = new Set(['div', 'section', 'header', 'footer', 'main', 'nav', 'article', 'aside']);
2
+ const TAGS = new Set([
3
+ 'div', 'section', 'header', 'footer', 'main', 'nav', 'article', 'aside',
4
+ 'ol', 'ul', 'li', 'dl', 'dt', 'dd', 'figure', 'figcaption', 'p', 'span',
5
+ ]);
3
6
  /** Used for `stack` and `grid`. All layout comes from `className`. `as` picks the HTML tag. */
4
7
  export function Container({ props, className, attributes, slotAttributes, slots }) {
5
8
  const tag = typeof props.as === 'string' && TAGS.has(props.as) ? props.as : 'div';
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // The Field block: one field of the current document, rendered by the value's type.
3
3
  import { FIELD_CLASS_MAP } from '../../blocks/index.js';
4
- import { FIELD_VALUE_PROP, formatDate, isIsoDate, isMissing, isRichText, isUploadDoc, titleOf, toPlainText, } from '../../core/index.js';
4
+ import { FIELD_VALUE_PROP, formatBindingValue, formatDate, isIsoDate, isMissing, isRichText, isUploadDoc, titleOf, toPlainText, } from '../../core/index.js';
5
5
  import { defaultResolveLink } from '../render/link.js';
6
6
  import { asText, PlaceholderText } from './placeholder.js';
7
7
  import { renderRichText } from './RichText.js';
@@ -29,8 +29,19 @@ function createField(resolveLink) {
29
29
  const path = asText(props.path);
30
30
  return (_jsx("div", { ...attributes, className: className, children: _jsx(PlaceholderText, { children: path ? `{${path}}` : 'Field' }) }));
31
31
  }
32
+ // `format`: a binding formatter such as "currency:AUD" or "date:en-AU". Rich text and uploads keep their own rendering.
33
+ const format = asText(props.format);
34
+ if (format && !isRichText(value) && !isUploadDoc(value)) {
35
+ const formatted = formatBindingValue(value, format);
36
+ if (formatted !== undefined) {
37
+ if (isIsoDate(value)) {
38
+ return (_jsx("time", { ...attributes, className: className, dateTime: value, children: formatted }));
39
+ }
40
+ return _jsx("div", { ...attributes, className: className, children: lines(formatted) });
41
+ }
42
+ }
32
43
  if (isRichText(value)) {
33
- return _jsx("div", { ...attributes, className: richTextClass(className), children: renderRichText(value, resolveLink) });
44
+ return (_jsx("div", { ...attributes, className: richTextClass(className), children: renderRichText(value, resolveLink, { headingIds: props.headingIds === true }) }));
34
45
  }
35
46
  if (isUploadDoc(value)) {
36
47
  if (!isImage(value)) {
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createElement } from 'react';
3
3
  import { editableText } from '../render/editable.js';
4
4
  import { asText, PlaceholderText } from './placeholder.js';
@@ -8,10 +8,17 @@ function toTag(level) {
8
8
  return 'h2';
9
9
  return `h${n}`;
10
10
  }
11
+ /** The text with the first `accent` phrase in `<em>`. The plain text when the phrase is not in it. */
12
+ function withAccent(text, accent) {
13
+ const at = accent ? text.indexOf(accent) : -1;
14
+ if (!accent || at < 0)
15
+ return text;
16
+ return (_jsxs(_Fragment, { children: [text.slice(0, at), _jsx("em", { children: accent }), text.slice(at + accent.length)] }));
17
+ }
11
18
  export function Heading({ props, className, attributes, mode }) {
12
19
  const text = asText(props.text);
13
20
  if (!text && mode !== 'canvas')
14
21
  return null;
15
- const content = text || _jsx(PlaceholderText, { children: "Heading" });
22
+ const content = text ? withAccent(text, asText(props.accent)?.trim()) : _jsx(PlaceholderText, { children: "Heading" });
16
23
  return createElement(toTag(props.level), { ...attributes, ...editableText(mode, 'text'), className }, content);
17
24
  }
@@ -1,5 +1,14 @@
1
1
  import type { BlockComponentProps } from '../render/types.js';
2
2
  export declare function isDoc(value: unknown): value is Record<string, unknown>;
3
+ /**
4
+ * The media focal point (Payload's `focalX`/`focalY`, percent) as `object-position`, so a cropped
5
+ * image keeps its subject. Payload's default 50/50 counts as unset: it is the browser's own
6
+ * position too, and leaving it out lets an `object-position` class (`object-top`) set the crop.
7
+ * Limit: an editor's focal point of exactly 50/50 loses to such a class.
8
+ */
9
+ export declare function focalStyle(doc: Record<string, unknown> | null | undefined): {
10
+ objectPosition: string;
11
+ } | undefined;
3
12
  /**
4
13
  * `srcset` from Payload's image sizes (`doc.sizes`) plus the original. Only sizes with the
5
14
  * original's aspect ratio count (a square crop would distort the image). Undefined when there
@@ -6,6 +6,19 @@ export function isDoc(value) {
6
6
  }
7
7
  const asString = (value) => typeof value === 'string' && value ? value : undefined;
8
8
  const asNumber = (value) => typeof value === 'number' ? value : undefined;
9
+ /**
10
+ * The media focal point (Payload's `focalX`/`focalY`, percent) as `object-position`, so a cropped
11
+ * image keeps its subject. Payload's default 50/50 counts as unset: it is the browser's own
12
+ * position too, and leaving it out lets an `object-position` class (`object-top`) set the crop.
13
+ * Limit: an editor's focal point of exactly 50/50 loses to such a class.
14
+ */
15
+ export function focalStyle(doc) {
16
+ const x = asNumber(doc?.focalX);
17
+ const y = asNumber(doc?.focalY);
18
+ if (x === undefined || y === undefined || (x === 50 && y === 50))
19
+ return undefined;
20
+ return { objectPosition: `${x}% ${y}%` };
21
+ }
9
22
  /**
10
23
  * `srcset` from Payload's image sizes (`doc.sizes`) plus the original. Only sizes with the
11
24
  * original's aspect ratio count (a square crop would distort the image). Undefined when there
@@ -49,5 +62,7 @@ export function Image({ props, className, attributes, mode }) {
49
62
  return _jsx(PlaceholderBox, { attributes: { ...attributes, ...editableImage(mode, 'image') }, className: className, label: "Image" });
50
63
  }
51
64
  const srcSet = srcSetOf(doc);
52
- return (_jsx("img", { ...attributes, ...editableImage(mode, 'image'), className: className, src: doc.url, ...(srcSet ? { srcSet, sizes: 'auto, 100vw' } : {}), alt: asString(props.alt) ?? asString(doc.alt) ?? '', width: asNumber(doc.width), height: asNumber(doc.height), loading: "lazy" }));
65
+ const priority = props.priority === true;
66
+ const sizes = asString(props.sizes)?.trim();
67
+ return (_jsx("img", { ...attributes, ...editableImage(mode, 'image'), className: className, src: doc.url, ...(srcSet ? { srcSet, sizes: sizes || (priority ? '100vw' : 'auto, 100vw') } : {}), alt: asString(props.alt) ?? asString(doc.alt) ?? '', width: asNumber(doc.width), height: asNumber(doc.height), style: focalStyle(doc), loading: priority ? 'eager' : 'lazy', ...(priority ? { fetchPriority: 'high' } : {}) }));
53
68
  }
@@ -18,5 +18,6 @@ export declare function List({ block, props, className, attributes, slots, slotA
18
18
  /**
19
19
  * One `<li>` of a list. Its text is edited in place on the canvas; Enter adds the next item and
20
20
  * Backspace at the start joins it to the item before. An empty item renders nothing on the site.
21
+ * With a `link` that resolves to an href, the text sits in an `<a>` inside the `<li>`.
21
22
  */
22
23
  export declare function ListItem({ props, className, attributes, mode }: BlockComponentProps): import("react").JSX.Element | null;
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createElement } from 'react';
3
3
  import { TEXT_LIST_SLOT } from '../../core/index.js';
4
4
  import { editableText } from '../render/editable.js';
5
+ import { linkAttributes } from '../render/link.js';
5
6
  import { asText, PlaceholderText } from './placeholder.js';
6
7
  const isItem = (value) => typeof value === 'object' && value !== null;
7
8
  /**
@@ -48,10 +49,15 @@ export function List({ block, props, className, attributes, slots, slotAttribute
48
49
  /**
49
50
  * One `<li>` of a list. Its text is edited in place on the canvas; Enter adds the next item and
50
51
  * Backspace at the start joins it to the item before. An empty item renders nothing on the site.
52
+ * With a `link` that resolves to an href, the text sits in an `<a>` inside the `<li>`.
51
53
  */
52
54
  export function ListItem({ props, className, attributes, mode }) {
53
55
  const text = asText(props.text);
54
56
  if (text === '' && mode !== 'canvas')
55
57
  return null;
58
+ const link = linkAttributes(props.link);
59
+ if (link) {
60
+ return (_jsx("li", { ...attributes, className: className, children: _jsx("a", { ...link, ...editableText(mode, 'text'), children: text === '' ? _jsx(PlaceholderText, { children: "List item" }) : text }) }));
61
+ }
56
62
  return (_jsx("li", { ...attributes, className: className, ...editableText(mode, 'text'), children: text === '' ? _jsx(PlaceholderText, { children: "List item" }) : text }));
57
63
  }
@@ -1,4 +1,20 @@
1
+ import { type LinkAttributes } from '../render/link.js';
1
2
  import type { BlockComponentProps } from '../render/types.js';
3
+ /** `path` is the row's prop path: the canvas edits `<path>.label` (`items.2.label`, `items.2.children.0.label`). */
4
+ type Item = {
5
+ key: string;
6
+ path: string;
7
+ label: string;
8
+ link: LinkAttributes | null;
9
+ children: Item[];
10
+ };
11
+ /** `page` for the current page, `true` for a parent whose child is the current page. */
12
+ type Current = 'page' | 'true' | undefined;
2
13
  /** True when `href` points at the current page, or at a section the page is in ("/blog" on "/blog/a-post"). */
3
14
  export declare function isCurrentLink(href: string, pathname: string | null, origin?: string): boolean;
15
+ /** The menu rows. The top level reads one level of `children`; deeper levels are ignored. */
16
+ export declare function toItems(value: unknown, path?: string, depth?: number): Item[];
17
+ /** `aria-current` of a menu row: `page` for the current page, `true` for a parent whose child is the current page. */
18
+ export declare function currentOf(item: Item, pathname: string | null, origin?: string): Current;
4
19
  export declare function Menu({ props, className, attributes, mode }: BlockComponentProps): import("react").JSX.Element | null;
20
+ export {};
@@ -5,11 +5,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  // <details> opens and closes without JavaScript, so the menu works before (and without) hydration.
6
6
  // JavaScript adds: Escape closes, a click outside closes, and the current page link gets
7
7
  // aria-current. An optional button (`ctaLabel` and `cta`) is the last row of the panel. Inner classes come from MENU_CLASS_MAP, which the block definition lists in `classes`.
8
+ // An item with `children` (one level) is a dropdown: a <details> in the inline list, beside the
9
+ // item's own link or in its place, and a nested list in the panel. Escape, a click outside and
10
+ // focus leaving close an open dropdown; opening one closes the others.
8
11
  import { useEffect, useRef, useSyncExternalStore } from 'react';
9
12
  import { MENU_CLASS_MAP as C } from '../../blocks/index.js';
10
13
  import { editableText } from '../render/editable.js';
11
14
  import { linkAttributes } from '../render/link.js';
12
15
  import { asText, PlaceholderText } from './placeholder.js';
16
+ /** The dropdowns of the inline list. */
17
+ const SUBMENU = 'li > details';
13
18
  const subscribe = (onChange) => {
14
19
  window.addEventListener('popstate', onChange);
15
20
  return () => window.removeEventListener('popstate', onChange);
@@ -39,45 +44,68 @@ export function isCurrentLink(href, pathname, origin) {
39
44
  return true;
40
45
  return target !== '/' && current.startsWith(`${target}/`);
41
46
  }
42
- function toItems(value) {
47
+ /** The menu rows. The top level reads one level of `children`; deeper levels are ignored. */
48
+ export function toItems(value, path = 'items', depth = 0) {
43
49
  if (!Array.isArray(value))
44
50
  return [];
45
51
  return value.flatMap((row, i) => {
46
52
  if (typeof row !== 'object' || row === null)
47
53
  return [];
48
- const { id, label, link } = row;
54
+ const { id, label, link, children } = row;
49
55
  const text = asText(label);
50
56
  if (!text)
51
57
  return [];
52
- return [{ key: typeof id === 'string' ? id : String(i), index: i, label: text, link: linkAttributes(link) }];
58
+ const rowPath = `${path}.${i}`;
59
+ return [
60
+ {
61
+ key: typeof id === 'string' ? id : String(i),
62
+ path: rowPath,
63
+ label: text,
64
+ link: linkAttributes(link),
65
+ children: depth === 0 ? toItems(children, `${rowPath}.children`, 1) : [],
66
+ },
67
+ ];
53
68
  });
54
69
  }
55
70
  function MenuLink({ item, className, current, mode }) {
56
- const editable = editableText(mode, `items.${item.index}.label`);
71
+ const editable = editableText(mode, `${item.path}.label`);
57
72
  if (!item.link) {
58
73
  return (_jsx("span", { ...editable, className: className, children: item.label }));
59
74
  }
60
- return (_jsx("a", { ...item.link, ...editable, className: className, "aria-current": current ? 'page' : undefined, children: item.label }));
75
+ return (_jsx("a", { ...item.link, ...editable, className: className, "aria-current": current, children: item.label }));
61
76
  }
62
77
  function Icon({ className, open }) {
63
78
  return (_jsx("svg", { className: className, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", "aria-hidden": "true", children: open ? _jsx("path", { d: "M5 5l10 10M15 5L5 15" }) : _jsx("path", { d: "M3 6h14M3 10h14M3 14h14" }) }));
64
79
  }
80
+ function Chevron({ className }) {
81
+ return (_jsx("svg", { className: className, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M4 6l4 4 4-4" }) }));
82
+ }
83
+ /** `aria-current` of a menu row: `page` for the current page, `true` for a parent whose child is the current page. */
84
+ export function currentOf(item, pathname, origin) {
85
+ const is = (row) => (row.link ? isCurrentLink(row.link.href, pathname, origin) : false);
86
+ if (is(item))
87
+ return 'page';
88
+ return item.children.some(is) ? 'true' : undefined;
89
+ }
65
90
  export function Menu({ props, className, attributes, mode }) {
66
91
  const items = toItems(props.items);
67
92
  const collapse = props.collapse === 'lg' || props.collapse === 'never' ? props.collapse : 'md';
68
93
  const label = asText(props.label) || 'Main';
94
+ const submenuLabel = asText(props.submenuLabel) || '{label} menu';
69
95
  // The panel button needs a label and a link; without both it is not shown.
70
96
  const ctaLink = linkAttributes(props.cta);
71
97
  const ctaLabel = asText(props.ctaLabel);
72
98
  const cta = ctaLink && ctaLabel ? { link: ctaLink, label: ctaLabel } : null;
73
99
  const pathname = useSyncExternalStore(subscribe, clientPath, serverPath);
74
100
  const origin = pathname === null ? undefined : window.location.origin;
75
- const details = useRef(null);
101
+ const nav = useRef(null);
102
+ // The panel and the dropdowns. Escape closes the one that holds the focus and focuses its
103
+ // toggle. A click outside closes them all.
76
104
  useEffect(() => {
77
- const element = details.current;
78
- if (!element)
105
+ const root = nav.current;
106
+ if (!root)
79
107
  return;
80
- const close = (focusToggle) => {
108
+ const close = (element, focusToggle) => {
81
109
  if (!element.open)
82
110
  return;
83
111
  element.open = false;
@@ -85,26 +113,62 @@ export function Menu({ props, className, attributes, mode }) {
85
113
  element.querySelector('summary')?.focus();
86
114
  };
87
115
  const onKeyDown = (event) => {
88
- if (event.key === 'Escape')
89
- close(true);
116
+ if (event.key !== 'Escape' || !(event.target instanceof Element))
117
+ return;
118
+ const open = event.target.closest('details[open]');
119
+ if (open instanceof HTMLDetailsElement && root.contains(open))
120
+ close(open, true);
90
121
  };
91
122
  const onPointerDown = (event) => {
92
- if (event.target instanceof Node && !element.contains(event.target))
93
- close(false);
123
+ if (!(event.target instanceof Node))
124
+ return;
125
+ for (const element of root.querySelectorAll('details'))
126
+ if (!element.contains(event.target))
127
+ close(element, false);
128
+ };
129
+ // A dropdown closes when the focus leaves it.
130
+ const onFocusOut = (event) => {
131
+ const dropdown = event.target instanceof Element ? event.target.closest(SUBMENU) : null;
132
+ if (!(dropdown instanceof HTMLDetailsElement))
133
+ return;
134
+ if (event.relatedTarget instanceof Node && dropdown.contains(event.relatedTarget))
135
+ return;
136
+ close(dropdown, false);
94
137
  };
95
- element.addEventListener('keydown', onKeyDown);
138
+ // Opening a dropdown closes the others. `toggle` does not bubble, so listen while it captures.
139
+ const onToggle = (event) => {
140
+ const opened = event.target;
141
+ if (!(opened instanceof HTMLDetailsElement) || !opened.open || !opened.matches(SUBMENU))
142
+ return;
143
+ for (const element of root.querySelectorAll(SUBMENU))
144
+ if (element !== opened)
145
+ close(element, false);
146
+ };
147
+ root.addEventListener('keydown', onKeyDown);
148
+ root.addEventListener('focusout', onFocusOut);
149
+ root.addEventListener('toggle', onToggle, true);
96
150
  document.addEventListener('pointerdown', onPointerDown);
97
151
  return () => {
98
- element.removeEventListener('keydown', onKeyDown);
152
+ root.removeEventListener('keydown', onKeyDown);
153
+ root.removeEventListener('focusout', onFocusOut);
154
+ root.removeEventListener('toggle', onToggle, true);
99
155
  document.removeEventListener('pointerdown', onPointerDown);
100
156
  };
101
157
  }, []);
102
158
  if (items.length === 0) {
103
159
  if (mode !== 'canvas')
104
160
  return null;
105
- return (_jsx("nav", { ...attributes, "aria-label": label, className: className, children: _jsx(PlaceholderText, { children: "Menu: add links in the Content tab" }) }));
161
+ return (_jsx("nav", { ...attributes, ref: nav, "aria-label": label, className: className, children: _jsx(PlaceholderText, { children: "Menu: add links in the Content tab" }) }));
106
162
  }
107
- const current = (item) => (item.link ? isCurrentLink(item.link.href, pathname, origin) : false);
108
- const list = (linkClass) => items.map((item) => (_jsx("li", { children: _jsx(MenuLink, { item: item, className: linkClass, current: current(item), mode: mode }) }, item.key)));
109
- return (_jsxs("nav", { ...attributes, "aria-label": label, className: className, children: [_jsx("ul", { role: "list", className: C.list[collapse], children: list(C.link) }), collapse === 'never' ? null : (_jsxs("details", { ref: details, className: `group ${C.toggleWrap[collapse]}`, children: [_jsxs("summary", { className: C.toggle, children: [_jsx("span", { children: "Menu" }), _jsx(Icon, { className: C.iconOpen, open: false }), _jsx(Icon, { className: C.iconClose, open: true })] }), _jsx("div", { className: C.panel, children: _jsxs("ul", { className: C.panelList, children: [items.map((item) => (_jsx("li", { children: _jsx(MenuLink, { item: item, className: C.panelLink, current: current(item), mode: mode }) }, item.key))), cta ? (_jsx("li", { children: _jsx("a", { ...cta.link, ...editableText(mode, 'ctaLabel'), className: C.panelCta, children: cta.label }) })) : null] }) })] }))] }));
163
+ const current = (item) => currentOf(item, pathname, origin);
164
+ const childList = (item, listClass, linkClass) => (_jsx("ul", { className: listClass, children: item.children.map((child) => (_jsx("li", { children: _jsx(MenuLink, { item: child, className: linkClass, current: current(child), mode: mode }) }, child.key))) }));
165
+ const list = (linkClass) => items.map((item) => {
166
+ if (item.children.length === 0) {
167
+ return (_jsx("li", { children: _jsx(MenuLink, { item: item, className: linkClass, current: current(item), mode: mode }) }, item.key));
168
+ }
169
+ // With its own link: the link and a small toggle beside it, named by `submenuLabel`.
170
+ // Without one: the label is the toggle.
171
+ return (_jsxs("li", { className: C.submenu, children: [item.link ? _jsx(MenuLink, { item: item, className: linkClass, current: current(item), mode: mode }) : null, _jsxs("details", { className: C.submenuDetails, children: [_jsxs("summary", { className: C.submenuToggle, "aria-label": item.link ? submenuLabel.replaceAll('{label}', item.label) : undefined, "aria-current": item.link ? undefined : current(item), children: [item.link ? null : _jsx("span", { ...editableText(mode, `${item.path}.label`), children: item.label }), _jsx(Chevron, { className: C.submenuIcon })] }), childList(item, C.submenuList, C.submenuLink)] })] }, item.key));
172
+ });
173
+ return (_jsxs("nav", { ...attributes, ref: nav, "aria-label": label, className: className, children: [_jsx("ul", { role: "list", className: C.list[collapse], children: list(C.link) }), collapse === 'never' ? null : (_jsxs("details", { className: `group ${C.toggleWrap[collapse]}`, children: [_jsxs("summary", { className: C.toggle, children: [_jsx("span", { children: asText(props.toggleLabel) || 'Menu' }), _jsx(Icon, { className: C.iconOpen, open: false }), _jsx(Icon, { className: C.iconClose, open: true })] }), _jsx("div", { className: C.panel, children: _jsxs("ul", { className: C.panelList, children: [items.map((item) => (_jsxs("li", { children: [_jsx(MenuLink, { item: item, className: C.panelLink, current: current(item), mode: mode }), item.children.length > 0 ? childList(item, C.panelSubList, C.panelSubLink) : null] }, item.key))), cta ? (_jsx("li", { children: _jsx("a", { ...cta.link, ...editableText(mode, 'ctaLabel'), className: C.panelCta, children: cta.label }) })) : null] }) })] }))] }));
110
174
  }
@@ -1,9 +1,14 @@
1
- import type { ComponentType, ReactNode } from 'react';
1
+ import { type ComponentType, type ReactNode } from 'react';
2
2
  import type { BlockComponentProps, ResolveLink } from '../render/types.js';
3
3
  /** True when the editor holds no text and no non-text node (image, rule, block…). */
4
4
  export declare function isEmptyRichText(value: unknown): boolean;
5
- /** Lexical rich text as React elements, with internal links resolved by `resolveLink`. No wrapper. */
6
- export declare function renderRichText(content: unknown, resolveLink: ResolveLink): ReactNode;
5
+ /**
6
+ * Lexical rich text as React elements, with internal links resolved by `resolveLink`. No wrapper.
7
+ * `headingIds`: each heading gets an id from its text (`richTextHeadings`), for `#id` links.
8
+ */
9
+ export declare function renderRichText(content: unknown, resolveLink: ResolveLink, options?: {
10
+ headingIds?: boolean;
11
+ }): ReactNode;
7
12
  /** One component per resolver, so React keeps the same component type between renders. */
8
13
  export declare function richTextFor(resolveLink: ResolveLink): ComponentType<BlockComponentProps>;
9
14
  /** The rich text component with the default link resolver. */