Render quill insert deltas to HTML.
Quill deltas renderer, converts deltas to HTML, the attributes supported by version 1.00.0 are listed below. Version 2.00.0 is in development, I'm working on support for additional Quill attributes, markdown support and a full rewrite of the parser, version 2.00.0 will only support PHP7+.
Created for use within Dlayer but works as a stand-alone tool.
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.
try {
$quill = new \DBlackborough\Quill\Render($deltas, 'HTML');
echo $quill->render();
} catch (\Exception $e) {
echo $e->getMessage();
}
$parser = new \DBlackborough\Quill\Parser\Html();
$parser->load($deltas);
$parser->parse();
$renderer = new \DBlackborough\Quill\Renderer\Html($parser->content());
echo $renderer->render();
The HTML tag to use for Quill attributes can be set along with the HTML tags for the container.
Separator | HTML Tag |
---|---|
Container | <p> |
Quill 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> |
- Parser logic rework
- Markdown support
- Formatting options (justification etc.)
- Remaining Quill toolbar options
- Full options management
- Tests
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.