feat: added more text commands

This commit is contained in:
jideguru 2021-05-28 01:41:07 +01:00
parent 87db96d65a
commit 25c6c39e1b
10 changed files with 695 additions and 17 deletions

View File

@ -2,12 +2,18 @@ PODS:
- Flutter (1.0.0)
- image_picker (0.0.1):
- Flutter
- video_player (0.0.1):
- Flutter
- wakelock (0.0.1):
- Flutter
- webview_flutter (0.0.1):
- Flutter
DEPENDENCIES:
- Flutter (from `Flutter`)
- image_picker (from `.symlinks/plugins/image_picker/ios`)
- video_player (from `.symlinks/plugins/video_player/ios`)
- wakelock (from `.symlinks/plugins/wakelock/ios`)
- webview_flutter (from `.symlinks/plugins/webview_flutter/ios`)
EXTERNAL SOURCES:
@ -15,12 +21,18 @@ EXTERNAL SOURCES:
:path: Flutter
image_picker:
:path: ".symlinks/plugins/image_picker/ios"
video_player:
:path: ".symlinks/plugins/video_player/ios"
wakelock:
:path: ".symlinks/plugins/wakelock/ios"
webview_flutter:
:path: ".symlinks/plugins/webview_flutter/ios"
SPEC CHECKSUMS:
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
image_picker: 50e7c7ff960e5f58faa4d1f4af84a771c671bc4a
video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e
wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f
webview_flutter: 9f491a9b5a66f2573946a389b2677987b0ff8c0b
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

View File

@ -29,6 +29,20 @@ 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:
@ -43,6 +57,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
cupertino_icons:
dependency: "direct main"
description:
@ -57,11 +78,46 @@ 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
source: sdk
version: "0.0.0"
flutter_colorpicker:
dependency: transitive
description:
name: flutter_colorpicker
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0"
flutter_html:
dependency: transitive
description:
name: flutter_html
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"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
@ -69,6 +125,13 @@ 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
@ -79,6 +142,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.0"
http:
dependency: transitive
description:
@ -142,6 +212,13 @@ 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: transitive
description:
@ -149,6 +226,20 @@ 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:
@ -156,6 +247,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
plugin_platform_interface:
dependency: transitive
description:
@ -163,6 +261,20 @@ 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"
rich_editor:
dependency: "direct main"
description:
@ -217,6 +329,13 @@ 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:
@ -231,6 +350,62 @@ 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: transitive
description:
@ -238,6 +413,20 @@ packages:
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:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.1"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.22.0"
dart: ">=2.13.0 <3.0.0"
flutter: ">=2.0.0"

View File

@ -1,9 +1,5 @@
import 'package:flutter/material.dart';
extension ColorX on Color {
String toHexColorString() => '#${value.toString().replaceAll('ColorSwatch(',
'').replaceAll('Color(0xff', '').replaceAll('MaterialColor(', '')
.replaceAll('MaterialAccentColor(', '').replaceAll('primary value: '
'Color(0xff', '').replaceAll('primary', '').replaceAll('value:', '')
.replaceAll(')', '').trim()}';
String toHexColorString() => '#${value.toRadixString(16).replaceAll('ff', '')}';
}

View File

@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
import 'custom_dialog_template.dart';
class CheckDialog extends StatelessWidget {
TextEditingController text = TextEditingController();
@override
Widget build(BuildContext context) {
return CustomDialogTemplate(
body: [
Text('Checkbox title'),
TextField(
controller: text,
decoration: InputDecoration(hintText: ''),
),
],
onDone: () => Navigator.pop(context, text.text),
onCancel: () => Navigator.pop(context),
);
}
}

View File

@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
class ColorPickerDialog extends StatefulWidget {
final Color? color;
ColorPickerDialog({this.color});
@override
_ColorPickerDialogState createState() => _ColorPickerDialogState();
}
class _ColorPickerDialogState extends State<ColorPickerDialog> {
Color? color;
@override
void initState() {
super.initState();
color = widget.color;
}
@override
Widget build(BuildContext context) {
return AlertDialog(
titlePadding: const EdgeInsets.all(0.0),
contentPadding: const EdgeInsets.all(0.0),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: color!,
onColorChanged: (pickedColor) {
color = pickedColor;
setState(() {});
},
colorPickerWidth: 300.0,
pickerAreaHeightPercent: 0.7,
enableAlpha: true,
displayThumbColor: true,
showLabel: true,
paletteType: PaletteType.hsv,
pickerAreaBorderRadius: const BorderRadius.only(
topLeft: const Radius.circular(2.0),
topRight: const Radius.circular(2.0),
),
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, color),
child: Text('Done'),
)
],
);
}
}

View File

@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
class FontsDialog extends StatelessWidget {
List fonts = [
{
'id': 'cursive',
'title': '<p style="font-family:cursive">This is a paragraph.</p>'
},
{
'id': 'monospace',
'title': '<p style="font-family:monospace">This is a paragraph.</p>'
}
];
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
for (Map font in fonts)
InkWell(
child: Html(data: font['title']),
onTap: () => Navigator.pop(context, font['id']),
)
],
);
}
}

View File

@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
class HeadingDialog extends StatelessWidget {
List formats = [
{'id': '1', 'title': '<h1>Heading 1</h1>'},
{'id': '2', 'title': '<h2>Heading 2</h2>'},
{'id': '3', 'title': '<h3>Heading 3</h3>'},
{'id': '4', 'title': '<h4>Heading 4</h4>'},
{'id': '5', 'title': '<h5>Heading 5</h5>'},
{'id': '6', 'title': '<h6>Heading 6</h6>'},
{'id': 'p', 'title': '<p>Text body</p>'},
{
'id': 'pre',
'title': '<pre><font face=\"courier\">Preformat</font></pre>'
},
{'id': 'blockquote', 'title': '<blockquote>Quote</blockquote>'},
];
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
for (Map format in formats)
InkWell(
child: Html(data: format['title']),
onTap: () => Navigator.pop(context, format['id']),
)
],
);
}
}

