@portabletext/editor 1.40.2 → 1.40.4

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 (74) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +37 -16
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/behavior.markdown.cjs +22 -10
  4. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  5. package/lib/_chunks-cjs/editor-provider.cjs +93 -100
  6. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  7. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs +6 -0
  8. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -0
  9. package/lib/_chunks-cjs/util.merge-text-blocks.cjs +26 -0
  10. package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -0
  11. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +1 -0
  12. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
  13. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
  14. package/lib/_chunks-es/behavior.core.js +37 -16
  15. package/lib/_chunks-es/behavior.core.js.map +1 -1
  16. package/lib/_chunks-es/behavior.markdown.js +22 -10
  17. package/lib/_chunks-es/behavior.markdown.js.map +1 -1
  18. package/lib/_chunks-es/editor-provider.js +94 -101
  19. package/lib/_chunks-es/editor-provider.js.map +1 -1
  20. package/lib/_chunks-es/util.is-selection-collapsed.js +7 -0
  21. package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -0
  22. package/lib/_chunks-es/util.merge-text-blocks.js +27 -0
  23. package/lib/_chunks-es/util.merge-text-blocks.js.map +1 -0
  24. package/lib/_chunks-es/util.selection-point-to-block-offset.js +1 -0
  25. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  26. package/lib/behaviors/index.d.cts +3881 -5053
  27. package/lib/behaviors/index.d.ts +3881 -5053
  28. package/lib/index.cjs +47 -13
  29. package/lib/index.cjs.map +1 -1
  30. package/lib/index.d.cts +3402 -4440
  31. package/lib/index.d.ts +3402 -4440
  32. package/lib/index.js +49 -14
  33. package/lib/index.js.map +1 -1
  34. package/lib/plugins/index.cjs +9 -127
  35. package/lib/plugins/index.cjs.map +1 -1
  36. package/lib/plugins/index.d.cts +3404 -4441
  37. package/lib/plugins/index.d.ts +3404 -4441
  38. package/lib/plugins/index.js +11 -129
  39. package/lib/plugins/index.js.map +1 -1
  40. package/lib/selectors/index.d.cts +3401 -4440
  41. package/lib/selectors/index.d.ts +3401 -4440
  42. package/lib/utils/index.cjs +45 -7
  43. package/lib/utils/index.cjs.map +1 -1
  44. package/lib/utils/index.d.cts +3403 -4443
  45. package/lib/utils/index.d.ts +3403 -4443
  46. package/lib/utils/index.js +45 -5
  47. package/lib/utils/index.js.map +1 -1
  48. package/package.json +6 -6
  49. package/src/behavior-actions/behavior.action.delete.block.ts +2 -2
  50. package/src/behavior-actions/behavior.action.insert-blocks.ts +5 -1
  51. package/src/behavior-actions/behavior.actions.ts +0 -18
  52. package/src/behaviors/behavior.core.block-objects.ts +57 -7
  53. package/src/behaviors/behavior.core.insert-break.ts +0 -4
  54. package/src/behaviors/behavior.default.ts +1 -1
  55. package/src/behaviors/behavior.markdown.ts +22 -10
  56. package/src/behaviors/behavior.types.ts +171 -138
  57. package/src/editor/create-editor.ts +2 -0
  58. package/src/editor/editor-machine.ts +28 -28
  59. package/src/editor/plugins/create-with-event-listeners.ts +15 -0
  60. package/src/editor/plugins/createWithEditableAPI.ts +4 -4
  61. package/src/internal-utils/drag-selection.test.ts +74 -1
  62. package/src/internal-utils/drag-selection.ts +20 -4
  63. package/src/internal-utils/event-position.ts +38 -7
  64. package/src/internal-utils/slate-utils.ts +60 -1
  65. package/src/plugins/plugin.one-line.tsx +10 -128
  66. package/src/types/block-with-optional-key.ts +13 -0
  67. package/src/utils/util.is-keyed-segment.ts +2 -2
  68. package/src/utils/util.is-text-block.ts +4 -3
  69. package/lib/_chunks-cjs/util.split-text-block.cjs +0 -68
  70. package/lib/_chunks-cjs/util.split-text-block.cjs.map +0 -1
  71. package/lib/_chunks-es/util.split-text-block.js +0 -70
  72. package/lib/_chunks-es/util.split-text-block.js.map +0 -1
  73. package/src/behavior-actions/behavior.action.insert.block-object.ts +0 -20
  74. package/src/behavior-actions/behavior.action.insert.text-block.ts +0 -33
