mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-26 02:04:43 +03:00
feat: add helper function for debug (#1241)
This commit is contained in:
parent
5cda4a5ebc
commit
71a0951c77
@ -13,3 +13,4 @@ NODE_API_SERVER=
|
||||
ENABLE_IDB_PROVIDER=1
|
||||
PREFETCH_WORKSPACE=1
|
||||
ENABLE_BC_PROVIDER=1
|
||||
EXPOSE_INTERNAL=1
|
||||
|
@ -6,4 +6,5 @@ export default {
|
||||
process.env.ENABLE_BC_PROVIDER ?? '1'
|
||||
),
|
||||
prefetchWorkspace: Boolean(process.env.PREFETCH_WORKSPACE ?? '1'),
|
||||
exposeInternal: Boolean(process.env.EXPOSE_INTERNAL ?? '1'),
|
||||
};
|
||||
|
@ -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>;
|
||||
|
@ -10,6 +10,7 @@ export default function getConfig() {
|
||||
enableBroadCastChannelProvider: true,
|
||||
enableIndexedDBProvider: true,
|
||||
prefetchWorkspace: false,
|
||||
exposeInternal: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user