feat: add helper function for debug (#1241)

This commit is contained in:
Himself65
2023-03-01 16:33:52 -06:00
committed by GitHub
parent 5cda4a5ebc
commit 71a0951c77
5 changed files with 18 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import { assertExists } from '@blocksuite/store';
import { useEffect, useRef } from 'react';
import { BlockSuiteWorkspace } from '../../../shared';
import { config } from '../../../shared/env';
export type EditorProps = {
blockSuiteWorkspace: BlockSuiteWorkspace;
@@ -26,6 +27,13 @@ const exampleText = markdown.split('\n').slice(1).join('\n');
const kFirstPage = 'affine-first-page';
declare global {
// eslint-disable-next-line no-var
var currentBlockSuiteWorkspace: BlockSuiteWorkspace | undefined;
// eslint-disable-next-line no-var
var currentPage: Page | undefined;
}
export const BlockSuiteEditor = (props: EditorProps) => {
const page = props.page;
const editorRef = useRef<EditorContainer | null>(null);
@@ -73,6 +81,11 @@ export const BlockSuiteEditor = (props: EditorProps) => {
page.resetHistory();
}
}
if (config.exposeInternal) {
globalThis.currentBlockSuiteWorkspace = props.blockSuiteWorkspace;
globalThis.currentPage = page;
}
props.onLoad?.(page, editor);
return;
}, [page, props]);