@portabletext/editor 1.46.0 → 1.47.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/index.d.cts CHANGED
@@ -6273,11 +6273,19 @@ declare type SyntheticBehaviorEvent =
6273
6273
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
6274
6274
  text: string
6275
6275
  }
6276
+ | {
6277
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
6278
+ distance: number
6279
+ }
6276
6280
  | {
6277
6281
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
6278
6282
  at: [KeyedSegment]
6279
6283
  to: [KeyedSegment]
6280
6284
  }
6285
+ | {
6286
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
6287
+ distance: number
6288
+ }
6281
6289
  | {
6282
6290
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
6283
6291
  at: EditorSelection
@@ -6314,7 +6322,9 @@ declare const syntheticBehaviorEventTypes: readonly [
6314
6322
  'insert.block',
6315
6323
  'insert.span',
6316
6324
  'insert.text',
6325
+ 'move.backward',
6317
6326
  'move.block',
6327
+ 'move.forward',
6318
6328
  'select',
6319
6329
  'split.block',
6320
6330
  ]
package/lib/index.d.ts CHANGED
@@ -6273,11 +6273,19 @@ declare type SyntheticBehaviorEvent =
6273
6273
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
6274
6274
  text: string
6275
6275
  }
6276
+ | {
6277
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
6278
+ distance: number
6279
+ }
6276
6280
  | {
6277
6281
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
6278
6282
  at: [KeyedSegment]
6279
6283
  to: [KeyedSegment]
6280
6284
  }
6285
+ | {
6286
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
6287
+ distance: number
6288
+ }
6281
6289
  | {
6282
6290
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
6283
6291
  at: EditorSelection
@@ -6314,7 +6322,9 @@ declare const syntheticBehaviorEventTypes: readonly [
6314
6322
  'insert.block',
6315
6323
  'insert.span',
6316
6324
  'insert.text',
6325
+ 'move.backward',
6317
6326
  'move.block',
6327
+ 'move.forward',
6318
6328
  'select',
6319
6329
  'split.block',
6320
6330
  ]
@@ -5354,11 +5354,19 @@ declare type SyntheticBehaviorEvent =
5354
5354
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
5355
5355
  text: string
5356
5356
  }
5357
+ | {
5358
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
5359
+ distance: number
5360
+ }
5357
5361
  | {
5358
5362
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
5359
5363
  at: [KeyedSegment]
5360
5364
  to: [KeyedSegment]
5361
5365
  }
5366
+ | {
5367
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
5368
+ distance: number
5369
+ }
5362
5370
  | {
5363
5371
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5364
5372
  at: EditorSelection
@@ -5395,7 +5403,9 @@ declare const syntheticBehaviorEventTypes: readonly [
5395
5403
  'insert.block',
5396
5404
  'insert.span',
5397
5405
  'insert.text',
5406
+ 'move.backward',
5398
5407
  'move.block',
5408
+ 'move.forward',
5399
5409
  'select',
5400
5410
  'split.block',
5401
5411
  ]
@@ -5354,11 +5354,19 @@ declare type SyntheticBehaviorEvent =
5354
5354
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
5355
5355
  text: string
5356
5356
  }
5357
+ | {
5358
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
5359
+ distance: number
5360
+ }
5357
5361
  | {
5358
5362
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
5359
5363
  at: [KeyedSegment]
5360
5364
  to: [KeyedSegment]
5361
5365
  }
5366
+ | {
5367
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
5368
+ distance: number
5369
+ }
5362
5370
  | {
5363
5371
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5364
5372
  at: EditorSelection
@@ -5395,7 +5403,9 @@ declare const syntheticBehaviorEventTypes: readonly [
5395
5403
  'insert.block',
5396
5404
  'insert.span',
5397
5405
  'insert.text',
5406
+ 'move.backward',
5398
5407
  'move.block',
5408
+ 'move.forward',
5399
5409
  'select',
5400
5410
  'split.block',
5401
5411
  ]
@@ -5448,11 +5448,19 @@ declare type SyntheticBehaviorEvent =
5448
5448
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
5449
5449
  text: string
5450
5450
  }
