Skip to content

Commit fdb4b45

Browse files
committed
Fix formatting and try again to improve pub score
1 parent 232ed23 commit fdb4b45

File tree

7 files changed

+112
-112
lines changed

7 files changed

+112
-112
lines changed

lib/html_editor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart
1818
if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart';
1919

2020
export 'package:html_editor_enhanced/utils/shims/flutter_inappwebview_fake.dart'
21-
if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart';
21+
if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart';
2222

2323
/// Defines the 3 different cases for file insertion failing
2424
enum UploadError { unsupportedFile, exceededMaxSize, jsException }

lib/src/html_editor_controller_unsupported.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class HtmlEditorController {
9797
/// [withHtmlTags] may not work properly when the selected text is entirely
9898
/// within one HTML tag. However if the selected text spans multiple different
9999
/// tags, it should work as expected.
100-
Future<String> getSelectedTextWeb({bool withHtmlTags = false}) => Future.value('');
100+
Future<String> getSelectedTextWeb({bool withHtmlTags = false}) =>
101+
Future.value('');
101102

102103
/// Insert HTML at the position of the cursor in the editor
103104
/// Note: This method should not be used for plaintext strings

lib/src/html_editor_controller_web.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'dart:convert';
33
import 'dart:html' as html;
44

55
import 'package:flutter/foundation.dart';
6-
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
76
import 'package:html_editor_enhanced/html_editor.dart';
87
import 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart'
98
as unsupported;
@@ -75,8 +74,8 @@ class HtmlEditorController extends unsupported.HtmlEditorController {
7574
} else {
7675
_evaluateJavascriptWeb(data: {'type': 'toIframe: getSelectedText'});
7776
}
78-
var e = await html.window.onMessage.firstWhere(
79-
(element) => json.decode(element.data)['type'] == 'toDart: getSelectedText');
77+
var e = await html.window.onMessage.firstWhere((element) =>
78+
json.decode(element.data)['type'] == 'toDart: getSelectedText');
8079
return json.decode(e.data)['text'];
8180
}
8281

