mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(core): action items in the ai response are not optimized for dark mode (#11839)
### TL;DR * Fix action items in the AI response are not optimized for dark mode. * Fix answer content in the AI response are not optimized for edgeless theme.  [uploading 截屏2025-04-21 14.30.00.png...] > CLOSE BS-3249
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createLitPortal } from '@blocksuite/affine/components/portal';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
||||
import { ColorScheme } from '@blocksuite/affine/model';
|
||||
import { ThemeProvider } from '@blocksuite/affine/shared/services';
|
||||
import {
|
||||
EditorHost,
|
||||
PropTypes,
|
||||
@@ -112,6 +112,7 @@ export class AIItemList extends WithDisposable(LitElement) {
|
||||
}
|
||||
|
||||
override render() {
|
||||
const theme = this.host.std.get(ThemeProvider).app$.value;
|
||||
return html`${repeat(this.groups, group => {
|
||||
return html`
|
||||
${group.name
|
||||
@@ -124,7 +125,7 @@ export class AIItemList extends WithDisposable(LitElement) {
|
||||
item => item.name,
|
||||
item =>
|
||||
html`<ai-item
|
||||
.theme=${this.theme}
|
||||
.theme=${theme}
|
||||
.onClick=${this.onClick}
|
||||
.item=${item}
|
||||
.host=${this.host}
|
||||
@@ -147,9 +148,6 @@ export class AIItemList extends WithDisposable(LitElement) {
|
||||
|
||||
@property({ attribute: 'data-testid', reflect: true })
|
||||
accessor testId = 'ai-item-list';
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor theme: ColorScheme = ColorScheme.Light;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -86,10 +86,8 @@ export class AskAIPanel extends WithDisposable(LitElement) {
|
||||
const style = styleMap({
|
||||
minWidth: `${this.minWidth}px`,
|
||||
});
|
||||
const appTheme = this.host.std.get(ThemeProvider).app$.value;
|
||||
return html`<div class="ask-ai-panel" style=${style}>
|
||||
<ai-item-list
|
||||
.theme=${appTheme}
|
||||
.host=${this.host}
|
||||
.groups=${this._actionGroups}
|
||||
.onClick=${this.onItemClick}
|
||||
|
||||
@@ -8,7 +8,11 @@ import { PageEditorBlockSpecs } from '@blocksuite/affine/extensions';
|
||||
import { Container, type ServiceProvider } from '@blocksuite/affine/global/di';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
||||
import { codeBlockWrapMiddleware } from '@blocksuite/affine/shared/adapters';
|
||||
import { LinkPreviewerService } from '@blocksuite/affine/shared/services';
|
||||
import {
|
||||
LinkPreviewerService,
|
||||
ThemeProvider,
|
||||
} from '@blocksuite/affine/shared/services';
|
||||
import { unsafeCSSVarV2 } from '@blocksuite/affine/shared/theme';
|
||||
import {
|
||||
BlockStdScope,
|
||||
BlockViewIdentifier,
|
||||
@@ -22,7 +26,11 @@ import type {
|
||||
Store,
|
||||
TransformerMiddleware,
|
||||
} from '@blocksuite/affine/store';
|
||||
import { css, html, nothing, type PropertyValues } from 'lit';
|
||||
import {
|
||||
darkCssVariablesV2,
|
||||
lightCssVariablesV2,
|
||||
} from '@toeverything/theme/v2';
|
||||
import { css, html, nothing, type PropertyValues, unsafeCSS } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
import { classMap } from 'lit/directives/class-map.js';
|
||||
import { keyed } from 'lit/directives/keyed.js';
|
||||
@@ -109,7 +117,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
line-height: var(--affine-line-height);
|
||||
color: var(--affine-text-primary-color);
|
||||
color: ${unsafeCSSVarV2('text/primary')};
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
@@ -168,6 +176,18 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
}
|
||||
|
||||
.text-renderer-container[data-app-theme='dark'] {
|
||||
.ai-answer-text-editor .affine-page-root-block-container {
|
||||
color: ${unsafeCSS(darkCssVariablesV2['--affine-v2-text-primary'])};
|
||||
}
|
||||
}
|
||||
|
||||
.text-renderer-container[data-app-theme='light'] {
|
||||
.ai-answer-text-editor .affine-page-root-block-container {
|
||||
color: ${unsafeCSS(lightCssVariablesV2['--affine-v2-text-primary'])};
|
||||
}
|
||||
}
|
||||
|
||||
${customHeadingStyles}
|
||||
`;
|
||||
|
||||
@@ -288,8 +308,9 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
'text-renderer-container': true,
|
||||
'custom-heading': !!customHeading,
|
||||
});
|
||||
const theme = this.host?.std.get(ThemeProvider).app$.value;
|
||||
return html`
|
||||
<div class=${classes} data-testid=${testId}>
|
||||
<div class=${classes} data-testid=${testId} data-app-theme=${theme}>
|
||||
${keyed(
|
||||
this._doc,
|
||||
html`<div class="ai-answer-text-editor affine-page-viewport">
|
||||
|
||||
Reference in New Issue
Block a user