@toast-ui/editor 3.1.0 → 3.1.1

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 (56) hide show
  1. package/README.md +4 -4
  2. package/dist/esm/i18n/ar.js +1 -1
  3. package/dist/esm/i18n/cs-cz.js +1 -1
  4. package/dist/esm/i18n/de-de.js +1 -1
  5. package/dist/esm/i18n/en-us.js +1 -1
  6. package/dist/esm/i18n/es-es.js +1 -1
  7. package/dist/esm/i18n/fi-fi.js +1 -1
  8. package/dist/esm/i18n/fr-fr.js +1 -1
  9. package/dist/esm/i18n/gl-es.js +1 -1
  10. package/dist/esm/i18n/hr-hr.js +1 -1
  11. package/dist/esm/i18n/i18n.js +9 -5
  12. package/dist/esm/i18n/it-it.js +1 -1
  13. package/dist/esm/i18n/ja-jp.js +1 -1
  14. package/dist/esm/i18n/ko-kr.js +1 -1
  15. package/dist/esm/i18n/nb-no.js +1 -1
  16. package/dist/esm/i18n/nl-nl.js +1 -1
  17. package/dist/esm/i18n/pl-pl.js +1 -1
  18. package/dist/esm/i18n/pt-br.js +1 -1
  19. package/dist/esm/i18n/ru-ru.js +1 -1
  20. package/dist/esm/i18n/sv-se.js +1 -1
  21. package/dist/esm/i18n/tr-tr.js +1 -1
  22. package/dist/esm/i18n/uk-ua.js +1 -1
  23. package/dist/esm/i18n/zh-cn.js +1 -1
  24. package/dist/esm/i18n/zh-tw.js +1 -1
  25. package/dist/esm/index.js +1604 -229
  26. package/dist/esm/indexViewer.js +1503 -161
  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 +1 -1
  49. package/dist/toastui-editor-viewer.css +1 -1
  50. package/dist/toastui-editor-viewer.js +1572 -168
  51. package/dist/toastui-editor.css +1 -1
  52. package/dist/toastui-editor.js +1668 -219
  53. package/package.json +5 -1
  54. package/types/editor.d.ts +1 -0
  55. package/types/index.d.ts +4 -3
  56. package/types/toastui-editor-viewer.d.ts +39 -0
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @toast-ui/editor
3
- * @version 3.1.0 | Tue Sep 07 2021
3
+ * @version 3.1.1 | Wed Oct 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"}
@@ -2704,7 +4185,7 @@ var EditorBase = /** @class */ (function () {
2704
4185
  var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
2705
4186
  var rules = this.createInputRules();
2706
4187
  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)),
