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