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