Skip to content

Commit 84c6d7d

Browse files
author
Edward
committed
Added caption for Embed block
1 parent e783dd9 commit 84c6d7d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Parser.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,8 @@ private function parseLink($block)
240240

241241
private function parseEmbed($block)
242242
{
243-
$wrapper = $this->dom->createElement('div');
244-
245-
$wrapper->setAttribute('class', "{$this->prefix}-embed");
243+
$figure = $this->dom->createElement('figure');
244+
$figure->setAttribute('class', $block->type);
246245

247246
switch ($block->data->service) {
248247
case 'youtube':
@@ -254,22 +253,25 @@ private function parseEmbed($block)
254253
'allowfullscreen' => true
255254
];
256255

257-
$wrapper->appendChild($this->createIframe($attrs));
258-
259256
break;
260-
case 'codepen' || 'gfycat':
257+
// case 'codepen' || 'gfycat':
258+
default:
261259

262260
$attrs = [
263261
'height' => $block->data->height,
264262
'src' => $block->data->embed,
265263
];
264+
}
266265

267-
$wrapper->appendChild($this->createIframe($attrs));
266+
$figure->appendChild($this->createIframe($attrs));
268267

269-
break;
268+
if ($block->data->caption) {
269+
$figCaption = $this->dom->createElement('figcaption');
270+
$figCaption->appendChild($this->html5->loadHTMLFragment($block->data->caption));
271+
$figure->appendChild($figCaption);
270272
}
271273

272-
$this->dom->appendChild($wrapper);
274+
$this->dom->appendChild($figure);
273275
}
274276

275277
private function createIframe(array $attrs)

0 commit comments

Comments
 (0)