@toast-ui/editor 3.0.2 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +4 -4
  2. package/dist/esm/i18n/ar.js +7 -0
  3. package/dist/esm/i18n/cs-cz.js +7 -0
  4. package/dist/esm/i18n/de-de.js +7 -0
  5. package/dist/esm/i18n/en-us.js +7 -0
  6. package/dist/esm/i18n/es-es.js +7 -0
  7. package/dist/esm/i18n/fi-fi.js +7 -0
  8. package/dist/esm/i18n/fr-fr.js +7 -0
  9. package/dist/esm/i18n/gl-es.js +7 -0
  10. package/dist/esm/i18n/hr-hr.js +7 -0
  11. package/dist/esm/i18n/i18n.js +15 -4
  12. package/dist/esm/i18n/it-it.js +7 -0
  13. package/dist/esm/i18n/ja-jp.js +7 -0
  14. package/dist/esm/i18n/ko-kr.js +7 -0
  15. package/dist/esm/i18n/nb-no.js +7 -0
  16. package/dist/esm/i18n/nl-nl.js +7 -0
  17. package/dist/esm/i18n/pl-pl.js +7 -0
  18. package/dist/esm/i18n/pt-br.js +7 -0
  19. package/dist/esm/i18n/ru-ru.js +7 -0
  20. package/dist/esm/i18n/sv-se.js +7 -0
  21. package/dist/esm/i18n/tr-tr.js +7 -0
  22. package/dist/esm/i18n/uk-ua.js +7 -0
  23. package/dist/esm/i18n/zh-cn.js +7 -0
  24. package/dist/esm/i18n/zh-tw.js +7 -0
  25. package/dist/esm/index.js +2885 -426
  26. package/dist/esm/indexViewer.js +1672 -297
  27. package/dist/i18n/ar.js +1 -1
  28. package/dist/i18n/cs-cz.js +1 -1
  29. package/dist/i18n/de-de.js +1 -1
  30. package/dist/i18n/es-es.js +1 -1
  31. package/dist/i18n/fi-fi.js +1 -1
  32. package/dist/i18n/fr-fr.js +1 -1
  33. package/dist/i18n/gl-es.js +1 -1
  34. package/dist/i18n/hr-hr.js +1 -1
  35. package/dist/i18n/it-it.js +1 -1
  36. package/dist/i18n/ja-jp.js +1 -1
  37. package/dist/i18n/ko-kr.js +1 -1
  38. package/dist/i18n/nb-no.js +1 -1
  39. package/dist/i18n/nl-nl.js +1 -1
  40. package/dist/i18n/pl-pl.js +1 -1
  41. package/dist/i18n/pt-br.js +1 -1
  42. package/dist/i18n/ru-ru.js +1 -1
  43. package/dist/i18n/sv-se.js +1 -1
  44. package/dist/i18n/tr-tr.js +1 -1
  45. package/dist/i18n/uk-ua.js +1 -1
  46. package/dist/i18n/zh-cn.js +1 -1
  47. package/dist/i18n/zh-tw.js +1 -1
  48. package/dist/toastui-editor-only.css +22 -16
  49. package/dist/toastui-editor-viewer.css +10 -2
  50. package/dist/toastui-editor-viewer.js +1823 -370
  51. package/dist/toastui-editor.css +31 -17
  52. package/dist/toastui-editor.js +2853 -318
  53. package/package.json +5 -1
  54. package/types/editor.d.ts +6 -4
  55. package/types/event.d.ts +1 -0
  56. package/types/index.d.ts +4 -3
  57. package/types/toastui-editor-viewer.d.ts +39 -0
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @toast-ui/editor
3
- * @version 3.0.2 | Wed Aug 04 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -15,12 +15,1416 @@
15
15
  root["toastui"] = root["toastui"] || {}, root["toastui"]["Editor"] = factory(root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined]);
