Skip to content

Commit

Permalink
More formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tneotia committed Mar 13, 2021
1 parent 56efaf5 commit 26341d6
Showing 1 changed file with 42 additions and 38 deletions.
80 changes: 42 additions & 38 deletions lib/src/widgets/html_editor_widget_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
(p == widget.plugins.last
? "]]\n"
: p.getToolbarString().isNotEmpty
? ", "
: "");
? ", "
: "");
headString = headString + p.getHeadString() + "\n";
if (p is SummernoteAtMention) {
summernoteCallbacks = summernoteCallbacks +
Expand Down Expand Up @@ -140,10 +140,10 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
summernoteCallbacks = summernoteCallbacks + "}";
String darkCSS = "";
if ((Theme.of(widget.initBC).brightness == Brightness.dark ||
widget.darkMode == true) &&
widget.darkMode == true) &&
widget.darkMode != false) {
darkCSS =
"<link href=\"assets/packages/html_editor_enhanced/assets/summernote-lite-dark.css\" rel=\"stylesheet\">";
"<link href=\"assets/packages/html_editor_enhanced/assets/summernote-lite-dark.css\" rel=\"stylesheet\">";
}
String jsCallbacks = "";
if (widget.callbacks != null)
Expand Down Expand Up @@ -264,7 +264,9 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
if (widget.callbacks != null) addJSListener(widget.callbacks!);
final html.IFrameElement iframe = html.IFrameElement()
..width = MediaQuery.of(widget.initBC).size.width.toString() //'800'
..height = widget.autoAdjustHeight ? actualHeight.toString() : widget.height.toString()
..height = widget.autoAdjustHeight
? actualHeight.toString()
: widget.height.toString()
..srcdoc = htmlString
..style.border = 'none'
..onLoad.listen((event) async {
Expand Down Expand Up @@ -297,39 +299,39 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
: Container(height: 0, width: 0),
widget.showBottomToolbar
? Padding(
padding:
const EdgeInsets.only(left: 4, right: 4, bottom: 8, top: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
toolbarIcon(context, Icons.content_copy, "Copy",
onTap: () async {
String? data = await widget.controller.getText();
Clipboard.setData(new ClipboardData(text: data));
}),
toolbarIcon(context, Icons.content_paste, "Paste",
onTap: () async {
ClipboardData? data =
await Clipboard.getData(Clipboard.kTextPlain);
if (data != null) {
String text = data.text!;
if (widget.controller.processInputHtml) {
text = data.text!
.replaceAll("'", '\\"')
.replaceAll('"', '\\"')
.replaceAll("[", "\\[")
.replaceAll("]", "\\]")
.replaceAll("\n", "<br/>")
.replaceAll("\n\n", "<br/>")
.replaceAll("\r", " ")
.replaceAll('\r\n', " ");
padding: const EdgeInsets.only(
left: 4, right: 4, bottom: 8, top: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
toolbarIcon(context, Icons.content_copy, "Copy",
onTap: () async {
String? data = await widget.controller.getText();
Clipboard.setData(new ClipboardData(text: data));
}),
toolbarIcon(context, Icons.content_paste, "Paste",
onTap: () async {
ClipboardData? data =
await Clipboard.getData(Clipboard.kTextPlain);
if (data != null) {
String text = data.text!;
if (widget.controller.processInputHtml) {
text = data.text!
.replaceAll("'", '\\"')
.replaceAll('"', '\\"')
.replaceAll("[", "\\[")
.replaceAll("]", "\\]")
.replaceAll("\n", "<br/>")
.replaceAll("\n\n", "<br/>")
.replaceAll("\r", " ")
.replaceAll('\r\n', " ");
}
widget.controller.insertHtml(text);
}
widget.controller.insertHtml(text);
}
}),
],
),
)
}),
],
),
)
: Container(height: 0, width: 0),
],
),
Expand Down Expand Up @@ -410,7 +412,9 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
void addJSListener(Callbacks c) {
html.window.onMessage.listen((event) {
var data = json.decode(event.data);
if (data["type"].contains("toDart:") && data["view"] == createdViewId) {
if (data["type"] != null &&
data["type"].contains("toDart:") &&
data["view"] == createdViewId) {
if (data["type"].contains("htmlHeight") && widget.autoAdjustHeight) {
final docHeight = data["height"] ?? actualHeight;
if ((docHeight != null && docHeight != actualHeight) && mounted) {
Expand Down

0 comments on commit 26341d6

Please sign in to comment.