API-based HTML editor for Flutter.

Overview

enough_html_editor

Slim HTML editor for Flutter with full API control and optional Flutter-based widget controls. screenshot

API Documentation

Check out the full API documentation at https://pub.dev/documentation/enough_html_editor/latest/

Usage

The current enough_html_editor package the following widgets:

  • HtmlEditor the HTML editor.
  • HtmlEditorControls optional editor controls.
  • SliverHeaderHtmlEditorControls wrapper to use the editor controls within a CustomScrollView as a sticky header.
  • HtmlEditorApi - not a widget - the API to control the editor, use the API to access the edited HTML text or to set the current text bold, add an unordered list, etc.
  • PackagedHtmlEditor a simple to use Widget that contains both the HtmlEditor and the HtmlEditorControls

Access API

You choose between two options to access the API:

  1. Use the onCreated(HtmlEditorApi) callback:

    HtmlEditor(
        onCreated: (api) {
            setState(() {
            _editorApi = api;
            });
        },
        ...
    );

    You can then access the API afterwards directly, e.g.

    final text = await _editorApi.getText();
  2. Define and assign a GlobalKey<HtmlEditorState>:

    final _keyEditor = GlobalKey<HtmlEditorState>();
    Widget build(BuildContext context) {
        return HtmlEditor(
              key: _keyEditor,
              ...
        );
    }

    You can then access the HtmlEditorState via this GlobalKey:

    final text = await _keyEditor.currentState.api.getText();

Either the API or the global key is required for creating the HtmlEditorControls.

Quick Start

Use the PackagedHtmlEditor for a quick start. This contains both the default controls and the editor.

import 'package:enough_html_editor/enough_html_editor.dart';
[...]
HtmlEditorApi _editorApi;

@override
Widget build(BuildContext context) {
    return PackagedHtmlEditor(
          onCreated: (api) {
            _editorApi = api;
          },
          initialContent: '''<p>Here is some text</p>
          <p>Here is <b>bold</b> text</p>
          <p>Here is <i>some italic sic</i> text</p>
          <p>Here is <i><b>bold and italic</b></i> text</p>
          <p style="text-align: center;">Here is <u><i><b>bold and italic and underline</b></i></u> text</p>
          <ul><li>one list element</li><li>another point</li></ul>
          <blockquote>Here is a quote<br/>
            that spans several lines<br/>
            <blockquote>
                Another second level blockqote 
            </blockquote>
        </blockquote>
''',
        );
}

Use the HtmlEditorApi that you receive in the onCreated callback to query the final text:

// retrieve only the edited text as HTML code: 
final text = await _editorApi.getText();
// retrieve the full document as HTML code:
final fullHtml = await _editorApi.getFullHtml();

Installation

Add this dependency your pubspec.yaml file:

dependencies:
  enough_html_editor: ^0.0.4

The latest version or enough_html_editor is enough_html_editor version.

Features and bugs

Please file feature requests and bugs at the issue tracker.

License

Licensed under the commercial friendly Mozilla Public License 2.0.

