@portabletext/editor 2.12.2 → 2.13.0

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 (33) hide show
  1. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +64 -5
  2. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  3. package/lib/_chunks-cjs/util.slice-blocks.cjs +1 -0
  4. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
  5. package/lib/_chunks-dts/behavior.types.action.d.cts +64 -72
  6. package/lib/_chunks-dts/behavior.types.action.d.ts +9 -17
  7. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +65 -6
  8. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  9. package/lib/_chunks-es/util.slice-blocks.js +1 -0
  10. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  11. package/lib/index.cjs +69 -60
  12. package/lib/index.cjs.map +1 -1
  13. package/lib/index.js +69 -60
  14. package/lib/index.js.map +1 -1
  15. package/lib/plugins/index.cjs +1 -1
  16. package/lib/plugins/index.d.ts +3 -3
  17. package/lib/plugins/index.js +1 -1
  18. package/lib/selectors/index.cjs +1 -0
  19. package/lib/selectors/index.cjs.map +1 -1
  20. package/lib/selectors/index.d.cts +15 -1
  21. package/lib/selectors/index.d.ts +15 -1
  22. package/lib/selectors/index.js +2 -1
  23. package/package.json +16 -16
  24. package/src/behaviors/behavior.abstract.delete.ts +1 -0
  25. package/src/behaviors/behavior.abstract.keyboard.ts +27 -0
  26. package/src/editor/Editable.tsx +1 -90
  27. package/src/internal-utils/asserters.ts +1 -1
  28. package/src/keyboard-shortcuts/default-keyboard-shortcuts.ts +22 -0
  29. package/src/operations/behavior.operation.delete.ts +6 -24
  30. package/src/selectors/index.ts +1 -0
  31. package/src/selectors/selector.get-mark-state.ts +75 -6
  32. package/src/test/vitest/step-definitions.tsx +1 -8
  33. package/src/types/paths.ts +18 -0
@@ -61,14 +61,7 @@ export const stepDefinitions = [
61
61
  }),
62
62
 
63
63
  Given('the editor is focused', async (context: Context) => {
64
- context.editor.send({
65
- type: 'focus',
66
- })
67
-
68
- await vi.waitFor(() => {
69
- const selection = context.editor.getSnapshot().context.selection
70
- expect(selection).not.toBeNull()
71
- })
64
+ await userEvent.click(context.locator)
72
65
  }),
73
66
 
74
67
  Given(
@@ -1,8 +1,26 @@
1
+ import type {Path} from '@sanity/types'
2
+ import {isRecord} from '../internal-utils/asserters'
3
+
1
4
  /**
2
5
  * @public
3
6
  */
4
7
  export type BlockPath = [{_key: string}]
5
8
 
9
+ /**
10
+ * @public
11
+ */
12
+ export function isBlockPath(path: Path): path is BlockPath {
13
+ const firstSegment = path.at(0)
14
+
15
+ return (
16
+ path.length === 1 &&
17
+ firstSegment !== undefined &&
18
+ isRecord(firstSegment) &&
19
+ '_key' in firstSegment &&
20
+ typeof firstSegment._key === 'string'
21
+ )
22
+ }
23
+
6
24
  /**
7
25
  * @public
8
26
  */