chore: added features list to readme
This commit is contained in:
parent
50c75819ae
commit
f95b40bb5b
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright 2021 Festus Olusegun
|
Copyright 2021 JideGuru
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
51
README.md
51
README.md
@ -1,14 +1,45 @@
|
|||||||
# rich_editor
|
# ✨ rich_editor
|
||||||
|
[![pub package](https://img.shields.io/pub/v/badge.svg)](https://pub.dartlang.org/packages/rich_editor)
|
||||||
|
[![pub points](https://badges.bar/rich_editor/pub%20points)](https://pub.dev/packages/sentry/rich_editor)
|
||||||
|
|
||||||
A new Flutter package.
|
WYSIWYG editor for Android and JavaFX with a rich set of supported formatting options.
|
||||||
|
|
||||||
## Getting Started
|
Based on https://github.com/dankito/RichTextEditor, but but for Flutter.
|
||||||
|
|
||||||
This project is a starting point for a Dart
|
## ✨ Features
|
||||||
[package](https://flutter.dev/developing-packages/),
|
- [x] Bold, Italic, Underline, Strike through, Subscript, Superscript
|
||||||
a library module containing code that can be shared easily across
|
- [x] Heading 1 - 6, Text body, Preformatted, Block quote
|
||||||
multiple Flutter or Dart projects.
|
- [] Font (reads all system fonts)
|
||||||
|
- [x] Font Size
|
||||||
|
- [x] Text Color
|
||||||
|
- [x] Text Background Color
|
||||||
|
- [x] Highlight text
|
||||||
|
- [x] Justify Left, Center, Right, Blockquote
|
||||||
|
- [x] Indent, Outdent
|
||||||
|
- [x] Undo, Redo
|
||||||
|
- [x] Unordered List (Bullets)
|
||||||
|
- [x] Ordered List (Numbers)
|
||||||
|
- [x] Insert local or remote Image
|
||||||
|
- [x] Insert Link
|
||||||
|
- [x] Insert Checkbox
|
||||||
|
- [] Search
|
||||||
|
|
||||||
For help getting started with Flutter, view our
|
## 📸 Screenshots
|
||||||
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
|
||||||
samples, guidance on mobile development, and a full API reference.
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright 2021 JideGuru
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
44
lib/src/models/enum.dart
Normal file
44
lib/src/models/enum.dart
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
enum CommandName {
|
||||||
|
UNDO,
|
||||||
|
REDO,
|
||||||
|
FORECOLOR,
|
||||||
|
BACKCOLOR,
|
||||||
|
FONTNAME,
|
||||||
|
FONTSIZE,
|
||||||
|
BOLD,
|
||||||
|
ITALIC,
|
||||||
|
UNDERLINE,
|
||||||
|
SUBSCRIPT,
|
||||||
|
SUPERSCRIPT,
|
||||||
|
STRIKETHROUGH,
|
||||||
|
FORMATBLOCK, // passes value for below format
|
||||||
|
H1,
|
||||||
|
H2,
|
||||||
|
H3,
|
||||||
|
H4,
|
||||||
|
H5,
|
||||||
|
H6,
|
||||||
|
P,
|
||||||
|
PRE,
|
||||||
|
BR, // not settable (at least i don't know how)
|
||||||
|
BLOCKQUOTE,
|
||||||
|
REMOVEFORMAT,
|
||||||
|
JUSTIFYCENTER,
|
||||||
|
JUSTIFYFULL,
|
||||||
|
JUSTIFYLEFT,
|
||||||
|
JUSTIFYRIGHT,
|
||||||
|
INDENT,
|
||||||
|
OUTDENT,
|
||||||
|
INSERTUNORDEREDLIST,
|
||||||
|
INSERTORDEREDLIST,
|
||||||
|
INSERTHORIZONTALRULE,
|
||||||
|
INSERTHTML, // determines if the three command below are executable
|
||||||
|
INSERTLINK, // pseudo commands, there are no corresponding values for execCommand()
|
||||||
|
INSERTIMAGE,
|
||||||
|
INSERTCHECKBOX,
|
||||||
|
// pseudo commands for toggling grouped command views
|
||||||
|
ENTER_VIEWING_MODE,
|
||||||
|
EXPANDING_SEARCH_VIEWING,
|
||||||
|
TOGGLE_GROUPED_TEXT_STYLES_COMMANDS_VIEW,
|
||||||
|
TOGGLE_GROUPED_INSERT_COMMANDS_COMMANDS_VIEW
|
||||||
|
}
|
6
lib/src/utils/command_state.dart
Normal file
6
lib/src/utils/command_state.dart
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class CommandState {
|
||||||
|
bool executable = false;
|
||||||
|
var value = "";
|
||||||
|
|
||||||
|
CommandState(this.executable, this.value);
|
||||||
|
}
|
@ -1,10 +1,22 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:rich_editor/src/extensions/extensions.dart';
|
import 'package:rich_editor/src/extensions/extensions.dart';
|
||||||
|
import 'package:rich_editor/src/models/enum.dart';
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
|
import 'command_state.dart';
|
||||||
|
|
||||||
class JavascriptExecutorBase {
|
class JavascriptExecutorBase {
|
||||||
WebViewController? _controller;
|
WebViewController? _controller;
|
||||||
|
|
||||||
|
String defaultHtml = "<p>\u200B</p>";
|
||||||
|
|
||||||
|
String editorStateChangedCallbackScheme = "editor-state-changed-callback://";
|
||||||
|
|
||||||
|
String defaultEncoding = "UTF-8";
|
||||||
|
|
||||||
|
String? htmlField = "";
|
||||||
|
Map<CommandName, CommandState> commandStates = {};
|
||||||
|
|
||||||
init(WebViewController controller) {
|
init(WebViewController controller) {
|
||||||
_controller = controller;
|
_controller = controller;
|
||||||
}
|
}
|
||||||
@ -13,12 +25,17 @@ class JavascriptExecutorBase {
|
|||||||
return await _controller!.evaluateJavascript('editor.$command');
|
return await _controller!.evaluateJavascript('editor.$command');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getCachedHtml() {
|
||||||
|
return htmlField!;
|
||||||
|
}
|
||||||
|
|
||||||
setHtml(String html) async {
|
setHtml(String html) async {
|
||||||
String? baseUrl;
|
String? baseUrl;
|
||||||
await executeJavascript("setHtml('" + encodeHtml(html) + "', '$baseUrl');");
|
await executeJavascript("setHtml('" + encodeHtml(html) + "', '$baseUrl');");
|
||||||
|
htmlField = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHtml() async {
|
getCurrentHtml() async {
|
||||||
String? html = await executeJavascript('getEncodedHtml()');
|
String? html = await executeJavascript('getEncodedHtml()');
|
||||||
String? decodedHtml = Uri.decodeFull(html!);
|
String? decodedHtml = Uri.decodeFull(html!);
|
||||||
if (decodedHtml.startsWith('"') && decodedHtml.endsWith('"')) {
|
if (decodedHtml.startsWith('"') && decodedHtml.endsWith('"')) {
|
||||||
@ -27,6 +44,10 @@ class JavascriptExecutorBase {
|
|||||||
return decodedHtml;
|
return decodedHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDefaultRichTextEditorHtml(String html) {
|
||||||
|
return defaultHtml == html;
|
||||||
|
}
|
||||||
|
|
||||||
// Text commands
|
// Text commands
|
||||||
undo() async {
|
undo() async {
|
||||||
await executeJavascript("undo()");
|
await executeJavascript("undo()");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: rich_editor
|
name: rich_editor
|
||||||
description: A new Flutter package.
|
description: WYSIWYG editor for Flutter with a rich set of supported formatting options.
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
homepage: https://github.com/JideGuru/rich_editor
|
homepage: https://github.com/JideGuru/rich_editor
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user