@portabletext/editor 1.47.2 → 1.47.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.
package/lib/index.js CHANGED
@@ -12,7 +12,7 @@ import { isSelectionCollapsed, getFocusTextBlock, getFocusSpan, getSelectedBlock
12
12
  import { getBlockEndPoint, getBlockStartPoint, isKeyedSegment } from "./_chunks-es/util.slice-blocks.js";
13
13
  import { getFocusInlineObject } from "./_chunks-es/selector.get-focus-inline-object.js";
14
14
  import { DOMEditor, isDOMNode } from "slate-dom";
15
- import { isSelectionCollapsed as isSelectionCollapsed$1, getSelectionEndPoint } from "./_chunks-es/util.is-selection-collapsed.js";
15
+ import { isSelectionCollapsed as isSelectionCollapsed$1, isEqualSelections, getSelectionEndPoint } from "./_chunks-es/util.is-selection-collapsed.js";
16
16
  import { parseBlocks } from "./_chunks-es/parse-blocks.js";
17
17
  import isEqual from "lodash/isEqual.js";
18
18
  import { isSelectingEntireBlocks } from "./_chunks-es/selector.is-selecting-entire-blocks.js";
@@ -1178,7 +1178,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
1178
1178
  });
1179
1179
  }
1180
1180
  }, [onCut, editorActor, slateEditor]), handlePaste = useCallback((event_1) => {
1181
- const value = PortableTextEditor.getValue(portableTextEditor), path = (slateEditor.selection ? slateRangeToSelection({
1181
+ const value = fromSlateValue(slateEditor.children, editorActor.getSnapshot().context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(slateEditor)), path = (slateEditor.selection ? slateRangeToSelection({
1182
1182
  schema: editorActor.getSnapshot().context.schema,
1183
1183
  editor: slateEditor,
1184
1184
  range: slateEditor.selection
@@ -1261,18 +1261,26 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
1261
1261
  debug("No result from custom paste handler, pasting normally");
1262
1262
  }, [editorActor, onPaste, portableTextEditor, slateEditor]), handleOnFocus = useCallback((event_2) => {
1263
1263
  if (onFocus && onFocus(event_2), !event_2.isDefaultPrevented()) {
1264
- const selection_3 = PortableTextEditor.getSelection(portableTextEditor);
1265
- selection_3 === null && (Transforms.select(slateEditor, Editor.start(slateEditor, [])), slateEditor.onChange()), editorActor.send({
1264
+ const selectionBefore = slateEditor.selection ? slateRangeToSelection({
1265
+ schema: editorActor.getSnapshot().context.schema,
1266
+ editor: slateEditor,
1267
+ range: slateEditor.selection
1268
+ }) : null;
1269
+ editorActor.send({
1266
1270
  type: "notify.focused",
1267
1271
  event: event_2
1268
1272
  });
1269
- const newSelection = PortableTextEditor.getSelection(portableTextEditor);
1270
- selection_3 === newSelection && editorActor.send({
1273
+ const selectionAfter = slateEditor.selection ? slateRangeToSelection({
1274
+ schema: editorActor.getSnapshot().context.schema,
1275
+ editor: slateEditor,
1276
+ range: slateEditor.selection
1277
+ }) : null;
1278
+ selectionBefore && selectionAfter && isEqualSelections(selectionBefore, selectionAfter) && editorActor.send({
1271
1279
  type: "notify.selection",
1272
- selection: selection_3
1280
+ selection: selectionBefore
1273
1281
  });
1274
1282
  }
1275
- }, [editorActor, onFocus, portableTextEditor, slateEditor]), handleClick = useCallback((event_3) => {
1283
+ }, [editorActor, onFocus, slateEditor]), handleClick = useCallback((event_3) => {
1276
1284
  if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
1277
1285
  return;
1278
1286
  const position_3 = getEventPosition({