我正在使用 CKEDITOR 5 与文档工具栏
进行 react 。
当我使用媒体嵌入图标插入 YouTube 视频时,我可以正确地看到 YouTube 视频,因为 html 包含 iframe
但当我保存它时,html 变成这样:
<figure class="media">
<oembed url="https://www.youtube.com/watch?v=H08tGjXNHO4"></oembed></figure>
在ckeditor中它说
Currently, the preview is only available for content providers for which CKEditor 5 can predict the code: YouTube, Vimeo, Dailymotion, Spotify, etc. For other providers like Twitter or Instagram the editor cannot produce an code and it does not, so far, allow retrieving this code from an external oEmbed service.
所以我应该有 iframe
标签,但它没有。
有什么想法吗?
最佳答案
我也遇到了同样的问题。我从 CKEDITOR 获得了 oembed 字符串。我使用这个配置解决了这个问题:
editorConfig = {
toolbar: [....],
mediaEmbed: {
previewsInData: true
}
}
在这种情况下,CKEDITOR 返回的不是 oembed 字符串,而是 iframe。只需保存并按原样显示即可。 看 https://ckeditor.com/docs/ckeditor5/latest/features/media-embed.html#semantic-data-output-default
关于javascript - CKEDITOR5如何插入youtube视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57490383/