@portabletext/editor 1.5.6 → 1.6.1

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/index.d.mts CHANGED
@@ -133,6 +133,9 @@ export declare type BehaviorActionIntend =
133
133
  type: 'select'
134
134
  selection: EditorSelection
135
135
  }
136
+ | {
137
+ type: 'reselect'
138
+ }
136
139
 
137
140
  /**
138
141
  * @alpha
@@ -164,6 +167,18 @@ export declare type BehaviorContext = {
164
167
  * @alpha
165
168
  */
166
169
  export declare type BehaviorEvent =
170
+ | {
171
+ type: 'decorator.add'
172
+ decorator: string
173
+ }
174
+ | {
175
+ type: 'decorator.remove'
176
+ decorator: string
177
+ }
178
+ | {
179
+ type: 'decorator.toggle'
180
+ decorator: string
181
+ }
167
182
  | {
168
183
  type: 'delete backward'
169
184
  unit: TextUnit
@@ -302,53 +317,106 @@ export declare type ConnectionChange = {
302
317
  */
303
318
  export declare const coreBehavior: {
304
319
  softReturn: Behavior<
305
- | 'insert break'
306
- | 'insert soft break'
320
+ | 'decorator.add'
321
+ | 'decorator.remove'
322
+ | 'decorator.toggle'
307
323
  | 'delete backward'
308
324
  | 'delete forward'
325
+ | 'insert soft break'
326
+ | 'insert break'
309
327
  | 'insert text',
310
328
  true
311
329
  >
312
- blockObjects: {
313
- breakingBlockObject: Behavior<
314
- | 'insert break'
330
+ decorators: {
331
+ decoratorAdd: Behavior<
332
+ | 'decorator.add'
333
+ | 'decorator.remove'
334
+ | 'decorator.toggle'
335
+ | 'delete backward'
336
+ | 'delete forward'
315
337
  | 'insert soft break'
338
+ | 'insert break'
339
+ | 'insert text',
340
+ true
341
+ >
342
+ decoratorRemove: Behavior<
343
+ | 'decorator.add'
344
+ | 'decorator.remove'
345
+ | 'decorator.toggle'
316
346
  | 'delete backward'
317
347
  | 'delete forward'
348
+ | 'insert soft break'
349
+ | 'insert break'
318
350
  | 'insert text',
319
351
  true
320
352
  >
321
- deletingEmptyTextBlockAfterBlockObject: Behavior<
353
+ decoratorToggle: Behavior<
354
+ | 'decorator.add'
355
+ | 'decorator.remove'
356
+ | 'decorator.toggle'
357
+ | 'delete backward'
358
+ | 'delete forward'
359
+ | 'insert soft break'
322
360
  | 'insert break'
361
+ | 'insert text',
362
+ true
363
+ >
364
+ }
365
+ blockObjects: {
366
+ breakingBlockObject: Behavior<
367
+ | 'decorator.add'
368
+ | 'decorator.remove'
369
+ | 'decorator.toggle'
370
+ | 'delete backward'
371
+ | 'delete forward'
323
372
  | 'insert soft break'
373
+ | 'insert break'
374
+ | 'insert text',
375
+ true
376
+ >
377
+ deletingEmptyTextBlockAfterBlockObject: Behavior<
378
+ | 'decorator.add'
379
+ | 'decorator.remove'
380
+ | 'decorator.toggle'
324
381
  | 'delete backward'
325
382
  | 'delete forward'
383
+ | 'insert soft break'
384
+ | 'insert break'
326
385
  | 'insert text',
327
386
  true
328
387
  >
329
388
  deletingEmptyTextBlockBeforeBlockObject: Behavior<
330
- | 'insert break'
331
- | 'insert soft break'
389
+ | 'decorator.add'
390
+ | 'decorator.remove'
391
+ | 'decorator.toggle'
332
392
  | 'delete backward'
333
393
  | 'delete forward'
394
+ | 'insert soft break'
395
+ | 'insert break'
334
396
  | 'insert text',
335
397
  true
336
398
  >
337
399
  }
338
400
  lists: {
339
401
  clearListOnBackspace: Behavior<
340
- | 'insert break'
341
- | 'insert soft break'
402
+ | 'decorator.add'
403
+ | 'decorator.remove'
404
+ | 'decorator.toggle'
342
405
  | 'delete backward'
343
406
  | 'delete forward'
407
+ | 'insert soft break'
408
+ | 'insert break'
344
409
  | 'insert text',
345
410
  true
346
411
  >
347
412
  unindentListOnBackspace: Behavior<
348
- | 'insert break'
349
- | 'insert soft break'
413
+ | 'decorator.add'
414
+ | 'decorator.remove'
415
+ | 'decorator.toggle'
350
416
  | 'delete backward'
351
417
  | 'delete forward'
418
+ | 'insert soft break'
419
+ | 'insert break'
352
420
  | 'insert text',
353
421
  true
354
422
  >
@@ -359,10 +427,13 @@ export declare const coreBehavior: {
359
427
  * @alpha
360
428
  */
361
429
  export declare const coreBehaviors: Behavior<
362
- | 'insert break'
363
- | 'insert soft break'
430
+ | 'decorator.add'
431
+ | 'decorator.remove'
432
+ | 'decorator.toggle'
364
433
  | 'delete backward'
365
434
  | 'delete forward'
435
+ | 'insert soft break'
436
+ | 'insert break'
366
437
  | 'insert text',
367
438
  true
368
439
  >[]
@@ -383,10 +454,13 @@ export declare type createEditorOptions = {
383
454
  export declare function createMarkdownBehaviors(
384
455
  config: MarkdownBehaviorsConfig,
385
456
  ): Behavior<
386
- | 'insert break'
387
- | 'insert soft break'
457
+ | 'decorator.add'
458
+ | 'decorator.remove'
459
+ | 'decorator.toggle'
388
460
  | 'delete backward'
389
461
  | 'delete forward'
462
+ | 'insert soft break'
463
+ | 'insert break'
390
464
  | 'insert text',
391
465
  true
392
466
  >[]
@@ -2917,6 +2991,187 @@ export declare const editorMachine: StateMachine<
2917
2991
  type: 'done loading'
2918
2992
  }
2919
2993
  >) => void,
2994
+ ActionFunction<
2995
+ {
2996
+ behaviors: Array<Behavior>
2997
+ keyGenerator: () => string
2998
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
2999
+ schema: PortableTextMemberSchemaTypes
3000
+ },
3001
+ {
3002
+ type: 'behavior action intends'
3003
+ editor: PortableTextSlateEditor
3004
+ actionIntends: Array<BehaviorActionIntend>
3005
+ },
3006
+ | PatchEvent
3007
+ | MutationEvent_2
3008
+ | {
3009
+ type: 'normalizing'
3010
+ }
3011
+ | {
3012
+ type: 'done normalizing'
3013
+ }
3014
+ | {
3015
+ type: 'behavior event'
3016
+ behaviorEvent: BehaviorEvent
3017
+ editor: PortableTextSlateEditor
3018
+ }
3019
+ | {
3020
+ type: 'behavior action intends'
3021
+ editor: PortableTextSlateEditor
3022
+ actionIntends: Array<BehaviorActionIntend>
3023
+ }
3024
+ | {
3025
+ type: 'update schema'
3026
+ schema: PortableTextMemberSchemaTypes
3027
+ }
3028
+ | {
3029
+ type: 'update behaviors'
3030
+ behaviors: Array<Behavior>
3031
+ }
3032
+ | {
3033
+ type: 'ready'
3034
+ }
3035
+ | PatchesEvent
3036
+ | {
3037
+ type: 'unset'
3038
+ previousValue: Array<PortableTextBlock>
3039
+ }
3040
+ | {
3041
+ type: 'value changed'
3042
+ value: Array<PortableTextBlock> | undefined
3043
+ }
3044
+ | {
3045
+ type: 'invalid value'
3046
+ resolution: InvalidValueResolution | null
3047
+ value: Array<PortableTextBlock> | undefined
3048
+ }
3049
+ | {
3050
+ type: 'error'
3051
+ name: string
3052
+ description: string
3053
+ data: unknown
3054
+ }
3055
+ | {
3056
+ type: 'selection'
3057
+ selection: EditorSelection
3058
+ }
3059
+ | {
3060
+ type: 'blur'
3061
+ event: FocusEvent_2<HTMLDivElement, Element>
3062
+ }
3063
+ | {
3064
+ type: 'focus'
3065
+ event: FocusEvent_2<HTMLDivElement, Element>
3066
+ }
3067
+ | {
3068
+ type: 'online'
3069
+ }
3070
+ | {
3071
+ type: 'offline'
3072
+ }
3073
+ | {
3074
+ type: 'loading'
3075
+ }
3076
+ | {
3077
+ type: 'done loading'
3078
+ },
3079
+ undefined,
3080
+ {
3081
+ src: 'networkLogic'
3082
+ logic: CallbackActorLogic<
3083
+ EventObject,
3084
+ NonReducibleUnknown,
3085
+ EventObject
3086
+ >
3087
+ id: string | undefined
3088
+ },
3089
+ Values<{
3090
+ 'assign behaviors': {
3091
+ type: 'assign behaviors'
3092
+ params: NonReducibleUnknown
3093
+ }
3094
+ 'assign schema': {
3095
+ type: 'assign schema'
3096
+ params: NonReducibleUnknown
3097
+ }
3098
+ 'emit patch event': {
3099
+ type: 'emit patch event'
3100
+ params: NonReducibleUnknown
3101
+ }
3102
+ 'emit mutation event': {
3103
+ type: 'emit mutation event'
3104
+ params: NonReducibleUnknown
3105
+ }
3106
+ 'defer event': {
3107
+ type: 'defer event'
3108
+ params: NonReducibleUnknown
3109
+ }
3110
+ 'emit pending events': {
3111
+ type: 'emit pending events'
3112
+ params: NonReducibleUnknown
3113
+ }
3114
+ 'clear pending events': {
3115
+ type: 'clear pending events'
3116
+ params: NonReducibleUnknown
3117
+ }
3118
+ 'handle behavior event': {
3119
+ type: 'handle behavior event'
3120
+ params: NonReducibleUnknown
3121
+ }
3122
+ }>,
3123
+ never,
3124
+ never,
3125
+ | PatchEvent
3126
+ | MutationEvent_2
3127
+ | {
3128
+ type: 'ready'
3129
+ }
3130
+ | PatchesEvent
3131
+ | {
3132
+ type: 'unset'
3133
+ previousValue: Array<PortableTextBlock>
3134
+ }
3135
+ | {
3136
+ type: 'value changed'
3137
+ value: Array<PortableTextBlock> | undefined
3138
+ }
3139
+ | {
3140
+ type: 'invalid value'
3141
+ resolution: InvalidValueResolution | null
3142
+ value: Array<PortableTextBlock> | undefined
3143
+ }
3144
+ | {
3145
+ type: 'error'
3146
+ name: string
3147
+ description: string
3148
+ data: unknown
3149
+ }
3150
+ | {
3151
+ type: 'selection'
3152
+ selection: EditorSelection
3153
+ }
3154
+ | {
3155
+ type: 'blur'
3156
+ event: FocusEvent_2<HTMLDivElement, Element>
3157
+ }
3158
+ | {
3159
+ type: 'focus'
3160
+ event: FocusEvent_2<HTMLDivElement, Element>
3161
+ }
3162
+ | {
3163
+ type: 'online'
3164
+ }
3165
+ | {
3166
+ type: 'offline'
3167
+ }
3168
+ | {
3169
+ type: 'loading'
3170
+ }
3171
+ | {
3172
+ type: 'done loading'
3173
+ }
3174
+ >,
2920
3175
  ]
2921
3176
  }
2922
3177
  }
@@ -3521,18 +3776,6 @@ export declare interface PortableTextSlateEditor extends ReactEditor {
3521
3776
  * @returns True if a list was ended in the selection
3522
3777
  */
3523
3778
  pteEndList: () => boolean
3524
- /**
3525
- * Toggle marks in the selection
3526
- *
3527
- * @param mark - Mark to toggle on/off
3528
- */
3529
- pteToggleMark: (mark: string) => void
3530
- /**
3531
- * Test if a mark is active in the current selection
3532
- *
3533
- * @param mark - Mark to check whether or not is active
3534
- */
3535
- pteIsMarkActive: (mark: string) => boolean
3536
3779
  /**
3537
3780
  * Toggle the selected block style
3538
3781
  *
@@ -6092,6 +6335,187 @@ export declare function useEditor(config: EditorConfig): Actor<
6092
6335
  type: 'done loading'
6093
6336
  }
6094
6337
  >) => void,
6338
+ ActionFunction<
6339
+ {
6340
+ behaviors: Array<Behavior>
6341
+ keyGenerator: () => string
6342
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
6343
+ schema: PortableTextMemberSchemaTypes
6344
+ },
6345
+ {
6346
+ type: 'behavior action intends'
6347
+ editor: PortableTextSlateEditor
6348
+ actionIntends: Array<BehaviorActionIntend>
6349
+ },
6350
+ | PatchEvent
6351
+ | MutationEvent_2
6352
+ | {
6353
+ type: 'normalizing'
6354
+ }
6355
+ | {
6356
+ type: 'done normalizing'
6357
+ }
6358
+ | {
6359
+ type: 'behavior event'
6360
+ behaviorEvent: BehaviorEvent
6361
+ editor: PortableTextSlateEditor
6362
+ }
6363
+ | {
6364
+ type: 'behavior action intends'
6365
+ editor: PortableTextSlateEditor
6366
+ actionIntends: Array<BehaviorActionIntend>
6367
+ }
6368
+ | {
6369
+ type: 'update schema'
6370
+ schema: PortableTextMemberSchemaTypes
6371
+ }
6372
+ | {
6373
+ type: 'update behaviors'
6374
+ behaviors: Array<Behavior>
6375
+ }
6376
+ | {
6377
+ type: 'ready'
6378
+ }
6379
+ | PatchesEvent
6380
+ | {
6381
+ type: 'unset'
6382
+ previousValue: Array<PortableTextBlock>
6383
+ }
6384
+ | {
6385
+ type: 'value changed'
6386
+ value: Array<PortableTextBlock> | undefined
6387
+ }
6388
+ | {
6389
+ type: 'invalid value'
6390
+ resolution: InvalidValueResolution | null
6391
+ value: Array<PortableTextBlock> | undefined
6392
+ }
6393
+ | {
6394
+ type: 'error'
6395
+ name: string
6396
+ description: string
6397
+ data: unknown
6398
+ }
6399
+ | {
6400
+ type: 'selection'
6401
+ selection: EditorSelection
6402
+ }
6403
+ | {
6404
+ type: 'blur'
6405
+ event: FocusEvent_2<HTMLDivElement, Element>
6406
+ }
6407
+ | {
6408
+ type: 'focus'
6409
+ event: FocusEvent_2<HTMLDivElement, Element>
6410
+ }
6411
+ | {
6412
+ type: 'online'
6413
+ }
6414
+ | {
6415
+ type: 'offline'
6416
+ }
6417
+ | {
6418
+ type: 'loading'
6419
+ }
6420
+ | {
6421
+ type: 'done loading'
6422
+ },
6423
+ undefined,
6424
+ {
6425
+ src: 'networkLogic'
6426
+ logic: CallbackActorLogic<
6427
+ EventObject,
6428
+ NonReducibleUnknown,
6429
+ EventObject
6430
+ >
6431
+ id: string | undefined
6432
+ },
6433
+ Values<{
6434
+ 'assign behaviors': {
6435
+ type: 'assign behaviors'
6436
+ params: NonReducibleUnknown
6437
+ }
6438
+ 'assign schema': {
6439
+ type: 'assign schema'
6440
+ params: NonReducibleUnknown
6441
+ }
6442
+ 'emit patch event': {
6443
+ type: 'emit patch event'
6444
+ params: NonReducibleUnknown
6445
+ }
6446
+ 'emit mutation event': {
6447
+ type: 'emit mutation event'
6448
+ params: NonReducibleUnknown
6449
+ }
6450
+ 'defer event': {
6451
+ type: 'defer event'
6452
+ params: NonReducibleUnknown
6453
+ }
6454
+ 'emit pending events': {
6455
+ type: 'emit pending events'
6456
+ params: NonReducibleUnknown
6457
+ }
6458
+ 'clear pending events': {
6459
+ type: 'clear pending events'
6460
+ params: NonReducibleUnknown
6461
+ }
6462
+ 'handle behavior event': {
6463
+ type: 'handle behavior event'
6464
+ params: NonReducibleUnknown
6465
+ }
6466
+ }>,
6467
+ never,
6468
+ never,
6469
+ | PatchEvent
6470
+ | MutationEvent_2
6471
+ | {
6472
+ type: 'ready'
6473
+ }
6474
+ | PatchesEvent
6475
+ | {
6476
+ type: 'unset'
6477
+ previousValue: Array<PortableTextBlock>
6478
+ }
6479
+ | {
6480
+ type: 'value changed'
6481
+ value: Array<PortableTextBlock> | undefined
6482
+ }
6483
+ | {
6484
+ type: 'invalid value'
6485
+ resolution: InvalidValueResolution | null
6486
+ value: Array<PortableTextBlock> | undefined
6487
+ }
6488
+ | {
6489
+ type: 'error'
6490
+ name: string
6491
+ description: string
6492
+ data: unknown
6493
+ }
6494
+ | {
6495
+ type: 'selection'
6496
+ selection: EditorSelection
6497
+ }
6498
+ | {
6499
+ type: 'blur'
6500
+ event: FocusEvent_2<HTMLDivElement, Element>
6501
+ }
6502
+ | {
6503
+ type: 'focus'
6504
+ event: FocusEvent_2<HTMLDivElement, Element>
6505
+ }
6506
+ | {
6507
+ type: 'online'
6508
+ }
6509
+ | {
6510
+ type: 'offline'
6511
+ }
6512
+ | {
6513
+ type: 'loading'
6514
+ }
6515
+ | {
6516
+ type: 'done loading'
6517
+ }
6518
+ >,
6095
6519
  ]
6096
6520
  }
6097
6521
  }