Quill插入html5的video标签
2018-11-27 20:59 zhoujie 阅读(3261) 评论(0) 编辑 收藏 举报quill的video模块插入的是iframe标签,我们需要的是video标签。
1、定义自己的video模块
declare const require: any; const Quill = require('quill'); var BlockEmbed = Quill.import('blots/block/embed'); export class Video extends BlockEmbed { static create(value) { var node = super.create(value); node.setAttribute('src', value); node.setAttribute('width', '100%'); node.setAttribute("controls","controls"); return node; } static value(node) { return node.getAttribute('src'); } } Video.blotName = 'video'; Video.tagName = 'Video'; Video.className = 'ql-video';
2、调用:
import { Video } from './quill-video'; declare var require: any; const Quill = require('quill'); Quill.register({ 'formats/video': Video }, true);
----------------------踩空分割线------------------
最开始写了下面的代码,倒是变成video标签了,但是不能播放:
var video = Quill.import("formats/video"); video.tagName = "video"; Quill.register(video, true); console.log(video);