Skip to content

Commit 5d49f3d

Browse files
committed
removed autofocus in order to support web
1 parent dbf0091 commit 5d49f3d

File tree

9 files changed

+50
-46
lines changed

9 files changed

+50
-46
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.9+1
2+
* Temparory fix for buttons not working in web
3+
* Shift to Parsed Markdown Body and Text Field will not work
4+
15
## 0.2.9
26
* added non-scrolling markdown parser
37
* improved logic for min, max lines in markdownfield

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
This is a fork of [simple_markdown_editor by zahnia88](https://github.com/zahniar88/simple_markdown_editor)
44
with contributions from [fossfreaks](https://github.com/fossfreaks)
55

6-
<!-- [![GitHub stars](https://img.shields.io/github/stars/zahniar88/simple_markdown_editor?color=green)](https://github.com/fossfreaks/simple_markdown_editor)
7-
[![undo](https://img.shields.io/pub/v/simple_markdown_editor_plus.svg?color=teal)](https://pub.dev/packages/simple_markdown_editor_plus)
8-
![GitHub](https://img.shields.io/github/license/fossfreaks/simple_markdown_editor?color=red) -->
9-
10-
116
Simple markdown editor library For flutter.
127
For demo video, you can see it at this url [Demo](https://youtu.be/aYBeXXDoNPo)
138

14-
## What's new (14/04/2022)
15-
16-
* Allow use of custom background color for tool bar.
17-
189

1910
## Features
2011
- ✅ Convert to Bold, Italic, Strikethrough
@@ -53,10 +44,9 @@ FocusNode _focusNode = FocusNode();
5344
Show widget for editor
5445

5546
```dart
56-
// editable text with toolbar
47+
// editable text with toolbar by default
5748
MarkdownFormField(
5849
controller: _controller,
59-
enableToolBar: true,
6050
emojiConvert: true,
6151
autoCloseAfterSelectEmoji: false,
6252
)
@@ -65,6 +55,7 @@ MarkdownFormField(
6555
MarkdownField(
6656
controller: _controller,
6757
emojiConvert: true,
58+
enableToolBar: false,
6859
)
6960
```
7061

@@ -92,7 +83,7 @@ MarkdownParse(
9283
)
9384
```
9485

95-
Make sure to enable toolbar `enableToolBar: true`, in order to set the colors
86+
In order to set the colors
9687

9788
```dart
9889
MarkdownFormField(

example/lib/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class _HomeScreenState extends State<HomeScreen> {
4444
children: [
4545
MarkdownFormField(
4646
controller: _controller,
47-
enableToolBar: true,
4847
emojiConvert: true,
4948
autoCloseAfterSelectEmoji: false,
5049
// maxLines: 10,

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ packages:
115115
path: ".."
116116
relative: true
117117
source: path
118-
version: "0.2.9"
118+
version: "0.2.9+1"
119119
matcher:
120120
dependency: transitive
121121
description:

lib/widgets/markdown_field.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class MarkdownField extends StatelessWidget {
1717
this.maxLines,
1818
this.minLines,
1919
this.expands = false,
20-
this.decoration = const InputDecoration(hintText: 'Type here...'),
20+
this.decoration =
21+
const InputDecoration(hintText: 'Type here...', isDense: true),
2122
this.padding = const EdgeInsets.all(8),
2223
}) : super(key: key);
2324

lib/widgets/markdown_form_field.dart

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class MarkdownFormField extends StatefulWidget {
1212
this.style,
1313
this.emojiConvert = false,
1414
this.onTap,
15-
this.enableToolBar = false,
15+
this.enableToolBar = true,
1616
this.autoCloseAfterSelectEmoji = true,
1717
this.textCapitalization = TextCapitalization.sentences,
1818
this.readOnly = false,
@@ -23,7 +23,8 @@ class MarkdownFormField extends StatefulWidget {
2323
this.maxLines,
2424
this.minLines,
2525
this.expands = false,
26-
this.decoration = const InputDecoration(hintText: 'Type here...'),
26+
this.decoration =
27+
const InputDecoration(hintText: 'Type here...', isDense: true),
2728
this.padding = const EdgeInsets.all(8),
2829
}) : super(key: key);
2930

@@ -162,20 +163,21 @@ class _MarkdownFormFieldState extends State<MarkdownFormField> {
162163
_internalController = widget.controller ?? TextEditingController();
163164
_internalFocus = widget.focusNode ?? FocusNode();
164165

165-
_internalFocus.addListener(_requestFocused);
166+
// _internalFocus.addListener(_requestFocused);
166167

167168
super.initState();
168169
}
169170

170-
void _requestFocused() {
171-
if (_internalFocus.hasFocus) {
172-
_focused = true;
173-
} else {
174-
_focused = false;
175-
}
171+
// void _requestFocused() {
172+
// if (_internalFocus.hasFocus) {
173+
// _focused = true;
174+
// } else {
175+
// _focused = false;
176+
// }
177+
// // print('Focus Changed.. $_focused');
176178

177-
setState(() {});
178-
}
179+
// setState(() {});
180+
// }
179181

180182
@override
181183
Widget build(BuildContext context) {
@@ -187,11 +189,14 @@ class _MarkdownFormFieldState extends State<MarkdownFormField> {
187189
_internalFocus.requestFocus();
188190
setState(() {});
189191
},
190-
child: MarkdownParseBody(
191-
key: const ValueKey<String>("zmarkdown-parse-body"),
192-
data: _internalController.text == ""
193-
? "Type here. . ."
194-
: _internalController.text,
192+
child: Align(
193+
alignment: Alignment.centerLeft,
194+
child: MarkdownParseBody(
195+
key: const ValueKey<String>("zmarkdown-parse-body"),
196+
data: _internalController.text == ""
197+
? "Type here. . ."
198+
: _internalController.text,
199+
),
195200
),
196201
);
197202
}
@@ -201,6 +206,7 @@ class _MarkdownFormFieldState extends State<MarkdownFormField> {
201206
? _editor()
202207
: Column(
203208
mainAxisSize: MainAxisSize.min,
209+
crossAxisAlignment: CrossAxisAlignment.start,
204210
children: [
205211
_editor(),
206212

@@ -213,10 +219,12 @@ class _MarkdownFormFieldState extends State<MarkdownFormField> {
213219
autoCloseAfterSelectEmoji:
214220
widget.autoCloseAfterSelectEmoji,
215221
isEditorFocused: (bool status) {
222+
// print('isEditorFocused...');
216223
_focused = status;
217224
setState(() {});
218225
},
219226
onPreviewChanged: () {
227+
// print('onPreviewChanged');
220228
_focused = _focused ? false : true;
221229
FocusScope.of(context).unfocus();
222230
setState(() {});
@@ -232,10 +240,12 @@ class _MarkdownFormFieldState extends State<MarkdownFormField> {
232240
autoCloseAfterSelectEmoji:
233241
widget.autoCloseAfterSelectEmoji,
234242
isEditorFocused: (bool status) {
243+
// print('isEditorFocused...');
235244
_focused = status;
236245
setState(() {});
237246
},
238247
onPreviewChanged: () {
248+
// print('onPreviewChanged');
239249
_focused = _focused ? false : true;
240250
FocusScope.of(context).unfocus();
241251
setState(() {});

lib/widgets/markdown_toolbar.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ import 'modal_input_url.dart';
66
import 'toolbar_item.dart';
77

88
class MarkdownToolbar extends StatelessWidget {
9+
final VoidCallback onPreviewChanged;
10+
final TextEditingController controller;
11+
final FocusNode focusNode;
12+
final bool emojiConvert;
13+
final bool autoCloseAfterSelectEmoji;
14+
final Toolbar toolbar;
15+
final ValueChanged<bool> isEditorFocused;
16+
final Color? toolbarBackground;
17+
final Color? expandableBackground;
18+
919
MarkdownToolbar({
1020
Key? key,
1121
required this.onPreviewChanged,
@@ -23,16 +33,6 @@ class MarkdownToolbar extends StatelessWidget {
2333
),
2434
super(key: key);
2535

26-
final VoidCallback onPreviewChanged;
27-
final TextEditingController controller;
28-
final FocusNode focusNode;
29-
final bool emojiConvert;
30-
final bool autoCloseAfterSelectEmoji;
31-
final Toolbar toolbar;
32-
final ValueChanged<bool> isEditorFocused;
33-
final Color? toolbarBackground;
34-
final Color? expandableBackground;
35-
3636
@override
3737
Widget build(BuildContext context) {
3838
return Container(

lib/widgets/toolbar_item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ToolbarItem extends StatelessWidget {
1717
final VoidCallback? onPressedButton;
1818
final String? tooltip;
1919
final bool isExpandable;
20-
final List? items;
20+
final List<Widget>? items;
2121
final Color? expandableBackground;
2222

2323
@override

pubspec.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: markdown_editor_plus
2-
description:
3-
A TextFormField Widget that allow you to convert easily what's in the
4-
FormField to Markdown with custom toolbar support.
2+
description: A TextField Widget that allow you to convert easily what's in the
3+
TextField to Markdown with custom toolbar support.
54

6-
version: 0.2.9
5+
version: 0.2.9+1
76
homepage: https://github.com/OmkarDabade/markdown_editor_plus
87
repository: https://github.com/OmkarDabade/markdown_editor_plus
98

0 commit comments

Comments
 (0)