UNPKG

@elliemae/ds-wysiwygeditor

Version:

Ellie Mae - Dim Sum - WYSIWYG Editor

55 lines (43 loc) 2.51 kB
import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck'; import _createClass from '@babel/runtime/helpers/esm/createClass'; import _get from '@babel/runtime/helpers/esm/get'; import _inherits from '@babel/runtime/helpers/esm/inherits'; import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn'; import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf'; import { Quill } from 'react-quill'; 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; } } var Parchment = Quill.import('parchment'); var levels = [1, 2, 3, 4, 5]; var multiplier = 2; var IndentAttributor = /*#__PURE__*/function (_Parchment$Attributor) { _inherits(IndentAttributor, _Parchment$Attributor); var _super = _createSuper(IndentAttributor); function IndentAttributor() { _classCallCheck(this, IndentAttributor); return _super.apply(this, arguments); } _createClass(IndentAttributor, [{ key: "add", value: function add(node, value) { return _get(_getPrototypeOf(IndentAttributor.prototype), "add", this).call(this, node, "".concat(value * multiplier, "em")); } }, { key: "value", value: function value(node) { return parseFloat(_get(_getPrototypeOf(IndentAttributor.prototype), "value", this).call(this, node)) / multiplier || undefined; // Don't return NaN } }]); return IndentAttributor; }(Parchment.Attributor.Style); /** * Meant to override quill's indent format's style and add the indentation inline instead of applying a class */ var IndentStyle = new IndentAttributor('indent', 'margin-left', { scope: Parchment.Scope.BLOCK, whitelist: levels.map(function (value) { return "".concat(value * multiplier, "em"); }) }); export default IndentStyle; //# sourceMappingURL=IndentStyle.js.map