5451
+ | {
5452
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
5453
+ distance: number
5454
+ }
5451
5455
  | {
5452
5456
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
5453
5457
  at: [KeyedSegment]
5454
5458
  to: [KeyedSegment]
5455
5459
  }
5460
+ | {
5461
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
5462
+ distance: number
5463
+ }
5456
5464
  | {
5457
5465
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5458
5466
  at: EditorSelection
@@ -5489,7 +5497,9 @@ declare const syntheticBehaviorEventTypes: readonly [
5489
5497
  'insert.block',
5490
5498
  'insert.span',
5491
5499
  'insert.text',
5500
+ 'move.backward',
5492
5501
  'move.block',
5502
+ 'move.forward',
5493
5503
  'select',
5494
5504
  'split.block',
5495
5505
  ]
@@ -5448,11 +5448,19 @@ declare type SyntheticBehaviorEvent =
5448
5448
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
5449
5449
  text: string
5450
5450
  }
5451
+ | {
5452
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
5453
+ distance: number
5454
+ }
5451
5455
  | {
5452
5456
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
5453
5457
  at: [KeyedSegment]
5454
5458
  to: [KeyedSegment]
5455
5459
  }
5460
+ | {
5461
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
5462
+ distance: number
5463
+ }
5456
5464
  | {
5457
5465
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5458
5466
  at: EditorSelection
@@ -5489,7 +5497,9 @@ declare const syntheticBehaviorEventTypes: readonly [
5489
5497
  'insert.block',
5490
5498
  'insert.span',
5491
5499
  'insert.text',
5500
+ 'move.backward',
5492
5501
  'move.block',
5502
+ 'move.forward',
5493
5503
  'select',
5494
5504
  'split.block',
5495
5505
  ]
@@ -5282,11 +5282,19 @@ declare type SyntheticBehaviorEvent =
5282
5282
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
5283
5283
  text: string
5284
5284
  }
5285
+ | {
5286
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
5287
+ distance: number
5288
+ }
5285
5289
  | {
5286
5290
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
5287
5291
  at: [KeyedSegment]
5288
5292
  to: [KeyedSegment]
5289
5293
  }
5294
+ | {
5295
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
5296
+ distance: number
5297
+ }
5290
5298
  | {
5291
5299
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5292
5300
  at: EditorSelection
@@ -5323,7 +5331,9 @@ declare const syntheticBehaviorEventTypes: readonly [
5323
5331
  'insert.block',
5324
5332
  'insert.span',
5325
5333
  'insert.text',
5334
+ 'move.backward',
5326
5335
  'move.block',
5336
+ 'move.forward',
5327
5337
  'select',
5328
5338
  'split.block',
5329
5339
  ]
@@ -5282,11 +5282,19 @@ declare type SyntheticBehaviorEvent =
5282
5282
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
5283
5283
  text: string
5284
5284
  }
5285
+ | {
5286
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
5287
+ distance: number
5288
+ }
5285
5289
  | {
5286
5290
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
5287
5291
  at: [KeyedSegment]
5288
5292
  to: [KeyedSegment]
5289
5293
  }
