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 { StoreExtension } from '@blocksuite/store';
|
||||||
|
|
||||||
import { setImageProxyMiddlewareURL } from './adapters/middleware';
|
import { setImageProxyMiddlewareURL } from './adapters/middleware';
|
||||||
@@ -5,5 +6,14 @@ import { setImageProxyMiddlewareURL } from './adapters/middleware';
|
|||||||
export class ImageProxyService extends StoreExtension {
|
export class ImageProxyService extends StoreExtension {
|
||||||
static override key = 'image-proxy';
|
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,
|
type EditorHost,
|
||||||
ShadowlessElement,
|
ShadowlessElement,
|
||||||
} from '@blocksuite/affine/block-std';
|
} 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 { PageEditorBlockSpecs } from '@blocksuite/affine/extensions';
|
||||||
import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';
|
import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';
|
||||||
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
||||||
@@ -15,6 +18,7 @@ import {
|
|||||||
MarkdownInlineToDeltaAdapterExtensions,
|
MarkdownInlineToDeltaAdapterExtensions,
|
||||||
} from '@blocksuite/affine/rich-text';
|
} from '@blocksuite/affine/rich-text';
|
||||||
import { codeBlockWrapMiddleware } from '@blocksuite/affine/shared/adapters';
|
import { codeBlockWrapMiddleware } from '@blocksuite/affine/shared/adapters';
|
||||||
|
import { LinkPreviewerService } from '@blocksuite/affine/shared/services';
|
||||||
import type {
|
import type {
|
||||||
ExtensionType,
|
ExtensionType,
|
||||||
Query,
|
Query,
|
||||||
@@ -254,6 +258,20 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
|||||||
if (this.state === 'generating') {
|
if (this.state === 'generating') {
|
||||||
this._timer = setInterval(this._updateDoc, 600);
|
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() {
|
private disposeDoc() {
|
||||||
|
|||||||
Reference in New Issue
Block a user