@portabletext/editor 1.47.11 → 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.
Files changed (47) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +61 -3
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/editor-provider.cjs +88 -58
  4. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  5. package/lib/_chunks-cjs/util.get-selection-start-point.cjs +10 -0
  6. package/lib/_chunks-cjs/util.get-selection-start-point.cjs.map +1 -0
  7. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +0 -8
  8. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
  9. package/lib/_chunks-es/behavior.core.js +63 -4
  10. package/lib/_chunks-es/behavior.core.js.map +1 -1
  11. package/lib/_chunks-es/editor-provider.js +90 -59
  12. package/lib/_chunks-es/editor-provider.js.map +1 -1
  13. package/lib/_chunks-es/util.get-selection-start-point.js +11 -0
  14. package/lib/_chunks-es/util.get-selection-start-point.js.map +1 -0
  15. package/lib/_chunks-es/util.selection-point-to-block-offset.js +0 -8
  16. package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
  17. package/lib/behaviors/index.d.cts +4876 -288
  18. package/lib/behaviors/index.d.ts +4876 -288
  19. package/lib/index.cjs +3 -3
  20. package/lib/index.cjs.map +1 -1
  21. package/lib/index.d.cts +29 -42
  22. package/lib/index.d.ts +29 -42
  23. package/lib/index.js +1 -1
  24. package/lib/plugins/index.cjs +0 -9
  25. package/lib/plugins/index.cjs.map +1 -1
  26. package/lib/plugins/index.d.cts +29 -42
  27. package/lib/plugins/index.d.ts +29 -42
  28. package/lib/plugins/index.js +0 -9
  29. package/lib/plugins/index.js.map +1 -1
  30. package/lib/selectors/index.d.cts +29 -41
  31. package/lib/selectors/index.d.ts +29 -41
  32. package/lib/utils/index.cjs +3 -3
  33. package/lib/utils/index.d.cts +29 -41
  34. package/lib/utils/index.d.ts +29 -41
  35. package/lib/utils/index.js +2 -1
  36. package/lib/utils/index.js.map +1 -1
  37. package/package.json +6 -6
  38. package/src/behavior-actions/behavior.action.insert.block.ts +136 -45
  39. package/src/behaviors/behavior.abstract.insert.ts +2 -2
  40. package/src/behaviors/behavior.abstract.split.ts +2 -46
  41. package/src/behaviors/behavior.core.insert-break.ts +113 -0
  42. package/src/behaviors/behavior.core.ts +2 -0
  43. package/src/behaviors/behavior.perform-event.ts +2 -7
  44. package/src/behaviors/behavior.types.action.ts +7 -13
  45. package/src/behaviors/behavior.types.event.ts +31 -33
  46. package/src/internal-utils/slate-utils.ts +50 -1
  47. package/src/plugins/plugin.one-line.tsx +0 -7
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var util_sliceBlocks = require("../_chunks-cjs/util.slice-blocks.cjs"), util_selectionPointToBlockOffset = require("../_chunks-cjs/util.selection-point-to-block-offset.cjs"), util_isSelectionCollapsed = require("../_chunks-cjs/util.is-selection-collapsed.cjs"), util_mergeTextBlocks = require("../_chunks-cjs/util.merge-text-blocks.cjs");
3
+ var util_sliceBlocks = require("../_chunks-cjs/util.slice-blocks.cjs"), util_selectionPointToBlockOffset = require("../_chunks-cjs/util.selection-point-to-block-offset.cjs"), util_getSelectionStartPoint = require("../_chunks-cjs/util.get-selection-start-point.cjs"), util_isSelectionCollapsed = require("../_chunks-cjs/util.is-selection-collapsed.cjs"), util_mergeTextBlocks = require("../_chunks-cjs/util.merge-text-blocks.cjs");
4
4
  function isEqualSelections(a, b) {
5
5
  return !a && !b ? !0 : !a || !b ? !1 : util_sliceBlocks.isEqualSelectionPoints(a.anchor, b.anchor) && util_sliceBlocks.isEqualSelectionPoints(a.focus, b.focus);
6
6
  }
@@ -60,9 +60,9 @@ exports.blockOffsetToBlockSelectionPoint = util_selectionPointToBlockOffset.bloc
60
60
  exports.blockOffsetToSelectionPoint = util_selectionPointToBlockOffset.blockOffsetToSelectionPoint;
