Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow safe behaviors while syncing #739

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions packages/editor/src/editor/editor-machine.ts
Original file line number Diff line number Diff line change
@@ -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',

Unchanged files with check annotations Beta

export const PortableTextEditable = forwardRef<
Omit<HTMLDivElement, 'as' | 'onPaste' | 'onBeforeInput'>,
PortableTextEditableProps
>(function PortableTextEditable(props, forwardedRef) {

Check warning on line 136 in packages/editor/src/editor/Editable.tsx

GitHub Actions / check-lint

[ReactCompilerBailout] Support value blocks (conditional, logical, optional chaining, etc) within a try/catch statement (@:637:8)
const {
hotkeys,
onBlur,
* Renders Portable Text block and inline object nodes in Slate
* @internal
*/
export const Element: FunctionComponent<ElementProps> = ({

Check warning on line 61 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:138:26)

Check warning on line 61 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:171:34)

Check warning on line 61 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:196:39)

Check warning on line 61 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:211:6)

Check warning on line 61 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:282:6)
attributes,
children,
element,
contentEditable={false}
>
{renderChild &&
renderChild({

Check warning on line 138 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
annotations: EMPTY_ANNOTATIONS, // These inline objects currently doesn't support annotations. This is a limitation of the current PT spec/model.
children: <ObjectNode value={value} />,
editorElementRef: inlineBlockObjectRef,
(item) => item.value === style,
)
if (renderStyle && blockStyleType) {
renderedBlock = renderStyle({

Check warning on line 171 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
block: element as PortableTextTextBlock,
children,
focused,
(item) => item.value === element.listItem,
)
if (renderListItem && listType) {
renderedBlock = renderListItem({

Check warning on line 196 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
block: value,
children: renderedBlock,
focused,
}
const renderProps: Omit<BlockRenderProps, 'type'> = Object.defineProperty(
{

Check warning on line 211 in packages/editor/src/editor/components/Element.tsx

GitHub Actions / check-lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
children: renderedBlock,
editorElementRef: blockRef,
focused,