Skip to content

Commit

Permalink
fix: new onChange
Browse files Browse the repository at this point in the history
  • Loading branch information
EETagent committed Aug 31, 2024
1 parent c12e4f7 commit a14d2f6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/plate-contember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import {
type SugarableRelativeSingleField,
useField,
} from '@contember/interface'
import {
replaceNodeChildren,
} from '@udecode/plate-common'
import { replaceNodeChildren } from '@udecode/plate-common'
import { useEffect } from 'react'

import { isJsonContent, isJsonObject } from './contember/utils'
import { ContemberImageToolBarButton } from './contember/contember-image-toolbar-button'
import { useEditorRef } from '@udecode/plate-common/react'
import type { Value } from '@udecode/plate-common'

export type PlateEditorForContemberProps = {
field: string | SugarableRelativeSingleField
Expand All @@ -29,7 +28,7 @@ const PlateEditorForContember = Component<Props & PlateEditorForContemberProps>(

const contentField = useField(field)

const handleEditorOnChange = (value: any) => {
const handleEditorOnChange = (value: Value) => {
const contentJson = isJsonObject(value) ? { children: value } : null

if (
Expand All @@ -52,7 +51,7 @@ const PlateEditorForContember = Component<Props & PlateEditorForContemberProps>(
? contentField?.value?.children
: undefined
}
onChange={handleEditorOnChange}
onChange={(options) => handleEditorOnChange(options.value)}
shouldNormalizeEditor
additionalToolbarButtons={
<>
Expand Down

0 comments on commit a14d2f6

Please sign in to comment.