lib/src/widgets/html_editor_widget_mobile.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import 'package:flutter/material.dart';
88
import 'package:flutter/services.dart';
99
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
1010
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
11-
import 'package:html_editor_enhanced/html_editor.dart' hide NavigationActionPolicy, UserScript, ContextMenu;
11+
import 'package:html_editor_enhanced/html_editor.dart'
12+
hide NavigationActionPolicy, UserScript, ContextMenu;
1213
import 'package:html_editor_enhanced/src/widgets/toolbar_widget.dart';
1314
import 'package:html_editor_enhanced/utils/utils.dart';
1415
import 'package:html_editor_enhanced/utils/plugins.dart';
@@ -156,9 +157,9 @@ class _HtmlEditorWidgetMobileState extends State<HtmlEditorWidget> {
156157
)),
157158
initialUserScripts:
158159
widget.htmlEditorOptions.mobileInitialScripts
159-
as UnmodifiableListView<UserScript>?,
160+
as UnmodifiableListView<UserScript>?,
160161
contextMenu: widget.htmlEditorOptions.mobileContextMenu
161-
as ContextMenu?,
162+
as ContextMenu?,
162163
gestureRecognizers: {
163164
Factory<VerticalDragGestureRecognizer>(
164165
() => VerticalDragGestureRecognizer()),
@@ -170,8 +171,9 @@ class _HtmlEditorWidgetMobileState extends State<HtmlEditorWidget> {
170171
shouldOverrideUrlLoading: (controller, action) async {
171172
if (!action.request.url.toString().contains(filePath)) {
172173
return (await widget.callbacks?.onNavigationRequestMobile
173-
?.call(action.request.url.toString()))
174-
as NavigationActionPolicy? ?? NavigationActionPolicy.ALLOW;
174+
?.call(action.request.url.toString()))
175+
as NavigationActionPolicy? ??
176+
NavigationActionPolicy.ALLOW;
175177
}
176178
return NavigationActionPolicy.ALLOW;
177179
},
@@ -189,8 +191,7 @@ class _HtmlEditorWidgetMobileState extends State<HtmlEditorWidget> {
189191
mounted &&
190192
!visibleStream.isClosed) {
191193
Future<void> setHeightJS() async {
192-
await controller.evaluateJavascript(
193-
source: """
194+
await controller.evaluateJavascript(source: """
194195
\$('div.note-editable').outerHeight(${max(docHeight - (toolbarKey.currentContext?.size?.height ?? 0), 30)});
195196
// from https://stackoverflow.com/a/67152280
196197
var selection = window.getSelection();

lib/src/widgets/toolbar_widget.dart

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,108 +1101,108 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
11011101
newColor = _backColorSelected;
11021102
}
11031103
await showDialog(
1104-
context: context,
1105-
builder: (BuildContext context) {
1106-
return PointerInterceptor(
1107-
child: AlertDialog(
1108-
scrollable: true,
1109-
content: ColorPicker(
1110-
color: newColor,
1111-
onColorChanged: (color) {
1112-
newColor = color;
1113-
},
1114-
title: Text('Choose a Color',
1115-
style: Theme.of(context).textTheme.headline6),
1116-
width: 40,
1117-
height: 40,
1118-
spacing: 0,
1119-
runSpacing: 0,
1120-
borderRadius: 0,
1121-
wheelDiameter: 165,
1122-
enableOpacity: false,
1123-
showColorCode: true,
1124-
colorCodeHasColor: true,
1125-
pickersEnabled: <ColorPickerType, bool>{
1126-
ColorPickerType.wheel: true,
1127-
},
1128-
copyPasteBehavior: const ColorPickerCopyPasteBehavior(
1129-
parseShortHexCode: true,
1130-
),
1131-
actionButtons: const ColorPickerActionButtons(
1132-
dialogActionButtons: true,
1133-
),
1134-
),
1135-
actions: <Widget>[
1136-
TextButton(
1137-
onPressed: () {
1138-
Navigator.of(context).pop();
1104+
context: context,
1105+
builder: (BuildContext context) {
1106+
return PointerInterceptor(
1107+
child: AlertDialog(
1108+
scrollable: true,
1109+
content: ColorPicker(
1110+
color: newColor,
1111+
onColorChanged: (color) {
1112+
newColor = color;
11391113
},
1140-
child: Text('Cancel'),
1114+
title: Text('Choose a Color',
1115+
style: Theme.of(context).textTheme.headline6),
1116+
width: 40,
1117+
height: 40,
1118+
spacing: 0,
1119+
runSpacing: 0,
1120+
borderRadius: 0,
1121+
wheelDiameter: 165,
1122+
enableOpacity: false,
1123+
showColorCode: true,
1124+
colorCodeHasColor: true,
1125+
pickersEnabled: <ColorPickerType, bool>{
1126+
ColorPickerType.wheel: true,
1127+
},
1128+
copyPasteBehavior:
1129+
const ColorPickerCopyPasteBehavior(
1130+
parseShortHexCode: true,
1131+
),
1132+
actionButtons: const ColorPickerActionButtons(
1133+
dialogActionButtons: true,
1134+
),
11411135
),
1142-
TextButton(
1136+
actions: <Widget>[
1137+
TextButton(
1138+
onPressed: () {
1139+
Navigator.of(context).pop();
1140+
},
1141+
child: Text('Cancel'),
1142+
),
1143+
TextButton(
1144+
onPressed: () {
1145+
if (t.getIcons()[index].icon ==
1146+
Icons.format_color_text) {
1147+
setState(mounted, this.setState, () {
1148+
_foreColorSelected = Colors.black;
1149+
});
1150+
widget.controller.execCommand(
1151+
'removeFormat',
1152+
argument: 'foreColor');
1153+
widget.controller.execCommand('foreColor',
1154+
argument: 'initial');
1155+
}
1156+
if (t.getIcons()[index].icon ==
1157+
Icons.format_color_fill) {
1158+
setState(mounted, this.setState, () {
1159+
_backColorSelected = Colors.yellow;
1160+
});
1161+
widget.controller.execCommand(
1162+
'removeFormat',
1163+
argument: 'hiliteColor');
1164+
widget.controller.execCommand('hiliteColor',
1165+
argument: 'initial');
1166+
}
1167+
Navigator.of(context).pop();
1168+
},
1169+
child: Text('Reset to default color')),
1170+
TextButton(
11431171
onPressed: () {
11441172
if (t.getIcons()[index].icon ==
11451173
Icons.format_color_text) {
1174+
widget.controller.execCommand('foreColor',
1175+
argument: (newColor.value & 0xFFFFFF)
1176+
.toRadixString(16)
1177+
.padLeft(6, '0')
1178+
.toUpperCase());
11461179
setState(mounted, this.setState, () {
1147-
_foreColorSelected = Colors.black;
1180+
_foreColorSelected = newColor;
11481181
});
1149-
widget.controller.execCommand(
1150-
'removeFormat',
1151-
argument: 'foreColor');
1152-
widget.controller.execCommand('foreColor',
1153-
argument: 'initial');
11541182
}
11551183
if (t.getIcons()[index].icon ==
11561184
Icons.format_color_fill) {
1185+
widget.controller.execCommand('hiliteColor',
1186+
argument: (newColor.value & 0xFFFFFF)
1187+
.toRadixString(16)
1188+
.padLeft(6, '0')
1189+
.toUpperCase());
11571190
setState(mounted, this.setState, () {
1158-
_backColorSelected = Colors.yellow;
1191+
_backColorSelected = newColor;
11591192
});
1160-
widget.controller.execCommand(
1161-
'removeFormat',
1162-
argument: 'hiliteColor');
1163-
widget.controller.execCommand('hiliteColor',
1164-
argument: 'initial');
11651193
}
1166-
Navigator.of(context).pop();
1167-
},
1168-
child: Text('Reset to default color')),
1169-
TextButton(
1170-
onPressed: () {
1171-
if (t.getIcons()[index].icon ==
1172-
Icons.format_color_text) {
1173-
widget.controller.execCommand('foreColor',
1174-
argument: (newColor.value & 0xFFFFFF)
1175-
.toRadixString(16)
1176-
.padLeft(6, '0')
1177-
.toUpperCase());
11781194
setState(mounted, this.setState, () {
1179-
_foreColorSelected = newColor;
1195+
_colorSelected[index] =
1196+
!_colorSelected[index];
11801197
});
1181-
}
1182-
if (t.getIcons()[index].icon ==
1183-
Icons.format_color_fill) {
1184-
widget.controller.execCommand('hiliteColor',
1185-
argument: (newColor.value & 0xFFFFFF)
1186-
.toRadixString(16)
1187-
.padLeft(6, '0')
1188-
.toUpperCase());
1189-
setState(mounted, this.setState, () {
1190-
_backColorSelected = newColor;
1191-
});
1192-
}
1193-
setState(mounted, this.setState, () {
1194-
_colorSelected[index] =
1195-
!_colorSelected[index];
1196-
});
1197-
Navigator.of(context).pop();
1198-
},
1199-
child: Text('Set color'),
1200-
)
1201-
],
1202-
),
1203-
);
1204-
}
1205-
);
1198+
Navigator.of(context).pop();
1199+
},
1200+
child: Text('Set color'),
1201+
)
1202+
],
1203+
),
1204+
);
1205+
});
12061206
}
12071207
}
12081208
},

