diff --git a/packages/common/env/src/global.ts b/packages/common/env/src/global.ts
index 279ec822e2506..9c99fe5e5ee3c 100644
--- a/packages/common/env/src/global.ts
+++ b/packages/common/env/src/global.ts
@@ -24,6 +24,7 @@ export const runtimeFlagsSchema = z.object({
enablePayment: z.boolean(),
enablePageHistory: z.boolean(),
enableExperimentalFeature: z.boolean(),
+ enablePeekView: z.boolean(),
allowLocalWorkspace: z.boolean(),
// this is for the electron app
serverUrlPrefix: z.string(),
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
index 18b6e0c99a93c..eed0bf0f5e683 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
@@ -86,7 +86,7 @@ const usePatchSpecs = (page: Doc, specs: BlockSpec[]) => {
patchReferenceRenderer(patched, reactToLit, referenceRenderer),
confirmModal
);
- if (!page.readonly) {
+ if (!page.readonly && runtimeConfig.enablePeekView) {
patched = patchPeekViewService(patched, peekViewService);
}
return patched;
diff --git a/packages/frontend/core/src/modules/peek-view/entities/peek-view.ts b/packages/frontend/core/src/modules/peek-view/entities/peek-view.ts
index 43d84b8b6c0cd..8839ffef4931a 100644
--- a/packages/frontend/core/src/modules/peek-view/entities/peek-view.ts
+++ b/packages/frontend/core/src/modules/peek-view/entities/peek-view.ts
@@ -124,13 +124,18 @@ export class PeekViewEntity extends Entity {
.map(show => show && this._active$.value !== null)
.distinctUntilChanged();
+ // return true if the peek view will be handled
open = (target: ActivePeekView['target']) => {
+ if (!runtimeConfig.enablePeekView) {
+ return false;
+ }
const resolvedInfo = resolvePeekInfoFromPeekTarget(target);
if (!resolvedInfo) {
- return;
+ return false;
}
this._active$.next({ target, info: resolvedInfo });
this._show$.next(true);
+ return true;
};
close = () => {
diff --git a/packages/frontend/core/src/providers/modal-provider.tsx b/packages/frontend/core/src/providers/modal-provider.tsx
index 4c0f2c2cd94bd..945555c858ca5 100644
--- a/packages/frontend/core/src/providers/modal-provider.tsx
+++ b/packages/frontend/core/src/providers/modal-provider.tsx
@@ -219,7 +219,7 @@ export function CurrentWorkspaceModals() {
)}
-
+ {runtimeConfig.enablePeekView && }
{environment.isDesktop && }
>
);
diff --git a/tools/cli/src/webpack/runtime-config.ts b/tools/cli/src/webpack/runtime-config.ts
index 588a7e6735baa..87e64951b40c9 100644
--- a/tools/cli/src/webpack/runtime-config.ts
+++ b/tools/cli/src/webpack/runtime-config.ts
@@ -23,6 +23,7 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
enablePayment: true,
enablePageHistory: true,
enableExperimentalFeature: false,
+ enablePeekView: false,
allowLocalWorkspace: buildFlags.distribution === 'desktop' ? true : false,
serverUrlPrefix: 'https://app.affine.pro',
appVersion: packageJson.version,
@@ -63,6 +64,7 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
enablePayment: true,
enablePageHistory: true,
enableExperimentalFeature: true,
+ enablePeekView: true,
allowLocalWorkspace: buildFlags.distribution === 'desktop' ? true : false,
serverUrlPrefix: 'https://affine.fail',
appVersion: packageJson.version,
@@ -117,6 +119,11 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
: buildFlags.mode === 'development'
? true
: currentBuildPreset.enablePageHistory,
+ enablePeekView: process.env.ENABLE_PEEK_VIEW
+ ? process.env.ENABLE_PEEK_VIEW === 'true'
+ : buildFlags.mode === 'development'
+ ? true
+ : currentBuildPreset.enablePeekView,
allowLocalWorkspace: process.env.ALLOW_LOCAL_WORKSPACE
? process.env.ALLOW_LOCAL_WORKSPACE === 'true'
: buildFlags.mode === 'development'