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.

57 lines (56 loc) 1.99 kB
"use strict"; var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const Quill = require("quill"); const editor_utils = require("../config/editor.utils.cjs.js"); const BlockEmbed = Quill.import("blots/block/embed"); const VIDEO_ATTRIBUTES = ["id", "title", "src"]; const _Video = 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; } }; __publicField(_Video, "blotName", "video"); __publicField(_Video, "tagName", "VIDEO"); __publicField(_Video, "SANITIZED_URL", "about:blank"); __publicField(_Video, "PROTOCOL_WHITELIST", ["http", "https", "blob"]); __publicField(_Video, "className", "ql-video"); let Video = _Video; exports.Video = Video; //# sourceMappingURL=video.cjs.js.map