This repository has been archived by the owner on Sep 18, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from Humni/add-video-attributes
Add video attributes
- Loading branch information
Showing
5 changed files
with
160 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters