@astryxdesign/lab 0.2.0-canary.e424a04 → 0.2.0-canary.e6beddb
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/dist/BottomSheet/BottomSheet.d.ts +29 -7
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +73 -24
- package/dist/BottomSheet/snapOffsets.d.ts +13 -5
- package/dist/BottomSheet/snapOffsets.d.ts.map +1 -1
- package/dist/BottomSheet/snapOffsets.js +22 -9
- package/dist/BottomSheet/useSheetGestures.d.ts +1 -1
- package/dist/BottomSheet/useSheetGestures.js +1 -1
- package/dist/RichTextEditor/RichTextEditorAutoLinkPlugin.d.ts +85 -0
- package/dist/RichTextEditor/RichTextEditorAutoLinkPlugin.d.ts.map +1 -0
- package/dist/RichTextEditor/RichTextEditorAutoLinkPlugin.js +95 -0
- package/dist/RichTextEditor/RichTextEditorToolbar.d.ts +30 -1
- package/dist/RichTextEditor/RichTextEditorToolbar.d.ts.map +1 -1
- package/dist/RichTextEditor/RichTextEditorToolbar.js +149 -3
- package/dist/RichTextEditor/RichTextView.d.ts.map +1 -1
- package/dist/RichTextEditor/RichTextView.js +48 -2
- package/dist/RichTextEditor/index.d.ts +3 -0
- package/dist/RichTextEditor/index.d.ts.map +1 -1
- package/dist/RichTextEditor/index.js +3 -1
- package/dist/RichTextEditor/linkUtils.d.ts +22 -0
- package/dist/RichTextEditor/linkUtils.d.ts.map +1 -0
- package/dist/RichTextEditor/linkUtils.js +91 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/lab.css +2 -0
- package/package.json +3 -3
- package/src/BottomSheet/BottomSheet.doc.mjs +21 -2
- package/src/BottomSheet/BottomSheet.test.tsx +93 -0
- package/src/BottomSheet/BottomSheet.tsx +93 -22
- package/src/BottomSheet/snapOffsets.test.ts +11 -5
- package/src/BottomSheet/snapOffsets.ts +22 -9
- package/src/BottomSheet/useSheetGestures.doc.mjs +1 -1
- package/src/BottomSheet/useSheetGestures.test.ts +11 -10
- package/src/BottomSheet/useSheetGestures.ts +2 -2
- package/src/RichTextEditor/RichTextEditor.doc.mjs +11 -1
- package/src/RichTextEditor/RichTextEditor.test.tsx +449 -2
- package/src/RichTextEditor/RichTextEditorAutoLinkPlugin.tsx +116 -0
- package/src/RichTextEditor/RichTextEditorToolbar.tsx +196 -1
- package/src/RichTextEditor/RichTextView.tsx +44 -1
- package/src/RichTextEditor/index.ts +14 -0
- package/src/RichTextEditor/linkUtils.ts +93 -0
- package/src/index.ts +8 -1
- package/dist/CodeBlock/index.d.ts +0 -8
- package/dist/CodeBlock/index.d.ts.map +0 -1
- package/dist/CodeBlock/index.js +0 -9
- package/src/CodeBlock/index.ts +0 -10
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @position Lab implementation; consumed by index.ts, tested by BottomSheet.test.tsx, demonstrated in Storybook
|
|
6
6
|
*
|
|
7
7
|
* A mobile touch surface that rises from the bottom edge: grab handle, snap
|
|
8
|
-
* points, and swipe-to-dismiss. It owns a native
|
|
8
|
+
* points, and swipe-to-dismiss. It owns a native `<dialog>` directly and
|
|
9
9
|
* composes core primitives (`useScrollLock`, `<dialog>.showModal()` for the
|
|
10
10
|
* top layer + focus trap, a `::backdrop` scrim) rather than delegating to a
|
|
11
11
|
* heavier overlay component — so it controls its own sizing and can render a
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
* That shell is what lets the sheet translate freely (including a little past
|
|
14
14
|
* fully-open) without clipping against a fixed dialog edge.
|
|
15
15
|
*
|
|
16
|
+
* `hasScrim` picks the presentation: `true` (default) uses `showModal()` (top
|
|
17
|
+
* layer, focus trap, scrim, scroll lock, background inert); `false` uses
|
|
18
|
+
* `show()` for a non-modal sheet with no scrim, leaving the page behind
|
|
19
|
+
* interactive and scrollable (the transparent shell is pointer-events:none so
|
|
20
|
+
* taps pass through).
|
|
21
|
+
*
|
|
16
22
|
* The drag/snap/dismiss machinery lives in `useSheetGestures`; the offset
|
|
17
23
|
* geometry lives in the pure, tested `snapOffsets` module. Both are internal
|
|
18
24
|
* to BottomSheet and not exported from the lab entry point.
|
|
@@ -71,16 +77,32 @@ export interface BottomSheetProps extends BaseProps<HTMLDialogElement> {
|
|
|
71
77
|
* @default 'capped'
|
|
72
78
|
*/
|
|
73
79
|
height?: BottomSheetHeight | number | string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether to render a modal scrim behind the sheet.
|
|
82
|
+
* - `true` (default) — `showModal()`: renders in the top layer with a focus
|
|
83
|
+
* trap, a `::backdrop` scrim, body scroll lock, and tap-scrim-to-dismiss.
|
|
84
|
+
* The background is inert. Use for focused tasks (filters, forms).
|
|
85
|
+
* - `false` — `show()`: a non-modal sheet with **no scrim**. The page behind
|
|
86
|
+
* stays interactive and scrollable (like Material's *standard* bottom
|
|
87
|
+
* sheet, or an iOS undimmed detent). Escape still closes while focus is
|
|
88
|
+
* inside the sheet, and drag/flick-to-dismiss still work. Use for a peek
|
|
89
|
+
* surface that coexists with the page (e.g. a panel over a live map).
|
|
90
|
+
* @default true
|
|
91
|
+
*/
|
|
92
|
+
hasScrim?: boolean;
|
|
74
93
|
/** Test ID for the root element. */
|
|
75
94
|
'data-testid'?: string;
|
|
76
95
|
}
|
|
77
96
|
/**
|
|
78
97
|
* A mobile touch sheet that rises from the bottom edge, with a grab handle,
|
|
79
|
-
* drag-to-resize snap points, and swipe-to-dismiss. It owns a native
|
|
80
|
-
* `<dialog>`
|
|
81
|
-
*
|
|
82
|
-
* dismisses, and Escape closes — so the swipe
|
|
83
|
-
* equivalent.
|
|
98
|
+
* drag-to-resize snap points, and swipe-to-dismiss. It owns a native
|
|
99
|
+
* `<dialog>` and, by default (`hasScrim`), enters the top layer with a focus
|
|
100
|
+
* trap + `::backdrop` scrim and locks body scroll; a slow drag settles to the
|
|
101
|
+
* nearest snap point, a flick down dismisses, and Escape closes — so the swipe
|
|
102
|
+
* always has a keyboard equivalent.
|
|
103
|
+
*
|
|
104
|
+
* With `hasScrim={false}` it opens non-modally (`show()`, no scrim), leaving
|
|
105
|
+
* the page behind interactive and scrollable.
|
|
84
106
|
*
|
|
85
107
|
* @example
|
|
86
108
|
* ```
|
|
@@ -93,7 +115,7 @@ export interface BottomSheetProps extends BaseProps<HTMLDialogElement> {
|
|
|
93
115
|
* </BottomSheet>
|
|
94
116
|
* ```
|
|
95
117
|
*/
|
|
96
|
-
export declare function BottomSheet({ ref, isOpen, onOpenChange, label, children, height, xstyle, ...props }: BottomSheetProps): import("react").JSX.Element;
|
|
118
|
+
export declare function BottomSheet({ ref, isOpen, onOpenChange, label, children, height, hasScrim, xstyle, ...props }: BottomSheetProps): import("react").JSX.Element;
|
|
97
119
|
export declare namespace BottomSheet {
|
|
98
120
|
var displayName: string;
|
|
99
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheet.d.ts","sourceRoot":"","sources":["../../src/BottomSheet/BottomSheet.tsx"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"BottomSheet.d.ts","sourceRoot":"","sources":["../../src/BottomSheet/BottomSheet.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAiC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAErE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AA2BlD;;;;;;GAMG;AACH,QAAA,MAAM,cAAc;;;;CAIV,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,cAAc,CAAC;AAiL5D,MAAM,WAAW,gBAAiB,SAAQ,SAAS,CAAC,iBAAiB,CAAC;IACpE,wDAAwD;IACxD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAEnC,8EAA8E;IAC9E,MAAM,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAExC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd,0EAA0E;IAC1E,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;IAE7C;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,GAAG,EACH,MAAM,EACN,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,MAAiB,EACjB,QAAe,EACf,MAAM,EACN,GAAG,KAAK,EACT,EAAE,gBAAgB,+BA0LlB;yBApMe,WAAW"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @position Lab implementation; consumed by index.ts, tested by BottomSheet.test.tsx, demonstrated in Storybook
|
|
10
10
|
*
|
|
11
11
|
* A mobile touch surface that rises from the bottom edge: grab handle, snap
|
|
12
|
-
* points, and swipe-to-dismiss. It owns a native
|
|
12
|
+
* points, and swipe-to-dismiss. It owns a native `<dialog>` directly and
|
|
13
13
|
* composes core primitives (`useScrollLock`, `<dialog>.showModal()` for the
|
|
14
14
|
* top layer + focus trap, a `::backdrop` scrim) rather than delegating to a
|
|
15
15
|
* heavier overlay component — so it controls its own sizing and can render a
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
* That shell is what lets the sheet translate freely (including a little past
|
|
18
18
|
* fully-open) without clipping against a fixed dialog edge.
|
|
19
19
|
*
|
|
20
|
+
* `hasScrim` picks the presentation: `true` (default) uses `showModal()` (top
|
|
21
|
+
* layer, focus trap, scrim, scroll lock, background inert); `false` uses
|
|
22
|
+
* `show()` for a non-modal sheet with no scrim, leaving the page behind
|
|
23
|
+
* interactive and scrollable (the transparent shell is pointer-events:none so
|
|
24
|
+
* taps pass through).
|
|
25
|
+
*
|
|
20
26
|
* The drag/snap/dismiss machinery lives in `useSheetGestures`; the offset
|
|
21
27
|
* geometry lives in the pure, tested `snapOffsets` module. Both are internal
|
|
22
28
|
* to BottomSheet and not exported from the lab entry point.
|
|
@@ -35,12 +41,18 @@ import { useDevWarning, useScrollLock } from '@astryxdesign/core/hooks';
|
|
|
35
41
|
import { mergeProps, mergeRefs, themeProps } from '@astryxdesign/core/utils';
|
|
36
42
|
import { useSheetGestures } from "./useSheetGestures.js";
|
|
37
43
|
|
|
44
|
+
// A non-modal sheet (hasScrim={false}) uses show() instead of showModal(), so
|
|
45
|
+
// it isn't in the native top layer and needs an explicit z-index to sit above
|
|
46
|
+
// page content. No z-index token exists in the theme; 1000 matches the Drawer
|
|
47
|
+
// / app-level overlay convention.
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
const NON_MODAL_Z = 1000;
|
|
50
|
+
|
|
38
51
|
// Detent fractions of the viewport, ascending (peek / mid / full). Detents
|
|
39
52
|
// that land within DETENT_DEDUP_PX of each other (e.g. a hug height next to a
|
|
40
53
|
// snap) are de-duped in the gesture hook, and any taller than the sheet are
|
|
41
54
|
// dropped, so a full set is safe to offer. The shortest is a glance "peek";
|
|
42
55
|
// the scrim hides as the sheet collapses onto it (see onScrimOpacity).
|
|
43
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
44
56
|
const SNAP_FRACTIONS = [0.14, 0.5, 0.92];
|
|
45
57
|
|
|
46
58
|
/**
|
|
@@ -116,11 +128,14 @@ const styles = {
|
|
|
116
128
|
};
|
|
117
129
|
/**
|
|
118
130
|
* A mobile touch sheet that rises from the bottom edge, with a grab handle,
|
|
119
|
-
* drag-to-resize snap points, and swipe-to-dismiss. It owns a native
|
|
120
|
-
* `<dialog>`
|
|
121
|
-
*
|
|
122
|
-
* dismisses, and Escape closes — so the swipe
|
|
123
|
-
* equivalent.
|
|
131
|
+
* drag-to-resize snap points, and swipe-to-dismiss. It owns a native
|
|
132
|
+
* `<dialog>` and, by default (`hasScrim`), enters the top layer with a focus
|
|
133
|
+
* trap + `::backdrop` scrim and locks body scroll; a slow drag settles to the
|
|
134
|
+
* nearest snap point, a flick down dismisses, and Escape closes — so the swipe
|
|
135
|
+
* always has a keyboard equivalent.
|
|
136
|
+
*
|
|
137
|
+
* With `hasScrim={false}` it opens non-modally (`show()`, no scrim), leaving
|
|
138
|
+
* the page behind interactive and scrollable.
|
|
124
139
|
*
|
|
125
140
|
* @example
|
|
126
141
|
* ```
|
|
@@ -140,6 +155,7 @@ export function BottomSheet({
|
|
|
140
155
|
label,
|
|
141
156
|
children,
|
|
142
157
|
height = 'capped',
|
|
158
|
+
hasScrim = true,
|
|
143
159
|
xstyle,
|
|
144
160
|
...props
|
|
145
161
|
}) {
|
|
@@ -149,7 +165,7 @@ export function BottomSheet({
|
|
|
149
165
|
const close = useCallback(() => onOpenChange(false), [onOpenChange]);
|
|
150
166
|
|
|
151
167
|
// Set imperatively (not via state) so a 60fps drag doesn't re-render. The
|
|
152
|
-
// hook reports the scrim opacity for the current detent (
|
|
168
|
+
// hook reports the scrim opacity for the current detent (a faint floor at the peek).
|
|
153
169
|
const handleScrimOpacity = useCallback(opacity => {
|
|
154
170
|
dialogRef.current?.style.setProperty('--_sheet-scrim-opacity', String(opacity));
|
|
155
171
|
}, []);
|
|
@@ -165,24 +181,32 @@ export function BottomSheet({
|
|
|
165
181
|
onScrimOpacity: handleScrimOpacity
|
|
166
182
|
});
|
|
167
183
|
|
|
168
|
-
// showModal() enters the top layer with a focus trap + ::backdrop
|
|
169
|
-
// we
|
|
184
|
+
// Modal: showModal() enters the top layer with a focus trap + ::backdrop and
|
|
185
|
+
// we restore focus to the opener on close. Standard: show() is non-modal, so
|
|
186
|
+
// we neither trap nor steal focus (the background stays interactive) — we
|
|
187
|
+
// only honor an explicit data-autofocus.
|
|
170
188
|
useEffect(() => {
|
|
171
189
|
const dialog = dialogRef.current;
|
|
172
190
|
if (!dialog) {
|
|
173
191
|
return;
|
|
174
192
|
}
|
|
175
193
|
if (isOpen) {
|
|
176
|
-
triggerRef.current = document.activeElement;
|
|
177
194
|
dialog.style.setProperty('--_sheet-scrim-opacity', '1');
|
|
178
195
|
if (!dialog.open) {
|
|
179
|
-
|
|
180
|
-
//
|
|
181
|
-
|
|
196
|
+
// Only remember/restore focus for modal sheets; a non-modal sheet must
|
|
197
|
+
// not yank focus back from whatever the user does in the live page.
|
|
198
|
+
if (hasScrim) {
|
|
199
|
+
triggerRef.current = document.activeElement;
|
|
200
|
+
dialog.showModal();
|
|
201
|
+
} else {
|
|
202
|
+
dialog.show();
|
|
203
|
+
}
|
|
204
|
+
// Land on the panel (so AT reads from the label) for modal sheets;
|
|
205
|
+
// otherwise only honor a descendant data-autofocus.
|
|
182
206
|
const autofocus = dialog.querySelector('[data-autofocus]');
|
|
183
207
|
if (autofocus) {
|
|
184
208
|
autofocus.focus();
|
|
185
|
-
} else {
|
|
209
|
+
} else if (hasScrim) {
|
|
186
210
|
sheetNodeRef.current?.focus();
|
|
187
211
|
}
|
|
188
212
|
}
|
|
@@ -219,8 +243,11 @@ export function BottomSheet({
|
|
|
219
243
|
sheet?.removeEventListener('transitionend', onEnd);
|
|
220
244
|
};
|
|
221
245
|
}
|
|
222
|
-
}, [isOpen]);
|
|
223
|
-
|
|
246
|
+
}, [isOpen, hasScrim]);
|
|
247
|
+
|
|
248
|
+
// Only a modal sheet locks body scroll; a non-modal sheet leaves the page
|
|
249
|
+
// scrollable behind it.
|
|
250
|
+
useScrollLock(isOpen && hasScrim);
|
|
224
251
|
|
|
225
252
|
// Enforce an accessible name: label is required by types, but a JS caller
|
|
226
253
|
// can still pass an empty string, leaving the sheet unnamed.
|
|
@@ -230,33 +257,55 @@ export function BottomSheet({
|
|
|
230
257
|
close();
|
|
231
258
|
}, [close]);
|
|
232
259
|
// Explicit Escape handler in addition to the native `cancel` event, for
|
|
233
|
-
// environments that don't synthesize `cancel
|
|
260
|
+
// environments that don't synthesize `cancel` (and the show() path, which
|
|
261
|
+
// never fires `cancel`). Only fires when focus is inside the sheet.
|
|
234
262
|
const handleKeyDown = useCallback(event => {
|
|
235
263
|
if (event.key === 'Escape') {
|
|
236
264
|
event.preventDefault();
|
|
237
265
|
close();
|
|
238
266
|
}
|
|
239
267
|
}, [close]);
|
|
268
|
+
// Tap-outside-to-dismiss only applies to modal sheets (the scrim). A non-modal
|
|
269
|
+
// sheet has no scrim and its transparent shell is pointer-events:none, so taps
|
|
270
|
+
// pass through to the page rather than dismissing.
|
|
240
271
|
const handleClick = useCallback(event => {
|
|
241
|
-
if (event.target === event.currentTarget) {
|
|
272
|
+
if (hasScrim && event.target === event.currentTarget) {
|
|
242
273
|
close();
|
|
243
274
|
}
|
|
244
|
-
}, [close]);
|
|
275
|
+
}, [close, hasScrim]);
|
|
245
276
|
const isNamed = typeof height === 'string' && height in HEIGHT_BUDGETS;
|
|
246
277
|
const budget = isNamed ? HEIGHT_BUDGETS[height] : typeof height === 'number' ? `${height}px` : height;
|
|
247
278
|
const isHug = height === 'hug';
|
|
248
279
|
return /*#__PURE__*/_jsx("dialog", {
|
|
249
280
|
...{
|
|
250
281
|
0: {
|
|
251
|
-
className: "xixxii4 x10a8y8t x1o6l61p xtdtrs8 x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1s85apg x1a2a7pz
|
|
282
|
+
className: "xixxii4 x10a8y8t x1o6l61p xtdtrs8 x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1s85apg x1a2a7pz"
|
|
283
|
+
},
|
|
284
|
+
4: {
|
|
285
|
+
className: "xixxii4 x10a8y8t x1o6l61p xtdtrs8 x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1a2a7pz x1lliihq"
|
|
286
|
+
},
|
|
287
|
+
2: {
|
|
288
|
+
className: "xixxii4 x10a8y8t x1o6l61p xtdtrs8 x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1s85apg x1a2a7pz xnixb3f xni466t xxiuuzi xc0dz0a xft5bk6 x15h3t91 x142juwg x1viac0w"
|
|
289
|
+
},
|
|
290
|
+
6: {
|
|
291
|
+
className: "xixxii4 x10a8y8t x1o6l61p xtdtrs8 x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1a2a7pz x1lliihq xnixb3f xni466t xxiuuzi xc0dz0a xft5bk6 x15h3t91 x142juwg x1viac0w"
|
|
252
292
|
},
|
|
253
293
|
1: {
|
|
254
|
-
className: "xixxii4 x10a8y8t
|
|
294
|
+
className: "xixxii4 x10a8y8t x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1s85apg x1a2a7pz x47corl xfo81ep xh8yej3 x5yr21d"
|
|
295
|
+
},
|
|
296
|
+
5: {
|
|
297
|
+
className: "xixxii4 x10a8y8t x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1a2a7pz x1lliihq x47corl xfo81ep xh8yej3 x5yr21d"
|
|
298
|
+
},
|
|
299
|
+
3: {
|
|
300
|
+
className: "xixxii4 x10a8y8t x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1s85apg x1a2a7pz xnixb3f xni466t xxiuuzi xc0dz0a xft5bk6 x15h3t91 x142juwg x1viac0w x47corl xfo81ep xh8yej3 x5yr21d"
|
|
301
|
+
},
|
|
302
|
+
7: {
|
|
303
|
+
className: "xixxii4 x10a8y8t x1x1rfll x7ab17h x1ghz6dp x1717udv xjbqb8w x1rea2x4 x1a2a7pz x1lliihq xnixb3f xni466t xxiuuzi xc0dz0a xft5bk6 x15h3t91 x142juwg x1viac0w x47corl xfo81ep xh8yej3 x5yr21d"
|
|
255
304
|
}
|
|
256
|
-
}[!!isOpen << 0],
|
|
305
|
+
}[!!isOpen << 2 | !!hasScrim << 1 | !!!hasScrim << 0],
|
|
257
306
|
ref: mergeRefs(ref, dialogRef),
|
|
258
307
|
"aria-label": label,
|
|
259
|
-
"aria-modal":
|
|
308
|
+
"aria-modal": hasScrim ? 'true' : undefined,
|
|
260
309
|
onCancel: handleCancel,
|
|
261
310
|
onClick: handleClick,
|
|
262
311
|
onKeyDown: handleKeyDown,
|
|
@@ -36,12 +36,20 @@ export declare function computeDetentOffsets(sheetHeight: number, detentHeights:
|
|
|
36
36
|
/** Nearest value in `offsets` to `value` (offsets must be non-empty). */
|
|
37
37
|
export declare function nearestOffset(value: number, offsets: readonly number[]): number;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Minimum scrim opacity at the peek detent. The scrim thins to a glance state
|
|
40
|
+
* but never fully vanishes, because a modal sheet keeps the background inert —
|
|
41
|
+
* a fully clear backdrop would read as "interactive" when it isn't. (For a
|
|
42
|
+
* genuinely interactive, undimmed peek, use a non-modal sheet, `hasScrim=false`.)
|
|
43
|
+
*/
|
|
44
|
+
export declare const MIN_PEEK_SCRIM_OPACITY = 0.3;
|
|
45
|
+
/**
|
|
46
|
+
* Scrim opacity (1 = fully visible) for a drag/settle `offset`.
|
|
40
47
|
* The scrim stays full while the sheet is at or above its second-shortest
|
|
41
|
-
* detent, then fades
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
48
|
+
* detent, then fades as it collapses onto the shortest ("peek") detent — a
|
|
49
|
+
* glance state that thins the backdrop to `MIN_PEEK_SCRIM_OPACITY` (not fully
|
|
50
|
+
* gone, since the sheet is still modal) and holds there below it.
|
|
51
|
+
* A single-detent sheet has no peek, so it instead fades all the way to 0
|
|
52
|
+
* across the dismiss overshoot toward `dismissOffset` (the sheet is leaving).
|
|
45
53
|
*/
|
|
46
54
|
export declare function scrimOpacityForOffset(offset: number, offsets: readonly number[], dismissOffset: number): number;
|
|
47
55
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapOffsets.d.ts","sourceRoot":"","sources":["../../src/BottomSheet/snapOffsets.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,4EAA4E;AAC5E,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAEV;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,OAAO,GAAE,MAAwB,GAChC,MAAM,EAAE,CAcV;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,CAKR;AAED
|
|
1
|
+
{"version":3,"file":"snapOffsets.d.ts","sourceRoot":"","sources":["../../src/BottomSheet/snapOffsets.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,4EAA4E;AAC5E,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAEV;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,OAAO,GAAE,MAAwB,GAChC,MAAM,EAAE,CAcV;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,CAKR;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,aAAa,EAAE,MAAM,GACpB,MAAM,CAeR;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GACjB,MAAM,CAcR"}
|
|
@@ -58,24 +58,37 @@ export function nearestOffset(value, offsets) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Minimum scrim opacity at the peek detent. The scrim thins to a glance state
|
|
62
|
+
* but never fully vanishes, because a modal sheet keeps the background inert —
|
|
63
|
+
* a fully clear backdrop would read as "interactive" when it isn't. (For a
|
|
64
|
+
* genuinely interactive, undimmed peek, use a non-modal sheet, `hasScrim=false`.)
|
|
65
|
+
*/
|
|
66
|
+
export const MIN_PEEK_SCRIM_OPACITY = 0.3;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Scrim opacity (1 = fully visible) for a drag/settle `offset`.
|
|
62
70
|
* The scrim stays full while the sheet is at or above its second-shortest
|
|
63
|
-
* detent, then fades
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
71
|
+
* detent, then fades as it collapses onto the shortest ("peek") detent — a
|
|
72
|
+
* glance state that thins the backdrop to `MIN_PEEK_SCRIM_OPACITY` (not fully
|
|
73
|
+
* gone, since the sheet is still modal) and holds there below it.
|
|
74
|
+
* A single-detent sheet has no peek, so it instead fades all the way to 0
|
|
75
|
+
* across the dismiss overshoot toward `dismissOffset` (the sheet is leaving).
|
|
67
76
|
*/
|
|
68
77
|
export function scrimOpacityForOffset(offset, offsets, dismissOffset) {
|
|
69
78
|
const shortest = offsets[offsets.length - 1];
|
|
70
|
-
const
|
|
71
|
-
const
|
|
79
|
+
const hasPeek = offsets.length >= 2;
|
|
80
|
+
const fadeStart = hasPeek ? offsets[offsets.length - 2] : 0;
|
|
81
|
+
const fadeEnd = hasPeek ? shortest : dismissOffset;
|
|
82
|
+
// Peek is a resting state on a still-modal sheet, so keep a floor; the
|
|
83
|
+
// dismiss overshoot is a sheet on its way out, so let it clear completely.
|
|
84
|
+
const floor = hasPeek ? MIN_PEEK_SCRIM_OPACITY : 0;
|
|
72
85
|
if (offset <= fadeStart) {
|
|
73
86
|
return 1;
|
|
74
87
|
}
|
|
75
88
|
if (offset >= fadeEnd) {
|
|
76
|
-
return
|
|
89
|
+
return floor;
|
|
77
90
|
}
|
|
78
|
-
return 1 - (offset - fadeStart) / (fadeEnd - fadeStart);
|
|
91
|
+
return 1 - (1 - floor) * ((offset - fadeStart) / (fadeEnd - fadeStart));
|
|
79
92
|
}
|
|
80
93
|
|
|
81
94
|
/**
|
|
@@ -43,7 +43,7 @@ export interface UseSheetGesturesOptions {
|
|
|
43
43
|
* Called with the scrim opacity the sheet should show (1 = fully visible,
|
|
44
44
|
* 0 = hidden) as the drag moves and on settle. Full while the sheet is at
|
|
45
45
|
* or above its mid detent, fading to 0 as it collapses onto the shortest
|
|
46
|
-
* "peek" detent —
|
|
46
|
+
* "peek" detent — thinning to a faint glance state without fully clearing — and
|
|
47
47
|
* on the dismiss overshoot. Lets the owner mirror it onto the scrim.
|
|
48
48
|
*/
|
|
49
49
|
onScrimOpacity?: (opacity: number) => void;
|
|
@@ -213,7 +213,7 @@ export function useSheetGestures({
|
|
|
213
213
|
const target = resolveSettleOffset(offset, offsets, dir, baseOffset);
|
|
214
214
|
setSettledOffset(target);
|
|
215
215
|
onSnapRef.current?.(height - target);
|
|
216
|
-
// Keep the scrim in sync with the resting detent (
|
|
216
|
+
// Keep the scrim in sync with the resting detent (faint floor at the peek).
|
|
217
217
|
const dismissOffset = maxOffset + shortestDetentHeight * DISMISS_OVERSHOOT_RATIO;
|
|
218
218
|
onScrimOpacityRef.current?.(scrimOpacityForOffset(target, offsets, dismissOffset));
|
|
219
219
|
// Haptic "tick" when landing on a different detent (where supported).
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file RichTextEditorAutoLinkPlugin.tsx
|
|
3
|
+
* @input Uses `@lexical/react/LexicalAutoLinkPlugin` (`AutoLinkPlugin`,
|
|
4
|
+
* `createLinkMatcherWithRegExp`) and the shared URL/email matchers from
|
|
5
|
+
* `linkUtils`.
|
|
6
|
+
* @output Exports `RichTextEditorAutoLinkPlugin` and its props type, plus the
|
|
7
|
+
* default `DEFAULT_LINK_MATCHERS`.
|
|
8
|
+
* @position Experimental (lab). Drop into RichTextEditor's `plugins` slot to
|
|
9
|
+
* auto-linkify URLs and emails as they are typed or pasted. Requires
|
|
10
|
+
* `AutoLinkNode` to be registered (it is, by default).
|
|
11
|
+
*
|
|
12
|
+
* SYNC: When modified, update:
|
|
13
|
+
* - /packages/lab/src/RichTextEditor/index.ts (exports)
|
|
14
|
+
* - /packages/lab/src/index.ts (barrel re-export)
|
|
15
|
+
* - /packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs (usage notes)
|
|
16
|
+
* - /packages/lab/src/RichTextEditor/RichTextEditor.test.tsx (tests)
|
|
17
|
+
* - /apps/storybook/stories/RichTextEditor.stories.tsx (story)
|
|
18
|
+
*
|
|
19
|
+
* NOTE: Experimental `@astryxdesign/lab` component (canary). `lexical` and
|
|
20
|
+
* `@lexical/*` are OPTIONAL peer dependencies — install them to use this.
|
|
21
|
+
*
|
|
22
|
+
* COMPATIBILITY: astryx aims for its RichTextEditor internals to eventually
|
|
23
|
+
* back Meta's EPS `EPSRichTextArea` (nest/libs/eps-lexical). EPS's auto-link is
|
|
24
|
+
* matcher-driven and applies `target="_blank"` + `rel="noopener noreferrer"` to
|
|
25
|
+
* created links (its `NEW_TAB_LINK_ATTRIBUTES`). This plugin uses the same
|
|
26
|
+
* matcher shape (`createLinkMatcherWithRegExp` + `attributes`) and the same
|
|
27
|
+
* new-tab defaults, so EPS can pass its own richer matcher set (e.g. shortform
|
|
28
|
+
* `D123` / `T456` / `S789` intern URLs) through the `matchers` prop without
|
|
29
|
+
* changing the contract. EPS ships a hardened fork of the transform itself
|
|
30
|
+
* (expanded separators, code-block exclusion) — astryx stays on the OSS
|
|
31
|
+
* `AutoLinkPlugin`, and EPS can substitute its own plugin in the same slot.
|
|
32
|
+
*/
|
|
33
|
+
import { type LinkMatcher } from '@lexical/react/LexicalAutoLinkPlugin';
|
|
34
|
+
/**
|
|
35
|
+
* Attributes written onto every auto-created link so it opens in a new tab.
|
|
36
|
+
* `rel="noopener noreferrer"` is required whenever `target="_blank"` is set, to
|
|
37
|
+
* prevent reverse-tabnabbing. Matches EPS eps-lexical's `NEW_TAB_LINK_ATTRIBUTES`.
|
|
38
|
+
*/
|
|
39
|
+
export declare const NEW_TAB_LINK_ATTRIBUTES: {
|
|
40
|
+
readonly target: "_blank";
|
|
41
|
+
readonly rel: "noopener noreferrer";
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Default matchers: bare URLs (defaulting to `https://` when scheme-less) and
|
|
45
|
+
* email addresses (as `mailto:` links). Both carry {@link NEW_TAB_LINK_ATTRIBUTES}.
|
|
46
|
+
* URLs are passed through {@link sanitizeUrl} so only http/https/mailto/tel
|
|
47
|
+
* schemes are ever written.
|
|
48
|
+
*/
|
|
49
|
+
export declare const DEFAULT_LINK_MATCHERS: LinkMatcher[];
|
|
50
|
+
export interface RichTextEditorAutoLinkPluginProps {
|
|
51
|
+
/**
|
|
52
|
+
* Link matchers to use. Defaults to {@link DEFAULT_LINK_MATCHERS} (URLs +
|
|
53
|
+
* emails, opening in a new tab). Provide a custom array to recognize
|
|
54
|
+
* additional patterns (e.g. product-specific shortform references) — build
|
|
55
|
+
* each with `createLinkMatcherWithRegExp` from
|
|
56
|
+
* `@lexical/react/LexicalAutoLinkPlugin`.
|
|
57
|
+
*/
|
|
58
|
+
matchers?: LinkMatcher[];
|
|
59
|
+
/**
|
|
60
|
+
* Called when a link is created, updated, or removed by auto-linking.
|
|
61
|
+
* Receives the new URL (or `null` when removed) and the previous URL.
|
|
62
|
+
*/
|
|
63
|
+
onChange?: (url: string | null, prevUrl: string | null) => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Automatically converts typed/pasted URLs and email addresses into links.
|
|
67
|
+
* Render it inside the editor's `plugins` slot — it reaches the editor via
|
|
68
|
+
* `useLexicalComposerContext()`, so it must live within the editor's
|
|
69
|
+
* `LexicalComposer`. Requires `AutoLinkNode` (registered by default).
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```
|
|
73
|
+
* import {RichTextEditor, RichTextEditorAutoLinkPlugin} from '@astryxdesign/lab';
|
|
74
|
+
*
|
|
75
|
+
* <RichTextEditor
|
|
76
|
+
* label="Notes"
|
|
77
|
+
* plugins={<RichTextEditorAutoLinkPlugin />}
|
|
78
|
+
* />
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function RichTextEditorAutoLinkPlugin({ matchers, onChange, }: RichTextEditorAutoLinkPluginProps): import("react").JSX.Element;
|
|
82
|
+
export declare namespace RichTextEditorAutoLinkPlugin {
|
|
83
|
+
var displayName: string;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=RichTextEditorAutoLinkPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextEditorAutoLinkPlugin.d.ts","sourceRoot":"","sources":["../../src/RichTextEditor/RichTextEditorAutoLinkPlugin.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;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"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file RichTextEditorAutoLinkPlugin.tsx
|
|
7
|
+
* @input Uses `@lexical/react/LexicalAutoLinkPlugin` (`AutoLinkPlugin`,
|
|
8
|
+
* `createLinkMatcherWithRegExp`) and the shared URL/email matchers from
|
|
9
|
+
* `linkUtils`.
|
|
10
|
+
* @output Exports `RichTextEditorAutoLinkPlugin` and its props type, plus the
|
|
11
|
+
* default `DEFAULT_LINK_MATCHERS`.
|
|
12
|
+
* @position Experimental (lab). Drop into RichTextEditor's `plugins` slot to
|
|
13
|
+
* auto-linkify URLs and emails as they are typed or pasted. Requires
|
|
14
|
+
* `AutoLinkNode` to be registered (it is, by default).
|
|
15
|
+
*
|
|
16
|
+
* SYNC: When modified, update:
|
|
17
|
+
* - /packages/lab/src/RichTextEditor/index.ts (exports)
|
|
18
|
+
* - /packages/lab/src/index.ts (barrel re-export)
|
|
19
|
+
* - /packages/lab/src/RichTextEditor/RichTextEditor.doc.mjs (usage notes)
|
|
20
|
+
* - /packages/lab/src/RichTextEditor/RichTextEditor.test.tsx (tests)
|
|
21
|
+
* - /apps/storybook/stories/RichTextEditor.stories.tsx (story)
|
|
22
|
+
*
|
|
23
|
+
* NOTE: Experimental `@astryxdesign/lab` component (canary). `lexical` and
|
|
24
|
+
* `@lexical/*` are OPTIONAL peer dependencies — install them to use this.
|
|
25
|
+
*
|
|
26
|
+
* COMPATIBILITY: astryx aims for its RichTextEditor internals to eventually
|
|
27
|
+
* back Meta's EPS `EPSRichTextArea` (nest/libs/eps-lexical). EPS's auto-link is
|
|
28
|
+
* matcher-driven and applies `target="_blank"` + `rel="noopener noreferrer"` to
|
|
29
|
+
* created links (its `NEW_TAB_LINK_ATTRIBUTES`). This plugin uses the same
|
|
30
|
+
* matcher shape (`createLinkMatcherWithRegExp` + `attributes`) and the same
|
|
31
|
+
* new-tab defaults, so EPS can pass its own richer matcher set (e.g. shortform
|
|
32
|
+
* `D123` / `T456` / `S789` intern URLs) through the `matchers` prop without
|
|
33
|
+
* changing the contract. EPS ships a hardened fork of the transform itself
|
|
34
|
+
* (expanded separators, code-block exclusion) — astryx stays on the OSS
|
|
35
|
+
* `AutoLinkPlugin`, and EPS can substitute its own plugin in the same slot.
|
|
36
|
+
*/
|
|
37
|
+
import { AutoLinkPlugin, createLinkMatcherWithRegExp } from '@lexical/react/LexicalAutoLinkPlugin';
|
|
38
|
+
import { URL_MATCHER, EMAIL_MATCHER, sanitizeUrl } from "./linkUtils.js";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Attributes written onto every auto-created link so it opens in a new tab.
|
|
42
|
+
* `rel="noopener noreferrer"` is required whenever `target="_blank"` is set, to
|
|
43
|
+
* prevent reverse-tabnabbing. Matches EPS eps-lexical's `NEW_TAB_LINK_ATTRIBUTES`.
|
|
44
|
+
*/
|
|
45
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
46
|
+
export const NEW_TAB_LINK_ATTRIBUTES = {
|
|
47
|
+
target: '_blank',
|
|
48
|
+
rel: 'noopener noreferrer'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Default matchers: bare URLs (defaulting to `https://` when scheme-less) and
|
|
53
|
+
* email addresses (as `mailto:` links). Both carry {@link NEW_TAB_LINK_ATTRIBUTES}.
|
|
54
|
+
* URLs are passed through {@link sanitizeUrl} so only http/https/mailto/tel
|
|
55
|
+
* schemes are ever written.
|
|
56
|
+
*/
|
|
57
|
+
export const DEFAULT_LINK_MATCHERS = [text => {
|
|
58
|
+
const match = createLinkMatcherWithRegExp(URL_MATCHER, url => sanitizeUrl(url))(text);
|
|
59
|
+
return match ? {
|
|
60
|
+
...match,
|
|
61
|
+
attributes: NEW_TAB_LINK_ATTRIBUTES
|
|
62
|
+
} : null;
|
|
63
|
+
}, text => {
|
|
64
|
+
const match = createLinkMatcherWithRegExp(EMAIL_MATCHER, email => `mailto:${email}`)(text);
|
|
65
|
+
return match ? {
|
|
66
|
+
...match,
|
|
67
|
+
attributes: NEW_TAB_LINK_ATTRIBUTES
|
|
68
|
+
} : null;
|
|
69
|
+
}];
|
|
70
|
+
/**
|
|
71
|
+
* Automatically converts typed/pasted URLs and email addresses into links.
|
|
72
|
+
* Render it inside the editor's `plugins` slot — it reaches the editor via
|
|
73
|
+
* `useLexicalComposerContext()`, so it must live within the editor's
|
|
74
|
+
* `LexicalComposer`. Requires `AutoLinkNode` (registered by default).
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```
|
|
78
|
+
* import {RichTextEditor, RichTextEditorAutoLinkPlugin} from '@astryxdesign/lab';
|
|
79
|
+
*
|
|
80
|
+
* <RichTextEditor
|
|
81
|
+
* label="Notes"
|
|
82
|
+
* plugins={<RichTextEditorAutoLinkPlugin />}
|
|
83
|
+
* />
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function RichTextEditorAutoLinkPlugin({
|
|
87
|
+
matchers = DEFAULT_LINK_MATCHERS,
|
|
88
|
+
onChange
|
|
89
|
+
}) {
|
|
90
|
+
return /*#__PURE__*/_jsx(AutoLinkPlugin, {
|
|
91
|
+
matchers: matchers,
|
|
92
|
+
onChange: onChange
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
RichTextEditorAutoLinkPlugin.displayName = 'RichTextEditorAutoLinkPlugin';
|
|
@@ -41,6 +41,7 @@ export declare const RICHTEXT_ICON_KEYS: {
|
|
|
41
41
|
readonly underline: "richtext:underline";
|
|
42
42
|
readonly strikethrough: "richtext:strikethrough";
|
|
43
43
|
readonly code: "richtext:code";
|
|
44
|
+
readonly link: "richtext:link";
|
|
44
45
|
readonly h1: "richtext:h1";
|
|
45
46
|
readonly h2: "richtext:h2";
|
|
46
47
|
readonly h3: "richtext:h3";
|
|
@@ -63,6 +64,34 @@ export interface RichTextEditorToolbarProps {
|
|
|
63
64
|
headingLevels?: ReadonlyArray<'h1' | 'h2' | 'h3'>;
|
|
64
65
|
/** Toolbar size, forwarded to the Astryx Toolbar. @default 'sm' */
|
|
65
66
|
size?: 'sm' | 'md' | 'lg';
|
|
67
|
+
/**
|
|
68
|
+
* Whether to show the insert/edit-link button. When enabled, pressing it on a
|
|
69
|
+
* collapsed or non-link selection prompts for a URL (via `promptForUrl`,
|
|
70
|
+
* `window.prompt` by default) and wraps the selection in a link; pressing it
|
|
71
|
+
* while a link is selected removes the link.
|
|
72
|
+
*
|
|
73
|
+
* Requires `LinkNode` to be registered (it is, by default) — no extra setup.
|
|
74
|
+
* The entered URL is sanitized (see `sanitizeUrl`) so only
|
|
75
|
+
* http/https/mailto/tel links are written.
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
hasLink?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Called to obtain a URL when the link button is pressed on a non-link
|
|
81
|
+
* selection. Return the URL string to link, or `null`/`''` to cancel.
|
|
82
|
+
* Receives the currently selected text as a hint. Defaults to
|
|
83
|
+
* `window.prompt`. Override to plug in a custom (e.g. Astryx Dialog) prompt.
|
|
84
|
+
*/
|
|
85
|
+
promptForUrl?: (selectedText: string) => string | null | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Whether links created via the toolbar open in a new tab. When `true`
|
|
88
|
+
* (default), the created link carries `target="_blank"` and
|
|
89
|
+
* `rel="noopener noreferrer"` — written into the link node's data (so it
|
|
90
|
+
* serializes and round-trips), not patched onto the DOM. Set `false` to
|
|
91
|
+
* create same-tab links.
|
|
92
|
+
* @default true
|
|
93
|
+
*/
|
|
94
|
+
linkOpensInNewTab?: boolean;
|
|
66
95
|
/**
|
|
67
96
|
* Extra items rendered at the end of the toolbar (after a divider). Use this
|
|
68
97
|
* to compose product-specific controls (e.g. mentions, AI) alongside the
|
|
@@ -90,7 +119,7 @@ export interface RichTextEditorToolbarProps {
|
|
|
90
119
|
* />
|
|
91
120
|
* ```
|
|
92
121
|
*/
|
|
93
|
-
export declare function RichTextEditorToolbar({ label, headingLevels, size, endContent, }: RichTextEditorToolbarProps): import("react").JSX.Element;
|
|
122
|
+
export declare function RichTextEditorToolbar({ label, headingLevels, size, hasLink, promptForUrl, linkOpensInNewTab, endContent, }: RichTextEditorToolbarProps): import("react").JSX.Element;
|
|
94
123
|
export declare namespace RichTextEditorToolbar {
|
|
95
124
|
var displayName: string;
|
|
96
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditorToolbar.d.ts","sourceRoot":"","sources":["../../src/RichTextEditor/RichTextEditorToolbar.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAmC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RichTextEditorToolbar.d.ts","sourceRoot":"","sources":["../../src/RichTextEditor/RichTextEditorToolbar.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAmC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAqEvE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;CAerB,CAAC;AAyNX,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,mEAAmE;IACnE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnE;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;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,+BA+W5B;yBAvXe,qBAAqB"}
|