@portabletext/editor 1.52.2 → 1.52.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
@@ -10720,18 +10720,21 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = React.
10720
10720
  debug("No result from custom paste handler, pasting normally");
10721
10721
  }, [editorActor, onPaste, portableTextEditor, relayActor, slateEditor]), handleOnFocus = React.useCallback((event_2) => {
10722
10722
  if (onFocus && onFocus(event_2), !event_2.isDefaultPrevented()) {
10723
- const selection_3 = PortableTextEditor.getSelection(portableTextEditor);
10724
- selection_3 === null && (slate.Transforms.select(slateEditor, slate.Editor.start(slateEditor, [])), slateEditor.onChange()), relayActor.send({
10723
+ relayActor.send({
10725
10724
  type: "focused",
10726
10725
  event: event_2
10727
10726
  });
10728
- const newSelection = PortableTextEditor.getSelection(portableTextEditor);
10729
- selection_3 === newSelection && editorActor.send({
10727
+ const selection_3 = slateEditor.selection ? slateRangeToSelection({
10728
+ schema: editorActor.getSnapshot().context.schema,
10729
+ editor: slateEditor,
10730
+ range: slateEditor.selection
10731
+ }) : null;
10732
+ selection_3 && editorActor.send({
10730
10733
  type: "update selection",
10731
10734
  selection: selection_3
10732
10735
  });
10733
10736
  }
10734
- }, [editorActor, onFocus, slateEditor, portableTextEditor, relayActor]), handleClick = React.useCallback((event_3) => {
10737
+ }, [editorActor, onFocus, slateEditor, relayActor]), handleClick = React.useCallback((event_3) => {
10735
10738
  if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
10736
10739
  return;
10737
10740
  const position_3 = getEventPosition({