@portabletext/toolbar 1.0.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.cts +361 -509
  2. package/dist/index.d.ts +361 -509
  3. package/package.json +7 -7
package/dist/index.d.cts CHANGED
@@ -1,522 +1,227 @@
1
- import {
2
- AnnotationPath,
3
- AnnotationSchemaType,
4
- BlockObjectSchemaType,
5
- BlockPath,
6
- ChildPath,
7
- DecoratorDefinition,
8
- DecoratorSchemaType,
9
- InlineObjectSchemaType,
10
- ListSchemaType,
11
- PortableTextObject,
12
- StyleSchemaType,
13
- } from '@portabletext/editor'
14
- import {InsertPlacement} from '@portabletext/editor/behaviors'
15
- import type {KeyboardShortcut} from '@portabletext/keyboard-shortcuts'
16
- import type {RefObject} from 'react'
17
-
18
- declare type ActiveContext = {
19
- annotations: Array<{
20
- value: PortableTextObject
21
- schemaType: ToolbarAnnotationSchemaType
22
- at: AnnotationPath
23
- }>
24
- elementRef: RefObject<Element | null>
25
- }
26
-
27
- declare type ActiveContext_2 = {
28
- blockObjects: Array<{
29
- value: PortableTextObject
30
- schemaType: ToolbarBlockObjectSchemaType
31
- at: BlockPath
32
- }>
33
- elementRef: RefObject<Element | null>
34
- }
35
-
36
- declare type ActiveContext_3 = {
37
- inlineObjects: Array<{
38
- value: PortableTextObject
39
- schemaType: ToolbarInlineObjectSchemaType
40
- at: ChildPath
41
- }>
42
- elementRef: RefObject<Element | null>
43
- }
44
-
1
+ import { AnnotationPath, AnnotationSchemaType, BlockObjectSchemaType, BlockPath, ChildPath, DecoratorDefinition, DecoratorSchemaType, InlineObjectSchemaType, ListSchemaType, PortableTextObject, StyleSchemaType } from "@portabletext/editor";
2
+ import { KeyboardShortcut } from "@portabletext/keyboard-shortcuts";
3
+ import { RefObject } from "react";
45
4
  /**
46
5
  * @beta
47
6
  */
