From fcce6f61984a2c980092e9fc56708be0424a43b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Hamburger=20Gr=C3=B8ngaard?= Date: Mon, 27 Jan 2025 20:02:00 +0100 Subject: [PATCH] fix: allow safe behaviors while syncing This makes it possible to make selections and copy content even while the editor is syncing. --- packages/editor/src/editor/editor-machine.ts | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/editor/src/editor/editor-machine.ts b/packages/editor/src/editor/editor-machine.ts index 300c0448..1acefcd0 100644 --- a/packages/editor/src/editor/editor-machine.ts +++ b/packages/editor/src/editor/editor-machine.ts @@ -548,6 +548,18 @@ export const editorMachine = setup({ states: { 'read only': { initial: 'determine initial edit mode', + on: { + 'behavior event': { + actions: 'handle behavior event', + guard: ({event}) => + event.behaviorEvent.type === 'copy' || + event.behaviorEvent.type === 'data transfer.set' || + event.behaviorEvent.type === 'serialize' || + event.behaviorEvent.type === 'serialization.failure' || + event.behaviorEvent.type === 'serialization.success' || + event.behaviorEvent.type === 'select', + }, + }, states: { 'determine initial edit mode': { on: { @@ -564,16 +576,6 @@ export const editorMachine = setup({ }, 'read only': { on: { - 'behavior event': { - actions: 'handle behavior event', - guard: ({event}) => - event.behaviorEvent.type === 'copy' || - event.behaviorEvent.type === 'data transfer.set' || - event.behaviorEvent.type === 'serialize' || - event.behaviorEvent.type === 'serialization.failure' || - event.behaviorEvent.type === 'serialization.success' || - event.behaviorEvent.type === 'select', - }, 'update readOnly': { guard: ({event}) => !event.readOnly, target: '#editor.edit mode.editable',