Download the PHP package hbryan/quill-delta-parser without Composer
On this page you can find all versions of the php package hbryan/quill-delta-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hbryan/quill-delta-parser
More information about hbryan/quill-delta-parser
Files in hbryan/quill-delta-parser
Package quill-delta-parser
Short Description A PHP library to parse Quill Deltas into HTML
License MIT
Informations about the package quill-delta-parser
Quill Delta to HTML Parser
A PHP library to parse Quill WYSIWYG editor deltas into HTML - flexible and extendible for custom elements. Every element is parsed by the same mechanism, this makes it easy to extend and understand.
What is Quill? Quill is a free, open source WYSIWYG editor built for the modern web. With its modular architecture and expressive API, it is completely customizable to fit any need.
Installation
The package is only available through composer:
Usage
Where $json
is the ops json array from quill, for example:
This would render the following HTML:
Extend the Parser
In order to extend the Parser by adding your own listeneres (this can be the case if you are using quill plugins which generates custom delta code), you have to decide whether its:
- inline element: Replaces content with new parsed content, this is mostly the case when working with quill extensions.
- block element: Block elements which encloses the whole input with a tag, for example heading.
An example for a mention plugin which generates the following delta {"insert":{"mention":{"id":"1","value":"Basil","denotationChar":"@"}}}
an inline plugin could look like this:
Now register the listenere:
Overide built-in Listeners
Certain listeners (image, video, color) produce a HTML output which maybe not suit your use case, so you have to the option to override the properties of those plugins, example with image tags:
Debuging
Sometimes the handling of delta and how the data is parsed is very hard to debug and understand. Therefore you can use the debugger class which will print a table with informations about how the data is parsed.
There is also a built in docker compose file which provides access to the output.php file. The output.php helps to directly write content with the quill editor while displaying what is rendered including all debug informations. In order to run this docker webserver execute the following command in the root directory of your clone:
and visit http://localhost:5555/
in your browser.