diff --git a/examples/my-gatsby-site/src/pages/index.js b/examples/my-gatsby-site/src/pages/index.js index 15a2a284..b01e9ff2 100644 --- a/examples/my-gatsby-site/src/pages/index.js +++ b/examples/my-gatsby-site/src/pages/index.js @@ -203,7 +203,7 @@ const IndexPage = () => {
${link.description}

`} />
@@ -212,35 +212,6 @@ const IndexPage = () => { - {/* */} - {/* This should resolve the window is not defined error and you should be able to build your code successfully. If you need more information regarding this, check the Gatsby documentation on Debugging HTML Builds.

" - }, - body2: { - _type: "TextBlock", - text: "

02

" - } - } - }, - 1: { - typeName: "TestBlock", - fields: { - body: { - _type: "TextBlock", - text: "

11

" - }, - body2: { - _type: "TextBlock", - text: "

12

" - } - } - } - }} blocks={[TestBlock, AirbnbBlock]}/> */} (
tsetsiasihfasjhfjkshs {Object.keys(page.children)}
diff --git a/packages/jaen-pages/src/containers/Editor/index.tsx b/packages/jaen-pages/src/containers/Editor/index.tsx index f7198816..ba505cc9 100644 --- a/packages/jaen-pages/src/containers/Editor/index.tsx +++ b/packages/jaen-pages/src/containers/Editor/index.tsx @@ -18,10 +18,9 @@ const LoadableCKEditor = loadable(() => import('@ckeditor/ckeditor5-react'), { }) type EditorProps = { - data: string + defaultData: {value: string; shouldOverrideRand?: number} editing: boolean disableToolbar: boolean - toolbarType: 'inline' | 'balloon' onChange: (data: string) => void } @@ -31,7 +30,7 @@ const Editor: React.FC = props => { const raw = ( ) @@ -49,8 +48,6 @@ const Editor: React.FC = props => { React.useEffect(() => { async function load() { - console.log('call', !BalloonEditor, props.editing) - if (!BalloonEditor && props.editing) { BalloonEditor = await import('@ckeditor/ckeditor5-build-balloon') @@ -59,7 +56,7 @@ const Editor: React.FC = props => { } load() - }, [props.editing]) + }) return ( @@ -69,7 +66,7 @@ const Editor: React.FC = props => { //@ts-ignore editor={editor?.default} config={editorConfig} - data={props.data} + data={props.defaultData.value} //@ts-ignore onChange={(event, editor) => { const data = editor.getData() @@ -86,29 +83,8 @@ const Editor: React.FC = props => { ) } -// // A custom React Hook for using CKEditor with SSR -// // particularly with NextJS. -// // https://ckeditor.com | https://nextjs.org - -// export function useCKEditor() { -// const editorRef = useRef() -// const [isEditorLoaded, setIsEditorLoaded] = useState(false) -// const {CKEditor, InlineEditor} = editorRef.current || {} - -// useEffect(() => { -// editorRef.current = { -// // CKEditor: require('@ckeditor/ckeditor5-react'), // depricated in v3 -// CKEditor: require('@ckeditor/ckeditor5-react').CKEditor, // v3+ -// InlineEditor: require('@ckeditor/ckeditor5-build-inline') -// } -// setIsEditorLoaded(true) -// }, []) - -// return Object.freeze({ -// isEditorLoaded, -// CKEditor, -// InlineEditor -// }) -// } - -export default Editor +export default React.memo( + Editor, + (prev, next) => + prev.defaultData.shouldOverrideRand === next.defaultData.shouldOverrideRand +) diff --git a/packages/jaen-pages/src/containers/fields/TextField/index.tsx b/packages/jaen-pages/src/containers/fields/TextField/index.tsx index c359ea05..77e052fc 100644 --- a/packages/jaen-pages/src/containers/fields/TextField/index.tsx +++ b/packages/jaen-pages/src/containers/fields/TextField/index.tsx @@ -98,16 +98,17 @@ const TextField: React.FC = ({ } } + // random Id + const resetEditorReset = + ((contextValue || initValue) === value && Math.random()) || undefined + return ( - <> - - + ) }