@portabletext/editor 1.16.1 → 1.16.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.16.1",
3
+ "version": "1.16.3",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -61,7 +61,7 @@
61
61
  "get-random-values-esm": "^1.0.2",
62
62
  "lodash": "^4.17.21",
63
63
  "lodash.startcase": "^4.4.0",
64
- "react-compiler-runtime": "19.0.0-beta-37ed2a7-20241206",
64
+ "react-compiler-runtime": "19.0.0-beta-201e55d-20241215",
65
65
  "slate": "0.112.0",
66
66
  "slate-dom": "^0.111.0",
67
67
  "slate-react": "0.112.0",
@@ -87,9 +87,9 @@
87
87
  "@vitejs/plugin-react": "^4.3.4",
88
88
  "@vitest/browser": "^2.1.8",
89
89
  "@vitest/coverage-istanbul": "^2.1.8",
90
- "babel-plugin-react-compiler": "19.0.0-beta-37ed2a7-20241206",
90
+ "babel-plugin-react-compiler": "19.0.0-beta-201e55d-20241215",
91
91
  "eslint": "8.57.1",
92
- "eslint-plugin-react-compiler": "19.0.0-beta-37ed2a7-20241206",
92
+ "eslint-plugin-react-compiler": "19.0.0-beta-201e55d-20241215",
93
93
  "eslint-plugin-react-hooks": "^5.1.0",
94
94
  "jsdom": "^25.0.1",
95
95
  "react": "^19.0.0",
@@ -23,7 +23,6 @@ import {
23
23
  } from '../editor/plugins/createWithPortableTextMarkModel'
24
24
  import {blockOffsetToSpanSelectionPoint} from '../editor/utils/utils.block-offset'
25
25
  import type {PickFromUnion} from '../type-utils'
26
- import debug from '../utils/debug'
27
26
  import {toSlatePath} from '../utils/paths'
28
27
  import {toSlateRange} from '../utils/ranges'
29
28
  import {fromSlateValue, toSlateValue} from '../utils/values'
@@ -283,8 +282,6 @@ export function performAction({
283
282
  context: BehaviorActionImplementationContext
284
283
  action: BehaviorAction
285
284
  }) {
286
- debug('Behavior action', action)
287
-
288
285
  switch (action.type) {
289
286
  case 'delete.block': {
290
287
  behaviorActionImplementations['delete.block']({
@@ -34,18 +34,33 @@ describe('RangeDecorations', () => {
34
34
  },
35
35
  },
36
36
  ]
37
- const {rerender} = render(
38
- <PortableTextEditorTester
39
- onChange={onChange}
40
- rangeDecorations={rangeDecorations}
41
- ref={editorRef}
42
- schemaType={schemaType}
43
- value={value}
44
- />,
37
+
38
+ const {rerender} = await waitFor(() =>
39
+ render(
40
+ <PortableTextEditorTester
41
+ onChange={onChange}
42
+ rangeDecorations={rangeDecorations}
43
+ ref={editorRef}
44
+ schemaType={schemaType}
45
+ value={value}
46
+ />,
47
+ ),
45
48
  )
49
+
50
+ await waitFor(() => {
51
+ if (editorRef.current) {
52
+ expect(onChange).toHaveBeenCalledWith({
53
+ type: 'value',
54
+ value,
55
+ })
56
+ expect(onChange).toHaveBeenCalledWith({type: 'ready'})
57
+ }
58
+ })
59
+
46
60
  await waitFor(() => {
47
61
  expect([rangeDecorationIteration, 'initial']).toEqual([1, 'initial'])
48
62
  })
63
+
49
64
  // Re-render with the same range decorations
50
65
  rerender(
51
66
  <PortableTextEditorTester
@@ -48,7 +48,7 @@ describe('when PTE would display warnings, instead it self solves', () => {
48
48
  _type: 'myTestBlockType',
49
49
  children: [
50
50
  {
51
- _key: '4',
51
+ _key: '2',
52
52
  _type: 'span',
53
53
  text: 'Hello with a new key',
54
54
  marks: [],
@@ -162,7 +162,7 @@ describe('when PTE would display warnings, instead it self solves', () => {
162
162
  _type: 'myTestBlockType',
163
163
  children: [
164
164
  {
165
- _key: '5',
165
+ _key: '2',
166
166
  _type: 'span',
167
167
  text: '',
168
168
  marks: [],
@@ -176,7 +176,7 @@ describe('when PTE would display warnings, instead it self solves', () => {
176
176
  _type: 'myTestBlockType',
177
177
  children: [
178
178
  {
179
- _key: '6',
179
+ _key: '4',
180
180
  _type: 'span',
181
181
  text: '',
182
182
  marks: [],
@@ -25,7 +25,6 @@ import type {
25
25
  InvalidValueResolution,
26
26
  PortableTextSlateEditor,
27
27
  } from '../types/editor'
28
- import debug from '../utils/debug'
29
28
  import {toPortableTextRange} from '../utils/ranges'
30
29
  import {fromSlateValue} from '../utils/values'
31
30
  import {KEY_TO_VALUE_ELEMENT} from '../utils/weakMaps'
@@ -69,7 +68,7 @@ export type MutationEvent = {
69
68
  export type InternalEditorEvent =
70
69
  | {type: 'normalizing'}
71
70
  | {type: 'done normalizing'}
72
- | {type: 'done syncing'}
71
+ | {type: 'done syncing initial value'}
73
72
  | {
74
73
  type: 'behavior event'
75
74
  behaviorEvent: SyntheticBehaviorEvent | NativeBehaviorEvent
@@ -101,7 +100,11 @@ export type InternalEditorEvent =
101
100
  type: 'update maxBlocks'
102
101
  maxBlocks: number | undefined
103
102
  }
104
- | OmitFromUnion<InternalEditorEmittedEvent, 'type', 'read only' | 'editable'>
103
+ | OmitFromUnion<
104
+ InternalEditorEmittedEvent,
105
+ 'type',
106
+ 'ready' | 'read only' | 'editable'
107
+ >
105
108
 
106
109
  /**
107
110
  * @alpha
@@ -242,8 +245,6 @@ export const editorMachine = setup({
242
245
  'handle behavior event': enqueueActions(({context, event, enqueue}) => {
243
246
  assertEvent(event, ['behavior event'])
244
247
 
245
- debug('Behavior event', event)
246
-
247
248
  const defaultAction =
248
249
  event.behaviorEvent.type === 'copy' ||
249
250
  event.behaviorEvent.type === 'key.down' ||
@@ -427,7 +428,7 @@ export const editorMachine = setup({
427
428
  states: {
428
429
  'determine initial edit mode': {
429
430
  on: {
430
- 'done syncing': [
431
+ 'done syncing initial value': [
431
432
  {
432
433
  target: '#editor.edit mode.read only.read only',
433
434
  guard: ({context}) => context.initialReadOnly,
@@ -502,7 +503,7 @@ export const editorMachine = setup({
502
503
  'mutation': {
503
504
  actions: 'defer event',
504
505
  },
505
- 'done syncing': {
506
+ 'done syncing initial value': {
506
507
  target: 'pristine',
507
508
  },
508
509
  },