Skip to content

Commit 9d747f3

Browse files
authored
Merge pull request #871 from LucasXu0/documentation/flowy_editor
docs: minor updates to documentation.
2 parents b8b2de2 + 45a120f commit 9d747f3

File tree

15 files changed

+191
-80
lines changed

15 files changed

+191
-80
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
## 0.0.2
2+
Minor Updates to Documentation.
3+
14
## 0.0.1
5+
Initial Version of the library.

frontend/app_flowy/packages/appflowy_editor/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ and the Flutter guide for
1515

1616
<p align="center">A highly customizable rich-text editor for Flutter</p>
1717

18+
<p align="center">
19+
<a href="https://discord.gg/ZCCYN4Anzq"><b>Discord</b></a> •
20+
<a href="https://twitter.com/appflowy"><b>Twitter</b></a>
21+
</p>
1822

1923
<div align="center">
2024
<img src="https://raw.githubusercontent.com/AppFlowy-IO/AppFlowy/main/frontend/app_flowy/packages/appflowy_editor/documentation/images/example.png" width = "900"/>
345 KB
Loading

frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,41 +81,6 @@ class _MyHomePageState extends State<MyHomePage> {
8181
return Container();
8282
}
8383

84-
Widget _buildExpandableFab() {
85-
return ExpandableFab(
86-
distance: 112.0,
87-
children: [
88-
ActionButton(
89-
onPressed: () {
90-
if (page == 0) return;
91-
setState(() {
92-
page = 0;
93-
});
94-
},
95-
icon: const Icon(Icons.note_add),
96-
),
97-
ActionButton(
98-
icon: const Icon(Icons.document_scanner),
99-
onPressed: () {
100-
if (page == 1) return;
101-
setState(() {
102-
page = 1;
103-
});
104-
},
105-
),
106-
ActionButton(
107-
onPressed: () {
108-
if (page == 2) return;
109-
setState(() {
110-
page = 2;
111-
});
112-
},
113-
icon: const Icon(Icons.text_fields),
114-
),
115-
],
116-
);
117-
}
118-
11984
Widget _buildAppFlowyEditorWithEmptyDocument() {
12085
final editorState = EditorState.empty();
12186
final editor = AppFlowyEditor(
@@ -176,4 +141,39 @@ class _MyHomePageState extends State<MyHomePage> {
176141
),
177142
);
178143
}
144+
145+
Widget _buildExpandableFab() {
146+
return ExpandableFab(
147+
distance: 112.0,
148+
children: [
149+
ActionButton(
150+
onPressed: () {
151+
if (page == 0) return;
152+
setState(() {
153+
page = 0;
154+
});
155+
},
156+
icon: const Icon(Icons.note_add),
157+
),
158+
ActionButton(
159+
icon: const Icon(Icons.document_scanner),
160+
onPressed: () {
161+
if (page == 1) return;
162+
setState(() {
163+
page = 1;
164+
});
165+
},
166+
),
167+
ActionButton(
168+
onPressed: () {
169+
if (page == 2) return;
170+
setState(() {
171+
page = 2;
172+
});
173+
},
174+
icon: const Icon(Icons.text_fields),
175+
),
176+
],
177+
);
178+
}
179179
}

