mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 03:49:56 +08:00
feat: add helper function for debug (#1241)
This commit is contained in:
@@ -13,3 +13,4 @@ NODE_API_SERVER=
|
|||||||
ENABLE_IDB_PROVIDER=1
|
ENABLE_IDB_PROVIDER=1
|
||||||
PREFETCH_WORKSPACE=1
|
PREFETCH_WORKSPACE=1
|
||||||
ENABLE_BC_PROVIDER=1
|
ENABLE_BC_PROVIDER=1
|
||||||
|
EXPOSE_INTERNAL=1
|
||||||
|
|||||||
@@ -6,4 +6,5 @@ export default {
|
|||||||
process.env.ENABLE_BC_PROVIDER ?? '1'
|
process.env.ENABLE_BC_PROVIDER ?? '1'
|
||||||
),
|
),
|
||||||
prefetchWorkspace: Boolean(process.env.PREFETCH_WORKSPACE ?? '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 { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
import { BlockSuiteWorkspace } from '../../../shared';
|
import { BlockSuiteWorkspace } from '../../../shared';
|
||||||
|
import { config } from '../../../shared/env';
|
||||||
|
|
||||||
export type EditorProps = {
|
export type EditorProps = {
|
||||||
blockSuiteWorkspace: BlockSuiteWorkspace;
|
blockSuiteWorkspace: BlockSuiteWorkspace;
|
||||||
@@ -26,6 +27,13 @@ const exampleText = markdown.split('\n').slice(1).join('\n');
|
|||||||
|
|
||||||
const kFirstPage = 'affine-first-page';
|
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) => {
|
export const BlockSuiteEditor = (props: EditorProps) => {
|
||||||
const page = props.page;
|
const page = props.page;
|
||||||
const editorRef = useRef<EditorContainer | null>(null);
|
const editorRef = useRef<EditorContainer | null>(null);
|
||||||
@@ -73,6 +81,11 @@ export const BlockSuiteEditor = (props: EditorProps) => {
|
|||||||
page.resetHistory();
|
page.resetHistory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.exposeInternal) {
|
||||||
|
globalThis.currentBlockSuiteWorkspace = props.blockSuiteWorkspace;
|
||||||
|
globalThis.currentPage = page;
|
||||||
|
}
|
||||||
props.onLoad?.(page, editor);
|
props.onLoad?.(page, editor);
|
||||||
return;
|
return;
|
||||||
}, [page, props]);
|
}, [page, props]);
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ export const publicRuntimeConfigSchema = z.object({
|
|||||||
enableIndexedDBProvider: z.boolean(),
|
enableIndexedDBProvider: z.boolean(),
|
||||||
enableBroadCastChannelProvider: z.boolean(),
|
enableBroadCastChannelProvider: z.boolean(),
|
||||||
prefetchWorkspace: z.boolean(),
|
prefetchWorkspace: z.boolean(),
|
||||||
|
// expose internal api to globalThis, **development only**
|
||||||
|
exposeInternal: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type PublicRuntimeConfig = z.infer<typeof publicRuntimeConfigSchema>;
|
export type PublicRuntimeConfig = z.infer<typeof publicRuntimeConfigSchema>;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export default function getConfig() {
|
|||||||
enableBroadCastChannelProvider: true,
|
enableBroadCastChannelProvider: true,
|
||||||
enableIndexedDBProvider: true,
|
enableIndexedDBProvider: true,
|
||||||
prefetchWorkspace: false,
|
prefetchWorkspace: false,
|
||||||
|
exposeInternal: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user