Skip to content

Commit 2acc946

Browse files
committed
fixed switching between markdown and textfield using focusnode
1 parent 5d49f3d commit 2acc946

13 files changed

+138
-141
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.10
2+
* Switch between markdown and textfield using focusNode reimplemented
3+
* Dependency upgrade
4+
* Using MarkdownBody instead of MarkdownParseBody in MarkdownFormField
5+
16
## 0.2.9+1
27
* Temparory fix for buttons not working in web
38
* Shift to Parsed Markdown Body and Text Field will not work

example/lib/main.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class _HomeScreenState extends State<HomeScreen> {
4343
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
4444
children: [
4545
MarkdownFormField(
46+
decoration: const InputDecoration(
47+
hintText: 'Type your markdown string here',
48+
),
4649
controller: _controller,
4750
emojiConvert: true,
4851
autoCloseAfterSelectEmoji: false,

example/pubspec.lock

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: args
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.3.0"
10+
version: "2.3.1"
1111
async:
1212
dependency: transitive
1313
description:
@@ -49,7 +49,7 @@ packages:
4949
name: collection
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.15.0"
52+
version: "1.16.0"
5353
expandable:
5454
dependency: transitive
5555
description:
@@ -63,7 +63,7 @@ packages:
6363
name: fake_async
6464
url: "https://pub.dartlang.org"
6565
source: hosted
66-
version: "1.2.0"
66+
version: "1.3.0"
6767
flutter:
6868
dependency: "direct main"
6969
description: flutter
@@ -75,14 +75,14 @@ packages:
7575
name: flutter_lints
7676
url: "https://pub.dartlang.org"
7777
source: hosted
78-
version: "1.0.4"
78+
version: "2.0.1"
7979
flutter_markdown:
8080
dependency: transitive
8181
description:
8282
name: flutter_markdown
8383
url: "https://pub.dartlang.org"
8484
source: hosted
85-
version: "0.6.10"
85+
version: "0.6.10+2"
8686
flutter_test:
8787
dependency: "direct dev"
8888
description: flutter
@@ -101,7 +101,7 @@ packages:
101101
name: lints
102102
url: "https://pub.dartlang.org"
103103
source: hosted
104-
version: "1.0.1"
104+
version: "2.0.0"
105105
markdown:
106106
dependency: transitive
107107
description:
@@ -110,7 +110,7 @@ packages:
110110
source: hosted
111111
version: "5.0.0"
112112
markdown_editor_plus:
113-
dependency: "direct dev"
113+
dependency: "direct main"
114114
description:
115115
path: ".."
116116
relative: true
@@ -129,7 +129,7 @@ packages:
129129
name: material_color_utilities
130130
url: "https://pub.dartlang.org"
131131
source: hosted
132-
version: "0.1.3"
132+
version: "0.1.4"
133133
meta:
134134
dependency: transitive
135135
description:
@@ -143,7 +143,7 @@ packages:
143143
name: path
144144
url: "https://pub.dartlang.org"
145145
source: hosted
146-
version: "1.8.0"
146+
version: "1.8.1"
147147
sky_engine:
148148
dependency: transitive
149149
description: flutter
@@ -155,7 +155,7 @@ packages:
155155
name: source_span
156156
url: "https://pub.dartlang.org"
157157
source: hosted
158-
version: "1.8.1"
158+
version: "1.8.2"
159159
stack_trace:
160160
dependency: transitive
161161
description:
@@ -190,21 +190,14 @@ packages:
190190
name: test_api
191191
url: "https://pub.dartlang.org"
192192
source: hosted
193-
version: "0.4.8"
194-
typed_data:
195-
dependency: transitive
196-
description:
197-
name: typed_data
198-
url: "https://pub.dartlang.org"
199-
source: hosted
200-
version: "1.3.0"
193+
version: "0.4.9"
201194
vector_math:
202195
dependency: transitive
203196
description:
204197
name: vector_math
205198
url: "https://pub.dartlang.org"
206199
source: hosted
207-
version: "2.1.1"
200+
version: "2.1.2"
208201
sdks:
209-
dart: ">=2.16.2 <3.0.0"
210-
flutter: ">=2.0.0"
202+
dart: ">=2.17.0 <3.0.0"
203+
flutter: ">=3.0.0"

example/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
1818
version: 1.0.0+1
1919

2020
environment:
21-
sdk: ">=2.16.2 <3.0.0"
21+
sdk: ">=2.17.0 <3.0.0"
2222

2323
dependencies:
2424
flutter:
2525
sdk: flutter
26+
markdown_editor_plus:
27+
path: ../
2628

2729
dev_dependencies:
2830
flutter_test:
2931
sdk: flutter
30-
flutter_lints: ^1.0.4
31-
markdown_editor_plus:
32-
path: ../
32+
flutter_lints: ^2.0.1
3333

3434
# For information on the generic Dart part of this file, see the
3535
# following page: https://dart.dev/tools/pub/pubspec

lib/src/emoji_parser.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ class EmojiParser {
194194
if (matches.isNotEmpty) {
195195
String result = text;
196196
matches.toList().forEach((m) {
197-
var _m0 = m.group(0);
198-
if (_m0 != null) {
199-
var _e = EmojiUtil.stripColons(_m0);
200-
if (hasName(_e)) {
201-
result = result.replaceAll(_m0, get(_e).code);
197+
var m0 = m.group(0);
198+
if (m0 != null) {
199+
var e = EmojiUtil.stripColons(m0);
200+
if (hasName(e)) {
201+
result = result.replaceAll(m0, get(e).code);
202202
}
203203
}
204204
});
@@ -218,10 +218,10 @@ class EmojiParser {
218218
if (matches.isNotEmpty) {
219219
String result = text;
220220
matches.toList().forEach((m) {
221-
var _m0 = m.group(0);
222-
if (_m0 != null) {
223-
if (hasEmoji(_m0)) {
224-
result = result.replaceAll(_m0, getEmoji(_m0).full);
221+
var m0 = m.group(0);
222+
if (m0 != null) {
223+
if (hasEmoji(m0)) {
224+
result = result.replaceAll(m0, getEmoji(m0).full);
225225

226226
/// Just a quick hack to clear graphical byte from emoji.
227227
result = result.replaceAll(

lib/src/markdown_syntax.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ColoredMentionElementBuilder extends MarkdownElementBuilder {
7878
);
7979
},
8080
child: Text(
81-
element.textContent + " ",
81+
"${element.textContent} ",
8282
style: TextStyle(
8383
color: Colors.blue[700],
8484
fontWeight: FontWeight.w500,

lib/src/toolbar.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Toolbar {
4646
TextSelection? textSelection,
4747
}) {
4848
if (!focusNode.hasFocus) {
49-
isEditorFocused.call(true);
49+
isEditorFocused(true);
5050
focusNode.requestFocus();
5151
}
5252

@@ -118,7 +118,7 @@ class Toolbar {
118118

119119
return index == splitData.length
120120
? text.replaceFirst(left, "").replaceFirst(right, "")
121-
: text.replaceFirst(left, "").replaceFirst(right, "") + "\n";
121+
: "${text.replaceFirst(left, "").replaceFirst(right, "")}\n";
122122
}
123123

124124
if (text.trim().isEmpty) {

0 commit comments

Comments
 (0)