An open source design system that's fully customizable and agent ready
TypeScript
fix(richtext): declare the editor's ref prop, and clear two stale headers and two dead style entries (#7422)
Sherry4a174093fd10
diff --git a/packages/richtext/src/RichTextEditor.tsx b/packages/richtext/src/RichTextEditor.tsxindex ca87459876..0045254b4a 100644--- a/packages/richtext/src/RichTextEditor.tsx+++ b/packages/richtext/src/RichTextEditor.tsx@@ -34,7 +34,6 @@ import {useMemo,useRef,useState,- forwardRef,type ReactNode,type Ref,} from 'react';@@ -240,8 +239,8 @@ const dynamicStyles = stylex.create({});const editorBodySizeStyles = stylex.create({- sm: {},- md: {},+ // Only `lg` adds block padding; `sm` and `md` take the base body spacing.+ // An empty entry each would read as deliberate size-specific styling.lg: {paddingBlock: spacingVars['--spacing-2'],},@@ -307,6 +306,12 @@ export interface RichTextEditorProps extends Omit<BaseProps,'onChange' | 'defaultValue'> {+ /**+ * Imperative handle for callers that manage the editor from outside. In+ * React 19 `ref` is an ordinary prop, so it is declared here rather than+ * supplied by a `forwardRef` wrapper.+ */+ ref?: Ref<RichTextEditorRef>;/** Label text for the editor (always rendered for accessibility). */label: string;/**@@ -492,44 +497,39 @@ export interface RichTextEditorProps extends Omit<* />* ```*/-export const RichTextEditor = forwardRef<- RichTextEditorRef,- RichTextEditorProps->(function RichTextEditor(- {- label,- isLabelHidden = false,- description,- isOptional = false,- isRequired = false,- defaultValue,- onChange,- placeholder,- isReadOnly = false,- isDisabled = false,- status,- statusVariant = 'attached',- width,- minHeight = '4.5rem',- labelTooltip,- size: sizeProp,- nodes,- toolbar,- plugins,- hasMarkdownShortcuts = true,- transformers = DEFAULT_TRANSFORMERS,- markdownExtensions,- hasAutoFocus = false,- tabEscapeHint: tabEscapeHintFromProps,- maxLength,- namespace = 'astryx-editor',- xstyle,- className,- style,- ...rest- }: RichTextEditorProps,- ref: Ref<RichTextEditorRef>,-) {+export const RichTextEditor = function RichTextEditor({+ label,+ isLabelHidden = false,+ description,+ isOptional = false,+ isRequired = false,+ defaultValue,+ onChange,+ placeholder,+ isReadOnly = false,+ isDisabled = false,+ status,+ statusVariant = 'attached',+ width,+ minHeight = '4.5rem',+ labelTooltip,+ size: sizeProp,+ nodes,+ toolbar,+ plugins,+ hasMarkdownShortcuts = true,+ transformers = DEFAULT_TRANSFORMERS,+ markdownExtensions,+ hasAutoFocus = false,+ tabEscapeHint: tabEscapeHintFromProps,+ maxLength,+ namespace = 'astryx-editor',+ xstyle,+ className,+ style,+ ref,+ ...rest+}: RichTextEditorProps) {const size = useSize(sizeProp, 'md');const t = useTranslator();const tabEscapeHint =@@ -672,7 +672,7 @@ export const RichTextEditor = forwardRef<styles.editorBody,hasToolbar && styles.editorBodyWithToolbar,!!statusIcon && styles.editorBodyWithStatus,- editorBodySizeStyles[size],+ size === 'lg' && editorBodySizeStyles.lg,)}><div {...stylex.props(styles.editorRoot)}><RichTextPlugin@@ -773,8 +773,11 @@ export const RichTextEditor = forwardRef<)}</Field>);-});+};+// Keeps the editor inside `@astryx/require-baseprops-passthrough`, which only+// checks components that assign a top-level `displayName`. Without it, a+// dropped `className`, `style` or `xstyle` on the root stops warning.RichTextEditor.displayName = 'RichTextEditor';/**@@ -890,7 +893,9 @@ function EditorRefBridge({editable,transformers,}: {- editorRef: Ref<RichTextEditorRef>;+ // Optional, matching the public `ref` prop: with `forwardRef` gone, React+ // no longer supplies `null` when the caller passes nothing.+ editorRef: Ref<RichTextEditorRef> | undefined;editable: boolean;transformers: Array<Transformer>;}): null {diff --git a/packages/richtext/src/RichTextEditorAutoLinkPlugin.tsx b/packages/richtext/src/RichTextEditorAutoLinkPlugin.tsxindex 0f3c119a75..f9585603f1 100644--- a/packages/richtext/src/RichTextEditorAutoLinkPlugin.tsx+++ b/packages/richtext/src/RichTextEditorAutoLinkPlugin.tsx@@ -9,7 +9,7 @@* `linkUtils`.* @output Exports `RichTextEditorAutoLinkPlugin` and its props type, plus the* default `DEFAULT_LINK_MATCHERS`.- * @position Experimental (lab). Drop into RichTextEditor's `plugins` slot to+ * @position Experimental (richtext). Drop into RichTextEditor's `plugins` slot to* auto-linkify URLs and emails as they are typed or pasted. Requires* `AutoLinkNode` to be registered (it is, by default).*diff --git a/packages/richtext/src/linkUtils.ts b/packages/richtext/src/linkUtils.tsindex 1eedfe6805..a5b57b6845 100644--- a/packages/richtext/src/linkUtils.ts+++ b/packages/richtext/src/linkUtils.ts@@ -5,7 +5,7 @@* @input Uses only the DOM URL constructor (guarded via try/catch for SSR/edge).* @output Exports `sanitizeUrl`, `validateUrl`, and the URL/email matcher regexes* used by the AutoLink wiring.- * @position Experimental (lab) helper shared by RichTextEditorToolbar (link+ * @position Experimental (richtext) helper shared by RichTextEditorToolbar (link* button) and the AutoLink matchers in RichTextEditor. Kept dependency-free so* both can import it without pulling in extra `@lexical/*` surface.*