16
16
  })(self, function(__WEBPACK_EXTERNAL_MODULE__818__, __WEBPACK_EXTERNAL_MODULE__168__, __WEBPACK_EXTERNAL_MODULE__925__, __WEBPACK_EXTERNAL_MODULE__703__, __WEBPACK_EXTERNAL_MODULE__959__, __WEBPACK_EXTERNAL_MODULE__676__, __WEBPACK_EXTERNAL_MODULE__747__, __WEBPACK_EXTERNAL_MODULE__754__) {
17
17
  return /******/ (function() { // webpackBootstrap
18
- /******/ "use strict";
19
18
  /******/ var __webpack_modules__ = ({
20
19
 
20
+ /***/ 368:
21
+ /***/ (function(module) {
22
+
23
+ /*! @license DOMPurify 2.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.3/LICENSE */
24
+
25
+ (function (global, factory) {
26
+ true ? module.exports = factory() :
27
+ 0;
28
+ }(this, function () { 'use strict';
29
+
30
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
31
+
32
+ var hasOwnProperty = Object.hasOwnProperty,
33
+ setPrototypeOf = Object.setPrototypeOf,
34
+ isFrozen = Object.isFrozen,
35
+ getPrototypeOf = Object.getPrototypeOf,
36
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
37
+ var freeze = Object.freeze,
38
+ seal = Object.seal,
39
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
40
+
41
+ var _ref = typeof Reflect !== 'undefined' && Reflect,
42
+ apply = _ref.apply,
43
+ construct = _ref.construct;
44
+
45
+ if (!apply) {
46
+ apply = function apply(fun, thisValue, args) {
47
+ return fun.apply(thisValue, args);
48
+ };
49
+ }
50
+
51
+ if (!freeze) {
52
+ freeze = function freeze(x) {
53
+ return x;
54
+ };
55
+ }
56
+
57
+ if (!seal) {
58
+ seal = function seal(x) {
59
+ return x;
60
+ };
61
+ }
62
+
63
+ if (!construct) {
64
+ construct = function construct(Func, args) {
65
+ return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))();
66
+ };
67
+ }
68
+
69
+ var arrayForEach = unapply(Array.prototype.forEach);
70
+ var arrayPop = unapply(Array.prototype.pop);
71
+ var arrayPush = unapply(Array.prototype.push);
72
+
73
+ var stringToLowerCase = unapply(String.prototype.toLowerCase);
74
+ var stringMatch = unapply(String.prototype.match);
75
+ var stringReplace = unapply(String.prototype.replace);
76
+ var stringIndexOf = unapply(String.prototype.indexOf);
77
+ var stringTrim = unapply(String.prototype.trim);
78
+
79
+ var regExpTest = unapply(RegExp.prototype.test);
80
+
81
+ var typeErrorCreate = unconstruct(TypeError);
82
+
83
+ function unapply(func) {
84
+ return function (thisArg) {
85
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
86
+ args[_key - 1] = arguments[_key];
87
+ }
88
+
89
+ return apply(func, thisArg, args);
90
+ };
91
+ }
92
+
93
+ function unconstruct(func) {
94
+ return function () {
95
+ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
96
+ args[_key2] = arguments[_key2];
97
+ }
98
+
99
+ return construct(func, args);
100
+ };
101
+ }
102
+
103
+ /* Add properties to a lookup table */
104
+ function addToSet(set, array) {
105
+ if (setPrototypeOf) {
106
+ // Make 'in' and truthy checks like Boolean(set.constructor)
107
+ // independent of any properties defined on Object.prototype.
108
+ // Prevent prototype setters from intercepting set as a this value.
109
+ setPrototypeOf(set, null);
110
+ }
111
+
112
+ var l = array.length;
113
+ while (l--) {
114
+ var element = array[l];
115
+ if (typeof element === 'string') {
116
+ var lcElement = stringToLowerCase(element);
117
+ if (lcElement !== element) {
118
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
119
+ if (!isFrozen(array)) {
120
+ array[l] = lcElement;
121
+ }
122
+
123
+ element = lcElement;
124
+ }
125
+ }
126
+
127
+ set[element] = true;
128
+ }
129
+
130
+ return set;
131
+ }
132
+
133
+ /* Shallow clone an object */
134
+ function clone(object) {
135
+ var newObject = create(null);
136
+
137
+ var property = void 0;
138
+ for (property in object) {
139
+ if (apply(hasOwnProperty, object, [property])) {
140
+ newObject[property] = object[property];
141
+ }
142
+ }
143
+
144
+ return newObject;
145
+ }
146
+
147
+ /* IE10 doesn't support __lookupGetter__ so lets'
148
+ * simulate it. It also automatically checks
149
+ * if the prop is function or getter and behaves
150
+ * accordingly. */
151
+ function lookupGetter(object, prop) {
152
+ while (object !== null) {
153
+ var desc = getOwnPropertyDescriptor(object, prop);
154
+ if (desc) {
155
+ if (desc.get) {
156
+ return unapply(desc.get);
157
+ }
158
+
159
+ if (typeof desc.value === 'function') {
160
+ return unapply(desc.value);
161
+ }
162
+ }
163
+
164
+ object = getPrototypeOf(object);
165
+ }
166
+
167
+ function fallbackValue(element) {
168
+ console.warn('fallback value for', element);
169
+ return null;
170
+ }
171
+
172
+ return fallbackValue;
173
+ }
174
+
175
+ var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
176
+
177
+ // SVG
178
+ var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
179
+
180
+ var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
181
+
182
+ // List of SVG elements that are disallowed by default.
183
+ // We still need to know them so that we can do namespace
184
+ // checks properly in case one wants to add them to
185
+ // allow-list.
186
+ var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
187
+
188
+ var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']);
189
+
190
+ // Similarly to SVG, we want to know all MathML elements,
191
+ // even those that we disallow by default.
192
+ var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
193
+
194
+ var text = freeze(['#text']);
195
+
196
+ var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
197
+
198
+ var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
199
+
200
+ var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
201
+
202
+ var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
203
+
204
+ // eslint-disable-next-line unicorn/better-regex
205
+ var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
206
+ var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm);
207
+ var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
208
+ var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
209
+ var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
210
+ );
211
+ var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
212
+ var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
213
+ );
214
+
215
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
216
+
217
+ function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
218
+
219
+ var getGlobal = function getGlobal() {
220
+ return typeof window === 'undefined' ? null : window;
221
+ };
222
+
223
+ /**
224
+ * Creates a no-op policy for internal use only.
225
+ * Don't export this function outside this module!
226
+ * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
227
+ * @param {Document} document The document object (to determine policy name suffix)
228
+ * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
229
+ * are not supported).
230
+ */
231
+ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
232
+ if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
233
+ return null;
234
+ }
235
+
236
+ // Allow the callers to control the unique policy name
237
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
238
+ // Policy creation with duplicate names throws in Trusted Types.
239
+ var suffix = null;
240
+ var ATTR_NAME = 'data-tt-policy-suffix';
241
+ if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
242
+ suffix = document.currentScript.getAttribute(ATTR_NAME);
243
+ }
244
+
245
+ var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
246
+
247
+ try {
248
+ return trustedTypes.createPolicy(policyName, {
249
+ createHTML: function createHTML(html$$1) {
250
+ return html$$1;
251
+ }
252
+ });
253
+ } catch (_) {
254
+ // Policy creation failed (most likely another DOMPurify script has
255
+ // already run). Skip creating the policy, as this will only cause errors
256
+ // if TT are enforced.
257
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
258
+ return null;
259
+ }
260
+ };
261
+
262
+ function createDOMPurify() {
263
+ var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
264
+
265
+ var DOMPurify = function DOMPurify(root) {
266
+ return createDOMPurify(root);
267
+ };
268
+
269
+ /**
270
+ * Version label, exposed for easier checks
271
+ * if DOMPurify is up to date or not
272
+ */
273
+ DOMPurify.version = '2.3.3';
274
+
275
+ /**
276
+ * Array of elements that DOMPurify removed during sanitation.
277
+ * Empty if nothing was removed.
278
+ */
279
+ DOMPurify.removed = [];
280
+
281
+ if (!window || !window.document || window.document.nodeType !== 9) {
282
+ // Not running in a browser, provide a factory function
283
+ // so that you can pass your own Window
284
+ DOMPurify.isSupported = false;
285
+
286
+ return DOMPurify;
287
+ }
288
+
289
+ var originalDocument = window.document;
290
+
291
+ var document = window.document;
292
+ var DocumentFragment = window.DocumentFragment,
293
+ HTMLTemplateElement = window.HTMLTemplateElement,
294
+ Node = window.Node,
295
+ Element = window.Element,
296
+ NodeFilter = window.NodeFilter,
297
+ _window$NamedNodeMap = window.NamedNodeMap,
298
+ NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
299
+ Text = window.Text,
300
+ Comment = window.Comment,
301
+ DOMParser = window.DOMParser,
302
+ trustedTypes = window.trustedTypes;
303
+
304
+
305
+ var ElementPrototype = Element.prototype;
306
+
307
+ var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
308
+ var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
309
+ var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
310
+ var getParentNode = lookupGetter(ElementPrototype, 'parentNode');
311
+
312
+ // As per issue #47, the web-components registry is inherited by a
313
+ // new document created via createHTMLDocument. As per the spec
314
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
315
+ // a new empty registry is used when creating a template contents owner
316
+ // document, so we use that as our parent document to ensure nothing
317
+ // is inherited.
318
+ if (typeof HTMLTemplateElement === 'function') {
319
+ var template = document.createElement('template');
320
+ if (template.content && template.content.ownerDocument) {
321
+ document = template.content.ownerDocument;
322
+ }
323
+ }
324
+
325
+ var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
326
+ var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : '';
327
+
328
+ var _document = document,
329
+ implementation = _document.implementation,
330
+ createNodeIterator = _document.createNodeIterator,
331
+ createDocumentFragment = _document.createDocumentFragment,
332
+ getElementsByTagName = _document.getElementsByTagName;
333
+ var importNode = originalDocument.importNode;
334
+
335
+
336
+ var documentMode = {};
337
+ try {
338
+ documentMode = clone(document).documentMode ? document.documentMode : {};
339
+ } catch (_) {}
340
+
341
+ var hooks = {};
342
+
343
+ /**
344
+ * Expose whether this browser supports running the full DOMPurify.
345
+ */
346
+ DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
347
+
348
+ var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR,
349
+ ERB_EXPR$$1 = ERB_EXPR,
350
+ DATA_ATTR$$1 = DATA_ATTR,
351
+ ARIA_ATTR$$1 = ARIA_ATTR,
352
+ IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA,
353
+ ATTR_WHITESPACE$$1 = ATTR_WHITESPACE;
354
+ var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI;
355
+
356
+ /**
357
+ * We consider the elements and attributes below to be safe. Ideally
358
+ * don't add any new ones but feel free to remove unwanted ones.
359
+ */
360
+
361
+ /* allowed element names */
362
+
363
+ var ALLOWED_TAGS = null;
364
+ var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text)));
365
+
366
+ /* Allowed attribute names */
367
+ var ALLOWED_ATTR = null;
368
+ var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml)));
369
+
370
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
371
+ var FORBID_TAGS = null;
372
+
373
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
374
+ var FORBID_ATTR = null;
375
+
376
+ /* Decide if ARIA attributes are okay */
377
+ var ALLOW_ARIA_ATTR = true;
378
+
379
+ /* Decide if custom data attributes are okay */
380
+ var ALLOW_DATA_ATTR = true;
381
+
382
+ /* Decide if unknown protocols are okay */
383
+ var ALLOW_UNKNOWN_PROTOCOLS = false;
384
+
385
+ /* Output should be safe for common template engines.
386
+ * This means, DOMPurify removes data attributes, mustaches and ERB
387
+ */
388
+ var SAFE_FOR_TEMPLATES = false;
389
+
390
+ /* Decide if document with <html>... should be returned */
391
+ var WHOLE_DOCUMENT = false;
392
+
393
+ /* Track whether config is already set on this instance of DOMPurify. */
394
+ var SET_CONFIG = false;
395
+
396
+ /* Decide if all elements (e.g. style, script) must be children of
397
+ * document.body. By default, browsers might move them to document.head */
398
+ var FORCE_BODY = false;
399
+
400
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
401
+ * string (or a TrustedHTML object if Trusted Types are supported).
402
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
403
+ */
404
+ var RETURN_DOM = false;
405
+
406
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
407
+ * string (or a TrustedHTML object if Trusted Types are supported) */
408
+ var RETURN_DOM_FRAGMENT = false;
409
+
410
+ /* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM
411
+ * `Node` is imported into the current `Document`. If this flag is not enabled the
412
+ * `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by
413
+ * DOMPurify.
414
+ *
415
+ * This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false`
416
+ * might cause XSS from attacks hidden in closed shadowroots in case the browser
417
+ * supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/
418
+ */
419
+ var RETURN_DOM_IMPORT = true;
420
+
421
+ /* Try to return a Trusted Type object instead of a string, return a string in
422
+ * case Trusted Types are not supported */
423
+ var RETURN_TRUSTED_TYPE = false;
424
+
425
+ /* Output should be free from DOM clobbering attacks? */
426
+ var SANITIZE_DOM = true;
427
+
428
+ /* Keep element content when removing element? */
429
+ var KEEP_CONTENT = true;
430
+
431
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
432
+ * of importing it into a new Document and returning a sanitized copy */
433
+ var IN_PLACE = false;
434
+
435
+ /* Allow usage of profiles like html, svg and mathMl */
436
+ var USE_PROFILES = {};
437
+
438
+ /* Tags to ignore content of when KEEP_CONTENT is true */
439
+ var FORBID_CONTENTS = null;
440
+ var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
441
+
442
+ /* Tags that are safe for data: URIs */
443
+ var DATA_URI_TAGS = null;
444
+ var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
445
+
446
+ /* Attributes safe for values like "javascript:" */
447
+ var URI_SAFE_ATTRIBUTES = null;
448
+ var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
449
+
450
+ var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
451
+ var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
452
+ var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
453
+ /* Document namespace */
454
+ var NAMESPACE = HTML_NAMESPACE;
455
+ var IS_EMPTY_INPUT = false;
456
+
457
+ /* Parsing of strict XHTML documents */
458
+ var PARSER_MEDIA_TYPE = void 0;
459
+ var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
460
+ var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
461
+ var transformCaseFunc = void 0;
462
+
463
+ /* Keep a reference to config to pass to hooks */
464
+ var CONFIG = null;
465
+
466
+ /* Ideally, do not touch anything below this line */
467
+ /* ______________________________________________ */
468
+
469
+ var formElement = document.createElement('form');
470
+
471
+ /**
472
+ * _parseConfig
473
+ *
474
+ * @param {Object} cfg optional config literal
475
+ */
476
+ // eslint-disable-next-line complexity
477
+ var _parseConfig = function _parseConfig(cfg) {
478
+ if (CONFIG && CONFIG === cfg) {
479
+ return;
480
+ }
481
+
482
+ /* Shield configuration object from tampering */
483
+ if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') {
484
+ cfg = {};
485
+ }
486
+
487
+ /* Shield configuration object from prototype pollution */
488
+ cfg = clone(cfg);
489
+
490
+ /* Set configuration parameters */
491
+ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS;
492
+ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR;
493
+ URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES;
494
+ DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS;
495
+ FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS) : DEFAULT_FORBID_CONTENTS;
496
+ FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {};
497
+ FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {};
498
+ USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
499
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
500
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
501
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
502
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
503
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
504
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
505
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
506
+ RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true
507
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
508
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
509
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
510
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
511
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
512
+ IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1;
513
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
514
+
515
+ PARSER_MEDIA_TYPE =
516
+ // eslint-disable-next-line unicorn/prefer-includes
517
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
518
+
519
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
520
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
521
+ return x;
522
+ } : stringToLowerCase;
523
+
524
+ if (SAFE_FOR_TEMPLATES) {
525
+ ALLOW_DATA_ATTR = false;
526
+ }
527
+
528
+ if (RETURN_DOM_FRAGMENT) {
529
+ RETURN_DOM = true;
530
+ }
531
+
532
+ /* Parse profile info */
533
+ if (USE_PROFILES) {
534
+ ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text)));
535
+ ALLOWED_ATTR = [];
536
+ if (USE_PROFILES.html === true) {
537
+ addToSet(ALLOWED_TAGS, html);
538
+ addToSet(ALLOWED_ATTR, html$1);
539
+ }
540
+
541
+ if (USE_PROFILES.svg === true) {
542
+ addToSet(ALLOWED_TAGS, svg);
543
+ addToSet(ALLOWED_ATTR, svg$1);
544
+ addToSet(ALLOWED_ATTR, xml);
545
+ }
546
+
547
+ if (USE_PROFILES.svgFilters === true) {
548
+ addToSet(ALLOWED_TAGS, svgFilters);
549
+ addToSet(ALLOWED_ATTR, svg$1);
550
+ addToSet(ALLOWED_ATTR, xml);
551
+ }
552
+
553
+ if (USE_PROFILES.mathMl === true) {
554
+ addToSet(ALLOWED_TAGS, mathMl);
555
+ addToSet(ALLOWED_ATTR, mathMl$1);
556
+ addToSet(ALLOWED_ATTR, xml);
557
+ }
558
+ }
559
+
560
+ /* Merge configuration parameters */
561
+ if (cfg.ADD_TAGS) {
562
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
563
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
564
+ }
565
+
566
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS);
567
+ }
568
+
569
+ if (cfg.ADD_ATTR) {
570
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
571
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
572
+ }
573
+
574
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR);
575
+ }
576
+
577
+ if (cfg.ADD_URI_SAFE_ATTR) {
578
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR);
579
+ }
580
+
581
+ if (cfg.FORBID_CONTENTS) {
582
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
583
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
584
+ }
585
+
586
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS);
587
+ }
588
+
589
+ /* Add #text in case KEEP_CONTENT is set to true */
590
+ if (KEEP_CONTENT) {
591
+ ALLOWED_TAGS['#text'] = true;
592
+ }
593
+
594
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
595
+ if (WHOLE_DOCUMENT) {
596
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
597
+ }
598
+
599
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
600
+ if (ALLOWED_TAGS.table) {
601
+ addToSet(ALLOWED_TAGS, ['tbody']);
602
+ delete FORBID_TAGS.tbody;
603
+ }
604
+
605
+ // Prevent further manipulation of configuration.
606
+ // Not available in IE8, Safari 5, etc.
607
+ if (freeze) {
608
+ freeze(cfg);
609
+ }
610
+
611
+ CONFIG = cfg;
612
+ };
613
+
614
+ var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
615
+
616
+ var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
617
+
618
+ /* Keep track of all possible SVG and MathML tags
619
+ * so that we can perform the namespace checks
620
+ * correctly. */
621
+ var ALL_SVG_TAGS = addToSet({}, svg);
622
+ addToSet(ALL_SVG_TAGS, svgFilters);
623
+ addToSet(ALL_SVG_TAGS, svgDisallowed);
624
+
625
+ var ALL_MATHML_TAGS = addToSet({}, mathMl);
626
+ addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
627
+
628
+ /**
629
+ *
630
+ *
631
+ * @param {Element} element a DOM element whose namespace is being checked
632
+ * @returns {boolean} Return false if the element has a
633
+ * namespace that a spec-compliant parser would never
634
+ * return. Return true otherwise.
635
+ */
636
+ var _checkValidNamespace = function _checkValidNamespace(element) {
637
+ var parent = getParentNode(element);
638
+
639
+ // In JSDOM, if we're inside shadow DOM, then parentNode
640
+ // can be null. We just simulate parent in this case.
641
+ if (!parent || !parent.tagName) {
642
+ parent = {
643
+ namespaceURI: HTML_NAMESPACE,
644
+ tagName: 'template'
645
+ };
646
+ }
647
+
648
+ var tagName = stringToLowerCase(element.tagName);
649
+ var parentTagName = stringToLowerCase(parent.tagName);
650
+
651
+ if (element.namespaceURI === SVG_NAMESPACE) {
652
+ // The only way to switch from HTML namespace to SVG
653
+ // is via <svg>. If it happens via any other tag, then
654
+ // it should be killed.
655
+ if (parent.namespaceURI === HTML_NAMESPACE) {
656
+ return tagName === 'svg';
657
+ }
658
+
659
+ // The only way to switch from MathML to SVG is via
660
+ // svg if parent is either <annotation-xml> or MathML
661
+ // text integration points.
662
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
663
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
664
+ }
665
+
666
+ // We only allow elements that are defined in SVG
667
+ // spec. All others are disallowed in SVG namespace.
668
+ return Boolean(ALL_SVG_TAGS[tagName]);
669
+ }
670
+
671
+ if (element.namespaceURI === MATHML_NAMESPACE) {
672
+ // The only way to switch from HTML namespace to MathML
673
+ // is via <math>. If it happens via any other tag, then
674
+ // it should be killed.
675
+ if (parent.namespaceURI === HTML_NAMESPACE) {
676
+ return tagName === 'math';
677
+ }
678
+
679
+ // The only way to switch from SVG to MathML is via
680
+ // <math> and HTML integration points
681
+ if (parent.namespaceURI === SVG_NAMESPACE) {
682
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
683
+ }
684
+
685
+ // We only allow elements that are defined in MathML
686
+ // spec. All others are disallowed in MathML namespace.
687
+ return Boolean(ALL_MATHML_TAGS[tagName]);
688
+ }
689
+
690
+ if (element.namespaceURI === HTML_NAMESPACE) {
691
+ // The only way to switch from SVG to HTML is via
692
+ // HTML integration points, and from MathML to HTML
693
+ // is via MathML text integration points
694
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
695
+ return false;
696
+ }
697
+
698
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
699
+ return false;
700
+ }
701
+
702
+ // Certain elements are allowed in both SVG and HTML
703
+ // namespace. We need to specify them explicitly
704
+ // so that they don't get erronously deleted from
705
+ // HTML namespace.
706
+ var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
707
+
708
+ // We disallow tags that are specific for MathML
709
+ // or SVG and should never appear in HTML namespace
710
+ return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]);
711
+ }
712
+
713
+ // The code should never reach this place (this means
714
+ // that the element somehow got namespace that is not
715
+ // HTML, SVG or MathML). Return false just in case.
716
+ return false;
717
+ };
718
+
719
+ /**
720
+ * _forceRemove
721
+ *
722
+ * @param {Node} node a DOM node
723
+ */
724
+ var _forceRemove = function _forceRemove(node) {
725
+ arrayPush(DOMPurify.removed, { element: node });
726
+ try {
727
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
728
+ node.parentNode.removeChild(node);
729
+ } catch (_) {
730
+ try {
731
+ node.outerHTML = emptyHTML;
732
+ } catch (_) {
733
+ node.remove();
734
+ }
735
+ }
736
+ };
737
+
738
+ /**
739
+ * _removeAttribute
740
+ *
741
+ * @param {String} name an Attribute name
742
+ * @param {Node} node a DOM node
743
+ */
744
+ var _removeAttribute = function _removeAttribute(name, node) {
745
+ try {
746
+ arrayPush(DOMPurify.removed, {
747
+ attribute: node.getAttributeNode(name),
748
+ from: node
749
+ });
750
+ } catch (_) {
751
+ arrayPush(DOMPurify.removed, {
752
+ attribute: null,
753
+ from: node
754
+ });
755
+ }
756
+
757
+ node.removeAttribute(name);
758
+
759
+ // We void attribute values for unremovable "is"" attributes
760
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
761
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
762
+ try {
763
+ _forceRemove(node);
764
+ } catch (_) {}
765
+ } else {
766
+ try {
767
+ node.setAttribute(name, '');
768
+ } catch (_) {}
769
+ }
770
+ }
771
+ };
772
+
773
+ /**
774
+ * _initDocument
775
+ *
776
+ * @param {String} dirty a string of dirty markup
777
+ * @return {Document} a DOM, filled with the dirty markup
778
+ */
779
+ var _initDocument = function _initDocument(dirty) {
780
+ /* Create a HTML document */
781
+ var doc = void 0;
782
+ var leadingWhitespace = void 0;
783
+
784
+ if (FORCE_BODY) {
785
+ dirty = '<remove></remove>' + dirty;
786
+ } else {
787
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
788
+ var matches = stringMatch(dirty, /^[\r\n\t ]+/);
789
+ leadingWhitespace = matches && matches[0];
790
+ }
791
+
792
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
793
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
794
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
795
+ }
796
+
797
+ var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
798
+ /*
799
+ * Use the DOMParser API by default, fallback later if needs be
800
+ * DOMParser not work for svg when has multiple root element.
801
+ */
802
+ if (NAMESPACE === HTML_NAMESPACE) {
803
+ try {
804
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
805
+ } catch (_) {}
806
+ }
807
+
808
+ /* Use createHTMLDocument in case DOMParser is not available */
809
+ if (!doc || !doc.documentElement) {
810
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
811
+ try {
812
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
813
+ } catch (_) {
814
+ // Syntax error if dirtyPayload is invalid xml
815
+ }
816
+ }
817
+
818
+ var body = doc.body || doc.documentElement;
819
+
820
+ if (dirty && leadingWhitespace) {
821
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
822
+ }
823
+
824
+ /* Work on whole document or just its body */
825
+ if (NAMESPACE === HTML_NAMESPACE) {
826
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
827
+ }
828
+
829
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
830
+ };
831
+
832
+ /**
833
+ * _createIterator
834
+ *
835
+ * @param {Document} root document/fragment to create iterator for
836
+ * @return {Iterator} iterator instance
837
+ */
838
+ var _createIterator = function _createIterator(root) {
839
+ return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
840
+ };
841
+
842
+ /**
843
+ * _isClobbered
844
+ *
845
+ * @param {Node} elm element to check for clobbering attacks
846
+ * @return {Boolean} true if clobbered, false if safe
847
+ */
848
+ var _isClobbered = function _isClobbered(elm) {
849
+ if (elm instanceof Text || elm instanceof Comment) {
850
+ return false;
851
+ }
852
+
853
+ if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') {
854
+ return true;
855
+ }
856
+
857
+ return false;
858
+ };
859
+
860
+ /**
861
+ * _isNode
862
+ *
863
+ * @param {Node} obj object to check whether it's a DOM node
864
+ * @return {Boolean} true is object is a DOM node
865
+ */
866
+ var _isNode = function _isNode(object) {
867
+ return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
868
+ };
869
+
870
+ /**
871
+ * _executeHook
872
+ * Execute user configurable hooks
873
+ *
874
+ * @param {String} entryPoint Name of the hook's entry point
875
+ * @param {Node} currentNode node to work on with the hook
876
+ * @param {Object} data additional hook parameters
877
+ */
878
+ var _executeHook = function _executeHook(entryPoint, currentNode, data) {
879
+ if (!hooks[entryPoint]) {
880
+ return;
881
+ }
882
+
883
+ arrayForEach(hooks[entryPoint], function (hook) {
884
+ hook.call(DOMPurify, currentNode, data, CONFIG);
885
+ });
886
+ };
887
+
888
+ /**
889
+ * _sanitizeElements
890
+ *
891
+ * @protect nodeName
892
+ * @protect textContent
893
+ * @protect removeChild
894
+ *
895
+ * @param {Node} currentNode to check for permission to exist
896
+ * @return {Boolean} true if node was killed, false if left alive
897
+ */
898
+ var _sanitizeElements = function _sanitizeElements(currentNode) {
899
+ var content = void 0;
900
+
901
+ /* Execute a hook if present */
902
+ _executeHook('beforeSanitizeElements', currentNode, null);
903
+
904
+ /* Check if element is clobbered or can clobber */
905
+ if (_isClobbered(currentNode)) {
906
+ _forceRemove(currentNode);
907
+ return true;
908
+ }
909
+
910
+ /* Check if tagname contains Unicode */
911
+ if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) {
912
+ _forceRemove(currentNode);
913
+ return true;
914
+ }
915
+
916
+ /* Now let's check the element's type and name */
917
+ var tagName = transformCaseFunc(currentNode.nodeName);
918
+
919
+ /* Execute a hook if present */
920
+ _executeHook('uponSanitizeElement', currentNode, {
921
+ tagName: tagName,
922
+ allowedTags: ALLOWED_TAGS
923
+ });
924
+
925
+ /* Detect mXSS attempts abusing namespace confusion */
926
+ if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
927
+ _forceRemove(currentNode);
928
+ return true;
929
+ }
930
+
931
+ /* Mitigate a problem with templates inside select */
932
+ if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
933
+ _forceRemove(currentNode);
934
+ return true;
935
+ }
936
+
937
+ /* Remove element if anything forbids its presence */
938
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
939
+ /* Keep content except for bad-listed elements */
940
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
941
+ var parentNode = getParentNode(currentNode) || currentNode.parentNode;
942
+ var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
943
+
944
+ if (childNodes && parentNode) {
945
+ var childCount = childNodes.length;
946
+
947
+ for (var i = childCount - 1; i >= 0; --i) {
948
+ parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
949
+ }
950
+ }
951
+ }
952
+
953
+ _forceRemove(currentNode);
954
+ return true;
955
+ }
956
+
957
+ /* Check whether element has a valid namespace */
958
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
959
+ _forceRemove(currentNode);
960
+ return true;
961
+ }
962
+
963
+ if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
964
+ _forceRemove(currentNode);
965
+ return true;
966
+ }
967
+
968
+ /* Sanitize element content to be template-safe */
969
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
970
+ /* Get the element's text content */
971
+ content = currentNode.textContent;
972
+ content = stringReplace(content, MUSTACHE_EXPR$$1, ' ');
973
+ content = stringReplace(content, ERB_EXPR$$1, ' ');
974
+ if (currentNode.textContent !== content) {
975
+ arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
976
+ currentNode.textContent = content;
977
+ }
978
+ }
979
+
980
+ /* Execute a hook if present */
981
+ _executeHook('afterSanitizeElements', currentNode, null);
982
+
983
+ return false;
984
+ };
985
+
986
+ /**
987
+ * _isValidAttribute
988
+ *
989
+ * @param {string} lcTag Lowercase tag name of containing element.
990
+ * @param {string} lcName Lowercase attribute name.
991
+ * @param {string} value Attribute value.
992
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
993
+ */
994
+ // eslint-disable-next-line complexity
995
+ var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
996
+ /* Make sure attribute cannot clobber */
997
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
998
+ return false;
999
+ }
1000
+
1001
+ /* Allow valid data-* attributes: At least one character after "-"
1002
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1003
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1004
+ We don't need to check the value; it's always URI safe. */
1005
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
1006
+ return false;
1007
+
1008
+ /* Check value is safe. First, is attr inert? If so, is safe */
1009
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else {
1010
+ return false;
1011
+ }
1012
+
1013
+ return true;
1014
+ };
1015
+
1016
+ /**
1017
+ * _sanitizeAttributes
1018
+ *
1019
+ * @protect attributes
1020
+ * @protect nodeName
1021
+ * @protect removeAttribute
1022
+ * @protect setAttribute
1023
+ *
1024
+ * @param {Node} currentNode to sanitize
1025
+ */
1026
+ var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1027
+ var attr = void 0;
1028
+ var value = void 0;
1029
+ var lcName = void 0;
1030
+ var l = void 0;
1031
+ /* Execute a hook if present */
1032
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
1033
+
1034
+ var attributes = currentNode.attributes;
1035
+
1036
+ /* Check if we have attributes; if not we might have a text node */
1037
+
1038
+ if (!attributes) {
1039
+ return;
1040
+ }
1041
+
1042
+ var hookEvent = {
1043
+ attrName: '',
1044
+ attrValue: '',
1045
+ keepAttr: true,
1046
+ allowedAttributes: ALLOWED_ATTR
1047
+ };
1048
+ l = attributes.length;
1049
+
1050
+ /* Go backwards over all attributes; safely remove bad ones */
1051
+ while (l--) {
1052
+ attr = attributes[l];
1053
+ var _attr = attr,
1054
+ name = _attr.name,
1055
+ namespaceURI = _attr.namespaceURI;
1056
+
1057
+ value = stringTrim(attr.value);
1058
+ lcName = transformCaseFunc(name);
1059
+
1060
+ /* Execute a hook if present */
1061
+ hookEvent.attrName = lcName;
1062
+ hookEvent.attrValue = value;
1063
+ hookEvent.keepAttr = true;
1064
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1065
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1066
+ value = hookEvent.attrValue;
1067
+ /* Did the hooks approve of the attribute? */
1068
+ if (hookEvent.forceKeepAttr) {
1069
+ continue;
1070
+ }
1071
+
1072
+ /* Remove attribute */
1073
+ _removeAttribute(name, currentNode);
1074
+
1075
+ /* Did the hooks approve of the attribute? */
1076
+ if (!hookEvent.keepAttr) {
1077
+ continue;
1078
+ }
1079
+
1080
+ /* Work around a security issue in jQuery 3.0 */
1081
+ if (regExpTest(/\/>/i, value)) {
1082
+ _removeAttribute(name, currentNode);
1083
+ continue;
1084
+ }
1085
+
1086
+ /* Sanitize attribute content to be template-safe */
1087
+ if (SAFE_FOR_TEMPLATES) {
1088
+ value = stringReplace(value, MUSTACHE_EXPR$$1, ' ');
1089
+ value = stringReplace(value, ERB_EXPR$$1, ' ');
1090
+ }
1091
+
1092
+ /* Is `value` valid for this attribute? */
1093
+ var lcTag = transformCaseFunc(currentNode.nodeName);
1094
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1095
+ continue;
1096
+ }
1097
+
1098
+ /* Handle invalid data-* attribute set by try-catching it */
1099
+ try {
1100
+ if (namespaceURI) {
1101
+ currentNode.setAttributeNS(namespaceURI, name, value);
1102
+ } else {
1103
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1104
+ currentNode.setAttribute(name, value);
1105
+ }
1106
+
1107
+ arrayPop(DOMPurify.removed);
1108
+ } catch (_) {}
1109
+ }
1110
+
1111
+ /* Execute a hook if present */
1112
+ _executeHook('afterSanitizeAttributes', currentNode, null);
1113
+ };
1114
+
1115
+ /**
1116
+ * _sanitizeShadowDOM
1117
+ *
1118
+ * @param {DocumentFragment} fragment to iterate over recursively
1119
+ */
1120
+ var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
1121
+ var shadowNode = void 0;
1122
+ var shadowIterator = _createIterator(fragment);
1123
+
1124
+ /* Execute a hook if present */
1125
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
1126
+
1127
+ while (shadowNode = shadowIterator.nextNode()) {
1128
+ /* Execute a hook if present */
1129
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
1130
+
1131
+ /* Sanitize tags and elements */
1132
+ if (_sanitizeElements(shadowNode)) {
1133
+ continue;
1134
+ }
1135
+
1136
+ /* Deep shadow DOM detected */
1137
+ if (shadowNode.content instanceof DocumentFragment) {
1138
+ _sanitizeShadowDOM(shadowNode.content);
1139
+ }
1140
+
1141
+ /* Check attributes, sanitize if necessary */
1142
+ _sanitizeAttributes(shadowNode);
1143
+ }
1144
+
1145
+ /* Execute a hook if present */
1146
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
1147
+ };
1148
+
1149
+ /**
1150
+ * Sanitize
1151
+ * Public method providing core sanitation functionality
1152
+ *
1153
+ * @param {String|Node} dirty string or DOM node
1154
+ * @param {Object} configuration object
1155
+ */
1156
+ // eslint-disable-next-line complexity
1157
+ DOMPurify.sanitize = function (dirty, cfg) {
1158
+ var body = void 0;
1159
+ var importedNode = void 0;
1160
+ var currentNode = void 0;
1161
+ var oldNode = void 0;
1162
+ var returnNode = void 0;
1163
+ /* Make sure we have a string to sanitize.
1164
+ DO NOT return early, as this will return the wrong type if
1165
+ the user has requested a DOM object rather than a string */
1166
+ IS_EMPTY_INPUT = !dirty;
1167
+ if (IS_EMPTY_INPUT) {
1168
+ dirty = '<!-->';
1169
+ }
1170
+
1171
+ /* Stringify, in case dirty is an object */
1172
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1173
+ // eslint-disable-next-line no-negated-condition
1174
+ if (typeof dirty.toString !== 'function') {
1175
+ throw typeErrorCreate('toString is not a function');
1176
+ } else {
1177
+ dirty = dirty.toString();
1178
+ if (typeof dirty !== 'string') {
1179
+ throw typeErrorCreate('dirty is not a string, aborting');
1180
+ }
1181
+ }
1182
+ }
1183
+
1184
+ /* Check we can run. Otherwise fall back or ignore */
1185
+ if (!DOMPurify.isSupported) {
1186
+ if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
1187
+ if (typeof dirty === 'string') {
1188
+ return window.toStaticHTML(dirty);
1189
+ }
1190
+
1191
+ if (_isNode(dirty)) {
1192
+ return window.toStaticHTML(dirty.outerHTML);
1193
+ }
1194
+ }
1195
+
1196
+ return dirty;
1197
+ }
1198
+
1199
+ /* Assign config vars */
1200
+ if (!SET_CONFIG) {
1201
+ _parseConfig(cfg);
1202
+ }
1203
+
1204
+ /* Clean up removed elements */
1205
+ DOMPurify.removed = [];
1206
+
1207
+ /* Check if dirty is correctly typed for IN_PLACE */
1208
+ if (typeof dirty === 'string') {
1209
+ IN_PLACE = false;
1210
+ }
1211
+
1212
+ if (IN_PLACE) ; else if (dirty instanceof Node) {
1213
+ /* If dirty is a DOM element, append to an empty document to avoid
1214
+ elements being stripped by the parser */
1215
+ body = _initDocument('<!---->');
1216
+ importedNode = body.ownerDocument.importNode(dirty, true);
1217
+ if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
1218
+ /* Node is already a body, use as is */
1219
+ body = importedNode;
1220
+ } else if (importedNode.nodeName === 'HTML') {
1221
+ body = importedNode;
1222
+ } else {
1223
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1224
+ body.appendChild(importedNode);
1225
+ }
1226
+ } else {
1227
+ /* Exit directly if we have nothing to do */
1228
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
1229
+ // eslint-disable-next-line unicorn/prefer-includes
1230
+ dirty.indexOf('<') === -1) {
1231
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1232
+ }
1233
+
1234
+ /* Initialize the document to work on */
1235
+ body = _initDocument(dirty);
1236
+
1237
+ /* Check we have a DOM node from the data */
1238
+ if (!body) {
1239
+ return RETURN_DOM ? null : emptyHTML;
1240
+ }
1241
+ }
1242
+
1243
+ /* Remove first element node (ours) if FORCE_BODY is set */
1244
+ if (body && FORCE_BODY) {
1245
+ _forceRemove(body.firstChild);
1246
+ }
1247
+
1248
+ /* Get node iterator */
1249
+ var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
1250
+
1251
+ /* Now start iterating over the created document */
1252
+ while (currentNode = nodeIterator.nextNode()) {
1253
+ /* Fix IE's strange behavior with manipulated textNodes #89 */
1254
+ if (currentNode.nodeType === 3 && currentNode === oldNode) {
1255
+ continue;
1256
+ }
1257
+
1258
+ /* Sanitize tags and elements */
1259
+ if (_sanitizeElements(currentNode)) {
1260
+ continue;
1261
+ }
1262
+
1263
+ /* Shadow DOM detected, sanitize it */
1264
+ if (currentNode.content instanceof DocumentFragment) {
1265
+ _sanitizeShadowDOM(currentNode.content);
1266
+ }
1267
+
1268
+ /* Check attributes, sanitize if necessary */
1269
+ _sanitizeAttributes(currentNode);
1270
+
1271
+ oldNode = currentNode;
1272
+ }
1273
+
1274
+ oldNode = null;
1275
+
1276
+ /* If we sanitized `dirty` in-place, return it. */
1277
+ if (IN_PLACE) {
1278
+ return dirty;
1279
+ }
1280
+
1281
+ /* Return sanitized string or DOM */
1282
+ if (RETURN_DOM) {
1283
+ if (RETURN_DOM_FRAGMENT) {
1284
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1285
+
1286
+ while (body.firstChild) {
1287
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1288
+ returnNode.appendChild(body.firstChild);
1289
+ }
1290
+ } else {
1291
+ returnNode = body;
1292
+ }
1293
+
1294
+ if (RETURN_DOM_IMPORT) {
1295
+ /*
1296
+ AdoptNode() is not used because internal state is not reset
1297
+ (e.g. the past names map of a HTMLFormElement), this is safe
1298
+ in theory but we would rather not risk another attack vector.
1299
+ The state that is cloned by importNode() is explicitly defined
1300
+ by the specs.
1301
+ */
1302
+ returnNode = importNode.call(originalDocument, returnNode, true);
1303
+ }
1304
+
1305
+ return returnNode;
1306
+ }
1307
+
1308
+ var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1309
+
1310
+ /* Sanitize final string template-safe */
1311
+ if (SAFE_FOR_TEMPLATES) {
1312
+ serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' ');
1313
+ serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' ');
1314
+ }
1315
+
1316
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1317
+ };
1318
+
1319
+ /**
1320
+ * Public method to set the configuration once
1321
+ * setConfig
1322
+ *
1323
+ * @param {Object} cfg configuration object
1324
+ */
1325
+ DOMPurify.setConfig = function (cfg) {
1326
+ _parseConfig(cfg);
1327
+ SET_CONFIG = true;
1328
+ };
1329
+
1330
+ /**
1331
+ * Public method to remove the configuration
1332
+ * clearConfig
1333
+ *
1334
+ */
1335
+ DOMPurify.clearConfig = function () {
1336
+ CONFIG = null;
1337
+ SET_CONFIG = false;
1338
+ };
1339
+
1340
+ /**
1341
+ * Public method to check if an attribute value is valid.
1342
+ * Uses last set config, if any. Otherwise, uses config defaults.
1343
+ * isValidAttribute
1344
+ *
1345
+ * @param {string} tag Tag name of containing element.
1346
+ * @param {string} attr Attribute name.
1347
+ * @param {string} value Attribute value.
1348
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
1349
+ */
1350
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1351
+ /* Initialize shared config vars if necessary. */
1352
+ if (!CONFIG) {
1353
+ _parseConfig({});
1354
+ }
1355
+
1356
+ var lcTag = transformCaseFunc(tag);
1357
+ var lcName = transformCaseFunc(attr);
1358
+ return _isValidAttribute(lcTag, lcName, value);
1359
+ };
1360
+
1361
+ /**
1362
+ * AddHook
1363
+ * Public method to add DOMPurify hooks
1364
+ *
1365
+ * @param {String} entryPoint entry point for the hook to add
1366
+ * @param {Function} hookFunction function to execute
1367
+ */
1368
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1369
+ if (typeof hookFunction !== 'function') {
1370
+ return;
1371
+ }
1372
+
1373
+ hooks[entryPoint] = hooks[entryPoint] || [];
1374
+ arrayPush(hooks[entryPoint], hookFunction);
1375
+ };
1376
+
1377
+ /**
1378
+ * RemoveHook
1379
+ * Public method to remove a DOMPurify hook at a given entryPoint
1380
+ * (pops it from the stack of hooks if more are present)
1381
+ *
1382
+ * @param {String} entryPoint entry point for the hook to remove
1383
+ */
1384
+ DOMPurify.removeHook = function (entryPoint) {
1385
+ if (hooks[entryPoint]) {
1386
+ arrayPop(hooks[entryPoint]);
1387
+ }
1388
+ };
1389
+
1390
+ /**
1391
+ * RemoveHooks
1392
+ * Public method to remove all DOMPurify hooks at a given entryPoint
1393
+ *
1394
+ * @param {String} entryPoint entry point for the hooks to remove
1395
+ */
1396
+ DOMPurify.removeHooks = function (entryPoint) {
1397
+ if (hooks[entryPoint]) {
1398
+ hooks[entryPoint] = [];
1399
+ }
1400
+ };
1401
+
1402
+ /**
1403
+ * RemoveAllHooks
1404
+ * Public method to remove all DOMPurify hooks
1405
+ *
1406
+ */
1407
+ DOMPurify.removeAllHooks = function () {
1408
+ hooks = {};
1409
+ };
1410
+
1411
+ return DOMPurify;
1412
+ }
1413
+
1414
+ var purify = createDOMPurify();
1415
+
1416
+ return purify;
1417
+
1418
+ }));
1419
+ //# sourceMappingURL=purify.js.map
1420
+
1421
+
1422
+ /***/ }),
1423
+
21
1424
  /***/ 928:
