Skip to content

Commit

Permalink
add allow video configuration (#41)
Browse files Browse the repository at this point in the history
* add allow video configuration

* update changelog
  • Loading branch information
nadar authored Jun 29, 2020
1 parent 0e9eb0c commit a7c6df4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/).

## 2.5.0 (29. June 2020)

+ [#41](https://github.com/nadar/quill-delta-parser/pull/41) Add option to configure Embed Video `allow` option.

## 2.4.0 (2. November 2019)

+ [#32](https://github.com/nadar/quill-delta-parser/pull/32) Added new `wrapElement` method to simplify building block listeners.
Expand Down
10 changes: 8 additions & 2 deletions src/listener/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@
*/
class Video extends BlockListener
{
/**
* @var array Allow options for iframe allow param
* @since 2.5.0
*/
public $allow = ['accelerometer', 'autoplay', 'encrypted-media', 'gyroscope', 'picture-in-picture'];

/**
* @var string The wrapper template which is taken to generate the video element.
*/
public $wrapper = '<div class="embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>';
public $wrapper = '<div class="embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" src="{url}" frameborder="0" allow="{allow}" allowfullscreen></iframe></div>';

/**
* {@inheritDoc}
Expand All @@ -26,7 +32,7 @@ public function process(Line $line)
{
$embedUrl = $line->insertJsonKey('video');
if ($embedUrl) {
$line->output = str_replace(['{url}'], [$line->getLexer()->escape($embedUrl)], $this->wrapper);
$line->output = str_replace(['{url}', '{allow}'], [$line->getLexer()->escape($embedUrl), implode("; ", $this->allow)], $this->wrapper);
$line->setDone();
}
}
Expand Down

0 comments on commit a7c6df4

Please sign in to comment.