5294
+ | {
5295
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
5296
+ distance: number
5297
+ }
5290
5298
  | {
5291
5299
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5292
5300
  at: EditorSelection
@@ -5323,7 +5331,9 @@ declare const syntheticBehaviorEventTypes: readonly [
5323
5331
  'insert.block',
5324
5332
  'insert.span',
5325
5333
  'insert.text',
5334
+ 'move.backward',
5326
5335
  'move.block',
5336
+ 'move.forward',
5327
5337
  'select',
5328
5338
  'split.block',
5329
5339
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.46.0",
3
+ "version": "1.47.0",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -79,8 +79,8 @@
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.17",
83
- "@portabletext/patches": "1.1.3"
82
+ "@portabletext/patches": "1.1.3",
83
+ "@portabletext/block-tools": "1.1.17"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@portabletext/toolkit": "^2.0.17",
@@ -0,0 +1,12 @@
1
+ import {Transforms} from 'slate'
2
+ import type {BehaviorActionImplementation} from './behavior.actions'
3
+
4
+ export const moveBackwardActionImplementation: BehaviorActionImplementation<
5
+ 'move.backward'
6
+ > = ({action}) => {
7
+ Transforms.move(action.editor, {
8
+ unit: 'character',
9
+ distance: action.distance,
10
+ reverse: true,
11
+ })
12
+ }
@@ -0,0 +1,11 @@
1
+ import {Transforms} from 'slate'
2
+ import type {BehaviorActionImplementation} from './behavior.actions'
3
+
4
+ export const moveForwardActionImplementation: BehaviorActionImplementation<
5
+ 'move.forward'
6
+ > = ({action}) => {
7
+ Transforms.move(action.editor, {
8
+ unit: 'character',
9
+ distance: action.distance,
10
+ })
11
+ }
@@ -24,7 +24,9 @@ import {insertInlineObjectActionImplementation} from './behavior.action.insert-i
24
24
  import {insertSpanActionImplementation} from './behavior.action.insert-span'
25
25
  import {insertBlockActionImplementation} from './behavior.action.insert.block'
26
26
  import {insertTextActionImplementation} from './behavior.action.insert.text'
27
+ import {moveBackwardActionImplementation} from './behavior.action.move.backward'
27
28
  import {moveBlockActionImplementation} from './behavior.action.move.block'
29
+ import {moveForwardActionImplementation} from './behavior.action.move.forward'
28
30
  import {noopActionImplementation} from './behavior.action.noop'
29
31
  import {selectActionImplementation} from './behavior.action.select'
30
32
  import {splitBlockActionImplementation} from './behavior.action.split.block'
@@ -71,7 +73,9 @@ const behaviorActionImplementations: BehaviorActionImplementations = {
71
73
  'insert.span': insertSpanActionImplementation,
72
74
  'insert.text': insertTextActionImplementation,
73
75
  'effect': effectActionImplementation,
76
+ 'move.backward': moveBackwardActionImplementation,
74
77
  'move.block': moveBlockActionImplementation,
78
+ 'move.forward': moveForwardActionImplementation,
75
79
  'noop': noopActionImplementation,
76
80
  'select': selectActionImplementation,
77
81
  'split.block': splitBlockActionImplementation,
@@ -220,6 +224,13 @@ export function performAction({
220
224
  })
221
225
  break
222
226
  }
227
+ case 'move.backward': {
228
+ behaviorActionImplementations['move.backward']({
229
+ context,
230
+ action,
231
+ })
232
+ break
233
+ }
223
234
  case 'move.block': {
224
235
  behaviorActionImplementations['move.block']({
225
236
  context,
@@ -227,6 +238,13 @@ export function performAction({
227
238
  })
228
239
  break
229
240
  }
241
+ case 'move.forward': {
242
+ behaviorActionImplementations['move.forward']({
243
+ context,
244
+ action,
245
+ })
246
+ break
247
+ }
230
248
  case 'noop': {
231
249
  behaviorActionImplementations.noop({
232
250
  context,
@@ -75,7 +75,9 @@ const syntheticBehaviorEventTypes = [
75
75
  'insert.block',
76
76
  'insert.span',
77
77
  'insert.text',
78
+ 'move.backward',
78
79
  'move.block',
80
+ 'move.forward',
79
81
  'select',
80
82
  'split.block',
81
83
  ] as const
@@ -178,11 +180,19 @@ export type SyntheticBehaviorEvent =
178
180
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
179
181
  text: string
180
182
  }
183
+ | {
184
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
185
+ distance: number
186
+ }
181
187
  | {
182
188
  type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
183
189
  at: [KeyedSegment]
184
190
  to: [KeyedSegment]
185
191
  }
192
+ | {
193
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
194
+ distance: number
195
+ }
186
196
  | {
187
197
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
188
198
  at: EditorSelection