@astryxdesign/richtext 0.6.5-canary.c3016f8 → 0.6.5-canary.c8d8a1d

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 (38) hide show
  1. package/README.md +3 -2
  2. package/dist/RichTextEditor.d.ts +11 -5
  3. package/dist/RichTextEditor.d.ts.map +1 -1
  4. package/dist/RichTextEditor.js +50 -5
  5. package/dist/RichTextEditorAutoLinkPlugin.d.ts +10 -11
  6. package/dist/RichTextEditorAutoLinkPlugin.d.ts.map +1 -1
  7. package/dist/RichTextEditorAutoLinkPlugin.js +10 -11
  8. package/dist/RichTextEditorToolbar.d.ts.map +1 -1
  9. package/dist/RichTextEditorToolbar.js +2 -3
  10. package/dist/RichTextView.d.ts +9 -4
  11. package/dist/RichTextView.d.ts.map +1 -1
  12. package/dist/RichTextView.js +69 -13
  13. package/dist/editorNodes.d.ts +2 -2
  14. package/dist/editorNodes.d.ts.map +1 -1
  15. package/dist/editorNodes.js +4 -3
  16. package/dist/editorTheme.d.ts.map +1 -1
  17. package/dist/editorTheme.js +15 -0
  18. package/dist/markdownSerializers.d.ts +4 -3
  19. package/dist/markdownSerializers.d.ts.map +1 -1
  20. package/dist/markdownSerializers.js +6 -5
  21. package/dist/markdownTable.d.ts +28 -0
  22. package/dist/markdownTable.d.ts.map +1 -0
  23. package/dist/markdownTable.js +182 -0
  24. package/dist/richtext.css +9 -0
  25. package/package.json +9 -3
  26. package/src/RichTextEditor.doc.mjs +21 -5
  27. package/src/RichTextEditor.test.tsx +420 -18
  28. package/src/RichTextEditor.tsx +63 -12
  29. package/src/RichTextEditorAutoLinkPlugin.tsx +10 -11
  30. package/src/RichTextEditorToolbar.tsx +2 -3
  31. package/src/RichTextView.tsx +72 -12
  32. package/src/__tests__/MarkdownParitySandbox.a11y.chromium.spec.ts +488 -0
  33. package/src/doc-mjs.d.ts +23 -0
  34. package/src/editorNodes.ts +6 -2
  35. package/src/editorTheme.ts +37 -0
  36. package/src/markdownSerializers.ts +9 -8
  37. package/src/markdownTable.test.tsx +197 -0
  38. package/src/markdownTable.ts +243 -0
package/README.md CHANGED
@@ -7,7 +7,7 @@ with Astryx design tokens.
7
7
  import {RichTextEditor, RichTextView} from '@astryxdesign/richtext';
8
8
 
9
9
  <RichTextEditor label="Notes" onChange={setState} />;
10
- <RichTextView label="Notes" value={serializedState} />;
10
+ <RichTextView value={serializedState} />;
11
11
  ```
12
12
 
13
13
  The editor is deliberately minimal and extensible: pass `nodes` and `plugins` to
@@ -27,7 +27,8 @@ It ships to npm **only under the `@canary` dist-tag** — there is never a stabl
27
27
 
28
28
  > Note: this package is the successor to the experimental `RichTextEditor` that
29
29
  > used to live in `@astryxdesign/lab`; that code has moved here so it can be
30
- > canaried independently (e.g. into EPS/Nest) without a fresh package rollout.
30
+ > canaried independently by an adopting application without a fresh package
31
+ > rollout.
31
32
 
32
33
  ## Status
33
34
 
@@ -4,7 +4,8 @@
4
4
  * LexicalExtensionComposer), Field, VisuallyHidden, useInputStatusIcon,
5
5
  * mergeProps, design tokens
6
6
  * @output Exports an accessibly labelled RichTextEditor component with a flush
7
- * top toolbar slot and configurable editable-surface minimum height, RichTextEditorProps,
7
+ * top toolbar slot, configurable editable-surface minimum height, and distinct
8
+ * read-only and disabled states that follow prop changes, RichTextEditorProps,
8
9
  * RichTextEditorStatus, RichTextEditorStatusType, RichTextEditorSize
9
10
  * @position Experimental (richtext) implementation; consumed by the package index.ts and
10
11
  * re-exported from @astryxdesign/richtext. Tested by RichTextEditor.test.tsx.
@@ -107,12 +108,16 @@ export interface RichTextEditorProps extends Omit<BaseProps, 'onChange' | 'defau
107
108
  /** Placeholder text shown when the editor is empty. */
108
109
  placeholder?: string;
109
110
  /**
110
- * Whether the editor is read-only (non-editable).
111
+ * Whether the editor is read-only (non-editable). The content stays at full
112
+ * opacity, in the tab order, and announced as read-only, so people can still
113
+ * reach, read, and copy it. Takes effect when changed after mount.
111
114
  * @default false
112
115
  */
113
116
  isReadOnly?: boolean;
114
117
  /**
115
- * Whether the editor is disabled (non-editable, dimmed).
118
+ * Whether the editor is disabled: non-editable, dimmed, out of the tab
119
+ * order, and announced as disabled. Wins when `isReadOnly` is also set.
120
+ * Takes effect when changed after mount.
116
121
  * @default false
117
122
  */
118
123
  isDisabled?: boolean;
@@ -171,13 +176,14 @@ export interface RichTextEditorProps extends Omit<BaseProps, 'onChange' | 'defau
171
176
  /**
172
177
  * Whether to enable Markdown shortcut typing (e.g. `# ` for a heading,
