Giter Club home page Giter Club logo

php-quill-renderer's Introduction

Hi ๐Ÿ‘‹

My name is Dean Blackborough (that shouldn't be a suprise as it is my username).

I've been a web developer forever, mostly PHP, however I dabble with lots of other languages, most recently I've starting using C++ and love it!

Since 2019 I've been concentrating on Costs to Expect, a business my Wife and I started.

Costs to Expect is a service we are building which includes an Open Source REST API, an expense app, budgeting apps a long-term social experiment tracking the cost to raise our children, a Yahtzee/Yatzy game scorer and other things, have a look if any of that sounds interesting.

  • ๐Ÿ”ญ I'm working on anything and everything for Costs to Expect, currently Budget and Budget Pro.
  • ๐ŸŒฑ For fun, I'm building the basis of a Platformer in Game Maker with my kids.
  • ๐ŸŒฑ For fun, I'm building a C++ 2D Game Engine, playing at C++ game engine development with my kids.
  • ๐ŸŒฑ For fun, I'm building a C++ Maths Quiz console app for my nine and three year old to learn C++.
  • ๐ŸŒฑ For fun, I'm building a Yahtzee game scorer, powered by the Costs to Expect API.
  • ๐ŸŒฑ For fun, I'm building a Yatzy game scorer, powered by the Costs to Expect API.
  • ๐Ÿ“ซ How to reach me: My email is on my profile
  • ๐Ÿค” Iโ€™m looking for help with new game scorers, check out Yahtzee and Yatzy as a base, docs coming soon(tm)

php-quill-renderer's People

Contributors

deanblackborough avatar humni avatar lode avatar on2 avatar sald19 avatar theomeunier avatar typicalfence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-quill-renderer's Issues

Markdown parser

Add the initial parser for Markdown, just the basic attributes to get the model working

wrong output for lists

Hi, we found some issues with your package with this quill delta:

{
  "ops": [
    {
      "insert": "Headline 1"
    },
    {
      "attributes": {
        "header": 1
      },
      "insert": "\n"
    },
    {
      "insert": "Some text. "
    },
    {
      "attributes": {
        "bold": true
      },
      "insert": "Bold Text"
    },
    {
      "insert": ". "
    },
    {
      "attributes": {
        "italic": true
      },
      "insert": "Italic Text"
    },
    {
      "insert": ". "
    },
    {
      "attributes": {
        "italic": true,
        "bold": true
      },
      "insert": "Bold and italic Text"
    },
    {
      "insert": ". Here is a "
    },
    {
      "attributes": {
        "link": "https://scrumpy.io"
      },
      "insert": "Link"
    },
    {
      "insert": ". \nHeadline 2"
    },
    {
      "attributes": {
        "header": 2
      },
      "insert": "\n"
    },
    {
      "insert": "ordered list item"
    },
    {
      "attributes": {
        "list": "ordered"
      },
      "insert": "\n"
    },
    {
      "insert": "ordered list item"
    },
    {
      "attributes": {
        "list": "ordered"
      },
      "insert": "\n"
    },
    {
      "insert": "ordered list item"
    },
    {
      "attributes": {
        "list": "ordered"
      },
      "insert": "\n"
    },
    {
      "insert": "unordered list item"
    },
    {
      "attributes": {
        "list": "bullet"
      },
      "insert": "\n"
    },
    {
      "insert": "unordered list item with "
    },
    {
      "attributes": {
        "bold": true,
        "link": "https://scrumpy.io"
      },
      "insert": "link"
    },
    {
      "attributes": {
        "list": "bullet"
      },
      "insert": "\n"
    },
    {
      "insert": "unordered list item"
    },
    {
      "attributes": {
        "list": "bullet"
      },
      "insert": "\n"
    },
    {
      "insert": "Some Text.\n"
    }
  ]
}

This is the expected output:

<h1>Headline 1</h1>
<p>Some text. <strong>Bold Text</strong>. <em>Italic Text</em>. <strong><em>Bold and italic Text</em></strong>. Here is a <a href="https://scrumpy.io">Link</a>. </p>
<h2>Headline 2</h2>
<ol>
<li>ordered list item</li>
<li>ordered list item</li>
<li>ordered list item</li>
</ol>
<ul>
<li>unordered list item</li>
<li>unordered list item with <a href="https://scrumpy.io"><strong>link</strong></a></li>
<li>unordered list item</li></ul>
<p>Some Text.</p>

This is the current output:

<h1>Headline 1</h1>
<p>Some text. <strong>Bold Text</strong>. <em>Italic Text</em>. <em><strong>Bold and italic Text</strong></em>. Here is a <a href="https://scrumpy.io">Link</a>.
<br />
<h2>Headline 2</h2>
<ol>
<li>ordered list item</li>
<li>ordered list item</li>
<li>ordered list item</li>
<li>unordered list item</li>
<li>unordered list item with <a href="https://scrumpy.io">link</a><strong>link</strong></li> <li>unordered list item</li>
</ul>
Some Text.<br />
</p>

There are three issues here.

  • there is only one wrapping paragraph around the lists
  • there is an <ol> opening tag and a </ul> closing tag
  • there is duplicated text output for a strong link within a list item

Test coverage

The test coverage in a couple of classes if a little low, increase it.

PHP 7.0/7.1 support?

What exactly forces the 7.2 requirement?

I am asking before I implement 3.x because I will also have to upgrade PHP on a few servers if it's actually necessary. I am running 7.1.x almost everywhere.

Undefined index: image (when dealing with a video).

Hello,

I'm currently using the method render in the Render class and it seems to be working fine with most things such as bold, italic, underline, strike, images, headings. But whenever I include a video it throws an undefined index error.

The error is thrown on line 340 or /src/Parser/Html.php:

public function image(array $quill)
{
    $this->deltas[] = new Image($quill['insert']['image']);
}

After being called from line 181 /src/Parser/Parse.php using the delta:

array:1 [โ–ผ
  "insert" => array:1 [โ–ผ
    "video" => "https://www.youtube.com/embed/videoid"
  ]
]

Here's the stack trace:

ErrorException: Undefined index: image in file D:\Documents\GitProjects\ProjectName\app\vendor\deanblackborough\php-quill-renderer\src\Parser\Html.php on line 340
Stack trace:
  1. ErrorException->() D:\Documents\GitProjects\ProjectName\app\vendor\deanblackborough\php-quill-renderer\src\Parser\Html.php:340
  2. Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() D:\Documents\GitProjects\ProjectName\app\vendor\deanblackborough\php-quill-renderer\src\Parser\Html.php:340
  3. DBlackborough\Quill\Parser\Html->image() D:\Documents\GitProjects\ProjectName\app\vendor\deanblackborough\php-quill-renderer\src\Parser\Parse.php:181
  4. DBlackborough\Quill\Parser\Parse->parse() D:\Documents\GitProjects\ProjectName\app\vendor\deanblackborough\php-quill-renderer\src\Render.php:73
  5. DBlackborough\Quill\Render->render() D:\Documents\GitProjects\ProjectName\app\app\Http\Controllers\PageController.php:71
  6. App\Http\Controllers\PageController->getPost() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Controller.php:54
  7. call_user_func_array() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Controller.php:54
  8. Illuminate\Routing\Controller->callAction() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php:45
  9. Illuminate\Routing\ControllerDispatcher->dispatch() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Route.php:212
 10. Illuminate\Routing\Route->runController() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Route.php:169
 11. Illuminate\Routing\Route->run() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Router.php:665
 12. Illuminate\Routing\Router->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:30
 13. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php:41
 14. Illuminate\Routing\Middleware\SubstituteBindings->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 15. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 16. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php:67
 17. Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 18. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 19. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSomething is wrong.php:49
 20. Illuminate\View\Middleware\ShareErrorsFromSomething is wrong->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 21. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 22. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Something is wrong\Middleware\StartSomething is wrong.php:63
 23. Illuminate\Something is wrong\Middleware\StartSomething is wrong->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 24. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 25. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php:37
 26. Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 27. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 28. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php:59
 29. Illuminate\Cookie\Middleware\EncryptCookies->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 30. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 31. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:104
 32. Illuminate\Pipeline\Pipeline->then() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Router.php:667
 33. Illuminate\Routing\Router->runRouteWithinStack() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Router.php:642
 34. Illuminate\Routing\Router->runRoute() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Router.php:608
 35. Illuminate\Routing\Router->dispatchToRoute() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Router.php:597
 36. Illuminate\Routing\Router->dispatch() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:176
 37. Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:30
 38. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php:65
 39. Barryvdh\Debugbar\Middleware\InjectDebugbar->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 40. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 41. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\fideloper\proxy\src\TrustProxies.php:57
 42. Fideloper\Proxy\TrustProxies->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 43. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 44. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:31
 45. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 46. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 47. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:31
 48. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 49. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 50. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php:27
 51. Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 52. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 53. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php:51
 54. Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
 55. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
 56. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:104
 57. Illuminate\Pipeline\Pipeline->then() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:151
 58. Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() D:\Documents\GitProjects\ProjectName\app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:116
 59. Illuminate\Foundation\Http\Kernel->handle() D:\Documents\GitProjects\ProjectName\app\public\index.php:55
 60. _once() D:\Documents\GitProjects\ProjectName\app\server.php:21

Paragraph after two headers, opening p inbetween headers

With the following delta

{"ops":[{"insert":"Primary Header"},{"attributes":{"header":1},"insert":"\n"},{"insert":"\nSecondary header"},{"attributes":{"header":2},"insert":"\n"},{"insert":"\nA paragraph.\n"}]}

The HTML is incorrect, the opening p tag is being placed between the two headers.

Need a failing test and then the fix to solve the bug!

API

Tweaks and improvements to the API.

  • Update render multiple to allow format to be set per json_string?
  • Allow the format to be set via method, chaining, move from constructor? or support both
  • Why do we need render and render multiple, a single Quill class could work and mark the render classes as deprecated x versions out.
  • Anything else?

Bug parse delta to html

Hi Dean, i found this bug parsing delta with only one \n

the text generate this JSON Delta

{
	"ops": [{
		"insert": "normal text here\nbullet 1"
	}, {
		"attributes": {
			"list": "bullet"
		},
		"insert": "\n"
	}, {
		"insert": "bullet 2"
	}, {
		"attributes": {
			"list": "bullet"
		},
		"insert": "\n"
	}, {
		"insert": "bullet3"
	}, {
		"attributes": {
			"list": "bullet"
		},
		"insert": "\n"
	}]
}

render HTML

<ul>
    <li>normal text herebullet 1</li>
    <li>bullet 2</li>
    <li>bullet3</li>
</ul>

Test suite

Expand the test suite to support the initial Markdown support, #68 and #74

Support for complex unknown attributes

Notes from v3.15.0 release detailing requirements.

  • Added support for Color delta type, it creates a span with a style="color: #xxx" definition,
    thank you (https://github.com/on2)

Notes

The implementation works and does not break anything, however, I will extend the feature in the future.
It should really be handled in the same way unknown attributes are handled in the plain Insert delta.
The Insert delta only deals with a simple key and value, it needs to be extended to allow complex values,
that way an attribute like {"attributes":{"style":{"color": #e60000"}} could generate the same output and allow much more flexibility. I'm happy to leave the Color delta in until the next major version as I
believe it is a feature other people may use.

Missing line break after bold or italic words

Hello,

At the moment, line break in the quill editor are rendered as <br> inside paragraphs which is perfect. But the feature is missing for bold and italic format.

Delta

{"ops":[{"attributes":{"bold":true},"insert":"Bold text"},{"insert":"\nAny text\n"}]}

Is rendered

<p><strong>Bold text</strong>Any text</p>

Should be

<p><strong>Bold text</strong><br>Any text</p>

Markdown renderer and lists

The markdown renderer is not up to date with the HTML renderer, it fails to handle lists where the entire list item should be anything but a basic delta, for example, the following delta should produce a list with one item where the entire entry is bold.

{"ops":[{"attributes":{"bold":true},"insert":"This is a single row list item."},{"attributes":{"list":"ordered"},"insert":"\n"}]}

This should be fixed this evening when I push v3.13.3.

Where are the line breaks?

If I use the following delta, I don't get line breaks.

{"ops":[{"insert":"Paragraph\n\nLine 1, should have a BR\nLine 2, should have a BR\nLine 3\n"}]}

I get

<p>Paragraph</p><p>Line 1, should have a BRLine 2, should have a BRLine 3</p>

but expect

<p>Paragraph</p><p>Line 1, should have a BR<br />Line 2, should have a BR<br />Line 3</p>

Lists, don't work when list item contains formatting

If the text in lists is formatted the layout breaks, for some reason my code assumes you want to start a new paragraph.

This delta

{"ops":[{"insert":"List item 1"},{"attributes":{"list":"bullet"},"insert":"\n"},{"insert":"List "},{"attributes":{"bold":true},"insert":"item"},{"insert":" 2"},{"attributes":{"list":"bullet"},"insert":"\n"},{"insert":"List item 2"},{"attributes":{"list":"bullet"},"insert":"\n"}]}

Produces

<ul> <li>List item 1</li> <p>List <strong>item</strong></p> <ul> <li> 2</li> <li>List item 2</li> </ul>

It should produce

<ul> <li>List item 1</li> <li>List <strong>item</strong> 2</li> <li>List item 2</li> </ul>

Test previous versions and see where this breaks or has it ever worked, either way, poor testing on my part.

All [P]aragraph blocks are merged into a single one

Hi Dean and thanks for this renderer!

I have a little issue on my end, though... While retrieving the content, all paragraphs are merged into a single one, and '\n\n' separators from the original json seem to be ignored.

Any idea why this might happen?

Thanks!

Subclass

  • Separate parse json and generate html code.
  • Simplify api, pass in json and then set required output.

Updated README for release

Update and restructure the README now that two formats are supported. may be time for a docs section? Maybe not if we add a single entry class

Link always gets parsed on new line

I am using the following versions:
"deanblackborough/php-quill-renderer": "^3.15",
"quill": "^1.3.6",

And i am trying to parse the following in the editor:
screenshot 2018-12-10 at 11 58 44

This has a link on the same line, on the second line a change of color in the text. The output of the quill javascript contents are the following:
screenshot 2018-12-10 at 12 00 08

This shows that the 'contactformulier' link is added, but also the color change on the next line. I save this in the database but when i render it, it renders like this:
screenshot 2018-12-10 at 12 02 09

The link is always on a new line. I am using the following code to render the deltas:

`$parser = new HtmlParser();
$renderer = new HtmlRenderer();

    $parser->load($deltas)->parse();
    return $renderer->load($parser->deltas())->render();`

Is there something i am doing wrong? Or is this something that can be changed?

Code duplication

Code duplication has crept into the parsers, for example the methods attributeBold() are the same in each, the only difference being the Delta class instantiated, find a way to correct this, you should only need to define additional functionality.

Heading

Add support for all headings, H1 to H7.

Erroneous br tag

Erroneous tag with the following deltas, end up with a mangled br tag at the end of the generated HTML but before the final p tag.

{"ops":[{"attributes":{"underline":true,"bold":true},"insert":"Rich text:"},{"insert":"\n\nMorbi ultrices accumsan tortor, quis bibendum metus convallis eu. Phasellus in dictum dui. Cras "},{"attributes":{"italic":true},"insert":"bibendum viverra"},{"insert":" vestibulum. Fusce vel accumsan dui, at blandit sem. Aenean rutrum eu "},{"attributes":{"strike":true},"insert":"sapien vel"},{"insert":" viverra. Sed accumsan convallis tellus id mollis.\n\nMorbi ultrices accumsan tortor, quis bibendum metus convallis eu.\n"}]}

Plain text parser

Add plain text as a parsing option, could end up being useful and is pretty simple to add as we just need to ensure the new lines are handled correctly.

Markdown

Add support for additional renderers and parsers, Markdown.

Pushed back to post version 2.0.0 refactoring.

Error with specific JSON related to array where string is expected

I'm receiving the following error for the JSON structure listed below.

Internal message: Argument 1 passed to DBlackborough\Quill\Delta\Html\Compound::__construct() must be of the type string, array given, called in /var/www/app/vendor/deanblackborough/php-quill-renderer/src/Parser/Html.php on line 138

I'm not always getting errors with this kind of structure, but with this JSON I seem to be able to reliably reproduce it.

{
	"ops": [{
		"insert": "Text 1 "
	}, {
		"attributes": {
			"bold": true
		},
		"insert": "assumenda"
	}, {
		"insert": " Text 2.\n\n"
	}, {
		"attributes": {
			"width": "214",
			"style": "display: inline; float: right; margin: 0px 0px 1em 1em;"
		},
		"insert": {
			"image": "data:image/png;base64,ImageDataOmittedforSize"
		}
	}, {
		"insert": "\n\nText 3.\n\n"
	}]
}

Thanks!

Images

Add support for external images.

List support

Add support for ordered and bulleted lists, need to change how the HTML is generated as I will need to look back and modify the previous item to support lists.

Hi Dean! I'm super interested in this.

Hi! I'm super interested in this. Didn't know how to contact you in a good fashion. Hope this is ok. =)

I'm looking at using Quill as a word processor and would like to cut out some steps. I currently save the html from the editor root. But would like to instead save the current full doc Delta and render the html on the server side for saving.

This seems promising as I was just about to do this. =) And use it for exporting.

Compound deltas markdown

The following delta is not generating the correct markdown

{"ops":[{"insert":"The "},{"attributes":{"italic":true},"insert":"quick"},{"insert":" brown fox "},{"attributes":{"bold":true},"insert":"jumps"},{"insert":" over the "},{"attributes":{"italic":true,"bold":true},"insert":"lazy"},{"insert":" dog...\n"}]}

The compound insert lazy, is being ignored.

The resolution, the Markdown and GitHub parsers generate the correct Markdown

The *quick* brown fox **jumps** over the ***lazy*** dog...
or
The *quick* brown fox **jumps** over the _**lazy**_ dog...

General refactor

There is a little duplication in the code, why do we need to duplicate the attribute switch statements, review and fix

Check Quill attributes, not tags

A couple of methods in the code check for existence of html tags directly, this needs to be altered, tags can be overridden so the existing checks may fail at some point.

The tags array could include a index referring back to the existing quill attribute and maybe attribute type inline/block.

Rogue p tag

With the following delta {"ops":[{"insert":"Another list"},{"attributes":{"list":"bullet"},"insert":"\n"},{"insert":"List item two entry two"},{"attributes":{"list":"bullet"},"insert":"\n"},{"insert":"\nAnd now a HEADER"},{"attributes":{"header":4},"insert":"\n"}]}

A rogue p tag appears between the list and the final header.

Need a failing test and then the fix to solve the bug!

Newline and paragraphs

Regression to newline and paragraph support in v0.50, return feature after refactoring tasks.

How to extend the Parser

We do have some custom tags like mentions, it would be nice if i could register my own module, for example:

class MentionModule extends .... BasicRendere
{
    public $attribute = 'mention';

    public function handle($input)
  ย  {
        // do something with input and return changed value.
    }
}

$render->register(new MentionModule());

Maybe there is also already such an option to register a new not internal plugin to the rendered, but i could not find anything in the docs.

Here an example delta of such a mention plugin delta response (which is this plugin actually: https://github.com/afconsult/quill-mention):

value="{
  "ops": [
    {
      "insert": "Hello "
    },
    {
      "insert": {
        "mention": {
          "id": "1",
          "value": "Fredrik Sundqvist",
          "denotationChar": "@"
        }
      }
    },
    {
      "insert": " \n"
    }
  ]
}"

As this is really the benefit of delta response, maybe it should be possible to register my own listener / renderer for a given tag.

Or at list a hook which i can attach to for EVERY element and decided by myself whether i want to change the value - or keep the basic renderer do his job.

Set atribute option

Switch to an abstract method in Quilll\Renderer, setting values need to be handled at the renderer level, you don't set the tag 'bold' the same way you do for 'link'.

Type error: preg_match() expects parameter 2 to be string, null given

Hi there,

With some (pasted) text I get the error you see in the subject line. It happens when your ops contains a line like this

		{"insert": },

which I have no idea how and why it happens. This causes "runtime" errors (and a consequent 500 as I am using your lovely code as an asynchronous renderer.) I have had to add the following in three places (but there might be still more that need the extra check): ! (null === $delta['insert']) &&.

The lines I updates were 216, 246 and 345 but of course things might have moved a bit now!

I've attached a screenshot of my Chrome's console so you can see what i encountered. My extra check seems to have fixed it so I will attach my version of Html.php to this report in addition to requesting a pul, as I don't know what your pull request policies are. By all means, incorporate my fix if you prefer it that way, or accept the request!

Thank you,

Petros

screen shot 2018-04-14 at 17 19 40

Html.php.txt

Handle undefined attributes

The compound delta need to handle all undefined attributes in a similar way to the CompoundImage delta, at the same time reduce the duplication in the code, why is the switch in two places?

Parser/Parse::load does not clear deltas

When reusing the same parser to process multiple Quill JSONs, the new deltas are plainly stacked upon the previous ones, effectively merging any previous ones into the new one.

Thought I should report this as I just lost an hour trying to figure out why this happened, thinking I was invoking my own code multiple times :-).

EDIT: I'm using version 3, by the way.

Problems with newlines

Dear @deanblackborough thanks for the greate package. We do have an issue with newlines and breaks - its not rendered like the html direct output.

bildschirmfoto 2018-09-10 um 21 23 08

The text above the HR renders the direct "html" output from quill. The output below the hr renders the deltas trough your library:

$quill = new Render($json);
return $quill->render();

Here is the delta code:

{
  "ops": [
    {
      "insert": "Hallo"
    },
    {
      "attributes": {
        "header": 1
      },
      "insert": "\n"
    },
    {
      "insert": "\nDas ist ein normaler Text:\n\n"
    },
    {
      "attributes": {
        "bold": true
      },
      "insert": "Test: Eintrag"
    },
    {
      "insert": "\n"
    },
    {
      "attributes": {
        "bold": true
      },
      "insert": "Test: Zwei"
    },
    {
      "insert": "\n\nhttps://heartbeat.gmbh\n\n\n"
    }
  ]
}

Do you have any idea what we are doing wrong - or its a problem of the library? It seems to be a very common use case.

Media

Add support for media, initially video urls and then images. Work on API from Dlayer side to include images from Media library when it is added back in.

Parser, method chaining

Is a reason why the direct example in the README using method chaining for the renderer and not the parser, if there isn't update the README, otherwise update the parser to support method chaining, not consistent.

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.