Skip to content

Commit df7fe97

Browse files
authored
feat: wrap code block lines in AI chat (#6828)
1 parent 9c22bb4 commit df7fe97

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_editor_style.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:appflowy/workspace/application/appearance_defaults.dart';
1313
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
1414
import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart';
1515
import 'package:appflowy_editor/appflowy_editor.dart';
16+
import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';
1617
import 'package:collection/collection.dart';
1718
import 'package:flowy_infra/theme_extension.dart';
1819
import 'package:flutter/material.dart';
@@ -104,12 +105,18 @@ class ChatEditorStyleCustomizer extends EditorStyleCustomizer {
104105
}
105106

106107
@override
107-
TextStyle codeBlockStyleBuilder() {
108+
CodeBlockStyle codeBlockStyleBuilder() {
108109
final fontFamily =
109110
context.read<DocumentAppearanceCubit>().state.codeFontFamily;
110-
return baseTextStyle(fontFamily).copyWith(
111-
height: 1.4,
112-
color: AFThemeExtension.of(context).onBackground,
111+
112+
return CodeBlockStyle(
113+
textStyle: baseTextStyle(fontFamily).copyWith(
114+
height: 1.4,
115+
color: AFThemeExtension.of(context).onBackground,
116+
),
117+
backgroundColor: AFThemeExtension.of(context).calloutBGColor,
118+
foregroundColor: AFThemeExtension.of(context).textColor.withAlpha(155),
119+
wrapLines: true,
113120
);
114121
}
115122

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -546,18 +546,10 @@ CodeBlockComponentBuilder _buildCodeBlockComponentBuilder(
546546
EditorStyleCustomizer styleCustomizer,
547547
) {
548548
return CodeBlockComponentBuilder(
549-
configuration: configuration.copyWith(
550-
textStyle: (_) => styleCustomizer.codeBlockStyleBuilder(),
551-
placeholderTextStyle: (_) => styleCustomizer.codeBlockStyleBuilder(),
552-
),
553-
styleBuilder: () => CodeBlockStyle(
554-
backgroundColor: AFThemeExtension.of(context).calloutBGColor,
555-
foregroundColor: AFThemeExtension.of(context).textColor.withAlpha(155),
556-
),
549+
styleBuilder: styleCustomizer.codeBlockStyleBuilder,
557550
padding: const EdgeInsets.only(left: 20, right: 30, bottom: 34),
558551
languagePickerBuilder: codeBlockLanguagePickerBuilder,
559552
copyButtonBuilder: codeBlockCopyBuilder,
560-
showLineNumbers: false,
561553
);
562554
}
563555

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_style.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:appflowy/workspace/application/appearance_defaults.dart';
1414
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
1515
import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart';
1616
import 'package:appflowy_editor/appflowy_editor.dart';
17+
import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';
1718
import 'package:collection/collection.dart';
1819
import 'package:easy_localization/easy_localization.dart';
1920
import 'package:flowy_infra/theme_extension.dart';
@@ -194,14 +195,19 @@ class EditorStyleCustomizer {
194195
);
195196
}
196197

197-
TextStyle codeBlockStyleBuilder() {
198+
CodeBlockStyle codeBlockStyleBuilder() {
198199
final fontSize = context.read<DocumentAppearanceCubit>().state.fontSize;
199200
final fontFamily =
200201
context.read<DocumentAppearanceCubit>().state.codeFontFamily;
201-
return baseTextStyle(fontFamily).copyWith(
202-
fontSize: fontSize,
203-
height: 1.5,
204-
color: AFThemeExtension.of(context).onBackground,
202+
203+
return CodeBlockStyle(
204+
textStyle: baseTextStyle(fontFamily).copyWith(
205+
fontSize: fontSize,
206+
height: 1.5,
207+
color: AFThemeExtension.of(context).onBackground,
208+
),
209+
backgroundColor: AFThemeExtension.of(context).calloutBGColor,
210+
foregroundColor: AFThemeExtension.of(context).textColor.withAlpha(155),
205211
);
206212
}
207213

frontend/appflowy_flutter/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ packages:
7070
dependency: "direct main"
7171
description:
7272
path: "packages/appflowy_editor_plugins"
73-
ref: "2d3d4fb"
74-
resolved-ref: "2d3d4fb536f32cbcdf9fcd52dfe3033429666285"
73+
ref: "27c898d"
74+
resolved-ref: "27c898d1343f52d80444a0f469b8ee403606cf36"
7575
url: "https://github.com/AppFlowy-IO/AppFlowy-plugins.git"
7676
source: git
7777
version: "0.0.6"

frontend/appflowy_flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ dependency_overrides:
177177
git:
178178
url: https://github.com/AppFlowy-IO/AppFlowy-plugins.git
179179
path: "packages/appflowy_editor_plugins"
180-
ref: "2d3d4fb"
180+
ref: "27c898d"
181181

182182
sheet:
183183
git:

0 commit comments

Comments
 (0)