@portabletext/editor
Advanced tools
Comparing version 1.16.2 to 1.16.3
{ | ||
"name": "@portabletext/editor", | ||
"version": "1.16.2", | ||
"version": "1.16.3", | ||
"description": "Portable Text Editor made in React", | ||
@@ -64,3 +64,3 @@ "keywords": [ | ||
"lodash.startcase": "^4.4.0", | ||
"react-compiler-runtime": "19.0.0-beta-37ed2a7-20241206", | ||
"react-compiler-runtime": "19.0.0-beta-201e55d-20241215", | ||
"slate": "0.112.0", | ||
@@ -91,5 +91,5 @@ "slate-dom": "^0.111.0", | ||
"@vitest/coverage-istanbul": "^2.1.8", | ||
"babel-plugin-react-compiler": "19.0.0-beta-37ed2a7-20241206", | ||
"babel-plugin-react-compiler": "19.0.0-beta-201e55d-20241215", | ||
"eslint": "8.57.1", | ||
"eslint-plugin-react-compiler": "19.0.0-beta-37ed2a7-20241206", | ||
"eslint-plugin-react-compiler": "19.0.0-beta-201e55d-20241215", | ||
"eslint-plugin-react-hooks": "^5.1.0", | ||
@@ -96,0 +96,0 @@ "jsdom": "^25.0.1", |
@@ -26,3 +26,2 @@ import { | ||
import type {PickFromUnion} from '../type-utils' | ||
import debug from '../utils/debug' | ||
import {toSlatePath} from '../utils/paths' | ||
@@ -287,4 +286,2 @@ import {toSlateRange} from '../utils/ranges' | ||
}) { | ||
debug('Behavior action', action) | ||
switch (action.type) { | ||
@@ -291,0 +288,0 @@ case 'delete.block': { |
@@ -28,3 +28,2 @@ import type {Patch} from '@portabletext/patches' | ||
} from '../types/editor' | ||
import debug from '../utils/debug' | ||
import {toPortableTextRange} from '../utils/ranges' | ||
@@ -73,3 +72,3 @@ import {fromSlateValue} from '../utils/values' | ||
| {type: 'done normalizing'} | ||
| {type: 'done syncing'} | ||
| {type: 'done syncing initial value'} | ||
| { | ||
@@ -106,3 +105,7 @@ type: 'behavior event' | ||
} | ||
| OmitFromUnion<InternalEditorEmittedEvent, 'type', 'read only' | 'editable'> | ||
| OmitFromUnion< | ||
InternalEditorEmittedEvent, | ||
'type', | ||
'ready' | 'read only' | 'editable' | ||
> | ||
@@ -248,4 +251,2 @@ /** | ||
debug('Behavior event', event) | ||
const defaultAction = | ||
@@ -434,3 +435,3 @@ event.behaviorEvent.type === 'copy' || | ||
on: { | ||
'done syncing': [ | ||
'done syncing initial value': [ | ||
{ | ||
@@ -510,3 +511,3 @@ target: '#editor.edit mode.read only.read only', | ||
}, | ||
'done syncing': { | ||
'done syncing initial value': { | ||
target: 'pristine', | ||
@@ -513,0 +514,0 @@ }, |
@@ -6,3 +6,2 @@ import type {Patch} from '@portabletext/patches' | ||
import { | ||
and, | ||
assertEvent, | ||
@@ -12,4 +11,2 @@ assign, | ||
fromCallback, | ||
not, | ||
or, | ||
setup, | ||
@@ -123,7 +120,9 @@ type AnyEventObject, | ||
| SyncValueEvent, | ||
emitted: {} as PickFromUnion< | ||
SyncValueEvent, | ||
'type', | ||
'done syncing' | 'invalid value' | 'patch' | 'value changed' | ||
>, | ||
emitted: {} as | ||
| PickFromUnion< | ||
SyncValueEvent, | ||
'type', | ||
'invalid value' | 'patch' | 'value changed' | ||
> | ||
| {type: 'done syncing initial value'}, | ||
}, | ||
@@ -155,17 +154,15 @@ actions: { | ||
}), | ||
'emit done syncing': emit(({event}) => { | ||
assertEvent(event, 'done syncing') | ||
return event | ||
'emit done syncing initial value': emit({ | ||
type: 'done syncing initial value', | ||
}), | ||
}, | ||
guards: { | ||
'is readOnly': ({context}) => context.readOnly, | ||
'is processing local changes': ({context}) => | ||
context.isProcessingLocalChanges, | ||
'is processing remote changes': ({context}) => | ||
isChangingRemotely(context.slateEditor) ?? false, | ||
'is busy': and([ | ||
not('is readOnly'), | ||
or(['is processing local changes', 'is processing remote changes']), | ||
]), | ||
'initial value synced': ({context}) => context.initialValueSynced, | ||
'is busy': ({context}) => { | ||
return ( | ||
!context.readOnly && | ||
(context.isProcessingLocalChanges || | ||
(isChangingRemotely(context.slateEditor) ?? false)) | ||
) | ||
}, | ||
'value changed while syncing': ({context, event}) => { | ||
@@ -196,3 +193,2 @@ assertEvent(event, 'done syncing') | ||
}), | ||
initial: 'idle', | ||
on: { | ||
@@ -213,99 +209,113 @@ 'has pending patches': { | ||
}, | ||
type: 'parallel', | ||
states: { | ||
idle: { | ||
on: { | ||
'update value': [ | ||
{ | ||
guard: 'is busy', | ||
target: 'busy', | ||
actions: ['assign pending value'], | ||
'setting up': { | ||
initial: 'syncing initial value', | ||
states: { | ||
'syncing initial value': { | ||
always: { | ||
guard: 'initial value synced', | ||
target: 'done syncing initial value', | ||
}, | ||
{ | ||
target: 'syncing', | ||
actions: ['assign pending value'], | ||
}, | ||
], | ||
}, | ||
'done syncing initial value': { | ||
entry: ['emit done syncing initial value'], | ||
type: 'final', | ||
}, | ||
}, | ||
}, | ||
busy: { | ||
after: { | ||
1000: { | ||
target: 'syncing', | ||
'syncing': { | ||
initial: 'idle', | ||
states: { | ||
idle: { | ||
on: { | ||
'update value': [ | ||
{ | ||
guard: 'is busy', | ||
target: 'busy', | ||
actions: ['assign pending value'], | ||
}, | ||
{ | ||
target: 'syncing', | ||
actions: ['assign pending value'], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
on: { | ||
'update value': [ | ||
{ | ||
guard: 'is busy', | ||
actions: ['assign pending value'], | ||
reenter: true, | ||
busy: { | ||
after: { | ||
1000: [ | ||
{ | ||
guard: 'is busy', | ||
reenter: true, | ||
}, | ||
{ | ||
target: 'syncing', | ||
}, | ||
], | ||
}, | ||
{ | ||
target: 'syncing', | ||
actions: ['assign pending value'], | ||
on: { | ||
'update value': [ | ||
{ | ||
actions: ['assign pending value'], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
syncing: { | ||
invoke: { | ||
src: 'sync value', | ||
id: 'sync value', | ||
input: ({context}) => { | ||
return { | ||
context: { | ||
keyGenerator: context.keyGenerator, | ||
previousValue: context.previousValue, | ||
readOnly: context.readOnly, | ||
schema: context.schema, | ||
}, | ||
slateEditor: context.slateEditor, | ||
streamBlocks: !context.initialValueSynced, | ||
value: context.pendingValue ?? undefined, | ||
} | ||
}, | ||
}, | ||
always: { | ||
guard: 'pending value equals previous value', | ||
actions: [ | ||
emit(({context}) => ({ | ||
type: 'done syncing', | ||
value: context.previousValue, | ||
})), | ||
], | ||
target: 'idle', | ||
}, | ||
on: { | ||
'update value': { | ||
actions: ['assign pending value'], | ||
}, | ||
'patch': { | ||
actions: [emit(({event}) => event)], | ||
}, | ||
'invalid value': { | ||
actions: [emit(({event}) => event)], | ||
}, | ||
'value changed': { | ||
actions: [emit(({event}) => event)], | ||
}, | ||
'done syncing': [ | ||
{ | ||
guard: 'value changed while syncing', | ||
actions: [ | ||
'assign previous value', | ||
'emit done syncing', | ||
'assign initial value synced', | ||
], | ||
reenter: true, | ||
syncing: { | ||
always: { | ||
guard: 'pending value equals previous value', | ||
target: 'idle', | ||
actions: ['clear pending value', 'assign initial value synced'], | ||
}, | ||
{ | ||
target: 'idle', | ||
actions: [ | ||
'clear pending value', | ||
'assign previous value', | ||
'emit done syncing', | ||
'assign initial value synced', | ||
invoke: { | ||
src: 'sync value', | ||
id: 'sync value', | ||
input: ({context}) => { | ||
return { | ||
context: { | ||
keyGenerator: context.keyGenerator, | ||
previousValue: context.previousValue, | ||
readOnly: context.readOnly, | ||
schema: context.schema, | ||
}, | ||
slateEditor: context.slateEditor, | ||
streamBlocks: !context.initialValueSynced, | ||
value: context.pendingValue, | ||
} | ||
}, | ||
}, | ||
on: { | ||
'update value': { | ||
actions: ['assign pending value'], | ||
}, | ||
'patch': { | ||
actions: [emit(({event}) => event)], | ||
}, | ||
'invalid value': { | ||
actions: [emit(({event}) => event)], | ||
}, | ||
'value changed': { | ||
actions: [emit(({event}) => event)], | ||
}, | ||
'done syncing': [ | ||
{ | ||
guard: 'value changed while syncing', | ||
actions: [ | ||
'assign previous value', | ||
'assign initial value synced', | ||
], | ||
reenter: true, | ||
}, | ||
{ | ||
target: 'idle', | ||
actions: [ | ||
'clear pending value', | ||
'assign previous value', | ||
'assign initial value synced', | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
@@ -312,0 +322,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
3441809
48284
+ Addedreact-compiler-runtime@19.0.0-beta-201e55d-20241215(transitive)
- Removedreact-compiler-runtime@19.0.0-beta-37ed2a7-20241206(transitive)