@astryxdesign/richtext 0.7.1-canary.e199fa4 → 0.7.1-canary.e71c4e9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -4
- package/dist/RichTextEditor.d.ts +11 -2
- package/dist/RichTextEditor.d.ts.map +1 -1
- package/dist/RichTextEditor.js +35 -36
- package/dist/RichTextEditorAutoLinkPlugin.d.ts +1 -1
- package/dist/RichTextEditorAutoLinkPlugin.js +1 -1
- package/dist/linkUtils.js +1 -1
- package/package.json +4 -4
- package/src/RichTextEditor.doc.mjs +1 -1
- package/src/RichTextEditor.tsx +49 -44
- package/src/RichTextEditorAutoLinkPlugin.tsx +1 -1
- package/src/linkUtils.ts +1 -1
package/README.md
CHANGED
|
@@ -18,8 +18,20 @@ editor's `plugins` slot, and `markdownToEditorStateJSON` /
|
|
|
18
18
|
headlessly (no mounted editor required). It consumes `@astryxdesign/core` theme
|
|
19
19
|
tokens directly (StyleX build mirrors `@astryxdesign/lab` / `@astryxdesign/charts`).
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
## Built on Lexical
|
|
22
|
+
|
|
23
|
+
RichText is built on [Lexical](https://lexical.dev) and does not hide it:
|
|
24
|
+
`nodes` and `transformers` take Lexical types, `plugins` takes Lexical React
|
|
25
|
+
plugins, and `onChange(editorState, editor)` and the editor ref's
|
|
26
|
+
`getEditorState()` report Lexical types, so you extend the editor with Lexical
|
|
27
|
+
directly. The value you store is serialized Lexical editor state;
|
|
28
|
+
`markdownToEditorStateJSON` and `editorStateJSONToMarkdown` convert it to and
|
|
29
|
+
from Markdown.
|
|
30
|
+
|
|
31
|
+
RichText supports one Lexical minor at a time, named by its `lexical` and
|
|
32
|
+
`@lexical/*` peer ranges. Those are **optional** peer dependencies, so your
|
|
33
|
+
package manager does not add them: install them at that minor alongside
|
|
34
|
+
richtext. See the RFC:
|
|
23
35
|
[facebook/astryx#3899](https://github.com/facebook/astryx/issues/3899).
|
|
24
36
|
|
|
25
37
|
It ships to npm **only under the `@canary` dist-tag** — there is never a stable
|
|
@@ -56,10 +68,12 @@ you must request that tag explicitly. There is no `latest` version to install.
|
|
|
56
68
|
|
|
57
69
|
```bash
|
|
58
70
|
npm install @astryxdesign/richtext@canary @astryxdesign/core@canary
|
|
59
|
-
# plus the optional lexical peers you use:
|
|
60
|
-
npm install lexical @lexical/react @lexical/markdown @lexical/rich-text
|
|
61
71
|
```
|
|
62
72
|
|
|
73
|
+
Then install every `lexical` and `@lexical/*` package listed in richtext's
|
|
74
|
+
`peerDependencies`, at the range shown there (`npm view
|
|
75
|
+
@astryxdesign/richtext@canary peerDependencies` prints them).
|
|
76
|
+
|
|
63
77
|
> Canary builds track the latest commit on `main` (`0.x.y-canary.<sha>`). They
|
|
64
78
|
> can break between any two versions — pin an exact version if you need
|
|
65
79
|
> stability.
|
package/dist/RichTextEditor.d.ts
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* Component Specification Protocol. `lexical` and `@lexical/*` are OPTIONAL peer
|
|
23
23
|
* dependencies — install them to use this component.
|
|
24
24
|
*/
|
|
25
|
-
import { type ReactNode } from 'react';
|
|
25
|
+
import { type ReactNode, type Ref } from 'react';
|
|
26
26
|
import { type FieldStatusVariant } from '@astryxdesign/core/Field';
|
|
27
27
|
import type { BaseProps } from '@astryxdesign/core';
|
|
28
28
|
import { type SizeValue } from '@astryxdesign/core/utils';
|
|
@@ -77,6 +77,12 @@ export interface RichTextEditorRef {
|
|
|
77
77
|
getEditor: () => LexicalEditor;
|
|
78
78
|
}
|
|
79
79
|
export interface RichTextEditorProps extends Omit<BaseProps, 'onChange' | 'defaultValue'> {
|
|
80
|
+
/**
|
|
81
|
+
* Imperative handle for callers that manage the editor from outside. In
|
|
82
|
+
* React 19 `ref` is an ordinary prop, so it is declared here rather than
|
|
83
|
+
* supplied by a `forwardRef` wrapper.
|
|
84
|
+
*/
|
|
85
|
+
ref?: Ref<RichTextEditorRef>;
|
|
80
86
|
/** Label text for the editor (always rendered for accessibility). */
|
|
81
87
|
label: string;
|
|
82
88
|
/**
|
|
@@ -261,5 +267,8 @@ export interface RichTextEditorProps extends Omit<BaseProps, 'onChange' | 'defau
|
|
|
261
267
|
* />
|
|
262
268
|
* ```
|
|
263
269
|
*/
|
|
264
|
-
export declare const RichTextEditor:
|
|
270
|
+
export declare const RichTextEditor: {
|
|
271
|
+
({ label, isLabelHidden, description, isOptional, isRequired, defaultValue, onChange, placeholder, isReadOnly, isDisabled, status, statusVariant, width, minHeight, labelTooltip, size: sizeProp, nodes, toolbar, plugins, hasMarkdownShortcuts, transformers, markdownExtensions, hasAutoFocus, tabEscapeHint: tabEscapeHintFromProps, maxLength, namespace, xstyle, className, style, ref, ...rest }: RichTextEditorProps): import("react").JSX.Element;
|
|
272
|
+
displayName: string;
|
|
273
|
+
};
|
|
265
274
|
//# sourceMappingURL=RichTextEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../src/RichTextEditor.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../src/RichTextEditor.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AASf,OAAO,EAML,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAIlD,OAAO,EAAyB,KAAK,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAqBhF,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,mBAAmB,CAAC;AACn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H,eAAO,MAAM,cAAc;4YAgCxB,mBAAmB;;CAoPrB,CAAC"}
|
package/dist/RichTextEditor.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* Component Specification Protocol. `lexical` and `@lexical/*` are OPTIONAL peer
|
|
27
27
|
* dependencies — install them to use this component.
|
|
28
28
|
*/
|
|
29
|
-
import { useEffect, useId, useImperativeHandle, useMemo, useRef, useState
|
|
29
|
+
import { useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
30
30
|
import * as stylex from '@stylexjs/stylex';
|
|
31
31
|
import '@astryxdesign/core/theme/tokens.stylex';
|
|
32
32
|
import { colorVars, spacingVars, typographyVars, typeScaleVars } from '@astryxdesign/core/theme/tokens.stylex';
|
|
@@ -108,24 +108,6 @@ const styles = {
|
|
|
108
108
|
kAzted: "x65nank",
|
|
109
109
|
$$css: true
|
|
110
110
|
},
|
|
111
|
-
editorBody: {
|
|
112
|
-
kVAEAm: "x1n2onr6",
|
|
113
|
-
kB7OPa: "x9f619",
|
|
114
|
-
kzqmXN: "xh8yej3",
|
|
115
|
-
k8WAf4: "xu0wf1k",
|
|
116
|
-
kg3NbH: "xf314gf",
|
|
117
|
-
$$css: true
|
|
118
|
-
},
|
|
119
|
-
editorBodyWithToolbar: {
|
|
120
|
-
kEafiO: "x178xt8z",
|
|
121
|
-
kPef9Z: "x13fuv20",
|
|
122
|
-
kLZC3w: "x1pc3f07",
|
|
123
|
-
$$css: true
|
|
124
|
-
},
|
|
125
|
-
editorBodyWithStatus: {
|
|
126
|
-
kwRFfy: "xp74n0j",
|
|
127
|
-
$$css: true
|
|
128
|
-
},
|
|
129
111
|
contentEditable: {
|
|
130
112
|
k1xSpc: "x1lliihq",
|
|
131
113
|
kzqmXN: "xh8yej3",
|
|
@@ -149,19 +131,6 @@ const dynamicStyles = {
|
|
|
149
131
|
"--x-minHeight": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(minHeight)
|
|
150
132
|
}]
|
|
151
133
|
};
|
|
152
|
-
const editorBodySizeStyles = {
|
|
153
|
-
sm: {
|
|
154
|
-
$$css: true
|
|
155
|
-
},
|
|
156
|
-
md: {
|
|
157
|
-
$$css: true
|
|
158
|
-
},
|
|
159
|
-
lg: {
|
|
160
|
-
k8WAf4: "xce4md1",
|
|
161
|
-
$$css: true
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
134
|
/**
|
|
166
135
|
* Fraction of `maxLength` at which the character counter begins announcing
|
|
167
136
|
* remaining/over-limit characters to screen readers. Matches TextArea.
|
|
@@ -198,7 +167,7 @@ const COUNTER_WARNING_THRESHOLD = 0.8;
|
|
|
198
167
|
* />
|
|
199
168
|
* ```
|
|
200
169
|
*/
|
|
201
|
-
export const RichTextEditor =
|
|
170
|
+
export const RichTextEditor = function RichTextEditor({
|
|
202
171
|
label,
|
|
203
172
|
isLabelHidden = false,
|
|
204
173
|
description,
|
|
@@ -228,8 +197,9 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
|
|
|
228
197
|
xstyle,
|
|
229
198
|
className,
|
|
230
199
|
style,
|
|
200
|
+
ref,
|
|
231
201
|
...rest
|
|
232
|
-
}
|
|
202
|
+
}) {
|
|
233
203
|
const size = useSize(sizeProp, 'md');
|
|
234
204
|
const t = useTranslator();
|
|
235
205
|
const tabEscapeHint = tabEscapeHintFromProps ?? t('@astryx.richTextEditor.tabEscapeHint');
|
|
@@ -333,7 +303,32 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
|
|
|
333
303
|
extension: extensionRef.current,
|
|
334
304
|
contentEditable: null,
|
|
335
305
|
children: [hasToolbar ? toolbar : null, /*#__PURE__*/_jsxs("div", {
|
|
336
|
-
...
|
|
306
|
+
...{
|
|
307
|
+
0: {
|
|
308
|
+
className: "x1n2onr6 x9f619 xh8yej3 xu0wf1k xf314gf"
|
|
309
|
+
},
|
|
310
|
+
4: {
|
|
311
|
+
className: "x1n2onr6 x9f619 xh8yej3 xu0wf1k xf314gf x178xt8z x13fuv20 x1pc3f07"
|
|
312
|
+
},
|
|
313
|
+
2: {
|
|
314
|
+
className: "x1n2onr6 x9f619 xh8yej3 xu0wf1k xf314gf xp74n0j"
|
|
315
|
+
},
|
|
316
|
+
6: {
|
|
317
|
+
className: "x1n2onr6 x9f619 xh8yej3 xu0wf1k xf314gf x178xt8z x13fuv20 x1pc3f07 xp74n0j"
|
|
318
|
+
},
|
|
319
|
+
1: {
|
|
320
|
+
className: "x1n2onr6 x9f619 xh8yej3 xf314gf xce4md1"
|
|
321
|
+
},
|
|
322
|
+
5: {
|
|
323
|
+
className: "x1n2onr6 x9f619 xh8yej3 xf314gf x178xt8z x13fuv20 x1pc3f07 xce4md1"
|
|
324
|
+
},
|
|
325
|
+
3: {
|
|
326
|
+
className: "x1n2onr6 x9f619 xh8yej3 xf314gf xp74n0j xce4md1"
|
|
327
|
+
},
|
|
328
|
+
7: {
|
|
329
|
+
className: "x1n2onr6 x9f619 xh8yej3 xf314gf x178xt8z x13fuv20 x1pc3f07 xp74n0j xce4md1"
|
|
330
|
+
}
|
|
331
|
+
}[!!hasToolbar << 2 | !!!!statusIcon << 1 | !!(size === 'lg') << 0],
|
|
337
332
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
338
333
|
...{
|
|
339
334
|
className: "x1n2onr6 xh8yej3 x9ynric xjm74w1 xf9zqsd xw6l6zx"
|
|
@@ -409,7 +404,11 @@ export const RichTextEditor = /*#__PURE__*/forwardRef(function RichTextEditor({
|
|
|
409
404
|
})]
|
|
410
405
|
})]
|
|
411
406
|
});
|
|
412
|
-
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
// Keeps the editor inside `@astryx/require-baseprops-passthrough`, which only
|
|
410
|
+
// checks components that assign a top-level `displayName`. Without it, a
|
|
411
|
+
// dropped `className`, `style` or `xstyle` on the root stops warning.
|
|
413
412
|
RichTextEditor.displayName = 'RichTextEditor';
|
|
414
413
|
|
|
415
414
|
/**
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `linkUtils`.
|
|
6
6
|
* @output Exports `RichTextEditorAutoLinkPlugin` and its props type, plus the
|
|
7
7
|
* default `DEFAULT_LINK_MATCHERS`.
|
|
8
|
-
* @position Experimental (
|
|
8
|
+
* @position Experimental (richtext). Drop into RichTextEditor's `plugins` slot to
|
|
9
9
|
* auto-linkify URLs and emails as they are typed or pasted. Requires
|
|
10
10
|
* `AutoLinkNode` to be registered (it is, by default).
|
|
11
11
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* `linkUtils`.
|
|
10
10
|
* @output Exports `RichTextEditorAutoLinkPlugin` and its props type, plus the
|
|
11
11
|
* default `DEFAULT_LINK_MATCHERS`.
|
|
12
|
-
* @position Experimental (
|
|
12
|
+
* @position Experimental (richtext). Drop into RichTextEditor's `plugins` slot to
|
|
13
13
|
* auto-linkify URLs and emails as they are typed or pasted. Requires
|
|
14
14
|
* `AutoLinkNode` to be registered (it is, by default).
|
|
15
15
|
*
|
package/dist/linkUtils.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @input Uses only the DOM URL constructor (guarded via try/catch for SSR/edge).
|
|
6
6
|
* @output Exports `sanitizeUrl`, `validateUrl`, and the URL/email matcher regexes
|
|
7
7
|
* used by the AutoLink wiring.
|
|
8
|
-
* @position Experimental (
|
|
8
|
+
* @position Experimental (richtext) helper shared by RichTextEditorToolbar (link
|
|
9
9
|
* button) and the AutoLink matchers in RichTextEditor. Kept dependency-free so
|
|
10
10
|
* both can import it without pulling in extra `@lexical/*` surface.
|
|
11
11
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/richtext",
|
|
3
3
|
"displayName": "Rich Text",
|
|
4
|
-
"version": "0.7.1-canary.
|
|
4
|
+
"version": "0.7.1-canary.e71c4e9",
|
|
5
5
|
"description": "Astryx rich text — a Lexical-based rich text editor and viewer. Published to npm only under the @canary dist-tag for early testing; never released as a stable (latest) version.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
7
7
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@stylexjs/stylex": ">=0.10.0",
|
|
58
|
-
"@astryxdesign/core": "0.7.1-canary.
|
|
58
|
+
"@astryxdesign/core": "0.7.1-canary.e71c4e9",
|
|
59
59
|
"react": ">=19.0.0",
|
|
60
60
|
"react-dom": ">=19.0.0",
|
|
61
61
|
"lexical": "^0.46.0",
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
|
-
"@astryxdesign/a11y-spec": "0.7.1-canary.
|
|
118
|
-
"@astryxdesign/cli": "0.7.1-canary.
|
|
117
|
+
"@astryxdesign/a11y-spec": "0.7.1-canary.e71c4e9",
|
|
118
|
+
"@astryxdesign/cli": "0.7.1-canary.e71c4e9",
|
|
119
119
|
"@babel/cli": "^7.29.7",
|
|
120
120
|
"@babel/core": "^7.29.7",
|
|
121
121
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -184,7 +184,7 @@ export const docs = {
|
|
|
184
184
|
{
|
|
185
185
|
guidance: true,
|
|
186
186
|
description:
|
|
187
|
-
'Install lexical and @lexical
|
|
187
|
+
'RichText is built on Lexical and exposes it: nodes and transformers take Lexical types, plugins takes Lexical React plugins, and onChange and getEditorState() report Lexical types. Install the lexical and @lexical/* peers (optional peers) at the Lexical minor named in the package peer ranges before importing from @astryxdesign/richtext.',
|
|
188
188
|
},
|
|
189
189
|
{
|
|
190
190
|
guidance: true,
|
package/src/RichTextEditor.tsx
CHANGED
|
@@ -34,7 +34,6 @@ import {
|
|
|
34
34
|
useMemo,
|
|
35
35
|
useRef,
|
|
36
36
|
useState,
|
|
37
|
-
forwardRef,
|
|
38
37
|
type ReactNode,
|
|
39
38
|
type Ref,
|
|
40
39
|
} from 'react';
|
|
@@ -240,8 +239,8 @@ const dynamicStyles = stylex.create({
|
|
|
240
239
|
});
|
|
241
240
|
|
|
242
241
|
const editorBodySizeStyles = stylex.create({
|
|
243
|
-
sm
|
|
244
|
-
|
|
242
|
+
// Only `lg` adds block padding; `sm` and `md` take the base body spacing.
|
|
243
|
+
// An empty entry each would read as deliberate size-specific styling.
|
|
245
244
|
lg: {
|
|
246
245
|
paddingBlock: spacingVars['--spacing-2'],
|
|
247
246
|
},
|
|
@@ -307,6 +306,12 @@ export interface RichTextEditorProps extends Omit<
|
|
|
307
306
|
BaseProps,
|
|
308
307
|
'onChange' | 'defaultValue'
|
|
309
308
|
> {
|
|
309
|
+
/**
|
|
310
|
+
* Imperative handle for callers that manage the editor from outside. In
|
|
311
|
+
* React 19 `ref` is an ordinary prop, so it is declared here rather than
|
|
312
|
+
* supplied by a `forwardRef` wrapper.
|
|
313
|
+
*/
|
|
314
|
+
ref?: Ref<RichTextEditorRef>;
|
|
310
315
|
/** Label text for the editor (always rendered for accessibility). */
|
|
311
316
|
label: string;
|
|
312
317
|
/**
|
|
@@ -492,44 +497,39 @@ export interface RichTextEditorProps extends Omit<
|
|
|
492
497
|
* />
|
|
493
498
|
* ```
|
|
494
499
|
*/
|
|
495
|
-
export const RichTextEditor =
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
style,
|
|
529
|
-
...rest
|
|
530
|
-
}: RichTextEditorProps,
|
|
531
|
-
ref: Ref<RichTextEditorRef>,
|
|
532
|
-
) {
|
|
500
|
+
export const RichTextEditor = function RichTextEditor({
|
|
501
|
+
label,
|
|
502
|
+
isLabelHidden = false,
|
|
503
|
+
description,
|
|
504
|
+
isOptional = false,
|
|
505
|
+
isRequired = false,
|
|
506
|
+
defaultValue,
|
|
507
|
+
onChange,
|
|
508
|
+
placeholder,
|
|
509
|
+
isReadOnly = false,
|
|
510
|
+
isDisabled = false,
|
|
511
|
+
status,
|
|
512
|
+
statusVariant = 'attached',
|
|
513
|
+
width,
|
|
514
|
+
minHeight = '4.5rem',
|
|
515
|
+
labelTooltip,
|
|
516
|
+
size: sizeProp,
|
|
517
|
+
nodes,
|
|
518
|
+
toolbar,
|
|
519
|
+
plugins,
|
|
520
|
+
hasMarkdownShortcuts = true,
|
|
521
|
+
transformers = DEFAULT_TRANSFORMERS,
|
|
522
|
+
markdownExtensions,
|
|
523
|
+
hasAutoFocus = false,
|
|
524
|
+
tabEscapeHint: tabEscapeHintFromProps,
|
|
525
|
+
maxLength,
|
|
526
|
+
namespace = 'astryx-editor',
|
|
527
|
+
xstyle,
|
|
528
|
+
className,
|
|
529
|
+
style,
|
|
530
|
+
ref,
|
|
531
|
+
...rest
|
|
532
|
+
}: RichTextEditorProps) {
|
|
533
533
|
const size = useSize(sizeProp, 'md');
|
|
534
534
|
const t = useTranslator();
|
|
535
535
|
const tabEscapeHint =
|
|
@@ -672,7 +672,7 @@ export const RichTextEditor = forwardRef<
|
|
|
672
672
|
styles.editorBody,
|
|
673
673
|
hasToolbar && styles.editorBodyWithToolbar,
|
|
674
674
|
!!statusIcon && styles.editorBodyWithStatus,
|
|
675
|
-
editorBodySizeStyles
|
|
675
|
+
size === 'lg' && editorBodySizeStyles.lg,
|
|
676
676
|
)}>
|
|
677
677
|
<div {...stylex.props(styles.editorRoot)}>
|
|
678
678
|
<RichTextPlugin
|
|
@@ -773,8 +773,11 @@ export const RichTextEditor = forwardRef<
|
|
|
773
773
|
)}
|
|
774
774
|
</Field>
|
|
775
775
|
);
|
|
776
|
-
}
|
|
776
|
+
};
|
|
777
777
|
|
|
778
|
+
// Keeps the editor inside `@astryx/require-baseprops-passthrough`, which only
|
|
779
|
+
// checks components that assign a top-level `displayName`. Without it, a
|
|
780
|
+
// dropped `className`, `style` or `xstyle` on the root stops warning.
|
|
778
781
|
RichTextEditor.displayName = 'RichTextEditor';
|
|
779
782
|
|
|
780
783
|
/**
|
|
@@ -890,7 +893,9 @@ function EditorRefBridge({
|
|
|
890
893
|
editable,
|
|
891
894
|
transformers,
|
|
892
895
|
}: {
|
|
893
|
-
|
|
896
|
+
// Optional, matching the public `ref` prop: with `forwardRef` gone, React
|
|
897
|
+
// no longer supplies `null` when the caller passes nothing.
|
|
898
|
+
editorRef: Ref<RichTextEditorRef> | undefined;
|
|
894
899
|
editable: boolean;
|
|
895
900
|
transformers: Array<Transformer>;
|
|
896
901
|
}): null {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* `linkUtils`.
|
|
10
10
|
* @output Exports `RichTextEditorAutoLinkPlugin` and its props type, plus the
|
|
11
11
|
* default `DEFAULT_LINK_MATCHERS`.
|
|
12
|
-
* @position Experimental (
|
|
12
|
+
* @position Experimental (richtext). Drop into RichTextEditor's `plugins` slot to
|
|
13
13
|
* auto-linkify URLs and emails as they are typed or pasted. Requires
|
|
14
14
|
* `AutoLinkNode` to be registered (it is, by default).
|
|
15
15
|
*
|
package/src/linkUtils.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @input Uses only the DOM URL constructor (guarded via try/catch for SSR/edge).
|
|
6
6
|
* @output Exports `sanitizeUrl`, `validateUrl`, and the URL/email matcher regexes
|
|
7
7
|
* used by the AutoLink wiring.
|
|
8
|
-
* @position Experimental (
|
|
8
|
+
* @position Experimental (richtext) helper shared by RichTextEditorToolbar (link
|
|
9
9
|
* button) and the AutoLink matchers in RichTextEditor. Kept dependency-free so
|
|
10
10
|
* both can import it without pulling in extra `@lexical/*` surface.
|
|
11
11
|
*
|