@portabletext/editor 1.55.4 → 1.55.5

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.
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var selectionPoint = require("./selection-point.cjs"), util_childSelectionPointToBlockOffset = require("./util.child-selection-point-to-block-offset.cjs");
3
+ function isSelectionCollapsed(selection) {
4
+ return selection ? JSON.stringify(selection.anchor.path) === JSON.stringify(selection.focus.path) && selection.anchor.offset === selection.focus.offset : !1;
5
+ }
6
+ function selectionPointToBlockOffset({
7
+ context,
8
+ selectionPoint: selectionPoint$1
9
+ }) {
10
+ const blockKey = selectionPoint.getBlockKeyFromSelectionPoint(selectionPoint$1);
11
+ return selectionPoint$1.path.length === 1 && blockKey !== void 0 ? {
12
+ path: [{
13
+ _key: blockKey
14
+ }],
15
+ offset: selectionPoint$1.offset
16
+ } : util_childSelectionPointToBlockOffset.childSelectionPointToBlockOffset({
17
+ context,
18
+ selectionPoint: selectionPoint$1
19
+ });
20
+ }
21
+ function sliceTextBlock({
22
+ context,
23
+ block
24
+ }) {
25
+ const startPoint = selectionPoint.getSelectionStartPoint(context.selection), endPoint = selectionPoint.getSelectionEndPoint(context.selection);
26
+ if (!startPoint || !endPoint)
27
+ return block;
28
+ const startBlockKey = selectionPoint.getBlockKeyFromSelectionPoint(startPoint), endBlockKey = selectionPoint.getBlockKeyFromSelectionPoint(endPoint);
29
+ if (startBlockKey !== endBlockKey || startBlockKey !== block._key)
30
+ return block;
31
+ const startChildKey = selectionPoint.getChildKeyFromSelectionPoint(startPoint), endChildKey = selectionPoint.getChildKeyFromSelectionPoint(endPoint);
32
+ if (!startChildKey || !endChildKey)
33
+ return block;
34
+ let startChildFound = !1;
35
+ const children = [];
36
+ for (const child of block.children) {
37
+ if (child._key === startChildKey) {
38
+ if (startChildFound = !0, selectionPoint.isSpan$1(context, child)) {
39
+ const text = child._key === endChildKey ? child.text.slice(startPoint.offset, endPoint.offset) : child.text.slice(startPoint.offset);
40
+ children.push({
41
+ ...child,
42
+ text
43
+ });
44
+ } else
45
+ children.push(child);
46
+ if (startChildKey === endChildKey)
47
+ break;
48
+ continue;
49
+ }
50
+ if (child._key === endChildKey) {
51
+ selectionPoint.isSpan$1(context, child) ? children.push({
52
+ ...child,
53
+ text: child.text.slice(0, endPoint.offset)
54
+ }) : children.push(child);
55
+ break;
56
+ }
57
+ startChildFound && children.push(child);
58
+ }
59
+ return {
60
+ ...block,
61
+ children
62
+ };
63
+ }
64
+ exports.isSelectionCollapsed = isSelectionCollapsed;
65
+ exports.selectionPointToBlockOffset = selectionPointToBlockOffset;
66
+ exports.sliceTextBlock = sliceTextBlock;
67
+ //# sourceMappingURL=util.slice-text-block.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.slice-text-block.cjs","sources":["../../src/utils/util.is-selection-collapsed.ts","../../src/utils/util.selection-point-to-block-offset.ts","../../src/utils/util.slice-text-block.ts"],"sourcesContent":["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 JSON.stringify(selection.anchor.path) ===\n JSON.stringify(selection.focus.path) &&\n selection.anchor.offset === selection.focus.offset\n )\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport {getBlockKeyFromSelectionPoint} from '../selection/selection-point'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {childSelectionPointToBlockOffset} from './util.child-selection-point-to-block-offset'\n\n/**\n * @public\n */\nexport function selectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n const blockKey = getBlockKeyFromSelectionPoint(selectionPoint)\n\n if (selectionPoint.path.length === 1 && blockKey !== undefined) {\n return {\n path: [{_key: blockKey}],\n offset: selectionPoint.offset,\n }\n }\n\n return childSelectionPointToBlockOffset({\n context,\n selectionPoint,\n })\n}\n","import type {PortableTextChild, PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '..'\nimport {isSpan} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport {getSelectionEndPoint} from './util.get-selection-end-point'\nimport {getSelectionStartPoint} from './util.get-selection-start-point'\n\nexport function sliceTextBlock({\n context,\n block,\n}: {\n context: Pick<EditorContext, 'schema' | 'selection'>\n block: PortableTextTextBlock\n}): PortableTextTextBlock {\n const startPoint = getSelectionStartPoint(context.selection)\n const endPoint = getSelectionEndPoint(context.selection)\n\n if (!startPoint || !endPoint) {\n return block\n }\n\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n\n if (startBlockKey !== endBlockKey || startBlockKey !== block._key) {\n return block\n }\n\n const startChildKey = getChildKeyFromSelectionPoint(startPoint)\n const endChildKey = getChildKeyFromSelectionPoint(endPoint)\n\n if (!startChildKey || !endChildKey) {\n return block\n }\n\n let startChildFound = false\n const children: Array<PortableTextChild> = []\n\n for (const child of block.children) {\n if (child._key === startChildKey) {\n startChildFound = true\n\n if (isSpan(context, child)) {\n const text =\n child._key === endChildKey\n ? child.text.slice(startPoint.offset, endPoint.offset)\n : child.text.slice(startPoint.offset)\n\n children.push({\n ...child,\n text,\n })\n } else {\n children.push(child)\n }\n\n if (startChildKey === endChildKey) {\n break\n }\n\n continue\n }\n\n if (child._key === endChildKey) {\n if (isSpan(context, child)) {\n children.push({\n ...child,\n text: child.text.slice(0, endPoint.offset),\n })\n } else {\n children.push(child)\n }\n\n break\n }\n\n if (startChildFound) {\n children.push(child)\n }\n }\n\n return {\n ...block,\n children,\n }\n}\n"],"names":["isSelectionCollapsed","selection","JSON","stringify","anchor","path","focus","offset","selectionPointToBlockOffset","context","selectionPoint","blockKey","getBlockKeyFromSelectionPoint","length","undefined","_key","childSelectionPointToBlockOffset","sliceTextBlock","block","startPoint","getSelectionStartPoint","endPoint","getSelectionEndPoint","startBlockKey","endBlockKey","startChildKey","getChildKeyFromSelectionPoint","endChildKey","startChildFound","children","child","isSpan","text","slice","push"],"mappings":";;AAKO,SAASA,qBAAqBC,WAA4B;AAC/D,SAAKA,YAKHC,KAAKC,UAAUF,UAAUG,OAAOC,IAAI,MAClCH,KAAKC,UAAUF,UAAUK,MAAMD,IAAI,KACrCJ,UAAUG,OAAOG,WAAWN,UAAUK,MAAMC,SANrC;AAQX;ACNO,SAASC,4BAA4B;AAAA,EAC1CC;AAAAA,EAAAA,gBACAC;AAIF,GAA4B;AAC1B,QAAMC,WAAWC,eAAAA,8BAA8BF,gBAAc;AAE7D,SAAIA,iBAAeL,KAAKQ,WAAW,KAAKF,aAAaG,SAC5C;AAAA,IACLT,MAAM,CAAC;AAAA,MAACU,MAAMJ;AAAAA,IAAAA,CAAS;AAAA,IACvBJ,QAAQG,iBAAeH;AAAAA,EAAAA,IAIpBS,uEAAiC;AAAA,IACtCP;AAAAA,IAAAA,gBACAC;AAAAA,EAAAA,CACD;AACH;ACnBO,SAASO,eAAe;AAAA,EAC7BR;AAAAA,EACAS;AAIF,GAA0B;AACxB,QAAMC,aAAaC,eAAAA,uBAAuBX,QAAQR,SAAS,GACrDoB,WAAWC,eAAAA,qBAAqBb,QAAQR,SAAS;AAEvD,MAAI,CAACkB,cAAc,CAACE;AAClB,WAAOH;AAGT,QAAMK,gBAAgBX,eAAAA,8BAA8BO,UAAU,GACxDK,cAAcZ,eAAAA,8BAA8BS,QAAQ;AAE1D,MAAIE,kBAAkBC,eAAeD,kBAAkBL,MAAMH;AAC3D,WAAOG;AAGT,QAAMO,gBAAgBC,eAAAA,8BAA8BP,UAAU,GACxDQ,cAAcD,eAAAA,8BAA8BL,QAAQ;AAE1D,MAAI,CAACI,iBAAiB,CAACE;AACrB,WAAOT;AAGT,MAAIU,kBAAkB;AACtB,QAAMC,WAAqC,CAAA;AAE3C,aAAWC,SAASZ,MAAMW,UAAU;AAClC,QAAIC,MAAMf,SAASU,eAAe;AAGhC,UAFAG,kBAAkB,IAEdG,eAAAA,SAAOtB,SAASqB,KAAK,GAAG;AAC1B,cAAME,OACJF,MAAMf,SAASY,cACXG,MAAME,KAAKC,MAAMd,WAAWZ,QAAQc,SAASd,MAAM,IACnDuB,MAAME,KAAKC,MAAMd,WAAWZ,MAAM;AAExCsB,iBAASK,KAAK;AAAA,UACZ,GAAGJ;AAAAA,UACHE;AAAAA,QAAAA,CACD;AAAA,MAAA;AAEDH,iBAASK,KAAKJ,KAAK;AAGrB,UAAIL,kBAAkBE;AACpB;AAGF;AAAA,IAAA;AAGF,QAAIG,MAAMf,SAASY,aAAa;AAC1BI,qBAAAA,SAAOtB,SAASqB,KAAK,IACvBD,SAASK,KAAK;AAAA,QACZ,GAAGJ;AAAAA,QACHE,MAAMF,MAAME,KAAKC,MAAM,GAAGZ,SAASd,MAAM;AAAA,MAAA,CAC1C,IAEDsB,SAASK,KAAKJ,KAAK;AAGrB;AAAA,IAAA;AAGEF,uBACFC,SAASK,KAAKJ,KAAK;AAAA,EAAA;AAIvB,SAAO;AAAA,IACL,GAAGZ;AAAAA,IACHW;AAAAA,EAAAA;AAEJ;;;;"}
@@ -0,0 +1,69 @@
1
+ import { getBlockKeyFromSelectionPoint, getSelectionStartPoint, getSelectionEndPoint, getChildKeyFromSelectionPoint, isSpan$1 as isSpan } from "./selection-point.js";
2
+ import { childSelectionPointToBlockOffset } from "./util.child-selection-point-to-block-offset.js";
3
+ function isSelectionCollapsed(selection) {
4
+ return selection ? JSON.stringify(selection.anchor.path) === JSON.stringify(selection.focus.path) && selection.anchor.offset === selection.focus.offset : !1;
5
+ }
6
+ function selectionPointToBlockOffset({
7
+ context,
8
+ selectionPoint
9
+ }) {
10
+ const blockKey = getBlockKeyFromSelectionPoint(selectionPoint);
11
+ return selectionPoint.path.length === 1 && blockKey !== void 0 ? {
12
+ path: [{
13
+ _key: blockKey
14
+ }],
15
+ offset: selectionPoint.offset
16
+ } : childSelectionPointToBlockOffset({
17
+ context,
18
+ selectionPoint
19
+ });
20
+ }
21
+ function sliceTextBlock({
22
+ context,
23
+ block
24
+ }) {
25
+ const startPoint = getSelectionStartPoint(context.selection), endPoint = getSelectionEndPoint(context.selection);
26
+ if (!startPoint || !endPoint)
27
+ return block;
28
+ const startBlockKey = getBlockKeyFromSelectionPoint(startPoint), endBlockKey = getBlockKeyFromSelectionPoint(endPoint);
29
+ if (startBlockKey !== endBlockKey || startBlockKey !== block._key)
30
+ return block;
31
+ const startChildKey = getChildKeyFromSelectionPoint(startPoint), endChildKey = getChildKeyFromSelectionPoint(endPoint);
32
+ if (!startChildKey || !endChildKey)
33
+ return block;
34
+ let startChildFound = !1;
35
+ const children = [];
36
+ for (const child of block.children) {
37
+ if (child._key === startChildKey) {
38
+ if (startChildFound = !0, isSpan(context, child)) {
39
+ const text = child._key === endChildKey ? child.text.slice(startPoint.offset, endPoint.offset) : child.text.slice(startPoint.offset);
40
+ children.push({
41
+ ...child,
42
+ text
43
+ });
44
+ } else
45
+ children.push(child);
46
+ if (startChildKey === endChildKey)
47
+ break;
48
+ continue;
49
+ }
50
+ if (child._key === endChildKey) {
51
+ isSpan(context, child) ? children.push({
52
+ ...child,
53
+ text: child.text.slice(0, endPoint.offset)
54
+ }) : children.push(child);
55
+ break;
56
+ }
57
+ startChildFound && children.push(child);
58
+ }
59
+ return {
60
+ ...block,
61
+ children
62
+ };
63
+ }
64
+ export {
65
+ isSelectionCollapsed,
66
+ selectionPointToBlockOffset,
67
+ sliceTextBlock
68
+ };
69
+ //# sourceMappingURL=util.slice-text-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.slice-text-block.js","sources":["../../src/utils/util.is-selection-collapsed.ts","../../src/utils/util.selection-point-to-block-offset.ts","../../src/utils/util.slice-text-block.ts"],"sourcesContent":["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 JSON.stringify(selection.anchor.path) ===\n JSON.stringify(selection.focus.path) &&\n selection.anchor.offset === selection.focus.offset\n )\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport {getBlockKeyFromSelectionPoint} from '../selection/selection-point'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {childSelectionPointToBlockOffset} from './util.child-selection-point-to-block-offset'\n\n/**\n * @public\n */\nexport function selectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n const blockKey = getBlockKeyFromSelectionPoint(selectionPoint)\n\n if (selectionPoint.path.length === 1 && blockKey !== undefined) {\n return {\n path: [{_key: blockKey}],\n offset: selectionPoint.offset,\n }\n }\n\n return childSelectionPointToBlockOffset({\n context,\n selectionPoint,\n })\n}\n","import type {PortableTextChild, PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '..'\nimport {isSpan} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport {getSelectionEndPoint} from './util.get-selection-end-point'\nimport {getSelectionStartPoint} from './util.get-selection-start-point'\n\nexport function sliceTextBlock({\n context,\n block,\n}: {\n context: Pick<EditorContext, 'schema' | 'selection'>\n block: PortableTextTextBlock\n}): PortableTextTextBlock {\n const startPoint = getSelectionStartPoint(context.selection)\n const endPoint = getSelectionEndPoint(context.selection)\n\n if (!startPoint || !endPoint) {\n return block\n }\n\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n\n if (startBlockKey !== endBlockKey || startBlockKey !== block._key) {\n return block\n }\n\n const startChildKey = getChildKeyFromSelectionPoint(startPoint)\n const endChildKey = getChildKeyFromSelectionPoint(endPoint)\n\n if (!startChildKey || !endChildKey) {\n return block\n }\n\n let startChildFound = false\n const children: Array<PortableTextChild> = []\n\n for (const child of block.children) {\n if (child._key === startChildKey) {\n startChildFound = true\n\n if (isSpan(context, child)) {\n const text =\n child._key === endChildKey\n ? child.text.slice(startPoint.offset, endPoint.offset)\n : child.text.slice(startPoint.offset)\n\n children.push({\n ...child,\n text,\n })\n } else {\n children.push(child)\n }\n\n if (startChildKey === endChildKey) {\n break\n }\n\n continue\n }\n\n if (child._key === endChildKey) {\n if (isSpan(context, child)) {\n children.push({\n ...child,\n text: child.text.slice(0, endPoint.offset),\n })\n } else {\n children.push(child)\n }\n\n break\n }\n\n if (startChildFound) {\n children.push(child)\n }\n }\n\n return {\n ...block,\n children,\n }\n}\n"],"names":["isSelectionCollapsed","selection","JSON","stringify","anchor","path","focus","offset","selectionPointToBlockOffset","context","selectionPoint","blockKey","getBlockKeyFromSelectionPoint","length","undefined","_key","childSelectionPointToBlockOffset","sliceTextBlock","block","startPoint","getSelectionStartPoint","endPoint","getSelectionEndPoint","startBlockKey","endBlockKey","startChildKey","getChildKeyFromSelectionPoint","endChildKey","startChildFound","children","child","isSpan","text","slice","push"],"mappings":";;AAKO,SAASA,qBAAqBC,WAA4B;AAC/D,SAAKA,YAKHC,KAAKC,UAAUF,UAAUG,OAAOC,IAAI,MAClCH,KAAKC,UAAUF,UAAUK,MAAMD,IAAI,KACrCJ,UAAUG,OAAOG,WAAWN,UAAUK,MAAMC,SANrC;AAQX;ACNO,SAASC,4BAA4B;AAAA,EAC1CC;AAAAA,EACAC;AAIF,GAA4B;AAC1B,QAAMC,WAAWC,8BAA8BF,cAAc;AAE7D,SAAIA,eAAeL,KAAKQ,WAAW,KAAKF,aAAaG,SAC5C;AAAA,IACLT,MAAM,CAAC;AAAA,MAACU,MAAMJ;AAAAA,IAAAA,CAAS;AAAA,IACvBJ,QAAQG,eAAeH;AAAAA,EAAAA,IAIpBS,iCAAiC;AAAA,IACtCP;AAAAA,IACAC;AAAAA,EAAAA,CACD;AACH;ACnBO,SAASO,eAAe;AAAA,EAC7BR;AAAAA,EACAS;AAIF,GAA0B;AACxB,QAAMC,aAAaC,uBAAuBX,QAAQR,SAAS,GACrDoB,WAAWC,qBAAqBb,QAAQR,SAAS;AAEvD,MAAI,CAACkB,cAAc,CAACE;AAClB,WAAOH;AAGT,QAAMK,gBAAgBX,8BAA8BO,UAAU,GACxDK,cAAcZ,8BAA8BS,QAAQ;AAE1D,MAAIE,kBAAkBC,eAAeD,kBAAkBL,MAAMH;AAC3D,WAAOG;AAGT,QAAMO,gBAAgBC,8BAA8BP,UAAU,GACxDQ,cAAcD,8BAA8BL,QAAQ;AAE1D,MAAI,CAACI,iBAAiB,CAACE;AACrB,WAAOT;AAGT,MAAIU,kBAAkB;AACtB,QAAMC,WAAqC,CAAA;AAE3C,aAAWC,SAASZ,MAAMW,UAAU;AAClC,QAAIC,MAAMf,SAASU,eAAe;AAGhC,UAFAG,kBAAkB,IAEdG,OAAOtB,SAASqB,KAAK,GAAG;AAC1B,cAAME,OACJF,MAAMf,SAASY,cACXG,MAAME,KAAKC,MAAMd,WAAWZ,QAAQc,SAASd,MAAM,IACnDuB,MAAME,KAAKC,MAAMd,WAAWZ,MAAM;AAExCsB,iBAASK,KAAK;AAAA,UACZ,GAAGJ;AAAAA,UACHE;AAAAA,QAAAA,CACD;AAAA,MAAA;AAEDH,iBAASK,KAAKJ,KAAK;AAGrB,UAAIL,kBAAkBE;AACpB;AAGF;AAAA,IAAA;AAGF,QAAIG,MAAMf,SAASY,aAAa;AAC1BI,aAAOtB,SAASqB,KAAK,IACvBD,SAASK,KAAK;AAAA,QACZ,GAAGJ;AAAAA,QACHE,MAAMF,MAAME,KAAKC,MAAM,GAAGZ,SAASd,MAAM;AAAA,MAAA,CAC1C,IAEDsB,SAASK,KAAKJ,KAAK;AAGrB;AAAA,IAAA;AAGEF,uBACFC,SAASK,KAAKJ,KAAK;AAAA,EAAA;AAIvB,SAAO;AAAA,IACL,GAAGZ;AAAAA,IACHW;AAAAA,EAAAA;AAEJ;"}
package/lib/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), useEditor = require("./_chunks-cjs/use-editor.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), debug$f = require("debug"), slateDom = require("slate-dom"), selectionPoint = require("./_chunks-cjs/selection-point.cjs"), util_isEqualSelectionPoints = require("./_chunks-cjs/util.is-equal-selection-points.cjs"), util_selectionPointToBlockOffset = require("./_chunks-cjs/util.selection-point-to-block-offset.cjs"), isEqual = require("lodash/isEqual.js"), selector_isSelectionExpanded = require("./_chunks-cjs/selector.is-selection-expanded.cjs"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), getRandomValues = require("get-random-values-esm"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), flatten = require("lodash/flatten.js"), omit = require("lodash/omit.js"), patches = require("@portabletext/patches"), util_childSelectionPointToBlockOffset = require("./_chunks-cjs/util.child-selection-point-to-block-offset.cjs"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), types = require("@sanity/types"), startCase = require("lodash.startcase"), isPlainObject = require("lodash/isPlainObject.js");
3
+ var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), useEditor = require("./_chunks-cjs/use-editor.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), debug$f = require("debug"), slateDom = require("slate-dom"), selectionPoint = require("./_chunks-cjs/selection-point.cjs"), util_isEqualSelectionPoints = require("./_chunks-cjs/util.is-equal-selection-points.cjs"), util_sliceTextBlock = require("./_chunks-cjs/util.slice-text-block.cjs"), isEqual = require("lodash/isEqual.js"), selector_isSelectionExpanded = require("./_chunks-cjs/selector.is-selection-expanded.cjs"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), getRandomValues = require("get-random-values-esm"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), flatten = require("lodash/flatten.js"), omit = require("lodash/omit.js"), patches = require("@portabletext/patches"), util_childSelectionPointToBlockOffset = require("./_chunks-cjs/util.child-selection-point-to-block-offset.cjs"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), types = require("@sanity/types"), startCase = require("lodash.startcase"), isPlainObject = require("lodash/isPlainObject.js");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
@@ -417,7 +417,7 @@ function getEventPosition({
417
417
  return;
418
418
  const eventSelectionFocusBlockKey = selectionPoint.getBlockKeyFromSelectionPoint(eventSelection.focus);
419
419
  if (eventSelectionFocusBlockKey !== void 0)
420
- return util_selectionPointToBlockOffset.isSelectionCollapsed(eventSelection) && eventBlock && eventSelectionFocusBlockKey !== eventBlock._key ? {
420
+ return util_sliceTextBlock.isSelectionCollapsed(eventSelection) && eventBlock && eventSelectionFocusBlockKey !== eventBlock._key ? {
421
421
  block: eventPositionBlock,
422
422
  isEditor: !1,
423
423
  selection: {
@@ -3163,13 +3163,13 @@ const addAnnotationOperationImplementation = ({
3163
3163
  schema: context.schema,
3164
3164
  editor,
3165
3165
  range: selection
3166
- }), anchorOffset = editorSelection ? util_selectionPointToBlockOffset.selectionPointToBlockOffset({
3166
+ }), anchorOffset = editorSelection ? util_sliceTextBlock.selectionPointToBlockOffset({
3167
3167
  context: {
3168
3168
  ...context,
3169
3169
  value
3170
3170
  },
3171
3171
  selectionPoint: editorSelection.anchor
3172
- }) : void 0, focusOffset = editorSelection ? util_selectionPointToBlockOffset.selectionPointToBlockOffset({
3172
+ }) : void 0, focusOffset = editorSelection ? util_sliceTextBlock.selectionPointToBlockOffset({
3173
3173
  context: {
3174
3174
  ...context,
3175
3175
  value
@@ -6832,7 +6832,7 @@ const coreDndBehaviors = [
6832
6832
  snapshot
6833
6833
  }) => {
6834
6834
  const selection = snapshot.context.selection;
6835
- if (!selection || util_selectionPointToBlockOffset.isSelectionCollapsed(selection))
6835
+ if (!selection || util_sliceTextBlock.isSelectionCollapsed(selection))
6836
6836
  return !1;
6837
6837
  const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
6838
6838
  return !selectionStartBlock || !selectionEndBlock ? !1 : !selectionPoint.isTextBlock(snapshot.context, selectionStartBlock.node) && selectionPoint.isTextBlock(snapshot.context, selectionEndBlock.node) ? {
@@ -6852,7 +6852,7 @@ const coreDndBehaviors = [
6852
6852
  snapshot
6853
6853
  }) => {
6854
6854
  const selection = snapshot.context.selection;
6855
- return !selection || util_selectionPointToBlockOffset.isSelectionCollapsed(selection) ? !1 : {
6855
+ return !selection || util_sliceTextBlock.isSelectionCollapsed(selection) ? !1 : {
6856
6856
  selection
6857
6857
  };
6858
6858
  },
@@ -6871,7 +6871,7 @@ const coreDndBehaviors = [
6871
6871
  snapshot
6872
6872
  }) => {
6873
6873
  const selection = snapshot.context.selection;
6874
- if (!selection || !util_selectionPointToBlockOffset.isSelectionCollapsed(selection))
6874
+ if (!selection || !util_sliceTextBlock.isSelectionCollapsed(selection))
6875
6875
  return !1;
6876
6876
  const selectionStartPoint = selectionPoint.getSelectionStartPoint(selection), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
6877
6877
  if (!focusTextBlock)
@@ -6883,13 +6883,13 @@ const coreDndBehaviors = [
6883
6883
  anchor: selectionStartPoint,
6884
6884
  focus: blockEndPoint
6885
6885
  }, newTextBlock = selectionPoint.parseBlock({
6886
- block: selector_isSelectionExpanded.getSelectedValue({
6887
- ...snapshot,
6886
+ block: util_sliceTextBlock.sliceTextBlock({
6888
6887
  context: {
6889
6888
  ...snapshot.context,
6890
6889
  selection: newTextBlockSelection
6891
- }
6892
- }).at(0),
6890
+ },
6891
+ block: focusTextBlock.node
6892
+ }),
6893
6893
  context: snapshot.context,
6894
6894
  options: {
6895
6895
  refreshKeys: !0,
@@ -6904,7 +6904,7 @@ const coreDndBehaviors = [
6904
6904
  actions: [(_, {
6905
6905
  newTextBlock,
6906
6906
  newTextBlockSelection
6907
- }) => util_selectionPointToBlockOffset.isSelectionCollapsed(newTextBlockSelection) ? [behaviors_index.raise({
6907
+ }) => util_sliceTextBlock.isSelectionCollapsed(newTextBlockSelection) ? [behaviors_index.raise({
6908
6908
  type: "insert.block",
6909
6909
  block: newTextBlock,
6910
6910
  placement: "after",