mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
fix: block hub not working in the editor
This commit is contained in:
@@ -143,50 +143,58 @@ export const PageDetailEditor: FC<PageDetailEditorProps> = props => {
|
|||||||
|
|
||||||
const [layout, setLayout] = useAtom(contentLayoutAtom);
|
const [layout, setLayout] = useAtom(contentLayoutAtom);
|
||||||
|
|
||||||
|
const onChange = useCallback(
|
||||||
|
(_: MosaicNode<string | number> | null) => {
|
||||||
|
// type cast
|
||||||
|
const node = _ as MosaicNode<string> | 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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<Mosaic
|
{layout === 'editor' ? (
|
||||||
onChange={useCallback(
|
<EditorWrapper {...props} />
|
||||||
(_: MosaicNode<string | number> | null) => {
|
) : (
|
||||||
// type cast
|
<Mosaic
|
||||||
const node = _ as MosaicNode<string> | null;
|
onChange={onChange}
|
||||||
if (node) {
|
renderTile={id => {
|
||||||
if (typeof node === 'string') {
|
if (id === 'editor') {
|
||||||
console.error('unexpected layout');
|
return <EditorWrapper {...props} />;
|
||||||
} else {
|
} else {
|
||||||
if (node.splitPercentage && node.splitPercentage < 70) {
|
const plugin = plugins.find(
|
||||||
return;
|
plugin => plugin.definition.id === id
|
||||||
} else if (node.first !== 'editor') {
|
);
|
||||||
return;
|
if (plugin && plugin.uiAdapter.detailContent) {
|
||||||
}
|
return (
|
||||||
setLayout(node as ExpectedLayout);
|
<Suspense>
|
||||||
|
<PluginContentAdapter
|
||||||
|
detailContent={plugin.uiAdapter.detailContent}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
throw new Unreachable();
|
||||||
[setLayout]
|
}}
|
||||||
)}
|
value={layout}
|
||||||
renderTile={id => {
|
/>
|
||||||
if (id === 'editor') {
|
)}
|
||||||
return <EditorWrapper {...props} />;
|
|
||||||
} else {
|
|
||||||
const plugin = plugins.find(plugin => plugin.definition.id === id);
|
|
||||||
if (plugin && plugin.uiAdapter.detailContent) {
|
|
||||||
return (
|
|
||||||
<Suspense>
|
|
||||||
<PluginContentAdapter
|
|
||||||
detailContent={plugin.uiAdapter.detailContent}
|
|
||||||
/>
|
|
||||||
</Suspense>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Unreachable();
|
|
||||||
}}
|
|
||||||
value={layout}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user