diff --git a/CHANGELOG.md b/CHANGELOG.md index a1a6f5d..b49971b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,13 @@ Full changelog for PHP Quill Renderer -## v3.17.1 - 2019-03-xx +## v3.17.2 - 2019-03-09 + +* Additional work to fix [#117](https://github.com/deanblackborough/php-quill-renderer/issues/117), +allow through any empty insert, some are valid so for now just render what quill wants, I'll +add strict mode later to remove what I consider to be the redundant inserts. + +## v3.17.1 - 2019-03-07 * Fixed [#117](https://github.com/deanblackborough/php-quill-renderer/issues/117), compound deltas not aware of the fact that they can also be links. diff --git a/README.md b/README.md index 8557415..92b5e47 100644 --- a/README.md +++ b/README.md @@ -18,15 +18,11 @@ supported are listed in the table below, the goal is to eventually support every ## Planned features -The latest update, v3.16.0, took a while, after receiving many bug reports related -to mishandling of newlines I decided to do a minor refactor, mainly splitting the deltas -sooner. I'm hoping that by the v3.17.0 release I'll be done and can then concentrate on new features. - 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 +#### 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 @@ -37,7 +33,7 @@ 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 backported, it very much depends on the particular feature. +be back-ported, it very much depends on the particular feature. ## Installation diff --git a/Tests/Api/BugTest.php b/Tests/Api/BugTest.php index 2823a3b..404b2cd 100644 --- a/Tests/Api/BugTest.php +++ b/Tests/Api/BugTest.php @@ -250,6 +250,40 @@ final class BugTest extends \PHPUnit\Framework\TestCase } ] }'; + private $delta_bug_117_links_deltas_with_attributes_take_2 = ' + { + "ops":[ + { + "attributes":{ + "italic":true, + "link":"https://www.amazon.com" + }, + "insert":"Space" + }, + { + "insert":" " + }, + { + "attributes":{ + "bold":true, + "link":"https://www.yahoo.com" + }, + "insert":"removed" + }, + { + "insert":" but shoudn\'t" + }, + { + "attributes":{ + "bold":true + }, + "insert":"." + }, + { + "insert":"\n" + } + ] + }'; private $expected_bug_external_3 = '
Lorem ipsum
@@ -279,7 +313,10 @@ final class BugTest extends \PHPUnit\Framework\TestCase
Some Text.
The quick brown fox jumps over the lazy dog... Spaceremoved. + private $expected_bug_117_links_deltas_with_attributes = '
The quick brown fox jumps over the lazy dog... Space removed.
+
+
Now some normal text. + private $expected_header_then_text = '
-
Now some normal text.
+Now some normal text.
+
+
+
+Now some normal text.
This is another paragraph +
+
+This is another paragraph
This is another paragraph. +
+
+This is another paragraph.
+
+
A paragraph. +
+
+A paragraph.
+
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed efficitur nibh tempor augue lobortis, nec eleifend velit venenatis. Nullam fringilla dui eget lectus mattis tincidunt.
@@ -169,7 +177,10 @@ final class MixTest extends \PHPUnit\Framework\TestCase
private $expected_multiple_unknown_attributes_image = '
Text 1 assumenda Text 2.
-Text 3.
'; ++ +
+Text 3.
'; /** * Test for issue #64, opening p tag between two opening headers diff --git a/src/Parser/Html.php b/src/Parser/Html.php index 700e348..0b8c27a 100644 --- a/src/Parser/Html.php +++ b/src/Parser/Html.php @@ -309,22 +309,19 @@ public function insert(array $quill) { $insert = $quill['insert']; - if (strlen(trim($insert)) > 0) { - - /** - * @var Delta - */ - $delta = new $this->class_delta_insert($insert, (array_key_exists('attributes', $quill) ? $quill['attributes'] : [])); - - if (preg_match("/[\n]{2,}/", $insert) !== 0) { - $delta->setClose(); - } else { - if (preg_match("/[\n]{1}/", $insert) !== 0) { - $delta->setNewLine(); - } + /** + * @var Delta + */ + $delta = new $this->class_delta_insert($insert, (array_key_exists('attributes', $quill) ? $quill['attributes'] : [])); + + if (preg_match("/[\n]{2,}/", $insert) !== 0) { + $delta->setClose(); + } else { + if (preg_match("/[\n]{1}/", $insert) !== 0) { + $delta->setNewLine(); } - - $this->deltas[] = $delta; } + + $this->deltas[] = $delta; } }