48
- export declare type AnnotationButton = {
49
- snapshot: {
50
- matches: (
51
- state:
52
- | 'disabled'
53
- | 'enabled'
54
- | {
55
- disabled: 'inactive'
56
- }
57
- | {
58
- disabled: 'active'
59
- }
60
- | {
61
- enabled: 'inactive'
62
- }
63
- | {
64
- enabled: {
65
- inactive: 'idle'
66
- }
67
- }
68
- | {
69
- enabled: {
70
- inactive: 'showing dialog'
71
- }
72
- }
73
- | {
74
- enabled: 'active'
75
- },
76
- ) => boolean
77
- }
78
- send: (event: AnnotationButtonEvent) => void
79
- }
80
-
81
- /**
82
- * @beta
83
- */
84
- export declare type AnnotationButtonEvent =
85
- | {
86
- type: 'close dialog'
87
- }
88
- | {
89
- type: 'open dialog'
90
- }
91
- | {
92
- type: 'add'
93
- annotation: {
94
- value: Record<string, unknown>
95
- }
96
- }
97
- | {
98
- type: 'remove'
99
- }
100
-
101
- /**
102
- * @beta
103
- */
104
- export declare type AnnotationPopover = {
105
- snapshot: {
106
- context: ActiveContext
107
- matches: (
108
- state:
109
- | 'disabled'
110
- | 'enabled'
111
- | {
112
- enabled: 'inactive' | 'active'
113
- },
114
- ) => boolean
115
- }
116
- send: (event: AnnotationPopoverEvent) => void
117
- }
118
-
119
- /**
120
- * @beta
121
- */
122
- export declare type AnnotationPopoverEvent =
123
- | {
124
- type: 'remove'
125
- schemaType: AnnotationSchemaType
126
- }
127
- | {
128
- type: 'edit'
129
- at: AnnotationPath
130
- props: {
131
- [key: string]: unknown
132
- }
133
- }
134
- | {
135
- type: 'close'
136
- }
137
-
138
- /**
139
- * @beta
140
- */
141
- export declare type BlockObjectButton = {
142
- snapshot: {
143
- matches: (
144
- state:
145
- | 'disabled'
146
- | 'enabled'
147
- | {
148
- enabled: 'idle'
149
- }
150
- | {
151
- enabled: 'showing dialog'
152
- },
153
- ) => boolean
154
- }
155
- send: (event: BlockObjectButtonEvent) => void
156
- }
157
-
158
- /**
159
- * @beta
160
- */
161
- export declare type BlockObjectButtonEvent =
162
- | {
163
- type: 'close dialog'
164
- }
165
- | {
166
- type: 'open dialog'
167
- }
168
- | {
169
- type: 'insert'
170
- value: {
171
- [key: string]: unknown
172
- }
173
- placement: InsertPlacement | undefined
174
- }
175
-
176
- /**
177
- * @beta
178
- */
179
- export declare type BlockObjectPopover = {
180
- snapshot: {
181
- context: ActiveContext_2
182
- matches: (
183
- state:
184
- | 'disabled'
185
- | 'enabled'
186
- | {
187
- enabled: 'inactive' | 'active'
188
- },
189
- ) => boolean
190
- }
191
- send: (event: BlockObjectPopoverEvent) => void
192
- }
193
-
194
- /**
195
- * @beta
196
- */
197
- export declare type BlockObjectPopoverEvent =
198
- | {
199
- type: 'remove'
200
- at: BlockPath
201
- }
202
- | {
203
- type: 'edit'
204
- at: BlockPath
205
- props: {
206
- [key: string]: unknown
207
- }
208
- }
209
- | {
210
- type: 'close'
211
- }
212
-
213
- /**
214
- * @beta
215
- */
216
- export declare type DecoratorButton = {
217
- snapshot: {
218
- matches: (
219
- state:
220
- | 'disabled'
221
- | 'enabled'
222
- | {
223
- disabled: 'inactive'
224
- }
225
- | {
226
- disabled: 'active'
227
- }
228
- | {
229
- enabled: 'inactive'
230
- }
231
- | {
232
- enabled: 'active'
233
- },
234
- ) => boolean
235
- }
236
- send: (event: DecoratorButtonEvent) => void
237
- }
238
-
7
+ type ExtendDecoratorSchemaType = (decorator: DecoratorSchemaType) => ToolbarDecoratorSchemaType;
239
8
  /**
240
9
  * @beta
241
10
  */
242
- export declare type DecoratorButtonEvent = {
243
- type: 'toggle'
244
- }
245
-
11
+ type ExtendAnnotationSchemaType = (annotation: AnnotationSchemaType) => ToolbarAnnotationSchemaType;
246
12
  /**
247
13
  * @beta
248
14
  */
249
- export declare type ExtendAnnotationSchemaType = (
250
- annotation: AnnotationSchemaType,
251
- ) => ToolbarAnnotationSchemaType
252
-
15
+ type ExtendListSchemaType = (list: ListSchemaType) => ToolbarListSchemaType;
253
16
  /**
254
17
  * @beta
255
18
  */
256
- export declare type ExtendBlockObjectSchemaType = (
257
- blockObject: BlockObjectSchemaType,
258
- ) => ToolbarBlockObjectSchemaType
259
-
19
+ type ExtendBlockObjectSchemaType = (blockObject: BlockObjectSchemaType) => ToolbarBlockObjectSchemaType;
260
20
  /**
261
21
  * @beta
262
22
  */
263
- export declare type ExtendDecoratorSchemaType = (
264
- decorator: DecoratorSchemaType,
265
- ) => ToolbarDecoratorSchemaType
266
-
23
+ type ExtendInlineObjectSchemaType = (inlineObject: InlineObjectSchemaType) => ToolbarInlineObjectSchemaType;
267
24
  /**
268
25
  * @beta
269
26
  */
270
- export declare type ExtendInlineObjectSchemaType = (
271
- inlineObject: InlineObjectSchemaType,
272
- ) => ToolbarInlineObjectSchemaType
273
-
27
+ type ExtendStyleSchemaType = (style: StyleSchemaType) => ToolbarStyleSchemaType;
274
28
  /**
275
29
  * @beta
30
+ * Extend the editor's schema with default values, icons, shortcuts and more.
31
+ * This makes it easier to use the schema to render toolbars, forms and other
32
+ * UI components.
276
33
  */
