@portabletext/editor 1.48.6 → 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 (131) 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 +137 -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 +91 -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 +2328 -23
  51. package/lib/plugins/index.d.ts +2328 -23
  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/behavior-actions/behavior.action.delete.ts +21 -1
  70. package/src/behaviors/behavior.abstract.decorator.ts +1 -1
  71. package/src/behaviors/behavior.abstract.delete.ts +1 -1
  72. package/src/behaviors/behavior.abstract.insert.ts +2 -2
  73. package/src/behaviors/behavior.abstract.select.ts +16 -4
  74. package/src/behaviors/behavior.abstract.split.ts +9 -6
  75. package/src/behaviors/behavior.core.block-objects.ts +5 -5
  76. package/src/behaviors/behavior.core.insert-break.ts +16 -4
  77. package/src/behaviors/behavior.core.lists.ts +4 -6
  78. package/src/behaviors/behavior.decorator-pair.ts +13 -4
  79. package/src/behaviors/behavior.default.ts +1 -1
  80. package/src/behaviors/behavior.markdown.ts +5 -5
  81. package/src/converters/converter.portable-text.ts +1 -1
  82. package/src/converters/converter.text-html.ts +1 -1
  83. package/src/converters/converter.text-plain.ts +4 -4
  84. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
  85. package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
  86. package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
  87. package/src/internal-utils/drag-selection.ts +16 -4
  88. package/src/internal-utils/event-position.ts +20 -8
  89. package/src/internal-utils/parse-blocks.ts +17 -5
  90. package/src/internal-utils/validateValue.ts +6 -6
  91. package/src/plugins/plugin.decorator-shortcut.ts +3 -2
  92. package/src/plugins/plugin.markdown.tsx +2 -0
  93. package/src/plugins/plugin.one-line.tsx +2 -0
  94. package/src/selectors/selector.get-active-annotations.ts +5 -2
  95. package/src/selectors/selector.get-active-list-item.ts +4 -3
  96. package/src/selectors/selector.get-active-style.ts +4 -3
  97. package/src/selectors/selector.get-anchor-text-block.ts +3 -6
  98. package/src/selectors/selector.get-block-offsets.ts +2 -2
  99. package/src/selectors/selector.get-caret-word-selection.ts +11 -5
  100. package/src/selectors/selector.get-selected-slice.ts +1 -1
  101. package/src/selectors/selector.get-selected-spans.ts +11 -15
  102. package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
  103. package/src/selectors/selector.get-selection-text.ts +3 -3
  104. package/src/selectors/selector.get-text-before.ts +5 -2
  105. package/src/selectors/selector.get-trimmed-selection.ts +20 -14
  106. package/src/selectors/selector.is-active-annotation.ts +4 -2
  107. package/src/selectors/selector.is-active-decorator.test.ts +3 -3
  108. package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
  109. package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
  110. package/src/selectors/selector.is-point-after-selection.ts +7 -6
  111. package/src/selectors/selector.is-point-before-selection.ts +7 -6
  112. package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
  113. package/src/selectors/selectors.ts +25 -28
  114. package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
  115. package/src/utils/util.block-offset-to-selection-point.ts +5 -5
  116. package/src/utils/util.block-offset.test.ts +219 -156
  117. package/src/utils/util.block-offset.ts +14 -17
  118. package/src/utils/util.block-offsets-to-selection.ts +5 -5
  119. package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
  120. package/src/utils/util.get-block-end-point.ts +15 -15
  121. package/src/utils/util.get-block-start-point.ts +13 -12
  122. package/src/utils/util.is-empty-text-block.ts +9 -8
  123. package/src/utils/util.selection-point-to-block-offset.ts +4 -4
  124. package/src/utils/util.slice-blocks.test.ts +178 -121
  125. package/src/utils/util.slice-blocks.ts +25 -24
  126. package/src/utils/util.split-text-block.ts +18 -12
  127. package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
  128. package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
  129. package/lib/_chunks-es/parse-blocks.js +0 -206
  130. package/lib/_chunks-es/parse-blocks.js.map +0 -1
  131. 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
