@portabletext/editor 1.48.9 → 1.48.10

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.
@@ -1626,8 +1626,11 @@ const debug$d = debugWithName("sync machine"), syncValueCallback = ({
1626
1626
  event
1627
1627
  }) => (xstate.assertEvent(event, "done syncing"), event.value)
1628
1628
  }),
1629
- "emit done syncing initial value": xstate.emit({
1630
- type: "done syncing initial value"
1629
+ "emit done syncing value": xstate.emit({
1630
+ type: "done syncing value"
1631
+ }),
1632
+ "emit syncing value": xstate.emit({
1633
+ type: "syncing value"
1631
1634
  })
1632
1635
  },
1633
1636
  guards: {
@@ -1703,7 +1706,7 @@ const debug$d = debugWithName("sync machine"), syncValueCallback = ({
1703
1706
  }
1704
1707
  },
1705
1708
  "done syncing initial value": {
1706
- entry: ["emit done syncing initial value", () => {
1709
+ entry: ["emit done syncing value", () => {
1707
1710
  debug$d("entry: done syncing initial value");
1708
1711
  }],
1709
1712
  exit: [() => {
@@ -1762,10 +1765,10 @@ const debug$d = debugWithName("sync machine"), syncValueCallback = ({
1762
1765
  syncing: {
1763
1766
  entry: [() => {
1764
1767
  debug$d("entry: syncing->syncing");
1765
- }],
1768
+ }, "emit syncing value"],
1766
1769
  exit: [() => {
1767
1770
  debug$d("exit: syncing->syncing");
1768
- }],
1771
+ }, "emit done syncing value"],
1769
1772
  always: {
1770
1773
  guard: "pending value equals previous value",
1771
1774
  target: "idle",
@@ -6986,6 +6989,22 @@ const editorMachine = xstate.setup({
6986
6989
  "clear pending events": xstate.assign({
6987
6990
  pendingEvents: []
6988
6991
  }),
6992
+ "defer incoming patches": xstate.assign({
6993
+ pendingIncomingPatchesEvents: ({
6994
+ context,
6995
+ event
6996
+ }) => event.type === "patches" ? [...context.pendingIncomingPatchesEvents, event] : context.pendingIncomingPatchesEvents
6997
+ }),
6998
+ "emit pending incoming patches": xstate.enqueueActions(({
6999
+ context,
7000
+ enqueue
7001
+ }) => {
7002
+ for (const event of context.pendingIncomingPatchesEvents)
7003
+ enqueue.emit(event);
7004
+ }),
7005
+ "clear pending incoming patches": xstate.assign({
7006
+ pendingIncomingPatchesEvents: []
7007
+ }),
6989
7008
  "handle blur": ({
6990
7009
  event
6991
7010
  }) => {
@@ -7053,6 +7072,7 @@ const editorMachine = xstate.setup({
7053
7072
  getLegacySchema: input.getLegacySchema,
7054
7073
  keyGenerator: input.keyGenerator,
7055
7074
  pendingEvents: [],
7075
+ pendingIncomingPatchesEvents: [],
7056
7076
  schema: input.schema,
7057
7077
  selection: null,
7058
7078
  initialReadOnly: input.readOnly ?? !1,
@@ -7136,11 +7156,6 @@ const editorMachine = xstate.setup({
7136
7156
  "remove behavior": {
7137
7157
  actions: "remove behavior from context"
7138
7158
  },
7139
- patches: {
7140
- actions: xstate.emit(({
7141
- event
7142
- }) => event)
7143
- },
7144
7159
  "update behaviors": {
7145
7160
  actions: "assign behaviors"
7146
7161
  },
@@ -7187,7 +7202,7 @@ const editorMachine = xstate.setup({
7187
7202
  states: {
7188
7203
  "determine initial edit mode": {
7189
7204
  on: {
7190
- "done syncing initial value": [{
7205
+ "done syncing value": [{
7191
7206
  target: "#editor.edit mode.read only.read only",
7192
7207
  guard: ({
7193
7208
  context
@@ -7303,7 +7318,7 @@ const editorMachine = xstate.setup({
7303
7318
  initial: "setting up",
7304
7319
  states: {
7305
7320
  "setting up": {
7306
- exit: ["emit ready"],
7321
+ exit: ["emit ready", "emit pending incoming patches", "clear pending incoming patches"],
7307
7322
  on: {
7308
7323
  "internal.patch": {
7309
7324
  actions: "defer event"
@@ -7311,54 +7326,95 @@ const editorMachine = xstate.setup({
7311
7326
  mutation: {
7312
7327
  actions: "defer event"
7313
7328
  },
7314
- "done syncing initial value": {
7315
- target: "pristine"
7329
+ "done syncing value": {
7330
+ target: "set up"
7331
+ },
7332
+ patches: {
7333
+ actions: ["defer incoming patches"]
7316
7334
  }
7317
7335
  }
7318
7336
  },
7319
- pristine: {
7320
- initial: "idle",
7337
+ "set up": {
7338
+ type: "parallel",
7321
7339
  states: {
7322
- idle: {
7323
- on: {
7324
- normalizing: {
7325
- target: "normalizing"
7326
- },
7327
- "internal.patch": {
7328
- actions: "defer event",
7329
- target: "#editor.setup.dirty"
7340
+ "value sync": {
7341
+ initial: "idle",
7342
+ states: {
7343
+ idle: {
7344
+ on: {
7345
+ patches: {
7346
+ actions: [xstate.emit(({
7347
+ event
7348
+ }) => event)]
7349
+ },
7350
+ "syncing value": {
7351
+ target: "syncing value"
7352
+ }
7353
+ }
7330
7354
  },
7331
- mutation: {
7332
- actions: "defer event",
7333
- target: "#editor.setup.dirty"
7355
+ "syncing value": {
7356
+ exit: ["emit pending incoming patches", "clear pending incoming patches"],
7357
+ on: {
7358
+ patches: {
7359
+ actions: ["defer incoming patches"]
7360
+ },
7361
+ "done syncing value": {
7362
+ target: "idle"
7363
+ }
7364
+ }
7334
7365
  }
7335
7366
  }
7336
7367
  },
7337
- normalizing: {
7338
- on: {
7339
- "done normalizing": {
7340
- target: "idle"
7341
- },
7342
- "internal.patch": {
7343
- actions: "defer event"
7368
+ writing: {
7369
+ initial: "pristine",
7370
+ states: {
7371
+ pristine: {
7372
+ initial: "idle",
7373
+ states: {
7374
+ idle: {
7375
+ on: {
7376
+ normalizing: {
7377
+ target: "normalizing"
7378
+ },
7379
+ "internal.patch": {
7380
+ actions: "defer event",
7381
+ target: "#editor.setup.set up.writing.dirty"
7382
+ },
7383
+ mutation: {
7384
+ actions: "defer event",
7385
+ target: "#editor.setup.set up.writing.dirty"
7386
+ }
7387
+ }
7388
+ },
7389
+ normalizing: {
7390
+ on: {
7391
+ "done normalizing": {
7392
+ target: "idle"
7393
+ },
7394
+ "internal.patch": {
7395
+ actions: "defer event"
7396
+ },
7397
+ mutation: {
7398
+ actions: "defer event"
7399
+ }
7400
+ }
7401
+ }
7402
+ }
7344
7403
  },
7345
- mutation: {
7346
- actions: "defer event"
7404
+ dirty: {
7405
+ entry: ["emit pending events", "clear pending events"],
7406
+ on: {
7407
+ "internal.patch": {
7408
+ actions: "emit patch event"
7409
+ },
7410
+ mutation: {
7411
+ actions: "emit mutation event"
7412
+ }
7413
+ }
7347
7414
  }
7348
7415
  }
7349
7416
  }
7350
7417
  }
7351
- },
7352
- dirty: {
7353
- entry: ["emit pending events", "clear pending events"],
7354
- on: {
7355
- "internal.patch": {
7356
- actions: "emit patch event"
7357
- },
7358
- mutation: {
7359
- actions: "emit mutation event"
7360
- }
7361
- }
7362
7418
  }
7363
7419
  }
7364
7420
  }