mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 13:38:49 +08:00
fix: ai text renderer specs (#8611)
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
|||||||
DividerBlockComponent,
|
DividerBlockComponent,
|
||||||
ListBlockComponent,
|
ListBlockComponent,
|
||||||
ParagraphBlockComponent,
|
ParagraphBlockComponent,
|
||||||
SpecProvider,
|
|
||||||
} from '@blocksuite/affine/blocks';
|
} from '@blocksuite/affine/blocks';
|
||||||
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||||
import { BlockViewType, type Doc, type Query } from '@blocksuite/affine/store';
|
import { BlockViewType, type Doc, type Query } from '@blocksuite/affine/store';
|
||||||
@@ -17,6 +16,7 @@ import { property, query } from 'lit/decorators.js';
|
|||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { keyed } from 'lit/directives/keyed.js';
|
import { keyed } from 'lit/directives/keyed.js';
|
||||||
|
|
||||||
|
import { CustomPageEditorBlockSpecs } from '../utils/custom-specs';
|
||||||
import { markDownToDoc } from '../utils/markdown-utils';
|
import { markDownToDoc } from '../utils/markdown-utils';
|
||||||
|
|
||||||
const textBlockStyles = css`
|
const textBlockStyles = css`
|
||||||
@@ -107,27 +107,27 @@ export class TextRenderer extends WithDisposable(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ai-answer-text-container {
|
.text-renderer-container {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
overscroll-behavior-y: none;
|
overscroll-behavior-y: none;
|
||||||
}
|
}
|
||||||
.ai-answer-text-container.show-scrollbar::-webkit-scrollbar {
|
.text-renderer-container.show-scrollbar::-webkit-scrollbar {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
}
|
}
|
||||||
.ai-answer-text-container.show-scrollbar::-webkit-scrollbar-thumb {
|
.text-renderer-container.show-scrollbar::-webkit-scrollbar-thumb {
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
}
|
}
|
||||||
.ai-answer-text-container.show-scrollbar:hover::-webkit-scrollbar-thumb {
|
.text-renderer-container.show-scrollbar:hover::-webkit-scrollbar-thumb {
|
||||||
background-color: var(--affine-black-30);
|
background-color: var(--affine-black-30);
|
||||||
}
|
}
|
||||||
.ai-answer-text-container.show-scrollbar::-webkit-scrollbar-corner {
|
.text-renderer-container.show-scrollbar::-webkit-scrollbar-corner {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ai-answer-text-container {
|
.text-renderer-container {
|
||||||
rich-text .nowrap-lines v-text span,
|
rich-text .nowrap-lines v-text span,
|
||||||
rich-text .nowrap-lines v-element span {
|
rich-text .nowrap-lines v-element span {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
@@ -138,6 +138,9 @@ export class TextRenderer extends WithDisposable(LitElement) {
|
|||||||
editor-host * {
|
editor-host * {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
editor-host {
|
||||||
|
isolation: isolate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
${textBlockStyles}
|
${textBlockStyles}
|
||||||
@@ -225,15 +228,14 @@ export class TextRenderer extends WithDisposable(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { maxHeight, customHeading } = this.options;
|
const { maxHeight, customHeading } = this.options;
|
||||||
const previewSpec = SpecProvider.getInstance().getSpec('page:preview');
|
|
||||||
const classes = classMap({
|
const classes = classMap({
|
||||||
'ai-answer-text-container': true,
|
'text-renderer-container': true,
|
||||||
'show-scrollbar': !!maxHeight,
|
'show-scrollbar': !!maxHeight,
|
||||||
'custom-heading': !!customHeading,
|
'custom-heading': !!customHeading,
|
||||||
});
|
});
|
||||||
return html`
|
return html`
|
||||||
<style>
|
<style>
|
||||||
.ai-answer-text-container {
|
.text-renderer-container {
|
||||||
max-height: ${maxHeight ? Math.max(maxHeight, 200) + 'px' : ''};
|
max-height: ${maxHeight ? Math.max(maxHeight, 200) + 'px' : ''};
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -243,7 +245,7 @@ export class TextRenderer extends WithDisposable(LitElement) {
|
|||||||
html`<div class="ai-answer-text-editor affine-page-viewport">
|
html`<div class="ai-answer-text-editor affine-page-viewport">
|
||||||
${new BlockStdScope({
|
${new BlockStdScope({
|
||||||
doc: this._doc,
|
doc: this._doc,
|
||||||
extensions: previewSpec.value,
|
extensions: CustomPageEditorBlockSpecs,
|
||||||
}).render()}
|
}).render()}
|
||||||
</div>`
|
</div>`
|
||||||
)}
|
)}
|
||||||
@@ -268,7 +270,7 @@ export class TextRenderer extends WithDisposable(LitElement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@query('.ai-answer-text-container')
|
@query('.text-renderer-container')
|
||||||
private accessor _container!: HTMLDivElement;
|
private accessor _container!: HTMLDivElement;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
|
|||||||
Reference in New Issue
Block a user