Skip to content

Commit baa5d0c

Browse files
committed
fix: #1732 the actions of an image look different than the ones of a code block
1 parent 243a781 commit baa5d0c

File tree

5 files changed

+75
-10
lines changed

5 files changed

+75
-10
lines changed
Lines changed: 6 additions & 0 deletions
Loading

frontend/app_flowy/packages/appflowy_editor_plugins/lib/src/code_block/code_block_node_widget.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:appflowy_editor/appflowy_editor.dart';
2+
import 'package:appflowy_editor_plugins/src/infra/svg.dart';
23
import 'package:flutter/material.dart';
34
import 'package:highlight/highlight.dart' as highlight;
45
import 'package:highlight/languages/all.dart';
@@ -141,10 +142,11 @@ class __CodeBlockNodeWidgeState extends State<_CodeBlockNodeWidge>
141142
top: -5,
142143
right: -5,
143144
child: IconButton(
144-
icon: Icon(
145-
Icons.delete_forever_outlined,
145+
icon: Svg(
146+
name: 'delete',
146147
color: widget.editorState.editorStyle.selectionMenuItemIconColor,
147-
size: 16,
148+
width: 16,
149+
height: 16,
148150
),
149151
onPressed: () {
150152
final transaction = widget.editorState.transaction
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_svg/svg.dart';
3+
4+
class Svg extends StatelessWidget {
5+
const Svg({
6+
Key? key,
7+
this.name,
8+
this.width,
9+
this.height,
10+
this.color,
11+
this.number,
12+
this.padding,
13+
}) : super(key: key);
14+
15+
final String? name;
16+
final double? width;
17+
final double? height;
18+
final Color? color;
19+
final int? number;
20+
final EdgeInsets? padding;
21+
22+
final _defaultWidth = 20.0;
23+
final _defaultHeight = 20.0;
24+
25+
@override
26+
Widget build(BuildContext context) {
27+
return Padding(
28+
padding: padding ?? const EdgeInsets.all(0),
29+
child: _buildSvg(),
30+
);
31+
}
32+
33+
Widget _buildSvg() {
34+
if (name != null) {
35+
return SvgPicture.asset(
36+
'assets/images/$name.svg',
37+
color: color,
38+
fit: BoxFit.fill,
39+
height: height,
40+
width: width,
41+
package: 'appflowy_editor_plugins',
42+
);
43+
} else if (number != null) {
44+
final numberText =
45+
'<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg"><text x="30" y="150" fill="black" font-size="160">$number.</text></svg>';
46+
return SvgPicture.string(
47+
numberText,
48+
width: width ?? _defaultWidth,
49+
height: height ?? _defaultHeight,
50+
);
51+
}
52+
return Container();
53+
}
54+
}

frontend/app_flowy/packages/appflowy_editor_plugins/lib/src/math_ equation/math_equation_node_widget.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:appflowy_editor/appflowy_editor.dart';
2+
import 'package:appflowy_editor_plugins/src/infra/svg.dart';
23
import 'package:flutter/material.dart';
34
import 'package:flutter/services.dart';
45
import 'package:flutter_math_fork/flutter_math.dart';
@@ -141,10 +142,11 @@ class _MathEquationNodeWidgetState extends State<_MathEquationNodeWidget> {
141142
top: -5,
142143
right: -5,
143144
child: IconButton(
144-
icon: Icon(
145-
Icons.delete_forever_outlined,
145+
icon: Svg(
146+
name: 'delete',
146147
color: widget.editorState.editorStyle.selectionMenuItemIconColor,
147-
size: 16,
148+
width: 16,
149+
height: 16,
148150
),
149151
onPressed: () {
150152
final transaction = widget.editorState.transaction

frontend/app_flowy/packages/appflowy_editor_plugins/pubspec.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ environment:
1212
dependencies:
1313
flutter:
1414
sdk: flutter
15-
appflowy_editor:
15+
appflowy_editor:
1616
path: ../appflowy_editor
17-
flowy_infra_ui:
17+
flowy_infra_ui:
1818
path: ../flowy_infra_ui
1919
flutter_math_fork: ^0.6.3+1
2020
highlight: ^0.7.0
2121
shared_preferences: ^2.0.15
22+
flutter_svg: ^1.1.1+1
2223

2324
dev_dependencies:
2425
flutter_test:
@@ -32,8 +33,8 @@ dev_dependencies:
3233
flutter:
3334

3435
# To add assets to your package, add an assets section, like this:
35-
# assets:
36-
# - images/a_dot_burr.jpeg
36+
assets:
37+
- assets/images/
3738
# - images/a_dot_ham.jpeg
3839
#
3940
# For details regarding assets in packages, see

0 commit comments

Comments
 (0)