@toast-ui/editor 3.0.2 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/esm/i18n/ar.js +7 -0
- package/dist/esm/i18n/cs-cz.js +7 -0
- package/dist/esm/i18n/de-de.js +7 -0
- package/dist/esm/i18n/en-us.js +7 -0
- package/dist/esm/i18n/es-es.js +7 -0
- package/dist/esm/i18n/fi-fi.js +7 -0
- package/dist/esm/i18n/fr-fr.js +7 -0
- package/dist/esm/i18n/gl-es.js +7 -0
- package/dist/esm/i18n/hr-hr.js +7 -0
- package/dist/esm/i18n/i18n.js +15 -4
- package/dist/esm/i18n/it-it.js +7 -0
- package/dist/esm/i18n/ja-jp.js +7 -0
- package/dist/esm/i18n/ko-kr.js +7 -0
- package/dist/esm/i18n/nb-no.js +7 -0
- package/dist/esm/i18n/nl-nl.js +7 -0
- package/dist/esm/i18n/pl-pl.js +7 -0
- package/dist/esm/i18n/pt-br.js +7 -0
- package/dist/esm/i18n/ru-ru.js +7 -0
- package/dist/esm/i18n/sv-se.js +7 -0
- package/dist/esm/i18n/tr-tr.js +7 -0
- package/dist/esm/i18n/uk-ua.js +7 -0
- package/dist/esm/i18n/zh-cn.js +7 -0
- package/dist/esm/i18n/zh-tw.js +7 -0
- package/dist/esm/index.js +2885 -426
- package/dist/esm/indexViewer.js +1672 -297
- package/dist/i18n/ar.js +1 -1
- package/dist/i18n/cs-cz.js +1 -1
- package/dist/i18n/de-de.js +1 -1
- package/dist/i18n/es-es.js +1 -1
- package/dist/i18n/fi-fi.js +1 -1
- package/dist/i18n/fr-fr.js +1 -1
- package/dist/i18n/gl-es.js +1 -1
- package/dist/i18n/hr-hr.js +1 -1
- package/dist/i18n/it-it.js +1 -1
- package/dist/i18n/ja-jp.js +1 -1
- package/dist/i18n/ko-kr.js +1 -1
- package/dist/i18n/nb-no.js +1 -1
- package/dist/i18n/nl-nl.js +1 -1
- package/dist/i18n/pl-pl.js +1 -1
- package/dist/i18n/pt-br.js +1 -1
- package/dist/i18n/ru-ru.js +1 -1
- package/dist/i18n/sv-se.js +1 -1
- package/dist/i18n/tr-tr.js +1 -1
- package/dist/i18n/uk-ua.js +1 -1
- package/dist/i18n/zh-cn.js +1 -1
- package/dist/i18n/zh-tw.js +1 -1
- package/dist/toastui-editor-only.css +22 -16
- package/dist/toastui-editor-viewer.css +10 -2
- package/dist/toastui-editor-viewer.js +1823 -370
- package/dist/toastui-editor.css +31 -17
- package/dist/toastui-editor.js +2853 -318
- package/package.json +5 -1
- package/types/editor.d.ts +6 -4
- package/types/event.d.ts +1 -0
- package/types/index.d.ts +4 -3
- package/types/toastui-editor-viewer.d.ts +39 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @toast-ui/editor
|
|
3
|
-
* @version 3.
|
|
3
|
+
* @version 3.1.2 | Mon Dec 27 2021
|
|
4
4
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -15,12 +15,1416 @@
|
|
|
15
15
|
root["toastui"] = root["toastui"] || {}, root["toastui"]["Editor"] = factory(root[undefined], root[undefined], root[undefined]);
|
|
16
16
|
})(self, function(__WEBPACK_EXTERNAL_MODULE__959__, __WEBPACK_EXTERNAL_MODULE__676__, __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
|
-
*
|
|
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
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
1529
|
+
* let sum = 0;
|
|
117
1530
|
*
|
|
118
1531
|
* forEach([1,2,3], function(value){
|
|
119
|
-
*
|
|
1532
|
+
* sum += value;
|
|
120
1533
|
* });
|
|
121
1534
|
* alert(sum); // 6
|
|
122
1535
|
*
|
|
123
1536
|
* // In case of Array-like object
|
|
124
|
-
*
|
|
1537
|
+
* const array = Array.prototype.slice.call(arrayLike); // change to array
|
|
125
1538
|
* forEach(array, function(value){
|
|
126
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
1585
|
+
* let sum = 0;
|
|
168
1586
|
*
|
|
169
1587
|
* forEachArray([1,2,3], function(value){
|
|
170
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
1639
|
+
* let sum = 0;
|
|
217
1640
|
*
|
|
218
1641
|
* forEachOwnProperties({a:1,b:2,c:3}, function(value){
|
|
219
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
1691
|
+
* const arrayLike = {
|
|
1692
|
+
* 0: 'one',
|
|
1693
|
+
* 1: 'two',
|
|
1694
|
+
* 2: 'three',
|
|
1695
|
+
* 3: 'four',
|
|
1696
|
+
* length: 4
|
|
269
1697
|
* };
|
|
270
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
483
|
-
*
|
|
1913
|
+
* const name = 'global';
|
|
1914
|
+
* const repository = {name: 'CodeSnippet'};
|
|
484
1915
|
* on(div, 'drag', function() {
|
|
485
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
931
|
-
*
|
|
932
|
-
*
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
*
|
|
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
|
/***/ 322:
|
|
1036
2481
|
/***/ (function(module) {
|
|
1037
2482
|
|
|
2483
|
+
"use strict";
|
|
1038
2484
|
/**
|
|
1039
2485
|
* @fileoverview Check whether the given variable is an instance of Array or not.
|
|
1040
2486
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1061,6 +2507,7 @@ module.exports = isArray;
|
|
|
1061
2507
|
/***/ 65:
|
|
1062
2508
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1063
2509
|
|
|
2510
|
+
"use strict";
|
|
1064
2511
|
/**
|
|
1065
2512
|
* @fileoverview Check whether the given variable is existing or not.
|
|
1066
2513
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1078,7 +2525,11 @@ var isNull = __webpack_require__(934);
|
|
|
1078
2525
|
* @returns {boolean} Is existy?
|
|
1079
2526
|
* @memberof module:type
|
|
1080
2527
|
* @example
|
|
1081
|
-
*
|
|
2528
|
+
* // ES6
|
|
2529
|
+
* import isExisty from 'tui-code-snippet/type/isExisty');
|
|
2530
|
+
*
|
|
2531
|
+
* // CommonJS
|
|
2532
|
+
* const isExisty = require('tui-code-snippet/type/isExisty');
|
|
1082
2533
|
*
|
|
1083
2534
|
* isExisty(''); //true
|
|
1084
2535
|
* isExisty(0); //true
|
|
@@ -1099,6 +2550,7 @@ module.exports = isExisty;
|
|
|
1099
2550
|
/***/ 404:
|
|
1100
2551
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1101
2552
|
|
|
2553
|
+
"use strict";
|
|
1102
2554
|
/**
|
|
1103
2555
|
* @fileoverview Check whether the given variable is falsy or not.
|
|
1104
2556
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1127,6 +2579,7 @@ module.exports = isFalsy;
|
|
|
1127
2579
|
/***/ 294:
|
|
1128
2580
|
/***/ (function(module) {
|
|
1129
2581
|
|
|
2582
|
+
"use strict";
|
|
1130
2583
|
/**
|
|
1131
2584
|
* @fileoverview Check whether the given variable is a function or not.
|
|
1132
2585
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1153,6 +2606,7 @@ module.exports = isFunction;
|
|
|
1153
2606
|
/***/ 934:
|
|
1154
2607
|
/***/ (function(module) {
|
|
1155
2608
|
|
|
2609
|
+
"use strict";
|
|
1156
2610
|
/**
|
|
1157
2611
|
* @fileoverview Check whether the given variable is null or not.
|
|
1158
2612
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1179,6 +2633,7 @@ module.exports = isNull;
|
|
|
1179
2633
|
/***/ 758:
|
|
1180
2634
|
/***/ (function(module) {
|
|
1181
2635
|
|
|
2636
|
+
"use strict";
|
|
1182
2637
|
/**
|
|
1183
2638
|
* @fileoverview Check whether the given variable is a string or not.
|
|
1184
2639
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1205,6 +2660,7 @@ module.exports = isString;
|
|
|
1205
2660
|
/***/ 790:
|
|
1206
2661
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1207
2662
|
|
|
2663
|
+
"use strict";
|
|
1208
2664
|
/**
|
|
1209
2665
|
* @fileoverview Check whether the given variable is truthy or not.
|
|
1210
2666
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1234,6 +2690,7 @@ module.exports = isTruthy;
|
|
|
1234
2690
|
/***/ 929:
|
|
1235
2691
|
/***/ (function(module) {
|
|
1236
2692
|
|
|
2693
|
+
"use strict";
|
|
1237
2694
|
/**
|
|
1238
2695
|
* @fileoverview Check whether the given variable is undefined or not.
|
|
1239
2696
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1260,6 +2717,7 @@ module.exports = isUndefined;
|
|
|
1260
2717
|
/***/ 959:
|
|
1261
2718
|
/***/ (function(module) {
|
|
1262
2719
|
|
|
2720
|
+
"use strict";
|
|
1263
2721
|
module.exports = __WEBPACK_EXTERNAL_MODULE__959__;
|
|
1264
2722
|
|
|
1265
2723
|
/***/ }),
|
|
@@ -1267,6 +2725,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__959__;
|
|
|
1267
2725
|
/***/ 676:
|
|
1268
2726
|
/***/ (function(module) {
|
|
1269
2727
|
|
|
2728
|
+
"use strict";
|
|
1270
2729
|
module.exports = __WEBPACK_EXTERNAL_MODULE__676__;
|
|
1271
2730
|
|
|
1272
2731
|
/***/ }),
|
|
@@ -1274,6 +2733,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__676__;
|
|
|
1274
2733
|
/***/ 754:
|
|
1275
2734
|
/***/ (function(module) {
|
|
1276
2735
|
|
|
2736
|
+
"use strict";
|
|
1277
2737
|
module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
|
|
1278
2738
|
|
|
1279
2739
|
/***/ })
|
|
@@ -1298,7 +2758,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
|
|
|
1298
2758
|
/******/ };
|
|
1299
2759
|
/******/
|
|
1300
2760
|
/******/ // Execute the module function
|
|
1301
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
2761
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
1302
2762
|
/******/
|
|
1303
2763
|
/******/ // Return the exports of the module
|
|
1304
2764
|
/******/ return module.exports;
|
|
@@ -1348,8 +2808,9 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
|
|
|
1348
2808
|
/******/
|
|
1349
2809
|
/************************************************************************/
|
|
1350
2810
|
var __webpack_exports__ = {};
|
|
1351
|
-
// This entry need to be wrapped in an IIFE because it need to be
|
|
2811
|
+
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
|
1352
2812
|
!function() {
|
|
2813
|
+
"use strict";
|
|
1353
2814
|
|
|
1354
2815
|
// EXPORTS
|
|
1355
2816
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -1521,10 +2982,14 @@ function __spreadArrays() {
|
|
|
1521
2982
|
return r;
|
|
1522
2983
|
}
|
|
1523
2984
|
|
|
1524
|
-
function __spreadArray(to, from) {
|
|
1525
|
-
for (var i = 0,
|
|
1526
|
-
|
|
1527
|
-
|
|
2985
|
+
function __spreadArray(to, from, pack) {
|
|
2986
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2987
|
+
if (ar || !(i in from)) {
|
|
2988
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2989
|
+
ar[i] = from[i];
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1528
2993
|
}
|
|
1529
2994
|
|
|
1530
2995
|
function __await(v) {
|
|
@@ -1580,19 +3045,17 @@ function __importDefault(mod) {
|
|
|
1580
3045
|
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
1581
3046
|
}
|
|
1582
3047
|
|
|
1583
|
-
function __classPrivateFieldGet(receiver,
|
|
1584
|
-
if (!
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
return privateMap.get(receiver);
|
|
3048
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
3049
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3050
|
+
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");
|
|
3051
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1588
3052
|
}
|
|
1589
3053
|
|
|
1590
|
-
function __classPrivateFieldSet(receiver,
|
|
1591
|
-
if (
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
return value;
|
|
3054
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
3055
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3056
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
3057
|
+
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");
|
|
3058
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1596
3059
|
}
|
|
1597
3060
|
|
|
1598
3061
|
;// CONCATENATED MODULE: ../../libs/toastmark/dist/esm/index.js
|
|
@@ -1638,10 +3101,16 @@ var esm_assign = function () {
|
|
|
1638
3101
|
};
|
|
1639
3102
|
return esm_assign.apply(this, arguments);
|
|
1640
3103
|
};
|
|
1641
|
-
function esm_spreadArray(to, from) {
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
3104
|
+
function esm_spreadArray(to, from, pack) {
|
|
3105
|
+
if (pack || arguments.length === 2)
|
|
3106
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3107
|
+
if (ar || !(i in from)) {
|
|
3108
|
+
if (!ar)
|
|
3109
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
3110
|
+
ar[i] = from[i];
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1645
3114
|
}
|
|
1646
3115
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof self !== 'undefined' ? self : {};
|
|
1647
3116
|
var encodeCache = {};
|
|
@@ -10027,6 +11496,7 @@ function filterDisallowedTags(str) {
|
|
|
10027
11496
|
}
|
|
10028
11497
|
return str;
|
|
10029
11498
|
}
|
|
11499
|
+
var CUSTOM_SYNTAX_LENGTH = 4;
|
|
10030
11500
|
var baseConvertors = {
|
|
10031
11501
|
heading: function (node, _a) {
|
|
10032
11502
|
var entering = _a.entering;
|
|
@@ -10194,7 +11664,7 @@ var baseConvertors = {
|
|
|
10194
11664
|
return customConvertor(node, context);
|
|
10195
11665
|
}
|
|
10196
11666
|
catch (e) {
|
|
10197
|
-
console.warn(e);
|
|
11667
|
+
console.warn("[@toast-ui/editor] - The error occurred when " + info + " block node was parsed in markdown renderer: " + e);
|
|
10198
11668
|
}
|
|
10199
11669
|
}
|
|
10200
11670
|
return [
|
|
@@ -10217,15 +11687,30 @@ var baseConvertors = {
|
|
|
10217
11687
|
];
|
|
10218
11688
|
},
|
|
10219
11689
|
customInline: function (node, context, convertors) {
|
|
10220
|
-
var
|
|
10221
|
-
var
|
|
11690
|
+
var _a = node, sourcepos = _a.sourcepos, info = _a.info;
|
|
11691
|
+
var nomalizedInfo = info.trim().toLowerCase();
|
|
11692
|
+
var customConvertor = convertors[nomalizedInfo];
|
|
11693
|
+
var entering = context.entering;
|
|
10222
11694
|
if (customConvertor) {
|
|
10223
|
-
|
|
11695
|
+
try {
|
|
11696
|
+
return customConvertor(node, context);
|
|
11697
|
+
}
|
|
11698
|
+
catch (e) {
|
|
11699
|
+
console.warn("[@toast-ui/editor] - The error occurred when " + nomalizedInfo + " inline node was parsed in markdown renderer: " + e);
|
|
11700
|
+
}
|
|
10224
11701
|
}
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
11702
|
+
var text = sourcepos[1][1] - sourcepos[0][1] + 1 === info.length + CUSTOM_SYNTAX_LENGTH
|
|
11703
|
+
? ''
|
|
11704
|
+
: info + " ";
|
|
11705
|
+
return entering
|
|
11706
|
+
? [
|
|
11707
|
+
{ type: 'openTag', tagName: 'span' },
|
|
11708
|
+
{ type: 'text', content: "$$" + text },
|
|
11709
|
+
]
|
|
11710
|
+
: [
|
|
11711
|
+
{ type: 'text', content: '$$' },
|
|
11712
|
+
{ type: 'closeTag', tagName: 'span' },
|
|
11713
|
+
];
|
|
10229
11714
|
},
|
|
10230
11715
|
};
|
|
10231
11716
|
var gfmConvertors = {
|
|
@@ -10388,8 +11873,8 @@ var Renderer = /** @class */ (function () {
|
|
|
10388
11873
|
? nodeType.toLowerCase()
|
|
10389
11874
|
: nodeType;
|
|
10390
11875
|
if (orgConvertor) {
|
|
10391
|
-
convertors[convertorType] = function (node, context) {
|
|
10392
|
-
context.origin = function () { return orgConvertor(node, context); };
|
|
11876
|
+
convertors[convertorType] = function (node, context, convertors) {
|
|
11877
|
+
context.origin = function () { return orgConvertor(node, context, convertors); };
|
|
10393
11878
|
return convertor(node, context);
|
|
10394
11879
|
};
|
|
10395
11880
|
}
|
|
@@ -10586,6 +12071,217 @@ var constants_OPEN_TAG = "<(" + TAG_NAME + ")(" + constants_ATTRIBUTE + ")*\\s*/
|
|
|
10586
12071
|
var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
|
|
10587
12072
|
var constants_HTML_TAG = "(?:" + constants_OPEN_TAG + "|" + CLOSE_TAG + ")";
|
|
10588
12073
|
var reHTMLTag = new RegExp("^" + constants_HTML_TAG, 'i');
|
|
12074
|
+
var constants_reBR = /<br\s*\/*>/i;
|
|
12075
|
+
var constants_ALTERNATIVE_TAG_FOR_BR = '</p><p>';
|
|
12076
|
+
|
|
12077
|
+
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isNull.js
|
|
12078
|
+
var type_isNull = __webpack_require__(934);
|
|
12079
|
+
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/request/sendHostname.js
|
|
12080
|
+
var request_sendHostname = __webpack_require__(391);
|
|
12081
|
+
;// CONCATENATED MODULE: ./src/utils/common.ts
|
|
12082
|
+
|
|
12083
|
+
|
|
12084
|
+
|
|
12085
|
+
|
|
12086
|
+
|
|
12087
|
+
var isMac = /Mac/.test(navigator.platform);
|
|
12088
|
+
var reSpaceMoreThanOne = /[\u0020]+/g;
|
|
12089
|
+
var common_reEscapeChars = /[>(){}[\]+-.!#|]/g;
|
|
12090
|
+
var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\/>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>|<!--[^-]+-->|<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g;
|
|
12091
|
+
var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
|
|
12092
|
+
var reEscapePairedChars = /[*_~`]/g;
|
|
12093
|
+
var common_XMLSPECIAL = '[&<>"]';
|
|
12094
|
+
var common_reXmlSpecial = new RegExp(common_XMLSPECIAL, 'g');
|
|
12095
|
+
function common_replaceUnsafeChar(char) {
|
|
12096
|
+
switch (char) {
|
|
12097
|
+
case '&':
|
|
12098
|
+
return '&';
|
|
12099
|
+
case '<':
|
|
12100
|
+
return '<';
|
|
12101
|
+
case '>':
|
|
12102
|
+
return '>';
|
|
12103
|
+
case '"':
|
|
12104
|
+
return '"';
|
|
12105
|
+
default:
|
|
12106
|
+
return char;
|
|
12107
|
+
}
|
|
12108
|
+
}
|
|
12109
|
+
function common_escapeXml(text) {
|
|
12110
|
+
if (common_reXmlSpecial.test(text)) {
|
|
12111
|
+
return text.replace(common_reXmlSpecial, common_replaceUnsafeChar);
|
|
12112
|
+
}
|
|
12113
|
+
return text;
|
|
12114
|
+
}
|
|
12115
|
+
function sendHostName() {
|
|
12116
|
+
sendHostname('editor', 'UA-129966929-1');
|
|
12117
|
+
}
|
|
12118
|
+
function common_includes(arr, targetItem) {
|
|
12119
|
+
return arr.indexOf(targetItem) !== -1;
|
|
12120
|
+
}
|
|
12121
|
+
var availableLinkAttributes = ['rel', 'target', 'hreflang', 'type'];
|
|
12122
|
+
var reMarkdownTextToEscapeMap = {
|
|
12123
|
+
codeblock: /(^ {4}[^\n]+\n*)+/,
|
|
12124
|
+
thematicBreak: /^ *((\* *){3,}|(- *){3,} *|(_ *){3,}) */,
|
|
12125
|
+
atxHeading: /^(#{1,6}) +[\s\S]+/,
|
|
12126
|
+
seTextheading: /^([^\n]+)\n *(=|-){2,} */,
|
|
12127
|
+
blockquote: /^( *>[^\n]+.*)+/,
|
|
12128
|
+
list: /^ *(\*+|-+|\d+\.) [\s\S]+/,
|
|
12129
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? */,
|
|
12130
|
+
link: /!?\[.*\]\(.*\)/,
|
|
12131
|
+
reflink: /!?\[.*\]\s*\[([^\]]*)\]/,
|
|
12132
|
+
verticalBar: /\u007C/,
|
|
12133
|
+
fencedCodeblock: /^((`|~){3,})/,
|
|
12134
|
+
};
|
|
12135
|
+
function sanitizeLinkAttribute(attribute) {
|
|
12136
|
+
if (!attribute) {
|
|
12137
|
+
return null;
|
|
12138
|
+
}
|
|
12139
|
+
var linkAttributes = {};
|
|
12140
|
+
availableLinkAttributes.forEach(function (key) {
|
|
12141
|
+
if (!isUndefined_default()(attribute[key])) {
|
|
12142
|
+
linkAttributes[key] = attribute[key];
|
|
12143
|
+
}
|
|
12144
|
+
});
|
|
12145
|
+
return linkAttributes;
|
|
12146
|
+
}
|
|
12147
|
+
function common_repeat(text, count) {
|
|
12148
|
+
var result = '';
|
|
12149
|
+
for (var i = 0; i < count; i += 1) {
|
|
12150
|
+
result += text;
|
|
12151
|
+
}
|
|
12152
|
+
return result;
|
|
12153
|
+
}
|
|
12154
|
+
function isNeedEscapeText(text) {
|
|
12155
|
+
var needEscape = false;
|
|
12156
|
+
forEachOwnProperties(reMarkdownTextToEscapeMap, function (reMarkdownTextToEscape) {
|
|
12157
|
+
if (reMarkdownTextToEscape.test(text)) {
|
|
12158
|
+
needEscape = true;
|
|
12159
|
+
}
|
|
12160
|
+
return !needEscape;
|
|
12161
|
+
});
|
|
12162
|
+
return needEscape;
|
|
12163
|
+
}
|
|
12164
|
+
function common_escape(text) {
|
|
12165
|
+
var replacer = function (matched) { return "\\" + matched; };
|
|
12166
|
+
var escapedText = text.replace(reSpaceMoreThanOne, ' ');
|
|
12167
|
+
if (reEscapeBackSlash.test(escapedText)) {
|
|
12168
|
+
escapedText = escapedText.replace(reEscapeBackSlash, replacer);
|
|
12169
|
+
}
|
|
12170
|
+
escapedText = escapedText.replace(reEscapePairedChars, replacer);
|
|
12171
|
+
if (reEscapeHTML.test(escapedText)) {
|
|
12172
|
+
escapedText = escapedText.replace(reEscapeHTML, replacer);
|
|
12173
|
+
}
|
|
12174
|
+
if (isNeedEscapeText(escapedText)) {
|
|
12175
|
+
escapedText = escapedText.replace(common_reEscapeChars, replacer);
|
|
12176
|
+
}
|
|
12177
|
+
return escapedText;
|
|
12178
|
+
}
|
|
12179
|
+
function quote(text) {
|
|
12180
|
+
var result;
|
|
12181
|
+
if (text.indexOf('"') === -1) {
|
|
12182
|
+
result = '""';
|
|
12183
|
+
}
|
|
12184
|
+
else {
|
|
12185
|
+
result = text.indexOf("'") === -1 ? "''" : '()';
|
|
12186
|
+
}
|
|
12187
|
+
return result[0] + text + result[1];
|
|
12188
|
+
}
|
|
12189
|
+
function common_isNil(value) {
|
|
12190
|
+
return isNull(value) || isUndefined(value);
|
|
12191
|
+
}
|
|
12192
|
+
function shallowEqual(o1, o2) {
|
|
12193
|
+
if (o1 === null && o1 === o2) {
|
|
12194
|
+
return true;
|
|
12195
|
+
}
|
|
12196
|
+
if (typeof o1 !== 'object' || typeof o2 !== 'object' || common_isNil(o1) || common_isNil(o2)) {
|
|
12197
|
+
return o1 === o2;
|
|
12198
|
+
}
|
|
12199
|
+
for (var key in o1) {
|
|
12200
|
+
if (o1[key] !== o2[key]) {
|
|
12201
|
+
return false;
|
|
12202
|
+
}
|
|
12203
|
+
}
|
|
12204
|
+
for (var key in o2) {
|
|
12205
|
+
if (!(key in o1)) {
|
|
12206
|
+
return false;
|
|
12207
|
+
}
|
|
12208
|
+
}
|
|
12209
|
+
return true;
|
|
12210
|
+
}
|
|
12211
|
+
function common_last(arr) {
|
|
12212
|
+
return arr[arr.length - 1];
|
|
12213
|
+
}
|
|
12214
|
+
function common_between(value, min, max) {
|
|
12215
|
+
return value >= min && value <= max;
|
|
12216
|
+
}
|
|
12217
|
+
function isObject(obj) {
|
|
12218
|
+
return typeof obj === 'object' && obj !== null;
|
|
12219
|
+
}
|
|
12220
|
+
function deepMergedCopy(targetObj, obj) {
|
|
12221
|
+
var resultObj = tslib_es6_assign({}, targetObj);
|
|
12222
|
+
if (targetObj && obj) {
|
|
12223
|
+
Object.keys(obj).forEach(function (prop) {
|
|
12224
|
+
if (isObject(resultObj[prop])) {
|
|
12225
|
+
if (Array.isArray(obj[prop])) {
|
|
12226
|
+
resultObj[prop] = deepCopyArray(obj[prop]);
|
|
12227
|
+
}
|
|
12228
|
+
else if (resultObj.hasOwnProperty(prop)) {
|
|
12229
|
+
resultObj[prop] = deepMergedCopy(resultObj[prop], obj[prop]);
|
|
12230
|
+
}
|
|
12231
|
+
else {
|
|
12232
|
+
resultObj[prop] = deepCopy(obj[prop]);
|
|
12233
|
+
}
|
|
12234
|
+
}
|
|
12235
|
+
else {
|
|
12236
|
+
resultObj[prop] = obj[prop];
|
|
12237
|
+
}
|
|
12238
|
+
});
|
|
12239
|
+
}
|
|
12240
|
+
return resultObj;
|
|
12241
|
+
}
|
|
12242
|
+
function deepCopyArray(items) {
|
|
12243
|
+
return items.map(function (item) {
|
|
12244
|
+
if (isObject(item)) {
|
|
12245
|
+
return Array.isArray(item) ? deepCopyArray(item) : deepCopy(item);
|
|
12246
|
+
}
|
|
12247
|
+
return item;
|
|
12248
|
+
});
|
|
12249
|
+
}
|
|
12250
|
+
function deepCopy(obj) {
|
|
12251
|
+
var keys = Object.keys(obj);
|
|
12252
|
+
if (!keys.length) {
|
|
12253
|
+
return obj;
|
|
12254
|
+
}
|
|
12255
|
+
return keys.reduce(function (acc, prop) {
|
|
12256
|
+
if (isObject(obj[prop])) {
|
|
12257
|
+
acc[prop] = Array.isArray(obj[prop]) ? deepCopyArray(obj[prop]) : deepCopy(obj[prop]);
|
|
12258
|
+
}
|
|
12259
|
+
else {
|
|
12260
|
+
acc[prop] = obj[prop];
|
|
12261
|
+
}
|
|
12262
|
+
return acc;
|
|
12263
|
+
}, {});
|
|
12264
|
+
}
|
|
12265
|
+
function common_assign(targetObj, obj) {
|
|
12266
|
+
if (obj === void 0) { obj = {}; }
|
|
12267
|
+
Object.keys(obj).forEach(function (prop) {
|
|
12268
|
+
if (targetObj.hasOwnProperty(prop) && typeof targetObj[prop] === 'object') {
|
|
12269
|
+
if (Array.isArray(obj[prop])) {
|
|
12270
|
+
targetObj[prop] = obj[prop];
|
|
12271
|
+
}
|
|
12272
|
+
else {
|
|
12273
|
+
common_assign(targetObj[prop], obj[prop]);
|
|
12274
|
+
}
|
|
12275
|
+
}
|
|
12276
|
+
else {
|
|
12277
|
+
targetObj[prop] = obj[prop];
|
|
12278
|
+
}
|
|
12279
|
+
});
|
|
12280
|
+
return targetObj;
|
|
12281
|
+
}
|
|
12282
|
+
function getSortedNumPair(valueA, valueB) {
|
|
12283
|
+
return valueA > valueB ? [valueB, valueA] : [valueA, valueB];
|
|
12284
|
+
}
|
|
10589
12285
|
|
|
10590
12286
|
;// CONCATENATED MODULE: ./src/utils/dom.ts
|
|
10591
12287
|
|
|
@@ -10597,6 +12293,7 @@ var reHTMLTag = new RegExp("^" + constants_HTML_TAG, 'i');
|
|
|
10597
12293
|
|
|
10598
12294
|
|
|
10599
12295
|
|
|
12296
|
+
|
|
10600
12297
|
function isPositionInBox(style, offsetX, offsetY) {
|
|
10601
12298
|
var left = parseInt(style.left, 10);
|
|
10602
12299
|
var top = parseInt(style.top, 10);
|
|
@@ -10640,7 +12337,7 @@ function isElemNode(node) {
|
|
|
10640
12337
|
return node && node.nodeType === Node.ELEMENT_NODE;
|
|
10641
12338
|
}
|
|
10642
12339
|
function findNodes(element, selector) {
|
|
10643
|
-
var nodeList =
|
|
12340
|
+
var nodeList = toArray(element.querySelectorAll(selector));
|
|
10644
12341
|
if (nodeList.length) {
|
|
10645
12342
|
return nodeList;
|
|
10646
12343
|
}
|
|
@@ -10735,7 +12432,7 @@ function finalizeHtml(html, needHtmlText) {
|
|
|
10735
12432
|
}
|
|
10736
12433
|
else {
|
|
10737
12434
|
var frag = document.createDocumentFragment();
|
|
10738
|
-
var childNodes =
|
|
12435
|
+
var childNodes = toArray(html.childNodes);
|
|
10739
12436
|
var length = childNodes.length;
|
|
10740
12437
|
for (var i = 0; i < length; i += 1) {
|
|
10741
12438
|
frag.appendChild(childNodes[i]);
|
|
@@ -10777,225 +12474,39 @@ function prependNode(node, appended) {
|
|
|
10777
12474
|
}
|
|
10778
12475
|
function setAttributes(attributes, element) {
|
|
10779
12476
|
Object.keys(attributes).forEach(function (attrName) {
|
|
10780
|
-
if (attributes[attrName]) {
|
|
10781
|
-
element.
|
|
12477
|
+
if (isNil(attributes[attrName])) {
|
|
12478
|
+
element.removeAttribute(attrName);
|
|
10782
12479
|
}
|
|
10783
12480
|
else {
|
|
10784
|
-
element.
|
|
12481
|
+
element.setAttribute(attrName, attributes[attrName]);
|
|
10785
12482
|
}
|
|
10786
12483
|
});
|
|
10787
12484
|
}
|
|
10788
12485
|
function replaceBRWithEmptyBlock(html) {
|
|
10789
|
-
|
|
12486
|
+
// remove br in paragraph to compatible with markdown
|
|
12487
|
+
var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
|
|
10790
12488
|
var reHTMLTag = new RegExp(HTML_TAG, 'ig');
|
|
10791
|
-
var htmlTagMatched =
|
|
12489
|
+
var htmlTagMatched = replacedHTML.match(reHTMLTag);
|
|
10792
12490
|
htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
|
|
10793
|
-
if (
|
|
10794
|
-
var alternativeTag =
|
|
12491
|
+
if (reBR.test(htmlTag)) {
|
|
12492
|
+
var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
|
|
10795
12493
|
if (index) {
|
|
10796
12494
|
var prevTag = htmlTagMatched[index - 1];
|
|
10797
12495
|
var openTagMatched = prevTag.match(OPEN_TAG);
|
|
10798
|
-
if (openTagMatched) {
|
|
12496
|
+
if (openTagMatched && !/br/i.test(openTagMatched[1])) {
|
|
10799
12497
|
var tagName = openTagMatched[1];
|
|
10800
12498
|
alternativeTag = "</" + tagName + "><" + tagName + ">";
|
|
10801
12499
|
}
|
|
10802
12500
|
}
|
|
10803
|
-
|
|
12501
|
+
replacedHTML = replacedHTML.replace(reBR, alternativeTag);
|
|
10804
12502
|
}
|
|
10805
12503
|
});
|
|
10806
|
-
return
|
|
12504
|
+
return replacedHTML;
|
|
10807
12505
|
}
|
|
10808
12506
|
|
|
10809
12507
|
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isFunction.js
|
|
10810
12508
|
var isFunction = __webpack_require__(294);
|
|
10811
12509
|
var isFunction_default = /*#__PURE__*/__webpack_require__.n(isFunction);
|
|
10812
|
-
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isNull.js
|
|
10813
|
-
var type_isNull = __webpack_require__(934);
|
|
10814
|
-
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/request/sendHostname.js
|
|
10815
|
-
var request_sendHostname = __webpack_require__(391);
|
|
10816
|
-
;// CONCATENATED MODULE: ./src/utils/common.ts
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
var isMac = /Mac/.test(navigator.platform);
|
|
10823
|
-
var reSpaceMoreThanOne = /[\u0020]+/g;
|
|
10824
|
-
var common_reEscapeChars = /[>(){}[\]+-.!#|]/g;
|
|
10825
|
-
var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\/>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>|<!--[^-]+-->|<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g;
|
|
10826
|
-
var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
|
|
10827
|
-
var reEscapePairedChars = /[*_~`]/g;
|
|
10828
|
-
function sendHostName() {
|
|
10829
|
-
sendHostname('editor', 'UA-129966929-1');
|
|
10830
|
-
}
|
|
10831
|
-
function common_includes(arr, targetItem) {
|
|
10832
|
-
return arr.indexOf(targetItem) !== -1;
|
|
10833
|
-
}
|
|
10834
|
-
var availableLinkAttributes = ['rel', 'target', 'hreflang', 'type'];
|
|
10835
|
-
var reMarkdownTextToEscapeMap = {
|
|
10836
|
-
codeblock: /(^ {4}[^\n]+\n*)+/,
|
|
10837
|
-
thematicBreak: /^ *((\* *){3,}|(- *){3,} *|(_ *){3,}) */,
|
|
10838
|
-
atxHeading: /^(#{1,6}) +[\s\S]+/,
|
|
10839
|
-
seTextheading: /^([^\n]+)\n *(=|-){2,} */,
|
|
10840
|
-
blockquote: /^( *>[^\n]+.*)+/,
|
|
10841
|
-
list: /^ *(\*+|-+|\d+\.) [\s\S]+/,
|
|
10842
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? */,
|
|
10843
|
-
link: /!?\[.*\]\(.*\)/,
|
|
10844
|
-
reflink: /!?\[.*\]\s*\[([^\]]*)\]/,
|
|
10845
|
-
verticalBar: /\u007C/,
|
|
10846
|
-
fencedCodeblock: /^((`|~){3,})/,
|
|
10847
|
-
};
|
|
10848
|
-
function sanitizeLinkAttribute(attribute) {
|
|
10849
|
-
if (!attribute) {
|
|
10850
|
-
return null;
|
|
10851
|
-
}
|
|
10852
|
-
var linkAttributes = {};
|
|
10853
|
-
availableLinkAttributes.forEach(function (key) {
|
|
10854
|
-
if (!isUndefined_default()(attribute[key])) {
|
|
10855
|
-
linkAttributes[key] = attribute[key];
|
|
10856
|
-
}
|
|
10857
|
-
});
|
|
10858
|
-
return linkAttributes;
|
|
10859
|
-
}
|
|
10860
|
-
function common_repeat(text, count) {
|
|
10861
|
-
var result = '';
|
|
10862
|
-
for (var i = 0; i < count; i += 1) {
|
|
10863
|
-
result += text;
|
|
10864
|
-
}
|
|
10865
|
-
return result;
|
|
10866
|
-
}
|
|
10867
|
-
function isNeedEscapeText(text) {
|
|
10868
|
-
var needEscape = false;
|
|
10869
|
-
forEachOwnProperties(reMarkdownTextToEscapeMap, function (reMarkdownTextToEscape) {
|
|
10870
|
-
if (reMarkdownTextToEscape.test(text)) {
|
|
10871
|
-
needEscape = true;
|
|
10872
|
-
}
|
|
10873
|
-
return !needEscape;
|
|
10874
|
-
});
|
|
10875
|
-
return needEscape;
|
|
10876
|
-
}
|
|
10877
|
-
function common_escape(text) {
|
|
10878
|
-
var replacer = function (matched) { return "\\" + matched; };
|
|
10879
|
-
var escapedText = text.replace(reSpaceMoreThanOne, ' ');
|
|
10880
|
-
if (reEscapeBackSlash.test(escapedText)) {
|
|
10881
|
-
escapedText = escapedText.replace(reEscapeBackSlash, replacer);
|
|
10882
|
-
}
|
|
10883
|
-
escapedText = escapedText.replace(reEscapePairedChars, replacer);
|
|
10884
|
-
if (reEscapeHTML.test(escapedText)) {
|
|
10885
|
-
escapedText = escapedText.replace(reEscapeHTML, replacer);
|
|
10886
|
-
}
|
|
10887
|
-
if (isNeedEscapeText(escapedText)) {
|
|
10888
|
-
escapedText = escapedText.replace(common_reEscapeChars, replacer);
|
|
10889
|
-
}
|
|
10890
|
-
return escapedText;
|
|
10891
|
-
}
|
|
10892
|
-
function quote(text) {
|
|
10893
|
-
var result;
|
|
10894
|
-
if (text.indexOf('"') === -1) {
|
|
10895
|
-
result = '""';
|
|
10896
|
-
}
|
|
10897
|
-
else {
|
|
10898
|
-
result = text.indexOf("'") === -1 ? "''" : '()';
|
|
10899
|
-
}
|
|
10900
|
-
return result[0] + text + result[1];
|
|
10901
|
-
}
|
|
10902
|
-
function isNil(value) {
|
|
10903
|
-
return isNull(value) || isUndefined(value);
|
|
10904
|
-
}
|
|
10905
|
-
function shallowEqual(o1, o2) {
|
|
10906
|
-
if (o1 === null && o1 === o2) {
|
|
10907
|
-
return true;
|
|
10908
|
-
}
|
|
10909
|
-
if (typeof o1 !== 'object' || typeof o2 !== 'object' || isNil(o1) || isNil(o2)) {
|
|
10910
|
-
return o1 === o2;
|
|
10911
|
-
}
|
|
10912
|
-
for (var key in o1) {
|
|
10913
|
-
if (o1[key] !== o2[key]) {
|
|
10914
|
-
return false;
|
|
10915
|
-
}
|
|
10916
|
-
}
|
|
10917
|
-
for (var key in o2) {
|
|
10918
|
-
if (!(key in o1)) {
|
|
10919
|
-
return false;
|
|
10920
|
-
}
|
|
10921
|
-
}
|
|
10922
|
-
return true;
|
|
10923
|
-
}
|
|
10924
|
-
function common_last(arr) {
|
|
10925
|
-
return arr[arr.length - 1];
|
|
10926
|
-
}
|
|
10927
|
-
function common_between(value, min, max) {
|
|
10928
|
-
return value >= min && value <= max;
|
|
10929
|
-
}
|
|
10930
|
-
function isObject(obj) {
|
|
10931
|
-
return typeof obj === 'object' && obj !== null;
|
|
10932
|
-
}
|
|
10933
|
-
function deepMergedCopy(targetObj, obj) {
|
|
10934
|
-
var resultObj = tslib_es6_assign({}, targetObj);
|
|
10935
|
-
if (targetObj && obj) {
|
|
10936
|
-
Object.keys(obj).forEach(function (prop) {
|
|
10937
|
-
if (isObject(resultObj[prop])) {
|
|
10938
|
-
if (Array.isArray(obj[prop])) {
|
|
10939
|
-
resultObj[prop] = deepCopyArray(obj[prop]);
|
|
10940
|
-
}
|
|
10941
|
-
else if (resultObj.hasOwnProperty(prop)) {
|
|
10942
|
-
resultObj[prop] = deepMergedCopy(resultObj[prop], obj[prop]);
|
|
10943
|
-
}
|
|
10944
|
-
else {
|
|
10945
|
-
resultObj[prop] = deepCopy(obj[prop]);
|
|
10946
|
-
}
|
|
10947
|
-
}
|
|
10948
|
-
else {
|
|
10949
|
-
resultObj[prop] = obj[prop];
|
|
10950
|
-
}
|
|
10951
|
-
});
|
|
10952
|
-
}
|
|
10953
|
-
return resultObj;
|
|
10954
|
-
}
|
|
10955
|
-
function deepCopyArray(items) {
|
|
10956
|
-
return items.map(function (item) {
|
|
10957
|
-
if (isObject(item)) {
|
|
10958
|
-
return Array.isArray(item) ? deepCopyArray(item) : deepCopy(item);
|
|
10959
|
-
}
|
|
10960
|
-
return item;
|
|
10961
|
-
});
|
|
10962
|
-
}
|
|
10963
|
-
function deepCopy(obj) {
|
|
10964
|
-
var keys = Object.keys(obj);
|
|
10965
|
-
if (!keys.length) {
|
|
10966
|
-
return obj;
|
|
10967
|
-
}
|
|
10968
|
-
return keys.reduce(function (acc, prop) {
|
|
10969
|
-
if (isObject(obj[prop])) {
|
|
10970
|
-
acc[prop] = Array.isArray(obj[prop]) ? deepCopyArray(obj[prop]) : deepCopy(obj[prop]);
|
|
10971
|
-
}
|
|
10972
|
-
else {
|
|
10973
|
-
acc[prop] = obj[prop];
|
|
10974
|
-
}
|
|
10975
|
-
return acc;
|
|
10976
|
-
}, {});
|
|
10977
|
-
}
|
|
10978
|
-
function common_assign(targetObj, obj) {
|
|
10979
|
-
if (obj === void 0) { obj = {}; }
|
|
10980
|
-
Object.keys(obj).forEach(function (prop) {
|
|
10981
|
-
if (targetObj.hasOwnProperty(prop) && typeof targetObj[prop] === 'object') {
|
|
10982
|
-
if (Array.isArray(obj[prop])) {
|
|
10983
|
-
targetObj[prop] = obj[prop];
|
|
10984
|
-
}
|
|
10985
|
-
else {
|
|
10986
|
-
common_assign(targetObj[prop], obj[prop]);
|
|
10987
|
-
}
|
|
10988
|
-
}
|
|
10989
|
-
else {
|
|
10990
|
-
targetObj[prop] = obj[prop];
|
|
10991
|
-
}
|
|
10992
|
-
});
|
|
10993
|
-
return targetObj;
|
|
10994
|
-
}
|
|
10995
|
-
function getSortedNumPair(valueA, valueB) {
|
|
10996
|
-
return valueA > valueB ? [valueB, valueA] : [valueA, valueB];
|
|
10997
|
-
}
|
|
10998
|
-
|
|
10999
12510
|
;// CONCATENATED MODULE: ./src/utils/markdown.ts
|
|
11000
12511
|
|
|
11001
12512
|
function hasSpecificTypeAncestor(mdNode) {
|
|
@@ -11268,112 +12779,35 @@ function getWidgetContent(widgetNode) {
|
|
|
11268
12779
|
return text;
|
|
11269
12780
|
}
|
|
11270
12781
|
|
|
12782
|
+
// EXTERNAL MODULE: ../../node_modules/dompurify/dist/purify.js
|
|
12783
|
+
var purify = __webpack_require__(368);
|
|
12784
|
+
var purify_default = /*#__PURE__*/__webpack_require__.n(purify);
|
|
11271
12785
|
;// CONCATENATED MODULE: ./src/sanitizer/htmlSanitizer.ts
|
|
11272
12786
|
|
|
11273
12787
|
|
|
11274
12788
|
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
var reHTMLAttr = new RegExp('^(abbr|align|alt|axis|bgcolor|border|cellpadding|cellspacing|class|clear|' +
|
|
11279
|
-
'color|cols|compact|coords|dir|face|headers|height|hreflang|hspace|' +
|
|
11280
|
-
'ismap|lang|language|nohref|nowrap|rel|rev|rows|rules|' +
|
|
11281
|
-
'scope|scrolling|shape|size|span|start|summary|tabindex|target|title|type|' +
|
|
11282
|
-
'valign|value|vspace|width|checked|mathvariant|encoding|id|name|' +
|
|
11283
|
-
'background|cite|href|longdesc|src|usemap|xlink:href|data-+|checked|style)', 'g');
|
|
11284
|
-
var reSvgAttr = new RegExp('^(accent-height|accumulate|additive|alphabetic|arabic-form|ascent|' +
|
|
11285
|
-
'baseProfile|bbox|begin|by|calcMode|cap-height|class|color|color-rendering|content|' +
|
|
11286
|
-
'cx|cy|d|dx|dy|descent|display|dur|end|fill|fill-rule|font-family|font-size|font-stretch|' +
|
|
11287
|
-
'font-style|font-variant|font-weight|from|fx|fy|g1|g2|glyph-name|gradientUnits|hanging|' +
|
|
11288
|
-
'height|horiz-adv-x|horiz-origin-x|ideographic|k|keyPoints|keySplines|keyTimes|lang|' +
|
|
11289
|
-
'marker-end|marker-mid|marker-start|markerHeight|markerUnits|markerWidth|mathematical|' +
|
|
11290
|
-
'max|min|offset|opacity|orient|origin|overline-position|overline-thickness|panose-1|' +
|
|
11291
|
-
'path|pathLength|points|preserveAspectRatio|r|refX|refY|repeatCount|repeatDur|' +
|
|
11292
|
-
'requiredExtensions|requiredFeatures|restart|rotate|rx|ry|slope|stemh|stemv|stop-color|' +
|
|
11293
|
-
'stop-opacity|strikethrough-position|strikethrough-thickness|stroke|stroke-dasharray|' +
|
|
11294
|
-
'stroke-dashoffset|stroke-linecap|stroke-linejoin|stroke-miterlimit|stroke-opacity|' +
|
|
11295
|
-
'stroke-width|systemLanguage|target|text-anchor|to|transform|type|u1|u2|underline-position|' +
|
|
11296
|
-
'underline-thickness|unicode|unicode-range|units-per-em|values|version|viewBox|visibility|' +
|
|
11297
|
-
'width|widths|x|x-height|x1|x2|xlink:actuate|xlink:arcrole|xlink:role|xlink:show|xlink:title|' +
|
|
11298
|
-
'xlink:type|xml:base|xml:lang|xml:space|xmlns|xmlns:xlink|y|y1|y2|zoomAndPan)', 'g');
|
|
11299
|
-
var reXSSAttr = /href|src|background/i;
|
|
11300
|
-
var reXSSAttrValue = /((java|vb|live)script|x):/i;
|
|
11301
|
-
var reOnEvent = /^on\S+/i;
|
|
11302
|
-
var reXSSOnload = new RegExp("(<" + TAG_NAME + "[^>]*)(onload\\s*=)", 'ig');
|
|
11303
|
-
var reComment = /<!--[\s\S]*?-->/g;
|
|
11304
|
-
var reWhitespace = /[ \t\r\n]/g;
|
|
11305
|
-
var DEFAULT_TAG_BLACK_LIST = [
|
|
11306
|
-
'script',
|
|
11307
|
-
'iframe',
|
|
11308
|
-
'textarea',
|
|
11309
|
-
'form',
|
|
11310
|
-
'button',
|
|
11311
|
-
'select',
|
|
11312
|
-
'input',
|
|
11313
|
-
'meta',
|
|
11314
|
-
'style',
|
|
11315
|
-
'link',
|
|
11316
|
-
'title',
|
|
11317
|
-
'embed',
|
|
11318
|
-
'object',
|
|
11319
|
-
'details',
|
|
11320
|
-
'summary',
|
|
11321
|
-
'base',
|
|
11322
|
-
];
|
|
11323
|
-
var CAN_BE_TAG_WHITE_LIST = (/* unused pure expression or super */ null && (['iframe', 'embed', 'details', 'summary']));
|
|
11324
|
-
var tagBlacklist = __spreadArray([], DEFAULT_TAG_BLACK_LIST);
|
|
12789
|
+
var CAN_BE_WHITE_TAG_LIST = ['iframe', 'embed'];
|
|
12790
|
+
var whiteTagList = [];
|
|
11325
12791
|
function htmlSanitizer_registerTagWhitelistIfPossible(tagName) {
|
|
11326
|
-
if (
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
removedTags.forEach(function (node) {
|
|
11346
|
-
removeNode(node);
|
|
11347
|
-
});
|
|
11348
|
-
}
|
|
11349
|
-
function isXSSAttribute(attrName, attrValue) {
|
|
11350
|
-
return attrName.match(reXSSAttr) && attrValue.replace(reWhitespace, '').match(reXSSAttrValue);
|
|
11351
|
-
}
|
|
11352
|
-
function removeBlacklistAttributes(node, blacklistAttrs) {
|
|
11353
|
-
blacklistAttrs.forEach(function (_a) {
|
|
11354
|
-
var name = _a.name;
|
|
11355
|
-
if (reOnEvent.test(name)) {
|
|
11356
|
-
node[name] = null;
|
|
11357
|
-
}
|
|
11358
|
-
node.removeAttribute(name);
|
|
11359
|
-
});
|
|
11360
|
-
}
|
|
11361
|
-
function leaveOnlyWhitelistAttribute(html) {
|
|
11362
|
-
findNodes(html, '*').forEach(function (node) {
|
|
11363
|
-
var attributes = node.attributes;
|
|
11364
|
-
var blacklist = toArray_default()(attributes).filter(function (attr) {
|
|
11365
|
-
var name = attr.name, value = attr.value;
|
|
11366
|
-
var htmlAttr = name.match(reHTMLAttr);
|
|
11367
|
-
var svgAttr = name.match(reSvgAttr);
|
|
11368
|
-
var xssAttr = htmlAttr && isXSSAttribute(name, value);
|
|
11369
|
-
return (!htmlAttr && !svgAttr) || xssAttr;
|
|
11370
|
-
});
|
|
11371
|
-
removeBlacklistAttributes(node, blacklist);
|
|
11372
|
-
});
|
|
11373
|
-
}
|
|
11374
|
-
function sanitizeXSSAttributeValue(attrValue) {
|
|
11375
|
-
attrValue = attrValue.replace(reComment, '');
|
|
11376
|
-
return reXSSAttrValue.test(attrValue) ? '' : attrValue;
|
|
12792
|
+
if (common_includes(CAN_BE_WHITE_TAG_LIST, tagName)) {
|
|
12793
|
+
whiteTagList.push(tagName.toLowerCase());
|
|
12794
|
+
}
|
|
12795
|
+
}
|
|
12796
|
+
function sanitizeHTML(html, options) {
|
|
12797
|
+
return purify_default().sanitize(html, tslib_es6_assign({ ADD_TAGS: whiteTagList, ADD_ATTR: ['rel', 'target', 'hreflang', 'type'], FORBID_TAGS: [
|
|
12798
|
+
'input',
|
|
12799
|
+
'script',
|
|
12800
|
+
'textarea',
|
|
12801
|
+
'form',
|
|
12802
|
+
'button',
|
|
12803
|
+
'select',
|
|
12804
|
+
'meta',
|
|
12805
|
+
'style',
|
|
12806
|
+
'link',
|
|
12807
|
+
'title',
|
|
12808
|
+
'object',
|
|
12809
|
+
'base',
|
|
12810
|
+
] }, options));
|
|
11377
12811
|
}
|
|
11378
12812
|
|
|
11379
12813
|
;// CONCATENATED MODULE: ./src/wysiwyg/nodes/html.ts
|
|
@@ -11825,10 +13259,16 @@ var MarkdownPreview = /** @class */ (function () {
|
|
|
11825
13259
|
this.sanitizer = sanitizer;
|
|
11826
13260
|
this.initEvent(highlight);
|
|
11827
13261
|
this.initContentSection();
|
|
13262
|
+
// To prevent overflowing contents in the viewer
|
|
13263
|
+
if (this.isViewer) {
|
|
13264
|
+
this.previewContent.style.overflowWrap = 'break-word';
|
|
13265
|
+
}
|
|
11828
13266
|
}
|
|
11829
13267
|
MarkdownPreview.prototype.initContentSection = function () {
|
|
11830
13268
|
this.previewContent = createElementWith("<div class=\"" + cls('contents') + "\"></div>");
|
|
11831
|
-
|
|
13269
|
+
if (!this.isViewer) {
|
|
13270
|
+
this.el.appendChild(this.previewContent);
|
|
13271
|
+
}
|
|
11832
13272
|
};
|
|
11833
13273
|
MarkdownPreview.prototype.toggleActive = function (active) {
|
|
11834
13274
|
toggleClass(this.el, 'active', active);
|
|
@@ -11836,6 +13276,9 @@ var MarkdownPreview = /** @class */ (function () {
|
|
|
11836
13276
|
MarkdownPreview.prototype.initEvent = function (highlight) {
|
|
11837
13277
|
var _this = this;
|
|
11838
13278
|
this.eventEmitter.listen('updatePreview', this.update.bind(this));
|
|
13279
|
+
if (this.isViewer) {
|
|
13280
|
+
return;
|
|
13281
|
+
}
|
|
11839
13282
|
if (highlight) {
|
|
11840
13283
|
this.eventEmitter.listen('changeToolbarState', function (_a) {
|
|
11841
13284
|
var mdNode = _a.mdNode, cursorPos = _a.cursorPos;
|
|
@@ -12430,6 +13873,7 @@ var eventTypeList = [
|
|
|
12430
13873
|
'mixinTableOffsetMapPrototype',
|
|
12431
13874
|
'setFocusedNode',
|
|
12432
13875
|
'removePopupWidget',
|
|
13876
|
+
'query',
|
|
12433
13877
|
// provide event for user
|
|
12434
13878
|
'openPopup',
|
|
12435
13879
|
'closePopup',
|
|
@@ -12641,6 +14085,14 @@ var EventEmitter = /** @class */ (function () {
|
|
|
12641
14085
|
var TASK_ATTR_NAME = 'data-task';
|
|
12642
14086
|
var DISABLED_TASK_ATTR_NAME = 'data-task-disabled';
|
|
12643
14087
|
var TASK_CHECKED_CLASS_NAME = 'checked';
|
|
14088
|
+
function registerHTMLTagToWhitelist(convertorMap) {
|
|
14089
|
+
['htmlBlock', 'htmlInline'].forEach(function (htmlType) {
|
|
14090
|
+
if (convertorMap[htmlType]) {
|
|
14091
|
+
// register tag white list for preventing to remove the html in sanitizer
|
|
14092
|
+
Object.keys(convertorMap[htmlType]).forEach(function (type) { return htmlSanitizer_registerTagWhitelistIfPossible(type); });
|
|
14093
|
+
}
|
|
14094
|
+
});
|
|
14095
|
+
}
|
|
12644
14096
|
/**
|
|
12645
14097
|
* Class ToastUIEditorViewer
|
|
12646
14098
|
* @param {object} options Option object
|
|
@@ -12686,6 +14138,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
|
|
|
12686
14138
|
frontMatter: frontMatter,
|
|
12687
14139
|
sanitizer: customHTMLSanitizer || sanitizeHTML,
|
|
12688
14140
|
};
|
|
14141
|
+
registerHTMLTagToWhitelist(rendererOptions.customHTMLRenderer);
|
|
12689
14142
|
if (this.options.events) {
|
|
12690
14143
|
forEachOwnProperties_default()(this.options.events, function (fn, key) {
|
|
12691
14144
|
_this.on(key, fn);
|
|
@@ -12706,7 +14159,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
|
|
|
12706
14159
|
customParser: markdownParsers,
|
|
12707
14160
|
});
|
|
12708
14161
|
this.preview = new mdPreview(this.eventEmitter, tslib_es6_assign(tslib_es6_assign({}, rendererOptions), { isViewer: true }));
|
|
12709
|
-
on_default()(this.preview.
|
|
14162
|
+
on_default()(this.preview.previewContent, 'mousedown', this.toggleTask.bind(this));
|
|
12710
14163
|
if (initialValue) {
|
|
12711
14164
|
this.setMarkdown(initialValue);
|
|
12712
14165
|
}
|