277
- export declare type ExtendListSchemaType = (
278
- list: ListSchemaType,
279
- ) => ToolbarListSchemaType
280
-
34
+ declare function useToolbarSchema(props: {
35
+ extendDecorator?: (decorator: DecoratorSchemaType) => ToolbarDecoratorSchemaType;
36
+ extendAnnotation?: (annotation: AnnotationSchemaType) => ToolbarAnnotationSchemaType;
37
+ extendList?: (list: ListSchemaType) => ToolbarListSchemaType;
38
+ extendBlockObject?: (blockObject: BlockObjectSchemaType) => ToolbarBlockObjectSchemaType;
39
+ extendInlineObject?: (inlineObject: InlineObjectSchemaType) => ToolbarInlineObjectSchemaType;
40
+ extendStyle?: (style: StyleSchemaType) => ToolbarStyleSchemaType;
41
+ }): ToolbarSchema;
281
42
  /**
282
43
  * @beta
283
44
  */
284
- export declare type ExtendStyleSchemaType = (
285
- style: StyleSchemaType,
286
- ) => ToolbarStyleSchemaType
287
-
45
+ type ToolbarSchema = {
46
+ decorators?: ReadonlyArray<ToolbarDecoratorSchemaType>;
47
+ annotations?: ReadonlyArray<ToolbarAnnotationSchemaType>;
48
+ lists?: ReadonlyArray<ToolbarListSchemaType>;
49
+ blockObjects?: ReadonlyArray<ToolbarBlockObjectSchemaType>;
50
+ inlineObjects?: ReadonlyArray<ToolbarInlineObjectSchemaType>;
51
+ styles?: ReadonlyArray<ToolbarStyleSchemaType>;
52
+ };
288
53
  /**
289
54
  * @beta
290
55
  */
291
- export declare type HistoryButtons = {
292
- snapshot: {
293
- matches: (state: 'disabled' | 'enabled') => boolean
294
- }
295
- send: (event: HistoryButtonsEvent) => void
296
- }
297
-
56
+ type ToolbarDecoratorSchemaType = DecoratorSchemaType & {
57
+ icon?: React.ComponentType;
58
+ shortcut?: KeyboardShortcut;
59
+ mutuallyExclusive?: ReadonlyArray<DecoratorDefinition['name']>;
60
+ };
298
61
  /**
299
62
  * @beta
300
63
  */
301
- export declare type HistoryButtonsEvent =
302
- | {
303
- type: 'history.undo'
304
- }
305
- | {
306
- type: 'history.redo'
307
- }
308
-
64
+ type ToolbarAnnotationSchemaType = AnnotationSchemaType & {
65
+ icon?: React.ComponentType;
66
+ defaultValues?: Record<string, unknown>;
67
+ shortcut?: KeyboardShortcut;
68
+ };
309
69
  /**
310
70
  * @beta
311
71
  */
