Skip to content

Commit

Permalink
Merge pull request #59 from johnpuddephatt/master
Browse files Browse the repository at this point in the history
Add tunes data to sanitised block
  • Loading branch information
neSpecc committed Sep 30, 2022
2 parents c6a96e8 + f2452cb commit 9446738
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions EditorJS/BlockHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ public function validateBlock($blockType, $blockData)
*
* @return array|bool
*/
public function sanitizeBlock($blockType, $blockData)
public function sanitizeBlock($blockType, $blockData, $blockTunes)
{
$rule = $this->rules->tools[$blockType];

return [
'type' => $blockType,
'data' => $this->sanitize($rule, $blockData)
'data' => $this->sanitize($rule, $blockData),
'tunes' => $blockTunes
];
}

Expand Down
6 changes: 5 additions & 1 deletion EditorJS/EditorJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ public function getBlocks()
$sanitizedBlocks = [];

foreach ($this->blocks as $block) {
$sanitizedBlock = $this->handler->sanitizeBlock($block['type'], $block['data']);
$sanitizedBlock = $this->handler->sanitizeBlock(
$block['type'],
$block['data'],
$block["tunes"] ?? []
);
if (!empty($sanitizedBlock)) {
array_push($sanitizedBlocks, $sanitizedBlock);
}
Expand Down

0 comments on commit 9446738

Please sign in to comment.