@portabletext/editor 1.47.6 → 1.47.7

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.
@@ -1,16 +1,21 @@
1
1
  import type {Patch} from '@portabletext/patches'
2
- import {
3
- KeyedSegment,
4
- PortableTextBlock,
5
- PortableTextObject,
6
- PortableTextSpan,
7
- } from '@sanity/types'
8
2
  import type {
3
+ ArraySchemaType,
4
+ BlockDecoratorDefinition,
5
+ BlockListDefinition,
6
+ BlockStyleDefinition,
7
+ ObjectSchemaType,
9
8
  Path,
10
9
  PortableTextChild,
11
10
  PortableTextListBlock,
12
11
  PortableTextTextBlock,
13
12
  } from '@sanity/types'
13
+ import {
14
+ KeyedSegment,
15
+ PortableTextBlock,
16
+ PortableTextObject,
17
+ PortableTextSpan,
18
+ } from '@sanity/types'
14
19
  import type {
15
20
  FocusEvent as FocusEvent_2,
16
21
  KeyboardEvent as KeyboardEvent_2,
@@ -653,6 +658,7 @@ declare const editorMachine: StateMachine<
653
658
  {
654
659
  behaviors: Set<Behavior>
655
660
  converters: Set<Converter>
661
+ getLegacySchema: () => PortableTextMemberSchemaTypes
656
662
  keyGenerator: () => string
657
663
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
658
664
  schema: EditorSchema
@@ -886,6 +892,7 @@ declare const editorMachine: StateMachine<
886
892
  {
887
893
  behaviors?: Array<Behavior>
888
894
  converters?: Array<Converter>
895
+ getLegacySchema: () => PortableTextMemberSchemaTypes
889
896
  keyGenerator: () => string
890
897
  maxBlocks?: number
891
898
  readOnly?: boolean
@@ -971,6 +978,7 @@ declare const editorMachine: StateMachine<
971
978
  input: {
972
979
  behaviors?: Array<Behavior>
973
980
  converters?: Array<Converter>
981
+ getLegacySchema: () => PortableTextMemberSchemaTypes
974
982
  keyGenerator: () => string
975
983
  maxBlocks?: number
976
984
  readOnly?: boolean
@@ -982,6 +990,7 @@ declare const editorMachine: StateMachine<
982
990
  {
983
991
  behaviors: Set<Behavior>
984
992
  converters: Set<Converter>
993
+ getLegacySchema: () => PortableTextMemberSchemaTypes
985
994
  keyGenerator: () => string
986
995
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
987
996
  schema: EditorSchema
@@ -1261,6 +1270,7 @@ declare const editorMachine: StateMachine<
1261
1270
  }) => {
1262
1271
  behaviors: Set<Behavior>
1263
1272
  converters: Set<Converter>
1273
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1264
1274
  keyGenerator: () => string
1265
1275
  pendingEvents: never[]
1266
1276
  schema: EditorSchema
@@ -1275,6 +1285,7 @@ declare const editorMachine: StateMachine<
1275
1285
  {
1276
1286
  behaviors: Set<Behavior>
1277
1287
  converters: Set<Converter>
1288
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1278
1289
  keyGenerator: () => string
1279
1290
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1280
1291
  schema: EditorSchema
@@ -1478,6 +1489,7 @@ declare const editorMachine: StateMachine<
1478
1489
  {
1479
1490
  behaviors: Set<Behavior>
1480
1491
  converters: Set<Converter>
1492
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1481
1493
  keyGenerator: () => string
1482
1494
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1483
1495
  schema: EditorSchema
@@ -1680,6 +1692,7 @@ declare const editorMachine: StateMachine<
1680
1692
  {
1681
1693
  behaviors: Set<Behavior>
1682
1694
  converters: Set<Converter>
1695
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1683
1696
  keyGenerator: () => string
1684
1697
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1685
1698
  schema: EditorSchema
@@ -1885,6 +1898,7 @@ declare const editorMachine: StateMachine<
1885
1898
  {
1886
1899
  behaviors: Set<Behavior>
1887
1900
  converters: Set<Converter>
1901
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1888
1902
  keyGenerator: () => string
1889
1903
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1890
1904
  schema: EditorSchema
@@ -2089,6 +2103,7 @@ declare const editorMachine: StateMachine<
2089
2103
  {
2090
2104
  behaviors: Set<Behavior>
2091
2105
  converters: Set<Converter>
2106
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2092
2107
  keyGenerator: () => string
2093
2108
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2094
2109
  schema: EditorSchema
@@ -2293,6 +2308,7 @@ declare const editorMachine: StateMachine<
2293
2308
  {
2294
2309
  behaviors: Set<Behavior>
2295
2310
  converters: Set<Converter>
2311
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2296
2312
  keyGenerator: () => string
2297
2313
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2298
2314
  schema: EditorSchema
@@ -2448,6 +2464,7 @@ declare const editorMachine: StateMachine<
2448
2464
  {
2449
2465
  behaviors: Set<Behavior>
2450
2466
  converters: Set<Converter>
2467
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2451
2468
  keyGenerator: () => string
2452
2469
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2453
2470
  schema: EditorSchema
@@ -2652,6 +2669,7 @@ declare const editorMachine: StateMachine<
2652
2669
  {
2653
2670
  behaviors: Set<Behavior>
2654
2671
  converters: Set<Converter>
2672
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2655
2673
  keyGenerator: () => string
2656
2674
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2657
2675
  schema: EditorSchema
@@ -2855,6 +2873,7 @@ declare const editorMachine: StateMachine<
2855
2873
  {
2856
2874
  behaviors: Set<Behavior>
2857
2875
  converters: Set<Converter>
2876
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2858
2877
  keyGenerator: () => string
2859
2878
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2860
2879
  schema: EditorSchema
@@ -3057,6 +3076,7 @@ declare const editorMachine: StateMachine<
3057
3076
  {
3058
3077
  behaviors: Set<Behavior>
3059
3078
  converters: Set<Converter>
3079
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3060
3080
  keyGenerator: () => string
3061
3081
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3062
3082
  schema: EditorSchema
@@ -3266,6 +3286,7 @@ declare const editorMachine: StateMachine<
3266
3286
  {
3267
3287
  behaviors: Set<Behavior>
3268
3288
  converters: Set<Converter>
3289
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3269
3290
  keyGenerator: () => string
3270
3291
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3271
3292
  schema: EditorSchema
@@ -3469,6 +3490,7 @@ declare const editorMachine: StateMachine<
3469
3490
  {
3470
3491
  behaviors: Set<Behavior>
3471
3492
  converters: Set<Converter>
3493
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3472
3494
  keyGenerator: () => string
3473
3495
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3474
3496
  schema: EditorSchema
@@ -3629,6 +3651,7 @@ declare const editorMachine: StateMachine<
3629
3651
  {
3630
3652
  behaviors: Set<Behavior>
3631
3653
  converters: Set<Converter>
3654
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3632
3655
  keyGenerator: () => string
3633
3656
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3634
3657
  schema: EditorSchema
@@ -3786,6 +3809,7 @@ declare const editorMachine: StateMachine<
3786
3809
  {
3787
3810
  behaviors: Set<Behavior>
3788
3811
  converters: Set<Converter>
3812
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3789
3813
  keyGenerator: () => string
3790
3814
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3791
3815
  schema: EditorSchema
@@ -3955,6 +3979,7 @@ declare const editorMachine: StateMachine<
3955
3979
  {
3956
3980
  behaviors: Set<Behavior>
3957
3981
  converters: Set<Converter>
3982
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3958
3983
  keyGenerator: () => string
3959
3984
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3960
3985
  schema: EditorSchema
@@ -3991,6 +4016,7 @@ declare const editorMachine: StateMachine<
3991
4016
  {
3992
4017
  behaviors: Set<Behavior>
3993
4018
  converters: Set<Converter>
4019
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3994
4020
  keyGenerator: () => string
3995
4021
  pendingEvents: Array<
3996
4022
  InternalPatchEvent | MutationEvent
@@ -4026,6 +4052,7 @@ declare const editorMachine: StateMachine<
4026
4052
  {
4027
4053
  behaviors: Set<Behavior>
4028
4054
  converters: Set<Converter>
4055
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4029
4056
  keyGenerator: () => string
4030
4057
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4031
4058
  schema: EditorSchema
@@ -4060,6 +4087,7 @@ declare const editorMachine: StateMachine<
4060
4087
  {
4061
4088
  behaviors: Set<Behavior>
4062
4089
  converters: Set<Converter>
4090
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4063
4091
  keyGenerator: () => string
4064
4092
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4065
4093
  schema: EditorSchema
@@ -4094,6 +4122,7 @@ declare const editorMachine: StateMachine<
4094
4122
  {
4095
4123
  behaviors: Set<Behavior>
4096
4124
  converters: Set<Converter>
4125
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4097
4126
  keyGenerator: () => string
4098
4127
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4099
4128
  schema: EditorSchema
@@ -4258,6 +4287,7 @@ declare const editorMachine: StateMachine<
4258
4287
  {
4259
4288
  behaviors: Set<Behavior>
4260
4289
  converters: Set<Converter>
4290
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4261
4291
  keyGenerator: () => string
4262
4292
  pendingEvents: Array<
4263
4293
  InternalPatchEvent | MutationEvent
@@ -4449,6 +4479,7 @@ declare const editorMachine: StateMachine<
4449
4479
  {
4450
4480
  behaviors: Set<Behavior>
4451
4481
  converters: Set<Converter>
4482
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4452
4483
  keyGenerator: () => string
4453
4484
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4454
4485
  schema: EditorSchema
@@ -4721,6 +4752,7 @@ declare const editorMachine: StateMachine<
4721
4752
  {
4722
4753
  behaviors: Set<Behavior>
4723
4754
  converters: Set<Converter>
4755
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4724
4756
  keyGenerator: () => string
4725
4757
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4726
4758
  schema: EditorSchema
@@ -5477,6 +5509,21 @@ declare type PickFromUnion<
5477
5509
  TPickedTags extends TUnion[TTagKey],
5478
5510
  > = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
5479
5511
 
5512
+ /** @beta */
5513
+ declare type PortableTextMemberSchemaTypes = {
5514
+ annotations: (ObjectSchemaType & {
5515
+ i18nTitleKey?: string
5516
+ })[]
5517
+ block: ObjectSchemaType
5518
+ blockObjects: ObjectSchemaType[]
5519
+ decorators: BlockDecoratorDefinition[]
5520
+ inlineObjects: ObjectSchemaType[]
5521
+ portableText: ArraySchemaType<PortableTextBlock>
5522
+ span: ObjectSchemaType
5523
+ styles: BlockStyleDefinition[]
5524
+ lists: BlockListDefinition[]
5525
+ }
5526
+
5480
5527
  declare interface PortableTextSlateEditor extends ReactEditor {
5481
5528
  _key: 'editor'
5482
5529
  _type: 'editor'
@@ -1,16 +1,21 @@
1
1
  import type {Patch} from '@portabletext/patches'
2
- import {
3
- KeyedSegment,
4
- PortableTextBlock,
5
- PortableTextObject,
6
- PortableTextSpan,
7
- } from '@sanity/types'
8
2
  import type {
3
+ ArraySchemaType,
4
+ BlockDecoratorDefinition,
5
+ BlockListDefinition,
6
+ BlockStyleDefinition,
7
+ ObjectSchemaType,
9
8
  Path,
10
9
  PortableTextChild,
11
10
  PortableTextListBlock,
12
11
  PortableTextTextBlock,
13
12
  } from '@sanity/types'
13
+ import {
14
+ KeyedSegment,
15
+ PortableTextBlock,
16
+ PortableTextObject,
17
+ PortableTextSpan,
18
+ } from '@sanity/types'
14
19
  import type {
15
20
  FocusEvent as FocusEvent_2,
16
21
  KeyboardEvent as KeyboardEvent_2,
@@ -653,6 +658,7 @@ declare const editorMachine: StateMachine<
653
658
  {
654
659
  behaviors: Set<Behavior>
655
660
  converters: Set<Converter>
661
+ getLegacySchema: () => PortableTextMemberSchemaTypes
656
662
  keyGenerator: () => string
657
663
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
658
664
  schema: EditorSchema
@@ -886,6 +892,7 @@ declare const editorMachine: StateMachine<
886
892
  {
887
893
  behaviors?: Array<Behavior>
888
894
  converters?: Array<Converter>
895
+ getLegacySchema: () => PortableTextMemberSchemaTypes
889
896
  keyGenerator: () => string
890
897
  maxBlocks?: number
891
898
  readOnly?: boolean
@@ -971,6 +978,7 @@ declare const editorMachine: StateMachine<
971
978
  input: {
972
979
  behaviors?: Array<Behavior>
973
980
  converters?: Array<Converter>
981
+ getLegacySchema: () => PortableTextMemberSchemaTypes
974
982
  keyGenerator: () => string
975
983
  maxBlocks?: number
976
984
  readOnly?: boolean
@@ -982,6 +990,7 @@ declare const editorMachine: StateMachine<
982
990
  {
983
991
  behaviors: Set<Behavior>
984
992
  converters: Set<Converter>
993
+ getLegacySchema: () => PortableTextMemberSchemaTypes
985
994
  keyGenerator: () => string
986
995
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
987
996
  schema: EditorSchema
@@ -1261,6 +1270,7 @@ declare const editorMachine: StateMachine<
1261
1270
  }) => {
1262
1271
  behaviors: Set<Behavior>
1263
1272
  converters: Set<Converter>
1273
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1264
1274
  keyGenerator: () => string
1265
1275
  pendingEvents: never[]
1266
1276
  schema: EditorSchema
@@ -1275,6 +1285,7 @@ declare const editorMachine: StateMachine<
1275
1285
  {
1276
1286
  behaviors: Set<Behavior>
1277
1287
  converters: Set<Converter>
1288
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1278
1289
  keyGenerator: () => string
1279
1290
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1280
1291
  schema: EditorSchema
@@ -1478,6 +1489,7 @@ declare const editorMachine: StateMachine<
1478
1489
  {
1479
1490
  behaviors: Set<Behavior>
1480
1491
  converters: Set<Converter>
1492
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1481
1493
  keyGenerator: () => string
1482
1494
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1483
1495
  schema: EditorSchema
@@ -1680,6 +1692,7 @@ declare const editorMachine: StateMachine<
1680
1692
  {
1681
1693
  behaviors: Set<Behavior>
1682
1694
  converters: Set<Converter>
1695
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1683
1696
  keyGenerator: () => string
1684
1697
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1685
1698
  schema: EditorSchema
@@ -1885,6 +1898,7 @@ declare const editorMachine: StateMachine<
1885
1898
  {
1886
1899
  behaviors: Set<Behavior>
1887
1900
  converters: Set<Converter>
1901
+ getLegacySchema: () => PortableTextMemberSchemaTypes
1888
1902
  keyGenerator: () => string
1889
1903
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1890
1904
  schema: EditorSchema
@@ -2089,6 +2103,7 @@ declare const editorMachine: StateMachine<
2089
2103
  {
2090
2104
  behaviors: Set<Behavior>
2091
2105
  converters: Set<Converter>
2106
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2092
2107
  keyGenerator: () => string
2093
2108
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2094
2109
  schema: EditorSchema
@@ -2293,6 +2308,7 @@ declare const editorMachine: StateMachine<
2293
2308
  {
2294
2309
  behaviors: Set<Behavior>
2295
2310
  converters: Set<Converter>
2311
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2296
2312
  keyGenerator: () => string
2297
2313
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2298
2314
  schema: EditorSchema
@@ -2448,6 +2464,7 @@ declare const editorMachine: StateMachine<
2448
2464
  {
2449
2465
  behaviors: Set<Behavior>
2450
2466
  converters: Set<Converter>
2467
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2451
2468
  keyGenerator: () => string
2452
2469
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2453
2470
  schema: EditorSchema
@@ -2652,6 +2669,7 @@ declare const editorMachine: StateMachine<
2652
2669
  {
2653
2670
  behaviors: Set<Behavior>
2654
2671
  converters: Set<Converter>
2672
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2655
2673
  keyGenerator: () => string
2656
2674
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2657
2675
  schema: EditorSchema
@@ -2855,6 +2873,7 @@ declare const editorMachine: StateMachine<
2855
2873
  {
2856
2874
  behaviors: Set<Behavior>
2857
2875
  converters: Set<Converter>
2876
+ getLegacySchema: () => PortableTextMemberSchemaTypes
2858
2877
  keyGenerator: () => string
2859
2878
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2860
2879
  schema: EditorSchema
@@ -3057,6 +3076,7 @@ declare const editorMachine: StateMachine<
3057
3076
  {
3058
3077
  behaviors: Set<Behavior>
3059
3078
  converters: Set<Converter>
3079
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3060
3080
  keyGenerator: () => string
3061
3081
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3062
3082
  schema: EditorSchema
@@ -3266,6 +3286,7 @@ declare const editorMachine: StateMachine<
3266
3286
  {
3267
3287
  behaviors: Set<Behavior>
3268
3288
  converters: Set<Converter>
3289
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3269
3290
  keyGenerator: () => string
3270
3291
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3271
3292
  schema: EditorSchema
@@ -3469,6 +3490,7 @@ declare const editorMachine: StateMachine<
3469
3490
  {
3470
3491
  behaviors: Set<Behavior>
3471
3492
  converters: Set<Converter>
3493
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3472
3494
  keyGenerator: () => string
3473
3495
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3474
3496
  schema: EditorSchema
@@ -3629,6 +3651,7 @@ declare const editorMachine: StateMachine<
3629
3651
  {
3630
3652
  behaviors: Set<Behavior>
3631
3653
  converters: Set<Converter>
3654
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3632
3655
  keyGenerator: () => string
3633
3656
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3634
3657
  schema: EditorSchema
@@ -3786,6 +3809,7 @@ declare const editorMachine: StateMachine<
3786
3809
  {
3787
3810
  behaviors: Set<Behavior>
3788
3811
  converters: Set<Converter>
3812
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3789
3813
  keyGenerator: () => string
3790
3814
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3791
3815
  schema: EditorSchema
@@ -3955,6 +3979,7 @@ declare const editorMachine: StateMachine<
3955
3979
  {
3956
3980
  behaviors: Set<Behavior>
3957
3981
  converters: Set<Converter>
3982
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3958
3983
  keyGenerator: () => string
3959
3984
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3960
3985
  schema: EditorSchema
@@ -3991,6 +4016,7 @@ declare const editorMachine: StateMachine<
3991
4016
  {
3992
4017
  behaviors: Set<Behavior>
3993
4018
  converters: Set<Converter>
4019
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3994
4020
  keyGenerator: () => string
3995
4021
  pendingEvents: Array<
3996
4022
  InternalPatchEvent | MutationEvent
@@ -4026,6 +4052,7 @@ declare const editorMachine: StateMachine<
4026
4052
  {
4027
4053
  behaviors: Set<Behavior>
4028
4054
  converters: Set<Converter>
4055
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4029
4056
  keyGenerator: () => string
4030
4057
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4031
4058
  schema: EditorSchema
@@ -4060,6 +4087,7 @@ declare const editorMachine: StateMachine<
4060
4087
  {
4061
4088
  behaviors: Set<Behavior>
4062
4089
  converters: Set<Converter>
4090
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4063
4091
  keyGenerator: () => string
4064
4092
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4065
4093
  schema: EditorSchema
@@ -4094,6 +4122,7 @@ declare const editorMachine: StateMachine<
4094
4122
  {
4095
4123
  behaviors: Set<Behavior>
4096
4124
  converters: Set<Converter>
4125
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4097
4126
  keyGenerator: () => string
4098
4127
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4099
4128
  schema: EditorSchema
@@ -4258,6 +4287,7 @@ declare const editorMachine: StateMachine<
4258
4287
  {
4259
4288
  behaviors: Set<Behavior>
4260
4289
  converters: Set<Converter>
4290
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4261
4291
  keyGenerator: () => string
4262
4292
  pendingEvents: Array<
4263
4293
  InternalPatchEvent | MutationEvent
@@ -4449,6 +4479,7 @@ declare const editorMachine: StateMachine<
4449
4479
  {
4450
4480
  behaviors: Set<Behavior>
4451
4481
  converters: Set<Converter>
4482
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4452
4483
  keyGenerator: () => string
4453
4484
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4454
4485
  schema: EditorSchema
@@ -4721,6 +4752,7 @@ declare const editorMachine: StateMachine<
4721
4752
  {
4722
4753
  behaviors: Set<Behavior>
4723
4754
  converters: Set<Converter>
4755
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4724
4756
  keyGenerator: () => string
4725
4757
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4726
4758
  schema: EditorSchema
@@ -5477,6 +5509,21 @@ declare type PickFromUnion<
5477
5509
  TPickedTags extends TUnion[TTagKey],
5478
5510
  > = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
5479
5511
 
5512
+ /** @beta */
5513
+ declare type PortableTextMemberSchemaTypes = {
5514
+ annotations: (ObjectSchemaType & {
5515
+ i18nTitleKey?: string
5516
+ })[]
5517
+ block: ObjectSchemaType
5518
+ blockObjects: ObjectSchemaType[]
5519
+ decorators: BlockDecoratorDefinition[]
5520
+ inlineObjects: ObjectSchemaType[]
5521
+ portableText: ArraySchemaType<PortableTextBlock>
5522
+ span: ObjectSchemaType
5523
+ styles: BlockStyleDefinition[]
5524
+ lists: BlockListDefinition[]
5525
+ }
5526
+
5480
5527
  declare interface PortableTextSlateEditor extends ReactEditor {
5481
5528
  _key: 'editor'
5482
5529
  _type: 'editor'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.47.6",
3
+ "version": "1.47.7",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -79,15 +79,15 @@
79
79
  "slate-react": "0.112.1",
80
80
  "use-effect-event": "^1.0.2",
81
81
  "xstate": "^5.19.2",
82
- "@portabletext/block-tools": "1.1.18",
82
+ "@portabletext/block-tools": "1.1.19",
83
83
  "@portabletext/patches": "1.1.3"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@portabletext/toolkit": "^2.0.17",
87
87
  "@sanity/diff-match-patch": "^3.2.0",
88
88
  "@sanity/pkg-utils": "^7.2.2",
89
- "@sanity/schema": "^3.84.0",
90
- "@sanity/types": "^3.84.0",
89
+ "@sanity/schema": "^3.85.1",
90
+ "@sanity/types": "^3.85.1",
91
91
  "@testing-library/jest-dom": "^6.6.3",
92
92
  "@testing-library/react": "^16.3.0",
93
93
  "@types/debug": "^4.1.12",
@@ -115,8 +115,8 @@
115
115
  "racejar": "1.2.3"
116
116
  },
117
117
  "peerDependencies": {
118
- "@sanity/schema": "^3.84.0",
119
- "@sanity/types": "^3.84.0",
118
+ "@sanity/schema": "^3.85.1",
119
+ "@sanity/types": "^3.85.1",
120
120
  "react": "^16.9 || ^17 || ^18 || ^19",
121
121
  "rxjs": "^7.8.2"
122
122
  },
@@ -15,7 +15,9 @@ import {
15
15
  import {Subject} from 'rxjs'
16
16
  import {Slate} from 'slate-react'
17
17
  import {useEffectEvent} from 'use-effect-event'
18
+ import {createActor} from 'xstate'
18
19
  import type {AddedAnnotationPaths} from '../behavior-actions/behavior.action.annotation.add'
20
+ import {createCoreConverters} from '../converters/converters.core'
19
21
  import {debugWithName} from '../internal-utils/debug'
20
22
  import {compileType} from '../internal-utils/schema'
21
23
  import type {
@@ -30,7 +32,7 @@ import type {
30
32
  import {Synchronizer} from './components/Synchronizer'
31
33
  import {createInternalEditor, type InternalEditor} from './create-editor'
32
34
  import {EditorActorContext} from './editor-actor-context'
33
- import type {EditorActor} from './editor-machine'
35
+ import {editorMachine, type EditorActor} from './editor-machine'
34
36
  import {legacySchemaToEditorSchema} from './editor-schema'
35
37
  import {PortableTextEditorContext} from './hooks/usePortableTextEditor'
36
38
  import {PortableTextEditorSelectionProvider} from './hooks/usePortableTextEditorSelection'
@@ -136,20 +138,36 @@ export class PortableTextEditor extends Component<
136
138
 
137
139
  if (props.editor) {
138
140
  this.editor = props.editor as InternalEditor
141
+ this.schemaTypes = this.editor._internal.editorActor
142
+ .getSnapshot()
143
+ .context.getLegacySchema()
139
144
  } else {
140
- this.editor = createInternalEditor({
141
- keyGenerator: props.keyGenerator ?? defaultKeyGenerator,
142
- schema: props.schemaType,
143
- initialValue: props.value,
144
- maxBlocks:
145
- props.maxBlocks === undefined
146
- ? undefined
147
- : Number.parseInt(props.maxBlocks.toString(), 10),
148
- readOnly: props.readOnly,
145
+ const legacySchema = createLegacySchema(
146
+ props.schemaType.hasOwnProperty('jsonType')
147
+ ? props.schemaType
148
+ : compileType(props.schemaType),
149
+ )
150
+ const schema = legacySchemaToEditorSchema(legacySchema)
151
+ const editorActor = createActor(editorMachine, {
152
+ input: {
153
+ converters: createCoreConverters(legacySchema),
154
+ getLegacySchema: () => legacySchema,
155
+ initialValue: props.value,
156
+ keyGenerator: props.keyGenerator ?? defaultKeyGenerator,
157
+ maxBlocks:
158
+ props.maxBlocks === undefined
159
+ ? undefined
160
+ : Number.parseInt(props.maxBlocks.toString(), 10),
161
+ readOnly: props.readOnly,
162
+ schema,
163
+ },
149
164
  })
165
+ editorActor.start()
166
+
167
+ this.editor = createInternalEditor(editorActor)
168
+ this.schemaTypes = legacySchema
150
169
  }
151
170
 
152
- this.schemaTypes = this.editor._internal.legacySchema
153
171
  this.editable = this.editor._internal.editable
154
172
  }
155
173