Comments
  • I can not paste text in the html_editor

    I can not paste text in the html_editor

    Description

    On device android When I do a long tap in the html_editor nothing happens. But it works well on iOS

    [✓] Flutter (Channel stable, 2.10.1, on macOS 11.5.2 20G95 darwin-arm, locale en-VN)
        • Flutter version 2.10.1 at /Users/dab.dev/FlutterDev/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision db747aa133 (3 weeks ago), 2022-02-09 13:57:35 -0600
        • Engine revision ab46186b24
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
        • Android SDK at /Users/dab.dev/Library/Android/sdk
        • Platform android-32, build-tools 32.1.0-rc1
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.1)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    
    [✓] Connected device (2 available)
        • sdk gphone arm64 (mobile) • emulator-5554 • android-arm64  • Android 11 (API 30) (emulator)
        • Chrome (web)              • chrome        • web-javascript • Google Chrome 98.0.4758.109
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    
    bug 
    opened by dab246 1
  • Detect bold/italic/underline also from CSS styles

    Detect bold/italic/underline also from CSS styles

    Right now the editor assume that , and elements are being used for bold, italic and underlined texts. Additionally, the editor should recognize such formats from CSS styles, too.

    enhancement 
    opened by robert-virkus 1
  • Support iOS

    Support iOS

    Currently the editor does not work at all on iOS.

    In principle, contenteditable should work fine:

    • https://webkit.org/blog/7358/enhanced-editing-with-input-events/
    • https://stackoverflow.com/questions/4251227/contenteditable-div-not-actually-editable-in-webkit
    bug iOS 
    opened by robert-virkus 0
  • Specify fonts

    Specify fonts

    Provide API and UI for setting the font for the selected text, the current paragraph or possibly for the whole document. Consider using web safe fonts: https://blog.hubspot.com/website/web-safe-html-css-fonts

    enhancement api controls 
    opened by robert-virkus 0
  • Allow to specify font color

    Allow to specify font color

    Let users specify the font color.

    Use execCommand("foreColor", false, "#00ff00")

    foreColor Changes a font color for the selection or at the insertion point. This requires a hexadecimal color value string as a value argument.

    enhancement 
    opened by robert-virkus 0
  • Allow to increase and decrease font size

    Allow to increase and decrease font size

    Add API and widgets in HtmlEditorControls.

    Use execCommand("fontSize", false, 1...7) for that.

    fontSize Changes the font size for the selection or at the insertion point. This requires an integer from 1-7 as a value argument.

    enhancement api controls 
    opened by robert-virkus 0
  • Access HTML with styles

    Access HTML with styles

    Right now only a style for blockqotes is being used but over time there will come more (default) styles. It should be possible to request a full HTML text not only the HTML text of the content area.

    enhancement 
    opened by robert-virkus 0
  • Simplify usage

    Simplify usage

    In most cases devs will want to use the editor controls as they are. For this case there should be option to have one simple widget like HtmlEditorWithControls.

    enhancement 
    opened by robert-virkus 0
  • Option to break up blockquotes when editing

    Option to break up blockquotes when editing

    It should be possible to configure <blockquote> elements to break up when users edit them. This is for example desired when editing mail messages.

    enhancement 
    opened by robert-virkus 0
  • I can't edit the text in IOS

    I can't edit the text in IOS

    In IOS the text field is not editable. As you mentioned in #22 , it's possible to use CSS to solve this as it says here https://stackoverflow.com/questions/4251227/contenteditable-div-not-actually-editable-in-webkit, but I couldn't understand how to add this css in the editor.

    My config is: enough_html_editor: ^0.0.4 sdk: ">=2.7.0 <3.0.0" • Flutter version 2.0.6 • Dart version 2.12.3

    bug iOS 
    opened by GuilhermeDemoliner 2
  • How unfocus the HtmlEditor to close keyboard?

    How unfocus the HtmlEditor to close keyboard?

    I need to close keyboard by onTap in Parent, but not found where to configure FocusNode of editor. I have: final GlobalKey<HtmlEditorState> _keyEditor = GlobalKey<HtmlEditorState>(); with: HtmlEditor(key: _keyEditor,)

    documentation enhancement 
    opened by GuilhermeDemoliner 9
  • Resource provider

    Resource provider

    Currently an image can only be displayed inline with base64 HTML code. It should be possible to alternativly specify a resource loader to visualize images and possibly other media inline.

    api core 
    opened by robert-virkus 0
  • Controls for including images

    Controls for including images

    The API already includes to add images, so add a simple to configure UI control for this, too. enough_html_editor should not depend on further packages such as file_picker, so abstract the picking process.

    enhancement controls 
    opened by robert-virkus 0
Releases(v0.0.5)
  • v0.0.5(May 18, 2022)

    • New feature: edit / add links
    • New feature: color document foreground and background
    • New feature: replace text (parts) using the HtmlEditorApi.
    • Use cupertino look and feel on iOS
    • Improve code style and documentation
    • Ensure compatibility with Flutter 3.0
    Source code(tar.gz)
    Source code(zip)
  • v0.0.4(Apr 28, 2021)

    • Support dark theme
    • Simpler usage with PackagedHtmlEditor #2
    • Select text foreground and background colors #12, $14
    • New strike through option
    • Bold, italic, underline text is now detected from inline CSS styles, too #5
    • Optionally specify your own context menu items using the textSelectionMenuItems parameter
    • Optionally specify your own widgets for the predefined HtmlEditorControls widget using the prefix and/or suffix parameters
    Source code(tar.gz)
    Source code(zip)
  • v0.0.3(Mar 13, 2021)

  • v0.0.2(Feb 27, 2021)

    • Improve documentation.
    • Retrieve the full HTML document's text with await editorApi.getFullHtml()
    • Add any custom CSS styles with editorApi.customStyles setter, for example
      editorApi.customStyles = 
        '''
        blockquote {
            font: normal helvetica, sans-serif;
            margin-top: 10px;
            margin-bottom: 10px;
            margin-left: 20px;
            padding-left: 15px;
            border-left: 3px solid #ccc;
        }
        ''';
      
    • Replace all CSS styles with the editorApi.styles setter.
    • Use the minimum height specified in HtmlEditor.minHeight.
    Source code(tar.gz)
    Source code(zip)
