Skip to content

Commit

Permalink
Merge pull request #16 from JEuler/ios-null-text-fix
Browse files Browse the repository at this point in the history
iOS fix for null text
  • Loading branch information
chandrabezzo committed Feb 5, 2021
2 parents b0c23db + 6c669e6 commit d066f1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ Parameter | Type | Default | Description
**hint** | String | empty | Placeholder hint text
**customToolbar** | String | empty | Add all available [Toolbar](https://summernote.org/deep-dive/#custom-toolbar-popover). Don't use insert (video & picture), please use **hasAttachment** option.
**hasAttachment** | Boolean | false | Use this option if yout want to show or hide attachment button
**returnContent** | Function | null | Use this callback to return text content on `await keyEditor.currentState.getText()` function call.
**showBottomToolbar** | Boolean | false | Use this option if yout want to show or hide bottom toolbar

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
11 changes: 8 additions & 3 deletions lib/flutter_summernote.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class FlutterSummernote extends StatefulWidget {
final String customToolbar;
final bool hasAttachment;
final bool showBottomToolbar;
final Function(String) returnContent;

FlutterSummernote(
{Key key,
Expand All @@ -37,7 +38,8 @@ class FlutterSummernote extends StatefulWidget {
this.hint,
this.customToolbar,
this.hasAttachment: false,
this.showBottomToolbar: true})
this.showBottomToolbar: true,
this.returnContent})
: super(key: key);

@override
Expand Down Expand Up @@ -204,12 +206,15 @@ class FlutterSummernoteState extends State<FlutterSummernote> {
setState(() {
text = isi;
});
if (widget.returnContent != null) {
widget.returnContent(text);
}
});
}

Future<String> getText() async {
await _controller.evaluateJavascript(
"GetTextSummernote.postMessage(document.getElementsByClassName('note-editable')[0].innerHTML);");
"setTimeout(function(){GetTextSummernote.postMessage(document.getElementsByClassName('note-editable')[0].innerHTML)}, 0);");
return text;
}

Expand Down Expand Up @@ -245,7 +250,7 @@ class FlutterSummernoteState extends State<FlutterSummernote> {

setHint(String text) {
String hint = '\$(".note-placeholder").html("$text");';
_controller.evaluateJavascript(hint);
_controller.evaluateJavascript("setTimeout(function(){$hint}, 0);");
}

Widget widgetIcon(IconData icon, String title, {Function onTap}) {
Expand Down

0 comments on commit d066f1e

Please sign in to comment.