UNPKG

active-page-vue

Version:

A Vue-based visual page editor component

1,159 lines (968 loc) 347 kB
((typeof self !== 'undefined' ? self : this)["webpackJsonpAsEditor"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpAsEditor"] || []).push([[1],{ /***/ "060d": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createCounterText = exports.inlineListItemElement = exports.getListOwner = undefined; var _Util = __webpack_require__("0ce7"); var _NodeContainer = __webpack_require__("5644"); var _NodeContainer2 = _interopRequireDefault(_NodeContainer); var _TextContainer = __webpack_require__("b654"); var _TextContainer2 = _interopRequireDefault(_TextContainer); var _listStyle = __webpack_require__("7f66"); var _Unicode = __webpack_require__("33c1"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // Margin between the enumeration and the list item content var MARGIN_RIGHT = 7; var ancestorTypes = ['OL', 'UL', 'MENU']; var getListOwner = exports.getListOwner = function getListOwner(container) { var parent = container.parent; if (!parent) { return null; } do { var isAncestor = ancestorTypes.indexOf(parent.tagName) !== -1; if (isAncestor) { return parent; } parent = parent.parent; } while (parent); return container.parent; }; var inlineListItemElement = exports.inlineListItemElement = function inlineListItemElement(node, container, resourceLoader) { var listStyle = container.style.listStyle; if (!listStyle) { return; } var style = node.ownerDocument.defaultView.getComputedStyle(node, null); var wrapper = node.ownerDocument.createElement('html2canvaswrapper'); (0, _Util.copyCSSStyles)(style, wrapper); wrapper.style.position = 'absolute'; wrapper.style.bottom = 'auto'; wrapper.style.display = 'block'; wrapper.style.letterSpacing = 'normal'; switch (listStyle.listStylePosition) { case _listStyle.LIST_STYLE_POSITION.OUTSIDE: wrapper.style.left = 'auto'; wrapper.style.right = node.ownerDocument.defaultView.innerWidth - container.bounds.left - container.style.margin[1].getAbsoluteValue(container.bounds.width) + MARGIN_RIGHT + 'px'; wrapper.style.textAlign = 'right'; break; case _listStyle.LIST_STYLE_POSITION.INSIDE: wrapper.style.left = container.bounds.left - container.style.margin[3].getAbsoluteValue(container.bounds.width) + 'px'; wrapper.style.right = 'auto'; wrapper.style.textAlign = 'left'; break; } var text = void 0; var MARGIN_TOP = container.style.margin[0].getAbsoluteValue(container.bounds.width); var styleImage = listStyle.listStyleImage; if (styleImage) { if (styleImage.method === 'url') { var image = node.ownerDocument.createElement('img'); image.src = styleImage.args[0]; wrapper.style.top = container.bounds.top - MARGIN_TOP + 'px'; wrapper.style.width = 'auto'; wrapper.style.height = 'auto'; wrapper.appendChild(image); } else { var size = parseFloat(container.style.font.fontSize) * 0.5; wrapper.style.top = container.bounds.top - MARGIN_TOP + container.bounds.height - 1.5 * size + 'px'; wrapper.style.width = size + 'px'; wrapper.style.height = size + 'px'; wrapper.style.backgroundImage = style.listStyleImage; } } else if (typeof container.listIndex === 'number') { text = node.ownerDocument.createTextNode(createCounterText(container.listIndex, listStyle.listStyleType, true)); wrapper.appendChild(text); wrapper.style.top = container.bounds.top - MARGIN_TOP + 'px'; } // $FlowFixMe var body = node.ownerDocument.body; body.appendChild(wrapper); if (text) { container.childNodes.push(_TextContainer2.default.fromTextNode(text, container)); body.removeChild(wrapper); } else { // $FlowFixMe container.childNodes.push(new _NodeContainer2.default(wrapper, container, resourceLoader, 0)); } }; var ROMAN_UPPER = { integers: [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1], values: ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'] }; var ARMENIAN = { integers: [9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], values: ['Ք', 'Փ', 'Ւ', 'Ց', 'Ր', 'Տ', 'Վ', 'Ս', 'Ռ', 'Ջ', 'Պ', 'Չ', 'Ո', 'Շ', 'Ն', 'Յ', 'Մ', 'Ճ', 'Ղ', 'Ձ', 'Հ', 'Կ', 'Ծ', 'Խ', 'Լ', 'Ի', 'Ժ', 'Թ', 'Ը', 'Է', 'Զ', 'Ե', 'Դ', 'Գ', 'Բ', 'Ա'] }; var HEBREW = { integers: [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 19, 18, 17, 16, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], values: ['י׳', 'ט׳', 'ח׳', 'ז׳', 'ו׳', 'ה׳', 'ד׳', 'ג׳', 'ב׳', 'א׳', 'ת', 'ש', 'ר', 'ק', 'צ', 'פ', 'ע', 'ס', 'נ', 'מ', 'ל', 'כ', 'יט', 'יח', 'יז', 'טז', 'טו', 'י', 'ט', 'ח', 'ז', 'ו', 'ה', 'ד', 'ג', 'ב', 'א'] }; var GEORGIAN = { integers: [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], values: ['ჵ', 'ჰ', 'ჯ', 'ჴ', 'ხ', 'ჭ', 'წ', 'ძ', 'ც', 'ჩ', 'შ', 'ყ', 'ღ', 'ქ', 'ფ', 'ჳ', 'ტ', 'ს', 'რ', 'ჟ', 'პ', 'ო', 'ჲ', 'ნ', 'მ', 'ლ', 'კ', 'ი', 'თ', 'ჱ', 'ზ', 'ვ', 'ე', 'დ', 'გ', 'ბ', 'ა'] }; var createAdditiveCounter = function createAdditiveCounter(value, min, max, symbols, fallback, suffix) { if (value < min || value > max) { return createCounterText(value, fallback, suffix.length > 0); } return symbols.integers.reduce(function (string, integer, index) { while (value >= integer) { value -= integer; string += symbols.values[index]; } return string; }, '') + suffix; }; var createCounterStyleWithSymbolResolver = function createCounterStyleWithSymbolResolver(value, codePointRangeLength, isNumeric, resolver) { var string = ''; do { if (!isNumeric) { value--; } string = resolver(value) + string; value /= codePointRangeLength; } while (value * codePointRangeLength >= codePointRangeLength); return string; }; var createCounterStyleFromRange = function createCounterStyleFromRange(value, codePointRangeStart, codePointRangeEnd, isNumeric, suffix) { var codePointRangeLength = codePointRangeEnd - codePointRangeStart + 1; return (value < 0 ? '-' : '') + (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, function (codePoint) { return (0, _Unicode.fromCodePoint)(Math.floor(codePoint % codePointRangeLength) + codePointRangeStart); }) + suffix); }; var createCounterStyleFromSymbols = function createCounterStyleFromSymbols(value, symbols) { var suffix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '. '; var codePointRangeLength = symbols.length; return createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, false, function (codePoint) { return symbols[Math.floor(codePoint % codePointRangeLength)]; }) + suffix; }; var CJK_ZEROS = 1 << 0; var CJK_TEN_COEFFICIENTS = 1 << 1; var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2; var CJK_HUNDRED_COEFFICIENTS = 1 << 3; var createCJKCounter = function createCJKCounter(value, numbers, multipliers, negativeSign, suffix, flags) { if (value < -9999 || value > 9999) { return createCounterText(value, _listStyle.LIST_STYLE_TYPE.CJK_DECIMAL, suffix.length > 0); } var tmp = Math.abs(value); var string = suffix; if (tmp === 0) { return numbers[0] + string; } for (var digit = 0; tmp > 0 && digit <= 4; digit++) { var coefficient = tmp % 10; if (coefficient === 0 && (0, _Util.contains)(flags, CJK_ZEROS) && string !== '') { string = numbers[coefficient] + string; } else if (coefficient > 1 || coefficient === 1 && digit === 0 || coefficient === 1 && digit === 1 && (0, _Util.contains)(flags, CJK_TEN_COEFFICIENTS) || coefficient === 1 && digit === 1 && (0, _Util.contains)(flags, CJK_TEN_HIGH_COEFFICIENTS) && value > 100 || coefficient === 1 && digit > 1 && (0, _Util.contains)(flags, CJK_HUNDRED_COEFFICIENTS)) { string = numbers[coefficient] + (digit > 0 ? multipliers[digit - 1] : '') + string; } else if (coefficient === 1 && digit > 0) { string = multipliers[digit - 1] + string; } tmp = Math.floor(tmp / 10); } return (value < 0 ? negativeSign : '') + string; }; var CHINESE_INFORMAL_MULTIPLIERS = '十百千萬'; var CHINESE_FORMAL_MULTIPLIERS = '拾佰仟萬'; var JAPANESE_NEGATIVE = 'マイナス'; var KOREAN_NEGATIVE = '마이너스 '; var createCounterText = exports.createCounterText = function createCounterText(value, type, appendSuffix) { var defaultSuffix = appendSuffix ? '. ' : ''; var cjkSuffix = appendSuffix ? '、' : ''; var koreanSuffix = appendSuffix ? ', ' : ''; switch (type) { case _listStyle.LIST_STYLE_TYPE.DISC: return '•'; case _listStyle.LIST_STYLE_TYPE.CIRCLE: return '◦'; case _listStyle.LIST_STYLE_TYPE.SQUARE: return '◾'; case _listStyle.LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO: var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix); return string.length < 4 ? '0' + string : string; case _listStyle.LIST_STYLE_TYPE.CJK_DECIMAL: return createCounterStyleFromSymbols(value, '〇一二三四五六七八九', cjkSuffix); case _listStyle.LIST_STYLE_TYPE.LOWER_ROMAN: return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, _listStyle.LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase(); case _listStyle.LIST_STYLE_TYPE.UPPER_ROMAN: return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, _listStyle.LIST_STYLE_TYPE.DECIMAL, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.LOWER_GREEK: return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.LOWER_ALPHA: return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.UPPER_ALPHA: return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.ARABIC_INDIC: return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.ARMENIAN: case _listStyle.LIST_STYLE_TYPE.UPPER_ARMENIAN: return createAdditiveCounter(value, 1, 9999, ARMENIAN, _listStyle.LIST_STYLE_TYPE.DECIMAL, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.LOWER_ARMENIAN: return createAdditiveCounter(value, 1, 9999, ARMENIAN, _listStyle.LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase(); case _listStyle.LIST_STYLE_TYPE.BENGALI: return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.CAMBODIAN: case _listStyle.LIST_STYLE_TYPE.KHMER: return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH: return createCounterStyleFromSymbols(value, '子丑寅卯辰巳午未申酉戌亥', cjkSuffix); case _listStyle.LIST_STYLE_TYPE.CJK_HEAVENLY_STEM: return createCounterStyleFromSymbols(value, '甲乙丙丁戊己庚辛壬癸', cjkSuffix); case _listStyle.LIST_STYLE_TYPE.CJK_IDEOGRAPHIC: case _listStyle.LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL: return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS); case _listStyle.LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL: return createCJKCounter(value, '零壹貳參肆伍陸柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS); case _listStyle.LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL: return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS); case _listStyle.LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL: return createCJKCounter(value, '零壹贰叁肆伍陆柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS); case _listStyle.LIST_STYLE_TYPE.JAPANESE_INFORMAL: return createCJKCounter(value, '〇一二三四五六七八九', '十百千万', JAPANESE_NEGATIVE, cjkSuffix, 0); case _listStyle.LIST_STYLE_TYPE.JAPANESE_FORMAL: return createCJKCounter(value, '零壱弐参四伍六七八九', '拾百千万', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS); case _listStyle.LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL: return createCJKCounter(value, '영일이삼사오육칠팔구', '십백천만', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS); case _listStyle.LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL: return createCJKCounter(value, '零一二三四五六七八九', '十百千萬', KOREAN_NEGATIVE, koreanSuffix, 0); case _listStyle.LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL: return createCJKCounter(value, '零壹貳參四五六七八九', '拾百千', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS); case _listStyle.LIST_STYLE_TYPE.DEVANAGARI: return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.GEORGIAN: return createAdditiveCounter(value, 1, 19999, GEORGIAN, _listStyle.LIST_STYLE_TYPE.DECIMAL, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.GUJARATI: return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.GURMUKHI: return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.HEBREW: return createAdditiveCounter(value, 1, 10999, HEBREW, _listStyle.LIST_STYLE_TYPE.DECIMAL, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.HIRAGANA: return createCounterStyleFromSymbols(value, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん'); case _listStyle.LIST_STYLE_TYPE.HIRAGANA_IROHA: return createCounterStyleFromSymbols(value, 'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす'); case _listStyle.LIST_STYLE_TYPE.KANNADA: return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.KATAKANA: return createCounterStyleFromSymbols(value, 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン', cjkSuffix); case _listStyle.LIST_STYLE_TYPE.KATAKANA_IROHA: return createCounterStyleFromSymbols(value, 'イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス', cjkSuffix); case _listStyle.LIST_STYLE_TYPE.LAO: return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.MONGOLIAN: return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.MYANMAR: return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.ORIYA: return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.PERSIAN: return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.TAMIL: return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.TELUGU: return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.THAI: return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.TIBETAN: return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix); case _listStyle.LIST_STYLE_TYPE.DECIMAL: default: return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix); } }; /***/ }), /***/ "078d": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ANGLE = /([+-]?\d*\.?\d+)(deg|grad|rad|turn)/i; var parseAngle = exports.parseAngle = function parseAngle(angle) { var match = angle.match(ANGLE); if (match) { var value = parseFloat(match[1]); switch (match[2].toLowerCase()) { case 'deg': return Math.PI * value / 180; case 'grad': return Math.PI / 200 * value; case 'rad': return value; case 'turn': return Math.PI * 2 * value; } } return null; }; /***/ }), /***/ "0ce7": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var contains = exports.contains = function contains(bit, value) { return (bit & value) !== 0; }; var distance = exports.distance = function distance(a, b) { return Math.sqrt(a * a + b * b); }; var copyCSSStyles = exports.copyCSSStyles = function copyCSSStyles(style, target) { // Edge does not provide value for cssText for (var i = style.length - 1; i >= 0; i--) { var property = style.item(i); // Safari shows pseudoelements if content is set if (property !== 'content') { target.style.setProperty(property, style.getPropertyValue(property)); } } return target; }; var SMALL_IMAGE = exports.SMALL_IMAGE = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; /***/ }), /***/ "0d1b": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Path = __webpack_require__("f804"); var _Vector = __webpack_require__("120f"); var _Vector2 = _interopRequireDefault(_Vector); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var lerp = function lerp(a, b, t) { return new _Vector2.default(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }; var BezierCurve = function () { function BezierCurve(start, startControl, endControl, end) { _classCallCheck(this, BezierCurve); this.type = _Path.PATH.BEZIER_CURVE; this.start = start; this.startControl = startControl; this.endControl = endControl; this.end = end; } _createClass(BezierCurve, [{ key: 'subdivide', value: function subdivide(t, firstHalf) { var ab = lerp(this.start, this.startControl, t); var bc = lerp(this.startControl, this.endControl, t); var cd = lerp(this.endControl, this.end, t); var abbc = lerp(ab, bc, t); var bccd = lerp(bc, cd, t); var dest = lerp(abbc, bccd, t); return firstHalf ? new BezierCurve(this.start, ab, abbc, dest) : new BezierCurve(dest, bccd, cd, this.end); } }, { key: 'reverse', value: function reverse() { return new BezierCurve(this.end, this.endControl, this.startControl, this.start); } }]); return BezierCurve; }(); exports.default = BezierCurve; /***/ }), /***/ "0da8": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var OVERFLOW = exports.OVERFLOW = { VISIBLE: 0, HIDDEN: 1, SCROLL: 2, AUTO: 3 }; var parseOverflow = exports.parseOverflow = function parseOverflow(overflow) { switch (overflow) { case 'hidden': return OVERFLOW.HIDDEN; case 'scroll': return OVERFLOW.SCROLL; case 'auto': return OVERFLOW.AUTO; case 'visible': default: return OVERFLOW.VISIBLE; } }; /***/ }), /***/ "120f": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _Path = __webpack_require__("f804"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Vector = function Vector(x, y) { _classCallCheck(this, Vector); this.type = _Path.PATH.VECTOR; this.x = x; this.y = y; if (false) {} }; exports.default = Vector; /***/ }), /***/ "14ee": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ResourceStore = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Feature = __webpack_require__("510e"); var _Feature2 = _interopRequireDefault(_Feature); var _Proxy = __webpack_require__("66a3"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ResourceLoader = function () { function ResourceLoader(options, logger, window) { _classCallCheck(this, ResourceLoader); this.options = options; this._window = window; this.origin = this.getOrigin(window.location.href); this.cache = {}; this.logger = logger; this._index = 0; } _createClass(ResourceLoader, [{ key: 'loadImage', value: function loadImage(src) { var _this = this; if (this.hasResourceInCache(src)) { return src; } if (!isSVG(src) || _Feature2.default.SUPPORT_SVG_DRAWING) { if (this.options.allowTaint === true || isInlineImage(src) || this.isSameOrigin(src)) { return this.addImage(src, src, false); } else if (!this.isSameOrigin(src)) { if (typeof this.options.proxy === 'string') { this.cache[src] = (0, _Proxy.Proxy)(src, this.options).then(function (src) { return _loadImage(src, _this.options.imageTimeout || 0); }); return src; } else if (this.options.useCORS === true && _Feature2.default.SUPPORT_CORS_IMAGES) { return this.addImage(src, src, true); } } } } }, { key: 'inlineImage', value: function inlineImage(src) { var _this2 = this; if (isInlineImage(src)) { return _loadImage(src, this.options.imageTimeout || 0); } if (this.hasResourceInCache(src)) { return this.cache[src]; } if (!this.isSameOrigin(src) && typeof this.options.proxy === 'string') { return this.cache[src] = (0, _Proxy.Proxy)(src, this.options).then(function (src) { return _loadImage(src, _this2.options.imageTimeout || 0); }); } return this.xhrImage(src); } }, { key: 'xhrImage', value: function xhrImage(src) { var _this3 = this; this.cache[src] = new Promise(function (resolve, reject) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status !== 200) { reject('Failed to fetch image ' + src.substring(0, 256) + ' with status code ' + xhr.status); } else { var reader = new FileReader(); reader.addEventListener('load', function () { // $FlowFixMe var result = reader.result; resolve(result); }, false); reader.addEventListener('error', function (e) { return reject(e); }, false); reader.readAsDataURL(xhr.response); } } }; xhr.responseType = 'blob'; if (_this3.options.imageTimeout) { var timeout = _this3.options.imageTimeout; xhr.timeout = timeout; xhr.ontimeout = function () { return reject( false ? undefined : ''); }; } xhr.open('GET', src, true); xhr.send(); }).then(function (src) { return _loadImage(src, _this3.options.imageTimeout || 0); }); return this.cache[src]; } }, { key: 'loadCanvas', value: function loadCanvas(node) { var key = String(this._index++); this.cache[key] = Promise.resolve(node); return key; } }, { key: 'hasResourceInCache', value: function hasResourceInCache(key) { return typeof this.cache[key] !== 'undefined'; } }, { key: 'addImage', value: function addImage(key, src, useCORS) { var _this4 = this; if (false) {} var imageLoadHandler = function imageLoadHandler(supportsDataImages) { return new Promise(function (resolve, reject) { var img = new Image(); img.onload = function () { return resolve(img); }; //ios safari 10.3 taints canvas with data urls unless crossOrigin is set to anonymous if (!supportsDataImages || useCORS) { img.crossOrigin = 'anonymous'; } img.onerror = reject; img.src = src; if (img.complete === true) { // Inline XML images may fail to parse, throwing an Error later on setTimeout(function () { resolve(img); }, 500); } if (_this4.options.imageTimeout) { var timeout = _this4.options.imageTimeout; setTimeout(function () { return reject( false ? undefined : ''); }, timeout); } }); }; this.cache[key] = isInlineBase64Image(src) && !isSVG(src) ? // $FlowFixMe _Feature2.default.SUPPORT_BASE64_DRAWING(src).then(imageLoadHandler) : imageLoadHandler(true); return key; } }, { key: 'isSameOrigin', value: function isSameOrigin(url) { return this.getOrigin(url) === this.origin; } }, { key: 'getOrigin', value: function getOrigin(url) { var link = this._link || (this._link = this._window.document.createElement('a')); link.href = url; link.href = link.href; // IE9, LOL! - http://jsfiddle.net/niklasvh/2e48b/ return link.protocol + link.hostname + link.port; } }, { key: 'ready', value: function ready() { var _this5 = this; var keys = Object.keys(this.cache); var values = keys.map(function (str) { return _this5.cache[str].catch(function (e) { if (false) {} return null; }); }); return Promise.all(values).then(function (images) { if (false) {} return new ResourceStore(keys, images); }); } }]); return ResourceLoader; }(); exports.default = ResourceLoader; var ResourceStore = exports.ResourceStore = function () { function ResourceStore(keys, resources) { _classCallCheck(this, ResourceStore); this._keys = keys; this._resources = resources; } _createClass(ResourceStore, [{ key: 'get', value: function get(key) { var index = this._keys.indexOf(key); return index === -1 ? null : this._resources[index]; } }]); return ResourceStore; }(); var INLINE_SVG = /^data:image\/svg\+xml/i; var INLINE_BASE64 = /^data:image\/.*;base64,/i; var INLINE_IMG = /^data:image\/.*/i; var isInlineImage = function isInlineImage(src) { return INLINE_IMG.test(src); }; var isInlineBase64Image = function isInlineBase64Image(src) { return INLINE_BASE64.test(src); }; var isSVG = function isSVG(src) { return src.substr(-3).toLowerCase() === 'svg' || INLINE_SVG.test(src); }; var _loadImage = function _loadImage(src, timeout) { return new Promise(function (resolve, reject) { var img = new Image(); img.onload = function () { return resolve(img); }; img.onerror = reject; img.src = src; if (img.complete === true) { // Inline XML images may fail to parse, throwing an Error later on setTimeout(function () { resolve(img); }, 500); } if (timeout) { setTimeout(function () { return reject( false ? undefined : ''); }, timeout); } }); }; /***/ }), /***/ "1a3d": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Bounds = __webpack_require__("f137"); var _Font = __webpack_require__("9cb7"); var _Gradient = __webpack_require__("9d66"); var _TextContainer = __webpack_require__("b654"); var _TextContainer2 = _interopRequireDefault(_TextContainer); var _background = __webpack_require__("e21a"); var _border = __webpack_require__("9462"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Renderer = function () { function Renderer(target, options) { _classCallCheck(this, Renderer); this.target = target; this.options = options; target.render(options); } _createClass(Renderer, [{ key: 'renderNode', value: function renderNode(container) { if (container.isVisible()) { this.renderNodeBackgroundAndBorders(container); this.renderNodeContent(container); } } }, { key: 'renderNodeContent', value: function renderNodeContent(container) { var _this = this; var callback = function callback() { if (container.childNodes.length) { container.childNodes.forEach(function (child) { if (child instanceof _TextContainer2.default) { var style = child.parent.style; _this.target.renderTextNode(child.bounds, style.color, style.font, style.textDecoration, style.textShadow); } else { _this.target.drawShape(child, container.style.color); } }); } if (container.image) { var _image = _this.options.imageStore.get(container.image); if (_image) { var contentBox = (0, _Bounds.calculateContentBox)(container.bounds, container.style.padding, container.style.border); var _width = typeof _image.width === 'number' && _image.width > 0 ? _image.width : contentBox.width; var _height = typeof _image.height === 'number' && _image.height > 0 ? _image.height : contentBox.height; if (_width > 0 && _height > 0) { _this.target.clip([(0, _Bounds.calculatePaddingBoxPath)(container.curvedBounds)], function () { _this.target.drawImage(_image, new _Bounds.Bounds(0, 0, _width, _height), contentBox); }); } } } }; var paths = container.getClipPaths(); if (paths.length) { this.target.clip(paths, callback); } else { callback(); } } }, { key: 'renderNodeBackgroundAndBorders', value: function renderNodeBackgroundAndBorders(container) { var _this2 = this; var HAS_BACKGROUND = !container.style.background.backgroundColor.isTransparent() || container.style.background.backgroundImage.length; var hasRenderableBorders = container.style.border.some(function (border) { return border.borderStyle !== _border.BORDER_STYLE.NONE && !border.borderColor.isTransparent(); }); var callback = function callback() { var backgroundPaintingArea = (0, _background.calculateBackgroungPaintingArea)(container.curvedBounds, container.style.background.backgroundClip); if (HAS_BACKGROUND) { _this2.target.clip([backgroundPaintingArea], function () { if (!container.style.background.backgroundColor.isTransparent()) { _this2.target.fill(container.style.background.backgroundColor); } _this2.renderBackgroundImage(container); }); } container.style.border.forEach(function (border, side) { if (border.borderStyle !== _border.BORDER_STYLE.NONE && !border.borderColor.isTransparent()) { _this2.renderBorder(border, side, container.curvedBounds); } }); }; if (HAS_BACKGROUND || hasRenderableBorders) { var paths = container.parent ? container.parent.getClipPaths() : []; if (paths.length) { this.target.clip(paths, callback); } else { callback(); } } } }, { key: 'renderBackgroundImage', value: function renderBackgroundImage(container) { var _this3 = this; container.style.background.backgroundImage.slice(0).reverse().forEach(function (backgroundImage) { if (backgroundImage.source.method === 'url' && backgroundImage.source.args.length) { _this3.renderBackgroundRepeat(container, backgroundImage); } else if (/gradient/i.test(backgroundImage.source.method)) { _this3.renderBackgroundGradient(container, backgroundImage); } }); } }, { key: 'renderBackgroundRepeat', value: function renderBackgroundRepeat(container, background) { var image = this.options.imageStore.get(background.source.args[0]); if (image) { var backgroundPositioningArea = (0, _background.calculateBackgroungPositioningArea)(container.style.background.backgroundOrigin, container.bounds, container.style.padding, container.style.border); var backgroundImageSize = (0, _background.calculateBackgroundSize)(background, image, backgroundPositioningArea); var position = (0, _background.calculateBackgroundPosition)(background.position, backgroundImageSize, backgroundPositioningArea); var _path = (0, _background.calculateBackgroundRepeatPath)(background, position, backgroundImageSize, backgroundPositioningArea, container.bounds); var _offsetX = Math.round(backgroundPositioningArea.left + position.x); var _offsetY = Math.round(backgroundPositioningArea.top + position.y); this.target.renderRepeat(_path, image, backgroundImageSize, _offsetX, _offsetY); } } }, { key: 'renderBackgroundGradient', value: function renderBackgroundGradient(container, background) { var backgroundPositioningArea = (0, _background.calculateBackgroungPositioningArea)(container.style.background.backgroundOrigin, container.bounds, container.style.padding, container.style.border); var backgroundImageSize = (0, _background.calculateGradientBackgroundSize)(background, backgroundPositioningArea); var position = (0, _background.calculateBackgroundPosition)(background.position, backgroundImageSize, backgroundPositioningArea); var gradientBounds = new _Bounds.Bounds(Math.round(backgroundPositioningArea.left + position.x), Math.round(backgroundPositioningArea.top + position.y), backgroundImageSize.width, backgroundImageSize.height); var gradient = (0, _Gradient.parseGradient)(container, background.source, gradientBounds); if (gradient) { switch (gradient.type) { case _Gradient.GRADIENT_TYPE.LINEAR_GRADIENT: // $FlowFixMe this.target.renderLinearGradient(gradientBounds, gradient); break; case _Gradient.GRADIENT_TYPE.RADIAL_GRADIENT: // $FlowFixMe this.target.renderRadialGradient(gradientBounds, gradient); break; } } } }, { key: 'renderBorder', value: function renderBorder(border, side, curvePoints) { this.target.drawShape((0, _Bounds.parsePathForBorder)(curvePoints, side), border.borderColor); } }, { key: 'renderStack', value: function renderStack(stack) { var _this4 = this; if (stack.container.isVisible()) { var _opacity = stack.getOpacity(); if (_opacity !== this._opacity) { this.target.setOpacity(stack.getOpacity()); this._opacity = _opacity; } var _transform = stack.container.style.transform; if (_transform !== null) { this.target.transform(stack.container.bounds.left + _transform.transformOrigin[0].value, stack.container.bounds.top + _transform.transformOrigin[1].value, _transform.transform, function () { return _this4.renderStackContent(stack); }); } else { this.renderStackContent(stack); } } } }, { key: 'renderStackContent', value: function renderStackContent(stack) { var _splitStackingContext = splitStackingContexts(stack), _splitStackingContext2 = _slicedToArray(_splitStackingContext, 5), negativeZIndex = _splitStackingContext2[0], zeroOrAutoZIndexOrTransformedOrOpacity = _splitStackingContext2[1], positiveZIndex = _splitStackingContext2[2], nonPositionedFloats = _splitStackingContext2[3], nonPositionedInlineLevel = _splitStackingContext2[4]; var _splitDescendants = splitDescendants(stack), _splitDescendants2 = _slicedToArray(_splitDescendants, 2), inlineLevel = _splitDescendants2[0], nonInlineLevel = _splitDescendants2[1]; // https://www.w3.org/TR/css-position-3/#painting-order // 1. the background and borders of the element forming the stacking context. this.renderNodeBackgroundAndBorders(stack.container); // 2. the child stacking contexts with negative stack levels (most negative first). negativeZIndex.sort(sortByZIndex).forEach(this.renderStack, this); // 3. For all its in-flow, non-positioned, block-level descendants in tree order: this.renderNodeContent(stack.container); nonInlineLevel.forEach(this.renderNode, this); // 4. All non-positioned floating descendants, in tree order. For each one of these, // treat the element as if it created a new stacking context, but any positioned descendants and descendants // which actually create a new stacking context should be considered part of the parent stacking context, // not this new one. nonPositionedFloats.forEach(this.renderStack, this); // 5. the in-flow, inline-level, non-positioned descendants, including inline tables and inline blocks. nonPositionedInlineLevel.forEach(this.renderStack, this); inlineLevel.forEach(this.renderNode, this); // 6. All positioned, opacity or transform descendants, in tree order that fall into the following categories: // All positioned descendants with 'z-index: auto' or 'z-index: 0', in tree order. // For those with 'z-index: auto', treat the element as if it created a new stacking context, // but any positioned descendants and descendants which actually create a new stacking context should be // considered part of the parent stacking context, not this new one. For those with 'z-index: 0', // treat the stacking context generated atomically. // // All opacity descendants with opacity less than 1 // // All transform descendants with transform other than none zeroOrAutoZIndexOrTransformedOrOpacity.forEach(this.renderStack, this); // 7. Stacking contexts formed by positioned descendants with z-indices greater than or equal to 1 in z-index // order (smallest first) then tree order. positiveZIndex.sort(sortByZIndex).forEach(this.renderStack, this); } }, { key: 'render', value: function render(stack) { var _this5 = this; if (this.options.backgroundColor) { this.target.rectangle(this.options.x, this.options.y, this.options.width, this.options.height, this.options.backgroundColor); } this.renderStack(stack); var target = this.target.getTarget(); if (false) {} return target; } }]); return Renderer; }(); exports.default = Renderer; var splitDescendants = function splitDescendants(stack) { var inlineLevel = []; var nonInlineLevel = []; var length = stack.children.length; for (var i = 0; i < length; i++) { var child = stack.children[i]; if (child.isInlineLevel()) { inlineLevel.push(child); } else { nonInlineLevel.push(child); } } return [inlineLevel, nonInlineLevel]; }; var splitStackingContexts = function splitStackingContexts(stack) { var negativeZIndex = []; var zeroOrAutoZIndexOrTransformedOrOpacity = []; var positiveZIndex = []; var nonPositionedFloats = []; var nonPositionedInlineLevel = []; var length = stack.contexts.length; for (var i = 0; i < length; i++) { var child = stack.contexts[i]; if (child.container.isPositioned() || child.container.style.opacity < 1 || child.container.isTransformed()) { if (child.container.style.zIndex.order < 0) { negativeZIndex.push(child); } else if (child.container.style.zIndex.order > 0) { positiveZIndex.push(child); } else { zeroOrAutoZIndexOrTransformedOrOpacity.push(child); } } else { if (child.container.isFloating()) { nonPositionedFloats.push(child); } else { nonPositionedInlineLevel.push(child); } } } return [negativeZIndex, zeroOrAutoZIndexOrTransformedOrOpacity, positiveZIndex, nonPositionedFloats, nonPositionedInlineLevel]; }; var sortByZIndex = function sortByZIndex(a, b) { if (a.container.style.zIndex.order > b.container.style.zIndex.order) { return 1; } else if (a.container.style.zIndex.order < b.container.style.zIndex.order) { return -1; } return a.container.index > b.container.index ? 1 : -1; }; /***/ }), /***/ "1b11": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseTextBounds = exports.TextBounds = undefined; var _Bounds = __webpack_require__("f137"); var _textDecoration = __webpack_require__("a2a2"); var _Feature = __webpack_require__("510e"); var _Feature2 = _interopRequireDefault(_Feature); var _Unicode = __webpack_require__("33c1"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TextBounds = exports.TextBounds = function TextBounds(text, bounds) { _classCallCheck(this, TextBounds); this.text = text; this.bounds = bounds; }; var parseTextBounds = exports.parseTextBounds = function parseTextBounds(value, parent, node) { var letterRendering = parent.style.letterSpacing !== 0; var textList = letterRendering ? (0, _Unicode.toCodePoints)(value).map(function (i) { return (0, _Unicode.fromCodePoint)(i); }) : (0, _Unicode.breakWords)(value, parent); var length = textList.length; var defaultView = node.parentNode ? node.parentNode.ownerDocument.defaultView : null; var scrollX = defaultView ? defaultView.pageXOffset : 0; var scrollY = defaultView ? defaultView.pageYOffset : 0; var textBounds = []; var offset = 0; for (var i = 0; i < length; i++) { var text = textList[i]; if (parent.style.textDecoration !== _textDecoration.TEXT_DECORATION.NONE || text.trim().length > 0) { if (_Feature2.default.SUPPORT_RANGE_BOUNDS) { textBounds.push(new TextBounds(text, getRangeBounds(node, offset, text.length, scrollX, scrollY))); } else { var replacementNode = node.splitText(text.length); textBounds.push(new TextBounds(text, getWrapperBounds(node, scrollX, scroll