chore(editor): add feature flag to embed doc with alias (#11797)

This commit is contained in:
L-Sun
2025-04-18 07:39:16 +00:00
parent 9c02512d7c
commit 3264e65980
6 changed files with 38 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ import {
ActionPlacement, ActionPlacement,
DocDisplayMetaProvider, DocDisplayMetaProvider,
EditorSettingProvider, EditorSettingProvider,
FeatureFlagService,
type LinkEventType, type LinkEventType,
type OpenDocMode, type OpenDocMode,
type ToolbarAction, type ToolbarAction,
@@ -215,7 +216,12 @@ const conversionsActionGroup = {
run(ctx) { run(ctx) {
const block = ctx.getCurrentBlockByType(EmbedLinkedDocBlockComponent); const block = ctx.getCurrentBlockByType(EmbedLinkedDocBlockComponent);
if (isGfxBlockComponent(block)) { if (
ctx.std
.get(FeatureFlagService)
.getFlag('enable_embed_doc_with_alias') &&
isGfxBlockComponent(block)
) {
const editorSetting = ctx.std.getOptional(EditorSettingProvider); const editorSetting = ctx.std.getOptional(EditorSettingProvider);
editorSetting?.set?.( editorSetting?.set?.(
'docDropCanvasPreferView', 'docDropCanvasPreferView',

View File

@@ -4,6 +4,7 @@ import { EmbedSyncedDocModel } from '@blocksuite/affine-model';
import { import {
ActionPlacement, ActionPlacement,
EditorSettingProvider, EditorSettingProvider,
FeatureFlagService,
type LinkEventType, type LinkEventType,
type OpenDocMode, type OpenDocMode,
type ToolbarAction, type ToolbarAction,
@@ -142,7 +143,12 @@ const conversionsActionGroup = {
label: 'Card view', label: 'Card view',
run(ctx) { run(ctx) {
const block = ctx.getCurrentBlockByType(EmbedSyncedDocBlockComponent); const block = ctx.getCurrentBlockByType(EmbedSyncedDocBlockComponent);
if (isGfxBlockComponent(block)) { if (
ctx.std
.get(FeatureFlagService)
.getFlag('enable_embed_doc_with_alias') &&
isGfxBlockComponent(block)
) {
const editorSetting = ctx.std.getOptional(EditorSettingProvider); const editorSetting = ctx.std.getOptional(EditorSettingProvider);
editorSetting?.set?.( editorSetting?.set?.(
'docDropCanvasPreferView', 'docDropCanvasPreferView',

View File

@@ -18,6 +18,7 @@ export interface BlockSuiteFlags {
enable_block_meta: boolean; enable_block_meta: boolean;
enable_callout: boolean; enable_callout: boolean;
enable_edgeless_scribbled_style: boolean; enable_edgeless_scribbled_style: boolean;
enable_embed_doc_with_alias: boolean;
} }
export class FeatureFlagService extends StoreExtension { export class FeatureFlagService extends StoreExtension {
@@ -40,6 +41,7 @@ export class FeatureFlagService extends StoreExtension {
enable_block_meta: true, enable_block_meta: true,
enable_callout: false, enable_callout: false,
enable_edgeless_scribbled_style: false, enable_edgeless_scribbled_style: false,
enable_embed_doc_with_alias: false,
}); });
setFlag(key: keyof BlockSuiteFlags, value: boolean) { setFlag(key: keyof BlockSuiteFlags, value: boolean) {

View File

@@ -2,11 +2,17 @@ import { type Framework } from '@toeverything/infra';
import { DocsService } from '../doc'; import { DocsService } from '../doc';
import { EditorSettingService } from '../editor-setting'; import { EditorSettingService } from '../editor-setting';
import { FeatureFlagService } from '../feature-flag';
import { WorkspaceScope, WorkspaceService } from '../workspace'; import { WorkspaceScope, WorkspaceService } from '../workspace';
import { DndService } from './services'; import { DndService } from './services';
export function configureDndModule(framework: Framework) { export function configureDndModule(framework: Framework) {
framework framework
.scope(WorkspaceScope) .scope(WorkspaceScope)
.service(DndService, [DocsService, WorkspaceService, EditorSettingService]); .service(DndService, [
DocsService,
WorkspaceService,
EditorSettingService,
FeatureFlagService,
]);
} }

View File

@@ -18,6 +18,7 @@ import { Service } from '@toeverything/infra';
import type { DocsService } from '../../doc'; import type { DocsService } from '../../doc';
import type { EditorSettingService } from '../../editor-setting'; import type { EditorSettingService } from '../../editor-setting';
import type { FeatureFlagService } from '../../feature-flag';
import { resolveLinkToDoc } from '../../navigation'; import { resolveLinkToDoc } from '../../navigation';
import type { WorkspaceService } from '../../workspace'; import type { WorkspaceService } from '../../workspace';
@@ -34,7 +35,8 @@ export class DndService extends Service {
constructor( constructor(
private readonly docsService: DocsService, private readonly docsService: DocsService,
private readonly workspaceService: WorkspaceService, private readonly workspaceService: WorkspaceService,
private readonly editorSettingService: EditorSettingService private readonly editorSettingService: EditorSettingService,
private readonly featureFlagService: FeatureFlagService
) { ) {
super(); super();
@@ -185,7 +187,9 @@ export class DndService extends Service {
return false; return false;
}, },
onDropTargetChange: (args: MonitorDragEvent<MixedDNDData>) => { onDropTargetChange: (args: MonitorDragEvent<MixedDNDData>) => {
changeDocCardView(args); if (this.featureFlagService.flags.enable_embed_doc_with_alias.value) {
changeDocCardView(args);
}
}, },
}) })
); );

View File

@@ -260,6 +260,15 @@ export const AFFINE_FLAGS = {
'https://discord.com/channels/959027316334407691/1358384103925350542', 'https://discord.com/channels/959027316334407691/1358384103925350542',
defaultState: false, defaultState: false,
}, },
// TODO(@L-Sun): remove this flag after the feature is released
enable_embed_doc_with_alias: {
category: 'blocksuite',
bsFlag: 'enable_embed_doc_with_alias',
displayName: 'Embed doc with alias',
description: 'Embed doc with alias',
configurable: isCanaryBuild,
defaultState: isCanaryBuild,
},
} satisfies { [key in string]: FlagInfo }; } satisfies { [key in string]: FlagInfo };
// oxlint-disable-next-line no-redeclare // oxlint-disable-next-line no-redeclare