312
- export declare type InlineObjectButton = {
313
- snapshot: {
314
- matches: (
315
- state:
316
- | 'disabled'
317
- | 'enabled'
318
- | {
319
- enabled: 'idle'
320
- }
321
- | {
322
- enabled: 'showing dialog'
323
- },
324
- ) => boolean
325
- }
326
- send: (event: InlineObjectButtonEvent) => void
327
- }
328
-
329
- /**
330
- * @beta
331
- */
332
- export declare type InlineObjectButtonEvent =
333
- | {
334
- type: 'close dialog'
335
- }
336
- | {
337
- type: 'open dialog'
338
- }
339
- | {
340
- type: 'insert'
341
- value: {
342
- [key: string]: unknown
343
- }
344
- }
345
-
346
- /**
347
- * @beta
348
- */
349
- export declare type InlineObjectPopover = {
350
- snapshot: {
351
- context: ActiveContext_3
352
- matches: (
353
- state:
354
- | 'disabled'
355
- | 'enabled'
356
- | {
357
- enabled: 'inactive' | 'active'
358
- },
359
- ) => boolean
360
- }
361
- send: (event: InlineObjectPopoverEvent) => void
362
- }
363
-
364
- /**
365
- * @beta
366
- */
367
- export declare type InlineObjectPopoverEvent =
368
- | {
369
- type: 'remove'
370
- at: ChildPath
371
- }
372
- | {
373
- type: 'edit'
374
- at: ChildPath
375
- props: {
376
- [key: string]: unknown
377
- }
378
- }
379
- | {
380
- type: 'close'
381
- }
382
-
383
- /**
384
- * @beta
385
- */
386
- export declare type ListButton = {
387
- snapshot: {
388
- matches: (
389
- state:
390
- | 'disabled'
391
- | 'enabled'
392
- | {
393
- disabled: 'inactive'
394
- }
395
- | {
396
- disabled: 'active'
397
- }
398
- | {
399
- enabled: 'inactive'
400
- }
401
- | {
402
- enabled: 'active'
403
- },
404
- ) => boolean
405
- }
406
- send: (event: ListButtonEvent) => void
407
- }
408
-
409
- /**
410
- * @beta
411
- */
412
- export declare type ListButtonEvent = {
413
- type: 'toggle'
414
- }
415
-
416
- /**
417
- * @beta
418
- */
419
- export declare type StyleSelector = {
420
- snapshot: {
421
- matches: (state: 'disabled' | 'enabled') => boolean
422
- context: {
423
- activeStyle: StyleSchemaType['name'] | undefined
424
- }
425
- }
426
- send: (event: StyleSelectorEvent) => void
427
- }
428
-
72
+ type ToolbarListSchemaType = ListSchemaType & {
73
+ icon?: React.ComponentType;
74
+ };
75
+ /**
76
+ * @beta
77
+ */
78
+ type ToolbarBlockObjectSchemaType = BlockObjectSchemaType & {
79
+ icon?: React.ComponentType;
80
+ defaultValues?: Record<string, unknown>;
81
+ shortcut?: KeyboardShortcut;
82
+ };
83
+ /**
84
+ * @beta
85
+ */
86
+ type ToolbarInlineObjectSchemaType = InlineObjectSchemaType & {
87
+ icon?: React.ComponentType;
88
+ defaultValues?: Record<string, unknown>;
89
+ shortcut?: KeyboardShortcut;
90
+ };
429
91
  /**
430
92
  * @beta
431
93
  */
432
- export declare type StyleSelectorEvent = {
433
- type: 'toggle'
434
- style: StyleSchemaType['name']
435
- }
436
-
94
+ type ToolbarStyleSchemaType = StyleSchemaType & {
95
+ icon?: React.ComponentType;
96
+ shortcut?: KeyboardShortcut;
97
+ };
437
98
  /**
438
99
  * @beta
439
100
  */
440
- export declare type ToolbarAnnotationSchemaType = AnnotationSchemaType & {
441
- icon?: React.ComponentType
442
- defaultValues?: Record<string, unknown>
443
- shortcut?: KeyboardShortcut
444
- }
445
-
101
+ type AnnotationButtonEvent = {
102
+ type: 'close dialog';
103
+ } | {
104
+ type: 'open dialog';
105
+ } | {
106
+ type: 'add';
107
+ annotation: {
108
+ value: Record<string, unknown>;
109
+ };
110
+ } | {
111
+ type: 'remove';
112
+ };
446
113
  /**
447
114
  * @beta
448
115
  */
449
- export declare type ToolbarBlockObjectSchemaType = BlockObjectSchemaType & {
450
- icon?: React.ComponentType
451
- defaultValues?: Record<string, unknown>
452
- shortcut?: KeyboardShortcut
453
- }
454
-
116
+ type AnnotationButton = {
117
+ snapshot: {
118
+ matches: (state: 'disabled' | 'enabled' | {
119
+ disabled: 'inactive';
120
+ } | {
121
+ disabled: 'active';
122
+ } | {
123
+ enabled: 'inactive';
124
+ } | {
125
+ enabled: {
126
+ inactive: 'idle';
127
+ };
128
+ } | {
129
+ enabled: {
130
+ inactive: 'showing dialog';
131
+ };
132
+ } | {
133
+ enabled: 'active';
134
+ }) => boolean;
135
+ };
136
+ send: (event: AnnotationButtonEvent) => void;
137
+ };
455
138
  /**
456
139
  * @beta
140
+ * Manages the state, keyboard shortcut and available events for an annotation
141
+ * button.
142
+ *
143
+ * Note: This hook assumes that the button triggers a dialog for inputting
144
+ * the annotation value.
457
145
  */
