相关疑难解决方法(0)

将youtube视频网址转换为嵌入代码

我正在使用它将youtube网址转换为嵌入网址.

text(t).html().replace(/(?:http:\/\/)?(?:www\.)?(?:youtube\.com)\/(?:watch\?v=)?(.+)/g, '<iframe width="320" height="280" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>')
Run Code Online (Sandbox Code Playgroud)

我怎么能让它自己忽略?

t = $('<div></div>').text(t).html().replace(/(?:http:\/\/)?(?:www\.)?(?:youtube\.com)\/(?:watch\?v=)?(.+)/g, '<iframe width="400" height="380" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>')
Run Code Online (Sandbox Code Playgroud)

和嵌入式链接

<iframe width="560" height="315" src="//www.youtube.com/embed/1adfD9" frameborder="0" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)

或者,换句话说,我怎样才能使它只在这样的链接上工作而忽略其他一切?

http://www.youtube.com/watch?v=1adfD9
www.youtube.com/watch?v=1adfD9
youtube.com/watch?v=1adfD9
Run Code Online (Sandbox Code Playgroud)

javascript jquery

49
推荐指数
5
解决办法
6万
查看次数

CKEditor 5 显示视频元素,但插入 div 中的纯 HTML 不显示该元素

我正在创建一个课程编辑器。用户可以编辑内容(文本、视频、链接、图像等)或查看最终结果(渲染的 html)。

\n\n

编辑器工作正常,但是当我显示渲染的 html 时,链接的 YouTube 视频不可见。

\n\n

这是编辑器部分,您可以看到链接的视频可见:

\n\n

在此输入图像描述

\n\n

这是“渲染”版本;视频丢失(看起来它没有渲染标签figureoembed标签,但为什么?):

\n\n

在此输入图像描述

\n\n

html 是:

\n\n
<h2>This is the header of this section</h2>\n<figure class="media">\n<oembed url="https://www.youtube.com/watch?v=7km4EHgkQiw&amp;list=RDQK-Z1K67uaA&amp;index=9"></oembed>\n</figure>\n\n<p>Please let the student introduce himself.</p><blockquote><p>&nbsp; \xe2\x80\x98I was in no mood for talk and I was unpleasantly surprised to find Judy Poovey brushing her teeth at the sink. [\xe2\x80\xa6]<br>\xe2\x80\x98Hi, Richard,\xe2\x80\x99 she said, and spit out a mouthful of toothpaste. She was wearing cut-off jeans that had bizarre, frantic designs drawn …
Run Code Online (Sandbox Code Playgroud)

html javascript reactjs ckeditor5

8
推荐指数
1
解决办法
7980
查看次数

标签 统计

javascript ×2

ckeditor5 ×1

html ×1

jquery ×1

reactjs ×1