@portabletext/editor 1.48.7 → 1.48.8

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 (128) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +20 -8
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/behavior.markdown.cjs +5 -5
  4. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  5. package/lib/_chunks-cjs/editor-provider.cjs +121 -90
  6. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  7. package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
  8. package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
  9. package/lib/_chunks-cjs/selector.get-text-before.cjs +7 -4
  10. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  11. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +63 -47
  12. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
  13. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -23
  14. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  15. package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
  16. package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
  17. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +15 -15
  18. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
  19. package/lib/_chunks-cjs/util.slice-blocks.cjs +258 -38
  20. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
  21. package/lib/_chunks-es/behavior.core.js +21 -10
  22. package/lib/_chunks-es/behavior.core.js.map +1 -1
  23. package/lib/_chunks-es/behavior.markdown.js +5 -6
  24. package/lib/_chunks-es/behavior.markdown.js.map +1 -1
  25. package/lib/_chunks-es/editor-provider.js +75 -46
  26. package/lib/_chunks-es/editor-provider.js.map +1 -1
  27. package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -2
  28. package/lib/_chunks-es/selector.get-focus-inline-object.js.map +1 -1
  29. package/lib/_chunks-es/selector.get-text-before.js +7 -4
  30. package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
  31. package/lib/_chunks-es/selector.is-overlapping-selection.js +61 -46
  32. package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
  33. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +30 -26
  34. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  35. package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
  36. package/lib/_chunks-es/util.selection-point-to-block-offset.js +15 -16
  37. package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
  38. package/lib/_chunks-es/util.slice-blocks.js +258 -38
  39. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  40. package/lib/behaviors/index.d.cts +2552 -251
  41. package/lib/behaviors/index.d.ts +2552 -251
  42. package/lib/index.cjs +45 -21
  43. package/lib/index.cjs.map +1 -1
  44. package/lib/index.d.cts +2350 -51
  45. package/lib/index.d.ts +2350 -51
  46. package/lib/index.js +44 -21
  47. package/lib/index.js.map +1 -1
  48. package/lib/plugins/index.cjs +16 -7
  49. package/lib/plugins/index.cjs.map +1 -1
  50. package/lib/plugins/index.d.cts +2324 -24
  51. package/lib/plugins/index.d.ts +2324 -24
  52. package/lib/plugins/index.js +16 -7
  53. package/lib/plugins/index.js.map +1 -1
  54. package/lib/selectors/index.cjs +5 -5
  55. package/lib/selectors/index.cjs.map +1 -1
  56. package/lib/selectors/index.d.cts +2321 -28
  57. package/lib/selectors/index.d.ts +2321 -28
  58. package/lib/selectors/index.js +5 -6
  59. package/lib/selectors/index.js.map +1 -1
  60. package/lib/utils/index.cjs +30 -24
  61. package/lib/utils/index.cjs.map +1 -1
  62. package/lib/utils/index.d.cts +2350 -44
  63. package/lib/utils/index.d.ts +2350 -44
  64. package/lib/utils/index.js +30 -24
  65. package/lib/utils/index.js.map +1 -1
  66. package/package.json +1 -2
  67. package/src/behavior-actions/behavior.action.block.unset.ts +1 -1
  68. package/src/behavior-actions/behavior.action.decorator.add.ts +20 -5
  69. package/src/behaviors/behavior.abstract.decorator.ts +1 -1
  70. package/src/behaviors/behavior.abstract.delete.ts +1 -1
  71. package/src/behaviors/behavior.abstract.insert.ts +2 -2
  72. package/src/behaviors/behavior.abstract.select.ts +16 -4
  73. package/src/behaviors/behavior.abstract.split.ts +9 -6
  74. package/src/behaviors/behavior.core.block-objects.ts +5 -5
  75. package/src/behaviors/behavior.core.insert-break.ts +16 -4
  76. package/src/behaviors/behavior.core.lists.ts +4 -6
  77. package/src/behaviors/behavior.decorator-pair.ts +13 -4
  78. package/src/behaviors/behavior.default.ts +1 -1
  79. package/src/behaviors/behavior.markdown.ts +5 -5
  80. package/src/converters/converter.portable-text.ts +1 -1
  81. package/src/converters/converter.text-html.ts +1 -1
  82. package/src/converters/converter.text-plain.ts +4 -4
  83. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
  84. package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
  85. package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
  86. package/src/internal-utils/drag-selection.ts +16 -4
  87. package/src/internal-utils/event-position.ts +20 -8
  88. package/src/internal-utils/parse-blocks.ts +17 -5
  89. package/src/internal-utils/validateValue.ts +6 -6
  90. package/src/plugins/plugin.decorator-shortcut.ts +2 -2
  91. package/src/selectors/selector.get-active-annotations.ts +5 -2
  92. package/src/selectors/selector.get-active-list-item.ts +4 -3
  93. package/src/selectors/selector.get-active-style.ts +4 -3
  94. package/src/selectors/selector.get-anchor-text-block.ts +3 -6
  95. package/src/selectors/selector.get-block-offsets.ts +2 -2
  96. package/src/selectors/selector.get-caret-word-selection.ts +11 -5
  97. package/src/selectors/selector.get-selected-slice.ts +1 -1
  98. package/src/selectors/selector.get-selected-spans.ts +11 -15
  99. package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
  100. package/src/selectors/selector.get-selection-text.ts +3 -3
  101. package/src/selectors/selector.get-text-before.ts +5 -2
  102. package/src/selectors/selector.get-trimmed-selection.ts +20 -14
  103. package/src/selectors/selector.is-active-annotation.ts +4 -2
  104. package/src/selectors/selector.is-active-decorator.test.ts +3 -3
  105. package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
  106. package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
  107. package/src/selectors/selector.is-point-after-selection.ts +7 -6
  108. package/src/selectors/selector.is-point-before-selection.ts +7 -6
  109. package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
  110. package/src/selectors/selectors.ts +25 -28
  111. package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
  112. package/src/utils/util.block-offset-to-selection-point.ts +5 -5
  113. package/src/utils/util.block-offset.test.ts +219 -156
  114. package/src/utils/util.block-offset.ts +14 -17
  115. package/src/utils/util.block-offsets-to-selection.ts +5 -5
  116. package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
  117. package/src/utils/util.get-block-end-point.ts +15 -15
  118. package/src/utils/util.get-block-start-point.ts +13 -12
  119. package/src/utils/util.is-empty-text-block.ts +9 -8
  120. package/src/utils/util.selection-point-to-block-offset.ts +4 -4
  121. package/src/utils/util.slice-blocks.test.ts +178 -121
  122. package/src/utils/util.slice-blocks.ts +25 -24
  123. package/src/utils/util.split-text-block.ts +18 -12
  124. package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
  125. package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
  126. package/lib/_chunks-es/parse-blocks.js +0 -206
  127. package/lib/_chunks-es/parse-blocks.js.map +0 -1
  128. package/src/behavior-actions/behavior.guards.ts +0 -24
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), React = require("react"), slateReact = require("slate-react"), reactCompilerRuntime = require("react-compiler-runtime"), debug$f = require("debug"), isEqual = require("lodash/isEqual.js"), slate = require("slate"), xstate = require("xstate"), patches = require("@portabletext/patches"), types = require("@sanity/types"), flatten = require("lodash/flatten.js"), isPlainObject = require("lodash/isPlainObject.js"), uniq = require("lodash/uniq.js"), getRandomValues = require("get-random-values-esm"), parseBlocks = require("./parse-blocks.cjs"), util_sliceBlocks = require("./util.slice-blocks.cjs"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), omit = require("lodash/omit.js"), util_selectionPointToBlockOffset = require("./util.selection-point-to-block-offset.cjs"), selector_isSelectingEntireBlocks = require("./selector.is-selecting-entire-blocks.cjs"), slateDom = require("slate-dom"), startCase = require("lodash.startcase"), behavior_core = require("./behavior.core.cjs"), selector_isOverlappingSelection = require("./selector.is-overlapping-selection.cjs"), util_getSelectionStartPoint = require("./util.get-selection-start-point.cjs"), rxjs = require("rxjs"), useEffectEvent = require("use-effect-event");
2
+ var jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), React = require("react"), slateReact = require("slate-react"), reactCompilerRuntime = require("react-compiler-runtime"), debug$f = require("debug"), isEqual = require("lodash/isEqual.js"), slate = require("slate"), xstate = require("xstate"), patches = require("@portabletext/patches"), flatten = require("lodash/flatten.js"), isPlainObject = require("lodash/isPlainObject.js"), uniq = require("lodash/uniq.js"), util_sliceBlocks = require("./util.slice-blocks.cjs"), getRandomValues = require("get-random-values-esm"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), selector_isOverlappingSelection = require("./selector.is-overlapping-selection.cjs"), omit = require("lodash/omit.js"), util_selectionPointToBlockOffset = require("./util.selection-point-to-block-offset.cjs"), selector_isSelectingEntireBlocks = require("./selector.is-selecting-entire-blocks.cjs"), slateDom = require("slate-dom"), startCase = require("lodash.startcase"), behavior_core = require("./behavior.core.cjs"), util_getSelectionStartPoint = require("./util.get-selection-start-point.cjs"), rxjs = require("rxjs"), useEffectEvent = require("use-effect-event");
3
3
  function _interopDefaultCompat(e) {
4
4
  return e && typeof e == "object" && "default" in e ? e : { default: e };
5
5
  }
