fix(editor): chat panel text render link preview base url (#10791)

fix AF-2322
This commit is contained in:
pengx17
2025-03-19 03:19:09 +00:00
parent 3a2d386275
commit a118cbd036
2 changed files with 30 additions and 2 deletions

View File

@@ -6,7 +6,10 @@ import {
type EditorHost,
ShadowlessElement,
} from '@blocksuite/affine/block-std';
import { defaultImageProxyMiddleware } from '@blocksuite/affine/blocks/image';
import {
defaultImageProxyMiddleware,
ImageProxyService,
} from '@blocksuite/affine/blocks/image';
import { PageEditorBlockSpecs } from '@blocksuite/affine/extensions';
import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';
import { WithDisposable } from '@blocksuite/affine/global/lit';
@@ -15,6 +18,7 @@ import {
MarkdownInlineToDeltaAdapterExtensions,
} from '@blocksuite/affine/rich-text';
import { codeBlockWrapMiddleware } from '@blocksuite/affine/shared/adapters';
import { LinkPreviewerService } from '@blocksuite/affine/shared/services';
import type {
ExtensionType,
Query,
@@ -254,6 +258,20 @@ 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() {