@@ -1,12 +1,52 @@
1
- import { isEqualSelectionPoints } from "../_chunks-es/util.slice-blocks.js";
2
- import { blockOffsetToSpanSelectionPoint, getBlockEndPoint, getBlockStartPoint, getTextBlockText, isEmptyTextBlock, isKeyedSegment, isSpan, reverseSelection, sliceBlocks, spanSelectionPointToBlockOffset } from "../_chunks-es/util.slice-blocks.js";
1
+ import { isEqualSelectionPoints, sliceBlocks, isSpan } from "../_chunks-es/util.slice-blocks.js";
2
+ import { blockOffsetToSpanSelectionPoint, getBlockEndPoint, getBlockStartPoint, getTextBlockText, isEmptyTextBlock, isKeyedSegment, reverseSelection, spanSelectionPointToBlockOffset } from "../_chunks-es/util.slice-blocks.js";
3
3
  import { blockOffsetToBlockSelectionPoint, blockOffsetToSelectionPoint, blockOffsetsToSelection, childSelectionPointToBlockOffset, selectionPointToBlockOffset } from "../_chunks-es/util.selection-point-to-block-offset.js";
4
- import { isTextBlock, mergeTextBlocks, splitTextBlock } from "../_chunks-es/util.split-text-block.js";
4
+ import { isSelectionCollapsed } from "../_chunks-es/util.is-selection-collapsed.js";
5
+ import { isTextBlock } from "../_chunks-es/util.merge-text-blocks.js";
6
+ import { mergeTextBlocks } from "../_chunks-es/util.merge-text-blocks.js";
5
7
  function isEqualSelections(a, b) {
6
8
  return !a && !b ? !0 : !a || !b ? !1 : isEqualSelectionPoints(a.anchor, b.anchor) && isEqualSelectionPoints(a.focus, b.focus);
7
9
  }
