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