UNPKG

@makeen.io/material-ui-kit

Version:
46 lines (21 loc) 2.89 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";import _createClass from "@babel/runtime/helpers/createClass";import _get from "@babel/runtime/helpers/get";import _inherits from "@babel/runtime/helpers/inherits";import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";function _createSuper(Derived) {var hasNativeReflectConstruct = _isNativeReflectConstruct();return function _createSuperInternal() {var Super = _getPrototypeOf(Derived),result;if (hasNativeReflectConstruct) {var NewTarget = _getPrototypeOf(this).constructor;result = Reflect.construct(Super, arguments, NewTarget);} else {result = Super.apply(this, arguments);}return _possibleConstructorReturn(this, result);};}function _isNativeReflectConstruct() {if (typeof Reflect === "undefined" || !Reflect.construct) return false;if (Reflect.construct.sham) return false;if (typeof Proxy === "function") return true;try {Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));return true;} catch (e) {return false;}}import { Quill } from "react-quill"; var ATTRIBUTES = ["alt", "height", "width", "style"]; var ParchmentEmbed = Quill.import("blots/block/embed");var ImageWithStyle = /*#__PURE__*/function (_ParchmentEmbed) {_inherits(ImageWithStyle, _ParchmentEmbed);var _super = _createSuper(ImageWithStyle);function ImageWithStyle() {_classCallCheck(this, ImageWithStyle);return _super.apply(this, arguments);}_createClass(ImageWithStyle, [{ key: "format", value: function format( name, value) { if (ATTRIBUTES.indexOf(name) > -1) { if (value) { this.domNode.setAttribute(name, value); } else { this.domNode.removeAttribute(name); } } else { _get(_getPrototypeOf(ImageWithStyle.prototype), "format", this).call(this, name, value); } } }], [{ key: "create", value: function create(value) {var node = _get(_getPrototypeOf(ImageWithStyle), "create", this).call(this, value);if (typeof value === "string") {node.setAttribute("src", this.sanitize(value));}return node;} }, { key: "formats", value: function formats(domNode) {return ATTRIBUTES.reduce(function (formats, attribute) {if (domNode.hasAttribute(attribute)) {formats[attribute] = domNode.getAttribute(attribute);}return formats;}, {});} }, { key: "match", value: function match(url) {return /\.(jpe?g|gif|png)$/.test(url) || /^data:image\/.+;base64/.test(url);} }, { key: "sanitize", value: function sanitize(url) {return url;} }, { key: "value", value: function value(domNode) {return domNode.getAttribute("src");} }]);return ImageWithStyle;}(ParchmentEmbed); ImageWithStyle.blotName = "imagewithstyle"; ImageWithStyle.tagName = "IMG"; export default ImageWithStyle; //# sourceMappingURL=styledImage.js.map