Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(richtext,lab): promote RichTextEditor from lab into @astryxdesign/richtext (#4678)

Sherry401e16f69791
diff --git a/apps/storybook/package.json b/apps/storybook/package.json
index 724d09f16c..646942bddb 100644
--- a/apps/storybook/package.json
+++ b/apps/storybook/package.json
@@ -12,6 +12,7 @@
"@astryxdesign/charts": "*",
"@astryxdesign/core": "*",
"@astryxdesign/lab": "*",
+ "@astryxdesign/richtext": "*",
"@astryxdesign/theme-neutral": "*",
"@astryxdesign/theme-stone": "*",
"@astryxdesign/theme-y2k": "*",
diff --git a/apps/storybook/stories/RichTextEditor.stories.tsx b/apps/storybook/stories/RichTextEditor.stories.tsx
index 33741db88c..50fa6adbc0 100644
--- a/apps/storybook/stories/RichTextEditor.stories.tsx
+++ b/apps/storybook/stories/RichTextEditor.stories.tsx
@@ -10,7 +10,7 @@ import {
RichTextEditorToolbar,
RichTextEditorAutoLinkPlugin,
type RichTextEditorRef,
-} from '@astryxdesign/lab';
+} from '@astryxdesign/richtext';
import type {EditorState} from 'lexical';
import {BOLD_STAR, ITALIC_STAR, UNORDERED_LIST} from '@lexical/markdown';
import {$getRoot} from 'lexical';
diff --git a/apps/storybook/tsconfig.json b/apps/storybook/tsconfig.json
index 2ea40a3a26..3f94101b02 100644
--- a/apps/storybook/tsconfig.json
+++ b/apps/storybook/tsconfig.json
@@ -20,6 +20,13 @@
"../../packages/lab/src/*/index.ts",
"../../packages/lab/src/*"
],
+ "@astryxdesign/richtext": [
+ "../../packages/richtext/src/index.ts"
+ ],
+ "@astryxdesign/richtext/*": [
+ "../../packages/richtext/src/*/index.ts",
+ "../../packages/richtext/src/*"
+ ],
"@astryxdesign/build/vite": [
"../../packages/build/src/vite.ts"
]
diff --git a/packages/lab/package.json b/packages/lab/package.json
index 9d3cf43f00..8febb97432 100644
--- a/packages/lab/package.json
+++ b/packages/lab/package.json
@@ -60,18 +60,7 @@
"@stylexjs/stylex": ">=0.10.0",
"@astryxdesign/core": "0.4.0",
"react": ">=19.0.0",
- "react-dom": ">=19.0.0",
- "lexical": "^0.46.0",
- "@lexical/react": "^0.46.0",
- "@lexical/markdown": "^0.46.0",
- "@lexical/headless": "^0.46.0",
- "@lexical/html": "^0.46.0",
- "@lexical/link": "^0.46.0",
- "@lexical/list": "^0.46.0",
- "@lexical/rich-text": "^0.46.0",
- "@lexical/selection": "^0.46.0",
- "@lexical/code": "^0.46.0",
- "@lexical/utils": "^0.46.0"
+ "react-dom": ">=19.0.0"
},
"dependencies": {
"d3-array": "^3.2.4",
@@ -80,54 +69,8 @@
},
"devDependencies": {
"@astryxdesign/cli": "workspace:*",
- "@lexical/code": "^0.46.0",
- "@lexical/headless": "^0.46.0",
- "@lexical/html": "^0.46.0",
- "@lexical/link": "^0.46.0",
- "@lexical/list": "^0.46.0",
- "@lexical/markdown": "^0.46.0",
- "@lexical/react": "^0.46.0",
- "@lexical/rich-text": "^0.46.0",
- "@lexical/selection": "^0.46.0",
- "@lexical/utils": "^0.46.0",
"@types/d3-array": "^3.2.2",
"@types/d3-scale": "^4.0.9",
- "@types/d3-shape": "^3.1.8",
- "lexical": "^0.46.0"
- },
- "peerDependenciesMeta": {
- "lexical": {
- "optional": true
- },
- "@lexical/react": {
- "optional": true
- },
- "@lexical/markdown": {
- "optional": true
- },
- "@lexical/headless": {
- "optional": true
- },
- "@lexical/html": {
- "optional": true
- },
- "@lexical/link": {
- "optional": true
- },
- "@lexical/list": {
- "optional": true
- },
- "@lexical/rich-text": {
- "optional": true
- },
- "@lexical/selection": {
- "optional": true
- },
- "@lexical/code": {
- "optional": true
- },
- "@lexical/utils": {
- "optional": true
- }
+ "@types/d3-shape": "^3.1.8"
}
}
diff --git a/packages/lab/src/RichTextEditor/index.ts b/packages/lab/src/RichTextEditor/index.ts
deleted file mode 100644
index 78d4e01183..0000000000
--- a/packages/lab/src/RichTextEditor/index.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file index.ts
- * @input Imports RichTextEditor and RichTextView components and their types
- * @output Exports the RichTextEditor experimental surface
- * @position Component entry point; re-exported from @astryxdesign/lab's barrel
- * (packages/lab/src/index.ts).
- *
- * SYNC: When modified, update this header and the editor component doc files.
- */
-
-export {RichTextEditor} from './RichTextEditor';
-export type {
- RichTextEditorProps,
- RichTextEditorRef,
- RichTextEditorStatus,
- RichTextEditorStatusType,
- RichTextEditorSize,
- Transformer,
-} from './RichTextEditor';
-
-export {RichTextView} from './RichTextView';
-export type {RichTextViewProps} from './RichTextView';
-
-export {sharedEditorTheme} from './editorTheme';
-
-export {
- markdownToEditorStateJSON,
- editorStateJSONToMarkdown,
-} from './markdownSerializers';
-export type {MarkdownSerializerOptions} from './markdownSerializers';
-
-export {
- RichTextEditorToolbar,
- RICHTEXT_ICON_KEYS,
-} from './RichTextEditorToolbar';
-export type {RichTextEditorToolbarProps} from './RichTextEditorToolbar';
-
-export {
- RichTextEditorAutoLinkPlugin,
- DEFAULT_LINK_MATCHERS,
- NEW_TAB_LINK_ATTRIBUTES,
-} from './RichTextEditorAutoLinkPlugin';
-export type {RichTextEditorAutoLinkPluginProps} from './RichTextEditorAutoLinkPlugin';
-
-export {
- sanitizeUrl,
- validateUrl,
- URL_MATCHER,
- EMAIL_MATCHER,
-} from './linkUtils';
diff --git a/packages/lab/src/index.ts b/packages/lab/src/index.ts
index d8bb2a234c..12a9ad2880 100644
--- a/packages/lab/src/index.ts
+++ b/packages/lab/src/index.ts
@@ -257,31 +257,7 @@ export {
type LogStreamLevel,
} from './LogStream';
-// RichTextEditor — experimental Lexical WYSIWYG editor (RFC facebook/astryx#3899)
-// Optional peer deps: lexical + @lexical/*. Read-only rendering via RichTextView.
-export {
- RichTextEditor,
- type RichTextEditorProps,
- type RichTextEditorRef,
- type RichTextEditorStatus,
- type RichTextEditorStatusType,
- type RichTextEditorSize,
- type Transformer,
- RichTextView,
- type RichTextViewProps,
- sharedEditorTheme,
- markdownToEditorStateJSON,
- editorStateJSONToMarkdown,
- type MarkdownSerializerOptions,
- RichTextEditorToolbar,
- type RichTextEditorToolbarProps,
- RICHTEXT_ICON_KEYS,
- RichTextEditorAutoLinkPlugin,
- type RichTextEditorAutoLinkPluginProps,
- DEFAULT_LINK_MATCHERS,
- NEW_TAB_LINK_ATTRIBUTES,
- sanitizeUrl,
- validateUrl,
- URL_MATCHER,
- EMAIL_MATCHER,
-} from './RichTextEditor';
+// RichTextEditor (RFC facebook/astryx#3899) has graduated out of @astryxdesign/lab
+// into its own canary-only package, @astryxdesign/richtext, so it can be canaried
+// independently (e.g. into EPS/Nest). Import it from there:
+// import {RichTextEditor, RichTextView} from '@astryxdesign/richtext';
diff --git a/packages/richtext/README.md b/packages/richtext/README.md
index 6cbf2c952f..bde1f5cbd9 100644
--- a/packages/richtext/README.md
+++ b/packages/richtext/README.md
@@ -1,23 +1,62 @@
# @astryxdesign/richtext
-Astryx rich text — a Lexical-based rich text editor and viewer.
+Astryx rich text — a Lexical-based rich text editor and read-only viewer, styled
+with Astryx design tokens.
-> **Status: empty scaffold.** This package is bootstrapped but does not export
-> anything yet. It will house the rich text editor and viewer that currently
-> live in `@astryxdesign/lab`; that code will move here without a fresh package
-> rollout.
+```tsx
+import {RichTextEditor, RichTextView} from '@astryxdesign/richtext';
-It will ship to npm **only under the `@canary` dist-tag** — there is never a
-stable (`latest`) release yet.
+<RichTextEditor label="Notes" onChange={setState} />;
+<RichTextView label="Notes" value={serializedState} />;
+```
+
+The editor is deliberately minimal and extensible: pass `nodes` and `plugins` to
+layer richer behaviour (toolbars, mentions, hover cards) on top without forking.
+`RichTextEditorToolbar` is a composable formatting toolbar that drops into the
+editor's `plugins` slot, and `markdownToEditorStateJSON` /
+`editorStateJSONToMarkdown` convert Markdown to/from serialized editor state
+headlessly (no mounted editor required). It consumes `@astryxdesign/core` theme
+tokens directly (StyleX build mirrors `@astryxdesign/lab` / `@astryxdesign/charts`).
+
+`lexical` and the `@lexical/*` packages are **optional** peer dependencies —
+install them alongside richtext to use the editor. See the RFC:
+[facebook/astryx#3899](https://github.com/facebook/astryx/issues/3899).
+
+It ships to npm **only under the `@canary` dist-tag** — there is never a stable
+(`latest`) release yet.
+
+> Note: this package is the successor to the experimental `RichTextEditor` that
+> used to live in `@astryxdesign/lab`; that code has moved here so it can be
+> canaried independently (e.g. into EPS/Nest) without a fresh package rollout.
+
+## Status
+
+Under active development. The editor, view, composable toolbar, and Markdown
+serializers are in place; API and visuals are still being refined. The goal is
+graduation to `@astryxdesign/core` after the design/API stabilizes.
+
+## Usage
-## Trying richtext in your own project (canary)
+Inside the monorepo (storybook/sandbox), imports resolve via pnpm workspaces:
-Once components land, `@astryxdesign/richtext` will be published **only** under
-the `@canary` dist-tag, so you must request that tag explicitly. There is no
-`latest` version to install.
+```tsx
+import {RichTextEditor, RichTextView} from '@astryxdesign/richtext';
+import '@astryxdesign/core/astryx.css';
+import '@astryxdesign/richtext/richtext.css';
+```
+
+Interactive examples live in the storybook app under **Lab/RichTextEditor**
+(`apps/storybook/stories/RichTextEditor.stories.tsx`).
+
+### Trying richtext in your own project (canary)
+
+`@astryxdesign/richtext` is published **only** under the `@canary` dist-tag, so
+you must request that tag explicitly. There is no `latest` version to install.
```bash
npm install @astryxdesign/richtext@canary @astryxdesign/core@canary
+# plus the optional lexical peers you use:
+npm install lexical @lexical/react @lexical/markdown @lexical/rich-text
```
> Canary builds track the latest commit on `main` (`0.x.y-canary.<sha>`). They
@@ -37,28 +76,9 @@ checkout only (never in git) to publish the `@canary` tag. The committed
When maintainers are ready to promote richtext to a stable public release:
-1. Move the editor/view source from `@astryxdesign/lab` into `src/` and export
- it from `src/index.ts`. Add the StyleX CSS build wiring (see below).
-2. Remove `"private": true` **and** the `"astryx": { "canaryOnly": true }`
+1. Remove `"private": true` **and** the `"astryx": { "canaryOnly": true }`
marker from `package.json`.
-3. Add a changeset (`pnpm changeset`) selecting `@astryxdesign/richtext` so the
+2. Add a changeset (`pnpm changeset`) selecting `@astryxdesign/richtext` so the
release workflow versions and publishes it to the `latest` dist-tag.
-4. The stable (`latest`) release job (`.github/workflows/release.yml`) will then
+3. The stable (`latest`) release job (`.github/workflows/release.yml`) will then
include richtext on the next release.
-
-### Adding the StyleX CSS build (deferred until the first component)
-
-This scaffold intentionally omits the `build:css` step. `build-css.mjs` exits
-with an error ("No StyleX rules found") when a package has zero StyleX
-components, which would break CI for an empty package. When the first StyleX
-component lands:
-
-1. Register a `richtext` target in `scripts/build-css.mjs` (mirror the `lab` /
- `charts` entries — same core token alias).
-2. Add `"build:css": "node ../../scripts/build-css.mjs --package richtext"` to
- the `scripts` block and append `&& pnpm build:css` to the `build` script
- (before `check-no-dev-jsx`).
-3. Add a `"./richtext.css"` entry to `exports` and add `richtext.css` under
- `files` if needed.
-
-The babel config is already StyleX-ready, so this is a small, mechanical add.
diff --git a/packages/richtext/package.json b/packages/richtext/package.json
index 11e9c68b45..c271e87a96 100644
--- a/packages/richtext/package.json
+++ b/packages/richtext/package.json
@@ -41,22 +41,87 @@
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
+ },
+ "./richtext.css": {
+ "default": "./dist/richtext.css"
}
},
"scripts": {
"prepack": "pnpm build",
- "build": "rm -rf dist && pnpm build:esm && tsc --project tsconfig.build.json && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",
+ "build": "rm -rf dist && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",
"build:esm": "babel src --out-dir dist --extensions '.ts,.tsx' --out-file-extension '.js' --ignore '**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts' --config-file ./babel.config.js",
+ "build:css": "node ../../scripts/build-css.mjs --package richtext",
"dev": "babel src --watch --out-dir dist --extensions '.ts,.tsx' --out-file-extension '.js' --ignore '**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*' --config-file ./babel.config.js",
"test": "vitest run --root ../..",
"test:watch": "vitest --root ../..",
"lint": "eslint src",
+ "typecheck:docs": "tsc --project tsconfig.docs.json",
"typecheck": "tsc --project tsconfig.json --noEmit"
},
"peerDependencies": {
"@stylexjs/stylex": ">=0.10.0",
"@astryxdesign/core": "0.4.0",
"react": ">=19.0.0",
- "react-dom": ">=19.0.0"
+ "react-dom": ">=19.0.0",
+ "lexical": "^0.46.0",
+ "@lexical/react": "^0.46.0",
+ "@lexical/markdown": "^0.46.0",
+ "@lexical/headless": "^0.46.0",
+ "@lexical/html": "^0.46.0",
+ "@lexical/link": "^0.46.0",
+ "@lexical/list": "^0.46.0",
+ "@lexical/rich-text": "^0.46.0",
+ "@lexical/selection": "^0.46.0",
+ "@lexical/code": "^0.46.0",
+ "@lexical/utils": "^0.46.0"
+ },
+ "peerDependenciesMeta": {
+ "lexical": {
+ "optional": true
+ },
+ "@lexical/react": {
+ "optional": true
+ },
+ "@lexical/markdown": {
+ "optional": true
+ },
+ "@lexical/headless": {
+ "optional": true
+ },
+ "@lexical/html": {
+ "optional": true
+ },
+ "@lexical/link": {
+ "optional": true
+ },
+ "@lexical/list": {
+ "optional": true
+ },
+ "@lexical/rich-text": {
+ "optional": true
+ },
+ "@lexical/selection": {
+ "optional": true
+ },
+ "@lexical/code": {
+ "optional": true
+ },
+ "@lexical/utils": {
+ "optional": true
+ }
+ },
+ "devDependencies": {
+ "@astryxdesign/cli": "workspace:*",
+ "@lexical/code": "^0.46.0",
+ "@lexical/headless": "^0.46.0",
+ "@lexical/html": "^0.46.0",
+ "@lexical/link": "^0.46.0",
+ "@lexical/list": "^0.46.0",
+ "@lexical/markdown": "^0.46.0",
+ "@lexical/react": "^0.46.0",
+ "@lexical/rich-text": "^0.46.0",
+ "@lexical/selection": "^0.46.0",
+ "@lexical/utils": "^0.46.0",
+ "lexical": "^0.46.0"
}
}
diff --git a/packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs b/packages/richtext/src/RichTextEditor.doc.mjs
similarity index 96%
rename from packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs
rename to packages/richtext/src/RichTextEditor.doc.mjs
index 81fe1f529b..ed995d837f 100644
--- a/packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs
+++ b/packages/richtext/src/RichTextEditor.doc.mjs
@@ -161,12 +161,12 @@ export const docs = {
},
usage: {
description:
- 'A WYSIWYG rich-text editor built on Lexical, styled with Astryx design tokens. Its field container shares TextArea input visuals for the resting border, hover ring, focus-within ring, disabled state, and status colors. Experimental component in @astryxdesign/lab (canary). lexical and @lexical/* are optional peer dependencies. The editor is deliberately minimal and extensible: pass toolbar, nodes, and plugins to layer richer behaviour (formatting, mentions, hover cards) on top without forking. Use RichTextView to render serialized content read-only.',
+ 'A WYSIWYG rich-text editor built on Lexical, styled with Astryx design tokens. Its field container shares TextArea input visuals for the resting border, hover ring, focus-within ring, disabled state, and status colors. Experimental component in @astryxdesign/richtext (canary). lexical and @lexical/* are optional peer dependencies. The editor is deliberately minimal and extensible: pass toolbar, nodes, and plugins to layer richer behaviour (formatting, mentions, hover cards) on top without forking. Use RichTextView to render serialized content read-only.',
bestPractices: [
{
guidance: true,
description:
- 'Install lexical and @lexical/react (optional peers) before importing from @astryxdesign/lab.',
+ 'Install lexical and @lexical/react (optional peers) before importing from @astryxdesign/richtext.',
},
{
guidance: true,
diff --git a/packages/lab/src/RichTextEditor/RichTextEditor.test.tsx b/packages/richtext/src/RichTextEditor.test.tsx
similarity index 100%
rename from packages/lab/src/RichTextEditor/RichTextEditor.test.tsx
rename to packages/richtext/src/RichTextEditor.test.tsx
diff --git a/packages/lab/src/RichTextEditor/RichTextEditor.tsx b/packages/richtext/src/RichTextEditor.tsx
similarity index 97%
rename from packages/lab/src/RichTextEditor/RichTextEditor.tsx
rename to packages/richtext/src/RichTextEditor.tsx
index de2ce653a4..9781c01226 100644
--- a/packages/lab/src/RichTextEditor/RichTextEditor.tsx
+++ b/packages/richtext/src/RichTextEditor.tsx
@@ -9,17 +9,16 @@
* @output Exports an accessibly labelled RichTextEditor component with a flush
* top toolbar slot and configurable editable-surface minimum height, RichTextEditorProps,
* RichTextEditorStatus, RichTextEditorStatusType, RichTextEditorSize
- * @position Experimental (lab) implementation; consumed by RichTextEditor/index.ts and
- * re-exported from @astryxdesign/lab. Tested by RichTextEditor.test.tsx.
+ * @position Experimental (richtext) implementation; consumed by the package index.ts and
+ * re-exported from @astryxdesign/richtext. Tested by RichTextEditor.test.tsx.
*
* SYNC: When modified, update these files to stay in sync:
- * - /packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs (props table, features, implementation notes)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.test.tsx (tests for new/changed behavior)
- * - /packages/lab/src/RichTextEditor/index.ts (exports if types change)
- * - /packages/lab/src/index.ts (barrel re-export)
+ * - /packages/richtext/src/RichTextEditor.doc.mjs (props table, features, implementation notes)
+ * - /packages/richtext/src/RichTextEditor.test.tsx (tests for new/changed behavior)
+ * - /packages/richtext/src/index.ts (exports if types change)
* - /apps/storybook/stories/RichTextEditor.stories.tsx (storybook stories)
*
- * NOTE: This is an EXPERIMENTAL component in @astryxdesign/lab (published only under
+ * NOTE: This is an EXPERIMENTAL component in @astryxdesign/richtext (published only under
* the `@canary` dist-tag, never as stable `latest`). It is the initial landing for the
* OSS Lexical editor RFC; the goal is graduation to @astryxdesign/core after the
* Component Specification Protocol. `lexical` and `@lexical/*` are OPTIONAL peer
@@ -440,7 +439,7 @@ export interface RichTextEditorProps extends Omit<
/**
* A WYSIWYG rich-text editor built on Lexical, styled with Astryx design
- * tokens. Experimental — ships from `@astryxdesign/lab` (canary). `lexical` and
+ * tokens. Experimental — ships from `@astryxdesign/richtext` (canary). `lexical` and
* `@lexical/*` are optional peer dependencies — install them to use this
* component.
*
@@ -453,7 +452,7 @@ export interface RichTextEditorProps extends Omit<
*
* @example
* ```
- * import {RichTextEditor, type RichTextEditorRef} from '@astryxdesign/lab';
+ * import {RichTextEditor, type RichTextEditorRef} from '@astryxdesign/richtext';
* const ref = useRef<RichTextEditorRef>(null);
* <RichTextEditor
* ref={ref}
diff --git a/packages/lab/src/RichTextEditor/RichTextEditorAutoLinkPlugin.tsx b/packages/richtext/src/RichTextEditorAutoLinkPlugin.tsx
similarity index 92%
rename from packages/lab/src/RichTextEditor/RichTextEditorAutoLinkPlugin.tsx
rename to packages/richtext/src/RichTextEditorAutoLinkPlugin.tsx
index 5763ef6481..aa543b246b 100644
--- a/packages/lab/src/RichTextEditor/RichTextEditorAutoLinkPlugin.tsx
+++ b/packages/richtext/src/RichTextEditorAutoLinkPlugin.tsx
@@ -14,13 +14,12 @@
* `AutoLinkNode` to be registered (it is, by default).
*
* SYNC: When modified, update:
- * - /packages/lab/src/RichTextEditor/index.ts (exports)
- * - /packages/lab/src/index.ts (barrel re-export)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs (usage notes)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.test.tsx (tests)
+ * - /packages/richtext/src/index.ts (exports / barrel)
+ * - /packages/richtext/src/RichTextEditor.doc.mjs (usage notes)
+ * - /packages/richtext/src/RichTextEditor.test.tsx (tests)
* - /apps/storybook/stories/RichTextEditor.stories.tsx (story)
*
- * NOTE: Experimental `@astryxdesign/lab` component (canary). `lexical` and
+ * NOTE: Experimental `@astryxdesign/richtext` component (canary). `lexical` and
* `@lexical/*` are OPTIONAL peer dependencies — install them to use this.
*
* COMPATIBILITY: astryx aims for its RichTextEditor internals to eventually
@@ -98,7 +97,8 @@ export interface RichTextEditorAutoLinkPluginProps {
*
* @example
* ```
- * import {RichTextEditor, RichTextEditorAutoLinkPlugin} from '@astryxdesign/lab';
+ * import {RichTextEditor, RichTextEditorAutoLinkPlugin} from '@astryxdesign/richtext';
+ *
* <RichTextEditor
* label="Notes"
* plugins={<RichTextEditorAutoLinkPlugin />}
diff --git a/packages/lab/src/RichTextEditor/RichTextEditorToolbar.tsx b/packages/richtext/src/RichTextEditorToolbar.tsx
similarity index 98%
rename from packages/lab/src/RichTextEditor/RichTextEditorToolbar.tsx
rename to packages/richtext/src/RichTextEditorToolbar.tsx
index 8fe16e9d20..9cdc0911d7 100644
--- a/packages/lab/src/RichTextEditor/RichTextEditorToolbar.tsx
+++ b/packages/richtext/src/RichTextEditorToolbar.tsx
@@ -10,18 +10,17 @@
* ToggleButton / Divider / Dialog / TextInput / Button / Layout primitives.
* @output Exports RichTextEditorToolbar (a compact formatting toolbar with a
* horizontally scrollable action row) and RichTextEditorToolbarProps.
- * @position Experimental (lab). Drop into RichTextEditor's `toolbar` slot to
+ * @position Experimental (richtext). Drop into RichTextEditor's `toolbar` slot to
* add a flush top formatting toolbar. Themed via Astryx Toolbar, Selector,
* IconButton, and ToggleButton, so it inherits the active theme.
*
* SYNC: When modified, update:
- * - /packages/lab/src/RichTextEditor/index.ts (exports)
- * - /packages/lab/src/index.ts (barrel re-export)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs (usage notes)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.test.tsx (tests)
+ * - /packages/richtext/src/index.ts (exports)
+ * - /packages/richtext/src/RichTextEditor.doc.mjs (usage notes)
+ * - /packages/richtext/src/RichTextEditor.test.tsx (tests)
* - /apps/storybook/stories/RichTextEditor.stories.tsx (WithToolbar story)
*
- * NOTE: Experimental `@astryxdesign/lab` component (canary). `lexical` and
+ * NOTE: Experimental `@astryxdesign/richtext` component (canary). `lexical` and
* `@lexical/*` are OPTIONAL peer dependencies — install them to use this.
* Behavior mirrors the Lexical playground toolbar (selection sync + format
* commands); the UI is built from Astryx primitives so it matches the theme.
@@ -472,7 +471,7 @@ export interface RichTextEditorToolbarProps {
*
* @example
* ```
- * import {RichTextEditor, RichTextEditorToolbar} from '@astryxdesign/lab';
+ * import {RichTextEditor, RichTextEditorToolbar} from '@astryxdesign/richtext';
*
* <RichTextEditor
* label="Notes"
diff --git a/packages/lab/src/RichTextEditor/RichTextView.tsx b/packages/richtext/src/RichTextView.tsx
similarity index 96%
rename from packages/lab/src/RichTextEditor/RichTextView.tsx
rename to packages/richtext/src/RichTextView.tsx
index 937c891570..b0a63cd3da 100644
--- a/packages/lab/src/RichTextEditor/RichTextView.tsx
+++ b/packages/richtext/src/RichTextView.tsx
@@ -7,12 +7,11 @@
* @input Uses React, Lexical (lexical + @lexical/react), design tokens
* @output Exports RichTextView component and RichTextViewProps
* @position Read-only renderer for serialized Lexical editor state; experimental
- * (lab), re-exported from @astryxdesign/lab
+ * (richtext), exported from @astryxdesign/richtext
*
* SYNC: When modified, update these files to stay in sync:
- * - /packages/lab/src/RichTextEditor/RichTextView.test.tsx
- * - /packages/lab/src/RichTextEditor/index.ts
- * - /packages/lab/src/index.ts (barrel re-export)
+ * - /packages/richtext/src/RichTextView.test.tsx
+ * - /packages/richtext/src/index.ts
* - /apps/storybook/stories/RichTextEditor.stories.tsx
*/
@@ -134,7 +133,7 @@ function SyncValuePlugin({value}: {value: string}): null {
*
* @example
* ```
- * import {RichTextView} from '@astryxdesign/lab';
+ * import {RichTextView} from '@astryxdesign/richtext';
* <RichTextView value={storedEditorStateJSON} />
* ```
*/
diff --git a/packages/lab/src/RichTextEditor/editorNodes.ts b/packages/richtext/src/editorNodes.ts
similarity index 100%
rename from packages/lab/src/RichTextEditor/editorNodes.ts
rename to packages/richtext/src/editorNodes.ts
diff --git a/packages/lab/src/RichTextEditor/editorTheme.ts b/packages/richtext/src/editorTheme.ts
similarity index 100%
rename from packages/lab/src/RichTextEditor/editorTheme.ts
rename to packages/richtext/src/editorTheme.ts
diff --git a/packages/richtext/src/index.ts b/packages/richtext/src/index.ts
index 62980ea342..c1be519089 100644
--- a/packages/richtext/src/index.ts
+++ b/packages/richtext/src/index.ts
@@ -1,22 +1,56 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
* @file index.ts
- * @input (none yet — empty package)
+ * @input Imports RichTextEditor and RichTextView components and their types
* @output Public API surface for @astryxdesign/richtext
- * @position Barrel export; entry point for consumers of @astryxdesign/richtext
+ * @position Package entry point (barrel) for @astryxdesign/richtext — the
+ * Lexical-based rich text editor and viewer, promoted out of
+ * @astryxdesign/lab so it can be canaried independently.
*
- * SYNC: When modified, update /packages/richtext/README.md
+ * SYNC: When modified, update this header, /packages/richtext/README.md, and
+ * the editor component doc files.
*/
-/**
- * @astryxdesign/richtext will house the Lexical-based rich text editor and
- * viewer currently in @astryxdesign/lab. It is intentionally empty for now —
- * this bootstrap only establishes the package, its build wiring, and its npm
- * canary-only publishing setup so the editor/view can move here later without
- * a fresh package rollout.
- *
- * The `export {}` keeps this a valid ES module with no exports until the first
- * component lands.
- */
-export {};
+export {RichTextEditor} from './RichTextEditor';
+export type {
+ RichTextEditorProps,
+ RichTextEditorRef,
+ RichTextEditorStatus,
+ RichTextEditorStatusType,
+ RichTextEditorSize,
+ Transformer,
+} from './RichTextEditor';
+
+export {RichTextView} from './RichTextView';
+export type {RichTextViewProps} from './RichTextView';
+
+export {sharedEditorTheme} from './editorTheme';
+
+export {
+ markdownToEditorStateJSON,
+ editorStateJSONToMarkdown,
+} from './markdownSerializers';
+export type {MarkdownSerializerOptions} from './markdownSerializers';
+
+export {
+ RichTextEditorToolbar,
+ RICHTEXT_ICON_KEYS,
+} from './RichTextEditorToolbar';
+export type {RichTextEditorToolbarProps} from './RichTextEditorToolbar';
+
+export {
+ RichTextEditorAutoLinkPlugin,
+ DEFAULT_LINK_MATCHERS,
+ NEW_TAB_LINK_ATTRIBUTES,
+} from './RichTextEditorAutoLinkPlugin';
+export type {RichTextEditorAutoLinkPluginProps} from './RichTextEditorAutoLinkPlugin';
+
+export {
+ sanitizeUrl,
+ validateUrl,
+ URL_MATCHER,
+ EMAIL_MATCHER,
+} from './linkUtils';
diff --git a/packages/lab/src/RichTextEditor/linkUtils.ts b/packages/richtext/src/linkUtils.ts
similarity index 89%
rename from packages/lab/src/RichTextEditor/linkUtils.ts
rename to packages/richtext/src/linkUtils.ts
index e161428a3b..1eedfe6805 100644
--- a/packages/lab/src/RichTextEditor/linkUtils.ts
+++ b/packages/richtext/src/linkUtils.ts
@@ -10,12 +10,11 @@
* both can import it without pulling in extra `@lexical/*` surface.
*
* SYNC: When modified, update:
- * - /packages/lab/src/RichTextEditor/RichTextEditorToolbar.tsx (link button)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.tsx (AutoLink matchers)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.test.tsx (tests)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs (link docs)
- * - /packages/lab/src/RichTextEditor/index.ts (exports)
- * - /packages/lab/src/index.ts (barrel re-export)
+ * - /packages/richtext/src/RichTextEditorToolbar.tsx (link button)
+ * - /packages/richtext/src/RichTextEditor.tsx (AutoLink matchers)
+ * - /packages/richtext/src/RichTextEditor.test.tsx (tests)
+ * - /packages/richtext/src/RichTextEditor.doc.mjs (link docs)
+ * - /packages/richtext/src/index.ts (exports / barrel)
*
* NOTE: Mirrors the Lexical playground's url.ts (`sanitizeUrl` / `validateUrl`
* / `URL_REGEX` / `EMAIL_REGEX`). Sanitization is the security-critical part:
diff --git a/packages/lab/src/RichTextEditor/markdownSerializers.ts b/packages/richtext/src/markdownSerializers.ts
similarity index 92%
rename from packages/lab/src/RichTextEditor/markdownSerializers.ts
rename to packages/richtext/src/markdownSerializers.ts
index 6c964c3df2..d53eaa4a29 100644
--- a/packages/lab/src/RichTextEditor/markdownSerializers.ts
+++ b/packages/richtext/src/markdownSerializers.ts
@@ -7,15 +7,14 @@
* DEFAULT_NODES set.
* @output Standalone Markdown <-> serialized EditorState helpers:
* markdownToEditorStateJSON, editorStateJSONToMarkdown.
- * @position Re-exported from RichTextEditor/index.ts and the @astryxdesign/lab
+ * @position Re-exported from RichTextEditor/index.ts and the @astryxdesign/richtext
* barrel. Complements the ref's getMarkdown() by working WITHOUT a mounted
* editor (e.g. to produce a `defaultValue` from Markdown on the server).
*
* SYNC: When modified, update:
- * - /packages/lab/src/RichTextEditor/index.ts (exports)
- * - /packages/lab/src/index.ts (barrel re-export)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs (usage notes)
- * - /packages/lab/src/RichTextEditor/RichTextEditor.test.tsx (tests)
+ * - /packages/richtext/src/index.ts (exports)
+ * - /packages/richtext/src/RichTextEditor.doc.mjs (usage notes)
+ * - /packages/richtext/src/RichTextEditor.test.tsx (tests)
*
* NOTE: `@lexical/headless`, `@lexical/markdown`, and `lexical` are OPTIONAL
* peer dependencies (this is a canary lab module). Install them to use these
diff --git a/packages/richtext/tsconfig.docs.json b/packages/richtext/tsconfig.docs.json
new file mode 100644
index 0000000000..f19aeb0097
--- /dev/null
+++ b/packages/richtext/tsconfig.docs.json
@@ -0,0 +1,10 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "rootDir": "../..",
+ "allowJs": true,
+ "checkJs": true,
+ "noEmit": true
+ },
+ "include": ["src/**/*.doc.mjs"]
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8ccfd4c59f..4189190b41 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -326,6 +326,9 @@ importers:
'@astryxdesign/lab':
specifier: '*'
version: link:../../packages/lab
+ '@astryxdesign/richtext':
+ specifier: '*'
+ version: link:../../packages/richtext
'@astryxdesign/theme-neutral':
specifier: '*'
version: link:../../packages/themes/neutral
@@ -693,6 +696,34 @@ importers:
react-dom:
specifier: '>=19.0.0'
version: 19.2.7([email protected])
+ devDependencies:
+ '@astryxdesign/cli':
+ specifier: workspace:*
+ version: link:../cli
+ '@types/d3-array':
+ specifier: ^3.2.2
+ version: 3.2.2
+ '@types/d3-scale':
+ specifier: ^4.0.9
+ version: 4.0.9
+ '@types/d3-shape':
+ specifier: ^3.1.8
+ version: 3.1.8
+
+ packages/richtext:
+ dependencies:
+ '@astryxdesign/core':
+ specifier: 0.4.0
+ version: link:../core
+ '@stylexjs/stylex':
+ specifier: ^0.19.0
+ version: 0.19.0
+ react:
+ specifier: '>=19.0.0'
+ version: 19.2.7
+ react-dom:
+ specifier: '>=19.0.0'
+ version: 19.2.7([email protected])
devDependencies:
'@astryxdesign/cli':
specifier: workspace:*
@@ -727,34 +758,10 @@ importers:
'@lexical/utils':
specifier: ^0.46.0
version: 0.46.0([email protected])
- '@types/d3-array':
- specifier: ^3.2.2
- version: 3.2.2
- '@types/d3-scale':
- specifier: ^4.0.9
- version: 4.0.9
- '@types/d3-shape':
- specifier: ^3.1.8
- version: 3.1.8
lexical:
specifier: ^0.46.0
version: 0.46.0([email protected])
- packages/richtext:
- dependencies:
- '@astryxdesign/core':
- specifier: 0.4.0
- version: link:../core
- '@stylexjs/stylex':
- specifier: ^0.19.0
- version: 0.19.0
- react:
- specifier: '>=19.0.0'
- version: 19.2.7
- react-dom:
- specifier: '>=19.0.0'
- version: 19.2.7([email protected])
-
packages/themes/butter:
dependencies:
'@astryxdesign/core':
diff --git a/scripts/build-css.mjs b/scripts/build-css.mjs
index 76178345f5..4c69edc3c1 100644
--- a/scripts/build-css.mjs
+++ b/scripts/build-css.mjs
@@ -65,6 +65,19 @@ const TARGETS = {
'@astryxdesign/core': [path.join(ROOT, 'packages/core/src')],
},
},
+ richtext: {
+ src: path.resolve(ROOT, 'packages/richtext/src'),
+ dist: path.resolve(ROOT, 'packages/richtext/dist'),
+ outFile: 'richtext.css',
+ banner:
+ 'Astryx Rich Text Pre-compiled StyleX CSS — Lexical editor and viewer',
+ // richtext imports @astryxdesign/core/theme/tokens.stylex; point the
+ // resolver at core's source so the cross-package token reference resolves.
+ aliases: {
+ '@astryxdesign/core/*': [path.join(ROOT, 'packages/core/src/*')],
+ '@astryxdesign/core': [path.join(ROOT, 'packages/core/src')],
+ },
+ },
};
function parseTarget() {
diff --git a/vitest.config.ts b/vitest.config.ts
index d31d53b92d..b570cf55dd 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -88,7 +88,8 @@ export default defineConfig({
execArgv: ['--max-old-space-size=4096'],
// Test projects (migrated from vitest.workspace.ts). Partitioning rule
// (nothing can fall through):
- // - `ui` = packages/core + packages/lab + packages/charts — need jsdom, the StyleX babel
+ // - `ui` = packages/core + packages/lab + packages/charts + packages/richtext —
+ // need jsdom, the StyleX babel
// transform, and the jest-dom setup; inherit all of that from
// the root config via `extends: true`.
// - `node` = everything else (CLI, build tooling, scripts, internal
@@ -107,6 +108,7 @@ export default defineConfig({
'packages/core/src/**/*.test.{ts,tsx,mjs}',
'packages/lab/src/**/*.test.{ts,tsx,mjs}',
'packages/charts/src/**/*.test.{ts,tsx,mjs}',
+ 'packages/richtext/src/**/*.test.{ts,tsx,mjs}',
],
},
},
@@ -146,6 +148,7 @@ export default defineConfig({
'packages/core/**',
'packages/lab/**',
'packages/charts/**',
+ 'packages/richtext/**',
],
},
},