458
- export declare type ToolbarDecoratorSchemaType = DecoratorSchemaType & {
459
- icon?: React.ComponentType
460
- shortcut?: KeyboardShortcut
461
- mutuallyExclusive?: ReadonlyArray<DecoratorDefinition['name']>
462
- }
463
-
146
+ declare function useAnnotationButton(props: {
147
+ schemaType: ToolbarAnnotationSchemaType;
148
+ }): AnnotationButton;
149
+ type ActiveContext$2 = {
150
+ annotations: Array<{
151
+ value: PortableTextObject;
152
+ schemaType: ToolbarAnnotationSchemaType;
153
+ at: AnnotationPath;
154
+ }>;
155
+ elementRef: RefObject<Element | null>;
156
+ };
464
157
  /**
465
158
  * @beta
466
159
  */
467
- export declare type ToolbarInlineObjectSchemaType = InlineObjectSchemaType & {
468
- icon?: React.ComponentType
469
- defaultValues?: Record<string, unknown>
470
- shortcut?: KeyboardShortcut
471
- }
472
-
160
+ type AnnotationPopoverEvent = {
161
+ type: 'remove';
162
+ schemaType: AnnotationSchemaType;
163
+ } | {
164
+ type: 'edit';
165
+ at: AnnotationPath;
166
+ props: {
167
+ [key: string]: unknown;
168
+ };
169
+ } | {
170
+ type: 'close';
171
+ };
473
172
  /**
474
173
  * @beta
475
174
  */
476
- export declare type ToolbarListSchemaType = ListSchemaType & {
477
- icon?: React.ComponentType
478
- }
479
-
175
+ type AnnotationPopover = {
176
+ snapshot: {
177
+ context: ActiveContext$2;
178
+ matches: (state: 'disabled' | 'enabled' | {
179
+ enabled: 'inactive' | 'active';
180
+ }) => boolean;
181
+ };
182
+ send: (event: AnnotationPopoverEvent) => void;
183
+ };
480
184
  /**
481
185
  * @beta
186
+ * Manages the state and available events for an annotation popover.
482
187
  */
483
- export declare type ToolbarSchema = {
484
- decorators?: ReadonlyArray<ToolbarDecoratorSchemaType>
485
- annotations?: ReadonlyArray<ToolbarAnnotationSchemaType>
486
- lists?: ReadonlyArray<ToolbarListSchemaType>
487
- blockObjects?: ReadonlyArray<ToolbarBlockObjectSchemaType>
488
- inlineObjects?: ReadonlyArray<ToolbarInlineObjectSchemaType>
489
- styles?: ReadonlyArray<ToolbarStyleSchemaType>
490
- }
491
-
188
+ declare function useAnnotationPopover(props: {
189
+ schemaTypes: ReadonlyArray<ToolbarAnnotationSchemaType>;
190
+ }): AnnotationPopover;
492
191
  /**
493
192
  * @beta
494
193
  */
495
- export declare type ToolbarStyleSchemaType = StyleSchemaType & {
496
- icon?: React.ComponentType
497
- shortcut?: KeyboardShortcut
498
- }
499
-
194
+ type InsertPlacement = 'auto' | 'after' | 'before';
195
+ /**************************************
196
+ * Abstract events
197
+ **************************************/
500
198
  /**
501
199
  * @beta
502
- * Manages the state, keyboard shortcut and available events for an annotation
503
- * button.
504
- *
505
- * Note: This hook assumes that the button triggers a dialog for inputting
506
- * the annotation value.
507
200
  */
