mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-12 14:40:22 +08:00
0d518adc5b
Closes: [BS-2578](https://linear.app/affine-design/issue/BS-2578/优化-footnote-预览的逻辑:支持缓存结果,避免重复-loading) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a link preview caching mechanism, enabling faster and more efficient reuse of link preview data across the app. - Added a feature flag for enabling or disabling link preview cache, configurable through workspace experimental settings. - Enhanced localization with new entries describing the link preview cache feature. - **Improvements** - Updated link preview service architecture for better extensibility and maintainability. - Improved integration of feature flags throughout chat and rendering components. - **Bug Fixes** - Fixed tooltip formatting for footnote URLs. - **Chores** - Updated dependencies and localization completeness tracking. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
36 lines
957 B
TypeScript
36 lines
957 B
TypeScript
import {
|
|
EmbedYoutubeBlockSchema,
|
|
type EmbedYoutubeModel,
|
|
EmbedYoutubeStyles,
|
|
} from '@blocksuite/affine-model';
|
|
import {
|
|
EmbedOptionConfig,
|
|
LinkPreviewServiceIdentifier,
|
|
} from '@blocksuite/affine-shared/services';
|
|
import { BlockService } from '@blocksuite/std';
|
|
|
|
import { youtubeUrlRegex } from './embed-youtube-model.js';
|
|
import { queryEmbedYoutubeData } from './utils.js';
|
|
|
|
export class EmbedYoutubeBlockService extends BlockService {
|
|
static override readonly flavour = EmbedYoutubeBlockSchema.model.flavour;
|
|
|
|
queryUrlData = (
|
|
embedYoutubeModel: EmbedYoutubeModel,
|
|
signal?: AbortSignal
|
|
) => {
|
|
return queryEmbedYoutubeData(
|
|
embedYoutubeModel,
|
|
this.std.get(LinkPreviewServiceIdentifier),
|
|
signal
|
|
);
|
|
};
|
|
}
|
|
|
|
export const EmbedYoutubeBlockOptionConfig = EmbedOptionConfig({
|
|
flavour: EmbedYoutubeBlockSchema.model.flavour,
|
|
urlRegex: youtubeUrlRegex,
|
|
styles: EmbedYoutubeStyles,
|
|
viewType: 'embed',
|
|
});
|