deanblackborough/php-quill-renderer

Render quill insert deltas to HTML and soon markdown

v2.02.1 2017-10-01 18:10 UTC

README

Latest Stable Version License Minimum PHP Version Build Status

PHP Quill Renderer

Render quill insert deltas to HTML and soon Markdown.

Description

Quill deltas renderer, converts deltas to HTML, the Quill attributes supported are listed in a table below. I'm working on support for the remaining attributes and additional parsers (markdown etc.)

PHP 5.6

Use version 1.01.1 if you need PHP 5.6 support.

Installation

The easiest way to use the renderer is with composer. composer require deanblackborough/php-quill-renderer, alternatively include the classes in src/ in your library.

Usage

try {
    $quill = new \DBlackborough\Quill\Render($deltas, 'HTML');
    echo $quill->render();
} catch (\Exception $e) {
    echo $e->getMessage();
}

Usage, direct, parse and then render

$parser = new \DBlackborough\Quill\Parser\Html();
$parser->load($deltas);
$parser->parse();

$renderer = new \DBlackborough\Quill\Renderer\Html($parser->content());
echo $renderer->render();

Quill attributes support

Attribute v1+ v2+
Bold Yes Yes
Italic Yes Yes
Link Yes Yes
Strike Yes Yes
Script:Sub Yes Yes
Script:Super Yes Yes
Underline Yes Yes
Header Yes Yes
Image Yes Yes
List Yes Yes
Indent/Outdent Not yet No*
Text direction Not yet No*
Color Not yet No*
Font Not yet No*
Text align Not yet No*
Block quote Not yet No*
Code block Not yet No*

(*) Attribute support may be back ported to v1.

Attribute HTML Tag
Bold <strong>
Italic <em>
Link <a>
Strike <s>
Script:Sub <sub>
Script:Super <sup>
Underline <u>
Header <h[n]>
Image <img>
List <ul> <ol>

Credits

carlos https://github.com/sald19 [Bugfix] v1.01.0

Warnings

Image support

The image support is rudimentary; it isn't production ready, some work needs to be done to support images. I can think of two solutions, pre-save of deltas, post the base64 and return a URI to replace the base64, or, at render time, fetch/cache an image/URI by posting the base64, later down the line I may explore one of these options.

Why?

I'm using this package within Dlayer, my app has its own image handling and I will not be exposing the image functionality of Quill.