diff --git a/blocksuite/affine/blocks/bookmark/src/bookmark-block.ts b/blocksuite/affine/blocks/bookmark/src/bookmark-block.ts index a9c619b446..352556da8a 100644 --- a/blocksuite/affine/blocks/bookmark/src/bookmark-block.ts +++ b/blocksuite/affine/blocks/bookmark/src/bookmark-block.ts @@ -6,6 +6,7 @@ import type { BookmarkBlockModel, LinkPreviewData, } from '@blocksuite/affine-model'; +import { ImageProxyService } from '@blocksuite/affine-shared/adapters'; import { DocModeProvider, LinkPreviewerService, @@ -119,6 +120,10 @@ export class BookmarkBlockComponent extends CaptionedBlockComponent { event.stopPropagation(); @@ -135,9 +140,10 @@ export class BookmarkBlockComponent extends CaptionedBlockComponent { const { url, footnoteIdentifier } = this.model.props; const { icon, title, description } = this.linkPreview$.value; + const iconSrc = icon ? this.imageProxyService.buildUrl(icon) : undefined; return html` ` : WebIcon16; + const imageSrc = favicon + ? this.imageProxyService.buildUrl(favicon) + : undefined; + return imageSrc ? html`favicon` : WebIcon16; } return undefined; }); @@ -190,6 +194,10 @@ export class FootNotePopup extends SignalWatcher(WithDisposable(LitElement)) { `; } + get imageProxyService() { + return this.std.get(ImageProxyService); + } + @property({ attribute: false }) accessor footnote!: FootNote; diff --git a/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts b/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts index 386bc3a242..dbcdf580b9 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts @@ -273,6 +273,21 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) { this._doc.readonly = true; this.requestUpdate(); if (this.state !== 'generating') { + // LinkPreviewerService & ImageProxyService config should read from host settings + const linkPreviewerService = + this.host?.std.store.get(LinkPreviewerService); + const imageProxyService = + this.host?.std.store.get(ImageProxyService); + if (linkPreviewerService) { + this._doc + ?.get(LinkPreviewerService) + .setEndpoint(linkPreviewerService.endpoint); + } + if (imageProxyService) { + this._doc + ?.get(ImageProxyService) + .setImageProxyURL(imageProxyService.imageProxyURL); + } this._clearTimer(); } }) @@ -289,20 +304,6 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) { if (this.state === 'generating') { this._timer = setInterval(this._updateDoc, 600); } - - // LinkPreviewerService & ImageProxyService config should read from host settings - const linkPreviewerService = this.host?.std.store.get(LinkPreviewerService); - const imageProxyService = this.host?.std.store.get(ImageProxyService); - if (linkPreviewerService) { - this._doc - ?.get(LinkPreviewerService) - .setEndpoint(linkPreviewerService.endpoint); - } - if (imageProxyService) { - this._doc - ?.get(ImageProxyService) - .setImageProxyURL(imageProxyService.imageProxyURL); - } } private disposeDoc() {