508
- export declare function useAnnotationButton(props: {
509
- schemaType: ToolbarAnnotationSchemaType
510
- }): AnnotationButton
511
-
201
+ type BlockObjectButtonEvent = {
202
+ type: 'close dialog';
203
+ } | {
204
+ type: 'open dialog';
205
+ } | {
206
+ type: 'insert';
207
+ value: {
208
+ [key: string]: unknown;
209
+ };
210
+ placement: InsertPlacement | undefined;
211
+ };
512
212
  /**
513
213
  * @beta
514
- * Manages the state and available events for an annotation popover.
515
214
  */
516
- export declare function useAnnotationPopover(props: {
517
- schemaTypes: ReadonlyArray<ToolbarAnnotationSchemaType>
518
- }): AnnotationPopover
519
-
215
+ type BlockObjectButton = {
216
+ snapshot: {
217
+ matches: (state: 'disabled' | 'enabled' | {
218
+ enabled: 'idle';
219
+ } | {
220
+ enabled: 'showing dialog';
221
+ }) => boolean;
222
+ };
223
+ send: (event: BlockObjectButtonEvent) => void;
224
+ };
520
225
  /**
521
226
  * @beta
522
227
  * Manages the state, keyboard shortcut and available events for a block
@@ -525,32 +230,129 @@ export declare function useAnnotationPopover(props: {
525
230
  * Note: This hook assumes that the button triggers a dialog for inputting
526
231
  * the block object value.
527
232
  */
528
- export declare function useBlockObjectButton(props: {
529
- schemaType: ToolbarBlockObjectSchemaType
530
- }): BlockObjectButton
531
-
233
+ declare function useBlockObjectButton(props: {
234
+ schemaType: ToolbarBlockObjectSchemaType;
235
+ }): BlockObjectButton;
236
+ type ActiveContext$1 = {
237
+ blockObjects: Array<{
238
+ value: PortableTextObject;
239
+ schemaType: ToolbarBlockObjectSchemaType;
240
+ at: BlockPath;
241
+ }>;
242
+ elementRef: RefObject<Element | null>;
243
+ };
244
+ /**
245
+ * @beta
246
+ */
247
+ type BlockObjectPopoverEvent = {
248
+ type: 'remove';
249
+ at: BlockPath;
250
+ } | {
251
+ type: 'edit';
252
+ at: BlockPath;
253
+ props: {
254
+ [key: string]: unknown;
255
+ };
256
+ } | {
257
+ type: 'close';
258
+ };
259
+ /**
260
+ * @beta
261
+ */
262
+ type BlockObjectPopover = {
263
+ snapshot: {
264
+ context: ActiveContext$1;
265
+ matches: (state: 'disabled' | 'enabled' | {
266
+ enabled: 'inactive' | 'active';
267
+ }) => boolean;
268
+ };
269
+ send: (event: BlockObjectPopoverEvent) => void;
270
+ };
532
271
  /**
533
272
  * @beta
534
273
  * Manages the state and available events for a block object popover.
535
274
  */
536
- export declare function useBlockObjectPopover(props: {
537
- schemaTypes: ReadonlyArray<ToolbarBlockObjectSchemaType>
538
- }): BlockObjectPopover
539
-
275
+ declare function useBlockObjectPopover(props: {
276
+ schemaTypes: ReadonlyArray<ToolbarBlockObjectSchemaType>;
277
+ }): BlockObjectPopover;
278
+ /**
279
+ * @beta
280
+ */
281
+ type DecoratorButtonEvent = {
282
+ type: 'toggle';
283
+ };
284
+ /**
285
+ * @beta
286
+ */
287
+ type DecoratorButton = {
288
+ snapshot: {
289
+ matches: (state: 'disabled' | 'enabled' | {
290
+ disabled: 'inactive';
291
+ } | {
292
+ disabled: 'active';
293
+ } | {
294
+ enabled: 'inactive';
295
+ } | {
296
+ enabled: 'active';
297
+ }) => boolean;
298
+ };
299
+ send: (event: DecoratorButtonEvent) => void;
300
+ };
540
301
  /**
541
302
  * @beta
542
303
  * Manages the state, keyboard shortcuts and available events for a decorator
543
304
  * button and sets up mutually exclusive decorator behaviors.
544
305
  */
