mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat: add helper function for debug (#1241)
This commit is contained in:
@@ -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]);
|
||||
|
||||
@@ -10,6 +10,8 @@ export const publicRuntimeConfigSchema = z.object({
|
||||
enableIndexedDBProvider: z.boolean(),
|
||||
enableBroadCastChannelProvider: z.boolean(),
|
||||
prefetchWorkspace: z.boolean(),
|
||||
// expose internal api to globalThis, **development only**
|
||||
exposeInternal: z.boolean(),
|
||||
});
|
||||
|
||||
export type PublicRuntimeConfig = z.infer<typeof publicRuntimeConfigSchema>;
|
||||
|
||||
Reference in New Issue
Block a user