@portabletext/editor 1.47.3 → 1.47.5

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.
Files changed (39) hide show
  1. package/lib/_chunks-cjs/editor-provider.cjs +125 -100
  2. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  3. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs +0 -5
  4. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -1
  5. package/lib/_chunks-es/editor-provider.js +126 -101
  6. package/lib/_chunks-es/editor-provider.js.map +1 -1
  7. package/lib/_chunks-es/util.is-selection-collapsed.js +0 -5
  8. package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -1
  9. package/lib/behaviors/index.d.cts +404 -543
  10. package/lib/behaviors/index.d.ts +404 -543
  11. package/lib/index.cjs +6 -14
  12. package/lib/index.cjs.map +1 -1
  13. package/lib/index.d.cts +411 -34
  14. package/lib/index.d.ts +411 -34
  15. package/lib/index.js +7 -15
  16. package/lib/index.js.map +1 -1
  17. package/lib/plugins/index.d.cts +411 -34
  18. package/lib/plugins/index.d.ts +411 -34
  19. package/lib/selectors/index.d.cts +404 -33
  20. package/lib/selectors/index.d.ts +404 -33
  21. package/lib/utils/index.cjs +4 -1
  22. package/lib/utils/index.cjs.map +1 -1
  23. package/lib/utils/index.d.cts +404 -33
  24. package/lib/utils/index.d.ts +404 -33
  25. package/lib/utils/index.js +6 -3
  26. package/lib/utils/index.js.map +1 -1
  27. package/package.json +3 -3
  28. package/src/behavior-actions/behavior.action.insert.text.ts +10 -1
  29. package/src/behavior-actions/behavior.actions.ts +0 -18
  30. package/src/behaviors/behavior.perform-event.ts +55 -65
  31. package/src/behaviors/behavior.types.event.ts +7 -9
  32. package/src/editor/Editable.tsx +14 -27
  33. package/src/editor/create-editor.ts +14 -0
  34. package/src/editor/editor-machine.ts +76 -5
  35. package/src/editor/plugins/create-with-event-listeners.ts +0 -6
  36. package/src/editor/plugins/createWithEditableAPI.ts +2 -8
  37. package/src/editor/with-applying-behavior-actions.ts +2 -2
  38. package/src/behavior-actions/behavior.action.blur.ts +0 -8
  39. package/src/behavior-actions/behavior.action.focus.ts +0 -8
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, isEqualSelections, getSelectionEndPoint } from "./_chunks-es/util.is-selection-collapsed.js";
15
+ import { isSelectionCollapsed as isSelectionCollapsed$1, 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";
@@ -1261,26 +1261,18 @@ 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 selectionBefore = slateEditor.selection ? slateRangeToSelection({
1265
- schema: editorActor.getSnapshot().context.schema,
1266
- editor: slateEditor,
1267
- range: slateEditor.selection
1268
- }) : null;
1269
- editorActor.send({
1264
+ const selection_3 = PortableTextEditor.getSelection(portableTextEditor);
1265
+ selection_3 === null && (Transforms.select(slateEditor, Editor.start(slateEditor, [])), slateEditor.onChange()), editorActor.send({
1270
1266
  type: "notify.focused",
1271
1267
  event: event_2
1272
1268
  });
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({
1269
+ const newSelection = PortableTextEditor.getSelection(portableTextEditor);
1270
+ selection_3 === newSelection && editorActor.send({
1279
1271
  type: "notify.selection",
1280
- selection: selectionBefore
1272
+ selection: selection_3
1281
1273
  });
1282
1274
  }
1283
- }, [editorActor, onFocus, slateEditor]), handleClick = useCallback((event_3) => {
1275
+ }, [editorActor, onFocus, slateEditor, portableTextEditor]), handleClick = useCallback((event_3) => {
1284
1276
  if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
1285
1277
  return;
1286
1278
  const position_3 = getEventPosition({