545
- export declare function useDecoratorButton(props: {
546
- schemaType: ToolbarDecoratorSchemaType
547
- }): DecoratorButton
548
-
306
+ declare function useDecoratorButton(props: {
307
+ schemaType: ToolbarDecoratorSchemaType;
308
+ }): DecoratorButton;
309
+ /**
310
+ * @beta
311
+ */
312
+ type HistoryButtonsEvent = {
313
+ type: 'history.undo';
314
+ } | {
315
+ type: 'history.redo';
316
+ };
317
+ /**
318
+ * @beta
319
+ */
320
+ type HistoryButtons = {
321
+ snapshot: {
322
+ matches: (state: 'disabled' | 'enabled') => boolean;
323
+ };
324
+ send: (event: HistoryButtonsEvent) => void;
325
+ };
326
+ /**
327
+ * @beta
328
+ */
329
+ declare function useHistoryButtons(): HistoryButtons;
330
+ /**
331
+ * @beta
332
+ */
333
+ type InlineObjectButtonEvent = {
334
+ type: 'close dialog';
335
+ } | {
336
+ type: 'open dialog';
337
+ } | {
338
+ type: 'insert';
339
+ value: {
340
+ [key: string]: unknown;
341
+ };
342
+ };
549
343
  /**
550
344
  * @beta
551
345
  */
552
- export declare function useHistoryButtons(): HistoryButtons
553
-
346
+ type InlineObjectButton = {
347
+ snapshot: {
348
+ matches: (state: 'disabled' | 'enabled' | {
349
+ enabled: 'idle';
350
+ } | {
351
+ enabled: 'showing dialog';
352
+ }) => boolean;
353
+ };
354
+ send: (event: InlineObjectButtonEvent) => void;
355
+ };
554
356
  /**
555
357
  * @beta
556
358
  * Manages the state, keyboard shortcut and available events for an inline
@@ -559,56 +361,106 @@ export declare function useHistoryButtons(): HistoryButtons
559
361
  * Note: This hook assumes that the button triggers a dialog for inputting
560
362
  * the inline object value.
561
363
  */
562
- export declare function useInlineObjectButton(props: {
563
- schemaType: ToolbarInlineObjectSchemaType
564
- }): InlineObjectButton
565
-
364
+ declare function useInlineObjectButton(props: {
365
+ schemaType: ToolbarInlineObjectSchemaType;
366
+ }): InlineObjectButton;
367
+ type ActiveContext = {
368
+ inlineObjects: Array<{
369
+ value: PortableTextObject;
370
+ schemaType: ToolbarInlineObjectSchemaType;
371
+ at: ChildPath;
372
+ }>;
373
+ elementRef: RefObject<Element | null>;
374
+ };
375
+ /**
376
+ * @beta
377
+ */
378
+ type InlineObjectPopoverEvent = {
379
+ type: 'remove';
380
+ at: ChildPath;
381
+ } | {
382
+ type: 'edit';
383
+ at: ChildPath;
384
+ props: {
385
+ [key: string]: unknown;
386
+ };
387
+ } | {
388
+ type: 'close';
389
+ };
390
+ /**
391
+ * @beta
392
+ */
393
+ type InlineObjectPopover = {
394
+ snapshot: {
395
+ context: ActiveContext;
396
+ matches: (state: 'disabled' | 'enabled' | {
397
+ enabled: 'inactive' | 'active';
398
+ }) => boolean;
399
+ };
400
+ send: (event: InlineObjectPopoverEvent) => void;
401
+ };
566
402
  /**
567
403
  * @beta
568
404
  * Manages the state and available events for an inline object popover.
569
405
  */
570
- export declare function useInlineObjectPopover(props: {
571
- schemaTypes: ReadonlyArray<ToolbarInlineObjectSchemaType>
572
- }): InlineObjectPopover
573
-
406
+ declare function useInlineObjectPopover(props: {
407
+ schemaTypes: ReadonlyArray<ToolbarInlineObjectSchemaType>;
408
+ }): InlineObjectPopover;
409
+ /**
410
+ * @beta
411
+ */
412
+ type ListButtonEvent = {
413
+ type: 'toggle';
414
+ };
415
+ /**
416
+ * @beta
417
+ */
418
+ type ListButton = {
419
+ snapshot: {
420
+ matches: (state: 'disabled' | 'enabled' | {
421
+ disabled: 'inactive';
422
+ } | {
423
+ disabled: 'active';
424
+ } | {
425
+ enabled: 'inactive';
426
+ } | {
427
+ enabled: 'active';
428
+ }) => boolean;
429
+ };
430
+ send: (event: ListButtonEvent) => void;
431
+ };
574
432
  /**
575
433
  * @beta
576
434
  * Manages the state, keyboard shortcuts and available events for a list button.
577
435
  */