22
1425
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
23
1426
 
1427
+ "use strict";
24
1428
  /* eslint-disable complexity */
25
1429
  /**
26
1430
  * @fileoverview Returns the first index at which a given element can be found in the array.
@@ -46,11 +1450,15 @@ var isArray = __webpack_require__(322);
46
1450
  * @returns {number} the First index at which a given element, or -1 if it is not present
47
1451
  * @memberof module:array
48
1452
  * @example
49
- * var inArray = require('tui-code-snippet/array/inArray'); // node, commonjs
1453
+ * // ES6
1454
+ * import inArray from 'tui-code-snippet/array/inArray';
1455
+ *
1456
+ * // CommonJS
1457
+ * const inArray = require('tui-code-snippet/array/inArray');
50
1458
  *
51
- * var arr = ['one', 'two', 'three', 'four'];
52
- * var idx1 = inArray('one', arr, 3); // -1
53
- * var idx2 = inArray('one', arr); // 0
1459
+ * const arr = ['one', 'two', 'three', 'four'];
1460
+ * const idx1 = inArray('one', arr, 3); // -1
1461
+ * const idx2 = inArray('one', arr); // 0
54
1462
  */
55
1463
  function inArray(searchElement, array, startIndex) {
56
1464
  var i;
@@ -83,6 +1491,7 @@ module.exports = inArray;
83
1491
  /***/ 690:
84
1492
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
85
1493
 
1494
+ "use strict";
86
1495
  /**
87
1496
  * @fileoverview Execute the provided callback once for each property of object(or element of array) which actually exist.
88
1497
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -111,19 +1520,23 @@ var forEachOwnProperties = __webpack_require__(956);
111
1520
  * @param {Object} [context] Context(this) of callback function
112
1521
  * @memberof module:collection
113
1522
  * @example
114
- * var forEach = require('tui-code-snippet/collection/forEach'); // node, commonjs
1523
+ * // ES6
1524
+ * import forEach from 'tui-code-snippet/collection/forEach';
1525
+ *
1526
+ * // CommonJS
1527
+ * const forEach = require('tui-code-snippet/collection/forEach');
115
1528
  *
116
- * var sum = 0;
1529
+ * let sum = 0;
117
1530
  *
118
1531
  * forEach([1,2,3], function(value){
119
- * sum += value;
1532
+ * sum += value;
120
1533
  * });
121
1534
  * alert(sum); // 6
122
1535
  *
123
1536
  * // In case of Array-like object
124
- * var array = Array.prototype.slice.call(arrayLike); // change to array
1537
+ * const array = Array.prototype.slice.call(arrayLike); // change to array
125
1538
  * forEach(array, function(value){
126
- * sum += value;
1539
+ * sum += value;
127
1540
  * });
128
1541
  */
129
1542
  function forEach(obj, iteratee, context) {
@@ -142,6 +1555,7 @@ module.exports = forEach;
142
1555
  /***/ 893:
143
1556
  /***/ (function(module) {
144
1557
 
1558
+ "use strict";
145
1559
  /**
146
1560
  * @fileoverview Execute the provided callback once for each element present in the array(or Array-like object) in ascending order.
147
1561
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -162,12 +1576,16 @@ module.exports = forEach;
162
1576
  * @param {Object} [context] Context(this) of callback function
163
1577
  * @memberof module:collection
164
1578
  * @example
165
- * var forEachArray = require('tui-code-snippet/collection/forEachArray'); // node, commonjs
1579
+ * // ES6
1580
+ * import forEachArray from 'tui-code-snippet/collection/forEachArray';
1581
+ *
1582
+ * // CommonJS
1583
+ * const forEachArray = require('tui-code-snippet/collection/forEachArray');
166
1584
  *
167
- * var sum = 0;
1585
+ * let sum = 0;
168
1586
  *
169
1587
  * forEachArray([1,2,3], function(value){
170
- * sum += value;
1588
+ * sum += value;
171
1589
  * });
172
1590
  * alert(sum); // 6
173
1591
  */
@@ -192,6 +1610,7 @@ module.exports = forEachArray;
192
1610
  /***/ 956:
193
1611
  /***/ (function(module) {
194
1612
 
1613
+ "use strict";
195
1614
  /**
196
1615
  * @fileoverview Execute the provided callback once for each property of object which actually exist.
197
1616
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -211,12 +1630,16 @@ module.exports = forEachArray;
211
1630
  * @param {Object} [context] Context(this) of callback function
212
1631
  * @memberof module:collection
213
1632
  * @example
214
- * var forEachOwnProperties = require('tui-code-snippet/collection/forEachOwnProperties'); // node, commonjs
1633
+ * // ES6
1634
+ * import forEachOwnProperties from 'tui-code-snippet/collection/forEachOwnProperties';
1635
+ *
1636
+ * // CommonJS
1637
+ * const forEachOwnProperties = require('tui-code-snippet/collection/forEachOwnProperties');
215
1638
  *
216
- * var sum = 0;
1639
+ * let sum = 0;
217
1640
  *
218
1641
  * forEachOwnProperties({a:1,b:2,c:3}, function(value){
219
- * sum += value;
1642
+ * sum += value;
220
1643
  * });
221
1644
  * alert(sum); // 6
222
1645
  */
@@ -242,6 +1665,7 @@ module.exports = forEachOwnProperties;
242
1665
  /***/ 990:
243
1666
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
244
1667
 
1668
+ "use strict";
245
1669
  /**
246
1670
  * @fileoverview Transform the Array-like object to Array.
247
1671
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -258,16 +1682,20 @@ var forEachArray = __webpack_require__(893);
258
1682
  * @returns {Array} Array
259
1683
  * @memberof module:collection
260
1684
  * @example
261
- * var toArray = require('tui-code-snippet/collection/toArray'); // node, commonjs
1685
+ * // ES6
1686
+ * import toArray from 'tui-code-snippet/collection/toArray';
1687
+ *
1688
+ * // CommonJS
1689
+ * const toArray = require('tui-code-snippet/collection/toArray');
262
1690
  *
263
- * var arrayLike = {
264
- * 0: 'one',
265
- * 1: 'two',
266
- * 2: 'three',
267
- * 3: 'four',
268
- * length: 4
1691
+ * const arrayLike = {
1692
+ * 0: 'one',
1693
+ * 1: 'two',
1694
+ * 2: 'three',
1695
+ * 3: 'four',
1696
+ * length: 4
269
1697
  * };
270
- * var result = toArray(arrayLike);
1698
+ * const result = toArray(arrayLike);
271
1699
  *
272
1700
  * alert(result instanceof Array); // true
273
1701
  * alert(result); // one,two,three,four
@@ -294,6 +1722,7 @@ module.exports = toArray;
294
1722
  /***/ 755:
295
1723
  /***/ (function(module) {
296
1724
 
1725
+ "use strict";
297
1726
  /**
298
1727
  * @fileoverview Get event collection for specific HTML element
299
1728
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -334,6 +1763,7 @@ module.exports = safeEvent;
334
1763
  /***/ 349:
335
1764
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
336
1765
 
1766
+ "use strict";
337
1767
  /**
338
1768
  * @fileoverview Unbind DOM events
339
1769
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -442,6 +1872,7 @@ module.exports = off;
442
1872
  /***/ 348:
443
1873
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
444
1874
 
1875
+ "use strict";
445
1876
  /**
446
1877
  * @fileoverview Bind DOM events
447
1878
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -462,7 +1893,7 @@ var safeEvent = __webpack_require__(755);
462
1893
  * @param {object} [context] context - context for handler method.
463
1894
  * @memberof module:domEvent
464
1895
  * @example
465
- * var div = document.querySelector('div');
1896
+ * const div = document.querySelector('div');
466
1897
  *
467
1898
  * // Bind one event to an element.
468
1899
  * on(div, 'click', toggle);
@@ -479,10 +1910,10 @@ var safeEvent = __webpack_require__(755);
479
1910
  * });
480
1911
  *
481
1912
  * // Set a context for handler method.
482
- * var name = 'global';
483
- * var repository = {name: 'CodeSnippet'};
1913
+ * const name = 'global';
1914
+ * const repository = {name: 'CodeSnippet'};
484
1915
  * on(div, 'drag', function() {
485
- * console.log(this.name);
1916
+ * console.log(this.name);
486
1917
  * }, repository);
487
1918
  * // Result when you drag a div: "CodeSnippet"
488
1919
  */
@@ -563,6 +1994,7 @@ module.exports = on;
563
1994
  /***/ 24:
564
1995
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
565
1996
 
1997
+ "use strict";
566
1998
  /**
567
1999
  * @fileoverview Set className value
568
2000
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -601,6 +2033,7 @@ module.exports = setClassName;
601
2033
  /***/ 204:
602
2034
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
603
2035
 
2036
+ "use strict";
604
2037
  /**
605
2038
  * @fileoverview Add css class to element
606
2039
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -661,6 +2094,7 @@ module.exports = addClass;
661
2094
  /***/ 522:
662
2095
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
663
2096
 
2097
+ "use strict";
664
2098
  /**
665
2099
  * @fileoverview Setting element style
666
2100
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -700,6 +2134,7 @@ module.exports = css;
700
2134
  /***/ 902:
701
2135
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
702
2136
 
2137
+ "use strict";
703
2138
  /**
704
2139
  * @fileoverview Get HTML element's design classes.
705
2140
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -735,6 +2170,7 @@ module.exports = getClass;
735
2170
  /***/ 714:
736
2171
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
737
2172
 
2173
+ "use strict";
738
2174
  /**
739
2175
  * @fileoverview Check element has specific css class
740
2176
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -772,6 +2208,7 @@ module.exports = hasClass;
772
2208
  /***/ 471:
773
2209
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
774
2210
 
2211
+ "use strict";
775
2212
  /**
776
2213
  * @fileoverview Check element match selector
777
2214
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -812,6 +2249,7 @@ module.exports = matches;
812
2249
  /***/ 462:
813
2250
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
814
2251
 
2252
+ "use strict";
815
2253
  /**
816
2254
  * @fileoverview Remove css class from element
817
2255
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -862,6 +2300,7 @@ module.exports = removeClass;
862
2300
  /***/ 969:
863
2301
  /***/ (function(module) {
864
2302
 
2303
+ "use strict";
865
2304
  /**
866
2305
  * @fileoverview Extend the target object from other objects.
867
2306
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -904,6 +2343,7 @@ module.exports = extend;
904
2343
  /***/ 254:
905
2344
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
906
2345
 
2346
+ "use strict";
907
2347
  /**
908
2348
  * @fileoverview Request image ping.
909
2349
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -924,15 +2364,19 @@ var forEachOwnProperties = __webpack_require__(956);
924
2364
  * @returns {HTMLElement}
925
2365
  * @memberof module:request
926
2366
  * @example
927
- * var imagePing = require('tui-code-snippet/request/imagePing'); // node, commonjs
2367
+ * // ES6
2368
+ * import imagePing from 'tui-code-snippet/request/imagePing';
2369
+ *
2370
+ * // CommonJS
2371
+ * const imagePing = require('tui-code-snippet/request/imagePing');
928
2372
  *
929
2373
  * imagePing('https://www.google-analytics.com/collect', {
930
- * v: 1,
931
- * t: 'event',
932
- * tid: 'trackingid',
933
- * cid: 'cid',
934
- * dp: 'dp',
935
- * dh: 'dh'
2374
+ * v: 1,
2375
+ * t: 'event',
2376
+ * tid: 'trackingid',
2377
+ * cid: 'cid',
2378
+ * dp: 'dp',
2379
+ * dh: 'dh'
936
2380
  * });
937
2381
  */
938
2382
  function imagePing(url, trackingInfo) {
@@ -960,6 +2404,7 @@ module.exports = imagePing;
960
2404
  /***/ 391:
961
2405
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
962
2406
 
2407
+ "use strict";
963
2408
  /**
964
2409
  * @fileoverview Send hostname on DOMContentLoaded.
965
2410
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1035,6 +2480,7 @@ module.exports = sendHostname;
1035
2480
  /***/ 516:
1036
2481
  /***/ (function(module) {
1037
2482
 
2483
+ "use strict";
1038
2484
  /**
1039
2485
  * @fileoverview Creates a debounced function that delays invoking fn until after delay milliseconds has elapsed since the last time the debouced function was invoked.
1040
2486
  * @author NHN FE Development Lab <dl_javascript.nhn.com>
@@ -1054,11 +2500,15 @@ module.exports = sendHostname;
1054
2500
  * @returns {function} debounced function.
1055
2501
  * @memberof module:tricks
1056
2502
  * @example
1057
- * var debounce = require('tui-code-snippet/tricks/debounce'); // node, commonjs
2503
+ * // ES6
2504
+ * import debounce from 'tui-code-snippet/tricks/debounce';
2505
+ *
2506
+ * // CommonJS
2507
+ * const debounce = require('tui-code-snippet/tricks/debounce');
1058
2508
  *
1059
2509
  * function someMethodToInvokeDebounced() {}
1060
2510
  *
1061
- * var debounced = debounce(someMethodToInvokeDebounced, 300);
2511
+ * const debounced = debounce(someMethodToInvokeDebounced, 300);
1062
2512
  *
1063
2513
  * // invoke repeatedly
1064
2514
  * debounced();
@@ -1096,6 +2546,7 @@ module.exports = debounce;
1096
2546
  /***/ 423:
1097
2547
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1098
2548
 
2549
+ "use strict";
1099
2550
  /**
1100
2551
  * @fileoverview Creates a throttled function that only invokes fn at most once per every interval milliseconds.
1101
2552
  * @author NHN FE Development Lab <dl_javascript.nhn.com>
@@ -1114,11 +2565,15 @@ var debounce = __webpack_require__(516);
1114
2565
  * @returns {function} throttled function
1115
2566
  * @memberof module:tricks
1116
2567
  * @example
1117
- * var throttle = require('tui-code-snippet/tricks/throttle'); // node, commonjs
2568
+ * // ES6
2569
+ * import throttle from 'tui-code-snippet/tricks/throttle';
2570
+ *
2571
+ * // CommonJS
2572
+ * const throttle = require('tui-code-snippet/tricks/throttle');
1118
2573
  *
1119
2574
  * function someMethodToInvokeThrottled() {}
1120
2575
  *
1121
- * var throttled = throttle(someMethodToInvokeThrottled, 300);
2576
+ * const throttled = throttle(someMethodToInvokeThrottled, 300);
1122
2577
  *
1123
2578
  * // invoke repeatedly
1124
2579
  * throttled(); // invoke (leading)
@@ -1191,6 +2646,7 @@ module.exports = throttle;
1191
2646
  /***/ 322:
1192
2647
  /***/ (function(module) {
1193
2648
 
2649
+ "use strict";
1194
2650
  /**
1195
2651
  * @fileoverview Check whether the given variable is an instance of Array or not.
1196
2652
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1217,6 +2673,7 @@ module.exports = isArray;
1217
2673
  /***/ 326:
1218
2674
  /***/ (function(module) {
1219
2675
 
2676
+ "use strict";
1220
2677
  /**
1221
2678
  * @fileoverview Check whether the given variable is a string or not.
1222
2679
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1243,6 +2700,7 @@ module.exports = isBoolean;
1243
2700
  /***/ 65:
1244
2701
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1245
2702
 
2703
+ "use strict";
1246
2704
  /**
1247
2705
  * @fileoverview Check whether the given variable is existing or not.
1248
2706
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1260,7 +2718,11 @@ var isNull = __webpack_require__(934);
1260
2718
  * @returns {boolean} Is existy?
1261
2719
  * @memberof module:type
1262
2720
  * @example
1263
- * var isExisty = require('tui-code-snippet/type/isExisty'); // node, commonjs
2721
+ * // ES6
2722
+ * import isExisty from 'tui-code-snippet/type/isExisty');
2723
+ *
2724
+ * // CommonJS
2725
+ * const isExisty = require('tui-code-snippet/type/isExisty');
1264
2726
  *
1265
2727
  * isExisty(''); //true
1266
2728
  * isExisty(0); //true
@@ -1281,6 +2743,7 @@ module.exports = isExisty;
1281
2743
  /***/ 404:
1282
2744
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1283
2745
 
2746
+ "use strict";
1284
2747
  /**
1285
2748
  * @fileoverview Check whether the given variable is falsy or not.
1286
2749
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1309,6 +2772,7 @@ module.exports = isFalsy;
1309
2772
  /***/ 294:
1310
2773
  /***/ (function(module) {
1311
2774
 
2775
+ "use strict";
1312
2776
  /**
1313
2777
  * @fileoverview Check whether the given variable is a function or not.
1314
2778
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1335,6 +2799,7 @@ module.exports = isFunction;
1335
2799
  /***/ 934:
1336
2800
  /***/ (function(module) {
1337
2801
 
2802
+ "use strict";
1338
2803
  /**
1339
2804
  * @fileoverview Check whether the given variable is null or not.
1340
2805
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1361,6 +2826,7 @@ module.exports = isNull;
1361
2826
  /***/ 321:
1362
2827
  /***/ (function(module) {
1363
2828
 
2829
+ "use strict";
1364
2830
  /**
1365
2831
  * @fileoverview Check whether the given variable is a number or not.
1366
2832
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1387,6 +2853,7 @@ module.exports = isNumber;
1387
2853
  /***/ 73:
1388
2854
  /***/ (function(module) {
1389
2855
 
2856
+ "use strict";
1390
2857
  /**
1391
2858
  * @fileoverview Check whether the given variable is an object or not.
1392
2859
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1413,6 +2880,7 @@ module.exports = isObject;
1413
2880
  /***/ 758:
1414
2881
  /***/ (function(module) {
1415
2882
 
2883
+ "use strict";
1416
2884
  /**
1417
2885
  * @fileoverview Check whether the given variable is a string or not.
1418
2886
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1439,6 +2907,7 @@ module.exports = isString;
1439
2907
  /***/ 790:
1440
2908
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1441
2909
 
2910
+ "use strict";
1442
2911
  /**
1443
2912
  * @fileoverview Check whether the given variable is truthy or not.
1444
2913
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1468,6 +2937,7 @@ module.exports = isTruthy;
1468
2937
  /***/ 929:
1469
2938
  /***/ (function(module) {
1470
2939
 
2940
+ "use strict";
1471
2941
  /**
1472
2942
  * @fileoverview Check whether the given variable is undefined or not.
1473
2943
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
@@ -1494,6 +2964,7 @@ module.exports = isUndefined;
1494
2964
  /***/ 818:
1495
2965
  /***/ (function(module) {
1496
2966
 
2967
+ "use strict";
1497
2968
  module.exports = __WEBPACK_EXTERNAL_MODULE__818__;
1498
2969
 
1499
2970
  /***/ }),
@@ -1501,6 +2972,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__818__;
1501
2972
  /***/ 168:
1502
2973
  /***/ (function(module) {
1503
2974
 
2975
+ "use strict";
1504
2976
  module.exports = __WEBPACK_EXTERNAL_MODULE__168__;
1505
2977
 
1506
2978
  /***/ }),
@@ -1508,6 +2980,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__168__;
1508
2980
  /***/ 925:
1509
2981
  /***/ (function(module) {
1510
2982
 
2983
+ "use strict";
1511
2984
  module.exports = __WEBPACK_EXTERNAL_MODULE__925__;
1512
2985
 
1513
2986
  /***/ }),
@@ -1515,6 +2988,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__925__;
1515
2988
  /***/ 703:
1516
2989
  /***/ (function(module) {
1517
2990
 
2991
+ "use strict";
1518
2992
  module.exports = __WEBPACK_EXTERNAL_MODULE__703__;
1519
2993
 
1520
2994
  /***/ }),
@@ -1522,6 +2996,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__703__;
1522
2996
  /***/ 959:
1523
2997
  /***/ (function(module) {
1524
2998
 
2999
+ "use strict";
1525
3000
  module.exports = __WEBPACK_EXTERNAL_MODULE__959__;
1526
3001
 
1527
3002
  /***/ }),
@@ -1529,6 +3004,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__959__;
1529
3004
  /***/ 676:
1530
3005
  /***/ (function(module) {
1531
3006
 
3007
+ "use strict";
1532
3008
  module.exports = __WEBPACK_EXTERNAL_MODULE__676__;
1533
3009
 
1534
3010
  /***/ }),
@@ -1536,6 +3012,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__676__;
1536
3012
  /***/ 747:
1537
3013
  /***/ (function(module) {
1538
3014
 
3015
+ "use strict";
1539
3016
  module.exports = __WEBPACK_EXTERNAL_MODULE__747__;
1540
3017
 
1541
3018
  /***/ }),
@@ -1543,6 +3020,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__747__;
1543
3020
  /***/ 754:
1544
3021
  /***/ (function(module) {
1545
3022
 
3023
+ "use strict";
1546
3024
  module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
1547
3025
 
1548
3026
  /***/ })
@@ -1567,7 +3045,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
1567
3045
  /******/ };
1568
3046
  /******/
1569
3047
  /******/ // Execute the module function
1570
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
3048
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
1571
3049
  /******/
1572
3050
  /******/ // Return the exports of the module
1573
3051
  /******/ return module.exports;
@@ -1617,8 +3095,9 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
1617
3095
  /******/
1618
3096
  /************************************************************************/
1619
3097
  var __webpack_exports__ = {};
1620
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
3098
+ // This entry need to be wrapped in an IIFE because it need to be in strict mode.
1621
3099
  !function() {
3100
+ "use strict";
1622
3101
 
1623
3102
  // EXPORTS
1624
3103
  __webpack_require__.d(__webpack_exports__, {
@@ -1792,10 +3271,14 @@ function __spreadArrays() {
1792
3271
  return r;
1793
3272
  }
1794
3273
 
1795
- function __spreadArray(to, from) {
1796
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1797
- to[j] = from[i];
1798
- return to;
3274
+ function __spreadArray(to, from, pack) {
3275
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3276
+ if (ar || !(i in from)) {
3277
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3278
+ ar[i] = from[i];
3279
+ }
3280
+ }
3281
+ return to.concat(ar || Array.prototype.slice.call(from));
1799
3282
  }
1800
3283
 
1801
3284
  function __await(v) {
@@ -1851,19 +3334,17 @@ function __importDefault(mod) {
1851
3334
  return (mod && mod.__esModule) ? mod : { default: mod };
1852
3335
  }
1853
3336
 
1854
- function __classPrivateFieldGet(receiver, privateMap) {
1855
- if (!privateMap.has(receiver)) {
1856
- throw new TypeError("attempted to get private field on non-instance");
1857
- }
1858
- return privateMap.get(receiver);
3337
+ function __classPrivateFieldGet(receiver, state, kind, f) {
3338
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3339
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3340
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1859
3341
  }
1860
3342
 
1861
- function __classPrivateFieldSet(receiver, privateMap, value) {
1862
- if (!privateMap.has(receiver)) {
1863
- throw new TypeError("attempted to set private field on non-instance");
1864
- }
1865
- privateMap.set(receiver, value);
1866
- return value;
3343
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
3344
+ if (kind === "m") throw new TypeError("Private method is not writable");
3345
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3346
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3347
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1867
3348
  }
1868
3349
 
1869
3350
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-model","commonjs2":"prosemirror-model","amd":"prosemirror-model"}
@@ -1910,6 +3391,28 @@ var reEscapeChars = /[>(){}[\]+-.!#|]/g;
1910
3391
  var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\/>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>|<!--[^-]+-->|<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g;
1911
3392
  var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
1912
3393
  var reEscapePairedChars = /[*_~`]/g;
3394
+ var XMLSPECIAL = '[&<>"]';
3395
+ var reXmlSpecial = new RegExp(XMLSPECIAL, 'g');
3396
+ function replaceUnsafeChar(char) {
3397
+ switch (char) {
3398
+ case '&':
3399
+ return '&amp;';
3400
+ case '<':
3401
+ return '&lt;';
3402
+ case '>':
3403
+ return '&gt;';
3404
+ case '"':
3405
+ return '&quot;';
3406
+ default:
3407
+ return char;
3408
+ }
3409
+ }
3410
+ function escapeXml(text) {
3411
+ if (reXmlSpecial.test(text)) {
3412
+ return text.replace(reXmlSpecial, replaceUnsafeChar);
3413
+ }
3414
+ return text;
3415
+ }
1913
3416
  function sendHostName() {
1914
3417
  sendHostname_default()('editor', 'UA-129966929-1');
1915
3418
  }
@@ -2704,7 +4207,7 @@ var EditorBase = /** @class */ (function () {
2704
4207
  var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
2705
4208
  var rules = this.createInputRules();
2706
4209
  var plugins = __spreadArray(__spreadArray([], this.keymaps), [
2707
- (0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(__assign({ 'Mod-z': undo(), 'Shift-Mod-z': redo() }, external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap)),
4210
+ (0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(__assign({ 'Mod-z': undo(), 'Shift-Mod-z': redo(), 'Shift-Enter': external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap.Enter }, external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap)),
2708
4211
  (0,external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_.history)(),
2709
4212
  placeholder(this.placeholder),
2710
4213
  addWidget(this.eventEmitter),
@@ -2775,15 +4278,19 @@ var EditorBase = /** @class */ (function () {
2775
4278
  delete _this[prop];
2776
4279
  });
2777
4280
  };
2778
- EditorBase.prototype.moveCursorToStart = function () {
4281
+ EditorBase.prototype.moveCursorToStart = function (focus) {
2779
4282
  var tr = this.view.state.tr;
2780
4283
  this.view.dispatch(tr.setSelection(createTextSelection(tr, 1)).scrollIntoView());
2781
- this.focus();
4284
+ if (focus) {
4285
+ this.focus();
4286
+ }
2782
4287
  };
2783
- EditorBase.prototype.moveCursorToEnd = function () {
4288
+ EditorBase.prototype.moveCursorToEnd = function (focus) {
2784
4289
  var tr = this.view.state.tr;
2785
4290
  this.view.dispatch(tr.setSelection(createTextSelection(tr, tr.doc.content.size - 1)).scrollIntoView());
2786
- this.focus();
4291
+ if (focus) {
4292
+ this.focus();
4293
+ }
2787
4294
  };
2788
4295
  EditorBase.prototype.setScrollTop = function (top) {
2789
4296
  this.view.dom.scrollTop = top;
@@ -2915,6 +4422,8 @@ var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE + ")*\\s*/?>";
2915
4422
  var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
2916
4423
  var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
2917
4424
  var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
4425
+ var reBR = /<br\s*\/*>/i;
4426
+ var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
2918
4427
 
2919
4428
  ;// CONCATENATED MODULE: ./src/utils/dom.ts
2920
4429
 
@@ -2926,6 +4435,7 @@ var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
2926
4435
 
2927
4436
 
2928
4437
 
4438
+
2929
4439
  function isPositionInBox(style, offsetX, offsetY) {
2930
4440
  var left = parseInt(style.left, 10);
2931
4441
  var top = parseInt(style.top, 10);
@@ -3064,7 +4574,7 @@ function finalizeHtml(html, needHtmlText) {
3064
4574
  }
3065
4575
  else {
3066
4576
  var frag = document.createDocumentFragment();
3067
- var childNodes = toArray_default()(html.childNodes);
4577
+ var childNodes = toArray(html.childNodes);
3068
4578
  var length = childNodes.length;
3069
4579
  for (var i = 0; i < length; i += 1) {
3070
4580
  frag.appendChild(childNodes[i]);
@@ -3106,33 +4616,34 @@ function prependNode(node, appended) {
3106
4616
  }
3107
4617
  function setAttributes(attributes, element) {
3108
4618
  Object.keys(attributes).forEach(function (attrName) {
3109
- if (attributes[attrName]) {
3110
- element.setAttribute(attrName, attributes[attrName]);
4619
+ if (isNil(attributes[attrName])) {
4620
+ element.removeAttribute(attrName);
3111
4621
  }
3112
4622
  else {
3113
- element.removeAttribute(attrName);
4623
+ element.setAttribute(attrName, attributes[attrName]);
3114
4624
  }
3115
4625
  });
3116
4626
  }
3117
4627
  function replaceBRWithEmptyBlock(html) {
3118
- var reBr = /<br\s*\/*>/i;
4628
+ // remove br in paragraph to compatible with markdown
4629
+ var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
3119
4630
  var reHTMLTag = new RegExp(HTML_TAG, 'ig');
3120
- var htmlTagMatched = html.match(reHTMLTag);
4631
+ var htmlTagMatched = replacedHTML.match(reHTMLTag);
3121
4632
  htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
3122
- if (reBr.test(htmlTag)) {
3123
- var alternativeTag = '';
4633
+ if (reBR.test(htmlTag)) {
4634
+ var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
3124
4635
  if (index) {
3125
4636
  var prevTag = htmlTagMatched[index - 1];
3126
4637
  var openTagMatched = prevTag.match(OPEN_TAG);
3127
- if (openTagMatched) {
4638
+ if (openTagMatched && !/br/i.test(openTagMatched[1])) {
3128
4639
  var tagName = openTagMatched[1];
3129
4640
  alternativeTag = "</" + tagName + "><" + tagName + ">";
3130
4641
  }
3131
4642
  }
3132
- html = html.replace(reBr, alternativeTag);
4643
+ replacedHTML = replacedHTML.replace(reBR, alternativeTag);
3133
4644
  }
3134
4645
  });
3135
- return html;
4646
+ return replacedHTML;
3136
4647
  }
3137
4648
 
3138
4649
  ;// CONCATENATED MODULE: ./src/markdown/helper/pos.ts
@@ -3367,7 +4878,7 @@ function customBlock(node, start, end) {
3367
4878
  var marks = [markInfo(setOffsetPos(start, 1), end, CUSTOM_BLOCK)];
3368
4879
  marks.push(markInfo(start, addOffsetPos(start, syntaxEnd), DELIM));
3369
4880
  if (info) {
3370
- marks.push(markInfo(addOffsetPos(start, 2), addOffsetPos(start, syntaxLength + info.length), META));
4881
+ marks.push(markInfo(addOffsetPos(start, syntaxEnd), addOffsetPos(start, syntaxLength + info.length), META));
3371
4882
  }
3372
4883
  marks.push(markInfo(setOffsetPos(end, 1), end, DELIM));
3373
4884
  var lineBackgroundMarkInfo = lineBackground(parent, start, end, 'custom-block');
@@ -4678,9 +6189,11 @@ var ThematicBreak = /** @class */ (function (_super) {
4678
6189
 
4679
6190
 
4680
6191
 
4681
- function cannotBeListNode(_a) {
4682
- var type = _a.type;
4683
- return type === 'codeBlock' || type === 'heading' || type.indexOf('table') !== -1;
6192
+ function cannotBeListNode(_a, line) {
6193
+ var type = _a.type, sourcepos = _a.sourcepos;
6194
+ // eslint-disable-next-line prefer-destructuring
6195
+ var startLine = sourcepos[0][0];
6196
+ return line <= startLine && (type === 'codeBlock' || type === 'heading' || type.match('table'));
4684
6197
  }
4685
6198
  var ListItem = /** @class */ (function (_super) {
4686
6199
  __extends(ListItem, _super);
@@ -4783,7 +6296,7 @@ var ListItem = /** @class */ (function (_super) {
4783
6296
  var skipLines = [];
4784
6297
  for (var line = startLine; line <= endLine; line += 1) {
4785
6298
  var mdNode = toastMark.findFirstNodeAtLine(line);
4786
- if (mdNode && cannotBeListNode(mdNode)) {
6299
+ if (mdNode && cannotBeListNode(mdNode, line)) {
4787
6300
  break;
4788
6301
  }
4789
6302
  // to skip unnecessary processing
@@ -5525,15 +7038,20 @@ var MdEditor = /** @class */ (function (_super) {
5525
7038
  _this.commands = _this.createCommands();
5526
7039
  _this.specs.setContext(__assign(__assign({}, _this.context), { view: _this.view }));
5527
7040
  _this.createClipboard();
5528
- _this.eventEmitter.listen('changePreviewTabWrite', function () { return _this.toggleActive(true); });
7041
+ // To prevent unnecessary focus setting during initial rendering
7042
+ _this.eventEmitter.listen('changePreviewTabWrite', function (isMarkdownTabMounted) {
7043
+ return _this.toggleActive(true, isMarkdownTabMounted);
7044
+ });
5529
7045
  _this.eventEmitter.listen('changePreviewTabPreview', function () { return _this.toggleActive(false); });
5530
7046
  _this.initEvent();
5531
7047
  return _this;
5532
7048
  }
5533
- MdEditor.prototype.toggleActive = function (active) {
7049
+ MdEditor.prototype.toggleActive = function (active, isMarkdownTabMounted) {
5534
7050
  toggleClass(this.el, 'active', active);
5535
7051
  if (active) {
5536
- this.focus();
7052
+ if (!isMarkdownTabMounted) {
7053
+ this.focus();
7054
+ }
5537
7055
  }
5538
7056
  else {
5539
7057
  this.blur();
@@ -5750,7 +7268,7 @@ var MdEditor = /** @class */ (function (_super) {
5750
7268
  });
5751
7269
  this.view.dispatch(tr.replaceWith(0, doc.content.size, nodes));
5752
7270
  if (cursorToEnd) {
5753
- this.moveCursorToEnd();
7271
+ this.moveCursorToEnd(true);
5754
7272
  }
5755
7273
  };
5756
7274
  MdEditor.prototype.addWidget = function (node, style, mdPos) {
@@ -5837,10 +7355,16 @@ var esm_assign = function () {
5837
7355
  };
5838
7356
  return esm_assign.apply(this, arguments);
5839
7357
  };
5840
- function esm_spreadArray(to, from) {
5841
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
5842
- to[j] = from[i];
5843
- return to;
7358
+ function esm_spreadArray(to, from, pack) {
7359
+ if (pack || arguments.length === 2)
7360
+ for (var i = 0, l = from.length, ar; i < l; i++) {
7361
+ if (ar || !(i in from)) {
7362
+ if (!ar)
7363
+ ar = Array.prototype.slice.call(from, 0, i);
7364
+ ar[i] = from[i];
7365
+ }
7366
+ }
7367
+ return to.concat(ar || Array.prototype.slice.call(from));
5844
7368
  }
5845
7369
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof self !== 'undefined' ? self : {};
5846
7370
  var encodeCache = {};
@@ -6397,7 +7921,7 @@ var egrave$1 = "è";
6397
7921
  var egs = "⪖";
6398
7922
  var egsdot = "⪘";
6399
7923
  var el = "⪙";
6400
- var Element = "∈";
7924
+ var esm_Element = "∈";
6401
7925
  var elinters = "⏧";
6402
7926
  var ell = "ℓ";
6403
7927
  var els = "⪕";
@@ -8521,7 +10045,7 @@ var require$$1$1 = {
8521
10045
  egs: egs,
8522
10046
  egsdot: egsdot,
8523
10047
  el: el,
8524
- Element: Element,
10048
+ Element: esm_Element,
8525
10049
  elinters: elinters,
8526
10050
  ell: ell,
8527
10051
  els: els,
@@ -10707,8 +12231,8 @@ var C_BACKSLASH$1 = 92;
10707
12231
  var reBackslashOrAmp = /[\\&]/;
10708
12232
  var ESCAPABLE = '[!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]';
10709
12233
  var reEntityOrEscapedChar = new RegExp("\\\\" + ESCAPABLE + "|" + ENTITY, 'gi');
10710
- var XMLSPECIAL = '[&<>"]';
10711
- var reXmlSpecial = new RegExp(XMLSPECIAL, 'g');
12234
+ var esm_XMLSPECIAL = '[&<>"]';
12235
+ var esm_reXmlSpecial = new RegExp(esm_XMLSPECIAL, 'g');
10712
12236
  var unescapeChar = function (s) {
10713
12237
  if (s.charCodeAt(0) === C_BACKSLASH$1) {
10714
12238
  return s.charAt(1);
@@ -10730,7 +12254,7 @@ function normalizeURI(uri) {
10730
12254
  return uri;
10731
12255
  }
10732
12256
  }
10733
- function replaceUnsafeChar(s) {
12257
+ function esm_replaceUnsafeChar(s) {
10734
12258
  switch (s) {
10735
12259
  case '&':
10736
12260
  return '&amp;';
@@ -10744,9 +12268,9 @@ function replaceUnsafeChar(s) {
10744
12268
  return s;
10745
12269
  }
10746
12270
  }
10747
- function escapeXml(s) {
10748
- if (reXmlSpecial.test(s)) {
10749
- return s.replace(reXmlSpecial, replaceUnsafeChar);
12271
+ function esm_escapeXml(s) {
12272
+ if (esm_reXmlSpecial.test(s)) {
12273
+ return s.replace(esm_reXmlSpecial, esm_replaceUnsafeChar);
10750
12274
  }
10751
12275
  return s;
10752
12276
  }
@@ -14226,6 +15750,7 @@ function filterDisallowedTags(str) {
14226
15750
  }
14227
15751
  return str;
14228
15752
  }
15753
+ var CUSTOM_SYNTAX_LENGTH = 4;
14229
15754
  var baseConvertors = {
14230
15755
  heading: function (node, _a) {
14231
15756
  var entering = _a.entering;
@@ -14352,7 +15877,7 @@ var baseConvertors = {
14352
15877
  var infoWords = infoStr ? infoStr.split(/\s+/) : [];
14353
15878
  var codeClassNames = [];
14354
15879
  if (infoWords.length > 0 && infoWords[0].length > 0) {
14355
- codeClassNames.push("language-" + escapeXml(infoWords[0]));
15880
+ codeClassNames.push("language-" + esm_escapeXml(infoWords[0]));
14356
15881
  }
14357
15882
  return [
14358
15883
  { type: 'openTag', tagName: 'pre', outerNewLine: true },
@@ -14369,7 +15894,7 @@ var baseConvertors = {
14369
15894
  return {
14370
15895
  type: 'openTag',
14371
15896
  tagName: 'a',
14372
- attributes: esm_assign({ href: escapeXml(destination) }, (title && { title: escapeXml(title) })),
15897
+ attributes: esm_assign({ href: esm_escapeXml(destination) }, (title && { title: esm_escapeXml(title) })),
14373
15898
  };
14374
15899
  }
14375
15900
  return { type: 'closeTag', tagName: 'a' };
@@ -14382,7 +15907,7 @@ var baseConvertors = {
14382
15907
  type: 'openTag',
14383
15908
  tagName: 'img',
14384
15909
  selfClose: true,
14385
- attributes: esm_assign({ src: escapeXml(destination), alt: getChildrenText(node) }, (title && { title: escapeXml(title) })),
15910
+ attributes: esm_assign({ src: esm_escapeXml(destination), alt: getChildrenText(node) }, (title && { title: esm_escapeXml(title) })),
14386
15911
  };
14387
15912
  },
14388
15913
  customBlock: function (node, context, convertors) {
@@ -14393,7 +15918,7 @@ var baseConvertors = {
14393
15918
  return customConvertor(node, context);
14394
15919
  }
14395
15920
  catch (e) {
14396
- console.warn(e);
15921
+ console.warn("[@toast-ui/editor] - The error occurred when " + info + " block node was parsed in markdown renderer: " + e);
14397
15922
  }
14398
15923
  }
14399
15924
  return [
@@ -14416,15 +15941,30 @@ var baseConvertors = {
14416
15941
  ];
14417
15942
  },
14418
15943
  customInline: function (node, context, convertors) {
14419
- var info = node.info.trim().toLowerCase();
14420
- var customConvertor = convertors[info];
15944
+ var _a = node, sourcepos = _a.sourcepos, info = _a.info;
15945
+ var nomalizedInfo = info.trim().toLowerCase();
15946
+ var customConvertor = convertors[nomalizedInfo];
15947
+ var entering = context.entering;
14421
15948
  if (customConvertor) {
14422
- return customConvertor(node, context);
14423
- }
14424
- return {
14425
- type: context.entering ? 'openTag' : 'closeTag',
14426
- tagName: 'span',
14427
- };
15949
+ try {
15950
+ return customConvertor(node, context);
15951
+ }
15952
+ catch (e) {
15953
+ console.warn("[@toast-ui/editor] - The error occurred when " + nomalizedInfo + " inline node was parsed in markdown renderer: " + e);
15954
+ }
15955
+ }
15956
+ var text = sourcepos[1][1] - sourcepos[0][1] + 1 === info.length + CUSTOM_SYNTAX_LENGTH
15957
+ ? ''
15958
+ : info + " ";
15959
+ return entering
15960
+ ? [
15961
+ { type: 'openTag', tagName: 'span' },
15962
+ { type: 'text', content: "$$" + text },
15963
+ ]
15964
+ : [
15965
+ { type: 'text', content: '$$' },
15966
+ { type: 'closeTag', tagName: 'span' },
15967
+ ];
14428
15968
  },
14429
15969
  };
14430
15970
  var gfmConvertors = {
@@ -14587,8 +16127,8 @@ var Renderer = /** @class */ (function () {
14587
16127
  ? nodeType.toLowerCase()
14588
16128
  : nodeType;
14589
16129
  if (orgConvertor) {
14590
- convertors[convertorType] = function (node, context) {
14591
- context.origin = function () { return orgConvertor(node, context); };
16130
+ convertors[convertorType] = function (node, context, convertors) {
16131
+ context.origin = function () { return orgConvertor(node, context, convertors); };
14592
16132
  return convertor(node, context);
14593
16133
  };
14594
16134
  }
@@ -14706,7 +16246,7 @@ var Renderer = /** @class */ (function () {
14706
16246
  }
14707
16247
  };
14708
16248
  Renderer.prototype.renderTextNode = function (node) {
14709
- this.buffer.push(escapeXml(node.content));
16249
+ this.buffer.push(esm_escapeXml(node.content));
14710
16250
  };
14711
16251
  Renderer.prototype.renderRawHtmlNode = function (node) {
14712
16252
  this.addOuterNewLine(node);
@@ -14734,112 +16274,35 @@ var Renderer = /** @class */ (function () {
14734
16274
  }());
14735
16275
 
14736
16276
 
16277
+ // EXTERNAL MODULE: ../../node_modules/dompurify/dist/purify.js
16278
+ var purify = __webpack_require__(368);
16279
+ var purify_default = /*#__PURE__*/__webpack_require__.n(purify);
14737
16280
  ;// CONCATENATED MODULE: ./src/sanitizer/htmlSanitizer.ts
14738
16281
 
14739
16282
 
14740
16283
 
14741
-
14742
-
14743
-
14744
- var reHTMLAttr = new RegExp('^(abbr|align|alt|axis|bgcolor|border|cellpadding|cellspacing|class|clear|' +
14745
- 'color|cols|compact|coords|dir|face|headers|height|hreflang|hspace|' +
14746
- 'ismap|lang|language|nohref|nowrap|rel|rev|rows|rules|' +
14747
- 'scope|scrolling|shape|size|span|start|summary|tabindex|target|title|type|' +
14748
- 'valign|value|vspace|width|checked|mathvariant|encoding|id|name|' +
14749
- 'background|cite|href|longdesc|src|usemap|xlink:href|data-+|checked|style)', 'g');
14750
- var reSvgAttr = new RegExp('^(accent-height|accumulate|additive|alphabetic|arabic-form|ascent|' +
14751
- 'baseProfile|bbox|begin|by|calcMode|cap-height|class|color|color-rendering|content|' +
14752
- 'cx|cy|d|dx|dy|descent|display|dur|end|fill|fill-rule|font-family|font-size|font-stretch|' +
14753
- 'font-style|font-variant|font-weight|from|fx|fy|g1|g2|glyph-name|gradientUnits|hanging|' +
14754
- 'height|horiz-adv-x|horiz-origin-x|ideographic|k|keyPoints|keySplines|keyTimes|lang|' +
14755
- 'marker-end|marker-mid|marker-start|markerHeight|markerUnits|markerWidth|mathematical|' +
14756
- 'max|min|offset|opacity|orient|origin|overline-position|overline-thickness|panose-1|' +
14757
- 'path|pathLength|points|preserveAspectRatio|r|refX|refY|repeatCount|repeatDur|' +
14758
- 'requiredExtensions|requiredFeatures|restart|rotate|rx|ry|slope|stemh|stemv|stop-color|' +
14759
- 'stop-opacity|strikethrough-position|strikethrough-thickness|stroke|stroke-dasharray|' +
14760
- 'stroke-dashoffset|stroke-linecap|stroke-linejoin|stroke-miterlimit|stroke-opacity|' +
14761
- 'stroke-width|systemLanguage|target|text-anchor|to|transform|type|u1|u2|underline-position|' +
14762
- 'underline-thickness|unicode|unicode-range|units-per-em|values|version|viewBox|visibility|' +
14763
- 'width|widths|x|x-height|x1|x2|xlink:actuate|xlink:arcrole|xlink:role|xlink:show|xlink:title|' +
14764
- 'xlink:type|xml:base|xml:lang|xml:space|xmlns|xmlns:xlink|y|y1|y2|zoomAndPan)', 'g');
14765
- var reXSSAttr = /href|src|background/i;
14766
- var reXSSAttrValue = /((java|vb|live)script|x):/i;
14767
- var reOnEvent = /^on\S+/i;
14768
- var reXSSOnload = new RegExp("(<" + TAG_NAME + "[^>]*)(onload\\s*=)", 'ig');
14769
- var reComment = /<!--[\s\S]*?-->/g;
14770
- var reWhitespace = /[ \t\r\n]/g;
14771
- var DEFAULT_TAG_BLACK_LIST = [
14772
- 'script',
14773
- 'iframe',
14774
- 'textarea',
14775
- 'form',
14776
- 'button',
14777
- 'select',
14778
- 'input',
14779
- 'meta',
14780
- 'style',
14781
- 'link',
14782
- 'title',
14783
- 'embed',
14784
- 'object',
14785
- 'details',
14786
- 'summary',
14787
- 'base',
14788
- ];
14789
- var CAN_BE_TAG_WHITE_LIST = ['iframe', 'embed', 'details', 'summary'];
14790
- var tagBlacklist = __spreadArray([], DEFAULT_TAG_BLACK_LIST);
16284
+ var CAN_BE_WHITE_TAG_LIST = ['iframe', 'embed'];
16285
+ var whiteTagList = [];
14791
16286
  function registerTagWhitelistIfPossible(tagName) {
14792
- if (common_includes(CAN_BE_TAG_WHITE_LIST, tagName)) {
14793
- var index = tagBlacklist.indexOf(tagName);
14794
- if (index > -1) {
14795
- tagBlacklist.splice(index, 1);
14796
- }
14797
- }
14798
- }
14799
- function sanitizeHTML(html) {
14800
- var root = document.createElement('div');
14801
- if (isString_default()(html)) {
14802
- html = html.replace(reComment, '').replace(reXSSOnload, '$1');
14803
- root.innerHTML = html;
14804
- }
14805
- removeUnnecessaryTags(root);
14806
- leaveOnlyWhitelistAttribute(root);
14807
- return finalizeHtml(root, true);
14808
- }
14809
- function removeUnnecessaryTags(html) {
14810
- var removedTags = findNodes(html, tagBlacklist.join(','));
14811
- removedTags.forEach(function (node) {
14812
- removeNode(node);
14813
- });
14814
- }
14815
- function isXSSAttribute(attrName, attrValue) {
14816
- return attrName.match(reXSSAttr) && attrValue.replace(reWhitespace, '').match(reXSSAttrValue);
14817
- }
14818
- function removeBlacklistAttributes(node, blacklistAttrs) {
14819
- blacklistAttrs.forEach(function (_a) {
14820
- var name = _a.name;
14821
- if (reOnEvent.test(name)) {
14822
- node[name] = null;
14823
- }
14824
- node.removeAttribute(name);
14825
- });
14826
- }
14827
- function leaveOnlyWhitelistAttribute(html) {
14828
- findNodes(html, '*').forEach(function (node) {
14829
- var attributes = node.attributes;
14830
- var blacklist = toArray_default()(attributes).filter(function (attr) {
14831
- var name = attr.name, value = attr.value;
14832
- var htmlAttr = name.match(reHTMLAttr);
14833
- var svgAttr = name.match(reSvgAttr);
14834
- var xssAttr = htmlAttr && isXSSAttribute(name, value);
14835
- return (!htmlAttr && !svgAttr) || xssAttr;
14836
- });
14837
- removeBlacklistAttributes(node, blacklist);
14838
- });
14839
- }
14840
- function sanitizeXSSAttributeValue(attrValue) {
14841
- attrValue = attrValue.replace(reComment, '');
14842
- return reXSSAttrValue.test(attrValue) ? '' : attrValue;
16287
+ if (common_includes(CAN_BE_WHITE_TAG_LIST, tagName)) {
16288
+ whiteTagList.push(tagName.toLowerCase());
16289
+ }
16290
+ }
16291
+ function sanitizeHTML(html, options) {
16292
+ return purify_default().sanitize(html, __assign({ ADD_TAGS: whiteTagList, ADD_ATTR: ['rel', 'target', 'hreflang', 'type'], FORBID_TAGS: [
16293
+ 'input',
16294
+ 'script',
16295
+ 'textarea',
16296
+ 'form',
16297
+ 'button',
16298
+ 'select',
16299
+ 'meta',
16300
+ 'style',
16301
+ 'link',
16302
+ 'title',
16303
+ 'object',
16304
+ 'base',
16305
+ ] }, options));
14843
16306
  }
14844
16307
 
14845
16308
  ;// CONCATENATED MODULE: ./src/wysiwyg/nodes/html.ts
@@ -15291,10 +16754,16 @@ var MarkdownPreview = /** @class */ (function () {
15291
16754
  this.sanitizer = sanitizer;
15292
16755
  this.initEvent(highlight);
15293
16756
  this.initContentSection();
16757
+ // To prevent overflowing contents in the viewer
16758
+ if (this.isViewer) {
16759
+ this.previewContent.style.overflowWrap = 'break-word';
16760
+ }
15294
16761
  }
15295
16762
  MarkdownPreview.prototype.initContentSection = function () {
15296
16763
  this.previewContent = createElementWith("<div class=\"" + cls('contents') + "\"></div>");
15297
- this.el.appendChild(this.previewContent);
16764
+ if (!this.isViewer) {
16765
+ this.el.appendChild(this.previewContent);
16766
+ }
15298
16767
  };
15299
16768
  MarkdownPreview.prototype.toggleActive = function (active) {
15300
16769
  toggleClass(this.el, 'active', active);
@@ -15302,6 +16771,9 @@ var MarkdownPreview = /** @class */ (function () {
15302
16771
  MarkdownPreview.prototype.initEvent = function (highlight) {
15303
16772
  var _this = this;
15304
16773
  this.eventEmitter.listen('updatePreview', this.update.bind(this));
16774
+ if (this.isViewer) {
16775
+ return;
16776
+ }
15305
16777
  if (highlight) {
15306
16778
  this.eventEmitter.listen('changeToolbarState', function (_a) {
15307
16779
  var mdNode = _a.mdNode, cursorPos = _a.cursorPos;
@@ -16690,6 +18162,7 @@ var CustomBlockView = /** @class */ (function () {
16690
18162
  if (_this.innerEditorView) {
16691
18163
  throw new Error('The editor is already opened.');
16692
18164
  }
18165
+ _this.dom.draggable = false;
16693
18166
  _this.wrapper.style.display = 'none';
16694
18167
  _this.innerViewContainer.style.display = 'block';
16695
18168
  _this.innerEditorView = new external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_.EditorView(_this.innerViewContainer, {
@@ -17217,6 +18690,7 @@ function convertMsoParagraphsToList(html) {
17217
18690
 
17218
18691
 
17219
18692
 
18693
+
17220
18694
  var START_FRAGMENT_COMMENT = '<!--StartFragment-->';
17221
18695
  var END_FRAGMENT_COMMENT = '<!--EndFragment-->';
17222
18696
  function getContentBetweenFragmentComments(html) {
@@ -17225,7 +18699,7 @@ function getContentBetweenFragmentComments(html) {
17225
18699
  if (startFragmentIndex > -1 && endFragmentIndex > -1) {
17226
18700
  html = html.slice(startFragmentIndex + START_FRAGMENT_COMMENT.length, endFragmentIndex);
17227
18701
  }
17228
- return html;
18702
+ return html.replace(/<br[^>]*>/g, ALTERNATIVE_TAG_FOR_BR);
17229
18703
  }
17230
18704
  function convertMsoTableToCompletedTable(html) {
17231
18705
  // wrap with <tr> if html contains dangling <td> tags
@@ -17313,9 +18787,9 @@ function paste_createTableBody(tableBodyRows, maxColumnCount, schema) {
17313
18787
  }
17314
18788
  return schema.nodes.tableBody.create(null, copiedRows);
17315
18789
  }
17316
- function createTableFromPastingTable(rows, schema, startFromBody) {
18790
+ function createTableFromPastingTable(rows, schema, startFromBody, isInTable) {
17317
18791
  var columnCount = getMaxColumnCount(rows);
17318
- if (startFromBody) {
18792
+ if (startFromBody && isInTable) {
17319
18793
  return schema.nodes.table.create(null, [paste_createTableBody(rows, columnCount, schema)]);
17320
18794
  }
17321
18795
  var tableHeadRow = rows[0];
@@ -17326,15 +18800,16 @@ function createTableFromPastingTable(rows, schema, startFromBody) {
17326
18800
  }
17327
18801
  return schema.nodes.table.create(null, nodes);
17328
18802
  }
17329
- function changePastedSlice(slice, schema) {
18803
+ function changePastedSlice(slice, schema, isInTable) {
17330
18804
  var nodes = [];
17331
- slice.content.forEach(function (node) {
18805
+ var content = slice.content, openStart = slice.openStart, openEnd = slice.openEnd;
18806
+ content.forEach(function (node) {
17332
18807
  if (node.type.name === 'table') {
17333
18808
  var tableContent = getTableContentFromSlice(new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(node), 0, 0));
17334
18809
  if (tableContent) {
17335
18810
  var rows = createRowsFromPastingTable(tableContent);
17336
18811
  var startFromBody = tableContent.firstChild.type.name === 'tableBody';
17337
- var table = createTableFromPastingTable(rows, schema, startFromBody);
18812
+ var table = createTableFromPastingTable(rows, schema, startFromBody, isInTable);
17338
18813
  nodes.push(table);
17339
18814
  }
17340
18815
  }
@@ -17342,7 +18817,7 @@ function changePastedSlice(slice, schema) {
17342
18817
  nodes.push(node);
17343
18818
  }
17344
18819
  });
17345
- return new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(nodes), 0, 0);
18820
+ return new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(nodes), openStart, openEnd);
17346
18821
  }
17347
18822
 
17348
18823
  ;// CONCATENATED MODULE: ./src/wysiwyg/clipboard/pasteToTable.ts
@@ -17570,7 +19045,7 @@ var paragraph_Paragraph = /** @class */ (function (_super) {
17570
19045
  get: function () {
17571
19046
  return {
17572
19047
  content: 'inline*',
17573
- group: 'block listGroup',
19048
+ group: 'block',
17574
19049
  attrs: __assign({}, getDefaultCustomAttrs()),
17575
19050
  parseDOM: [{ tag: 'p' }],
17576
19051
  toDOM: function (_a) {
@@ -17704,7 +19179,8 @@ var heading_Heading = /** @class */ (function (_super) {
17704
19179
  });
17705
19180
  Heading.prototype.commands = function () {
17706
19181
  return function (payload) { return function (state, dispatch) {
17707
- return (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.setBlockType)(state.schema.nodes.heading, payload)(state, dispatch);
19182
+ var nodeType = state.schema.nodes[payload.level ? 'heading' : 'paragraph'];
19183
+ return (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.setBlockType)(nodeType, payload)(state, dispatch);
17708
19184
  }; };
17709
19185
  };
17710
19186
  return Heading;
@@ -17825,7 +19301,7 @@ var BulletList = /** @class */ (function (_super) {
17825
19301
  get: function () {
17826
19302
  return {
17827
19303
  content: 'listItem+',
17828
- group: 'block listGroup',
19304
+ group: 'block',
17829
19305
  attrs: __assign({ rawHTML: { default: null } }, getDefaultCustomAttrs()),
17830
19306
  parseDOM: [createDOMInfoParsedRawHTML('ul')],
17831
19307
  toDOM: function (_a) {
@@ -17882,7 +19358,7 @@ var OrderedList = /** @class */ (function (_super) {
17882
19358
  get: function () {
17883
19359
  return {
17884
19360
  content: 'listItem+',
17885
- group: 'block listGroup',
19361
+ group: 'block',
17886
19362
  attrs: __assign({ order: { default: 1 }, rawHTML: { default: null } }, getDefaultCustomAttrs()),
17887
19363
  parseDOM: [
17888
19364
  {
@@ -17943,7 +19419,8 @@ var listItem_ListItem = /** @class */ (function (_super) {
17943
19419
  Object.defineProperty(ListItem.prototype, "schema", {
17944
19420
  get: function () {
17945
19421
  return {
17946
- content: 'paragraph listGroup*',
19422
+ content: 'paragraph block*',
19423
+ selectable: false,
17947
19424
  attrs: {
17948
19425
  task: { default: false },
17949
19426
  checked: { default: false },
@@ -18851,9 +20328,13 @@ var Image = /** @class */ (function (_super) {
18851
20328
  {
18852
20329
  tag: 'img[src]',
18853
20330
  getAttrs: function (dom) {
18854
- var imageUrl = dom.getAttribute('src') || '';
18855
- var rawHTML = dom.getAttribute('data-raw-html');
18856
- return __assign({ imageUrl: sanitizeXSSAttributeValue(imageUrl), altText: dom.getAttribute('alt') }, (rawHTML && { rawHTML: rawHTML }));
20331
+ var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
20332
+ .firstChild;
20333
+ var imageUrl = sanitizedDOM.getAttribute('src') || '';
20334
+ var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
20335
+ var altText = sanitizedDOM.getAttribute('alt');
20336
+ return __assign({ imageUrl: imageUrl,
20337
+ altText: altText }, (rawHTML && { rawHTML: rawHTML }));
18857
20338
  },
18858
20339
  },
18859
20340
  ],
@@ -18876,7 +20357,7 @@ var Image = /** @class */ (function (_super) {
18876
20357
  if (!imageUrl) {
18877
20358
  return false;
18878
20359
  }
18879
- var node = schema.nodes.image.createAndFill(__assign({ imageUrl: encodeMarkdownText(imageUrl) }, (altText && { altText: altText })));
20360
+ var node = schema.nodes.image.createAndFill(__assign({ imageUrl: escapeXml(imageUrl) }, (altText && { altText: altText })));
18880
20361
  dispatch(tr.replaceSelectionWith(node).scrollIntoView());
18881
20362
  return true;
18882
20363
  }; };
@@ -19135,6 +20616,7 @@ var strike_Strike = /** @class */ (function (_super) {
19135
20616
 
19136
20617
 
19137
20618
 
20619
+
19138
20620
  var link_Link = /** @class */ (function (_super) {
19139
20621
  __extends(Link, _super);
19140
20622
  function Link(linkAttributes) {
@@ -19159,9 +20641,11 @@ var link_Link = /** @class */ (function (_super) {
19159
20641
  {
19160
20642
  tag: 'a[href]',
19161
20643
  getAttrs: function (dom) {
19162
- var href = dom.getAttribute('href') || '';
19163
- var rawHTML = dom.getAttribute('data-raw-html');
19164
- return __assign({ linkUrl: sanitizeXSSAttributeValue(href), linkText: dom.textContent }, (rawHTML && { rawHTML: rawHTML }));
20644
+ var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
20645
+ .firstChild;
20646
+ var href = sanitizedDOM.getAttribute('href') || '';
20647
+ var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
20648
+ return __assign({ linkUrl: href, linkText: sanitizedDOM.textContent }, (rawHTML && { rawHTML: rawHTML }));
19165
20649
  },
19166
20650
  },
19167
20651
  ],
@@ -19184,7 +20668,7 @@ var link_Link = /** @class */ (function (_super) {
19184
20668
  var empty = selection.empty, from = selection.from, to = selection.to;
19185
20669
  if (from && to && linkUrl) {
19186
20670
  var attrs = {
19187
- linkUrl: encodeMarkdownText(linkUrl),
20671
+ linkUrl: escapeXml(linkUrl),
19188
20672
  linkText: escapeMarkdownText(linkText),
19189
20673
  };
19190
20674
  var mark = schema.mark('link', attrs);
@@ -19448,6 +20932,7 @@ function createSpecs(linkAttributes) {
19448
20932
 
19449
20933
 
19450
20934
 
20935
+
19451
20936
 
19452
20937
 
19453
20938
  var CONTENTS_CLASS_NAME = cls('contents');
@@ -19531,7 +21016,9 @@ var WysiwygEditor = /** @class */ (function (_super) {
19531
21016
  _this.eventEmitter.emit('setFocusedNode', state.selection.$from.node(1));
19532
21017
  },
19533
21018
  transformPastedHTML: changePastedHTML,
19534
- transformPasted: function (slice) { return changePastedSlice(slice, _this.schema); },
21019
+ transformPasted: function (slice) {
21020
+ return changePastedSlice(slice, _this.schema, isInTableNode(_this.view.state.selection.$from));
21021
+ },
19535
21022
  handlePaste: function (view, _, slice) { return pasteToTable(view, slice); },
19536
21023
  handleKeyDown: function (_, ev) {
19537
21024
  _this.eventEmitter.emit('keydown', _this.editorType, ev);
@@ -19540,8 +21027,8 @@ var WysiwygEditor = /** @class */ (function (_super) {
19540
21027
  handleDOMEvents: {
19541
21028
  paste: function (_, ev) {
19542
21029
  var clipboardData = ev.clipboardData || window.clipboardData;
19543
- var items = clipboardData && clipboardData.items;
19544
- if (items) {
21030
+ var items = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.items;
21031
+ if ((items === null || items === void 0 ? void 0 : items.length) === 1) {
19545
21032
  var imageBlob = pasteImageOnly(items);
19546
21033
  if (imageBlob) {
19547
21034
  ev.preventDefault();
@@ -19609,7 +21096,7 @@ var WysiwygEditor = /** @class */ (function (_super) {
19609
21096
  var _a = this.view.state, tr = _a.tr, doc = _a.doc;
19610
21097
  this.view.dispatch(tr.replaceWith(0, doc.content.size, newDoc));
19611
21098
  if (cursorToEnd) {
19612
- this.moveCursorToEnd();
21099
+ this.moveCursorToEnd(true);
19613
21100
  }
19614
21101
  };
19615
21102
  WysiwygEditor.prototype.setSelection = function (start, end) {
@@ -19686,6 +21173,7 @@ var eventTypeList = [
19686
21173
  'mixinTableOffsetMapPrototype',
19687
21174
  'setFocusedNode',
19688
21175
  'removePopupWidget',
21176
+ 'query',
19689
21177
  // provide event for user
19690
21178
  'openPopup',
19691
21179
  'closePopup',
@@ -19948,6 +21436,9 @@ function htmlToWwConvertors_isInlineNode(_a) {
19948
21436
  var type = _a.type;
19949
21437
  return common_includes(['text', 'strong', 'emph', 'strike', 'image', 'link', 'code'], type);
19950
21438
  }
21439
+ function isSoftbreak(mdNode) {
21440
+ return (mdNode === null || mdNode === void 0 ? void 0 : mdNode.type) === 'softbreak';
21441
+ }
19951
21442
  function htmlToWwConvertors_isListNode(_a) {
19952
21443
  var type = _a.type, literal = _a.literal;
19953
21444
  var matched = type === 'htmlInline' && literal.match(reHTMLTag);
@@ -19966,11 +21457,15 @@ function getListItemAttrs(_a) {
19966
21457
  var checked = /data-task-checked/.test(literal);
19967
21458
  return { task: task, checked: checked };
19968
21459
  }
19969
- function getMatchedAttributeValue(rawHTML, attrName) {
21460
+ function getMatchedAttributeValue(rawHTML) {
21461
+ var attrNames = [];
21462
+ for (var _i = 1; _i < arguments.length; _i++) {
21463
+ attrNames[_i - 1] = arguments[_i];
21464
+ }
19970
21465
  var wrapper = document.createElement('div');
19971
- wrapper.innerHTML = rawHTML;
21466
+ wrapper.innerHTML = sanitizeHTML(rawHTML);
19972
21467
  var el = wrapper.firstChild;
19973
- return el.getAttribute(attrName) || '';
21468
+ return attrNames.map(function (attrName) { return el.getAttribute(attrName) || ''; });
19974
21469
  }
19975
21470
  function createConvertors(convertors) {
19976
21471
  var convertorMap = {};
@@ -20024,9 +21519,9 @@ var convertors = {
20024
21519
  var tag = node.literal;
20025
21520
  var link = state.schema.marks.link;
20026
21521
  if (openTagName) {
20027
- var linkUrl = getMatchedAttributeValue(tag, 'href');
21522
+ var linkUrl = getMatchedAttributeValue(tag, 'href')[0];
20028
21523
  state.openMark(link.create({
20029
- linkUrl: sanitizeXSSAttributeValue(linkUrl),
21524
+ linkUrl: linkUrl,
20030
21525
  rawHTML: openTagName,
20031
21526
  }));
20032
21527
  }
@@ -20036,11 +21531,10 @@ var convertors = {
20036
21531
  },
20037
21532
  img: function (state, node, openTagName) {
20038
21533
  var tag = node.literal;
20039
- var imageUrl = getMatchedAttributeValue(tag, 'src');
20040
- if (imageUrl) {
20041
- var altText = getMatchedAttributeValue(tag, 'alt');
21534
+ if (openTagName) {
21535
+ var _a = getMatchedAttributeValue(tag, 'src', 'alt'), imageUrl = _a[0], altText = _a[1];
20042
21536
  var image = state.schema.nodes.image;
20043
- state.addNode(image, __assign({ rawHTML: openTagName, imageUrl: sanitizeXSSAttributeValue(imageUrl) }, (altText && { altText: altText })));
21537
+ state.addNode(image, __assign({ rawHTML: openTagName, imageUrl: imageUrl }, (altText && { altText: altText })));
20044
21538
  }
20045
21539
  },
20046
21540
  hr: function (state, _, openTagName) {
@@ -20050,11 +21544,22 @@ var convertors = {
20050
21544
  var paragraph = state.schema.nodes.paragraph;
20051
21545
  var parent = node.parent, prev = node.prev, next = node.next;
20052
21546
  if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'paragraph') {
20053
- if (prev && !(prev.type === 'htmlInline' && prev.literal.match(CLOSE_TAG))) {
21547
+ // should open a paragraph node when line text has only <br> tag
21548
+ // ex) first line\n\n<br>\nfourth line
21549
+ if (isSoftbreak(prev)) {
20054
21550
  state.openNode(paragraph);
20055
21551
  }
20056
- if (next) {
21552
+ // should close a paragraph node when line text has only <br> tag
21553
+ // ex) first line\n\n<br>\nfourth line
21554
+ if (isSoftbreak(next)) {
20057
21555
  state.closeNode();
21556
+ // should close a paragraph node and open a paragraph node to separate between blocks
21557
+ // when <br> tag is in the middle of the paragraph
21558
+ // ex) first <br>line\nthird line
21559
+ }
21560
+ else if (next) {
21561
+ state.closeNode();
21562
+ state.openNode(paragraph);
20058
21563
  }
20059
21564
  }
20060
21565
  else if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'tableCell') {
@@ -20130,8 +21635,9 @@ var htmlToWwConvertors = createConvertors(convertors);
20130
21635
 
20131
21636
 
20132
21637
 
21638
+
20133
21639
  function isBRTag(node) {
20134
- return node.type === 'htmlInline' && /<br ?\/?>/.test(node.literal);
21640
+ return node.type === 'htmlInline' && reBR.test(node.literal);
20135
21641
  }
20136
21642
  function addRawHTMLAttributeToDOM(parent) {
20137
21643
  toArray_default()(parent.childNodes).forEach(function (child) {
@@ -20312,32 +21818,37 @@ var toWwConvertors = {
20312
21818
  }
20313
21819
  },
20314
21820
  tableCell: function (state, node, _a) {
21821
+ var _b;
20315
21822
  var entering = _a.entering;
20316
- if (!node.ignored) {
20317
- var hasParaNode = function (childNode) {
20318
- return childNode && (htmlToWwConvertors_isInlineNode(childNode) || isCustomHTMLInlineNode(state, childNode));
20319
- };
20320
- if (entering) {
20321
- var _b = state.schema.nodes, tableHeadCell = _b.tableHeadCell, tableBodyCell = _b.tableBodyCell, paragraph = _b.paragraph;
20322
- var tablePart = node.parent.parent;
20323
- var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
21823
+ var _c = state.schema.nodes, tableHeadCell = _c.tableHeadCell, tableBodyCell = _c.tableBodyCell, paragraph = _c.paragraph;
21824
+ var tablePart = node.parent.parent;
21825
+ var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
21826
+ var hasParaNode = function (childNode) {
21827
+ return childNode && (htmlToWwConvertors_isInlineNode(childNode) || isCustomHTMLInlineNode(state, childNode));
21828
+ };
21829
+ if (entering) {
21830
+ var attrs = null;
21831
+ if (!node.ignored) {
20324
21832
  var table = tablePart.parent;
20325
- var align = table.columns[node.startIdx].align;
20326
- var attrs = __assign({}, node.attrs);
20327
- if (align) {
20328
- attrs.align = align;
20329
- }
20330
- state.openNode(cell, attrs);
20331
- if (hasParaNode(node.firstChild)) {
20332
- state.openNode(paragraph);
21833
+ var startIdx = node.startIdx;
21834
+ if (table.columns.length > startIdx) {
21835
+ var align = table.columns[startIdx].align;
21836
+ attrs = (_b = node.attrs) !== null && _b !== void 0 ? _b : {};
21837
+ if (align) {
21838
+ attrs.align = align;
21839
+ }
20333
21840
  }
20334
21841
  }
20335
- else {
20336
- if (hasParaNode(node.lastChild)) {
20337
- state.closeNode();
20338
- }
21842
+ state.openNode(cell, attrs);
21843
+ if (hasParaNode(node.firstChild)) {
21844
+ state.openNode(paragraph);
21845
+ }
21846
+ }
21847
+ else {
21848
+ if (hasParaNode(node.lastChild)) {
20339
21849
  state.closeNode();
20340
21850
  }
21851
+ state.closeNode();
20341
21852
  }
20342
21853
  },
20343
21854
  strike: function (state, _, _a, customAttrs) {
@@ -20379,10 +21890,11 @@ var toWwConvertors = {
20379
21890
  var openTagName = matched[1], closeTagName = matched[3];
20380
21891
  var typeName = (openTagName || closeTagName).toLowerCase();
20381
21892
  var markType = state.schema.marks[typeName];
21893
+ var sanitizedHTML = sanitizeHTML(html);
20382
21894
  // for user defined html schema
20383
21895
  if (markType === null || markType === void 0 ? void 0 : markType.spec.attrs.htmlInline) {
20384
21896
  if (openTagName) {
20385
- var htmlAttrs = getHTMLAttrsByHTMLString(html);
21897
+ var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
20386
21898
  state.openMark(markType.create({ htmlAttrs: htmlAttrs }));
20387
21899
  }
20388
21900
  else {
@@ -20403,14 +21915,15 @@ var toWwConvertors = {
20403
21915
  var openTagName = matched[1], closeTagName = matched[3];
20404
21916
  var typeName = (openTagName || closeTagName).toLowerCase();
20405
21917
  var nodeType = state.schema.nodes[typeName];
21918
+ var sanitizedHTML = sanitizeHTML(html);
20406
21919
  // for user defined html schema
20407
21920
  if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
20408
- var htmlAttrs = getHTMLAttrsByHTMLString(html);
21921
+ var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
20409
21922
  var childrenHTML = getChildrenHTML(node, typeName);
20410
21923
  state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
20411
21924
  }
20412
21925
  else {
20413
- container.innerHTML = html;
21926
+ container.innerHTML = sanitizedHTML;
20414
21927
  addRawHTMLAttributeToDOM(container);
20415
21928
  state.convertByDOMParser(container);
20416
21929
  }
@@ -20525,6 +22038,27 @@ var ToWwConvertorState = /** @class */ (function () {
20525
22038
  var doc = external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.DOMParser.fromSchema(this.schema).parse(root);
20526
22039
  doc.content.forEach(function (node) { return _this.push(node); });
20527
22040
  };
22041
+ ToWwConvertorState.prototype.closeUnmatchedHTMLInline = function (node, entering) {
22042
+ var _a;
22043
+ if (!entering && node.type !== 'htmlInline') {
22044
+ var length = this.stack.length - 1;
22045
+ for (var i = length; i >= 0; i -= 1) {
22046
+ var nodeInfo = this.stack[i];
22047
+ if ((_a = nodeInfo.attrs) === null || _a === void 0 ? void 0 : _a.rawHTML) {
22048
+ if (nodeInfo.content.length) {
22049
+ this.closeNode();
22050
+ }
22051
+ else {
22052
+ // just pop useless unmatched html inline node
22053
+ this.stack.pop();
22054
+ }
22055
+ }
22056
+ else {
22057
+ break;
22058
+ }
22059
+ }
22060
+ }
22061
+ };
20528
22062
  ToWwConvertorState.prototype.convert = function (mdNode, infoForPosSync) {
20529
22063
  var walker = mdNode.walker();
20530
22064
  var event = walker.next();
@@ -20542,6 +22076,7 @@ var ToWwConvertorState = /** @class */ (function () {
20542
22076
  skipped = true;
20543
22077
  },
20544
22078
  };
22079
+ this_1.closeUnmatchedHTMLInline(node, entering);
20545
22080
  convertor(this_1, node, context);
20546
22081
  if ((infoForPosSync === null || infoForPosSync === void 0 ? void 0 : infoForPosSync.node) === node) {
20547
22082
  var pos = this_1.stack.reduce(function (nodeSize, stackItem) {
@@ -20947,7 +22482,7 @@ var toMdConvertors = {
20947
22482
  var node = _a.node;
20948
22483
  var attrs = node.attrs;
20949
22484
  var altText = common_escape(attrs.altText || '');
20950
- var imageUrl = common_escape(attrs.imageUrl);
22485
+ var imageUrl = escapeXml(attrs.imageUrl);
20951
22486
  var altAttr = altText ? " alt=\"" + altText + "\"" : '';
20952
22487
  return {
20953
22488
  rawHTML: attrs.rawHTML ? "<" + attrs.rawHTML + " src=\"" + imageUrl + "\"" + altAttr + ">" : null,
@@ -21015,7 +22550,7 @@ var toMdConvertors = {
21015
22550
  var node = _a.node;
21016
22551
  var entering = _b.entering;
21017
22552
  var attrs = node.attrs;
21018
- var linkUrl = common_escape(attrs.linkUrl);
22553
+ var linkUrl = escapeXml(attrs.linkUrl);
21019
22554
  var rawHTML = attrs.rawHTML;
21020
22555
  if (entering) {
21021
22556
  return {
@@ -21052,7 +22587,8 @@ var toMdConvertors = {
21052
22587
  var openTag = "<" + tagName;
21053
22588
  var closeTag = "</" + tagName + ">";
21054
22589
  Object.keys(attrs).forEach(function (attrName) {
21055
- openTag += " " + attrName + "=\"" + attrs[attrName] + "\"";
22590
+ // To prevent broken converting when attributes has double quote string
22591
+ openTag += " " + attrName + "=\"" + attrs[attrName].replace(/"/g, "'") + "\"";
21056
22592
  });
21057
22593
  openTag += '>';
21058
22594
  if (node.attrs.htmlInline) {
@@ -21547,6 +23083,14 @@ function getPluginInfo(plugins, eventEmitter, usageStatistics) {
21547
23083
  var TASK_ATTR_NAME = 'data-task';
21548
23084
  var DISABLED_TASK_ATTR_NAME = 'data-task-disabled';
21549
23085
  var TASK_CHECKED_CLASS_NAME = 'checked';
23086
+ function registerHTMLTagToWhitelist(convertorMap) {
23087
+ ['htmlBlock', 'htmlInline'].forEach(function (htmlType) {
23088
+ if (convertorMap[htmlType]) {
23089
+ // register tag white list for preventing to remove the html in sanitizer
23090
+ Object.keys(convertorMap[htmlType]).forEach(function (type) { return registerTagWhitelistIfPossible(type); });
23091
+ }
23092
+ });
23093
+ }
21550
23094
  /**
21551
23095
  * Class ToastUIEditorViewer
21552
23096
  * @param {object} options Option object
@@ -21592,6 +23136,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
21592
23136
  frontMatter: frontMatter,
21593
23137
  sanitizer: customHTMLSanitizer || sanitizeHTML,
21594
23138
  };
23139
+ registerHTMLTagToWhitelist(rendererOptions.customHTMLRenderer);
21595
23140
  if (this.options.events) {
21596
23141
  forEachOwnProperties_default()(this.options.events, function (fn, key) {
21597
23142
  _this.on(key, fn);
@@ -21612,7 +23157,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
21612
23157
  customParser: markdownParsers,
21613
23158
  });
21614
23159
  this.preview = new mdPreview(this.eventEmitter, __assign(__assign({}, rendererOptions), { isViewer: true }));
21615
- on_default()(this.preview.el, 'mousedown', this.toggleTask.bind(this));
23160
+ on_default()(this.preview.previewContent, 'mousedown', this.toggleTask.bind(this));
21616
23161
  if (initialValue) {
21617
23162
  this.setMarkdown(initialValue);
21618
23163
  }
@@ -22047,6 +23592,19 @@ var ScrollSync = /** @class */ (function () {
22047
23592
  }());
22048
23593
 
22049
23594
 
23595
+ ;// CONCATENATED MODULE: ./src/queries/queryManager.ts
23596
+ var queryMap = {
23597
+ getPopupInitialValues: function (editor, payload) {
23598
+ var popupName = payload.popupName;
23599
+ return popupName === 'link' ? { linkText: editor.getSelectedText() } : {};
23600
+ },
23601
+ };
23602
+ function buildQuery(editor) {
23603
+ editor.eventEmitter.listen('query', function (query, payload) {
23604
+ return queryMap[query](editor, payload);
23605
+ });
23606
+ }
23607
+
22050
23608
  ;// CONCATENATED MODULE: ./src/editorCore.ts
22051
23609
 
22052
23610
 
@@ -22074,6 +23632,7 @@ var ScrollSync = /** @class */ (function () {
22074
23632
 
22075
23633
 
22076
23634
 
23635
+
22077
23636
 
22078
23637
 
22079
23638
  /**
@@ -22115,11 +23674,12 @@ var ScrollSync = /** @class */ (function () {
22115
23674
  * @param {boolean} [options.frontMatter=false] - whether use the front matter
22116
23675
  * @param {Array.<object>} [options.widgetRules=[]] - The rules for replacing the text with widget node
22117
23676
  * @param {string} [options.theme] - The theme to style the editor with. The default is included in toastui-editor.css.
23677
+ * @param {autofocus} [options.autofocus=true] - automatically focus the editor on creation.
22118
23678
  */
22119
23679
  var ToastUIEditorCore = /** @class */ (function () {
22120
23680
  function ToastUIEditorCore(options) {
22121
23681
  var _this = this;
22122
- this.initialHtml = options.el.innerHTML;
23682
+ this.initialHTML = options.el.innerHTML;
22123
23683
  options.el.innerHTML = '';
22124
23684
  this.options = extend_default()({
22125
23685
  previewStyle: 'tab',
@@ -22148,10 +23708,13 @@ var ToastUIEditorCore = /** @class */ (function () {
22148
23708
  frontMatter: false,
22149
23709
  widgetRules: [],
22150
23710
  theme: 'light',
23711
+ autofocus: true,
22151
23712
  }, options);
22152
23713
  var _a = this.options, customHTMLRenderer = _a.customHTMLRenderer, extendedAutolinks = _a.extendedAutolinks, referenceDefinition = _a.referenceDefinition, frontMatter = _a.frontMatter, customMarkdownRenderer = _a.customMarkdownRenderer, useCommandShortcut = _a.useCommandShortcut, initialEditType = _a.initialEditType, widgetRules = _a.widgetRules, customHTMLSanitizer = _a.customHTMLSanitizer;
22153
23714
  this.mode = initialEditType || 'markdown';
22154
23715
  this.mdPreviewStyle = this.options.previewStyle;
23716
+ this.i18n = i18n;
23717
+ this.i18n.setCode(this.options.language);
22155
23718
  this.eventEmitter = new eventEmitter();
22156
23719
  setWidgetRules(widgetRules);
22157
23720
  var linkAttributes = sanitizeLinkAttribute(this.options.linkAttributes);
@@ -22167,8 +23730,6 @@ var ToastUIEditorCore = /** @class */ (function () {
22167
23730
  };
22168
23731
  var wwToDOMAdaptor = new WwToDOMAdaptor(linkAttributes, rendererOptions.customHTMLRenderer);
22169
23732
  var htmlSchemaMap = createHTMLSchemaMap(rendererOptions.customHTMLRenderer, rendererOptions.sanitizer, wwToDOMAdaptor);
22170
- this.i18n = i18n;
22171
- this.i18n.setCode(this.options.language);
22172
23733
  this.toastMark = new ToastMark('', {
22173
23734
  disallowedHtmlBlockTags: ['br', 'img'],
22174
23735
  extendedAutolinks: extendedAutolinks,
@@ -22199,7 +23760,7 @@ var ToastUIEditorCore = /** @class */ (function () {
22199
23760
  this.setPlaceholder(this.options.placeholder);
22200
23761
  }
22201
23762
  if (!this.options.initialValue) {
22202
- this.setHTML(this.initialHtml, false);
23763
+ this.setHTML(this.initialHTML, false);
22203
23764
  }
22204
23765
  this.commandManager = new commandManager(this.eventEmitter, this.mdEditor.commands, this.wwEditor.commands, function () { return _this.mode; });
22205
23766
  if (this.options.usageStatistics) {
@@ -22208,6 +23769,7 @@ var ToastUIEditorCore = /** @class */ (function () {
22208
23769
  this.scrollSync = new ScrollSync(this.mdEditor, this.preview, this.eventEmitter);
22209
23770
  this.addInitEvent();
22210
23771
  this.addInitCommand(mdCommands, wwCommands);
23772
+ buildQuery(this);
22211
23773
  if (this.options.hooks) {
22212
23774
  forEachOwnProperties_default()(this.options.hooks, function (fn, key) { return _this.addHook(key, fn); });
22213
23775
  }
@@ -22215,7 +23777,7 @@ var ToastUIEditorCore = /** @class */ (function () {
22215
23777
  forEachOwnProperties_default()(this.options.events, function (fn, key) { return _this.on(key, fn); });
22216
23778
  }
22217
23779
  this.eventEmitter.emit('load', this);
22218
- this.moveCursorToStart();
23780
+ this.moveCursorToStart(this.options.autofocus);
22219
23781
  }
22220
23782
  ToastUIEditorCore.prototype.addInitEvent = function () {
22221
23783
  this.on('needChangeMode', this.changeMode.bind(this));
@@ -22331,15 +23893,19 @@ var ToastUIEditorCore = /** @class */ (function () {
22331
23893
  };
22332
23894
  /**
22333
23895
  * Set cursor position to end
23896
+ * @param {boolean} [focus] - automatically focus the editor
22334
23897
  */
22335
- ToastUIEditorCore.prototype.moveCursorToEnd = function () {
22336
- this.getCurrentModeEditor().moveCursorToEnd();
23898
+ ToastUIEditorCore.prototype.moveCursorToEnd = function (focus) {
23899
+ if (focus === void 0) { focus = true; }
23900
+ this.getCurrentModeEditor().moveCursorToEnd(focus);
22337
23901
  };
22338
23902
  /**
22339
23903
  * Set cursor position to start
23904
+ * @param {boolean} [focus] - automatically focus the editor
22340
23905
  */
22341
- ToastUIEditorCore.prototype.moveCursorToStart = function () {
22342
- this.getCurrentModeEditor().moveCursorToStart();
23906
+ ToastUIEditorCore.prototype.moveCursorToStart = function (focus) {
23907
+ if (focus === void 0) { focus = true; }
23908
+ this.getCurrentModeEditor().moveCursorToStart(focus);
22343
23909
  };
22344
23910
  /**
22345
23911
  * Set markdown syntax text.
@@ -22392,16 +23958,13 @@ var ToastUIEditorCore = /** @class */ (function () {
22392
23958
  ToastUIEditorCore.prototype.getHTML = function () {
22393
23959
  var _this = this;
22394
23960
  this.eventEmitter.holdEventInvoke(function () {
22395
- if (_this.isWysiwygMode()) {
22396
- _this.mdEditor.setMarkdown(_this.convertor.toMarkdownText(_this.wwEditor.getModel()));
23961
+ if (_this.isMarkdownMode()) {
23962
+ var mdNode = _this.toastMark.getRootNode();
23963
+ var wwNode = _this.convertor.toWysiwygModel(mdNode);
23964
+ _this.wwEditor.setModel(wwNode);
22397
23965
  }
22398
23966
  });
22399
- var mdNode = this.toastMark.getRootNode();
22400
- var mdRenderer = this.preview.getRenderer();
22401
- return mdRenderer
22402
- .render(mdNode)
22403
- .replace(/\sdata-nodeid="\d{1,}"/g, '')
22404
- .trim();
23967
+ return this.wwEditor.view.dom.innerHTML;
22405
23968
  };
22406
23969
  /**
22407
23970
  * Insert text
@@ -23196,6 +24759,936 @@ var templateObject_1;
23196
24759
  // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/tricks/throttle.js
23197
24760
  var throttle = __webpack_require__(423);
23198
24761
  var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle);
24762
+ ;// CONCATENATED MODULE: ../../node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js
24763
+ /**
24764
+ * A collection of shims that provide minimal functionality of the ES6 collections.
24765
+ *
24766
+ * These implementations are not meant to be used outside of the ResizeObserver
24767
+ * modules as they cover only a limited range of use cases.
24768
+ */
24769
+ /* eslint-disable require-jsdoc, valid-jsdoc */
24770
+ var MapShim = (function () {
24771
+ if (typeof Map !== 'undefined') {
24772
+ return Map;
24773
+ }
24774
+ /**
24775
+ * Returns index in provided array that matches the specified key.
24776
+ *
24777
+ * @param {Array<Array>} arr
24778
+ * @param {*} key
24779
+ * @returns {number}
24780
+ */
24781
+ function getIndex(arr, key) {
24782
+ var result = -1;
24783
+ arr.some(function (entry, index) {
24784
+ if (entry[0] === key) {
24785
+ result = index;
24786
+ return true;
24787
+ }
24788
+ return false;
24789
+ });
24790
+ return result;
24791
+ }
24792
+ return /** @class */ (function () {
24793
+ function class_1() {
24794
+ this.__entries__ = [];
24795
+ }
24796
+ Object.defineProperty(class_1.prototype, "size", {
24797
+ /**
24798
+ * @returns {boolean}
24799
+ */
24800
+ get: function () {
24801
+ return this.__entries__.length;
24802
+ },
24803
+ enumerable: true,
24804
+ configurable: true
24805
+ });
24806
+ /**
24807
+ * @param {*} key
24808
+ * @returns {*}
24809
+ */
24810
+ class_1.prototype.get = function (key) {
24811
+ var index = getIndex(this.__entries__, key);
24812
+ var entry = this.__entries__[index];
24813
+ return entry && entry[1];
24814
+ };
24815
+ /**
24816
+ * @param {*} key
24817
+ * @param {*} value
24818
+ * @returns {void}
24819
+ */
24820
+ class_1.prototype.set = function (key, value) {
24821
+ var index = getIndex(this.__entries__, key);
24822
+ if (~index) {
24823
+ this.__entries__[index][1] = value;
24824
+ }
24825
+ else {
24826
+ this.__entries__.push([key, value]);
24827
+ }
24828
+ };
24829
+ /**
24830
+ * @param {*} key
24831
+ * @returns {void}
24832
+ */
24833
+ class_1.prototype.delete = function (key) {
24834
+ var entries = this.__entries__;
24835
+ var index = getIndex(entries, key);
24836
+ if (~index) {
24837
+ entries.splice(index, 1);
24838
+ }
24839
+ };
24840
+ /**
24841
+ * @param {*} key
24842
+ * @returns {void}
24843
+ */
24844
+ class_1.prototype.has = function (key) {
24845
+ return !!~getIndex(this.__entries__, key);
24846
+ };
24847
+ /**
24848
+ * @returns {void}
24849
+ */
24850
+ class_1.prototype.clear = function () {
24851
+ this.__entries__.splice(0);
24852
+ };
24853
+ /**
24854
+ * @param {Function} callback
24855
+ * @param {*} [ctx=null]
24856
+ * @returns {void}
24857
+ */
24858
+ class_1.prototype.forEach = function (callback, ctx) {
24859
+ if (ctx === void 0) { ctx = null; }
24860
+ for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
24861
+ var entry = _a[_i];
24862
+ callback.call(ctx, entry[1], entry[0]);
24863
+ }
24864
+ };
24865
+ return class_1;
24866
+ }());
24867
+ })();
24868
+
24869
+ /**
24870
+ * Detects whether window and document objects are available in current environment.
24871
+ */
24872
+ var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
24873
+
24874
+ // Returns global object of a current environment.
24875
+ var global$1 = (function () {
24876
+ if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.Math === Math) {
24877
+ return __webpack_require__.g;
24878
+ }
24879
+ if (typeof self !== 'undefined' && self.Math === Math) {
24880
+ return self;
24881
+ }
24882
+ if (typeof window !== 'undefined' && window.Math === Math) {
24883
+ return window;
24884
+ }
24885
+ // eslint-disable-next-line no-new-func
24886
+ return Function('return this')();
24887
+ })();
24888
+
24889
+ /**
24890
+ * A shim for the requestAnimationFrame which falls back to the setTimeout if
24891
+ * first one is not supported.
24892
+ *
24893
+ * @returns {number} Requests' identifier.
24894
+ */
24895
+ var requestAnimationFrame$1 = (function () {
24896
+ if (typeof requestAnimationFrame === 'function') {
24897
+ // It's required to use a bounded function because IE sometimes throws
24898
+ // an "Invalid calling object" error if rAF is invoked without the global
24899
+ // object on the left hand side.
24900
+ return requestAnimationFrame.bind(global$1);
24901
+ }
24902
+ return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
24903
+ })();
24904
+
24905
+ // Defines minimum timeout before adding a trailing call.
24906
+ var trailingTimeout = 2;
24907
+ /**
24908
+ * Creates a wrapper function which ensures that provided callback will be
24909
+ * invoked only once during the specified delay period.
24910
+ *
24911
+ * @param {Function} callback - Function to be invoked after the delay period.
24912
+ * @param {number} delay - Delay after which to invoke callback.
24913
+ * @returns {Function}
24914
+ */
24915
+ function ResizeObserver_es_throttle (callback, delay) {
24916
+ var leadingCall = false, trailingCall = false, lastCallTime = 0;
24917
+ /**
24918
+ * Invokes the original callback function and schedules new invocation if
24919
+ * the "proxy" was called during current request.
24920
+ *
24921
+ * @returns {void}
24922
+ */
24923
+ function resolvePending() {
24924
+ if (leadingCall) {
24925
+ leadingCall = false;
24926
+ callback();
24927
+ }
24928
+ if (trailingCall) {
24929
+ proxy();
24930
+ }
24931
+ }
24932
+ /**
24933
+ * Callback invoked after the specified delay. It will further postpone
24934
+ * invocation of the original function delegating it to the
24935
+ * requestAnimationFrame.
24936
+ *
24937
+ * @returns {void}
24938
+ */
24939
+ function timeoutCallback() {
24940
+ requestAnimationFrame$1(resolvePending);
24941
+ }
24942
+ /**
24943
+ * Schedules invocation of the original function.
24944
+ *
24945
+ * @returns {void}
24946
+ */
24947
+ function proxy() {
24948
+ var timeStamp = Date.now();
24949
+ if (leadingCall) {
24950
+ // Reject immediately following calls.
24951
+ if (timeStamp - lastCallTime < trailingTimeout) {
24952
+ return;
24953
+ }
24954
+ // Schedule new call to be in invoked when the pending one is resolved.
24955
+ // This is important for "transitions" which never actually start
24956
+ // immediately so there is a chance that we might miss one if change
24957
+ // happens amids the pending invocation.
24958
+ trailingCall = true;
24959
+ }
24960
+ else {
24961
+ leadingCall = true;
24962
+ trailingCall = false;
24963
+ setTimeout(timeoutCallback, delay);
24964
+ }
24965
+ lastCallTime = timeStamp;
24966
+ }
24967
+ return proxy;
24968
+ }
24969
+
24970
+ // Minimum delay before invoking the update of observers.
24971
+ var REFRESH_DELAY = 20;
24972
+ // A list of substrings of CSS properties used to find transition events that
24973
+ // might affect dimensions of observed elements.
24974
+ var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
24975
+ // Check if MutationObserver is available.
24976
+ var mutationObserverSupported = typeof MutationObserver !== 'undefined';
24977
+ /**
24978
+ * Singleton controller class which handles updates of ResizeObserver instances.
24979
+ */
24980
+ var ResizeObserverController = /** @class */ (function () {
24981
+ /**
24982
+ * Creates a new instance of ResizeObserverController.
24983
+ *
24984
+ * @private
24985
+ */
24986
+ function ResizeObserverController() {
24987
+ /**
24988
+ * Indicates whether DOM listeners have been added.
24989
+ *
24990
+ * @private {boolean}
24991
+ */
24992
+ this.connected_ = false;
24993
+ /**
24994
+ * Tells that controller has subscribed for Mutation Events.
24995
+ *
24996
+ * @private {boolean}
24997
+ */
24998
+ this.mutationEventsAdded_ = false;
24999
+ /**
25000
+ * Keeps reference to the instance of MutationObserver.
25001
+ *
25002
+ * @private {MutationObserver}
25003
+ */
25004
+ this.mutationsObserver_ = null;
25005
+ /**
25006
+ * A list of connected observers.
25007
+ *
25008
+ * @private {Array<ResizeObserverSPI>}
25009
+ */
25010
+ this.observers_ = [];
25011
+ this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
25012
+ this.refresh = ResizeObserver_es_throttle(this.refresh.bind(this), REFRESH_DELAY);
25013
+ }
25014
+ /**
25015
+ * Adds observer to observers list.
25016
+ *
25017
+ * @param {ResizeObserverSPI} observer - Observer to be added.
25018
+ * @returns {void}
25019
+ */
25020
+ ResizeObserverController.prototype.addObserver = function (observer) {
25021
+ if (!~this.observers_.indexOf(observer)) {
25022
+ this.observers_.push(observer);
25023
+ }
25024
+ // Add listeners if they haven't been added yet.
25025
+ if (!this.connected_) {
25026
+ this.connect_();
25027
+ }
25028
+ };
25029
+ /**
25030
+ * Removes observer from observers list.
25031
+ *
25032
+ * @param {ResizeObserverSPI} observer - Observer to be removed.
25033
+ * @returns {void}
25034
+ */
25035
+ ResizeObserverController.prototype.removeObserver = function (observer) {
25036
+ var observers = this.observers_;
25037
+ var index = observers.indexOf(observer);
25038
+ // Remove observer if it's present in registry.
25039
+ if (~index) {
25040
+ observers.splice(index, 1);
25041
+ }
25042
+ // Remove listeners if controller has no connected observers.
25043
+ if (!observers.length && this.connected_) {
25044
+ this.disconnect_();
25045
+ }
25046
+ };
25047
+ /**
25048
+ * Invokes the update of observers. It will continue running updates insofar
25049
+ * it detects changes.
25050
+ *
25051
+ * @returns {void}
25052
+ */
25053
+ ResizeObserverController.prototype.refresh = function () {
25054
+ var changesDetected = this.updateObservers_();
25055
+ // Continue running updates if changes have been detected as there might
25056
+ // be future ones caused by CSS transitions.
25057
+ if (changesDetected) {
25058
+ this.refresh();
25059
+ }
25060
+ };
25061
+ /**
25062
+ * Updates every observer from observers list and notifies them of queued
25063
+ * entries.
25064
+ *
25065
+ * @private
25066
+ * @returns {boolean} Returns "true" if any observer has detected changes in
25067
+ * dimensions of it's elements.
25068
+ */
25069
+ ResizeObserverController.prototype.updateObservers_ = function () {
25070
+ // Collect observers that have active observations.
25071
+ var activeObservers = this.observers_.filter(function (observer) {
25072
+ return observer.gatherActive(), observer.hasActive();
25073
+ });
25074
+ // Deliver notifications in a separate cycle in order to avoid any
25075
+ // collisions between observers, e.g. when multiple instances of
25076
+ // ResizeObserver are tracking the same element and the callback of one
25077
+ // of them changes content dimensions of the observed target. Sometimes
25078
+ // this may result in notifications being blocked for the rest of observers.
25079
+ activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
25080
+ return activeObservers.length > 0;
25081
+ };
25082
+ /**
25083
+ * Initializes DOM listeners.
25084
+ *
25085
+ * @private
25086
+ * @returns {void}
25087
+ */
25088
+ ResizeObserverController.prototype.connect_ = function () {
25089
+ // Do nothing if running in a non-browser environment or if listeners
25090
+ // have been already added.
25091
+ if (!isBrowser || this.connected_) {
25092
+ return;
25093
+ }
25094
+ // Subscription to the "Transitionend" event is used as a workaround for
25095
+ // delayed transitions. This way it's possible to capture at least the
25096
+ // final state of an element.
25097
+ document.addEventListener('transitionend', this.onTransitionEnd_);
25098
+ window.addEventListener('resize', this.refresh);
25099
+ if (mutationObserverSupported) {
25100
+ this.mutationsObserver_ = new MutationObserver(this.refresh);
25101
+ this.mutationsObserver_.observe(document, {
25102
+ attributes: true,
25103
+ childList: true,
25104
+ characterData: true,
25105
+ subtree: true
25106
+ });
25107
+ }
25108
+ else {
25109
+ document.addEventListener('DOMSubtreeModified', this.refresh);
25110
+ this.mutationEventsAdded_ = true;
25111
+ }
25112
+ this.connected_ = true;
25113
+ };
25114
+ /**
25115
+ * Removes DOM listeners.
25116
+ *
25117
+ * @private
25118
+ * @returns {void}
25119
+ */
25120
+ ResizeObserverController.prototype.disconnect_ = function () {
25121
+ // Do nothing if running in a non-browser environment or if listeners
25122
+ // have been already removed.
25123
+ if (!isBrowser || !this.connected_) {
25124
+ return;
25125
+ }
25126
+ document.removeEventListener('transitionend', this.onTransitionEnd_);
25127
+ window.removeEventListener('resize', this.refresh);
25128
+ if (this.mutationsObserver_) {
25129
+ this.mutationsObserver_.disconnect();
25130
+ }
25131
+ if (this.mutationEventsAdded_) {
25132
+ document.removeEventListener('DOMSubtreeModified', this.refresh);
25133
+ }
25134
+ this.mutationsObserver_ = null;
25135
+ this.mutationEventsAdded_ = false;
25136
+ this.connected_ = false;
25137
+ };
25138
+ /**
25139
+ * "Transitionend" event handler.
25140
+ *
25141
+ * @private
25142
+ * @param {TransitionEvent} event
25143
+ * @returns {void}
25144
+ */
25145
+ ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
25146
+ var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
25147
+ // Detect whether transition may affect dimensions of an element.
25148
+ var isReflowProperty = transitionKeys.some(function (key) {
25149
+ return !!~propertyName.indexOf(key);
25150
+ });
25151
+ if (isReflowProperty) {
25152
+ this.refresh();
25153
+ }
25154
+ };
25155
+ /**
25156
+ * Returns instance of the ResizeObserverController.
25157
+ *
25158
+ * @returns {ResizeObserverController}
25159
+ */
25160
+ ResizeObserverController.getInstance = function () {
25161
+ if (!this.instance_) {
25162
+ this.instance_ = new ResizeObserverController();
25163
+ }
25164
+ return this.instance_;
25165
+ };
25166
+ /**
25167
+ * Holds reference to the controller's instance.
25168
+ *
25169
+ * @private {ResizeObserverController}
25170
+ */
25171
+ ResizeObserverController.instance_ = null;
25172
+ return ResizeObserverController;
25173
+ }());
25174
+
25175
+ /**
25176
+ * Defines non-writable/enumerable properties of the provided target object.
25177
+ *
25178
+ * @param {Object} target - Object for which to define properties.
25179
+ * @param {Object} props - Properties to be defined.
25180
+ * @returns {Object} Target object.
25181
+ */
25182
+ var defineConfigurable = (function (target, props) {
25183
+ for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
25184
+ var key = _a[_i];
25185
+ Object.defineProperty(target, key, {
25186
+ value: props[key],
25187
+ enumerable: false,
25188
+ writable: false,
25189
+ configurable: true
25190
+ });
25191
+ }
25192
+ return target;
25193
+ });
25194
+
25195
+ /**
25196
+ * Returns the global object associated with provided element.
25197
+ *
25198
+ * @param {Object} target
25199
+ * @returns {Object}
25200
+ */
25201
+ var getWindowOf = (function (target) {
25202
+ // Assume that the element is an instance of Node, which means that it
25203
+ // has the "ownerDocument" property from which we can retrieve a
25204
+ // corresponding global object.
25205
+ var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
25206
+ // Return the local global object if it's not possible extract one from
25207
+ // provided element.
25208
+ return ownerGlobal || global$1;
25209
+ });
25210
+
25211
+ // Placeholder of an empty content rectangle.
25212
+ var emptyRect = createRectInit(0, 0, 0, 0);
25213
+ /**
25214
+ * Converts provided string to a number.
25215
+ *
25216
+ * @param {number|string} value
25217
+ * @returns {number}
25218
+ */
25219
+ function toFloat(value) {
25220
+ return parseFloat(value) || 0;
25221
+ }
25222
+ /**
25223
+ * Extracts borders size from provided styles.
25224
+ *
25225
+ * @param {CSSStyleDeclaration} styles
25226
+ * @param {...string} positions - Borders positions (top, right, ...)
25227
+ * @returns {number}
25228
+ */
25229
+ function getBordersSize(styles) {
25230
+ var positions = [];
25231
+ for (var _i = 1; _i < arguments.length; _i++) {
25232
+ positions[_i - 1] = arguments[_i];
25233
+ }
25234
+ return positions.reduce(function (size, position) {
25235
+ var value = styles['border-' + position + '-width'];
25236
+ return size + toFloat(value);
25237
+ }, 0);
25238
+ }
25239
+ /**
25240
+ * Extracts paddings sizes from provided styles.
25241
+ *
25242
+ * @param {CSSStyleDeclaration} styles
25243
+ * @returns {Object} Paddings box.
25244
+ */
25245
+ function getPaddings(styles) {
25246
+ var positions = ['top', 'right', 'bottom', 'left'];
25247
+ var paddings = {};
25248
+ for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
25249
+ var position = positions_1[_i];
25250
+ var value = styles['padding-' + position];
25251
+ paddings[position] = toFloat(value);
25252
+ }
25253
+ return paddings;
25254
+ }
25255
+ /**
25256
+ * Calculates content rectangle of provided SVG element.
25257
+ *
25258
+ * @param {SVGGraphicsElement} target - Element content rectangle of which needs
25259
+ * to be calculated.
25260
+ * @returns {DOMRectInit}
25261
+ */
25262
+ function getSVGContentRect(target) {
25263
+ var bbox = target.getBBox();
25264
+ return createRectInit(0, 0, bbox.width, bbox.height);
25265
+ }
25266
+ /**
25267
+ * Calculates content rectangle of provided HTMLElement.
25268
+ *
25269
+ * @param {HTMLElement} target - Element for which to calculate the content rectangle.
25270
+ * @returns {DOMRectInit}
25271
+ */
25272
+ function getHTMLElementContentRect(target) {
25273
+ // Client width & height properties can't be
25274
+ // used exclusively as they provide rounded values.
25275
+ var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
25276
+ // By this condition we can catch all non-replaced inline, hidden and
25277
+ // detached elements. Though elements with width & height properties less
25278
+ // than 0.5 will be discarded as well.
25279
+ //
25280
+ // Without it we would need to implement separate methods for each of
25281
+ // those cases and it's not possible to perform a precise and performance
25282
+ // effective test for hidden elements. E.g. even jQuery's ':visible' filter
25283
+ // gives wrong results for elements with width & height less than 0.5.
25284
+ if (!clientWidth && !clientHeight) {
25285
+ return emptyRect;
25286
+ }
25287
+ var styles = getWindowOf(target).getComputedStyle(target);
25288
+ var paddings = getPaddings(styles);
25289
+ var horizPad = paddings.left + paddings.right;
25290
+ var vertPad = paddings.top + paddings.bottom;
25291
+ // Computed styles of width & height are being used because they are the
25292
+ // only dimensions available to JS that contain non-rounded values. It could
25293
+ // be possible to utilize the getBoundingClientRect if only it's data wasn't
25294
+ // affected by CSS transformations let alone paddings, borders and scroll bars.
25295
+ var width = toFloat(styles.width), height = toFloat(styles.height);
25296
+ // Width & height include paddings and borders when the 'border-box' box
25297
+ // model is applied (except for IE).
25298
+ if (styles.boxSizing === 'border-box') {
25299
+ // Following conditions are required to handle Internet Explorer which
25300
+ // doesn't include paddings and borders to computed CSS dimensions.
25301
+ //
25302
+ // We can say that if CSS dimensions + paddings are equal to the "client"
25303
+ // properties then it's either IE, and thus we don't need to subtract
25304
+ // anything, or an element merely doesn't have paddings/borders styles.
25305
+ if (Math.round(width + horizPad) !== clientWidth) {
25306
+ width -= getBordersSize(styles, 'left', 'right') + horizPad;
25307
+ }
25308
+ if (Math.round(height + vertPad) !== clientHeight) {
25309
+ height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
25310
+ }
25311
+ }
25312
+ // Following steps can't be applied to the document's root element as its
25313
+ // client[Width/Height] properties represent viewport area of the window.
25314
+ // Besides, it's as well not necessary as the <html> itself neither has
25315
+ // rendered scroll bars nor it can be clipped.
25316
+ if (!isDocumentElement(target)) {
25317
+ // In some browsers (only in Firefox, actually) CSS width & height
25318
+ // include scroll bars size which can be removed at this step as scroll
25319
+ // bars are the only difference between rounded dimensions + paddings
25320
+ // and "client" properties, though that is not always true in Chrome.
25321
+ var vertScrollbar = Math.round(width + horizPad) - clientWidth;
25322
+ var horizScrollbar = Math.round(height + vertPad) - clientHeight;
25323
+ // Chrome has a rather weird rounding of "client" properties.
25324
+ // E.g. for an element with content width of 314.2px it sometimes gives
25325
+ // the client width of 315px and for the width of 314.7px it may give
25326
+ // 314px. And it doesn't happen all the time. So just ignore this delta
25327
+ // as a non-relevant.
25328
+ if (Math.abs(vertScrollbar) !== 1) {
25329
+ width -= vertScrollbar;
25330
+ }
25331
+ if (Math.abs(horizScrollbar) !== 1) {
25332
+ height -= horizScrollbar;
25333
+ }
25334
+ }
25335
+ return createRectInit(paddings.left, paddings.top, width, height);
25336
+ }
25337
+ /**
25338
+ * Checks whether provided element is an instance of the SVGGraphicsElement.
25339
+ *
25340
+ * @param {Element} target - Element to be checked.
25341
+ * @returns {boolean}
25342
+ */
25343
+ var isSVGGraphicsElement = (function () {
25344
+ // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
25345
+ // interface.
25346
+ if (typeof SVGGraphicsElement !== 'undefined') {
25347
+ return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
25348
+ }
25349
+ // If it's so, then check that element is at least an instance of the
25350
+ // SVGElement and that it has the "getBBox" method.
25351
+ // eslint-disable-next-line no-extra-parens
25352
+ return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
25353
+ typeof target.getBBox === 'function'); };
25354
+ })();
25355
+ /**
25356
+ * Checks whether provided element is a document element (<html>).
25357
+ *
25358
+ * @param {Element} target - Element to be checked.
25359
+ * @returns {boolean}
25360
+ */
25361
+ function isDocumentElement(target) {
25362
+ return target === getWindowOf(target).document.documentElement;
25363
+ }
25364
+ /**
25365
+ * Calculates an appropriate content rectangle for provided html or svg element.
25366
+ *
25367
+ * @param {Element} target - Element content rectangle of which needs to be calculated.
25368
+ * @returns {DOMRectInit}
25369
+ */
25370
+ function getContentRect(target) {
25371
+ if (!isBrowser) {
25372
+ return emptyRect;
25373
+ }
25374
+ if (isSVGGraphicsElement(target)) {
25375
+ return getSVGContentRect(target);
25376
+ }
25377
+ return getHTMLElementContentRect(target);
25378
+ }
25379
+ /**
25380
+ * Creates rectangle with an interface of the DOMRectReadOnly.
25381
+ * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
25382
+ *
25383
+ * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
25384
+ * @returns {DOMRectReadOnly}
25385
+ */
25386
+ function createReadOnlyRect(_a) {
25387
+ var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
25388
+ // If DOMRectReadOnly is available use it as a prototype for the rectangle.
25389
+ var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
25390
+ var rect = Object.create(Constr.prototype);
25391
+ // Rectangle's properties are not writable and non-enumerable.
25392
+ defineConfigurable(rect, {
25393
+ x: x, y: y, width: width, height: height,
25394
+ top: y,
25395
+ right: x + width,
25396
+ bottom: height + y,
25397
+ left: x
25398
+ });
25399
+ return rect;
25400
+ }
25401
+ /**
25402
+ * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
25403
+ * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
25404
+ *
25405
+ * @param {number} x - X coordinate.
25406
+ * @param {number} y - Y coordinate.
25407
+ * @param {number} width - Rectangle's width.
25408
+ * @param {number} height - Rectangle's height.
25409
+ * @returns {DOMRectInit}
25410
+ */
25411
+ function createRectInit(x, y, width, height) {
25412
+ return { x: x, y: y, width: width, height: height };
25413
+ }
25414
+
25415
+ /**
25416
+ * Class that is responsible for computations of the content rectangle of
25417
+ * provided DOM element and for keeping track of it's changes.
25418
+ */
25419
+ var ResizeObservation = /** @class */ (function () {
25420
+ /**
25421
+ * Creates an instance of ResizeObservation.
25422
+ *
25423
+ * @param {Element} target - Element to be observed.
25424
+ */
25425
+ function ResizeObservation(target) {
25426
+ /**
25427
+ * Broadcasted width of content rectangle.
25428
+ *
25429
+ * @type {number}
25430
+ */
25431
+ this.broadcastWidth = 0;
25432
+ /**
25433
+ * Broadcasted height of content rectangle.
25434
+ *
25435
+ * @type {number}
25436
+ */
25437
+ this.broadcastHeight = 0;
25438
+ /**
25439
+ * Reference to the last observed content rectangle.
25440
+ *
25441
+ * @private {DOMRectInit}
25442
+ */
25443
+ this.contentRect_ = createRectInit(0, 0, 0, 0);
25444
+ this.target = target;
25445
+ }
25446
+ /**
25447
+ * Updates content rectangle and tells whether it's width or height properties
25448
+ * have changed since the last broadcast.
25449
+ *
25450
+ * @returns {boolean}
25451
+ */
25452
+ ResizeObservation.prototype.isActive = function () {
25453
+ var rect = getContentRect(this.target);
25454
+ this.contentRect_ = rect;
25455
+ return (rect.width !== this.broadcastWidth ||
25456
+ rect.height !== this.broadcastHeight);
25457
+ };
25458
+ /**
25459
+ * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
25460
+ * from the corresponding properties of the last observed content rectangle.
25461
+ *
25462
+ * @returns {DOMRectInit} Last observed content rectangle.
25463
+ */
25464
+ ResizeObservation.prototype.broadcastRect = function () {
25465
+ var rect = this.contentRect_;
25466
+ this.broadcastWidth = rect.width;
25467
+ this.broadcastHeight = rect.height;
25468
+ return rect;
25469
+ };
25470
+ return ResizeObservation;
25471
+ }());
25472
+
25473
+ var ResizeObserverEntry = /** @class */ (function () {
25474
+ /**
25475
+ * Creates an instance of ResizeObserverEntry.
25476
+ *
25477
+ * @param {Element} target - Element that is being observed.
25478
+ * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
25479
+ */
25480
+ function ResizeObserverEntry(target, rectInit) {
25481
+ var contentRect = createReadOnlyRect(rectInit);
25482
+ // According to the specification following properties are not writable
25483
+ // and are also not enumerable in the native implementation.
25484
+ //
25485
+ // Property accessors are not being used as they'd require to define a
25486
+ // private WeakMap storage which may cause memory leaks in browsers that
25487
+ // don't support this type of collections.
25488
+ defineConfigurable(this, { target: target, contentRect: contentRect });
25489
+ }
25490
+ return ResizeObserverEntry;
25491
+ }());
25492
+
25493
+ var ResizeObserverSPI = /** @class */ (function () {
25494
+ /**
25495
+ * Creates a new instance of ResizeObserver.
25496
+ *
25497
+ * @param {ResizeObserverCallback} callback - Callback function that is invoked
25498
+ * when one of the observed elements changes it's content dimensions.
25499
+ * @param {ResizeObserverController} controller - Controller instance which
25500
+ * is responsible for the updates of observer.
25501
+ * @param {ResizeObserver} callbackCtx - Reference to the public
25502
+ * ResizeObserver instance which will be passed to callback function.
25503
+ */
25504
+ function ResizeObserverSPI(callback, controller, callbackCtx) {
25505
+ /**
25506
+ * Collection of resize observations that have detected changes in dimensions
25507
+ * of elements.
25508
+ *
25509
+ * @private {Array<ResizeObservation>}
25510
+ */
25511
+ this.activeObservations_ = [];
25512
+ /**
25513
+ * Registry of the ResizeObservation instances.
25514
+ *
25515
+ * @private {Map<Element, ResizeObservation>}
25516
+ */
25517
+ this.observations_ = new MapShim();
25518
+ if (typeof callback !== 'function') {
25519
+ throw new TypeError('The callback provided as parameter 1 is not a function.');
25520
+ }
25521
+ this.callback_ = callback;
25522
+ this.controller_ = controller;
25523
+ this.callbackCtx_ = callbackCtx;
25524
+ }
25525
+ /**
25526
+ * Starts observing provided element.
25527
+ *
25528
+ * @param {Element} target - Element to be observed.
25529
+ * @returns {void}
25530
+ */
25531
+ ResizeObserverSPI.prototype.observe = function (target) {
25532
+ if (!arguments.length) {
25533
+ throw new TypeError('1 argument required, but only 0 present.');
25534
+ }
25535
+ // Do nothing if current environment doesn't have the Element interface.
25536
+ if (typeof Element === 'undefined' || !(Element instanceof Object)) {
25537
+ return;
25538
+ }
25539
+ if (!(target instanceof getWindowOf(target).Element)) {
25540
+ throw new TypeError('parameter 1 is not of type "Element".');
25541
+ }
25542
+ var observations = this.observations_;
25543
+ // Do nothing if element is already being observed.
25544
+ if (observations.has(target)) {
25545
+ return;
25546
+ }
25547
+ observations.set(target, new ResizeObservation(target));
25548
+ this.controller_.addObserver(this);
25549
+ // Force the update of observations.
25550
+ this.controller_.refresh();
25551
+ };
25552
+ /**
25553
+ * Stops observing provided element.
25554
+ *
25555
+ * @param {Element} target - Element to stop observing.
25556
+ * @returns {void}
25557
+ */
25558
+ ResizeObserverSPI.prototype.unobserve = function (target) {
25559
+ if (!arguments.length) {
25560
+ throw new TypeError('1 argument required, but only 0 present.');
25561
+ }
25562
+ // Do nothing if current environment doesn't have the Element interface.
25563
+ if (typeof Element === 'undefined' || !(Element instanceof Object)) {
25564
+ return;
25565
+ }
25566
+ if (!(target instanceof getWindowOf(target).Element)) {
25567
+ throw new TypeError('parameter 1 is not of type "Element".');
25568
+ }
25569
+ var observations = this.observations_;
25570
+ // Do nothing if element is not being observed.
25571
+ if (!observations.has(target)) {
25572
+ return;
25573
+ }
25574
+ observations.delete(target);
25575
+ if (!observations.size) {
25576
+ this.controller_.removeObserver(this);
25577
+ }
25578
+ };
25579
+ /**
25580
+ * Stops observing all elements.
25581
+ *
25582
+ * @returns {void}
25583
+ */
25584
+ ResizeObserverSPI.prototype.disconnect = function () {
25585
+ this.clearActive();
25586
+ this.observations_.clear();
25587
+ this.controller_.removeObserver(this);
25588
+ };
25589
+ /**
25590
+ * Collects observation instances the associated element of which has changed
25591
+ * it's content rectangle.
25592
+ *
25593
+ * @returns {void}
25594
+ */
25595
+ ResizeObserverSPI.prototype.gatherActive = function () {
25596
+ var _this = this;
25597
+ this.clearActive();
25598
+ this.observations_.forEach(function (observation) {
25599
+ if (observation.isActive()) {
25600
+ _this.activeObservations_.push(observation);
25601
+ }
25602
+ });
25603
+ };
25604
+ /**
25605
+ * Invokes initial callback function with a list of ResizeObserverEntry
25606
+ * instances collected from active resize observations.
25607
+ *
25608
+ * @returns {void}
25609
+ */
25610
+ ResizeObserverSPI.prototype.broadcastActive = function () {
25611
+ // Do nothing if observer doesn't have active observations.
25612
+ if (!this.hasActive()) {
25613
+ return;
25614
+ }
25615
+ var ctx = this.callbackCtx_;
25616
+ // Create ResizeObserverEntry instance for every active observation.
25617
+ var entries = this.activeObservations_.map(function (observation) {
25618
+ return new ResizeObserverEntry(observation.target, observation.broadcastRect());
25619
+ });
25620
+ this.callback_.call(ctx, entries, ctx);
25621
+ this.clearActive();
25622
+ };
25623
+ /**
25624
+ * Clears the collection of active observations.
25625
+ *
25626
+ * @returns {void}
25627
+ */
25628
+ ResizeObserverSPI.prototype.clearActive = function () {
25629
+ this.activeObservations_.splice(0);
25630
+ };
25631
+ /**
25632
+ * Tells whether observer has active observations.
25633
+ *
25634
+ * @returns {boolean}
25635
+ */
25636
+ ResizeObserverSPI.prototype.hasActive = function () {
25637
+ return this.activeObservations_.length > 0;
25638
+ };
25639
+ return ResizeObserverSPI;
25640
+ }());
25641
+
25642
+ // Registry of internal observers. If WeakMap is not available use current shim
25643
+ // for the Map collection as it has all required methods and because WeakMap
25644
+ // can't be fully polyfilled anyway.
25645
+ var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
25646
+ /**
25647
+ * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
25648
+ * exposing only those methods and properties that are defined in the spec.
25649
+ */
25650
+ var ResizeObserver = /** @class */ (function () {
25651
+ /**
25652
+ * Creates a new instance of ResizeObserver.
25653
+ *
25654
+ * @param {ResizeObserverCallback} callback - Callback that is invoked when
25655
+ * dimensions of the observed elements change.
25656
+ */
25657
+ function ResizeObserver(callback) {
25658
+ if (!(this instanceof ResizeObserver)) {
25659
+ throw new TypeError('Cannot call a class as a function.');
25660
+ }
25661
+ if (!arguments.length) {
25662
+ throw new TypeError('1 argument required, but only 0 present.');
25663
+ }
25664
+ var controller = ResizeObserverController.getInstance();
25665
+ var observer = new ResizeObserverSPI(callback, controller, this);
25666
+ observers.set(this, observer);
25667
+ }
25668
+ return ResizeObserver;
25669
+ }());
25670
+ // Expose public methods of ResizeObserver.
25671
+ [
25672
+ 'observe',
25673
+ 'unobserve',
25674
+ 'disconnect'
25675
+ ].forEach(function (method) {
25676
+ ResizeObserver.prototype[method] = function () {
25677
+ var _a;
25678
+ return (_a = observers.get(this))[method].apply(_a, arguments);
25679
+ };
25680
+ });
25681
+
25682
+ var index = (function () {
25683
+ // Export existing implementation if available.
25684
+ if (typeof global$1.ResizeObserver !== 'undefined') {
25685
+ return global$1.ResizeObserver;
25686
+ }
25687
+ return ResizeObserver;
25688
+ })();
25689
+
25690
+ /* harmony default export */ var ResizeObserver_es = (index);
25691
+
23199
25692
  ;// CONCATENATED MODULE: ./src/ui/components/toolbar/headingPopupBody.ts
23200
25693
 
23201
25694
 
@@ -23495,17 +25988,17 @@ var TablePopupBody = /** @class */ (function (_super) {
23495
25988
  range.colIdx = Math.min(Math.max(range.colIdx, MIN_COL_SELECTION_INDEX), MAX_COL_INDEX);
23496
25989
  return range;
23497
25990
  };
23498
- TablePopupBody.prototype.mounted = function () {
23499
- var _a = this.refs.tableEl.getBoundingClientRect(), left = _a.left, top = _a.top;
23500
- this.offsetRect = {
23501
- left: window.pageXOffset + left,
23502
- top: window.pageYOffset + top,
23503
- };
23504
- };
23505
25991
  TablePopupBody.prototype.updated = function () {
23506
25992
  if (!this.props.show) {
23507
25993
  this.setState({ colIdx: -1, rowIdx: -1 });
23508
25994
  }
25995
+ else if (this.state.colIdx === -1 && this.state.rowIdx === -1) {
25996
+ var _a = this.refs.tableEl.getBoundingClientRect(), left = _a.left, top = _a.top;
25997
+ this.offsetRect = {
25998
+ left: window.pageXOffset + left,
25999
+ top: window.pageYOffset + top,
26000
+ };
26001
+ }
23509
26002
  };
23510
26003
  TablePopupBody.prototype.createTableArea = function (tableRange) {
23511
26004
  var colIdx = tableRange.colIdx, rowIdx = tableRange.rowIdx;
@@ -23537,15 +26030,17 @@ var tablePopupBody_templateObject_1, tablePopupBody_templateObject_2, templateOb
23537
26030
 
23538
26031
  var CustomPopupBody = /** @class */ (function (_super) {
23539
26032
  __extends(CustomPopupBody, _super);
23540
- function CustomPopupBody(props) {
23541
- var _this = _super.call(this, props) || this;
23542
- props.eventEmitter.listen('closePopup', _this.props.hidePopup);
23543
- return _this;
26033
+ function CustomPopupBody() {
26034
+ return _super !== null && _super.apply(this, arguments) || this;
23544
26035
  }
23545
26036
  CustomPopupBody.prototype.mounted = function () {
23546
26037
  // append the custom popup body element
23547
26038
  this.refs.el.appendChild(this.props.body);
23548
26039
  };
26040
+ CustomPopupBody.prototype.updated = function (prevProps) {
26041
+ // update custom popup element
26042
+ this.refs.el.replaceChild(this.props.body, prevProps.body);
26043
+ };
23549
26044
  CustomPopupBody.prototype.render = function () {
23550
26045
  var _this = this;
23551
26046
  return template(customPopupBody_templateObject_1 || (customPopupBody_templateObject_1 = __makeTemplateObject(["<div ref=", "></div>"], ["<div ref=", "></div>"])), function (el) { return (_this.refs.el = el); });
@@ -23843,6 +26338,7 @@ var Popup = /** @class */ (function (_super) {
23843
26338
  }
23844
26339
  Popup.prototype.mounted = function () {
23845
26340
  document.addEventListener('mousedown', this.handleMousedown);
26341
+ this.props.eventEmitter.listen('closePopup', this.props.hidePopup);
23846
26342
  };
23847
26343
  Popup.prototype.beforeDestroy = function () {
23848
26344
  document.removeEventListener('mousedown', this.handleMousedown);
@@ -23942,17 +26438,19 @@ var ToolbarButtonComp = /** @class */ (function (_super) {
23942
26438
  _this.props.showTooltip(_this.refs.el);
23943
26439
  };
23944
26440
  _this.execCommand = function () {
23945
- var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound;
26441
+ var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound, eventEmitter = _a.eventEmitter;
23946
26442
  var command = item.command, name = item.name, popup = item.popup;
23947
26443
  if (command) {
23948
26444
  execCommand(command);
23949
26445
  }
23950
26446
  else {
23951
26447
  var popupName = popup ? 'customPopupBody' : name;
26448
+ var initialValues = eventEmitter.emit('query', 'getPopupInitialValues', { popupName: popupName })[0];
23952
26449
  var info = createPopupInfo(popupName, {
23953
26450
  el: _this.refs.el,
23954
26451
  pos: getBound(_this.refs.el),
23955
26452
  popup: popup,
26453
+ initialValues: initialValues,
23956
26454
  });
23957
26455
  if (info) {
23958
26456
  setPopupInfo(info);
@@ -24149,8 +26647,9 @@ var dropdownToolbarButton_templateObject_1, dropdownToolbarButton_templateObject
24149
26647
 
24150
26648
 
24151
26649
 
24152
- var DROPDOWN_WIDTH = 120;
24153
- var toolbar_DEFAULT_WIDTH = 80;
26650
+
26651
+
26652
+ var INLINE_PADDING = 50;
24154
26653
  var Toolbar = /** @class */ (function (_super) {
24155
26654
  __extends(Toolbar, _super);
24156
26655
  function Toolbar(props) {
@@ -24208,6 +26707,7 @@ var Toolbar = /** @class */ (function (_super) {
24208
26707
  activeTab: 'write',
24209
26708
  };
24210
26709
  _this.tooltipRef = { current: null };
26710
+ _this.resizeObserver = new ResizeObserver_es(function () { return _this.handleResize(); });
24211
26711
  _this.addEvent();
24212
26712
  return _this;
24213
26713
  }
@@ -24241,9 +26741,13 @@ var Toolbar = /** @class */ (function (_super) {
24241
26741
  };
24242
26742
  Toolbar.prototype.addEvent = function () {
24243
26743
  var _this = this;
24244
- this.props.eventEmitter.listen('openPopup', this.openPopup);
24245
- this.handleResize = throttle_default()(function () { return _this.setState(_this.classifyToolbarItems()); }, 200);
24246
- window.addEventListener('resize', this.handleResize);
26744
+ var eventEmitter = this.props.eventEmitter;
26745
+ this.handleResize = throttle_default()(function () {
26746
+ // reset toolbar items to re-layout toolbar items with each clientWidth
26747
+ _this.setState({ items: _this.initialItems, dropdownItems: [] });
26748
+ _this.setState(_this.classifyToolbarItems());
26749
+ }, 200);
26750
+ eventEmitter.listen('openPopup', this.openPopup);
24247
26751
  };
24248
26752
  Toolbar.prototype.appendTooltipToRoot = function () {
24249
26753
  var tooltip = "<div class=\"" + cls('tooltip') + "\" style=\"display:none\">\n <div class=\"arrow\"></div>\n <span class=\"text\"></span>\n </div>";
@@ -24252,6 +26756,23 @@ var Toolbar = /** @class */ (function (_super) {
24252
26756
  Toolbar.prototype.hiddenScrollSync = function () {
24253
26757
  return this.props.editorType === 'wysiwyg' || this.props.previewStyle === 'tab';
24254
26758
  };
26759
+ Toolbar.prototype.movePrevItemToDropdownToolbar = function (itemIndex, items, group, dropdownGroup) {
26760
+ var moveItem = function (targetGroup) {
26761
+ var item = targetGroup.pop();
26762
+ if (item) {
26763
+ dropdownGroup.push(item);
26764
+ }
26765
+ };
26766
+ if (itemIndex > 1) {
26767
+ moveItem(group);
26768
+ }
26769
+ else {
26770
+ var prevGroup = last(items);
26771
+ if (prevGroup) {
26772
+ moveItem(prevGroup);
26773
+ }
26774
+ }
26775
+ };
24255
26776
  Toolbar.prototype.classifyToolbarItems = function () {
24256
26777
  var _this = this;
24257
26778
  var totalWidth = 0;
@@ -24260,13 +26781,25 @@ var Toolbar = /** @class */ (function (_super) {
24260
26781
  var dividerWidth = divider ? getOuterWidth(divider) : 0;
24261
26782
  var items = [];
24262
26783
  var dropdownItems = [];
24263
- this.initialItems.forEach(function (initialGroup, index) {
26784
+ var moved = false;
26785
+ this.initialItems.forEach(function (initialGroup, groupIndex) {
24264
26786
  var group = [];
24265
26787
  var dropdownGroup = [];
24266
- initialGroup.forEach(function (item) {
24267
- totalWidth += _this.itemWidthMap[item.name] || toolbar_DEFAULT_WIDTH;
24268
- var target = totalWidth >= clientWidth - DROPDOWN_WIDTH ? dropdownGroup : group;
24269
- target.push(item);
26788
+ initialGroup.forEach(function (item, itemIndex) {
26789
+ if (!item.hidden) {
26790
+ totalWidth += _this.itemWidthMap[item.name];
26791
+ if (totalWidth > clientWidth - INLINE_PADDING) {
26792
+ // should move the prev item to dropdown toolbar for placing the more button
26793
+ if (!moved) {
26794
+ _this.movePrevItemToDropdownToolbar(itemIndex, items, group, dropdownGroup);
26795
+ moved = true;
26796
+ }
26797
+ dropdownGroup.push(item);
26798
+ }
26799
+ else {
26800
+ group.push(item);
26801
+ }
26802
+ }
24270
26803
  });
24271
26804
  if (group.length) {
24272
26805
  setGroupState(group);
@@ -24277,7 +26810,7 @@ var Toolbar = /** @class */ (function (_super) {
24277
26810
  dropdownItems.push(dropdownGroup);
24278
26811
  }
24279
26812
  // add divider width
24280
- if (index < _this.state.items.length - 1) {
26813
+ if (groupIndex < _this.state.items.length - 1) {
24281
26814
  totalWidth += dividerWidth;
24282
26815
  }
24283
26816
  });
@@ -24285,11 +26818,12 @@ var Toolbar = /** @class */ (function (_super) {
24285
26818
  };
24286
26819
  Toolbar.prototype.mounted = function () {
24287
26820
  if (this.props.previewStyle === 'tab') {
24288
- this.props.eventEmitter.emit('changePreviewTabWrite');
26821
+ this.props.eventEmitter.emit('changePreviewTabWrite', true);
24289
26822
  }
24290
26823
  // classify toolbar and dropdown toolbar after DOM has been rendered
24291
26824
  this.setState(this.classifyToolbarItems());
24292
26825
  this.appendTooltipToRoot();
26826
+ this.resizeObserver.observe(this.refs.el);
24293
26827
  };
24294
26828
  Toolbar.prototype.updated = function (prevProps) {
24295
26829
  var _a = this.props, editorType = _a.editorType, previewStyle = _a.previewStyle, eventEmitter = _a.eventEmitter;
@@ -24308,6 +26842,7 @@ var Toolbar = /** @class */ (function (_super) {
24308
26842
  };
24309
26843
  Toolbar.prototype.beforeDestroy = function () {
24310
26844
  window.removeEventListener('resize', this.handleResize);
26845
+ this.resizeObserver.disconnect();
24311
26846
  removeNode(this.tooltipRef.current);
24312
26847
  };
24313
26848
  Toolbar.prototype.render = function () {
@@ -24457,8 +26992,8 @@ var Layout = /** @class */ (function (_super) {
24457
26992
  var editorTypeClassName = cls(editorType === 'markdown' ? 'md-mode' : 'ww-mode');
24458
26993
  var previewClassName = cls('md') + "-" + previewStyle + "-style";
24459
26994
  var themeClassName = cls([theme !== 'light', theme + " "]);
24460
- return template(layout_templateObject_2 || (layout_templateObject_2 = __makeTemplateObject(["\n <div\n class=\"", "", "", "\"\n ref=", "\n >\n <", "\n ref=", "\n eventEmitter=", "\n previewStyle=", "\n toolbarItems=", "\n editorType=", "\n />\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\"></div>\n </div>\n <div\n class=\"", "\"\n ref=", "\n />\n </div>\n ", "\n <", " eventEmitter=", " />\n </div>\n "], ["\n <div\n class=\"", "", "", "\"\n ref=", "\n >\n <", "\n ref=", "\n eventEmitter=", "\n previewStyle=", "\n toolbarItems=", "\n editorType=", "\n />\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\"></div>\n </div>\n <div\n class=\"", "\"\n ref=", "\n />\n </div>\n ",
24461
- "\n <", " eventEmitter=", " />\n </div>\n "])), themeClassName, cls('defaultUI'), displayClassName, function (el) { return (_this.refs.el = el); }, Toolbar, function (toolbar) { return (_this.toolbar = toolbar); }, eventEmitter, previewStyle, toolbarItems, editorType, cls('main'), editorTypeClassName, function (el) { return (_this.refs.editorSection = el); }, cls('md-container'), previewClassName, function (el) { return (_this.refs.mdContainer = el); }, cls('md-splitter'), cls('ww-container'), function (el) { return (_this.refs.wwContainer = el); }, !hideModeSwitch && template(layout_templateObject_1 || (layout_templateObject_1 = __makeTemplateObject(["<", " eventEmitter=", " editorType=", " />"], ["<", " eventEmitter=", " editorType=", " />"])), Switch, eventEmitter, editorType), ContextMenu, eventEmitter);
26995
+ return template(layout_templateObject_2 || (layout_templateObject_2 = __makeTemplateObject(["\n <div\n class=\"", "", "", "\"\n ref=", "\n >\n <", "\n ref=", "\n eventEmitter=", "\n previewStyle=", "\n toolbarItems=", "\n editorType=", "\n />\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\">\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\"></div>\n </div>\n <div\n class=\"", "\"\n ref=", "\n />\n </div>\n </div>\n ", "\n <", " eventEmitter=", " />\n </div>\n "], ["\n <div\n class=\"", "", "", "\"\n ref=", "\n >\n <", "\n ref=", "\n eventEmitter=", "\n previewStyle=", "\n toolbarItems=", "\n editorType=", "\n />\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\">\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\"></div>\n </div>\n <div\n class=\"", "\"\n ref=", "\n />\n </div>\n </div>\n ",
26996
+ "\n <", " eventEmitter=", " />\n </div>\n "])), themeClassName, cls('defaultUI'), displayClassName, function (el) { return (_this.refs.el = el); }, Toolbar, function (toolbar) { return (_this.toolbar = toolbar); }, eventEmitter, previewStyle, toolbarItems, editorType, cls('main'), editorTypeClassName, function (el) { return (_this.refs.editorSection = el); }, cls('main-container'), cls('md-container'), previewClassName, function (el) { return (_this.refs.mdContainer = el); }, cls('md-splitter'), cls('ww-container'), function (el) { return (_this.refs.wwContainer = el); }, !hideModeSwitch && template(layout_templateObject_1 || (layout_templateObject_1 = __makeTemplateObject(["<", " eventEmitter=", " editorType=", " />"], ["<", " eventEmitter=", " editorType=", " />"])), Switch, eventEmitter, editorType), ContextMenu, eventEmitter);
24462
26997
  };
24463
26998
  Layout.prototype.addEvent = function () {
24464
26999
  var eventEmitter = this.props.eventEmitter;