refactor: used flutter_inappwebview instead of webview_flutter

This commit is contained in:
jideguru 2021-06-04 13:58:03 +01:00
parent 0ba6803269
commit 7677e120cc
17 changed files with 152 additions and 399 deletions

View File

@ -73,6 +73,9 @@ Clear Editor content
await keyEditor.currentState?.clear(); await keyEditor.currentState?.clear();
``` ```
### Custom Toolbar
If you're interested in creating your own toolbar check the custom_toolbar_demo.dart in the example
## License ## License
Copyright 2021 JideGuru Copyright 2021 JideGuru

View File

@ -1,7 +1,15 @@
PODS: PODS:
- Flutter (1.0.0) - Flutter (1.0.0)
- flutter_inappwebview (0.0.1):
- Flutter
- flutter_inappwebview/Core (= 0.0.1)
- OrderedSet (~> 5.0)
- flutter_inappwebview/Core (0.0.1):
- Flutter
- OrderedSet (~> 5.0)
- image_picker (0.0.1): - image_picker (0.0.1):
- Flutter - Flutter
- OrderedSet (5.0.0)
- video_player (0.0.1): - video_player (0.0.1):
- Flutter - Flutter
- wakelock (0.0.1): - wakelock (0.0.1):
@ -11,14 +19,21 @@ PODS:
DEPENDENCIES: DEPENDENCIES:
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`)
- image_picker (from `.symlinks/plugins/image_picker/ios`) - image_picker (from `.symlinks/plugins/image_picker/ios`)
- video_player (from `.symlinks/plugins/video_player/ios`) - video_player (from `.symlinks/plugins/video_player/ios`)
- wakelock (from `.symlinks/plugins/wakelock/ios`) - wakelock (from `.symlinks/plugins/wakelock/ios`)
- webview_flutter (from `.symlinks/plugins/webview_flutter/ios`) - webview_flutter (from `.symlinks/plugins/webview_flutter/ios`)
SPEC REPOS:
trunk:
- OrderedSet
EXTERNAL SOURCES: EXTERNAL SOURCES:
Flutter: Flutter:
:path: Flutter :path: Flutter
flutter_inappwebview:
:path: ".symlinks/plugins/flutter_inappwebview/ios"
image_picker: image_picker:
:path: ".symlinks/plugins/image_picker/ios" :path: ".symlinks/plugins/image_picker/ios"
video_player: video_player:
@ -30,7 +45,9 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721
image_picker: 50e7c7ff960e5f58faa4d1f4af84a771c671bc4a image_picker: 50e7c7ff960e5f58faa4d1f4af84a771c671bc4a
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e
wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f
webview_flutter: 9f491a9b5a66f2573946a389b2677987b0ff8c0b webview_flutter: 9f491a9b5a66f2573946a389b2677987b0ff8c0b

View File

@ -62,29 +62,45 @@ class _CustomToolbarDemoState extends State<CustomToolbarDemo> {
), ),
], ],
), ),
body: RichEditor( body: Column(
key: keyEditor, children: [
Wrap(
children: [
IconButton(
icon: Icon(Icons.format_bold),
onPressed: () {
keyEditor.currentState!.javascriptExecutor.setBold();
},
),
],
),
Expanded(
child: RichEditor(
key: keyEditor,
// value: '', // initial HTML data // value: '', // initial HTML data
editorOptions: RichEditorOptions( editorOptions: RichEditorOptions(
placeholder: 'Start typing', placeholder: 'Start typing',
// backgroundColor: Colors.blueGrey, // Editor's bg color // backgroundColor: Colors.blueGrey, // Editor's bg color
// baseTextColor: Colors.white, // baseTextColor: Colors.white,
// editor padding // editor padding
padding: EdgeInsets.symmetric(horizontal: 5.0), padding: EdgeInsets.symmetric(horizontal: 5.0),
// font name // font name
baseFontFamily: 'sans-serif', baseFontFamily: 'sans-serif',
// Position of the editing bar (BarPosition.TOP or BarPosition.BOTTOM) // Position of the editing bar (BarPosition.TOP or BarPosition.BOTTOM)
barPosition: BarPosition.TOP, barPosition: BarPosition.CUSTOM,
), ),
// You can return a Link (maybe you need to upload the image to your // You can return a Link (maybe you need to upload the image to your
// storage before displaying in the editor or you can also use base64 // storage before displaying in the editor or you can also use base64
getImageUrl: (image) { getImageUrl: (image) {
String link = 'https://avatars.githubusercontent.com/u/24323581?v=4'; String link = 'https://avatars.githubusercontent.com/u/24323581?v=4';
String base64 = base64Encode(image.readAsBytesSync()); String base64 = base64Encode(image.readAsBytesSync());
String base64String = 'data:image/png;base64, $base64'; String base64String = 'data:image/png;base64, $base64';
return base64String; return base64String;
}, },
),
),
],
), ),
); );
} }

View File

@ -1,6 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'package:example/basic.dart'; import 'package:example/basic.dart';
import 'package:example/custom_toolbar_demo.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rich_editor/rich_editor.dart'; import 'package:rich_editor/rich_editor.dart';
@ -18,6 +19,7 @@ class MyApp extends StatelessWidget {
primarySwatch: Colors.blue, primarySwatch: Colors.blue,
), ),
home: BasicDemo(), home: BasicDemo(),
// home: CustomToolbarDemo(),
); );
} }
} }

View File

@ -5,8 +5,6 @@
import FlutterMacOS import FlutterMacOS
import Foundation import Foundation
import wakelock_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
} }

View File

@ -184,7 +184,6 @@
33CC10EB2044A3C60003C045 /* Resources */, 33CC10EB2044A3C60003C045 /* Resources */,
33CC110E2044A8840003C045 /* Bundle Framework */, 33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */, 3399D490228B24CF009A79C7 /* ShellScript */,
06400C234E158CC19ED60959 /* [CP] Embed Pods Frameworks */,
); );
buildRules = ( buildRules = (
); );
@ -254,23 +253,6 @@
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
06400C234E158CC19ED60959 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3399D490228B24CF009A79C7 /* ShellScript */ = { 3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;

View File

@ -29,20 +29,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
chewie:
dependency: transitive
description:
name: chewie
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
chewie_audio:
dependency: transitive
description:
name: chewie_audio
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -78,13 +64,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -97,27 +76,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.0" version: "0.4.0"
flutter_html: flutter_inappwebview:
dependency: transitive dependency: transitive
description: description:
name: flutter_html name: flutter_inappwebview
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "5.3.2"
flutter_layout_grid:
dependency: transitive
description:
name: flutter_layout_grid
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
flutter_math_fork:
dependency: transitive
description:
name: flutter_math_fork
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3"
flutter_plugin_android_lifecycle: flutter_plugin_android_lifecycle:
dependency: transitive dependency: transitive
description: description:
@ -125,13 +90,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.2" version: "2.0.2"
flutter_svg:
dependency: transitive
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "0.22.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -142,6 +100,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_widget_from_html_core:
dependency: transitive
description:
name: flutter_widget_from_html_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
html: html:
dependency: transitive dependency: transitive
description: description:
@ -212,13 +177,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -226,20 +184,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.1"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
@ -261,20 +205,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
provider:
dependency: transitive
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
rich_editor: rich_editor:
dependency: "direct main" dependency: "direct main"
description: description:
@ -329,13 +259,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.0" version: "0.3.0"
tuple:
dependency: transitive
description:
name: tuple
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -350,76 +273,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
video_player:
dependency: transitive
description:
name: video_player
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
video_player_platform_interface:
dependency: transitive
description:
name: video_player_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
video_player_web:
dependency: transitive
description:
name: video_player_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
wakelock:
dependency: transitive
description:
name: wakelock
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.2"
wakelock_macos:
dependency: transitive
description:
name: wakelock_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0+1"
wakelock_platform_interface:
dependency: transitive
description:
name: wakelock_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1+1"
wakelock_web:
dependency: transitive
description:
name: wakelock_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+1"
wakelock_windows:
dependency: transitive
description:
name: wakelock_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
webview_flutter:
dependency: transitive
description:
name: webview_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
xml: xml:
dependency: transitive dependency: transitive
description: description:
@ -435,5 +288,5 @@ packages:
source: hosted source: hosted
version: "5.2.0" version: "5.2.0"
sdks: sdks:
dart: ">=2.13.0 <3.0.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0" flutter: ">=2.0.0"

View File

@ -1 +1,2 @@
/// Position the inbuilt Toolbar or use your custom toolbar
enum BarPosition { TOP, BOTTOM, CUSTOM } enum BarPosition { TOP, BOTTOM, CUSTOM }

View File

@ -4,12 +4,13 @@ import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:rich_editor/src/models/enum/bar_position.dart'; import 'package:rich_editor/src/models/enum/bar_position.dart';
import 'package:rich_editor/src/models/rich_editor_options.dart'; import 'package:rich_editor/src/models/rich_editor_options.dart';
import 'package:rich_editor/src/services/local_server.dart'; import 'package:rich_editor/src/services/local_server.dart';
import 'package:rich_editor/src/utils/javascript_executor_base.dart'; import 'package:rich_editor/src/utils/javascript_executor_base.dart';
import 'package:rich_editor/src/widgets/editor_tool_bar.dart'; import 'package:rich_editor/src/widgets/editor_tool_bar.dart';
import 'package:webview_flutter/webview_flutter.dart'; // import 'package:webview_flutter/webview_flutter.dart';
class RichEditor extends StatefulWidget { class RichEditor extends StatefulWidget {
final String? value; final String? value;
@ -30,10 +31,12 @@ class RichEditor extends StatefulWidget {
} }
class RichEditorState extends State<RichEditor> { class RichEditorState extends State<RichEditor> {
WebViewController? _controller; InAppWebViewController? _controller;
final Key _mapKey = UniqueKey(); final Key _mapKey = UniqueKey();
String assetPath = 'packages/rich_editor/assets/editor/editor.html'; String assetPath = 'packages/rich_editor/assets/editor/editor.html';
// InAppWebViewController? webViewController;
int port = 5321; int port = 5321;
String html = ''; String html = '';
LocalServer? localServer; LocalServer? localServer;
@ -42,8 +45,7 @@ class RichEditorState extends State<RichEditor> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); if (Platform.isIOS) {
if (!Platform.isAndroid) {
_initServer(); _initServer();
} }
} }
@ -76,7 +78,11 @@ class RichEditorState extends State<RichEditor> {
_loadHtmlFromAssets() async { _loadHtmlFromAssets() async {
final filePath = assetPath; final filePath = assetPath;
_controller!.loadUrl("http://localhost:$port/$filePath"); _controller!.loadUrl(
urlRequest: URLRequest(
url: Uri.tryParse('http://localhost:$port/$filePath'),
),
);
} }
@override @override
@ -86,42 +92,50 @@ class RichEditorState extends State<RichEditor> {
Visibility( Visibility(
visible: widget.editorOptions!.barPosition == BarPosition.TOP, visible: widget.editorOptions!.barPosition == BarPosition.TOP,
child: EditorToolBar( child: EditorToolBar(
controller: _controller,
getImageUrl: widget.getImageUrl, getImageUrl: widget.getImageUrl,
javascriptExecutor: javascriptExecutor, javascriptExecutor: javascriptExecutor,
), ),
), ),
Expanded( Expanded(
child: WebView( child: InAppWebView(
key: _mapKey, key: _mapKey,
onWebViewCreated: (WebViewController controller) async { onWebViewCreated: (controller) async {
_controller = controller; _controller = controller;
setState(() {}); setState(() {});
if (!Platform.isAndroid) { if (!Platform.isAndroid) {
await _loadHtmlFromAssets(); await _loadHtmlFromAssets();
} else { } else {
await _controller! await _controller!.loadUrl(
.loadUrl('file:///android_asset/flutter_assets/$assetPath'); urlRequest: URLRequest(
url: Uri.tryParse(
'file:///android_asset/flutter_assets/$assetPath'),
),
);
} }
},
onLoadStop: (controller, link) async {
javascriptExecutor.init(_controller!); javascriptExecutor.init(_controller!);
},
onPageFinished: (link) async {
await _setInitialValues(); await _setInitialValues();
_addJSListener();
}, },
javascriptMode: JavascriptMode.unrestricted, // javascriptMode: JavascriptMode.unrestricted,
gestureNavigationEnabled: true, // gestureNavigationEnabled: false,
gestureRecognizers: [ gestureRecognizers: [
Factory(() => VerticalDragGestureRecognizer()..onUpdate = (_) {}), Factory(() => VerticalDragGestureRecognizer()..onUpdate = (_) {}),
].toSet(), ].toSet(),
onWebResourceError: (e) { onLoadError: (controller, url, code, e) {
print("error ${e.description}"); print("error $e $code");
},
onConsoleMessage: (controller, consoleMessage) async {
print(
'WebView Message: $consoleMessage',
);
}, },
), ),
), ),
Visibility( Visibility(
visible: widget.editorOptions!.barPosition == BarPosition.BOTTOM, visible: widget.editorOptions!.barPosition == BarPosition.BOTTOM,
child: EditorToolBar( child: EditorToolBar(
controller: _controller,
getImageUrl: widget.getImageUrl, getImageUrl: widget.getImageUrl,
javascriptExecutor: javascriptExecutor, javascriptExecutor: javascriptExecutor,
), ),
@ -148,6 +162,14 @@ class RichEditorState extends State<RichEditor> {
.setBaseFontFamily(widget.editorOptions!.baseFontFamily!); .setBaseFontFamily(widget.editorOptions!.baseFontFamily!);
} }
_addJSListener() async {
_controller!.addJavaScriptHandler(
handlerName: 'editor-state-changed-callback://',
callback: (c) {
print('Callback $c');
});
}
/// Get current HTML from editor /// Get current HTML from editor
Future<String?> getHtml() async { Future<String?> getHtml() async {
try { try {
@ -170,7 +192,7 @@ class RichEditorState extends State<RichEditor> {
/// Clear editor content using Javascript /// Clear editor content using Javascript
clear() { clear() {
_controller!.evaluateJavascript( _controller!.evaluateJavascript(
'document.getElementById(\'editor\').innerHTML = "";'); source: 'document.getElementById(\'editor\').innerHTML = "";');
} }
/// Focus and Show the keyboard using JavaScript /// Focus and Show the keyboard using JavaScript
@ -192,7 +214,7 @@ class RichEditorState extends State<RichEditor> {
" link.media = \"all\";" + " link.media = \"all\";" +
" head.appendChild(link);" + " head.appendChild(link);" +
"}) ();"; "}) ();";
_controller!.evaluateJavascript(jsCSSImport); _controller!.evaluateJavascript(source: jsCSSImport);
} }
/// if html is equal to html RichTextEditor sets by default at start /// if html is equal to html RichTextEditor sets by default at start

View File

@ -1,16 +1,16 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:rich_editor/src/extensions/extensions.dart'; import 'package:rich_editor/src/extensions/extensions.dart';
import 'package:rich_editor/src/models/editor_state.dart'; import 'package:rich_editor/src/models/editor_state.dart';
import 'package:rich_editor/src/models/enum/command_name.dart'; import 'package:rich_editor/src/models/enum/command_name.dart';
import 'package:webview_flutter/webview_flutter.dart';
import '../models/command_state.dart'; import '../models/command_state.dart';
/// A class that handles all editor-related javascript functions /// A class that handles all editor-related javascript functions
class JavascriptExecutorBase { class JavascriptExecutorBase {
WebViewController? _controller; InAppWebViewController? _controller;
String defaultHtml = "<p>\u200B</p>"; String defaultHtml = "<p>\u200B</p>";
@ -22,12 +22,12 @@ class JavascriptExecutorBase {
var didHtmlChange = false; var didHtmlChange = false;
Map<CommandName, CommandState> commandStates = {}; Map<CommandName, CommandState> commandStates = {};
init(WebViewController controller) { init(InAppWebViewController? controller) {
_controller = controller; _controller = controller;
} }
executeJavascript(String command) async { executeJavascript(String command) async {
return await _controller!.evaluateJavascript('editor.$command'); return await _controller!.evaluateJavascript(source: 'editor.$command');
} }
String getCachedHtml() { String getCachedHtml() {

View File

@ -7,20 +7,17 @@ import 'package:rich_editor/src/widgets/fonts_dialog.dart';
import 'package:rich_editor/src/widgets/insert_image_dialog.dart'; import 'package:rich_editor/src/widgets/insert_image_dialog.dart';
import 'package:rich_editor/src/widgets/insert_link_dialog.dart'; import 'package:rich_editor/src/widgets/insert_link_dialog.dart';
import 'package:rich_editor/src/widgets/tab_button.dart'; import 'package:rich_editor/src/widgets/tab_button.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'color_picker_dialog.dart'; import 'color_picker_dialog.dart';
import 'font_size_dialog.dart'; import 'font_size_dialog.dart';
import 'heading_dialog.dart'; import 'heading_dialog.dart';
class EditorToolBar extends StatelessWidget { class EditorToolBar extends StatelessWidget {
final WebViewController? controller;
final Function(File image)? getImageUrl; final Function(File image)? getImageUrl;
final Function(File video)? getVideoUrl; final Function(File video)? getVideoUrl;
final JavascriptExecutorBase javascriptExecutor; final JavascriptExecutorBase javascriptExecutor;
EditorToolBar({ EditorToolBar({
this.controller,
this.getImageUrl, this.getImageUrl,
this.getVideoUrl, this.getVideoUrl,
required this.javascriptExecutor, required this.javascriptExecutor,

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'html_text.dart';
class FontSizeDialog extends StatelessWidget { class FontSizeDialog extends StatelessWidget {
List formats = [ List formats = [
@ -22,7 +23,7 @@ class FontSizeDialog extends StatelessWidget {
children: [ children: [
for (Map format in formats) for (Map format in formats)
InkWell( InkWell(
child: Html(data: format['title']), child: HtmlText(html: format['title']),
onTap: () => Navigator.pop(context, format['id']), onTap: () => Navigator.pop(context, format['id']),
) )
], ],

View File

@ -1,9 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:path/path.dart'; import 'package:path/path.dart';
import 'package:rich_editor/src/models/system_font.dart'; import 'package:rich_editor/src/models/system_font.dart';
import 'package:rich_editor/src/utils/font_list_parser.dart'; import 'package:rich_editor/src/utils/font_list_parser.dart';
import 'html_text.dart';
class FontsDialog extends StatelessWidget { class FontsDialog extends StatelessWidget {
List<SystemFont> getSystemFonts() { List<SystemFont> getSystemFonts() {
return FontListParser().getSystemFonts(); return FontListParser().getSystemFonts();
@ -19,8 +20,8 @@ class FontsDialog extends StatelessWidget {
children: [ children: [
for (SystemFont font in getSystemFonts()) for (SystemFont font in getSystemFonts())
InkWell( InkWell(
child: Html( child: HtmlText(
data: '<p style="font-family:${font.name}">' html: '<p style="font-family:${font.name}">'
'${basename(font.path!)}</p>'), '${basename(font.path!)}</p>'),
onTap: () { onTap: () {
Navigator.pop(context, font.name); Navigator.pop(context, font.name);

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'html_text.dart';
class HeadingDialog extends StatelessWidget { class HeadingDialog extends StatelessWidget {
List formats = [ List formats = [
@ -27,7 +28,7 @@ class HeadingDialog extends StatelessWidget {
children: [ children: [
for (Map format in formats) for (Map format in formats)
InkWell( InkWell(
child: Html(data: format['title']), child: HtmlText(html: format['title']),
onTap: () => Navigator.pop(context, format['id']), onTap: () => Navigator.pop(context, format['id']),
) )
], ],

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
class HtmlText extends StatelessWidget {
final String html;
HtmlText({required this.html});
@override
Widget build(BuildContext context) {
return Container(child: HtmlWidget(html), height: 40.0,);
}
}

View File

@ -29,20 +29,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
chewie:
dependency: transitive
description:
name: chewie
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
chewie_audio:
dependency: transitive
description:
name: chewie_audio
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -64,13 +50,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.17.0" version: "0.17.0"
cupertino_icons:
dependency: transitive
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -78,13 +57,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -97,27 +69,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.0" version: "0.4.0"
flutter_html: flutter_inappwebview:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_html name: flutter_inappwebview
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "5.3.2"
flutter_layout_grid:
dependency: transitive
description:
name: flutter_layout_grid
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
flutter_math_fork:
dependency: transitive
description:
name: flutter_math_fork
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3"
flutter_plugin_android_lifecycle: flutter_plugin_android_lifecycle:
dependency: transitive dependency: transitive
description: description:
@ -125,13 +83,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.2" version: "2.0.2"
flutter_svg:
dependency: transitive
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "0.22.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -142,6 +93,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_widget_from_html_core:
dependency: "direct main"
description:
name: flutter_widget_from_html_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
html: html:
dependency: transitive dependency: transitive
description: description:
@ -212,13 +170,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
path: path:
dependency: "direct main" dependency: "direct main"
description: description:
@ -226,20 +177,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.1"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
@ -261,20 +198,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
provider:
dependency: transitive
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -322,13 +245,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.0" version: "0.3.0"
tuple:
dependency: transitive
description:
name: tuple
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -343,76 +259,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
video_player:
dependency: transitive
description:
name: video_player
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
video_player_platform_interface:
dependency: transitive
description:
name: video_player_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
video_player_web:
dependency: transitive
description:
name: video_player_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
wakelock:
dependency: transitive
description:
name: wakelock
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.2"
wakelock_macos:
dependency: transitive
description:
name: wakelock_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0+1"
wakelock_platform_interface:
dependency: transitive
description:
name: wakelock_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1+1"
wakelock_web:
dependency: transitive
description:
name: wakelock_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+1"
wakelock_windows:
dependency: transitive
description:
name: wakelock_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
webview_flutter:
dependency: "direct main"
description:
name: webview_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
xml: xml:
dependency: transitive dependency: transitive
description: description:
@ -428,5 +274,5 @@ packages:
source: hosted source: hosted
version: "5.2.0" version: "5.2.0"
sdks: sdks:
dart: ">=2.13.0 <3.0.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0" flutter: ">=2.0.0"

View File

@ -10,10 +10,10 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
webview_flutter: ^2.0.4 flutter_inappwebview: ^5.3.2
mime: ^1.0.0 mime: ^1.0.0
image_picker: ^0.7.5+3 image_picker: ^0.7.5+3
flutter_html: ^2.0.0 flutter_widget_from_html_core: ^0.6.1+1
flutter_colorpicker: ^0.4.0 flutter_colorpicker: ^0.4.0
path: ^1.8.0 path: ^1.8.0
xml2json: ^5.2.0 xml2json: ^5.2.0