@portabletext/editor 2.6.2 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -29
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs +5 -5
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +3 -3
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs +5 -5
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +2 -6
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +106 -117
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-text-block.cjs +3 -3
- package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.cts +10 -10
- package/lib/_chunks-dts/behavior.types.action.d.ts +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +3 -2
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js +3 -2
- package/lib/_chunks-es/selector.is-selection-expanded.js.map +1 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +2 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.is-selection-collapsed.js +2 -1
- package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +2 -5
- package/lib/_chunks-es/util.merge-text-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +101 -112
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-text-block.js +2 -1
- package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
- package/lib/index.cjs +132 -95
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +41 -4
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +5 -5
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/lib/plugins/index.js +6 -5
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +3 -3
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +2 -1
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +14 -4
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +4 -11
- package/lib/utils/index.d.ts +2 -9
- package/lib/utils/index.js +4 -3
- package/lib/utils/index.js.map +1 -1
- package/package.json +10 -9
- package/src/behaviors/behavior.abstract.delete.ts +1 -1
- package/src/behaviors/behavior.abstract.deserialize.ts +1 -1
- package/src/behaviors/behavior.abstract.split.ts +2 -1
- package/src/behaviors/behavior.core.block-objects.ts +1 -1
- package/src/behaviors/behavior.core.lists.ts +2 -1
- package/src/behaviors/behavior.markdown.ts +1 -1
- package/src/converters/converter.text-plain.ts +2 -1
- package/src/editor/Editable.tsx +1 -1
- package/src/editor/__tests__/PortableTextEditor.test.tsx +1 -1
- package/src/editor/__tests__/RangeDecorations.test.tsx +1 -1
- package/src/editor/__tests__/self-solving.test.tsx +1 -1
- package/src/editor/components/render-element.tsx +1 -1
- package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +2 -3
- package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +1 -1
- package/src/editor/plugins/createWithObjectKeys.ts +1 -1
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +1 -1
- package/src/editor/plugins/createWithSchemaTypes.ts +2 -5
- package/src/internal-utils/__tests__/valueNormalization.test.tsx +1 -1
- package/src/internal-utils/apply-operation-to-portable-text.test.ts +1 -1
- package/src/internal-utils/build-index-maps.ts +1 -1
- package/src/internal-utils/create-test-snapshot.ts +1 -1
- package/src/internal-utils/drag-selection.test.ts +1 -1
- package/src/internal-utils/editor-selection.ts +1 -1
- package/src/internal-utils/operation-to-patches.ts +1 -1
- package/src/internal-utils/parse-blocks.test.ts +1 -1
- package/src/internal-utils/parse-blocks.ts +1 -38
- package/src/internal-utils/selection-focus-text.ts +1 -1
- package/src/internal-utils/selection-text.ts +1 -1
- package/src/internal-utils/test-editor.tsx +1 -1
- package/src/internal-utils/text-block-key.ts +1 -1
- package/src/internal-utils/text-marks.ts +1 -1
- package/src/internal-utils/text-selection.ts +1 -1
- package/src/internal-utils/to-slate-range.test.ts +1 -1
- package/src/internal-utils/to-slate-range.ts +1 -1
- package/src/internal-utils/validateValue.ts +1 -1
- package/src/internal-utils/value-annotations.ts +1 -1
- package/src/operations/behavior.operation.block.unset.ts +2 -1
- package/src/operations/behavior.operation.delete.ts +98 -2
- package/src/operations/behavior.operation.insert.block.ts +2 -1
- package/src/plugins/plugin.behavior.tsx +3 -1
- package/src/plugins/plugin.internal.auto-close-brackets.test.tsx +1 -2
- package/src/plugins/plugin.markdown.test.tsx +1 -2
- package/src/selectors/selector.get-active-annotations.ts +1 -1
- package/src/selectors/selector.get-active-list-item.ts +1 -1
- package/src/selectors/selector.get-active-style.ts +1 -1
- package/src/selectors/selector.get-anchor-text-block.ts +1 -1
- package/src/selectors/selector.get-caret-word-selection.test.ts +1 -1
- package/src/selectors/selector.get-focus-block-object.ts +1 -1
- package/src/selectors/selector.get-focus-span.ts +1 -1
- package/src/selectors/selector.get-focus-text-block.ts +1 -1
- package/src/selectors/selector.get-list-state.ts +1 -1
- package/src/selectors/selector.get-next-span.ts +1 -1
- package/src/selectors/selector.get-previous-span.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +1 -1
- package/src/selectors/selector.get-selected-text-blocks.ts +1 -1
- package/src/selectors/selector.get-selection-text.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.test.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.ts +1 -1
- package/src/selectors/selector.is-active-annotation.ts +1 -1
- package/src/selectors/selector.is-point-after-selection.ts +1 -1
- package/src/selectors/selector.is-point-before-selection.ts +1 -1
- package/src/utils/index.ts +1 -2
- package/src/utils/util.at-the-beginning-of-block.ts +1 -1
- package/src/utils/util.block-offset.ts +1 -1
- package/src/utils/util.child-selection-point-to-block-offset.ts +1 -1
- package/src/utils/util.get-block-end-point.ts +1 -1
- package/src/utils/util.get-block-start-point.ts +1 -1
- package/src/utils/util.is-empty-text-block.ts +1 -1
- package/src/utils/util.merge-text-blocks.ts +1 -1
- package/src/utils/util.slice-blocks.ts +2 -2
- package/src/utils/util.slice-text-block.ts +2 -2
- package/src/utils/util.split-text-block.ts +1 -1
- package/src/internal-utils/terse-pt.test.ts +0 -175
- package/src/internal-utils/terse-pt.ts +0 -150
- package/src/internal-utils/test-key-generator.ts +0 -9
- package/src/utils/util.is-span.ts +0 -12
- package/src/utils/util.is-text-block.ts +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.slice-text-block.js","sources":["../../src/utils/util.selection-point-to-block-offset.ts","../../src/utils/util.slice-text-block.ts"],"sourcesContent":["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
|
|
1
|
+
{"version":3,"file":"util.slice-text-block.js","sources":["../../src/utils/util.selection-point-to-block-offset.ts","../../src/utils/util.slice-text-block.ts"],"sourcesContent":["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 {isSpan} from '@portabletext/schema'\nimport type {PortableTextChild, PortableTextTextBlock} from '@sanity/types'\nimport type {EditorContext} from '../editor/editor-snapshot'\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":["selectionPointToBlockOffset","context","selectionPoint","blockKey","getBlockKeyFromSelectionPoint","path","length","undefined","_key","offset","childSelectionPointToBlockOffset","sliceTextBlock","block","startPoint","getSelectionStartPoint","selection","endPoint","getSelectionEndPoint","startBlockKey","endBlockKey","startChildKey","getChildKeyFromSelectionPoint","endChildKey","startChildFound","children","child","isSpan","text","slice","push"],"mappings":";;;AASO,SAASA,4BAA4B;AAAA,EAC1CC;AAAAA,EACAC;AAIF,GAA4B;AAC1B,QAAMC,WAAWC,8BAA8BF,cAAc;AAE7D,SAAIA,eAAeG,KAAKC,WAAW,KAAKH,aAAaI,SAC5C;AAAA,IACLF,MAAM,CAAC;AAAA,MAACG,MAAML;AAAAA,IAAAA,CAAS;AAAA,IACvBM,QAAQP,eAAeO;AAAAA,EAAAA,IAIpBC,iCAAiC;AAAA,IACtCT;AAAAA,IACAC;AAAAA,EAAAA,CACD;AACH;ACnBO,SAASS,eAAe;AAAA,EAC7BV;AAAAA,EACAW;AAIF,GAA0B;AACxB,QAAMC,aAAaC,uBAAuBb,QAAQc,SAAS,GACrDC,WAAWC,qBAAqBhB,QAAQc,SAAS;AAEvD,MAAI,CAACF,cAAc,CAACG;AAClB,WAAOJ;AAGT,QAAMM,gBAAgBd,8BAA8BS,UAAU,GACxDM,cAAcf,8BAA8BY,QAAQ;AAE1D,MAAIE,kBAAkBC,eAAeD,kBAAkBN,MAAMJ;AAC3D,WAAOI;AAGT,QAAMQ,gBAAgBC,8BAA8BR,UAAU,GACxDS,cAAcD,8BAA8BL,QAAQ;AAE1D,MAAI,CAACI,iBAAiB,CAACE;AACrB,WAAOV;AAGT,MAAIW,kBAAkB;AACtB,QAAMC,WAAqC,CAAA;AAE3C,aAAWC,SAASb,MAAMY,UAAU;AAClC,QAAIC,MAAMjB,SAASY,eAAe;AAGhC,UAFAG,kBAAkB,IAEdG,OAAOzB,SAASwB,KAAK,GAAG;AAC1B,cAAME,OACJF,MAAMjB,SAASc,cACXG,MAAME,KAAKC,MAAMf,WAAWJ,QAAQO,SAASP,MAAM,IACnDgB,MAAME,KAAKC,MAAMf,WAAWJ,MAAM;AAExCe,iBAASK,KAAK;AAAA,UACZ,GAAGJ;AAAAA,UACHE;AAAAA,QAAAA,CACD;AAAA,MACH;AACEH,iBAASK,KAAKJ,KAAK;AAGrB,UAAIL,kBAAkBE;AACpB;AAGF;AAAA,IACF;AAEA,QAAIG,MAAMjB,SAASc,aAAa;AAC1BI,aAAOzB,SAASwB,KAAK,IACvBD,SAASK,KAAK;AAAA,QACZ,GAAGJ;AAAAA,QACHE,MAAMF,MAAME,KAAKC,MAAM,GAAGZ,SAASP,MAAM;AAAA,MAAA,CAC1C,IAEDe,SAASK,KAAKJ,KAAK;AAGrB;AAAA,IACF;AAEIF,uBACFC,SAASK,KAAKJ,KAAK;AAAA,EAEvB;AAEA,SAAO;AAAA,IACL,GAAGb;AAAAA,IACHY;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"), 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"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.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"), sanityBridge = require("@portabletext/sanity-bridge"),
|
|
3
|
+
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), 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"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), isEqual = require("lodash/isEqual.js"), schema = require("@portabletext/schema"), 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"), sanityBridge = require("@portabletext/sanity-bridge"), xstate = require("xstate"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema$1 = 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"), util_sliceTextBlock = require("./_chunks-cjs/util.slice-text-block.cjs"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), keyboardShortcuts = require("@portabletext/keyboard-shortcuts"), 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
|
}
|
|
@@ -589,7 +589,7 @@ function toSlateSelectionPoint(snapshot, selectionPoint, direction) {
|
|
|
589
589
|
const block = snapshot.context.value.at(blockIndex);
|
|
590
590
|
if (!block)
|
|
591
591
|
return;
|
|
592
|
-
if (!
|
|
592
|
+
if (!schema.isTextBlock(snapshot.context, block))
|
|
593
593
|
return {
|
|
594
594
|
path: [blockIndex, 0],
|
|
595
595
|
offset: 0
|
|
@@ -618,7 +618,7 @@ function toSlateSelectionPoint(snapshot, selectionPoint, direction) {
|
|
|
618
618
|
let offset = spanSelectionPoint?.offset ?? selectionPoint.offset, childPath = [], childIndex = -1, pathChild;
|
|
619
619
|
for (const child of block.children)
|
|
620
620
|
if (childIndex++, child._key === childKey) {
|
|
621
|
-
pathChild = child,
|
|
621
|
+
pathChild = child, schema.isSpan(snapshot.context, child) ? childPath = [childIndex] : (childPath = [childIndex, 0], offset = 0);
|
|
622
622
|
break;
|
|
623
623
|
}
|
|
624
624
|
return childPath.length === 0 ? {
|
|
@@ -626,7 +626,7 @@ function toSlateSelectionPoint(snapshot, selectionPoint, direction) {
|
|
|
626
626
|
offset: 0
|
|
627
627
|
} : {
|
|
628
628
|
path: [blockIndex].concat(childPath),
|
|
629
|
-
offset:
|
|
629
|
+
offset: schema.isSpan(snapshot.context, pathChild) ? Math.min(pathChild.text.length, offset) : offset
|
|
630
630
|
};
|
|
631
631
|
}
|
|
632
632
|
const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE_ELEMENT = /* @__PURE__ */ new WeakMap(), KEY_TO_VALUE_ELEMENT = /* @__PURE__ */ new WeakMap(), SLATE_TO_PORTABLE_TEXT_RANGE = /* @__PURE__ */ new WeakMap(), EditorActorContext = React.createContext({});
|
|
@@ -1008,17 +1008,17 @@ function RenderTextBlock(props) {
|
|
|
1008
1008
|
] });
|
|
1009
1009
|
}
|
|
1010
1010
|
function RenderElement(props) {
|
|
1011
|
-
const $ = reactCompilerRuntime.c(34), editorActor = React.useContext(EditorActorContext),
|
|
1011
|
+
const $ = reactCompilerRuntime.c(34), editorActor = React.useContext(EditorActorContext), schema$12 = react.useSelector(editorActor, _temp$2), legacySchema = react.useSelector(editorActor, _temp2$1), slateStatic = slateReact.useSlateStatic();
|
|
1012
1012
|
if ("__inline" in props.element && props.element.__inline === !0) {
|
|
1013
1013
|
let t02;
|
|
1014
|
-
return $[0] !== legacySchema || $[1] !== props.attributes || $[2] !== props.children || $[3] !== props.element || $[4] !== props.readOnly || $[5] !== props.renderChild || $[6] !==
|
|
1014
|
+
return $[0] !== legacySchema || $[1] !== props.attributes || $[2] !== props.children || $[3] !== props.element || $[4] !== props.readOnly || $[5] !== props.renderChild || $[6] !== schema$12 ? (t02 = /* @__PURE__ */ jsxRuntime.jsx(RenderInlineObject, { attributes: props.attributes, element: props.element, legacySchema, readOnly: props.readOnly, renderChild: props.renderChild, schema: schema$12, children: props.children }), $[0] = legacySchema, $[1] = props.attributes, $[2] = props.children, $[3] = props.element, $[4] = props.readOnly, $[5] = props.renderChild, $[6] = schema$12, $[7] = t02) : t02 = $[7], t02;
|
|
1015
1015
|
}
|
|
1016
1016
|
let block, t0;
|
|
1017
|
-
if ($[8] !== props.element._key || $[9] !==
|
|
1017
|
+
if ($[8] !== props.element._key || $[9] !== schema$12 || $[10] !== slateStatic.blockIndexMap || $[11] !== slateStatic.value) {
|
|
1018
1018
|
const blockIndex = slateStatic.blockIndexMap.get(props.element._key);
|
|
1019
|
-
block = blockIndex !== void 0 ? slateStatic.value.at(blockIndex) : void 0, t0 =
|
|
1020
|
-
schema:
|
|
1021
|
-
}, block), $[8] = props.element._key, $[9] =
|
|
1019
|
+
block = blockIndex !== void 0 ? slateStatic.value.at(blockIndex) : void 0, t0 = schema.isTextBlock({
|
|
1020
|
+
schema: schema$12
|
|
1021
|
+
}, block), $[8] = props.element._key, $[9] = schema$12, $[10] = slateStatic.blockIndexMap, $[11] = slateStatic.value, $[12] = block, $[13] = t0;
|
|
1022
1022
|
} else
|
|
1023
1023
|
block = $[12], t0 = $[13];
|
|
1024
1024
|
if (t0) {
|
|
@@ -1026,7 +1026,7 @@ function RenderElement(props) {
|
|
|
1026
1026
|
return $[14] !== block || $[15] !== legacySchema || $[16] !== props.attributes || $[17] !== props.children || $[18] !== props.element || $[19] !== props.readOnly || $[20] !== props.renderBlock || $[21] !== props.renderListItem || $[22] !== props.renderStyle || $[23] !== props.spellCheck ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(RenderTextBlock, { attributes: props.attributes, element: props.element, legacySchema, readOnly: props.readOnly, renderBlock: props.renderBlock, renderListItem: props.renderListItem, renderStyle: props.renderStyle, spellCheck: props.spellCheck, textBlock: block, children: props.children }), $[14] = block, $[15] = legacySchema, $[16] = props.attributes, $[17] = props.children, $[18] = props.element, $[19] = props.readOnly, $[20] = props.renderBlock, $[21] = props.renderListItem, $[22] = props.renderStyle, $[23] = props.spellCheck, $[24] = t12) : t12 = $[24], t12;
|
|
1027
1027
|
}
|
|
1028
1028
|
let t1;
|
|
1029
|
-
return $[25] !== block || $[26] !== legacySchema || $[27] !== props.attributes || $[28] !== props.children || $[29] !== props.element || $[30] !== props.readOnly || $[31] !== props.renderBlock || $[32] !==
|
|
1029
|
+
return $[25] !== block || $[26] !== legacySchema || $[27] !== props.attributes || $[28] !== props.children || $[29] !== props.element || $[30] !== props.readOnly || $[31] !== props.renderBlock || $[32] !== schema$12 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(RenderBlockObject, { attributes: props.attributes, blockObject: block, element: props.element, legacySchema, readOnly: props.readOnly, renderBlock: props.renderBlock, schema: schema$12, children: props.children }), $[25] = block, $[26] = legacySchema, $[27] = props.attributes, $[28] = props.children, $[29] = props.element, $[30] = props.readOnly, $[31] = props.renderBlock, $[32] = schema$12, $[33] = t1) : t1 = $[33], t1;
|
|
1030
1030
|
}
|
|
1031
1031
|
function _temp2$1(s_0) {
|
|
1032
1032
|
return s_0.context.getLegacySchema();
|
|
@@ -1225,7 +1225,7 @@ function createConverterTextPlain(legacySchema) {
|
|
|
1225
1225
|
event
|
|
1226
1226
|
}) => snapshot.context.selection ? {
|
|
1227
1227
|
type: "serialization.success",
|
|
1228
|
-
data: selector_isSelectionExpanded.getSelectedValue(snapshot).map((block) =>
|
|
1228
|
+
data: selector_isSelectionExpanded.getSelectedValue(snapshot).map((block) => schema.isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
|
|
1229
1229
|
|
|
1230
1230
|
`),
|
|
1231
1231
|
mimeType: "text/plain",
|
|
@@ -1298,7 +1298,7 @@ function buildIndexMaps(context, {
|
|
|
1298
1298
|
const block = context.value.at(blockIndex);
|
|
1299
1299
|
if (block === void 0)
|
|
1300
1300
|
continue;
|
|
1301
|
-
if (blockIndexMap.set(block._key, blockIndex), !
|
|
1301
|
+
if (blockIndexMap.set(block._key, blockIndex), !schema.isTextBlock(context, block)) {
|
|
1302
1302
|
levelIndexMaps.clear(), previousListItem = void 0;
|
|
1303
1303
|
continue;
|
|
1304
1304
|
}
|
|
@@ -1658,7 +1658,7 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
1658
1658
|
blockPath,
|
|
1659
1659
|
spanPath: [op.path[0], op.path[1] - 1]
|
|
1660
1660
|
}), nextSpanAnnotations = nextSpan ? nextSpan.marks?.filter((mark) => !decorators.includes(mark)) : [], annotationsEnding = previousSpanAnnotations?.filter((annotation) => !nextSpanAnnotations?.includes(annotation)) ?? [], atTheEndOfAnnotation = annotationsEnding.length > 0;
|
|
1661
|
-
if (atTheEndOfAnnotation &&
|
|
1661
|
+
if (atTheEndOfAnnotation && schema.isSpan(editorActor.getSnapshot().context, op.node) && op.node.marks?.some((mark) => annotationsEnding.includes(mark))) {
|
|
1662
1662
|
slate.Transforms.insertNodes(editor, {
|
|
1663
1663
|
...op.node,
|
|
1664
1664
|
_key: editorActor.getSnapshot().context.keyGenerator(),
|
|
@@ -1667,7 +1667,7 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
1667
1667
|
return;
|
|
1668
1668
|
}
|
|
1669
1669
|
const annotationsStarting = nextSpanAnnotations?.filter((annotation) => !previousSpanAnnotations?.includes(annotation)) ?? [], atTheStartOfAnnotation = annotationsStarting.length > 0;
|
|
1670
|
-
if (atTheStartOfAnnotation &&
|
|
1670
|
+
if (atTheStartOfAnnotation && schema.isSpan(editorActor.getSnapshot().context, op.node) && op.node.marks?.some((mark) => annotationsStarting.includes(mark))) {
|
|
1671
1671
|
slate.Transforms.insertNodes(editor, {
|
|
1672
1672
|
...op.node,
|
|
1673
1673
|
_key: editorActor.getSnapshot().context.keyGenerator(),
|
|
@@ -1676,7 +1676,7 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
1676
1676
|
return;
|
|
1677
1677
|
}
|
|
1678
1678
|
const nextSpanDecorators = nextSpan?.marks?.filter((mark) => decorators.includes(mark)) ?? [];
|
|
1679
|
-
if (nextSpanDecorators.length > 0 && atTheEndOfAnnotation && !atTheStartOfAnnotation &&
|
|
1679
|
+
if (nextSpanDecorators.length > 0 && atTheEndOfAnnotation && !atTheStartOfAnnotation && schema.isSpan(editorActor.getSnapshot().context, op.node) && op.node.marks?.length === 0) {
|
|
1680
1680
|
slate.Transforms.insertNodes(editor, {
|
|
1681
1681
|
...op.node,
|
|
1682
1682
|
_key: editorActor.getSnapshot().context.keyGenerator(),
|
|
@@ -1723,7 +1723,7 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
1723
1723
|
match: (n) => editor.isTextSpan(n),
|
|
1724
1724
|
voids: !1
|
|
1725
1725
|
}))[0] ?? [void 0, void 0];
|
|
1726
|
-
if (span && block &&
|
|
1726
|
+
if (span && block && schema.isTextBlock(editorActor.getSnapshot().context, block)) {
|
|
1727
1727
|
const markDefs = block.markDefs ?? [], marks = span.marks ?? [], spanHasAnnotations = marks.some((mark) => markDefs.find((markDef) => markDef._key === mark)), deletingFromTheEnd = op.offset + op.text.length === span.text.length, deletingAllText = op.offset === 0 && deletingFromTheEnd, previousSpan = getPreviousSpan({
|
|
1728
1728
|
editor,
|
|
1729
1729
|
blockPath,
|
|
@@ -2944,7 +2944,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
2944
2944
|
const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(operation.editor)).at(0);
|
|
2945
2945
|
if (!parsedBlock)
|
|
2946
2946
|
throw new Error(`Unable to parse block at ${JSON.stringify(operation.at)}`);
|
|
2947
|
-
if (
|
|
2947
|
+
if (schema.isTextBlock(context, parsedBlock)) {
|
|
2948
2948
|
const propsToRemove = operation.props.filter((prop) => prop !== "_type"), updatedTextBlock = util_sliceBlocks.parseBlock({
|
|
2949
2949
|
context,
|
|
2950
2950
|
block: omit__default.default(parsedBlock, propsToRemove),
|
|
@@ -3301,17 +3301,54 @@ const addAnnotationOperationImplementation = ({
|
|
|
3301
3301
|
});
|
|
3302
3302
|
if (!range)
|
|
3303
3303
|
throw new Error(`Failed to get Slate Range for selection ${JSON.stringify(operation.at)}`);
|
|
3304
|
-
|
|
3304
|
+
if (operation.direction === "backward" && operation.unit === "line") {
|
|
3305
|
+
const parentBlockEntry = slate.Editor.above(operation.editor, {
|
|
3306
|
+
match: (n) => slate.Element.isElement(n) && slate.Editor.isBlock(operation.editor, n),
|
|
3307
|
+
at: range
|
|
3308
|
+
});
|
|
3309
|
+
if (parentBlockEntry) {
|
|
3310
|
+
const [, parentBlockPath] = parentBlockEntry, parentElementRange = slate.Editor.range(operation.editor, parentBlockPath, range.anchor), currentLineRange = findCurrentLineRange(operation.editor, parentElementRange);
|
|
3311
|
+
if (!slate.Range.isCollapsed(currentLineRange)) {
|
|
3312
|
+
slate.Transforms.delete(operation.editor, {
|
|
3313
|
+
at: currentLineRange
|
|
3314
|
+
});
|
|
3315
|
+
return;
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
const hanging = schema.isTextBlock(context, endBlock) && endOffset === 0;
|
|
3305
3320
|
slate.deleteText(operation.editor, {
|
|
3306
3321
|
at: range,
|
|
3307
3322
|
reverse: operation.direction === "backward",
|
|
3308
3323
|
unit: operation.unit,
|
|
3309
3324
|
hanging
|
|
3310
|
-
}), operation.editor.selection &&
|
|
3325
|
+
}), operation.editor.selection && schema.isTextBlock(context, startBlock) && schema.isTextBlock(context, endBlock) && slate.setSelection(operation.editor, {
|
|
3311
3326
|
anchor: operation.editor.selection.focus,
|
|
3312
3327
|
focus: operation.editor.selection.focus
|
|
3313
3328
|
});
|
|
3314
|
-
}
|
|
3329
|
+
};
|
|
3330
|
+
function findCurrentLineRange(editor, parentRange) {
|
|
3331
|
+
const parentRangeBoundary = slate.Editor.range(editor, slate.Range.end(parentRange)), positions = Array.from(slate.Editor.positions(editor, {
|
|
3332
|
+
at: parentRange
|
|
3333
|
+
}));
|
|
3334
|
+
let left = 0, right = positions.length, middle = Math.floor(right / 2);
|
|
3335
|
+
if (rangesAreOnSameLine(editor, slate.Editor.range(editor, positions[left]), parentRangeBoundary))
|
|
3336
|
+
return slate.Editor.range(editor, positions[left], parentRangeBoundary);
|
|
3337
|
+
if (positions.length < 2)
|
|
3338
|
+
return slate.Editor.range(editor, positions[positions.length - 1], parentRangeBoundary);
|
|
3339
|
+
for (; middle !== positions.length && middle !== left; )
|
|
3340
|
+
rangesAreOnSameLine(editor, slate.Editor.range(editor, positions[middle]), parentRangeBoundary) ? right = middle : left = middle, middle = Math.floor((left + right) / 2);
|
|
3341
|
+
return slate.Editor.range(editor, positions[left], parentRangeBoundary);
|
|
3342
|
+
}
|
|
3343
|
+
function rangesAreOnSameLine(editor, range1, range2) {
|
|
3344
|
+
const rect1 = slateDom.DOMEditor.toDOMRange(editor, range1).getBoundingClientRect(), rect2 = slateDom.DOMEditor.toDOMRange(editor, range2).getBoundingClientRect();
|
|
3345
|
+
return domRectsIntersect(rect1, rect2) && domRectsIntersect(rect2, rect1);
|
|
3346
|
+
}
|
|
3347
|
+
function domRectsIntersect(rect, compareRect) {
|
|
3348
|
+
const middle = (compareRect.top + compareRect.bottom) / 2;
|
|
3349
|
+
return rect.top <= middle && rect.bottom >= middle;
|
|
3350
|
+
}
|
|
3351
|
+
const insertInlineObjectOperationImplementation = ({
|
|
3315
3352
|
context,
|
|
3316
3353
|
operation
|
|
3317
3354
|
}) => {
|
|
@@ -3513,7 +3550,7 @@ function insertBlock({
|
|
|
3513
3550
|
}
|
|
3514
3551
|
return markDef;
|
|
3515
3552
|
}), adjustedChildren = block.children.map((child) => {
|
|
3516
|
-
if (
|
|
3553
|
+
if (schema.isSpan(context, child)) {
|
|
3517
3554
|
const marks = child.marks?.map((mark) => markDefKeyMap.get(mark) || mark) ?? [];
|
|
3518
3555
|
if (!isEqual__default.default(child.marks, marks))
|
|
3519
3556
|
return {
|
|
@@ -4099,7 +4136,7 @@ function createWithObjectKeys(editorActor) {
|
|
|
4099
4136
|
apply2(operation);
|
|
4100
4137
|
return;
|
|
4101
4138
|
}
|
|
4102
|
-
if (!
|
|
4139
|
+
if (!schema.isTextBlock(editorActor.getSnapshot().context, block) || !schema.isTextBlock(editorActor.getSnapshot().context, previousBlock)) {
|
|
4103
4140
|
apply2(operation);
|
|
4104
4141
|
return;
|
|
4105
4142
|
}
|
|
@@ -4115,7 +4152,7 @@ function createWithObjectKeys(editorActor) {
|
|
|
4115
4152
|
});
|
|
4116
4153
|
let childIndex = 0;
|
|
4117
4154
|
for (const child of block.children) {
|
|
4118
|
-
if (
|
|
4155
|
+
if (schema.isSpan(editorActor.getSnapshot().context, child)) {
|
|
4119
4156
|
const marks = child.marks?.map((mark) => markDefKeyMap.get(mark) || mark) ?? [];
|
|
4120
4157
|
isEqual__default.default(child.marks, marks) || slate.Transforms.setNodes(editor, {
|
|
4121
4158
|
marks
|
|
@@ -4489,16 +4526,16 @@ function findBlockChild(block, path) {
|
|
|
4489
4526
|
index: childIndex
|
|
4490
4527
|
};
|
|
4491
4528
|
}
|
|
4492
|
-
function insertTextPatch(
|
|
4493
|
-
const block =
|
|
4494
|
-
schema:
|
|
4529
|
+
function insertTextPatch(schema$12, children, operation, beforeValue) {
|
|
4530
|
+
const block = schema.isTextBlock({
|
|
4531
|
+
schema: schema$12
|
|
4495
4532
|
}, children[operation.path[0]]) && children[operation.path[0]];
|
|
4496
4533
|
if (!block)
|
|
4497
4534
|
throw new Error("Could not find block");
|
|
4498
|
-
const textChild =
|
|
4499
|
-
schema:
|
|
4500
|
-
}, block) &&
|
|
4501
|
-
schema:
|
|
4535
|
+
const textChild = schema.isTextBlock({
|
|
4536
|
+
schema: schema$12
|
|
4537
|
+
}, block) && schema.isSpan({
|
|
4538
|
+
schema: schema$12
|
|
4502
4539
|
}, block.children[operation.path[1]]) && block.children[operation.path[1]];
|
|
4503
4540
|
if (!textChild)
|
|
4504
4541
|
throw new Error("Could not find child");
|
|
@@ -4506,21 +4543,21 @@ function insertTextPatch(schema2, children, operation, beforeValue) {
|
|
|
4506
4543
|
_key: block._key
|
|
4507
4544
|
}, "children", {
|
|
4508
4545
|
_key: textChild._key
|
|
4509
|
-
}, "text"], prevBlock = beforeValue[operation.path[0]], prevChild =
|
|
4510
|
-
schema:
|
|
4511
|
-
}, prevBlock) && prevBlock.children[operation.path[1]], prevText =
|
|
4512
|
-
schema:
|
|
4546
|
+
}, "text"], prevBlock = beforeValue[operation.path[0]], prevChild = schema.isTextBlock({
|
|
4547
|
+
schema: schema$12
|
|
4548
|
+
}, prevBlock) && prevBlock.children[operation.path[1]], prevText = schema.isSpan({
|
|
4549
|
+
schema: schema$12
|
|
4513
4550
|
}, prevChild) ? prevChild.text : "", patch = patches.diffMatchPatch(prevText, textChild.text, path);
|
|
4514
4551
|
return patch.value.length ? [patch] : [];
|
|
4515
4552
|
}
|
|
4516
|
-
function removeTextPatch(
|
|
4553
|
+
function removeTextPatch(schema$12, children, operation, beforeValue) {
|
|
4517
4554
|
const block = children[operation.path[0]];
|
|
4518
4555
|
if (!block)
|
|
4519
4556
|
throw new Error("Could not find block");
|
|
4520
|
-
const child =
|
|
4521
|
-
schema:
|
|
4522
|
-
}, block) && block.children[operation.path[1]] || void 0, textChild =
|
|
4523
|
-
schema:
|
|
4557
|
+
const child = schema.isTextBlock({
|
|
4558
|
+
schema: schema$12
|
|
4559
|
+
}, block) && block.children[operation.path[1]] || void 0, textChild = schema.isSpan({
|
|
4560
|
+
schema: schema$12
|
|
4524
4561
|
}, child) ? child : void 0;
|
|
4525
4562
|
if (child && !textChild)
|
|
4526
4563
|
throw new Error("Expected span");
|
|
@@ -4530,14 +4567,14 @@ function removeTextPatch(schema2, children, operation, beforeValue) {
|
|
|
4530
4567
|
_key: block._key
|
|
4531
4568
|
}, "children", {
|
|
4532
4569
|
_key: textChild._key
|
|
4533
|
-
}, "text"], beforeBlock = beforeValue[operation.path[0]], prevTextChild =
|
|
4534
|
-
schema:
|
|
4535
|
-
}, beforeBlock) && beforeBlock.children[operation.path[1]], prevText =
|
|
4536
|
-
schema:
|
|
4570
|
+
}, "text"], beforeBlock = beforeValue[operation.path[0]], prevTextChild = schema.isTextBlock({
|
|
4571
|
+
schema: schema$12
|
|
4572
|
+
}, beforeBlock) && beforeBlock.children[operation.path[1]], prevText = schema.isSpan({
|
|
4573
|
+
schema: schema$12
|
|
4537
4574
|
}, prevTextChild) && prevTextChild.text, patch = patches.diffMatchPatch(prevText || "", textChild.text, path);
|
|
4538
4575
|
return patch.value ? [patch] : [];
|
|
4539
4576
|
}
|
|
4540
|
-
function setNodePatch(
|
|
4577
|
+
function setNodePatch(schema$12, children, operation) {
|
|
4541
4578
|
if (operation.path.length === 1) {
|
|
4542
4579
|
const block = children[operation.path[0]];
|
|
4543
4580
|
if (typeof block._key != "string")
|
|
@@ -4546,13 +4583,13 @@ function setNodePatch(schema2, children, operation) {
|
|
|
4546
4583
|
...children[operation.path[0]],
|
|
4547
4584
|
...operation.newProperties
|
|
4548
4585
|
}, isUndefined__default.default);
|
|
4549
|
-
return [patches.set(fromSlateValue([setNode],
|
|
4586
|
+
return [patches.set(fromSlateValue([setNode], schema$12.block.name)[0], [{
|
|
4550
4587
|
_key: block._key
|
|
4551
4588
|
}])];
|
|
4552
4589
|
} else if (operation.path.length === 2) {
|
|
4553
4590
|
const block = children[operation.path[0]];
|
|
4554
|
-
if (
|
|
4555
|
-
schema:
|
|
4591
|
+
if (schema.isTextBlock({
|
|
4592
|
+
schema: schema$12
|
|
4556
4593
|
}, block)) {
|
|
4557
4594
|
const child = block.children[operation.path[1]];
|
|
4558
4595
|
if (child) {
|
|
@@ -4579,15 +4616,15 @@ function setNodePatch(schema2, children, operation) {
|
|
|
4579
4616
|
} else
|
|
4580
4617
|
throw new Error(`Unexpected path encountered: ${JSON.stringify(operation.path)}`);
|
|
4581
4618
|
}
|
|
4582
|
-
function insertNodePatch(
|
|
4619
|
+
function insertNodePatch(schema$12, children, operation, beforeValue) {
|
|
4583
4620
|
const block = beforeValue[operation.path[0]];
|
|
4584
4621
|
if (operation.path.length === 1) {
|
|
4585
4622
|
const position = operation.path[0] === 0 ? "before" : "after", beforeBlock = beforeValue[operation.path[0] - 1], targetKey = operation.path[0] === 0 ? block?._key : beforeBlock?._key;
|
|
4586
|
-
return targetKey ? [patches.insert([fromSlateValue([operation.node],
|
|
4623
|
+
return targetKey ? [patches.insert([fromSlateValue([operation.node], schema$12.block.name)[0]], position, [{
|
|
4587
4624
|
_key: targetKey
|
|
4588
|
-
}])] : [patches.setIfMissing(beforeValue, []), patches.insert([fromSlateValue([operation.node],
|
|
4589
|
-
} else if (
|
|
4590
|
-
schema:
|
|
4625
|
+
}])] : [patches.setIfMissing(beforeValue, []), patches.insert([fromSlateValue([operation.node], schema$12.block.name)[0]], "before", [operation.path[0]])];
|
|
4626
|
+
} else if (schema.isTextBlock({
|
|
4627
|
+
schema: schema$12
|
|
4591
4628
|
}, block) && operation.path.length === 2 && children[operation.path[0]]) {
|
|
4592
4629
|
const position = block.children.length === 0 || !block.children[operation.path[1] - 1] ? "before" : "after", node = {
|
|
4593
4630
|
...operation.node
|
|
@@ -4595,9 +4632,9 @@ function insertNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4595
4632
|
!node._type && slate.Text.isText(node) && (node._type = "span", node.marks = []);
|
|
4596
4633
|
const child = fromSlateValue([{
|
|
4597
4634
|
_key: "bogus",
|
|
4598
|
-
_type:
|
|
4635
|
+
_type: schema$12.block.name,
|
|
4599
4636
|
children: [node]
|
|
4600
|
-
}],
|
|
4637
|
+
}], schema$12.block.name)[0].children[0];
|
|
4601
4638
|
return [patches.insert([child], position, [{
|
|
4602
4639
|
_key: block._key
|
|
4603
4640
|
}, "children", block.children.length <= 1 || !block.children[operation.path[1] - 1] ? 0 : {
|
|
@@ -4606,18 +4643,18 @@ function insertNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4606
4643
|
}
|
|
4607
4644
|
return [];
|
|
4608
4645
|
}
|
|
4609
|
-
function splitNodePatch(
|
|
4646
|
+
function splitNodePatch(schema$12, children, operation, beforeValue) {
|
|
4610
4647
|
const patches$1 = [], splitBlock = children[operation.path[0]];
|
|
4611
|
-
if (!
|
|
4612
|
-
schema:
|
|
4648
|
+
if (!schema.isTextBlock({
|
|
4649
|
+
schema: schema$12
|
|
4613
4650
|
}, splitBlock))
|
|
4614
4651
|
throw new Error(`Block with path ${JSON.stringify(operation.path[0])} is not a text block and can't be split`);
|
|
4615
4652
|
if (operation.path.length === 1) {
|
|
4616
4653
|
const oldBlock = beforeValue[operation.path[0]];
|
|
4617
|
-
if (
|
|
4618
|
-
schema:
|
|
4654
|
+
if (schema.isTextBlock({
|
|
4655
|
+
schema: schema$12
|
|
4619
4656
|
}, oldBlock)) {
|
|
4620
|
-
const targetValue = fromSlateValue([children[operation.path[0] + 1]],
|
|
4657
|
+
const targetValue = fromSlateValue([children[operation.path[0] + 1]], schema$12.block.name)[0];
|
|
4621
4658
|
targetValue && (patches$1.push(patches.insert([targetValue], "after", [{
|
|
4622
4659
|
_key: splitBlock._key
|
|
4623
4660
|
}])), oldBlock.children.slice(operation.position).forEach((span) => {
|
|
@@ -4633,13 +4670,13 @@ function splitNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4633
4670
|
}
|
|
4634
4671
|
if (operation.path.length === 2) {
|
|
4635
4672
|
const splitSpan = splitBlock.children[operation.path[1]];
|
|
4636
|
-
if (
|
|
4637
|
-
schema:
|
|
4673
|
+
if (schema.isSpan({
|
|
4674
|
+
schema: schema$12
|
|
4638
4675
|
}, splitSpan)) {
|
|
4639
4676
|
const targetSpans = fromSlateValue([{
|
|
4640
4677
|
...splitBlock,
|
|
4641
4678
|
children: splitBlock.children.slice(operation.path[1] + 1, operation.path[1] + 2)
|
|
4642
|
-
}],
|
|
4679
|
+
}], schema$12.block.name)[0].children;
|
|
4643
4680
|
patches$1.push(patches.insert(targetSpans, "after", [{
|
|
4644
4681
|
_key: splitBlock._key
|
|
4645
4682
|
}, "children", {
|
|
@@ -4654,7 +4691,7 @@ function splitNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4654
4691
|
}
|
|
4655
4692
|
return patches$1;
|
|
4656
4693
|
}
|
|
4657
|
-
function removeNodePatch(
|
|
4694
|
+
function removeNodePatch(schema$12, beforeValue, operation) {
|
|
4658
4695
|
const block = beforeValue[operation.path[0]];
|
|
4659
4696
|
if (operation.path.length === 1) {
|
|
4660
4697
|
if (block && block._key)
|
|
@@ -4662,8 +4699,8 @@ function removeNodePatch(schema2, beforeValue, operation) {
|
|
|
4662
4699
|
_key: block._key
|
|
4663
4700
|
}])];
|
|
4664
4701
|
throw new Error("Block not found");
|
|
4665
|
-
} else if (
|
|
4666
|
-
schema:
|
|
4702
|
+
} else if (schema.isTextBlock({
|
|
4703
|
+
schema: schema$12
|
|
4667
4704
|
}, block) && operation.path.length === 2) {
|
|
4668
4705
|
const spanToRemove = block.children[operation.path[1]];
|
|
4669
4706
|
return spanToRemove ? block.children.filter((span) => span._key === operation.node._key).length > 1 ? (console.warn(`Multiple spans have \`_key\` ${operation.node._key}. It's ambiguous which one to remove.`, JSON.stringify(block, null, 2)), []) : [patches.unset([{
|
|
@@ -4674,11 +4711,11 @@ function removeNodePatch(schema2, beforeValue, operation) {
|
|
|
4674
4711
|
} else
|
|
4675
4712
|
return [];
|
|
4676
4713
|
}
|
|
4677
|
-
function mergeNodePatch(
|
|
4714
|
+
function mergeNodePatch(schema$12, children, operation, beforeValue) {
|
|
4678
4715
|
const patches$1 = [], block = beforeValue[operation.path[0]], updatedBlock = children[operation.path[0]];
|
|
4679
4716
|
if (operation.path.length === 1)
|
|
4680
4717
|
if (block?._key) {
|
|
4681
|
-
const newBlock = fromSlateValue([children[operation.path[0] - 1]],
|
|
4718
|
+
const newBlock = fromSlateValue([children[operation.path[0] - 1]], schema$12.block.name)[0];
|
|
4682
4719
|
patches$1.push(patches.set(newBlock, [{
|
|
4683
4720
|
_key: newBlock._key
|
|
4684
4721
|
}])), patches$1.push(patches.unset([{
|
|
@@ -4686,15 +4723,15 @@ function mergeNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4686
4723
|
}]));
|
|
4687
4724
|
} else
|
|
4688
4725
|
throw new Error("Target key not found!");
|
|
4689
|
-
else if (
|
|
4690
|
-
schema:
|
|
4691
|
-
}, block) &&
|
|
4692
|
-
schema:
|
|
4726
|
+
else if (schema.isTextBlock({
|
|
4727
|
+
schema: schema$12
|
|
4728
|
+
}, block) && schema.isTextBlock({
|
|
4729
|
+
schema: schema$12
|
|
4693
4730
|
}, updatedBlock) && operation.path.length === 2) {
|
|
4694
|
-
const updatedSpan = updatedBlock.children[operation.path[1] - 1] &&
|
|
4695
|
-
schema:
|
|
4696
|
-
}, updatedBlock.children[operation.path[1] - 1]) ? updatedBlock.children[operation.path[1] - 1] : void 0, removedSpan = block.children[operation.path[1]] &&
|
|
4697
|
-
schema:
|
|
4731
|
+
const updatedSpan = updatedBlock.children[operation.path[1] - 1] && schema.isSpan({
|
|
4732
|
+
schema: schema$12
|
|
4733
|
+
}, updatedBlock.children[operation.path[1] - 1]) ? updatedBlock.children[operation.path[1] - 1] : void 0, removedSpan = block.children[operation.path[1]] && schema.isSpan({
|
|
4734
|
+
schema: schema$12
|
|
4698
4735
|
}, block.children[operation.path[1]]) ? block.children[operation.path[1]] : void 0;
|
|
4699
4736
|
updatedSpan && (block.children.filter((span) => span._key === updatedSpan._key).length === 1 ? patches$1.push(patches.set(updatedSpan.text, [{
|
|
4700
4737
|
_key: block._key
|
|
@@ -4708,7 +4745,7 @@ function mergeNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4708
4745
|
}
|
|
4709
4746
|
return patches$1;
|
|
4710
4747
|
}
|
|
4711
|
-
function moveNodePatch(
|
|
4748
|
+
function moveNodePatch(schema$12, beforeValue, operation) {
|
|
4712
4749
|
const patches$1 = [], block = beforeValue[operation.path[0]], targetBlock = beforeValue[operation.newPath[0]];
|
|
4713
4750
|
if (!targetBlock)
|
|
4714
4751
|
return patches$1;
|
|
@@ -4716,15 +4753,15 @@ function moveNodePatch(schema2, beforeValue, operation) {
|
|
|
4716
4753
|
const position = operation.path[0] > operation.newPath[0] ? "before" : "after";
|
|
4717
4754
|
patches$1.push(patches.unset([{
|
|
4718
4755
|
_key: block._key
|
|
4719
|
-
}])), patches$1.push(patches.insert([fromSlateValue([block],
|
|
4756
|
+
}])), patches$1.push(patches.insert([fromSlateValue([block], schema$12.block.name)[0]], position, [{
|
|
4720
4757
|
_key: targetBlock._key
|
|
4721
4758
|
}]));
|
|
4722
|
-
} else if (operation.path.length === 2 &&
|
|
4723
|
-
schema:
|
|
4724
|
-
}, block) &&
|
|
4725
|
-
schema:
|
|
4759
|
+
} else if (operation.path.length === 2 && schema.isTextBlock({
|
|
4760
|
+
schema: schema$12
|
|
4761
|
+
}, block) && schema.isTextBlock({
|
|
4762
|
+
schema: schema$12
|
|
4726
4763
|
}, targetBlock)) {
|
|
4727
|
-
const child = block.children[operation.path[1]], targetChild = targetBlock.children[operation.newPath[1]], position = operation.newPath[1] === targetBlock.children.length ? "after" : "before", childToInsert = fromSlateValue([block],
|
|
4764
|
+
const child = block.children[operation.path[1]], targetChild = targetBlock.children[operation.newPath[1]], position = operation.newPath[1] === targetBlock.children.length ? "after" : "before", childToInsert = fromSlateValue([block], schema$12.block.name)[0].children[operation.path[1]];
|
|
4728
4765
|
patches$1.push(patches.unset([{
|
|
4729
4766
|
_key: block._key
|
|
4730
4767
|
}, "children", {
|
|
@@ -4881,7 +4918,7 @@ function createWithSchemaTypes({
|
|
|
4881
4918
|
editorActor
|
|
4882
4919
|
}) {
|
|
4883
4920
|
return function(editor) {
|
|
4884
|
-
editor.isTextBlock = (value) => slate.Editor.isEditor(value) ? !1 :
|
|
4921
|
+
editor.isTextBlock = (value) => slate.Editor.isEditor(value) ? !1 : schema.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => slate.Editor.isEditor(value) ? !1 : schema.isSpan(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => slate.Editor.isEditor(element) ? !1 : 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) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
|
|
4885
4922
|
const {
|
|
4886
4923
|
normalizeNode
|
|
4887
4924
|
} = editor;
|
|
@@ -5603,7 +5640,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
|
|
|
5603
5640
|
snapshot
|
|
5604
5641
|
}) => {
|
|
5605
5642
|
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
5606
|
-
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !
|
|
5643
|
+
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !schema.isTextBlock(snapshot.context, previousBlock.node) ? {
|
|
5607
5644
|
focusTextBlock,
|
|
5608
5645
|
previousBlock
|
|
5609
5646
|
} : !1;
|
|
@@ -5633,7 +5670,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
|
|
|
5633
5670
|
snapshot
|
|
5634
5671
|
}) => {
|
|
5635
5672
|
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
5636
|
-
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !
|
|
5673
|
+
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !schema.isTextBlock(snapshot.context, nextBlock.node) ? {
|
|
5637
5674
|
focusTextBlock,
|
|
5638
5675
|
nextBlock
|
|
5639
5676
|
} : !1;
|
|
@@ -6141,7 +6178,7 @@ function isAtTheBeginningOfBlock({
|
|
|
6141
6178
|
context,
|
|
6142
6179
|
block
|
|
6143
6180
|
}) {
|
|
6144
|
-
return !
|
|
6181
|
+
return !schema.isTextBlock(context, block) || !context.selection || !util_isSelectionCollapsed.isSelectionCollapsed(context.selection) ? !1 : util_sliceBlocks.getChildKeyFromSelectionPoint(context.selection.focus) === block.children[0]._key && context.selection.focus.offset === 0;
|
|
6145
6182
|
}
|
|
6146
6183
|
const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior({
|
|
6147
6184
|
on: "delete.backward",
|
|
@@ -6190,7 +6227,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
6190
6227
|
snapshot
|
|
6191
6228
|
}) => {
|
|
6192
6229
|
const focusListBlock = selector_isSelectingEntireBlocks.getFocusListBlock(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
6193
|
-
return !focusListBlock || !nextBlock || !
|
|
6230
|
+
return !focusListBlock || !nextBlock || !schema.isTextBlock(snapshot.context, nextBlock.node) || !util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
|
|
6194
6231
|
focusListBlock,
|
|
6195
6232
|
nextBlock
|
|
6196
6233
|
};
|
|
@@ -6679,7 +6716,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
6679
6716
|
context: snapshot.context,
|
|
6680
6717
|
block: previousBlock
|
|
6681
6718
|
});
|
|
6682
|
-
return
|
|
6719
|
+
return schema.isTextBlock(snapshot.context, previousBlock.node) ? {
|
|
6683
6720
|
previousBlockEndPoint,
|
|
6684
6721
|
focusTextBlock
|
|
6685
6722
|
} : !1;
|
|
@@ -6728,7 +6765,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
6728
6765
|
if (event.direction !== "forward")
|
|
6729
6766
|
return !1;
|
|
6730
6767
|
const nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
6731
|
-
return !nextBlock || !focusTextBlock || !selector_isSelectingEntireBlocks.isAtTheEndOfBlock(focusTextBlock)(snapshot) || !
|
|
6768
|
+
return !nextBlock || !focusTextBlock || !selector_isSelectingEntireBlocks.isAtTheEndOfBlock(focusTextBlock)(snapshot) || !schema.isTextBlock(snapshot.context, nextBlock.node) ? !1 : {
|
|
6732
6769
|
nextBlock
|
|
6733
6770
|
};
|
|
6734
6771
|
},
|
|
@@ -6782,7 +6819,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
6782
6819
|
}
|
|
6783
6820
|
}
|
|
6784
6821
|
});
|
|
6785
|
-
return focusChild ?
|
|
6822
|
+
return focusChild ? schema.isSpan(snapshot.context, focusChild.node) ? {
|
|
6786
6823
|
selection: {
|
|
6787
6824
|
anchor: {
|
|
6788
6825
|
path: event.at,
|
|
@@ -6931,7 +6968,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
6931
6968
|
return {
|
|
6932
6969
|
activeAnnotations: selector_isSelectingEntireBlocks.getActiveAnnotations(snapshot),
|
|
6933
6970
|
activeDecorators,
|
|
6934
|
-
textRuns: event.data.flatMap((block) =>
|
|
6971
|
+
textRuns: event.data.flatMap((block) => schema.isTextBlock(snapshot.context, block) ? [util_sliceBlocks.getTextBlockText(block)] : [])
|
|
6935
6972
|
};
|
|
6936
6973
|
}
|
|
6937
6974
|
return !1;
|
|
@@ -7462,7 +7499,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
7462
7499
|
if (!selection || util_isSelectionCollapsed.isSelectionCollapsed(selection))
|
|
7463
7500
|
return !1;
|
|
7464
7501
|
const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
7465
|
-
return !selectionStartBlock || !selectionEndBlock ? !1 : !
|
|
7502
|
+
return !selectionStartBlock || !selectionEndBlock ? !1 : !schema.isTextBlock(snapshot.context, selectionStartBlock.node) && schema.isTextBlock(snapshot.context, selectionEndBlock.node) ? {
|
|
7466
7503
|
selection
|
|
7467
7504
|
} : !1;
|
|
7468
7505
|
},
|
|
@@ -9261,7 +9298,7 @@ function validateValue(value, types, keyGenerator) {
|
|
|
9261
9298
|
}
|
|
9262
9299
|
}, !0;
|
|
9263
9300
|
}
|
|
9264
|
-
return !blk._type &&
|
|
9301
|
+
return !blk._type && schema.isTextBlock({
|
|
9265
9302
|
schema: types
|
|
9266
9303
|
}, {
|
|
9267
9304
|
...blk,
|