-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* background plugin * changelog and fixed since tag * upgrade doc * Update UPGRADE.md * Update UPGRADE.md * Update CHANGELOG.md
- Loading branch information
Showing
9 changed files
with
93 additions
and
9 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
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,31 @@ | ||
<?php | ||
|
||
namespace nadar\quill\listener; | ||
|
||
use nadar\quill\InlineListener; | ||
use nadar\quill\Line; | ||
|
||
/** | ||
* Convert background color attributes into span tag. | ||
* | ||
* @author Basil Suter <[email protected]> | ||
* @since 3.4.0 | ||
*/ | ||
class BackgroundColor extends InlineListener | ||
{ | ||
/** | ||
* @var boolean If ignore is enabled, the colors won't apply. This can be use full if coloring is disabled in your quill editor | ||
* but people copy past content from somewhere else which will then generate the color attribute. | ||
*/ | ||
public $ignore = false; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function process(Line $line) | ||
{ | ||
if (($color = $line->getAttribute('background'))) { | ||
$this->updateInput($line, $this->ignore ? $line->getInput() : '<span style="background-color:'.$line->getLexer()->escape($color).'">'.$line->getInput().'</span>'); | ||
} | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
namespace nadar\quill\tests; | ||
|
||
class BackgroundColorTest extends DeltaTestCase | ||
{ | ||
public $json = <<<'JSON' | ||
{ | ||
"ops": [ | ||
{ | ||
"attributes": { | ||
"background": "#000000" | ||
}, | ||
"insert": "xyz" | ||
}, | ||
{ | ||
"insert": "\n" | ||
}, | ||
{ | ||
"attributes": { | ||
"background": "#fff" | ||
}, | ||
"insert": "xyz" | ||
}, | ||
{ | ||
"insert": "\n" | ||
} | ||
] | ||
} | ||
JSON; | ||
|
||
public $html = <<<'EOT' | ||
<p><span style="background-color:#000000">xyz</span></p><p><span style="background-color:#fff">xyz</span></p> | ||
EOT; | ||
} |
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