8
- function isSelectionCollapsed(selection) {
9
- return selection ? selection.anchor.path.join() === selection.focus.path.join() && selection.anchor.offset === selection.focus.offset : !1;
10
+ function splitTextBlock({
11
+ context,
12
+ block,
13
+ point
14
+ }) {
15
+ const firstChild = block.children.at(0), lastChild = block.children.at(block.children.length - 1);
16
+ if (!firstChild || !lastChild)
17
+ return;
18
+ const before = sliceBlocks({
19
+ blocks: [block],
20
+ selection: {
21
+ anchor: {
22
+ path: [{
23
+ _key: block._key
24
+ }, "children", {
25
+ _key: firstChild._key
26
+ }],
27
+ offset: 0
28
+ },
29
+ focus: point
30
+ }
31
+ }).at(0), after = sliceBlocks({
32
+ blocks: [block],
33
+ selection: {
34
+ anchor: point,
35
+ focus: {
36
+ path: [{
37
+ _key: block._key
38
+ }, "children", {
39
+ _key: lastChild._key
40
+ }],
41
+ offset: isSpan(context, lastChild) ? lastChild.text.length : 0
42
+ }
43
+ }
44
+ }).at(0);
45
+ if (!(!before || !after) && !(!isTextBlock(context, before) || !isTextBlock(context, after)))
46
+ return {
47
+ before,
48
+ after
49
+ };
10
50
  }
11
51
  export {
12
52
  blockOffsetToBlockSelectionPoint,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/utils/util.is-equal-selections.ts","../../src/utils/util.is-selection-collapsed.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 {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport function isSelectionCollapsed(selection: EditorSelection) {\n if (!selection) {\n return false\n }\n\n return (\n selection.anchor.path.join() === selection.focus.path.join() &&\n selection.anchor.offset === selection.focus.offset\n )\n}\n"],"names":["isEqualSelections","a","b","isEqualSelectionPoints","anchor","focus","isSelectionCollapsed","selection","path","join","offset"],"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;ACdO,SAASC,qBAAqBC,WAA4B;AAC/D,SAAKA,YAKHA,UAAUH,OAAOI,KAAKC,KAAAA,MAAWF,UAAUF,MAAMG,KAAKC,KAAAA,KACtDF,UAAUH,OAAOM,WAAWH,UAAUF,MAAMK,SALrC;AAOX;"}
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.40.2",
3
+ "version": "1.40.4",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -80,14 +80,14 @@
80
80
  "use-effect-event": "^1.0.2",
81
81
  "xstate": "^5.19.2",
82
82
  "@portabletext/patches": "1.1.3",
83
- "@portabletext/block-tools": "1.1.13"
83
+ "@portabletext/block-tools": "1.1.14"
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.1.1",
89
- "@sanity/schema": "^3.79.0",
90
- "@sanity/types": "^3.79.0",
89
+ "@sanity/schema": "^3.80.1",
90
+ "@sanity/types": "^3.80.1",
91
91
  "@testing-library/jest-dom": "^6.6.3",
92
92
  "@testing-library/react": "^16.2.0",
93
93
  "@types/debug": "^4.1.12",
@@ -115,8 +115,8 @@
115
115
  "racejar": "1.2.2"
116
116
  },
117
117
  "peerDependencies": {
118
- "@sanity/schema": "^3.79.0",
119
- "@sanity/types": "^3.79.0",
118
+ "@sanity/schema": "^3.80.1",
119
+ "@sanity/types": "^3.80.1",
120
120
  "react": "^16.9 || ^17 || ^18 || ^19",
121
121
  "rxjs": "^7.8.2"
122
122
  },
@@ -7,8 +7,8 @@ export const deleteBlockActionImplementation: BehaviorActionImplementation<
7
7
  > = ({action}) => {
8
8
  const range = toSlateRange(
9
9
  {
10
- anchor: {path: action.blockPath, offset: 0},
11
- focus: {path: action.blockPath, offset: 0},
10
+ anchor: {path: action.at, offset: 0},
11
+ focus: {path: action.at, offset: 0},
12
12
  },
13
13
  action.editor,
14
14
  )
@@ -122,14 +122,18 @@ export const insertBlocksActionImplementation: BehaviorActionImplementation<
122
122
  index++
123
123
  }
124
124
  } else {
125
+ let index = 0
126
+
125
127
  for (const block of fragment) {
126
128
  insertBlock({
127
129
  block,
128
- placement: 'auto',
130
+ placement: index === 0 ? 'auto' : 'after',
129
131
  select: 'end',
130
132
  editor: action.editor,
131
133
  schema: context.schema,
132
134
  })
135
+
136
+ index++
133
137
  }
134
138
  }
135
139
  }
