UNPKG

@opentiny/fluent-editor

Version:

A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.

53 lines (52 loc) 1.58 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const Quill = require("quill"); const editor_utils = require("../config/editor.utils.cjs.js"); const BlockEmbed = Quill.imports["blots/block/embed"]; const VIDEO_ATTRIBUTES = ["id", "title", "src"]; class Video extends BlockEmbed { static sanitize(url) { return editor_utils.sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL; } static create(value) { const node = super.create(value); node.setAttribute("contenteditable", "false"); node.setAttribute("controls", "controls"); VIDEO_ATTRIBUTES.forEach((key) => { if (value[key]) { switch (key) { case "src": { const src = Video.sanitize(value[key]); node.setAttribute(key, src); break; } case "title": { node.setAttribute(key, value[key]); break; } default: { node.dataset[key] = value[key]; } } } }); return node; } static value(domNode) { const formats = {}; VIDEO_ATTRIBUTES.forEach((key) => { const value = domNode.getAttribute(key) || domNode.dataset[key]; if (value) { formats[key] = value; } }); return formats; } } Video.blotName = "video"; Video.tagName = "VIDEO"; Video.SANITIZED_URL = "about:blank"; Video.PROTOCOL_WHITELIST = ["http", "https"]; Video.className = "ql-video-item"; exports.default = Video; //# sourceMappingURL=video.cjs.js.map