mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 00:56:26 +08:00
fix(editor): chat panel text render link preview base url (#10791)
fix AF-2322
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { DEFAULT_IMAGE_PROXY_ENDPOINT } from '@blocksuite/affine-shared/consts';
|
||||
import { StoreExtension } from '@blocksuite/store';
|
||||
|
||||
import { setImageProxyMiddlewareURL } from './adapters/middleware';
|
||||
@@ -5,5 +6,14 @@ import { setImageProxyMiddlewareURL } from './adapters/middleware';
|
||||
export class ImageProxyService extends StoreExtension {
|
||||
static override key = 'image-proxy';
|
||||
|
||||
setImageProxyURL = setImageProxyMiddlewareURL;
|
||||
private _imageProxyURL = DEFAULT_IMAGE_PROXY_ENDPOINT;
|
||||
|
||||
setImageProxyURL(url: string) {
|
||||
this._imageProxyURL = url;
|
||||
setImageProxyMiddlewareURL(url);
|
||||
}
|
||||
|
||||
get imageProxyURL() {
|
||||
return this._imageProxyURL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user