@@ -36,9 +36,7 @@ import {
36
36
  import {insertInlineObjectActionImplementation} from './behavior.action.insert-inline-object'
37
37
  import {insertSpanActionImplementation} from './behavior.action.insert-span'
38
38
  import {insertBlockActionImplementation} from './behavior.action.insert.block'
39
- import {insertBlockObjectActionImplementation} from './behavior.action.insert.block-object'
40
39
  import {insertTextActionImplementation} from './behavior.action.insert.text'
41
- import {insertTextBlockActionImplementation} from './behavior.action.insert.text-block'
42
40
  import {
43
41
  addListItemActionImplementation,
44
42
  removeListItemActionImplementation,
@@ -102,13 +100,11 @@ const behaviorActionImplementations: BehaviorActionImplementations = {
102
100
  'history.undo': historyUndoActionImplementation,
103
101
  'insert.block': insertBlockActionImplementation,
104
102
  'insert.blocks': insertBlocksActionImplementation,
105
- 'insert.block object': insertBlockObjectActionImplementation,
106
103
  'insert.break': insertBreakActionImplementation,
107
104
  'insert.inline object': insertInlineObjectActionImplementation,
108
105
  'insert.soft break': insertSoftBreakActionImplementation,
109
106
  'insert.span': insertSpanActionImplementation,
110
107
  'insert.text': insertTextActionImplementation,
111
- 'insert.text block': insertTextBlockActionImplementation,
112
108
  'effect': effectActionImplementation,
113
109
  'list item.add': addListItemActionImplementation,
114
110
  'list item.remove': removeListItemActionImplementation,
@@ -296,13 +292,6 @@ export function performAction({
296
292
  })
297
293
  break
298
294
  }
299
- case 'insert.block object': {
300
- behaviorActionImplementations['insert.block object']({
301
- context,
302
- action,
303
- })
304
- break
305
- }
306
295
  case 'insert.inline object': {
307
296
  behaviorActionImplementations['insert.inline object']({
308
297
  context,
@@ -338,13 +327,6 @@ export function performAction({
338
327
  })
339
328
  break
340
329
  }
341
- case 'insert.text block': {
342
- behaviorActionImplementations['insert.text block']({
343
- context,
344
- action,
345
- })
346
- break
347
- }
348
330
  case 'list item.add': {
349
331
  behaviorActionImplementations['list item.add']({
350
332
  context,
@@ -24,7 +24,17 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
24
24
 
25
25
  return focusBlockObject && !nextBlock
26
26
  },
27
- actions: [() => [raise({type: 'insert.text block', placement: 'after'})]],
27
+ actions: [
28
+ ({snapshot}) => [
29
+ raise({
30
+ type: 'insert.block',
31
+ block: {
32
+ _type: snapshot.context.schema.block.name,
33
+ },
34
+ placement: 'after',
35
+ }),
36
+ ],
37
+ ],
28
38
  })
29
39
 
30
40
  const arrowUpOnLonelyBlockObject = defineBehavior({
@@ -47,7 +57,17 @@ const arrowUpOnLonelyBlockObject = defineBehavior({
47
57
 
48
58
  return focusBlockObject && !previousBlock
49
59
  },
50
- actions: [() => [raise({type: 'insert.text block', placement: 'before'})]],
60
+ actions: [
61
+ ({snapshot}) => [
62
+ raise({
63
+ type: 'insert.block',
64
+ block: {
65
+ _type: snapshot.context.schema.block.name,
66
+ },
67
+ placement: 'before',
68
+ }),
69
+ ],
70
+ ],
51
71
  })
52
72
 
53
73
  const breakingBlockObject = defineBehavior({
@@ -58,7 +78,17 @@ const breakingBlockObject = defineBehavior({
58
78
 
59
79
  return collapsedSelection && focusBlockObject !== undefined
60
80
  },
61
- actions: [() => [raise({type: 'insert.text block', placement: 'after'})]],
81
+ actions: [
82
+ ({snapshot}) => [
83
+ raise({
84
+ type: 'insert.block',
85
+ block: {
86
+ _type: snapshot.context.schema.block.name,
87
+ },
88
+ placement: 'after',
89
+ }),
90
+ ],
91
+ ],
62
92
  })
63
93
 
64
94
  const clickingAboveLonelyBlockObject = defineBehavior({
@@ -78,7 +108,17 @@ const clickingAboveLonelyBlockObject = defineBehavior({
78
108
  !previousBlock
79
109
  )
80
110
  },
81
- actions: [() => [raise({type: 'insert.text block', placement: 'before'})]],
111
+ actions: [
112
+ ({snapshot}) => [
113
+ raise({
114
+ type: 'insert.block',
115
+ block: {
116
+ _type: snapshot.context.schema.block.name,
117
+ },
118
+ placement: 'before',
119
+ }),
120
+ ],
121
+ ],
82
122
  })
83
123
 
84
124
  const clickingBelowLonelyBlockObject = defineBehavior({
@@ -98,7 +138,17 @@ const clickingBelowLonelyBlockObject = defineBehavior({
98
138
  !nextBlock
99
139
  )
100
140
  },
101
- actions: [() => [raise({type: 'insert.text block', placement: 'after'})]],
141
+ actions: [
142
+ ({snapshot}) => [
143
+ raise({
144
+ type: 'insert.block',
145
+ block: {
146
+ _type: snapshot.context.schema.block.name,
147
+ },
148
+ placement: 'after',
149
+ }),
150
+ ],
151
+ ],
102
152
  })
103
153
 
104
154
  const deletingEmptyTextBlockAfterBlockObject = defineBehavior({
@@ -125,7 +175,7 @@ const deletingEmptyTextBlockAfterBlockObject = defineBehavior({
125
175
  (_, {focusTextBlock, previousBlock}) => [
126
176
  raise({
127
177
  type: 'delete.block',
128
- blockPath: focusTextBlock.path,
178
+ at: focusTextBlock.path,
129
179
  }),
130
180
  raise({
131
181
  type: 'select',
@@ -162,7 +212,7 @@ const deletingEmptyTextBlockBeforeBlockObject = defineBehavior({
162
212
  (_, {focusTextBlock, nextBlock}) => [
163
213
  raise({
164
214
  type: 'delete.block',
165
- blockPath: focusTextBlock.path,
215
+ at: focusTextBlock.path,
166
216
  }),
167
217
  raise({
168
218
  type: 'select',
@@ -29,10 +29,8 @@ const breakingAtTheEndOfTextBlock = defineBehavior({
29
29
  type: 'insert.block',
30
30
  block: {
31
31
  _type: snapshot.context.schema.block.name,
32
- _key: snapshot.context.keyGenerator(),
33
32
  children: [
34
33
  {
35
- _key: snapshot.context.keyGenerator(),
36
34
  _type: snapshot.context.schema.span.name,
37
35
  text: '',
38
36
  marks: [],
@@ -94,11 +92,9 @@ const breakingAtTheStartOfTextBlock = defineBehavior({
94
92
  raise({
95
93
  type: 'insert.block',
96
94
  block: {
97
- _key: snapshot.context.keyGenerator(),
98
95
  _type: snapshot.context.schema.block.name,
99
96
  children: [
100
97
  {
101
- _key: snapshot.context.keyGenerator(),
102
98
  _type: snapshot.context.schema.span.name,
103
99
  marks: focusAnnotations.length === 0 ? focusDecorators : [],
104
100
  text: '',
@@ -359,7 +359,7 @@ export const defaultBehaviors = [
359
359
  ? draggedBlocks.map((block) =>
360
360
  raise({
361
361
  type: 'delete.block',
362
- blockPath: block.path,
362
+ at: block.path,
363
363
  }),
364
364
  )
365
365
  : [
@@ -204,9 +204,12 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
204
204
  ],
205
205
  (_, {hrObject, hrBlockOffsets}) => [
206
206
  {
207
- type: 'insert.block object',
207
+ type: 'insert.block',
208
208
  placement: 'before',
209
- blockObject: hrObject,
209
+ block: {
210
+ _type: hrObject.name,
211
+ ...(hrObject.value ?? {}),
212
+ },
210
213
  },
211
214
  {
212
215
  type: 'delete.text',
@@ -237,25 +240,34 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
237
240
  text: hrCharacters,
238
241
  },
239
242
  ],
240
- (_, {hrObject, focusBlock}) =>
243
+ ({snapshot}, {hrObject, focusBlock}) =>
241
244
  isPortableTextTextBlock(focusBlock.node)
242
245
  ? [
243
246
  {
244
- type: 'insert.text block',
245
- textBlock: {children: focusBlock.node.children},
247
+ type: 'insert.block',
248
+ block: {
249
+ _type: snapshot.context.schema.block.name,
250
+ children: focusBlock.node.children,
251
+ },
246
252
  placement: 'after',
247
253
  },
248
254
  {
249
- type: 'insert.block object',
250
- blockObject: hrObject,
255
+ type: 'insert.block',
256
+ block: {
257
+ _type: hrObject.name,
258
+ ...(hrObject.value ?? {}),
259
+ },
251
260
  placement: 'after',
252
261
  },
253
- {type: 'delete.block', blockPath: focusBlock.path},
262
+ {type: 'delete.block', at: focusBlock.path},
254
263
  ]
255
264
  : [
256
265
  {
257
- type: 'insert.block object',
258
- blockObject: hrObject,
266
+ type: 'insert.block',
267
+ block: {
268
+ _type: hrObject.name,
269
+ ...(hrObject.value ?? {}),
270
+ },
259
271
  placement: 'after',
260
272
  },
261
273
  ],