@portabletext/editor 1.30.2 → 1.30.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.30.2",
3
+ "version": "1.30.3",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -80,14 +80,14 @@
80
80
  "use-effect-event": "^1.0.2",
81
81
  "xstate": "^5.19.2",
82
82
  "@portabletext/patches": "1.1.2",
83
- "@portabletext/block-tools": "1.1.4"
83
+ "@portabletext/block-tools": "1.1.5"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@portabletext/toolkit": "^2.0.16",
87
87
  "@sanity/diff-match-patch": "^3.2.0",
88
88
  "@sanity/pkg-utils": "^7.0.4",
89
- "@sanity/schema": "^3.72.1",
90
- "@sanity/types": "^3.72.1",
89
+ "@sanity/schema": "^3.74.0",
90
+ "@sanity/types": "^3.74.0",
91
91
  "@testing-library/jest-dom": "^6.6.3",
92
92
  "@testing-library/react": "^16.2.0",
93
93
  "@types/debug": "^4.1.12",
@@ -112,11 +112,11 @@
112
112
  "vite": "^6.0.11",
113
113
  "vitest": "^3.0.5",
114
114
  "vitest-browser-react": "^0.0.4",
115
- "racejar": "1.1.2"
115
+ "racejar": "1.1.3"
116
116
  },
117
117
  "peerDependencies": {
118
- "@sanity/schema": "^3.72.1",
119
- "@sanity/types": "^3.72.1",
118
+ "@sanity/schema": "^3.74.0",
119
+ "@sanity/types": "^3.74.0",
120
120
  "react": "^16.9 || ^17 || ^18 || ^19",
121
121
  "rxjs": "^7.8.1"
122
122
  },
@@ -684,7 +684,6 @@ export class PortableTextEditor extends Component<
684
684
  static getFragment = (
685
685
  editor: PortableTextEditor,
686
686
  ): PortableTextBlock[] | undefined => {
687
- debug(`Host getting fragment`)
688
687
  return editor.editable?.getFragment()
689
688
  }
690
689
 
@@ -27,6 +27,8 @@ import type {
27
27
  import type {EditorSchema} from './define-schema'
28
28
  import {withoutSaving} from './plugins/createWithUndoRedo'
29
29
 
30
+ const debug = debugWithName('sync machine')
31
+
30
32
  type SyncValueEvent =
31
33
  | {
32
34
  type: 'patch'
@@ -158,11 +160,14 @@ export const syncMachine = setup({
158
160
  guards: {
159
161
  'initial value synced': ({context}) => context.initialValueSynced,
160
162
  'is busy': ({context}) => {
161
- return (
162
- !context.readOnly &&
163
- (context.isProcessingLocalChanges ||
164
- (isChangingRemotely(context.slateEditor) ?? false))
165
- )
163
+ const editable = !context.readOnly
164
+ const isProcessingLocalChanges = context.isProcessingLocalChanges
165
+ const isChanging = isChangingRemotely(context.slateEditor) ?? false
166
+ const isBusy = editable && (isProcessingLocalChanges || isChanging)
167
+
168
+ debug('isBusy', {isBusy, editable, isProcessingLocalChanges, isChanging})
169
+
170
+ return isBusy
166
171
  },
167
172
  'value changed while syncing': ({context, event}) => {
168
173
  assertEvent(event, 'done syncing')
@@ -208,13 +213,33 @@ export const syncMachine = setup({
208
213
  initial: 'syncing initial value',
209
214
  states: {
210
215
  'syncing initial value': {
216
+ entry: [
217
+ () => {
218
+ debug('entry: syncing initial value')
219
+ },
220
+ ],
221
+ exit: [
222
+ () => {
223
+ debug('exit: syncing initial value')
224
+ },
225
+ ],
211
226
  always: {
212
227
  guard: 'initial value synced',
213
228
  target: 'done syncing initial value',
214
229
  },
215
230
  },
216
231
  'done syncing initial value': {
217
- entry: ['emit done syncing initial value'],
232
+ entry: [
233
+ 'emit done syncing initial value',
234
+ () => {
235
+ debug('entry: done syncing initial value')
236
+ },
237
+ ],
238
+ exit: [
239
+ () => {
240
+ debug('exit: done syncing initial value')
241
+ },
242
+ ],
218
243
  type: 'final',
219
244
  },
220
245
  },
@@ -223,6 +248,16 @@ export const syncMachine = setup({
223
248
  initial: 'idle',
224
249
  states: {
225
250
  idle: {
251
+ entry: [
252
+ () => {
253
+ debug('entry: syncing->idle')
254
+ },
255
+ ],
256
+ exit: [
257
+ () => {
258
+ debug('exit: syncing->idle')
259
+ },
260
+ ],
226
261
  on: {
227
262
  'update value': [
228
263
  {
@@ -238,11 +273,27 @@ export const syncMachine = setup({
238
273
  },
239
274
  },
240
275
  busy: {
276
+ entry: [
277
+ () => {
278
+ debug('entry: syncing->busy')
279
+ },
280
+ ],
281
+ exit: [
282
+ () => {
283
+ debug('exit: syncing->busy')
284
+ },
285
+ ],
241
286
  after: {
242
287
  1000: [
243
288
  {
244
289
  guard: 'is busy',
290
+ target: '.',
245
291
  reenter: true,
292
+ actions: [
293
+ () => {
294
+ debug('reenter: syncing->busy')
295
+ },
296
+ ],
246
297
  },
247
298
  {
248
299
  target: 'syncing',
@@ -258,6 +309,16 @@ export const syncMachine = setup({
258
309
  },
259
310
  },
260
311
  syncing: {
312
+ entry: [
313
+ () => {
314
+ debug('entry: syncing->syncing')
315
+ },
316
+ ],
317
+ exit: [
318
+ () => {
319
+ debug('exit: syncing->syncing')
320
+ },
321
+ ],
261
322
  always: {
262
323
  guard: 'pending value equals previous value',
263
324
  target: 'idle',
@@ -318,8 +379,6 @@ export const syncMachine = setup({
318
379
  },
319
380
  })
320
381
 
321
- const debug = debugWithName('hook:useSyncValue')
322
-
323
382
  async function updateValue({
324
383
  context,
325
384
  sendBack,