@portabletext/editor 2.1.5 → 2.1.7

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.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { c } from "react-compiler-runtime";
2
2
  import React, { useEffect, createContext, useContext, useState, useRef, Component, useMemo, startTransition, useCallback, forwardRef, useImperativeHandle } from "react";
3
- import { useEffectEvent } from "use-effect-event";
4
3
  import { useEditor, EditorContext } from "./_chunks-es/use-editor.js";
5
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
6
5
  import { useSelector, useActorRef } from "@xstate/react";
@@ -8,7 +7,7 @@ import noop from "lodash/noop.js";
8
7
  import { Element as Element$1, Text, Range, Editor, Node, Transforms, Path, Operation, Point, createEditor } from "slate";
9
8
  import { useSelected, useSlateSelector, useSlateStatic, withReact, ReactEditor, Slate, useSlate, Editable } from "slate-react";
10
9
  import debug$f from "debug";
11
- import { DOMEditor, isDOMNode } from "slate-dom";
10
+ import { DOMEditor, isDOMNode, EDITOR_TO_PENDING_SELECTION } from "slate-dom";
12
11
  import { getBlockStartPoint, getBlockKeyFromSelectionPoint, isTextBlock, getChildKeyFromSelectionPoint, blockOffsetToSpanSelectionPoint, isSpan, parseBlock, parseAnnotation, parseInlineObject, isKeyedSegment, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint, getTextBlockText, parseBlocks } from "./_chunks-es/util.slice-blocks.js";
13
12
  import { getBlockEndPoint, isSelectionCollapsed, isEqualSelectionPoints, isEmptyTextBlock } from "./_chunks-es/util.is-selection-collapsed.js";
14
13
  import isEqual from "lodash/isEqual.js";
@@ -36,16 +35,14 @@ import { defineType, defineField } from "@sanity/types";
36
35
  import startCase from "lodash.startcase";
37
36
  import isPlainObject from "lodash/isPlainObject.js";
38
37
  function EditorEventListener(props) {
39
- const $ = c(5), editor = useEditor(), on = useEffectEvent(props.on);
40
- let t0;
41
- $[0] !== editor || $[1] !== on ? (t0 = () => {
42
- const subscription = editor.on("*", on);
38
+ const $ = c(4), editor = useEditor();
39
+ let t0, t1;
40
+ return $[0] !== editor || $[1] !== props.on ? (t0 = () => {
41
+ const subscription = editor.on("*", props.on);
43
42
  return () => {
44
43
  subscription.unsubscribe();
45
44
  };
46
- }, $[0] = editor, $[1] = on, $[2] = t0) : t0 = $[2];
47
- let t1;
48
- return $[3] !== editor ? (t1 = [editor], $[3] = editor, $[4] = t1) : t1 = $[4], useEffect(t0, t1), null;
45
+ }, t1 = [editor, props.on], $[0] = editor, $[1] = props.on, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), useEffect(t0, t1), null;
49
46
  }
50
47
  const rootName = "sanity-pte:";
51
48
  debug$f(rootName);
@@ -1428,7 +1425,7 @@ const insertTextOperationImplementation = ({
1428
1425
  _key: context.keyGenerator(),
1429
1426
  text: operation.text,
1430
1427
  marks: [...activeDecorators, ...activeAnnotations]
1431
- }), operation.editor.decoratorState = {};
1428
+ }), EDITOR_TO_PENDING_SELECTION.set(operation.editor, operation.editor.selection), operation.editor.decoratorState = {};
1432
1429
  };
1433
1430
  function isPortableTextSpan(node) {
1434
1431
  return node._type === "span" && "text" in node && typeof node.text == "string" && (typeof node.marks > "u" || Array.isArray(node.marks) && node.marks.every((mark) => typeof mark == "string"));