61
61
  exports.blockOffsetsToSelection = util_selectionPointToBlockOffset.blockOffsetsToSelection;
62
62
  exports.childSelectionPointToBlockOffset = util_selectionPointToBlockOffset.childSelectionPointToBlockOffset;
63
- exports.getSelectionEndPoint = util_selectionPointToBlockOffset.getSelectionEndPoint;
64
- exports.getSelectionStartPoint = util_selectionPointToBlockOffset.getSelectionStartPoint;
65
63
  exports.selectionPointToBlockOffset = util_selectionPointToBlockOffset.selectionPointToBlockOffset;
64
+ exports.getSelectionEndPoint = util_getSelectionStartPoint.getSelectionEndPoint;
65
+ exports.getSelectionStartPoint = util_getSelectionStartPoint.getSelectionStartPoint;
66
66
  exports.isSelectionCollapsed = util_isSelectionCollapsed.isSelectionCollapsed;
67
67
  exports.isTextBlock = util_mergeTextBlocks.isTextBlock;
68
68
  exports.mergeTextBlocks = util_mergeTextBlocks.mergeTextBlocks;
@@ -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.block'>
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
  **************************************/
@@ -216,7 +210,7 @@ declare const abstractBehaviorEventTypes: readonly [
216
210
  'serialize',
217
211
  'serialization.success',
218
212
  'serialization.failure',
219
- 'split.block',
213
+ 'split',
220
214
  'style.add',
221
215
  'style.remove',
222
216
  'style.toggle',
@@ -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.block'>
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
  **************************************/
@@ -216,7 +210,7 @@ declare const abstractBehaviorEventTypes: readonly [
216
210
  'serialize',
217
211
  'serialization.success',
218
212
  'serialization.failure',
219
- 'split.block',
213
+ 'split',
220
214
  'style.add',
221
215
  'style.remove',
222
216
  'style.toggle',
@@ -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
@@ -1,6 +1,7 @@
1
1
  import { isEqualSelectionPoints, sliceBlocks, isSpan } from "../_chunks-es/util.slice-blocks.js";
2
2
  import { blockOffsetToSpanSelectionPoint, getBlockEndPoint, getBlockStartPoint, getTextBlockText, isEmptyTextBlock, isKeyedSegment, reverseSelection, spanSelectionPointToBlockOffset } from "../_chunks-es/util.slice-blocks.js";
3
- import { blockOffsetToBlockSelectionPoint, blockOffsetToSelectionPoint, blockOffsetsToSelection, childSelectionPointToBlockOffset, getSelectionEndPoint, getSelectionStartPoint, selectionPointToBlockOffset } from "../_chunks-es/util.selection-point-to-block-offset.js";
3
+ import { blockOffsetToBlockSelectionPoint, blockOffsetToSelectionPoint, blockOffsetsToSelection, childSelectionPointToBlockOffset, selectionPointToBlockOffset } from "../_chunks-es/util.selection-point-to-block-offset.js";
4
+ import { getSelectionEndPoint, getSelectionStartPoint } from "../_chunks-es/util.get-selection-start-point.js";
4
5
  import { isSelectionCollapsed } from "../_chunks-es/util.is-selection-collapsed.js";
5
6
  import { isTextBlock } from "../_chunks-es/util.merge-text-blocks.js";
6
7
  import { mergeTextBlocks } from "../_chunks-es/util.merge-text-blocks.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/utils/util.is-equal-selections.ts","../../src/utils/util.split-text-block.ts"],"sourcesContent":["import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from './util.is-equal-selection-points'\n\n/**\n * @public\n */\nexport function isEqualSelections(a: EditorSelection, b: EditorSelection) {\n if (!a && !b) {\n return true\n }\n\n if (!a || !b) {\n return false\n }\n\n return (\n isEqualSelectionPoints(a.anchor, b.anchor) &&\n isEqualSelectionPoints(a.focus, b.focus)\n )\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelectionPoint} from '..'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {isSpan} from './util.is-span'\nimport {isTextBlock} from './util.is-text-block'\nimport {sliceBlocks} from './util.slice-blocks'\n\n/**\n * @beta\n */\nexport function splitTextBlock({\n context,\n block,\n point,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: PortableTextTextBlock\n point: EditorSelectionPoint\n}): {before: PortableTextTextBlock; after: PortableTextTextBlock} | undefined {\n const firstChild = block.children.at(0)\n const lastChild = block.children.at(block.children.length - 1)\n\n if (!firstChild || !lastChild) {\n return undefined\n }\n\n const before = sliceBlocks({\n blocks: [block],\n selection: {\n anchor: {\n path: [{_key: block._key}, 'children', {_key: firstChild._key}],\n offset: 0,\n },\n focus: point,\n },\n }).at(0)\n const after = sliceBlocks({\n blocks: [block],\n selection: {\n anchor: point,\n focus: {\n path: [{_key: block._key}, 'children', {_key: lastChild._key}],\n offset: isSpan(context, lastChild) ? lastChild.text.length : 0,\n },\n },\n }).at(0)\n\n if (!before || !after) {\n return undefined\n }\n\n if (!isTextBlock(context, before) || !isTextBlock(context, after)) {\n return undefined\n }\n\n return {before, after}\n}\n"],"names":["isEqualSelections","a","b","isEqualSelectionPoints","anchor","focus","splitTextBlock","context","block","point","firstChild","children","at","lastChild","length","before","sliceBlocks","blocks","selection","path","_key","offset","after","isSpan","text","isTextBlock"],"mappings":";;;;;;AAMgBA,SAAAA,kBAAkBC,GAAoBC,GAAoB;AACpE,SAAA,CAACD,KAAK,CAACC,IACF,KAGL,CAACD,KAAK,CAACC,IACF,KAIPC,uBAAuBF,EAAEG,QAAQF,EAAEE,MAAM,KACzCD,uBAAuBF,EAAEI,OAAOH,EAAEG,KAAK;AAE3C;ACTO,SAASC,eAAe;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AAKF,GAA8E;AAC5E,QAAMC,aAAaF,MAAMG,SAASC,GAAG,CAAC,GAChCC,YAAYL,MAAMG,SAASC,GAAGJ,MAAMG,SAASG,SAAS,CAAC;AAEzD,MAAA,CAACJ,cAAc,CAACG;AAClB;AAGF,QAAME,SAASC,YAAY;AAAA,IACzBC,QAAQ,CAACT,KAAK;AAAA,IACdU,WAAW;AAAA,MACTd,QAAQ;AAAA,QACNe,MAAM,CAAC;AAAA,UAACC,MAAMZ,MAAMY;AAAAA,WAAO,YAAY;AAAA,UAACA,MAAMV,WAAWU;AAAAA,QAAAA,CAAK;AAAA,QAC9DC,QAAQ;AAAA,MACV;AAAA,MACAhB,OAAOI;AAAAA,IAAAA;AAAAA,EAEV,CAAA,EAAEG,GAAG,CAAC,GACDU,QAAQN,YAAY;AAAA,IACxBC,QAAQ,CAACT,KAAK;AAAA,IACdU,WAAW;AAAA,MACTd,QAAQK;AAAAA,MACRJ,OAAO;AAAA,QACLc,MAAM,CAAC;AAAA,UAACC,MAAMZ,MAAMY;AAAAA,WAAO,YAAY;AAAA,UAACA,MAAMP,UAAUO;AAAAA,QAAAA,CAAK;AAAA,QAC7DC,QAAQE,OAAOhB,SAASM,SAAS,IAAIA,UAAUW,KAAKV,SAAS;AAAA,MAAA;AAAA,IAC/D;AAAA,EACF,CACD,EAAEF,GAAG,CAAC;AAEP,MAAI,EAACG,CAAAA,UAAU,CAACO,UAIZ,EAACG,CAAAA,YAAYlB,SAASQ,MAAM,KAAK,CAACU,YAAYlB,SAASe,KAAK;AAIzD,WAAA;AAAA,MAACP;AAAAA,MAAQO;AAAAA,IAAK;AACvB;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/utils/util.is-equal-selections.ts","../../src/utils/util.split-text-block.ts"],"sourcesContent":["import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from './util.is-equal-selection-points'\n\n/**\n * @public\n */\nexport function isEqualSelections(a: EditorSelection, b: EditorSelection) {\n if (!a && !b) {\n return true\n }\n\n if (!a || !b) {\n return false\n }\n\n return (\n isEqualSelectionPoints(a.anchor, b.anchor) &&\n isEqualSelectionPoints(a.focus, b.focus)\n )\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelectionPoint} from '..'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {isSpan} from './util.is-span'\nimport {isTextBlock} from './util.is-text-block'\nimport {sliceBlocks} from './util.slice-blocks'\n\n/**\n * @beta\n */\nexport function splitTextBlock({\n context,\n block,\n point,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: PortableTextTextBlock\n point: EditorSelectionPoint\n}): {before: PortableTextTextBlock; after: PortableTextTextBlock} | undefined {\n const firstChild = block.children.at(0)\n const lastChild = block.children.at(block.children.length - 1)\n\n if (!firstChild || !lastChild) {\n return undefined\n }\n\n const before = sliceBlocks({\n blocks: [block],\n selection: {\n anchor: {\n path: [{_key: block._key}, 'children', {_key: firstChild._key}],\n offset: 0,\n },\n focus: point,\n },\n }).at(0)\n const after = sliceBlocks({\n blocks: [block],\n selection: {\n anchor: point,\n focus: {\n path: [{_key: block._key}, 'children', {_key: lastChild._key}],\n offset: isSpan(context, lastChild) ? lastChild.text.length : 0,\n },\n },\n }).at(0)\n\n if (!before || !after) {\n return undefined\n }\n\n if (!isTextBlock(context, before) || !isTextBlock(context, after)) {\n return undefined\n }\n\n return {before, after}\n}\n"],"names":["isEqualSelections","a","b","isEqualSelectionPoints","anchor","focus","splitTextBlock","context","block","point","firstChild","children","at","lastChild","length","before","sliceBlocks","blocks","selection","path","_key","offset","after","isSpan","text","isTextBlock"],"mappings":";;;;;;;AAMgBA,SAAAA,kBAAkBC,GAAoBC,GAAoB;AACpE,SAAA,CAACD,KAAK,CAACC,IACF,KAGL,CAACD,KAAK,CAACC,IACF,KAIPC,uBAAuBF,EAAEG,QAAQF,EAAEE,MAAM,KACzCD,uBAAuBF,EAAEI,OAAOH,EAAEG,KAAK;AAE3C;ACTO,SAASC,eAAe;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AAKF,GAA8E;AAC5E,QAAMC,aAAaF,MAAMG,SAASC,GAAG,CAAC,GAChCC,YAAYL,MAAMG,SAASC,GAAGJ,MAAMG,SAASG,SAAS,CAAC;AAEzD,MAAA,CAACJ,cAAc,CAACG;AAClB;AAGF,QAAME,SAASC,YAAY;AAAA,IACzBC,QAAQ,CAACT,KAAK;AAAA,IACdU,WAAW;AAAA,MACTd,QAAQ;AAAA,QACNe,MAAM,CAAC;AAAA,UAACC,MAAMZ,MAAMY;AAAAA,WAAO,YAAY;AAAA,UAACA,MAAMV,WAAWU;AAAAA,QAAAA,CAAK;AAAA,QAC9DC,QAAQ;AAAA,MACV;AAAA,MACAhB,OAAOI;AAAAA,IAAAA;AAAAA,EAEV,CAAA,EAAEG,GAAG,CAAC,GACDU,QAAQN,YAAY;AAAA,IACxBC,QAAQ,CAACT,KAAK;AAAA,IACdU,WAAW;AAAA,MACTd,QAAQK;AAAAA,MACRJ,OAAO;AAAA,QACLc,MAAM,CAAC;AAAA,UAACC,MAAMZ,MAAMY;AAAAA,WAAO,YAAY;AAAA,UAACA,MAAMP,UAAUO;AAAAA,QAAAA,CAAK;AAAA,QAC7DC,QAAQE,OAAOhB,SAASM,SAAS,IAAIA,UAAUW,KAAKV,SAAS;AAAA,MAAA;AAAA,IAC/D;AAAA,EACF,CACD,EAAEF,GAAG,CAAC;AAEP,MAAI,EAACG,CAAAA,UAAU,CAACO,UAIZ,EAACG,CAAAA,YAAYlB,SAASQ,MAAM,KAAK,CAACU,YAAYlB,SAASe,KAAK;AAIzD,WAAA;AAAA,MAACP;AAAAA,MAAQO;AAAAA,IAAK;AACvB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.47.11",
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/block-tools": "1.1.19",
82
+ "@portabletext/block-tools": "1.1.20",
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.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
  },