4188
+ (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
4189
  (0,external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_.history)(),
2709
4190
  placeholder(this.placeholder),
2710
4191
  addWidget(this.eventEmitter),
@@ -2919,6 +4400,8 @@ var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE + ")*\\s*/?>";
2919
4400
  var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
2920
4401
  var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
2921
4402
  var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
4403
+ var reBR = /<br\s*\/*>/i;
4404
+ var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
2922
4405
 
2923
4406
  ;// CONCATENATED MODULE: ./src/utils/dom.ts
2924
4407
 
@@ -3069,7 +4552,7 @@ function finalizeHtml(html, needHtmlText) {
3069
4552
  }
3070
4553
  else {
3071
4554
  var frag = document.createDocumentFragment();
3072
- var childNodes = toArray_default()(html.childNodes);
4555
+ var childNodes = toArray(html.childNodes);
3073
4556
  var length = childNodes.length;
3074
4557
  for (var i = 0; i < length; i += 1) {
3075
4558
  frag.appendChild(childNodes[i]);
@@ -3120,24 +4603,25 @@ function setAttributes(attributes, element) {
3120
4603
  });
3121
4604
  }
3122
4605
  function replaceBRWithEmptyBlock(html) {
3123
- var reBr = /<br\s*\/*>/i;
4606
+ // remove br in paragraph to compatible with markdown
4607
+ var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
3124
4608
  var reHTMLTag = new RegExp(HTML_TAG, 'ig');
3125
- var htmlTagMatched = html.match(reHTMLTag);
4609
+ var htmlTagMatched = replacedHTML.match(reHTMLTag);
3126
4610
  htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
3127
- if (reBr.test(htmlTag)) {
3128
- var alternativeTag = '';
4611
+ if (reBR.test(htmlTag)) {
4612
+ var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
3129
4613
  if (index) {
3130
4614
  var prevTag = htmlTagMatched[index - 1];
3131
4615
  var openTagMatched = prevTag.match(OPEN_TAG);
3132
- if (openTagMatched) {
4616
+ if (openTagMatched && !/br/i.test(openTagMatched[1])) {
3133
4617
  var tagName = openTagMatched[1];
3134
4618
  alternativeTag = "</" + tagName + "><" + tagName + ">";
3135
4619
  }
3136
4620
  }
3137
- html = html.replace(reBr, alternativeTag);
4621
+ replacedHTML = replacedHTML.replace(reBR, alternativeTag);
3138
4622
  }
3139
4623
  });
3140
- return html;
4624
+ return replacedHTML;
3141
4625
  }
3142
4626
 
3143
4627
  ;// CONCATENATED MODULE: ./src/markdown/helper/pos.ts
@@ -5842,10 +7326,16 @@ var esm_assign = function () {
5842
7326
  };
5843
7327
  return esm_assign.apply(this, arguments);
5844
7328
  };
5845
- function esm_spreadArray(to, from) {
5846
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
5847
- to[j] = from[i];
5848
- return to;
7329
+ function esm_spreadArray(to, from, pack) {
7330
+ if (pack || arguments.length === 2)
7331
+ for (var i = 0, l = from.length, ar; i < l; i++) {
7332
+ if (ar || !(i in from)) {
7333
+ if (!ar)
7334
+ ar = Array.prototype.slice.call(from, 0, i);
7335
+ ar[i] = from[i];
7336
+ }
7337
+ }
7338
+ return to.concat(ar || Array.prototype.slice.call(from));
5849
7339
  }
5850
7340
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof self !== 'undefined' ? self : {};
5851
7341
  var encodeCache = {};
@@ -14755,112 +16245,35 @@ var Renderer = /** @class */ (function () {
14755
16245
  }());
14756
16246
 
14757
16247
 
16248
+ // EXTERNAL MODULE: ../../node_modules/dompurify/dist/purify.js
16249
+ var purify = __webpack_require__(368);
16250
+ var purify_default = /*#__PURE__*/__webpack_require__.n(purify);
14758
16251
  ;// CONCATENATED MODULE: ./src/sanitizer/htmlSanitizer.ts
14759
16252
 
14760
16253
 
14761
16254
 
14762
-
14763
-
14764
-
14765
- var reHTMLAttr = new RegExp('^(abbr|align|alt|axis|bgcolor|border|cellpadding|cellspacing|class|clear|' +
14766
- 'color|cols|compact|coords|dir|face|headers|height|hreflang|hspace|' +
14767
- 'ismap|lang|language|nohref|nowrap|rel|rev|rows|rules|' +
14768
- 'scope|scrolling|shape|size|span|start|summary|tabindex|target|title|type|' +
14769
- 'valign|value|vspace|width|checked|mathvariant|encoding|id|name|' +
14770
- 'background|cite|href|longdesc|src|usemap|xlink:href|data-+|checked|style|controls)', 'g');
14771
- var reSvgAttr = new RegExp('^(accent-height|accumulate|additive|alphabetic|arabic-form|ascent|' +
14772
- 'baseProfile|bbox|begin|by|calcMode|cap-height|class|color|color-rendering|content|' +
14773
- 'cx|cy|d|dx|dy|descent|display|dur|end|fill|fill-rule|font-family|font-size|font-stretch|' +
14774
- 'font-style|font-variant|font-weight|from|fx|fy|g1|g2|glyph-name|gradientUnits|hanging|' +
14775
- 'height|horiz-adv-x|horiz-origin-x|ideographic|k|keyPoints|keySplines|keyTimes|lang|' +
14776
- 'marker-end|marker-mid|marker-start|markerHeight|markerUnits|markerWidth|mathematical|' +
14777
- 'max|min|offset|opacity|orient|origin|overline-position|overline-thickness|panose-1|' +
14778
- 'path|pathLength|points|preserveAspectRatio|r|refX|refY|repeatCount|repeatDur|' +
14779
- 'requiredExtensions|requiredFeatures|restart|rotate|rx|ry|slope|stemh|stemv|stop-color|' +
14780
- 'stop-opacity|strikethrough-position|strikethrough-thickness|stroke|stroke-dasharray|' +
14781
- 'stroke-dashoffset|stroke-linecap|stroke-linejoin|stroke-miterlimit|stroke-opacity|' +
14782
- 'stroke-width|systemLanguage|target|text-anchor|to|transform|type|u1|u2|underline-position|' +
14783
- 'underline-thickness|unicode|unicode-range|units-per-em|values|version|viewBox|visibility|' +
14784
- 'width|widths|x|x-height|x1|x2|xlink:actuate|xlink:arcrole|xlink:role|xlink:show|xlink:title|' +
14785
- 'xlink:type|xml:base|xml:lang|xml:space|xmlns|xmlns:xlink|y|y1|y2|zoomAndPan)', 'g');
14786
- var reXSSAttr = /href|src|background/i;
14787
- var reXSSAttrValue = /((java|vb|live)script|x):/i;
14788
- var reOnEvent = /^on\S+/i;
14789
- var reXSSOnload = new RegExp("(<" + TAG_NAME + "[^>]*)(onload\\s*=)", 'ig');
14790
- var reComment = /<!--[\s\S]*?-->/g;
14791
- var reWhitespace = /[ \t\r\n]/g;
14792
- var DEFAULT_TAG_BLACK_LIST = [
14793
- 'script',
14794
- 'iframe',
14795
- 'textarea',
14796
- 'form',
14797
- 'button',
14798
- 'select',
14799
- 'input',
14800
- 'meta',
14801
- 'style',
14802
- 'link',
14803
- 'title',
14804
- 'embed',
14805
- 'object',
14806
- 'details',
14807
- 'summary',
14808
- 'base',
14809
- ];
14810
- var CAN_BE_TAG_WHITE_LIST = ['iframe', 'embed', 'details', 'summary'];
14811
- var tagBlacklist = __spreadArray([], DEFAULT_TAG_BLACK_LIST);
16255
+ var CAN_BE_WHITE_TAG_LIST = ['iframe', 'embed'];
16256
+ var whiteTagList = [];
14812
16257
  function registerTagWhitelistIfPossible(tagName) {
14813
- if (common_includes(CAN_BE_TAG_WHITE_LIST, tagName)) {
14814
- var index = tagBlacklist.indexOf(tagName);
14815
- if (index > -1) {
14816
- tagBlacklist.splice(index, 1);
14817
- }
14818
- }
14819
- }
14820
- function sanitizeHTML(html) {
14821
- var root = document.createElement('div');
14822
- if (isString_default()(html)) {
14823
- html = html.replace(reComment, '').replace(reXSSOnload, '$1');
14824
- root.innerHTML = html;
14825
- }
14826
- removeUnnecessaryTags(root);
14827
- leaveOnlyWhitelistAttribute(root);
14828
- return finalizeHtml(root, true);
14829
- }
14830
- function removeUnnecessaryTags(html) {
14831
- var removedTags = findNodes(html, tagBlacklist.join(','));
14832
- removedTags.forEach(function (node) {
14833
- removeNode(node);
14834
- });
14835
- }
14836
- function isXSSAttribute(attrName, attrValue) {
14837
- return attrName.match(reXSSAttr) && attrValue.replace(reWhitespace, '').match(reXSSAttrValue);
14838
- }
14839
- function removeBlacklistAttributes(node, blacklistAttrs) {
14840
- blacklistAttrs.forEach(function (_a) {
14841
- var name = _a.name;
14842
- if (reOnEvent.test(name)) {
14843
- node[name] = null;
14844
- }
14845
- node.removeAttribute(name);
14846
- });
14847
- }
14848
- function leaveOnlyWhitelistAttribute(html) {
14849
- findNodes(html, '*').forEach(function (node) {
14850
- var attributes = node.attributes;
14851
- var blacklist = toArray_default()(attributes).filter(function (attr) {
14852
- var name = attr.name, value = attr.value;
14853
- var htmlAttr = name.match(reHTMLAttr);
14854
- var svgAttr = name.match(reSvgAttr);
14855
- var xssAttr = htmlAttr && isXSSAttribute(name, value);
14856
- return (!htmlAttr && !svgAttr) || xssAttr;
14857
- });
14858
- removeBlacklistAttributes(node, blacklist);
14859
- });
14860
- }
14861
- function sanitizeXSSAttributeValue(attrValue) {
14862
- attrValue = attrValue.replace(reComment, '');
14863
- return reXSSAttrValue.test(attrValue) ? '' : attrValue;
16258
+ if (common_includes(CAN_BE_WHITE_TAG_LIST, tagName)) {
16259
+ whiteTagList.push(tagName.toLowerCase());
16260
+ }
16261
+ }
16262
+ function sanitizeHTML(html, options) {
16263
+ return purify_default().sanitize(html, __assign({ ADD_TAGS: whiteTagList, ADD_ATTR: ['rel', 'target', 'hreflang', 'type'], FORBID_TAGS: [
16264
+ 'input',
16265
+ 'script',
16266
+ 'textarea',
16267
+ 'form',
16268
+ 'button',
16269
+ 'select',
16270
+ 'meta',
16271
+ 'style',
16272
+ 'link',
16273
+ 'title',
16274
+ 'object',
16275
+ 'base',
16276
+ ] }, options));
14864
16277
  }
14865
16278
 
14866
16279
  ;// CONCATENATED MODULE: ./src/wysiwyg/nodes/html.ts
@@ -17238,6 +18651,7 @@ function convertMsoParagraphsToList(html) {
17238
18651
 
17239
18652
 
17240
18653
 
18654
+
17241
18655
  var START_FRAGMENT_COMMENT = '<!--StartFragment-->';
17242
18656
  var END_FRAGMENT_COMMENT = '<!--EndFragment-->';
17243
18657
  function getContentBetweenFragmentComments(html) {
@@ -17246,7 +18660,7 @@ function getContentBetweenFragmentComments(html) {
17246
18660
  if (startFragmentIndex > -1 && endFragmentIndex > -1) {
17247
18661
  html = html.slice(startFragmentIndex + START_FRAGMENT_COMMENT.length, endFragmentIndex);
17248
18662
  }
17249
- return html;
18663
+ return html.replace(/<br[^>]*>/g, ALTERNATIVE_TAG_FOR_BR);
17250
18664
  }
17251
18665
  function convertMsoTableToCompletedTable(html) {
17252
18666
  // wrap with <tr> if html contains dangling <td> tags
@@ -17334,9 +18748,9 @@ function paste_createTableBody(tableBodyRows, maxColumnCount, schema) {
17334
18748
  }
17335
18749
  return schema.nodes.tableBody.create(null, copiedRows);
17336
18750
  }
17337
- function createTableFromPastingTable(rows, schema, startFromBody) {
18751
+ function createTableFromPastingTable(rows, schema, startFromBody, isInTable) {
17338
18752
  var columnCount = getMaxColumnCount(rows);
17339
- if (startFromBody) {
18753
+ if (startFromBody && isInTable) {
17340
18754
  return schema.nodes.table.create(null, [paste_createTableBody(rows, columnCount, schema)]);
17341
18755
  }
17342
18756
  var tableHeadRow = rows[0];
@@ -17347,15 +18761,16 @@ function createTableFromPastingTable(rows, schema, startFromBody) {
17347
18761
  }
17348
18762
  return schema.nodes.table.create(null, nodes);
17349
18763
  }
17350
- function changePastedSlice(slice, schema) {
18764
+ function changePastedSlice(slice, schema, isInTable) {
17351
18765
  var nodes = [];
17352
- slice.content.forEach(function (node) {
18766
+ var content = slice.content, openStart = slice.openStart, openEnd = slice.openEnd;
18767
+ content.forEach(function (node) {
17353
18768
  if (node.type.name === 'table') {
17354
18769
  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));
17355
18770
  if (tableContent) {
17356
18771
  var rows = createRowsFromPastingTable(tableContent);
17357
18772
  var startFromBody = tableContent.firstChild.type.name === 'tableBody';
17358
- var table = createTableFromPastingTable(rows, schema, startFromBody);
18773
+ var table = createTableFromPastingTable(rows, schema, startFromBody, isInTable);
17359
18774
  nodes.push(table);
17360
18775
  }
17361
18776
  }
@@ -17363,7 +18778,7 @@ function changePastedSlice(slice, schema) {
17363
18778
  nodes.push(node);
17364
18779
  }
17365
18780
  });
17366
- 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);
18781
+ 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);
17367
18782
  }
17368
18783
 
17369
18784
  ;// CONCATENATED MODULE: ./src/wysiwyg/clipboard/pasteToTable.ts
@@ -18873,9 +20288,13 @@ var Image = /** @class */ (function (_super) {
18873
20288
  {
18874
20289
  tag: 'img[src]',
18875
20290
  getAttrs: function (dom) {
18876
- var imageUrl = dom.getAttribute('src') || '';
18877
- var rawHTML = dom.getAttribute('data-raw-html');
18878
- return __assign({ imageUrl: sanitizeXSSAttributeValue(imageUrl), altText: dom.getAttribute('alt') }, (rawHTML && { rawHTML: rawHTML }));
20291
+ var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
20292
+ .firstChild;
20293
+ var imageUrl = sanitizedDOM.getAttribute('src') || '';
20294
+ var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
20295
+ var altText = sanitizedDOM.getAttribute('alt');
20296
+ return __assign({ imageUrl: imageUrl,
20297
+ altText: altText }, (rawHTML && { rawHTML: rawHTML }));
18879
20298
  },
18880
20299
  },
18881
20300
  ],
@@ -19181,9 +20600,11 @@ var link_Link = /** @class */ (function (_super) {
19181
20600
  {
19182
20601
  tag: 'a[href]',
19183
20602
  getAttrs: function (dom) {
19184
- var href = dom.getAttribute('href') || '';
19185
- var rawHTML = dom.getAttribute('data-raw-html');
19186
- return __assign({ linkUrl: sanitizeXSSAttributeValue(href), linkText: dom.textContent }, (rawHTML && { rawHTML: rawHTML }));
20603
+ var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
20604
+ .firstChild;
20605
+ var href = sanitizedDOM.getAttribute('href') || '';
20606
+ var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
20607
+ return __assign({ linkUrl: href, linkText: sanitizedDOM.textContent }, (rawHTML && { rawHTML: rawHTML }));
19187
20608
  },
19188
20609
  },
19189
20610
  ],
@@ -19470,6 +20891,7 @@ function createSpecs(linkAttributes) {
19470
20891
 
19471
20892
 
19472
20893
 
20894
+
19473
20895
 
19474
20896
 
19475
20897
  var CONTENTS_CLASS_NAME = cls('contents');
@@ -19553,7 +20975,9 @@ var WysiwygEditor = /** @class */ (function (_super) {
19553
20975
  _this.eventEmitter.emit('setFocusedNode', state.selection.$from.node(1));
19554
20976
  },
19555
20977
  transformPastedHTML: changePastedHTML,
19556
- transformPasted: function (slice) { return changePastedSlice(slice, _this.schema); },
20978
+ transformPasted: function (slice) {
20979
+ return changePastedSlice(slice, _this.schema, isInTableNode(_this.view.state.selection.$from));
20980
+ },
19557
20981
  handlePaste: function (view, _, slice) { return pasteToTable(view, slice); },
19558
20982
  handleKeyDown: function (_, ev) {
19559
20983
  _this.eventEmitter.emit('keydown', _this.editorType, ev);
@@ -19562,8 +20986,8 @@ var WysiwygEditor = /** @class */ (function (_super) {
19562
20986
  handleDOMEvents: {
19563
20987
  paste: function (_, ev) {
19564
20988
  var clipboardData = ev.clipboardData || window.clipboardData;
19565
- var items = clipboardData && clipboardData.items;
19566
- if (items) {
20989
+ var items = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.items;
20990
+ if ((items === null || items === void 0 ? void 0 : items.length) === 1) {
19567
20991
  var imageBlob = pasteImageOnly(items);
19568
20992
  if (imageBlob) {
19569
20993
  ev.preventDefault();
@@ -19970,6 +21394,9 @@ function htmlToWwConvertors_isInlineNode(_a) {
19970
21394
  var type = _a.type;
19971
21395
  return common_includes(['text', 'strong', 'emph', 'strike', 'image', 'link', 'code'], type);
19972
21396
  }
21397
+ function isSoftbreak(mdNode) {
21398
+ return (mdNode === null || mdNode === void 0 ? void 0 : mdNode.type) === 'softbreak';
21399
+ }
19973
21400
  function htmlToWwConvertors_isListNode(_a) {
19974
21401
  var type = _a.type, literal = _a.literal;
19975
21402
  var matched = type === 'htmlInline' && literal.match(reHTMLTag);
@@ -19988,11 +21415,15 @@ function getListItemAttrs(_a) {
19988
21415
  var checked = /data-task-checked/.test(literal);
19989
21416
  return { task: task, checked: checked };
19990
21417
  }
19991
- function getMatchedAttributeValue(rawHTML, attrName) {
21418
+ function getMatchedAttributeValue(rawHTML) {
21419
+ var attrNames = [];
21420
+ for (var _i = 1; _i < arguments.length; _i++) {
21421
+ attrNames[_i - 1] = arguments[_i];
21422
+ }
19992
21423
  var wrapper = document.createElement('div');
19993
- wrapper.innerHTML = rawHTML;
21424
+ wrapper.innerHTML = sanitizeHTML(rawHTML);
19994
21425
  var el = wrapper.firstChild;
19995
- return el.getAttribute(attrName) || '';
21426
+ return attrNames.map(function (attrName) { return el.getAttribute(attrName) || ''; });
19996
21427
  }
19997
21428
  function createConvertors(convertors) {
19998
21429
  var convertorMap = {};
@@ -20046,9 +21477,9 @@ var convertors = {
20046
21477
  var tag = node.literal;
20047
21478
  var link = state.schema.marks.link;
20048
21479
  if (openTagName) {
20049
- var linkUrl = getMatchedAttributeValue(tag, 'href');
21480
+ var linkUrl = getMatchedAttributeValue(tag, 'href')[0];
20050
21481
  state.openMark(link.create({
20051
- linkUrl: sanitizeXSSAttributeValue(linkUrl),
21482
+ linkUrl: linkUrl,
20052
21483
  rawHTML: openTagName,
20053
21484
  }));
20054
21485
  }
@@ -20058,11 +21489,10 @@ var convertors = {
20058
21489
  },
20059
21490
  img: function (state, node, openTagName) {
20060
21491
  var tag = node.literal;
20061
- var imageUrl = getMatchedAttributeValue(tag, 'src');
20062
- if (imageUrl) {
20063
- var altText = getMatchedAttributeValue(tag, 'alt');
21492
+ if (openTagName) {
21493
+ var _a = getMatchedAttributeValue(tag, 'src', 'alt'), imageUrl = _a[0], altText = _a[1];
20064
21494
  var image = state.schema.nodes.image;
20065
- state.addNode(image, __assign({ rawHTML: openTagName, imageUrl: sanitizeXSSAttributeValue(imageUrl) }, (altText && { altText: altText })));
21495
+ state.addNode(image, __assign({ rawHTML: openTagName, imageUrl: imageUrl }, (altText && { altText: altText })));
20066
21496
  }
20067
21497
  },
20068
21498
  hr: function (state, _, openTagName) {
@@ -20072,11 +21502,22 @@ var convertors = {
20072
21502
  var paragraph = state.schema.nodes.paragraph;
20073
21503
  var parent = node.parent, prev = node.prev, next = node.next;
20074
21504
  if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'paragraph') {
20075
- if (prev && !(prev.type === 'htmlInline' && prev.literal.match(CLOSE_TAG))) {
21505
+ // should open a paragraph node when line text has only <br> tag
21506
+ // ex) first line\n\n<br>\nfourth line
21507
+ if (isSoftbreak(prev)) {
20076
21508
  state.openNode(paragraph);
20077
21509
  }
20078
- if (next) {
21510
+ // should close a paragraph node when line text has only <br> tag
21511
+ // ex) first line\n\n<br>\nfourth line
21512
+ if (isSoftbreak(next)) {
20079
21513
  state.closeNode();
21514
+ // should close a paragraph node and open a paragraph node to separate between blocks
21515
+ // when <br> tag is in the middle of the paragraph
21516
+ // ex) first <br>line\nthird line
21517
+ }
21518
+ else if (next) {
21519
+ state.closeNode();
21520
+ state.openNode(paragraph);
20080
21521
  }
20081
21522
  }
20082
21523
  else if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'tableCell') {
@@ -20152,8 +21593,9 @@ var htmlToWwConvertors = createConvertors(convertors);
20152
21593
 
20153
21594
 
20154
21595
 
21596
+
20155
21597
  function isBRTag(node) {
20156
- return node.type === 'htmlInline' && /<br ?\/?>/.test(node.literal);
21598
+ return node.type === 'htmlInline' && reBR.test(node.literal);
20157
21599
  }
20158
21600
  function addRawHTMLAttributeToDOM(parent) {
20159
21601
  toArray_default()(parent.childNodes).forEach(function (child) {
@@ -20401,10 +21843,11 @@ var toWwConvertors = {
20401
21843
  var openTagName = matched[1], closeTagName = matched[3];
20402
21844
  var typeName = (openTagName || closeTagName).toLowerCase();
20403
21845
  var markType = state.schema.marks[typeName];
21846
+ var sanitizedHTML = sanitizeHTML(html);
20404
21847
  // for user defined html schema
20405
21848
  if (markType === null || markType === void 0 ? void 0 : markType.spec.attrs.htmlInline) {
20406
21849
  if (openTagName) {
20407
- var htmlAttrs = getHTMLAttrsByHTMLString(html);
21850
+ var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
20408
21851
  state.openMark(markType.create({ htmlAttrs: htmlAttrs }));
20409
21852
  }
20410
21853
  else {
@@ -20425,14 +21868,15 @@ var toWwConvertors = {
20425
21868
  var openTagName = matched[1], closeTagName = matched[3];
20426
21869
  var typeName = (openTagName || closeTagName).toLowerCase();
20427
21870
  var nodeType = state.schema.nodes[typeName];
21871
+ var sanitizedHTML = sanitizeHTML(html);
20428
21872
  // for user defined html schema
20429
21873
  if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
20430
- var htmlAttrs = getHTMLAttrsByHTMLString(html);
21874
+ var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
20431
21875
  var childrenHTML = getChildrenHTML(node, typeName);
20432
21876
  state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
20433
21877
  }
20434
21878
  else {
20435
- container.innerHTML = html;
21879
+ container.innerHTML = sanitizedHTML;
20436
21880
  addRawHTMLAttributeToDOM(container);
20437
21881
  state.convertByDOMParser(container);
20438
21882
  }
@@ -21591,6 +23035,14 @@ function getPluginInfo(plugins, eventEmitter, usageStatistics) {
21591
23035
  var TASK_ATTR_NAME = 'data-task';
21592
23036
  var DISABLED_TASK_ATTR_NAME = 'data-task-disabled';
21593
23037
  var TASK_CHECKED_CLASS_NAME = 'checked';
23038
+ function registerHTMLTagToWhitelist(convertorMap) {
23039
+ ['htmlBlock', 'htmlInline'].forEach(function (htmlType) {
23040
+ if (convertorMap[htmlType]) {
23041
+ // register tag white list for preventing to remove the html in sanitizer
23042
+ Object.keys(convertorMap[htmlType]).forEach(function (type) { return registerTagWhitelistIfPossible(type); });
23043
+ }
23044
+ });
23045
+ }
21594
23046
  /**
21595
23047
  * Class ToastUIEditorViewer
21596
23048
  * @param {object} options Option object
@@ -21636,6 +23088,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
21636
23088
  frontMatter: frontMatter,
21637
23089
  sanitizer: customHTMLSanitizer || sanitizeHTML,
21638
23090
  };
23091
+ registerHTMLTagToWhitelist(rendererOptions.customHTMLRenderer);
21639
23092
  if (this.options.events) {
21640
23093
  forEachOwnProperties_default()(this.options.events, function (fn, key) {
21641
23094
  _this.on(key, fn);
@@ -22164,7 +23617,7 @@ var ScrollSync = /** @class */ (function () {
22164
23617
  var ToastUIEditorCore = /** @class */ (function () {
22165
23618
  function ToastUIEditorCore(options) {
22166
23619
  var _this = this;
22167
- this.initialHtml = options.el.innerHTML;
23620
+ this.initialHTML = options.el.innerHTML;
22168
23621
  options.el.innerHTML = '';
22169
23622
  this.options = extend_default()({
22170
23623
  previewStyle: 'tab',
@@ -22198,6 +23651,8 @@ var ToastUIEditorCore = /** @class */ (function () {
22198
23651
  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;
22199
23652
  this.mode = initialEditType || 'markdown';
22200
23653
  this.mdPreviewStyle = this.options.previewStyle;
23654
+ this.i18n = i18n;
23655
+ this.i18n.setCode(this.options.language);
22201
23656
  this.eventEmitter = new eventEmitter();
22202
23657
  setWidgetRules(widgetRules);
22203
23658
  var linkAttributes = sanitizeLinkAttribute(this.options.linkAttributes);
@@ -22213,8 +23668,6 @@ var ToastUIEditorCore = /** @class */ (function () {
22213
23668
  };
22214
23669
  var wwToDOMAdaptor = new WwToDOMAdaptor(linkAttributes, rendererOptions.customHTMLRenderer);
22215
23670
  var htmlSchemaMap = createHTMLSchemaMap(rendererOptions.customHTMLRenderer, rendererOptions.sanitizer, wwToDOMAdaptor);
22216
- this.i18n = i18n;
22217
- this.i18n.setCode(this.options.language);
22218
23671
  this.toastMark = new ToastMark('', {
22219
23672
  disallowedHtmlBlockTags: ['br', 'img'],
22220
23673
  extendedAutolinks: extendedAutolinks,
@@ -22245,7 +23698,7 @@ var ToastUIEditorCore = /** @class */ (function () {
22245
23698
  this.setPlaceholder(this.options.placeholder);
22246
23699
  }
22247
23700
  if (!this.options.initialValue) {
22248
- this.setHTML(this.initialHtml, false);
23701
+ this.setHTML(this.initialHTML, false);
22249
23702
  }
22250
23703
  this.commandManager = new commandManager(this.eventEmitter, this.mdEditor.commands, this.wwEditor.commands, function () { return _this.mode; });
22251
23704
  if (this.options.usageStatistics) {
@@ -22442,16 +23895,13 @@ var ToastUIEditorCore = /** @class */ (function () {
22442
23895
  ToastUIEditorCore.prototype.getHTML = function () {
22443
23896
  var _this = this;
22444
23897
  this.eventEmitter.holdEventInvoke(function () {
22445
- if (_this.isWysiwygMode()) {
22446
- _this.mdEditor.setMarkdown(_this.convertor.toMarkdownText(_this.wwEditor.getModel()));
23898
+ if (_this.isMarkdownMode()) {
23899
+ var mdNode = _this.toastMark.getRootNode();
23900
+ var wwNode = _this.convertor.toWysiwygModel(mdNode);
23901
+ _this.wwEditor.setModel(wwNode);
22447
23902
  }
22448
23903
  });
22449
- var mdNode = this.toastMark.getRootNode();
22450
- var mdRenderer = this.preview.getRenderer();
22451
- return mdRenderer
22452
- .render(mdNode)
22453
- .replace(/\sdata-nodeid="\d{1,}"/g, '')
22454
- .trim();
23904
+ return this.wwEditor.view.dom.innerHTML;
22455
23905
  };
22456
23906
  /**
22457
23907
  * Insert text
@@ -24517,10 +25967,8 @@ var tablePopupBody_templateObject_1, tablePopupBody_templateObject_2, templateOb
24517
25967
 
24518
25968
  var CustomPopupBody = /** @class */ (function (_super) {
24519
25969
  __extends(CustomPopupBody, _super);
24520
- function CustomPopupBody(props) {
24521
- var _this = _super.call(this, props) || this;
24522
- props.eventEmitter.listen('closePopup', _this.props.hidePopup);
24523
- return _this;
25970
+ function CustomPopupBody() {
25971
+ return _super !== null && _super.apply(this, arguments) || this;
24524
25972
  }
24525
25973
  CustomPopupBody.prototype.mounted = function () {
24526
25974
  // append the custom popup body element
@@ -24823,6 +26271,7 @@ var Popup = /** @class */ (function (_super) {
24823
26271
  }
24824
26272
  Popup.prototype.mounted = function () {
24825
26273
  document.addEventListener('mousedown', this.handleMousedown);
26274
+ this.props.eventEmitter.listen('closePopup', this.props.hidePopup);
24826
26275
  };
24827
26276
  Popup.prototype.beforeDestroy = function () {
24828
26277
  document.removeEventListener('mousedown', this.handleMousedown);