@portabletext/editor 1.44.16 → 1.45.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.
Files changed (63) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +5 -5
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/behavior.markdown.cjs +29 -23
  4. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  5. package/lib/_chunks-cjs/editor-provider.cjs +62 -38
  6. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  7. package/lib/_chunks-cjs/parse-blocks.cjs +74 -22
  8. package/lib/_chunks-cjs/parse-blocks.cjs.map +1 -1
  9. package/lib/_chunks-es/behavior.core.js +5 -5
  10. package/lib/_chunks-es/behavior.core.js.map +1 -1
  11. package/lib/_chunks-es/behavior.markdown.js +29 -23
  12. package/lib/_chunks-es/behavior.markdown.js.map +1 -1
  13. package/lib/_chunks-es/editor-provider.js +63 -39
  14. package/lib/_chunks-es/editor-provider.js.map +1 -1
  15. package/lib/_chunks-es/parse-blocks.js +75 -23
  16. package/lib/_chunks-es/parse-blocks.js.map +1 -1
  17. package/lib/behaviors/index.cjs +18 -14
  18. package/lib/behaviors/index.cjs.map +1 -1
  19. package/lib/behaviors/index.d.cts +53 -41
  20. package/lib/behaviors/index.d.ts +53 -41
  21. package/lib/behaviors/index.js +18 -14
  22. package/lib/behaviors/index.js.map +1 -1
  23. package/lib/index.cjs +1 -1
  24. package/lib/index.cjs.map +1 -1
  25. package/lib/index.d.cts +28 -9
  26. package/lib/index.d.ts +28 -9
  27. package/lib/index.js +1 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib/plugins/index.cjs +7 -7
  30. package/lib/plugins/index.cjs.map +1 -1
  31. package/lib/plugins/index.d.cts +8 -6
  32. package/lib/plugins/index.d.ts +8 -6
  33. package/lib/plugins/index.js +7 -7
  34. package/lib/plugins/index.js.map +1 -1
  35. package/lib/selectors/index.d.cts +8 -6
  36. package/lib/selectors/index.d.ts +8 -6
  37. package/lib/utils/index.d.cts +8 -6
  38. package/lib/utils/index.d.ts +8 -6
  39. package/package.json +3 -3
  40. package/src/behavior-actions/behavior.action.annotation.add.ts +26 -5
  41. package/src/behavior-actions/behavior.action.decorator.add.ts +4 -4
  42. package/src/behavior-actions/behavior.action.delete.text.ts +1 -4
  43. package/src/behavior-actions/behavior.action.delete.ts +2 -2
  44. package/src/behavior-actions/behavior.action.insert-inline-object.ts +14 -13
  45. package/src/behavior-actions/behavior.action.select.ts +1 -1
  46. package/src/behaviors/behavior.abstract.decorator.ts +2 -2
  47. package/src/behaviors/behavior.abstract.select.ts +2 -2
  48. package/src/behaviors/behavior.core.annotations.ts +1 -1
  49. package/src/behaviors/behavior.core.block-objects.ts +4 -4
  50. package/src/behaviors/behavior.decorator-pair.ts +3 -3
  51. package/src/behaviors/behavior.default.ts +4 -4
  52. package/src/behaviors/behavior.emoji-picker.ts +18 -14
  53. package/src/behaviors/behavior.markdown.ts +29 -23
  54. package/src/behaviors/behavior.types.event.ts +11 -6
  55. package/src/converters/converter.portable-text.deserialize.test.ts +12 -3
  56. package/src/converters/converter.text-html.deserialize.test.ts +3 -1
  57. package/src/editor/Editable.tsx +1 -1
  58. package/src/editor/define-schema.ts +29 -5
  59. package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +2 -2
  60. package/src/editor/plugins/create-with-event-listeners.ts +1 -1
  61. package/src/internal-utils/parse-blocks.ts +109 -39
  62. package/src/plugins/plugin.decorator-shortcut.ts +3 -3
  63. package/src/plugins/plugin.one-line.tsx +1 -1
