@toast-ui/editor 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/esm/i18n/ar.js +63 -0
- package/dist/esm/i18n/cs-cz.js +63 -0
- package/dist/esm/i18n/de-de.js +63 -0
- package/dist/esm/i18n/en-us.js +63 -0
- package/dist/esm/i18n/es-es.js +63 -0
- package/dist/esm/i18n/fi-fi.js +63 -0
- package/dist/esm/i18n/fr-fr.js +63 -0
- package/dist/esm/i18n/gl-es.js +63 -0
- package/dist/esm/i18n/hr-hr.js +63 -0
- package/dist/esm/i18n/i18n.js +223 -0
- package/dist/esm/i18n/it-it.js +63 -0
- package/dist/esm/i18n/ja-jp.js +63 -0
- package/dist/esm/i18n/ko-kr.js +63 -0
- package/dist/esm/i18n/nb-no.js +63 -0
- package/dist/esm/i18n/nl-nl.js +63 -0
- package/dist/esm/i18n/pl-pl.js +63 -0
- package/dist/esm/i18n/pt-br.js +63 -0
- package/dist/esm/i18n/ru-ru.js +64 -0
- package/dist/esm/i18n/sv-se.js +63 -0
- package/dist/esm/i18n/tr-tr.js +63 -0
- package/dist/esm/i18n/uk-ua.js +63 -0
- package/dist/esm/i18n/zh-cn.js +63 -0
- package/dist/esm/i18n/zh-tw.js +63 -0
- package/dist/esm/index.js +2887 -441
- package/dist/esm/indexViewer.js +1659 -293
- 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 +15 -14
- 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 +27 -19
- package/dist/toastui-editor-viewer.css +10 -2
- package/dist/toastui-editor-viewer.js +1849 -386
- package/dist/toastui-editor.css +36 -20
- package/dist/toastui-editor.js +2841 -318
- package/package.json +10 -1
- package/types/editor.d.ts +6 -4
- package/types/index.d.ts +4 -3
- package/types/toastui-editor-viewer.d.ts +39 -0
package/dist/toastui-editor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @toast-ui/editor
|
|
3
|
-
* @version 3.
|
|
3
|
+
* @version 3.1.1 | Wed Oct 27 2021
|
|
4
4
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -15,12 +15,1416 @@
|
|
|
15
15
|
root["toastui"] = root["toastui"] || {}, root["toastui"]["Editor"] = factory(root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined]);
|
|
16
16
|
})(self, function(__WEBPACK_EXTERNAL_MODULE__818__, __WEBPACK_EXTERNAL_MODULE__168__, __WEBPACK_EXTERNAL_MODULE__925__, __WEBPACK_EXTERNAL_MODULE__703__, __WEBPACK_EXTERNAL_MODULE__959__, __WEBPACK_EXTERNAL_MODULE__676__, __WEBPACK_EXTERNAL_MODULE__747__, __WEBPACK_EXTERNAL_MODULE__754__) {
|
|
17
17
|
return /******/ (function() { // webpackBootstrap
|
|
18
|
-
/******/ "use strict";
|
|
19
18
|
/******/ var __webpack_modules__ = ({
|
|
20
19
|
|
|
20
|
+
/***/ 368:
|
|
21
|
+
/***/ (function(module) {
|
|
22
|
+
|
|
23
|
+
/*! @license DOMPurify 2.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.3/LICENSE */
|
|
24
|
+
|
|
25
|
+
(function (global, factory) {
|
|
26
|
+
true ? module.exports = factory() :
|
|
27
|
+
0;
|
|
28
|
+
}(this, function () { 'use strict';
|
|
29
|
+
|
|
30
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
31
|
+
|
|
32
|
+
var hasOwnProperty = Object.hasOwnProperty,
|
|
33
|
+
setPrototypeOf = Object.setPrototypeOf,
|
|
34
|
+
isFrozen = Object.isFrozen,
|
|
35
|
+
getPrototypeOf = Object.getPrototypeOf,
|
|
36
|
+
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
37
|
+
var freeze = Object.freeze,
|
|
38
|
+
seal = Object.seal,
|
|
39
|
+
create = Object.create; // eslint-disable-line import/no-mutable-exports
|
|
40
|
+
|
|
41
|
+
var _ref = typeof Reflect !== 'undefined' && Reflect,
|
|
42
|
+
apply = _ref.apply,
|
|
43
|
+
construct = _ref.construct;
|
|
44
|
+
|
|
45
|
+
if (!apply) {
|
|
46
|
+
apply = function apply(fun, thisValue, args) {
|
|
47
|
+
return fun.apply(thisValue, args);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!freeze) {
|
|
52
|
+
freeze = function freeze(x) {
|
|
53
|
+
return x;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!seal) {
|
|
58
|
+
seal = function seal(x) {
|
|
59
|
+
return x;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!construct) {
|
|
64
|
+
construct = function construct(Func, args) {
|
|
65
|
+
return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))();
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var arrayForEach = unapply(Array.prototype.forEach);
|
|
70
|
+
var arrayPop = unapply(Array.prototype.pop);
|
|
71
|
+
var arrayPush = unapply(Array.prototype.push);
|
|
72
|
+
|
|
73
|
+
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
74
|
+
var stringMatch = unapply(String.prototype.match);
|
|
75
|
+
var stringReplace = unapply(String.prototype.replace);
|
|
76
|
+
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
77
|
+
var stringTrim = unapply(String.prototype.trim);
|
|
78
|
+
|
|
79
|
+
var regExpTest = unapply(RegExp.prototype.test);
|
|
80
|
+
|
|
81
|
+
var typeErrorCreate = unconstruct(TypeError);
|
|
82
|
+
|
|
83
|
+
function unapply(func) {
|
|
84
|
+
return function (thisArg) {
|
|
85
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
86
|
+
args[_key - 1] = arguments[_key];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return apply(func, thisArg, args);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function unconstruct(func) {
|
|
94
|
+
return function () {
|
|
95
|
+
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
96
|
+
args[_key2] = arguments[_key2];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return construct(func, args);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Add properties to a lookup table */
|
|
104
|
+
function addToSet(set, array) {
|
|
105
|
+
if (setPrototypeOf) {
|
|
106
|
+
// Make 'in' and truthy checks like Boolean(set.constructor)
|
|
107
|
+
// independent of any properties defined on Object.prototype.
|
|
108
|
+
// Prevent prototype setters from intercepting set as a this value.
|
|
109
|
+
setPrototypeOf(set, null);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
var l = array.length;
|
|
113
|
+
while (l--) {
|
|
114
|
+
var element = array[l];
|
|
115
|
+
if (typeof element === 'string') {
|
|
116
|
+
var lcElement = stringToLowerCase(element);
|
|
117
|
+
if (lcElement !== element) {
|
|
118
|
+
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
119
|
+
if (!isFrozen(array)) {
|
|
120
|
+
array[l] = lcElement;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
element = lcElement;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
set[element] = true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return set;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Shallow clone an object */
|
|
134
|
+
function clone(object) {
|
|
135
|
+
var newObject = create(null);
|
|
136
|
+
|
|
137
|
+
var property = void 0;
|
|
138
|
+
for (property in object) {
|
|
139
|
+
if (apply(hasOwnProperty, object, [property])) {
|
|
140
|
+
newObject[property] = object[property];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return newObject;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* IE10 doesn't support __lookupGetter__ so lets'
|
|
148
|
+
* simulate it. It also automatically checks
|
|
149
|
+
* if the prop is function or getter and behaves
|
|
150
|
+
* accordingly. */
|
|
151
|
+
function lookupGetter(object, prop) {
|
|
152
|
+
while (object !== null) {
|
|
153
|
+
var desc = getOwnPropertyDescriptor(object, prop);
|
|
154
|
+
if (desc) {
|
|
155
|
+
if (desc.get) {
|
|
156
|
+
return unapply(desc.get);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (typeof desc.value === 'function') {
|
|
160
|
+
return unapply(desc.value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
object = getPrototypeOf(object);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function fallbackValue(element) {
|
|
168
|
+
console.warn('fallback value for', element);
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return fallbackValue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
|
|
176
|
+
|
|
177
|
+
// SVG
|
|
178
|
+
var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
179
|
+
|
|
180
|
+
var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
|
|
181
|
+
|
|
182
|
+
// List of SVG elements that are disallowed by default.
|
|
183
|
+
// We still need to know them so that we can do namespace
|
|
184
|
+
// checks properly in case one wants to add them to
|
|
185
|
+
// allow-list.
|
|
186
|
+
var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
|
|
187
|
+
|
|
188
|
+
var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']);
|
|
189
|
+
|
|
190
|
+
// Similarly to SVG, we want to know all MathML elements,
|
|
191
|
+
// even those that we disallow by default.
|
|
192
|
+
var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
193
|
+
|
|
194
|
+
var text = freeze(['#text']);
|
|
195
|
+
|
|
196
|
+
var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
|
|
197
|
+
|
|
198
|
+
var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
199
|
+
|
|
200
|
+
var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
|
201
|
+
|
|
202
|
+
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
203
|
+
|
|
204
|
+
// eslint-disable-next-line unicorn/better-regex
|
|
205
|
+
var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
206
|
+
var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm);
|
|
207
|
+
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
|
|
208
|
+
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
209
|
+
var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
|
|
210
|
+
);
|
|
211
|
+
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
212
|
+
var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
216
|
+
|
|
217
|
+
function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
218
|
+
|
|
219
|
+
var getGlobal = function getGlobal() {
|
|
220
|
+
return typeof window === 'undefined' ? null : window;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Creates a no-op policy for internal use only.
|
|
225
|
+
* Don't export this function outside this module!
|
|
226
|
+
* @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
|
|
227
|
+
* @param {Document} document The document object (to determine policy name suffix)
|
|
228
|
+
* @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
|
|
229
|
+
* are not supported).
|
|
230
|
+
*/
|
|
231
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
|
|
232
|
+
if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Allow the callers to control the unique policy name
|
|
237
|
+
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
238
|
+
// Policy creation with duplicate names throws in Trusted Types.
|
|
239
|
+
var suffix = null;
|
|
240
|
+
var ATTR_NAME = 'data-tt-policy-suffix';
|
|
241
|
+
if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
|
|
242
|
+
suffix = document.currentScript.getAttribute(ATTR_NAME);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
return trustedTypes.createPolicy(policyName, {
|
|
249
|
+
createHTML: function createHTML(html$$1) {
|
|
250
|
+
return html$$1;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
} catch (_) {
|
|
254
|
+
// Policy creation failed (most likely another DOMPurify script has
|
|
255
|
+
// already run). Skip creating the policy, as this will only cause errors
|
|
256
|
+
// if TT are enforced.
|
|
257
|
+
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
function createDOMPurify() {
|
|
263
|
+
var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
264
|
+
|
|
265
|
+
var DOMPurify = function DOMPurify(root) {
|
|
266
|
+
return createDOMPurify(root);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Version label, exposed for easier checks
|
|
271
|
+
* if DOMPurify is up to date or not
|
|
272
|
+
*/
|
|
273
|
+
DOMPurify.version = '2.3.3';
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Array of elements that DOMPurify removed during sanitation.
|
|
277
|
+
* Empty if nothing was removed.
|
|
278
|
+
*/
|
|
279
|
+
DOMPurify.removed = [];
|
|
280
|
+
|
|
281
|
+
if (!window || !window.document || window.document.nodeType !== 9) {
|
|
282
|
+
// Not running in a browser, provide a factory function
|
|
283
|
+
// so that you can pass your own Window
|
|
284
|
+
DOMPurify.isSupported = false;
|
|
285
|
+
|
|
286
|
+
return DOMPurify;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var originalDocument = window.document;
|
|
290
|
+
|
|
291
|
+
var document = window.document;
|
|
292
|
+
var DocumentFragment = window.DocumentFragment,
|
|
293
|
+
HTMLTemplateElement = window.HTMLTemplateElement,
|
|
294
|
+
Node = window.Node,
|
|
295
|
+
Element = window.Element,
|
|
296
|
+
NodeFilter = window.NodeFilter,
|
|
297
|
+
_window$NamedNodeMap = window.NamedNodeMap,
|
|
298
|
+
NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
|
|
299
|
+
Text = window.Text,
|
|
300
|
+
Comment = window.Comment,
|
|
301
|
+
DOMParser = window.DOMParser,
|
|
302
|
+
trustedTypes = window.trustedTypes;
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
var ElementPrototype = Element.prototype;
|
|
306
|
+
|
|
307
|
+
var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
308
|
+
var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
309
|
+
var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
310
|
+
var getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
311
|
+
|
|
312
|
+
// As per issue #47, the web-components registry is inherited by a
|
|
313
|
+
// new document created via createHTMLDocument. As per the spec
|
|
314
|
+
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
315
|
+
// a new empty registry is used when creating a template contents owner
|
|
316
|
+
// document, so we use that as our parent document to ensure nothing
|
|
317
|
+
// is inherited.
|
|
318
|
+
if (typeof HTMLTemplateElement === 'function') {
|
|
319
|
+
var template = document.createElement('template');
|
|
320
|
+
if (template.content && template.content.ownerDocument) {
|
|
321
|
+
document = template.content.ownerDocument;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
|
|
326
|
+
var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : '';
|
|
327
|
+
|
|
328
|
+
var _document = document,
|
|
329
|
+
implementation = _document.implementation,
|
|
330
|
+
createNodeIterator = _document.createNodeIterator,
|
|
331
|
+
createDocumentFragment = _document.createDocumentFragment,
|
|
332
|
+
getElementsByTagName = _document.getElementsByTagName;
|
|
333
|
+
var importNode = originalDocument.importNode;
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
var documentMode = {};
|
|
337
|
+
try {
|
|
338
|
+
documentMode = clone(document).documentMode ? document.documentMode : {};
|
|
339
|
+
} catch (_) {}
|
|
340
|
+
|
|
341
|
+
var hooks = {};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
345
|
+
*/
|
|
346
|
+
DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
|
|
347
|
+
|
|
348
|
+
var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR,
|
|
349
|
+
ERB_EXPR$$1 = ERB_EXPR,
|
|
350
|
+
DATA_ATTR$$1 = DATA_ATTR,
|
|
351
|
+
ARIA_ATTR$$1 = ARIA_ATTR,
|
|
352
|
+
IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA,
|
|
353
|
+
ATTR_WHITESPACE$$1 = ATTR_WHITESPACE;
|
|
354
|
+
var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
358
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
/* allowed element names */
|
|
362
|
+
|
|
363
|
+
var ALLOWED_TAGS = null;
|
|
364
|
+
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text)));
|
|
365
|
+
|
|
366
|
+
/* Allowed attribute names */
|
|
367
|
+
var ALLOWED_ATTR = null;
|
|
368
|
+
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml)));
|
|
369
|
+
|
|
370
|
+
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
371
|
+
var FORBID_TAGS = null;
|
|
372
|
+
|
|
373
|
+
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
374
|
+
var FORBID_ATTR = null;
|
|
375
|
+
|
|
376
|
+
/* Decide if ARIA attributes are okay */
|
|
377
|
+
var ALLOW_ARIA_ATTR = true;
|
|
378
|
+
|
|
379
|
+
/* Decide if custom data attributes are okay */
|
|
380
|
+
var ALLOW_DATA_ATTR = true;
|
|
381
|
+
|
|
382
|
+
/* Decide if unknown protocols are okay */
|
|
383
|
+
var ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
384
|
+
|
|
385
|
+
/* Output should be safe for common template engines.
|
|
386
|
+
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
387
|
+
*/
|
|
388
|
+
var SAFE_FOR_TEMPLATES = false;
|
|
389
|
+
|
|
390
|
+
/* Decide if document with <html>... should be returned */
|
|
391
|
+
var WHOLE_DOCUMENT = false;
|
|
392
|
+
|
|
393
|
+
/* Track whether config is already set on this instance of DOMPurify. */
|
|
394
|
+
var SET_CONFIG = false;
|
|
395
|
+
|
|
396
|
+
/* Decide if all elements (e.g. style, script) must be children of
|
|
397
|
+
* document.body. By default, browsers might move them to document.head */
|
|
398
|
+
var FORCE_BODY = false;
|
|
399
|
+
|
|
400
|
+
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
401
|
+
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
402
|
+
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
403
|
+
*/
|
|
404
|
+
var RETURN_DOM = false;
|
|
405
|
+
|
|
406
|
+
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
407
|
+
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
408
|
+
var RETURN_DOM_FRAGMENT = false;
|
|
409
|
+
|
|
410
|
+
/* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM
|
|
411
|
+
* `Node` is imported into the current `Document`. If this flag is not enabled the
|
|
412
|
+
* `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by
|
|
413
|
+
* DOMPurify.
|
|
414
|
+
*
|
|
415
|
+
* This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false`
|
|
416
|
+
* might cause XSS from attacks hidden in closed shadowroots in case the browser
|
|
417
|
+
* supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/
|
|
418
|
+
*/
|
|
419
|
+
var RETURN_DOM_IMPORT = true;
|
|
420
|
+
|
|
421
|
+
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
422
|
+
* case Trusted Types are not supported */
|
|
423
|
+
var RETURN_TRUSTED_TYPE = false;
|
|
424
|
+
|
|
425
|
+
/* Output should be free from DOM clobbering attacks? */
|
|
426
|
+
var SANITIZE_DOM = true;
|
|
427
|
+
|
|
428
|
+
/* Keep element content when removing element? */
|
|
429
|
+
var KEEP_CONTENT = true;
|
|
430
|
+
|
|
431
|
+
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
432
|
+
* of importing it into a new Document and returning a sanitized copy */
|
|
433
|
+
var IN_PLACE = false;
|
|
434
|
+
|
|
435
|
+
/* Allow usage of profiles like html, svg and mathMl */
|
|
436
|
+
var USE_PROFILES = {};
|
|
437
|
+
|
|
438
|
+
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
439
|
+
var FORBID_CONTENTS = null;
|
|
440
|
+
var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
441
|
+
|
|
442
|
+
/* Tags that are safe for data: URIs */
|
|
443
|
+
var DATA_URI_TAGS = null;
|
|
444
|
+
var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
445
|
+
|
|
446
|
+
/* Attributes safe for values like "javascript:" */
|
|
447
|
+
var URI_SAFE_ATTRIBUTES = null;
|
|
448
|
+
var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
449
|
+
|
|
450
|
+
var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
451
|
+
var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
452
|
+
var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
453
|
+
/* Document namespace */
|
|
454
|
+
var NAMESPACE = HTML_NAMESPACE;
|
|
455
|
+
var IS_EMPTY_INPUT = false;
|
|
456
|
+
|
|
457
|
+
/* Parsing of strict XHTML documents */
|
|
458
|
+
var PARSER_MEDIA_TYPE = void 0;
|
|
459
|
+
var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
460
|
+
var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
461
|
+
var transformCaseFunc = void 0;
|
|
462
|
+
|
|
463
|
+
/* Keep a reference to config to pass to hooks */
|
|
464
|
+
var CONFIG = null;
|
|
465
|
+
|
|
466
|
+
/* Ideally, do not touch anything below this line */
|
|
467
|
+
/* ______________________________________________ */
|
|
468
|
+
|
|
469
|
+
var formElement = document.createElement('form');
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* _parseConfig
|
|
473
|
+
*
|
|
474
|
+
* @param {Object} cfg optional config literal
|
|
475
|
+
*/
|
|
476
|
+
// eslint-disable-next-line complexity
|
|
477
|
+
var _parseConfig = function _parseConfig(cfg) {
|
|
478
|
+
if (CONFIG && CONFIG === cfg) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/* Shield configuration object from tampering */
|
|
483
|
+
if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') {
|
|
484
|
+
cfg = {};
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/* Shield configuration object from prototype pollution */
|
|
488
|
+
cfg = clone(cfg);
|
|
489
|
+
|
|
490
|
+
/* Set configuration parameters */
|
|
491
|
+
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS;
|
|
492
|
+
ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR;
|
|
493
|
+
URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
494
|
+
DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS;
|
|
495
|
+
FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS) : DEFAULT_FORBID_CONTENTS;
|
|
496
|
+
FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {};
|
|
497
|
+
FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {};
|
|
498
|
+
USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
|
|
499
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
500
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
501
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
502
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
|
503
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
|
504
|
+
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
|
505
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
|
506
|
+
RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true
|
|
507
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
|
508
|
+
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
|
509
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
510
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
511
|
+
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
512
|
+
IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1;
|
|
513
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
514
|
+
|
|
515
|
+
PARSER_MEDIA_TYPE =
|
|
516
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
517
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
|
|
518
|
+
|
|
519
|
+
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
520
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
|
|
521
|
+
return x;
|
|
522
|
+
} : stringToLowerCase;
|
|
523
|
+
|
|
524
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
525
|
+
ALLOW_DATA_ATTR = false;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
529
|
+
RETURN_DOM = true;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/* Parse profile info */
|
|
533
|
+
if (USE_PROFILES) {
|
|
534
|
+
ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text)));
|
|
535
|
+
ALLOWED_ATTR = [];
|
|
536
|
+
if (USE_PROFILES.html === true) {
|
|
537
|
+
addToSet(ALLOWED_TAGS, html);
|
|
538
|
+
addToSet(ALLOWED_ATTR, html$1);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (USE_PROFILES.svg === true) {
|
|
542
|
+
addToSet(ALLOWED_TAGS, svg);
|
|
543
|
+
addToSet(ALLOWED_ATTR, svg$1);
|
|
544
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
548
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
549
|
+
addToSet(ALLOWED_ATTR, svg$1);
|
|
550
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (USE_PROFILES.mathMl === true) {
|
|
554
|
+
addToSet(ALLOWED_TAGS, mathMl);
|
|
555
|
+
addToSet(ALLOWED_ATTR, mathMl$1);
|
|
556
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/* Merge configuration parameters */
|
|
561
|
+
if (cfg.ADD_TAGS) {
|
|
562
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
563
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (cfg.ADD_ATTR) {
|
|
570
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
571
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
578
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (cfg.FORBID_CONTENTS) {
|
|
582
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
583
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/* Add #text in case KEEP_CONTENT is set to true */
|
|
590
|
+
if (KEEP_CONTENT) {
|
|
591
|
+
ALLOWED_TAGS['#text'] = true;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
595
|
+
if (WHOLE_DOCUMENT) {
|
|
596
|
+
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
600
|
+
if (ALLOWED_TAGS.table) {
|
|
601
|
+
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
602
|
+
delete FORBID_TAGS.tbody;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// Prevent further manipulation of configuration.
|
|
606
|
+
// Not available in IE8, Safari 5, etc.
|
|
607
|
+
if (freeze) {
|
|
608
|
+
freeze(cfg);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
CONFIG = cfg;
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
615
|
+
|
|
616
|
+
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
|
|
617
|
+
|
|
618
|
+
/* Keep track of all possible SVG and MathML tags
|
|
619
|
+
* so that we can perform the namespace checks
|
|
620
|
+
* correctly. */
|
|
621
|
+
var ALL_SVG_TAGS = addToSet({}, svg);
|
|
622
|
+
addToSet(ALL_SVG_TAGS, svgFilters);
|
|
623
|
+
addToSet(ALL_SVG_TAGS, svgDisallowed);
|
|
624
|
+
|
|
625
|
+
var ALL_MATHML_TAGS = addToSet({}, mathMl);
|
|
626
|
+
addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
*
|
|
630
|
+
*
|
|
631
|
+
* @param {Element} element a DOM element whose namespace is being checked
|
|
632
|
+
* @returns {boolean} Return false if the element has a
|
|
633
|
+
* namespace that a spec-compliant parser would never
|
|
634
|
+
* return. Return true otherwise.
|
|
635
|
+
*/
|
|
636
|
+
var _checkValidNamespace = function _checkValidNamespace(element) {
|
|
637
|
+
var parent = getParentNode(element);
|
|
638
|
+
|
|
639
|
+
// In JSDOM, if we're inside shadow DOM, then parentNode
|
|
640
|
+
// can be null. We just simulate parent in this case.
|
|
641
|
+
if (!parent || !parent.tagName) {
|
|
642
|
+
parent = {
|
|
643
|
+
namespaceURI: HTML_NAMESPACE,
|
|
644
|
+
tagName: 'template'
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
var tagName = stringToLowerCase(element.tagName);
|
|
649
|
+
var parentTagName = stringToLowerCase(parent.tagName);
|
|
650
|
+
|
|
651
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
652
|
+
// The only way to switch from HTML namespace to SVG
|
|
653
|
+
// is via <svg>. If it happens via any other tag, then
|
|
654
|
+
// it should be killed.
|
|
655
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
656
|
+
return tagName === 'svg';
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// The only way to switch from MathML to SVG is via
|
|
660
|
+
// svg if parent is either <annotation-xml> or MathML
|
|
661
|
+
// text integration points.
|
|
662
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
663
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// We only allow elements that are defined in SVG
|
|
667
|
+
// spec. All others are disallowed in SVG namespace.
|
|
668
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
672
|
+
// The only way to switch from HTML namespace to MathML
|
|
673
|
+
// is via <math>. If it happens via any other tag, then
|
|
674
|
+
// it should be killed.
|
|
675
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
676
|
+
return tagName === 'math';
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// The only way to switch from SVG to MathML is via
|
|
680
|
+
// <math> and HTML integration points
|
|
681
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
682
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// We only allow elements that are defined in MathML
|
|
686
|
+
// spec. All others are disallowed in MathML namespace.
|
|
687
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
691
|
+
// The only way to switch from SVG to HTML is via
|
|
692
|
+
// HTML integration points, and from MathML to HTML
|
|
693
|
+
// is via MathML text integration points
|
|
694
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
695
|
+
return false;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// Certain elements are allowed in both SVG and HTML
|
|
703
|
+
// namespace. We need to specify them explicitly
|
|
704
|
+
// so that they don't get erronously deleted from
|
|
705
|
+
// HTML namespace.
|
|
706
|
+
var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
707
|
+
|
|
708
|
+
// We disallow tags that are specific for MathML
|
|
709
|
+
// or SVG and should never appear in HTML namespace
|
|
710
|
+
return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// The code should never reach this place (this means
|
|
714
|
+
// that the element somehow got namespace that is not
|
|
715
|
+
// HTML, SVG or MathML). Return false just in case.
|
|
716
|
+
return false;
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* _forceRemove
|
|
721
|
+
*
|
|
722
|
+
* @param {Node} node a DOM node
|
|
723
|
+
*/
|
|
724
|
+
var _forceRemove = function _forceRemove(node) {
|
|
725
|
+
arrayPush(DOMPurify.removed, { element: node });
|
|
726
|
+
try {
|
|
727
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
728
|
+
node.parentNode.removeChild(node);
|
|
729
|
+
} catch (_) {
|
|
730
|
+
try {
|
|
731
|
+
node.outerHTML = emptyHTML;
|
|
732
|
+
} catch (_) {
|
|
733
|
+
node.remove();
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* _removeAttribute
|
|
740
|
+
*
|
|
741
|
+
* @param {String} name an Attribute name
|
|
742
|
+
* @param {Node} node a DOM node
|
|
743
|
+
*/
|
|
744
|
+
var _removeAttribute = function _removeAttribute(name, node) {
|
|
745
|
+
try {
|
|
746
|
+
arrayPush(DOMPurify.removed, {
|
|
747
|
+
attribute: node.getAttributeNode(name),
|
|
748
|
+
from: node
|
|
749
|
+
});
|
|
750
|
+
} catch (_) {
|
|
751
|
+
arrayPush(DOMPurify.removed, {
|
|
752
|
+
attribute: null,
|
|
753
|
+
from: node
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
node.removeAttribute(name);
|
|
758
|
+
|
|
759
|
+
// We void attribute values for unremovable "is"" attributes
|
|
760
|
+
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
|
761
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
762
|
+
try {
|
|
763
|
+
_forceRemove(node);
|
|
764
|
+
} catch (_) {}
|
|
765
|
+
} else {
|
|
766
|
+
try {
|
|
767
|
+
node.setAttribute(name, '');
|
|
768
|
+
} catch (_) {}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* _initDocument
|
|
775
|
+
*
|
|
776
|
+
* @param {String} dirty a string of dirty markup
|
|
777
|
+
* @return {Document} a DOM, filled with the dirty markup
|
|
778
|
+
*/
|
|
779
|
+
var _initDocument = function _initDocument(dirty) {
|
|
780
|
+
/* Create a HTML document */
|
|
781
|
+
var doc = void 0;
|
|
782
|
+
var leadingWhitespace = void 0;
|
|
783
|
+
|
|
784
|
+
if (FORCE_BODY) {
|
|
785
|
+
dirty = '<remove></remove>' + dirty;
|
|
786
|
+
} else {
|
|
787
|
+
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
|
788
|
+
var matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
789
|
+
leadingWhitespace = matches && matches[0];
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
|
|
793
|
+
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
794
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
798
|
+
/*
|
|
799
|
+
* Use the DOMParser API by default, fallback later if needs be
|
|
800
|
+
* DOMParser not work for svg when has multiple root element.
|
|
801
|
+
*/
|
|
802
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
803
|
+
try {
|
|
804
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
805
|
+
} catch (_) {}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/* Use createHTMLDocument in case DOMParser is not available */
|
|
809
|
+
if (!doc || !doc.documentElement) {
|
|
810
|
+
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
811
|
+
try {
|
|
812
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
|
|
813
|
+
} catch (_) {
|
|
814
|
+
// Syntax error if dirtyPayload is invalid xml
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
var body = doc.body || doc.documentElement;
|
|
819
|
+
|
|
820
|
+
if (dirty && leadingWhitespace) {
|
|
821
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/* Work on whole document or just its body */
|
|
825
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
826
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* _createIterator
|
|
834
|
+
*
|
|
835
|
+
* @param {Document} root document/fragment to create iterator for
|
|
836
|
+
* @return {Iterator} iterator instance
|
|
837
|
+
*/
|
|
838
|
+
var _createIterator = function _createIterator(root) {
|
|
839
|
+
return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* _isClobbered
|
|
844
|
+
*
|
|
845
|
+
* @param {Node} elm element to check for clobbering attacks
|
|
846
|
+
* @return {Boolean} true if clobbered, false if safe
|
|
847
|
+
*/
|
|
848
|
+
var _isClobbered = function _isClobbered(elm) {
|
|
849
|
+
if (elm instanceof Text || elm instanceof Comment) {
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') {
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
return false;
|
|
858
|
+
};
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* _isNode
|
|
862
|
+
*
|
|
863
|
+
* @param {Node} obj object to check whether it's a DOM node
|
|
864
|
+
* @return {Boolean} true is object is a DOM node
|
|
865
|
+
*/
|
|
866
|
+
var _isNode = function _isNode(object) {
|
|
867
|
+
return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* _executeHook
|
|
872
|
+
* Execute user configurable hooks
|
|
873
|
+
*
|
|
874
|
+
* @param {String} entryPoint Name of the hook's entry point
|
|
875
|
+
* @param {Node} currentNode node to work on with the hook
|
|
876
|
+
* @param {Object} data additional hook parameters
|
|
877
|
+
*/
|
|
878
|
+
var _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
|
879
|
+
if (!hooks[entryPoint]) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
arrayForEach(hooks[entryPoint], function (hook) {
|
|
884
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
885
|
+
});
|
|
886
|
+
};
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* _sanitizeElements
|
|
890
|
+
*
|
|
891
|
+
* @protect nodeName
|
|
892
|
+
* @protect textContent
|
|
893
|
+
* @protect removeChild
|
|
894
|
+
*
|
|
895
|
+
* @param {Node} currentNode to check for permission to exist
|
|
896
|
+
* @return {Boolean} true if node was killed, false if left alive
|
|
897
|
+
*/
|
|
898
|
+
var _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
899
|
+
var content = void 0;
|
|
900
|
+
|
|
901
|
+
/* Execute a hook if present */
|
|
902
|
+
_executeHook('beforeSanitizeElements', currentNode, null);
|
|
903
|
+
|
|
904
|
+
/* Check if element is clobbered or can clobber */
|
|
905
|
+
if (_isClobbered(currentNode)) {
|
|
906
|
+
_forceRemove(currentNode);
|
|
907
|
+
return true;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/* Check if tagname contains Unicode */
|
|
911
|
+
if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) {
|
|
912
|
+
_forceRemove(currentNode);
|
|
913
|
+
return true;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/* Now let's check the element's type and name */
|
|
917
|
+
var tagName = transformCaseFunc(currentNode.nodeName);
|
|
918
|
+
|
|
919
|
+
/* Execute a hook if present */
|
|
920
|
+
_executeHook('uponSanitizeElement', currentNode, {
|
|
921
|
+
tagName: tagName,
|
|
922
|
+
allowedTags: ALLOWED_TAGS
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
926
|
+
if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
927
|
+
_forceRemove(currentNode);
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/* Mitigate a problem with templates inside select */
|
|
932
|
+
if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
|
|
933
|
+
_forceRemove(currentNode);
|
|
934
|
+
return true;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/* Remove element if anything forbids its presence */
|
|
938
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
939
|
+
/* Keep content except for bad-listed elements */
|
|
940
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
941
|
+
var parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
942
|
+
var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
943
|
+
|
|
944
|
+
if (childNodes && parentNode) {
|
|
945
|
+
var childCount = childNodes.length;
|
|
946
|
+
|
|
947
|
+
for (var i = childCount - 1; i >= 0; --i) {
|
|
948
|
+
parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
_forceRemove(currentNode);
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/* Check whether element has a valid namespace */
|
|
958
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
959
|
+
_forceRemove(currentNode);
|
|
960
|
+
return true;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
|
|
964
|
+
_forceRemove(currentNode);
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/* Sanitize element content to be template-safe */
|
|
969
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
|
|
970
|
+
/* Get the element's text content */
|
|
971
|
+
content = currentNode.textContent;
|
|
972
|
+
content = stringReplace(content, MUSTACHE_EXPR$$1, ' ');
|
|
973
|
+
content = stringReplace(content, ERB_EXPR$$1, ' ');
|
|
974
|
+
if (currentNode.textContent !== content) {
|
|
975
|
+
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
|
976
|
+
currentNode.textContent = content;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/* Execute a hook if present */
|
|
981
|
+
_executeHook('afterSanitizeElements', currentNode, null);
|
|
982
|
+
|
|
983
|
+
return false;
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* _isValidAttribute
|
|
988
|
+
*
|
|
989
|
+
* @param {string} lcTag Lowercase tag name of containing element.
|
|
990
|
+
* @param {string} lcName Lowercase attribute name.
|
|
991
|
+
* @param {string} value Attribute value.
|
|
992
|
+
* @return {Boolean} Returns true if `value` is valid, otherwise false.
|
|
993
|
+
*/
|
|
994
|
+
// eslint-disable-next-line complexity
|
|
995
|
+
var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
996
|
+
/* Make sure attribute cannot clobber */
|
|
997
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/* Allow valid data-* attributes: At least one character after "-"
|
|
1002
|
+
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
1003
|
+
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
1004
|
+
We don't need to check the value; it's always URI safe. */
|
|
1005
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
1006
|
+
return false;
|
|
1007
|
+
|
|
1008
|
+
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
1009
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else {
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
return true;
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* _sanitizeAttributes
|
|
1018
|
+
*
|
|
1019
|
+
* @protect attributes
|
|
1020
|
+
* @protect nodeName
|
|
1021
|
+
* @protect removeAttribute
|
|
1022
|
+
* @protect setAttribute
|
|
1023
|
+
*
|
|
1024
|
+
* @param {Node} currentNode to sanitize
|
|
1025
|
+
*/
|
|
1026
|
+
var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
1027
|
+
var attr = void 0;
|
|
1028
|
+
var value = void 0;
|
|
1029
|
+
var lcName = void 0;
|
|
1030
|
+
var l = void 0;
|
|
1031
|
+
/* Execute a hook if present */
|
|
1032
|
+
_executeHook('beforeSanitizeAttributes', currentNode, null);
|
|
1033
|
+
|
|
1034
|
+
var attributes = currentNode.attributes;
|
|
1035
|
+
|
|
1036
|
+
/* Check if we have attributes; if not we might have a text node */
|
|
1037
|
+
|
|
1038
|
+
if (!attributes) {
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
var hookEvent = {
|
|
1043
|
+
attrName: '',
|
|
1044
|
+
attrValue: '',
|
|
1045
|
+
keepAttr: true,
|
|
1046
|
+
allowedAttributes: ALLOWED_ATTR
|
|
1047
|
+
};
|
|
1048
|
+
l = attributes.length;
|
|
1049
|
+
|
|
1050
|
+
/* Go backwards over all attributes; safely remove bad ones */
|
|
1051
|
+
while (l--) {
|
|
1052
|
+
attr = attributes[l];
|
|
1053
|
+
var _attr = attr,
|
|
1054
|
+
name = _attr.name,
|
|
1055
|
+
namespaceURI = _attr.namespaceURI;
|
|
1056
|
+
|
|
1057
|
+
value = stringTrim(attr.value);
|
|
1058
|
+
lcName = transformCaseFunc(name);
|
|
1059
|
+
|
|
1060
|
+
/* Execute a hook if present */
|
|
1061
|
+
hookEvent.attrName = lcName;
|
|
1062
|
+
hookEvent.attrValue = value;
|
|
1063
|
+
hookEvent.keepAttr = true;
|
|
1064
|
+
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
1065
|
+
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
|
|
1066
|
+
value = hookEvent.attrValue;
|
|
1067
|
+
/* Did the hooks approve of the attribute? */
|
|
1068
|
+
if (hookEvent.forceKeepAttr) {
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/* Remove attribute */
|
|
1073
|
+
_removeAttribute(name, currentNode);
|
|
1074
|
+
|
|
1075
|
+
/* Did the hooks approve of the attribute? */
|
|
1076
|
+
if (!hookEvent.keepAttr) {
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/* Work around a security issue in jQuery 3.0 */
|
|
1081
|
+
if (regExpTest(/\/>/i, value)) {
|
|
1082
|
+
_removeAttribute(name, currentNode);
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/* Sanitize attribute content to be template-safe */
|
|
1087
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1088
|
+
value = stringReplace(value, MUSTACHE_EXPR$$1, ' ');
|
|
1089
|
+
value = stringReplace(value, ERB_EXPR$$1, ' ');
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/* Is `value` valid for this attribute? */
|
|
1093
|
+
var lcTag = transformCaseFunc(currentNode.nodeName);
|
|
1094
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/* Handle invalid data-* attribute set by try-catching it */
|
|
1099
|
+
try {
|
|
1100
|
+
if (namespaceURI) {
|
|
1101
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
1102
|
+
} else {
|
|
1103
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
1104
|
+
currentNode.setAttribute(name, value);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
arrayPop(DOMPurify.removed);
|
|
1108
|
+
} catch (_) {}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/* Execute a hook if present */
|
|
1112
|
+
_executeHook('afterSanitizeAttributes', currentNode, null);
|
|
1113
|
+
};
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* _sanitizeShadowDOM
|
|
1117
|
+
*
|
|
1118
|
+
* @param {DocumentFragment} fragment to iterate over recursively
|
|
1119
|
+
*/
|
|
1120
|
+
var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
1121
|
+
var shadowNode = void 0;
|
|
1122
|
+
var shadowIterator = _createIterator(fragment);
|
|
1123
|
+
|
|
1124
|
+
/* Execute a hook if present */
|
|
1125
|
+
_executeHook('beforeSanitizeShadowDOM', fragment, null);
|
|
1126
|
+
|
|
1127
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
1128
|
+
/* Execute a hook if present */
|
|
1129
|
+
_executeHook('uponSanitizeShadowNode', shadowNode, null);
|
|
1130
|
+
|
|
1131
|
+
/* Sanitize tags and elements */
|
|
1132
|
+
if (_sanitizeElements(shadowNode)) {
|
|
1133
|
+
continue;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/* Deep shadow DOM detected */
|
|
1137
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
1138
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/* Check attributes, sanitize if necessary */
|
|
1142
|
+
_sanitizeAttributes(shadowNode);
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
/* Execute a hook if present */
|
|
1146
|
+
_executeHook('afterSanitizeShadowDOM', fragment, null);
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Sanitize
|
|
1151
|
+
* Public method providing core sanitation functionality
|
|
1152
|
+
*
|
|
1153
|
+
* @param {String|Node} dirty string or DOM node
|
|
1154
|
+
* @param {Object} configuration object
|
|
1155
|
+
*/
|
|
1156
|
+
// eslint-disable-next-line complexity
|
|
1157
|
+
DOMPurify.sanitize = function (dirty, cfg) {
|
|
1158
|
+
var body = void 0;
|
|
1159
|
+
var importedNode = void 0;
|
|
1160
|
+
var currentNode = void 0;
|
|
1161
|
+
var oldNode = void 0;
|
|
1162
|
+
var returnNode = void 0;
|
|
1163
|
+
/* Make sure we have a string to sanitize.
|
|
1164
|
+
DO NOT return early, as this will return the wrong type if
|
|
1165
|
+
the user has requested a DOM object rather than a string */
|
|
1166
|
+
IS_EMPTY_INPUT = !dirty;
|
|
1167
|
+
if (IS_EMPTY_INPUT) {
|
|
1168
|
+
dirty = '<!-->';
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/* Stringify, in case dirty is an object */
|
|
1172
|
+
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
1173
|
+
// eslint-disable-next-line no-negated-condition
|
|
1174
|
+
if (typeof dirty.toString !== 'function') {
|
|
1175
|
+
throw typeErrorCreate('toString is not a function');
|
|
1176
|
+
} else {
|
|
1177
|
+
dirty = dirty.toString();
|
|
1178
|
+
if (typeof dirty !== 'string') {
|
|
1179
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/* Check we can run. Otherwise fall back or ignore */
|
|
1185
|
+
if (!DOMPurify.isSupported) {
|
|
1186
|
+
if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
|
|
1187
|
+
if (typeof dirty === 'string') {
|
|
1188
|
+
return window.toStaticHTML(dirty);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
if (_isNode(dirty)) {
|
|
1192
|
+
return window.toStaticHTML(dirty.outerHTML);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
return dirty;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/* Assign config vars */
|
|
1200
|
+
if (!SET_CONFIG) {
|
|
1201
|
+
_parseConfig(cfg);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/* Clean up removed elements */
|
|
1205
|
+
DOMPurify.removed = [];
|
|
1206
|
+
|
|
1207
|
+
/* Check if dirty is correctly typed for IN_PLACE */
|
|
1208
|
+
if (typeof dirty === 'string') {
|
|
1209
|
+
IN_PLACE = false;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
if (IN_PLACE) ; else if (dirty instanceof Node) {
|
|
1213
|
+
/* If dirty is a DOM element, append to an empty document to avoid
|
|
1214
|
+
elements being stripped by the parser */
|
|
1215
|
+
body = _initDocument('<!---->');
|
|
1216
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
1217
|
+
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
|
|
1218
|
+
/* Node is already a body, use as is */
|
|
1219
|
+
body = importedNode;
|
|
1220
|
+
} else if (importedNode.nodeName === 'HTML') {
|
|
1221
|
+
body = importedNode;
|
|
1222
|
+
} else {
|
|
1223
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
1224
|
+
body.appendChild(importedNode);
|
|
1225
|
+
}
|
|
1226
|
+
} else {
|
|
1227
|
+
/* Exit directly if we have nothing to do */
|
|
1228
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
1229
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
1230
|
+
dirty.indexOf('<') === -1) {
|
|
1231
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/* Initialize the document to work on */
|
|
1235
|
+
body = _initDocument(dirty);
|
|
1236
|
+
|
|
1237
|
+
/* Check we have a DOM node from the data */
|
|
1238
|
+
if (!body) {
|
|
1239
|
+
return RETURN_DOM ? null : emptyHTML;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
1244
|
+
if (body && FORCE_BODY) {
|
|
1245
|
+
_forceRemove(body.firstChild);
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/* Get node iterator */
|
|
1249
|
+
var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
|
|
1250
|
+
|
|
1251
|
+
/* Now start iterating over the created document */
|
|
1252
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
1253
|
+
/* Fix IE's strange behavior with manipulated textNodes #89 */
|
|
1254
|
+
if (currentNode.nodeType === 3 && currentNode === oldNode) {
|
|
1255
|
+
continue;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/* Sanitize tags and elements */
|
|
1259
|
+
if (_sanitizeElements(currentNode)) {
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/* Shadow DOM detected, sanitize it */
|
|
1264
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
1265
|
+
_sanitizeShadowDOM(currentNode.content);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/* Check attributes, sanitize if necessary */
|
|
1269
|
+
_sanitizeAttributes(currentNode);
|
|
1270
|
+
|
|
1271
|
+
oldNode = currentNode;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
oldNode = null;
|
|
1275
|
+
|
|
1276
|
+
/* If we sanitized `dirty` in-place, return it. */
|
|
1277
|
+
if (IN_PLACE) {
|
|
1278
|
+
return dirty;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/* Return sanitized string or DOM */
|
|
1282
|
+
if (RETURN_DOM) {
|
|
1283
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
1284
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
1285
|
+
|
|
1286
|
+
while (body.firstChild) {
|
|
1287
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
1288
|
+
returnNode.appendChild(body.firstChild);
|
|
1289
|
+
}
|
|
1290
|
+
} else {
|
|
1291
|
+
returnNode = body;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
if (RETURN_DOM_IMPORT) {
|
|
1295
|
+
/*
|
|
1296
|
+
AdoptNode() is not used because internal state is not reset
|
|
1297
|
+
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
1298
|
+
in theory but we would rather not risk another attack vector.
|
|
1299
|
+
The state that is cloned by importNode() is explicitly defined
|
|
1300
|
+
by the specs.
|
|
1301
|
+
*/
|
|
1302
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
return returnNode;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
1309
|
+
|
|
1310
|
+
/* Sanitize final string template-safe */
|
|
1311
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1312
|
+
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' ');
|
|
1313
|
+
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' ');
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* Public method to set the configuration once
|
|
1321
|
+
* setConfig
|
|
1322
|
+
*
|
|
1323
|
+
* @param {Object} cfg configuration object
|
|
1324
|
+
*/
|
|
1325
|
+
DOMPurify.setConfig = function (cfg) {
|
|
1326
|
+
_parseConfig(cfg);
|
|
1327
|
+
SET_CONFIG = true;
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Public method to remove the configuration
|
|
1332
|
+
* clearConfig
|
|
1333
|
+
*
|
|
1334
|
+
*/
|
|
1335
|
+
DOMPurify.clearConfig = function () {
|
|
1336
|
+
CONFIG = null;
|
|
1337
|
+
SET_CONFIG = false;
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Public method to check if an attribute value is valid.
|
|
1342
|
+
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
1343
|
+
* isValidAttribute
|
|
1344
|
+
*
|
|
1345
|
+
* @param {string} tag Tag name of containing element.
|
|
1346
|
+
* @param {string} attr Attribute name.
|
|
1347
|
+
* @param {string} value Attribute value.
|
|
1348
|
+
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
1349
|
+
*/
|
|
1350
|
+
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
1351
|
+
/* Initialize shared config vars if necessary. */
|
|
1352
|
+
if (!CONFIG) {
|
|
1353
|
+
_parseConfig({});
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
var lcTag = transformCaseFunc(tag);
|
|
1357
|
+
var lcName = transformCaseFunc(attr);
|
|
1358
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* AddHook
|
|
1363
|
+
* Public method to add DOMPurify hooks
|
|
1364
|
+
*
|
|
1365
|
+
* @param {String} entryPoint entry point for the hook to add
|
|
1366
|
+
* @param {Function} hookFunction function to execute
|
|
1367
|
+
*/
|
|
1368
|
+
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
1369
|
+
if (typeof hookFunction !== 'function') {
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
1374
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* RemoveHook
|
|
1379
|
+
* Public method to remove a DOMPurify hook at a given entryPoint
|
|
1380
|
+
* (pops it from the stack of hooks if more are present)
|
|
1381
|
+
*
|
|
1382
|
+
* @param {String} entryPoint entry point for the hook to remove
|
|
1383
|
+
*/
|
|
1384
|
+
DOMPurify.removeHook = function (entryPoint) {
|
|
1385
|
+
if (hooks[entryPoint]) {
|
|
1386
|
+
arrayPop(hooks[entryPoint]);
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* RemoveHooks
|
|
1392
|
+
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
1393
|
+
*
|
|
1394
|
+
* @param {String} entryPoint entry point for the hooks to remove
|
|
1395
|
+
*/
|
|
1396
|
+
DOMPurify.removeHooks = function (entryPoint) {
|
|
1397
|
+
if (hooks[entryPoint]) {
|
|
1398
|
+
hooks[entryPoint] = [];
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* RemoveAllHooks
|
|
1404
|
+
* Public method to remove all DOMPurify hooks
|
|
1405
|
+
*
|
|
1406
|
+
*/
|
|
1407
|
+
DOMPurify.removeAllHooks = function () {
|
|
1408
|
+
hooks = {};
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
return DOMPurify;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
var purify = createDOMPurify();
|
|
1415
|
+
|
|
1416
|
+
return purify;
|
|
1417
|
+
|
|
1418
|
+
}));
|
|
1419
|
+
//# sourceMappingURL=purify.js.map
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
/***/ }),
|
|
1423
|
+
|
|
21
1424
|
/***/ 928:
|
|
22
1425
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
23
1426
|
|
|
1427
|
+
"use strict";
|
|
24
1428
|
/* eslint-disable complexity */
|
|
25
1429
|
/**
|
|
26
1430
|
* @fileoverview Returns the first index at which a given element can be found in the array.
|
|
@@ -46,11 +1450,15 @@ var isArray = __webpack_require__(322);
|
|
|
46
1450
|
* @returns {number} the First index at which a given element, or -1 if it is not present
|
|
47
1451
|
* @memberof module:array
|
|
48
1452
|
* @example
|
|
49
|
-
*
|
|
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
|
/***/ 516:
|
|
1036
2481
|
/***/ (function(module) {
|
|
1037
2482
|
|
|
2483
|
+
"use strict";
|
|
1038
2484
|
/**
|
|
1039
2485
|
* @fileoverview Creates a debounced function that delays invoking fn until after delay milliseconds has elapsed since the last time the debouced function was invoked.
|
|
1040
2486
|
* @author NHN FE Development Lab <dl_javascript.nhn.com>
|
|
@@ -1054,11 +2500,15 @@ module.exports = sendHostname;
|
|
|
1054
2500
|
* @returns {function} debounced function.
|
|
1055
2501
|
* @memberof module:tricks
|
|
1056
2502
|
* @example
|
|
1057
|
-
*
|
|
2503
|
+
* // ES6
|
|
2504
|
+
* import debounce from 'tui-code-snippet/tricks/debounce';
|
|
2505
|
+
*
|
|
2506
|
+
* // CommonJS
|
|
2507
|
+
* const debounce = require('tui-code-snippet/tricks/debounce');
|
|
1058
2508
|
*
|
|
1059
2509
|
* function someMethodToInvokeDebounced() {}
|
|
1060
2510
|
*
|
|
1061
|
-
*
|
|
2511
|
+
* const debounced = debounce(someMethodToInvokeDebounced, 300);
|
|
1062
2512
|
*
|
|
1063
2513
|
* // invoke repeatedly
|
|
1064
2514
|
* debounced();
|
|
@@ -1096,6 +2546,7 @@ module.exports = debounce;
|
|
|
1096
2546
|
/***/ 423:
|
|
1097
2547
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1098
2548
|
|
|
2549
|
+
"use strict";
|
|
1099
2550
|
/**
|
|
1100
2551
|
* @fileoverview Creates a throttled function that only invokes fn at most once per every interval milliseconds.
|
|
1101
2552
|
* @author NHN FE Development Lab <dl_javascript.nhn.com>
|
|
@@ -1114,11 +2565,15 @@ var debounce = __webpack_require__(516);
|
|
|
1114
2565
|
* @returns {function} throttled function
|
|
1115
2566
|
* @memberof module:tricks
|
|
1116
2567
|
* @example
|
|
1117
|
-
*
|
|
2568
|
+
* // ES6
|
|
2569
|
+
* import throttle from 'tui-code-snippet/tricks/throttle';
|
|
2570
|
+
*
|
|
2571
|
+
* // CommonJS
|
|
2572
|
+
* const throttle = require('tui-code-snippet/tricks/throttle');
|
|
1118
2573
|
*
|
|
1119
2574
|
* function someMethodToInvokeThrottled() {}
|
|
1120
2575
|
*
|
|
1121
|
-
*
|
|
2576
|
+
* const throttled = throttle(someMethodToInvokeThrottled, 300);
|
|
1122
2577
|
*
|
|
1123
2578
|
* // invoke repeatedly
|
|
1124
2579
|
* throttled(); // invoke (leading)
|
|
@@ -1191,6 +2646,7 @@ module.exports = throttle;
|
|
|
1191
2646
|
/***/ 322:
|
|
1192
2647
|
/***/ (function(module) {
|
|
1193
2648
|
|
|
2649
|
+
"use strict";
|
|
1194
2650
|
/**
|
|
1195
2651
|
* @fileoverview Check whether the given variable is an instance of Array or not.
|
|
1196
2652
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1217,6 +2673,7 @@ module.exports = isArray;
|
|
|
1217
2673
|
/***/ 326:
|
|
1218
2674
|
/***/ (function(module) {
|
|
1219
2675
|
|
|
2676
|
+
"use strict";
|
|
1220
2677
|
/**
|
|
1221
2678
|
* @fileoverview Check whether the given variable is a string or not.
|
|
1222
2679
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1243,6 +2700,7 @@ module.exports = isBoolean;
|
|
|
1243
2700
|
/***/ 65:
|
|
1244
2701
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1245
2702
|
|
|
2703
|
+
"use strict";
|
|
1246
2704
|
/**
|
|
1247
2705
|
* @fileoverview Check whether the given variable is existing or not.
|
|
1248
2706
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1260,7 +2718,11 @@ var isNull = __webpack_require__(934);
|
|
|
1260
2718
|
* @returns {boolean} Is existy?
|
|
1261
2719
|
* @memberof module:type
|
|
1262
2720
|
* @example
|
|
1263
|
-
*
|
|
2721
|
+
* // ES6
|
|
2722
|
+
* import isExisty from 'tui-code-snippet/type/isExisty');
|
|
2723
|
+
*
|
|
2724
|
+
* // CommonJS
|
|
2725
|
+
* const isExisty = require('tui-code-snippet/type/isExisty');
|
|
1264
2726
|
*
|
|
1265
2727
|
* isExisty(''); //true
|
|
1266
2728
|
* isExisty(0); //true
|
|
@@ -1281,6 +2743,7 @@ module.exports = isExisty;
|
|
|
1281
2743
|
/***/ 404:
|
|
1282
2744
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1283
2745
|
|
|
2746
|
+
"use strict";
|
|
1284
2747
|
/**
|
|
1285
2748
|
* @fileoverview Check whether the given variable is falsy or not.
|
|
1286
2749
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1309,6 +2772,7 @@ module.exports = isFalsy;
|
|
|
1309
2772
|
/***/ 294:
|
|
1310
2773
|
/***/ (function(module) {
|
|
1311
2774
|
|
|
2775
|
+
"use strict";
|
|
1312
2776
|
/**
|
|
1313
2777
|
* @fileoverview Check whether the given variable is a function or not.
|
|
1314
2778
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1335,6 +2799,7 @@ module.exports = isFunction;
|
|
|
1335
2799
|
/***/ 934:
|
|
1336
2800
|
/***/ (function(module) {
|
|
1337
2801
|
|
|
2802
|
+
"use strict";
|
|
1338
2803
|
/**
|
|
1339
2804
|
* @fileoverview Check whether the given variable is null or not.
|
|
1340
2805
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1361,6 +2826,7 @@ module.exports = isNull;
|
|
|
1361
2826
|
/***/ 321:
|
|
1362
2827
|
/***/ (function(module) {
|
|
1363
2828
|
|
|
2829
|
+
"use strict";
|
|
1364
2830
|
/**
|
|
1365
2831
|
* @fileoverview Check whether the given variable is a number or not.
|
|
1366
2832
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1387,6 +2853,7 @@ module.exports = isNumber;
|
|
|
1387
2853
|
/***/ 73:
|
|
1388
2854
|
/***/ (function(module) {
|
|
1389
2855
|
|
|
2856
|
+
"use strict";
|
|
1390
2857
|
/**
|
|
1391
2858
|
* @fileoverview Check whether the given variable is an object or not.
|
|
1392
2859
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1413,6 +2880,7 @@ module.exports = isObject;
|
|
|
1413
2880
|
/***/ 758:
|
|
1414
2881
|
/***/ (function(module) {
|
|
1415
2882
|
|
|
2883
|
+
"use strict";
|
|
1416
2884
|
/**
|
|
1417
2885
|
* @fileoverview Check whether the given variable is a string or not.
|
|
1418
2886
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1439,6 +2907,7 @@ module.exports = isString;
|
|
|
1439
2907
|
/***/ 790:
|
|
1440
2908
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1441
2909
|
|
|
2910
|
+
"use strict";
|
|
1442
2911
|
/**
|
|
1443
2912
|
* @fileoverview Check whether the given variable is truthy or not.
|
|
1444
2913
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1468,6 +2937,7 @@ module.exports = isTruthy;
|
|
|
1468
2937
|
/***/ 929:
|
|
1469
2938
|
/***/ (function(module) {
|
|
1470
2939
|
|
|
2940
|
+
"use strict";
|
|
1471
2941
|
/**
|
|
1472
2942
|
* @fileoverview Check whether the given variable is undefined or not.
|
|
1473
2943
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1494,6 +2964,7 @@ module.exports = isUndefined;
|
|
|
1494
2964
|
/***/ 818:
|
|
1495
2965
|
/***/ (function(module) {
|
|
1496
2966
|
|
|
2967
|
+
"use strict";
|
|
1497
2968
|
module.exports = __WEBPACK_EXTERNAL_MODULE__818__;
|
|
1498
2969
|
|
|
1499
2970
|
/***/ }),
|
|
@@ -1501,6 +2972,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__818__;
|
|
|
1501
2972
|
/***/ 168:
|
|
1502
2973
|
/***/ (function(module) {
|
|
1503
2974
|
|
|
2975
|
+
"use strict";
|
|
1504
2976
|
module.exports = __WEBPACK_EXTERNAL_MODULE__168__;
|
|
1505
2977
|
|
|
1506
2978
|
/***/ }),
|
|
@@ -1508,6 +2980,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__168__;
|
|
|
1508
2980
|
/***/ 925:
|
|
1509
2981
|
/***/ (function(module) {
|
|
1510
2982
|
|
|
2983
|
+
"use strict";
|
|
1511
2984
|
module.exports = __WEBPACK_EXTERNAL_MODULE__925__;
|
|
1512
2985
|
|
|
1513
2986
|
/***/ }),
|
|
@@ -1515,6 +2988,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__925__;
|
|
|
1515
2988
|
/***/ 703:
|
|
1516
2989
|
/***/ (function(module) {
|
|
1517
2990
|
|
|
2991
|
+
"use strict";
|
|
1518
2992
|
module.exports = __WEBPACK_EXTERNAL_MODULE__703__;
|
|
1519
2993
|
|
|
1520
2994
|
/***/ }),
|
|
@@ -1522,6 +2996,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__703__;
|
|
|
1522
2996
|
/***/ 959:
|
|
1523
2997
|
/***/ (function(module) {
|
|
1524
2998
|
|
|
2999
|
+
"use strict";
|
|
1525
3000
|
module.exports = __WEBPACK_EXTERNAL_MODULE__959__;
|
|
1526
3001
|
|
|
1527
3002
|
/***/ }),
|
|
@@ -1529,6 +3004,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__959__;
|
|
|
1529
3004
|
/***/ 676:
|
|
1530
3005
|
/***/ (function(module) {
|
|
1531
3006
|
|
|
3007
|
+
"use strict";
|
|
1532
3008
|
module.exports = __WEBPACK_EXTERNAL_MODULE__676__;
|
|
1533
3009
|
|
|
1534
3010
|
/***/ }),
|
|
@@ -1536,6 +3012,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__676__;
|
|
|
1536
3012
|
/***/ 747:
|
|
1537
3013
|
/***/ (function(module) {
|
|
1538
3014
|
|
|
3015
|
+
"use strict";
|
|
1539
3016
|
module.exports = __WEBPACK_EXTERNAL_MODULE__747__;
|
|
1540
3017
|
|
|
1541
3018
|
/***/ }),
|
|
@@ -1543,6 +3020,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__747__;
|
|
|
1543
3020
|
/***/ 754:
|
|
1544
3021
|
/***/ (function(module) {
|
|
1545
3022
|
|
|
3023
|
+
"use strict";
|
|
1546
3024
|
module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
|
|
1547
3025
|
|
|
1548
3026
|
/***/ })
|
|
@@ -1567,7 +3045,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
|
|
|
1567
3045
|
/******/ };
|
|
1568
3046
|
/******/
|
|
1569
3047
|
/******/ // Execute the module function
|
|
1570
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
3048
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
1571
3049
|
/******/
|
|
1572
3050
|
/******/ // Return the exports of the module
|
|
1573
3051
|
/******/ return module.exports;
|
|
@@ -1617,8 +3095,9 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
|
|
|
1617
3095
|
/******/
|
|
1618
3096
|
/************************************************************************/
|
|
1619
3097
|
var __webpack_exports__ = {};
|
|
1620
|
-
// This entry need to be wrapped in an IIFE because it need to be
|
|
3098
|
+
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
|
1621
3099
|
!function() {
|
|
3100
|
+
"use strict";
|
|
1622
3101
|
|
|
1623
3102
|
// EXPORTS
|
|
1624
3103
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -1792,10 +3271,14 @@ function __spreadArrays() {
|
|
|
1792
3271
|
return r;
|
|
1793
3272
|
}
|
|
1794
3273
|
|
|
1795
|
-
function __spreadArray(to, from) {
|
|
1796
|
-
for (var i = 0,
|
|
1797
|
-
|
|
1798
|
-
|
|
3274
|
+
function __spreadArray(to, from, pack) {
|
|
3275
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3276
|
+
if (ar || !(i in from)) {
|
|
3277
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
3278
|
+
ar[i] = from[i];
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1799
3282
|
}
|
|
1800
3283
|
|
|
1801
3284
|
function __await(v) {
|
|
@@ -1851,19 +3334,17 @@ function __importDefault(mod) {
|
|
|
1851
3334
|
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
1852
3335
|
}
|
|
1853
3336
|
|
|
1854
|
-
function __classPrivateFieldGet(receiver,
|
|
1855
|
-
if (!
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
return privateMap.get(receiver);
|
|
3337
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
3338
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3339
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
3340
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1859
3341
|
}
|
|
1860
3342
|
|
|
1861
|
-
function __classPrivateFieldSet(receiver,
|
|
1862
|
-
if (
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
return value;
|
|
3343
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
3344
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3345
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
3346
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3347
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1867
3348
|
}
|
|
1868
3349
|
|
|
1869
3350
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-model","commonjs2":"prosemirror-model","amd":"prosemirror-model"}
|
|
@@ -1903,7 +3384,13 @@ var sendHostname_default = /*#__PURE__*/__webpack_require__.n(sendHostname);
|
|
|
1903
3384
|
|
|
1904
3385
|
|
|
1905
3386
|
|
|
3387
|
+
|
|
1906
3388
|
var isMac = /Mac/.test(navigator.platform);
|
|
3389
|
+
var reSpaceMoreThanOne = /[\u0020]+/g;
|
|
3390
|
+
var reEscapeChars = /[>(){}[\]+-.!#|]/g;
|
|
3391
|
+
var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\/>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>|<!--[^-]+-->|<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g;
|
|
3392
|
+
var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
|
|
3393
|
+
var reEscapePairedChars = /[*_~`]/g;
|
|
1907
3394
|
function sendHostName() {
|
|
1908
3395
|
sendHostname_default()('editor', 'UA-129966929-1');
|
|
1909
3396
|
}
|
|
@@ -1911,6 +3398,19 @@ function common_includes(arr, targetItem) {
|
|
|
1911
3398
|
return arr.indexOf(targetItem) !== -1;
|
|
1912
3399
|
}
|
|
1913
3400
|
var availableLinkAttributes = ['rel', 'target', 'hreflang', 'type'];
|
|
3401
|
+
var reMarkdownTextToEscapeMap = {
|
|
3402
|
+
codeblock: /(^ {4}[^\n]+\n*)+/,
|
|
3403
|
+
thematicBreak: /^ *((\* *){3,}|(- *){3,} *|(_ *){3,}) */,
|
|
3404
|
+
atxHeading: /^(#{1,6}) +[\s\S]+/,
|
|
3405
|
+
seTextheading: /^([^\n]+)\n *(=|-){2,} */,
|
|
3406
|
+
blockquote: /^( *>[^\n]+.*)+/,
|
|
3407
|
+
list: /^ *(\*+|-+|\d+\.) [\s\S]+/,
|
|
3408
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? */,
|
|
3409
|
+
link: /!?\[.*\]\(.*\)/,
|
|
3410
|
+
reflink: /!?\[.*\]\s*\[([^\]]*)\]/,
|
|
3411
|
+
verticalBar: /\u007C/,
|
|
3412
|
+
fencedCodeblock: /^((`|~){3,})/,
|
|
3413
|
+
};
|
|
1914
3414
|
function sanitizeLinkAttribute(attribute) {
|
|
1915
3415
|
if (!attribute) {
|
|
1916
3416
|
return null;
|
|
@@ -1930,12 +3430,30 @@ function repeat(text, count) {
|
|
|
1930
3430
|
}
|
|
1931
3431
|
return result;
|
|
1932
3432
|
}
|
|
1933
|
-
function
|
|
1934
|
-
var
|
|
1935
|
-
|
|
1936
|
-
|
|
3433
|
+
function isNeedEscapeText(text) {
|
|
3434
|
+
var needEscape = false;
|
|
3435
|
+
forEachOwnProperties_default()(reMarkdownTextToEscapeMap, function (reMarkdownTextToEscape) {
|
|
3436
|
+
if (reMarkdownTextToEscape.test(text)) {
|
|
3437
|
+
needEscape = true;
|
|
3438
|
+
}
|
|
3439
|
+
return !needEscape;
|
|
3440
|
+
});
|
|
3441
|
+
return needEscape;
|
|
3442
|
+
}
|
|
3443
|
+
function common_escape(text) {
|
|
3444
|
+
var replacer = function (matched) { return "\\" + matched; };
|
|
3445
|
+
var escapedText = text.replace(reSpaceMoreThanOne, ' ');
|
|
3446
|
+
if (reEscapeBackSlash.test(escapedText)) {
|
|
3447
|
+
escapedText = escapedText.replace(reEscapeBackSlash, replacer);
|
|
1937
3448
|
}
|
|
1938
|
-
|
|
3449
|
+
escapedText = escapedText.replace(reEscapePairedChars, replacer);
|
|
3450
|
+
if (reEscapeHTML.test(escapedText)) {
|
|
3451
|
+
escapedText = escapedText.replace(reEscapeHTML, replacer);
|
|
3452
|
+
}
|
|
3453
|
+
if (isNeedEscapeText(escapedText)) {
|
|
3454
|
+
escapedText = escapedText.replace(reEscapeChars, replacer);
|
|
3455
|
+
}
|
|
3456
|
+
return escapedText;
|
|
1939
3457
|
}
|
|
1940
3458
|
function quote(text) {
|
|
1941
3459
|
var result;
|
|
@@ -2667,7 +4185,7 @@ var EditorBase = /** @class */ (function () {
|
|
|
2667
4185
|
var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
|
|
2668
4186
|
var rules = this.createInputRules();
|
|
2669
4187
|
var plugins = __spreadArray(__spreadArray([], this.keymaps), [
|
|
2670
|
-
(0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(__assign({ 'Mod-z': undo(), 'Shift-Mod-z': redo() }, external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap)),
|
|
4188
|
+
(0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(__assign({ 'Mod-z': undo(), 'Shift-Mod-z': redo(), 'Shift-Enter': external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap.Enter }, external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap)),
|
|
2671
4189
|
(0,external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_.history)(),
|
|
2672
4190
|
placeholder(this.placeholder),
|
|
2673
4191
|
addWidget(this.eventEmitter),
|
|
@@ -2738,15 +4256,19 @@ var EditorBase = /** @class */ (function () {
|
|
|
2738
4256
|
delete _this[prop];
|
|
2739
4257
|
});
|
|
2740
4258
|
};
|
|
2741
|
-
EditorBase.prototype.moveCursorToStart = function () {
|
|
4259
|
+
EditorBase.prototype.moveCursorToStart = function (focus) {
|
|
2742
4260
|
var tr = this.view.state.tr;
|
|
2743
4261
|
this.view.dispatch(tr.setSelection(createTextSelection(tr, 1)).scrollIntoView());
|
|
2744
|
-
|
|
4262
|
+
if (focus) {
|
|
4263
|
+
this.focus();
|
|
4264
|
+
}
|
|
2745
4265
|
};
|
|
2746
|
-
EditorBase.prototype.moveCursorToEnd = function () {
|
|
4266
|
+
EditorBase.prototype.moveCursorToEnd = function (focus) {
|
|
2747
4267
|
var tr = this.view.state.tr;
|
|
2748
4268
|
this.view.dispatch(tr.setSelection(createTextSelection(tr, tr.doc.content.size - 1)).scrollIntoView());
|
|
2749
|
-
|
|
4269
|
+
if (focus) {
|
|
4270
|
+
this.focus();
|
|
4271
|
+
}
|
|
2750
4272
|
};
|
|
2751
4273
|
EditorBase.prototype.setScrollTop = function (top) {
|
|
2752
4274
|
this.view.dom.scrollTop = top;
|
|
@@ -2878,6 +4400,8 @@ var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE + ")*\\s*/?>";
|
|
|
2878
4400
|
var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
|
|
2879
4401
|
var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
|
|
2880
4402
|
var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
|
|
4403
|
+
var reBR = /<br\s*\/*>/i;
|
|
4404
|
+
var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
|
|
2881
4405
|
|
|
2882
4406
|
;// CONCATENATED MODULE: ./src/utils/dom.ts
|
|
2883
4407
|
|
|
@@ -2889,6 +4413,7 @@ var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
|
|
|
2889
4413
|
|
|
2890
4414
|
|
|
2891
4415
|
|
|
4416
|
+
|
|
2892
4417
|
function isPositionInBox(style, offsetX, offsetY) {
|
|
2893
4418
|
var left = parseInt(style.left, 10);
|
|
2894
4419
|
var top = parseInt(style.top, 10);
|
|
@@ -3027,7 +4552,7 @@ function finalizeHtml(html, needHtmlText) {
|
|
|
3027
4552
|
}
|
|
3028
4553
|
else {
|
|
3029
4554
|
var frag = document.createDocumentFragment();
|
|
3030
|
-
var childNodes =
|
|
4555
|
+
var childNodes = toArray(html.childNodes);
|
|
3031
4556
|
var length = childNodes.length;
|
|
3032
4557
|
for (var i = 0; i < length; i += 1) {
|
|
3033
4558
|
frag.appendChild(childNodes[i]);
|
|
@@ -3069,33 +4594,34 @@ function prependNode(node, appended) {
|
|
|
3069
4594
|
}
|
|
3070
4595
|
function setAttributes(attributes, element) {
|
|
3071
4596
|
Object.keys(attributes).forEach(function (attrName) {
|
|
3072
|
-
if (attributes[attrName]) {
|
|
3073
|
-
element.
|
|
4597
|
+
if (isNil(attributes[attrName])) {
|
|
4598
|
+
element.removeAttribute(attrName);
|
|
3074
4599
|
}
|
|
3075
4600
|
else {
|
|
3076
|
-
element.
|
|
4601
|
+
element.setAttribute(attrName, attributes[attrName]);
|
|
3077
4602
|
}
|
|
3078
4603
|
});
|
|
3079
4604
|
}
|
|
3080
4605
|
function replaceBRWithEmptyBlock(html) {
|
|
3081
|
-
|
|
4606
|
+
// remove br in paragraph to compatible with markdown
|
|
4607
|
+
var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
|
|
3082
4608
|
var reHTMLTag = new RegExp(HTML_TAG, 'ig');
|
|
3083
|
-
var htmlTagMatched =
|
|
4609
|
+
var htmlTagMatched = replacedHTML.match(reHTMLTag);
|
|
3084
4610
|
htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
|
|
3085
|
-
if (
|
|
3086
|
-
var alternativeTag =
|
|
4611
|
+
if (reBR.test(htmlTag)) {
|
|
4612
|
+
var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
|
|
3087
4613
|
if (index) {
|
|
3088
4614
|
var prevTag = htmlTagMatched[index - 1];
|
|
3089
4615
|
var openTagMatched = prevTag.match(OPEN_TAG);
|
|
3090
|
-
if (openTagMatched) {
|
|
4616
|
+
if (openTagMatched && !/br/i.test(openTagMatched[1])) {
|
|
3091
4617
|
var tagName = openTagMatched[1];
|
|
3092
4618
|
alternativeTag = "</" + tagName + "><" + tagName + ">";
|
|
3093
4619
|
}
|
|
3094
4620
|
}
|
|
3095
|
-
|
|
4621
|
+
replacedHTML = replacedHTML.replace(reBR, alternativeTag);
|
|
3096
4622
|
}
|
|
3097
4623
|
});
|
|
3098
|
-
return
|
|
4624
|
+
return replacedHTML;
|
|
3099
4625
|
}
|
|
3100
4626
|
|
|
3101
4627
|
;// CONCATENATED MODULE: ./src/markdown/helper/pos.ts
|
|
@@ -3108,12 +4634,8 @@ function resolveSelectionPos(selection) {
|
|
|
3108
4634
|
}
|
|
3109
4635
|
return [from, to];
|
|
3110
4636
|
}
|
|
3111
|
-
function
|
|
3112
|
-
|
|
3113
|
-
var childCount = fragment.childCount;
|
|
3114
|
-
var startLine = Math.min(fragment.findIndex(from).index + 1, childCount);
|
|
3115
|
-
var endLine = from === to ? startLine : Math.min(fragment.findIndex(to).index + 1, childCount);
|
|
3116
|
-
return [startLine, endLine];
|
|
4637
|
+
function getMdLine(resolvedPos) {
|
|
4638
|
+
return resolvedPos.index(0) + 1;
|
|
3117
4639
|
}
|
|
3118
4640
|
function getWidgetNodePos(node, chPos, direction) {
|
|
3119
4641
|
if (direction === void 0) { direction = 1; }
|
|
@@ -3130,13 +4652,15 @@ function getEditorToMdPos(doc, from, to) {
|
|
|
3130
4652
|
if (to === void 0) { to = from; }
|
|
3131
4653
|
var collapsed = from === to;
|
|
3132
4654
|
var startResolvedPos = doc.resolve(from);
|
|
3133
|
-
var
|
|
4655
|
+
var startLine = getMdLine(startResolvedPos);
|
|
4656
|
+
var endLine = startLine;
|
|
3134
4657
|
var startOffset = startResolvedPos.start(1);
|
|
3135
4658
|
var endOffset = startOffset;
|
|
3136
4659
|
if (!collapsed) {
|
|
3137
4660
|
// prevent the end offset from pointing to the root document position
|
|
3138
4661
|
var endResolvedPos = doc.resolve(to === doc.content.size ? to - 1 : to);
|
|
3139
|
-
endOffset = endResolvedPos.start();
|
|
4662
|
+
endOffset = endResolvedPos.start(1);
|
|
4663
|
+
endLine = getMdLine(endResolvedPos);
|
|
3140
4664
|
// To resolve the end offset excluding document tag size
|
|
3141
4665
|
if (endResolvedPos.pos === doc.content.size) {
|
|
3142
4666
|
to = doc.content.size - 2;
|
|
@@ -3145,8 +4669,8 @@ function getEditorToMdPos(doc, from, to) {
|
|
|
3145
4669
|
var startCh = Math.max(from - startOffset + 1, 1);
|
|
3146
4670
|
var endCh = Math.max(to - endOffset + 1, 1);
|
|
3147
4671
|
return [
|
|
3148
|
-
[
|
|
3149
|
-
[
|
|
4672
|
+
[startLine, startCh + getWidgetNodePos(doc.child(startLine - 1), startCh, -1)],
|
|
4673
|
+
[endLine, endCh + getWidgetNodePos(doc.child(endLine - 1), endCh, -1)],
|
|
3150
4674
|
];
|
|
3151
4675
|
}
|
|
3152
4676
|
function getStartPosListPerLine(doc, endIndex) {
|
|
@@ -3332,7 +4856,7 @@ function customBlock(node, start, end) {
|
|
|
3332
4856
|
var marks = [markInfo(setOffsetPos(start, 1), end, CUSTOM_BLOCK)];
|
|
3333
4857
|
marks.push(markInfo(start, addOffsetPos(start, syntaxEnd), DELIM));
|
|
3334
4858
|
if (info) {
|
|
3335
|
-
marks.push(markInfo(addOffsetPos(start,
|
|
4859
|
+
marks.push(markInfo(addOffsetPos(start, syntaxEnd), addOffsetPos(start, syntaxLength + info.length), META));
|
|
3336
4860
|
}
|
|
3337
4861
|
marks.push(markInfo(setOffsetPos(end, 1), end, DELIM));
|
|
3338
4862
|
var lineBackgroundMarkInfo = lineBackground(parent, start, end, 'custom-block');
|
|
@@ -5401,15 +6925,16 @@ function smartTask(_a) {
|
|
|
5401
6925
|
props: {
|
|
5402
6926
|
handleDOMEvents: {
|
|
5403
6927
|
keyup: function (view, ev) {
|
|
5404
|
-
var _a
|
|
6928
|
+
var _a;
|
|
6929
|
+
var _b = view.state, doc = _b.doc, tr = _b.tr, selection = _b.selection;
|
|
5405
6930
|
if (selection.empty && reTaskMarkerKey.test(ev.key)) {
|
|
5406
|
-
var
|
|
6931
|
+
var _c = getRangeInfo(selection), startIndex = _c.startIndex, startFromOffset = _c.startFromOffset, from = _c.from;
|
|
5407
6932
|
// should add `1` to line for the markdown parser
|
|
5408
6933
|
// because markdown parser has `1`(not zero) as the start number
|
|
5409
6934
|
var mdPos = [startIndex + 1, from - startFromOffset + 1];
|
|
5410
6935
|
var mdNode = toastMark.findNodeAtPosition(mdPos);
|
|
5411
6936
|
var paraNode = findClosestNode(mdNode, function (node) { var _a; return node.type === 'paragraph' && ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === 'item'; });
|
|
5412
|
-
if (paraNode
|
|
6937
|
+
if ((_a = paraNode === null || paraNode === void 0 ? void 0 : paraNode.firstChild) === null || _a === void 0 ? void 0 : _a.literal) {
|
|
5413
6938
|
var firstChild = paraNode.firstChild;
|
|
5414
6939
|
var matched = firstChild.literal.match(reTaskMarker);
|
|
5415
6940
|
if (matched) {
|
|
@@ -5471,6 +6996,7 @@ function smartTask(_a) {
|
|
|
5471
6996
|
|
|
5472
6997
|
|
|
5473
6998
|
var EVENT_TYPE = 'cut';
|
|
6999
|
+
var reLineEnding = /\r\n|\n|\r/;
|
|
5474
7000
|
var MdEditor = /** @class */ (function (_super) {
|
|
5475
7001
|
__extends(MdEditor, _super);
|
|
5476
7002
|
function MdEditor(eventEmitter, options) {
|
|
@@ -5663,7 +7189,7 @@ var MdEditor = /** @class */ (function (_super) {
|
|
|
5663
7189
|
MdEditor.prototype.replaceSelection = function (text, start, end) {
|
|
5664
7190
|
var newTr;
|
|
5665
7191
|
var _a = this.view.state, tr = _a.tr, schema = _a.schema, doc = _a.doc;
|
|
5666
|
-
var lineTexts = text.split(
|
|
7192
|
+
var lineTexts = text.split(reLineEnding);
|
|
5667
7193
|
var nodes = lineTexts.map(function (lineText) {
|
|
5668
7194
|
return createParagraph(schema, createNodesWithWidget(lineText, schema));
|
|
5669
7195
|
});
|
|
@@ -5706,14 +7232,14 @@ var MdEditor = /** @class */ (function (_super) {
|
|
|
5706
7232
|
};
|
|
5707
7233
|
MdEditor.prototype.setMarkdown = function (markdown, cursorToEnd) {
|
|
5708
7234
|
if (cursorToEnd === void 0) { cursorToEnd = true; }
|
|
5709
|
-
var lineTexts = markdown.split(
|
|
7235
|
+
var lineTexts = markdown.split(reLineEnding);
|
|
5710
7236
|
var _a = this.view.state, tr = _a.tr, doc = _a.doc, schema = _a.schema;
|
|
5711
7237
|
var nodes = lineTexts.map(function (lineText) {
|
|
5712
7238
|
return createParagraph(schema, createNodesWithWidget(lineText, schema));
|
|
5713
7239
|
});
|
|
5714
7240
|
this.view.dispatch(tr.replaceWith(0, doc.content.size, nodes));
|
|
5715
7241
|
if (cursorToEnd) {
|
|
5716
|
-
this.moveCursorToEnd();
|
|
7242
|
+
this.moveCursorToEnd(true);
|
|
5717
7243
|
}
|
|
5718
7244
|
};
|
|
5719
7245
|
MdEditor.prototype.addWidget = function (node, style, mdPos) {
|
|
@@ -5800,10 +7326,16 @@ var esm_assign = function () {
|
|
|
5800
7326
|
};
|
|
5801
7327
|
return esm_assign.apply(this, arguments);
|
|
5802
7328
|
};
|
|
5803
|
-
function esm_spreadArray(to, from) {
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
7329
|
+
function esm_spreadArray(to, from, pack) {
|
|
7330
|
+
if (pack || arguments.length === 2)
|
|
7331
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
7332
|
+
if (ar || !(i in from)) {
|
|
7333
|
+
if (!ar)
|
|
7334
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
7335
|
+
ar[i] = from[i];
|
|
7336
|
+
}
|
|
7337
|
+
}
|
|
7338
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
5807
7339
|
}
|
|
5808
7340
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof self !== 'undefined' ? self : {};
|
|
5809
7341
|
var encodeCache = {};
|
|
@@ -6360,7 +7892,7 @@ var egrave$1 = "è";
|
|
|
6360
7892
|
var egs = "⪖";
|
|
6361
7893
|
var egsdot = "⪘";
|
|
6362
7894
|
var el = "⪙";
|
|
6363
|
-
var
|
|
7895
|
+
var esm_Element = "∈";
|
|
6364
7896
|
var elinters = "⏧";
|
|
6365
7897
|
var ell = "ℓ";
|
|
6366
7898
|
var els = "⪕";
|
|
@@ -8484,7 +10016,7 @@ var require$$1$1 = {
|
|
|
8484
10016
|
egs: egs,
|
|
8485
10017
|
egsdot: egsdot,
|
|
8486
10018
|
el: el,
|
|
8487
|
-
Element:
|
|
10019
|
+
Element: esm_Element,
|
|
8488
10020
|
elinters: elinters,
|
|
8489
10021
|
ell: ell,
|
|
8490
10022
|
els: els,
|
|
@@ -10576,7 +12108,7 @@ function getInverse(inverse, re) {
|
|
|
10576
12108
|
.replace(reNonASCII, singleCharReplacer);
|
|
10577
12109
|
};
|
|
10578
12110
|
}
|
|
10579
|
-
var
|
|
12111
|
+
var esm_reEscapeChars = new RegExp(xmlReplacer.source + "|" + reNonASCII.source, "g");
|
|
10580
12112
|
/**
|
|
10581
12113
|
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
|
10582
12114
|
* documents using numeric hexadecimal reference (eg. `ü`).
|
|
@@ -10587,7 +12119,7 @@ var reEscapeChars = new RegExp(xmlReplacer.source + "|" + reNonASCII.source, "g"
|
|
|
10587
12119
|
* @param data String to escape.
|
|
10588
12120
|
*/
|
|
10589
12121
|
function esm_escape(data) {
|
|
10590
|
-
return data.replace(
|
|
12122
|
+
return data.replace(esm_reEscapeChars, singleCharReplacer);
|
|
10591
12123
|
}
|
|
10592
12124
|
encode.escape = esm_escape;
|
|
10593
12125
|
/**
|
|
@@ -10604,7 +12136,7 @@ function escapeUTF8(data) {
|
|
|
10604
12136
|
encode.escapeUTF8 = escapeUTF8;
|
|
10605
12137
|
function getASCIIEncoder(obj) {
|
|
10606
12138
|
return function (data) {
|
|
10607
|
-
return data.replace(
|
|
12139
|
+
return data.replace(esm_reEscapeChars, function (c) { return obj[c] || singleCharReplacer(c); });
|
|
10608
12140
|
};
|
|
10609
12141
|
}
|
|
10610
12142
|
(function (exports) {
|
|
@@ -13856,7 +15388,7 @@ function isUnlinked(id) {
|
|
|
13856
15388
|
}
|
|
13857
15389
|
return false;
|
|
13858
15390
|
}
|
|
13859
|
-
var
|
|
15391
|
+
var esm_reLineEnding = /\r\n|\n|\r/;
|
|
13860
15392
|
function canBeContinuedListItem(lineText) {
|
|
13861
15393
|
var spaceMatch = lineText.match(/^[ \t]+/);
|
|
13862
15394
|
if (spaceMatch && (spaceMatch[0].length >= 2 || /\t/.test(spaceMatch[0]))) {
|
|
@@ -13888,14 +15420,14 @@ var ToastMark = /** @class */ (function () {
|
|
|
13888
15420
|
this.parser.setRefMaps(this.refMap, this.refLinkCandidateMap, this.refDefCandidateMap);
|
|
13889
15421
|
this.eventHandlerMap = { change: [] };
|
|
13890
15422
|
contents = contents || '';
|
|
13891
|
-
this.lineTexts = contents.split(
|
|
15423
|
+
this.lineTexts = contents.split(esm_reLineEnding);
|
|
13892
15424
|
this.root = this.parser.parse(contents, this.lineTexts);
|
|
13893
15425
|
}
|
|
13894
15426
|
ToastMark.prototype.updateLineTexts = function (startPos, endPos, newText) {
|
|
13895
15427
|
var _a;
|
|
13896
15428
|
var startLine = startPos[0], startCol = startPos[1];
|
|
13897
15429
|
var endLine = endPos[0], endCol = endPos[1];
|
|
13898
|
-
var newLines = newText.split(
|
|
15430
|
+
var newLines = newText.split(esm_reLineEnding);
|
|
13899
15431
|
var newLineLen = newLines.length;
|
|
13900
15432
|
var startLineText = this.lineTexts[startLine - 1];
|
|
13901
15433
|
var endLineText = this.lineTexts[endLine - 1];
|
|
@@ -14189,6 +15721,7 @@ function filterDisallowedTags(str) {
|
|
|
14189
15721
|
}
|
|
14190
15722
|
return str;
|
|
14191
15723
|
}
|
|
15724
|
+
var CUSTOM_SYNTAX_LENGTH = 4;
|
|
14192
15725
|
var baseConvertors = {
|
|
14193
15726
|
heading: function (node, _a) {
|
|
14194
15727
|
var entering = _a.entering;
|
|
@@ -14356,7 +15889,7 @@ var baseConvertors = {
|
|
|
14356
15889
|
return customConvertor(node, context);
|
|
14357
15890
|
}
|
|
14358
15891
|
catch (e) {
|
|
14359
|
-
console.warn(e);
|
|
15892
|
+
console.warn("[@toast-ui/editor] - The error occurred when " + info + " block node was parsed in markdown renderer: " + e);
|
|
14360
15893
|
}
|
|
14361
15894
|
}
|
|
14362
15895
|
return [
|
|
@@ -14379,15 +15912,30 @@ var baseConvertors = {
|
|
|
14379
15912
|
];
|
|
14380
15913
|
},
|
|
14381
15914
|
customInline: function (node, context, convertors) {
|
|
14382
|
-
var
|
|
14383
|
-
var
|
|
15915
|
+
var _a = node, sourcepos = _a.sourcepos, info = _a.info;
|
|
15916
|
+
var nomalizedInfo = info.trim().toLowerCase();
|
|
15917
|
+
var customConvertor = convertors[nomalizedInfo];
|
|
15918
|
+
var entering = context.entering;
|
|
14384
15919
|
if (customConvertor) {
|
|
14385
|
-
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
15920
|
+
try {
|
|
15921
|
+
return customConvertor(node, context);
|
|
15922
|
+
}
|
|
15923
|
+
catch (e) {
|
|
15924
|
+
console.warn("[@toast-ui/editor] - The error occurred when " + nomalizedInfo + " inline node was parsed in markdown renderer: " + e);
|
|
15925
|
+
}
|
|
15926
|
+
}
|
|
15927
|
+
var text = sourcepos[1][1] - sourcepos[0][1] + 1 === info.length + CUSTOM_SYNTAX_LENGTH
|
|
15928
|
+
? ''
|
|
15929
|
+
: info + " ";
|
|
15930
|
+
return entering
|
|
15931
|
+
? [
|
|
15932
|
+
{ type: 'openTag', tagName: 'span' },
|
|
15933
|
+
{ type: 'text', content: "$$" + text },
|
|
15934
|
+
]
|
|
15935
|
+
: [
|
|
15936
|
+
{ type: 'text', content: '$$' },
|
|
15937
|
+
{ type: 'closeTag', tagName: 'span' },
|
|
15938
|
+
];
|
|
14391
15939
|
},
|
|
14392
15940
|
};
|
|
14393
15941
|
var gfmConvertors = {
|
|
@@ -14550,8 +16098,8 @@ var Renderer = /** @class */ (function () {
|
|
|
14550
16098
|
? nodeType.toLowerCase()
|
|
14551
16099
|
: nodeType;
|
|
14552
16100
|
if (orgConvertor) {
|
|
14553
|
-
convertors[convertorType] = function (node, context) {
|
|
14554
|
-
context.origin = function () { return orgConvertor(node, context); };
|
|
16101
|
+
convertors[convertorType] = function (node, context, convertors) {
|
|
16102
|
+
context.origin = function () { return orgConvertor(node, context, convertors); };
|
|
14555
16103
|
return convertor(node, context);
|
|
14556
16104
|
};
|
|
14557
16105
|
}
|
|
@@ -14697,107 +16245,35 @@ var Renderer = /** @class */ (function () {
|
|
|
14697
16245
|
}());
|
|
14698
16246
|
|
|
14699
16247
|
|
|
16248
|
+
// EXTERNAL MODULE: ../../node_modules/dompurify/dist/purify.js
|
|
16249
|
+
var purify = __webpack_require__(368);
|
|
16250
|
+
var purify_default = /*#__PURE__*/__webpack_require__.n(purify);
|
|
14700
16251
|
;// CONCATENATED MODULE: ./src/sanitizer/htmlSanitizer.ts
|
|
14701
16252
|
|
|
14702
16253
|
|
|
14703
16254
|
|
|
14704
|
-
|
|
14705
|
-
|
|
14706
|
-
var reXSSHtmlAttr = new RegExp('^(abbr|align|alt|axis|bgcolor|border|cellpadding|cellspacing|class|clear|' +
|
|
14707
|
-
'color|cols|compact|coords|dir|face|headers|height|hreflang|hspace|' +
|
|
14708
|
-
'ismap|lang|language|nohref|nowrap|rel|rev|rows|rules|' +
|
|
14709
|
-
'scope|scrolling|shape|size|span|start|summary|tabindex|target|title|type|' +
|
|
14710
|
-
'valign|value|vspace|width|checked|mathvariant|encoding|id|name|' +
|
|
14711
|
-
'background|cite|href|longdesc|src|usemap|xlink:href|data-+|checked|style)', 'g');
|
|
14712
|
-
var reXSSSvgAttr = new RegExp('^(accent-height|accumulate|additive|alphabetic|arabic-form|ascent|' +
|
|
14713
|
-
'baseProfile|bbox|begin|by|calcMode|cap-height|class|color|color-rendering|content|' +
|
|
14714
|
-
'cx|cy|d|dx|dy|descent|display|dur|end|fill|fill-rule|font-family|font-size|font-stretch|' +
|
|
14715
|
-
'font-style|font-variant|font-weight|from|fx|fy|g1|g2|glyph-name|gradientUnits|hanging|' +
|
|
14716
|
-
'height|horiz-adv-x|horiz-origin-x|ideographic|k|keyPoints|keySplines|keyTimes|lang|' +
|
|
14717
|
-
'marker-end|marker-mid|marker-start|markerHeight|markerUnits|markerWidth|mathematical|' +
|
|
14718
|
-
'max|min|offset|opacity|orient|origin|overline-position|overline-thickness|panose-1|' +
|
|
14719
|
-
'path|pathLength|points|preserveAspectRatio|r|refX|refY|repeatCount|repeatDur|' +
|
|
14720
|
-
'requiredExtensions|requiredFeatures|restart|rotate|rx|ry|slope|stemh|stemv|stop-color|' +
|
|
14721
|
-
'stop-opacity|strikethrough-position|strikethrough-thickness|stroke|stroke-dasharray|' +
|
|
14722
|
-
'stroke-dashoffset|stroke-linecap|stroke-linejoin|stroke-miterlimit|stroke-opacity|' +
|
|
14723
|
-
'stroke-width|systemLanguage|target|text-anchor|to|transform|type|u1|u2|underline-position|' +
|
|
14724
|
-
'underline-thickness|unicode|unicode-range|units-per-em|values|version|viewBox|visibility|' +
|
|
14725
|
-
'width|widths|x|x-height|x1|x2|xlink:actuate|xlink:arcrole|xlink:role|xlink:show|xlink:title|' +
|
|
14726
|
-
'xlink:type|xml:base|xml:lang|xml:space|xmlns|xmlns:xlink|y|y1|y2|zoomAndPan)', 'g');
|
|
14727
|
-
var reXSSAttr = /href|src|background/i;
|
|
14728
|
-
var reXSSAttrValue = /((java|vb|live)script|x):/i;
|
|
14729
|
-
var reOnEvent = /^on\S+/i;
|
|
14730
|
-
var reComment = /<!--[\s\S]*?-->/g;
|
|
14731
|
-
var DEFAULT_TAG_BLACK_LIST = [
|
|
14732
|
-
'script',
|
|
14733
|
-
'iframe',
|
|
14734
|
-
'textarea',
|
|
14735
|
-
'form',
|
|
14736
|
-
'button',
|
|
14737
|
-
'select',
|
|
14738
|
-
'input',
|
|
14739
|
-
'meta',
|
|
14740
|
-
'style',
|
|
14741
|
-
'link',
|
|
14742
|
-
'title',
|
|
14743
|
-
'embed',
|
|
14744
|
-
'object',
|
|
14745
|
-
'details',
|
|
14746
|
-
'summary',
|
|
14747
|
-
];
|
|
14748
|
-
var CAN_BE_TAG_WHITE_LIST = ['iframe', 'embed', 'details', 'summary'];
|
|
14749
|
-
var tagBlacklist = __spreadArray([], DEFAULT_TAG_BLACK_LIST);
|
|
16255
|
+
var CAN_BE_WHITE_TAG_LIST = ['iframe', 'embed'];
|
|
16256
|
+
var whiteTagList = [];
|
|
14750
16257
|
function registerTagWhitelistIfPossible(tagName) {
|
|
14751
|
-
if (common_includes(
|
|
14752
|
-
|
|
14753
|
-
}
|
|
14754
|
-
}
|
|
14755
|
-
function sanitizeHTML(html) {
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
}
|
|
14771
|
-
function isXSSAttribute(attrName, attrValue) {
|
|
14772
|
-
return attrName.match(reXSSAttr) && attrValue.match(reXSSAttrValue);
|
|
14773
|
-
}
|
|
14774
|
-
function removeBlacklistAttributes(node, blacklistAttrs) {
|
|
14775
|
-
blacklistAttrs.forEach(function (_a) {
|
|
14776
|
-
var name = _a.name;
|
|
14777
|
-
if (reOnEvent.test(name)) {
|
|
14778
|
-
node[name] = null;
|
|
14779
|
-
}
|
|
14780
|
-
if (node.getAttribute(name)) {
|
|
14781
|
-
node.removeAttribute(name);
|
|
14782
|
-
}
|
|
14783
|
-
});
|
|
14784
|
-
}
|
|
14785
|
-
function leaveOnlyWhitelistAttribute(html) {
|
|
14786
|
-
findNodes(html, '*').forEach(function (node) {
|
|
14787
|
-
var attributes = node.attributes;
|
|
14788
|
-
var blacklist = toArray_default()(attributes).filter(function (attr) {
|
|
14789
|
-
var name = attr.name, value = attr.value;
|
|
14790
|
-
var htmlAttr = name.match(reXSSHtmlAttr);
|
|
14791
|
-
var svgAttr = name.match(reXSSSvgAttr);
|
|
14792
|
-
var xssAttr = htmlAttr && isXSSAttribute(name, value);
|
|
14793
|
-
return (!htmlAttr && !svgAttr) || xssAttr;
|
|
14794
|
-
});
|
|
14795
|
-
removeBlacklistAttributes(node, blacklist);
|
|
14796
|
-
});
|
|
14797
|
-
}
|
|
14798
|
-
function sanitizeXSSAttributeValue(attrValue) {
|
|
14799
|
-
attrValue = attrValue.replace(reComment, '');
|
|
14800
|
-
return reXSSAttrValue.test(attrValue) ? '' : attrValue;
|
|
16258
|
+
if (common_includes(CAN_BE_WHITE_TAG_LIST, tagName)) {
|
|
16259
|
+
whiteTagList.push(tagName.toLowerCase());
|
|
16260
|
+
}
|
|
16261
|
+
}
|
|
16262
|
+
function sanitizeHTML(html, options) {
|
|
16263
|
+
return purify_default().sanitize(html, __assign({ ADD_TAGS: whiteTagList, ADD_ATTR: ['rel', 'target', 'hreflang', 'type'], FORBID_TAGS: [
|
|
16264
|
+
'input',
|
|
16265
|
+
'script',
|
|
16266
|
+
'textarea',
|
|
16267
|
+
'form',
|
|
16268
|
+
'button',
|
|
16269
|
+
'select',
|
|
16270
|
+
'meta',
|
|
16271
|
+
'style',
|
|
16272
|
+
'link',
|
|
16273
|
+
'title',
|
|
16274
|
+
'object',
|
|
16275
|
+
'base',
|
|
16276
|
+
] }, options));
|
|
14801
16277
|
}
|
|
14802
16278
|
|
|
14803
16279
|
;// CONCATENATED MODULE: ./src/wysiwyg/nodes/html.ts
|
|
@@ -17175,6 +18651,7 @@ function convertMsoParagraphsToList(html) {
|
|
|
17175
18651
|
|
|
17176
18652
|
|
|
17177
18653
|
|
|
18654
|
+
|
|
17178
18655
|
var START_FRAGMENT_COMMENT = '<!--StartFragment-->';
|
|
17179
18656
|
var END_FRAGMENT_COMMENT = '<!--EndFragment-->';
|
|
17180
18657
|
function getContentBetweenFragmentComments(html) {
|
|
@@ -17183,7 +18660,7 @@ function getContentBetweenFragmentComments(html) {
|
|
|
17183
18660
|
if (startFragmentIndex > -1 && endFragmentIndex > -1) {
|
|
17184
18661
|
html = html.slice(startFragmentIndex + START_FRAGMENT_COMMENT.length, endFragmentIndex);
|
|
17185
18662
|
}
|
|
17186
|
-
return html;
|
|
18663
|
+
return html.replace(/<br[^>]*>/g, ALTERNATIVE_TAG_FOR_BR);
|
|
17187
18664
|
}
|
|
17188
18665
|
function convertMsoTableToCompletedTable(html) {
|
|
17189
18666
|
// wrap with <tr> if html contains dangling <td> tags
|
|
@@ -17271,9 +18748,9 @@ function paste_createTableBody(tableBodyRows, maxColumnCount, schema) {
|
|
|
17271
18748
|
}
|
|
17272
18749
|
return schema.nodes.tableBody.create(null, copiedRows);
|
|
17273
18750
|
}
|
|
17274
|
-
function createTableFromPastingTable(rows, schema, startFromBody) {
|
|
18751
|
+
function createTableFromPastingTable(rows, schema, startFromBody, isInTable) {
|
|
17275
18752
|
var columnCount = getMaxColumnCount(rows);
|
|
17276
|
-
if (startFromBody) {
|
|
18753
|
+
if (startFromBody && isInTable) {
|
|
17277
18754
|
return schema.nodes.table.create(null, [paste_createTableBody(rows, columnCount, schema)]);
|
|
17278
18755
|
}
|
|
17279
18756
|
var tableHeadRow = rows[0];
|
|
@@ -17284,15 +18761,16 @@ function createTableFromPastingTable(rows, schema, startFromBody) {
|
|
|
17284
18761
|
}
|
|
17285
18762
|
return schema.nodes.table.create(null, nodes);
|
|
17286
18763
|
}
|
|
17287
|
-
function changePastedSlice(slice, schema) {
|
|
18764
|
+
function changePastedSlice(slice, schema, isInTable) {
|
|
17288
18765
|
var nodes = [];
|
|
17289
|
-
slice.content.
|
|
18766
|
+
var content = slice.content, openStart = slice.openStart, openEnd = slice.openEnd;
|
|
18767
|
+
content.forEach(function (node) {
|
|
17290
18768
|
if (node.type.name === 'table') {
|
|
17291
18769
|
var tableContent = getTableContentFromSlice(new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(node), 0, 0));
|
|
17292
18770
|
if (tableContent) {
|
|
17293
18771
|
var rows = createRowsFromPastingTable(tableContent);
|
|
17294
18772
|
var startFromBody = tableContent.firstChild.type.name === 'tableBody';
|
|
17295
|
-
var table = createTableFromPastingTable(rows, schema, startFromBody);
|
|
18773
|
+
var table = createTableFromPastingTable(rows, schema, startFromBody, isInTable);
|
|
17296
18774
|
nodes.push(table);
|
|
17297
18775
|
}
|
|
17298
18776
|
}
|
|
@@ -17300,7 +18778,7 @@ function changePastedSlice(slice, schema) {
|
|
|
17300
18778
|
nodes.push(node);
|
|
17301
18779
|
}
|
|
17302
18780
|
});
|
|
17303
|
-
return new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(nodes),
|
|
18781
|
+
return new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(nodes), openStart, openEnd);
|
|
17304
18782
|
}
|
|
17305
18783
|
|
|
17306
18784
|
;// CONCATENATED MODULE: ./src/wysiwyg/clipboard/pasteToTable.ts
|
|
@@ -17528,7 +19006,7 @@ var paragraph_Paragraph = /** @class */ (function (_super) {
|
|
|
17528
19006
|
get: function () {
|
|
17529
19007
|
return {
|
|
17530
19008
|
content: 'inline*',
|
|
17531
|
-
group: 'block
|
|
19009
|
+
group: 'block',
|
|
17532
19010
|
attrs: __assign({}, getDefaultCustomAttrs()),
|
|
17533
19011
|
parseDOM: [{ tag: 'p' }],
|
|
17534
19012
|
toDOM: function (_a) {
|
|
@@ -17783,7 +19261,7 @@ var BulletList = /** @class */ (function (_super) {
|
|
|
17783
19261
|
get: function () {
|
|
17784
19262
|
return {
|
|
17785
19263
|
content: 'listItem+',
|
|
17786
|
-
group: 'block
|
|
19264
|
+
group: 'block',
|
|
17787
19265
|
attrs: __assign({ rawHTML: { default: null } }, getDefaultCustomAttrs()),
|
|
17788
19266
|
parseDOM: [createDOMInfoParsedRawHTML('ul')],
|
|
17789
19267
|
toDOM: function (_a) {
|
|
@@ -17840,7 +19318,7 @@ var OrderedList = /** @class */ (function (_super) {
|
|
|
17840
19318
|
get: function () {
|
|
17841
19319
|
return {
|
|
17842
19320
|
content: 'listItem+',
|
|
17843
|
-
group: 'block
|
|
19321
|
+
group: 'block',
|
|
17844
19322
|
attrs: __assign({ order: { default: 1 }, rawHTML: { default: null } }, getDefaultCustomAttrs()),
|
|
17845
19323
|
parseDOM: [
|
|
17846
19324
|
{
|
|
@@ -17901,7 +19379,8 @@ var listItem_ListItem = /** @class */ (function (_super) {
|
|
|
17901
19379
|
Object.defineProperty(ListItem.prototype, "schema", {
|
|
17902
19380
|
get: function () {
|
|
17903
19381
|
return {
|
|
17904
|
-
content: 'paragraph
|
|
19382
|
+
content: 'paragraph block*',
|
|
19383
|
+
selectable: false,
|
|
17905
19384
|
attrs: {
|
|
17906
19385
|
task: { default: false },
|
|
17907
19386
|
checked: { default: false },
|
|
@@ -18809,9 +20288,13 @@ var Image = /** @class */ (function (_super) {
|
|
|
18809
20288
|
{
|
|
18810
20289
|
tag: 'img[src]',
|
|
18811
20290
|
getAttrs: function (dom) {
|
|
18812
|
-
var
|
|
18813
|
-
|
|
18814
|
-
|
|
20291
|
+
var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
|
|
20292
|
+
.firstChild;
|
|
20293
|
+
var imageUrl = sanitizedDOM.getAttribute('src') || '';
|
|
20294
|
+
var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
|
|
20295
|
+
var altText = sanitizedDOM.getAttribute('alt');
|
|
20296
|
+
return __assign({ imageUrl: imageUrl,
|
|
20297
|
+
altText: altText }, (rawHTML && { rawHTML: rawHTML }));
|
|
18815
20298
|
},
|
|
18816
20299
|
},
|
|
18817
20300
|
],
|
|
@@ -19117,9 +20600,11 @@ var link_Link = /** @class */ (function (_super) {
|
|
|
19117
20600
|
{
|
|
19118
20601
|
tag: 'a[href]',
|
|
19119
20602
|
getAttrs: function (dom) {
|
|
19120
|
-
var
|
|
19121
|
-
|
|
19122
|
-
|
|
20603
|
+
var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
|
|
20604
|
+
.firstChild;
|
|
20605
|
+
var href = sanitizedDOM.getAttribute('href') || '';
|
|
20606
|
+
var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
|
|
20607
|
+
return __assign({ linkUrl: href, linkText: sanitizedDOM.textContent }, (rawHTML && { rawHTML: rawHTML }));
|
|
19123
20608
|
},
|
|
19124
20609
|
},
|
|
19125
20610
|
],
|
|
@@ -19406,6 +20891,7 @@ function createSpecs(linkAttributes) {
|
|
|
19406
20891
|
|
|
19407
20892
|
|
|
19408
20893
|
|
|
20894
|
+
|
|
19409
20895
|
|
|
19410
20896
|
|
|
19411
20897
|
var CONTENTS_CLASS_NAME = cls('contents');
|
|
@@ -19489,7 +20975,9 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19489
20975
|
_this.eventEmitter.emit('setFocusedNode', state.selection.$from.node(1));
|
|
19490
20976
|
},
|
|
19491
20977
|
transformPastedHTML: changePastedHTML,
|
|
19492
|
-
transformPasted: function (slice) {
|
|
20978
|
+
transformPasted: function (slice) {
|
|
20979
|
+
return changePastedSlice(slice, _this.schema, isInTableNode(_this.view.state.selection.$from));
|
|
20980
|
+
},
|
|
19493
20981
|
handlePaste: function (view, _, slice) { return pasteToTable(view, slice); },
|
|
19494
20982
|
handleKeyDown: function (_, ev) {
|
|
19495
20983
|
_this.eventEmitter.emit('keydown', _this.editorType, ev);
|
|
@@ -19498,8 +20986,8 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19498
20986
|
handleDOMEvents: {
|
|
19499
20987
|
paste: function (_, ev) {
|
|
19500
20988
|
var clipboardData = ev.clipboardData || window.clipboardData;
|
|
19501
|
-
var items = clipboardData
|
|
19502
|
-
if (items) {
|
|
20989
|
+
var items = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.items;
|
|
20990
|
+
if ((items === null || items === void 0 ? void 0 : items.length) === 1) {
|
|
19503
20991
|
var imageBlob = pasteImageOnly(items);
|
|
19504
20992
|
if (imageBlob) {
|
|
19505
20993
|
ev.preventDefault();
|
|
@@ -19567,7 +21055,7 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19567
21055
|
var _a = this.view.state, tr = _a.tr, doc = _a.doc;
|
|
19568
21056
|
this.view.dispatch(tr.replaceWith(0, doc.content.size, newDoc));
|
|
19569
21057
|
if (cursorToEnd) {
|
|
19570
|
-
this.moveCursorToEnd();
|
|
21058
|
+
this.moveCursorToEnd(true);
|
|
19571
21059
|
}
|
|
19572
21060
|
};
|
|
19573
21061
|
WysiwygEditor.prototype.setSelection = function (start, end) {
|
|
@@ -19906,6 +21394,9 @@ function htmlToWwConvertors_isInlineNode(_a) {
|
|
|
19906
21394
|
var type = _a.type;
|
|
19907
21395
|
return common_includes(['text', 'strong', 'emph', 'strike', 'image', 'link', 'code'], type);
|
|
19908
21396
|
}
|
|
21397
|
+
function isSoftbreak(mdNode) {
|
|
21398
|
+
return (mdNode === null || mdNode === void 0 ? void 0 : mdNode.type) === 'softbreak';
|
|
21399
|
+
}
|
|
19909
21400
|
function htmlToWwConvertors_isListNode(_a) {
|
|
19910
21401
|
var type = _a.type, literal = _a.literal;
|
|
19911
21402
|
var matched = type === 'htmlInline' && literal.match(reHTMLTag);
|
|
@@ -19924,11 +21415,15 @@ function getListItemAttrs(_a) {
|
|
|
19924
21415
|
var checked = /data-task-checked/.test(literal);
|
|
19925
21416
|
return { task: task, checked: checked };
|
|
19926
21417
|
}
|
|
19927
|
-
function getMatchedAttributeValue(rawHTML
|
|
21418
|
+
function getMatchedAttributeValue(rawHTML) {
|
|
21419
|
+
var attrNames = [];
|
|
21420
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
21421
|
+
attrNames[_i - 1] = arguments[_i];
|
|
21422
|
+
}
|
|
19928
21423
|
var wrapper = document.createElement('div');
|
|
19929
|
-
wrapper.innerHTML = rawHTML;
|
|
21424
|
+
wrapper.innerHTML = sanitizeHTML(rawHTML);
|
|
19930
21425
|
var el = wrapper.firstChild;
|
|
19931
|
-
return el.getAttribute(attrName) || '';
|
|
21426
|
+
return attrNames.map(function (attrName) { return el.getAttribute(attrName) || ''; });
|
|
19932
21427
|
}
|
|
19933
21428
|
function createConvertors(convertors) {
|
|
19934
21429
|
var convertorMap = {};
|
|
@@ -19982,9 +21477,9 @@ var convertors = {
|
|
|
19982
21477
|
var tag = node.literal;
|
|
19983
21478
|
var link = state.schema.marks.link;
|
|
19984
21479
|
if (openTagName) {
|
|
19985
|
-
var linkUrl = getMatchedAttributeValue(tag, 'href');
|
|
21480
|
+
var linkUrl = getMatchedAttributeValue(tag, 'href')[0];
|
|
19986
21481
|
state.openMark(link.create({
|
|
19987
|
-
linkUrl:
|
|
21482
|
+
linkUrl: linkUrl,
|
|
19988
21483
|
rawHTML: openTagName,
|
|
19989
21484
|
}));
|
|
19990
21485
|
}
|
|
@@ -19994,32 +21489,42 @@ var convertors = {
|
|
|
19994
21489
|
},
|
|
19995
21490
|
img: function (state, node, openTagName) {
|
|
19996
21491
|
var tag = node.literal;
|
|
19997
|
-
|
|
19998
|
-
|
|
19999
|
-
var altText = getMatchedAttributeValue(tag, 'alt');
|
|
21492
|
+
if (openTagName) {
|
|
21493
|
+
var _a = getMatchedAttributeValue(tag, 'src', 'alt'), imageUrl = _a[0], altText = _a[1];
|
|
20000
21494
|
var image = state.schema.nodes.image;
|
|
20001
|
-
state.addNode(image, __assign({ rawHTML: openTagName, imageUrl:
|
|
21495
|
+
state.addNode(image, __assign({ rawHTML: openTagName, imageUrl: imageUrl }, (altText && { altText: altText })));
|
|
20002
21496
|
}
|
|
20003
21497
|
},
|
|
20004
21498
|
hr: function (state, _, openTagName) {
|
|
20005
21499
|
state.addNode(state.schema.nodes.thematicBreak, { rawHTML: openTagName });
|
|
20006
21500
|
},
|
|
20007
21501
|
br: function (state, node) {
|
|
20008
|
-
var _a, _b;
|
|
20009
21502
|
var paragraph = state.schema.nodes.paragraph;
|
|
20010
|
-
|
|
20011
|
-
|
|
21503
|
+
var parent = node.parent, prev = node.prev, next = node.next;
|
|
21504
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'paragraph') {
|
|
21505
|
+
// should open a paragraph node when line text has only <br> tag
|
|
21506
|
+
// ex) first line\n\n<br>\nfourth line
|
|
21507
|
+
if (isSoftbreak(prev)) {
|
|
20012
21508
|
state.openNode(paragraph);
|
|
20013
21509
|
}
|
|
20014
|
-
|
|
21510
|
+
// should close a paragraph node when line text has only <br> tag
|
|
21511
|
+
// ex) first line\n\n<br>\nfourth line
|
|
21512
|
+
if (isSoftbreak(next)) {
|
|
21513
|
+
state.closeNode();
|
|
21514
|
+
// should close a paragraph node and open a paragraph node to separate between blocks
|
|
21515
|
+
// when <br> tag is in the middle of the paragraph
|
|
21516
|
+
// ex) first <br>line\nthird line
|
|
21517
|
+
}
|
|
21518
|
+
else if (next) {
|
|
20015
21519
|
state.closeNode();
|
|
21520
|
+
state.openNode(paragraph);
|
|
20016
21521
|
}
|
|
20017
21522
|
}
|
|
20018
|
-
else if ((
|
|
20019
|
-
if (
|
|
21523
|
+
else if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'tableCell') {
|
|
21524
|
+
if (prev && (htmlToWwConvertors_isInlineNode(prev) || isCustomHTMLInlineNode(state, prev))) {
|
|
20020
21525
|
state.closeNode();
|
|
20021
21526
|
}
|
|
20022
|
-
if (
|
|
21527
|
+
if (next && (htmlToWwConvertors_isInlineNode(next) || isCustomHTMLInlineNode(state, next))) {
|
|
20023
21528
|
state.openNode(paragraph);
|
|
20024
21529
|
}
|
|
20025
21530
|
}
|
|
@@ -20088,8 +21593,9 @@ var htmlToWwConvertors = createConvertors(convertors);
|
|
|
20088
21593
|
|
|
20089
21594
|
|
|
20090
21595
|
|
|
21596
|
+
|
|
20091
21597
|
function isBRTag(node) {
|
|
20092
|
-
return node.type === 'htmlInline' &&
|
|
21598
|
+
return node.type === 'htmlInline' && reBR.test(node.literal);
|
|
20093
21599
|
}
|
|
20094
21600
|
function addRawHTMLAttributeToDOM(parent) {
|
|
20095
21601
|
toArray_default()(parent.childNodes).forEach(function (child) {
|
|
@@ -20337,10 +21843,11 @@ var toWwConvertors = {
|
|
|
20337
21843
|
var openTagName = matched[1], closeTagName = matched[3];
|
|
20338
21844
|
var typeName = (openTagName || closeTagName).toLowerCase();
|
|
20339
21845
|
var markType = state.schema.marks[typeName];
|
|
21846
|
+
var sanitizedHTML = sanitizeHTML(html);
|
|
20340
21847
|
// for user defined html schema
|
|
20341
21848
|
if (markType === null || markType === void 0 ? void 0 : markType.spec.attrs.htmlInline) {
|
|
20342
21849
|
if (openTagName) {
|
|
20343
|
-
var htmlAttrs = getHTMLAttrsByHTMLString(
|
|
21850
|
+
var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
|
|
20344
21851
|
state.openMark(markType.create({ htmlAttrs: htmlAttrs }));
|
|
20345
21852
|
}
|
|
20346
21853
|
else {
|
|
@@ -20361,14 +21868,15 @@ var toWwConvertors = {
|
|
|
20361
21868
|
var openTagName = matched[1], closeTagName = matched[3];
|
|
20362
21869
|
var typeName = (openTagName || closeTagName).toLowerCase();
|
|
20363
21870
|
var nodeType = state.schema.nodes[typeName];
|
|
21871
|
+
var sanitizedHTML = sanitizeHTML(html);
|
|
20364
21872
|
// for user defined html schema
|
|
20365
21873
|
if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
|
|
20366
|
-
var htmlAttrs = getHTMLAttrsByHTMLString(
|
|
21874
|
+
var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
|
|
20367
21875
|
var childrenHTML = getChildrenHTML(node, typeName);
|
|
20368
21876
|
state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
|
|
20369
21877
|
}
|
|
20370
21878
|
else {
|
|
20371
|
-
container.innerHTML =
|
|
21879
|
+
container.innerHTML = sanitizedHTML;
|
|
20372
21880
|
addRawHTMLAttributeToDOM(container);
|
|
20373
21881
|
state.convertByDOMParser(container);
|
|
20374
21882
|
}
|
|
@@ -20483,6 +21991,27 @@ var ToWwConvertorState = /** @class */ (function () {
|
|
|
20483
21991
|
var doc = external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.DOMParser.fromSchema(this.schema).parse(root);
|
|
20484
21992
|
doc.content.forEach(function (node) { return _this.push(node); });
|
|
20485
21993
|
};
|
|
21994
|
+
ToWwConvertorState.prototype.closeUnmatchedHTMLInline = function (node, entering) {
|
|
21995
|
+
var _a;
|
|
21996
|
+
if (!entering && node.type !== 'htmlInline') {
|
|
21997
|
+
var length = this.stack.length - 1;
|
|
21998
|
+
for (var i = length; i >= 0; i -= 1) {
|
|
21999
|
+
var nodeInfo = this.stack[i];
|
|
22000
|
+
if ((_a = nodeInfo.attrs) === null || _a === void 0 ? void 0 : _a.rawHTML) {
|
|
22001
|
+
if (nodeInfo.content.length) {
|
|
22002
|
+
this.closeNode();
|
|
22003
|
+
}
|
|
22004
|
+
else {
|
|
22005
|
+
// just pop useless unmatched html inline node
|
|
22006
|
+
this.stack.pop();
|
|
22007
|
+
}
|
|
22008
|
+
}
|
|
22009
|
+
else {
|
|
22010
|
+
break;
|
|
22011
|
+
}
|
|
22012
|
+
}
|
|
22013
|
+
}
|
|
22014
|
+
};
|
|
20486
22015
|
ToWwConvertorState.prototype.convert = function (mdNode, infoForPosSync) {
|
|
20487
22016
|
var walker = mdNode.walker();
|
|
20488
22017
|
var event = walker.next();
|
|
@@ -20500,6 +22029,7 @@ var ToWwConvertorState = /** @class */ (function () {
|
|
|
20500
22029
|
skipped = true;
|
|
20501
22030
|
},
|
|
20502
22031
|
};
|
|
22032
|
+
this_1.closeUnmatchedHTMLInline(node, entering);
|
|
20503
22033
|
convertor(this_1, node, context);
|
|
20504
22034
|
if ((infoForPosSync === null || infoForPosSync === void 0 ? void 0 : infoForPosSync.node) === node) {
|
|
20505
22035
|
var pos = this_1.stack.reduce(function (nodeSize, stackItem) {
|
|
@@ -21192,11 +22722,11 @@ var ToMdConvertorState = /** @class */ (function () {
|
|
|
21192
22722
|
this.closed = node;
|
|
21193
22723
|
};
|
|
21194
22724
|
ToMdConvertorState.prototype.text = function (text, escaped) {
|
|
22725
|
+
if (escaped === void 0) { escaped = true; }
|
|
21195
22726
|
var lines = text.split('\n');
|
|
21196
22727
|
for (var i = 0; i < lines.length; i += 1) {
|
|
21197
|
-
var startOfLine = this.isInBlank() || !!this.closed;
|
|
21198
22728
|
this.write();
|
|
21199
|
-
this.result += escaped
|
|
22729
|
+
this.result += escaped ? common_escape(lines[i]) : lines[i];
|
|
21200
22730
|
if (i !== lines.length - 1) {
|
|
21201
22731
|
this.result += '\n';
|
|
21202
22732
|
}
|
|
@@ -21505,6 +23035,14 @@ function getPluginInfo(plugins, eventEmitter, usageStatistics) {
|
|
|
21505
23035
|
var TASK_ATTR_NAME = 'data-task';
|
|
21506
23036
|
var DISABLED_TASK_ATTR_NAME = 'data-task-disabled';
|
|
21507
23037
|
var TASK_CHECKED_CLASS_NAME = 'checked';
|
|
23038
|
+
function registerHTMLTagToWhitelist(convertorMap) {
|
|
23039
|
+
['htmlBlock', 'htmlInline'].forEach(function (htmlType) {
|
|
23040
|
+
if (convertorMap[htmlType]) {
|
|
23041
|
+
// register tag white list for preventing to remove the html in sanitizer
|
|
23042
|
+
Object.keys(convertorMap[htmlType]).forEach(function (type) { return registerTagWhitelistIfPossible(type); });
|
|
23043
|
+
}
|
|
23044
|
+
});
|
|
23045
|
+
}
|
|
21508
23046
|
/**
|
|
21509
23047
|
* Class ToastUIEditorViewer
|
|
21510
23048
|
* @param {object} options Option object
|
|
@@ -21550,6 +23088,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
|
|
|
21550
23088
|
frontMatter: frontMatter,
|
|
21551
23089
|
sanitizer: customHTMLSanitizer || sanitizeHTML,
|
|
21552
23090
|
};
|
|
23091
|
+
registerHTMLTagToWhitelist(rendererOptions.customHTMLRenderer);
|
|
21553
23092
|
if (this.options.events) {
|
|
21554
23093
|
forEachOwnProperties_default()(this.options.events, function (fn, key) {
|
|
21555
23094
|
_this.on(key, fn);
|
|
@@ -22073,11 +23612,12 @@ var ScrollSync = /** @class */ (function () {
|
|
|
22073
23612
|
* @param {boolean} [options.frontMatter=false] - whether use the front matter
|
|
22074
23613
|
* @param {Array.<object>} [options.widgetRules=[]] - The rules for replacing the text with widget node
|
|
22075
23614
|
* @param {string} [options.theme] - The theme to style the editor with. The default is included in toastui-editor.css.
|
|
23615
|
+
* @param {autofocus} [options.autofocus=true] - automatically focus the editor on creation.
|
|
22076
23616
|
*/
|
|
22077
23617
|
var ToastUIEditorCore = /** @class */ (function () {
|
|
22078
23618
|
function ToastUIEditorCore(options) {
|
|
22079
23619
|
var _this = this;
|
|
22080
|
-
this.
|
|
23620
|
+
this.initialHTML = options.el.innerHTML;
|
|
22081
23621
|
options.el.innerHTML = '';
|
|
22082
23622
|
this.options = extend_default()({
|
|
22083
23623
|
previewStyle: 'tab',
|
|
@@ -22106,10 +23646,13 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22106
23646
|
frontMatter: false,
|
|
22107
23647
|
widgetRules: [],
|
|
22108
23648
|
theme: 'light',
|
|
23649
|
+
autofocus: true,
|
|
22109
23650
|
}, options);
|
|
22110
23651
|
var _a = this.options, customHTMLRenderer = _a.customHTMLRenderer, extendedAutolinks = _a.extendedAutolinks, referenceDefinition = _a.referenceDefinition, frontMatter = _a.frontMatter, customMarkdownRenderer = _a.customMarkdownRenderer, useCommandShortcut = _a.useCommandShortcut, initialEditType = _a.initialEditType, widgetRules = _a.widgetRules, customHTMLSanitizer = _a.customHTMLSanitizer;
|
|
22111
23652
|
this.mode = initialEditType || 'markdown';
|
|
22112
23653
|
this.mdPreviewStyle = this.options.previewStyle;
|
|
23654
|
+
this.i18n = i18n;
|
|
23655
|
+
this.i18n.setCode(this.options.language);
|
|
22113
23656
|
this.eventEmitter = new eventEmitter();
|
|
22114
23657
|
setWidgetRules(widgetRules);
|
|
22115
23658
|
var linkAttributes = sanitizeLinkAttribute(this.options.linkAttributes);
|
|
@@ -22125,8 +23668,6 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22125
23668
|
};
|
|
22126
23669
|
var wwToDOMAdaptor = new WwToDOMAdaptor(linkAttributes, rendererOptions.customHTMLRenderer);
|
|
22127
23670
|
var htmlSchemaMap = createHTMLSchemaMap(rendererOptions.customHTMLRenderer, rendererOptions.sanitizer, wwToDOMAdaptor);
|
|
22128
|
-
this.i18n = i18n;
|
|
22129
|
-
this.i18n.setCode(this.options.language);
|
|
22130
23671
|
this.toastMark = new ToastMark('', {
|
|
22131
23672
|
disallowedHtmlBlockTags: ['br', 'img'],
|
|
22132
23673
|
extendedAutolinks: extendedAutolinks,
|
|
@@ -22157,7 +23698,7 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22157
23698
|
this.setPlaceholder(this.options.placeholder);
|
|
22158
23699
|
}
|
|
22159
23700
|
if (!this.options.initialValue) {
|
|
22160
|
-
this.setHTML(this.
|
|
23701
|
+
this.setHTML(this.initialHTML, false);
|
|
22161
23702
|
}
|
|
22162
23703
|
this.commandManager = new commandManager(this.eventEmitter, this.mdEditor.commands, this.wwEditor.commands, function () { return _this.mode; });
|
|
22163
23704
|
if (this.options.usageStatistics) {
|
|
@@ -22173,7 +23714,7 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22173
23714
|
forEachOwnProperties_default()(this.options.events, function (fn, key) { return _this.on(key, fn); });
|
|
22174
23715
|
}
|
|
22175
23716
|
this.eventEmitter.emit('load', this);
|
|
22176
|
-
this.moveCursorToStart();
|
|
23717
|
+
this.moveCursorToStart(this.options.autofocus);
|
|
22177
23718
|
}
|
|
22178
23719
|
ToastUIEditorCore.prototype.addInitEvent = function () {
|
|
22179
23720
|
this.on('needChangeMode', this.changeMode.bind(this));
|
|
@@ -22289,15 +23830,19 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22289
23830
|
};
|
|
22290
23831
|
/**
|
|
22291
23832
|
* Set cursor position to end
|
|
23833
|
+
* @param {boolean} [focus] - automatically focus the editor
|
|
22292
23834
|
*/
|
|
22293
|
-
ToastUIEditorCore.prototype.moveCursorToEnd = function () {
|
|
22294
|
-
|
|
23835
|
+
ToastUIEditorCore.prototype.moveCursorToEnd = function (focus) {
|
|
23836
|
+
if (focus === void 0) { focus = true; }
|
|
23837
|
+
this.getCurrentModeEditor().moveCursorToEnd(focus);
|
|
22295
23838
|
};
|
|
22296
23839
|
/**
|
|
22297
23840
|
* Set cursor position to start
|
|
23841
|
+
* @param {boolean} [focus] - automatically focus the editor
|
|
22298
23842
|
*/
|
|
22299
|
-
ToastUIEditorCore.prototype.moveCursorToStart = function () {
|
|
22300
|
-
|
|
23843
|
+
ToastUIEditorCore.prototype.moveCursorToStart = function (focus) {
|
|
23844
|
+
if (focus === void 0) { focus = true; }
|
|
23845
|
+
this.getCurrentModeEditor().moveCursorToStart(focus);
|
|
22301
23846
|
};
|
|
22302
23847
|
/**
|
|
22303
23848
|
* Set markdown syntax text.
|
|
@@ -22350,16 +23895,13 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22350
23895
|
ToastUIEditorCore.prototype.getHTML = function () {
|
|
22351
23896
|
var _this = this;
|
|
22352
23897
|
this.eventEmitter.holdEventInvoke(function () {
|
|
22353
|
-
if (_this.
|
|
22354
|
-
_this.
|
|
23898
|
+
if (_this.isMarkdownMode()) {
|
|
23899
|
+
var mdNode = _this.toastMark.getRootNode();
|
|
23900
|
+
var wwNode = _this.convertor.toWysiwygModel(mdNode);
|
|
23901
|
+
_this.wwEditor.setModel(wwNode);
|
|
22355
23902
|
}
|
|
22356
23903
|
});
|
|
22357
|
-
|
|
22358
|
-
var mdRenderer = this.preview.getRenderer();
|
|
22359
|
-
return mdRenderer
|
|
22360
|
-
.render(mdNode)
|
|
22361
|
-
.replace(/\sdata-nodeid="\d{1,}"/g, '')
|
|
22362
|
-
.trim();
|
|
23904
|
+
return this.wwEditor.view.dom.innerHTML;
|
|
22363
23905
|
};
|
|
22364
23906
|
/**
|
|
22365
23907
|
* Insert text
|
|
@@ -23154,6 +24696,936 @@ var templateObject_1;
|
|
|
23154
24696
|
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/tricks/throttle.js
|
|
23155
24697
|
var throttle = __webpack_require__(423);
|
|
23156
24698
|
var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle);
|
|
24699
|
+
;// CONCATENATED MODULE: ../../node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js
|
|
24700
|
+
/**
|
|
24701
|
+
* A collection of shims that provide minimal functionality of the ES6 collections.
|
|
24702
|
+
*
|
|
24703
|
+
* These implementations are not meant to be used outside of the ResizeObserver
|
|
24704
|
+
* modules as they cover only a limited range of use cases.
|
|
24705
|
+
*/
|
|
24706
|
+
/* eslint-disable require-jsdoc, valid-jsdoc */
|
|
24707
|
+
var MapShim = (function () {
|
|
24708
|
+
if (typeof Map !== 'undefined') {
|
|
24709
|
+
return Map;
|
|
24710
|
+
}
|
|
24711
|
+
/**
|
|
24712
|
+
* Returns index in provided array that matches the specified key.
|
|
24713
|
+
*
|
|
24714
|
+
* @param {Array<Array>} arr
|
|
24715
|
+
* @param {*} key
|
|
24716
|
+
* @returns {number}
|
|
24717
|
+
*/
|
|
24718
|
+
function getIndex(arr, key) {
|
|
24719
|
+
var result = -1;
|
|
24720
|
+
arr.some(function (entry, index) {
|
|
24721
|
+
if (entry[0] === key) {
|
|
24722
|
+
result = index;
|
|
24723
|
+
return true;
|
|
24724
|
+
}
|
|
24725
|
+
return false;
|
|
24726
|
+
});
|
|
24727
|
+
return result;
|
|
24728
|
+
}
|
|
24729
|
+
return /** @class */ (function () {
|
|
24730
|
+
function class_1() {
|
|
24731
|
+
this.__entries__ = [];
|
|
24732
|
+
}
|
|
24733
|
+
Object.defineProperty(class_1.prototype, "size", {
|
|
24734
|
+
/**
|
|
24735
|
+
* @returns {boolean}
|
|
24736
|
+
*/
|
|
24737
|
+
get: function () {
|
|
24738
|
+
return this.__entries__.length;
|
|
24739
|
+
},
|
|
24740
|
+
enumerable: true,
|
|
24741
|
+
configurable: true
|
|
24742
|
+
});
|
|
24743
|
+
/**
|
|
24744
|
+
* @param {*} key
|
|
24745
|
+
* @returns {*}
|
|
24746
|
+
*/
|
|
24747
|
+
class_1.prototype.get = function (key) {
|
|
24748
|
+
var index = getIndex(this.__entries__, key);
|
|
24749
|
+
var entry = this.__entries__[index];
|
|
24750
|
+
return entry && entry[1];
|
|
24751
|
+
};
|
|
24752
|
+
/**
|
|
24753
|
+
* @param {*} key
|
|
24754
|
+
* @param {*} value
|
|
24755
|
+
* @returns {void}
|
|
24756
|
+
*/
|
|
24757
|
+
class_1.prototype.set = function (key, value) {
|
|
24758
|
+
var index = getIndex(this.__entries__, key);
|
|
24759
|
+
if (~index) {
|
|
24760
|
+
this.__entries__[index][1] = value;
|
|
24761
|
+
}
|
|
24762
|
+
else {
|
|
24763
|
+
this.__entries__.push([key, value]);
|
|
24764
|
+
}
|
|
24765
|
+
};
|
|
24766
|
+
/**
|
|
24767
|
+
* @param {*} key
|
|
24768
|
+
* @returns {void}
|
|
24769
|
+
*/
|
|
24770
|
+
class_1.prototype.delete = function (key) {
|
|
24771
|
+
var entries = this.__entries__;
|
|
24772
|
+
var index = getIndex(entries, key);
|
|
24773
|
+
if (~index) {
|
|
24774
|
+
entries.splice(index, 1);
|
|
24775
|
+
}
|
|
24776
|
+
};
|
|
24777
|
+
/**
|
|
24778
|
+
* @param {*} key
|
|
24779
|
+
* @returns {void}
|
|
24780
|
+
*/
|
|
24781
|
+
class_1.prototype.has = function (key) {
|
|
24782
|
+
return !!~getIndex(this.__entries__, key);
|
|
24783
|
+
};
|
|
24784
|
+
/**
|
|
24785
|
+
* @returns {void}
|
|
24786
|
+
*/
|
|
24787
|
+
class_1.prototype.clear = function () {
|
|
24788
|
+
this.__entries__.splice(0);
|
|
24789
|
+
};
|
|
24790
|
+
/**
|
|
24791
|
+
* @param {Function} callback
|
|
24792
|
+
* @param {*} [ctx=null]
|
|
24793
|
+
* @returns {void}
|
|
24794
|
+
*/
|
|
24795
|
+
class_1.prototype.forEach = function (callback, ctx) {
|
|
24796
|
+
if (ctx === void 0) { ctx = null; }
|
|
24797
|
+
for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
|
|
24798
|
+
var entry = _a[_i];
|
|
24799
|
+
callback.call(ctx, entry[1], entry[0]);
|
|
24800
|
+
}
|
|
24801
|
+
};
|
|
24802
|
+
return class_1;
|
|
24803
|
+
}());
|
|
24804
|
+
})();
|
|
24805
|
+
|
|
24806
|
+
/**
|
|
24807
|
+
* Detects whether window and document objects are available in current environment.
|
|
24808
|
+
*/
|
|
24809
|
+
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
|
|
24810
|
+
|
|
24811
|
+
// Returns global object of a current environment.
|
|
24812
|
+
var global$1 = (function () {
|
|
24813
|
+
if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.Math === Math) {
|
|
24814
|
+
return __webpack_require__.g;
|
|
24815
|
+
}
|
|
24816
|
+
if (typeof self !== 'undefined' && self.Math === Math) {
|
|
24817
|
+
return self;
|
|
24818
|
+
}
|
|
24819
|
+
if (typeof window !== 'undefined' && window.Math === Math) {
|
|
24820
|
+
return window;
|
|
24821
|
+
}
|
|
24822
|
+
// eslint-disable-next-line no-new-func
|
|
24823
|
+
return Function('return this')();
|
|
24824
|
+
})();
|
|
24825
|
+
|
|
24826
|
+
/**
|
|
24827
|
+
* A shim for the requestAnimationFrame which falls back to the setTimeout if
|
|
24828
|
+
* first one is not supported.
|
|
24829
|
+
*
|
|
24830
|
+
* @returns {number} Requests' identifier.
|
|
24831
|
+
*/
|
|
24832
|
+
var requestAnimationFrame$1 = (function () {
|
|
24833
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
24834
|
+
// It's required to use a bounded function because IE sometimes throws
|
|
24835
|
+
// an "Invalid calling object" error if rAF is invoked without the global
|
|
24836
|
+
// object on the left hand side.
|
|
24837
|
+
return requestAnimationFrame.bind(global$1);
|
|
24838
|
+
}
|
|
24839
|
+
return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
|
|
24840
|
+
})();
|
|
24841
|
+
|
|
24842
|
+
// Defines minimum timeout before adding a trailing call.
|
|
24843
|
+
var trailingTimeout = 2;
|
|
24844
|
+
/**
|
|
24845
|
+
* Creates a wrapper function which ensures that provided callback will be
|
|
24846
|
+
* invoked only once during the specified delay period.
|
|
24847
|
+
*
|
|
24848
|
+
* @param {Function} callback - Function to be invoked after the delay period.
|
|
24849
|
+
* @param {number} delay - Delay after which to invoke callback.
|
|
24850
|
+
* @returns {Function}
|
|
24851
|
+
*/
|
|
24852
|
+
function ResizeObserver_es_throttle (callback, delay) {
|
|
24853
|
+
var leadingCall = false, trailingCall = false, lastCallTime = 0;
|
|
24854
|
+
/**
|
|
24855
|
+
* Invokes the original callback function and schedules new invocation if
|
|
24856
|
+
* the "proxy" was called during current request.
|
|
24857
|
+
*
|
|
24858
|
+
* @returns {void}
|
|
24859
|
+
*/
|
|
24860
|
+
function resolvePending() {
|
|
24861
|
+
if (leadingCall) {
|
|
24862
|
+
leadingCall = false;
|
|
24863
|
+
callback();
|
|
24864
|
+
}
|
|
24865
|
+
if (trailingCall) {
|
|
24866
|
+
proxy();
|
|
24867
|
+
}
|
|
24868
|
+
}
|
|
24869
|
+
/**
|
|
24870
|
+
* Callback invoked after the specified delay. It will further postpone
|
|
24871
|
+
* invocation of the original function delegating it to the
|
|
24872
|
+
* requestAnimationFrame.
|
|
24873
|
+
*
|
|
24874
|
+
* @returns {void}
|
|
24875
|
+
*/
|
|
24876
|
+
function timeoutCallback() {
|
|
24877
|
+
requestAnimationFrame$1(resolvePending);
|
|
24878
|
+
}
|
|
24879
|
+
/**
|
|
24880
|
+
* Schedules invocation of the original function.
|
|
24881
|
+
*
|
|
24882
|
+
* @returns {void}
|
|
24883
|
+
*/
|
|
24884
|
+
function proxy() {
|
|
24885
|
+
var timeStamp = Date.now();
|
|
24886
|
+
if (leadingCall) {
|
|
24887
|
+
// Reject immediately following calls.
|
|
24888
|
+
if (timeStamp - lastCallTime < trailingTimeout) {
|
|
24889
|
+
return;
|
|
24890
|
+
}
|
|
24891
|
+
// Schedule new call to be in invoked when the pending one is resolved.
|
|
24892
|
+
// This is important for "transitions" which never actually start
|
|
24893
|
+
// immediately so there is a chance that we might miss one if change
|
|
24894
|
+
// happens amids the pending invocation.
|
|
24895
|
+
trailingCall = true;
|
|
24896
|
+
}
|
|
24897
|
+
else {
|
|
24898
|
+
leadingCall = true;
|
|
24899
|
+
trailingCall = false;
|
|
24900
|
+
setTimeout(timeoutCallback, delay);
|
|
24901
|
+
}
|
|
24902
|
+
lastCallTime = timeStamp;
|
|
24903
|
+
}
|
|
24904
|
+
return proxy;
|
|
24905
|
+
}
|
|
24906
|
+
|
|
24907
|
+
// Minimum delay before invoking the update of observers.
|
|
24908
|
+
var REFRESH_DELAY = 20;
|
|
24909
|
+
// A list of substrings of CSS properties used to find transition events that
|
|
24910
|
+
// might affect dimensions of observed elements.
|
|
24911
|
+
var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
|
|
24912
|
+
// Check if MutationObserver is available.
|
|
24913
|
+
var mutationObserverSupported = typeof MutationObserver !== 'undefined';
|
|
24914
|
+
/**
|
|
24915
|
+
* Singleton controller class which handles updates of ResizeObserver instances.
|
|
24916
|
+
*/
|
|
24917
|
+
var ResizeObserverController = /** @class */ (function () {
|
|
24918
|
+
/**
|
|
24919
|
+
* Creates a new instance of ResizeObserverController.
|
|
24920
|
+
*
|
|
24921
|
+
* @private
|
|
24922
|
+
*/
|
|
24923
|
+
function ResizeObserverController() {
|
|
24924
|
+
/**
|
|
24925
|
+
* Indicates whether DOM listeners have been added.
|
|
24926
|
+
*
|
|
24927
|
+
* @private {boolean}
|
|
24928
|
+
*/
|
|
24929
|
+
this.connected_ = false;
|
|
24930
|
+
/**
|
|
24931
|
+
* Tells that controller has subscribed for Mutation Events.
|
|
24932
|
+
*
|
|
24933
|
+
* @private {boolean}
|
|
24934
|
+
*/
|
|
24935
|
+
this.mutationEventsAdded_ = false;
|
|
24936
|
+
/**
|
|
24937
|
+
* Keeps reference to the instance of MutationObserver.
|
|
24938
|
+
*
|
|
24939
|
+
* @private {MutationObserver}
|
|
24940
|
+
*/
|
|
24941
|
+
this.mutationsObserver_ = null;
|
|
24942
|
+
/**
|
|
24943
|
+
* A list of connected observers.
|
|
24944
|
+
*
|
|
24945
|
+
* @private {Array<ResizeObserverSPI>}
|
|
24946
|
+
*/
|
|
24947
|
+
this.observers_ = [];
|
|
24948
|
+
this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
|
|
24949
|
+
this.refresh = ResizeObserver_es_throttle(this.refresh.bind(this), REFRESH_DELAY);
|
|
24950
|
+
}
|
|
24951
|
+
/**
|
|
24952
|
+
* Adds observer to observers list.
|
|
24953
|
+
*
|
|
24954
|
+
* @param {ResizeObserverSPI} observer - Observer to be added.
|
|
24955
|
+
* @returns {void}
|
|
24956
|
+
*/
|
|
24957
|
+
ResizeObserverController.prototype.addObserver = function (observer) {
|
|
24958
|
+
if (!~this.observers_.indexOf(observer)) {
|
|
24959
|
+
this.observers_.push(observer);
|
|
24960
|
+
}
|
|
24961
|
+
// Add listeners if they haven't been added yet.
|
|
24962
|
+
if (!this.connected_) {
|
|
24963
|
+
this.connect_();
|
|
24964
|
+
}
|
|
24965
|
+
};
|
|
24966
|
+
/**
|
|
24967
|
+
* Removes observer from observers list.
|
|
24968
|
+
*
|
|
24969
|
+
* @param {ResizeObserverSPI} observer - Observer to be removed.
|
|
24970
|
+
* @returns {void}
|
|
24971
|
+
*/
|
|
24972
|
+
ResizeObserverController.prototype.removeObserver = function (observer) {
|
|
24973
|
+
var observers = this.observers_;
|
|
24974
|
+
var index = observers.indexOf(observer);
|
|
24975
|
+
// Remove observer if it's present in registry.
|
|
24976
|
+
if (~index) {
|
|
24977
|
+
observers.splice(index, 1);
|
|
24978
|
+
}
|
|
24979
|
+
// Remove listeners if controller has no connected observers.
|
|
24980
|
+
if (!observers.length && this.connected_) {
|
|
24981
|
+
this.disconnect_();
|
|
24982
|
+
}
|
|
24983
|
+
};
|
|
24984
|
+
/**
|
|
24985
|
+
* Invokes the update of observers. It will continue running updates insofar
|
|
24986
|
+
* it detects changes.
|
|
24987
|
+
*
|
|
24988
|
+
* @returns {void}
|
|
24989
|
+
*/
|
|
24990
|
+
ResizeObserverController.prototype.refresh = function () {
|
|
24991
|
+
var changesDetected = this.updateObservers_();
|
|
24992
|
+
// Continue running updates if changes have been detected as there might
|
|
24993
|
+
// be future ones caused by CSS transitions.
|
|
24994
|
+
if (changesDetected) {
|
|
24995
|
+
this.refresh();
|
|
24996
|
+
}
|
|
24997
|
+
};
|
|
24998
|
+
/**
|
|
24999
|
+
* Updates every observer from observers list and notifies them of queued
|
|
25000
|
+
* entries.
|
|
25001
|
+
*
|
|
25002
|
+
* @private
|
|
25003
|
+
* @returns {boolean} Returns "true" if any observer has detected changes in
|
|
25004
|
+
* dimensions of it's elements.
|
|
25005
|
+
*/
|
|
25006
|
+
ResizeObserverController.prototype.updateObservers_ = function () {
|
|
25007
|
+
// Collect observers that have active observations.
|
|
25008
|
+
var activeObservers = this.observers_.filter(function (observer) {
|
|
25009
|
+
return observer.gatherActive(), observer.hasActive();
|
|
25010
|
+
});
|
|
25011
|
+
// Deliver notifications in a separate cycle in order to avoid any
|
|
25012
|
+
// collisions between observers, e.g. when multiple instances of
|
|
25013
|
+
// ResizeObserver are tracking the same element and the callback of one
|
|
25014
|
+
// of them changes content dimensions of the observed target. Sometimes
|
|
25015
|
+
// this may result in notifications being blocked for the rest of observers.
|
|
25016
|
+
activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
|
|
25017
|
+
return activeObservers.length > 0;
|
|
25018
|
+
};
|
|
25019
|
+
/**
|
|
25020
|
+
* Initializes DOM listeners.
|
|
25021
|
+
*
|
|
25022
|
+
* @private
|
|
25023
|
+
* @returns {void}
|
|
25024
|
+
*/
|
|
25025
|
+
ResizeObserverController.prototype.connect_ = function () {
|
|
25026
|
+
// Do nothing if running in a non-browser environment or if listeners
|
|
25027
|
+
// have been already added.
|
|
25028
|
+
if (!isBrowser || this.connected_) {
|
|
25029
|
+
return;
|
|
25030
|
+
}
|
|
25031
|
+
// Subscription to the "Transitionend" event is used as a workaround for
|
|
25032
|
+
// delayed transitions. This way it's possible to capture at least the
|
|
25033
|
+
// final state of an element.
|
|
25034
|
+
document.addEventListener('transitionend', this.onTransitionEnd_);
|
|
25035
|
+
window.addEventListener('resize', this.refresh);
|
|
25036
|
+
if (mutationObserverSupported) {
|
|
25037
|
+
this.mutationsObserver_ = new MutationObserver(this.refresh);
|
|
25038
|
+
this.mutationsObserver_.observe(document, {
|
|
25039
|
+
attributes: true,
|
|
25040
|
+
childList: true,
|
|
25041
|
+
characterData: true,
|
|
25042
|
+
subtree: true
|
|
25043
|
+
});
|
|
25044
|
+
}
|
|
25045
|
+
else {
|
|
25046
|
+
document.addEventListener('DOMSubtreeModified', this.refresh);
|
|
25047
|
+
this.mutationEventsAdded_ = true;
|
|
25048
|
+
}
|
|
25049
|
+
this.connected_ = true;
|
|
25050
|
+
};
|
|
25051
|
+
/**
|
|
25052
|
+
* Removes DOM listeners.
|
|
25053
|
+
*
|
|
25054
|
+
* @private
|
|
25055
|
+
* @returns {void}
|
|
25056
|
+
*/
|
|
25057
|
+
ResizeObserverController.prototype.disconnect_ = function () {
|
|
25058
|
+
// Do nothing if running in a non-browser environment or if listeners
|
|
25059
|
+
// have been already removed.
|
|
25060
|
+
if (!isBrowser || !this.connected_) {
|
|
25061
|
+
return;
|
|
25062
|
+
}
|
|
25063
|
+
document.removeEventListener('transitionend', this.onTransitionEnd_);
|
|
25064
|
+
window.removeEventListener('resize', this.refresh);
|
|
25065
|
+
if (this.mutationsObserver_) {
|
|
25066
|
+
this.mutationsObserver_.disconnect();
|
|
25067
|
+
}
|
|
25068
|
+
if (this.mutationEventsAdded_) {
|
|
25069
|
+
document.removeEventListener('DOMSubtreeModified', this.refresh);
|
|
25070
|
+
}
|
|
25071
|
+
this.mutationsObserver_ = null;
|
|
25072
|
+
this.mutationEventsAdded_ = false;
|
|
25073
|
+
this.connected_ = false;
|
|
25074
|
+
};
|
|
25075
|
+
/**
|
|
25076
|
+
* "Transitionend" event handler.
|
|
25077
|
+
*
|
|
25078
|
+
* @private
|
|
25079
|
+
* @param {TransitionEvent} event
|
|
25080
|
+
* @returns {void}
|
|
25081
|
+
*/
|
|
25082
|
+
ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
|
|
25083
|
+
var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
|
|
25084
|
+
// Detect whether transition may affect dimensions of an element.
|
|
25085
|
+
var isReflowProperty = transitionKeys.some(function (key) {
|
|
25086
|
+
return !!~propertyName.indexOf(key);
|
|
25087
|
+
});
|
|
25088
|
+
if (isReflowProperty) {
|
|
25089
|
+
this.refresh();
|
|
25090
|
+
}
|
|
25091
|
+
};
|
|
25092
|
+
/**
|
|
25093
|
+
* Returns instance of the ResizeObserverController.
|
|
25094
|
+
*
|
|
25095
|
+
* @returns {ResizeObserverController}
|
|
25096
|
+
*/
|
|
25097
|
+
ResizeObserverController.getInstance = function () {
|
|
25098
|
+
if (!this.instance_) {
|
|
25099
|
+
this.instance_ = new ResizeObserverController();
|
|
25100
|
+
}
|
|
25101
|
+
return this.instance_;
|
|
25102
|
+
};
|
|
25103
|
+
/**
|
|
25104
|
+
* Holds reference to the controller's instance.
|
|
25105
|
+
*
|
|
25106
|
+
* @private {ResizeObserverController}
|
|
25107
|
+
*/
|
|
25108
|
+
ResizeObserverController.instance_ = null;
|
|
25109
|
+
return ResizeObserverController;
|
|
25110
|
+
}());
|
|
25111
|
+
|
|
25112
|
+
/**
|
|
25113
|
+
* Defines non-writable/enumerable properties of the provided target object.
|
|
25114
|
+
*
|
|
25115
|
+
* @param {Object} target - Object for which to define properties.
|
|
25116
|
+
* @param {Object} props - Properties to be defined.
|
|
25117
|
+
* @returns {Object} Target object.
|
|
25118
|
+
*/
|
|
25119
|
+
var defineConfigurable = (function (target, props) {
|
|
25120
|
+
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
|
|
25121
|
+
var key = _a[_i];
|
|
25122
|
+
Object.defineProperty(target, key, {
|
|
25123
|
+
value: props[key],
|
|
25124
|
+
enumerable: false,
|
|
25125
|
+
writable: false,
|
|
25126
|
+
configurable: true
|
|
25127
|
+
});
|
|
25128
|
+
}
|
|
25129
|
+
return target;
|
|
25130
|
+
});
|
|
25131
|
+
|
|
25132
|
+
/**
|
|
25133
|
+
* Returns the global object associated with provided element.
|
|
25134
|
+
*
|
|
25135
|
+
* @param {Object} target
|
|
25136
|
+
* @returns {Object}
|
|
25137
|
+
*/
|
|
25138
|
+
var getWindowOf = (function (target) {
|
|
25139
|
+
// Assume that the element is an instance of Node, which means that it
|
|
25140
|
+
// has the "ownerDocument" property from which we can retrieve a
|
|
25141
|
+
// corresponding global object.
|
|
25142
|
+
var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
|
|
25143
|
+
// Return the local global object if it's not possible extract one from
|
|
25144
|
+
// provided element.
|
|
25145
|
+
return ownerGlobal || global$1;
|
|
25146
|
+
});
|
|
25147
|
+
|
|
25148
|
+
// Placeholder of an empty content rectangle.
|
|
25149
|
+
var emptyRect = createRectInit(0, 0, 0, 0);
|
|
25150
|
+
/**
|
|
25151
|
+
* Converts provided string to a number.
|
|
25152
|
+
*
|
|
25153
|
+
* @param {number|string} value
|
|
25154
|
+
* @returns {number}
|
|
25155
|
+
*/
|
|
25156
|
+
function toFloat(value) {
|
|
25157
|
+
return parseFloat(value) || 0;
|
|
25158
|
+
}
|
|
25159
|
+
/**
|
|
25160
|
+
* Extracts borders size from provided styles.
|
|
25161
|
+
*
|
|
25162
|
+
* @param {CSSStyleDeclaration} styles
|
|
25163
|
+
* @param {...string} positions - Borders positions (top, right, ...)
|
|
25164
|
+
* @returns {number}
|
|
25165
|
+
*/
|
|
25166
|
+
function getBordersSize(styles) {
|
|
25167
|
+
var positions = [];
|
|
25168
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
25169
|
+
positions[_i - 1] = arguments[_i];
|
|
25170
|
+
}
|
|
25171
|
+
return positions.reduce(function (size, position) {
|
|
25172
|
+
var value = styles['border-' + position + '-width'];
|
|
25173
|
+
return size + toFloat(value);
|
|
25174
|
+
}, 0);
|
|
25175
|
+
}
|
|
25176
|
+
/**
|
|
25177
|
+
* Extracts paddings sizes from provided styles.
|
|
25178
|
+
*
|
|
25179
|
+
* @param {CSSStyleDeclaration} styles
|
|
25180
|
+
* @returns {Object} Paddings box.
|
|
25181
|
+
*/
|
|
25182
|
+
function getPaddings(styles) {
|
|
25183
|
+
var positions = ['top', 'right', 'bottom', 'left'];
|
|
25184
|
+
var paddings = {};
|
|
25185
|
+
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
25186
|
+
var position = positions_1[_i];
|
|
25187
|
+
var value = styles['padding-' + position];
|
|
25188
|
+
paddings[position] = toFloat(value);
|
|
25189
|
+
}
|
|
25190
|
+
return paddings;
|
|
25191
|
+
}
|
|
25192
|
+
/**
|
|
25193
|
+
* Calculates content rectangle of provided SVG element.
|
|
25194
|
+
*
|
|
25195
|
+
* @param {SVGGraphicsElement} target - Element content rectangle of which needs
|
|
25196
|
+
* to be calculated.
|
|
25197
|
+
* @returns {DOMRectInit}
|
|
25198
|
+
*/
|
|
25199
|
+
function getSVGContentRect(target) {
|
|
25200
|
+
var bbox = target.getBBox();
|
|
25201
|
+
return createRectInit(0, 0, bbox.width, bbox.height);
|
|
25202
|
+
}
|
|
25203
|
+
/**
|
|
25204
|
+
* Calculates content rectangle of provided HTMLElement.
|
|
25205
|
+
*
|
|
25206
|
+
* @param {HTMLElement} target - Element for which to calculate the content rectangle.
|
|
25207
|
+
* @returns {DOMRectInit}
|
|
25208
|
+
*/
|
|
25209
|
+
function getHTMLElementContentRect(target) {
|
|
25210
|
+
// Client width & height properties can't be
|
|
25211
|
+
// used exclusively as they provide rounded values.
|
|
25212
|
+
var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
|
|
25213
|
+
// By this condition we can catch all non-replaced inline, hidden and
|
|
25214
|
+
// detached elements. Though elements with width & height properties less
|
|
25215
|
+
// than 0.5 will be discarded as well.
|
|
25216
|
+
//
|
|
25217
|
+
// Without it we would need to implement separate methods for each of
|
|
25218
|
+
// those cases and it's not possible to perform a precise and performance
|
|
25219
|
+
// effective test for hidden elements. E.g. even jQuery's ':visible' filter
|
|
25220
|
+
// gives wrong results for elements with width & height less than 0.5.
|
|
25221
|
+
if (!clientWidth && !clientHeight) {
|
|
25222
|
+
return emptyRect;
|
|
25223
|
+
}
|
|
25224
|
+
var styles = getWindowOf(target).getComputedStyle(target);
|
|
25225
|
+
var paddings = getPaddings(styles);
|
|
25226
|
+
var horizPad = paddings.left + paddings.right;
|
|
25227
|
+
var vertPad = paddings.top + paddings.bottom;
|
|
25228
|
+
// Computed styles of width & height are being used because they are the
|
|
25229
|
+
// only dimensions available to JS that contain non-rounded values. It could
|
|
25230
|
+
// be possible to utilize the getBoundingClientRect if only it's data wasn't
|
|
25231
|
+
// affected by CSS transformations let alone paddings, borders and scroll bars.
|
|
25232
|
+
var width = toFloat(styles.width), height = toFloat(styles.height);
|
|
25233
|
+
// Width & height include paddings and borders when the 'border-box' box
|
|
25234
|
+
// model is applied (except for IE).
|
|
25235
|
+
if (styles.boxSizing === 'border-box') {
|
|
25236
|
+
// Following conditions are required to handle Internet Explorer which
|
|
25237
|
+
// doesn't include paddings and borders to computed CSS dimensions.
|
|
25238
|
+
//
|
|
25239
|
+
// We can say that if CSS dimensions + paddings are equal to the "client"
|
|
25240
|
+
// properties then it's either IE, and thus we don't need to subtract
|
|
25241
|
+
// anything, or an element merely doesn't have paddings/borders styles.
|
|
25242
|
+
if (Math.round(width + horizPad) !== clientWidth) {
|
|
25243
|
+
width -= getBordersSize(styles, 'left', 'right') + horizPad;
|
|
25244
|
+
}
|
|
25245
|
+
if (Math.round(height + vertPad) !== clientHeight) {
|
|
25246
|
+
height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
|
|
25247
|
+
}
|
|
25248
|
+
}
|
|
25249
|
+
// Following steps can't be applied to the document's root element as its
|
|
25250
|
+
// client[Width/Height] properties represent viewport area of the window.
|
|
25251
|
+
// Besides, it's as well not necessary as the <html> itself neither has
|
|
25252
|
+
// rendered scroll bars nor it can be clipped.
|
|
25253
|
+
if (!isDocumentElement(target)) {
|
|
25254
|
+
// In some browsers (only in Firefox, actually) CSS width & height
|
|
25255
|
+
// include scroll bars size which can be removed at this step as scroll
|
|
25256
|
+
// bars are the only difference between rounded dimensions + paddings
|
|
25257
|
+
// and "client" properties, though that is not always true in Chrome.
|
|
25258
|
+
var vertScrollbar = Math.round(width + horizPad) - clientWidth;
|
|
25259
|
+
var horizScrollbar = Math.round(height + vertPad) - clientHeight;
|
|
25260
|
+
// Chrome has a rather weird rounding of "client" properties.
|
|
25261
|
+
// E.g. for an element with content width of 314.2px it sometimes gives
|
|
25262
|
+
// the client width of 315px and for the width of 314.7px it may give
|
|
25263
|
+
// 314px. And it doesn't happen all the time. So just ignore this delta
|
|
25264
|
+
// as a non-relevant.
|
|
25265
|
+
if (Math.abs(vertScrollbar) !== 1) {
|
|
25266
|
+
width -= vertScrollbar;
|
|
25267
|
+
}
|
|
25268
|
+
if (Math.abs(horizScrollbar) !== 1) {
|
|
25269
|
+
height -= horizScrollbar;
|
|
25270
|
+
}
|
|
25271
|
+
}
|
|
25272
|
+
return createRectInit(paddings.left, paddings.top, width, height);
|
|
25273
|
+
}
|
|
25274
|
+
/**
|
|
25275
|
+
* Checks whether provided element is an instance of the SVGGraphicsElement.
|
|
25276
|
+
*
|
|
25277
|
+
* @param {Element} target - Element to be checked.
|
|
25278
|
+
* @returns {boolean}
|
|
25279
|
+
*/
|
|
25280
|
+
var isSVGGraphicsElement = (function () {
|
|
25281
|
+
// Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
|
|
25282
|
+
// interface.
|
|
25283
|
+
if (typeof SVGGraphicsElement !== 'undefined') {
|
|
25284
|
+
return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
|
|
25285
|
+
}
|
|
25286
|
+
// If it's so, then check that element is at least an instance of the
|
|
25287
|
+
// SVGElement and that it has the "getBBox" method.
|
|
25288
|
+
// eslint-disable-next-line no-extra-parens
|
|
25289
|
+
return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
|
|
25290
|
+
typeof target.getBBox === 'function'); };
|
|
25291
|
+
})();
|
|
25292
|
+
/**
|
|
25293
|
+
* Checks whether provided element is a document element (<html>).
|
|
25294
|
+
*
|
|
25295
|
+
* @param {Element} target - Element to be checked.
|
|
25296
|
+
* @returns {boolean}
|
|
25297
|
+
*/
|
|
25298
|
+
function isDocumentElement(target) {
|
|
25299
|
+
return target === getWindowOf(target).document.documentElement;
|
|
25300
|
+
}
|
|
25301
|
+
/**
|
|
25302
|
+
* Calculates an appropriate content rectangle for provided html or svg element.
|
|
25303
|
+
*
|
|
25304
|
+
* @param {Element} target - Element content rectangle of which needs to be calculated.
|
|
25305
|
+
* @returns {DOMRectInit}
|
|
25306
|
+
*/
|
|
25307
|
+
function getContentRect(target) {
|
|
25308
|
+
if (!isBrowser) {
|
|
25309
|
+
return emptyRect;
|
|
25310
|
+
}
|
|
25311
|
+
if (isSVGGraphicsElement(target)) {
|
|
25312
|
+
return getSVGContentRect(target);
|
|
25313
|
+
}
|
|
25314
|
+
return getHTMLElementContentRect(target);
|
|
25315
|
+
}
|
|
25316
|
+
/**
|
|
25317
|
+
* Creates rectangle with an interface of the DOMRectReadOnly.
|
|
25318
|
+
* Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
|
|
25319
|
+
*
|
|
25320
|
+
* @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
|
|
25321
|
+
* @returns {DOMRectReadOnly}
|
|
25322
|
+
*/
|
|
25323
|
+
function createReadOnlyRect(_a) {
|
|
25324
|
+
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
|
25325
|
+
// If DOMRectReadOnly is available use it as a prototype for the rectangle.
|
|
25326
|
+
var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
|
|
25327
|
+
var rect = Object.create(Constr.prototype);
|
|
25328
|
+
// Rectangle's properties are not writable and non-enumerable.
|
|
25329
|
+
defineConfigurable(rect, {
|
|
25330
|
+
x: x, y: y, width: width, height: height,
|
|
25331
|
+
top: y,
|
|
25332
|
+
right: x + width,
|
|
25333
|
+
bottom: height + y,
|
|
25334
|
+
left: x
|
|
25335
|
+
});
|
|
25336
|
+
return rect;
|
|
25337
|
+
}
|
|
25338
|
+
/**
|
|
25339
|
+
* Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
|
|
25340
|
+
* Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
|
|
25341
|
+
*
|
|
25342
|
+
* @param {number} x - X coordinate.
|
|
25343
|
+
* @param {number} y - Y coordinate.
|
|
25344
|
+
* @param {number} width - Rectangle's width.
|
|
25345
|
+
* @param {number} height - Rectangle's height.
|
|
25346
|
+
* @returns {DOMRectInit}
|
|
25347
|
+
*/
|
|
25348
|
+
function createRectInit(x, y, width, height) {
|
|
25349
|
+
return { x: x, y: y, width: width, height: height };
|
|
25350
|
+
}
|
|
25351
|
+
|
|
25352
|
+
/**
|
|
25353
|
+
* Class that is responsible for computations of the content rectangle of
|
|
25354
|
+
* provided DOM element and for keeping track of it's changes.
|
|
25355
|
+
*/
|
|
25356
|
+
var ResizeObservation = /** @class */ (function () {
|
|
25357
|
+
/**
|
|
25358
|
+
* Creates an instance of ResizeObservation.
|
|
25359
|
+
*
|
|
25360
|
+
* @param {Element} target - Element to be observed.
|
|
25361
|
+
*/
|
|
25362
|
+
function ResizeObservation(target) {
|
|
25363
|
+
/**
|
|
25364
|
+
* Broadcasted width of content rectangle.
|
|
25365
|
+
*
|
|
25366
|
+
* @type {number}
|
|
25367
|
+
*/
|
|
25368
|
+
this.broadcastWidth = 0;
|
|
25369
|
+
/**
|
|
25370
|
+
* Broadcasted height of content rectangle.
|
|
25371
|
+
*
|
|
25372
|
+
* @type {number}
|
|
25373
|
+
*/
|
|
25374
|
+
this.broadcastHeight = 0;
|
|
25375
|
+
/**
|
|
25376
|
+
* Reference to the last observed content rectangle.
|
|
25377
|
+
*
|
|
25378
|
+
* @private {DOMRectInit}
|
|
25379
|
+
*/
|
|
25380
|
+
this.contentRect_ = createRectInit(0, 0, 0, 0);
|
|
25381
|
+
this.target = target;
|
|
25382
|
+
}
|
|
25383
|
+
/**
|
|
25384
|
+
* Updates content rectangle and tells whether it's width or height properties
|
|
25385
|
+
* have changed since the last broadcast.
|
|
25386
|
+
*
|
|
25387
|
+
* @returns {boolean}
|
|
25388
|
+
*/
|
|
25389
|
+
ResizeObservation.prototype.isActive = function () {
|
|
25390
|
+
var rect = getContentRect(this.target);
|
|
25391
|
+
this.contentRect_ = rect;
|
|
25392
|
+
return (rect.width !== this.broadcastWidth ||
|
|
25393
|
+
rect.height !== this.broadcastHeight);
|
|
25394
|
+
};
|
|
25395
|
+
/**
|
|
25396
|
+
* Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
|
|
25397
|
+
* from the corresponding properties of the last observed content rectangle.
|
|
25398
|
+
*
|
|
25399
|
+
* @returns {DOMRectInit} Last observed content rectangle.
|
|
25400
|
+
*/
|
|
25401
|
+
ResizeObservation.prototype.broadcastRect = function () {
|
|
25402
|
+
var rect = this.contentRect_;
|
|
25403
|
+
this.broadcastWidth = rect.width;
|
|
25404
|
+
this.broadcastHeight = rect.height;
|
|
25405
|
+
return rect;
|
|
25406
|
+
};
|
|
25407
|
+
return ResizeObservation;
|
|
25408
|
+
}());
|
|
25409
|
+
|
|
25410
|
+
var ResizeObserverEntry = /** @class */ (function () {
|
|
25411
|
+
/**
|
|
25412
|
+
* Creates an instance of ResizeObserverEntry.
|
|
25413
|
+
*
|
|
25414
|
+
* @param {Element} target - Element that is being observed.
|
|
25415
|
+
* @param {DOMRectInit} rectInit - Data of the element's content rectangle.
|
|
25416
|
+
*/
|
|
25417
|
+
function ResizeObserverEntry(target, rectInit) {
|
|
25418
|
+
var contentRect = createReadOnlyRect(rectInit);
|
|
25419
|
+
// According to the specification following properties are not writable
|
|
25420
|
+
// and are also not enumerable in the native implementation.
|
|
25421
|
+
//
|
|
25422
|
+
// Property accessors are not being used as they'd require to define a
|
|
25423
|
+
// private WeakMap storage which may cause memory leaks in browsers that
|
|
25424
|
+
// don't support this type of collections.
|
|
25425
|
+
defineConfigurable(this, { target: target, contentRect: contentRect });
|
|
25426
|
+
}
|
|
25427
|
+
return ResizeObserverEntry;
|
|
25428
|
+
}());
|
|
25429
|
+
|
|
25430
|
+
var ResizeObserverSPI = /** @class */ (function () {
|
|
25431
|
+
/**
|
|
25432
|
+
* Creates a new instance of ResizeObserver.
|
|
25433
|
+
*
|
|
25434
|
+
* @param {ResizeObserverCallback} callback - Callback function that is invoked
|
|
25435
|
+
* when one of the observed elements changes it's content dimensions.
|
|
25436
|
+
* @param {ResizeObserverController} controller - Controller instance which
|
|
25437
|
+
* is responsible for the updates of observer.
|
|
25438
|
+
* @param {ResizeObserver} callbackCtx - Reference to the public
|
|
25439
|
+
* ResizeObserver instance which will be passed to callback function.
|
|
25440
|
+
*/
|
|
25441
|
+
function ResizeObserverSPI(callback, controller, callbackCtx) {
|
|
25442
|
+
/**
|
|
25443
|
+
* Collection of resize observations that have detected changes in dimensions
|
|
25444
|
+
* of elements.
|
|
25445
|
+
*
|
|
25446
|
+
* @private {Array<ResizeObservation>}
|
|
25447
|
+
*/
|
|
25448
|
+
this.activeObservations_ = [];
|
|
25449
|
+
/**
|
|
25450
|
+
* Registry of the ResizeObservation instances.
|
|
25451
|
+
*
|
|
25452
|
+
* @private {Map<Element, ResizeObservation>}
|
|
25453
|
+
*/
|
|
25454
|
+
this.observations_ = new MapShim();
|
|
25455
|
+
if (typeof callback !== 'function') {
|
|
25456
|
+
throw new TypeError('The callback provided as parameter 1 is not a function.');
|
|
25457
|
+
}
|
|
25458
|
+
this.callback_ = callback;
|
|
25459
|
+
this.controller_ = controller;
|
|
25460
|
+
this.callbackCtx_ = callbackCtx;
|
|
25461
|
+
}
|
|
25462
|
+
/**
|
|
25463
|
+
* Starts observing provided element.
|
|
25464
|
+
*
|
|
25465
|
+
* @param {Element} target - Element to be observed.
|
|
25466
|
+
* @returns {void}
|
|
25467
|
+
*/
|
|
25468
|
+
ResizeObserverSPI.prototype.observe = function (target) {
|
|
25469
|
+
if (!arguments.length) {
|
|
25470
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
25471
|
+
}
|
|
25472
|
+
// Do nothing if current environment doesn't have the Element interface.
|
|
25473
|
+
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
|
|
25474
|
+
return;
|
|
25475
|
+
}
|
|
25476
|
+
if (!(target instanceof getWindowOf(target).Element)) {
|
|
25477
|
+
throw new TypeError('parameter 1 is not of type "Element".');
|
|
25478
|
+
}
|
|
25479
|
+
var observations = this.observations_;
|
|
25480
|
+
// Do nothing if element is already being observed.
|
|
25481
|
+
if (observations.has(target)) {
|
|
25482
|
+
return;
|
|
25483
|
+
}
|
|
25484
|
+
observations.set(target, new ResizeObservation(target));
|
|
25485
|
+
this.controller_.addObserver(this);
|
|
25486
|
+
// Force the update of observations.
|
|
25487
|
+
this.controller_.refresh();
|
|
25488
|
+
};
|
|
25489
|
+
/**
|
|
25490
|
+
* Stops observing provided element.
|
|
25491
|
+
*
|
|
25492
|
+
* @param {Element} target - Element to stop observing.
|
|
25493
|
+
* @returns {void}
|
|
25494
|
+
*/
|
|
25495
|
+
ResizeObserverSPI.prototype.unobserve = function (target) {
|
|
25496
|
+
if (!arguments.length) {
|
|
25497
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
25498
|
+
}
|
|
25499
|
+
// Do nothing if current environment doesn't have the Element interface.
|
|
25500
|
+
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
|
|
25501
|
+
return;
|
|
25502
|
+
}
|
|
25503
|
+
if (!(target instanceof getWindowOf(target).Element)) {
|
|
25504
|
+
throw new TypeError('parameter 1 is not of type "Element".');
|
|
25505
|
+
}
|
|
25506
|
+
var observations = this.observations_;
|
|
25507
|
+
// Do nothing if element is not being observed.
|
|
25508
|
+
if (!observations.has(target)) {
|
|
25509
|
+
return;
|
|
25510
|
+
}
|
|
25511
|
+
observations.delete(target);
|
|
25512
|
+
if (!observations.size) {
|
|
25513
|
+
this.controller_.removeObserver(this);
|
|
25514
|
+
}
|
|
25515
|
+
};
|
|
25516
|
+
/**
|
|
25517
|
+
* Stops observing all elements.
|
|
25518
|
+
*
|
|
25519
|
+
* @returns {void}
|
|
25520
|
+
*/
|
|
25521
|
+
ResizeObserverSPI.prototype.disconnect = function () {
|
|
25522
|
+
this.clearActive();
|
|
25523
|
+
this.observations_.clear();
|
|
25524
|
+
this.controller_.removeObserver(this);
|
|
25525
|
+
};
|
|
25526
|
+
/**
|
|
25527
|
+
* Collects observation instances the associated element of which has changed
|
|
25528
|
+
* it's content rectangle.
|
|
25529
|
+
*
|
|
25530
|
+
* @returns {void}
|
|
25531
|
+
*/
|
|
25532
|
+
ResizeObserverSPI.prototype.gatherActive = function () {
|
|
25533
|
+
var _this = this;
|
|
25534
|
+
this.clearActive();
|
|
25535
|
+
this.observations_.forEach(function (observation) {
|
|
25536
|
+
if (observation.isActive()) {
|
|
25537
|
+
_this.activeObservations_.push(observation);
|
|
25538
|
+
}
|
|
25539
|
+
});
|
|
25540
|
+
};
|
|
25541
|
+
/**
|
|
25542
|
+
* Invokes initial callback function with a list of ResizeObserverEntry
|
|
25543
|
+
* instances collected from active resize observations.
|
|
25544
|
+
*
|
|
25545
|
+
* @returns {void}
|
|
25546
|
+
*/
|
|
25547
|
+
ResizeObserverSPI.prototype.broadcastActive = function () {
|
|
25548
|
+
// Do nothing if observer doesn't have active observations.
|
|
25549
|
+
if (!this.hasActive()) {
|
|
25550
|
+
return;
|
|
25551
|
+
}
|
|
25552
|
+
var ctx = this.callbackCtx_;
|
|
25553
|
+
// Create ResizeObserverEntry instance for every active observation.
|
|
25554
|
+
var entries = this.activeObservations_.map(function (observation) {
|
|
25555
|
+
return new ResizeObserverEntry(observation.target, observation.broadcastRect());
|
|
25556
|
+
});
|
|
25557
|
+
this.callback_.call(ctx, entries, ctx);
|
|
25558
|
+
this.clearActive();
|
|
25559
|
+
};
|
|
25560
|
+
/**
|
|
25561
|
+
* Clears the collection of active observations.
|
|
25562
|
+
*
|
|
25563
|
+
* @returns {void}
|
|
25564
|
+
*/
|
|
25565
|
+
ResizeObserverSPI.prototype.clearActive = function () {
|
|
25566
|
+
this.activeObservations_.splice(0);
|
|
25567
|
+
};
|
|
25568
|
+
/**
|
|
25569
|
+
* Tells whether observer has active observations.
|
|
25570
|
+
*
|
|
25571
|
+
* @returns {boolean}
|
|
25572
|
+
*/
|
|
25573
|
+
ResizeObserverSPI.prototype.hasActive = function () {
|
|
25574
|
+
return this.activeObservations_.length > 0;
|
|
25575
|
+
};
|
|
25576
|
+
return ResizeObserverSPI;
|
|
25577
|
+
}());
|
|
25578
|
+
|
|
25579
|
+
// Registry of internal observers. If WeakMap is not available use current shim
|
|
25580
|
+
// for the Map collection as it has all required methods and because WeakMap
|
|
25581
|
+
// can't be fully polyfilled anyway.
|
|
25582
|
+
var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
|
|
25583
|
+
/**
|
|
25584
|
+
* ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
|
|
25585
|
+
* exposing only those methods and properties that are defined in the spec.
|
|
25586
|
+
*/
|
|
25587
|
+
var ResizeObserver = /** @class */ (function () {
|
|
25588
|
+
/**
|
|
25589
|
+
* Creates a new instance of ResizeObserver.
|
|
25590
|
+
*
|
|
25591
|
+
* @param {ResizeObserverCallback} callback - Callback that is invoked when
|
|
25592
|
+
* dimensions of the observed elements change.
|
|
25593
|
+
*/
|
|
25594
|
+
function ResizeObserver(callback) {
|
|
25595
|
+
if (!(this instanceof ResizeObserver)) {
|
|
25596
|
+
throw new TypeError('Cannot call a class as a function.');
|
|
25597
|
+
}
|
|
25598
|
+
if (!arguments.length) {
|
|
25599
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
25600
|
+
}
|
|
25601
|
+
var controller = ResizeObserverController.getInstance();
|
|
25602
|
+
var observer = new ResizeObserverSPI(callback, controller, this);
|
|
25603
|
+
observers.set(this, observer);
|
|
25604
|
+
}
|
|
25605
|
+
return ResizeObserver;
|
|
25606
|
+
}());
|
|
25607
|
+
// Expose public methods of ResizeObserver.
|
|
25608
|
+
[
|
|
25609
|
+
'observe',
|
|
25610
|
+
'unobserve',
|
|
25611
|
+
'disconnect'
|
|
25612
|
+
].forEach(function (method) {
|
|
25613
|
+
ResizeObserver.prototype[method] = function () {
|
|
25614
|
+
var _a;
|
|
25615
|
+
return (_a = observers.get(this))[method].apply(_a, arguments);
|
|
25616
|
+
};
|
|
25617
|
+
});
|
|
25618
|
+
|
|
25619
|
+
var index = (function () {
|
|
25620
|
+
// Export existing implementation if available.
|
|
25621
|
+
if (typeof global$1.ResizeObserver !== 'undefined') {
|
|
25622
|
+
return global$1.ResizeObserver;
|
|
25623
|
+
}
|
|
25624
|
+
return ResizeObserver;
|
|
25625
|
+
})();
|
|
25626
|
+
|
|
25627
|
+
/* harmony default export */ var ResizeObserver_es = (index);
|
|
25628
|
+
|
|
23157
25629
|
;// CONCATENATED MODULE: ./src/ui/components/toolbar/headingPopupBody.ts
|
|
23158
25630
|
|
|
23159
25631
|
|
|
@@ -23173,9 +25645,9 @@ var HeadingPopupBody = /** @class */ (function (_super) {
|
|
|
23173
25645
|
};
|
|
23174
25646
|
HeadingPopupBody.prototype.render = function () {
|
|
23175
25647
|
var _this = this;
|
|
23176
|
-
return template(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n <ul
|
|
23177
|
-
"\n <li data-type=\"Paragraph\"
|
|
23178
|
-
return template(headingPopupBody_templateObject_1 || (headingPopupBody_templateObject_1 = __makeTemplateObject(["\n <li data-level=\"", "\" data-type=\"Heading\">\n <", ">", " ", "</$>\n </li>\n "], ["\n <li data-level=\"", "\" data-type=\"Heading\">\n <", ">", " ", "</$>\n </li>\n "])), level, "h" + level, i18n.get('Heading'), level);
|
|
25648
|
+
return template(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n <ul\n onClick=", "\n aria-role=\"menu\"\n aria-label=\"", "\"\n >\n ", "\n <li data-type=\"Paragraph\" aria-role=\"menuitem\">\n <div>", "</div>\n </li>\n </ul>\n "], ["\n <ul\n onClick=", "\n aria-role=\"menu\"\n aria-label=\"", "\"\n >\n ",
|
|
25649
|
+
"\n <li data-type=\"Paragraph\" aria-role=\"menuitem\">\n <div>", "</div>\n </li>\n </ul>\n "])), function (ev) { return _this.execCommand(ev); }, i18n.get('Headings'), [1, 2, 3, 4, 5, 6].map(function (level) {
|
|
25650
|
+
return template(headingPopupBody_templateObject_1 || (headingPopupBody_templateObject_1 = __makeTemplateObject(["\n <li data-level=\"", "\" data-type=\"Heading\" aria-role=\"menuitem\">\n <", ">", " ", "</$>\n </li>\n "], ["\n <li data-level=\"", "\" data-type=\"Heading\" aria-role=\"menuitem\">\n <", ">", " ", "</$>\n </li>\n "])), level, "h" + level, i18n.get('Heading'), level);
|
|
23179
25651
|
}), i18n.get('Paragraph'));
|
|
23180
25652
|
};
|
|
23181
25653
|
return HeadingPopupBody;
|
|
@@ -23199,10 +25671,11 @@ var Tabs = /** @class */ (function (_super) {
|
|
|
23199
25671
|
};
|
|
23200
25672
|
Tabs.prototype.render = function () {
|
|
23201
25673
|
var _this = this;
|
|
23202
|
-
return template(tabs_templateObject_2 || (tabs_templateObject_2 = __makeTemplateObject(["\n <div class=\"", "\">\n ", "\n </div>\n "], ["\n <div class=\"", "\">\n ",
|
|
25674
|
+
return template(tabs_templateObject_2 || (tabs_templateObject_2 = __makeTemplateObject(["\n <div class=\"", "\" aria-role=\"tabpanel\">\n ", "\n </div>\n "], ["\n <div class=\"", "\" aria-role=\"tabpanel\">\n ",
|
|
23203
25675
|
"\n </div>\n "])), cls('tabs'), this.props.tabs.map(function (_a) {
|
|
23204
25676
|
var name = _a.name, text = _a.text;
|
|
23205
|
-
|
|
25677
|
+
var isActive = _this.props.activeTab === name;
|
|
25678
|
+
return template(tabs_templateObject_1 || (tabs_templateObject_1 = __makeTemplateObject(["\n <div\n class=\"tab-item", "\"\n onClick=", "\n aria-role=\"tab\"\n aria-label=\"", "\"\n aria-selected=\"", "\"\n tabindex=\"", "\"\n >\n ", "\n </div>\n "], ["\n <div\n class=\"tab-item", "\"\n onClick=", "\n aria-role=\"tab\"\n aria-label=\"", "\"\n aria-selected=\"", "\"\n tabindex=\"", "\"\n >\n ", "\n </div>\n "])), isActive ? ' active' : '', function (ev) { return _this.toggleTab(ev, name); }, i18n.get(text), isActive ? 'true' : 'false', isActive ? '0' : '-1', i18n.get(text));
|
|
23206
25679
|
}));
|
|
23207
25680
|
};
|
|
23208
25681
|
return Tabs;
|
|
@@ -23302,7 +25775,7 @@ var ImagePopupBody = /** @class */ (function (_super) {
|
|
|
23302
25775
|
ImagePopupBody.prototype.render = function () {
|
|
23303
25776
|
var _this = this;
|
|
23304
25777
|
var _a = this.state, activeTab = _a.activeTab, file = _a.file, fileNameElClassName = _a.fileNameElClassName;
|
|
23305
|
-
return template(imagePopupBody_templateObject_1 || (imagePopupBody_templateObject_1 = __makeTemplateObject(["\n <div>\n <", " tabs=", " activeTab=", " onClick=", " />\n <div style=\"display:", "\">\n <label for=\"toastuiImageUrlInput\">", "</label>\n <input\n id=\"toastuiImageUrlInput\"\n type=\"text\"\n ref=", "\n />\n </div>\n <div style=\"display:", ";position: relative;\">\n <label for=\"toastuiImageFileInput\">", "</label>\n <span\n class=\"", "", "\"\n onClick=", "\n onSelectstart=", "\n >\n ", "\n </span>\n <button\n type=\"button\"\n class=\"", "\"\n onClick=", "\n >\n ", "\n </button>\n <input\n id=\"toastuiImageFileInput\"\n type=\"file\"\n accept=\"image/*\"\n onChange=", "\n ref=", "\n />\n </div>\n <label for=\"toastuiAltTextInput\">", "</label>\n <input\n id=\"toastuiAltTextInput\"\n type=\"text\"\n ref=", "\n />\n <div class=\"", "\">\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n </div>\n </div>\n "], ["\n <div>\n <", " tabs=", " activeTab=", " onClick=", " />\n <div style=\"display:", "\">\n <label for=\"toastuiImageUrlInput\">", "</label>\n <input\n id=\"toastuiImageUrlInput\"\n type=\"text\"\n ref=", "\n />\n </div>\n <div style=\"display:", ";position: relative;\">\n <label for=\"toastuiImageFileInput\">", "</label>\n <span\n class=\"", "", "\"\n onClick=", "\n onSelectstart=", "\n >\n ", "\n </span>\n <button\n type=\"button\"\n class=\"", "\"\n onClick=", "\n >\n ", "\n </button>\n <input\n id=\"toastuiImageFileInput\"\n type=\"file\"\n accept=\"image/*\"\n onChange=", "\n ref=", "\n />\n </div>\n <label for=\"toastuiAltTextInput\">", "</label>\n <input\n id=\"toastuiAltTextInput\"\n type=\"text\"\n ref=", "\n />\n <div class=\"", "\">\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n </div>\n </div>\n "])), Tabs, this.tabs, activeTab, this.toggleTab, activeTab === 'url' ? 'block' : 'none', i18n.get('Image URL'), function (el) { return (_this.refs.url = el); }, activeTab === 'file' ? 'block' : 'none', i18n.get('Select image file'), cls('file-name'), file ? ' has-file' : fileNameElClassName, this.showFileSelectBox, this.preventSelectStart, file ? file.name : i18n.get('No file'), cls('file-select-button'), this.showFileSelectBox, i18n.get('Choose a file'), this.changeFile, function (el) { return (_this.refs.file = el); }, i18n.get('Description'), function (el) { return (_this.refs.altText = el); }, cls('button-container'), cls('close-button'), this.props.hidePopup, i18n.get('Cancel'), cls('ok-button'), this.execCommand, i18n.get('OK'));
|
|
25778
|
+
return template(imagePopupBody_templateObject_1 || (imagePopupBody_templateObject_1 = __makeTemplateObject(["\n <div aria-label=\"", "\">\n <", " tabs=", " activeTab=", " onClick=", " />\n <div style=\"display:", "\">\n <label for=\"toastuiImageUrlInput\">", "</label>\n <input\n id=\"toastuiImageUrlInput\"\n type=\"text\"\n ref=", "\n />\n </div>\n <div style=\"display:", ";position: relative;\">\n <label for=\"toastuiImageFileInput\">", "</label>\n <span\n class=\"", "", "\"\n onClick=", "\n onSelectstart=", "\n >\n ", "\n </span>\n <button\n type=\"button\"\n class=\"", "\"\n onClick=", "\n >\n ", "\n </button>\n <input\n id=\"toastuiImageFileInput\"\n type=\"file\"\n accept=\"image/*\"\n onChange=", "\n ref=", "\n />\n </div>\n <label for=\"toastuiAltTextInput\">", "</label>\n <input\n id=\"toastuiAltTextInput\"\n type=\"text\"\n ref=", "\n />\n <div class=\"", "\">\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n </div>\n </div>\n "], ["\n <div aria-label=\"", "\">\n <", " tabs=", " activeTab=", " onClick=", " />\n <div style=\"display:", "\">\n <label for=\"toastuiImageUrlInput\">", "</label>\n <input\n id=\"toastuiImageUrlInput\"\n type=\"text\"\n ref=", "\n />\n </div>\n <div style=\"display:", ";position: relative;\">\n <label for=\"toastuiImageFileInput\">", "</label>\n <span\n class=\"", "", "\"\n onClick=", "\n onSelectstart=", "\n >\n ", "\n </span>\n <button\n type=\"button\"\n class=\"", "\"\n onClick=", "\n >\n ", "\n </button>\n <input\n id=\"toastuiImageFileInput\"\n type=\"file\"\n accept=\"image/*\"\n onChange=", "\n ref=", "\n />\n </div>\n <label for=\"toastuiAltTextInput\">", "</label>\n <input\n id=\"toastuiAltTextInput\"\n type=\"text\"\n ref=", "\n />\n <div class=\"", "\">\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n </div>\n </div>\n "])), i18n.get('Insert image'), Tabs, this.tabs, activeTab, this.toggleTab, activeTab === 'url' ? 'block' : 'none', i18n.get('Image URL'), function (el) { return (_this.refs.url = el); }, activeTab === 'file' ? 'block' : 'none', i18n.get('Select image file'), cls('file-name'), file ? ' has-file' : fileNameElClassName, this.showFileSelectBox, this.preventSelectStart, file ? file.name : i18n.get('No file'), cls('file-select-button'), this.showFileSelectBox, i18n.get('Choose a file'), this.changeFile, function (el) { return (_this.refs.file = el); }, i18n.get('Description'), function (el) { return (_this.refs.altText = el); }, cls('button-container'), cls('close-button'), this.props.hidePopup, i18n.get('Cancel'), cls('ok-button'), this.execCommand, i18n.get('OK'));
|
|
23306
25779
|
};
|
|
23307
25780
|
return ImagePopupBody;
|
|
23308
25781
|
}(Component));
|
|
@@ -23367,7 +25840,7 @@ var LinkPopupBody = /** @class */ (function (_super) {
|
|
|
23367
25840
|
};
|
|
23368
25841
|
LinkPopupBody.prototype.render = function () {
|
|
23369
25842
|
var _this = this;
|
|
23370
|
-
return template(linkPopupBody_templateObject_1 || (linkPopupBody_templateObject_1 = __makeTemplateObject(["\n <div>\n <label for=\"toastuiLinkUrlInput\">", "</label>\n <input\n id=\"toastuiLinkUrlInput\"\n type=\"text\"\n ref=", "\n />\n <label for=\"toastuiLinkTextInput\">", "</label>\n <input\n id=\"toastuiLinkTextInput\"\n type=\"text\"\n ref=", "\n />\n <div class=\"", "\">\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n </div>\n </div>\n "], ["\n <div>\n <label for=\"toastuiLinkUrlInput\">", "</label>\n <input\n id=\"toastuiLinkUrlInput\"\n type=\"text\"\n ref=", "\n />\n <label for=\"toastuiLinkTextInput\">", "</label>\n <input\n id=\"toastuiLinkTextInput\"\n type=\"text\"\n ref=", "\n />\n <div class=\"", "\">\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n </div>\n </div>\n "])), i18n.get('URL'), function (el) { return (_this.refs.url = el); }, i18n.get('Link text'), function (el) { return (_this.refs.text = el); }, cls('button-container'), cls('close-button'), this.props.hidePopup, i18n.get('Cancel'), cls('ok-button'), this.execCommand, i18n.get('OK'));
|
|
25843
|
+
return template(linkPopupBody_templateObject_1 || (linkPopupBody_templateObject_1 = __makeTemplateObject(["\n <div aria-label=\"", "\">\n <label for=\"toastuiLinkUrlInput\">", "</label>\n <input\n id=\"toastuiLinkUrlInput\"\n type=\"text\"\n ref=", "\n />\n <label for=\"toastuiLinkTextInput\">", "</label>\n <input\n id=\"toastuiLinkTextInput\"\n type=\"text\"\n ref=", "\n />\n <div class=\"", "\">\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n </div>\n </div>\n "], ["\n <div aria-label=\"", "\">\n <label for=\"toastuiLinkUrlInput\">", "</label>\n <input\n id=\"toastuiLinkUrlInput\"\n type=\"text\"\n ref=", "\n />\n <label for=\"toastuiLinkTextInput\">", "</label>\n <input\n id=\"toastuiLinkTextInput\"\n type=\"text\"\n ref=", "\n />\n <div class=\"", "\">\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n <button type=\"button\" class=\"", "\" onClick=", ">\n ", "\n </button>\n </div>\n </div>\n "])), i18n.get('Insert link'), i18n.get('URL'), function (el) { return (_this.refs.url = el); }, i18n.get('Link text'), function (el) { return (_this.refs.text = el); }, cls('button-container'), cls('close-button'), this.props.hidePopup, i18n.get('Cancel'), cls('ok-button'), this.execCommand, i18n.get('OK'));
|
|
23371
25844
|
};
|
|
23372
25845
|
return LinkPopupBody;
|
|
23373
25846
|
}(Component));
|
|
@@ -23379,6 +25852,7 @@ var linkPopupBody_templateObject_1;
|
|
|
23379
25852
|
|
|
23380
25853
|
|
|
23381
25854
|
|
|
25855
|
+
|
|
23382
25856
|
var CELL_WIDTH = 20;
|
|
23383
25857
|
var CELL_HEIGHT = 20;
|
|
23384
25858
|
var MIN_ROW_INDEX = 5;
|
|
@@ -23451,17 +25925,17 @@ var TablePopupBody = /** @class */ (function (_super) {
|
|
|
23451
25925
|
range.colIdx = Math.min(Math.max(range.colIdx, MIN_COL_SELECTION_INDEX), MAX_COL_INDEX);
|
|
23452
25926
|
return range;
|
|
23453
25927
|
};
|
|
23454
|
-
TablePopupBody.prototype.mounted = function () {
|
|
23455
|
-
var _a = this.refs.tableEl.getBoundingClientRect(), left = _a.left, top = _a.top;
|
|
23456
|
-
this.offsetRect = {
|
|
23457
|
-
left: window.pageXOffset + left,
|
|
23458
|
-
top: window.pageYOffset + top,
|
|
23459
|
-
};
|
|
23460
|
-
};
|
|
23461
25928
|
TablePopupBody.prototype.updated = function () {
|
|
23462
25929
|
if (!this.props.show) {
|
|
23463
25930
|
this.setState({ colIdx: -1, rowIdx: -1 });
|
|
23464
25931
|
}
|
|
25932
|
+
else if (this.state.colIdx === -1 && this.state.rowIdx === -1) {
|
|
25933
|
+
var _a = this.refs.tableEl.getBoundingClientRect(), left = _a.left, top = _a.top;
|
|
25934
|
+
this.offsetRect = {
|
|
25935
|
+
left: window.pageXOffset + left,
|
|
25936
|
+
top: window.pageYOffset + top,
|
|
25937
|
+
};
|
|
25938
|
+
}
|
|
23465
25939
|
};
|
|
23466
25940
|
TablePopupBody.prototype.createTableArea = function (tableRange) {
|
|
23467
25941
|
var colIdx = tableRange.colIdx, rowIdx = tableRange.rowIdx;
|
|
@@ -23480,7 +25954,7 @@ var TablePopupBody = /** @class */ (function (_super) {
|
|
|
23480
25954
|
var _this = this;
|
|
23481
25955
|
var tableRange = this.getTableRange();
|
|
23482
25956
|
var selectionAreaBound = this.getSelectionAreaBound();
|
|
23483
|
-
return template(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n <div>\n <div\n class=\"", "\"\n ref=", "\n onMousemove=", "\n onClick=", "\n >\n ", "\n <div class=\"", "\" style=", "></div>\n </div>\n <p class=\"", "\">", "</p>\n </div>\n "], ["\n <div>\n <div\n class=\"", "\"\n ref=", "\n onMousemove=", "\n onClick=", "\n >\n ", "\n <div class=\"", "\" style=", "></div>\n </div>\n <p class=\"", "\">", "</p>\n </div>\n "])), cls('table-selection'), function (el) { return (_this.refs.tableEl = el); }, this.extendSelectionRange, this.execCommand, this.createTableArea(tableRange), cls('table-selection-layer'), selectionAreaBound, cls('table-description'), this.getDescription());
|
|
25957
|
+
return template(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n <div aria-label=\"", "\">\n <div\n class=\"", "\"\n ref=", "\n onMousemove=", "\n onClick=", "\n >\n ", "\n <div class=\"", "\" style=", "></div>\n </div>\n <p class=\"", "\">", "</p>\n </div>\n "], ["\n <div aria-label=\"", "\">\n <div\n class=\"", "\"\n ref=", "\n onMousemove=", "\n onClick=", "\n >\n ", "\n <div class=\"", "\" style=", "></div>\n </div>\n <p class=\"", "\">", "</p>\n </div>\n "])), i18n.get('Insert table'), cls('table-selection'), function (el) { return (_this.refs.tableEl = el); }, this.extendSelectionRange, this.execCommand, this.createTableArea(tableRange), cls('table-selection-layer'), selectionAreaBound, cls('table-description'), this.getDescription());
|
|
23484
25958
|
};
|
|
23485
25959
|
return TablePopupBody;
|
|
23486
25960
|
}(Component));
|
|
@@ -23493,10 +25967,8 @@ var tablePopupBody_templateObject_1, tablePopupBody_templateObject_2, templateOb
|
|
|
23493
25967
|
|
|
23494
25968
|
var CustomPopupBody = /** @class */ (function (_super) {
|
|
23495
25969
|
__extends(CustomPopupBody, _super);
|
|
23496
|
-
function CustomPopupBody(
|
|
23497
|
-
|
|
23498
|
-
props.eventEmitter.listen('closePopup', _this.props.hidePopup);
|
|
23499
|
-
return _this;
|
|
25970
|
+
function CustomPopupBody() {
|
|
25971
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23500
25972
|
}
|
|
23501
25973
|
CustomPopupBody.prototype.mounted = function () {
|
|
23502
25974
|
// append the custom popup body element
|
|
@@ -23712,7 +26184,6 @@ function createDefaultToolbarItemInfo(type) {
|
|
|
23712
26184
|
}
|
|
23713
26185
|
return info;
|
|
23714
26186
|
}
|
|
23715
|
-
// eslint-disable-next-line consistent-return
|
|
23716
26187
|
function createPopupInfo(type, payload) {
|
|
23717
26188
|
var el = payload.el, pos = payload.pos, popup = payload.popup, initialValues = payload.initialValues;
|
|
23718
26189
|
switch (type) {
|
|
@@ -23784,6 +26255,8 @@ var toolbarItemFactory_templateObject_1, toolbarItemFactory_templateObject_2, to
|
|
|
23784
26255
|
|
|
23785
26256
|
|
|
23786
26257
|
|
|
26258
|
+
|
|
26259
|
+
var MARGIN_FROM_RIGHT_SIDE = 20;
|
|
23787
26260
|
var Popup = /** @class */ (function (_super) {
|
|
23788
26261
|
__extends(Popup, _super);
|
|
23789
26262
|
function Popup() {
|
|
@@ -23798,19 +26271,32 @@ var Popup = /** @class */ (function (_super) {
|
|
|
23798
26271
|
}
|
|
23799
26272
|
Popup.prototype.mounted = function () {
|
|
23800
26273
|
document.addEventListener('mousedown', this.handleMousedown);
|
|
26274
|
+
this.props.eventEmitter.listen('closePopup', this.props.hidePopup);
|
|
23801
26275
|
};
|
|
23802
26276
|
Popup.prototype.beforeDestroy = function () {
|
|
23803
26277
|
document.removeEventListener('mousedown', this.handleMousedown);
|
|
23804
26278
|
};
|
|
26279
|
+
Popup.prototype.updated = function (prevProps) {
|
|
26280
|
+
var _a = this.props, show = _a.show, info = _a.info;
|
|
26281
|
+
if (show && info.pos && prevProps.show !== show) {
|
|
26282
|
+
var popupPos = __assign({}, info.pos);
|
|
26283
|
+
var offsetWidth = this.refs.el.offsetWidth;
|
|
26284
|
+
var toolbarEl = closest(this.refs.el, "." + cls('toolbar'));
|
|
26285
|
+
var toolbarOffsetWidth = toolbarEl.offsetWidth;
|
|
26286
|
+
if (popupPos.left + offsetWidth >= toolbarOffsetWidth) {
|
|
26287
|
+
popupPos.left = toolbarOffsetWidth - offsetWidth - MARGIN_FROM_RIGHT_SIDE;
|
|
26288
|
+
}
|
|
26289
|
+
if (!shallowEqual(this.state.popupPos, popupPos)) {
|
|
26290
|
+
this.setState({ popupPos: popupPos });
|
|
26291
|
+
}
|
|
26292
|
+
}
|
|
26293
|
+
};
|
|
23805
26294
|
Popup.prototype.render = function () {
|
|
26295
|
+
var _this = this;
|
|
23806
26296
|
var _a = this.props, info = _a.info, show = _a.show, hidePopup = _a.hidePopup, eventEmitter = _a.eventEmitter, execCommand = _a.execCommand;
|
|
23807
|
-
var _b = info || {}, _c = _b.className, className = _c === void 0 ? '' : _c, style = _b.style, render = _b.render,
|
|
23808
|
-
var popupStyle = __assign({ display: show ? 'block' : 'none' }, style);
|
|
23809
|
-
|
|
23810
|
-
popupStyle.left = pos.left;
|
|
23811
|
-
popupStyle.top = pos.top;
|
|
23812
|
-
}
|
|
23813
|
-
return template(popup_templateObject_1 || (popup_templateObject_1 = __makeTemplateObject(["\n <div class=\"", " ", "\" style=", ">\n <div class=\"", "\">\n ", "\n </div>\n </div>\n "], ["\n <div class=\"", " ", "\" style=", ">\n <div class=\"", "\">\n ", "\n </div>\n </div>\n "])), cls('popup'), className, popupStyle, cls('popup-body'), render && render({ eventEmitter: eventEmitter, show: show, hidePopup: hidePopup, execCommand: execCommand, initialValues: initialValues }));
|
|
26297
|
+
var _b = info || {}, _c = _b.className, className = _c === void 0 ? '' : _c, style = _b.style, render = _b.render, _d = _b.initialValues, initialValues = _d === void 0 ? {} : _d;
|
|
26298
|
+
var popupStyle = __assign(__assign({ display: show ? 'block' : 'none' }, style), this.state.popupPos);
|
|
26299
|
+
return template(popup_templateObject_1 || (popup_templateObject_1 = __makeTemplateObject(["\n <div\n class=\"", " ", "\"\n style=", "\n ref=", "\n aria-role=\"dialog\"\n >\n <div class=\"", "\">\n ", "\n </div>\n </div>\n "], ["\n <div\n class=\"", " ", "\"\n style=", "\n ref=", "\n aria-role=\"dialog\"\n >\n <div class=\"", "\">\n ", "\n </div>\n </div>\n "])), cls('popup'), className, popupStyle, function (el) { return (_this.refs.el = el); }, cls('popup-body'), render && render({ eventEmitter: eventEmitter, show: show, hidePopup: hidePopup, execCommand: execCommand, initialValues: initialValues }));
|
|
23814
26300
|
};
|
|
23815
26301
|
return Popup;
|
|
23816
26302
|
}(Component));
|
|
@@ -23924,7 +26410,7 @@ var ToolbarButtonComp = /** @class */ (function (_super) {
|
|
|
23924
26410
|
var _a = this.props, hideTooltip = _a.hideTooltip, disabled = _a.disabled, item = _a.item, active = _a.active;
|
|
23925
26411
|
var style = __assign({ display: item.hidden ? 'none' : null }, item.style);
|
|
23926
26412
|
var classNames = "" + (item.className || '') + (active ? ' active' : '');
|
|
23927
|
-
return template(toolbarButton_templateObject_1 || (toolbarButton_templateObject_1 = __makeTemplateObject(["\n <button\n ref=", "\n type=\"button\"\n style=", "\n class=", "\n onClick=", "\n onMouseover=", "\n onMouseout=", "\n disabled=", "\n >\n ", "\n </button>\n "], ["\n <button\n ref=", "\n type=\"button\"\n style=", "\n class=", "\n onClick=", "\n onMouseover=", "\n onMouseout=", "\n disabled=", "\n >\n ", "\n </button>\n "])), function (el) { return (_this.refs.el = el); }, style, classNames, this.execCommand, this.showTooltip, hideTooltip, !!disabled, item.text || '');
|
|
26413
|
+
return template(toolbarButton_templateObject_1 || (toolbarButton_templateObject_1 = __makeTemplateObject(["\n <button\n ref=", "\n type=\"button\"\n style=", "\n class=", "\n onClick=", "\n onMouseover=", "\n onMouseout=", "\n disabled=", "\n aria-label=", "\n >\n ", "\n </button>\n "], ["\n <button\n ref=", "\n type=\"button\"\n style=", "\n class=", "\n onClick=", "\n onMouseover=", "\n onMouseout=", "\n disabled=", "\n aria-label=", "\n >\n ", "\n </button>\n "])), function (el) { return (_this.refs.el = el); }, style, classNames, this.execCommand, this.showTooltip, hideTooltip, !!disabled, item.text || item.tooltip || '', item.text || '');
|
|
23928
26414
|
};
|
|
23929
26415
|
return ToolbarButtonComp;
|
|
23930
26416
|
}(Component));
|
|
@@ -24092,8 +26578,9 @@ var dropdownToolbarButton_templateObject_1, dropdownToolbarButton_templateObject
|
|
|
24092
26578
|
|
|
24093
26579
|
|
|
24094
26580
|
|
|
24095
|
-
|
|
24096
|
-
|
|
26581
|
+
|
|
26582
|
+
|
|
26583
|
+
var INLINE_PADDING = 50;
|
|
24097
26584
|
var Toolbar = /** @class */ (function (_super) {
|
|
24098
26585
|
__extends(Toolbar, _super);
|
|
24099
26586
|
function Toolbar(props) {
|
|
@@ -24151,6 +26638,7 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
24151
26638
|
activeTab: 'write',
|
|
24152
26639
|
};
|
|
24153
26640
|
_this.tooltipRef = { current: null };
|
|
26641
|
+
_this.resizeObserver = new ResizeObserver_es(function () { return _this.handleResize(); });
|
|
24154
26642
|
_this.addEvent();
|
|
24155
26643
|
return _this;
|
|
24156
26644
|
}
|
|
@@ -24184,9 +26672,13 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
24184
26672
|
};
|
|
24185
26673
|
Toolbar.prototype.addEvent = function () {
|
|
24186
26674
|
var _this = this;
|
|
24187
|
-
this.props.eventEmitter
|
|
24188
|
-
this.handleResize = throttle_default()(function () {
|
|
24189
|
-
|
|
26675
|
+
var eventEmitter = this.props.eventEmitter;
|
|
26676
|
+
this.handleResize = throttle_default()(function () {
|
|
26677
|
+
// reset toolbar items to re-layout toolbar items with each clientWidth
|
|
26678
|
+
_this.setState({ items: _this.initialItems, dropdownItems: [] });
|
|
26679
|
+
_this.setState(_this.classifyToolbarItems());
|
|
26680
|
+
}, 200);
|
|
26681
|
+
eventEmitter.listen('openPopup', this.openPopup);
|
|
24190
26682
|
};
|
|
24191
26683
|
Toolbar.prototype.appendTooltipToRoot = function () {
|
|
24192
26684
|
var tooltip = "<div class=\"" + cls('tooltip') + "\" style=\"display:none\">\n <div class=\"arrow\"></div>\n <span class=\"text\"></span>\n </div>";
|
|
@@ -24195,6 +26687,23 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
24195
26687
|
Toolbar.prototype.hiddenScrollSync = function () {
|
|
24196
26688
|
return this.props.editorType === 'wysiwyg' || this.props.previewStyle === 'tab';
|
|
24197
26689
|
};
|
|
26690
|
+
Toolbar.prototype.movePrevItemToDropdownToolbar = function (itemIndex, items, group, dropdownGroup) {
|
|
26691
|
+
var moveItem = function (targetGroup) {
|
|
26692
|
+
var item = targetGroup.pop();
|
|
26693
|
+
if (item) {
|
|
26694
|
+
dropdownGroup.push(item);
|
|
26695
|
+
}
|
|
26696
|
+
};
|
|
26697
|
+
if (itemIndex > 1) {
|
|
26698
|
+
moveItem(group);
|
|
26699
|
+
}
|
|
26700
|
+
else {
|
|
26701
|
+
var prevGroup = last(items);
|
|
26702
|
+
if (prevGroup) {
|
|
26703
|
+
moveItem(prevGroup);
|
|
26704
|
+
}
|
|
26705
|
+
}
|
|
26706
|
+
};
|
|
24198
26707
|
Toolbar.prototype.classifyToolbarItems = function () {
|
|
24199
26708
|
var _this = this;
|
|
24200
26709
|
var totalWidth = 0;
|
|
@@ -24203,13 +26712,25 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
24203
26712
|
var dividerWidth = divider ? getOuterWidth(divider) : 0;
|
|
24204
26713
|
var items = [];
|
|
24205
26714
|
var dropdownItems = [];
|
|
24206
|
-
|
|
26715
|
+
var moved = false;
|
|
26716
|
+
this.initialItems.forEach(function (initialGroup, groupIndex) {
|
|
24207
26717
|
var group = [];
|
|
24208
26718
|
var dropdownGroup = [];
|
|
24209
|
-
initialGroup.forEach(function (item) {
|
|
24210
|
-
|
|
24211
|
-
|
|
24212
|
-
|
|
26719
|
+
initialGroup.forEach(function (item, itemIndex) {
|
|
26720
|
+
if (!item.hidden) {
|
|
26721
|
+
totalWidth += _this.itemWidthMap[item.name];
|
|
26722
|
+
if (totalWidth > clientWidth - INLINE_PADDING) {
|
|
26723
|
+
// should move the prev item to dropdown toolbar for placing the more button
|
|
26724
|
+
if (!moved) {
|
|
26725
|
+
_this.movePrevItemToDropdownToolbar(itemIndex, items, group, dropdownGroup);
|
|
26726
|
+
moved = true;
|
|
26727
|
+
}
|
|
26728
|
+
dropdownGroup.push(item);
|
|
26729
|
+
}
|
|
26730
|
+
else {
|
|
26731
|
+
group.push(item);
|
|
26732
|
+
}
|
|
26733
|
+
}
|
|
24213
26734
|
});
|
|
24214
26735
|
if (group.length) {
|
|
24215
26736
|
setGroupState(group);
|
|
@@ -24220,7 +26741,7 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
24220
26741
|
dropdownItems.push(dropdownGroup);
|
|
24221
26742
|
}
|
|
24222
26743
|
// add divider width
|
|
24223
|
-
if (
|
|
26744
|
+
if (groupIndex < _this.state.items.length - 1) {
|
|
24224
26745
|
totalWidth += dividerWidth;
|
|
24225
26746
|
}
|
|
24226
26747
|
});
|
|
@@ -24233,6 +26754,7 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
24233
26754
|
// classify toolbar and dropdown toolbar after DOM has been rendered
|
|
24234
26755
|
this.setState(this.classifyToolbarItems());
|
|
24235
26756
|
this.appendTooltipToRoot();
|
|
26757
|
+
this.resizeObserver.observe(this.refs.el);
|
|
24236
26758
|
};
|
|
24237
26759
|
Toolbar.prototype.updated = function (prevProps) {
|
|
24238
26760
|
var _a = this.props, editorType = _a.editorType, previewStyle = _a.previewStyle, eventEmitter = _a.eventEmitter;
|
|
@@ -24251,6 +26773,7 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
24251
26773
|
};
|
|
24252
26774
|
Toolbar.prototype.beforeDestroy = function () {
|
|
24253
26775
|
window.removeEventListener('resize', this.handleResize);
|
|
26776
|
+
this.resizeObserver.disconnect();
|
|
24254
26777
|
removeNode(this.tooltipRef.current);
|
|
24255
26778
|
};
|
|
24256
26779
|
Toolbar.prototype.render = function () {
|
|
@@ -24327,7 +26850,7 @@ var ContextMenu = /** @class */ (function (_super) {
|
|
|
24327
26850
|
_this.setState({ pos: null });
|
|
24328
26851
|
}
|
|
24329
26852
|
};
|
|
24330
|
-
menuItem.push(template(contextMenu_templateObject_1 || (contextMenu_templateObject_1 = __makeTemplateObject(["\n <li
|
|
26853
|
+
menuItem.push(template(contextMenu_templateObject_1 || (contextMenu_templateObject_1 = __makeTemplateObject(["\n <li\n onClick=", "\n class=\"menu-item", "\"\n aria-role=\"menuitem\"\n >\n <span class=\"", "\">", "</span>\n </li>\n "], ["\n <li\n onClick=", "\n class=\"menu-item", "\"\n aria-role=\"menuitem\"\n >\n <span class=\"", "\">", "</span>\n </li>\n "])), handleClick, disabled ? ' disabled' : '', className, label));
|
|
24331
26854
|
});
|
|
24332
26855
|
acc.push(template(contextMenu_templateObject_2 || (contextMenu_templateObject_2 = __makeTemplateObject(["<ul class=\"menu-group\">\n ", "\n </ul>"], ["<ul class=\"menu-group\">\n ", "\n </ul>"])), menuItem));
|
|
24333
26856
|
return acc;
|
|
@@ -24336,7 +26859,7 @@ var ContextMenu = /** @class */ (function (_super) {
|
|
|
24336
26859
|
};
|
|
24337
26860
|
ContextMenu.prototype.render = function () {
|
|
24338
26861
|
var style = __assign({ display: this.state.pos ? 'block' : 'none' }, this.state.pos);
|
|
24339
|
-
return template(contextMenu_templateObject_3 || (contextMenu_templateObject_3 = __makeTemplateObject(["<div class=\"", "\" style=", ">\n ", "\n </div>"], ["<div class=\"", "\" style=", ">\n ", "\n </div>"])), cls('context-menu'), style, this.getMenuGroupElements());
|
|
26862
|
+
return template(contextMenu_templateObject_3 || (contextMenu_templateObject_3 = __makeTemplateObject(["<div class=\"", "\" style=", " aria-role=\"menu\">\n ", "\n </div>"], ["<div class=\"", "\" style=", " aria-role=\"menu\">\n ", "\n </div>"])), cls('context-menu'), style, this.getMenuGroupElements());
|
|
24340
26863
|
};
|
|
24341
26864
|
return ContextMenu;
|
|
24342
26865
|
}(Component));
|
|
@@ -24400,8 +26923,8 @@ var Layout = /** @class */ (function (_super) {
|
|
|
24400
26923
|
var editorTypeClassName = cls(editorType === 'markdown' ? 'md-mode' : 'ww-mode');
|
|
24401
26924
|
var previewClassName = cls('md') + "-" + previewStyle + "-style";
|
|
24402
26925
|
var themeClassName = cls([theme !== 'light', theme + " "]);
|
|
24403
|
-
return template(layout_templateObject_2 || (layout_templateObject_2 = __makeTemplateObject(["\n <div\n class=\"", "", "", "\"\n ref=", "\n >\n <", "\n ref=", "\n eventEmitter=", "\n previewStyle=", "\n toolbarItems=", "\n editorType=", "\n />\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div\n class=\"", " ", "\"\n
|
|
24404
|
-
"\n <", " eventEmitter=", " />\n </div>\n "])), themeClassName, cls('defaultUI'), displayClassName, function (el) { return (_this.refs.el = el); }, Toolbar, function (toolbar) { return (_this.toolbar = toolbar); }, eventEmitter, previewStyle, toolbarItems, editorType, cls('main'), editorTypeClassName, function (el) { return (_this.refs.editorSection = el); }, cls('md-container'), previewClassName, function (el) { return (_this.refs.mdContainer = el); }, cls('md-splitter'), cls('ww-container'), function (el) { return (_this.refs.wwContainer = el); }, !hideModeSwitch && template(layout_templateObject_1 || (layout_templateObject_1 = __makeTemplateObject(["<", " eventEmitter=", " editorType=", " />"], ["<", " eventEmitter=", " editorType=", " />"])), Switch, eventEmitter, editorType), ContextMenu, eventEmitter);
|
|
26926
|
+
return template(layout_templateObject_2 || (layout_templateObject_2 = __makeTemplateObject(["\n <div\n class=\"", "", "", "\"\n ref=", "\n >\n <", "\n ref=", "\n eventEmitter=", "\n previewStyle=", "\n toolbarItems=", "\n editorType=", "\n />\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\">\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\"></div>\n </div>\n <div\n class=\"", "\"\n ref=", "\n />\n </div>\n </div>\n ", "\n <", " eventEmitter=", " />\n </div>\n "], ["\n <div\n class=\"", "", "", "\"\n ref=", "\n >\n <", "\n ref=", "\n eventEmitter=", "\n previewStyle=", "\n toolbarItems=", "\n editorType=", "\n />\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\">\n <div\n class=\"", " ", "\"\n ref=", "\n >\n <div class=\"", "\"></div>\n </div>\n <div\n class=\"", "\"\n ref=", "\n />\n </div>\n </div>\n ",
|
|
26927
|
+
"\n <", " eventEmitter=", " />\n </div>\n "])), themeClassName, cls('defaultUI'), displayClassName, function (el) { return (_this.refs.el = el); }, Toolbar, function (toolbar) { return (_this.toolbar = toolbar); }, eventEmitter, previewStyle, toolbarItems, editorType, cls('main'), editorTypeClassName, function (el) { return (_this.refs.editorSection = el); }, cls('main-container'), cls('md-container'), previewClassName, function (el) { return (_this.refs.mdContainer = el); }, cls('md-splitter'), cls('ww-container'), function (el) { return (_this.refs.wwContainer = el); }, !hideModeSwitch && template(layout_templateObject_1 || (layout_templateObject_1 = __makeTemplateObject(["<", " eventEmitter=", " editorType=", " />"], ["<", " eventEmitter=", " editorType=", " />"])), Switch, eventEmitter, editorType), ContextMenu, eventEmitter);
|
|
24405
26928
|
};
|
|
24406
26929
|
Layout.prototype.addEvent = function () {
|
|
24407
26930
|
var eventEmitter = this.props.eventEmitter;
|