@portabletext/editor 1.52.6 → 1.52.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.52.6",
3
+ "version": "1.52.7",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -80,8 +80,8 @@
80
80
  "slate-react": "0.114.2",
81
81
  "use-effect-event": "^1.0.2",
82
82
  "xstate": "^5.19.4",
83
- "@portabletext/patches": "1.1.4",
84
- "@portabletext/block-tools": "1.1.30"
83
+ "@portabletext/block-tools": "1.1.30",
84
+ "@portabletext/patches": "1.1.4"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@portabletext/toolkit": "^2.0.17",
@@ -89,16 +89,15 @@
89
89
  "@sanity/pkg-utils": "^7.2.4",
90
90
  "@sanity/schema": "^3.92.0",
91
91
  "@sanity/types": "^3.92.0",
92
- "@testing-library/jest-dom": "^6.6.3",
93
92
  "@testing-library/react": "^16.3.0",
94
93
  "@types/debug": "^4.1.12",
95
94
  "@types/lodash": "^4.17.16",
96
95
  "@types/lodash.startcase": "^4.4.9",
97
- "@types/react": "^19.1.4",
98
- "@types/react-dom": "^19.1.5",
96
+ "@types/react": "^19.1.8",
97
+ "@types/react-dom": "^19.1.6",
99
98
  "@typescript-eslint/eslint-plugin": "^8.33.0",
100
99
  "@typescript-eslint/parser": "^8.33.0",
101
- "@vitejs/plugin-react": "^4.4.1",
100
+ "@vitejs/plugin-react": "^4.5.2",
102
101
  "@vitest/browser": "^3.2.3",
103
102
  "@vitest/coverage-istanbul": "^3.2.3",
104
103
  "babel-plugin-react-compiler": "19.1.0-rc.1",
@@ -112,7 +111,7 @@
112
111
  "vite": "^6.2.5",
113
112
  "vitest": "^3.2.3",
114
113
  "vitest-browser-react": "^0.2.0",
115
- "racejar": "1.2.5"
114
+ "racejar": "1.2.6"
116
115
  },
117
116
  "peerDependencies": {
118
117
  "@sanity/schema": "^3.92.0",
@@ -15,7 +15,7 @@ import {
15
15
  type MutableRefObject,
16
16
  type TextareaHTMLAttributes,
17
17
  } from 'react'
18
- import {Transforms, type Text} from 'slate'
18
+ import {Editor, Transforms, type Text} from 'slate'
19
19
  import {
20
20
  ReactEditor,
21
21
  Editable as SlateEditable,
@@ -29,7 +29,7 @@ import {parseBlocks} from '../internal-utils/parse-blocks'
29
29
  import {toSlateRange} from '../internal-utils/ranges'
30
30
  import {normalizeSelection} from '../internal-utils/selection'
31
31
  import {slateRangeToSelection} from '../internal-utils/slate-utils'
32
- import {fromSlateValue} from '../internal-utils/values'
32
+ import {fromSlateValue, isEqualToEmptyEditor} from '../internal-utils/values'
33
33
  import {KEY_TO_VALUE_ELEMENT} from '../internal-utils/weakMaps'
34
34
  import type {
35
35
  EditorSelection,
@@ -534,9 +534,20 @@ export const PortableTextEditable = forwardRef<
534
534
 
535
535
  if (!event.isDefaultPrevented()) {
536
536
  relayActor.send({type: 'focused', event})
537
+
538
+ if (
539
+ !slateEditor.selection &&
540
+ isEqualToEmptyEditor(
541
+ slateEditor.children,
542
+ editorActor.getSnapshot().context.schema,
543
+ )
544
+ ) {
545
+ Transforms.select(slateEditor, Editor.start(slateEditor, []))
546
+ slateEditor.onChange()
547
+ }
537
548
  }
538
549
  },
539
- [onFocus, relayActor],
550
+ [editorActor, onFocus, relayActor, slateEditor],
540
551
  )
541
552
 
542
553
  const handleClick = useCallback(