最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - CKEditor 5 showing video element, but plain HTML inserted in a div does not show the element - Stack Overflow

programmeradmin4浏览0评论

I am creating a lesson editor. The user can edit the content (text, videos, links, images etc) or view the final result (the rendered html).

The editor works fine, but when I show the rendered html the linked youtube videos are not visible.

This is the editor part, as you can see the video linked is visible:

And this is the 'rendered' version; the video is missing (it looks like it's not rendering the figure tag and the oembed tag, but why?):

The html is:

<h2>This is the header of this section</h2>
<figure class="media">
<oembed url=";amp;list=RDQK-Z1K67uaA&amp;index=9"></oembed>
</figure>

<p>Please let the student introduce himself.</p><blockquote><p>&nbsp; ‘I was in no mood for talk and I was unpleasantly surprised to find Judy Poovey brushing her teeth at the sink. […]<br>‘Hi, Richard,’ she said, and spit out a mouthful of toothpaste. She was wearing cut-off jeans that had bizarre, frantic designs drawn on them in Magic Marker and a spandex top which revealed her intensely aerobicized midriff.<br>‘Hello,’ I said, setting to work on my tie.<br>‘You look cute today.’<br>‘Thanks.’<br>‘Got a date?’<br>I looked away from the mirror, at her. ‘What?’<br>‘Where you going?’<br>By now I was used to her interrogations.’ (pp. 51-52)</p></blockquote>

<figure class="media">
<oembed url=";amp;list=RDQK-Z1K67uaA&amp;index=9">
</oembed>
</figure>

I am creating a lesson editor. The user can edit the content (text, videos, links, images etc) or view the final result (the rendered html).

The editor works fine, but when I show the rendered html the linked youtube videos are not visible.

This is the editor part, as you can see the video linked is visible:

And this is the 'rendered' version; the video is missing (it looks like it's not rendering the figure tag and the oembed tag, but why?):

The html is:

<h2>This is the header of this section</h2>
<figure class="media">
<oembed url="https://www.youtube./watch?v=7km4EHgkQiw&amp;list=RDQK-Z1K67uaA&amp;index=9"></oembed>
</figure>

<p>Please let the student introduce himself.</p><blockquote><p>&nbsp; ‘I was in no mood for talk and I was unpleasantly surprised to find Judy Poovey brushing her teeth at the sink. […]<br>‘Hi, Richard,’ she said, and spit out a mouthful of toothpaste. She was wearing cut-off jeans that had bizarre, frantic designs drawn on them in Magic Marker and a spandex top which revealed her intensely aerobicized midriff.<br>‘Hello,’ I said, setting to work on my tie.<br>‘You look cute today.’<br>‘Thanks.’<br>‘Got a date?’<br>I looked away from the mirror, at her. ‘What?’<br>‘Where you going?’<br>By now I was used to her interrogations.’ (pp. 51-52)</p></blockquote>

<figure class="media">
<oembed url="https://www.youtube./watch?v=7km4EHgkQiw&amp;list=RDQK-Z1K67uaA&amp;index=9">
</oembed>
</figure>
Share Improve this question asked Aug 2, 2019 at 5:00 devamatdevamat 2,5038 gold badges33 silver badges56 bronze badges 1
  • Read this ckeditor./docs/ckeditor5/latest/features/… – Jaspreet Singh Commented Aug 11, 2019 at 12:10
Add a ment  | 

1 Answer 1

Reset to default 16

You need to update your CKEditor configuration for the Media embed plugin. By setting previewsInData to true the produced HTML is functionally equivalent to what you see in the CKEditor at design time.

Include the following line in the configuration.

mediaEmbed: {previewsInData: true}

If this is not what you are looking for then you need to transform the output either server side or client side as the produced HTML from CKEditor only produces semantic output. The CKEditor documentation remends using a tools including Iframely or Embedly to do this but you can do it any way you wish.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论