fix: preview page (#1355)

This commit is contained in:
Himself65
2023-03-06 03:06:11 -06:00
committed by GitHub
parent 78fdaf140d
commit 5760c41cd0
4 changed files with 30 additions and 12 deletions

View File

@@ -97,16 +97,18 @@ export const BlockSuiteEditor = (props: EditorProps) => {
if (!editor || !container || !page) {
return;
}
if (page.awarenessStore.getFlag('enable_block_hub')) {
editor.createBlockHub().then(blockHub => {
if (blockHubRef.current) {
blockHubRef.current.remove();
}
blockHubRef.current = blockHub;
const toolWrapper = document.querySelector('#toolWrapper');
assertExists(toolWrapper);
toolWrapper.appendChild(blockHub);
});
}
editor.createBlockHub().then(blockHub => {
if (blockHubRef.current) {
blockHubRef.current.remove();
}
blockHubRef.current = blockHub;
const toolWrapper = document.querySelector('#toolWrapper');
assertExists(toolWrapper);
toolWrapper.appendChild(blockHub);
});
container.appendChild(editor);
return () => {
blockHubRef.current?.remove();

View File

@@ -21,6 +21,7 @@ export type BlockSuiteEditorHeaderProps = React.PropsWithChildren<{
blockSuiteWorkspace: BlockSuiteWorkspace;
pageId: string;
isPublic?: boolean;
isPreview?: boolean;
}>;
export const BlockSuiteEditorHeader: React.FC<BlockSuiteEditorHeaderProps> = ({
@@ -28,6 +29,7 @@ export const BlockSuiteEditorHeader: React.FC<BlockSuiteEditorHeaderProps> = ({
pageId,
children,
isPublic,
isPreview,
}) => {
const page = blockSuiteWorkspace.getPage(pageId);
// fixme(himself65): remove this atom and move it to props
@@ -46,7 +48,7 @@ export const BlockSuiteEditorHeader: React.FC<BlockSuiteEditorHeaderProps> = ({
<Header
rightItems={
// fixme(himself65): other right items not supported in public mode
isPublic
isPublic || isPreview
? ['themeModeSwitch']
: isTrash
? ['trashButtonGroup']