mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 18:46:19 +08:00
f80b69273f
fix BS-3606 #### PR Dependency Tree * **PR #12892** * **PR #12895** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced support for embedding generic iframes with customizable dimensions and permissions, while ensuring only secure, non-AFFiNE URLs are allowed. * Enhanced embedding options by prioritizing custom embed blocks over iframe blocks for a richer embedding experience across toolbars and link actions. * Added URL validation to support secure and flexible embedding configurations. * **Bug Fixes** * Improved iframe embedding reliability by removing restrictive HTTP headers and certain Content Security Policy directives that could block iframe usage in the Electron app. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import {
|
|
EmbedCardDarkBannerIcon,
|
|
EmbedCardDarkCubeIcon,
|
|
EmbedCardDarkHorizontalIcon,
|
|
EmbedCardDarkListIcon,
|
|
EmbedCardDarkVerticalIcon,
|
|
EmbedCardLightBannerIcon,
|
|
EmbedCardLightCubeIcon,
|
|
EmbedCardLightHorizontalIcon,
|
|
EmbedCardLightListIcon,
|
|
EmbedCardLightVerticalIcon,
|
|
} from '@blocksuite/affine-components/icons';
|
|
import { ColorScheme } from '@blocksuite/affine-model';
|
|
import { EmbedOptionProvider } from '@blocksuite/affine-shared/services';
|
|
import type { BlockStdScope } from '@blocksuite/std';
|
|
import type { TemplateResult } from 'lit';
|
|
|
|
type EmbedCardIcons = {
|
|
EmbedCardBannerIcon: TemplateResult<1>;
|
|
EmbedCardHorizontalIcon: TemplateResult<1>;
|
|
EmbedCardListIcon: TemplateResult<1>;
|
|
EmbedCardVerticalIcon: TemplateResult<1>;
|
|
EmbedCardCubeIcon: TemplateResult<1>;
|
|
};
|
|
|
|
export function getEmbedCardIcons(theme: ColorScheme): EmbedCardIcons {
|
|
if (theme === ColorScheme.Light) {
|
|
return {
|
|
EmbedCardBannerIcon: EmbedCardLightBannerIcon,
|
|
EmbedCardHorizontalIcon: EmbedCardLightHorizontalIcon,
|
|
EmbedCardListIcon: EmbedCardLightListIcon,
|
|
EmbedCardVerticalIcon: EmbedCardLightVerticalIcon,
|
|
EmbedCardCubeIcon: EmbedCardLightCubeIcon,
|
|
};
|
|
} else {
|
|
return {
|
|
EmbedCardBannerIcon: EmbedCardDarkBannerIcon,
|
|
EmbedCardHorizontalIcon: EmbedCardDarkHorizontalIcon,
|
|
EmbedCardListIcon: EmbedCardDarkListIcon,
|
|
EmbedCardVerticalIcon: EmbedCardDarkVerticalIcon,
|
|
EmbedCardCubeIcon: EmbedCardDarkCubeIcon,
|
|
};
|
|
}
|
|
}
|
|
|
|
export function canEmbedAsEmbedBlock(std: BlockStdScope, url: string) {
|
|
const options = std.get(EmbedOptionProvider).getEmbedBlockOptions(url);
|
|
return options?.viewType === 'embed';
|
|
}
|