fix: block hub not working in the editor

This commit is contained in:
himself65
2023-06-01 14:32:15 +08:00
parent 88757ce488
commit fbcaed40e7

View File

@@ -143,13 +143,7 @@ export const PageDetailEditor: FC<PageDetailEditorProps> = props => {
const [layout, setLayout] = useAtom(contentLayoutAtom);
return (
<>
<Head>
<title>{title}</title>
</Head>
<Mosaic
onChange={useCallback(
const onChange = useCallback(
(_: MosaicNode<string | number> | null) => {
// type cast
const node = _ as MosaicNode<string> | null;
@@ -167,12 +161,25 @@ export const PageDetailEditor: FC<PageDetailEditorProps> = props => {
}
},
[setLayout]
)}
);
return (
<>
<Head>
<title>{title}</title>
</Head>
{layout === 'editor' ? (
<EditorWrapper {...props} />
) : (
<Mosaic
onChange={onChange}
renderTile={id => {
if (id === 'editor') {
return <EditorWrapper {...props} />;
} else {
const plugin = plugins.find(plugin => plugin.definition.id === id);
const plugin = plugins.find(
plugin => plugin.definition.id === id
);
if (plugin && plugin.uiAdapter.detailContent) {
return (
<Suspense>
@@ -187,6 +194,7 @@ export const PageDetailEditor: FC<PageDetailEditorProps> = props => {
}}
value={layout}
/>
)}
</>
);
};