mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 07:06:28 +08:00
chore(editor): add feature flag to embed doc with alias (#11797)
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
ActionPlacement,
|
||||
DocDisplayMetaProvider,
|
||||
EditorSettingProvider,
|
||||
FeatureFlagService,
|
||||
type LinkEventType,
|
||||
type OpenDocMode,
|
||||
type ToolbarAction,
|
||||
@@ -215,7 +216,12 @@ const conversionsActionGroup = {
|
||||
run(ctx) {
|
||||
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);
|
||||
editorSetting?.set?.(
|
||||
'docDropCanvasPreferView',
|
||||
|
||||
@@ -4,6 +4,7 @@ import { EmbedSyncedDocModel } from '@blocksuite/affine-model';
|
||||
import {
|
||||
ActionPlacement,
|
||||
EditorSettingProvider,
|
||||
FeatureFlagService,
|
||||
type LinkEventType,
|
||||
type OpenDocMode,
|
||||
type ToolbarAction,
|
||||
@@ -142,7 +143,12 @@ const conversionsActionGroup = {
|
||||
label: 'Card view',
|
||||
run(ctx) {
|
||||
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);
|
||||
editorSetting?.set?.(
|
||||
'docDropCanvasPreferView',
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface BlockSuiteFlags {
|
||||
enable_block_meta: boolean;
|
||||
enable_callout: boolean;
|
||||
enable_edgeless_scribbled_style: boolean;
|
||||
enable_embed_doc_with_alias: boolean;
|
||||
}
|
||||
|
||||
export class FeatureFlagService extends StoreExtension {
|
||||
@@ -40,6 +41,7 @@ export class FeatureFlagService extends StoreExtension {
|
||||
enable_block_meta: true,
|
||||
enable_callout: false,
|
||||
enable_edgeless_scribbled_style: false,
|
||||
enable_embed_doc_with_alias: false,
|
||||
});
|
||||
|
||||
setFlag(key: keyof BlockSuiteFlags, value: boolean) {
|
||||
|
||||
@@ -2,11 +2,17 @@ import { type Framework } from '@toeverything/infra';
|
||||
|
||||
import { DocsService } from '../doc';
|
||||
import { EditorSettingService } from '../editor-setting';
|
||||
import { FeatureFlagService } from '../feature-flag';
|
||||
import { WorkspaceScope, WorkspaceService } from '../workspace';
|
||||
import { DndService } from './services';
|
||||
|
||||
export function configureDndModule(framework: Framework) {
|
||||
framework
|
||||
.scope(WorkspaceScope)
|
||||
.service(DndService, [DocsService, WorkspaceService, EditorSettingService]);
|
||||
.service(DndService, [
|
||||
DocsService,
|
||||
WorkspaceService,
|
||||
EditorSettingService,
|
||||
FeatureFlagService,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import { Service } from '@toeverything/infra';
|
||||
|
||||
import type { DocsService } from '../../doc';
|
||||
import type { EditorSettingService } from '../../editor-setting';
|
||||
import type { FeatureFlagService } from '../../feature-flag';
|
||||
import { resolveLinkToDoc } from '../../navigation';
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
|
||||
@@ -34,7 +35,8 @@ export class DndService extends Service {
|
||||
constructor(
|
||||
private readonly docsService: DocsService,
|
||||
private readonly workspaceService: WorkspaceService,
|
||||
private readonly editorSettingService: EditorSettingService
|
||||
private readonly editorSettingService: EditorSettingService,
|
||||
private readonly featureFlagService: FeatureFlagService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -185,7 +187,9 @@ export class DndService extends Service {
|
||||
return false;
|
||||
},
|
||||
onDropTargetChange: (args: MonitorDragEvent<MixedDNDData>) => {
|
||||
changeDocCardView(args);
|
||||
if (this.featureFlagService.flags.enable_embed_doc_with_alias.value) {
|
||||
changeDocCardView(args);
|
||||
}
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
@@ -260,6 +260,15 @@ export const AFFINE_FLAGS = {
|
||||
'https://discord.com/channels/959027316334407691/1358384103925350542',
|
||||
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 };
|
||||
|
||||
// oxlint-disable-next-line no-redeclare
|
||||
|
||||
Reference in New Issue
Block a user