Giter Club home page Giter Club logo

php-quill-renderer's Introduction

Latest Stable Version Packagist License Minimum PHP Version Build Status Coverage Status

PHP Quill Renderer

Render quill insert deltas to HTML, Markdown and GitHub flavoured Markdown.

Description

Quill deltas renderer, converts deltas to HTML and Markdown, the Quill attributes supported are listed in the table below, the goal is to eventually support every Quill feature.

Quill is a modern WYSIWYG editor built for compatibility and extensibility.

Planned features (v4.00.0 dev starting soon, 2019-11-25)

If you check the table below you will note that I don't support all of Quills features, that is definitely the plan, however, before I add support for new attributes I want to add a major new feature.

Plugins

I'm planning to add support for plugins, all the existing features will become plugins, therefore, based on your particular needs you will be able to disable plugins/deltas you don't need, in addition, this will allow me to add support for third-party plugins.

Plugin support, will, of course, be a breaking change so once I have resolved all the known bugs and completed my planned refactoring I will start work on plugins in the v4 branch.

I will continue to support v3 after the eventual release of v4, some features may be back-ported, it very much depends on the particular feature.

Installation

The easiest way to use the PHP Quill Renderer is via composer. composer require deanblackborough/php-quill-renderer, alternatively you can include the classes in my src/ directory directly in your library or app.

Usage

Via API, single $quill_json

try {
    $quill = new \DBlackborough\Quill\Render($quill_json);
    $result = $quill->render();
} catch (\Exception $e) {
    echo $e->getMessage();
}

echo $result;

Via API, multiple $quill_json, passed in via array

try {
    $quill = new RenderMultiple($quill_json, 'HTML');
    
    $result_one = $quill->render('one');
    $result_two = $quill->render('two');
} catch (\Exception $e) {
    echo $e->getMessage();
}

echo $result_one;
echo $result_two;

Direct, parse and then render, single $quill_json - updated in v3.10.0

$parser = new \DBlackborough\Quill\Parser\Html();
$renderer = new \DBlackborough\Quill\Renderer\Html();

$parser->load($quill_json)->parse();

echo $renderer->load($parser->deltas())->render();

Direct, parse and then render, multiple $quill_json - updated in v3.10.0

$parser = new \DBlackborough\Quill\Parser\Html();
$renderer = new \DBlackborough\Quill\Renderer\Html();

$parser->loadMultiple(['one'=> $quill_json_1, 'two' => $quill_json_2)->parseMultiple();

echo $renderer->load($parser->deltasByIndex('one'))->render();
echo $renderer->load($parser->deltasByIndex('two'))->render();

Quill attributes and text flow support

Attribute v1+ v2+ v3 HTML v3 Markdown
Bold Yes Yes Yes Yes
Italic Yes Yes Yes Yes
Link Yes Yes Yes Yes
Strike Yes Yes Yes N/A
Script:Sub Yes Yes Yes N/A
Script:Super Yes Yes Yes N/A
Underline Yes Yes Yes N/A
Header Yes Yes Yes Yes
Image Yes Yes Yes Yes
Video No No Yes Yes
List Yes Yes Yes Yes
Child lists No No Planned Planned
Indent/Outdent No No Planned Planned
Text direction No No Planned N/A
Color No No Planned N/K
Font No No Planned N/K
Text align No No Planned N/A
Block quote No No Planned Planned
Code block No No Planned Planned
Custom attributes No No Yes N/A
Line breaks No No Yes Yes
Paragraphs Yes Yes Yes Yes
Attribute HTML Tag Markdown Token
Bold <strong> **
Italic <em> *
Link <a> [Text](Link)
Strike <s>
Script:Sub <sub>
Script:Super <sup>
Underline <u>
Header <h[n]> #[n]
Image <img> ![Image](\path\to\image)
Video <iframe> ![Video](\path\to\video)
List <ul> <ol> * & [n]

Copyright and license

The deanblackborough/php-quill-renderer library is copyright © Dean Blackborough and licensed for use under the MIT License (MIT).

Credits

  • carlos [Bugfix] v1.01.0.
  • pdiveris [Issue #43] - Null inserts.
  • Mark Davison - Pushed me in the right direction for v3.00.0.
  • tominventisbe [Issue #54] - Parser::load() does not reset the deltas array.
  • tominventisbe [Issue #55] - Image deltas with multiple attributes incorrectly being passed to Compound delta.
  • bcorcoran [Issue #81] - Suggested reverting requirements to necessary requirements.
  • kingga [Issue #86] - Video support.
  • Jonathanm10 [Issue #87] - Newlines proceeding inserts ignored, bug report.
  • raphaelsaunier [Issue #87] - Newlines proceeding inserts ignored, bug location.
  • Basil [Issue #101] - Newline only inserts being ignored by parser.
  • Lee Hesselden [PR #104] - Color delta to allowing spans with a style:color="#xxx" definition. (Feature will be extended by [Issue #106])
  • Alex [PR #112] - Custom attributes assigned to style attribute if sensible.
  • davidraijmakers [Issue #108] - Children not supported with headers.
  • philippkuehn [Issue #109] - Multiple list output incorrect and paragraphs not being closed.
  • mechanicalgux [Issue #117] - Compound deltas don't know that they can be links.
  • Lode Claassen [PR121] - Missing supported format in exception messages.
  • Lode Claassen [PR122] - Validation code DRY.
  • Lode Claassen [PR123] - Allow already decoded json to be passed to parser.
  • Nicholas Humphries [PR128] - Videos with attributes not supported.

Coding standards credits

php-quill-renderer's People

Contributors

deanblackborough avatar humni avatar lode avatar odinti avatar on2 avatar sald19 avatar typicalfence avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.