@portabletext/editor 2.14.3 → 2.15.0

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/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$g = require("debug"), slateDom = require("slate-dom"), util_isEmptyTextBlock = require("./_chunks-cjs/util.is-empty-text-block.cjs"), util_getTextBlockText = require("./_chunks-cjs/util.get-text-block-text.cjs"), isEqual = require("lodash/isEqual.js"), schema = require("@portabletext/schema"), selector_isActiveStyle = require("./_chunks-cjs/selector.is-active-style.cjs"), selector_getSelectionText = require("./_chunks-cjs/selector.get-selection-text.cjs"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), xstate = require("xstate"), sanityBridge = require("@portabletext/sanity-bridge"), 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"), rxjs = require("rxjs");
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$g = require("debug"), slateDom = require("slate-dom"), util_isEmptyTextBlock = require("./_chunks-cjs/util.is-empty-text-block.cjs"), util_getTextBlockText = require("./_chunks-cjs/util.get-text-block-text.cjs"), isEqual = require("lodash/isEqual.js"), schema = require("@portabletext/schema"), selector_isAtTheStartOfBlock = require("./_chunks-cjs/selector.is-at-the-start-of-block.cjs"), selector_getSelectionText = require("./_chunks-cjs/selector.get-selection-text.cjs"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), xstate = require("xstate"), sanityBridge = require("@portabletext/sanity-bridge"), 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"), rxjs = require("rxjs");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
@@ -687,7 +687,7 @@ function getDragSelection({
687
687
  snapshot
688
688
  }) {
689
689
  let dragSelection = eventSelection;
690
- if (selector_isActiveStyle.getFocusInlineObject({
690
+ if (selector_isAtTheStartOfBlock.getFocusInlineObject({
691
691
  ...snapshot,
692
692
  context: {
693
693
  ...snapshot.context,
@@ -723,9 +723,9 @@ function getDragSelection({
723
723
  block: draggedTextBlock
724
724
  })
725
725
  });
726
- const selectedBlocks = selector_isActiveStyle.getSelectedBlocks(snapshot);
726
+ const selectedBlocks = selector_isAtTheStartOfBlock.getSelectedBlocks(snapshot);
727
727
  if (snapshot.context.selection && selector_getSelectionText.isSelectionExpanded(snapshot) && selectedBlocks.length > 1) {
728
- const selectionStartBlock = selector_isActiveStyle.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isActiveStyle.getSelectionEndBlock(snapshot);
728
+ const selectionStartBlock = selector_isAtTheStartOfBlock.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isAtTheStartOfBlock.getSelectionEndBlock(snapshot);
729
729
  if (!selectionStartBlock || !selectionEndBlock)
730
730
  return dragSelection;
731
731
  const selectionStartPoint = util_getTextBlockText.getBlockStartPoint({
@@ -735,7 +735,7 @@ function getDragSelection({
735
735
  context: snapshot.context,
736
736
  block: selectionEndBlock
737
737
  });
738
- selector_isActiveStyle.isOverlappingSelection(eventSelection)({
738
+ selector_isAtTheStartOfBlock.isOverlappingSelection(eventSelection)({
739
739
  ...snapshot,
740
740
  context: {
741
741
  ...snapshot.context,
@@ -778,13 +778,13 @@ function createCoreBlockElementBehaviorsConfig({
778
778
  eventSelection: dragOrigin.selection,
779
779
  snapshot
780
780
  });
781
- return selector_isActiveStyle.getSelectedBlocks({
781
+ return selector_isAtTheStartOfBlock.getSelectedBlocks({
782
782
  ...snapshot,
783
783
  context: {
784
784
  ...snapshot.context,
785
785
  selection: dragSelection
786
786
  }
787
- }).some((draggedBlock) => draggedBlock.node._key === key) ? !1 : selector_isActiveStyle.isSelectingEntireBlocks({
787
+ }).some((draggedBlock) => draggedBlock.node._key === key) ? !1 : selector_isAtTheStartOfBlock.isSelectingEntireBlocks({
788
788
  ...snapshot,
789
789
  context: {
790
790
  ...snapshot.context,
@@ -1263,7 +1263,7 @@ function RenderSpan(props) {
1263
1263
  offset: props.leaf.text.length
1264
1264
  }
1265
1265
  } : null;
1266
- return selector_isActiveStyle.isOverlappingSelection(spanSelection)(snapshot_0);
1266
+ return selector_isAtTheStartOfBlock.isOverlappingSelection(spanSelection)(snapshot_0);
1267
1267
  }, $[3] = props.children.props.parent, $[4] = props.leaf._key, $[5] = props.leaf.text, $[6] = slateEditor, $[7] = t1) : t1 = $[7];
1268
1268
  const selected = react.useSelector(editorActor, t1), parent_0 = props.children.props.parent, block_0 = parent_0 && slateEditor.isTextBlock(parent_0) ? parent_0 : void 0;
1269
1269
  let t2;
@@ -1966,7 +1966,7 @@ function validateSelection(slateEditor, editorElement) {
1966
1966
  }
1967
1967
  }
1968
1968
  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(), debug$d = debugWithName("component:Editable"), PortableTextEditable = React.forwardRef(function(props, forwardedRef) {
1969
- const $ = reactCompilerRuntime.c(174);
1969
+ const $ = reactCompilerRuntime.c(176);
1970
1970
  let hotkeys, onBeforeInput, onBlur, onClick, onCopy, onCut, onDrag, onDragEnd, onDragEnter, onDragLeave, onDragOver, onDragStart, onDrop, onFocus, onPaste, propsSelection, rangeDecorations, renderAnnotation, renderBlock, renderChild, renderDecorator, renderListItem, renderPlaceholder, renderStyle, restProps, scrollSelectionIntoView, spellCheck;
1971
1971
  $[0] !== props ? ({
1972
1972
  hotkeys,
@@ -2009,47 +2009,50 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2009
2009
  $[30] !== rangeDecorations ? (t1 = rangeDecorations ?? [], $[30] = rangeDecorations, $[31] = t1) : t1 = $[31];
2010
2010
  let t2;
2011
2011
  $[32] !== editorActor ? (t2 = editorActor.getSnapshot(), $[32] = editorActor, $[33] = t2) : t2 = $[33];
2012
- const t3 = !editorActor.getSnapshot().matches({
2013
- setup: "setting up"
2014
- });
2012
+ const t3 = t2.context.schema;
2015
2013
  let t4;
2016
- $[34] !== readOnly || $[35] !== slateEditor || $[36] !== t1 || $[37] !== t2.context.schema || $[38] !== t3 ? (t4 = {
2014
+ $[34] !== editorActor ? (t4 = editorActor.getSnapshot().matches({
2015
+ setup: "setting up"
2016
+ }), $[34] = editorActor, $[35] = t4) : t4 = $[35];
2017
+ const t5 = !t4;
2018
+ let t6;
2019
+ $[36] !== readOnly || $[37] !== slateEditor || $[38] !== t1 || $[39] !== t2.context.schema || $[40] !== t5 ? (t6 = {
2017
2020
  input: {
2018
2021
  rangeDecorations: t1,
2019
2022
  readOnly,
2020
- schema: t2.context.schema,
2023
+ schema: t3,
2021
2024
  slateEditor,
2022
- skipSetup: t3
2025
+ skipSetup: t5
2023
2026
  }
2024
- }, $[34] = readOnly, $[35] = slateEditor, $[36] = t1, $[37] = t2.context.schema, $[38] = t3, $[39] = t4) : t4 = $[39];
2025
- const rangeDecorationsActor = react.useActorRef(rangeDecorationsMachine, t4), decorate = react.useSelector(rangeDecorationsActor, _temp2);
2026
- let t5, t6;
2027
- $[40] !== rangeDecorationsActor || $[41] !== readOnly ? (t5 = () => {
2027
+ }, $[36] = readOnly, $[37] = slateEditor, $[38] = t1, $[39] = t2.context.schema, $[40] = t5, $[41] = t6) : t6 = $[41];
2028
+ const rangeDecorationsActor = react.useActorRef(rangeDecorationsMachine, t6), decorate = react.useSelector(rangeDecorationsActor, _temp2);
2029
+ let t7, t8;
2030
+ $[42] !== rangeDecorationsActor || $[43] !== readOnly ? (t7 = () => {
2028
2031
  rangeDecorationsActor.send({
2029
2032
  type: "update read only",
2030
2033
  readOnly
2031
2034
  });
2032
- }, t6 = [rangeDecorationsActor, readOnly], $[40] = rangeDecorationsActor, $[41] = readOnly, $[42] = t5, $[43] = t6) : (t5 = $[42], t6 = $[43]), React.useEffect(t5, t6);
2033
- let t7, t8;
2034
- $[44] !== rangeDecorations || $[45] !== rangeDecorationsActor ? (t7 = () => {
2035
+ }, t8 = [rangeDecorationsActor, readOnly], $[42] = rangeDecorationsActor, $[43] = readOnly, $[44] = t7, $[45] = t8) : (t7 = $[44], t8 = $[45]), React.useEffect(t7, t8);
2036
+ let t10, t9;
2037
+ $[46] !== rangeDecorations || $[47] !== rangeDecorationsActor ? (t9 = () => {
2035
2038
  rangeDecorationsActor.send({
2036
2039
  type: "range decorations updated",
2037
2040
  rangeDecorations: rangeDecorations ?? []
2038
2041
  });
2039
- }, t8 = [rangeDecorationsActor, rangeDecorations], $[44] = rangeDecorations, $[45] = rangeDecorationsActor, $[46] = t7, $[47] = t8) : (t7 = $[46], t8 = $[47]), React.useEffect(t7, t8);
2042
+ }, t10 = [rangeDecorationsActor, rangeDecorations], $[46] = rangeDecorations, $[47] = rangeDecorationsActor, $[48] = t10, $[49] = t9) : (t10 = $[48], t9 = $[49]), React.useEffect(t9, t10);
2040
2043
  bb0: {
2041
2044
  if (readOnly)
2042
2045
  break bb0;
2043
2046
  createWithHotkeys(editorActor, portableTextEditor, hotkeys)(slateEditor);
2044
2047
  }
2045
- let t10;
2046
- $[48] !== readOnly || $[49] !== renderBlock || $[50] !== renderChild || $[51] !== renderListItem || $[52] !== renderStyle || $[53] !== spellCheck ? (t10 = (eProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderElement, { ...eProps, readOnly, renderBlock, renderChild, renderListItem, renderStyle, spellCheck }), $[48] = readOnly, $[49] = renderBlock, $[50] = renderChild, $[51] = renderListItem, $[52] = renderStyle, $[53] = spellCheck, $[54] = t10) : t10 = $[54];
2047
- const renderElement = t10;
2048
- let t11;
2049
- $[55] !== readOnly || $[56] !== renderAnnotation || $[57] !== renderChild || $[58] !== renderDecorator || $[59] !== renderPlaceholder ? (t11 = (leafProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderLeaf, { ...leafProps, readOnly, renderAnnotation, renderChild, renderDecorator, renderPlaceholder }), $[55] = readOnly, $[56] = renderAnnotation, $[57] = renderChild, $[58] = renderDecorator, $[59] = renderPlaceholder, $[60] = t11) : t11 = $[60];
2050
- const renderLeaf = t11, renderText = _temp3;
2051
2048
  let t12;
2052
- $[61] !== editorActor || $[62] !== propsSelection || $[63] !== slateEditor ? (t12 = () => {
2049
+ $[50] !== readOnly || $[51] !== renderBlock || $[52] !== renderChild || $[53] !== renderListItem || $[54] !== renderStyle || $[55] !== spellCheck ? (t12 = (eProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderElement, { ...eProps, readOnly, renderBlock, renderChild, renderListItem, renderStyle, spellCheck }), $[50] = readOnly, $[51] = renderBlock, $[52] = renderChild, $[53] = renderListItem, $[54] = renderStyle, $[55] = spellCheck, $[56] = t12) : t12 = $[56];
2050
+ const renderElement = t12;
2051
+ let t13;
2052
+ $[57] !== readOnly || $[58] !== renderAnnotation || $[59] !== renderChild || $[60] !== renderDecorator || $[61] !== renderPlaceholder ? (t13 = (leafProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderLeaf, { ...leafProps, readOnly, renderAnnotation, renderChild, renderDecorator, renderPlaceholder }), $[57] = readOnly, $[58] = renderAnnotation, $[59] = renderChild, $[60] = renderDecorator, $[61] = renderPlaceholder, $[62] = t13) : t13 = $[62];
2053
+ const renderLeaf = t13, renderText = _temp3;
2054
+ let t14;
2055
+ $[63] !== editorActor || $[64] !== propsSelection || $[65] !== slateEditor ? (t14 = () => {
2053
2056
  if (propsSelection) {
2054
2057
  debug$d(`Selection from props ${JSON.stringify(propsSelection)}`);
2055
2058
  const normalizedSelection = normalizeSelection(propsSelection, fromSlateValue(slateEditor.children, editorActor.getSnapshot().context.schema.block.name));
@@ -2069,10 +2072,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2069
2072
  }), slateEditor.onChange());
2070
2073
  }
2071
2074
  }
2072
- }, $[61] = editorActor, $[62] = propsSelection, $[63] = slateEditor, $[64] = t12) : t12 = $[64];
2073
- const restoreSelectionFromProps = t12;
2074
- let t13, t14;
2075
- $[65] !== editorActor || $[66] !== rangeDecorationsActor || $[67] !== restoreSelectionFromProps ? (t13 = () => {
2075
+ }, $[63] = editorActor, $[64] = propsSelection, $[65] = slateEditor, $[66] = t14) : t14 = $[66];
2076
+ const restoreSelectionFromProps = t14;
2077
+ let t15, t16;
2078
+ $[67] !== editorActor || $[68] !== rangeDecorationsActor || $[69] !== restoreSelectionFromProps ? (t15 = () => {
2076
2079
  const onReady = editorActor.on("ready", () => {
2077
2080
  rangeDecorationsActor.send({
2078
2081
  type: "ready"
@@ -2085,13 +2088,13 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2085
2088
  return () => {
2086
2089
  onReady.unsubscribe(), onInvalidValue.unsubscribe(), onValueChanged.unsubscribe();
2087
2090
  };
2088
- }, t14 = [rangeDecorationsActor, editorActor, restoreSelectionFromProps], $[65] = editorActor, $[66] = rangeDecorationsActor, $[67] = restoreSelectionFromProps, $[68] = t13, $[69] = t14) : (t13 = $[68], t14 = $[69]), React.useEffect(t13, t14);
2089
- let t15, t16;
2090
- $[70] !== hasInvalidValue || $[71] !== propsSelection || $[72] !== restoreSelectionFromProps ? (t15 = () => {
2091
+ }, t16 = [rangeDecorationsActor, editorActor, restoreSelectionFromProps], $[67] = editorActor, $[68] = rangeDecorationsActor, $[69] = restoreSelectionFromProps, $[70] = t15, $[71] = t16) : (t15 = $[70], t16 = $[71]), React.useEffect(t15, t16);
2092
+ let t17, t18;
2093
+ $[72] !== hasInvalidValue || $[73] !== propsSelection || $[74] !== restoreSelectionFromProps ? (t17 = () => {
2091
2094
  propsSelection && !hasInvalidValue && restoreSelectionFromProps();
2092
- }, t16 = [hasInvalidValue, propsSelection, restoreSelectionFromProps], $[70] = hasInvalidValue, $[71] = propsSelection, $[72] = restoreSelectionFromProps, $[73] = t15, $[74] = t16) : (t15 = $[73], t16 = $[74]), React.useEffect(t15, t16);
2093
- let t17;
2094
- $[75] !== editorActor || $[76] !== onCopy || $[77] !== slateEditor ? (t17 = (event) => {
2095
+ }, t18 = [hasInvalidValue, propsSelection, restoreSelectionFromProps], $[72] = hasInvalidValue, $[73] = propsSelection, $[74] = restoreSelectionFromProps, $[75] = t17, $[76] = t18) : (t17 = $[75], t18 = $[76]), React.useEffect(t17, t18);
2096
+ let t19;
2097
+ $[77] !== editorActor || $[78] !== onCopy || $[79] !== slateEditor ? (t19 = (event) => {
2095
2098
  if (onCopy)
2096
2099
  onCopy(event) !== void 0 && event.preventDefault();
2097
2100
  else if (event.nativeEvent.clipboardData) {
@@ -2120,10 +2123,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2120
2123
  nativeEvent: event
2121
2124
  });
2122
2125
  }
2123
- }, $[75] = editorActor, $[76] = onCopy, $[77] = slateEditor, $[78] = t17) : t17 = $[78];
2124
- const handleCopy = t17;
2125
- let t18;
2126
- $[79] !== editorActor || $[80] !== onCut || $[81] !== slateEditor ? (t18 = (event_0) => {
2126
+ }, $[77] = editorActor, $[78] = onCopy, $[79] = slateEditor, $[80] = t19) : t19 = $[80];
2127
+ const handleCopy = t19;
2128
+ let t20;
2129
+ $[81] !== editorActor || $[82] !== onCut || $[83] !== slateEditor ? (t20 = (event_0) => {
2127
2130
  if (onCut)
2128
2131
  onCut(event_0) !== void 0 && event_0.preventDefault();
2129
2132
  else if (event_0.nativeEvent.clipboardData) {
@@ -2148,10 +2151,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2148
2151
  nativeEvent: event_0
2149
2152
  });
2150
2153
  }
2151
- }, $[79] = editorActor, $[80] = onCut, $[81] = slateEditor, $[82] = t18) : t18 = $[82];
2152
- const handleCut = t18;
2153
- let t19;
2154
- $[83] !== editorActor || $[84] !== onPaste || $[85] !== portableTextEditor || $[86] !== relayActor || $[87] !== slateEditor ? (t19 = (event_1) => {
2154
+ }, $[81] = editorActor, $[82] = onCut, $[83] = slateEditor, $[84] = t20) : t20 = $[84];
2155
+ const handleCut = t20;
2156
+ let t21;
2157
+ $[85] !== editorActor || $[86] !== onPaste || $[87] !== portableTextEditor || $[88] !== relayActor || $[89] !== slateEditor ? (t21 = (event_1) => {
2155
2158
  const value = fromSlateValue(slateEditor.children, editorActor.getSnapshot().context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(slateEditor)), path = (slateEditor.selection ? slateRangeToSelection({
2156
2159
  schema: editorActor.getSnapshot().context.schema,
2157
2160
  editor: slateEditor,
@@ -2235,18 +2238,18 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2235
2238
  });
2236
2239
  }
2237
2240
  debug$d("No result from custom paste handler, pasting normally");
2238
- }, $[83] = editorActor, $[84] = onPaste, $[85] = portableTextEditor, $[86] = relayActor, $[87] = slateEditor, $[88] = t19) : t19 = $[88];
2239
- const handlePaste = t19;
2240
- let t20;
2241
- $[89] !== editorActor || $[90] !== onFocus || $[91] !== relayActor || $[92] !== slateEditor ? (t20 = (event_2) => {
2241
+ }, $[85] = editorActor, $[86] = onPaste, $[87] = portableTextEditor, $[88] = relayActor, $[89] = slateEditor, $[90] = t21) : t21 = $[90];
2242
+ const handlePaste = t21;
2243
+ let t22;
2244
+ $[91] !== editorActor || $[92] !== onFocus || $[93] !== relayActor || $[94] !== slateEditor ? (t22 = (event_2) => {
2242
2245
  onFocus && onFocus(event_2), event_2.isDefaultPrevented() || (relayActor.send({
2243
2246
  type: "focused",
2244
2247
  event: event_2
2245
2248
  }), !slateEditor.selection && isEqualToEmptyEditor(slateEditor.children, editorActor.getSnapshot().context.schema) && (slate.Transforms.select(slateEditor, slate.Editor.start(slateEditor, [])), slateEditor.onChange()));
2246
- }, $[89] = editorActor, $[90] = onFocus, $[91] = relayActor, $[92] = slateEditor, $[93] = t20) : t20 = $[93];
2247
- const handleOnFocus = t20;
2248
- let t21;
2249
- $[94] !== editorActor || $[95] !== onClick || $[96] !== slateEditor ? (t21 = (event_3) => {
2249
+ }, $[91] = editorActor, $[92] = onFocus, $[93] = relayActor, $[94] = slateEditor, $[95] = t22) : t22 = $[95];
2250
+ const handleOnFocus = t22;
2251
+ let t23;
2252
+ $[96] !== editorActor || $[97] !== onClick || $[98] !== slateEditor ? (t23 = (event_3) => {
2250
2253
  if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
2251
2254
  return;
2252
2255
  const position_3 = getEventPosition({
@@ -2263,23 +2266,23 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2263
2266
  editor: slateEditor,
2264
2267
  nativeEvent: event_3
2265
2268
  });
2266
- }, $[94] = editorActor, $[95] = onClick, $[96] = slateEditor, $[97] = t21) : t21 = $[97];
2267
- const handleClick = t21;
2268
- let t22;
2269
- $[98] !== onBlur || $[99] !== relayActor ? (t22 = (event_4) => {
2269
+ }, $[96] = editorActor, $[97] = onClick, $[98] = slateEditor, $[99] = t23) : t23 = $[99];
2270
+ const handleClick = t23;
2271
+ let t24;
2272
+ $[100] !== onBlur || $[101] !== relayActor ? (t24 = (event_4) => {
2270
2273
  onBlur && onBlur(event_4), event_4.isPropagationStopped() || relayActor.send({
2271
2274
  type: "blurred",
2272
2275
  event: event_4
2273
2276
  });
2274
- }, $[98] = onBlur, $[99] = relayActor, $[100] = t22) : t22 = $[100];
2275
- const handleOnBlur = t22;
2276
- let t23;
2277
- $[101] !== onBeforeInput ? (t23 = (event_5) => {
2277
+ }, $[100] = onBlur, $[101] = relayActor, $[102] = t24) : t24 = $[102];
2278
+ const handleOnBlur = t24;
2279
+ let t25;
2280
+ $[103] !== onBeforeInput ? (t25 = (event_5) => {
2278
2281
  onBeforeInput && onBeforeInput(event_5);
2279
- }, $[101] = onBeforeInput, $[102] = t23) : t23 = $[102];
2280
- const handleOnBeforeInput = t23;
2281
- let t24;
2282
- $[103] !== editorActor || $[104] !== props || $[105] !== slateEditor ? (t24 = (event_6) => {
2282
+ }, $[103] = onBeforeInput, $[104] = t25) : t25 = $[104];
2283
+ const handleOnBeforeInput = t25;
2284
+ let t26;
2285
+ $[105] !== editorActor || $[106] !== props || $[107] !== slateEditor ? (t26 = (event_6) => {
2283
2286
  props.onKeyDown && props.onKeyDown(event_6), event_6.isDefaultPrevented() || slateEditor.pteWithHotKeys(event_6), event_6.isDefaultPrevented() || editorActor.send({
2284
2287
  type: "behavior event",
2285
2288
  behaviorEvent: {
@@ -2296,10 +2299,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2296
2299
  editor: slateEditor,
2297
2300
  nativeEvent: event_6
2298
2301
  });
2299
- }, $[103] = editorActor, $[104] = props, $[105] = slateEditor, $[106] = t24) : t24 = $[106];
2300
- const handleKeyDown = t24;
2301
- let t25;
2302
- $[107] !== editorActor || $[108] !== props || $[109] !== slateEditor ? (t25 = (event_7) => {
2302
+ }, $[105] = editorActor, $[106] = props, $[107] = slateEditor, $[108] = t26) : t26 = $[108];
2303
+ const handleKeyDown = t26;
2304
+ let t27;
2305
+ $[109] !== editorActor || $[110] !== props || $[111] !== slateEditor ? (t27 = (event_7) => {
2303
2306
  props.onKeyUp && props.onKeyUp(event_7), event_7.isDefaultPrevented() || editorActor.send({
2304
2307
  type: "behavior event",
2305
2308
  behaviorEvent: {
@@ -2316,26 +2319,26 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2316
2319
  editor: slateEditor,
2317
2320
  nativeEvent: event_7
2318
2321
  });
2319
- }, $[107] = editorActor, $[108] = props, $[109] = slateEditor, $[110] = t25) : t25 = $[110];
2320
- const handleKeyUp = t25;
2321
- let t26;
2322
+ }, $[109] = editorActor, $[110] = props, $[111] = slateEditor, $[112] = t27) : t27 = $[112];
2323
+ const handleKeyUp = t27;
2324
+ let t28;
2322
2325
  bb1: {
2323
2326
  if (scrollSelectionIntoView === void 0) {
2324
- t26 = void 0;
2327
+ t28 = void 0;
2325
2328
  break bb1;
2326
2329
  }
2327
2330
  if (scrollSelectionIntoView === null) {
2328
- t26 = noop__default.default;
2331
+ t28 = noop__default.default;
2329
2332
  break bb1;
2330
2333
  }
2331
- let t272;
2332
- $[111] !== portableTextEditor || $[112] !== scrollSelectionIntoView ? (t272 = (_editor, domRange) => {
2334
+ let t292;
2335
+ $[113] !== portableTextEditor || $[114] !== scrollSelectionIntoView ? (t292 = (_editor, domRange) => {
2333
2336
  scrollSelectionIntoView(portableTextEditor, domRange);
2334
- }, $[111] = portableTextEditor, $[112] = scrollSelectionIntoView, $[113] = t272) : t272 = $[113], t26 = t272;
2337
+ }, $[113] = portableTextEditor, $[114] = scrollSelectionIntoView, $[115] = t292) : t292 = $[115], t28 = t292;
2335
2338
  }
2336
- const scrollSelectionIntoViewToSlate = t26;
2337
- let t27, t28;
2338
- $[114] !== editorActor || $[115] !== slateEditor ? (t27 = () => {
2339
+ const scrollSelectionIntoViewToSlate = t28;
2340
+ let t29, t30;
2341
+ $[116] !== editorActor || $[117] !== slateEditor ? (t29 = () => {
2339
2342
  const window2 = slateReact.ReactEditor.getWindow(slateEditor), onDragEnd_0 = () => {
2340
2343
  editorActor.send({
2341
2344
  type: "dragend"
@@ -2348,9 +2351,9 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2348
2351
  return window2.document.addEventListener("dragend", onDragEnd_0), window2.document.addEventListener("drop", onDrop_0), () => {
2349
2352
  window2.document.removeEventListener("dragend", onDragEnd_0), window2.document.removeEventListener("drop", onDrop_0);
2350
2353
  };
2351
- }, t28 = [slateEditor, editorActor], $[114] = editorActor, $[115] = slateEditor, $[116] = t27, $[117] = t28) : (t27 = $[116], t28 = $[117]), React.useEffect(t27, t28);
2352
- let t29;
2353
- $[118] !== editorActor || $[119] !== onDragStart || $[120] !== slateEditor ? (t29 = (event_8) => {
2354
+ }, t30 = [slateEditor, editorActor], $[116] = editorActor, $[117] = slateEditor, $[118] = t29, $[119] = t30) : (t29 = $[118], t30 = $[119]), React.useEffect(t29, t30);
2355
+ let t31;
2356
+ $[120] !== editorActor || $[121] !== onDragStart || $[122] !== slateEditor ? (t31 = (event_8) => {
2354
2357
  if (onDragStart?.(event_8), event_8.isDefaultPrevented() || event_8.isPropagationStopped())
2355
2358
  return;
2356
2359
  const position_4 = getEventPosition({
@@ -2378,10 +2381,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2378
2381
  },
2379
2382
  editor: slateEditor
2380
2383
  }), !0;
2381
- }, $[118] = editorActor, $[119] = onDragStart, $[120] = slateEditor, $[121] = t29) : t29 = $[121];
2382
- const handleDragStart = t29;
2383
- let t30;
2384
- $[122] !== editorActor || $[123] !== onDrag || $[124] !== slateEditor ? (t30 = (event_9) => {
2384
+ }, $[120] = editorActor, $[121] = onDragStart, $[122] = slateEditor, $[123] = t31) : t31 = $[123];
2385
+ const handleDragStart = t31;
2386
+ let t32;
2387
+ $[124] !== editorActor || $[125] !== onDrag || $[126] !== slateEditor ? (t32 = (event_9) => {
2385
2388
  if (onDrag?.(event_9), !(event_9.isDefaultPrevented() || event_9.isPropagationStopped() || !getEventPosition({
2386
2389
  editorActor,
2387
2390
  slateEditor,
@@ -2397,10 +2400,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2397
2400
  },
2398
2401
  editor: slateEditor
2399
2402
  }), !0;
2400
- }, $[122] = editorActor, $[123] = onDrag, $[124] = slateEditor, $[125] = t30) : t30 = $[125];
2401
- const handleDrag = t30;
2402
- let t31;
2403
- $[126] !== editorActor || $[127] !== onDragEnd || $[128] !== slateEditor ? (t31 = (event_10) => {
2403
+ }, $[124] = editorActor, $[125] = onDrag, $[126] = slateEditor, $[127] = t32) : t32 = $[127];
2404
+ const handleDrag = t32;
2405
+ let t33;
2406
+ $[128] !== editorActor || $[129] !== onDragEnd || $[130] !== slateEditor ? (t33 = (event_10) => {
2404
2407
  if (onDragEnd?.(event_10), !(event_10.isDefaultPrevented() || event_10.isPropagationStopped()))
2405
2408
  return editorActor.send({
2406
2409
  type: "behavior event",
@@ -2412,10 +2415,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2412
2415
  },
2413
2416
  editor: slateEditor
2414
2417
  }), !0;
2415
- }, $[126] = editorActor, $[127] = onDragEnd, $[128] = slateEditor, $[129] = t31) : t31 = $[129];
2416
- const handleDragEnd = t31;
2417
- let t32;
2418
- $[130] !== editorActor || $[131] !== onDragEnter || $[132] !== slateEditor ? (t32 = (event_11) => {
2418
+ }, $[128] = editorActor, $[129] = onDragEnd, $[130] = slateEditor, $[131] = t33) : t33 = $[131];
2419
+ const handleDragEnd = t33;
2420
+ let t34;
2421
+ $[132] !== editorActor || $[133] !== onDragEnter || $[134] !== slateEditor ? (t34 = (event_11) => {
2419
2422
  if (onDragEnter?.(event_11), event_11.isDefaultPrevented() || event_11.isPropagationStopped())
2420
2423
  return;
2421
2424
  const position_6 = getEventPosition({
@@ -2435,10 +2438,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2435
2438
  },
2436
2439
  editor: slateEditor
2437
2440
  }), !0;
2438
- }, $[130] = editorActor, $[131] = onDragEnter, $[132] = slateEditor, $[133] = t32) : t32 = $[133];
2439
- const handleDragEnter = t32;
2440
- let t33;
2441
- $[134] !== editorActor || $[135] !== onDragOver || $[136] !== slateEditor ? (t33 = (event_12) => {
2441
+ }, $[132] = editorActor, $[133] = onDragEnter, $[134] = slateEditor, $[135] = t34) : t34 = $[135];
2442
+ const handleDragEnter = t34;
2443
+ let t35;
2444
+ $[136] !== editorActor || $[137] !== onDragOver || $[138] !== slateEditor ? (t35 = (event_12) => {
2442
2445
  if (onDragOver?.(event_12), event_12.isDefaultPrevented() || event_12.isPropagationStopped())
2443
2446
  return;
2444
2447
  const position_7 = getEventPosition({
@@ -2460,10 +2463,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2460
2463
  editor: slateEditor,
2461
2464
  nativeEvent: event_12
2462
2465
  }), !0;
2463
- }, $[134] = editorActor, $[135] = onDragOver, $[136] = slateEditor, $[137] = t33) : t33 = $[137];
2464
- const handleDragOver = t33;
2465
- let t34;
2466
- $[138] !== editorActor || $[139] !== onDrop || $[140] !== slateEditor ? (t34 = (event_13) => {
2466
+ }, $[136] = editorActor, $[137] = onDragOver, $[138] = slateEditor, $[139] = t35) : t35 = $[139];
2467
+ const handleDragOver = t35;
2468
+ let t36;
2469
+ $[140] !== editorActor || $[141] !== onDrop || $[142] !== slateEditor ? (t36 = (event_13) => {
2467
2470
  if (onDrop?.(event_13), event_13.isDefaultPrevented() || event_13.isPropagationStopped())
2468
2471
  return;
2469
2472
  const position_8 = getEventPosition({
@@ -2488,10 +2491,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2488
2491
  editor: slateEditor,
2489
2492
  nativeEvent: event_13
2490
2493
  }), !0;
2491
- }, $[138] = editorActor, $[139] = onDrop, $[140] = slateEditor, $[141] = t34) : t34 = $[141];
2492
- const handleDrop = t34;
2493
- let t35;
2494
- $[142] !== editorActor || $[143] !== onDragLeave || $[144] !== slateEditor ? (t35 = (event_14) => {
2494
+ }, $[140] = editorActor, $[141] = onDrop, $[142] = slateEditor, $[143] = t36) : t36 = $[143];
2495
+ const handleDrop = t36;
2496
+ let t37;
2497
+ $[144] !== editorActor || $[145] !== onDragLeave || $[146] !== slateEditor ? (t37 = (event_14) => {
2495
2498
  if (onDragLeave?.(event_14), !(event_14.isDefaultPrevented() || event_14.isPropagationStopped() || !getEventPosition({
2496
2499
  editorActor,
2497
2500
  slateEditor,
@@ -2507,10 +2510,10 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2507
2510
  },
2508
2511
  editor: slateEditor
2509
2512
  }), !0;
2510
- }, $[142] = editorActor, $[143] = onDragLeave, $[144] = slateEditor, $[145] = t35) : t35 = $[145];
2511
- const handleDragLeave = t35;
2512
- let t36;
2513
- $[146] !== forwardedRef || $[147] !== validateSelectionActor ? (t36 = (editorElement) => {
2513
+ }, $[144] = editorActor, $[145] = onDragLeave, $[146] = slateEditor, $[147] = t37) : t37 = $[147];
2514
+ const handleDragLeave = t37;
2515
+ let t38;
2516
+ $[148] !== forwardedRef || $[149] !== validateSelectionActor ? (t38 = (editorElement) => {
2514
2517
  if (typeof forwardedRef == "function" ? forwardedRef(editorElement) : forwardedRef && (forwardedRef.current = editorElement), editorElement) {
2515
2518
  const mutationObserver = new MutationObserver(() => {
2516
2519
  validateSelectionActor.send({
@@ -2528,12 +2531,12 @@ const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE
2528
2531
  mutationObserver.disconnect();
2529
2532
  };
2530
2533
  }
2531
- }, $[146] = forwardedRef, $[147] = validateSelectionActor, $[148] = t36) : t36 = $[148];
2532
- const callbackRef = t36;
2534
+ }, $[148] = forwardedRef, $[149] = validateSelectionActor, $[150] = t38) : t38 = $[150];
2535
+ const callbackRef = t38;
2533
2536
  if (!portableTextEditor)
2534
2537
  return null;
2535
- let t37;
2536
- return $[149] !== callbackRef || $[150] !== decorate || $[151] !== handleClick || $[152] !== handleCopy || $[153] !== handleCut || $[154] !== handleDrag || $[155] !== handleDragEnd || $[156] !== handleDragEnter || $[157] !== handleDragLeave || $[158] !== handleDragOver || $[159] !== handleDragStart || $[160] !== handleDrop || $[161] !== handleKeyDown || $[162] !== handleKeyUp || $[163] !== handleOnBeforeInput || $[164] !== handleOnBlur || $[165] !== handleOnFocus || $[166] !== handlePaste || $[167] !== hasInvalidValue || $[168] !== readOnly || $[169] !== renderElement || $[170] !== renderLeaf || $[171] !== restProps || $[172] !== scrollSelectionIntoViewToSlate ? (t37 = hasInvalidValue ? null : /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editable, { ...restProps, ref: callbackRef, "data-read-only": readOnly, autoFocus: !1, className: restProps.className || "pt-editable", decorate, onBlur: handleOnBlur, onCopy: handleCopy, onCut: handleCut, onClick: handleClick, onDOMBeforeInput: handleOnBeforeInput, onDragStart: handleDragStart, onDrag: handleDrag, onDragEnd: handleDragEnd, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDrop: handleDrop, onDragLeave: handleDragLeave, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onPaste: handlePaste, readOnly, renderPlaceholder: void 0, renderElement, renderLeaf, renderText, scrollSelectionIntoView: scrollSelectionIntoViewToSlate }), $[149] = callbackRef, $[150] = decorate, $[151] = handleClick, $[152] = handleCopy, $[153] = handleCut, $[154] = handleDrag, $[155] = handleDragEnd, $[156] = handleDragEnter, $[157] = handleDragLeave, $[158] = handleDragOver, $[159] = handleDragStart, $[160] = handleDrop, $[161] = handleKeyDown, $[162] = handleKeyUp, $[163] = handleOnBeforeInput, $[164] = handleOnBlur, $[165] = handleOnFocus, $[166] = handlePaste, $[167] = hasInvalidValue, $[168] = readOnly, $[169] = renderElement, $[170] = renderLeaf, $[171] = restProps, $[172] = scrollSelectionIntoViewToSlate, $[173] = t37) : t37 = $[173], t37;
2538
+ let t39;
2539
+ return $[151] !== callbackRef || $[152] !== decorate || $[153] !== handleClick || $[154] !== handleCopy || $[155] !== handleCut || $[156] !== handleDrag || $[157] !== handleDragEnd || $[158] !== handleDragEnter || $[159] !== handleDragLeave || $[160] !== handleDragOver || $[161] !== handleDragStart || $[162] !== handleDrop || $[163] !== handleKeyDown || $[164] !== handleKeyUp || $[165] !== handleOnBeforeInput || $[166] !== handleOnBlur || $[167] !== handleOnFocus || $[168] !== handlePaste || $[169] !== hasInvalidValue || $[170] !== readOnly || $[171] !== renderElement || $[172] !== renderLeaf || $[173] !== restProps || $[174] !== scrollSelectionIntoViewToSlate ? (t39 = hasInvalidValue ? null : /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editable, { ...restProps, ref: callbackRef, "data-read-only": readOnly, autoFocus: !1, className: restProps.className || "pt-editable", decorate, onBlur: handleOnBlur, onCopy: handleCopy, onCut: handleCut, onClick: handleClick, onDOMBeforeInput: handleOnBeforeInput, onDragStart: handleDragStart, onDrag: handleDrag, onDragEnd: handleDragEnd, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDrop: handleDrop, onDragLeave: handleDragLeave, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onPaste: handlePaste, readOnly, renderPlaceholder: void 0, renderElement, renderLeaf, renderText, scrollSelectionIntoView: scrollSelectionIntoViewToSlate }), $[151] = callbackRef, $[152] = decorate, $[153] = handleClick, $[154] = handleCopy, $[155] = handleCut, $[156] = handleDrag, $[157] = handleDragEnd, $[158] = handleDragEnter, $[159] = handleDragLeave, $[160] = handleDragOver, $[161] = handleDragStart, $[162] = handleDrop, $[163] = handleKeyDown, $[164] = handleKeyUp, $[165] = handleOnBeforeInput, $[166] = handleOnBlur, $[167] = handleOnFocus, $[168] = handlePaste, $[169] = hasInvalidValue, $[170] = readOnly, $[171] = renderElement, $[172] = renderLeaf, $[173] = restProps, $[174] = scrollSelectionIntoViewToSlate, $[175] = t39) : t39 = $[175], t39;
2537
2540
  });
2538
2541
  PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
2539
2542
  function _temp(s) {
@@ -3117,7 +3120,7 @@ function createWithPortableTextMarkModel(editorActor) {
3117
3120
  });
3118
3121
  slate.Editor.withoutNormalizing(editor, () => {
3119
3122
  apply2(op), slate.Transforms.setNodes(editor, {
3120
- marks: selector_isActiveStyle.getActiveDecorators(snapshot)
3123
+ marks: selector_isAtTheStartOfBlock.getActiveDecorators(snapshot)
3121
3124
  }, {
3122
3125
  at: op.path
3123
3126
  });
@@ -3901,27 +3904,26 @@ function createWithUndoRedo(options) {
3901
3904
  apply2(op);
3902
3905
  return;
3903
3906
  }
3904
- const {
3905
- operations,
3906
- history
3907
- } = editor, {
3908
- undos
3909
- } = history, step = undos[undos.length - 1], lastOp = step && step.operations && step.operations[step.operations.length - 1], overwrite = shouldOverwrite(op, lastOp), save = isSaving(editor), currentUndoStepId = getCurrentUndoStepId(editor);
3910
- let merge = currentUndoStepId === previousUndoStepId || isNormalizingNode(editor);
3911
- if (save) {
3912
- if (step ? operations.length === 0 && (merge = currentUndoStepId === void 0 && previousUndoStepId === void 0 ? shouldMerge(op, lastOp) || overwrite : merge) : merge = !1, step && merge)
3913
- step.operations.push(op);
3914
- else {
3915
- const newStep = {
3916
- operations: [...editor.selection === null ? [] : [createSelectOperation(editor)], op],
3917
- timestamp: /* @__PURE__ */ new Date()
3918
- };
3919
- undos.push(newStep), debug$b("Created new undo step", step);
3920
- }
3921
- for (; undos.length > UNDO_STEP_LIMIT; )
3922
- undos.shift();
3923
- shouldClear(op) && (history.redos = []);
3907
+ const savingUndoSteps = isSaving(editor), currentUndoStepId = getCurrentUndoStepId(editor);
3908
+ if (!savingUndoSteps) {
3909
+ previousUndoStepId = currentUndoStepId, apply2(op);
3910
+ return;
3924
3911
  }
3912
+ op.type !== "set_selection" && (editor.history.redos = []);
3913
+ const step = editor.history.undos.at(editor.history.undos.length - 1);
3914
+ if (!step) {
3915
+ editor.history.undos.push({
3916
+ operations: [...editor.selection === null ? [] : [createSelectOperation(editor)], op],
3917
+ timestamp: /* @__PURE__ */ new Date()
3918
+ }), apply2(op), previousUndoStepId = currentUndoStepId;
3919
+ return;
3920
+ }
3921
+ const selectingWithoutUndoStepId = op.type === "set_selection" && currentUndoStepId === void 0 && previousUndoStepId !== void 0, selectingWithDifferentUndoStepId = op.type === "set_selection" && currentUndoStepId !== void 0 && previousUndoStepId !== void 0 && previousUndoStepId !== currentUndoStepId, lastOp = step.operations.at(-1);
3922
+ for ((editor.operations.length > 0 ? currentUndoStepId === previousUndoStepId || isNormalizingNode(editor) : selectingWithoutUndoStepId || selectingWithDifferentUndoStepId || currentUndoStepId === void 0 && previousUndoStepId === void 0 ? shouldMerge(op, lastOp) || lastOp?.type === "set_selection" && op.type === "set_selection" : currentUndoStepId === previousUndoStepId || isNormalizingNode(editor)) ? step.operations.push(op) : editor.history.undos.push({
3923
+ operations: [...editor.selection === null ? [] : [createSelectOperation(editor)], op],
3924
+ timestamp: /* @__PURE__ */ new Date()
3925
+ }); editor.history.undos.length > UNDO_STEP_LIMIT; )
3926
+ editor.history.undos.shift();
3925
3927
  previousUndoStepId = currentUndoStepId, apply2(op);
3926
3928
  }, editor;
3927
3929
  };
@@ -4080,7 +4082,7 @@ function adjustBlockPath(operation, level, blockIndex) {
4080
4082
  }
4081
4083
  return transformedOperation;
4082
4084
  }
4083
- const shouldMerge = (op, prev) => !!(op.type === "set_selection" || prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length && slate.Path.equals(op.path, prev.path) && op.text !== " " || prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset && slate.Path.equals(op.path, prev.path)), shouldOverwrite = (op, prev) => !!(prev && op.type === "set_selection" && prev.type === "set_selection"), shouldClear = (op) => op.type !== "set_selection";
4085
+ const shouldMerge = (op, prev) => !!(op.type === "set_selection" || prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length && slate.Path.equals(op.path, prev.path) && op.text !== " " || prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset && slate.Path.equals(op.path, prev.path));
4084
4086
  function withoutSaving(editor, fn) {
4085
4087
  const prev = isSaving(editor);
4086
4088
  SAVING.set(editor, !1), fn(), SAVING.set(editor, prev);
@@ -4531,7 +4533,7 @@ const addAnnotationOperationImplementation = ({
4531
4533
  focus: focusOffset
4532
4534
  },
4533
4535
  backward: editorSelection?.backward
4534
- }), trimmedSelection = selector_isActiveStyle.getTrimmedSelection({
4536
+ }), trimmedSelection = selector_isAtTheStartOfBlock.getTrimmedSelection({
4535
4537
  blockIndexMap: editor.blockIndexMap,
4536
4538
  context: {
4537
4539
  converters: [],
@@ -5930,7 +5932,24 @@ function setNodePatch(schema$12, children, operation) {
5930
5932
  }, block)) {
5931
5933
  const child = block.children[operation.path[1]];
5932
5934
  if (child) {
5933
- const blockKey = block._key, childKey = child._key, patches$1 = [], keys = Object.keys(operation.newProperties);
5935
+ const blockKey = block._key, childKey = child._key, patches$1 = [];
5936
+ if (slate.Element.isElement(child)) {
5937
+ const _key = operation.newProperties._key;
5938
+ _key !== void 0 && patches$1.push(patches.set(_key, [{
5939
+ _key: blockKey
5940
+ }, "children", block.children.indexOf(child), "_key"]));
5941
+ const properties = "value" in operation.newProperties && typeof operation.newProperties.value == "object" ? operation.newProperties.value : {}, keys2 = Object.keys(properties);
5942
+ for (const key of keys2) {
5943
+ const value = properties[key];
5944
+ patches$1.push(patches.set(value, [{
5945
+ _key: blockKey
5946
+ }, "children", {
5947
+ _key: childKey
5948
+ }, key]));
5949
+ }
5950
+ return patches$1;
5951
+ }
5952
+ const keys = Object.keys(operation.newProperties);
5934
5953
  return keys.forEach((keyName) => {
5935
5954
  if (keys.length === 1 && keyName === "_key") {
5936
5955
  const val = get__default.default(operation.newProperties, keyName);
@@ -6697,6 +6716,10 @@ function createEditorDom(sendBack, slateEditor) {
6697
6716
  return {
6698
6717
  getBlockNodes: (snapshot) => getBlockNodes(slateEditor, snapshot),
6699
6718
  getChildNodes: (snapshot) => getChildNodes(slateEditor, snapshot),
6719
+ getEditorElement: () => getEditorElement(slateEditor),
6720
+ getSelectionRect: (snapshot) => getSelectionRect(snapshot),
6721
+ getStartBlockElement: (snapshot) => getStartBlockElement(slateEditor, snapshot),
6722
+ getEndBlockElement: (snapshot) => getEndBlockElement(slateEditor, snapshot),
6700
6723
  setDragGhost: ({
6701
6724
  event,
6702
6725
  ghost
@@ -6739,6 +6762,67 @@ function getChildNodes(slateEditor, snapshot) {
6739
6762
  return [];
6740
6763
  }
6741
6764
  }
6765
+ function getEditorElement(slateEditor) {
6766
+ try {
6767
+ return slateDom.DOMEditor.toDOMNode(slateEditor, slateEditor);
6768
+ } catch {
6769
+ return;
6770
+ }
6771
+ }
6772
+ function getSelectionRect(snapshot) {
6773
+ if (!snapshot.context.selection)
6774
+ return null;
6775
+ try {
6776
+ const selection = window.getSelection();
6777
+ return selection ? selection.getRangeAt(0).getBoundingClientRect() : null;
6778
+ } catch {
6779
+ return null;
6780
+ }
6781
+ }
6782
+ function getStartBlockElement(slateEditor, snapshot) {
6783
+ const startBlock = selector_isAtTheStartOfBlock.getSelectionStartBlock(snapshot);
6784
+ if (!startBlock)
6785
+ return null;
6786
+ const startBlockNode = getBlockNodes(slateEditor, {
6787
+ ...snapshot,
6788
+ context: {
6789
+ ...snapshot.context,
6790
+ selection: {
6791
+ anchor: {
6792
+ path: startBlock.path,
6793
+ offset: 0
6794
+ },
6795
+ focus: {
6796
+ path: startBlock.path,
6797
+ offset: 0
6798
+ }
6799
+ }
6800
+ }
6801
+ })?.at(0);
6802
+ return startBlockNode && startBlockNode instanceof Element ? startBlockNode : null;
6803
+ }
6804
+ function getEndBlockElement(slateEditor, snapshot) {
6805
+ const endBlock = selector_isAtTheStartOfBlock.getSelectionEndBlock(snapshot);
6806
+ if (!endBlock)
6807
+ return null;
6808
+ const endBlockNode = getBlockNodes(slateEditor, {
6809
+ ...snapshot,
6810
+ context: {
6811
+ ...snapshot.context,
6812
+ selection: {
6813
+ anchor: {
6814
+ path: endBlock.path,
6815
+ offset: 0
6816
+ },
6817
+ focus: {
6818
+ path: endBlock.path,
6819
+ offset: 0
6820
+ }
6821
+ }
6822
+ }
6823
+ })?.at(0);
6824
+ return endBlockNode && endBlockNode instanceof Element ? endBlockNode : null;
6825
+ }
6742
6826
  function setDragGhost({
6743
6827
  sendBack,
6744
6828
  event,
@@ -6756,7 +6840,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
6756
6840
  }) => {
6757
6841
  if (!selector_getSelectionText.isSelectionCollapsed(snapshot))
6758
6842
  return !1;
6759
- const caretWordSelection = selector_isActiveStyle.getCaretWordSelection(snapshot);
6843
+ const caretWordSelection = selector_isAtTheStartOfBlock.getCaretWordSelection(snapshot);
6760
6844
  return !caretWordSelection || !selector_getSelectionText.isSelectionExpanded({
6761
6845
  context: {
6762
6846
  ...snapshot.context,
@@ -6784,7 +6868,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
6784
6868
  guard: ({
6785
6869
  snapshot,
6786
6870
  event
6787
- }) => selector_isActiveStyle.isActiveAnnotation(event.annotation.name, {
6871
+ }) => selector_isAtTheStartOfBlock.isActiveAnnotation(event.annotation.name, {
6788
6872
  mode: "partial"
6789
6873
  })(snapshot),
6790
6874
  // Then the existing annotation is removed
@@ -6879,7 +6963,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
6879
6963
  }) => {
6880
6964
  if (!defaultKeyboardShortcuts.arrowDown.guard(event.originEvent) || !selector_getSelectionText.isSelectionCollapsed(snapshot))
6881
6965
  return !1;
6882
- const focusBlockObject = selector_isActiveStyle.getFocusBlockObject(snapshot), nextBlock = selector_isActiveStyle.getNextBlock(snapshot);
6966
+ const focusBlockObject = selector_isAtTheStartOfBlock.getFocusBlockObject(snapshot), nextBlock = selector_isAtTheStartOfBlock.getNextBlock(snapshot);
6883
6967
  return focusBlockObject && !nextBlock;
6884
6968
  },
6885
6969
  actions: [({
@@ -6899,7 +6983,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
6899
6983
  }) => {
6900
6984
  if (!defaultKeyboardShortcuts.arrowUp.guard(event.originEvent) || !selector_getSelectionText.isSelectionCollapsed(snapshot))
6901
6985
  return !1;
6902
- const focusBlockObject = selector_isActiveStyle.getFocusBlockObject(snapshot), previousBlock = selector_isActiveStyle.getPreviousBlock(snapshot);
6986
+ const focusBlockObject = selector_isAtTheStartOfBlock.getFocusBlockObject(snapshot), previousBlock = selector_isAtTheStartOfBlock.getPreviousBlock(snapshot);
6903
6987
  return focusBlockObject && !previousBlock;
6904
6988
  },
6905
6989
  actions: [({
@@ -6916,7 +7000,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
6916
7000
  guard: ({
6917
7001
  snapshot
6918
7002
  }) => {
6919
- const focusBlockObject = selector_isActiveStyle.getFocusBlockObject(snapshot);
7003
+ const focusBlockObject = selector_isAtTheStartOfBlock.getFocusBlockObject(snapshot);
6920
7004
  return selector_getSelectionText.isSelectionCollapsed(snapshot) && focusBlockObject !== void 0;
6921
7005
  },
6922
7006
  actions: [({
@@ -6936,13 +7020,13 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
6936
7020
  }) => {
6937
7021
  if (snapshot.context.readOnly || snapshot.context.selection && !selector_getSelectionText.isSelectionCollapsed(snapshot))
6938
7022
  return !1;
6939
- const focusBlockObject = selector_isActiveStyle.getFocusBlockObject({
7023
+ const focusBlockObject = selector_isAtTheStartOfBlock.getFocusBlockObject({
6940
7024
  ...snapshot,
6941
7025
  context: {
6942
7026
  ...snapshot.context,
6943
7027
  selection: event.position.selection
6944
7028
  }
6945
- }), previousBlock = selector_isActiveStyle.getPreviousBlock({
7029
+ }), previousBlock = selector_isAtTheStartOfBlock.getPreviousBlock({
6946
7030
  ...snapshot,
6947
7031
  context: {
6948
7032
  ...snapshot.context,
@@ -6973,13 +7057,13 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
6973
7057
  }) => {
6974
7058
  if (snapshot.context.readOnly || snapshot.context.selection && !selector_getSelectionText.isSelectionCollapsed(snapshot))
6975
7059
  return !1;
6976
- const focusBlockObject = selector_isActiveStyle.getFocusBlockObject({
7060
+ const focusBlockObject = selector_isAtTheStartOfBlock.getFocusBlockObject({
6977
7061
  ...snapshot,
6978
7062
  context: {
6979
7063
  ...snapshot.context,
6980
7064
  selection: event.position.selection
6981
7065
  }
6982
- }), nextBlock = selector_isActiveStyle.getNextBlock({
7066
+ }), nextBlock = selector_isAtTheStartOfBlock.getNextBlock({
6983
7067
  ...snapshot,
6984
7068
  context: {
6985
7069
  ...snapshot.context,
@@ -7007,7 +7091,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
7007
7091
  guard: ({
7008
7092
  snapshot
7009
7093
  }) => {
7010
- const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot), previousBlock = selector_isActiveStyle.getPreviousBlock(snapshot);
7094
+ const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot), previousBlock = selector_isAtTheStartOfBlock.getPreviousBlock(snapshot);
7011
7095
  return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !schema.isTextBlock(snapshot.context, previousBlock.node) ? {
7012
7096
  focusTextBlock,
7013
7097
  previousBlock
@@ -7037,7 +7121,7 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
7037
7121
  guard: ({
7038
7122
  snapshot
7039
7123
  }) => {
7040
- const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot), nextBlock = selector_isActiveStyle.getNextBlock(snapshot);
7124
+ const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot), nextBlock = selector_isAtTheStartOfBlock.getNextBlock(snapshot);
7041
7125
  return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !schema.isTextBlock(snapshot.context, nextBlock.node) ? {
7042
7126
  focusTextBlock,
7043
7127
  nextBlock
@@ -7146,7 +7230,7 @@ const coreDndBehaviors = [
7146
7230
  const dragSelection = getDragSelection({
7147
7231
  snapshot,
7148
7232
  eventSelection: event.position.selection
7149
- }), selectingEntireBlocks = selector_isActiveStyle.isSelectingEntireBlocks({
7233
+ }), selectingEntireBlocks = selector_isAtTheStartOfBlock.isSelectingEntireBlocks({
7150
7234
  ...snapshot,
7151
7235
  context: {
7152
7236
  ...snapshot.context,
@@ -7252,7 +7336,7 @@ const coreDndBehaviors = [
7252
7336
  event
7253
7337
  }) => {
7254
7338
  const dragOrigin = event.dragOrigin;
7255
- return dragOrigin ? selector_isActiveStyle.isOverlappingSelection(event.position.selection)({
7339
+ return dragOrigin ? selector_isAtTheStartOfBlock.isOverlappingSelection(event.position.selection)({
7256
7340
  ...snapshot,
7257
7341
  context: {
7258
7342
  ...snapshot.context,
@@ -7273,7 +7357,7 @@ const coreDndBehaviors = [
7273
7357
  event
7274
7358
  }) => {
7275
7359
  const dragOrigin = event.dragOrigin, dropPosition = event.position.selection;
7276
- return dragOrigin ? selector_isActiveStyle.isOverlappingSelection(dropPosition)({
7360
+ return dragOrigin ? selector_isAtTheStartOfBlock.isOverlappingSelection(dropPosition)({
7277
7361
  ...snapshot,
7278
7362
  context: {
7279
7363
  ...snapshot.context,
@@ -7329,19 +7413,19 @@ const coreDndBehaviors = [
7329
7413
  const dragOrigin = event.originEvent.dragOrigin, dragSelection = getDragSelection({
7330
7414
  eventSelection: dragOrigin.selection,
7331
7415
  snapshot
7332
- }), dropPosition = event.originEvent.position.selection, droppingOnDragOrigin = dragOrigin ? selector_isActiveStyle.isOverlappingSelection(dropPosition)({
7416
+ }), dropPosition = event.originEvent.position.selection, droppingOnDragOrigin = dragOrigin ? selector_isAtTheStartOfBlock.isOverlappingSelection(dropPosition)({
7333
7417
  ...snapshot,
7334
7418
  context: {
7335
7419
  ...snapshot.context,
7336
7420
  selection: dragSelection
7337
7421
  }
7338
- }) : !1, draggingEntireBlocks = selector_isActiveStyle.isSelectingEntireBlocks({
7422
+ }) : !1, draggingEntireBlocks = selector_isAtTheStartOfBlock.isSelectingEntireBlocks({
7339
7423
  ...snapshot,
7340
7424
  context: {
7341
7425
  ...snapshot.context,
7342
7426
  selection: dragSelection
7343
7427
  }
7344
- }), draggedBlocks = selector_isActiveStyle.getSelectedBlocks({
7428
+ }), draggedBlocks = selector_isAtTheStartOfBlock.getSelectedBlocks({
7345
7429
  ...snapshot,
7346
7430
  context: {
7347
7431
  ...snapshot.context,
@@ -7386,7 +7470,7 @@ const coreDndBehaviors = [
7386
7470
  }) => {
7387
7471
  if (!selector_getSelectionText.getFocusSpan(snapshot))
7388
7472
  return !1;
7389
- const markState = selector_isActiveStyle.getMarkState(snapshot), activeDecorators = selector_isActiveStyle.getActiveDecorators(snapshot), activeAnnotations = selector_isActiveStyle.getActiveAnnotationsMarks(snapshot);
7473
+ const markState = selector_isAtTheStartOfBlock.getMarkState(snapshot), activeDecorators = selector_isAtTheStartOfBlock.getActiveDecorators(snapshot), activeAnnotations = selector_isAtTheStartOfBlock.getActiveAnnotationsMarks(snapshot);
7390
7474
  if (markState && markState.state === "unchanged") {
7391
7475
  const markStateDecorators = (markState.marks ?? []).filter((mark) => snapshot.context.schema.decorators.map((decorator) => decorator.name).includes(mark));
7392
7476
  if (markStateDecorators.length === activeDecorators.length && markStateDecorators.every((mark) => activeDecorators.includes(mark)))
@@ -7419,7 +7503,7 @@ const coreDndBehaviors = [
7419
7503
  const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot);
7420
7504
  if (!snapshot.context.selection || !focusTextBlock || !selectionCollapsed)
7421
7505
  return !1;
7422
- const atTheEndOfBlock = selector_isActiveStyle.isAtTheEndOfBlock(focusTextBlock)(snapshot), focusListItem = focusTextBlock.node.listItem, focusLevel = focusTextBlock.node.level;
7506
+ const atTheEndOfBlock = selector_isAtTheStartOfBlock.isAtTheEndOfBlock(focusTextBlock)(snapshot), focusListItem = focusTextBlock.node.listItem, focusLevel = focusTextBlock.node.level;
7423
7507
  return atTheEndOfBlock ? {
7424
7508
  focusListItem,
7425
7509
  focusLevel
@@ -7455,7 +7539,7 @@ const coreDndBehaviors = [
7455
7539
  if (!snapshot.context.selection || !focusTextBlock || !selectionCollapsed)
7456
7540
  return !1;
7457
7541
  const focusSpan = selector_getSelectionText.getFocusSpan(snapshot), focusDecorators = focusSpan?.node.marks?.filter((mark) => snapshot.context.schema.decorators.some((decorator) => decorator.name === mark) ?? []), focusAnnotations = focusSpan?.node.marks?.filter((mark) => !snapshot.context.schema.decorators.some((decorator) => decorator.name === mark)) ?? [], focusListItem = focusTextBlock.node.listItem, focusLevel = focusTextBlock.node.level;
7458
- return selector_isActiveStyle.isAtTheStartOfBlock(focusTextBlock)(snapshot) ? {
7542
+ return selector_isAtTheStartOfBlock.isAtTheStartOfBlock(focusTextBlock)(snapshot) ? {
7459
7543
  focusAnnotations,
7460
7544
  focusDecorators,
7461
7545
  focusListItem,
@@ -7492,7 +7576,7 @@ const coreDndBehaviors = [
7492
7576
  }) => {
7493
7577
  if (!snapshot.context.selection || !selector_getSelectionText.isSelectionExpanded(snapshot))
7494
7578
  return !1;
7495
- const firstBlock = selector_isActiveStyle.getFirstBlock(snapshot), lastBlock = selector_isActiveStyle.getLastBlock(snapshot);
7579
+ const firstBlock = selector_isAtTheStartOfBlock.getFirstBlock(snapshot), lastBlock = selector_isAtTheStartOfBlock.getLastBlock(snapshot);
7496
7580
  if (!firstBlock || !lastBlock)
7497
7581
  return !1;
7498
7582
  const firstBlockStartPoint = util_getTextBlockText.getBlockStartPoint({
@@ -7519,7 +7603,7 @@ const coreDndBehaviors = [
7519
7603
  }) => {
7520
7604
  if (!snapshot.context.selection || !selector_getSelectionText.isSelectionExpanded(snapshot))
7521
7605
  return !1;
7522
- const selectedBlocks = selector_isActiveStyle.getSelectedBlocks(snapshot), selectionStartBlock = selector_isActiveStyle.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isActiveStyle.getSelectionEndBlock(snapshot);
7606
+ const selectedBlocks = selector_isAtTheStartOfBlock.getSelectedBlocks(snapshot), selectionStartBlock = selector_isAtTheStartOfBlock.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isAtTheStartOfBlock.getSelectionEndBlock(snapshot);
7523
7607
  if (!selectionStartBlock || !selectionEndBlock)
7524
7608
  return !1;
7525
7609
  const startBlockStartPoint = util_getTextBlockText.getBlockStartPoint({
@@ -7558,7 +7642,7 @@ const coreDndBehaviors = [
7558
7642
  guard: ({
7559
7643
  snapshot
7560
7644
  }) => {
7561
- const selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot), focusInlineObject = selector_isActiveStyle.getFocusInlineObject(snapshot);
7645
+ const selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot), focusInlineObject = selector_isAtTheStartOfBlock.getFocusInlineObject(snapshot);
7562
7646
  return selectionCollapsed && focusInlineObject;
7563
7647
  },
7564
7648
  actions: [() => [behaviors_index.raise({
@@ -7626,7 +7710,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7626
7710
  guard: ({
7627
7711
  snapshot
7628
7712
  }) => {
7629
- const focusListBlock = selector_isActiveStyle.getFocusListBlock(snapshot), nextBlock = selector_isActiveStyle.getNextBlock(snapshot);
7713
+ const focusListBlock = selector_isAtTheStartOfBlock.getFocusListBlock(snapshot), nextBlock = selector_isAtTheStartOfBlock.getNextBlock(snapshot);
7630
7714
  return !focusListBlock || !nextBlock || !schema.isTextBlock(snapshot.context, nextBlock.node) || !util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
7631
7715
  focusListBlock,
7632
7716
  nextBlock
@@ -7648,7 +7732,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7648
7732
  guard: ({
7649
7733
  snapshot
7650
7734
  }) => {
7651
- const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), previousBlock = selector_isActiveStyle.getPreviousBlock(snapshot);
7735
+ const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot), previousBlock = selector_isAtTheStartOfBlock.getPreviousBlock(snapshot);
7652
7736
  if (!focusTextBlock || !previousBlock || !isAtTheBeginningOfBlock({
7653
7737
  context: snapshot.context,
7654
7738
  block: focusTextBlock.node
@@ -7687,7 +7771,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7687
7771
  snapshot,
7688
7772
  event
7689
7773
  }) => {
7690
- const blocksToDelete = selector_isActiveStyle.getSelectedBlocks({
7774
+ const blocksToDelete = selector_isAtTheStartOfBlock.getSelectedBlocks({
7691
7775
  ...snapshot,
7692
7776
  context: {
7693
7777
  ...snapshot.context,
@@ -7704,7 +7788,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7704
7788
  ...snapshot.context,
7705
7789
  selection: event.at
7706
7790
  }
7707
- }), deleteEndPoint = selector_isActiveStyle.getSelectionEndPoint({
7791
+ }), deleteEndPoint = selector_isAtTheStartOfBlock.getSelectionEndPoint({
7708
7792
  context: {
7709
7793
  ...snapshot.context,
7710
7794
  selection: event.at
@@ -7806,7 +7890,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7806
7890
  guard: ({
7807
7891
  snapshot
7808
7892
  }) => {
7809
- const selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot), focusListBlock = selector_isActiveStyle.getFocusListBlock(snapshot);
7893
+ const selectionCollapsed = selector_getSelectionText.isSelectionCollapsed(snapshot), focusListBlock = selector_isAtTheStartOfBlock.getFocusListBlock(snapshot);
7810
7894
  return !selectionCollapsed || !focusListBlock || !util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
7811
7895
  focusListBlock
7812
7896
  };
@@ -7826,7 +7910,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7826
7910
  }) => {
7827
7911
  if (!defaultKeyboardShortcuts.tab.guard(event.originEvent))
7828
7912
  return !1;
7829
- const selectedBlocks = selector_isActiveStyle.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => util_getTextBlockText.isListBlock(snapshot.context, block.node) ? [{
7913
+ const selectedBlocks = selector_isAtTheStartOfBlock.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => util_getTextBlockText.isListBlock(snapshot.context, block.node) ? [{
7830
7914
  node: block.node,
7831
7915
  path: block.path
7832
7916
  }] : []);
@@ -7851,7 +7935,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7851
7935
  }) => {
7852
7936
  if (!defaultKeyboardShortcuts.shiftTab.guard(event.originEvent))
7853
7937
  return !1;
7854
- const selectedBlocks = selector_isActiveStyle.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => util_getTextBlockText.isListBlock(snapshot.context, block.node) ? [{
7938
+ const selectedBlocks = selector_isAtTheStartOfBlock.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => util_getTextBlockText.isListBlock(snapshot.context, block.node) ? [{
7855
7939
  node: block.node,
7856
7940
  path: block.path
7857
7941
  }] : []);
@@ -7874,7 +7958,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7874
7958
  snapshot,
7875
7959
  event
7876
7960
  }) => {
7877
- const focusListBlock = selector_isActiveStyle.getFocusListBlock(snapshot);
7961
+ const focusListBlock = selector_isAtTheStartOfBlock.getFocusListBlock(snapshot);
7878
7962
  if (!focusListBlock)
7879
7963
  return !1;
7880
7964
  const firstInsertedBlock = event.blocks.at(0), secondInsertedBlock = event.blocks.at(1), insertedListBlock = util_getTextBlockText.isListBlock(snapshot.context, firstInsertedBlock) ? firstInsertedBlock : util_getTextBlockText.isListBlock(snapshot.context, secondInsertedBlock) ? secondInsertedBlock : void 0;
@@ -7908,7 +7992,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7908
7992
  snapshot,
7909
7993
  event
7910
7994
  }) => {
7911
- const focusListBlock = selector_isActiveStyle.getFocusListBlock(snapshot);
7995
+ const focusListBlock = selector_isAtTheStartOfBlock.getFocusListBlock(snapshot);
7912
7996
  if (!focusListBlock || util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusListBlock.node))
7913
7997
  return !1;
7914
7998
  const firstInsertedBlock = event.blocks.at(0), secondInsertedBlock = event.blocks.at(1), insertedListBlock = util_getTextBlockText.isListBlock(snapshot.context, firstInsertedBlock) ? firstInsertedBlock : util_getTextBlockText.isListBlock(snapshot.context, secondInsertedBlock) ? secondInsertedBlock : void 0;
@@ -7941,7 +8025,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7941
8025
  }) => {
7942
8026
  if (event.placement !== "auto" || event.block._type !== snapshot.context.schema.block.name || event.block.listItem !== void 0)
7943
8027
  return !1;
7944
- const focusListBlock = selector_isActiveStyle.getFocusListBlock(snapshot);
8028
+ const focusListBlock = selector_isAtTheStartOfBlock.getFocusListBlock(snapshot);
7945
8029
  return !focusListBlock || !util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
7946
8030
  level: focusListBlock.node.level,
7947
8031
  listItem: focusListBlock.node.listItem
@@ -8033,7 +8117,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8033
8117
  guard: ({
8034
8118
  snapshot,
8035
8119
  event
8036
- }) => selector_isActiveStyle.isActiveAnnotation(event.annotation.name)(snapshot),
8120
+ }) => selector_isAtTheStartOfBlock.isActiveAnnotation(event.annotation.name)(snapshot),
8037
8121
  actions: [({
8038
8122
  event
8039
8123
  }) => [behaviors_index.raise({
@@ -8045,7 +8129,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8045
8129
  guard: ({
8046
8130
  snapshot,
8047
8131
  event
8048
- }) => !selector_isActiveStyle.isActiveAnnotation(event.annotation.name)(snapshot),
8132
+ }) => !selector_isAtTheStartOfBlock.isActiveAnnotation(event.annotation.name)(snapshot),
8049
8133
  actions: [({
8050
8134
  event
8051
8135
  }) => [behaviors_index.raise({
@@ -8057,7 +8141,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8057
8141
  guard: ({
8058
8142
  snapshot,
8059
8143
  event
8060
- }) => selector_isActiveStyle.isActiveDecorator(event.decorator)(snapshot),
8144
+ }) => selector_isAtTheStartOfBlock.isActiveDecorator(event.decorator)(snapshot),
8061
8145
  actions: [({
8062
8146
  event
8063
8147
  }) => [behaviors_index.raise({
@@ -8074,13 +8158,13 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8074
8158
  context: snapshot.context,
8075
8159
  offsets: event.at
8076
8160
  }) : null;
8077
- return manualSelection ? !selector_isActiveStyle.isActiveDecorator(event.decorator)({
8161
+ return manualSelection ? !selector_isAtTheStartOfBlock.isActiveDecorator(event.decorator)({
8078
8162
  ...snapshot,
8079
8163
  context: {
8080
8164
  ...snapshot.context,
8081
8165
  selection: manualSelection
8082
8166
  }
8083
- }) : !selector_isActiveStyle.isActiveDecorator(event.decorator)(snapshot);
8167
+ }) : !selector_isAtTheStartOfBlock.isActiveDecorator(event.decorator)(snapshot);
8084
8168
  },
8085
8169
  actions: [({
8086
8170
  event
@@ -8113,8 +8197,8 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8113
8197
  }) => {
8114
8198
  if (event.direction !== "backward")
8115
8199
  return !1;
8116
- const previousBlock = selector_isActiveStyle.getPreviousBlock(snapshot), focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
8117
- if (!previousBlock || !focusTextBlock || !selector_isActiveStyle.isAtTheStartOfBlock(focusTextBlock)(snapshot))
8200
+ const previousBlock = selector_isAtTheStartOfBlock.getPreviousBlock(snapshot), focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
8201
+ if (!previousBlock || !focusTextBlock || !selector_isAtTheStartOfBlock.isAtTheStartOfBlock(focusTextBlock)(snapshot))
8118
8202
  return !1;
8119
8203
  const previousBlockEndPoint = util_isEmptyTextBlock.getBlockEndPoint({
8120
8204
  context: snapshot.context,
@@ -8168,7 +8252,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8168
8252
  }) => {
8169
8253
  if (event.direction !== "forward")
8170
8254
  return !1;
8171
- const nextBlock = selector_isActiveStyle.getNextBlock({
8255
+ const nextBlock = selector_isAtTheStartOfBlock.getNextBlock({
8172
8256
  ...snapshot,
8173
8257
  context: {
8174
8258
  ...snapshot.context,
@@ -8213,8 +8297,8 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8213
8297
  }) => {
8214
8298
  if (event.direction !== "forward")
8215
8299
  return !1;
8216
- const nextBlock = selector_isActiveStyle.getNextBlock(snapshot), focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
8217
- return !nextBlock || !focusTextBlock || !selector_isActiveStyle.isAtTheEndOfBlock(focusTextBlock)(snapshot) || !schema.isTextBlock(snapshot.context, nextBlock.node) ? !1 : {
8300
+ const nextBlock = selector_isAtTheStartOfBlock.getNextBlock(snapshot), focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
8301
+ return !nextBlock || !focusTextBlock || !selector_isAtTheStartOfBlock.isAtTheEndOfBlock(focusTextBlock)(snapshot) || !schema.isTextBlock(snapshot.context, nextBlock.node) ? !1 : {
8218
8302
  nextBlock
8219
8303
  };
8220
8304
  },
@@ -8311,7 +8395,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8311
8395
  });
8312
8396
  if (!selection)
8313
8397
  return !1;
8314
- const trimmedSelection = selector_isActiveStyle.getTrimmedSelection({
8398
+ const trimmedSelection = selector_isAtTheStartOfBlock.getTrimmedSelection({
8315
8399
  ...snapshot,
8316
8400
  context: {
8317
8401
  ...snapshot.context,
@@ -8414,9 +8498,9 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8414
8498
  event
8415
8499
  }) => {
8416
8500
  if (selector_getSelectionText.getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
8417
- const activeDecorators = selector_isActiveStyle.getActiveDecorators(snapshot);
8501
+ const activeDecorators = selector_isAtTheStartOfBlock.getActiveDecorators(snapshot);
8418
8502
  return {
8419
- activeAnnotations: selector_isActiveStyle.getActiveAnnotations(snapshot),
8503
+ activeAnnotations: selector_isAtTheStartOfBlock.getActiveAnnotations(snapshot),
8420
8504
  activeDecorators,
8421
8505
  textRuns: event.data.flatMap((block) => schema.isTextBlock(snapshot.context, block) ? [util_getTextBlockText.getTextBlockText(block)] : [])
8422
8506
  };
@@ -8766,7 +8850,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8766
8850
  guard: ({
8767
8851
  snapshot
8768
8852
  }) => {
8769
- const lastBlock = selector_isActiveStyle.getLastBlock(snapshot);
8853
+ const lastBlock = selector_isAtTheStartOfBlock.getLastBlock(snapshot);
8770
8854
  return !lastBlock || snapshot.context.selection ? !1 : {
8771
8855
  lastBlockEndPoint: util_isEmptyTextBlock.getBlockEndPoint({
8772
8856
  context: snapshot.context,
@@ -8921,7 +9005,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8921
9005
  guard: ({
8922
9006
  snapshot,
8923
9007
  event
8924
- }) => defaultKeyboardShortcuts.backspace.guard(event.originEvent) && selector_getSelectionText.isSelectionCollapsed(snapshot) && selector_isActiveStyle.getFocusInlineObject(snapshot),
9008
+ }) => defaultKeyboardShortcuts.backspace.guard(event.originEvent) && selector_getSelectionText.isSelectionCollapsed(snapshot) && selector_isAtTheStartOfBlock.getFocusInlineObject(snapshot),
8925
9009
  actions: [() => [behaviors_index.raise({
8926
9010
  type: "delete.backward",
8927
9011
  unit: "character"
@@ -8937,7 +9021,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8937
9021
  guard: ({
8938
9022
  snapshot,
8939
9023
  event
8940
- }) => defaultKeyboardShortcuts.delete.guard(event.originEvent) && selector_getSelectionText.isSelectionCollapsed(snapshot) && selector_isActiveStyle.getFocusInlineObject(snapshot),
9024
+ }) => defaultKeyboardShortcuts.delete.guard(event.originEvent) && selector_getSelectionText.isSelectionCollapsed(snapshot) && selector_isAtTheStartOfBlock.getFocusInlineObject(snapshot),
8941
9025
  actions: [() => [behaviors_index.raise({
8942
9026
  type: "delete.forward",
8943
9027
  unit: "character"
@@ -8952,7 +9036,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8952
9036
  guard: ({
8953
9037
  snapshot,
8954
9038
  event
8955
- }) => defaultKeyboardShortcuts.break.guard(event.originEvent) && selector_getSelectionText.isSelectionCollapsed(snapshot) && selector_isActiveStyle.getFocusInlineObject(snapshot),
9039
+ }) => defaultKeyboardShortcuts.break.guard(event.originEvent) && selector_getSelectionText.isSelectionCollapsed(snapshot) && selector_isAtTheStartOfBlock.getFocusInlineObject(snapshot),
8956
9040
  actions: [() => [behaviors_index.raise({
8957
9041
  type: "insert.break"
8958
9042
  })]]
@@ -9024,7 +9108,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9024
9108
  const focusBlock = selector_getSelectionText.getFocusBlock(snapshot);
9025
9109
  if (!focusBlock)
9026
9110
  return !1;
9027
- const previousBlock = selector_isActiveStyle.getPreviousBlock({
9111
+ const previousBlock = selector_isAtTheStartOfBlock.getPreviousBlock({
9028
9112
  ...snapshot,
9029
9113
  context: {
9030
9114
  ...snapshot.context,
@@ -9067,7 +9151,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9067
9151
  snapshot,
9068
9152
  event
9069
9153
  }) => snapshot.context.schema.lists.some((list) => list.name === event.listItem) ? {
9070
- selectedTextBlocks: selector_isActiveStyle.getSelectedTextBlocks(snapshot)
9154
+ selectedTextBlocks: selector_isAtTheStartOfBlock.getSelectedTextBlocks(snapshot)
9071
9155
  } : !1,
9072
9156
  actions: [({
9073
9157
  event
@@ -9086,7 +9170,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9086
9170
  guard: ({
9087
9171
  snapshot
9088
9172
  }) => ({
9089
- selectedTextBlocks: selector_isActiveStyle.getSelectedTextBlocks(snapshot)
9173
+ selectedTextBlocks: selector_isAtTheStartOfBlock.getSelectedTextBlocks(snapshot)
9090
9174
  }),
9091
9175
  actions: [(_, {
9092
9176
  selectedTextBlocks
@@ -9100,7 +9184,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9100
9184
  guard: ({
9101
9185
  snapshot,
9102
9186
  event
9103
- }) => selector_isActiveStyle.isActiveListItem(event.listItem)(snapshot),
9187
+ }) => selector_isAtTheStartOfBlock.isActiveListItem(event.listItem)(snapshot),
9104
9188
  actions: [({
9105
9189
  event
9106
9190
  }) => [behaviors_index.raise({
@@ -9112,7 +9196,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9112
9196
  guard: ({
9113
9197
  snapshot,
9114
9198
  event
9115
- }) => !selector_isActiveStyle.isActiveListItem(event.listItem)(snapshot),
9199
+ }) => !selector_isAtTheStartOfBlock.isActiveListItem(event.listItem)(snapshot),
9116
9200
  actions: [({
9117
9201
  event
9118
9202
  }) => [behaviors_index.raise({
@@ -9125,7 +9209,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9125
9209
  snapshot,
9126
9210
  event
9127
9211
  }) => {
9128
- const previousBlock = selector_isActiveStyle.getPreviousBlock({
9212
+ const previousBlock = selector_isAtTheStartOfBlock.getPreviousBlock({
9129
9213
  ...snapshot,
9130
9214
  context: {
9131
9215
  ...snapshot.context,
@@ -9160,7 +9244,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9160
9244
  snapshot,
9161
9245
  event
9162
9246
  }) => {
9163
- const nextBlock = selector_isActiveStyle.getNextBlock({
9247
+ const nextBlock = selector_isAtTheStartOfBlock.getNextBlock({
9164
9248
  ...snapshot,
9165
9249
  context: {
9166
9250
  ...snapshot.context,
@@ -9251,7 +9335,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9251
9335
  guard: ({
9252
9336
  snapshot
9253
9337
  }) => {
9254
- const previousBlock = selector_isActiveStyle.getPreviousBlock(snapshot);
9338
+ const previousBlock = selector_isAtTheStartOfBlock.getPreviousBlock(snapshot);
9255
9339
  return previousBlock ? {
9256
9340
  previousBlock
9257
9341
  } : !1;
@@ -9270,7 +9354,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9270
9354
  guard: ({
9271
9355
  snapshot
9272
9356
  }) => {
9273
- const nextBlock = selector_isActiveStyle.getNextBlock(snapshot);
9357
+ const nextBlock = selector_isAtTheStartOfBlock.getNextBlock(snapshot);
9274
9358
  return nextBlock ? {
9275
9359
  nextBlock
9276
9360
  } : !1;
@@ -9354,7 +9438,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9354
9438
  on: "split",
9355
9439
  guard: ({
9356
9440
  snapshot
9357
- }) => util_isEmptyTextBlock.isSelectionCollapsed(snapshot.context.selection) && selector_isActiveStyle.getFocusInlineObject(snapshot),
9441
+ }) => util_isEmptyTextBlock.isSelectionCollapsed(snapshot.context.selection) && selector_isAtTheStartOfBlock.getFocusInlineObject(snapshot),
9358
9442
  actions: []
9359
9443
  }),
9360
9444
  /**
@@ -9364,7 +9448,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9364
9448
  on: "split",
9365
9449
  guard: ({
9366
9450
  snapshot
9367
- }) => util_isEmptyTextBlock.isSelectionCollapsed(snapshot.context.selection) && selector_isActiveStyle.getFocusBlockObject(snapshot),
9451
+ }) => util_isEmptyTextBlock.isSelectionCollapsed(snapshot.context.selection) && selector_isAtTheStartOfBlock.getFocusBlockObject(snapshot),
9368
9452
  actions: []
9369
9453
  }),
9370
9454
  behaviors_index.defineBehavior({
@@ -9375,7 +9459,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9375
9459
  const selection = snapshot.context.selection;
9376
9460
  if (!selection || util_isEmptyTextBlock.isSelectionCollapsed(selection))
9377
9461
  return !1;
9378
- const selectionStartBlock = selector_isActiveStyle.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isActiveStyle.getSelectionEndBlock(snapshot);
9462
+ const selectionStartBlock = selector_isAtTheStartOfBlock.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isAtTheStartOfBlock.getSelectionEndBlock(snapshot);
9379
9463
  return !selectionStartBlock || !selectionEndBlock ? !1 : !schema.isTextBlock(snapshot.context, selectionStartBlock.node) && schema.isTextBlock(snapshot.context, selectionEndBlock.node) ? {
9380
9464
  selection
9381
9465
  } : !1;
@@ -9395,7 +9479,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9395
9479
  const selection = snapshot.context.selection;
9396
9480
  if (!selection || util_isEmptyTextBlock.isSelectionCollapsed(selection))
9397
9481
  return !1;
9398
- const selectionStartBlock = selector_isActiveStyle.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isActiveStyle.getSelectionEndBlock(snapshot);
9482
+ const selectionStartBlock = selector_isAtTheStartOfBlock.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isAtTheStartOfBlock.getSelectionEndBlock(snapshot);
9399
9483
  if (!selectionStartBlock || !selectionEndBlock || selectionStartBlock.node._key === selectionEndBlock.node._key)
9400
9484
  return !1;
9401
9485
  const startPoint = util_getTextBlockText.getSelectionStartPoint(selection), startBlockEndPoint = util_isEmptyTextBlock.getBlockEndPoint({
@@ -9516,7 +9600,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9516
9600
  guard: ({
9517
9601
  snapshot
9518
9602
  }) => ({
9519
- selectedTextBlocks: selector_isActiveStyle.getSelectedTextBlocks(snapshot)
9603
+ selectedTextBlocks: selector_isAtTheStartOfBlock.getSelectedTextBlocks(snapshot)
9520
9604
  }),
9521
9605
  actions: [({
9522
9606
  event
@@ -9534,7 +9618,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9534
9618
  guard: ({
9535
9619
  snapshot
9536
9620
  }) => ({
9537
- selectedTextBlocks: selector_isActiveStyle.getSelectedTextBlocks(snapshot)
9621
+ selectedTextBlocks: selector_isAtTheStartOfBlock.getSelectedTextBlocks(snapshot)
9538
9622
  }),
9539
9623
  actions: [(_, {
9540
9624
  selectedTextBlocks
@@ -9548,7 +9632,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9548
9632
  guard: ({
9549
9633
  snapshot,
9550
9634
  event
9551
- }) => selector_isActiveStyle.isActiveStyle(event.style)(snapshot),
9635
+ }) => selector_isAtTheStartOfBlock.isActiveStyle(event.style)(snapshot),
9552
9636
  actions: [({
9553
9637
  event
9554
9638
  }) => [behaviors_index.raise({
@@ -9560,7 +9644,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
9560
9644
  guard: ({
9561
9645
  snapshot,
9562
9646
  event
9563
- }) => !selector_isActiveStyle.isActiveStyle(event.style)(snapshot),
9647
+ }) => !selector_isAtTheStartOfBlock.isActiveStyle(event.style)(snapshot),
9564
9648
  actions: [({
9565
9649
  event
9566
9650
  }) => [behaviors_index.raise({
@@ -10703,13 +10787,13 @@ function createEditableAPI(editor, editorActor) {
10703
10787
  editorActorSnapshot: editorActor.getSnapshot(),
10704
10788
  slateEditorInstance: editor
10705
10789
  });
10706
- return selector_isActiveStyle.getActiveDecorators(snapshot).includes(mark);
10790
+ return selector_isAtTheStartOfBlock.getActiveDecorators(snapshot).includes(mark);
10707
10791
  },
10708
10792
  marks: () => {
10709
10793
  const snapshot = getEditorSnapshot({
10710
10794
  editorActorSnapshot: editorActor.getSnapshot(),
10711
10795
  slateEditorInstance: editor
10712
- }), activeAnnotations = selector_isActiveStyle.getActiveAnnotationsMarks(snapshot), activeDecorators = selector_isActiveStyle.getActiveDecorators(snapshot);
10796
+ }), activeAnnotations = selector_isAtTheStartOfBlock.getActiveAnnotationsMarks(snapshot), activeDecorators = selector_isAtTheStartOfBlock.getActiveDecorators(snapshot);
10713
10797
  return [...activeAnnotations, ...activeDecorators];
10714
10798
  },
10715
10799
  undo: () => {
@@ -10919,7 +11003,7 @@ function createEditableAPI(editor, editorActor) {
10919
11003
  editorActorSnapshot: editorActor.getSnapshot(),
10920
11004
  slateEditorInstance: editor
10921
11005
  });
10922
- return selector_isActiveStyle.isActiveAnnotation(annotationType)(snapshot);
11006
+ return selector_isAtTheStartOfBlock.isActiveAnnotation(annotationType)(snapshot);
10923
11007
  },
10924
11008
  addAnnotation: (type, value) => {
10925
11009
  const snapshotBefore = getEditorSnapshot({
@@ -11691,89 +11775,67 @@ async function updateValue({
11691
11775
  }) {
11692
11776
  let doneSyncing = !1, isChanged = !1, isValid = !0;
11693
11777
  const hadSelection = !!slateEditor.selection;
11694
- if ((!value || value.length === 0) && (debug$2("Value is empty"), slate.Editor.withoutNormalizing(slateEditor, () => {
11695
- withoutSaving(slateEditor, () => {
11696
- withRemoteChanges(slateEditor, () => {
11697
- withoutPatching(slateEditor, () => {
11698
- if (doneSyncing)
11699
- return;
11700
- hadSelection && slate.Transforms.deselect(slateEditor);
11701
- const childrenLength = slateEditor.children.length;
11702
- slateEditor.children.forEach((_, index) => {
11703
- slate.Transforms.removeNodes(slateEditor, {
11704
- at: [childrenLength - 1 - index]
11705
- });
11706
- }), slate.Transforms.insertNodes(slateEditor, slateEditor.pteCreateTextBlock({
11707
- decorators: []
11708
- }), {
11709
- at: [0]
11710
- }), hadSelection && slate.Transforms.select(slateEditor, [0, 0]);
11711
- });
11712
- });
11713
- });
11714
- }), isChanged = !0), value && value.length > 0 && (streamBlocks ? await new Promise((resolve) => {
11715
- slate.Editor.withoutNormalizing(slateEditor, () => {
11716
- withRemoteChanges(slateEditor, () => {
11717
- withoutPatching(slateEditor, () => {
11718
- if (doneSyncing) {
11719
- resolve();
11720
- return;
11721
- }
11722
- isChanged = removeExtraBlocks({
11723
- slateEditor,
11724
- value
11725
- }), (async () => {
11726
- for await (const [currentBlock, currentBlockIndex] of getStreamedBlocks({
11727
- value
11728
- })) {
11729
- const {
11730
- blockChanged,
11731
- blockValid
11732
- } = syncBlock({
11733
- context,
11734
- sendBack,
11735
- block: currentBlock,
11736
- index: currentBlockIndex,
11737
- slateEditor,
11738
- value
11739
- });
11740
- if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !isValid)
11741
- break;
11742
- }
11743
- resolve();
11744
- })();
11745
- });
11746
- });
11747
- });
11748
- }) : slate.Editor.withoutNormalizing(slateEditor, () => {
11749
- withRemoteChanges(slateEditor, () => {
11750
- withoutPatching(slateEditor, () => {
11751
- if (doneSyncing)
11778
+ if ((!value || value.length === 0) && (debug$2("Value is empty"), clearEditor({
11779
+ slateEditor,
11780
+ doneSyncing,
11781
+ hadSelection
11782
+ }), isChanged = !0), value && value.length > 0)
11783
+ if (streamBlocks)
11784
+ await new Promise((resolve) => {
11785
+ if (doneSyncing) {
11786
+ resolve();
11752
11787
  return;
11788
+ }
11753
11789
  isChanged = removeExtraBlocks({
11754
11790
  slateEditor,
11755
11791
  value
11756
- });
11757
- let index = 0;
11758
- for (const currentBlock of value) {
11759
- const {
11760
- blockChanged,
11761
- blockValid
11762
- } = syncBlock({
11763
- context,
11764
- sendBack,
11765
- block: currentBlock,
11766
- index,
11767
- slateEditor,
11792
+ }), (async () => {
11793
+ for await (const [currentBlock, currentBlockIndex] of getStreamedBlocks({
11768
11794
  value
11769
- });
11770
- if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !blockValid)
11771
- break;
11772
- index++;
11773
- }
11795
+ })) {
11796
+ const {
11797
+ blockChanged,
11798
+ blockValid
11799
+ } = syncBlock({
11800
+ context,
11801
+ sendBack,
11802
+ block: currentBlock,
11803
+ index: currentBlockIndex,
11804
+ slateEditor,
11805
+ value
11806
+ });
11807
+ if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !isValid)
11808
+ break;
11809
+ }
11810
+ resolve();
11811
+ })();
11774
11812
  });
11775
- });
11776
- })), !isValid) {
11813
+ else {
11814
+ if (doneSyncing)
11815
+ return;
11816
+ isChanged = removeExtraBlocks({
11817
+ slateEditor,
11818
+ value
11819
+ });
11820
+ let index = 0;
11821
+ for (const block of value) {
11822
+ const {
11823
+ blockChanged,
11824
+ blockValid
11825
+ } = syncBlock({
11826
+ context,
11827
+ sendBack,
11828
+ block,
11829
+ index,
11830
+ slateEditor,
11831
+ value
11832
+ });
11833
+ if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !blockValid)
11834
+ break;
11835
+ index++;
11836
+ }
11837
+ }
11838
+ if (!isValid) {
11777
11839
  debug$2("Invalid value, returning"), doneSyncing = !0, sendBack({
11778
11840
  type: "done syncing",
11779
11841
  value
@@ -11815,21 +11877,6 @@ async function updateValue({
11815
11877
  value
11816
11878
  });
11817
11879
  }
11818
- function removeExtraBlocks({
11819
- slateEditor,
11820
- value
11821
- }) {
11822
- let isChanged = !1;
11823
- const childrenLength = slateEditor.children.length;
11824
- if (value.length < childrenLength) {
11825
- for (let i = childrenLength - 1; i > value.length - 1; i--)
11826
- slate.Transforms.removeNodes(slateEditor, {
11827
- at: [i]
11828
- });
11829
- isChanged = !0;
11830
- }
11831
- return isChanged;
11832
- }
11833
11880
  async function* getStreamedBlocks({
11834
11881
  value
11835
11882
  }) {
@@ -11837,87 +11884,182 @@ async function* getStreamedBlocks({
11837
11884
  for await (const block of value)
11838
11885
  index % 10 === 0 && await new Promise((resolve) => setTimeout(resolve, 0)), yield [block, index], index++;
11839
11886
  }
11840
- function syncBlock({
11841
- context,
11842
- sendBack,
11843
- block,
11844
- index,
11887
+ function clearEditor({
11888
+ slateEditor,
11889
+ doneSyncing,
11890
+ hadSelection
11891
+ }) {
11892
+ slate.Editor.withoutNormalizing(slateEditor, () => {
11893
+ withoutSaving(slateEditor, () => {
11894
+ withRemoteChanges(slateEditor, () => {
11895
+ withoutPatching(slateEditor, () => {
11896
+ if (doneSyncing)
11897
+ return;
11898
+ hadSelection && slate.Transforms.deselect(slateEditor);
11899
+ const childrenLength = slateEditor.children.length;
11900
+ slateEditor.children.forEach((_, index) => {
11901
+ slate.Transforms.removeNodes(slateEditor, {
11902
+ at: [childrenLength - 1 - index]
11903
+ });
11904
+ }), slate.Transforms.insertNodes(slateEditor, slateEditor.pteCreateTextBlock({
11905
+ decorators: []
11906
+ }), {
11907
+ at: [0]
11908
+ }), hadSelection && slate.Transforms.select(slateEditor, [0, 0]);
11909
+ });
11910
+ });
11911
+ });
11912
+ });
11913
+ }
11914
+ function removeExtraBlocks({
11845
11915
  slateEditor,
11846
11916
  value
11847
11917
  }) {
11848
- let blockChanged = !1, blockValid = !0;
11849
- const currentBlock = block, currentBlockIndex = index, oldBlock = slateEditor.children[currentBlockIndex], hasChanges = oldBlock && !isEqual__default.default(currentBlock, oldBlock);
11918
+ let isChanged = !1;
11850
11919
  return slate.Editor.withoutNormalizing(slateEditor, () => {
11851
11920
  withRemoteChanges(slateEditor, () => {
11852
11921
  withoutPatching(slateEditor, () => {
11853
- if (hasChanges && blockValid) {
11854
- const validationValue = [value[currentBlockIndex]], validation = validateValue(validationValue, context.schema, context.keyGenerator);
11855
- if (!validation.valid && validation.resolution?.autoResolve && validation.resolution?.patches.length > 0 && !context.readOnly && context.previousValue && context.previousValue !== value && (console.warn(`${validation.resolution.action} for block with _key '${validationValue[0]._key}'. ${validation.resolution?.description}`), validation.resolution.patches.forEach((patch) => {
11856
- sendBack({
11857
- type: "patch",
11858
- patch
11859
- });
11860
- })), validation.valid || validation.resolution?.autoResolve) {
11861
- const slateBlock = toSlateBlock(currentBlock, {
11862
- schemaTypes: context.schema
11922
+ const childrenLength = slateEditor.children.length;
11923
+ if (value.length < childrenLength) {
11924
+ for (let i = childrenLength - 1; i > value.length - 1; i--)
11925
+ slate.Transforms.removeNodes(slateEditor, {
11926
+ at: [i]
11863
11927
  });
11864
- oldBlock._key === currentBlock._key ? (debug$2.enabled && debug$2("Updating block", oldBlock, currentBlock), _updateBlock(slateEditor, slateBlock, oldBlock, currentBlockIndex)) : (debug$2.enabled && debug$2("Replacing block", oldBlock, currentBlock), _replaceBlock(slateEditor, slateBlock, currentBlockIndex)), blockChanged = !0;
11865
- } else
11866
- sendBack({
11867
- type: "invalid value",
11868
- resolution: validation.resolution,
11869
- value
11870
- }), blockValid = !1;
11928
+ isChanged = !0;
11871
11929
  }
11872
- if (!oldBlock && blockValid) {
11873
- const validation = validateValue([currentBlock], context.schema, context.keyGenerator);
11874
- if (debug$2.enabled && debug$2("Validating and inserting new block in the end of the value", currentBlock), validation.valid || validation.resolution?.autoResolve) {
11875
- const slateBlock = toSlateBlock(currentBlock, {
11876
- schemaTypes: context.schema
11877
- });
11930
+ });
11931
+ });
11932
+ }), isChanged;
11933
+ }
11934
+ function syncBlock({
11935
+ context,
11936
+ sendBack,
11937
+ block,
11938
+ index,
11939
+ slateEditor,
11940
+ value
11941
+ }) {
11942
+ const oldBlock = slateEditor.children.at(index);
11943
+ if (!oldBlock) {
11944
+ const validation2 = validateValue([block], context.schema, context.keyGenerator);
11945
+ if (debug$2.enabled && debug$2("Validating and inserting new block in the end of the value", block), validation2.valid || validation2.resolution?.autoResolve) {
11946
+ const slateBlock = toSlateBlock(block, {
11947
+ schemaTypes: context.schema
11948
+ });
11949
+ return slate.Editor.withoutNormalizing(slateEditor, () => {
11950
+ withRemoteChanges(slateEditor, () => {
11951
+ withoutPatching(slateEditor, () => {
11878
11952
  slate.Transforms.insertNodes(slateEditor, slateBlock, {
11879
- at: [currentBlockIndex]
11953
+ at: [index]
11880
11954
  });
11881
- } else
11882
- debug$2("Invalid", validation), sendBack({
11883
- type: "invalid value",
11884
- resolution: validation.resolution,
11885
- value
11886
- }), blockValid = !1;
11887
- }
11955
+ });
11956
+ });
11957
+ }), {
11958
+ blockChanged: !0,
11959
+ blockValid: !0
11960
+ };
11961
+ }
11962
+ return debug$2("Invalid", validation2), sendBack({
11963
+ type: "invalid value",
11964
+ resolution: validation2.resolution,
11965
+ value
11966
+ }), {
11967
+ blockChanged: !1,
11968
+ blockValid: !1
11969
+ };
11970
+ }
11971
+ if (isEqual__default.default(block, oldBlock))
11972
+ return {
11973
+ blockChanged: !1,
11974
+ blockValid: !0
11975
+ };
11976
+ const validationValue = [value[index]], validation = validateValue(validationValue, context.schema, context.keyGenerator);
11977
+ return !validation.valid && validation.resolution?.autoResolve && validation.resolution?.patches.length > 0 && !context.readOnly && context.previousValue && context.previousValue !== value && (console.warn(`${validation.resolution.action} for block with _key '${validationValue[0]._key}'. ${validation.resolution?.description}`), validation.resolution.patches.forEach((patch) => {
11978
+ sendBack({
11979
+ type: "patch",
11980
+ patch
11981
+ });
11982
+ })), validation.valid || validation.resolution?.autoResolve ? (oldBlock._key === block._key ? (debug$2.enabled && debug$2("Updating block", oldBlock, block), slate.Editor.withoutNormalizing(slateEditor, () => {
11983
+ withRemoteChanges(slateEditor, () => {
11984
+ withoutPatching(slateEditor, () => {
11985
+ updateBlock({
11986
+ context,
11987
+ slateEditor,
11988
+ oldBlock,
11989
+ block,
11990
+ index
11991
+ });
11888
11992
  });
11889
11993
  });
11994
+ })) : (debug$2.enabled && debug$2("Replacing block", oldBlock, block), slate.Editor.withoutNormalizing(slateEditor, () => {
11995
+ withRemoteChanges(slateEditor, () => {
11996
+ withoutPatching(slateEditor, () => {
11997
+ replaceBlock({
11998
+ context,
11999
+ slateEditor,
12000
+ block,
12001
+ index
12002
+ });
12003
+ });
12004
+ });
12005
+ })), {
12006
+ blockChanged: !0,
12007
+ blockValid: !0
12008
+ }) : (sendBack({
12009
+ type: "invalid value",
12010
+ resolution: validation.resolution,
12011
+ value
11890
12012
  }), {
11891
- blockChanged,
11892
- blockValid
11893
- };
12013
+ blockChanged: !1,
12014
+ blockValid: !1
12015
+ });
11894
12016
  }
11895
- function _replaceBlock(slateEditor, currentBlock, currentBlockIndex) {
11896
- const currentSelection = slateEditor.selection, selectionFocusOnBlock = currentSelection && currentSelection.focus.path[0] === currentBlockIndex;
12017
+ function replaceBlock({
12018
+ context,
12019
+ slateEditor,
12020
+ block,
12021
+ index
12022
+ }) {
12023
+ const slateBlock = toSlateBlock(block, {
12024
+ schemaTypes: context.schema
12025
+ }), currentSelection = slateEditor.selection, selectionFocusOnBlock = currentSelection && currentSelection.focus.path[0] === index;
11897
12026
  selectionFocusOnBlock && slate.Transforms.deselect(slateEditor), slate.Transforms.removeNodes(slateEditor, {
11898
- at: [currentBlockIndex]
11899
- }), slate.Transforms.insertNodes(slateEditor, currentBlock, {
11900
- at: [currentBlockIndex]
12027
+ at: [index]
12028
+ }), slate.Transforms.insertNodes(slateEditor, slateBlock, {
12029
+ at: [index]
11901
12030
  }), slateEditor.onChange(), selectionFocusOnBlock && slate.Transforms.select(slateEditor, currentSelection);
11902
12031
  }
11903
- function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
11904
- if (slate.Transforms.setNodes(slateEditor, currentBlock, {
11905
- at: [currentBlockIndex]
11906
- }), slateEditor.isTextBlock(currentBlock) && slateEditor.isTextBlock(oldBlock)) {
12032
+ function updateBlock({
12033
+ context,
12034
+ slateEditor,
12035
+ oldBlock,
12036
+ block,
12037
+ index
12038
+ }) {
12039
+ const slateBlock = toSlateBlock(block, {
12040
+ schemaTypes: context.schema
12041
+ });
12042
+ if (slate.Transforms.setNodes(slateEditor, slateBlock, {
12043
+ at: [index]
12044
+ }), slateEditor.isTextBlock(slateBlock) && slateEditor.isTextBlock(oldBlock)) {
11907
12045
  const oldBlockChildrenLength = oldBlock.children.length;
11908
- currentBlock.children.length < oldBlockChildrenLength && Array.from(Array(oldBlockChildrenLength - currentBlock.children.length)).forEach((_, index) => {
11909
- const childIndex = oldBlockChildrenLength - 1 - index;
12046
+ slateBlock.children.length < oldBlockChildrenLength && Array.from(Array(oldBlockChildrenLength - slateBlock.children.length)).forEach((_, index2) => {
12047
+ const childIndex = oldBlockChildrenLength - 1 - index2;
11910
12048
  childIndex > 0 && (debug$2("Removing child"), slate.Transforms.removeNodes(slateEditor, {
11911
- at: [currentBlockIndex, childIndex]
12049
+ at: [index2, childIndex]
11912
12050
  }));
11913
- }), currentBlock.children.forEach((currentBlockChild, currentBlockChildIndex) => {
11914
- const oldBlockChild = oldBlock.children[currentBlockChildIndex], isChildChanged = !isEqual__default.default(currentBlockChild, oldBlockChild), isTextChanged = !isEqual__default.default(currentBlockChild.text, oldBlockChild?.text), path = [currentBlockIndex, currentBlockChildIndex];
12051
+ }), slateBlock.children.forEach((currentBlockChild, currentBlockChildIndex) => {
12052
+ const oldBlockChild = oldBlock.children[currentBlockChildIndex], isChildChanged = !isEqual__default.default(currentBlockChild, oldBlockChild), isTextChanged = !isEqual__default.default(currentBlockChild.text, oldBlockChild?.text), path = [index, currentBlockChildIndex];
11915
12053
  if (isChildChanged)
11916
12054
  if (currentBlockChild._key === oldBlockChild?._key) {
11917
12055
  debug$2("Updating changed child", currentBlockChild, oldBlockChild), slate.Transforms.setNodes(slateEditor, currentBlockChild, {
11918
12056
  at: path
11919
12057
  });
11920
- const isSpanNode2 = slate.Text.isText(currentBlockChild) && currentBlockChild._type === "span" && slate.Text.isText(oldBlockChild) && oldBlockChild._type === "span";
12058
+ const isSpanNode2 = schema.isSpan({
12059
+ schema: context.schema
12060
+ }, currentBlockChild) && schema.isSpan({
12061
+ schema: context.schema
12062
+ }, oldBlockChild);
11921
12063
  isSpanNode2 && isTextChanged ? (oldBlockChild.text.length > 0 && slate.deleteText(slateEditor, {
11922
12064
  at: {
11923
12065
  focus: {
@@ -11938,11 +12080,11 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
11938
12080
  voids: !0
11939
12081
  }));
11940
12082
  } else oldBlockChild ? (debug$2("Replacing child", currentBlockChild), slate.Transforms.removeNodes(slateEditor, {
11941
- at: [currentBlockIndex, currentBlockChildIndex]
12083
+ at: [index, currentBlockChildIndex]
11942
12084
  }), slate.Transforms.insertNodes(slateEditor, currentBlockChild, {
11943
- at: [currentBlockIndex, currentBlockChildIndex]
12085
+ at: [index, currentBlockChildIndex]
11944
12086
  }), slateEditor.onChange()) : oldBlockChild || (debug$2("Inserting new child", currentBlockChild), slate.Transforms.insertNodes(slateEditor, currentBlockChild, {
11945
- at: [currentBlockIndex, currentBlockChildIndex]
12087
+ at: [index, currentBlockChildIndex]
11946
12088
  }), slateEditor.onChange());
11947
12089
  });
11948
12090
  }