@@ -59,7 +59,7 @@ declare type AbstractBehaviorEvent =
59
59
  | {
60
60
  type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'>
61
61
  decorator: string
62
- offsets?: {
62
+ at?: {
63
63
  anchor: BlockOffset
64
64
  focus: BlockOffset
65
65
  }
@@ -5380,7 +5380,7 @@ declare type SyntheticBehaviorEvent =
5380
5380
  | {
5381
5381
  type: StrictExtract<SyntheticBehaviorEventType, 'decorator.add'>
5382
5382
  decorator: string
5383
- offsets?: {
5383
+ at?: {
5384
5384
  anchor: BlockOffset
5385
5385
  focus: BlockOffset
5386
5386
  }
@@ -5391,7 +5391,7 @@ declare type SyntheticBehaviorEvent =
5391
5391
  }
5392
5392
  | {
5393
5393
  type: StrictExtract<SyntheticBehaviorEventType, 'delete'>
5394
- selection: NonNullable<EditorSelection>
5394
+ at: NonNullable<EditorSelection>
5395
5395
  }
5396
5396
  | {
5397
5397
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.backward'>
@@ -5407,8 +5407,10 @@ declare type SyntheticBehaviorEvent =
5407
5407
  }
5408
5408
  | {
5409
5409
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
5410
- anchor: BlockOffset
5411
- focus: BlockOffset
5410
+ at: {
5411
+ anchor: BlockOffset
5412
+ focus: BlockOffset
5413
+ }
5412
5414
  }
5413
5415
  | {
5414
5416
  type: StrictExtract<SyntheticBehaviorEventType, 'focus'>
@@ -5456,7 +5458,7 @@ declare type SyntheticBehaviorEvent =
5456
5458
  }
5457
5459
  | {
5458
5460
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5459
- selection: EditorSelection
5461
+ at: EditorSelection
5460
5462
  }
5461
5463
  | {
5462
5464
  type: StrictExtract<SyntheticBehaviorEventType, 'split.block'>
@@ -59,7 +59,7 @@ declare type AbstractBehaviorEvent =
59
59
  | {
60
60
  type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'>
61
61
  decorator: string
62
- offsets?: {
62
+ at?: {
63
63
  anchor: BlockOffset
64
64
  focus: BlockOffset
65
65
  }
@@ -5380,7 +5380,7 @@ declare type SyntheticBehaviorEvent =
5380
5380
  | {
5381
5381
  type: StrictExtract<SyntheticBehaviorEventType, 'decorator.add'>
5382
5382
  decorator: string
5383
- offsets?: {
5383
+ at?: {
5384
5384
  anchor: BlockOffset
5385
5385
  focus: BlockOffset
5386
5386
  }
@@ -5391,7 +5391,7 @@ declare type SyntheticBehaviorEvent =
5391
5391
  }
5392
5392
  | {
5393
5393
  type: StrictExtract<SyntheticBehaviorEventType, 'delete'>
5394
- selection: NonNullable<EditorSelection>
5394
+ at: NonNullable<EditorSelection>
5395
5395
  }
5396
5396
  | {
5397
5397
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.backward'>
@@ -5407,8 +5407,10 @@ declare type SyntheticBehaviorEvent =
5407
5407
  }
5408
5408
  | {
5409
5409
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
5410
- anchor: BlockOffset
5411
- focus: BlockOffset
5410
+ at: {
5411
+ anchor: BlockOffset
5412
+ focus: BlockOffset
5413
+ }
5412
5414
  }
5413
5415
  | {
5414
5416
  type: StrictExtract<SyntheticBehaviorEventType, 'focus'>
@@ -5456,7 +5458,7 @@ declare type SyntheticBehaviorEvent =
5456
5458
  }
5457
5459
  | {
5458
5460
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5459
- selection: EditorSelection
5461
+ at: EditorSelection
5460
5462
  }
5461
5463
  | {
5462
5464
  type: StrictExtract<SyntheticBehaviorEventType, 'split.block'>
@@ -59,7 +59,7 @@ declare type AbstractBehaviorEvent =
59
59
  | {
60
60
  type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'>
61
61
  decorator: string
62
- offsets?: {
62
+ at?: {
63
63
  anchor: BlockOffset
64
64
  focus: BlockOffset
65
65
  }
@@ -5214,7 +5214,7 @@ declare type SyntheticBehaviorEvent =
5214
5214
  | {
5215
5215
  type: StrictExtract<SyntheticBehaviorEventType, 'decorator.add'>
5216
5216
  decorator: string
5217
- offsets?: {
5217
+ at?: {
5218
5218
  anchor: BlockOffset
5219
5219
  focus: BlockOffset
5220
5220
  }
@@ -5225,7 +5225,7 @@ declare type SyntheticBehaviorEvent =
5225
5225
  }
5226
5226
  | {
5227
5227
  type: StrictExtract<SyntheticBehaviorEventType, 'delete'>
5228
- selection: NonNullable<EditorSelection>
5228
+ at: NonNullable<EditorSelection>
5229
5229
  }
5230
5230
  | {
5231
5231
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.backward'>
@@ -5241,8 +5241,10 @@ declare type SyntheticBehaviorEvent =
5241
5241
  }
5242
5242
  | {
5243
5243
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
5244
- anchor: BlockOffset
5245
- focus: BlockOffset
5244
+ at: {
5245
+ anchor: BlockOffset
5246
+ focus: BlockOffset
5247
+ }
5246
5248
  }
5247
5249
  | {
5248
5250
  type: StrictExtract<SyntheticBehaviorEventType, 'focus'>
@@ -5290,7 +5292,7 @@ declare type SyntheticBehaviorEvent =
5290
5292
  }
5291
5293
  | {
5292
5294
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5293
- selection: EditorSelection
5295
+ at: EditorSelection
5294
5296
  }
5295
5297
  | {
5296
5298
  type: StrictExtract<SyntheticBehaviorEventType, 'split.block'>
@@ -59,7 +59,7 @@ declare type AbstractBehaviorEvent =
59
59
  | {
60
60
  type: StrictExtract<AbstractBehaviorEventType, 'decorator.toggle'>
61
61
  decorator: string
62
- offsets?: {
62
+ at?: {
63
63
  anchor: BlockOffset
64
64
  focus: BlockOffset
65
65
  }
@@ -5214,7 +5214,7 @@ declare type SyntheticBehaviorEvent =
5214
5214
  | {
5215
5215
  type: StrictExtract<SyntheticBehaviorEventType, 'decorator.add'>
5216
5216
  decorator: string
5217
- offsets?: {
5217
+ at?: {
5218
5218
  anchor: BlockOffset
5219
5219
  focus: BlockOffset
5220
5220
  }
@@ -5225,7 +5225,7 @@ declare type SyntheticBehaviorEvent =
5225
5225
  }
5226
5226
  | {
5227
5227
  type: StrictExtract<SyntheticBehaviorEventType, 'delete'>
5228
- selection: NonNullable<EditorSelection>
5228
+ at: NonNullable<EditorSelection>
5229
5229
  }
5230
5230
  | {
5231
5231
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.backward'>
@@ -5241,8 +5241,10 @@ declare type SyntheticBehaviorEvent =
5241
5241
  }
5242
5242
  | {
5243
5243
  type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
5244
- anchor: BlockOffset
5245
- focus: BlockOffset
5244
+ at: {
5245
+ anchor: BlockOffset
5246
+ focus: BlockOffset
5247
+ }
5246
5248
  }
5247
5249
  | {
5248
5250
  type: StrictExtract<SyntheticBehaviorEventType, 'focus'>
@@ -5290,7 +5292,7 @@ declare type SyntheticBehaviorEvent =
5290
5292
  }
5291
5293
  | {
5292
5294
  type: StrictExtract<SyntheticBehaviorEventType, 'select'>
5293
- selection: EditorSelection
5295
+ at: EditorSelection
5294
5296
  }
5295
5297
  | {
5296
5298
  type: StrictExtract<SyntheticBehaviorEventType, 'split.block'>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.44.16",
3
+ "version": "1.45.1",
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/patches": "1.1.3",
83
- "@portabletext/block-tools": "1.1.16"
82
+ "@portabletext/block-tools": "1.1.16",
83
+ "@portabletext/patches": "1.1.3"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@portabletext/toolkit": "^2.0.17",
@@ -1,5 +1,6 @@
1
1
  import type {Path} from '@sanity/types'
2
2
  import {Editor, Node, Range, Text, Transforms} from 'slate'
3
+ import {parseAnnotation} from '../internal-utils/parse-blocks'
3
4
  import type {BehaviorActionImplementation} from './behavior.actions'
4
5
 
5
6
  /**
@@ -24,6 +25,21 @@ export const addAnnotationActionImplementation: BehaviorActionImplementation<
24
25
  'annotation.add',
25
26
  AddedAnnotationPaths | undefined
26
27
  > = ({context, action}) => {
28
+ const parsedAnnotation = parseAnnotation({
29
+ annotation: {
30
+ _type: action.annotation.name,
31
+ ...action.annotation.value,
32
+ },
33
+ context,
34
+ options: {refreshKeys: false},
35
+ })
36
+
37
+ if (!parsedAnnotation) {
38
+ throw new Error(
39
+ `Failed to parse annotation ${JSON.stringify(action.annotation)}`,
40
+ )
41
+ }
42
+
27
43
  const editor = action.editor
28
44
 
29
45
  if (!editor.selection || Range.isCollapsed(editor.selection)) {
@@ -41,6 +57,8 @@ export const addAnnotationActionImplementation: BehaviorActionImplementation<
41
57
  reverse: Range.isBackward(editor.selection),
42
58
  })
43
59
 
60
+ let blockIndex = 0
61
+
44
62
  for (const [block, blockPath] of selectedBlocks) {
45
63
  if (block.children.length === 0) {
46
64
  continue
@@ -50,11 +68,13 @@ export const addAnnotationActionImplementation: BehaviorActionImplementation<
50
68
  continue
51
69
  }
52
70
 
53
- const annotationKey = context.keyGenerator()
71
+ // Make sure we don't generate more keys than needed
72
+ const annotationKey =
73
+ blockIndex === 0 ? parsedAnnotation._key : context.keyGenerator()
54
74
  const markDefs = block.markDefs ?? []
55
75
  const existingMarkDef = markDefs.find(
56
76
  (markDef) =>
57
- markDef._type === action.annotation.name &&
77
+ markDef._type === parsedAnnotation._type &&
58
78
  markDef._key === annotationKey,
59
79
  )
60
80
 
@@ -65,9 +85,8 @@ export const addAnnotationActionImplementation: BehaviorActionImplementation<
65
85
  markDefs: [
66
86
  ...markDefs,
67
87
  {
68
- _type: action.annotation.name,
88
+ ...parsedAnnotation,
69
89
  _key: annotationKey,
70
- ...action.annotation.value,
71
90
  },
72
91
  ],
73
92
  },
@@ -100,7 +119,7 @@ export const addAnnotationActionImplementation: BehaviorActionImplementation<
100
119
  const existingSameTypeAnnotations = marks.filter((mark) =>
101
120
  markDefs.some(
102
121
  (markDef) =>
103
- markDef._key === mark && markDef._type === action.annotation.name,
122
+ markDef._key === mark && markDef._type === parsedAnnotation._type,
104
123
  ),
105
124
  )
106
125
 
@@ -119,6 +138,8 @@ export const addAnnotationActionImplementation: BehaviorActionImplementation<
119
138
 
120
139
  spanPath = [{_key: block._key}, 'children', {_key: span._key}]
121
140
  }
141
+
142
+ blockIndex++
122
143
  }
123
144
 
124
145
  if (markDefPath && spanPath) {
@@ -18,17 +18,17 @@ export const decoratorAddActionImplementation: BehaviorActionImplementation<
18
18
  KEY_TO_VALUE_ELEMENT.get(editor),
19
19
  )
20
20
 
21
- const manualAnchor = action.offsets?.anchor
21
+ const manualAnchor = action.at?.anchor
22
22
  ? utils.blockOffsetToSpanSelectionPoint({
23
23
  value,
24
- blockOffset: action.offsets.anchor,
24
+ blockOffset: action.at.anchor,
25
25
  direction: 'backward',
26
26
  })
27
27
  : undefined
28
- const manualFocus = action.offsets?.focus
28
+ const manualFocus = action.at?.focus
29
29
  ? utils.blockOffsetToSpanSelectionPoint({
30
30
  value,
31
- blockOffset: action.offsets.focus,
31
+ blockOffset: action.at.focus,
32
32
  direction: 'forward',
33
33
  })
34
34
  : undefined
@@ -17,10 +17,7 @@ export const deleteTextActionImplementation: BehaviorActionImplementation<
17
17
 
18
18
  const selection = utils.blockOffsetsToSelection({
19
19
  value,
20
- offsets: {
21
- anchor: action.anchor,
22
- focus: action.focus,
23
- },
20
+ offsets: action.at,
24
21
  })
25
22
 
26
23
  if (!selection) {
@@ -4,11 +4,11 @@ import type {BehaviorActionImplementation} from './behavior.actions'
4
4
  export const deleteActionImplementation: BehaviorActionImplementation<
5
5
  'delete'
6
6
  > = ({action}) => {
7
- const range = toSlateRange(action.selection, action.editor)
7
+ const range = toSlateRange(action.at, action.editor)
8
8
 
9
9
  if (!range) {
10
10
  throw new Error(
11
- `Failed to get Slate Range for selection ${JSON.stringify(action.selection)}`,
11
+ `Failed to get Slate Range for selection ${JSON.stringify(action.at)}`,
12
12
  )
13
13
  }
14
14
 
@@ -1,17 +1,24 @@
1
1
  import {Editor, Transforms, type Element} from 'slate'
2
+ import {parseInlineObject} from '../internal-utils/parse-blocks'
2
3
  import {toSlateValue} from '../internal-utils/values'
3
4
  import type {BehaviorActionImplementation} from './behavior.actions'
4
5
 
5
6
  export const insertInlineObjectActionImplementation: BehaviorActionImplementation<
6
7
  'insert.inline object'
7
8
  > = ({context, action}) => {
8
- if (
9
- !context.schema.inlineObjects.some(
10
- (inlineObject) => inlineObject.name === action.inlineObject.name,
9
+ const parsedInlineObject = parseInlineObject({
10
+ context,
11
+ inlineObject: {
12
+ _type: action.inlineObject.name,
13
+ ...(action.inlineObject.value ?? {}),
14
+ },
15
+ options: {refreshKeys: false},
16
+ })
17
+
18
+ if (!parsedInlineObject) {
19
+ throw new Error(
20
+ `Failed to parse inline object ${JSON.stringify(action.inlineObject)}`,
11
21
  )
12
- ) {
13
- console.error('Unable to insert unknown inline object')
14
- return
15
22
  }
16
23
 
17
24
  if (!action.editor.selection) {
@@ -36,13 +43,7 @@ export const insertInlineObjectActionImplementation: BehaviorActionImplementatio
36
43
  {
37
44
  _type: context.schema.block.name,
38
45
  _key: context.keyGenerator(),
39
- children: [
40
- {
41
- _type: action.inlineObject.name,
42
- _key: context.keyGenerator(),
43
- ...(action.inlineObject.value ?? {}),
44
- },
45
- ],
46
+ children: [parsedInlineObject],
46
47
  },
47
48
  ],
48
49
  {schemaTypes: context.schema},
@@ -5,7 +5,7 @@ import type {BehaviorActionImplementation} from './behavior.actions'
5
5
  export const selectActionImplementation: BehaviorActionImplementation<
6
6
  'select'
7
7
  > = ({action}) => {
8
- const newSelection = toSlateRange(action.selection, action.editor)
8
+ const newSelection = toSlateRange(action.at, action.editor)
9
9
 
10
10
  if (newSelection) {
11
11
  Transforms.select(action.editor, newSelection)
@@ -16,10 +16,10 @@ export const abstractDecoratorBehaviors = [
16
16
  defineBehavior({
17
17
  on: 'decorator.toggle',
18
18
  guard: ({snapshot, event}) => {
19
- const manualSelection = event.offsets
19
+ const manualSelection = event.at
20
20
  ? blockOffsetsToSelection({
21
21
  value: snapshot.context.value,
22
- offsets: event.offsets,
22
+ offsets: event.at,
23
23
  })
24
24
  : null
25
25
 
@@ -29,7 +29,7 @@ export const abstractSelectBehaviors = [
29
29
  (_, {selection}) => [
30
30
  raise({
31
31
  type: 'select',
32
- selection,
32
+ at: selection,
33
33
  }),
34
34
  ],
35
35
  ],
@@ -54,7 +54,7 @@ export const abstractSelectBehaviors = [
54
54
  (_, {selection}) => [
55
55
  raise({
56
56
  type: 'select',
57
- selection,
57
+ at: selection,
58
58
  }),
59
59
  ],
60
60
  ],
@@ -28,7 +28,7 @@ const addAnnotationOnCollapsedSelection = defineBehavior({
28
28
  },
29
29
  actions: [
30
30
  ({event}, {caretWordSelection}) => [
31
- raise({type: 'select', selection: caretWordSelection}),
31
+ raise({type: 'select', at: caretWordSelection}),
32
32
  raise({type: 'annotation.add', annotation: event.annotation}),
33
33
  ],
34
34
  ],
@@ -132,7 +132,7 @@ const clickingAboveLonelyBlockObject = defineBehavior({
132
132
  ({snapshot, event}) => [
133
133
  raise({
134
134
  type: 'select',
135
- selection: event.position.selection,
135
+ at: event.position.selection,
136
136
  }),
137
137
  raise({
138
138
  type: 'insert.block',
@@ -186,7 +186,7 @@ const clickingBelowLonelyBlockObject = defineBehavior({
186
186
  ({snapshot, event}) => [
187
187
  raise({
188
188
  type: 'select',
189
- selection: event.position.selection,
189
+ at: event.position.selection,
190
190
  }),
191
191
  raise({
192
192
  type: 'insert.block',
@@ -228,7 +228,7 @@ const deletingEmptyTextBlockAfterBlockObject = defineBehavior({
228
228
  }),
229
229
  raise({
230
230
  type: 'select',
231
- selection: {
231
+ at: {
232
232
  anchor: {path: previousBlock.path, offset: 0},
233
233
  focus: {path: previousBlock.path, offset: 0},
234
234
  },
@@ -265,7 +265,7 @@ const deletingEmptyTextBlockBeforeBlockObject = defineBehavior({
265
265
  }),
266
266
  raise({
267
267
  type: 'select',
268
- selection: {
268
+ at: {
269
269
  anchor: {path: nextBlock.path, offset: 0},
270
270
  focus: {path: nextBlock.path, offset: 0},
271
271
  },
@@ -165,7 +165,7 @@ export function createDecoratorPairBehavior(config: {
165
165
  {
166
166
  type: 'decorator.add',
167
167
  decorator,
168
- offsets: {
168
+ at: {
169
169
  anchor: prefixOffsets.focus,
170
170
  focus: suffixOffsets.anchor,
171
171
  },
@@ -173,12 +173,12 @@ export function createDecoratorPairBehavior(config: {
173
173
  // Delete the suffix
174
174
  {
175
175
  type: 'delete.text',
176
- ...suffixOffsets,
176
+ at: suffixOffsets,
177
177
  },
178
178
  // Delete the prefix
179
179
  {
180
180
  type: 'delete.text',
181
- ...prefixOffsets,
181
+ at: prefixOffsets,
182
182
  },
183
183
  // Toggle the decorator off so the next inserted text isn't emphasized
184
184
  {
@@ -149,7 +149,7 @@ export const defaultBehaviors = [
149
149
  }),
150
150
  raise({
151
151
  type: 'delete',
152
- selection,
152
+ at: selection,
153
153
  }),
154
154
  ],
155
155
  ],
@@ -220,7 +220,7 @@ export const defaultBehaviors = [
220
220
  ({event}) => [
221
221
  raise({
222
222
  type: 'select',
223
- selection: event.position.selection,
223
+ at: event.position.selection,
224
224
  }),
225
225
  raise({
226
226
  type: 'deserialize',
@@ -293,7 +293,7 @@ export const defaultBehaviors = [
293
293
  : [
294
294
  raise({
295
295
  type: 'delete',
296
- selection: dragOrigin.selection,
296
+ at: dragOrigin.selection,
297
297
  }),
298
298
  ]),
299
299
  raise({
@@ -414,7 +414,7 @@ export const defaultBehaviors = [
414
414
  ({event}, {selection}) => [
415
415
  raise({
416
416
  type: 'delete',
417
- selection,
417
+ at: selection,
418
418
  }),
419
419
  raise({
420
420
  type: 'deserialize',
@@ -131,13 +131,15 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
131
131
  },
132
132
  {
133
133
  type: 'delete.text',
134
- anchor: {
135
- path: params.focusBlock.path,
136
- offset: params.textBeforeLength - params.emojiStringLength,
137
- },
138
- focus: {
139
- path: params.focusBlock.path,
140
- offset: params.textBeforeLength,
134
+ at: {
135
+ anchor: {
136
+ path: params.focusBlock.path,
137
+ offset: params.textBeforeLength - params.emojiStringLength,
138
+ },
139
+ focus: {
140
+ path: params.focusBlock.path,
141
+ offset: params.textBeforeLength,
142
+ },
141
143
  },
142
144
  },
143
145
  {
@@ -225,13 +227,15 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
225
227
  },
226
228
  {
227
229
  type: 'delete.text',
228
- anchor: {
229
- path: params.focusBlock.path,
230
- offset: params.textBeforeLength - params.emojiStringLength,
231
- },
232
- focus: {
233
- path: params.focusBlock.path,
234
- offset: params.textBeforeLength,
230
+ at: {
231
+ anchor: {
232
+ path: params.focusBlock.path,
233
+ offset: params.textBeforeLength - params.emojiStringLength,
234
+ },
235
+ focus: {
236
+ path: params.focusBlock.path,
237
+ offset: params.textBeforeLength,
238
+ },
235
239
  },
236
240
  },
237
241
  {
@@ -137,13 +137,15 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
137
137
  },
138
138
  {
139
139
  type: 'delete.text',
140
- anchor: {
141
- path: focusTextBlock.path,
142
- offset: 0,
143
- },
144
- focus: {
145
- path: focusTextBlock.path,
146
- offset: 2,
140
+ at: {
141
+ anchor: {
142
+ path: focusTextBlock.path,
143
+ offset: 0,
144
+ },
145
+ focus: {
146
+ path: focusTextBlock.path,
147
+ offset: 2,
148
+ },
147
149
  },
148
150
  },
149
151
  ],
@@ -213,7 +215,7 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
213
215
  },
214
216
  {
215
217
  type: 'delete.text',
216
- ...hrBlockOffsets,
218
+ at: hrBlockOffsets,
217
219
  },
218
220
  ],
219
221
  ],
@@ -222,7 +224,7 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
222
224
  on: 'clipboard.paste',
223
225
  guard: ({snapshot, event}) => {
224
226
  const text = event.originEvent.dataTransfer.getData('text/plain')
225
- const hrRegExp = /^(---)$|(___)$|(\*\*\*)$/gm
227
+ const hrRegExp = /^(---)$|(___)$|(\*\*\*)$/
226
228
  const hrCharacters = text.match(hrRegExp)?.[0]
227
229
  const hrObject = config.horizontalRuleObject?.(snapshot.context)
228
230
  const focusBlock = selectors.getFocusBlock(snapshot)
@@ -348,13 +350,15 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
348
350
  },
349
351
  {
350
352
  type: 'delete.text',
351
- anchor: {
352
- path: focusTextBlock.path,
353
- offset: 0,
354
- },
355
- focus: {
356
- path: focusTextBlock.path,
357
- offset: level + 1,
353
+ at: {
354
+ anchor: {
355
+ path: focusTextBlock.path,
356
+ offset: 0,
357
+ },
358
+ focus: {
359
+ path: focusTextBlock.path,
360
+ offset: level + 1,
361
+ },
358
362
  },
359
363
  },
360
364
  ],
@@ -485,13 +489,15 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
485
489
  },
486
490
  {
487
491
  type: 'delete.text',
488
- anchor: {
489
- path: focusTextBlock.path,
490
- offset: 0,
491
- },
492
- focus: {
493
- path: focusTextBlock.path,
494
- offset: listItemLength + 1,
492
+ at: {
493
+ anchor: {
494
+ path: focusTextBlock.path,
495
+ offset: 0,
496
+ },
497
+ focus: {
498
+ path: focusTextBlock.path,
499
+ offset: listItemLength + 1,
500
+ },
495
501
  },
496
502
  },
497
503
  ],