@@ -279,9 +279,9 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
279
279
  }
280
280
  }
281
281
  });
282
- function validateValue(value, types$1, keyGenerator) {
282
+ function validateValue(value, types, keyGenerator) {
283
283
  let resolution = null, valid = !0;
284
- const validChildTypes = [types$1.span.name, ...types$1.inlineObjects.map((t) => t.name)], validBlockTypes = [types$1.block.name, ...types$1.blockObjects.map((t) => t.name)];
284
+ const validChildTypes = [types.span.name, ...types.inlineObjects.map((t) => t.name)], validBlockTypes = [types.block.name, ...types.blockObjects.map((t) => t.name)];
285
285
  return value === void 0 ? {
286
286
  valid: !0,
287
287
  resolution: null,
@@ -333,7 +333,7 @@ function validateValue(value, types$1, keyGenerator) {
333
333
  }, !0;
334
334
  if (!blk._type || !validBlockTypes.includes(blk._type)) {
335
335
  if (blk._type === "block") {
336
- const currentBlockTypeName = types$1.block.name;
336
+ const currentBlockTypeName = types.block.name;
337
337
  return resolution = {
338
338
  patches: [patches.set({
339
339
  ...blk,
@@ -354,25 +354,27 @@ function validateValue(value, types$1, keyGenerator) {
354
354
  }
355
355
  }, !0;
356
356
  }
357
- return !blk._type && types.isPortableTextTextBlock({
357
+ return !blk._type && util_sliceBlocks.isTextBlock({
358
+ schema: types
359
+ }, {
358
360
  ...blk,
359
- _type: types$1.block.name
361
+ _type: types.block.name
360
362
  }) ? (resolution = {
361
363
  patches: [patches.set({
362
364
  ...blk,
363
- _type: types$1.block.name
365
+ _type: types.block.name
364
366
  }, [{
365
367
  _key: blk._key
366
368
  }])],
367
- description: `Block with _key '${blk._key}' is missing a type name. According to the schema, the block type name is '${types$1.block.name}'`,
368
- action: `Use type '${types$1.block.name}'`,
369
+ description: `Block with _key '${blk._key}' is missing a type name. According to the schema, the block type name is '${types.block.name}'`,
370
+ action: `Use type '${types.block.name}'`,
369
371
  item: blk,
370
372
  i18n: {
371
373
  description: "inputs.portable-text.invalid-value.missing-block-type.description",
372
374
  action: "inputs.portable-text.invalid-value.missing-block-type.action",
373
375
  values: {
374
376
  key: blk._key,
375
- expectedTypeName: types$1.block.name
377
+ expectedTypeName: types.block.name
376
378
  }
377
379
  }
378
380
  }, !0) : blk._type ? (resolution = {
@@ -406,7 +408,7 @@ function validateValue(value, types$1, keyGenerator) {
406
408
  }
407
409
  }, !0);
408
410
  }
409
- if (blk._type === types$1.block.name) {
411
+ if (blk._type === types.block.name) {
410
412
  const textBlock = blk;
411
413
  if (textBlock.children && !Array.isArray(textBlock.children))
412
414
  return resolution = {
@@ -428,7 +430,7 @@ function validateValue(value, types$1, keyGenerator) {
428
430
  }, !0;
429
431
  if (textBlock.children === void 0 || Array.isArray(textBlock.children) && textBlock.children.length === 0) {
430
432
  const newSpan = {
431
- _type: types$1.span.name,
433
+ _type: types.span.name,
432
434
  _key: keyGenerator(),
433
435
  text: "",
434
436
  marks: []
@@ -452,7 +454,7 @@ function validateValue(value, types$1, keyGenerator) {
452
454
  }
453
455
  }, !0;
454
456
  }
455
- const allUsedMarks = uniq__default.default(flatten__default.default(textBlock.children.filter((cld) => cld._type === types$1.span.name).map((cld) => cld.marks || [])));
457
+ const allUsedMarks = uniq__default.default(flatten__default.default(textBlock.children.filter((cld) => cld._type === types.span.name).map((cld) => cld.marks || [])));
456
458
  if (Array.isArray(blk.markDefs) && blk.markDefs.length > 0) {
457
459
  const unusedMarkDefs = uniq__default.default(blk.markDefs.map((def) => def._key).filter((key) => !allUsedMarks.includes(key)));
458
460
  if (unusedMarkDefs.length > 0)
@@ -476,9 +478,9 @@ function validateValue(value, types$1, keyGenerator) {
476
478
  }
477
479
  }, !0;
478
480
  }
479
- const orphanedMarks = allUsedMarks.filter((mark) => !types$1.decorators.map((dec) => dec.name).includes(mark)).filter((mark) => textBlock.markDefs === void 0 || !textBlock.markDefs.find((def) => def._key === mark));
481
+ const orphanedMarks = allUsedMarks.filter((mark) => !types.decorators.map((dec) => dec.name).includes(mark)).filter((mark) => textBlock.markDefs === void 0 || !textBlock.markDefs.find((def) => def._key === mark));
480
482
  if (orphanedMarks.length > 0) {
481
- const spanChildren = textBlock.children.filter((cld) => cld._type === types$1.span.name && Array.isArray(cld.marks) && cld.marks.some((mark) => orphanedMarks.includes(mark)));
483
+ const spanChildren = textBlock.children.filter((cld) => cld._type === types.span.name && Array.isArray(cld.marks) && cld.marks.some((mark) => orphanedMarks.includes(mark)));
482
484
  if (spanChildren) {
483
485
  const orphaned = orphanedMarks.join(", ");
484
486
  return resolution = {
@@ -543,7 +545,7 @@ function validateValue(value, types$1, keyGenerator) {
543
545
  }
544
546
  }, !0;
545
547
  }
546
- return child._type ? validChildTypes.includes(child._type) ? child._type === types$1.span.name && typeof child.text != "string" ? (resolution = {
548
+ return child._type ? validChildTypes.includes(child._type) ? child._type === types.span.name && typeof child.text != "string" ? (resolution = {
547
549
  patches: [patches.set({
548
550
  ...child,
549
551
  text: ""
@@ -2202,8 +2204,7 @@ const converterJson = {
2202
2204
  snapshot,
2203
2205
  event
2204
2206
  }) => {
2205
- const selection = snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection;
2206
- if (!selection)
2207
+ if (!(snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection))
2207
2208
  return {
2208
2209
  type: "serialization.failure",
2209
2210
  mimeType: "application/x-portable-text",
@@ -2211,8 +2212,8 @@ const converterJson = {
2211
2212
  reason: "No selection"
2212
2213
  };
2213
2214
  const blocks = util_sliceBlocks.sliceBlocks({
2214
- blocks: snapshot.context.value,
2215
- selection
2215
+ context: snapshot.context,
2216
+ blocks: snapshot.context.value
2216
2217
  });
2217
2218
  return blocks.length === 0 ? {
2218
2219
  type: "serialization.failure",
@@ -2238,7 +2239,7 @@ const converterJson = {
2238
2239
  reason: "Data is not an array"
2239
2240
  };
2240
2241
  const parsedBlocks = blocks.flatMap((block) => {
2241
- const parsedBlock = parseBlocks.parseBlock({
2242
+ const parsedBlock = util_sliceBlocks.parseBlock({
2242
2243
  context: snapshot.context,
2243
2244
  block,
2244
2245
  options: {
@@ -2269,8 +2270,7 @@ function createConverterTextHtml(legacySchema) {
2269
2270
  snapshot,
2270
2271
  event
2271
2272
  }) => {
2272
- const selection = snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection;
2273
- if (!selection)
2273
+ if (!(snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection))
2274
2274
  return {
2275
2275
  type: "serialization.failure",
2276
2276
  mimeType: "text/html",
@@ -2278,8 +2278,8 @@ function createConverterTextHtml(legacySchema) {
2278
2278
  reason: "No selection"
2279
2279
  };
2280
2280
  const blocks = util_sliceBlocks.sliceBlocks({
2281
- blocks: snapshot.context.value,
2282
- selection
2281
+ context: snapshot.context,
2282
+ blocks: snapshot.context.value
2283
2283
  }), html = toHtml.toHTML(blocks, {
2284
2284
  onMissingComponent: !1,
2285
2285
  components: {
@@ -2308,7 +2308,7 @@ function createConverterTextHtml(legacySchema) {
2308
2308
  keyGenerator: snapshot.context.keyGenerator,
2309
2309
  unstable_whitespaceOnPasteMode: legacySchema.block.options.unstable_whitespaceOnPasteMode
2310
2310
  }).flatMap((block) => {
2311
- const parsedBlock = parseBlocks.parseBlock({
2311
+ const parsedBlock = util_sliceBlocks.parseBlock({
2312
2312
  context: snapshot.context,
2313
2313
  block,
2314
2314
  options: {
@@ -2335,24 +2335,21 @@ function createConverterTextPlain(legacySchema) {
2335
2335
  serialize: ({
2336
2336
  snapshot,
2337
2337
  event
2338
- }) => {
2339
- const selection = snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection;
2340
- return selection ? {
2341
- type: "serialization.success",
2342
- data: util_sliceBlocks.sliceBlocks({
2343
- blocks: snapshot.context.value,
2344
- selection
2345
- }).map((block) => types.isPortableTextTextBlock(block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
2338
+ }) => snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection ? {
2339
+ type: "serialization.success",
2340
+ data: util_sliceBlocks.sliceBlocks({
2341
+ context: snapshot.context,
2342
+ blocks: snapshot.context.value
2343
+ }).map((block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
2346
2344
 
2347
2345
  `),
2348
- mimeType: "text/plain",
2349
- originEvent: event.originEvent
2350
- } : {
2351
- type: "serialization.failure",
2352
- mimeType: "text/plain",
2353
- originEvent: event.originEvent,
2354
- reason: "No selection"
2355
- };
2346
+ mimeType: "text/plain",
2347
+ originEvent: event.originEvent
2348
+ } : {
2349
+ type: "serialization.failure",
2350
+ mimeType: "text/plain",
2351
+ originEvent: event.originEvent,
2352
+ reason: "No selection"
2356
2353
  },
2357
2354
  deserialize: ({
2358
2355
  snapshot,
@@ -2361,7 +2358,7 @@ function createConverterTextPlain(legacySchema) {
2361
2358
  const textToHtml = `<html><body>${escapeHtml(event.data).split(/\n{2,}/).map((line) => line ? `<p>${line.replace(/(?:\r\n|\r|\n)/g, "<br/>")}</p>` : "<p></p>").join("")}</body></html>`, parsedBlocks = blockTools.htmlToBlocks(textToHtml, legacySchema.portableText, {
2362
2359
  keyGenerator: snapshot.context.keyGenerator
2363
2360
  }).flatMap((block) => {
2364
- const parsedBlock = parseBlocks.parseBlock({
2361
+ const parsedBlock = util_sliceBlocks.parseBlock({
2365
2362
  context: snapshot.context,
2366
2363
  block,
2367
2364
  options: {
@@ -3110,7 +3107,7 @@ const addAnnotationActionImplementation = ({
3110
3107
  context,
3111
3108
  action
3112
3109
  }) => {
3113
- const parsedAnnotation = parseBlocks.parseAnnotation({
3110
+ const parsedAnnotation = util_sliceBlocks.parseAnnotation({
3114
3111
  annotation: {
3115
3112
  _type: action.annotation.name,
3116
3113
  ...action.annotation.value
@@ -3244,7 +3241,7 @@ function toSlatePath(path, editor) {
3244
3241
  return [];
3245
3242
  const [block, blockPath] = Array.from(slate.Editor.nodes(editor, {
3246
3243
  at: [],
3247
- match: (n) => types.isKeySegment(path[0]) && n._key === path[0]._key
3244
+ match: (n) => selector_isOverlappingSelection.isKeySegment(path[0]) && n._key === path[0]._key
3248
3245
  }))[0] || [void 0, void 0];
3249
3246
  if (!block || !slate.Element.isElement(block))
3250
3247
  return [];
@@ -3308,7 +3305,7 @@ const blockSetBehaviorActionImplementation = ({
3308
3305
  const {
3309
3306
  _type,
3310
3307
  ...filteredProps
3311
- } = action.props, updatedBlock = parseBlocks.parseBlock({
3308
+ } = action.props, updatedBlock = util_sliceBlocks.parseBlock({
3312
3309
  context,
3313
3310
  block: {
3314
3311
  ...parsedBlock,
@@ -3352,8 +3349,8 @@ const blockSetBehaviorActionImplementation = ({
3352
3349
  const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(action.editor)).at(0);
3353
3350
  if (!parsedBlock)
3354
3351
  throw new Error(`Unable to parse block at ${JSON.stringify(action.at)}`);
3355
- if (parseBlocks.isTextBlock(context.schema, parsedBlock)) {
3356
- const propsToRemove = action.props.filter((prop) => prop !== "_type"), updatedTextBlock = parseBlocks.parseBlock({
3352
+ if (util_sliceBlocks.isTextBlock(context, parsedBlock)) {
3353
+ const propsToRemove = action.props.filter((prop) => prop !== "_type"), updatedTextBlock = util_sliceBlocks.parseBlock({
3357
3354
  context,
3358
3355
  block: omit__default.default(parsedBlock, propsToRemove),
3359
3356
  options: {
@@ -3370,7 +3367,7 @@ const blockSetBehaviorActionImplementation = ({
3370
3367
  });
3371
3368
  return;
3372
3369
  }
3373
- const updatedBlockObject = parseBlocks.parseBlock({
3370
+ const updatedBlockObject = util_sliceBlocks.parseBlock({
3374
3371
  context,
3375
3372
  block: omit__default.default(parsedBlock, action.props.filter((prop) => prop !== "_type")),
3376
3373
  options: {
@@ -3598,11 +3595,17 @@ const decoratorAddActionImplementation = ({
3598
3595
  action
3599
3596
  }) => {
3600
3597
  const editor = action.editor, mark = action.decorator, value = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), manualAnchor = action.at?.anchor ? util_sliceBlocks.blockOffsetToSpanSelectionPoint({
3601
- value,
3598
+ context: {
3599
+ ...context,
3600
+ value
3601
+ },
3602
3602
  blockOffset: action.at.anchor,
3603
3603
  direction: "backward"
3604
3604
  }) : void 0, manualFocus = action.at?.focus ? util_sliceBlocks.blockOffsetToSpanSelectionPoint({
3605
- value,
3605
+ context: {
3606
+ ...context,
3607
+ value
3608
+ },
3606
3609
  blockOffset: action.at.focus,
3607
3610
  direction: "forward"
3608
3611
  }) : void 0, manualSelection = manualAnchor && manualFocus ? {
@@ -3616,10 +3619,16 @@ const decoratorAddActionImplementation = ({
3616
3619
  editor,
3617
3620
  range: selection
3618
3621
  }), anchorOffset = editorSelection ? util_selectionPointToBlockOffset.selectionPointToBlockOffset({
3619
- value,
3622
+ context: {
3623
+ ...context,
3624
+ value
3625
+ },
3620
3626
  selectionPoint: editorSelection.anchor
3621
3627
  }) : void 0, focusOffset = editorSelection ? util_selectionPointToBlockOffset.selectionPointToBlockOffset({
3622
- value,
3628
+ context: {
3629
+ ...context,
3630
+ value
3631
+ },
3623
3632
  selectionPoint: editorSelection.focus
3624
3633
  }) : void 0;
3625
3634
  if (!anchorOffset || !focusOffset)
@@ -3632,7 +3641,10 @@ const decoratorAddActionImplementation = ({
3632
3641
  hanging: !0
3633
3642
  });
3634
3643
  const newValue = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), newSelection = util_selectionPointToBlockOffset.blockOffsetsToSelection({
3635
- value: newValue,
3644
+ context: {
3645
+ ...context,
3646
+ value: newValue
3647
+ },
3636
3648
  offsets: {
3637
3649
  anchor: anchorOffset,
3638
3650
  focus: focusOffset
@@ -3763,7 +3775,7 @@ const decoratorAddActionImplementation = ({
3763
3775
  context,
3764
3776
  action
3765
3777
  }) => {
3766
- const parsedInlineObject = parseBlocks.parseInlineObject({
3778
+ const parsedInlineObject = util_sliceBlocks.parseInlineObject({
3767
3779
  context,
3768
3780
  inlineObject: {
3769
3781
  _type: action.inlineObject.name,
@@ -3832,7 +3844,7 @@ const decoratorAddActionImplementation = ({
3832
3844
  context,
3833
3845
  action
3834
3846
  }) => {
3835
- const parsedBlock = parseBlocks.parseBlock({
3847
+ const parsedBlock = util_sliceBlocks.parseBlock({
3836
3848
  block: action.block,
3837
3849
  context,
3838
3850
  options: {
@@ -4931,7 +4943,7 @@ function createWithSchemaTypes({
4931
4943
  editorActor
4932
4944
  }) {
4933
4945
  return function(editor) {
4934
- editor.isTextBlock = (value) => types.isPortableTextTextBlock(value) && value._type === editorActor.getSnapshot().context.schema.block.name, editor.isTextSpan = (value) => types.isPortableTextSpan(value) && value._type === editorActor.getSnapshot().context.schema.span.name, editor.isListBlock = (value) => types.isPortableTextListBlock(value) && value._type === editorActor.getSnapshot().context.schema.block.name, editor.isVoid = (element) => editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
4946
+ editor.isTextBlock = (value) => util_sliceBlocks.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => util_sliceBlocks.isSpan(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => util_sliceBlocks.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
4935
4947
  const {
4936
4948
  normalizeNode
4937
4949
  } = editor;
@@ -5151,7 +5163,7 @@ function legacySchemaToEditorSchema(schema2) {
5151
5163
  };
5152
5164
  }
5153
5165
  function compileSchemaDefinitionToLegacySchema(definition) {
5154
- const blockObjects = definition?.blockObjects?.map((blockObject) => types.defineType({
5166
+ const blockObjects = definition?.blockObjects?.map((blockObject) => selector_isOverlappingSelection.defineType({
5155
5167
  type: "object",
5156
5168
  // Very naive way to work around `SanitySchema.compile` adding default
5157
5169
  // fields to objects with certain names.
@@ -5164,7 +5176,7 @@ function compileSchemaDefinitionToLegacySchema(definition) {
5164
5176
  name: field.name,
5165
5177
  type: field.type
5166
5178
  })) ?? []
5167
- })) ?? [], inlineObjects = definition?.inlineObjects?.map((inlineObject) => types.defineType({
5179
+ })) ?? [], inlineObjects = definition?.inlineObjects?.map((inlineObject) => selector_isOverlappingSelection.defineType({
5168
5180
  type: "object",
5169
5181
  // Very naive way to work around `SanitySchema.compile` adding default
5170
5182
  // fields to objects with certain names.
@@ -5177,7 +5189,7 @@ function compileSchemaDefinitionToLegacySchema(definition) {
5177
5189
  name: field.name,
5178
5190
  type: field.type
5179
5191
  })) ?? []
5180
- })) ?? [], portableTextSchema = types.defineField({
5192
+ })) ?? [], portableTextSchema = selector_isOverlappingSelection.defineField({
5181
5193
  type: "array",
5182
5194
  name: "portable-text",
5183
5195
  of: [...blockObjects.map((blockObject) => ({
@@ -5309,7 +5321,7 @@ function getEditorSnapshot({
5309
5321
  }
5310
5322
  const debug$3 = debugWithName("API:editable");
5311
5323
  function createEditableAPI(editor, editorActor) {
5312
- const types2 = editorActor.getSnapshot().context.schema;
5324
+ const types = editorActor.getSnapshot().context.schema;
5313
5325
  return {
5314
5326
  focus: () => {
5315
5327
  editorActor.send({
@@ -5392,18 +5404,18 @@ function createEditableAPI(editor, editorActor) {
5392
5404
  if (editor.selection) {
5393
5405
  const block = slate.Node.descendant(editor, editor.selection.focus.path.slice(0, 1));
5394
5406
  if (block)
5395
- return fromSlateValue([block], types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0];
5407
+ return fromSlateValue([block], types.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0];
5396
5408
  }
5397
5409
  },
5398
5410
  focusChild: () => {
5399
5411
  if (editor.selection) {
5400
5412
  const block = slate.Node.descendant(editor, editor.selection.focus.path.slice(0, 1));
5401
5413
  if (block && editor.isTextBlock(block))
5402
- return fromSlateValue([block], types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0].children[editor.selection.focus.path[1]];
5414
+ return fromSlateValue([block], types.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0].children[editor.selection.focus.path[1]];
5403
5415
  }
5404
5416
  },
5405
5417
  insertChild: (type, value) => {
5406
- if (type.name !== types2.span.name)
5418
+ if (type.name !== types.span.name)
5407
5419
  return editorActor.send({
5408
5420
  type: "behavior event",
5409
5421
  behaviorEvent: {
@@ -5423,15 +5435,15 @@ function createEditableAPI(editor, editorActor) {
5423
5435
  throw new Error("The editor has no selection");
5424
5436
  const [focusBlock] = Array.from(slate.Editor.nodes(editor, {
5425
5437
  at: editor.selection.focus.path.slice(0, 1),
5426
- match: (n) => n._type === types2.block.name
5438
+ match: (n) => n._type === types.block.name
5427
5439
  }))[0] || [void 0];
5428
5440
  if (!focusBlock)
5429
5441
  throw new Error("No focused text block");
5430
- if (type.name !== types2.span.name && !types2.inlineObjects.some((t) => t.name === type.name))
5442
+ if (type.name !== types.span.name && !types.inlineObjects.some((t) => t.name === type.name))
5431
5443
  throw new Error("This type cannot be inserted as a child to a text block");
5432
5444
  const child = toSlateValue([{
5433
5445
  _key: editorActor.getSnapshot().context.keyGenerator(),
5434
- _type: types2.block.name,
5446
+ _type: types.block.name,
5435
5447
  children: [{
5436
5448
  _key: editorActor.getSnapshot().context.keyGenerator(),
5437
5449
  _type: type.name,
@@ -5439,8 +5451,8 @@ function createEditableAPI(editor, editorActor) {
5439
5451
  }]
5440
5452
  }], {
5441
5453
  schemaTypes: editorActor.getSnapshot().context.schema
5442
- })[0].children[0], focusChildPath = editor.selection.focus.path.slice(0, 2), isSpanNode = child._type === types2.span.name, focusNode = slate.Node.get(editor, focusChildPath);
5443
- return isSpanNode && focusNode._type !== types2.span.name && (debug$3("Inserting span child next to inline object child, moving selection + 1"), editor.move({
5454
+ })[0].children[0], focusChildPath = editor.selection.focus.path.slice(0, 2), isSpanNode = child._type === types.span.name, focusNode = slate.Node.get(editor, focusChildPath);
5455
+ return isSpanNode && focusNode._type !== types.span.name && (debug$3("Inserting span child next to inline object child, moving selection + 1"), editor.move({
5444
5456
  distance: 1,
5445
5457
  unit: "character"
5446
5458
  })), slate.Transforms.insertNodes(editor, child, {
@@ -5488,7 +5500,7 @@ function createEditableAPI(editor, editorActor) {
5488
5500
  return !1;
5489
5501
  }
5490
5502
  },
5491
- isVoid: (element) => ![types2.block.name, types2.span.name].includes(element._type),
5503
+ isVoid: (element) => ![types.block.name, types.span.name].includes(element._type),
5492
5504
  findByPath: (path) => {
5493
5505
  const slatePath = toSlateRange({
5494
5506
  focus: {
@@ -5504,10 +5516,10 @@ function createEditableAPI(editor, editorActor) {
5504
5516
  const [block, blockPath] = slate.Editor.node(editor, slatePath.focus.path.slice(0, 1));
5505
5517
  if (block && blockPath && typeof block._key == "string") {
5506
5518
  if (path.length === 1 && slatePath.focus.path.length === 1)
5507
- return [fromSlateValue([block], types2.block.name)[0], [{
5519
+ return [fromSlateValue([block], types.block.name)[0], [{
5508
5520
  _key: block._key
5509
5521
  }]];
5510
- const ptBlock = fromSlateValue([block], types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0];
5522
+ const ptBlock = fromSlateValue([block], types.block.name, KEY_TO_VALUE_ELEMENT.get(editor))[0];
5511
5523
  if (editor.isTextBlock(ptBlock)) {
5512
5524
  const ptChild = ptBlock.children[slatePath.focus.path[1]];
5513
5525
  if (ptChild)
@@ -5566,7 +5578,7 @@ function createEditableAPI(editor, editorActor) {
5566
5578
  paths = addAnnotationActionImplementation({
5567
5579
  context: {
5568
5580
  keyGenerator: editorActor.getSnapshot().context.keyGenerator,
5569
- schema: types2
5581
+ schema: types
5570
5582
  },
5571
5583
  action: {
5572
5584
  annotation: {
@@ -5599,7 +5611,7 @@ function createEditableAPI(editor, editorActor) {
5599
5611
  })), options?.mode === "children" && (debug$3("Deleting children touched by selection"), slate.Transforms.removeNodes(editor, {
5600
5612
  at: range,
5601
5613
  voids: !0,
5602
- match: (node) => node._type === types2.span.name || // Text children
5614
+ match: (node) => node._type === types.span.name || // Text children
5603
5615
  !editor.isTextBlock(node) && slate.Element.isElement(node)
5604
5616
  })), editor.children.length === 0 && (editor.children = [editor.pteCreateTextBlock({
5605
5617
  decorators: []
@@ -5633,13 +5645,13 @@ function createEditableAPI(editor, editorActor) {
5633
5645
  }
5634
5646
  return ptRange;
5635
5647
  },
5636
- getValue: () => fromSlateValue(editor.children, types2.block.name, KEY_TO_VALUE_ELEMENT.get(editor)),
5648
+ getValue: () => fromSlateValue(editor.children, types.block.name, KEY_TO_VALUE_ELEMENT.get(editor)),
5637
5649
  isCollapsedSelection: () => !!editor.selection && slate.Range.isCollapsed(editor.selection),
5638
5650
  isExpandedSelection: () => !!editor.selection && slate.Range.isExpanded(editor.selection),
5639
5651
  insertBreak: () => {
5640
5652
  editor.insertBreak(), editor.onChange();
5641
5653
  },
5642
- getFragment: () => fromSlateValue(editor.getFragment(), types2.block.name),
5654
+ getFragment: () => fromSlateValue(editor.getFragment(), types.block.name),
5643
5655
  isSelectionsOverlapping: (selectionA, selectionB) => {
5644
5656
  const rangeA = toSlateRange(selectionA, editor), rangeB = toSlateRange(selectionB, editor);
5645
5657
  return slate.Range.isRange(rangeA) && slate.Range.isRange(rangeB) && slate.Range.includes(rangeA, rangeB);
@@ -5657,14 +5669,14 @@ function isAnnotationActive({
5657
5669
  at: editor.selection,
5658
5670
  match: (node) => slate.Text.isText(node)
5659
5671
  })];
5660
- if (spans.length === 0 || spans.some(([span]) => !types.isPortableTextSpan(span) || !span.marks || span.marks?.length === 0)) return !1;
5672
+ if (spans.length === 0 || spans.some(([span]) => !selector_isOverlappingSelection.isPortableTextSpan(span) || !span.marks || span.marks?.length === 0)) return !1;
5661
5673
  const selectionMarkDefs = spans.reduce((accMarkDefs, [, path]) => {
5662
5674
  const [block] = slate.Editor.node(editor, path, {
5663
5675
  depth: 1
5664
5676
  });
5665
5677
  return editor.isTextBlock(block) && block.markDefs ? [...accMarkDefs, ...block.markDefs] : accMarkDefs;
5666
5678
  }, []);
5667
- return spans.every(([span]) => types.isPortableTextSpan(span) ? span.marks?.map((markKey) => selectionMarkDefs.find((def) => def?._key === markKey)?._type)?.includes(annotation.name) : !1);
5679
+ return spans.every(([span]) => selector_isOverlappingSelection.isPortableTextSpan(span) ? span.marks?.map((markKey) => selectionMarkDefs.find((def) => def?._key === markKey)?._type)?.includes(annotation.name) : !1);
5668
5680
  } catch {
5669
5681
  return !1;
5670
5682
  }
@@ -5839,7 +5851,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
5839
5851
  event
5840
5852
  }) => {
5841
5853
  const manualSelection = event.at ? util_selectionPointToBlockOffset.blockOffsetsToSelection({
5842
- value: snapshot.context.value,
5854
+ context: snapshot.context,
5843
5855
  offsets: event.at
5844
5856
  }) : null;
5845
5857
  return manualSelection ? !selector_isSelectingEntireBlocks.isActiveDecorator(event.decorator)({
@@ -5863,7 +5875,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
5863
5875
  event
5864
5876
  }) => {
5865
5877
  const selection = util_selectionPointToBlockOffset.blockOffsetsToSelection({
5866
- value: snapshot.context.value,
5878
+ context: snapshot.context,
5867
5879
  offsets: event.at
5868
5880
  });
5869
5881
  if (!selection)
@@ -5929,6 +5941,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
5929
5941
  } : !1;
5930
5942
  },
5931
5943
  actions: [({
5944
+ snapshot,
5932
5945
  event
5933
5946
  }, {
5934
5947
  focusTextBlock
@@ -5937,7 +5950,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
5937
5950
  block: event.blocks[0],
5938
5951
  placement: "auto",
5939
5952
  select: "end"
5940
- })] : util_sliceBlocks.isEmptyTextBlock(focusTextBlock.node) ? event.blocks.map((block, index) => behavior_core.raise({
5953
+ })] : util_sliceBlocks.isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) => behavior_core.raise({
5941
5954
  type: "insert.block",
5942
5955
  block,
5943
5956
  placement: index === 0 ? "auto" : "after",
@@ -6125,7 +6138,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6125
6138
  const previousBlock = selector_isOverlappingSelection.getPreviousBlock(snapshot);
6126
6139
  if (!previousBlock)
6127
6140
  return !1;
6128
- const point = event.select === "end" ? util_sliceBlocks.getBlockEndPoint(previousBlock) : util_sliceBlocks.getBlockStartPoint(previousBlock);
6141
+ const point = event.select === "end" ? util_sliceBlocks.getBlockEndPoint({
6142
+ context: snapshot.context,
6143
+ block: previousBlock
6144
+ }) : util_sliceBlocks.getBlockStartPoint({
6145
+ context: snapshot.context,
6146
+ block: previousBlock
6147
+ });
6129
6148
  return {
6130
6149
  selection: {
6131
6150
  anchor: point,
@@ -6148,7 +6167,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6148
6167
  const nextBlock = selector_isOverlappingSelection.getNextBlock(snapshot);
6149
6168
  if (!nextBlock)
6150
6169
  return !1;
6151
- const point = event.select === "end" ? util_sliceBlocks.getBlockEndPoint(nextBlock) : util_sliceBlocks.getBlockStartPoint(nextBlock);
6170
+ const point = event.select === "end" ? util_sliceBlocks.getBlockEndPoint({
6171
+ context: snapshot.context,
6172
+ block: nextBlock
6173
+ }) : util_sliceBlocks.getBlockStartPoint({
6174
+ context: snapshot.context,
6175
+ block: nextBlock
6176
+ });
6152
6177
  return {
6153
6178
  selection: {
6154
6179
  anchor: point,
@@ -6179,20 +6204,26 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6179
6204
  }
6180
6205
  });
6181
6206
  if (focusTextBlock) {
6182
- const blockEndPoint = util_sliceBlocks.getBlockEndPoint(focusTextBlock), newTextBlockSelection = {
6207
+ const blockEndPoint = util_sliceBlocks.getBlockEndPoint({
6208
+ context: snapshot.context,
6209
+ block: focusTextBlock
6210
+ }), newTextBlockSelection = {
6183
6211
  anchor: selectionEndPoint,
6184
6212
  focus: blockEndPoint
6185
- }, newTextBlock = parseBlocks.parseBlock({
6213
+ }, newTextBlock = util_sliceBlocks.parseBlock({
6186
6214
  block: util_sliceBlocks.sliceBlocks({
6187
- blocks: [focusTextBlock.node],
6188
- selection: newTextBlockSelection
6215
+ context: {
6216
+ ...snapshot.context,
6217
+ selection: newTextBlockSelection
6218
+ },
6219
+ blocks: [focusTextBlock.node]
6189
6220
  }).at(0),
6190
6221
  context: snapshot.context,
6191
6222
  options: {
6192
6223
  refreshKeys: !0
6193
6224
  }
6194
6225
  });
6195
- return !newTextBlock || !parseBlocks.isTextBlock(snapshot.context.schema, newTextBlock) ? !1 : {
6226
+ return !newTextBlock || !util_sliceBlocks.isTextBlock(snapshot.context, newTextBlock) ? !1 : {
6196
6227
  newTextBlock,
6197
6228
  newTextBlockSelection,
6198
6229
  selection: {
@@ -6210,7 +6241,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6210
6241
  }
6211
6242
  }
6212
6243
  })) {
6213
- const newTextBlock = parseBlocks.parseBlock({
6244
+ const newTextBlock = util_sliceBlocks.parseBlock({
6214
6245
  block: {
6215
6246
  _type: snapshot.context.schema.block.name,
6216
6247
  children: []
@@ -6545,7 +6576,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6545
6576
  return {
6546
6577
  activeAnnotations: selector_isSelectingEntireBlocks.getActiveAnnotations(snapshot),
6547
6578
  activeDecorators,
6548
- textRuns: event.data.flatMap((block) => parseBlocks.isTextBlock(snapshot.context.schema, block) ? [util_sliceBlocks.getTextBlockText(block)] : [])
6579
+ textRuns: event.data.flatMap((block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? [util_sliceBlocks.getTextBlockText(block)] : [])
6549
6580
  };
6550
6581
  }
6551
6582
  return !1;