getSystemFonts() {
return FontListParser().getSystemFonts();
@@ -21,21 +20,16 @@ class FontsDialog extends StatelessWidget {
children: [
for (SystemFont font in getSystemFonts())
InkWell(
- child: Html(data: ''
- '${basename(font.path!)}
'),
- onTap: () => Navigator.pop(context, font.path),
+ child: HtmlText(
+ html: ''
+ '${basename(font.path!)}
'),
+ onTap: () {
+ Navigator.pop(context, font.name);
+ },
)
],
),
),
);
}
-
- fontSlug(FileSystemEntity font) {
- String name = basename(font.path);
- String slug = name.toLowerCase();
- slug = slug.replaceAll(extension(font.path), '');
- // print(slug);
- return slug;
- }
}
diff --git a/lib/src/widgets/heading_dialog.dart b/lib/src/widgets/heading_dialog.dart
index 8a7c6ce..900f1f6 100644
--- a/lib/src/widgets/heading_dialog.dart
+++ b/lib/src/widgets/heading_dialog.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
-import 'package:flutter_html/flutter_html.dart';
+
+import 'html_text.dart';
class HeadingDialog extends StatelessWidget {
List formats = [
@@ -27,7 +28,7 @@ class HeadingDialog extends StatelessWidget {
children: [
for (Map format in formats)
InkWell(
- child: Html(data: format['title']),
+ child: HtmlText(html: format['title']),
onTap: () => Navigator.pop(context, format['id']),
)
],
diff --git a/lib/src/widgets/html_text.dart b/lib/src/widgets/html_text.dart
new file mode 100644
index 0000000..0415f25
--- /dev/null
+++ b/lib/src/widgets/html_text.dart
@@ -0,0 +1,16 @@
+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,
+ );
+ }
+}
diff --git a/lib/src/widgets/insert_image_dialog.dart b/lib/src/widgets/insert_image_dialog.dart
index bfc01bc..2a6f139 100644
--- a/lib/src/widgets/insert_image_dialog.dart
+++ b/lib/src/widgets/insert_image_dialog.dart
@@ -4,6 +4,10 @@ import 'package:image_picker/image_picker.dart';
import 'custom_dialog_template.dart';
class InsertImageDialog extends StatefulWidget {
+ final bool isVideo;
+
+ InsertImageDialog({this.isVideo = false});
+
@override
_InsertImageDialogState createState() => _InsertImageDialogState();
}
@@ -21,7 +25,7 @@ class _InsertImageDialogState extends State {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text('Image link'),
+ Text(widget.isVideo ? 'Video link' : 'Image link'),
ElevatedButton(
onPressed: () => getImage(),
child: Text('...'),
@@ -34,12 +38,21 @@ class _InsertImageDialogState extends State {
hintText: '',
),
),
- SizedBox(height: 20.0),
- Text('Alt text (optional)'),
- TextField(
- controller: alt,
- decoration: InputDecoration(
- hintText: '',
+ Visibility(
+ visible: !widget.isVideo,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(height: 20.0),
+ Text('Alt text (optional)'),
+ TextField(
+ controller: alt,
+ decoration: InputDecoration(
+ hintText: '',
+ ),
+ ),
+ ],
),
),
],
@@ -50,11 +63,16 @@ class _InsertImageDialogState extends State {
Future getImage() async {
final picker = ImagePicker();
- var image = await picker.getImage(
- source: ImageSource.gallery,
- maxWidth: 800.0,
- maxHeight: 600.0,
- );
+ var image;
+ if (widget.isVideo) {
+ image = await picker.getVideo(source: ImageSource.gallery);
+ } else {
+ image = await picker.getImage(
+ source: ImageSource.gallery,
+ maxWidth: 800.0,
+ maxHeight: 600.0,
+ );
+ }
if (image != null) {
link.text = image.path;
diff --git a/lib/src/widgets/tab_button.dart b/lib/src/widgets/tab_button.dart
index e2bfafd..5658cd8 100644
--- a/lib/src/widgets/tab_button.dart
+++ b/lib/src/widgets/tab_button.dart
@@ -4,8 +4,9 @@ class TabButton extends StatelessWidget {
final IconData? icon;
final Function? onTap;
final String tooltip;
+ final bool selected;
- TabButton({this.icon, this.onTap, this.tooltip = ''});
+ TabButton({this.icon, this.onTap, this.tooltip = '', this.selected = false});
@override
Widget build(BuildContext context) {
@@ -17,7 +18,9 @@ class TabButton extends StatelessWidget {
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
- // color: Color(0xff212121),
+ color: selected
+ ? Theme.of(context).accentColor.withOpacity(0.2)
+ : Colors.transparent,
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
@@ -32,7 +35,9 @@ class TabButton extends StatelessWidget {
padding: const EdgeInsets.all(5.0),
child: Icon(
icon,
- // color: Theme.of(context).accentColor,
+ color: selected
+ ? Theme.of(context).accentColor
+ : Theme.of(context).iconTheme.color,
),
),
),
diff --git a/pubspec.lock b/pubspec.lock
index efe17d1..59bc79e 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -29,20 +29,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:
@@ -64,13 +50,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:
@@ -78,13 +57,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
- ffi:
- dependency: transitive
- description:
- name: ffi
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.1.1"
flutter:
dependency: "direct main"
description: flutter
@@ -97,27 +69,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0"
- flutter_html:
+ flutter_inappwebview:
dependency: "direct main"
description:
- name: flutter_html
+ name: flutter_inappwebview
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
- 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"
+ version: "5.3.2"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
@@ -125,13 +83,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: "direct dev"
description: flutter
@@ -142,6 +93,13 @@ packages:
description: flutter
source: sdk
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:
dependency: transitive
description:
@@ -212,13 +170,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
- nested:
- dependency: transitive
- description:
- name: nested
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.0.0"
path:
dependency: "direct main"
description:
@@ -226,20 +177,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:
@@ -261,20 +198,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description: flutter
@@ -322,13 +245,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
- tuple:
- dependency: transitive
- description:
- name: tuple
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.0.0"
typed_data:
dependency: transitive
description:
@@ -343,76 +259,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:
@@ -428,5 +274,5 @@ packages:
source: hosted
version: "5.2.0"
sdks:
- dart: ">=2.13.0 <3.0.0"
+ dart: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 75f82d0..b6f30d1 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: rich_editor
description: WYSIWYG editor for Flutter with a rich set of supported formatting options.
-version: 0.0.2
+version: 0.0.3
homepage: https://github.com/JideGuru/rich_editor
environment:
@@ -10,10 +10,10 @@ environment:
dependencies:
flutter:
sdk: flutter
- webview_flutter: ^2.0.4
+ flutter_inappwebview: ^5.3.2
mime: ^1.0.0
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
path: ^1.8.0
xml2json: ^5.2.0
@@ -27,10 +27,9 @@ dev_dependencies:
# The following section is specific to Flutter.
flutter:
-
# To add assets to your package, add an assets section, like this:
assets:
- - assets/editor/
+ - assets/editor/
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
diff --git a/test/rich_editor_test.dart b/test/rich_editor_test.dart
index 2f4b195..ab73b3a 100644
--- a/test/rich_editor_test.dart
+++ b/test/rich_editor_test.dart
@@ -1,12 +1 @@
-import 'package:flutter_test/flutter_test.dart';
-
-import 'package:rich_editor/rich_editor.dart';
-
-void main() {
- // test('adds one to input values', () {
- // final calculator = Calculator();
- // expect(calculator.addOne(2), 3);
- // expect(calculator.addOne(-7), -6);
- // expect(calculator.addOne(0), 1);
- // });
-}
+void main() {}