frontend/app_flowy/packages/appflowy_editor/lib/src/infra/flowy_svg.dart

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@ class FlowySvg extends StatelessWidget {
55
const FlowySvg({
66
Key? key,
77
this.name,
8-
this.size = const Size(20, 20),
8+
this.width,
9+
this.height,
910
this.color,
1011
this.number,
1112
this.padding,
1213
}) : super(key: key);
1314

1415
final String? name;
15-
final Size size;
16+
final double? width;
17+
final double? height;
1618
final Color? color;
1719
final int? number;
1820
final EdgeInsets? padding;
1921

22+
final _defaultWidth = 20.0;
23+
final _defaultHeight = 20.0;
24+
2025
@override
2126
Widget build(BuildContext context) {
2227
return Padding(
@@ -27,22 +32,21 @@ class FlowySvg extends StatelessWidget {
2732

2833
Widget _buildSvg() {
2934
if (name != null) {
30-
return SizedBox.fromSize(
31-
size: size,
32-
child: SvgPicture.asset(
33-
'assets/images/$name.svg',
34-
color: color,
35-
package: 'appflowy_editor',
36-
fit: BoxFit.fill,
37-
),
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',
3842
);
3943
} else if (number != null) {
4044
final numberText =
4145
'<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>';
4246
return SvgPicture.string(
4347
numberText,
44-
width: size.width,
45-
height: size.width,
48+
width: width ?? _defaultWidth,
49+
height: height ?? _defaultHeight,
4650
);
4751
}
4852
return Container();

frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/bulleted_list_text.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class _BulletedListTextNodeWidgetState extends State<BulletedListTextNodeWidget>
4747
final iconKey = GlobalKey();
4848

4949
final _richTextKey = GlobalKey(debugLabel: 'bulleted_list_text');
50-
final _iconSize = 20.0;
50+
final _iconWidth = 20.0;
5151
final _iconRightPadding = 5.0;
5252

5353
@override
@@ -67,7 +67,8 @@ class _BulletedListTextNodeWidgetState extends State<BulletedListTextNodeWidget>
6767
children: [
6868
FlowySvg(
6969
key: iconKey,
70-
size: Size.square(_iconSize),
70+
width: _iconWidth,
71+
height: _iconWidth,
7172
padding:
7273
EdgeInsets.only(top: topPadding, right: _iconRightPadding),
7374
name: 'point',

frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class _CheckboxNodeWidgetState extends State<CheckboxNodeWidget>
4545
final iconKey = GlobalKey();
4646

4747
final _richTextKey = GlobalKey(debugLabel: 'checkbox_text');
48-
final _iconSize = 20.0;
48+
final _iconWidth = 20.0;
4949
final _iconRightPadding = 5.0;
5050

5151
@override
@@ -74,7 +74,8 @@ class _CheckboxNodeWidgetState extends State<CheckboxNodeWidget>
7474
GestureDetector(
7575
key: iconKey,
7676
child: FlowySvg(
77-
size: Size.square(_iconSize),
77+
width: _iconWidth,
78+
height: _iconWidth,
7879
padding: EdgeInsets.only(
7980
top: topPadding,
8081
right: _iconRightPadding,

frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/number_list_text.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class _NumberListTextNodeWidgetState extends State<NumberListTextNodeWidget>
4747
final iconKey = GlobalKey();
4848

4949
final _richTextKey = GlobalKey(debugLabel: 'number_list_text');
50-
final _iconSize = 20.0;
50+
final _iconWidth = 20.0;
5151
final _iconRightPadding = 5.0;
5252

5353
@override
@@ -66,7 +66,8 @@ class _NumberListTextNodeWidgetState extends State<NumberListTextNodeWidget>
6666
children: [
6767
FlowySvg(
6868
key: iconKey,
69-
size: Size.square(_iconSize),
69+
width: _iconWidth,
70+
height: _iconWidth,
7071
padding:
7172
EdgeInsets.only(top: topPadding, right: _iconRightPadding),
7273
number: widget.textNode.attributes.number,

frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/quoted_text.dart

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class _QuotedTextNodeWidgetState extends State<QuotedTextNodeWidget>
4646
final iconKey = GlobalKey();
4747

4848
final _richTextKey = GlobalKey(debugLabel: 'quoted_text');
49-
final _iconSize = 20.0;
49+
final _iconWidth = 20.0;
5050
final _iconRightPadding = 5.0;
5151

5252
@override
@@ -60,32 +60,34 @@ class _QuotedTextNodeWidgetState extends State<QuotedTextNodeWidget>
6060
width: defaultMaxTextNodeWidth,
6161
child: Padding(
6262
padding: EdgeInsets.only(bottom: defaultLinePadding),
63-
child: Row(
64-
crossAxisAlignment: CrossAxisAlignment.start,
65-
children: [
66-
FlowySvg(
67-
key: iconKey,
68-
size: Size(_iconSize, _quoteHeight),
69-
padding:
70-
EdgeInsets.only(top: topPadding, right: _iconRightPadding),
71-
name: 'quote',
72-
),
73-
Expanded(
74-
child: FlowyRichText(
75-
key: _richTextKey,
76-
placeholderText: 'Quote',
77-
textNode: widget.textNode,
78-
editorState: widget.editorState,
63+
child: IntrinsicHeight(
64+
child: Row(
65+
crossAxisAlignment: CrossAxisAlignment.stretch,
66+
children: [
67+
FlowySvg(
68+
key: iconKey,
69+
width: _iconWidth,
70+
padding: EdgeInsets.only(
71+
top: topPadding, right: _iconRightPadding),
72+
name: 'quote',
7973
),
80-
),
81-
],
74+
Expanded(
75+
child: FlowyRichText(
76+
key: _richTextKey,
77+
placeholderText: 'Quote',
78+
textNode: widget.textNode,
79+
editorState: widget.editorState,
80+
),
81+
),
82+
],
83+
),
8284
),
8385
));
8486
}
8587

8688
double get _quoteHeight {
8789
final lines =
8890
widget.textNode.toRawString().characters.where((c) => c == '\n').length;
89-
return (lines + 1) * _iconSize;
91+
return (lines + 1) * _iconWidth;
9092
}
9193
}

frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection/toolbar_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class _ToolbarWidgetState extends State<ToolbarWidget> with ToolbarMixin {
141141
Size(toolbarHeight - (width != null ? 20 : 0), toolbarHeight),
142142
child: Center(
143143
child: FlowySvg(
144-
size: Size(width ?? 20, 20),
144+
width: width ?? 20,
145145
name: 'toolbar/$name',
146146
),
147147
),

0 commit comments

Comments
 (0)