@portabletext/editor 4.2.2 → 4.2.3

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.
@@ -1,9 +1,9 @@
1
1
  import * as _portabletext_schema6 from "@portabletext/schema";
2
2
  import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextListBlock, PortableTextObject, PortableTextObject as PortableTextObject$1, PortableTextSpan, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$1, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, TypedObject, defineSchema } from "@portabletext/schema";
3
3
  import { BaseRange, Descendant, Operation, Range } from "slate";
4
- import * as xstate71 from "xstate";
4
+ import * as xstate75 from "xstate";
5
5
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
6
- import * as react10 from "react";
6
+ import * as react8 from "react";
7
7
  import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
8
8
  import { Patch, Patch as Patch$1 } from "@portabletext/patches";
9
9
  import { Observable, Subject } from "rxjs";
@@ -306,7 +306,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
306
306
  componentDidUpdate(prevProps: PortableTextEditorProps): void;
307
307
  componentWillUnmount(): void;
308
308
  setEditable: (editable: EditableAPI) => void;
309
- render(): react10.JSX.Element;
309
+ render(): react8.JSX.Element;
310
310
  /**
311
311
  * @deprecated
312
312
  * Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
@@ -715,7 +715,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
715
715
  * ```
716
716
  * @group Components
717
717
  */
718
- declare const PortableTextEditable: react10.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react10.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
718
+ declare const PortableTextEditable: react8.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react8.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
719
719
  /** @beta */
