feat(editor): remove embed iframe feature flag (#11432)

Close [BS-3019](https://linear.app/affine-design/issue/BS-3019/remove-embed-iframe-feature-flag)
This commit is contained in:
donteatfriedrice
2025-04-03 04:59:52 +00:00
parent f2646796fc
commit 9206145a48
9 changed files with 24 additions and 97 deletions
@@ -4,10 +4,7 @@ import {
insertEmbedLinkedDocCommand,
type LinkableFlavour,
} from '@blocksuite/affine-block-embed';
import {
FeatureFlagService,
QuickSearchProvider,
} from '@blocksuite/affine-shared/services';
import { QuickSearchProvider } from '@blocksuite/affine-shared/services';
import type { Command } from '@blocksuite/std';
import { insertBookmarkCommand } from './insert-bookmark';
@@ -41,35 +38,20 @@ export const insertLinkByQuickSearchCommand: Command<
// add normal link;
if ('externalUrl' in result) {
const featureFlagService = std.get(FeatureFlagService);
const enableEmbedIframeBlock = featureFlagService.getFlag(
'enable_embed_iframe_block'
);
if (enableEmbedIframeBlock) {
// try to insert embed iframe block first
const [success, { flavour }] = std.command
.chain()
.try(chain => [
chain.pipe(insertEmbedIframeWithUrlCommand, {
url: result.externalUrl,
}),
chain.pipe(insertBookmarkCommand, { url: result.externalUrl }),
])
.run();
if (!success || !flavour) return null;
return {
flavour: flavour as LinkableFlavour,
};
} else {
const [success, { flavour }] = std.command.exec(
insertBookmarkCommand,
{ url: result.externalUrl }
);
if (!success || !flavour) return null;
return {
flavour: flavour as LinkableFlavour,
};
}
// try to insert embed iframe block first
const [success, { flavour }] = std.command
.chain()
.try(chain => [
chain.pipe(insertEmbedIframeWithUrlCommand, {
url: result.externalUrl,
}),
chain.pipe(insertBookmarkCommand, { url: result.externalUrl }),
])
.run();
if (!success || !flavour) return null;
return {
flavour: flavour as LinkableFlavour,
};
}
return null;
@@ -1,5 +1,4 @@
import { getSelectedModelsCommand } from '@blocksuite/affine-shared/commands';
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
import type { SlashMenuConfig } from '@blocksuite/affine-widget-slash-menu';
import { EmbedIcon } from '@blocksuite/icons/lit';
@@ -17,12 +16,8 @@ export const embedIframeSlashMenuConfig: SlashMenuConfig = {
caption: 'Embed',
},
group: '4_Content & Media@5',
when: ({ model, std }) => {
const featureFlagService = std.get(FeatureFlagService);
return (
featureFlagService.getFlag('enable_embed_iframe_block') &&
model.doc.schema.flavourSchemaMap.has('affine:embed-iframe')
);
when: ({ model }) => {
return model.doc.schema.flavourSchemaMap.has('affine:embed-iframe');
},
action: ({ std }) => {
std.command
@@ -1,7 +1,6 @@
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
import { Bound } from '@blocksuite/global/gfx';
import { toGfxBlockComponent } from '@blocksuite/std';
import { nothing } from 'lit';
import { styleMap } from 'lit/directives/style-map.js';
import { html } from 'lit/static-html.js';
@@ -36,10 +35,6 @@ export class EmbedEdgelessIframeBlockComponent extends toGfxBlockComponent(
}
override renderGfxBlock() {
if (!this.isEmbedIframeBlockEnabled) {
return nothing;
}
const bound = Bound.deserialize(this.model.props.xywh$.value);
const scale = this.model.props.scale$.value;
const width = bound.w / scale;
@@ -8,7 +8,6 @@ import type { EmbedIframeBlockModel } from '@blocksuite/affine-model';
import {
type EmbedIframeData,
EmbedIframeService,
FeatureFlagService,
type IframeOptions,
LinkPreviewerService,
NotificationProvider,
@@ -23,7 +22,7 @@ import {
type ReadonlySignal,
signal,
} from '@preact/signals-core';
import { html, nothing } from 'lit';
import { html } from 'lit';
import { query } from 'lit/decorators.js';
import { type ClassInfo, classMap } from 'lit/directives/class-map.js';
import { ifDefined } from 'lit/directives/if-defined.js';
@@ -106,12 +105,6 @@ export class EmbedIframeBlockComponent extends CaptionedBlockComponent<EmbedIfra
return matchModels(this.model.parent, [SurfaceBlockModel]);
}
get isEmbedIframeBlockEnabled() {
const featureFlagService = this.doc.get(FeatureFlagService);
const flag = featureFlagService.getFlag('enable_embed_iframe_block');
return flag ?? false;
}
get _horizontalCardHeight(): number {
switch (this.status$.value) {
case 'idle':
@@ -420,10 +413,6 @@ export class EmbedIframeBlockComponent extends CaptionedBlockComponent<EmbedIfra
}
override renderBlock() {
if (!this.isEmbedIframeBlockEnabled) {
return nothing;
}
const containerClasses = classMap({
'affine-embed-iframe-block-container': true,
...this.selectedStyle$?.value,
@@ -1,7 +1,4 @@
import {
EmbedIframeService,
FeatureFlagService,
} from '@blocksuite/affine-shared/services';
import { EmbedIframeService } from '@blocksuite/affine-shared/services';
import type { BlockStdScope } from '@blocksuite/std';
/**
@@ -73,8 +70,6 @@ export function safeGetIframeSrc(htmlString: string): string | undefined {
* @returns Whether the url can be embedded as an iframe
*/
export function canEmbedAsIframe(std: BlockStdScope, url: string) {
const featureFlag = std.get(FeatureFlagService);
const isEmbedIframeEnabled = featureFlag.getFlag('enable_embed_iframe_block');
const embedIframeService = std.get(EmbedIframeService);
return isEmbedIframeEnabled && embedIframeService.canEmbed(url);
return embedIframeService.canEmbed(url);
}
@@ -48,10 +48,7 @@ import {
getTextSelectionCommand,
} from '@blocksuite/affine-shared/commands';
import { REFERENCE_NODE } from '@blocksuite/affine-shared/consts';
import {
FeatureFlagService,
FileSizeLimitService,
} from '@blocksuite/affine-shared/services';
import { FileSizeLimitService } from '@blocksuite/affine-shared/services';
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import {
createDefaultDoc,
@@ -477,11 +474,7 @@ const embedToolGroup: KeyboardToolPanelGroup = {
name: 'Embed',
icon: EmbedIcon({ style: `color: black` }),
showWhen: ({ std }) => {
const featureFlagService = std.get(FeatureFlagService);
return (
featureFlagService.getFlag('enable_embed_iframe_block') &&
std.store.schema.flavourSchemaMap.has('affine:embed-iframe')
);
return std.store.schema.flavourSchemaMap.has('affine:embed-iframe');
},
action: async ({ std }) => {
std.command
@@ -3,7 +3,6 @@ import {
ActionPlacement,
EmbedIframeService,
EmbedOptionProvider,
FeatureFlagService,
type ToolbarAction,
type ToolbarActionGroup,
type ToolbarModuleConfig,
@@ -196,13 +195,8 @@ export const builtinInlineLinkToolbarConfig = {
if (!url) return false;
// check if the url can be embedded as iframe block
const featureFlag = ctx.std.get(FeatureFlagService);
const embedIframeService = ctx.std.get(EmbedIframeService);
const isEmbedIframeEnabled = featureFlag.getFlag(
'enable_embed_iframe_block'
);
const canEmbedAsIframe =
isEmbedIframeEnabled && embedIframeService.canEmbed(url);
const canEmbedAsIframe = embedIframeService.canEmbed(url);
const options = ctx.std
.get(EmbedOptionProvider)
@@ -234,12 +228,8 @@ export const builtinInlineLinkToolbarConfig = {
let blockId: string | undefined;
// first try to embed as iframe block
const featureFlag = ctx.std.get(FeatureFlagService);
const isEmbedIframeEnabled = featureFlag.getFlag(
'enable_embed_iframe_block'
);
const embedIframeService = ctx.std.get(EmbedIframeService);
if (isEmbedIframeEnabled && embedIframeService.canEmbed(url)) {
if (embedIframeService.canEmbed(url)) {
blockId = embedIframeService.addEmbedIframeBlock(
props,
parent.id,
@@ -18,7 +18,6 @@ export interface BlockSuiteFlags {
enable_mobile_linked_doc_menu: boolean;
enable_block_meta: boolean;
enable_callout: boolean;
enable_embed_iframe_block: boolean;
enable_edgeless_scribbled_style: boolean;
}
@@ -42,7 +41,6 @@ export class FeatureFlagService extends StoreExtension {
enable_mobile_linked_doc_menu: false,
enable_block_meta: false,
enable_callout: false,
enable_embed_iframe_block: false,
enable_edgeless_scribbled_style: false,
});
@@ -105,16 +105,6 @@ export const AFFINE_FLAGS = {
configurable: isCanaryBuild,
defaultState: isCanaryBuild,
},
enable_embed_iframe_block: {
category: 'blocksuite',
bsFlag: 'enable_embed_iframe_block',
displayName:
'com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.name',
description:
'com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.description',
configurable: isCanaryBuild,
defaultState: false,
},
enable_emoji_folder_icon: {
category: 'affine',