@@ -3703,11 +3715,27 @@ const decoratorAddActionImplementation = ({
3703
3715
  };
3704
3716
  }
3705
3717
  }, deleteActionImplementation = ({
3718
+ context,
3706
3719
  action
3707
3720
  }) => {
3708
3721
  const range = toSlateRange(action.at, action.editor);
3709
3722
  if (!range)
3710
3723
  throw new Error(`Failed to get Slate Range for selection ${JSON.stringify(action.at)}`);
3724
+ if (slate.Range.isCollapsed(range)) {
3725
+ const [focusBlock] = getFocusBlock({
3726
+ editor: {
3727
+ ...action.editor,
3728
+ selection: range
3729
+ }
3730
+ }), [focusChild] = getFocusChild({
3731
+ editor: {
3732
+ ...action.editor,
3733
+ selection: range
3734
+ }
3735
+ });
3736
+ if (focusBlock && focusBlock._type === context.schema.block.name && focusChild && focusChild._type === context.schema.span.name)
3737
+ return;
3738
+ }
3711
3739
  action.editor.delete({
3712
3740
  at: range
3713
3741
  });
@@ -3747,7 +3775,7 @@ const decoratorAddActionImplementation = ({
3747
3775
  context,
3748
3776
  action
3749
3777
  }) => {
3750
- const parsedInlineObject = parseBlocks.parseInlineObject({
3778
+ const parsedInlineObject = util_sliceBlocks.parseInlineObject({
3751
3779
  context,
3752
3780
  inlineObject: {
3753
3781
  _type: action.inlineObject.name,
@@ -3816,7 +3844,7 @@ const decoratorAddActionImplementation = ({
3816
3844
  context,
3817
3845
  action
3818
3846
  }) => {
3819
- const parsedBlock = parseBlocks.parseBlock({
3847
+ const parsedBlock = util_sliceBlocks.parseBlock({
3820
3848
  block: action.block,
3821
3849
  context,
3822
3850
  options: {
@@ -4915,7 +4943,7 @@ function createWithSchemaTypes({
4915
4943
  editorActor
4916
4944
  }) {
4917
4945
  return function(editor) {
4918
- 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;
4919
4947
  const {
4920
4948
  normalizeNode
4921
4949
  } = editor;
@@ -5135,7 +5163,7 @@ function legacySchemaToEditorSchema(schema2) {
5135
5163
  };
5136
5164
  }
5137
5165
  function compileSchemaDefinitionToLegacySchema(definition) {
5138
- const blockObjects = definition?.blockObjects?.map((blockObject) => types.defineType({
5166
+ const blockObjects = definition?.blockObjects?.map((blockObject) => selector_isOverlappingSelection.defineType({
5139
5167
  type: "object",
5140
5168
  // Very naive way to work around `SanitySchema.compile` adding default
5141
5169
  // fields to objects with certain names.
@@ -5148,7 +5176,7 @@ function compileSchemaDefinitionToLegacySchema(definition) {
5148
5176
  name: field.name,
5149
5177
  type: field.type
5150
5178
  })) ?? []
5151
- })) ?? [], inlineObjects = definition?.inlineObjects?.map((inlineObject) => types.defineType({
5179
+ })) ?? [], inlineObjects = definition?.inlineObjects?.map((inlineObject) => selector_isOverlappingSelection.defineType({
5152
5180
  type: "object",
5153
5181
  // Very naive way to work around `SanitySchema.compile` adding default
5154
5182
  // fields to objects with certain names.
@@ -5161,7 +5189,7 @@ function compileSchemaDefinitionToLegacySchema(definition) {
5161
5189
  name: field.name,
5162
5190
  type: field.type
5163
5191
  })) ?? []
5164
- })) ?? [], portableTextSchema = types.defineField({
5192
+ })) ?? [], portableTextSchema = selector_isOverlappingSelection.defineField({
5165
5193
  type: "array",
5166
5194
  name: "portable-text",
5167
5195
  of: [...blockObjects.map((blockObject) => ({
@@ -5293,7 +5321,7 @@ function getEditorSnapshot({
5293
5321
  }
5294
5322
  const debug$3 = debugWithName("API:editable");
5295
5323
  function createEditableAPI(editor, editorActor) {
5296
- const types2 = editorActor.getSnapshot().context.schema;
5324
+ const types = editorActor.getSnapshot().context.schema;
5297
5325
  return {
5298
5326
  focus: () => {
5299
5327
  editorActor.send({
@@ -5376,18 +5404,18 @@ function createEditableAPI(editor, editorActor) {
5376
5404
  if (editor.selection) {
5377
5405
  const block = slate.Node.descendant(editor, editor.selection.focus.path.slice(0, 1));
5378
5406
  if (block)
5379
- 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];
5380
5408
  }
5381
5409
  },
5382
5410
  focusChild: () => {
5383
5411
  if (editor.selection) {
5384
5412
  const block = slate.Node.descendant(editor, editor.selection.focus.path.slice(0, 1));
5385
5413
  if (block && editor.isTextBlock(block))
5386
- 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]];
5387
5415
  }
5388
5416
  },
5389
5417
  insertChild: (type, value) => {
5390
- if (type.name !== types2.span.name)
5418
+ if (type.name !== types.span.name)
5391
5419
  return editorActor.send({
5392
5420
  type: "behavior event",
5393
5421
  behaviorEvent: {
@@ -5407,15 +5435,15 @@ function createEditableAPI(editor, editorActor) {
5407
5435
  throw new Error("The editor has no selection");
5408
5436
  const [focusBlock] = Array.from(slate.Editor.nodes(editor, {
5409
5437
  at: editor.selection.focus.path.slice(0, 1),
5410
- match: (n) => n._type === types2.block.name
5438
+ match: (n) => n._type === types.block.name
5411
5439
  }))[0] || [void 0];
5412
5440
  if (!focusBlock)
5413
5441
  throw new Error("No focused text block");
5414
- 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))
5415
5443
  throw new Error("This type cannot be inserted as a child to a text block");
5416
5444
  const child = toSlateValue([{
5417
5445
  _key: editorActor.getSnapshot().context.keyGenerator(),
5418
- _type: types2.block.name,
5446
+ _type: types.block.name,
5419
5447
  children: [{
5420
5448
  _key: editorActor.getSnapshot().context.keyGenerator(),
5421
5449
  _type: type.name,
@@ -5423,8 +5451,8 @@ function createEditableAPI(editor, editorActor) {
5423
5451
  }]
5424
5452
  }], {
5425
5453
  schemaTypes: editorActor.getSnapshot().context.schema
5426
- })[0].children[0], focusChildPath = editor.selection.focus.path.slice(0, 2), isSpanNode = child._type === types2.span.name, focusNode = slate.Node.get(editor, focusChildPath);
5427
- 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({
5428
5456
  distance: 1,
5429
5457
  unit: "character"
5430
5458
  })), slate.Transforms.insertNodes(editor, child, {
@@ -5472,7 +5500,7 @@ function createEditableAPI(editor, editorActor) {
5472
5500
  return !1;
5473
5501
  }
5474
5502
  },
5475
- isVoid: (element) => ![types2.block.name, types2.span.name].includes(element._type),
5503
+ isVoid: (element) => ![types.block.name, types.span.name].includes(element._type),
5476
5504
  findByPath: (path) => {
5477
5505
  const slatePath = toSlateRange({
5478
5506
  focus: {
@@ -5488,10 +5516,10 @@ function createEditableAPI(editor, editorActor) {
5488
5516
  const [block, blockPath] = slate.Editor.node(editor, slatePath.focus.path.slice(0, 1));
5489
5517
  if (block && blockPath && typeof block._key == "string") {
5490
5518
  if (path.length === 1 && slatePath.focus.path.length === 1)
5491
- return [fromSlateValue([block], types2.block.name)[0], [{
5519
+ return [fromSlateValue([block], types.block.name)[0], [{
5492
5520
  _key: block._key
5493
5521
  }]];
5494
- 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];
5495
5523
  if (editor.isTextBlock(ptBlock)) {
5496
5524
  const ptChild = ptBlock.children[slatePath.focus.path[1]];
5497
5525
  if (ptChild)
@@ -5550,7 +5578,7 @@ function createEditableAPI(editor, editorActor) {
5550
5578
  paths = addAnnotationActionImplementation({
5551
5579
  context: {
5552
5580
  keyGenerator: editorActor.getSnapshot().context.keyGenerator,
5553
- schema: types2
5581
+ schema: types
5554
5582
  },
5555
5583
  action: {
5556
5584
  annotation: {
@@ -5583,7 +5611,7 @@ function createEditableAPI(editor, editorActor) {
5583
5611
  })), options?.mode === "children" && (debug$3("Deleting children touched by selection"), slate.Transforms.removeNodes(editor, {
5584
5612
  at: range,
5585
5613
  voids: !0,
5586
- match: (node) => node._type === types2.span.name || // Text children
5614
+ match: (node) => node._type === types.span.name || // Text children
5587
5615
  !editor.isTextBlock(node) && slate.Element.isElement(node)
5588
5616
  })), editor.children.length === 0 && (editor.children = [editor.pteCreateTextBlock({
5589
5617
  decorators: []
@@ -5617,13 +5645,13 @@ function createEditableAPI(editor, editorActor) {
5617
5645
  }
5618
5646
  return ptRange;
5619
5647
  },
5620
- 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)),
5621
5649
  isCollapsedSelection: () => !!editor.selection && slate.Range.isCollapsed(editor.selection),
5622
5650
  isExpandedSelection: () => !!editor.selection && slate.Range.isExpanded(editor.selection),
5623
5651
  insertBreak: () => {
5624
5652
  editor.insertBreak(), editor.onChange();
5625
5653
  },
5626
- getFragment: () => fromSlateValue(editor.getFragment(), types2.block.name),
5654
+ getFragment: () => fromSlateValue(editor.getFragment(), types.block.name),
5627
5655
  isSelectionsOverlapping: (selectionA, selectionB) => {
5628
5656
  const rangeA = toSlateRange(selectionA, editor), rangeB = toSlateRange(selectionB, editor);
5629
5657
  return slate.Range.isRange(rangeA) && slate.Range.isRange(rangeB) && slate.Range.includes(rangeA, rangeB);
@@ -5641,14 +5669,14 @@ function isAnnotationActive({
5641
5669
  at: editor.selection,
5642
5670
  match: (node) => slate.Text.isText(node)
5643
5671
  })];
5644
- 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;
5645
5673
  const selectionMarkDefs = spans.reduce((accMarkDefs, [, path]) => {
5646
5674
  const [block] = slate.Editor.node(editor, path, {
5647
5675
  depth: 1
5648
5676
  });
5649
5677
  return editor.isTextBlock(block) && block.markDefs ? [...accMarkDefs, ...block.markDefs] : accMarkDefs;
5650
5678
  }, []);
5651
- 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);
5652
5680
  } catch {
5653
5681
  return !1;
5654
5682
  }
@@ -5823,7 +5851,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
5823
5851
  event
5824
5852
  }) => {
5825
5853
  const manualSelection = event.at ? util_selectionPointToBlockOffset.blockOffsetsToSelection({
5826
- value: snapshot.context.value,
5854
+ context: snapshot.context,
5827
5855
  offsets: event.at
5828
5856
  }) : null;
5829
5857
  return manualSelection ? !selector_isSelectingEntireBlocks.isActiveDecorator(event.decorator)({
@@ -5847,7 +5875,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
5847
5875
  event
5848
5876
  }) => {
5849
5877
  const selection = util_selectionPointToBlockOffset.blockOffsetsToSelection({
5850
- value: snapshot.context.value,
5878
+ context: snapshot.context,
5851
5879
  offsets: event.at
5852
5880
  });
5853
5881
  if (!selection)
@@ -5913,6 +5941,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
5913
5941
  } : !1;
5914
5942
  },
5915
5943
  actions: [({
5944
+ snapshot,
5916
5945
  event
5917
5946
  }, {
5918
5947
  focusTextBlock
@@ -5921,7 +5950,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
5921
5950
  block: event.blocks[0],
5922
5951
  placement: "auto",
5923
5952
  select: "end"
5924
- })] : 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({
5925
5954
  type: "insert.block",
5926
5955
  block,
5927
5956
  placement: index === 0 ? "auto" : "after",
@@ -6109,7 +6138,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6109
6138
  const previousBlock = selector_isOverlappingSelection.getPreviousBlock(snapshot);
6110
6139
  if (!previousBlock)
6111
6140
  return !1;
6112
- 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
+ });
6113
6148
  return {
6114
6149
  selection: {
6115
6150
  anchor: point,
@@ -6132,7 +6167,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6132
6167
  const nextBlock = selector_isOverlappingSelection.getNextBlock(snapshot);
6133
6168
  if (!nextBlock)
6134
6169
  return !1;
6135
- 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
+ });
6136
6177
  return {
6137
6178
  selection: {
6138
6179
  anchor: point,
@@ -6163,20 +6204,26 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6163
6204
  }
6164
6205
  });
6165
6206
  if (focusTextBlock) {
6166
- const blockEndPoint = util_sliceBlocks.getBlockEndPoint(focusTextBlock), newTextBlockSelection = {
6207
+ const blockEndPoint = util_sliceBlocks.getBlockEndPoint({
6208
+ context: snapshot.context,
6209
+ block: focusTextBlock
6210
+ }), newTextBlockSelection = {
6167
6211
  anchor: selectionEndPoint,
6168
6212
  focus: blockEndPoint
6169
- }, newTextBlock = parseBlocks.parseBlock({
6213
+ }, newTextBlock = util_sliceBlocks.parseBlock({
6170
6214
  block: util_sliceBlocks.sliceBlocks({
6171
- blocks: [focusTextBlock.node],
6172
- selection: newTextBlockSelection
6215
+ context: {
6216
+ ...snapshot.context,
6217
+ selection: newTextBlockSelection
6218
+ },
6219
+ blocks: [focusTextBlock.node]
6173
6220
  }).at(0),
6174
6221
  context: snapshot.context,
6175
6222
  options: {
6176
6223
  refreshKeys: !0
6177
6224
  }
6178
6225
  });
6179
- return !newTextBlock || !parseBlocks.isTextBlock(snapshot.context.schema, newTextBlock) ? !1 : {
6226
+ return !newTextBlock || !util_sliceBlocks.isTextBlock(snapshot.context, newTextBlock) ? !1 : {
6180
6227
  newTextBlock,
6181
6228
  newTextBlockSelection,
6182
6229
  selection: {
@@ -6194,7 +6241,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6194
6241
  }
6195
6242
  }
6196
6243
  })) {
6197
- const newTextBlock = parseBlocks.parseBlock({
6244
+ const newTextBlock = util_sliceBlocks.parseBlock({
6198
6245
  block: {
6199
6246
  _type: snapshot.context.schema.block.name,
6200
6247
  children: []
@@ -6529,7 +6576,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
6529
6576
  return {
6530
6577
  activeAnnotations: selector_isSelectingEntireBlocks.getActiveAnnotations(snapshot),
6531
6578
  activeDecorators,
6532
- 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)] : [])
6533
6580
  };
6534
6581
  }
6535
6582
  return !1;