Skip to content

Commit

Permalink
Fix formatting and try again to improve pub score
Browse files Browse the repository at this point in the history
  • Loading branch information
tneotia committed Oct 30, 2021
1 parent 232ed23 commit fdb4b45
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 112 deletions.
2 changes: 1 addition & 1 deletion lib/html_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart
if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart';

export 'package:html_editor_enhanced/utils/shims/flutter_inappwebview_fake.dart'
if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart';
if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart';

/// Defines the 3 different cases for file insertion failing
enum UploadError { unsupportedFile, exceededMaxSize, jsException }
Expand Down
3 changes: 2 additions & 1 deletion lib/src/html_editor_controller_unsupported.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class HtmlEditorController {
/// [withHtmlTags] may not work properly when the selected text is entirely
/// within one HTML tag. However if the selected text spans multiple different
/// tags, it should work as expected.
Future<String> getSelectedTextWeb({bool withHtmlTags = false}) => Future.value('');
Future<String> getSelectedTextWeb({bool withHtmlTags = false}) =>
Future.value('');

/// Insert HTML at the position of the cursor in the editor
/// Note: This method should not be used for plaintext strings
Expand Down
5 changes: 2 additions & 3 deletions lib/src/html_editor_controller_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:convert';
import 'dart:html' as html;

import 'package:flutter/foundation.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:html_editor_enhanced/html_editor.dart';
import 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart'
as unsupported;
Expand Down Expand Up @@ -75,8 +74,8 @@ class HtmlEditorController extends unsupported.HtmlEditorController {
} else {
_evaluateJavascriptWeb(data: {'type': 'toIframe: getSelectedText'});
}
var e = await html.window.onMessage.firstWhere(
(element) => json.decode(element.data)['type'] == 'toDart: getSelectedText');
var e = await html.window.onMessage.firstWhere((element) =>
json.decode(element.data)['type'] == 'toDart: getSelectedText');
return json.decode(e.data)['text'];
}

