Overview
The HTML plugin enables bidirectional conversion between HTML and AppFlowy Editor documents. It supports rich text formatting, semantic HTML elements, and CSS inline styles.Installation
The HTML plugin is included with AppFlowy Editor:Importing HTML
Basic Usage
Convert HTML to an AppFlowy document:With Custom Decoders
Add custom element parsers for special HTML elements:Supported HTML Elements
The decoder automatically handles:Block Elements
- Headings:
<h1>through<h6> - Paragraphs:
<p> - Lists:
<ul>,<ol>,<li> - Block quotes:
<blockquote> - Tables:
<table>,<tr>,<td>,<th> - Dividers:
<hr> - Images:
<img>
Inline Elements
- Bold:
<b>,<strong> - Italic:
<i>,<em> - Underline:
<u> - Strikethrough:
<del>,<s> - Code:
<code> - Links:
<a href="..."> - Spans:
<span>(with style attributes) - Mark:
<mark>
CSS Inline Styles
The decoder parses these CSS properties from style attributes:font-weight: Bold text (values:boldor >= 500)font-style: Italic text (italic)text-decoration: Underline and strikethroughbackground-color: Text highlight colorcolor: Text colortext-align: Text alignment
Exporting to HTML
Basic Usage
Convert an AppFlowy document to HTML:With Custom Parsers
Handle custom node types during export:Implementation Details
HTML Codec
The plugin uses aCodec<Document, String> implementation (from /lib/src/plugins/html/html_document.dart:45-63):
Built-in Parsers
Encoder Parsers
The encoder uses these parsers (from/lib/src/plugins/html/html_document.dart:30-41):
HTMLTextNodeParserHTMLBulletedListNodeParserHTMLNumberedListNodeParserHTMLTodoListNodeParserHTMLQuoteNodeParserHTMLHeadingNodeParserHTMLImageNodeParserHtmlTableNodeParserHTMLDividerNodeParser
Color Parsing
Color parsing can be enabled or disabled:Creating Custom Parsers
Custom HTML Node Parser (Encoder)
Implement theHTMLNodeParser interface:
Custom Element Parser (Decoder)
Add a custom decoder for specific HTML elements:Advanced Features
Table Support
The HTML plugin fully supports table import and export with:- Row and column spanning
- Nested formatting within cells
- Table headers (
<th>) and data cells (<td>)
Rich Text Formatting
Nested formatting is preserved:Google Docs Compatibility
Special handling for documents copied from Google Docs to prevent parsing issues.Limitations
- Only network images are supported (URLs starting with
http) - Some complex CSS properties may not be preserved
- JavaScript and interactive elements are not supported
- External stylesheets are not processed
Example: Complete Workflow
See Also
- Markdown Plugin - Markdown import/export
- PDF Export Plugin - Export to PDF via HTML
- Quill Delta Plugin - Quill Delta support