Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #128 from Humni/add-video-attributes
Browse files Browse the repository at this point in the history
Add video attributes
  • Loading branch information
deanblackborough authored Dec 10, 2019
2 parents e1a03f4 + 215f84b commit 8259b5f
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 3 deletions.
44 changes: 43 additions & 1 deletion Tests/Attributes/Html/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
final class ImageTest extends \PHPUnit\Framework\TestCase
{
private $delta_image = '{"ops":[{"insert": {"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAgCAYAAACcuBHKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAAhdEVYdENyZWF0aW9uIFRpbWUAMjAxODowNTowNiAwMDowMToyNa9H3HIAAARpSURBVFhHtZa/b1NXFMePHceOE2iXAgIJFNpOrSNn6l4kYETZWColf0CnqnsyFqnK0KFjonQoYs0EQ2mGqmsiQWBCEZZAIIoSipTEdvx6P8fv+3JsOY1U0a90dH7ec773vvueXZqYmMgsYWxszHq9nkupVHJdLpdJOYhlWeYakMMHR0dHha8a1QHFVRN7ISle9iSNSAASkFKhFisHqIdobAqwVUMeKBZrVeMbIKBdRyEu3e12fYF8NVUjIJ8axdHqH31qFMMuzltBtI5X4FRoQI4mUQTZiqtfRKwRUVBWsYYoqYHy4yJsJBKNiH3QbIJakQAD/biYasgJCMS0SDaPJd4doCHVatV9cghxrUPH3v4IwjzfiorQ8jVIuXa7bY1Gw1ZWVmx3d9dz6OXlZY8fHBwMnJ7WE0M0GMTeHuMk6vV6IfhpZ1mlUnGdirLp6elsdXU1rT1Gv9cxyFOXGhfrEfVHS2q12oAuUQAj2ILUzw4PD21xcdFmZ2ctNbZms+m5iLjbiK2tLdvZ2bHNzU3vMTk56XUIa4Bm6WRKU1NTmR4FSTRHO2pAxEkkIqh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Vw7UxD49v6Pdvfxg7zi+FFIS5hVvKIqJBBJ8fO8vr5uCwsLXiNc+ehCbpm1ckIPE5FRBADD6InmcuqxK+ZfTLEiCPBVyCVdW1uzubm5gUfDawj2Dt/brXvf27ukRxHovXzvfeIc3T98UHwngHQkJHQ6HZuZmfG3hl/V2swFfw1PQ/vXp3b05C8fGi+/Ngr8TogREAHFWYjNo9ne3vaf96WlJf8QfdW+nK8ajc5vz627/WZgQ3Ees7BL/LFwI4mKScJSmlzcCafC/cGvNy/a+NeX/S0QeASdhy3rPX07QEA71zzgpPhno4RYRrYRsSEEQWysvMgL5OK3AR/RxvqdEgjGIrSaylfN8BAgnzps1SrGBScGiCtPbdJ9QxKhRWqKYIvQsI41w1AN8/QpUJ1fTBLuJI3E5rLVXLbysoGaKoeoN3YENTwKX59uPf+o81Q/WTAM5IhpqJ4vwB+GCJCLRLQWrZzb+rdNQJCvIsUATcBwHGDH0wLaEIhrNA+7+O2IQ6VjMc3iLgA7JK+digAx1QPVxbxiWZbZP/xo6NrxoHtXAAAAAElFTkSuQmCC"},"attributes":{"width":"100"}}]}';
private $delta_image_attributes = '{"ops":[{"insert": {"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAgCAYAAACcuBHKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAAhdEVYdENyZWF0aW9uIFRpbWUAMjAxODowNTowNiAwMDowMToyNa9H3HIAAARpSURBVFhHtZa/b1NXFMePHceOE2iXAgIJFNpOrSNn6l4kYETZWColf0CnqnsyFqnK0KFjonQoYs0EQ2mGqmsiQWBCEZZAIIoSipTEdvx6P8fv+3JsOY1U0a90dH7ec773vvueXZqYmMgsYWxszHq9nkupVHJdLpdJOYhlWeYakMMHR0dHha8a1QHFVRN7ISle9iSNSAASkFKhFisHqIdobAqwVUMeKBZrVeMbIKBdRyEu3e12fYF8NVUjIJ8axdHqH31qFMMuzltBtI5X4FRoQI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RWqKYIvQsI41w1AN8/QpUJ1fTBLuJI3E5rLVXLbysoGaKoeoN3YENTwKX59uPf+o81Q/WTAM5IhpqJ4vwB+GCJCLRLQWrZzb+rdNQJCvIsUATcBwHGDH0wLaEIhrNA+7+O2IQ6VjMc3iLgA7JK+digAx1QPVxbxiWZbZP/xo6NrxoHtXAAAAAElFTkSuQmCC"},"attributes":{"width":"100","height":"200"}}]}';

private $expected_image = '<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAgCAYAAACcuBHKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAAhdEVYdENyZWF0aW9uIFRpbWUAMjAxODowNTowNiAwMDowMToyNa9H3HIAAARpSURBVFhHtZa/b1NXFMePHceOE2iXAgIJFNpOrSNn6l4kYETZWColf0CnqnsyFqnK0KFjonQoYs0EQ2mGqmsiQWBCEZZAIIoSipTEdvx6P8fv+3JsOY1U0a90dH7ec773vvueXZqYmMgsYWxszHq9nkupVHJdLpdJOYhlWeYakMMHR0dHha8a1QHFVRN7ISle9iSNSAASkFKhFisHqIdobAqwVUMeKBZrVeMbIKBdRyEu3e12fYF8NVUjIJ8axdHqH31qFMMuzltBtI5X4FRoQI4mUQTZiqtfRKwRUVBWsYYoqYHy4yJsJBKNiH3QbIJakQAD/biYasgJCMS0SDaPJd4doCHVatV9cghxrUPH3v4IwjzfiorQ8jVIuXa7bY1Gw1ZWVmx3d9dz6OXlZY8fHBwMnJ7WE0M0GMTeHuMk6vV6IfhpZ1mlUnGdirLp6elsdXU1rT1Gv9cxyFOXGhfrEfVHS2q12oAuUQAj2ILUzw4PD21xcdFmZ2ctNbZms+m5iLjbiK2tLdvZ2bHNzU3vMTk56XUIa4Bm6WRKU1NTmR4FSTRHO2pAxEkkIqhJmyz6otPpDPh+afUNIAhOa/xfQG+EgQwGzOEk8Msa7k4Kyv+QYKCE/iIA0MV3Qvg/SNBTQ5mHj4YMV6H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yCVdW1uzubm5gUfDawj2Dt/brXvf27ukRxHovXzvfeIc3T98UHwngHQkJHQ6HZuZmfG3hl/V2swFfw1PQ/vXp3b05C8fGi+/Ngr8TogREAHFWYjNo9ne3vaf96WlJf8QfdW+nK8ajc5vz627/WZgQ3Ees7BL/LFwI4mKScJSmlzcCafC/cGvNy/a+NeX/S0QeASdhy3rPX07QEA71zzgpPhno4RYRrYRsSEEQWysvMgL5OK3AR/RxvqdEgjGIrSaylfN8BAgnzps1SrGBScGiCtPbdJ9QxKhRWqKYIvQsI41w1AN8/QpUJ1fTBLuJI3E5rLVXLbysoGaKoeoN3YENTwKX59uPf+o81Q/WTAM5IhpqJ4vwB+GCJCLRLQWrZzb+rdNQJCvIsUATcBwHGDH0wLaEIhrNA+7+O2IQ6VjMc3iLgA7JK+digAx1QPVxbxiWZbZP/xo6NrxoHtXAAAAAElFTkSuQmCC" width="100" /></p>';
private $expected_image_attributes = '<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAgCAYAAACcuBHKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAAhdEVYdENyZWF0aW9uIFRpbWUAMjAxODowNTowNiAwMDowMToyNa9H3HIAAARpSURBVFhHtZa/b1NXFMePHceOE2iXAgIJFNpOrSNn6l4kYETZWColf0CnqnsyFqnK0KFjonQoYs0EQ2mGqmsiQWBCEZZAIIoSipTEdvx6P8fv+3JsOY1U0a90dH7ec773vvueXZqYmMgsYWxszHq9nkupVHJdLpdJOYhlWeYakMMHR0dHha8a1QHFVRN7ISle9iSNSAASkFKhFisHqIdobAqwVUMeKBZrVeMbIKBdRyEu3e12fYF8NVUjIJ8axdHqH31qFMMuzltBtI5X4FRoQI4mUQTZiqtfRKwRUVBWsYYoqYHy4yJsJBKNiH3QbIJakQAD/biYasgJCMS0SDaPJd4doCHVatV9cghxrUPH3v4IwjzfiorQ8jVIuXa7bY1Gw1ZWVmx3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GDH0wLaEIhrNA+7+O2IQ6VjMc3iLgA7JK+digAx1QPVxbxiWZbZP/xo6NrxoHtXAAAAAElFTkSuQmCC" width="100" height="200" /></p>';

/**
* Link
* Image
*
* @return void
* @throws \Exception
Expand All @@ -34,4 +38,42 @@ public function testImage()

$this->assertEquals($this->expected_image, trim($result), __METHOD__ . ' Image failure');
}
/**
* Image with single attribute
*
* @return void
* @throws \Exception
*/
public function testImageWithAttribute()
{
$result = null;

try {
$quill = new QuillRender($this->delta_image_attribute);
$result = $quill->render();
} catch (\Exception $e) {
$this->fail(__METHOD__ . 'failure, ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
}

$this->assertEquals($this->expected_image_attribute, trim($result), __METHOD__ . ' Image failure');
}
/**
* Image with multiple attributes
*
* @return void
* @throws \Exception
*/
public function testImageWithAttributes()
{
$result = null;

try {
$quill = new QuillRender($this->delta_image_attributes);
$result = $quill->render();
} catch (\Exception $e) {
$this->fail(__METHOD__ . 'failure, ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
}

$this->assertEquals($this->expected_image_attributes, trim($result), __METHOD__ . ' Image failure');
}
}
44 changes: 44 additions & 0 deletions Tests/Attributes/Html/VideoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
final class VideoTest extends \PHPUnit\Framework\TestCase
{
private $delta_video = '{"ops":[{"insert":{"video":"https://video.url"}}]}';
private $delta_video_attribute = '{"ops":[{"insert":{"video":"https://video.url"},"attributes":{"width":"560"}}]}';
private $delta_video_attributes = '{"ops":[{"insert":{"video":"https://video.url"},"attributes":{"width":"560","height":"315"}}]}';

private $expected_video = '<p><iframe class="ql-video" frameborder="0" allowfullscreen="true" src="https://video.url"></iframe></p>';
private $expected_video_attribute = '<p><iframe class="ql-video" frameborder="0" allowfullscreen="true" width="560" src="https://video.url"></iframe></p>';
private $expected_video_attributes = '<p><iframe class="ql-video" frameborder="0" allowfullscreen="true" width="560" height="315" src="https://video.url"></iframe></p>';

/**
* Video
Expand All @@ -34,4 +38,44 @@ public function testVideo()

$this->assertEquals($this->expected_video, trim($result), __METHOD__ . ' Video failure');
}

/**
* Video with a single attribute
*
* @return void
* @throws \Exception
*/
public function testVideoWithAttribute()
{
$result = null;

try {
$quill = new QuillRender($this->delta_video_attribute);
$result = $quill->render();
} catch (\Exception $e) {
$this->fail(__METHOD__ . 'failure, ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
}

$this->assertEquals($this->expected_video_attribute, trim($result), __METHOD__ . ' Video failure');
}

/**
* Video with multiple attributes
*
* @return void
* @throws \Exception
*/
public function testVideoWithAttributes()
{
$result = null;

try {
$quill = new QuillRender($this->delta_video_attributes);
$result = $quill->render();
} catch (\Exception $e) {
$this->fail(__METHOD__ . 'failure, ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
}

$this->assertEquals($this->expected_video_attributes, trim($result), __METHOD__ . ' Video failure');
}
}
62 changes: 62 additions & 0 deletions src/Delta/Html/CompoundVideo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace DBlackborough\Quill\Delta\Html;

use DBlackborough\Quill\Settings;

/**
* Default delta class for compound video inserts, multiple attributes
*
* @author Dean Blackborough <[email protected]>
* @copyright Dean Blackborough
* @license https://github.com/deanblackborough/php-quill-renderer/blob/master/LICENSE
*/
class CompoundVideo extends Delta
{
/**
* Set the initial properties for the delta
*
* @param string $insert
*/
public function __construct(string $insert)
{
$this->insert = $insert;
}

/**
* Pass in an attribute value for conversion
*
* @param string $attribute Attribute name
* @param string $value Attribute value to assign
*
* @return CompoundVideo
*/
public function setAttribute($attribute, $value): CompoundVideo
{
$this->attributes[$attribute] = $value;

return $this;
}

/**
* Render the HTML for the specific Delta type
*
* @return string
*/
public function render(): string
{
$video_attributes = '';
foreach ($this->attributes as $attribute => $value) {
if (
is_string($attribute) &&
is_string($value) &&
in_array($attribute, Settings::ignoredCustomAttributes()) === false
) {
$video_attributes .= "{$attribute}=\"{$value}\" ";
}
}
return '<iframe class="ql-video" frameborder="0" allowfullscreen="true" '. $video_attributes .'src="' . $this->escape($this->insert) . '"></iframe>';
}
}
6 changes: 5 additions & 1 deletion src/Parser/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DBlackborough\Quill\Delta\Html\Color;
use DBlackborough\Quill\Delta\Html\Compound;
use DBlackborough\Quill\Delta\Html\CompoundImage;
use DBlackborough\Quill\Delta\Html\CompoundVideo;
use DBlackborough\Quill\Delta\Html\Delta;
use DBlackborough\Quill\Delta\Html\Header;
use DBlackborough\Quill\Delta\Html\Image;
Expand Down Expand Up @@ -287,9 +288,12 @@ public function compoundInsert(array $quill)
if (count($quill['attributes']) > 0) {
if (is_array($quill['insert']) === false) {
$delta = new Compound($quill['insert']);
} else {
} else if(array_key_exists('image', $quill['insert']) === true) {
$delta = new CompoundImage($quill['insert']['image']);
} else if(array_key_exists('video', $quill['insert']) === true) {
$delta = new CompoundVideo($quill['insert']['video']);
}

foreach ($quill['attributes'] as $attribute => $value) {
$delta->setAttribute($attribute, $value);
}
Expand Down
7 changes: 6 additions & 1 deletion src/Parser/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ public function parse(): bool
break;

default:
$this->insert($quill);
if (is_array($quill['insert'])) {
$this->compoundInsert($quill);
} else {
$this->insert($quill);
}

break;
}
}
Expand Down

0 comments on commit 8259b5f

Please sign in to comment.