Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: block hub not working in the editor

himself65fbcaed40e728
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<PageDetailEditorProps> = props => {
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 (
<>
<Head>
<title>{title}</title>
</Head>
- <Mosaic
- 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]
- )}
- 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>
+ {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
);
+ if (plugin && plugin.uiAdapter.detailContent) {
+ return (
+ <Suspense>
+ <PluginContentAdapter
+ detailContent={plugin.uiAdapter.detailContent}
+ />
+ </Suspense>
+ );
+ }
}
- }
- throw new Unreachable();
- }}
- value={layout}
- />
+ throw new Unreachable();
+ }}
+ value={layout}
+ />
+ )}
</>
);
};