@portabletext/editor 1.47.12 → 1.47.13

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.
@@ -47,7 +47,7 @@ import {GuardArgs} from 'xstate/guards'
47
47
 
48
48
  declare type AbstractBehaviorEvent =
49
49
  | {
50
- type: StrictExtract<AbstractBehaviorEventType, 'annotation.toggle'>
50
+ type: StrictExtract<SyntheticBehaviorEventType, 'annotation.toggle'>
51
51
  annotation: {
52
52
  name: string
53
53
  value: {
@@ -56,7 +56,7 @@ declare type AbstractBehaviorEvent =
56
56
  }
57
57
  }
58
58
  | {
59
- type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'>
59
+ type: StrictExtract<SyntheticBehaviorEventType, 'decorator.toggle'>
60
60
  decorator: string
61
61
  at?: {
62
62
  anchor: BlockOffset
@@ -64,14 +64,14 @@ declare type AbstractBehaviorEvent =
64
64
  }
65
65
  }
66
66
  | {
67
- type: StrictExtract<AbstractBehaviorEventType, 'delete.text'>
67
+ type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
68
68
  at: {
69
69
  anchor: BlockOffset
70
70
  focus: BlockOffset
71
71
  }
72
72
  }
73
73
  | {
74
- type: StrictExtract<AbstractBehaviorEventType, 'deserialize'>
74
+ type: StrictExtract<SyntheticBehaviorEventType, 'deserialize'>
75
75
  originEvent:
76
76
  | PickFromUnion<
77
77
  NativeBehaviorEvent,
@@ -81,7 +81,7 @@ declare type AbstractBehaviorEvent =
81
81
  | InputBehaviorEvent
82
82
  }
83
83
  | {
84
- type: StrictExtract<AbstractBehaviorEventType, 'serialize'>
84
+ type: StrictExtract<SyntheticBehaviorEventType, 'serialize'>
85
85
  originEvent: PickFromUnion<
86
86
  NativeBehaviorEvent,
87
87
  'type',
@@ -89,7 +89,7 @@ declare type AbstractBehaviorEvent =
89
89
  >
90
90
  }
91
91
  | {
92
- type: StrictExtract<AbstractBehaviorEventType, 'deserialization.success'>
92
+ type: StrictExtract<SyntheticBehaviorEventType, 'deserialization.success'>
93
93
  mimeType: MIMEType
94
94
  data: Array<PortableTextBlock>
95
95
  originEvent:
@@ -101,7 +101,7 @@ declare type AbstractBehaviorEvent =
101
101
  | InputBehaviorEvent
102
102
  }
103
103
  | {
104
- type: StrictExtract<AbstractBehaviorEventType, 'deserialization.failure'>
104
+ type: StrictExtract<SyntheticBehaviorEventType, 'deserialization.failure'>
105
105
  mimeType: MIMEType
106
106
  reason: string
107
107
  originEvent:
@@ -113,7 +113,7 @@ declare type AbstractBehaviorEvent =
113
113
  | InputBehaviorEvent
114
114
  }
115
115
  | {
116
- type: StrictExtract<AbstractBehaviorEventType, 'serialization.success'>
116
+ type: StrictExtract<SyntheticBehaviorEventType, 'serialization.success'>
117
117
  mimeType: MIMEType
118
118
  data: string
119
119
  originEvent: PickFromUnion<
@@ -123,7 +123,7 @@ declare type AbstractBehaviorEvent =
123
123
  >
124
124
  }
125
125
  | {
126
- type: StrictExtract<AbstractBehaviorEventType, 'serialization.failure'>
126
+ type: StrictExtract<SyntheticBehaviorEventType, 'serialization.failure'>
127
127
  mimeType: MIMEType
128
128
  reason: string
129
129
  originEvent: PickFromUnion<
@@ -133,66 +133,60 @@ declare type AbstractBehaviorEvent =
133
133
  >
134
134
  }
135
135
  | {
136
- type: StrictExtract<AbstractBehaviorEventType, 'insert.blocks'>
136
+ type: StrictExtract<SyntheticBehaviorEventType, 'insert.blocks'>
137
137
  blocks: Array<PortableTextBlock>
138
138
  placement: InsertPlacement
139
139
  }
140
140
  | {
141
- type: StrictExtract<AbstractBehaviorEventType, 'insert.break'>
141
+ type: StrictExtract<SyntheticBehaviorEventType, 'insert.break'>
142
142
  }
143
143
  | {
144
- type: StrictExtract<AbstractBehaviorEventType, 'insert.soft break'>
144
+ type: StrictExtract<SyntheticBehaviorEventType, 'insert.soft break'>
145
145
  }
146
146
  | {
147
- type: StrictExtract<AbstractBehaviorEventType, 'list item.add'>
147
+ type: StrictExtract<SyntheticBehaviorEventType, 'list item.add'>
148
148
  listItem: string
149
149
  }
150
150
  | {
151
- type: StrictExtract<AbstractBehaviorEventType, 'list item.remove'>
151
+ type: StrictExtract<SyntheticBehaviorEventType, 'list item.remove'>
152
152
  listItem: string
153
153
  }
154
154
  | {
155
- type: StrictExtract<AbstractBehaviorEventType, 'list item.toggle'>
155
+ type: StrictExtract<SyntheticBehaviorEventType, 'list item.toggle'>
156
156
  listItem: string
157
157
  }
158
158
  | {
159
- type: StrictExtract<AbstractBehaviorEventType, 'move.block down'>
159
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.block down'>
160
160
  at: [KeyedSegment]
161
161
  }
162
162
  | {
163
- type: StrictExtract<AbstractBehaviorEventType, 'move.block up'>
163
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.block up'>
164
164
  at: [KeyedSegment]
165
165
  }
166
166
  | {
167
- type: StrictExtract<AbstractBehaviorEventType, 'select.previous block'>
167
+ type: StrictExtract<SyntheticBehaviorEventType, 'select.previous block'>
168
168
  select?: 'start' | 'end'
169
169
  }
170
170
  | {
171
- type: StrictExtract<AbstractBehaviorEventType, 'select.next block'>
171
+ type: StrictExtract<SyntheticBehaviorEventType, 'select.next block'>
172
172
  select?: 'start' | 'end'
173
173
  }
174
174
  | {
175
- type: StrictExtract<AbstractBehaviorEventType, 'split'>
175
+ type: StrictExtract<SyntheticBehaviorEventType, 'split'>
176
176
  }
177
177
  | {
178
- type: StrictExtract<AbstractBehaviorEventType, 'style.add'>
178
+ type: StrictExtract<SyntheticBehaviorEventType, 'style.add'>
179
179
  style: string
180
180
  }
181
181
  | {
182
- type: StrictExtract<AbstractBehaviorEventType, 'style.remove'>
182
+ type: StrictExtract<SyntheticBehaviorEventType, 'style.remove'>
183
183
  style: string
184
184
  }
185
185
  | {
186
- type: StrictExtract<AbstractBehaviorEventType, 'style.toggle'>
186
+ type: StrictExtract<SyntheticBehaviorEventType, 'style.toggle'>
187
187
  style: string
188
188
  }
189
189
 
190
- declare type AbstractBehaviorEventNamespace =
191
- ExtractNamespace<AbstractBehaviorEventType>
192
-
193
- declare type AbstractBehaviorEventType =
194
- (typeof abstractBehaviorEventTypes)[number]
195
-
196
190
  /**************************************
197
191
  * Abstract events
198
192
  **************************************/
@@ -268,17 +262,11 @@ declare type Behavior<
268
262
  declare type BehaviorAction =
269
263
  | {
270
264
  type: 'execute'
271
- event:
272
- | AbstractBehaviorEvent
273
- | SyntheticBehaviorEvent
274
- | CustomBehaviorEvent
265
+ event: SyntheticBehaviorEvent
275
266
  }
276
267
  | {
277
268
  type: 'raise'
278
- event:
279
- | AbstractBehaviorEvent
280
- | SyntheticBehaviorEvent
281
- | CustomBehaviorEvent
269
+ event: SyntheticBehaviorEvent | CustomBehaviorEvent
282
270
  }
283
271
  | {
284
272
  type: 'noop'
@@ -304,13 +292,11 @@ declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
304
292
  */
305
293
  declare type BehaviorEvent =
306
294
  | SyntheticBehaviorEvent
307
- | AbstractBehaviorEvent
308
295
  | NativeBehaviorEvent
309
296
  | CustomBehaviorEvent
310
297
 
311
298
  declare type BehaviorEventTypeNamespace =
312
299
  | SyntheticBehaviorEventNamespace
313
- | AbstractBehaviorEventNamespace
314
300
  | NativeBehaviorEventNamespace
315
301
  | CustomBehaviorEventNamespace
316
302
 
@@ -5768,12 +5754,14 @@ declare type SyntheticBehaviorEvent =
5768
5754
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5769
5755
  at: EditorSelection
5770
5756
  }
5757
+ | AbstractBehaviorEvent
5771
5758
 
5772
5759
  declare type SyntheticBehaviorEventNamespace =
5773
5760
  ExtractNamespace<SyntheticBehaviorEventType>
5774
5761
 
5775
5762
  declare type SyntheticBehaviorEventType =
5776
- (typeof syntheticBehaviorEventTypes)[number]
5763
+ | (typeof syntheticBehaviorEventTypes)[number]
5764
+ | (typeof abstractBehaviorEventTypes)[number]
5777
5765
 
5778
5766
  /**************************************
5779
5767
  * Synthetic events
@@ -47,7 +47,7 @@ import {GuardArgs} from 'xstate/guards'
47
47
 
48
48
  declare type AbstractBehaviorEvent =
49
49
  | {
50
- type: StrictExtract<AbstractBehaviorEventType, 'annotation.toggle'>
50
+ type: StrictExtract<SyntheticBehaviorEventType, 'annotation.toggle'>
51
51
  annotation: {
52
52
  name: string
53
53
  value: {
@@ -56,7 +56,7 @@ declare type AbstractBehaviorEvent =
56
56
  }
57
57
  }
58
58
  | {
59
- type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'>
59
+ type: StrictExtract<SyntheticBehaviorEventType, 'decorator.toggle'>
60
60
  decorator: string
61
61
  at?: {
62
62
  anchor: BlockOffset
@@ -64,14 +64,14 @@ declare type AbstractBehaviorEvent =
64
64
  }
65
65
  }
66
66
  | {
67
- type: StrictExtract<AbstractBehaviorEventType, 'delete.text'>
67
+ type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
68
68
  at: {
69
69
  anchor: BlockOffset
70
70
  focus: BlockOffset
71
71
  }
72
72
  }
73
73
  | {
74
- type: StrictExtract<AbstractBehaviorEventType, 'deserialize'>
74
+ type: StrictExtract<SyntheticBehaviorEventType, 'deserialize'>
75
75
  originEvent:
76
76
  | PickFromUnion<
77
77
  NativeBehaviorEvent,
@@ -81,7 +81,7 @@ declare type AbstractBehaviorEvent =
81
81
  | InputBehaviorEvent
82
82
  }
83
83
  | {
84
- type: StrictExtract<AbstractBehaviorEventType, 'serialize'>
84
+ type: StrictExtract<SyntheticBehaviorEventType, 'serialize'>
85
85
  originEvent: PickFromUnion<
86
86
  NativeBehaviorEvent,
87
87
  'type',
@@ -89,7 +89,7 @@ declare type AbstractBehaviorEvent =
89
89
  >
90
90
  }
91
91
  | {
92
- type: StrictExtract<AbstractBehaviorEventType, 'deserialization.success'>
92
+ type: StrictExtract<SyntheticBehaviorEventType, 'deserialization.success'>
93
93
  mimeType: MIMEType
94
94
  data: Array<PortableTextBlock>
95
95
  originEvent:
@@ -101,7 +101,7 @@ declare type AbstractBehaviorEvent =
101
101
  | InputBehaviorEvent
102
102
  }
103
103
  | {
104
- type: StrictExtract<AbstractBehaviorEventType, 'deserialization.failure'>
104
+ type: StrictExtract<SyntheticBehaviorEventType, 'deserialization.failure'>
105
105
  mimeType: MIMEType
106
106
  reason: string
107
107
  originEvent:
@@ -113,7 +113,7 @@ declare type AbstractBehaviorEvent =
113
113
  | InputBehaviorEvent
114
114
  }
115
115
  | {
116
- type: StrictExtract<AbstractBehaviorEventType, 'serialization.success'>
116
+ type: StrictExtract<SyntheticBehaviorEventType, 'serialization.success'>
117
117
  mimeType: MIMEType
118
118
  data: string
119
119
  originEvent: PickFromUnion<
@@ -123,7 +123,7 @@ declare type AbstractBehaviorEvent =
123
123
  >
124
124
  }
125
125
  | {
126
- type: StrictExtract<AbstractBehaviorEventType, 'serialization.failure'>
126
+ type: StrictExtract<SyntheticBehaviorEventType, 'serialization.failure'>
127
127
  mimeType: MIMEType
128
128
  reason: string
129
129
  originEvent: PickFromUnion<
@@ -133,66 +133,60 @@ declare type AbstractBehaviorEvent =
133
133
  >
134
134
  }
135
135
  | {
136
- type: StrictExtract<AbstractBehaviorEventType, 'insert.blocks'>
136
+ type: StrictExtract<SyntheticBehaviorEventType, 'insert.blocks'>
137
137
  blocks: Array<PortableTextBlock>
138
138
  placement: InsertPlacement
139
139
  }
140
140
  | {
141
- type: StrictExtract<AbstractBehaviorEventType, 'insert.break'>
141
+ type: StrictExtract<SyntheticBehaviorEventType, 'insert.break'>
142
142
  }
143
143
  | {
144
- type: StrictExtract<AbstractBehaviorEventType, 'insert.soft break'>
144
+ type: StrictExtract<SyntheticBehaviorEventType, 'insert.soft break'>
145
145
  }
146
146
  | {
147
- type: StrictExtract<AbstractBehaviorEventType, 'list item.add'>
147
+ type: StrictExtract<SyntheticBehaviorEventType, 'list item.add'>
148
148
  listItem: string
149
149
  }
150
150
  | {
151
- type: StrictExtract<AbstractBehaviorEventType, 'list item.remove'>
151
+ type: StrictExtract<SyntheticBehaviorEventType, 'list item.remove'>
152
152
  listItem: string
153
153
  }
154
154
  | {
155
- type: StrictExtract<AbstractBehaviorEventType, 'list item.toggle'>
155
+ type: StrictExtract<SyntheticBehaviorEventType, 'list item.toggle'>
156
156
  listItem: string
157
157
  }
158
158
  | {
159
- type: StrictExtract<AbstractBehaviorEventType, 'move.block down'>
159
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.block down'>
160
160
  at: [KeyedSegment]
161
161
  }
162
162
  | {
163
- type: StrictExtract<AbstractBehaviorEventType, 'move.block up'>
163
+ type: StrictExtract<SyntheticBehaviorEventType, 'move.block up'>
164
164
  at: [KeyedSegment]
165
165
  }
166
166
  | {
167
- type: StrictExtract<AbstractBehaviorEventType, 'select.previous block'>
167
+ type: StrictExtract<SyntheticBehaviorEventType, 'select.previous block'>
168
168
  select?: 'start' | 'end'
169
169
  }
170
170
  | {
171
- type: StrictExtract<AbstractBehaviorEventType, 'select.next block'>
171
+ type: StrictExtract<SyntheticBehaviorEventType, 'select.next block'>
172
172
  select?: 'start' | 'end'
173
173
  }
174
174
  | {
175
- type: StrictExtract<AbstractBehaviorEventType, 'split'>
175
+ type: StrictExtract<SyntheticBehaviorEventType, 'split'>
176
176
  }
177
177
  | {
178
- type: StrictExtract<AbstractBehaviorEventType, 'style.add'>
178
+ type: StrictExtract<SyntheticBehaviorEventType, 'style.add'>
179
179
  style: string
180
180
  }
181
181
  | {
182
- type: StrictExtract<AbstractBehaviorEventType, 'style.remove'>
182
+ type: StrictExtract<SyntheticBehaviorEventType, 'style.remove'>
183
183
  style: string
184
184
  }
185
185
  | {
186
- type: StrictExtract<AbstractBehaviorEventType, 'style.toggle'>
186
+ type: StrictExtract<SyntheticBehaviorEventType, 'style.toggle'>
187
187
  style: string
188
188
  }
189
189
 
190
- declare type AbstractBehaviorEventNamespace =
191
- ExtractNamespace<AbstractBehaviorEventType>
192
-
193
- declare type AbstractBehaviorEventType =
194
- (typeof abstractBehaviorEventTypes)[number]
195
-
196
190
  /**************************************
197
191
  * Abstract events
198
192
  **************************************/
@@ -268,17 +262,11 @@ declare type Behavior<
268
262
  declare type BehaviorAction =
269
263
  | {
270
264
  type: 'execute'
271
- event:
272
- | AbstractBehaviorEvent
273
- | SyntheticBehaviorEvent
274
- | CustomBehaviorEvent
265
+ event: SyntheticBehaviorEvent
275
266
  }
276
267
  | {
277
268
  type: 'raise'
278
- event:
279
- | AbstractBehaviorEvent
280
- | SyntheticBehaviorEvent
281
- | CustomBehaviorEvent
269
+ event: SyntheticBehaviorEvent | CustomBehaviorEvent
282
270
  }
283
271
  | {
284
272
  type: 'noop'
@@ -304,13 +292,11 @@ declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
304
292
  */
305
293
  declare type BehaviorEvent =
306
294
  | SyntheticBehaviorEvent
307
- | AbstractBehaviorEvent
308
295
  | NativeBehaviorEvent
309
296
  | CustomBehaviorEvent
310
297
 
311
298
  declare type BehaviorEventTypeNamespace =
312
299
  | SyntheticBehaviorEventNamespace
313
- | AbstractBehaviorEventNamespace
314
300
  | NativeBehaviorEventNamespace
315
301
  | CustomBehaviorEventNamespace
316
302
 
@@ -5768,12 +5754,14 @@ declare type SyntheticBehaviorEvent =
5768
5754
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5769
5755
  at: EditorSelection
5770
5756
  }
5757
+ | AbstractBehaviorEvent
5771
5758
 
5772
5759
  declare type SyntheticBehaviorEventNamespace =
5773
5760
  ExtractNamespace<SyntheticBehaviorEventType>
5774
5761
 
5775
5762
  declare type SyntheticBehaviorEventType =
5776
- (typeof syntheticBehaviorEventTypes)[number]
5763
+ | (typeof syntheticBehaviorEventTypes)[number]
5764
+ | (typeof abstractBehaviorEventTypes)[number]
5777
5765
 
5778
5766
  /**************************************
5779
5767
  * Synthetic events
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.47.12",
3
+ "version": "1.47.13",
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/patches": "1.1.3",
83
- "@portabletext/block-tools": "1.1.19"
82
+ "@portabletext/block-tools": "1.1.20",
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.85.1",
90
- "@sanity/types": "^3.85.1",
89
+ "@sanity/schema": "^3.86.0",
90
+ "@sanity/types": "^3.86.0",
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.4"
116
116
  },
117
117
  "peerDependencies": {
118
- "@sanity/schema": "^3.85.1",
119
- "@sanity/types": "^3.85.1",
118
+ "@sanity/schema": "^3.86.0",
119
+ "@sanity/types": "^3.86.0",
120
120
  "react": "^16.9 || ^17 || ^18 || ^19",
121
121
  "rxjs": "^7.8.2"
122
122
  },
@@ -188,15 +188,10 @@ export function performEvent({
188
188
  }
189
189
 
190
190
  if (action.type === 'execute') {
191
- if (
192
- isAbstractBehaviorEvent(action.event) ||
193
- isCustomBehaviorEvent(action.event)
194
- ) {
191
+ if (isAbstractBehaviorEvent(action.event)) {
195
192
  performEvent({
196
193
  mode: 'execute',
197
- behaviors: isCustomBehaviorEvent(action.event)
198
- ? [...behaviors, ...defaultBehaviors]
199
- : defaultBehaviors,
194
+ behaviors: defaultBehaviors,
200
195
  event: action.event,
201
196
  editor,
202
197
  keyGenerator,
@@ -1,8 +1,8 @@
1
1
  import type {EditorSnapshot} from '../editor/editor-snapshot'
2
- import type {PickFromUnion} from '../type-utils'
2
+ import type {OmitFromUnion, PickFromUnion} from '../type-utils'
3
3
  import type {PortableTextSlateEditor} from '../types/editor'
4
4
  import type {
5
- AbstractBehaviorEvent,
5
+ AbstractBehaviorEventType,
6
6
  CustomBehaviorEvent,
7
7
  SyntheticBehaviorEvent,
8
8
  } from './behavior.types.event'
@@ -13,17 +13,11 @@ import type {
13
13
  export type BehaviorAction =
14
14
  | {
15
15
  type: 'execute'
16
- event:
17
- | AbstractBehaviorEvent
18
- | SyntheticBehaviorEvent
19
- | CustomBehaviorEvent
16
+ event: SyntheticBehaviorEvent
20
17
  }
21
18
  | {
22
19
  type: 'raise'
23
- event:
24
- | AbstractBehaviorEvent
25
- | SyntheticBehaviorEvent
26
- | CustomBehaviorEvent
20
+ event: SyntheticBehaviorEvent | CustomBehaviorEvent
27
21
  }
28
22
  | {
29
23
  type: 'noop'
@@ -37,7 +31,7 @@ export type BehaviorAction =
37
31
  * @beta
38
32
  */
39
33
  export function execute(
40
- event: AbstractBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,
34
+ event: SyntheticBehaviorEvent,
41
35
  ): PickFromUnion<BehaviorAction, 'type', 'execute'> {
42
36
  return {type: 'execute', event}
43
37
  }
@@ -46,7 +40,7 @@ export function execute(
46
40
  * @beta
47
41
  */
48
42
  export function raise(
49
- event: AbstractBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,
43
+ event: SyntheticBehaviorEvent | CustomBehaviorEvent,
50
44
  ): PickFromUnion<BehaviorAction, 'type', 'raise'> {
51
45
  return {type: 'raise', event}
52
46
  }
@@ -79,7 +73,7 @@ export type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
79
73
  ) => Array<BehaviorAction>
80
74
 
81
75
  export type InternalBehaviorAction = (
82
- | SyntheticBehaviorEvent
76
+ | OmitFromUnion<SyntheticBehaviorEvent, 'type', AbstractBehaviorEventType>
83
77
  | {type: 'noop'}
84
78
  | {type: 'effect'; effect: () => void}
85
79
  ) & {