@portabletext/editor 1.47.2 → 1.47.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1164,7 +1164,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1164
1164
  });
1165
1165
  }
1166
1166
  }, [onCut, editorActor, slateEditor]), handlePaste = React.useCallback((event_1) => {
1167
- const value = editorProvider.PortableTextEditor.getValue(portableTextEditor), path = (slateEditor.selection ? editorProvider.slateRangeToSelection({
1167
+ const value = editorProvider.fromSlateValue(slateEditor.children, editorActor.getSnapshot().context.schema.block.name, editorProvider.KEY_TO_VALUE_ELEMENT.get(slateEditor)), path = (slateEditor.selection ? editorProvider.slateRangeToSelection({
1168
1168
  schema: editorActor.getSnapshot().context.schema,
1169
1169
  editor: slateEditor,
1170
1170
  range: slateEditor.selection
@@ -1247,18 +1247,21 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1247
1247
  debug("No result from custom paste handler, pasting normally");
1248
1248
  }, [editorActor, onPaste, portableTextEditor, slateEditor]), handleOnFocus = React.useCallback((event_2) => {
1249
1249
  if (onFocus && onFocus(event_2), !event_2.isDefaultPrevented()) {
1250
- const selection_3 = editorProvider.PortableTextEditor.getSelection(portableTextEditor);
1251
- selection_3 === null && (slate.Transforms.select(slateEditor, slate.Editor.start(slateEditor, [])), slateEditor.onChange()), editorActor.send({
1250
+ editorActor.send({
1252
1251
  type: "notify.focused",
1253
1252
  event: event_2
1254
1253
  });
1255
- const newSelection = editorProvider.PortableTextEditor.getSelection(portableTextEditor);
1256
- selection_3 === newSelection && editorActor.send({
1254
+ const selection_3 = slateEditor.selection ? editorProvider.slateRangeToSelection({
1255
+ schema: editorActor.getSnapshot().context.schema,
1256
+ editor: slateEditor,
1257
+ range: slateEditor.selection
1258
+ }) : null;
1259
+ selection_3 && editorActor.send({
1257
1260
  type: "notify.selection",
1258
1261
  selection: selection_3
1259
1262
  });
1260
1263
  }
1261
- }, [editorActor, onFocus, portableTextEditor, slateEditor]), handleClick = React.useCallback((event_3) => {
1264
+ }, [editorActor, onFocus, slateEditor]), handleClick = React.useCallback((event_3) => {
1262
1265
  if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
1263
1266
  return;
1264
1267
  const position_3 = getEventPosition({