View File

@ -1,10 +1,15 @@
import 'package:flutter/material.dart';
import 'package:rich_editor/src/utils/javascript_executor_base.dart';
import 'package:rich_editor/src/widgets/check_dialog.dart';
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_link_dialog.dart';
import 'package:rich_editor/src/widgets/tab_button.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'color_picker_dialog.dart';
import 'heading_dialog.dart';
class GroupedTab extends StatelessWidget {
final WebViewController? controller;
@ -102,25 +107,164 @@ class GroupedTab extends StatelessWidget {
await javascriptExecutorBase.removeFormat();
},
),
TabButton(
icon: Icons.undo,
onTap: () async {
await javascriptExecutorBase.undo();
},
),
TabButton(
icon: Icons.redo,
onTap: () async {
await javascriptExecutorBase.redo();
},
),
TabButton(
icon: Icons.undo,
onTap: () async {
await javascriptExecutorBase.undo();
},
),
TabButton(
icon: Icons.format_quote,
onTap: () async {
await javascriptExecutorBase.setBlockQuote();
},
),
TabButton(
icon: Icons.text_format,
onTap: () async {
var command = await showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (_) {
return HeadingDialog();
},
);
if (command != null) {
if (command == 'p') {
await javascriptExecutorBase.setFormattingToParagraph();
} else if (command == 'pre') {
await javascriptExecutorBase.setPreformat();
} else if (command == 'blockquote') {
await javascriptExecutorBase.setBlockQuote();
} else {
await javascriptExecutorBase
.setHeading(int.tryParse(command)!);
}
}
},
),
TabButton(
icon: Icons.font_download,
onTap: () async {
var command = await showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (_) {
return FontsDialog();
},
);
if (command != null)
await javascriptExecutorBase.setFontName(command);
},
),
TabButton(
icon: Icons.format_size,
onTap: () async {
await javascriptExecutorBase.setFontSize(7);
},
),
TabButton(
icon: Icons.format_color_text,
onTap: () async {
var color = await showDialog(
context: context,
builder: (BuildContext context) {
return ColorPickerDialog(color: Colors.blue);
},
);
if (color != null)
await javascriptExecutorBase.setTextColor(color);
},
),
TabButton(
icon: Icons.format_color_fill,
onTap: () async {
var color = await showDialog(
context: context,
builder: (BuildContext context) {
return ColorPickerDialog(color: Colors.blue);
},
);
if (color != null)
await javascriptExecutorBase
.setTextBackgroundColor(color);
},
),
TabButton(
icon: Icons.format_indent_increase,
onTap: () async {
await javascriptExecutorBase.setIndent();
},
),
TabButton(
icon: Icons.format_indent_decrease,
onTap: () async {
await javascriptExecutorBase.setOutdent();
},
),
TabButton(
icon: Icons.format_align_left_outlined,
onTap: () async {
await javascriptExecutorBase.setJustifyLeft();
},
),
TabButton(
icon: Icons.format_align_center,
onTap: () async {
await javascriptExecutorBase.setJustifyCenter();
},
),
TabButton(
icon: Icons.format_align_right,
onTap: () async {
await javascriptExecutorBase.setJustifyRight();
},
),
TabButton(
icon: Icons.format_align_justify,
onTap: () async {
await javascriptExecutorBase.setJustifyFull();
},
),
TabButton(
icon: Icons.format_list_bulleted,
onTap: () async {
await javascriptExecutorBase.insertBulletList();
},
),
TabButton(
icon: Icons.format_list_numbered,
onTap: () async {
await javascriptExecutorBase.insertNumberedList();
},
),
TabButton(
icon: Icons.check_box_outlined,
onTap: () async {
var text = await showDialog(
context: context,
builder: (BuildContext context) {
return CheckDialog();
},
);
print(text);
if(text != null)
await javascriptExecutorBase.insertCheckbox(text);
},
),
TabButton(
icon: Icons.search,
onTap: () async {
// await javascriptExecutorBase.insertNumberedList();
},
),
],
),
),

View File

@ -29,6 +29,20 @@ 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:
@ -43,6 +57,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
csslib:
dependency: transitive
description:
name: csslib
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:
@ -50,11 +78,46 @@ 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
source: sdk
version: "0.0.0"
flutter_colorpicker:
dependency: "direct main"
description:
name: flutter_colorpicker
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0"
flutter_html:
dependency: "direct main"
description:
name: flutter_html
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"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
@ -62,6 +125,13 @@ 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
@ -72,6 +142,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.0"
http:
dependency: transitive
description:
@ -135,6 +212,13 @@ 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: transitive
description:
@ -142,6 +226,20 @@ 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:
@ -149,6 +247,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
plugin_platform_interface:
dependency: transitive
description:
@ -156,6 +261,20 @@ 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
@ -203,6 +322,13 @@ 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:
@ -217,6 +343,62 @@ 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:
@ -224,6 +406,20 @@ packages:
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:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.1"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.22.0"
dart: ">=2.13.0 <3.0.0"
flutter: ">=2.0.0"

View File

@ -13,7 +13,8 @@ dependencies:
webview_flutter: ^2.0.4
mime: ^1.0.0
image_picker: ^0.7.5+3
# path_provider: ^2.0.2
flutter_html: ^2.0.0
flutter_colorpicker: ^0.4.0
dev_dependencies:
flutter_test: