mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
fix(core): text-renderer should be readonly (#9244)
fix AF-2010, AF-2009
This commit is contained in:
@@ -195,6 +195,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
if (latestAnswer && schema) {
|
||||
markDownToDoc(schema, latestAnswer, this.options.additionalMiddlewares)
|
||||
.then(doc => {
|
||||
this.disposeDoc();
|
||||
this._doc = doc.blockCollection.getDoc({
|
||||
query: this._query,
|
||||
});
|
||||
@@ -232,9 +233,15 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
}
|
||||
|
||||
private disposeDoc() {
|
||||
this._doc?.dispose();
|
||||
this._doc?.collection.dispose();
|
||||
}
|
||||
|
||||
override disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._clearTimer();
|
||||
this.disposeDoc();
|
||||
}
|
||||
|
||||
override render() {
|
||||
|
||||
@@ -194,7 +194,6 @@ export async function markDownToDoc(
|
||||
const collection = new DocCollection({
|
||||
schema,
|
||||
});
|
||||
collection.awarenessStore.awareness.destroy();
|
||||
collection.meta.initialize();
|
||||
const middlewares = [defaultImageProxyMiddleware];
|
||||
if (additionalMiddlewares) {
|
||||
|
||||
@@ -150,5 +150,7 @@ export const copyText = async (host: EditorHost, text: string) => {
|
||||
.flatMap(model => model.children);
|
||||
const slice = Slice.fromModels(previewDoc, models);
|
||||
await host.std.clipboard.copySlice(slice);
|
||||
previewDoc.dispose();
|
||||
previewDoc.collection.dispose();
|
||||
return true;
|
||||
};
|
||||
|
||||
+5
@@ -98,6 +98,7 @@ export const linkPreviewContainer = style({
|
||||
});
|
||||
|
||||
export const linkPreview = style({
|
||||
cursor: 'default',
|
||||
border: `0.5px solid ${cssVarV2('backlinks/blockBorder')}`,
|
||||
borderRadius: '8px',
|
||||
padding: '8px',
|
||||
@@ -111,6 +112,10 @@ export const linkPreview = style({
|
||||
},
|
||||
});
|
||||
|
||||
globalStyle(`${linkPreview} *`, {
|
||||
cursor: 'default',
|
||||
});
|
||||
|
||||
export const linkPreviewRenderer = style({
|
||||
cursor: 'pointer',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user