From fbcaed40e72882422a1c80be9df23f7d25d8f1ed Mon Sep 17 00:00:00 2001 From: himself65 Date: Thu, 1 Jun 2023 14:32:15 +0800 Subject: [PATCH] fix: block hub not working in the editor --- .../web/src/components/page-detail-editor.tsx | 82 ++++++++++--------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/apps/web/src/components/page-detail-editor.tsx b/apps/web/src/components/page-detail-editor.tsx index e43736fda7..74d802e6bd 100644 --- a/apps/web/src/components/page-detail-editor.tsx +++ b/apps/web/src/components/page-detail-editor.tsx @@ -143,50 +143,58 @@ export const PageDetailEditor: FC = props => { const [layout, setLayout] = useAtom(contentLayoutAtom); + const onChange = useCallback( + (_: MosaicNode | null) => { + // type cast + const node = _ as MosaicNode | null; + if (node) { + if (typeof node === 'string') { + console.error('unexpected layout'); + } else { + if (node.splitPercentage && node.splitPercentage < 70) { + return; + } else if (node.first !== 'editor') { + return; + } + setLayout(node as ExpectedLayout); + } + } + }, + [setLayout] + ); + return ( <> {title} - | null) => { - // type cast - const node = _ as MosaicNode | null; - if (node) { - if (typeof node === 'string') { - console.error('unexpected layout'); - } else { - if (node.splitPercentage && node.splitPercentage < 70) { - return; - } else if (node.first !== 'editor') { - return; - } - setLayout(node as ExpectedLayout); + {layout === 'editor' ? ( + + ) : ( + { + if (id === 'editor') { + return ; + } else { + const plugin = plugins.find( + plugin => plugin.definition.id === id + ); + if (plugin && plugin.uiAdapter.detailContent) { + return ( + + + + ); } } - }, - [setLayout] - )} - renderTile={id => { - if (id === 'editor') { - return ; - } else { - const plugin = plugins.find(plugin => plugin.definition.id === id); - if (plugin && plugin.uiAdapter.detailContent) { - return ( - - - - ); - } - } - throw new Unreachable(); - }} - value={layout} - /> + throw new Unreachable(); + }} + value={layout} + /> + )} ); };