@portabletext/editor 1.49.3 → 1.49.5
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/behaviors/index.d.cts +24 -0
- package/lib/behaviors/index.d.ts +24 -0
- package/lib/index.cjs +323 -247
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +24 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +324 -248
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +24 -0
- package/lib/plugins/index.d.ts +24 -0
- package/lib/selectors/index.d.cts +24 -0
- package/lib/selectors/index.d.ts +24 -0
- package/lib/utils/index.d.cts +24 -0
- package/lib/utils/index.d.ts +24 -0
- package/package.json +1 -1
- package/src/editor/Editable.tsx +0 -2
- package/src/editor/editor-machine.ts +131 -1
- package/src/editor/sync-machine.ts +202 -182
package/src/editor/Editable.tsx
CHANGED
|
@@ -200,7 +200,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
200
200
|
useMemo(() => {
|
|
201
201
|
// React/UI-specific plugins
|
|
202
202
|
if (readOnly) {
|
|
203
|
-
debug('Editable is in read only mode')
|
|
204
203
|
return slateEditor
|
|
205
204
|
}
|
|
206
205
|
const withHotKeys = createWithHotkeys(
|
|
@@ -209,7 +208,6 @@ export const PortableTextEditable = forwardRef<
|
|
|
209
208
|
hotkeys,
|
|
210
209
|
)
|
|
211
210
|
|
|
212
|
-
debug('Editable is in edit mode')
|
|
213
211
|
return withHotKeys(slateEditor)
|
|
214
212
|
}, [editorActor, hotkeys, portableTextEditor, readOnly, slateEditor])
|
|
215
213
|
|
|
@@ -16,6 +16,7 @@ import {coreBehaviorsConfig} from '../behaviors/behavior.core'
|
|
|
16
16
|
import {performEvent} from '../behaviors/behavior.perform-event'
|
|
17
17
|
import type {BehaviorEvent} from '../behaviors/behavior.types.event'
|
|
18
18
|
import type {Converter} from '../converters/converter.types'
|
|
19
|
+
import {debugWithName} from '../internal-utils/debug'
|
|
19
20
|
import type {EventPosition} from '../internal-utils/event-position'
|
|
20
21
|
import {sortByPriority} from '../priority/priority.sort'
|
|
21
22
|
import type {NamespaceEvent} from '../type-utils'
|
|
@@ -30,6 +31,8 @@ import {createEditorSnapshot} from './editor-snapshot'
|
|
|
30
31
|
|
|
31
32
|
export * from 'xstate/guards'
|
|
32
33
|
|
|
34
|
+
const debug = debugWithName('editor machine')
|
|
35
|
+
|
|
33
36
|
/**
|
|
34
37
|
* @public
|
|
35
38
|
*/
|
|
@@ -459,6 +462,20 @@ export const editorMachine = setup({
|
|
|
459
462
|
},
|
|
460
463
|
states: {
|
|
461
464
|
'determine initial edit mode': {
|
|
465
|
+
entry: [
|
|
466
|
+
() => {
|
|
467
|
+
debug(
|
|
468
|
+
'entry: edit mode->read only->determine initial edit mode',
|
|
469
|
+
)
|
|
470
|
+
},
|
|
471
|
+
],
|
|
472
|
+
exit: [
|
|
473
|
+
() => {
|
|
474
|
+
debug(
|
|
475
|
+
'exit: edit mode->read only->determine initial edit mode',
|
|
476
|
+
)
|
|
477
|
+
},
|
|
478
|
+
],
|
|
462
479
|
on: {
|
|
463
480
|
'done syncing value': [
|
|
464
481
|
{
|
|
@@ -472,6 +489,16 @@ export const editorMachine = setup({
|
|
|
472
489
|
},
|
|
473
490
|
},
|
|
474
491
|
'read only': {
|
|
492
|
+
entry: [
|
|
493
|
+
() => {
|
|
494
|
+
debug('entry: edit mode->read only->read only')
|
|
495
|
+
},
|
|
496
|
+
],
|
|
497
|
+
exit: [
|
|
498
|
+
() => {
|
|
499
|
+
debug('exit: edit mode->read only->read only')
|
|
500
|
+
},
|
|
501
|
+
],
|
|
475
502
|
on: {
|
|
476
503
|
'update readOnly': {
|
|
477
504
|
guard: ({event}) => !event.readOnly,
|
|
@@ -503,6 +530,16 @@ export const editorMachine = setup({
|
|
|
503
530
|
initial: 'idle',
|
|
504
531
|
states: {
|
|
505
532
|
'idle': {
|
|
533
|
+
entry: [
|
|
534
|
+
() => {
|
|
535
|
+
debug('entry: edit mode->editable->idle')
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
exit: [
|
|
539
|
+
() => {
|
|
540
|
+
debug('exit: edit mode->editable-idle')
|
|
541
|
+
},
|
|
542
|
+
],
|
|
506
543
|
on: {
|
|
507
544
|
dragstart: {
|
|
508
545
|
actions: [
|
|
@@ -521,6 +558,20 @@ export const editorMachine = setup({
|
|
|
521
558
|
initial: 'checking if busy',
|
|
522
559
|
states: {
|
|
523
560
|
'checking if busy': {
|
|
561
|
+
entry: [
|
|
562
|
+
() => {
|
|
563
|
+
debug(
|
|
564
|
+
'entry: edit mode->editable->focusing->checking if busy',
|
|
565
|
+
)
|
|
566
|
+
},
|
|
567
|
+
],
|
|
568
|
+
exit: [
|
|
569
|
+
() => {
|
|
570
|
+
debug(
|
|
571
|
+
'exit: edit mode->editable->focusing->checking if busy',
|
|
572
|
+
)
|
|
573
|
+
},
|
|
574
|
+
],
|
|
524
575
|
always: [
|
|
525
576
|
{
|
|
526
577
|
guard: 'slate is busy',
|
|
@@ -533,6 +584,16 @@ export const editorMachine = setup({
|
|
|
533
584
|
],
|
|
534
585
|
},
|
|
535
586
|
'busy': {
|
|
587
|
+
entry: [
|
|
588
|
+
() => {
|
|
589
|
+
debug('entry: edit mode->editable->focusing-busy')
|
|
590
|
+
},
|
|
591
|
+
],
|
|
592
|
+
exit: [
|
|
593
|
+
() => {
|
|
594
|
+
debug('exit: edit mode->editable->focusing->busy')
|
|
595
|
+
},
|
|
596
|
+
],
|
|
536
597
|
after: {
|
|
537
598
|
10: {
|
|
538
599
|
target: 'checking if busy',
|
|
@@ -542,7 +603,15 @@ export const editorMachine = setup({
|
|
|
542
603
|
},
|
|
543
604
|
},
|
|
544
605
|
'dragging internally': {
|
|
606
|
+
entry: [
|
|
607
|
+
() => {
|
|
608
|
+
debug('entry: edit mode->editable->dragging internally')
|
|
609
|
+
},
|
|
610
|
+
],
|
|
545
611
|
exit: [
|
|
612
|
+
() => {
|
|
613
|
+
debug('exit: edit mode->editable->dragging internally')
|
|
614
|
+
},
|
|
546
615
|
({context}) => {
|
|
547
616
|
if (context.internalDrag?.ghost) {
|
|
548
617
|
try {
|
|
@@ -574,7 +643,15 @@ export const editorMachine = setup({
|
|
|
574
643
|
initial: 'setting up',
|
|
575
644
|
states: {
|
|
576
645
|
'setting up': {
|
|
646
|
+
entry: [
|
|
647
|
+
() => {
|
|
648
|
+
debug('entry: setup->setting up')
|
|
649
|
+
},
|
|
650
|
+
],
|
|
577
651
|
exit: [
|
|
652
|
+
() => {
|
|
653
|
+
debug('exit: setup->setting up')
|
|
654
|
+
},
|
|
578
655
|
'emit ready',
|
|
579
656
|
'emit pending incoming patches',
|
|
580
657
|
'clear pending incoming patches',
|
|
@@ -601,6 +678,16 @@ export const editorMachine = setup({
|
|
|
601
678
|
initial: 'idle',
|
|
602
679
|
states: {
|
|
603
680
|
'idle': {
|
|
681
|
+
entry: [
|
|
682
|
+
() => {
|
|
683
|
+
debug('entry: setup->set up->value sync->idle')
|
|
684
|
+
},
|
|
685
|
+
],
|
|
686
|
+
exit: [
|
|
687
|
+
() => {
|
|
688
|
+
debug('exit: setup->set up->value sync->idle')
|
|
689
|
+
},
|
|
690
|
+
],
|
|
604
691
|
on: {
|
|
605
692
|
'patches': {
|
|
606
693
|
actions: [emit(({event}) => event)],
|
|
@@ -611,7 +698,15 @@ export const editorMachine = setup({
|
|
|
611
698
|
},
|
|
612
699
|
},
|
|
613
700
|
'syncing value': {
|
|
701
|
+
entry: [
|
|
702
|
+
() => {
|
|
703
|
+
debug('entry: setup->set up->value sync->syncing value')
|
|
704
|
+
},
|
|
705
|
+
],
|
|
614
706
|
exit: [
|
|
707
|
+
() => {
|
|
708
|
+
debug('exit: setup->set up->value sync->syncing value')
|
|
709
|
+
},
|
|
615
710
|
'emit pending incoming patches',
|
|
616
711
|
'clear pending incoming patches',
|
|
617
712
|
],
|
|
@@ -633,6 +728,16 @@ export const editorMachine = setup({
|
|
|
633
728
|
initial: 'idle',
|
|
634
729
|
states: {
|
|
635
730
|
idle: {
|
|
731
|
+
entry: [
|
|
732
|
+
() => {
|
|
733
|
+
debug('entry: setup->set up->writing->pristine->idle')
|
|
734
|
+
},
|
|
735
|
+
],
|
|
736
|
+
exit: [
|
|
737
|
+
() => {
|
|
738
|
+
debug('exit: setup->set up->writing->pristine->idle')
|
|
739
|
+
},
|
|
740
|
+
],
|
|
636
741
|
on: {
|
|
637
742
|
'normalizing': {
|
|
638
743
|
target: 'normalizing',
|
|
@@ -648,6 +753,20 @@ export const editorMachine = setup({
|
|
|
648
753
|
},
|
|
649
754
|
},
|
|
650
755
|
normalizing: {
|
|
756
|
+
entry: [
|
|
757
|
+
() => {
|
|
758
|
+
debug(
|
|
759
|
+
'entry: setup->set up->writing->pristine->normalizing',
|
|
760
|
+
)
|
|
761
|
+
},
|
|
762
|
+
],
|
|
763
|
+
exit: [
|
|
764
|
+
() => {
|
|
765
|
+
debug(
|
|
766
|
+
'exit: setup->set up->writing->pristine->normalizing',
|
|
767
|
+
)
|
|
768
|
+
},
|
|
769
|
+
],
|
|
651
770
|
on: {
|
|
652
771
|
'done normalizing': {
|
|
653
772
|
target: 'idle',
|
|
@@ -663,7 +782,18 @@ export const editorMachine = setup({
|
|
|
663
782
|
},
|
|
664
783
|
},
|
|
665
784
|
dirty: {
|
|
666
|
-
entry: [
|
|
785
|
+
entry: [
|
|
786
|
+
() => {
|
|
787
|
+
debug('entry: setup->set up->writing->dirty')
|
|
788
|
+
},
|
|
789
|
+
'emit pending events',
|
|
790
|
+
'clear pending events',
|
|
791
|
+
],
|
|
792
|
+
exit: [
|
|
793
|
+
() => {
|
|
794
|
+
debug('exit: setup->set up->writing->dirty')
|
|
795
|
+
},
|
|
796
|
+
],
|
|
667
797
|
on: {
|
|
668
798
|
'internal.patch': {
|
|
669
799
|
actions: 'emit patch event',
|