@portabletext/editor 1.35.4 → 1.36.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/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +25 -3
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +25 -3
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.d.cts +33 -282
- package/lib/behaviors/index.d.ts +33 -282
- package/lib/index.d.cts +28 -5
- package/lib/index.d.ts +28 -5
- package/lib/plugins/index.cjs +19 -19
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +17 -5
- package/lib/plugins/index.d.ts +17 -5
- package/lib/plugins/index.js +21 -21
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +6 -5
- package/lib/selectors/index.d.ts +6 -5
- package/lib/utils/index.d.cts +6 -5
- package/lib/utils/index.d.ts +6 -5
- package/package.json +6 -6
- package/src/behavior-actions/behavior.actions.ts +2 -2
- package/src/behaviors/behavior.types.ts +10 -7
- package/src/editor/PortableTextEditor.tsx +22 -0
- package/src/editor/editor-machine.ts +4 -1
- package/src/plugins/index.ts +2 -1
- package/src/plugins/plugin.decorator-shortcut.ts +3 -0
- package/src/utils/util.slice-blocks.test.ts +64 -0
package/lib/behaviors/index.d.ts
CHANGED
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
Values,
|
|
45
45
|
} from 'xstate'
|
|
46
46
|
import {GuardArgs} from 'xstate/guards'
|
|
47
|
-
import {PickFromUnion as PickFromUnion_2} from '.'
|
|
48
47
|
import {
|
|
49
48
|
BlockOffset as BlockOffset_2,
|
|
50
49
|
PortableTextMemberSchemaTypes as PortableTextMemberSchemaTypes_2,
|
|
@@ -61,11 +60,9 @@ import {
|
|
|
61
60
|
export declare type Behavior<
|
|
62
61
|
TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
|
|
63
62
|
TGuardResponse = true,
|
|
64
|
-
TBehaviorEvent extends BehaviorEvent =
|
|
65
|
-
BehaviorEvent
|
|
66
|
-
'type',
|
|
67
|
-
TBehaviorEventType
|
|
68
|
-
>,
|
|
63
|
+
TBehaviorEvent extends BehaviorEvent = TBehaviorEventType extends '*'
|
|
64
|
+
? BehaviorEvent
|
|
65
|
+
: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>,
|
|
69
66
|
> = {
|
|
70
67
|
/**
|
|
71
68
|
* The internal editor event that triggers this behavior.
|
|
@@ -123,6 +120,9 @@ export declare type BehaviorEvent =
|
|
|
123
120
|
| SyntheticBehaviorEvent
|
|
124
121
|
| NativeBehaviorEvent
|
|
125
122
|
| CustomBehaviorEvent
|
|
123
|
+
| {
|
|
124
|
+
type: '*'
|
|
125
|
+
}
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* @beta
|
|
@@ -244,62 +244,10 @@ export declare const coreBehaviors: Behavior_2<
|
|
|
244
244
|
| 'style.toggle'
|
|
245
245
|
| 'key.down'
|
|
246
246
|
| 'key.up'
|
|
247
|
-
| 'paste'
|
|
247
|
+
| 'paste'
|
|
248
|
+
| '*',
|
|
248
249
|
true,
|
|
249
|
-
|
|
250
|
-
BehaviorEvent_2,
|
|
251
|
-
'type',
|
|
252
|
-
| 'focus'
|
|
253
|
-
| 'delete'
|
|
254
|
-
| 'select'
|
|
255
|
-
| 'serialize'
|
|
256
|
-
| 'deserialize'
|
|
257
|
-
| 'serialization.failure'
|
|
258
|
-
| 'serialization.success'
|
|
259
|
-
| 'deserialization.failure'
|
|
260
|
-
| 'deserialization.success'
|
|
261
|
-
| 'copy'
|
|
262
|
-
| `custom.${string}`
|
|
263
|
-
| 'annotation.add'
|
|
264
|
-
| 'annotation.remove'
|
|
265
|
-
| 'annotation.toggle'
|
|
266
|
-
| 'block.set'
|
|
267
|
-
| 'block.unset'
|
|
268
|
-
| 'blur'
|
|
269
|
-
| 'data transfer.set'
|
|
270
|
-
| 'decorator.add'
|
|
271
|
-
| 'decorator.remove'
|
|
272
|
-
| 'decorator.toggle'
|
|
273
|
-
| 'delete.backward'
|
|
274
|
-
| 'delete.block'
|
|
275
|
-
| 'delete.forward'
|
|
276
|
-
| 'delete.text'
|
|
277
|
-
| 'history.redo'
|
|
278
|
-
| 'history.undo'
|
|
279
|
-
| 'insert.blocks'
|
|
280
|
-
| 'insert.block object'
|
|
281
|
-
| 'insert.inline object'
|
|
282
|
-
| 'insert.break'
|
|
283
|
-
| 'insert.soft break'
|
|
284
|
-
| 'insert.block'
|
|
285
|
-
| 'insert.span'
|
|
286
|
-
| 'insert.text'
|
|
287
|
-
| 'insert.text block'
|
|
288
|
-
| 'list item.add'
|
|
289
|
-
| 'list item.remove'
|
|
290
|
-
| 'list item.toggle'
|
|
291
|
-
| 'move.block'
|
|
292
|
-
| 'move.block down'
|
|
293
|
-
| 'move.block up'
|
|
294
|
-
| 'select.previous block'
|
|
295
|
-
| 'select.next block'
|
|
296
|
-
| 'style.add'
|
|
297
|
-
| 'style.remove'
|
|
298
|
-
| 'style.toggle'
|
|
299
|
-
| 'key.down'
|
|
300
|
-
| 'key.up'
|
|
301
|
-
| 'paste'
|
|
302
|
-
>
|
|
250
|
+
BehaviorEvent_2
|
|
303
251
|
>[]
|
|
304
252
|
|
|
305
253
|
/**
|
|
@@ -357,62 +305,10 @@ export declare function createCodeEditorBehaviors(
|
|
|
357
305
|
| 'style.toggle'
|
|
358
306
|
| 'key.down'
|
|
359
307
|
| 'key.up'
|
|
360
|
-
| 'paste'
|
|
308
|
+
| 'paste'
|
|
309
|
+
| '*',
|
|
361
310
|
true,
|
|
362
|
-
|
|
363
|
-
BehaviorEvent_2,
|
|
364
|
-
'type',
|
|
365
|
-
| 'focus'
|
|
366
|
-
| 'delete'
|
|
367
|
-
| 'select'
|
|
368
|
-
| 'serialize'
|
|
369
|
-
| 'deserialize'
|
|
370
|
-
| 'serialization.failure'
|
|
371
|
-
| 'serialization.success'
|
|
372
|
-
| 'deserialization.failure'
|
|
373
|
-
| 'deserialization.success'
|
|
374
|
-
| 'copy'
|
|
375
|
-
| `custom.${string}`
|
|
376
|
-
| 'annotation.add'
|
|
377
|
-
| 'annotation.remove'
|
|
378
|
-
| 'annotation.toggle'
|
|
379
|
-
| 'block.set'
|
|
380
|
-
| 'block.unset'
|
|
381
|
-
| 'blur'
|
|
382
|
-
| 'data transfer.set'
|
|
383
|
-
| 'decorator.add'
|
|
384
|
-
| 'decorator.remove'
|
|
385
|
-
| 'decorator.toggle'
|
|
386
|
-
| 'delete.backward'
|
|
387
|
-
| 'delete.block'
|
|
388
|
-
| 'delete.forward'
|
|
389
|
-
| 'delete.text'
|
|
390
|
-
| 'history.redo'
|
|
391
|
-
| 'history.undo'
|
|
392
|
-
| 'insert.blocks'
|
|
393
|
-
| 'insert.block object'
|
|
394
|
-
| 'insert.inline object'
|
|
395
|
-
| 'insert.break'
|
|
396
|
-
| 'insert.soft break'
|
|
397
|
-
| 'insert.block'
|
|
398
|
-
| 'insert.span'
|
|
399
|
-
| 'insert.text'
|
|
400
|
-
| 'insert.text block'
|
|
401
|
-
| 'list item.add'
|
|
402
|
-
| 'list item.remove'
|
|
403
|
-
| 'list item.toggle'
|
|
404
|
-
| 'move.block'
|
|
405
|
-
| 'move.block down'
|
|
406
|
-
| 'move.block up'
|
|
407
|
-
| 'select.previous block'
|
|
408
|
-
| 'select.next block'
|
|
409
|
-
| 'style.add'
|
|
410
|
-
| 'style.remove'
|
|
411
|
-
| 'style.toggle'
|
|
412
|
-
| 'key.down'
|
|
413
|
-
| 'key.up'
|
|
414
|
-
| 'paste'
|
|
415
|
-
>
|
|
311
|
+
BehaviorEvent_2
|
|
416
312
|
>[]
|
|
417
313
|
|
|
418
314
|
/**
|
|
@@ -470,62 +366,10 @@ export declare function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
|
470
366
|
| 'style.toggle'
|
|
471
367
|
| 'key.down'
|
|
472
368
|
| 'key.up'
|
|
473
|
-
| 'paste'
|
|
369
|
+
| 'paste'
|
|
370
|
+
| '*',
|
|
474
371
|
true,
|
|
475
|
-
|
|
476
|
-
BehaviorEvent_2,
|
|
477
|
-
'type',
|
|
478
|
-
| 'focus'
|
|
479
|
-
| 'delete'
|
|
480
|
-
| 'select'
|
|
481
|
-
| 'serialize'
|
|
482
|
-
| 'deserialize'
|
|
483
|
-
| 'serialization.failure'
|
|
484
|
-
| 'serialization.success'
|
|
485
|
-
| 'deserialization.failure'
|
|
486
|
-
| 'deserialization.success'
|
|
487
|
-
| 'copy'
|
|
488
|
-
| `custom.${string}`
|
|
489
|
-
| 'annotation.add'
|
|
490
|
-
| 'annotation.remove'
|
|
491
|
-
| 'annotation.toggle'
|
|
492
|
-
| 'block.set'
|
|
493
|
-
| 'block.unset'
|
|
494
|
-
| 'blur'
|
|
495
|
-
| 'data transfer.set'
|
|
496
|
-
| 'decorator.add'
|
|
497
|
-
| 'decorator.remove'
|
|
498
|
-
| 'decorator.toggle'
|
|
499
|
-
| 'delete.backward'
|
|
500
|
-
| 'delete.block'
|
|
501
|
-
| 'delete.forward'
|
|
502
|
-
| 'delete.text'
|
|
503
|
-
| 'history.redo'
|
|
504
|
-
| 'history.undo'
|
|
505
|
-
| 'insert.blocks'
|
|
506
|
-
| 'insert.block object'
|
|
507
|
-
| 'insert.inline object'
|
|
508
|
-
| 'insert.break'
|
|
509
|
-
| 'insert.soft break'
|
|
510
|
-
| 'insert.block'
|
|
511
|
-
| 'insert.span'
|
|
512
|
-
| 'insert.text'
|
|
513
|
-
| 'insert.text block'
|
|
514
|
-
| 'list item.add'
|
|
515
|
-
| 'list item.remove'
|
|
516
|
-
| 'list item.toggle'
|
|
517
|
-
| 'move.block'
|
|
518
|
-
| 'move.block down'
|
|
519
|
-
| 'move.block up'
|
|
520
|
-
| 'select.previous block'
|
|
521
|
-
| 'select.next block'
|
|
522
|
-
| 'style.add'
|
|
523
|
-
| 'style.remove'
|
|
524
|
-
| 'style.toggle'
|
|
525
|
-
| 'key.down'
|
|
526
|
-
| 'key.up'
|
|
527
|
-
| 'paste'
|
|
528
|
-
>
|
|
372
|
+
BehaviorEvent_2
|
|
529
373
|
>[]
|
|
530
374
|
|
|
531
375
|
/**
|
|
@@ -583,62 +427,10 @@ export declare function createLinkBehaviors(
|
|
|
583
427
|
| 'style.toggle'
|
|
584
428
|
| 'key.down'
|
|
585
429
|
| 'key.up'
|
|
586
|
-
| 'paste'
|
|
430
|
+
| 'paste'
|
|
431
|
+
| '*',
|
|
587
432
|
true,
|
|
588
|
-
|
|
589
|
-
BehaviorEvent_2,
|
|
590
|
-
'type',
|
|
591
|
-
| 'focus'
|
|
592
|
-
| 'delete'
|
|
593
|
-
| 'select'
|
|
594
|
-
| 'serialize'
|
|
595
|
-
| 'deserialize'
|
|
596
|
-
| 'serialization.failure'
|
|
597
|
-
| 'serialization.success'
|
|
598
|
-
| 'deserialization.failure'
|
|
599
|
-
| 'deserialization.success'
|
|
600
|
-
| 'copy'
|
|
601
|
-
| `custom.${string}`
|
|
602
|
-
| 'annotation.add'
|
|
603
|
-
| 'annotation.remove'
|
|
604
|
-
| 'annotation.toggle'
|
|
605
|
-
| 'block.set'
|
|
606
|
-
| 'block.unset'
|
|
607
|
-
| 'blur'
|
|
608
|
-
| 'data transfer.set'
|
|
609
|
-
| 'decorator.add'
|
|
610
|
-
| 'decorator.remove'
|
|
611
|
-
| 'decorator.toggle'
|
|
612
|
-
| 'delete.backward'
|
|
613
|
-
| 'delete.block'
|
|
614
|
-
| 'delete.forward'
|
|
615
|
-
| 'delete.text'
|
|
616
|
-
| 'history.redo'
|
|
617
|
-
| 'history.undo'
|
|
618
|
-
| 'insert.blocks'
|
|
619
|
-
| 'insert.block object'
|
|
620
|
-
| 'insert.inline object'
|
|
621
|
-
| 'insert.break'
|
|
622
|
-
| 'insert.soft break'
|
|
623
|
-
| 'insert.block'
|
|
624
|
-
| 'insert.span'
|
|
625
|
-
| 'insert.text'
|
|
626
|
-
| 'insert.text block'
|
|
627
|
-
| 'list item.add'
|
|
628
|
-
| 'list item.remove'
|
|
629
|
-
| 'list item.toggle'
|
|
630
|
-
| 'move.block'
|
|
631
|
-
| 'move.block down'
|
|
632
|
-
| 'move.block up'
|
|
633
|
-
| 'select.previous block'
|
|
634
|
-
| 'select.next block'
|
|
635
|
-
| 'style.add'
|
|
636
|
-
| 'style.remove'
|
|
637
|
-
| 'style.toggle'
|
|
638
|
-
| 'key.down'
|
|
639
|
-
| 'key.up'
|
|
640
|
-
| 'paste'
|
|
641
|
-
>
|
|
433
|
+
BehaviorEvent_2
|
|
642
434
|
>[]
|
|
643
435
|
|
|
644
436
|
/**
|
|
@@ -738,62 +530,10 @@ export declare function createMarkdownBehaviors(
|
|
|
738
530
|
| 'style.toggle'
|
|
739
531
|
| 'key.down'
|
|
740
532
|
| 'key.up'
|
|
741
|
-
| 'paste'
|
|
533
|
+
| 'paste'
|
|
534
|
+
| '*',
|
|
742
535
|
true,
|
|
743
|
-
|
|
744
|
-
BehaviorEvent_2,
|
|
745
|
-
'type',
|
|
746
|
-
| 'focus'
|
|
747
|
-
| 'delete'
|
|
748
|
-
| 'select'
|
|
749
|
-
| 'serialize'
|
|
750
|
-
| 'deserialize'
|
|
751
|
-
| 'serialization.failure'
|
|
752
|
-
| 'serialization.success'
|
|
753
|
-
| 'deserialization.failure'
|
|
754
|
-
| 'deserialization.success'
|
|
755
|
-
| 'copy'
|
|
756
|
-
| `custom.${string}`
|
|
757
|
-
| 'annotation.add'
|
|
758
|
-
| 'annotation.remove'
|
|
759
|
-
| 'annotation.toggle'
|
|
760
|
-
| 'block.set'
|
|
761
|
-
| 'block.unset'
|
|
762
|
-
| 'blur'
|
|
763
|
-
| 'data transfer.set'
|
|
764
|
-
| 'decorator.add'
|
|
765
|
-
| 'decorator.remove'
|
|
766
|
-
| 'decorator.toggle'
|
|
767
|
-
| 'delete.backward'
|
|
768
|
-
| 'delete.block'
|
|
769
|
-
| 'delete.forward'
|
|
770
|
-
| 'delete.text'
|
|
771
|
-
| 'history.redo'
|
|
772
|
-
| 'history.undo'
|
|
773
|
-
| 'insert.blocks'
|
|
774
|
-
| 'insert.block object'
|
|
775
|
-
| 'insert.inline object'
|
|
776
|
-
| 'insert.break'
|
|
777
|
-
| 'insert.soft break'
|
|
778
|
-
| 'insert.block'
|
|
779
|
-
| 'insert.span'
|
|
780
|
-
| 'insert.text'
|
|
781
|
-
| 'insert.text block'
|
|
782
|
-
| 'list item.add'
|
|
783
|
-
| 'list item.remove'
|
|
784
|
-
| 'list item.toggle'
|
|
785
|
-
| 'move.block'
|
|
786
|
-
| 'move.block down'
|
|
787
|
-
| 'move.block up'
|
|
788
|
-
| 'select.previous block'
|
|
789
|
-
| 'select.next block'
|
|
790
|
-
| 'style.add'
|
|
791
|
-
| 'style.remove'
|
|
792
|
-
| 'style.toggle'
|
|
793
|
-
| 'key.down'
|
|
794
|
-
| 'key.up'
|
|
795
|
-
| 'paste'
|
|
796
|
-
>
|
|
536
|
+
BehaviorEvent_2
|
|
797
537
|
>[]
|
|
798
538
|
|
|
799
539
|
/**
|
|
@@ -836,7 +576,9 @@ export declare function defineBehavior<
|
|
|
836
576
|
TGuardResponse,
|
|
837
577
|
TBehaviorEventType extends `custom.${infer TType}`
|
|
838
578
|
? CustomBehaviorEvent<TPayload, TType>
|
|
839
|
-
:
|
|
579
|
+
: TBehaviorEventType extends '*'
|
|
580
|
+
? OmitFromUnion<BehaviorEvent, 'type', '*'>
|
|
581
|
+
: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
|
|
840
582
|
>,
|
|
841
583
|
): Behavior
|
|
842
584
|
|
|
@@ -20100,6 +19842,15 @@ export declare type NativeBehaviorEvent =
|
|
|
20100
19842
|
dataTransfer: DataTransfer
|
|
20101
19843
|
}
|
|
20102
19844
|
|
|
19845
|
+
/**
|
|
19846
|
+
* @internal
|
|
19847
|
+
*/
|
|
19848
|
+
declare type OmitFromUnion<
|
|
19849
|
+
TUnion,
|
|
19850
|
+
TTagKey extends keyof TUnion,
|
|
19851
|
+
TOmittedTags extends TUnion[TTagKey],
|
|
19852
|
+
> = TUnion extends Record<TTagKey, TOmittedTags> ? never : TUnion
|
|
19853
|
+
|
|
20103
19854
|
/**
|
|
20104
19855
|
* @public
|
|
20105
19856
|
*/
|
package/lib/index.d.cts
CHANGED
|
@@ -103,11 +103,9 @@ export declare type BaseDefinition = {
|
|
|
103
103
|
export declare type Behavior<
|
|
104
104
|
TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
|
|
105
105
|
TGuardResponse = true,
|
|
106
|
-
TBehaviorEvent extends BehaviorEvent =
|
|
107
|
-
BehaviorEvent
|
|
108
|
-
'type',
|
|
109
|
-
TBehaviorEventType
|
|
110
|
-
>,
|
|
106
|
+
TBehaviorEvent extends BehaviorEvent = TBehaviorEventType extends '*'
|
|
107
|
+
? BehaviorEvent
|
|
108
|
+
: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>,
|
|
111
109
|
> = {
|
|
112
110
|
/**
|
|
113
111
|
* The internal editor event that triggers this behavior.
|
|
@@ -165,6 +163,9 @@ export declare type BehaviorEvent =
|
|
|
165
163
|
| SyntheticBehaviorEvent
|
|
166
164
|
| NativeBehaviorEvent
|
|
167
165
|
| CustomBehaviorEvent
|
|
166
|
+
| {
|
|
167
|
+
type: '*'
|
|
168
|
+
}
|
|
168
169
|
|
|
169
170
|
/**
|
|
170
171
|
* @beta
|
|
@@ -20387,7 +20388,29 @@ export declare class PortableTextEditor extends Component<
|
|
|
20387
20388
|
static getFragment: (
|
|
20388
20389
|
editor: PortableTextEditor,
|
|
20389
20390
|
) => PortableTextBlock[] | undefined
|
|
20391
|
+
/**
|
|
20392
|
+
* @deprecated
|
|
20393
|
+
* Use `editor.send(...)` instead
|
|
20394
|
+
*
|
|
20395
|
+
* ```
|
|
20396
|
+
* const editor = useEditor()
|
|
20397
|
+
* editor.send({
|
|
20398
|
+
* type: 'history.undo',
|
|
20399
|
+
* })
|
|
20400
|
+
* ```
|
|
20401
|
+
*/
|
|
20390
20402
|
static undo: (editor: PortableTextEditor) => void
|
|
20403
|
+
/**
|
|
20404
|
+
* @deprecated
|
|
20405
|
+
* Use `editor.send(...)` instead
|
|
20406
|
+
*
|
|
20407
|
+
* ```
|
|
20408
|
+
* const editor = useEditor()
|
|
20409
|
+
* editor.send({
|
|
20410
|
+
* type: 'history.redo',
|
|
20411
|
+
* })
|
|
20412
|
+
* ```
|
|
20413
|
+
*/
|
|
20391
20414
|
static redo: (editor: PortableTextEditor) => void
|
|
20392
20415
|
/**
|
|
20393
20416
|
* @deprecated
|
package/lib/index.d.ts
CHANGED
|
@@ -103,11 +103,9 @@ export declare type BaseDefinition = {
|
|
|
103
103
|
export declare type Behavior<
|
|
104
104
|
TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
|
|
105
105
|
TGuardResponse = true,
|
|
106
|
-
TBehaviorEvent extends BehaviorEvent =
|
|
107
|
-
BehaviorEvent
|
|
108
|
-
'type',
|
|
109
|
-
TBehaviorEventType
|
|
110
|
-
>,
|
|
106
|
+
TBehaviorEvent extends BehaviorEvent = TBehaviorEventType extends '*'
|
|
107
|
+
? BehaviorEvent
|
|
108
|
+
: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>,
|
|
111
109
|
> = {
|
|
112
110
|
/**
|
|
113
111
|
* The internal editor event that triggers this behavior.
|
|
@@ -165,6 +163,9 @@ export declare type BehaviorEvent =
|
|
|
165
163
|
| SyntheticBehaviorEvent
|
|
166
164
|
| NativeBehaviorEvent
|
|
167
165
|
| CustomBehaviorEvent
|
|
166
|
+
| {
|
|
167
|
+
type: '*'
|
|
168
|
+
}
|
|
168
169
|
|
|
169
170
|
/**
|
|
170
171
|
* @beta
|
|
@@ -20387,7 +20388,29 @@ export declare class PortableTextEditor extends Component<
|
|
|
20387
20388
|
static getFragment: (
|
|
20388
20389
|
editor: PortableTextEditor,
|
|
20389
20390
|
) => PortableTextBlock[] | undefined
|
|
20391
|
+
/**
|
|
20392
|
+
* @deprecated
|
|
20393
|
+
* Use `editor.send(...)` instead
|
|
20394
|
+
*
|
|
20395
|
+
* ```
|
|
20396
|
+
* const editor = useEditor()
|
|
20397
|
+
* editor.send({
|
|
20398
|
+
* type: 'history.undo',
|
|
20399
|
+
* })
|
|
20400
|
+
* ```
|
|
20401
|
+
*/
|
|
20390
20402
|
static undo: (editor: PortableTextEditor) => void
|
|
20403
|
+
/**
|
|
20404
|
+
* @deprecated
|
|
20405
|
+
* Use `editor.send(...)` instead
|
|
20406
|
+
*
|
|
20407
|
+
* ```
|
|
20408
|
+
* const editor = useEditor()
|
|
20409
|
+
* editor.send({
|
|
20410
|
+
* type: 'history.redo',
|
|
20411
|
+
* })
|
|
20412
|
+
* ```
|
|
20413
|
+
*/
|
|
20391
20414
|
static redo: (editor: PortableTextEditor) => void
|
|
20392
20415
|
/**
|
|
20393
20416
|
* @deprecated
|
package/lib/plugins/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), editorProvider = require("../_chunks-cjs/editor-provider.cjs"),
|
|
3
|
+
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), editorProvider = require("../_chunks-cjs/editor-provider.cjs"), react = require("@xstate/react"), isEqual = require("lodash/isEqual.js"), xstate = require("xstate"), selector_isAtTheStartOfBlock = require("../_chunks-cjs/selector.is-at-the-start-of-block.cjs"), util_sliceBlocks = require("../_chunks-cjs/util.slice-blocks.cjs"), util_blockOffsetsToSelection = require("../_chunks-cjs/util.block-offsets-to-selection.cjs"), utils_index = require("../utils/index.cjs"), selector_getTextBefore = require("../_chunks-cjs/selector.get-text-before.cjs"), behavior_core = require("../_chunks-cjs/behavior.core.cjs"), useEffectEvent = require("use-effect-event"), jsxRuntime = require("react/jsx-runtime"), behavior_markdown = require("../_chunks-cjs/behavior.markdown.cjs");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -20,24 +20,6 @@ function BehaviorPlugin(props) {
|
|
|
20
20
|
function _temp(unregister) {
|
|
21
21
|
return unregister();
|
|
22
22
|
}
|
|
23
|
-
function EventListenerPlugin(props) {
|
|
24
|
-
const $ = reactCompilerRuntime.c(5), editor = editorProvider.useEditor(), on = useEffectEvent.useEffectEvent(props.on);
|
|
25
|
-
let t0;
|
|
26
|
-
$[0] !== editor || $[1] !== on ? (t0 = () => {
|
|
27
|
-
const subscription = editor.on("*", on);
|
|
28
|
-
return () => {
|
|
29
|
-
subscription.unsubscribe();
|
|
30
|
-
};
|
|
31
|
-
}, $[0] = editor, $[1] = on, $[2] = t0) : t0 = $[2];
|
|
32
|
-
let t1;
|
|
33
|
-
return $[3] !== editor ? (t1 = [editor], $[3] = editor, $[4] = t1) : t1 = $[4], React.useEffect(t0, t1), null;
|
|
34
|
-
}
|
|
35
|
-
const EditorRefPlugin = React__default.default.forwardRef((_, ref) => {
|
|
36
|
-
const $ = reactCompilerRuntime.c(2), editor = editorProvider.useEditor(), portableTextEditorRef = React__default.default.useRef(editor);
|
|
37
|
-
let t0, t1;
|
|
38
|
-
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => portableTextEditorRef.current, t1 = [], $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]), React__default.default.useImperativeHandle(ref, t0, t1), null;
|
|
39
|
-
});
|
|
40
|
-
EditorRefPlugin.displayName = "EditorRefPlugin";
|
|
41
23
|
function createPairRegex(char, amount) {
|
|
42
24
|
const prePrefix = `(?<!\\${char})`, prefix = `\\${char}`.repeat(Math.max(amount, 1)), postPrefix = "(?!\\s)", content = `([^${char}\\n]+?)`, preSuffix = "(?<!\\s)", suffix = `\\${char}`.repeat(Math.max(amount, 1)), postSuffix = `(?!\\${char})`;
|
|
43
25
|
return `${prePrefix}${prefix}${postPrefix}${content}${preSuffix}${suffix}${postSuffix}`;
|
|
@@ -341,7 +323,24 @@ const emphasisListener = ({
|
|
|
341
323
|
}
|
|
342
324
|
}
|
|
343
325
|
}
|
|
326
|
+
}), EditorRefPlugin = React__default.default.forwardRef((_, ref) => {
|
|
327
|
+
const $ = reactCompilerRuntime.c(2), editor = editorProvider.useEditor(), portableTextEditorRef = React__default.default.useRef(editor);
|
|
328
|
+
let t0, t1;
|
|
329
|
+
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => portableTextEditorRef.current, t1 = [], $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]), React__default.default.useImperativeHandle(ref, t0, t1), null;
|
|
344
330
|
});
|
|
331
|
+
EditorRefPlugin.displayName = "EditorRefPlugin";
|
|
332
|
+
function EventListenerPlugin(props) {
|
|
333
|
+
const $ = reactCompilerRuntime.c(5), editor = editorProvider.useEditor(), on = useEffectEvent.useEffectEvent(props.on);
|
|
334
|
+
let t0;
|
|
335
|
+
$[0] !== editor || $[1] !== on ? (t0 = () => {
|
|
336
|
+
const subscription = editor.on("*", on);
|
|
337
|
+
return () => {
|
|
338
|
+
subscription.unsubscribe();
|
|
339
|
+
};
|
|
340
|
+
}, $[0] = editor, $[1] = on, $[2] = t0) : t0 = $[2];
|
|
341
|
+
let t1;
|
|
342
|
+
return $[3] !== editor ? (t1 = [editor], $[3] = editor, $[4] = t1) : t1 = $[4], React.useEffect(t0, t1), null;
|
|
343
|
+
}
|
|
345
344
|
function MarkdownPlugin(props) {
|
|
346
345
|
const $ = reactCompilerRuntime.c(17), editor = editorProvider.useEditor();
|
|
347
346
|
let t0, t1;
|
|
@@ -612,6 +611,7 @@ function OneLinePlugin() {
|
|
|
612
611
|
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(BehaviorPlugin, { behaviors: oneLineBehaviors }), $[0] = t0) : t0 = $[0], t0;
|
|
613
612
|
}
|
|
614
613
|
exports.BehaviorPlugin = BehaviorPlugin;
|
|
614
|
+
exports.DecoratorShortcutPlugin = DecoratorShortcutPlugin;
|
|
615
615
|
exports.EditorRefPlugin = EditorRefPlugin;
|
|
616
616
|
exports.EventListenerPlugin = EventListenerPlugin;
|
|
617
617
|
exports.MarkdownPlugin = MarkdownPlugin;
|