Owner
Enough Software GmbH & Co. KG
Enough Software GmbH & Co. KG
Json editor - A json editor on flutter

Features Support add comment; Support show errors for invalid json text; Pretty

Chan Young 12 Nov 18, 2022
This library helps you to convert Delta to HTML. Based on Flutter_Quill Delta

Delta_To_HTML This library helps you to convert Delta to HTML. Based on Flutter_Quill Delta [ currently in under development ] Usage import 'package:d

Secanonm 3 Oct 19, 2022
A Flutter widget for rendering HTML and CSS as Flutter widgets

flutter_html A Flutter widget for rendering HTML and CSS as Flutter widgets. Screenshot 1 Screenshot 2 Screenshot 3 Table of Contents: Installing Curr

Vishal Raj 1 Dec 15, 2021
A revolutionary new browser. HTML to Flutter transpiler. Written in Go (using Dart FFI) and Flutter.

Flutter Browser An experimental HTML & CSS to Flutter transpiler written in Go, using Dart FFI and Flutter. Screenshots Notice This works great for si

Mitja 12 Oct 24, 2022
Generate responsive pages and apps on HTML, Tailwind, Flutter and SwiftUI.

Figma to Code Most design to code plugins are bad, some are even paid. This project aims to raise the bar by generating responsive layouts in Tailwind

Bernardo Ferrari 2.7k Nov 23, 2022
Flutter package to render html as widgets that supports hyperlink, image, audio, video, iframe and many other tags.

HtmlWidget monorepo This repo contains the source code for everything HtmlWidget-related. Name Link flutter_widget_from_html_core flutter_widget_from_

Đào Hoàng Sơn 421 Nov 18, 2022
A Flutter based code editor

rich_code_editor A simple package that supports creating code editors in Flutter. Flutter version supported: Flutter 1.22.5 Getting Started There are

Sovit 109 Oct 13, 2022
Rich text editor for Flutter based on Delta format (Quill fork)

Visual Editor Visual Editor is a Rich Text editor for Flutter originally forked from Flutter Quill. The editor is built around the powerful Delta docu

Visual Space 174 Nov 21, 2022
Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Ravi Kovind 7 Apr 5, 2022
FLUTTER API: Video Editor allows trim, crop, rotate and scale video with a super flexible UI Design

video_editor My other APIs Scroll Navigation Video Viewer Helpers Features Super flexible UI Design. Support actions: Crop Trim Scale Rotate Cover sel

Luis Felipe Murguia Ramos 203 Nov 15, 2022
WYSIWYG editor for Flutter with a rich set of supported formatting options. (WIP)

✨ rich_editor WYSIWYG editor for Flutter with a rich set of supported formatting options. Based on https://github.com/dankito/RichTextEditor, but for

Festus Olusegun 115 Nov 25, 2022
A Flutter material theme editor

Flutter Theme ⚠️ WARNING: This app is still under development so please expect bugs and missing features in the app. ⚠️ Inspired by Panache, a Flutter

null 0 Jan 2, 2022
A Flutter package that provides a WYSIWYG editor backed by flutter_inappwebview and the Summernote library.

Flutter Html Editor - Enhanced Flutter HTML Editor Enhanced is a text editor for Android, iOS, and Web to help write WYSIWYG HTML code with the Summer

Tanay Neotia 190 Nov 15, 2022
🎨 Flutter Material Theme editor

?? Panache A Flutter Material Theme editor. Panache helps you to create beautiful Material themes for your Flutter applications. Customize widgets col

Erick Ghaumez 1.7k Nov 19, 2022
Rich text editor for Flutter

A rich text editor for Flutter FlutterQuill is a rich text editor and a Quill component for Flutter. This library is a WYSIWYG editor built for the mo

X Code 1.6k Nov 22, 2022
An online Dart editor with support for console, web, and Flutter apps

DartPad DartPad is a free, open-source online editor to help developers learn about Dart and Flutter. You can access it at dartpad.dev. What is it? Wh

Dart 1.4k Nov 23, 2022
Panache - 🎨 Flutter Material Theme editor

?? Panache A Flutter Material Theme editor. Panache helps you to create beautiful Material themes for your Flutter applications. Customize widgets col

Erick Ghaumez 1.7k Nov 23, 2022
An Instagram like text editor Flutter widget that helps you to change your text style.

TextEditor An instagram like text editor widget for flutter Show some ❤️ and star the repo to support the project Features Edit TextStyle object font

Mehdi Zarepour 66 Nov 2, 2022
Umbra - visual editor for shaders in Flutter

Umbra Generated by the Very Good CLI ?? Umbra, visual editor for shaders in Flutter. Getting Started ?? This project contains 3 flavors: development s

Jochum van der Ploeg 176 Nov 22, 2022