Hello,
It seems that Kirby doesn’t want me to store an html iframe in a block text field created programmatically :
$preparedBlock = new Kirby\Cms\Block([
'content' => [
'text' => nl2br($incomingBlock->content->text),
'width' => $incomingBlock->content->width,
'height' => $incomingBlock->content->height,
'transform' => $incomingBlock->content->transform,
'zindex' => (int)$incomingBlock->content->zindex,
'backgroundcolor' => $incomingBlock->content->backgroundcolor,
'textcolor' => $incomingBlock->content->textcolor,
'refs' => $incomingBlock->content->refs
],
'id' => $incomingBlock->id,
'type' => 'text'
]);
It doesn’t work if text
is <iframe src="https://player.vimeo.com/video/181043785?h=b7f7bbb9ea" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen="" width="640" height="360" frameborder="0"></iframe>
while it works if I replace all <
and >
by some random characters. For the moment, I make it works like this, by replacing all <
and >
before creating the block and reinstall them before displaying it.
A Vue computed data is parsing the text before displaying the block :
parsedText: function() {
const iframedText = this.block.content.text.replaceAll('::', '<').replaceAll('&&', '>')
return iframedText
}
Any idea to improve this code ?
Thanks for your help