@portabletext/editor 1.33.1 → 1.33.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.
Files changed (36) hide show
  1. package/lib/_chunks-cjs/plugin.event-listener.cjs +13 -9
  2. package/lib/_chunks-cjs/plugin.event-listener.cjs.map +1 -1
  3. package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs +28 -22
  4. package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +1 -1
  5. package/lib/_chunks-cjs/util.block-offsets-to-selection.cjs +4 -2
  6. package/lib/_chunks-cjs/util.block-offsets-to-selection.cjs.map +1 -1
  7. package/lib/_chunks-cjs/util.reverse-selection.cjs +34 -15
  8. package/lib/_chunks-cjs/util.reverse-selection.cjs.map +1 -1
  9. package/lib/_chunks-es/plugin.event-listener.js +16 -12
  10. package/lib/_chunks-es/plugin.event-listener.js.map +1 -1
  11. package/lib/_chunks-es/selector.is-at-the-start-of-block.js +29 -23
  12. package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
  13. package/lib/_chunks-es/util.block-offsets-to-selection.js +4 -2
  14. package/lib/_chunks-es/util.block-offsets-to-selection.js.map +1 -1
  15. package/lib/_chunks-es/util.reverse-selection.js +34 -15
  16. package/lib/_chunks-es/util.reverse-selection.js.map +1 -1
  17. package/lib/plugins/index.cjs +8 -4
  18. package/lib/plugins/index.cjs.map +1 -1
  19. package/lib/plugins/index.js +8 -4
  20. package/lib/plugins/index.js.map +1 -1
  21. package/lib/selectors/index.d.cts +2 -0
  22. package/lib/selectors/index.d.ts +2 -0
  23. package/lib/utils/index.d.cts +2 -0
  24. package/lib/utils/index.d.ts +2 -0
  25. package/package.json +2 -2
  26. package/src/behavior-actions/behavior.actions.ts +2 -8
  27. package/src/behaviors/behavior.markdown-emphasis.ts +4 -0
  28. package/src/editor/PortableTextEditor.tsx +1 -1
  29. package/src/internal-utils/get-text-to-emphasize.test.ts +24 -0
  30. package/src/plugins/plugin.event-listener.tsx +1 -1
  31. package/src/selectors/selector.get-caret-word-selection.ts +9 -0
  32. package/src/selectors/selector.get-selection-text.test.ts +383 -36
  33. package/src/selectors/selector.get-selection-text.ts +57 -42
  34. package/src/utils/util.block-offset.test.ts +312 -0
  35. package/src/utils/util.block-offset.ts +39 -7
  36. package/src/utils/util.block-offsets-to-selection.ts +2 -0
@@ -4264,7 +4264,7 @@ const blockSetBehaviorActionImplementation = ({
4264
4264
  "delete.backward": ({
4265
4265
  action
4266
4266
  }) => {
4267
- slate.deleteBackward(action.editor, action.unit);
4267
+ action.editor.deleteBackward(action.unit);
4268
4268
  },
4269
4269
  "delete.forward": ({
4270
4270
  action
@@ -6773,12 +6773,12 @@ function RoutePatchesObservableToEditorActor(props) {
6773
6773
  }, t1 = [props.editorActor, props.patches$], $[0] = props.editorActor, $[1] = props.patches$, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), React.useEffect(t0, t1), null;
6774
6774
  }
6775
6775
  function RouteEventsToChanges(props) {
6776
- const $ = reactCompilerRuntime.c(6);
6776
+ const $ = reactCompilerRuntime.c(7);
6777
6777
  let t0;
6778
6778
  $[0] !== props ? (t0 = (change) => props.onChange(change), $[0] = props, $[1] = t0) : t0 = $[1];
6779
6779
  const handleChange = useEffectEvent.useEffectEvent(t0);
6780
- let t1, t2;
6781
- return $[2] !== handleChange || $[3] !== props.editorActor ? (t1 = () => {
6780
+ let t1;
6781
+ $[2] !== handleChange || $[3] !== props.editorActor ? (t1 = () => {
6782
6782
  debug("Subscribing to editor changes");
6783
6783
  const sub = props.editorActor.on("*", (event) => {
6784
6784
  bb5: switch (event.type) {
@@ -6855,7 +6855,9 @@ function RouteEventsToChanges(props) {
6855
6855
  return () => {
6856
6856
  debug("Unsubscribing to changes"), sub.unsubscribe();
6857
6857
  };
6858
- }, t2 = [props.editorActor, handleChange], $[2] = handleChange, $[3] = props.editorActor, $[4] = t1, $[5] = t2) : (t1 = $[4], t2 = $[5]), React.useEffect(t1, t2), null;
6858
+ }, $[2] = handleChange, $[3] = props.editorActor, $[4] = t1) : t1 = $[4];
6859
+ let t2;
6860
+ return $[5] !== props.editorActor ? (t2 = [props.editorActor], $[5] = props.editorActor, $[6] = t2) : t2 = $[6], React.useEffect(t1, t2), null;
6859
6861
  }
6860
6862
  const EditorContext = React__default.default.createContext(void 0);
6861
6863
  function EditorProvider(props) {
@@ -6895,14 +6897,16 @@ function useEditor() {
6895
6897
  return editor;
6896
6898
  }
6897
6899
  function EventListenerPlugin(props) {
6898
- const $ = reactCompilerRuntime.c(4), editor = useEditor(), on = useEffectEvent.useEffectEvent(props.on);
6899
- let t0, t1;
6900
- return $[0] !== editor || $[1] !== on ? (t0 = () => {
6900
+ const $ = reactCompilerRuntime.c(5), editor = useEditor(), on = useEffectEvent.useEffectEvent(props.on);
6901
+ let t0;
6902
+ $[0] !== editor || $[1] !== on ? (t0 = () => {
6901
6903
  const subscription = editor.on("*", on);
6902
6904
  return () => {
6903
6905
  subscription.unsubscribe();
6904
6906
  };
6905
- }, t1 = [editor, on], $[0] = editor, $[1] = on, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), React.useEffect(t0, t1), null;
6907
+ }, $[0] = editor, $[1] = on, $[2] = t0) : t0 = $[2];
6908
+ let t1;
6909
+ return $[3] !== editor ? (t1 = [editor], $[3] = editor, $[4] = t1) : t1 = $[4], React.useEffect(t0, t1), null;
6906
6910
  }
6907
6911
  exports.EditorActorContext = EditorActorContext;
6908
6912
  exports.EditorProvider = EditorProvider;