mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +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 { createLitPortal } from '@blocksuite/affine/components/portal';
|
||||||
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
||||||
import { ColorScheme } from '@blocksuite/affine/model';
|
import { ThemeProvider } from '@blocksuite/affine/shared/services';
|
||||||
import {
|
import {
|
||||||
EditorHost,
|
EditorHost,
|
||||||
PropTypes,
|
PropTypes,
|
||||||
@@ -112,6 +112,7 @@ export class AIItemList extends WithDisposable(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override render() {
|
override render() {
|
||||||
|
const theme = this.host.std.get(ThemeProvider).app$.value;
|
||||||
return html`${repeat(this.groups, group => {
|
return html`${repeat(this.groups, group => {
|
||||||
return html`
|
return html`
|
||||||
${group.name
|
${group.name
|
||||||
@@ -124,7 +125,7 @@ export class AIItemList extends WithDisposable(LitElement) {
|
|||||||
item => item.name,
|
item => item.name,
|
||||||
item =>
|
item =>
|
||||||
html`<ai-item
|
html`<ai-item
|
||||||
.theme=${this.theme}
|
.theme=${theme}
|
||||||
.onClick=${this.onClick}
|
.onClick=${this.onClick}
|
||||||
.item=${item}
|
.item=${item}
|
||||||
.host=${this.host}
|
.host=${this.host}
|
||||||
@@ -147,9 +148,6 @@ export class AIItemList extends WithDisposable(LitElement) {
|
|||||||
|
|
||||||
@property({ attribute: 'data-testid', reflect: true })
|
@property({ attribute: 'data-testid', reflect: true })
|
||||||
accessor testId = 'ai-item-list';
|
accessor testId = 'ai-item-list';
|
||||||
|
|
||||||
@property({ attribute: false })
|
|
||||||
accessor theme: ColorScheme = ColorScheme.Light;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -86,10 +86,8 @@ export class AskAIPanel extends WithDisposable(LitElement) {
|
|||||||
const style = styleMap({
|
const style = styleMap({
|
||||||
minWidth: `${this.minWidth}px`,
|
minWidth: `${this.minWidth}px`,
|
||||||
});
|
});
|
||||||
const appTheme = this.host.std.get(ThemeProvider).app$.value;
|
|
||||||
return html`<div class="ask-ai-panel" style=${style}>
|
return html`<div class="ask-ai-panel" style=${style}>
|
||||||
<ai-item-list
|
<ai-item-list
|
||||||
.theme=${appTheme}
|
|
||||||
.host=${this.host}
|
.host=${this.host}
|
||||||
.groups=${this._actionGroups}
|
.groups=${this._actionGroups}
|
||||||
.onClick=${this.onItemClick}
|
.onClick=${this.onItemClick}
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ 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';
|
||||||
import { codeBlockWrapMiddleware } from '@blocksuite/affine/shared/adapters';
|
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 {
|
import {
|
||||||
BlockStdScope,
|
BlockStdScope,
|
||||||
BlockViewIdentifier,
|
BlockViewIdentifier,
|
||||||
@@ -22,7 +26,11 @@ import type {
|
|||||||
Store,
|
Store,
|
||||||
TransformerMiddleware,
|
TransformerMiddleware,
|
||||||
} from '@blocksuite/affine/store';
|
} 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 { 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';
|
||||||
@@ -109,7 +117,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
line-height: var(--affine-line-height);
|
line-height: var(--affine-line-height);
|
||||||
color: var(--affine-text-primary-color);
|
color: ${unsafeCSSVarV2('text/primary')};
|
||||||
font-weight: 400;
|
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}
|
${customHeadingStyles}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -288,8 +308,9 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
|||||||
'text-renderer-container': true,
|
'text-renderer-container': true,
|
||||||
'custom-heading': !!customHeading,
|
'custom-heading': !!customHeading,
|
||||||
});
|
});
|
||||||
|
const theme = this.host?.std.get(ThemeProvider).app$.value;
|
||||||
return html`
|
return html`
|
||||||
<div class=${classes} data-testid=${testId}>
|
<div class=${classes} data-testid=${testId} data-app-theme=${theme}>
|
||||||
${keyed(
|
${keyed(
|
||||||
this._doc,
|
this._doc,
|
||||||
html`<div class="ai-answer-text-editor affine-page-viewport">
|
html`<div class="ai-answer-text-editor affine-page-viewport">
|
||||||
|
|||||||
Reference in New Issue
Block a user