Expand Down
15 changes: 8 additions & 7 deletions lib/src/widgets/html_editor_widget_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:html_editor_enhanced/html_editor.dart' hide NavigationActionPolicy, UserScript, ContextMenu;
import 'package:html_editor_enhanced/html_editor.dart'
hide NavigationActionPolicy, UserScript, ContextMenu;
import 'package:html_editor_enhanced/src/widgets/toolbar_widget.dart';
import 'package:html_editor_enhanced/utils/utils.dart';
import 'package:html_editor_enhanced/utils/plugins.dart';
Expand Down Expand Up @@ -156,9 +157,9 @@ class _HtmlEditorWidgetMobileState extends State<HtmlEditorWidget> {
)),
initialUserScripts:
widget.htmlEditorOptions.mobileInitialScripts
as UnmodifiableListView<UserScript>?,
as UnmodifiableListView<UserScript>?,
contextMenu: widget.htmlEditorOptions.mobileContextMenu
as ContextMenu?,
as ContextMenu?,
gestureRecognizers: {
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer()),
Expand All @@ -170,8 +171,9 @@ class _HtmlEditorWidgetMobileState extends State<HtmlEditorWidget> {
shouldOverrideUrlLoading: (controller, action) async {
if (!action.request.url.toString().contains(filePath)) {
return (await widget.callbacks?.onNavigationRequestMobile
?.call(action.request.url.toString()))
as NavigationActionPolicy? ?? NavigationActionPolicy.ALLOW;
?.call(action.request.url.toString()))
as NavigationActionPolicy? ??
NavigationActionPolicy.ALLOW;
}
return NavigationActionPolicy.ALLOW;
},
Expand All @@ -189,8 +191,7 @@ class _HtmlEditorWidgetMobileState extends State<HtmlEditorWidget> {
mounted &&
!visibleStream.isClosed) {
Future<void> setHeightJS() async {
await controller.evaluateJavascript(
source: """
await controller.evaluateJavascript(source: """
\$('div.note-editable').outerHeight(${max(docHeight - (toolbarKey.currentContext?.size?.height ?? 0), 30)});
// from https://stackoverflow.com/a/67152280
var selection = window.getSelection();
Expand Down
174 changes: 87 additions & 87 deletions lib/src/widgets/toolbar_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1101,108 +1101,108 @@ class ToolbarWidgetState extends State<ToolbarWidget> {
newColor = _backColorSelected;
}
await showDialog(
context: context,
builder: (BuildContext context) {
return PointerInterceptor(
child: AlertDialog(
scrollable: true,
content: ColorPicker(
color: newColor,
onColorChanged: (color) {
newColor = color;
},
title: Text('Choose a Color',
style: Theme.of(context).textTheme.headline6),
width: 40,
height: 40,
spacing: 0,
runSpacing: 0,
borderRadius: 0,
wheelDiameter: 165,
enableOpacity: false,
showColorCode: true,
colorCodeHasColor: true,
pickersEnabled: <ColorPickerType, bool>{
ColorPickerType.wheel: true,
},
copyPasteBehavior: const ColorPickerCopyPasteBehavior(
parseShortHexCode: true,
),
actionButtons: const ColorPickerActionButtons(
dialogActionButtons: true,
),
),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
context: context,
builder: (BuildContext context) {
return PointerInterceptor(
child: AlertDialog(
scrollable: true,
content: ColorPicker(
color: newColor,
onColorChanged: (color) {
newColor = color;
},
child: Text('Cancel'),
title: Text('Choose a Color',
style: Theme.of(context).textTheme.headline6),
width: 40,
height: 40,
spacing: 0,
runSpacing: 0,
borderRadius: 0,
wheelDiameter: 165,
enableOpacity: false,
showColorCode: true,
colorCodeHasColor: true,
pickersEnabled: <ColorPickerType, bool>{
ColorPickerType.wheel: true,
},
copyPasteBehavior:
const ColorPickerCopyPasteBehavior(
parseShortHexCode: true,
),
actionButtons: const ColorPickerActionButtons(
dialogActionButtons: true,
),
),
TextButton(
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('Cancel'),
),
TextButton(
onPressed: () {
if (t.getIcons()[index].icon ==
Icons.format_color_text) {
setState(mounted, this.setState, () {
_foreColorSelected = Colors.black;
});
widget.controller.execCommand(
'removeFormat',
argument: 'foreColor');
widget.controller.execCommand('foreColor',
argument: 'initial');
}
if (t.getIcons()[index].icon ==
Icons.format_color_fill) {
setState(mounted, this.setState, () {
_backColorSelected = Colors.yellow;
});
widget.controller.execCommand(
'removeFormat',
argument: 'hiliteColor');
widget.controller.execCommand('hiliteColor',
argument: 'initial');
}
Navigator.of(context).pop();
},
child: Text('Reset to default color')),
TextButton(
onPressed: () {
if (t.getIcons()[index].icon ==
Icons.format_color_text) {
widget.controller.execCommand('foreColor',
argument: (newColor.value & 0xFFFFFF)
.toRadixString(16)
.padLeft(6, '0')
.toUpperCase());
setState(mounted, this.setState, () {
_foreColorSelected = Colors.black;
_foreColorSelected = newColor;
});
widget.controller.execCommand(
'removeFormat',
argument: 'foreColor');
widget.controller.execCommand('foreColor',
argument: 'initial');
}
if (t.getIcons()[index].icon ==
Icons.format_color_fill) {
widget.controller.execCommand('hiliteColor',
argument: (newColor.value & 0xFFFFFF)
.toRadixString(16)
.padLeft(6, '0')
.toUpperCase());
setState(mounted, this.setState, () {
_backColorSelected = Colors.yellow;
_backColorSelected = newColor;
});
widget.controller.execCommand(
'removeFormat',
argument: 'hiliteColor');
widget.controller.execCommand('hiliteColor',
argument: 'initial');
}
Navigator.of(context).pop();
},
child: Text('Reset to default color')),
TextButton(
onPressed: () {
if (t.getIcons()[index].icon ==
Icons.format_color_text) {
widget.controller.execCommand('foreColor',
argument: (newColor.value & 0xFFFFFF)
.toRadixString(16)
.padLeft(6, '0')
.toUpperCase());
setState(mounted, this.setState, () {
_foreColorSelected = newColor;
_colorSelected[index] =
!_colorSelected[index];
});
}
if (t.getIcons()[index].icon ==
Icons.format_color_fill) {
widget.controller.execCommand('hiliteColor',
argument: (newColor.value & 0xFFFFFF)
.toRadixString(16)
.padLeft(6, '0')
.toUpperCase());
setState(mounted, this.setState, () {
_backColorSelected = newColor;
});
}
setState(mounted, this.setState, () {
_colorSelected[index] =
!_colorSelected[index];
});
Navigator.of(context).pop();
},
child: Text('Set color'),
)
],
),
);
}
);
Navigator.of(context).pop();
},
child: Text('Set color'),
)
],
),
);
});
}
}
},
Expand Down
23 changes: 11 additions & 12 deletions lib/utils/shims/flutter_inappwebview_fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class ContextMenu {
///Event fired when the context menu for this WebView is being built.
///
///[hitTestResult] represents the hit result for hitting an HTML elements.
final void Function(dynamic hitTestResult)?
onCreateContextMenu;
final void Function(dynamic hitTestResult)? onCreateContextMenu;

///Event fired when the context menu for this WebView is being hidden.
final void Function()? onHideContextMenu;
Expand All @@ -43,7 +42,7 @@ class ContextMenu {
///
///[contextMenuItemClicked] represents the [ContextMenuItem] clicked.
final void Function(ContextMenuItem contextMenuItemClicked)?
onContextMenuActionItemClicked;
onContextMenuActionItemClicked;

///Context menu options.
final ContextMenuOptions? options;
Expand All @@ -53,10 +52,10 @@ class ContextMenu {

ContextMenu(
{this.menuItems = const [],
this.onCreateContextMenu,
this.onHideContextMenu,
this.options,
this.onContextMenuActionItemClicked});
this.onCreateContextMenu,
this.onHideContextMenu,
this.options,
this.onContextMenuActionItemClicked});

Map<String, dynamic> toMap() {
return {
Expand Down Expand Up @@ -206,10 +205,10 @@ class UserScript {

UserScript(
{this.groupName,
required this.source,
required this.injectionTime,
this.iosForMainFrameOnly = true,
ContentWorld? contentWorld}) {
required this.source,
required this.injectionTime,
this.iosForMainFrameOnly = true,
ContentWorld? contentWorld}) {
this.contentWorld = contentWorld ?? ContentWorld.PAGE;
}

Expand Down Expand Up @@ -261,7 +260,7 @@ class ContentWorld {
///The default world for clients.
// ignore: non_constant_identifier_names
static final ContentWorld DEFAULT_CLIENT =
ContentWorld.world(name: 'defaultClient');
ContentWorld.world(name: 'defaultClient');

///The content world for the current webpage’s content.
///This property contains the content world for scripts that the current webpage executes.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: html_editor_enhanced
description: HTML rich text editor for Android, iOS, and Web, using the Summernote library.
Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more.
version: 2.4.0
version: 2.4.0+1
homepage: https://github.com/tneotia/html-editor-enhanced

environment:
Expand Down

0 comments on commit fdb4b45

Please sign in to comment.