173
178
  * `- ` for a list). Uses the `transformers` prop (defaults to the standard
174
- * `@lexical/markdown` transformers).
179
+ * `@lexical/markdown` transformers plus GFM tables).
175
180
  * @default true
176
181
  */
177
182
  hasMarkdownShortcuts?: boolean;
178
183
  /**
179
184
  * Markdown transformers — the single source of truth for markdown behaviour.
180
- * Defaults to the standard `@lexical/markdown` `TRANSFORMERS`.
185
+ * Defaults to the standard `@lexical/markdown` `TRANSFORMERS` plus GFM
186
+ * tables. A custom array replaces the default, tables included.
181
187
  *
182
188
  * The same array drives all three markdown operations in Lexical (see the
183
189
  * lexical-playground reference, where one `PLAYGROUND_TRANSFORMERS` array
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../src/RichTextEditor.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AASf,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAyB,KAAK,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAchF,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EASL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK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;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,cAAc,mHAoQzB,CAAC"}
@@ -8,7 +8,8 @@
8
8
  * LexicalExtensionComposer), Field, VisuallyHidden, useInputStatusIcon,
9
9
  * mergeProps, design tokens
10
10
  * @output Exports an accessibly labelled RichTextEditor component with a flush
11
- * top toolbar slot and configurable editable-surface minimum height, RichTextEditorProps,
11
+ * top toolbar slot, configurable editable-surface minimum height, and distinct
12
+ * read-only and disabled states that follow prop changes, RichTextEditorProps,
12
13
  * RichTextEditorStatus, RichTextEditorStatusType, RichTextEditorSize
13
14
  * @position Experimental (richtext) implementation; consumed by the package index.ts and
14
15
  * re-exported from @astryxdesign/richtext. Tested by RichTextEditor.test.tsx.
@@ -46,9 +47,11 @@ import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
46
47
  import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin';
47
48
  import { MarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin';
48
49
  import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
49
- import { TRANSFORMERS, $convertToMarkdownString } from '@lexical/markdown';
50
+ import { TablePlugin } from '@lexical/react/LexicalTablePlugin';
51
+ import { $convertToMarkdownString } from '@lexical/markdown';
50
52
  import { $generateHtmlFromNodes } from '@lexical/html';
51
53
  import { DEFAULT_NODES } from "./editorNodes.js";
54
+ import { DEFAULT_TRANSFORMERS } from "./markdownTable.js";
52
55
  import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, defineExtension, KEY_DOWN_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, mergeRegister } from 'lexical';
53
56
 
54
57
  /**
@@ -214,7 +217,7 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
214
217
  toolbar,
215
218
  plugins,
216
219
  hasMarkdownShortcuts = true,
217
- transformers = TRANSFORMERS,
220
+ transformers = DEFAULT_TRANSFORMERS,
218
221
  hasAutoFocus = false,
219
222
  tabEscapeHint = DEFAULT_TAB_ESCAPE_HINT,
220
223
  maxLength,
@@ -314,7 +317,10 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
314
317
  ...mergeProps(themeProps('rich-text-editor', {
315
318
  size,
316
319
  status: status?.type ?? null
317
- }), stylex.props(inputWrapperStyles.base, styles.wrapper, (isDisabled || isReadOnly) && inputWrapperStyles.disabled, isDisabled && styles.disabled, status && inputStatusBorderStyles[status.type], status && !isDisabled && !isReadOnly && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], xstyle), className, style),
320
+ }), stylex.props(inputWrapperStyles.base, styles.wrapper,
321
+ // Only disabled is dimmed, matching TextArea: a read-only editor
322
+ // keeps full-opacity text and stays keyboard-reachable.
323
+ isDisabled && inputWrapperStyles.disabled, isDisabled && styles.disabled, status && inputStatusBorderStyles[status.type], status && !isDisabled && !isReadOnly && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], xstyle), className, style),
318
324
  children: [/*#__PURE__*/_jsxs(LexicalExtensionComposer, {
319
325
  extension: extensionRef.current,
320
326
  contentEditable: null,
@@ -332,6 +338,8 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
332
338
  ariaDescribedBy: ariaDescribedBy,
333
339
  ariaRequired: isRequired && !isOptional,
334
340
  ariaInvalid: status?.type === 'error',
341
+ isReadOnly: isReadOnly,
342
+ isDisabled: isDisabled,
335
343
  placeholderText: placeholder,
336
344
  placeholderID: placeholderID,
337
345
  minHeight: minHeight,
@@ -339,7 +347,12 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
339
347
  }),