720
720
  interface EditableAPIDeleteOptions {
721
721
  mode?: 'blocks' | 'children' | 'selected';
@@ -1375,7 +1375,7 @@ type EditorActor = ActorRefFrom<typeof editorMachine>;
1375
1375
  /**
1376
1376
  * @internal
1377
1377
  */
1378
- declare const editorMachine: xstate71.StateMachine<{
1378
+ declare const editorMachine: xstate75.StateMachine<{
1379
1379
  behaviors: Set<BehaviorConfig>;
1380
1380
  behaviorIndex: BehaviorIndex;
1381
1381
  abstractBehaviorIndex: BehaviorIndex;
@@ -1439,46 +1439,46 @@ declare const editorMachine: xstate71.StateMachine<{
1439
1439
  editor: PortableTextSlateEditor;
1440
1440
  }, {}, never, {
1441
1441
  type: "add behavior to context";
1442
- params: xstate71.NonReducibleUnknown;
1442
+ params: xstate75.NonReducibleUnknown;
1443
1443
  } | {
1444
1444
  type: "remove behavior from context";
1445
- params: xstate71.NonReducibleUnknown;
1445
+ params: xstate75.NonReducibleUnknown;
1446
1446
  } | {
1447
1447
  type: "add slate editor to context";
1448
- params: xstate71.NonReducibleUnknown;
1448
+ params: xstate75.NonReducibleUnknown;
1449
1449
  } | {
1450
1450
  type: "emit patch event";
1451
- params: xstate71.NonReducibleUnknown;
1451
+ params: xstate75.NonReducibleUnknown;
1452
1452
  } | {
1453
1453
  type: "emit mutation event";
1454
- params: xstate71.NonReducibleUnknown;
1454
+ params: xstate75.NonReducibleUnknown;
1455
1455
  } | {
1456
1456
  type: "emit read only";
1457
- params: xstate71.NonReducibleUnknown;
1457
+ params: xstate75.NonReducibleUnknown;
1458
1458
  } | {
1459
1459
  type: "emit editable";
1460
- params: xstate71.NonReducibleUnknown;
1460
+ params: xstate75.NonReducibleUnknown;
1461
1461
  } | {
1462
1462
  type: "defer event";
1463
- params: xstate71.NonReducibleUnknown;
1463
+ params: xstate75.NonReducibleUnknown;
1464
1464
  } | {
1465
1465
  type: "emit pending events";
1466
- params: xstate71.NonReducibleUnknown;
1466
+ params: xstate75.NonReducibleUnknown;
1467
1467
  } | {
1468
1468
  type: "emit ready";
1469
- params: xstate71.NonReducibleUnknown;
1469
+ params: xstate75.NonReducibleUnknown;
1470
1470
  } | {
1471
1471
  type: "clear pending events";
1472
- params: xstate71.NonReducibleUnknown;
1472
+ params: xstate75.NonReducibleUnknown;
1473
1473
  } | {
1474
1474
  type: "defer incoming patches";
1475
- params: xstate71.NonReducibleUnknown;
1475
+ params: xstate75.NonReducibleUnknown;
1476
1476
  } | {
1477
1477
  type: "emit pending incoming patches";
1478
- params: xstate71.NonReducibleUnknown;
1478
+ params: xstate75.NonReducibleUnknown;
1479
1479
  } | {
1480
1480
  type: "clear pending incoming patches";
1481
- params: xstate71.NonReducibleUnknown;
1481
+ params: xstate75.NonReducibleUnknown;
1482
1482
  } | {
1483
1483
  type: "handle blur";
1484
1484
  params: unknown;
@@ -1490,7 +1490,7 @@ declare const editorMachine: xstate71.StateMachine<{
1490
1490
  params: unknown;
1491
1491
  } | {
1492
1492
  type: "index behaviors";
1493
- params: xstate71.NonReducibleUnknown;
1493
+ params: xstate75.NonReducibleUnknown;
1494
1494
  }, {
1495
1495
  type: "slate is busy";
1496
1496
  params: unknown;
@@ -1520,9 +1520,9 @@ declare const editorMachine: xstate71.StateMachine<{
1520
1520
  readOnly?: boolean;
1521
1521
  schema: EditorSchema;
1522
1522
  initialValue?: Array<PortableTextBlock>;
1523
- }, xstate71.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
1523
+ }, xstate75.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
1524
1524
  type: "blurred";
1525
- event: react10.FocusEvent<HTMLDivElement, Element>;
1525
+ event: react8.FocusEvent<HTMLDivElement, Element>;
1526
1526
  } | {
1527
1527
  type: "done loading";
1528
1528
  } | {
@@ -1534,7 +1534,7 @@ declare const editorMachine: xstate71.StateMachine<{
1534
1534
  data: unknown;
1535
1535
  } | {
1536
1536
  type: "focused";
1537
- event: react10.FocusEvent<HTMLDivElement, Element>;
1537
+ event: react8.FocusEvent<HTMLDivElement, Element>;
1538
1538
  } | {
1539
1539
  type: "invalid value";
1540
1540
  resolution: InvalidValueResolution | null;
@@ -1551,7 +1551,7 @@ declare const editorMachine: xstate71.StateMachine<{
1551
1551
  } | {
1552
1552
  type: "value changed";
1553
1553
  value: Array<PortableTextBlock> | undefined;
1554
- }, xstate71.MetaObject, {
1554
+ }, xstate75.MetaObject, {
1555
1555
  id: "editor";
1556
1556
  states: {
1557
1557
  readonly 'edit mode': {
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ import { c } from "react/compiler-runtime";
3
3
  import { useSelector, useActorRef } from "@xstate/react";
4
4
  import { createContext, useContext, useRef, useState, useEffect, forwardRef, Component, startTransition } from "react";
5
5
  import { Element as Element$1, Text, Range, Editor, Node, Point, Path, Transforms, createEditor, deleteText, Operation } from "slate";
6
- import { useSlateStatic, ReactEditor, useSlate, Editable, withReact, Slate } from "slate-react";
6
+ import { useSlateStatic, useSlateSelector, ReactEditor, useSlate, Editable, withReact, Slate } from "slate-react";
7
7
  import rawDebug from "debug";
8
8
  import { DOMEditor, isDOMNode, EDITOR_TO_PENDING_SELECTION, IS_FOCUSED, IS_READ_ONLY } from "slate-dom";
9
9
  import { getBlockEndPoint, getBlockStartPoint, getBlockKeyFromSelectionPoint, isSelectionCollapsed, isKeyedSegment, isEqualSelectionPoints, getChildKeyFromSelectionPoint, blockOffsetToSpanSelectionPoint, defaultKeyGenerator, parseBlocks, parseBlock, isListBlock, isTypedObject, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint as getSelectionEndPoint$1, parseAnnotation, parseMarkDefs, parseSpan, parseInlineObject } from "./_chunks-es/util.slice-blocks.js";
@@ -1575,90 +1575,90 @@ function RenderChild$1({
1575
1575
  });
1576
1576
  }
1577
1577
  function RenderTextBlock(props) {
1578
- const $ = c(77), blockRef = useRef(null), {
1578
+ const $ = c(76), blockRef = useRef(null), {
1579
1579
  selectedBlockKeys,
1580
1580
  focusedBlockKey
1581
1581
  } = useContext(SelectionStateContext);
1582
1582
  let t0;
1583
1583
  $[0] !== props.textBlock._key || $[1] !== selectedBlockKeys ? (t0 = selectedBlockKeys.has(props.textBlock._key), $[0] = props.textBlock._key, $[1] = selectedBlockKeys, $[2] = t0) : t0 = $[2];
1584
- const selected = t0, focused = focusedBlockKey === props.textBlock._key, slateEditor = useSlateStatic();
1584
+ const selected = t0, focused = focusedBlockKey === props.textBlock._key;
1585
1585
  let t1;
1586
- $[3] !== props.textBlock._key || $[4] !== slateEditor.listIndexMap ? (t1 = slateEditor.listIndexMap.get(props.textBlock._key), $[3] = props.textBlock._key, $[4] = slateEditor.listIndexMap, $[5] = t1) : t1 = $[5];
1587
- const listIndex = t1;
1586
+ $[3] !== props.textBlock._key ? (t1 = (editor) => editor.listIndexMap.get(props.textBlock._key), $[3] = props.textBlock._key, $[4] = t1) : t1 = $[4];
1587
+ const listIndex = useSlateSelector(t1);
1588
1588
  let children = props.children;
1589
1589
  if (props.renderStyle && props.textBlock.style) {
1590
1590
  let t22;
1591
- $[6] !== props.legacySchema || $[7] !== props.textBlock.style ? (t22 = props.textBlock.style !== void 0 ? props.legacySchema.styles.find((style) => style.value === props.textBlock.style) : void 0, $[6] = props.legacySchema, $[7] = props.textBlock.style, $[8] = t22) : t22 = $[8];
1591
+ $[5] !== props.legacySchema || $[6] !== props.textBlock.style ? (t22 = props.textBlock.style !== void 0 ? props.legacySchema.styles.find((style) => style.value === props.textBlock.style) : void 0, $[5] = props.legacySchema, $[6] = props.textBlock.style, $[7] = t22) : t22 = $[7];
1592
1592
  const legacyStyleSchemaType = t22;
1593
1593
  if (legacyStyleSchemaType) {
1594
1594
  let t32;
1595
- $[9] !== props.textBlock._key ? (t32 = [{
1595
+ $[8] !== props.textBlock._key ? (t32 = [{
1596
1596
  _key: props.textBlock._key
1597
- }], $[9] = props.textBlock._key, $[10] = t32) : t32 = $[10];
1597
+ }], $[8] = props.textBlock._key, $[9] = t32) : t32 = $[9];
1598
1598
  let t42;
1599
- $[11] !== children || $[12] !== focused || $[13] !== legacyStyleSchemaType || $[14] !== props.renderStyle || $[15] !== props.textBlock || $[16] !== selected || $[17] !== t32 ? (t42 = /* @__PURE__ */ jsx(RenderStyle, { renderStyle: props.renderStyle, block: props.textBlock, editorElementRef: blockRef, focused, path: t32, schemaType: legacyStyleSchemaType, selected, value: props.textBlock.style, children }), $[11] = children, $[12] = focused, $[13] = legacyStyleSchemaType, $[14] = props.renderStyle, $[15] = props.textBlock, $[16] = selected, $[17] = t32, $[18] = t42) : t42 = $[18], children = t42;
1599
+ $[10] !== children || $[11] !== focused || $[12] !== legacyStyleSchemaType || $[13] !== props.renderStyle || $[14] !== props.textBlock || $[15] !== selected || $[16] !== t32 ? (t42 = /* @__PURE__ */ jsx(RenderStyle, { renderStyle: props.renderStyle, block: props.textBlock, editorElementRef: blockRef, focused, path: t32, schemaType: legacyStyleSchemaType, selected, value: props.textBlock.style, children }), $[10] = children, $[11] = focused, $[12] = legacyStyleSchemaType, $[13] = props.renderStyle, $[14] = props.textBlock, $[15] = selected, $[16] = t32, $[17] = t42) : t42 = $[17], children = t42;
1600
1600
  } else
1601
1601
  console.error(`Unable to find Schema type for text block style ${props.textBlock.style}`);
1602
1602
  }
1603
1603
  if (props.renderListItem && props.textBlock.listItem) {
1604
1604
  let t22;
1605
- if ($[19] !== props.legacySchema.lists || $[20] !== props.textBlock.listItem) {
1605
+ if ($[18] !== props.legacySchema.lists || $[19] !== props.textBlock.listItem) {
1606
1606
  let t32;
1607
- $[22] !== props.textBlock.listItem ? (t32 = (list) => list.value === props.textBlock.listItem, $[22] = props.textBlock.listItem, $[23] = t32) : t32 = $[23], t22 = props.legacySchema.lists.find(t32), $[19] = props.legacySchema.lists, $[20] = props.textBlock.listItem, $[21] = t22;
1607
+ $[21] !== props.textBlock.listItem ? (t32 = (list) => list.value === props.textBlock.listItem, $[21] = props.textBlock.listItem, $[22] = t32) : t32 = $[22], t22 = props.legacySchema.lists.find(t32), $[18] = props.legacySchema.lists, $[19] = props.textBlock.listItem, $[20] = t22;
1608
1608
  } else
1609
- t22 = $[21];
1609
+ t22 = $[20];
1610
1610
  const legacyListItemSchemaType = t22;
1611
1611
  if (legacyListItemSchemaType) {
1612
1612
  const t32 = props.textBlock.level ?? 1;
1613
1613
  let t42;
1614
- $[24] !== props.textBlock._key ? (t42 = [{
1614
+ $[23] !== props.textBlock._key ? (t42 = [{
1615
1615
  _key: props.textBlock._key
1616
- }], $[24] = props.textBlock._key, $[25] = t42) : t42 = $[25];
1616
+ }], $[23] = props.textBlock._key, $[24] = t42) : t42 = $[24];
1617
1617
  let t52;
1618
- $[26] !== children || $[27] !== focused || $[28] !== legacyListItemSchemaType || $[29] !== props.renderListItem || $[30] !== props.textBlock || $[31] !== selected || $[32] !== t32 || $[33] !== t42 ? (t52 = /* @__PURE__ */ jsx(RenderListItem, { renderListItem: props.renderListItem, block: props.textBlock, editorElementRef: blockRef, focused, level: t32, path: t42, selected, value: props.textBlock.listItem, schemaType: legacyListItemSchemaType, children }), $[26] = children, $[27] = focused, $[28] = legacyListItemSchemaType, $[29] = props.renderListItem, $[30] = props.textBlock, $[31] = selected, $[32] = t32, $[33] = t42, $[34] = t52) : t52 = $[34], children = t52;
1618
+ $[25] !== children || $[26] !== focused || $[27] !== legacyListItemSchemaType || $[28] !== props.renderListItem || $[29] !== props.textBlock || $[30] !== selected || $[31] !== t32 || $[32] !== t42 ? (t52 = /* @__PURE__ */ jsx(RenderListItem, { renderListItem: props.renderListItem, block: props.textBlock, editorElementRef: blockRef, focused, level: t32, path: t42, selected, value: props.textBlock.listItem, schemaType: legacyListItemSchemaType, children }), $[25] = children, $[26] = focused, $[27] = legacyListItemSchemaType, $[28] = props.renderListItem, $[29] = props.textBlock, $[30] = selected, $[31] = t32, $[32] = t42, $[33] = t52) : t52 = $[33], children = t52;
1619
1619
  } else
1620
1620
  console.error(`Unable to find Schema type for text block list item ${props.textBlock.listItem}`);
1621
1621
  }
1622
1622
  const t2 = props.attributes;
1623
1623
  let t3;
1624
- $[35] !== props.textBlock.style ? (t3 = props.textBlock.style ? [`pt-text-block-style-${props.textBlock.style}`] : [], $[35] = props.textBlock.style, $[36] = t3) : t3 = $[36];
1624
+ $[34] !== props.textBlock.style ? (t3 = props.textBlock.style ? [`pt-text-block-style-${props.textBlock.style}`] : [], $[34] = props.textBlock.style, $[35] = t3) : t3 = $[35];
1625
1625
  let t4;
1626
- $[37] !== props.textBlock.level || $[38] !== props.textBlock.listItem ? (t4 = props.textBlock.listItem ? ["pt-list-item", `pt-list-item-${props.textBlock.listItem}`, `pt-list-item-level-${props.textBlock.level ?? 1}`] : [], $[37] = props.textBlock.level, $[38] = props.textBlock.listItem, $[39] = t4) : t4 = $[39];
1626
+ $[36] !== props.textBlock.level || $[37] !== props.textBlock.listItem ? (t4 = props.textBlock.listItem ? ["pt-list-item", `pt-list-item-${props.textBlock.listItem}`, `pt-list-item-level-${props.textBlock.level ?? 1}`] : [], $[36] = props.textBlock.level, $[37] = props.textBlock.listItem, $[38] = t4) : t4 = $[38];
1627
1627
  let t5;
1628
- $[40] !== t3 || $[41] !== t4 ? (t5 = ["pt-block", "pt-text-block", ...t3, ...t4], $[40] = t3, $[41] = t4, $[42] = t5) : t5 = $[42];
1628
+ $[39] !== t3 || $[40] !== t4 ? (t5 = ["pt-block", "pt-text-block", ...t3, ...t4], $[39] = t3, $[40] = t4, $[41] = t5) : t5 = $[41];
1629
1629
  const t6 = t5.join(" ");
1630
1630
  let t7;
1631
- $[43] !== props.textBlock.listItem ? (t7 = props.textBlock.listItem !== void 0 ? {
1631
+ $[42] !== props.textBlock.listItem ? (t7 = props.textBlock.listItem !== void 0 ? {
1632
1632
  "data-list-item": props.textBlock.listItem
1633
- } : {}, $[43] = props.textBlock.listItem, $[44] = t7) : t7 = $[44];
1633
+ } : {}, $[42] = props.textBlock.listItem, $[43] = t7) : t7 = $[43];
1634
1634
  let t8;
1635
- $[45] !== props.textBlock.level ? (t8 = props.textBlock.level !== void 0 ? {
1635
+ $[44] !== props.textBlock.level ? (t8 = props.textBlock.level !== void 0 ? {
1636
1636
  "data-level": props.textBlock.level
1637
- } : {}, $[45] = props.textBlock.level, $[46] = t8) : t8 = $[46];
1637
+ } : {}, $[44] = props.textBlock.level, $[45] = t8) : t8 = $[45];
1638
1638
  let t9;
1639
- $[47] !== props.textBlock.style ? (t9 = props.textBlock.style !== void 0 ? {
1639
+ $[46] !== props.textBlock.style ? (t9 = props.textBlock.style !== void 0 ? {
1640
1640
  "data-style": props.textBlock.style
1641
- } : {}, $[47] = props.textBlock.style, $[48] = t9) : t9 = $[48];
1641
+ } : {}, $[46] = props.textBlock.style, $[47] = t9) : t9 = $[47];
1642
1642
  let t10;
1643
- $[49] !== listIndex ? (t10 = listIndex !== void 0 ? {
1643
+ $[48] !== listIndex ? (t10 = listIndex !== void 0 ? {
1644
1644
  "data-list-index": listIndex
1645
- } : {}, $[49] = listIndex, $[50] = t10) : t10 = $[50];
1645
+ } : {}, $[48] = listIndex, $[49] = t10) : t10 = $[49];
1646
1646
  let t11;
1647
- $[51] !== props.dropPosition ? (t11 = props.dropPosition === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[51] = props.dropPosition, $[52] = t11) : t11 = $[52];
1647
+ $[50] !== props.dropPosition ? (t11 = props.dropPosition === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[50] = props.dropPosition, $[51] = t11) : t11 = $[51];
1648
1648
  let t12;
1649
- $[53] !== children || $[54] !== focused || $[55] !== props.legacySchema || $[56] !== props.renderBlock || $[57] !== props.textBlock || $[58] !== selected ? (t12 = props.renderBlock ? /* @__PURE__ */ jsx(RenderBlock, { renderBlock: props.renderBlock, editorElementRef: blockRef, focused, level: props.textBlock.level, listItem: props.textBlock.listItem, path: [{
1649
+ $[52] !== children || $[53] !== focused || $[54] !== props.legacySchema || $[55] !== props.renderBlock || $[56] !== props.textBlock || $[57] !== selected ? (t12 = props.renderBlock ? /* @__PURE__ */ jsx(RenderBlock, { renderBlock: props.renderBlock, editorElementRef: blockRef, focused, level: props.textBlock.level, listItem: props.textBlock.listItem, path: [{
1650
1650
  _key: props.textBlock._key
1651
- }], selected, schemaType: props.legacySchema.block, style: props.textBlock.style, type: props.legacySchema.block, value: props.textBlock, children }) : children, $[53] = children, $[54] = focused, $[55] = props.legacySchema, $[56] = props.renderBlock, $[57] = props.textBlock, $[58] = selected, $[59] = t12) : t12 = $[59];
1651
+ }], selected, schemaType: props.legacySchema.block, style: props.textBlock.style, type: props.legacySchema.block, value: props.textBlock, children }) : children, $[52] = children, $[53] = focused, $[54] = props.legacySchema, $[55] = props.renderBlock, $[56] = props.textBlock, $[57] = selected, $[58] = t12) : t12 = $[58];
1652
1652
  let t13;
1653
- $[60] !== t12 ? (t13 = /* @__PURE__ */ jsx("div", { ref: blockRef, children: t12 }), $[60] = t12, $[61] = t13) : t13 = $[61];
1653
+ $[59] !== t12 ? (t13 = /* @__PURE__ */ jsx("div", { ref: blockRef, children: t12 }), $[59] = t12, $[60] = t13) : t13 = $[60];
1654
1654
  let t14;
1655
- $[62] !== props.dropPosition ? (t14 = props.dropPosition === "end" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[62] = props.dropPosition, $[63] = t14) : t14 = $[63];
1655
+ $[61] !== props.dropPosition ? (t14 = props.dropPosition === "end" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[61] = props.dropPosition, $[62] = t14) : t14 = $[62];
1656
1656
  let t15;
1657
- return $[64] !== props.attributes || $[65] !== props.spellCheck || $[66] !== props.textBlock._key || $[67] !== props.textBlock._type || $[68] !== t10 || $[69] !== t11 || $[70] !== t13 || $[71] !== t14 || $[72] !== t6 || $[73] !== t7 || $[74] !== t8 || $[75] !== t9 ? (t15 = /* @__PURE__ */ jsxs("div", { ...t2, className: t6, spellCheck: props.spellCheck, "data-block-key": props.textBlock._key, "data-block-name": props.textBlock._type, "data-block-type": "text", ...t7, ...t8, ...t9, ...t10, children: [
1657
+ return $[63] !== props.attributes || $[64] !== props.spellCheck || $[65] !== props.textBlock._key || $[66] !== props.textBlock._type || $[67] !== t10 || $[68] !== t11 || $[69] !== t13 || $[70] !== t14 || $[71] !== t6 || $[72] !== t7 || $[73] !== t8 || $[74] !== t9 ? (t15 = /* @__PURE__ */ jsxs("div", { ...t2, className: t6, spellCheck: props.spellCheck, "data-block-key": props.textBlock._key, "data-block-name": props.textBlock._type, "data-block-type": "text", ...t7, ...t8, ...t9, ...t10, children: [
1658
1658
  t11,
1659
1659
  t13,
1660
1660
  t14
1661
- ] }), $[64] = props.attributes, $[65] = props.spellCheck, $[66] = props.textBlock._key, $[67] = props.textBlock._type, $[68] = t10, $[69] = t11, $[70] = t13, $[71] = t14, $[72] = t6, $[73] = t7, $[74] = t8, $[75] = t9, $[76] = t15) : t15 = $[76], t15;
1661
+ ] }), $[63] = props.attributes, $[64] = props.spellCheck, $[65] = props.textBlock._key, $[66] = props.textBlock._type, $[67] = t10, $[68] = t11, $[69] = t13, $[70] = t14, $[71] = t6, $[72] = t7, $[73] = t8, $[74] = t9, $[75] = t15) : t15 = $[75], t15;
1662
1662
  }
1663
1663
  function RenderBlock({
1664
1664
  renderBlock,
@@ -9667,69 +9667,69 @@ const addAnnotationOperationImplementation = ({
9667
9667
  },
9668
9668
  blockIndexMap: operation.editor.blockIndexMap
9669
9669
  }) : operation.editor.selection;
9670
- if (!at)
9671
- throw new Error("Unable to add decorator without a selection");
9672
- if (Range.isExpanded(at)) {
9673
- const rangeRef = Editor.rangeRef(editor, at, {
9674
- affinity: "inward"
9675
- }), [start, end] = Range.edges(at), endAtEndOfNode = Editor.isEnd(editor, end, end.path);
9676
- Transforms.splitNodes(editor, {
9677
- at: end,
9678
- match: Text.isText,
9679
- mode: "lowest",
9680
- voids: !1,
9681
- always: !endAtEndOfNode
9682
- });
9683
- const startAtStartOfNode = Editor.isStart(editor, start, start.path);
9684
- if (Transforms.splitNodes(editor, {
9685
- at: start,
9686
- match: Text.isText,
9687
- mode: "lowest",
9688
- voids: !1,
9689
- always: !startAtStartOfNode
9690
- }), at = rangeRef.unref(), !at)
9691
- throw new Error("Unable to add decorator without a selection");
9692
- operation.at || Transforms.select(editor, at);
9693
- const splitTextNodes = Editor.nodes(editor, {
9694
- at,
9695
- match: Text.isText
9696
- });
9697
- for (const [node, path] of splitTextNodes) {
9698
- const marks = [...(Array.isArray(node.marks) ? node.marks : []).filter((eMark) => eMark !== mark), mark];
9699
- Transforms.setNodes(editor, {
9700
- marks
9701
- }, {
9702
- at: path,
9670
+ if (at) {
9671
+ if (Range.isExpanded(at)) {
9672
+ const rangeRef = Editor.rangeRef(editor, at, {
9673
+ affinity: "inward"
9674
+ }), [start, end] = Range.edges(at), endAtEndOfNode = Editor.isEnd(editor, end, end.path);
9675
+ Transforms.splitNodes(editor, {
9676
+ at: end,
9703
9677
  match: Text.isText,
9704
- split: !0,
9705
- hanging: !0
9678
+ mode: "lowest",
9679
+ voids: !1,
9680
+ always: !endAtEndOfNode
9706
9681
  });
9707
- }
9708
- } else {
9709
- if (!Array.from(Editor.nodes(editor, {
9710
- at,
9711
- match: (node) => editor.isTextSpan(node)
9712
- }))?.at(0))
9713
- return;
9714
- const [block, blockPath] = Editor.node(editor, at, {
9715
- depth: 1
9716
- }), lonelyEmptySpan = editor.isTextBlock(block) && block.children.length === 1 && editor.isTextSpan(block.children[0]) && block.children[0].text === "" ? block.children[0] : void 0;
9717
- if (lonelyEmptySpan) {
9718
- const existingMarks = lonelyEmptySpan.marks ?? [], existingMarksWithoutDecorator = existingMarks.filter((existingMark) => existingMark !== mark);
9719
- Transforms.setNodes(editor, {
9720
- marks: existingMarks.length === existingMarksWithoutDecorator.length ? [...existingMarks, mark] : existingMarksWithoutDecorator
9721
- }, {
9722
- at: blockPath,
9723
- match: (node) => editor.isTextSpan(node)
9682
+ const startAtStartOfNode = Editor.isStart(editor, start, start.path);
9683
+ if (Transforms.splitNodes(editor, {
9684
+ at: start,
9685
+ match: Text.isText,
9686
+ mode: "lowest",
9687
+ voids: !1,
9688
+ always: !startAtStartOfNode
9689
+ }), at = rangeRef.unref(), !at)
9690
+ throw new Error("Unable to add decorator without a selection");
9691
+ operation.at || Transforms.select(editor, at);
9692
+ const splitTextNodes = Editor.nodes(editor, {
9693
+ at,
9694
+ match: Text.isText
9724
9695
  });
9725
- } else
9726
- editor.decoratorState[mark] = !0;
9727
- }
9728
- if (editor.selection) {
9729
- const selection = editor.selection;
9730
- editor.selection = {
9731
- ...selection
9732
- };
9696
+ for (const [node, path] of splitTextNodes) {
9697
+ const marks = [...(Array.isArray(node.marks) ? node.marks : []).filter((eMark) => eMark !== mark), mark];
9698
+ Transforms.setNodes(editor, {
9699
+ marks
9700
+ }, {
9701
+ at: path,
9702
+ match: Text.isText,
9703
+ split: !0,
9704
+ hanging: !0
9705
+ });
9706
+ }
9707
+ } else {
9708
+ if (!Array.from(Editor.nodes(editor, {
9709
+ at,
9710
+ match: (node) => editor.isTextSpan(node)
9711
+ }))?.at(0))
9712
+ return;
9713
+ const [block, blockPath] = Editor.node(editor, at, {
9714
+ depth: 1
9715
+ }), lonelyEmptySpan = editor.isTextBlock(block) && block.children.length === 1 && editor.isTextSpan(block.children[0]) && block.children[0].text === "" ? block.children[0] : void 0;
9716
+ if (lonelyEmptySpan) {
9717
+ const existingMarks = lonelyEmptySpan.marks ?? [], existingMarksWithoutDecorator = existingMarks.filter((existingMark) => existingMark !== mark);
9718
+ Transforms.setNodes(editor, {
9719
+ marks: existingMarks.length === existingMarksWithoutDecorator.length ? [...existingMarks, mark] : existingMarksWithoutDecorator
9720
+ }, {
9721
+ at: blockPath,
9722
+ match: (node) => editor.isTextSpan(node)
9723
+ });
9724
+ } else
9725
+ editor.decoratorState[mark] = !0;
9726
+ }
9727
+ if (editor.selection) {
9728
+ const selection = editor.selection;
9729
+ editor.selection = {
9730
+ ...selection
9731
+ };
9732
+ }
9733
9733
  }
9734
9734
  }, decoratorRemoveOperationImplementation = ({
9735
9735
  context,