578
- export declare function useListButton(props: {
579
- schemaType: ToolbarListSchemaType
580
- }): ListButton
581
-
436
+ declare function useListButton(props: {
437
+ schemaType: ToolbarListSchemaType;
438
+ }): ListButton;
582
439
  /**
583
440
  * @beta
584
- * Manages the state, keyboard shortcuts and available events for a style
585
- * selector.
586
441
  */
587
- export declare function useStyleSelector(props: {
588
- schemaTypes: ReadonlyArray<ToolbarStyleSchemaType>
589
- }): StyleSelector
590
-
442
+ type StyleSelectorEvent = {
443
+ type: 'toggle';
444
+ style: StyleSchemaType['name'];
445
+ };
591
446
  /**
592
447
  * @beta
593
- * Extend the editor's schema with default values, icons, shortcuts and more.
594
- * This makes it easier to use the schema to render toolbars, forms and other
595
- * UI components.
596
448
  */
597
- export declare function useToolbarSchema(props: {
598
- extendDecorator?: (
599
- decorator: DecoratorSchemaType,
600
- ) => ToolbarDecoratorSchemaType
601
- extendAnnotation?: (
602
- annotation: AnnotationSchemaType,
603
- ) => ToolbarAnnotationSchemaType
604
- extendList?: (list: ListSchemaType) => ToolbarListSchemaType
605
- extendBlockObject?: (
606
- blockObject: BlockObjectSchemaType,
607
- ) => ToolbarBlockObjectSchemaType
608
- extendInlineObject?: (
609
- inlineObject: InlineObjectSchemaType,
610
- ) => ToolbarInlineObjectSchemaType
611
- extendStyle?: (style: StyleSchemaType) => ToolbarStyleSchemaType
612
- }): ToolbarSchema
613
-
614
- export {}
449
+ type StyleSelector = {
450
+ snapshot: {
451
+ matches: (state: 'disabled' | 'enabled') => boolean;
452
+ context: {
453
+ activeStyle: StyleSchemaType['name'] | undefined;
454
+ };
455
+ };
456
+ send: (event: StyleSelectorEvent) => void;
457
+ };
458
+ /**
459
+ * @beta
460
+ * Manages the state, keyboard shortcuts and available events for a style
461
+ * selector.
462
+ */
463
+ declare function useStyleSelector(props: {
464
+ schemaTypes: ReadonlyArray<ToolbarStyleSchemaType>;
465
+ }): StyleSelector;
466
+ export { AnnotationButton, AnnotationButtonEvent, AnnotationPopover, AnnotationPopoverEvent, BlockObjectButton, BlockObjectButtonEvent, BlockObjectPopover, BlockObjectPopoverEvent, DecoratorButton, DecoratorButtonEvent, ExtendAnnotationSchemaType, ExtendBlockObjectSchemaType, ExtendDecoratorSchemaType, ExtendInlineObjectSchemaType, ExtendListSchemaType, ExtendStyleSchemaType, HistoryButtons, HistoryButtonsEvent, InlineObjectButton, InlineObjectButtonEvent, InlineObjectPopover, InlineObjectPopoverEvent, ListButton, ListButtonEvent, StyleSelector, StyleSelectorEvent, ToolbarAnnotationSchemaType, ToolbarBlockObjectSchemaType, ToolbarDecoratorSchemaType, ToolbarInlineObjectSchemaType, ToolbarListSchemaType, ToolbarSchema, ToolbarStyleSchemaType, useAnnotationButton, useAnnotationPopover, useBlockObjectButton, useBlockObjectPopover, useDecoratorButton, useHistoryButtons, useInlineObjectButton, useInlineObjectPopover, useListButton, useStyleSelector, useToolbarSchema };