340
348
  placeholder: null,
341
349
  ErrorBoundary: LexicalErrorBoundary
342
- }), /*#__PURE__*/_jsx(HistoryPlugin, {}), /*#__PURE__*/_jsx(ListPlugin, {}), /*#__PURE__*/_jsx(LinkPlugin, {}), /*#__PURE__*/_jsx(TabIndentationPlugin, {}), /*#__PURE__*/_jsx(TabFocusEscapePlugin, {}), hasMarkdownShortcuts && /*#__PURE__*/_jsx(MarkdownShortcutPlugin, {
350
+ }), /*#__PURE__*/_jsx(HistoryPlugin, {}), /*#__PURE__*/_jsx(ListPlugin, {}), /*#__PURE__*/_jsx(LinkPlugin, {}), /*#__PURE__*/_jsx(TablePlugin, {
351
+ hasCellMerge: false,
352
+ hasCellBackgroundColor: false,
353
+ hasTabHandler: false,
354
+ hasHorizontalScroll: true
355
+ }), /*#__PURE__*/_jsx(TabIndentationPlugin, {}), /*#__PURE__*/_jsx(TabFocusEscapePlugin, {}), hasMarkdownShortcuts && /*#__PURE__*/_jsx(MarkdownShortcutPlugin, {
343
356
  transformers: markdownTransformers
344
357
  }), hasAutoFocus && /*#__PURE__*/_jsx(AutoFocusOnMount, {}), onChange && /*#__PURE__*/_jsx(OnChangePlugin, {
345
358
  onChange: onChange,
@@ -468,6 +481,22 @@ function EditorRefBridge({
468
481
  transformers
469
482
  }) {
470
483
  const [editor] = useLexicalComposerContext();
484
+
485
+ // The extension applies `editable` once, when the composer builds the
486
+ // editor, so a later isReadOnly/isDisabled change would leave
487
+ // contenteditable at its mount value while the wrapper styling and ARIA
488
+ // follow the props. Sync the editor on a prop change only: the mount value
489
+ // is already applied, and this bridge renders after `plugins`, so
490
+ // re-asserting it on mount would undo a plugin that set editability during
491
+ // its own mount.
492
+ const syncedEditableRef = useRef(editable);
493
+ useEffect(() => {
494
+ if (syncedEditableRef.current === editable) {
495
+ return;
496
+ }
497
+ syncedEditableRef.current = editable;
498
+ editor.setEditable(editable);
499
+ }, [editor, editable]);
471
500
  useImperativeHandle(editorRef, () => ({
472
501
  focus: () => {
473
502
  if (!editable) {
@@ -541,6 +570,8 @@ function EditorContentEditable({
541
570
  ariaDescribedBy,
542
571
  ariaRequired,
543
572
  ariaInvalid,
573
+ isReadOnly,
574
+ isDisabled,
544
575
  placeholderText,
545
576
  placeholderID,
546
577
  minHeight,
@@ -555,6 +586,20 @@ function EditorContentEditable({
555
586
  'aria-describedby': ariaDescribedBy,
556
587
  'aria-required': ariaRequired ? 'true' : undefined,
557
588
  'aria-invalid': ariaInvalid ? 'true' : undefined,
589
+ // Lexical announces every non-editable surface as aria-readonly and
590
+ // leaves it out of the tab order. Split the two states: read-only stays
591
+ // reachable and is announced read-only; disabled is announced disabled
592
+ // instead. These keys land after Lexical's computed attributes, so the
593
+ // disabled branch's explicit `undefined` removes the wrong read-only
594
+ // announcement. With neither prop set no keys are passed, so a plugin
595
+ // that drives editor.setEditable keeps Lexical's own aria-readonly.
596
+ ...(isDisabled ? {
597
+ 'aria-disabled': 'true',
598
+ 'aria-readonly': undefined
599
+ } : isReadOnly ? {
600
+ tabIndex: 0,
601
+ 'aria-readonly': 'true'
602
+ } : null),
558
603
  ...stylex.props(styles.contentEditable, dynamicStyles.contentEditableMinHeight(minHeight)),
559
604
  ...rest
560
605
  };
@@ -18,22 +18,21 @@
18
18
  * NOTE: Experimental `@astryxdesign/richtext` component (canary). `lexical` and
19
19
  * `@lexical/*` are OPTIONAL peer dependencies — install them to use this.
20
20
  *
21
- * COMPATIBILITY: astryx aims for its RichTextEditor internals to eventually
22
- * back Meta's EPS `EPSRichTextArea` (nest/libs/eps-lexical). EPS's auto-link is
23
- * matcher-driven and applies `target="_blank"` + `rel="noopener noreferrer"` to
24
- * created links (its `NEW_TAB_LINK_ATTRIBUTES`). This plugin uses the same
25
- * matcher shape (`createLinkMatcherWithRegExp` + `attributes`) and the same
26
- * new-tab defaults, so EPS can pass its own richer matcher set (e.g. shortform
27
- * `D123` / `T456` / `S789` intern URLs) through the `matchers` prop without
28
- * changing the contract. EPS ships a hardened fork of the transform itself
29
- * (expanded separators, code-block exclusion) — astryx stays on the OSS
30
- * `AutoLinkPlugin`, and EPS can substitute its own plugin in the same slot.
21
+ * COMPATIBILITY: the plugin is deliberately a thin pass-through so an
22
+ * application with its own link conventions can adopt it without forking. It
23
+ * uses the stock matcher shape (`createLinkMatcherWithRegExp` + `attributes`)
24
+ * and new-tab defaults, so a consumer supplies a richer matcher set — an
25
+ * application-specific identifier or ticket syntax, say — through the
26
+ * `matchers` prop without changing the contract. An application needing a
27
+ * hardened transform (expanded separators, code-block exclusion) substitutes
28
+ * its own plugin in the same slot; astryx stays on the upstream
29
+ * `AutoLinkPlugin`.
31
30
  */
32
31
  import { type LinkMatcher } from '@lexical/react/LexicalAutoLinkPlugin';
33
32
  /**
34
33
  * Attributes written onto every auto-created link so it opens in a new tab.
35
34
  * `rel="noopener noreferrer"` is required whenever `target="_blank"` is set, to
36
- * prevent reverse-tabnabbing. Matches EPS eps-lexical's `NEW_TAB_LINK_ATTRIBUTES`.
35
+ * prevent reverse-tabnabbing.
37
36
  */
38
37
  export declare const NEW_TAB_LINK_ATTRIBUTES: {
39
38
  readonly target: "_blank";
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditorAutoLinkPlugin.d.ts","sourceRoot":"","sources":["../src/RichTextEditorAutoLinkPlugin.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAG9C;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;CAG1B,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAAW,EAc9C,CAAC;AAEF,MAAM,WAAW,iCAAiC;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACjE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,QAAgC,EAChC,QAAQ,GACT,EAAE,iCAAiC,+BAEnC;yBALe,4BAA4B"}
1
+ {"version":3,"file":"RichTextEditorAutoLinkPlugin.d.ts","sourceRoot":"","sources":["../src/RichTextEditorAutoLinkPlugin.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAG9C;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;CAG1B,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAAW,EAc9C,CAAC;AAEF,MAAM,WAAW,iCAAiC;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACjE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,QAAgC,EAChC,QAAQ,GACT,EAAE,iCAAiC,+BAEnC;yBALe,4BAA4B"}
@@ -22,16 +22,15 @@
22
22
  * NOTE: Experimental `@astryxdesign/richtext` component (canary). `lexical` and
23
23
  * `@lexical/*` are OPTIONAL peer dependencies — install them to use this.
24
24
  *
25
- * COMPATIBILITY: astryx aims for its RichTextEditor internals to eventually
26
- * back Meta's EPS `EPSRichTextArea` (nest/libs/eps-lexical). EPS's auto-link is
27
- * matcher-driven and applies `target="_blank"` + `rel="noopener noreferrer"` to
28
- * created links (its `NEW_TAB_LINK_ATTRIBUTES`). This plugin uses the same
29
- * matcher shape (`createLinkMatcherWithRegExp` + `attributes`) and the same
30
- * new-tab defaults, so EPS can pass its own richer matcher set (e.g. shortform
31
- * `D123` / `T456` / `S789` intern URLs) through the `matchers` prop without
32
- * changing the contract. EPS ships a hardened fork of the transform itself
33
- * (expanded separators, code-block exclusion) — astryx stays on the OSS
34
- * `AutoLinkPlugin`, and EPS can substitute its own plugin in the same slot.
25
+ * COMPATIBILITY: the plugin is deliberately a thin pass-through so an
26
+ * application with its own link conventions can adopt it without forking. It
27
+ * uses the stock matcher shape (`createLinkMatcherWithRegExp` + `attributes`)
28
+ * and new-tab defaults, so a consumer supplies a richer matcher set — an
29
+ * application-specific identifier or ticket syntax, say — through the
30
+ * `matchers` prop without changing the contract. An application needing a
31
+ * hardened transform (expanded separators, code-block exclusion) substitutes
32
+ * its own plugin in the same slot; astryx stays on the upstream
33
+ * `AutoLinkPlugin`.
35
34
  */
36
35
  import { AutoLinkPlugin, createLinkMatcherWithRegExp } from '@lexical/react/LexicalAutoLinkPlugin';
37
36
  import { URL_MATCHER, EMAIL_MATCHER, sanitizeUrl } from "./linkUtils.js";
@@ -39,7 +38,7 @@ import { URL_MATCHER, EMAIL_MATCHER, sanitizeUrl } from "./linkUtils.js";
39
38
  /**
40
39
  * Attributes written onto every auto-created link so it opens in a new tab.
41
40
  * `rel="noopener noreferrer"` is required whenever `target="_blank"` is set, to
42
- * prevent reverse-tabnabbing. Matches EPS eps-lexical's `NEW_TAB_LINK_ATTRIBUTES`.
41
+ * prevent reverse-tabnabbing.
43
42
  */
44
43
  import { jsx as _jsx } from "react/jsx-runtime";
45
44
  export const NEW_TAB_LINK_ATTRIBUTES = {
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextEditorToolbar.d.ts","sourceRoot":"","sources":["../src/RichTextEditorToolbar.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAgHf;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAwOX,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IAClD;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,G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5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,KAAyB,EACzB,aAAkC,EAClC,IAAW,EACX,OAAc,EACd,YAAY,EACZ,iBAAwB,EACxB,UAAU,GACX,EAAE,0BAA0B,+BA6d5B;yBAree,qBAAqB"}
@@ -431,9 +431,8 @@ export function RichTextEditorToolbar({
431
431
  setActiveFormats(formats);
432
432
 
433
433
  // Link active state — a link is "active" when the caret/selection anchor
434
- // sits inside a LinkNode (or its immediate parent is one). Mirrors the EPS
435
- // eps-lexical toolbar (`$isLinkNode(parent) || $isLinkNode(node)`), which is
436
- // the implementation astryx aims to be swappable with.
434
+ // sits inside a LinkNode (or its immediate parent is one):
435
+ // `$isLinkNode(parent) || $isLinkNode(node)`.
437
436
  const node = selection.anchor.getNode();
438
437
  const parent = node.getParent();
439
438
  const linkNode = $isLinkNode(node) ? node : $isLinkNode(parent) ? parent : null;
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * @file RichTextView.tsx
3
3
  * @input Uses React, Lexical (lexical + @lexical/react, composed through
4
- * LexicalExtensionComposer), design tokens
4
+ * LexicalExtensionComposer), mergeProps from core utils, design tokens
5
5
  * @output Exports RichTextView component and RichTextViewProps
6
- * @position Read-only renderer for serialized Lexical editor state; experimental
7
- * (richtext), exported from @astryxdesign/richtext
6
+ * @position Read-only renderer for serialized Lexical editor state, exposed to
7
+ * assistive technology as document content rather than a form field;
8
+ * experimental (richtext), exported from @astryxdesign/richtext
8
9
  *
9
10
  * SYNC: When modified, update these files to stay in sync:
10
- * - /packages/richtext/src/RichTextView.test.tsx
11
+ * - /packages/richtext/src/RichTextEditor.test.tsx
11
12
  * - /packages/richtext/src/index.ts
12
13
  * - /apps/storybook/stories/RichTextEditor.stories.tsx
13
14
  */
@@ -52,6 +53,10 @@ export interface RichTextViewProps extends BaseProps {
52
53
  * A read-only renderer for serialized Lexical content. Renders the same styled
53
54
  * output as {@link RichTextEditor} without any editing affordances.
54
55
  *
56
+ * The output is document content, not a form field: headings, lists and links
57
+ * keep their own roles for assistive technology, and the view takes no label.
58
+ * For a labelled, read-only field, use `<RichTextEditor isReadOnly />`.
59
+ *
55
60
  * @example
56
61
  * ```
57
62
  * import {RichTextView} from '@astryxdesign/richtext';
@@ -1 +1 @@
1
- {"version":3,"file":"RichTextView.d.ts","sourceRoot":"","sources":["../src/RichTextView.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAA8B,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAGlE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAWlD,OAAO,KAAK,EAEV,KAAK,EACL,WAAW,EAEZ,MAAM,SAAS,CAAC;AAoBjB,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1C;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAyCD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAyB,EACzB,YAAY,EACZ,aAAoB,EACpB,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,iBAAiB,+BAyFnB;yBApGe,YAAY"}
1
+ {"version":3,"file":"RichTextView.d.ts","sourceRoot":"","sources":["../src/RichTextView.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAA8B,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAGlE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAclD,OAAO,KAAK,EAEV,KAAK,EACL,WAAW,EAEZ,MAAM,SAAS,CAAC;AAkDjB,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1C;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAyCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAyB,EACzB,YAAY,EACZ,aAAoB,EACpB,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,iBAAiB,+BA+GnB;yBA1He,YAAY"}
@@ -5,28 +5,32 @@
5
5
  /**
6
6
  * @file RichTextView.tsx
7
7
  * @input Uses React, Lexical (lexical + @lexical/react, composed through
8
- * LexicalExtensionComposer), design tokens
8
+ * LexicalExtensionComposer), mergeProps from core utils, design tokens
9
9
  * @output Exports RichTextView component and RichTextViewProps
10
- * @position Read-only renderer for serialized Lexical editor state; experimental
11
- * (richtext), exported from @astryxdesign/richtext
10
+ * @position Read-only renderer for serialized Lexical editor state, exposed to
11
+ * assistive technology as document content rather than a form field;
12
+ * experimental (richtext), exported from @astryxdesign/richtext
12
13
  *
13
14
  * SYNC: When modified, update these files to stay in sync:
14
- * - /packages/richtext/src/RichTextView.test.tsx
15
+ * - /packages/richtext/src/RichTextEditor.test.tsx
15
16
  * - /packages/richtext/src/index.ts
16
17
  * - /apps/storybook/stories/RichTextEditor.stories.tsx
17
18
  */
18
19
  import { useEffect, useRef, useState } from 'react';
19
20
  import * as stylex from '@stylexjs/stylex';
20
21
  import { sharedEditorTheme } from "./editorTheme.js";
22
+ import { mergeProps } from '@astryxdesign/core/utils';
21
23
  import { LexicalExtensionComposer } from '@lexical/react/LexicalExtensionComposer';
22
24
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
23
25
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
24
26
  import { ContentEditable } from '@lexical/react/LexicalContentEditable';
25
27
  import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
28
+ import { TablePlugin } from '@lexical/react/LexicalTablePlugin';
26
29
  import { ListNode, ListItemNode } from '@lexical/list';
27
30
  import { HeadingNode, QuoteNode } from '@lexical/rich-text';
28
31
  import { LinkNode, AutoLinkNode } from '@lexical/link';
29
32
  import { CodeNode, CodeHighlightNode } from '@lexical/code';
33
+ import { TableNode, TableRowNode, TableCellNode } from '@lexical/table';
30
34
  import { defineExtension } from 'lexical';
31
35
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
32
36
  const styles = {
@@ -35,7 +39,34 @@ const styles = {
35
39
  $$css: true
36
40
  }
37
41
  };
38
- const DEFAULT_NODES = [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode];
42
+ const DEFAULT_NODES = [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode, TableNode, TableRowNode, TableCellNode];
43
+
44
+ /**
45
+ * Lexical's `ContentEditable` renders `role="textbox"` and widget-only ARIA
46
+ * (`aria-autocomplete`, `aria-readonly`) even when the editor is not editable.
47
+ * A view renders document content, not a form field, so all three are cleared:
48
+ *
49
+ * - A textbox is a widget, so an unnamed one fails axe
50
+ * `aria-input-field-name` — and a view has no name to give, because it is
51
+ * content rather than a labelled input.
52
+ * - The widget role exposes the rendered document to assistive technology
53
+ * as a form field rather than as the content it is.
54
+ * - Widget-only ARIA is invalid without a widget role, so clearing only the
55
+ * role would trade `aria-input-field-name` for `aria-allowed-attr`.
56
+ *
57
+ * `role` must be `null`, not `undefined`: Lexical substitutes its `textbox`
58
+ * default for `undefined`. The ARIA keys reach the element through Lexical's
59
+ * trailing prop spread, which is why `undefined` clears them. A proposed
60
+ * upstream fix (facebook/lexical#9270) would make these overrides no-ops.
61
+ *
62
+ * A caller who wants read-only form-field semantics instead wants
63
+ * `<RichTextEditor isReadOnly />`, which is a labelled field by construction.
64
+ */
65
+ const VIEW_CONTENT_EDITABLE_PROPS = {
66
+ 'aria-autocomplete': undefined,
67
+ 'aria-readonly': undefined,
68
+ role: null
69
+ };
39
70
  /**
40
71
  * Keeps the rendered content in sync with the `value` prop after mount.
41
72
  *
@@ -81,6 +112,10 @@ function SyncValuePlugin({
81
112
  * A read-only renderer for serialized Lexical content. Renders the same styled
82
113
  * output as {@link RichTextEditor} without any editing affordances.
83
114
  *
115
+ * The output is document content, not a form field: headings, lists and links
116
+ * keep their own roles for assistive technology, and the view takes no label.
117
+ * For a labelled, read-only field, use `<RichTextEditor isReadOnly />`.
118
+ *
84
119
  * @example
85
120
  * ```
86
121
  * import {RichTextView} from '@astryxdesign/richtext';
@@ -119,8 +154,26 @@ export function RichTextView({
119
154
  } else {
120
155
  lastValueRef.current = value;
121
156
  }
157
+
158
+ // A parse failure is recorded during render (below, or from Lexical's
159
+ // `onError` while the composer builds the editor) but reported to the
160
+ // consumer only after commit. Updating this component's own state during
161
+ // render is allowed; running a consumer's callback is not — a callback that
162
+ // updates its own component would do so during another component's render,
163
+ // and StrictMode or a discarded concurrent render would repeat it or run it
164
+ // for output that never commits. This Effect synchronizes the consumer's
165
+ // `onParseError`, reporting each distinct failure exactly once.
166
+ const pendingErrorRef = useRef(null);
167
+ const reportedErrorRef = useRef(null);
168
+ useEffect(() => {
169
+ const error = pendingErrorRef.current;
170
+ if (error !== null && error !== reportedErrorRef.current) {
171
+ reportedErrorRef.current = error;
172
+ onParseError?.(error);
173
+ }
174
+ });
122
175
  const handleError = error => {
123
- onParseError?.(error);
176
+ pendingErrorRef.current = error;
124
177
  setHasError(true);
125
178
  };
126
179
 
@@ -141,9 +194,7 @@ export function RichTextView({
141
194
  // with the corrected `value`.
142
195
  extensionRef.current = null;
143
196
  return /*#__PURE__*/_jsx("div", {
144
- ...stylex.props(styles.root, xstyle),
145
- className: className,
146
- style: style,
197
+ ...mergeProps(stylex.props(styles.root, xstyle), className, style),
147
198
  ...rest,
148
199
  children: errorFallback
149
200
  });
@@ -162,17 +213,22 @@ export function RichTextView({
162
213
  });
163
214
  }
164
215
  return /*#__PURE__*/_jsx("div", {
165
- ...stylex.props(styles.root, xstyle),
166
- className: className,
167
- style: style,
216
+ ...mergeProps(stylex.props(styles.root, xstyle), className, style),
168
217
  ...rest,
169
218
  children: /*#__PURE__*/_jsxs(LexicalExtensionComposer, {
170
219
  extension: extensionRef.current,
171
220
  contentEditable: null,
172
221
  children: [/*#__PURE__*/_jsx(SyncValuePlugin, {
173
222
  value: value
223
+ }), /*#__PURE__*/_jsx(TablePlugin, {
224
+ hasCellMerge: false,
225
+ hasCellBackgroundColor: false,
226
+ hasTabHandler: false,
227
+ hasHorizontalScroll: true
174
228
  }), /*#__PURE__*/_jsx(RichTextPlugin, {
175
- contentEditable: /*#__PURE__*/_jsx(ContentEditable, {}),
229
+ contentEditable: /*#__PURE__*/_jsx(ContentEditable, {
230
+ ...VIEW_CONTENT_EDITABLE_PROPS
231
+ }),
176
232
  placeholder: null,
177
233
  ErrorBoundary: LexicalErrorBoundary
178
234
  }), plugins]
@@ -1,8 +1,8 @@
1
1
  import type { Klass, LexicalNode } from 'lexical';
2
2
  /**
3
3
  * The default OSS node set registered with the editor: headings, quotes,
4
- * lists, links, and code. Extend via the `nodes` prop / option rather than
5
- * editing this list.
4
+ * lists, links, code, and tables. Extend via the `nodes` prop / option rather
5
+ * than editing this list.
6
6
  */
7
7
  export declare const DEFAULT_NODES: ReadonlyArray<Klass<LexicalNode>>;
8
8
  //# sourceMappingURL=editorNodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"editorNodes.d.ts","sourceRoot":"","sources":["../src/editorNodes.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAS3D,CAAC"}
1
+ {"version":3,"file":"editorNodes.d.ts","sourceRoot":"","sources":["../src/editorNodes.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAY3D,CAAC"}
@@ -15,9 +15,10 @@ import { ListNode, ListItemNode } from '@lexical/list';
15
15
  import { HeadingNode, QuoteNode } from '@lexical/rich-text';
16
16
  import { LinkNode, AutoLinkNode } from '@lexical/link';
17
17
  import { CodeNode, CodeHighlightNode } from '@lexical/code';
18
+ import { TableNode, TableRowNode, TableCellNode } from '@lexical/table';
18
19
  /**
19
20
  * The default OSS node set registered with the editor: headings, quotes,
20
- * lists, links, and code. Extend via the `nodes` prop / option rather than
21
- * editing this list.
21
+ * lists, links, code, and tables. Extend via the `nodes` prop / option rather
22
+ * than editing this list.
22
23
  */
23
- export const DEFAULT_NODES = [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode];
24
+ export const DEFAULT_NODES = [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode, TableNode, TableRowNode, TableCellNode];
@@ -1 +1 @@
1
- {"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../src/editorTheme.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AA+GhD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CA8CtD"}
1
+ {"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../src/editorTheme.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AA8IhD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CAoDtD"}
@@ -97,6 +97,21 @@ export function sharedEditorTheme() {
97
97
  },
98
98
  code: {
99
99
  className: "x1lliihq x9m5x89 xwmxj5m x1b2ylru xx3sua9 x141an7d x1g06x3t x126k92a"
100
+ }.className,
101
+ table: {
102
+ className: "x1mwwwfo xh8yej3 xfo4z36"
103
+ }.className,
104
+ tableRow: {
105
+ className: "xso031l x1q0q8m5 xw8gpjh x1bta2m4"
106
+ }.className,
107
+ tableCell: {
108
+ className: "xce4md1 xf314gf x1yc453h xxymvpz x1mzt3pk"
109
+ }.className,
110
+ tableCellHeader: {
111
+ className: "x2mo6ok xv1l7n4"
112
+ }.className,
113
+ tableScrollableWrapper: {
114
+ className: "xw2csxc x193iq5w"
100
115
  }.className
101
116
  };
102
117
  }
@@ -3,9 +3,10 @@ import type { Klass, LexicalNode } from 'lexical';
3
3
  /** Options shared by the Markdown serializer helpers. */
4
4
  export interface MarkdownSerializerOptions {
5
5
  /**
6
- * Markdown transformers to use. Defaults to the standard `@lexical/markdown`
7
- * `TRANSFORMERS`. Pass the same array you give `RichTextEditor`'s
8
- * `transformers` prop so content round-trips consistently.
6
+ * Markdown transformers to use. Defaults to the editor's default set: the
7
+ * standard `@lexical/markdown` `TRANSFORMERS` plus GFM tables. Pass the same
8
+ * array you give `RichTextEditor`'s `transformers` prop so content
9
+ * round-trips consistently.
9
10
  */
10
11
  transformers?: ReadonlyArray<Transformer>;
11
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"markdownSerializers.d.ts","sourceRoot":"","sources":["../src/markdownSerializers.ts"],"names":[],"mappings":"AAyBA,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAEhD,yDAAyD;AACzD,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC1C;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;CAC3C;AAYD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAUR;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAKR"}
1
+ {"version":3,"file":"markdownSerializers.d.ts","sourceRoot":"","sources":["../src/markdownSerializers.ts"],"names":[],"mappings":"AAyBA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAEhD,yDAAyD;AACzD,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC1C;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;CAC3C;AAYD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAUR;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAKR"}
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @file markdownSerializers.ts
5
5
  * @input Uses @lexical/headless (createHeadlessEditor), @lexical/markdown
6
- * ($convertFromMarkdownString / $convertToMarkdownString), and the shared
7
- * DEFAULT_NODES set.
6
+ * ($convertFromMarkdownString / $convertToMarkdownString), the shared
7
+ * DEFAULT_NODES set, and DEFAULT_TRANSFORMERS.
8
8
  * @output Standalone Markdown <-> serialized EditorState helpers:
9
9
  * markdownToEditorStateJSON, editorStateJSONToMarkdown.
10
10
  * @position Re-exported from RichTextEditor/index.ts and the @astryxdesign/richtext
@@ -23,8 +23,9 @@
23
23
  */
24
24
 
25
25
  import { createHeadlessEditor } from '@lexical/headless';
26
- import { TRANSFORMERS, $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown';
26
+ import { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown';
27
27
  import { DEFAULT_NODES } from "./editorNodes.js";
28
+ import { DEFAULT_TRANSFORMERS } from "./markdownTable.js";
28
29
 
29
30
  /** Options shared by the Markdown serializer helpers. */
30
31
 
@@ -51,7 +52,7 @@ function createSerializerEditor(nodes) {
51
52
  */
52
53
  export function markdownToEditorStateJSON(markdown, options = {}) {
53
54
  const {
54
- transformers = TRANSFORMERS,
55
+ transformers = DEFAULT_TRANSFORMERS,
55
56
  nodes
56
57
  } = options;
57
58
  const editor = createSerializerEditor(nodes);
@@ -75,7 +76,7 @@ export function markdownToEditorStateJSON(markdown, options = {}) {
75
76
  */
76
77
  export function editorStateJSONToMarkdown(editorStateJSON, options = {}) {
77
78
  const {
78
- transformers = TRANSFORMERS,
79
+ transformers = DEFAULT_TRANSFORMERS,
79
80
  nodes
80
81
  } = options;
81
82
  const editor = createSerializerEditor(nodes);