lib/utils/shims/flutter_inappwebview_fake.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class ContextMenu {
3333
///Event fired when the context menu for this WebView is being built.
3434
///
3535
///[hitTestResult] represents the hit result for hitting an HTML elements.
36-
final void Function(dynamic hitTestResult)?
37-
onCreateContextMenu;
36+
final void Function(dynamic hitTestResult)? onCreateContextMenu;
3837

3938
///Event fired when the context menu for this WebView is being hidden.
4039
final void Function()? onHideContextMenu;
@@ -43,7 +42,7 @@ class ContextMenu {
4342
///
4443
///[contextMenuItemClicked] represents the [ContextMenuItem] clicked.
4544
final void Function(ContextMenuItem contextMenuItemClicked)?
46-
onContextMenuActionItemClicked;
45+
onContextMenuActionItemClicked;
4746

4847
///Context menu options.
4948
final ContextMenuOptions? options;
@@ -53,10 +52,10 @@ class ContextMenu {
5352

5453
ContextMenu(
5554
{this.menuItems = const [],
56-
this.onCreateContextMenu,
57-
this.onHideContextMenu,
58-
this.options,
59-
this.onContextMenuActionItemClicked});
55+
this.onCreateContextMenu,
56+
this.onHideContextMenu,
57+
this.options,
58+
this.onContextMenuActionItemClicked});
6059

6160
Map<String, dynamic> toMap() {
6261
return {
@@ -206,10 +205,10 @@ class UserScript {
206205

207206
UserScript(
208207
{this.groupName,
209-
required this.source,
210-
required this.injectionTime,
211-
this.iosForMainFrameOnly = true,
212-
ContentWorld? contentWorld}) {
208+
required this.source,
209+
required this.injectionTime,
210+
this.iosForMainFrameOnly = true,
211+
ContentWorld? contentWorld}) {
213212
this.contentWorld = contentWorld ?? ContentWorld.PAGE;
214213
}
215214

@@ -261,7 +260,7 @@ class ContentWorld {
261260
///The default world for clients.
262261
// ignore: non_constant_identifier_names
263262
static final ContentWorld DEFAULT_CLIENT =
264-
ContentWorld.world(name: 'defaultClient');
263+
ContentWorld.world(name: 'defaultClient');
265264

266265
///The content world for the current webpage’s content.
267266
///This property contains the content world for scripts that the current webpage executes.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: html_editor_enhanced
22
description: HTML rich text editor for Android, iOS, and Web, using the Summernote library.
33
Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more.
4-
version: 2.4.0
4+
version: 2.4.0+1
55
homepage: https://github.com/tneotia/html-editor-enhanced
66

77
environment:

0 commit comments

Comments
 (0)