@toast-ui/editor 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/esm/i18n/ar.js +1 -1
- package/dist/esm/i18n/cs-cz.js +1 -1
- package/dist/esm/i18n/de-de.js +1 -1
- package/dist/esm/i18n/en-us.js +1 -1
- package/dist/esm/i18n/es-es.js +1 -1
- package/dist/esm/i18n/fi-fi.js +1 -1
- package/dist/esm/i18n/fr-fr.js +1 -1
- package/dist/esm/i18n/gl-es.js +1 -1
- package/dist/esm/i18n/hr-hr.js +1 -1
- package/dist/esm/i18n/i18n.js +9 -5
- package/dist/esm/i18n/it-it.js +1 -1
- package/dist/esm/i18n/ja-jp.js +1 -1
- package/dist/esm/i18n/ko-kr.js +1 -1
- package/dist/esm/i18n/nb-no.js +1 -1
- package/dist/esm/i18n/nl-nl.js +1 -1
- package/dist/esm/i18n/pl-pl.js +1 -1
- package/dist/esm/i18n/pt-br.js +1 -1
- package/dist/esm/i18n/ru-ru.js +1 -1
- package/dist/esm/i18n/sv-se.js +1 -1
- package/dist/esm/i18n/tr-tr.js +1 -1
- package/dist/esm/i18n/uk-ua.js +1 -1
- package/dist/esm/i18n/zh-cn.js +1 -1
- package/dist/esm/i18n/zh-tw.js +1 -1
- package/dist/esm/index.js +1604 -229
- package/dist/esm/indexViewer.js +1503 -161
- package/dist/i18n/ar.js +1 -1
- package/dist/i18n/cs-cz.js +1 -1
- package/dist/i18n/de-de.js +1 -1
- package/dist/i18n/es-es.js +1 -1
- package/dist/i18n/fi-fi.js +1 -1
- package/dist/i18n/fr-fr.js +1 -1
- package/dist/i18n/gl-es.js +1 -1
- package/dist/i18n/hr-hr.js +1 -1
- package/dist/i18n/it-it.js +1 -1
- package/dist/i18n/ja-jp.js +1 -1
- package/dist/i18n/ko-kr.js +1 -1
- package/dist/i18n/nb-no.js +1 -1
- package/dist/i18n/nl-nl.js +1 -1
- package/dist/i18n/pl-pl.js +1 -1
- package/dist/i18n/pt-br.js +1 -1
- package/dist/i18n/ru-ru.js +1 -1
- package/dist/i18n/sv-se.js +1 -1
- package/dist/i18n/tr-tr.js +1 -1
- package/dist/i18n/uk-ua.js +1 -1
- package/dist/i18n/zh-cn.js +1 -1
- package/dist/i18n/zh-tw.js +1 -1
- package/dist/toastui-editor-only.css +1 -1
- package/dist/toastui-editor-viewer.css +1 -1
- package/dist/toastui-editor-viewer.js +1572 -168
- package/dist/toastui-editor.css +1 -1
- package/dist/toastui-editor.js +1668 -219
- package/package.json +5 -1
- package/types/editor.d.ts +1 -0
- package/types/index.d.ts +4 -3
- package/types/toastui-editor-viewer.d.ts +39 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @toast-ui/editor
|
|
3
|
-
* @version 3.1.
|
|
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
|
*/
|
|
@@ -56,10 +56,14 @@ var __assign$1 = function() {
|
|
|
56
56
|
return __assign$1.apply(this, arguments);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
function __spreadArray$1(to, from) {
|
|
60
|
-
for (var i = 0,
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
function __spreadArray$1(to, from, pack) {
|
|
60
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
|
+
if (ar || !(i in from)) {
|
|
62
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
63
|
+
ar[i] = from[i];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
function __makeTemplateObject(cooked, raw) {
|
|
@@ -84,12 +88,16 @@ function __makeTemplateObject(cooked, raw) {
|
|
|
84
88
|
* @param {Object} [context] Context(this) of callback function
|
|
85
89
|
* @memberof module:collection
|
|
86
90
|
* @example
|
|
87
|
-
*
|
|
91
|
+
* // ES6
|
|
92
|
+
* import forEachOwnProperties from 'tui-code-snippet/collection/forEachOwnProperties';
|
|
93
|
+
*
|
|
94
|
+
* // CommonJS
|
|
95
|
+
* const forEachOwnProperties = require('tui-code-snippet/collection/forEachOwnProperties');
|
|
88
96
|
*
|
|
89
|
-
*
|
|
97
|
+
* let sum = 0;
|
|
90
98
|
*
|
|
91
99
|
* forEachOwnProperties({a:1,b:2,c:3}, function(value){
|
|
92
|
-
*
|
|
100
|
+
* sum += value;
|
|
93
101
|
* });
|
|
94
102
|
* alert(sum); // 6
|
|
95
103
|
*/
|
|
@@ -197,12 +205,16 @@ var isArray_1 = isArray$3;
|
|
|
197
205
|
* @param {Object} [context] Context(this) of callback function
|
|
198
206
|
* @memberof module:collection
|
|
199
207
|
* @example
|
|
200
|
-
*
|
|
208
|
+
* // ES6
|
|
209
|
+
* import forEachArray from 'tui-code-snippet/collection/forEachArray';
|
|
210
|
+
*
|
|
211
|
+
* // CommonJS
|
|
212
|
+
* const forEachArray = require('tui-code-snippet/collection/forEachArray');
|
|
201
213
|
*
|
|
202
|
-
*
|
|
214
|
+
* let sum = 0;
|
|
203
215
|
*
|
|
204
216
|
* forEachArray([1,2,3], function(value){
|
|
205
|
-
*
|
|
217
|
+
* sum += value;
|
|
206
218
|
* });
|
|
207
219
|
* alert(sum); // 6
|
|
208
220
|
*/
|
|
@@ -247,19 +259,23 @@ var forEachOwnProperties$1 = forEachOwnProperties_1;
|
|
|
247
259
|
* @param {Object} [context] Context(this) of callback function
|
|
248
260
|
* @memberof module:collection
|
|
249
261
|
* @example
|
|
250
|
-
*
|
|
262
|
+
* // ES6
|
|
263
|
+
* import forEach from 'tui-code-snippet/collection/forEach';
|
|
264
|
+
*
|
|
265
|
+
* // CommonJS
|
|
266
|
+
* const forEach = require('tui-code-snippet/collection/forEach');
|
|
251
267
|
*
|
|
252
|
-
*
|
|
268
|
+
* let sum = 0;
|
|
253
269
|
*
|
|
254
270
|
* forEach([1,2,3], function(value){
|
|
255
|
-
*
|
|
271
|
+
* sum += value;
|
|
256
272
|
* });
|
|
257
273
|
* alert(sum); // 6
|
|
258
274
|
*
|
|
259
275
|
* // In case of Array-like object
|
|
260
|
-
*
|
|
276
|
+
* const array = Array.prototype.slice.call(arrayLike); // change to array
|
|
261
277
|
* forEach(array, function(value){
|
|
262
|
-
*
|
|
278
|
+
* sum += value;
|
|
263
279
|
* });
|
|
264
280
|
*/
|
|
265
281
|
function forEach$4(obj, iteratee, context) {
|
|
@@ -322,11 +338,15 @@ var isArray$1 = isArray_1;
|
|
|
322
338
|
* @returns {number} the First index at which a given element, or -1 if it is not present
|
|
323
339
|
* @memberof module:array
|
|
324
340
|
* @example
|
|
325
|
-
*
|
|
341
|
+
* // ES6
|
|
342
|
+
* import inArray from 'tui-code-snippet/array/inArray';
|
|
343
|
+
*
|
|
344
|
+
* // CommonJS
|
|
345
|
+
* const inArray = require('tui-code-snippet/array/inArray');
|
|
326
346
|
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
347
|
+
* const arr = ['one', 'two', 'three', 'four'];
|
|
348
|
+
* const idx1 = inArray('one', arr, 3); // -1
|
|
349
|
+
* const idx2 = inArray('one', arr); // 0
|
|
330
350
|
*/
|
|
331
351
|
function inArray$4(searchElement, array, startIndex) {
|
|
332
352
|
var i;
|
|
@@ -576,15 +596,19 @@ var forEachOwnProperties = forEachOwnProperties_1;
|
|
|
576
596
|
* @returns {HTMLElement}
|
|
577
597
|
* @memberof module:request
|
|
578
598
|
* @example
|
|
579
|
-
*
|
|
599
|
+
* // ES6
|
|
600
|
+
* import imagePing from 'tui-code-snippet/request/imagePing';
|
|
601
|
+
*
|
|
602
|
+
* // CommonJS
|
|
603
|
+
* const imagePing = require('tui-code-snippet/request/imagePing');
|
|
580
604
|
*
|
|
581
605
|
* imagePing('https://www.google-analytics.com/collect', {
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
606
|
+
* v: 1,
|
|
607
|
+
* t: 'event',
|
|
608
|
+
* tid: 'trackingid',
|
|
609
|
+
* cid: 'cid',
|
|
610
|
+
* dp: 'dp',
|
|
611
|
+
* dh: 'dh'
|
|
588
612
|
* });
|
|
589
613
|
*/
|
|
590
614
|
function imagePing$1(url, trackingInfo) {
|
|
@@ -1241,16 +1265,20 @@ var forEachArray = forEachArray_1;
|
|
|
1241
1265
|
* @returns {Array} Array
|
|
1242
1266
|
* @memberof module:collection
|
|
1243
1267
|
* @example
|
|
1244
|
-
*
|
|
1268
|
+
* // ES6
|
|
1269
|
+
* import toArray from 'tui-code-snippet/collection/toArray';
|
|
1270
|
+
*
|
|
1271
|
+
* // CommonJS
|
|
1272
|
+
* const toArray = require('tui-code-snippet/collection/toArray');
|
|
1245
1273
|
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1274
|
+
* const arrayLike = {
|
|
1275
|
+
* 0: 'one',
|
|
1276
|
+
* 1: 'two',
|
|
1277
|
+
* 2: 'three',
|
|
1278
|
+
* 3: 'four',
|
|
1279
|
+
* length: 4
|
|
1252
1280
|
* };
|
|
1253
|
-
*
|
|
1281
|
+
* const result = toArray(arrayLike);
|
|
1254
1282
|
*
|
|
1255
1283
|
* alert(result instanceof Array); // true
|
|
1256
1284
|
* alert(result); // one,two,three,four
|
|
@@ -1429,7 +1457,7 @@ var EditorBase = /** @class */ (function () {
|
|
|
1429
1457
|
var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
|
|
1430
1458
|
var rules = this.createInputRules();
|
|
1431
1459
|
var plugins = __spreadArray$1(__spreadArray$1([], this.keymaps), [
|
|
1432
|
-
keymap(__assign$1({ 'Mod-z': undo(), 'Shift-Mod-z': redo() }, baseKeymap)),
|
|
1460
|
+
keymap(__assign$1({ 'Mod-z': undo(), 'Shift-Mod-z': redo(), 'Shift-Enter': baseKeymap.Enter }, baseKeymap)),
|
|
1433
1461
|
history(),
|
|
1434
1462
|
placeholder(this.placeholder),
|
|
1435
1463
|
addWidget(this.eventEmitter),
|
|
@@ -1703,6 +1731,8 @@ var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE$1 + ")*\\s*/?>";
|
|
|
1703
1731
|
var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
|
|
1704
1732
|
var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
|
|
1705
1733
|
var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
|
|
1734
|
+
var reBR = /<br\s*\/*>/i;
|
|
1735
|
+
var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
|
|
1706
1736
|
|
|
1707
1737
|
function isPositionInBox(style, offsetX, offsetY) {
|
|
1708
1738
|
var left = parseInt(style.left, 10);
|
|
@@ -1835,22 +1865,6 @@ function getTotalOffset(el, root) {
|
|
|
1835
1865
|
}
|
|
1836
1866
|
return { offsetTop: offsetTop, offsetLeft: offsetLeft };
|
|
1837
1867
|
}
|
|
1838
|
-
function finalizeHtml(html, needHtmlText) {
|
|
1839
|
-
var result;
|
|
1840
|
-
if (needHtmlText) {
|
|
1841
|
-
result = html.innerHTML;
|
|
1842
|
-
}
|
|
1843
|
-
else {
|
|
1844
|
-
var frag = document.createDocumentFragment();
|
|
1845
|
-
var childNodes = toArray_1(html.childNodes);
|
|
1846
|
-
var length_1 = childNodes.length;
|
|
1847
|
-
for (var i = 0; i < length_1; i += 1) {
|
|
1848
|
-
frag.appendChild(childNodes[i]);
|
|
1849
|
-
}
|
|
1850
|
-
result = frag;
|
|
1851
|
-
}
|
|
1852
|
-
return result;
|
|
1853
|
-
}
|
|
1854
1868
|
function setAttributes(attributes, element) {
|
|
1855
1869
|
Object.keys(attributes).forEach(function (attrName) {
|
|
1856
1870
|
if (isNil(attributes[attrName])) {
|
|
@@ -1862,24 +1876,25 @@ function setAttributes(attributes, element) {
|
|
|
1862
1876
|
});
|
|
1863
1877
|
}
|
|
1864
1878
|
function replaceBRWithEmptyBlock(html) {
|
|
1865
|
-
|
|
1879
|
+
// remove br in paragraph to compatible with markdown
|
|
1880
|
+
var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
|
|
1866
1881
|
var reHTMLTag = new RegExp(HTML_TAG, 'ig');
|
|
1867
|
-
var htmlTagMatched =
|
|
1882
|
+
var htmlTagMatched = replacedHTML.match(reHTMLTag);
|
|
1868
1883
|
htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
|
|
1869
|
-
if (
|
|
1870
|
-
var alternativeTag =
|
|
1884
|
+
if (reBR.test(htmlTag)) {
|
|
1885
|
+
var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
|
|
1871
1886
|
if (index) {
|
|
1872
1887
|
var prevTag = htmlTagMatched[index - 1];
|
|
1873
1888
|
var openTagMatched = prevTag.match(OPEN_TAG);
|
|
1874
|
-
if (openTagMatched) {
|
|
1889
|
+
if (openTagMatched && !/br/i.test(openTagMatched[1])) {
|
|
1875
1890
|
var tagName = openTagMatched[1];
|
|
1876
1891
|
alternativeTag = "</" + tagName + "><" + tagName + ">";
|
|
1877
1892
|
}
|
|
1878
1893
|
}
|
|
1879
|
-
|
|
1894
|
+
replacedHTML = replacedHTML.replace(reBR, alternativeTag);
|
|
1880
1895
|
}
|
|
1881
1896
|
});
|
|
1882
|
-
return
|
|
1897
|
+
return replacedHTML;
|
|
1883
1898
|
}
|
|
1884
1899
|
|
|
1885
1900
|
function resolveSelectionPos(selection) {
|
|
@@ -4496,7 +4511,7 @@ var safeEvent = _safeEvent;
|
|
|
4496
4511
|
* @param {object} [context] context - context for handler method.
|
|
4497
4512
|
* @memberof module:domEvent
|
|
4498
4513
|
* @example
|
|
4499
|
-
*
|
|
4514
|
+
* const div = document.querySelector('div');
|
|
4500
4515
|
*
|
|
4501
4516
|
* // Bind one event to an element.
|
|
4502
4517
|
* on(div, 'click', toggle);
|
|
@@ -4513,10 +4528,10 @@ var safeEvent = _safeEvent;
|
|
|
4513
4528
|
* });
|
|
4514
4529
|
*
|
|
4515
4530
|
* // Set a context for handler method.
|
|
4516
|
-
*
|
|
4517
|
-
*
|
|
4531
|
+
* const name = 'global';
|
|
4532
|
+
* const repository = {name: 'CodeSnippet'};
|
|
4518
4533
|
* on(div, 'drag', function() {
|
|
4519
|
-
*
|
|
4534
|
+
* console.log(this.name);
|
|
4520
4535
|
* }, repository);
|
|
4521
4536
|
* // Result when you drag a div: "CodeSnippet"
|
|
4522
4537
|
*/
|
|
@@ -4633,10 +4648,14 @@ var __assign = function() {
|
|
|
4633
4648
|
return __assign.apply(this, arguments);
|
|
4634
4649
|
};
|
|
4635
4650
|
|
|
4636
|
-
function __spreadArray(to, from) {
|
|
4637
|
-
for (var i = 0,
|
|
4638
|
-
|
|
4639
|
-
|
|
4651
|
+
function __spreadArray(to, from, pack) {
|
|
4652
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4653
|
+
if (ar || !(i in from)) {
|
|
4654
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
4655
|
+
ar[i] = from[i];
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4658
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
4640
4659
|
}
|
|
4641
4660
|
|
|
4642
4661
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -9969,7 +9988,7 @@ function isCustomBlock(node) {
|
|
|
9969
9988
|
function isCustomInline(node) {
|
|
9970
9989
|
return node.type === 'customInline';
|
|
9971
9990
|
}
|
|
9972
|
-
function text(s, sourcepos) {
|
|
9991
|
+
function text$1(s, sourcepos) {
|
|
9973
9992
|
var node = createNode$1('text', sourcepos);
|
|
9974
9993
|
node.literal = s;
|
|
9975
9994
|
return node;
|
|
@@ -10145,17 +10164,17 @@ function convertExtAutoLinks(walker, autolinkParser) {
|
|
|
10145
10164
|
for (var _i = 0, linkInfos_1 = linkInfos; _i < linkInfos_1.length; _i++) {
|
|
10146
10165
|
var _b = linkInfos_1[_i], range = _b.range, url = _b.url, linkText = _b.text;
|
|
10147
10166
|
if (range[0] > lastIdx) {
|
|
10148
|
-
newNodes.push(text(literal.substring(lastIdx, range[0]), sourcepos(lastIdx, range[0] - 1)));
|
|
10167
|
+
newNodes.push(text$1(literal.substring(lastIdx, range[0]), sourcepos(lastIdx, range[0] - 1)));
|
|
10149
10168
|
}
|
|
10150
10169
|
var linkNode = createNode$1('link', sourcepos.apply(void 0, range));
|
|
10151
|
-
linkNode.appendChild(text(linkText, sourcepos.apply(void 0, range)));
|
|
10170
|
+
linkNode.appendChild(text$1(linkText, sourcepos.apply(void 0, range)));
|
|
10152
10171
|
linkNode.destination = url;
|
|
10153
10172
|
linkNode.extendedAutolink = true;
|
|
10154
10173
|
newNodes.push(linkNode);
|
|
10155
10174
|
lastIdx = range[1] + 1;
|
|
10156
10175
|
}
|
|
10157
10176
|
if (lastIdx < literal.length) {
|
|
10158
|
-
newNodes.push(text(literal.substring(lastIdx), sourcepos(lastIdx, literal.length - 1)));
|
|
10177
|
+
newNodes.push(text$1(literal.substring(lastIdx), sourcepos(lastIdx, literal.length - 1)));
|
|
10159
10178
|
}
|
|
10160
10179
|
for (var _c = 0, newNodes_1 = newNodes; _c < newNodes_1.length; _c++) {
|
|
10161
10180
|
var newNode = newNodes_1[_c];
|
|
@@ -10346,7 +10365,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
10346
10365
|
}
|
|
10347
10366
|
// If we got here, we didn't match a closing backtick sequence.
|
|
10348
10367
|
this.pos = afterOpenTicks;
|
|
10349
|
-
block.appendChild(text(ticks, this.sourcepos(startpos, this.pos - 1)));
|
|
10368
|
+
block.appendChild(text$1(ticks, this.sourcepos(startpos, this.pos - 1)));
|
|
10350
10369
|
return true;
|
|
10351
10370
|
};
|
|
10352
10371
|
// Parse a backslash-escaped special character, adding either the escaped
|
|
@@ -10365,11 +10384,11 @@ var InlineParser = /** @class */ (function () {
|
|
|
10365
10384
|
this.nextLine();
|
|
10366
10385
|
}
|
|
10367
10386
|
else if (reEscapable.test(subj.charAt(this.pos))) {
|
|
10368
|
-
block.appendChild(text(subj.charAt(this.pos), this.sourcepos(startpos, this.pos)));
|
|
10387
|
+
block.appendChild(text$1(subj.charAt(this.pos), this.sourcepos(startpos, this.pos)));
|
|
10369
10388
|
this.pos += 1;
|
|
10370
10389
|
}
|
|
10371
10390
|
else {
|
|
10372
|
-
block.appendChild(text('\\', this.sourcepos(startpos, startpos)));
|
|
10391
|
+
block.appendChild(text$1('\\', this.sourcepos(startpos, startpos)));
|
|
10373
10392
|
}
|
|
10374
10393
|
return true;
|
|
10375
10394
|
};
|
|
@@ -10384,7 +10403,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
10384
10403
|
node = createNode$1('link', this.sourcepos(startpos, this.pos));
|
|
10385
10404
|
node.destination = normalizeURI("mailto:" + dest);
|
|
10386
10405
|
node.title = '';
|
|
10387
|
-
node.appendChild(text(dest, this.sourcepos(startpos + 1, this.pos - 1)));
|
|
10406
|
+
node.appendChild(text$1(dest, this.sourcepos(startpos + 1, this.pos - 1)));
|
|
10388
10407
|
block.appendChild(node);
|
|
10389
10408
|
return true;
|
|
10390
10409
|
}
|
|
@@ -10393,7 +10412,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
10393
10412
|
node = createNode$1('link', this.sourcepos(startpos, this.pos));
|
|
10394
10413
|
node.destination = normalizeURI(dest);
|
|
10395
10414
|
node.title = '';
|
|
10396
|
-
node.appendChild(text(dest, this.sourcepos(startpos + 1, this.pos - 1)));
|
|
10415
|
+
node.appendChild(text$1(dest, this.sourcepos(startpos + 1, this.pos - 1)));
|
|
10397
10416
|
block.appendChild(node);
|
|
10398
10417
|
return true;
|
|
10399
10418
|
}
|
|
@@ -10487,7 +10506,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
10487
10506
|
else {
|
|
10488
10507
|
contents = this.subject.slice(startpos - 1, this.pos);
|
|
10489
10508
|
}
|
|
10490
|
-
var node = text(contents, this.sourcepos(startpos, this.pos));
|
|
10509
|
+
var node = text$1(contents, this.sourcepos(startpos, this.pos));
|
|
10491
10510
|
block.appendChild(node);
|
|
10492
10511
|
// Add entry to stack for this opener
|
|
10493
10512
|
if ((res.canOpen || res.canClose) &&
|
|
@@ -10758,7 +10777,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
10758
10777
|
InlineParser.prototype.parseOpenBracket = function (block) {
|
|
10759
10778
|
var startpos = this.pos;
|
|
10760
10779
|
this.pos += 1;
|
|
10761
|
-
var node = text('[', this.sourcepos(this.pos, this.pos));
|
|
10780
|
+
var node = text$1('[', this.sourcepos(this.pos, this.pos));
|
|
10762
10781
|
block.appendChild(node);
|
|
10763
10782
|
// Add entry to stack for this opener
|
|
10764
10783
|
this.addBracket(node, startpos, false);
|
|
@@ -10771,13 +10790,13 @@ var InlineParser = /** @class */ (function () {
|
|
|
10771
10790
|
this.pos += 1;
|
|
10772
10791
|
if (this.peek() === C_OPEN_BRACKET$1) {
|
|
10773
10792
|
this.pos += 1;
|
|
10774
|
-
var node = text('![', this.sourcepos(this.pos - 1, this.pos));
|
|
10793
|
+
var node = text$1('![', this.sourcepos(this.pos - 1, this.pos));
|
|
10775
10794
|
block.appendChild(node);
|
|
10776
10795
|
// Add entry to stack for this opener
|
|
10777
10796
|
this.addBracket(node, startpos + 1, true);
|
|
10778
10797
|
}
|
|
10779
10798
|
else {
|
|
10780
|
-
var node = text('!', this.sourcepos(this.pos, this.pos));
|
|
10799
|
+
var node = text$1('!', this.sourcepos(this.pos, this.pos));
|
|
10781
10800
|
block.appendChild(node);
|
|
10782
10801
|
}
|
|
10783
10802
|
return true;
|
|
@@ -10796,12 +10815,12 @@ var InlineParser = /** @class */ (function () {
|
|
|
10796
10815
|
var opener = this.brackets;
|
|
10797
10816
|
if (opener === null) {
|
|
10798
10817
|
// no matched opener, just return a literal
|
|
10799
|
-
block.appendChild(text(']', this.sourcepos(startpos, startpos)));
|
|
10818
|
+
block.appendChild(text$1(']', this.sourcepos(startpos, startpos)));
|
|
10800
10819
|
return true;
|
|
10801
10820
|
}
|
|
10802
10821
|
if (!opener.active) {
|
|
10803
10822
|
// no matched opener, just return a literal
|
|
10804
|
-
block.appendChild(text(']', this.sourcepos(startpos, startpos)));
|
|
10823
|
+
block.appendChild(text$1(']', this.sourcepos(startpos, startpos)));
|
|
10805
10824
|
// take opener off brackets stack
|
|
10806
10825
|
this.removeBracket();
|
|
10807
10826
|
return true;
|
|
@@ -10893,7 +10912,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
10893
10912
|
} // no match
|
|
10894
10913
|
this.removeBracket(); // remove this opener from stack
|
|
10895
10914
|
this.pos = startpos;
|
|
10896
|
-
block.appendChild(text(']', this.sourcepos(startpos, startpos)));
|
|
10915
|
+
block.appendChild(text$1(']', this.sourcepos(startpos, startpos)));
|
|
10897
10916
|
if (this.options.referenceDefinition) {
|
|
10898
10917
|
this.refLinkCandidateMap[block.id] = { node: block, refLabel: refLabel };
|
|
10899
10918
|
}
|
|
@@ -10923,7 +10942,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
10923
10942
|
var m;
|
|
10924
10943
|
var startpos = this.pos + 1;
|
|
10925
10944
|
if ((m = this.match(reEntityHere))) {
|
|
10926
|
-
block.appendChild(text(lib.decodeHTML(m), this.sourcepos(startpos, this.pos)));
|
|
10945
|
+
block.appendChild(text$1(lib.decodeHTML(m), this.sourcepos(startpos, this.pos)));
|
|
10927
10946
|
return true;
|
|
10928
10947
|
}
|
|
10929
10948
|
return false;
|
|
@@ -10958,10 +10977,10 @@ var InlineParser = /** @class */ (function () {
|
|
|
10958
10977
|
}
|
|
10959
10978
|
return repeat('\u2014', emCount) + repeat('\u2013', enCount);
|
|
10960
10979
|
});
|
|
10961
|
-
block.appendChild(text(lit, this.sourcepos(startpos, this.pos)));
|
|
10980
|
+
block.appendChild(text$1(lit, this.sourcepos(startpos, this.pos)));
|
|
10962
10981
|
}
|
|
10963
10982
|
else {
|
|
10964
|
-
var node = text(m, this.sourcepos(startpos, this.pos));
|
|
10983
|
+
var node = text$1(m, this.sourcepos(startpos, this.pos));
|
|
10965
10984
|
block.appendChild(node);
|
|
10966
10985
|
}
|
|
10967
10986
|
return true;
|
|
@@ -11184,7 +11203,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
11184
11203
|
}
|
|
11185
11204
|
if (!res) {
|
|
11186
11205
|
this.pos += 1;
|
|
11187
|
-
block.appendChild(text(fromCodePoint$1(c), this.sourcepos(this.pos, this.pos + 1)));
|
|
11206
|
+
block.appendChild(text$1(fromCodePoint$1(c), this.sourcepos(this.pos, this.pos + 1)));
|
|
11188
11207
|
}
|
|
11189
11208
|
return true;
|
|
11190
11209
|
};
|
|
@@ -13595,105 +13614,1416 @@ var Renderer = /** @class */ (function () {
|
|
|
13595
13614
|
return Renderer;
|
|
13596
13615
|
}());
|
|
13597
13616
|
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
var
|
|
13644
|
-
var
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13617
|
+
/*! @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 */
|
|
13618
|
+
|
|
13619
|
+
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); } }
|
|
13620
|
+
|
|
13621
|
+
var hasOwnProperty = Object.hasOwnProperty,
|
|
13622
|
+
setPrototypeOf = Object.setPrototypeOf,
|
|
13623
|
+
isFrozen = Object.isFrozen,
|
|
13624
|
+
getPrototypeOf = Object.getPrototypeOf,
|
|
13625
|
+
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
13626
|
+
var freeze = Object.freeze,
|
|
13627
|
+
seal = Object.seal,
|
|
13628
|
+
create = Object.create; // eslint-disable-line import/no-mutable-exports
|
|
13629
|
+
|
|
13630
|
+
var _ref = typeof Reflect !== 'undefined' && Reflect,
|
|
13631
|
+
apply = _ref.apply,
|
|
13632
|
+
construct = _ref.construct;
|
|
13633
|
+
|
|
13634
|
+
if (!apply) {
|
|
13635
|
+
apply = function apply(fun, thisValue, args) {
|
|
13636
|
+
return fun.apply(thisValue, args);
|
|
13637
|
+
};
|
|
13638
|
+
}
|
|
13639
|
+
|
|
13640
|
+
if (!freeze) {
|
|
13641
|
+
freeze = function freeze(x) {
|
|
13642
|
+
return x;
|
|
13643
|
+
};
|
|
13644
|
+
}
|
|
13645
|
+
|
|
13646
|
+
if (!seal) {
|
|
13647
|
+
seal = function seal(x) {
|
|
13648
|
+
return x;
|
|
13649
|
+
};
|
|
13650
|
+
}
|
|
13651
|
+
|
|
13652
|
+
if (!construct) {
|
|
13653
|
+
construct = function construct(Func, args) {
|
|
13654
|
+
return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))();
|
|
13655
|
+
};
|
|
13656
|
+
}
|
|
13657
|
+
|
|
13658
|
+
var arrayForEach = unapply(Array.prototype.forEach);
|
|
13659
|
+
var arrayPop = unapply(Array.prototype.pop);
|
|
13660
|
+
var arrayPush = unapply(Array.prototype.push);
|
|
13661
|
+
|
|
13662
|
+
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
13663
|
+
var stringMatch = unapply(String.prototype.match);
|
|
13664
|
+
var stringReplace = unapply(String.prototype.replace);
|
|
13665
|
+
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
13666
|
+
var stringTrim = unapply(String.prototype.trim);
|
|
13667
|
+
|
|
13668
|
+
var regExpTest = unapply(RegExp.prototype.test);
|
|
13669
|
+
|
|
13670
|
+
var typeErrorCreate = unconstruct(TypeError);
|
|
13671
|
+
|
|
13672
|
+
function unapply(func) {
|
|
13673
|
+
return function (thisArg) {
|
|
13674
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
13675
|
+
args[_key - 1] = arguments[_key];
|
|
13651
13676
|
}
|
|
13677
|
+
|
|
13678
|
+
return apply(func, thisArg, args);
|
|
13679
|
+
};
|
|
13652
13680
|
}
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13681
|
+
|
|
13682
|
+
function unconstruct(func) {
|
|
13683
|
+
return function () {
|
|
13684
|
+
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
13685
|
+
args[_key2] = arguments[_key2];
|
|
13658
13686
|
}
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13687
|
+
|
|
13688
|
+
return construct(func, args);
|
|
13689
|
+
};
|
|
13662
13690
|
}
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13691
|
+
|
|
13692
|
+
/* Add properties to a lookup table */
|
|
13693
|
+
function addToSet(set, array) {
|
|
13694
|
+
if (setPrototypeOf) {
|
|
13695
|
+
// Make 'in' and truthy checks like Boolean(set.constructor)
|
|
13696
|
+
// independent of any properties defined on Object.prototype.
|
|
13697
|
+
// Prevent prototype setters from intercepting set as a this value.
|
|
13698
|
+
setPrototypeOf(set, null);
|
|
13699
|
+
}
|
|
13700
|
+
|
|
13701
|
+
var l = array.length;
|
|
13702
|
+
while (l--) {
|
|
13703
|
+
var element = array[l];
|
|
13704
|
+
if (typeof element === 'string') {
|
|
13705
|
+
var lcElement = stringToLowerCase(element);
|
|
13706
|
+
if (lcElement !== element) {
|
|
13707
|
+
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
13708
|
+
if (!isFrozen(array)) {
|
|
13709
|
+
array[l] = lcElement;
|
|
13710
|
+
}
|
|
13711
|
+
|
|
13712
|
+
element = lcElement;
|
|
13713
|
+
}
|
|
13714
|
+
}
|
|
13715
|
+
|
|
13716
|
+
set[element] = true;
|
|
13717
|
+
}
|
|
13718
|
+
|
|
13719
|
+
return set;
|
|
13668
13720
|
}
|
|
13669
|
-
|
|
13670
|
-
|
|
13721
|
+
|
|
13722
|
+
/* Shallow clone an object */
|
|
13723
|
+
function clone(object) {
|
|
13724
|
+
var newObject = create(null);
|
|
13725
|
+
|
|
13726
|
+
var property = void 0;
|
|
13727
|
+
for (property in object) {
|
|
13728
|
+
if (apply(hasOwnProperty, object, [property])) {
|
|
13729
|
+
newObject[property] = object[property];
|
|
13730
|
+
}
|
|
13731
|
+
}
|
|
13732
|
+
|
|
13733
|
+
return newObject;
|
|
13671
13734
|
}
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13735
|
+
|
|
13736
|
+
/* IE10 doesn't support __lookupGetter__ so lets'
|
|
13737
|
+
* simulate it. It also automatically checks
|
|
13738
|
+
* if the prop is function or getter and behaves
|
|
13739
|
+
* accordingly. */
|
|
13740
|
+
function lookupGetter(object, prop) {
|
|
13741
|
+
while (object !== null) {
|
|
13742
|
+
var desc = getOwnPropertyDescriptor(object, prop);
|
|
13743
|
+
if (desc) {
|
|
13744
|
+
if (desc.get) {
|
|
13745
|
+
return unapply(desc.get);
|
|
13746
|
+
}
|
|
13747
|
+
|
|
13748
|
+
if (typeof desc.value === 'function') {
|
|
13749
|
+
return unapply(desc.value);
|
|
13750
|
+
}
|
|
13751
|
+
}
|
|
13752
|
+
|
|
13753
|
+
object = getPrototypeOf(object);
|
|
13754
|
+
}
|
|
13755
|
+
|
|
13756
|
+
function fallbackValue(element) {
|
|
13757
|
+
console.warn('fallback value for', element);
|
|
13758
|
+
return null;
|
|
13759
|
+
}
|
|
13760
|
+
|
|
13761
|
+
return fallbackValue;
|
|
13680
13762
|
}
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13763
|
+
|
|
13764
|
+
var html$2 = 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']);
|
|
13765
|
+
|
|
13766
|
+
// SVG
|
|
13767
|
+
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']);
|
|
13768
|
+
|
|
13769
|
+
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']);
|
|
13770
|
+
|
|
13771
|
+
// List of SVG elements that are disallowed by default.
|
|
13772
|
+
// We still need to know them so that we can do namespace
|
|
13773
|
+
// checks properly in case one wants to add them to
|
|
13774
|
+
// allow-list.
|
|
13775
|
+
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']);
|
|
13776
|
+
|
|
13777
|
+
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']);
|
|
13778
|
+
|
|
13779
|
+
// Similarly to SVG, we want to know all MathML elements,
|
|
13780
|
+
// even those that we disallow by default.
|
|
13781
|
+
var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
13782
|
+
|
|
13783
|
+
var text = freeze(['#text']);
|
|
13784
|
+
|
|
13785
|
+
var html$1$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']);
|
|
13786
|
+
|
|
13787
|
+
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']);
|
|
13788
|
+
|
|
13789
|
+
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']);
|
|
13790
|
+
|
|
13791
|
+
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
13792
|
+
|
|
13793
|
+
// eslint-disable-next-line unicorn/better-regex
|
|
13794
|
+
var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
13795
|
+
var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm);
|
|
13796
|
+
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
|
|
13797
|
+
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
13798
|
+
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
|
|
13799
|
+
);
|
|
13800
|
+
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
13801
|
+
var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
|
13802
|
+
);
|
|
13803
|
+
|
|
13804
|
+
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; };
|
|
13805
|
+
|
|
13806
|
+
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); } }
|
|
13807
|
+
|
|
13808
|
+
var getGlobal = function getGlobal() {
|
|
13809
|
+
return typeof window === 'undefined' ? null : window;
|
|
13810
|
+
};
|
|
13811
|
+
|
|
13812
|
+
/**
|
|
13813
|
+
* Creates a no-op policy for internal use only.
|
|
13814
|
+
* Don't export this function outside this module!
|
|
13815
|
+
* @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
|
|
13816
|
+
* @param {Document} document The document object (to determine policy name suffix)
|
|
13817
|
+
* @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
|
|
13818
|
+
* are not supported).
|
|
13819
|
+
*/
|
|
13820
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
|
|
13821
|
+
if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
13822
|
+
return null;
|
|
13823
|
+
}
|
|
13824
|
+
|
|
13825
|
+
// Allow the callers to control the unique policy name
|
|
13826
|
+
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
13827
|
+
// Policy creation with duplicate names throws in Trusted Types.
|
|
13828
|
+
var suffix = null;
|
|
13829
|
+
var ATTR_NAME = 'data-tt-policy-suffix';
|
|
13830
|
+
if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
|
|
13831
|
+
suffix = document.currentScript.getAttribute(ATTR_NAME);
|
|
13832
|
+
}
|
|
13833
|
+
|
|
13834
|
+
var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
|
|
13835
|
+
|
|
13836
|
+
try {
|
|
13837
|
+
return trustedTypes.createPolicy(policyName, {
|
|
13838
|
+
createHTML: function createHTML(html$$1) {
|
|
13839
|
+
return html$$1;
|
|
13840
|
+
}
|
|
13841
|
+
});
|
|
13842
|
+
} catch (_) {
|
|
13843
|
+
// Policy creation failed (most likely another DOMPurify script has
|
|
13844
|
+
// already run). Skip creating the policy, as this will only cause errors
|
|
13845
|
+
// if TT are enforced.
|
|
13846
|
+
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
13847
|
+
return null;
|
|
13848
|
+
}
|
|
13849
|
+
};
|
|
13850
|
+
|
|
13851
|
+
function createDOMPurify() {
|
|
13852
|
+
var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
13853
|
+
|
|
13854
|
+
var DOMPurify = function DOMPurify(root) {
|
|
13855
|
+
return createDOMPurify(root);
|
|
13856
|
+
};
|
|
13857
|
+
|
|
13858
|
+
/**
|
|
13859
|
+
* Version label, exposed for easier checks
|
|
13860
|
+
* if DOMPurify is up to date or not
|
|
13861
|
+
*/
|
|
13862
|
+
DOMPurify.version = '2.3.3';
|
|
13863
|
+
|
|
13864
|
+
/**
|
|
13865
|
+
* Array of elements that DOMPurify removed during sanitation.
|
|
13866
|
+
* Empty if nothing was removed.
|
|
13867
|
+
*/
|
|
13868
|
+
DOMPurify.removed = [];
|
|
13869
|
+
|
|
13870
|
+
if (!window || !window.document || window.document.nodeType !== 9) {
|
|
13871
|
+
// Not running in a browser, provide a factory function
|
|
13872
|
+
// so that you can pass your own Window
|
|
13873
|
+
DOMPurify.isSupported = false;
|
|
13874
|
+
|
|
13875
|
+
return DOMPurify;
|
|
13876
|
+
}
|
|
13877
|
+
|
|
13878
|
+
var originalDocument = window.document;
|
|
13879
|
+
|
|
13880
|
+
var document = window.document;
|
|
13881
|
+
var DocumentFragment = window.DocumentFragment,
|
|
13882
|
+
HTMLTemplateElement = window.HTMLTemplateElement,
|
|
13883
|
+
Node = window.Node,
|
|
13884
|
+
Element = window.Element,
|
|
13885
|
+
NodeFilter = window.NodeFilter,
|
|
13886
|
+
_window$NamedNodeMap = window.NamedNodeMap,
|
|
13887
|
+
NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
|
|
13888
|
+
Text = window.Text,
|
|
13889
|
+
Comment = window.Comment,
|
|
13890
|
+
DOMParser = window.DOMParser,
|
|
13891
|
+
trustedTypes = window.trustedTypes;
|
|
13892
|
+
|
|
13893
|
+
|
|
13894
|
+
var ElementPrototype = Element.prototype;
|
|
13895
|
+
|
|
13896
|
+
var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
13897
|
+
var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
13898
|
+
var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
13899
|
+
var getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
13900
|
+
|
|
13901
|
+
// As per issue #47, the web-components registry is inherited by a
|
|
13902
|
+
// new document created via createHTMLDocument. As per the spec
|
|
13903
|
+
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
13904
|
+
// a new empty registry is used when creating a template contents owner
|
|
13905
|
+
// document, so we use that as our parent document to ensure nothing
|
|
13906
|
+
// is inherited.
|
|
13907
|
+
if (typeof HTMLTemplateElement === 'function') {
|
|
13908
|
+
var template = document.createElement('template');
|
|
13909
|
+
if (template.content && template.content.ownerDocument) {
|
|
13910
|
+
document = template.content.ownerDocument;
|
|
13911
|
+
}
|
|
13912
|
+
}
|
|
13913
|
+
|
|
13914
|
+
var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
|
|
13915
|
+
var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : '';
|
|
13916
|
+
|
|
13917
|
+
var _document = document,
|
|
13918
|
+
implementation = _document.implementation,
|
|
13919
|
+
createNodeIterator = _document.createNodeIterator,
|
|
13920
|
+
createDocumentFragment = _document.createDocumentFragment,
|
|
13921
|
+
getElementsByTagName = _document.getElementsByTagName;
|
|
13922
|
+
var importNode = originalDocument.importNode;
|
|
13923
|
+
|
|
13924
|
+
|
|
13925
|
+
var documentMode = {};
|
|
13926
|
+
try {
|
|
13927
|
+
documentMode = clone(document).documentMode ? document.documentMode : {};
|
|
13928
|
+
} catch (_) {}
|
|
13929
|
+
|
|
13930
|
+
var hooks = {};
|
|
13931
|
+
|
|
13932
|
+
/**
|
|
13933
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
13934
|
+
*/
|
|
13935
|
+
DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
|
|
13936
|
+
|
|
13937
|
+
var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR,
|
|
13938
|
+
ERB_EXPR$$1 = ERB_EXPR,
|
|
13939
|
+
DATA_ATTR$$1 = DATA_ATTR,
|
|
13940
|
+
ARIA_ATTR$$1 = ARIA_ATTR,
|
|
13941
|
+
IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA,
|
|
13942
|
+
ATTR_WHITESPACE$$1 = ATTR_WHITESPACE;
|
|
13943
|
+
var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI;
|
|
13944
|
+
|
|
13945
|
+
/**
|
|
13946
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
13947
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
13948
|
+
*/
|
|
13949
|
+
|
|
13950
|
+
/* allowed element names */
|
|
13951
|
+
|
|
13952
|
+
var ALLOWED_TAGS = null;
|
|
13953
|
+
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html$2), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text)));
|
|
13954
|
+
|
|
13955
|
+
/* Allowed attribute names */
|
|
13956
|
+
var ALLOWED_ATTR = null;
|
|
13957
|
+
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml)));
|
|
13958
|
+
|
|
13959
|
+
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
13960
|
+
var FORBID_TAGS = null;
|
|
13961
|
+
|
|
13962
|
+
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
13963
|
+
var FORBID_ATTR = null;
|
|
13964
|
+
|
|
13965
|
+
/* Decide if ARIA attributes are okay */
|
|
13966
|
+
var ALLOW_ARIA_ATTR = true;
|
|
13967
|
+
|
|
13968
|
+
/* Decide if custom data attributes are okay */
|
|
13969
|
+
var ALLOW_DATA_ATTR = true;
|
|
13970
|
+
|
|
13971
|
+
/* Decide if unknown protocols are okay */
|
|
13972
|
+
var ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
13973
|
+
|
|
13974
|
+
/* Output should be safe for common template engines.
|
|
13975
|
+
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
13976
|
+
*/
|
|
13977
|
+
var SAFE_FOR_TEMPLATES = false;
|
|
13978
|
+
|
|
13979
|
+
/* Decide if document with <html>... should be returned */
|
|
13980
|
+
var WHOLE_DOCUMENT = false;
|
|
13981
|
+
|
|
13982
|
+
/* Track whether config is already set on this instance of DOMPurify. */
|
|
13983
|
+
var SET_CONFIG = false;
|
|
13984
|
+
|
|
13985
|
+
/* Decide if all elements (e.g. style, script) must be children of
|
|
13986
|
+
* document.body. By default, browsers might move them to document.head */
|
|
13987
|
+
var FORCE_BODY = false;
|
|
13988
|
+
|
|
13989
|
+
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
13990
|
+
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
13991
|
+
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
13992
|
+
*/
|
|
13993
|
+
var RETURN_DOM = false;
|
|
13994
|
+
|
|
13995
|
+
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
13996
|
+
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
13997
|
+
var RETURN_DOM_FRAGMENT = false;
|
|
13998
|
+
|
|
13999
|
+
/* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM
|
|
14000
|
+
* `Node` is imported into the current `Document`. If this flag is not enabled the
|
|
14001
|
+
* `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by
|
|
14002
|
+
* DOMPurify.
|
|
14003
|
+
*
|
|
14004
|
+
* This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false`
|
|
14005
|
+
* might cause XSS from attacks hidden in closed shadowroots in case the browser
|
|
14006
|
+
* supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/
|
|
14007
|
+
*/
|
|
14008
|
+
var RETURN_DOM_IMPORT = true;
|
|
14009
|
+
|
|
14010
|
+
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
14011
|
+
* case Trusted Types are not supported */
|
|
14012
|
+
var RETURN_TRUSTED_TYPE = false;
|
|
14013
|
+
|
|
14014
|
+
/* Output should be free from DOM clobbering attacks? */
|
|
14015
|
+
var SANITIZE_DOM = true;
|
|
14016
|
+
|
|
14017
|
+
/* Keep element content when removing element? */
|
|
14018
|
+
var KEEP_CONTENT = true;
|
|
14019
|
+
|
|
14020
|
+
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
14021
|
+
* of importing it into a new Document and returning a sanitized copy */
|
|
14022
|
+
var IN_PLACE = false;
|
|
14023
|
+
|
|
14024
|
+
/* Allow usage of profiles like html, svg and mathMl */
|
|
14025
|
+
var USE_PROFILES = {};
|
|
14026
|
+
|
|
14027
|
+
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
14028
|
+
var FORBID_CONTENTS = null;
|
|
14029
|
+
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']);
|
|
14030
|
+
|
|
14031
|
+
/* Tags that are safe for data: URIs */
|
|
14032
|
+
var DATA_URI_TAGS = null;
|
|
14033
|
+
var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
14034
|
+
|
|
14035
|
+
/* Attributes safe for values like "javascript:" */
|
|
14036
|
+
var URI_SAFE_ATTRIBUTES = null;
|
|
14037
|
+
var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
14038
|
+
|
|
14039
|
+
var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
14040
|
+
var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
14041
|
+
var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
14042
|
+
/* Document namespace */
|
|
14043
|
+
var NAMESPACE = HTML_NAMESPACE;
|
|
14044
|
+
var IS_EMPTY_INPUT = false;
|
|
14045
|
+
|
|
14046
|
+
/* Parsing of strict XHTML documents */
|
|
14047
|
+
var PARSER_MEDIA_TYPE = void 0;
|
|
14048
|
+
var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
14049
|
+
var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
14050
|
+
var transformCaseFunc = void 0;
|
|
14051
|
+
|
|
14052
|
+
/* Keep a reference to config to pass to hooks */
|
|
14053
|
+
var CONFIG = null;
|
|
14054
|
+
|
|
14055
|
+
/* Ideally, do not touch anything below this line */
|
|
14056
|
+
/* ______________________________________________ */
|
|
14057
|
+
|
|
14058
|
+
var formElement = document.createElement('form');
|
|
14059
|
+
|
|
14060
|
+
/**
|
|
14061
|
+
* _parseConfig
|
|
14062
|
+
*
|
|
14063
|
+
* @param {Object} cfg optional config literal
|
|
14064
|
+
*/
|
|
14065
|
+
// eslint-disable-next-line complexity
|
|
14066
|
+
var _parseConfig = function _parseConfig(cfg) {
|
|
14067
|
+
if (CONFIG && CONFIG === cfg) {
|
|
14068
|
+
return;
|
|
14069
|
+
}
|
|
14070
|
+
|
|
14071
|
+
/* Shield configuration object from tampering */
|
|
14072
|
+
if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') {
|
|
14073
|
+
cfg = {};
|
|
14074
|
+
}
|
|
14075
|
+
|
|
14076
|
+
/* Shield configuration object from prototype pollution */
|
|
14077
|
+
cfg = clone(cfg);
|
|
14078
|
+
|
|
14079
|
+
/* Set configuration parameters */
|
|
14080
|
+
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS;
|
|
14081
|
+
ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR;
|
|
14082
|
+
URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
14083
|
+
DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS;
|
|
14084
|
+
FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS) : DEFAULT_FORBID_CONTENTS;
|
|
14085
|
+
FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {};
|
|
14086
|
+
FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {};
|
|
14087
|
+
USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
|
|
14088
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
14089
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
14090
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
14091
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
|
14092
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
|
14093
|
+
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
|
14094
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
|
14095
|
+
RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true
|
|
14096
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
|
14097
|
+
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
|
14098
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
14099
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
14100
|
+
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
14101
|
+
IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1;
|
|
14102
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
14103
|
+
|
|
14104
|
+
PARSER_MEDIA_TYPE =
|
|
14105
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
14106
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
|
|
14107
|
+
|
|
14108
|
+
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
14109
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
|
|
14110
|
+
return x;
|
|
14111
|
+
} : stringToLowerCase;
|
|
14112
|
+
|
|
14113
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
14114
|
+
ALLOW_DATA_ATTR = false;
|
|
14115
|
+
}
|
|
14116
|
+
|
|
14117
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
14118
|
+
RETURN_DOM = true;
|
|
14119
|
+
}
|
|
14120
|
+
|
|
14121
|
+
/* Parse profile info */
|
|
14122
|
+
if (USE_PROFILES) {
|
|
14123
|
+
ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text)));
|
|
14124
|
+
ALLOWED_ATTR = [];
|
|
14125
|
+
if (USE_PROFILES.html === true) {
|
|
14126
|
+
addToSet(ALLOWED_TAGS, html$2);
|
|
14127
|
+
addToSet(ALLOWED_ATTR, html$1$1);
|
|
14128
|
+
}
|
|
14129
|
+
|
|
14130
|
+
if (USE_PROFILES.svg === true) {
|
|
14131
|
+
addToSet(ALLOWED_TAGS, svg);
|
|
14132
|
+
addToSet(ALLOWED_ATTR, svg$1);
|
|
14133
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
14134
|
+
}
|
|
14135
|
+
|
|
14136
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
14137
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
14138
|
+
addToSet(ALLOWED_ATTR, svg$1);
|
|
14139
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
14140
|
+
}
|
|
14141
|
+
|
|
14142
|
+
if (USE_PROFILES.mathMl === true) {
|
|
14143
|
+
addToSet(ALLOWED_TAGS, mathMl);
|
|
14144
|
+
addToSet(ALLOWED_ATTR, mathMl$1);
|
|
14145
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
14146
|
+
}
|
|
14147
|
+
}
|
|
14148
|
+
|
|
14149
|
+
/* Merge configuration parameters */
|
|
14150
|
+
if (cfg.ADD_TAGS) {
|
|
14151
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
14152
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
14153
|
+
}
|
|
14154
|
+
|
|
14155
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS);
|
|
14156
|
+
}
|
|
14157
|
+
|
|
14158
|
+
if (cfg.ADD_ATTR) {
|
|
14159
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
14160
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
14161
|
+
}
|
|
14162
|
+
|
|
14163
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR);
|
|
14164
|
+
}
|
|
14165
|
+
|
|
14166
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
14167
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR);
|
|
14168
|
+
}
|
|
14169
|
+
|
|
14170
|
+
if (cfg.FORBID_CONTENTS) {
|
|
14171
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
14172
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
14173
|
+
}
|
|
14174
|
+
|
|
14175
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS);
|
|
14176
|
+
}
|
|
14177
|
+
|
|
14178
|
+
/* Add #text in case KEEP_CONTENT is set to true */
|
|
14179
|
+
if (KEEP_CONTENT) {
|
|
14180
|
+
ALLOWED_TAGS['#text'] = true;
|
|
14181
|
+
}
|
|
14182
|
+
|
|
14183
|
+
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
14184
|
+
if (WHOLE_DOCUMENT) {
|
|
14185
|
+
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
14186
|
+
}
|
|
14187
|
+
|
|
14188
|
+
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
14189
|
+
if (ALLOWED_TAGS.table) {
|
|
14190
|
+
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
14191
|
+
delete FORBID_TAGS.tbody;
|
|
14192
|
+
}
|
|
14193
|
+
|
|
14194
|
+
// Prevent further manipulation of configuration.
|
|
14195
|
+
// Not available in IE8, Safari 5, etc.
|
|
14196
|
+
if (freeze) {
|
|
14197
|
+
freeze(cfg);
|
|
14198
|
+
}
|
|
14199
|
+
|
|
14200
|
+
CONFIG = cfg;
|
|
14201
|
+
};
|
|
14202
|
+
|
|
14203
|
+
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
14204
|
+
|
|
14205
|
+
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
|
|
14206
|
+
|
|
14207
|
+
/* Keep track of all possible SVG and MathML tags
|
|
14208
|
+
* so that we can perform the namespace checks
|
|
14209
|
+
* correctly. */
|
|
14210
|
+
var ALL_SVG_TAGS = addToSet({}, svg);
|
|
14211
|
+
addToSet(ALL_SVG_TAGS, svgFilters);
|
|
14212
|
+
addToSet(ALL_SVG_TAGS, svgDisallowed);
|
|
14213
|
+
|
|
14214
|
+
var ALL_MATHML_TAGS = addToSet({}, mathMl);
|
|
14215
|
+
addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
|
|
14216
|
+
|
|
14217
|
+
/**
|
|
14218
|
+
*
|
|
14219
|
+
*
|
|
14220
|
+
* @param {Element} element a DOM element whose namespace is being checked
|
|
14221
|
+
* @returns {boolean} Return false if the element has a
|
|
14222
|
+
* namespace that a spec-compliant parser would never
|
|
14223
|
+
* return. Return true otherwise.
|
|
14224
|
+
*/
|
|
14225
|
+
var _checkValidNamespace = function _checkValidNamespace(element) {
|
|
14226
|
+
var parent = getParentNode(element);
|
|
14227
|
+
|
|
14228
|
+
// In JSDOM, if we're inside shadow DOM, then parentNode
|
|
14229
|
+
// can be null. We just simulate parent in this case.
|
|
14230
|
+
if (!parent || !parent.tagName) {
|
|
14231
|
+
parent = {
|
|
14232
|
+
namespaceURI: HTML_NAMESPACE,
|
|
14233
|
+
tagName: 'template'
|
|
14234
|
+
};
|
|
14235
|
+
}
|
|
14236
|
+
|
|
14237
|
+
var tagName = stringToLowerCase(element.tagName);
|
|
14238
|
+
var parentTagName = stringToLowerCase(parent.tagName);
|
|
14239
|
+
|
|
14240
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
14241
|
+
// The only way to switch from HTML namespace to SVG
|
|
14242
|
+
// is via <svg>. If it happens via any other tag, then
|
|
14243
|
+
// it should be killed.
|
|
14244
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
14245
|
+
return tagName === 'svg';
|
|
14246
|
+
}
|
|
14247
|
+
|
|
14248
|
+
// The only way to switch from MathML to SVG is via
|
|
14249
|
+
// svg if parent is either <annotation-xml> or MathML
|
|
14250
|
+
// text integration points.
|
|
14251
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
14252
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
14253
|
+
}
|
|
14254
|
+
|
|
14255
|
+
// We only allow elements that are defined in SVG
|
|
14256
|
+
// spec. All others are disallowed in SVG namespace.
|
|
14257
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
14258
|
+
}
|
|
14259
|
+
|
|
14260
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
14261
|
+
// The only way to switch from HTML namespace to MathML
|
|
14262
|
+
// is via <math>. If it happens via any other tag, then
|
|
14263
|
+
// it should be killed.
|
|
14264
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
14265
|
+
return tagName === 'math';
|
|
14266
|
+
}
|
|
14267
|
+
|
|
14268
|
+
// The only way to switch from SVG to MathML is via
|
|
14269
|
+
// <math> and HTML integration points
|
|
14270
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
14271
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
14272
|
+
}
|
|
14273
|
+
|
|
14274
|
+
// We only allow elements that are defined in MathML
|
|
14275
|
+
// spec. All others are disallowed in MathML namespace.
|
|
14276
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
14277
|
+
}
|
|
14278
|
+
|
|
14279
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
14280
|
+
// The only way to switch from SVG to HTML is via
|
|
14281
|
+
// HTML integration points, and from MathML to HTML
|
|
14282
|
+
// is via MathML text integration points
|
|
14283
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
14284
|
+
return false;
|
|
14285
|
+
}
|
|
14286
|
+
|
|
14287
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
14288
|
+
return false;
|
|
14289
|
+
}
|
|
14290
|
+
|
|
14291
|
+
// Certain elements are allowed in both SVG and HTML
|
|
14292
|
+
// namespace. We need to specify them explicitly
|
|
14293
|
+
// so that they don't get erronously deleted from
|
|
14294
|
+
// HTML namespace.
|
|
14295
|
+
var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
14296
|
+
|
|
14297
|
+
// We disallow tags that are specific for MathML
|
|
14298
|
+
// or SVG and should never appear in HTML namespace
|
|
14299
|
+
return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
14300
|
+
}
|
|
14301
|
+
|
|
14302
|
+
// The code should never reach this place (this means
|
|
14303
|
+
// that the element somehow got namespace that is not
|
|
14304
|
+
// HTML, SVG or MathML). Return false just in case.
|
|
14305
|
+
return false;
|
|
14306
|
+
};
|
|
14307
|
+
|
|
14308
|
+
/**
|
|
14309
|
+
* _forceRemove
|
|
14310
|
+
*
|
|
14311
|
+
* @param {Node} node a DOM node
|
|
14312
|
+
*/
|
|
14313
|
+
var _forceRemove = function _forceRemove(node) {
|
|
14314
|
+
arrayPush(DOMPurify.removed, { element: node });
|
|
14315
|
+
try {
|
|
14316
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
14317
|
+
node.parentNode.removeChild(node);
|
|
14318
|
+
} catch (_) {
|
|
14319
|
+
try {
|
|
14320
|
+
node.outerHTML = emptyHTML;
|
|
14321
|
+
} catch (_) {
|
|
14322
|
+
node.remove();
|
|
14323
|
+
}
|
|
14324
|
+
}
|
|
14325
|
+
};
|
|
14326
|
+
|
|
14327
|
+
/**
|
|
14328
|
+
* _removeAttribute
|
|
14329
|
+
*
|
|
14330
|
+
* @param {String} name an Attribute name
|
|
14331
|
+
* @param {Node} node a DOM node
|
|
14332
|
+
*/
|
|
14333
|
+
var _removeAttribute = function _removeAttribute(name, node) {
|
|
14334
|
+
try {
|
|
14335
|
+
arrayPush(DOMPurify.removed, {
|
|
14336
|
+
attribute: node.getAttributeNode(name),
|
|
14337
|
+
from: node
|
|
14338
|
+
});
|
|
14339
|
+
} catch (_) {
|
|
14340
|
+
arrayPush(DOMPurify.removed, {
|
|
14341
|
+
attribute: null,
|
|
14342
|
+
from: node
|
|
14343
|
+
});
|
|
14344
|
+
}
|
|
14345
|
+
|
|
14346
|
+
node.removeAttribute(name);
|
|
14347
|
+
|
|
14348
|
+
// We void attribute values for unremovable "is"" attributes
|
|
14349
|
+
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
|
14350
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
14351
|
+
try {
|
|
14352
|
+
_forceRemove(node);
|
|
14353
|
+
} catch (_) {}
|
|
14354
|
+
} else {
|
|
14355
|
+
try {
|
|
14356
|
+
node.setAttribute(name, '');
|
|
14357
|
+
} catch (_) {}
|
|
14358
|
+
}
|
|
14359
|
+
}
|
|
14360
|
+
};
|
|
14361
|
+
|
|
14362
|
+
/**
|
|
14363
|
+
* _initDocument
|
|
14364
|
+
*
|
|
14365
|
+
* @param {String} dirty a string of dirty markup
|
|
14366
|
+
* @return {Document} a DOM, filled with the dirty markup
|
|
14367
|
+
*/
|
|
14368
|
+
var _initDocument = function _initDocument(dirty) {
|
|
14369
|
+
/* Create a HTML document */
|
|
14370
|
+
var doc = void 0;
|
|
14371
|
+
var leadingWhitespace = void 0;
|
|
14372
|
+
|
|
14373
|
+
if (FORCE_BODY) {
|
|
14374
|
+
dirty = '<remove></remove>' + dirty;
|
|
14375
|
+
} else {
|
|
14376
|
+
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
|
14377
|
+
var matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
14378
|
+
leadingWhitespace = matches && matches[0];
|
|
14379
|
+
}
|
|
14380
|
+
|
|
14381
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
|
|
14382
|
+
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
14383
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
14384
|
+
}
|
|
14385
|
+
|
|
14386
|
+
var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
14387
|
+
/*
|
|
14388
|
+
* Use the DOMParser API by default, fallback later if needs be
|
|
14389
|
+
* DOMParser not work for svg when has multiple root element.
|
|
14390
|
+
*/
|
|
14391
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
14392
|
+
try {
|
|
14393
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
14394
|
+
} catch (_) {}
|
|
14395
|
+
}
|
|
14396
|
+
|
|
14397
|
+
/* Use createHTMLDocument in case DOMParser is not available */
|
|
14398
|
+
if (!doc || !doc.documentElement) {
|
|
14399
|
+
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
14400
|
+
try {
|
|
14401
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
|
|
14402
|
+
} catch (_) {
|
|
14403
|
+
// Syntax error if dirtyPayload is invalid xml
|
|
14404
|
+
}
|
|
14405
|
+
}
|
|
14406
|
+
|
|
14407
|
+
var body = doc.body || doc.documentElement;
|
|
14408
|
+
|
|
14409
|
+
if (dirty && leadingWhitespace) {
|
|
14410
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
14411
|
+
}
|
|
14412
|
+
|
|
14413
|
+
/* Work on whole document or just its body */
|
|
14414
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
14415
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
14416
|
+
}
|
|
14417
|
+
|
|
14418
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
14419
|
+
};
|
|
14420
|
+
|
|
14421
|
+
/**
|
|
14422
|
+
* _createIterator
|
|
14423
|
+
*
|
|
14424
|
+
* @param {Document} root document/fragment to create iterator for
|
|
14425
|
+
* @return {Iterator} iterator instance
|
|
14426
|
+
*/
|
|
14427
|
+
var _createIterator = function _createIterator(root) {
|
|
14428
|
+
return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
|
|
14429
|
+
};
|
|
14430
|
+
|
|
14431
|
+
/**
|
|
14432
|
+
* _isClobbered
|
|
14433
|
+
*
|
|
14434
|
+
* @param {Node} elm element to check for clobbering attacks
|
|
14435
|
+
* @return {Boolean} true if clobbered, false if safe
|
|
14436
|
+
*/
|
|
14437
|
+
var _isClobbered = function _isClobbered(elm) {
|
|
14438
|
+
if (elm instanceof Text || elm instanceof Comment) {
|
|
14439
|
+
return false;
|
|
14440
|
+
}
|
|
14441
|
+
|
|
14442
|
+
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') {
|
|
14443
|
+
return true;
|
|
14444
|
+
}
|
|
14445
|
+
|
|
14446
|
+
return false;
|
|
14447
|
+
};
|
|
14448
|
+
|
|
14449
|
+
/**
|
|
14450
|
+
* _isNode
|
|
14451
|
+
*
|
|
14452
|
+
* @param {Node} obj object to check whether it's a DOM node
|
|
14453
|
+
* @return {Boolean} true is object is a DOM node
|
|
14454
|
+
*/
|
|
14455
|
+
var _isNode = function _isNode(object) {
|
|
14456
|
+
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';
|
|
14457
|
+
};
|
|
14458
|
+
|
|
14459
|
+
/**
|
|
14460
|
+
* _executeHook
|
|
14461
|
+
* Execute user configurable hooks
|
|
14462
|
+
*
|
|
14463
|
+
* @param {String} entryPoint Name of the hook's entry point
|
|
14464
|
+
* @param {Node} currentNode node to work on with the hook
|
|
14465
|
+
* @param {Object} data additional hook parameters
|
|
14466
|
+
*/
|
|
14467
|
+
var _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
|
14468
|
+
if (!hooks[entryPoint]) {
|
|
14469
|
+
return;
|
|
14470
|
+
}
|
|
14471
|
+
|
|
14472
|
+
arrayForEach(hooks[entryPoint], function (hook) {
|
|
14473
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
14474
|
+
});
|
|
14475
|
+
};
|
|
14476
|
+
|
|
14477
|
+
/**
|
|
14478
|
+
* _sanitizeElements
|
|
14479
|
+
*
|
|
14480
|
+
* @protect nodeName
|
|
14481
|
+
* @protect textContent
|
|
14482
|
+
* @protect removeChild
|
|
14483
|
+
*
|
|
14484
|
+
* @param {Node} currentNode to check for permission to exist
|
|
14485
|
+
* @return {Boolean} true if node was killed, false if left alive
|
|
14486
|
+
*/
|
|
14487
|
+
var _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
14488
|
+
var content = void 0;
|
|
14489
|
+
|
|
14490
|
+
/* Execute a hook if present */
|
|
14491
|
+
_executeHook('beforeSanitizeElements', currentNode, null);
|
|
14492
|
+
|
|
14493
|
+
/* Check if element is clobbered or can clobber */
|
|
14494
|
+
if (_isClobbered(currentNode)) {
|
|
14495
|
+
_forceRemove(currentNode);
|
|
14496
|
+
return true;
|
|
14497
|
+
}
|
|
14498
|
+
|
|
14499
|
+
/* Check if tagname contains Unicode */
|
|
14500
|
+
if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) {
|
|
14501
|
+
_forceRemove(currentNode);
|
|
14502
|
+
return true;
|
|
14503
|
+
}
|
|
14504
|
+
|
|
14505
|
+
/* Now let's check the element's type and name */
|
|
14506
|
+
var tagName = transformCaseFunc(currentNode.nodeName);
|
|
14507
|
+
|
|
14508
|
+
/* Execute a hook if present */
|
|
14509
|
+
_executeHook('uponSanitizeElement', currentNode, {
|
|
14510
|
+
tagName: tagName,
|
|
14511
|
+
allowedTags: ALLOWED_TAGS
|
|
13692
14512
|
});
|
|
14513
|
+
|
|
14514
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
14515
|
+
if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
14516
|
+
_forceRemove(currentNode);
|
|
14517
|
+
return true;
|
|
14518
|
+
}
|
|
14519
|
+
|
|
14520
|
+
/* Mitigate a problem with templates inside select */
|
|
14521
|
+
if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
|
|
14522
|
+
_forceRemove(currentNode);
|
|
14523
|
+
return true;
|
|
14524
|
+
}
|
|
14525
|
+
|
|
14526
|
+
/* Remove element if anything forbids its presence */
|
|
14527
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
14528
|
+
/* Keep content except for bad-listed elements */
|
|
14529
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
14530
|
+
var parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
14531
|
+
var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
14532
|
+
|
|
14533
|
+
if (childNodes && parentNode) {
|
|
14534
|
+
var childCount = childNodes.length;
|
|
14535
|
+
|
|
14536
|
+
for (var i = childCount - 1; i >= 0; --i) {
|
|
14537
|
+
parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
|
|
14538
|
+
}
|
|
14539
|
+
}
|
|
14540
|
+
}
|
|
14541
|
+
|
|
14542
|
+
_forceRemove(currentNode);
|
|
14543
|
+
return true;
|
|
14544
|
+
}
|
|
14545
|
+
|
|
14546
|
+
/* Check whether element has a valid namespace */
|
|
14547
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
14548
|
+
_forceRemove(currentNode);
|
|
14549
|
+
return true;
|
|
14550
|
+
}
|
|
14551
|
+
|
|
14552
|
+
if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
|
|
14553
|
+
_forceRemove(currentNode);
|
|
14554
|
+
return true;
|
|
14555
|
+
}
|
|
14556
|
+
|
|
14557
|
+
/* Sanitize element content to be template-safe */
|
|
14558
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
|
|
14559
|
+
/* Get the element's text content */
|
|
14560
|
+
content = currentNode.textContent;
|
|
14561
|
+
content = stringReplace(content, MUSTACHE_EXPR$$1, ' ');
|
|
14562
|
+
content = stringReplace(content, ERB_EXPR$$1, ' ');
|
|
14563
|
+
if (currentNode.textContent !== content) {
|
|
14564
|
+
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
|
14565
|
+
currentNode.textContent = content;
|
|
14566
|
+
}
|
|
14567
|
+
}
|
|
14568
|
+
|
|
14569
|
+
/* Execute a hook if present */
|
|
14570
|
+
_executeHook('afterSanitizeElements', currentNode, null);
|
|
14571
|
+
|
|
14572
|
+
return false;
|
|
14573
|
+
};
|
|
14574
|
+
|
|
14575
|
+
/**
|
|
14576
|
+
* _isValidAttribute
|
|
14577
|
+
*
|
|
14578
|
+
* @param {string} lcTag Lowercase tag name of containing element.
|
|
14579
|
+
* @param {string} lcName Lowercase attribute name.
|
|
14580
|
+
* @param {string} value Attribute value.
|
|
14581
|
+
* @return {Boolean} Returns true if `value` is valid, otherwise false.
|
|
14582
|
+
*/
|
|
14583
|
+
// eslint-disable-next-line complexity
|
|
14584
|
+
var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
14585
|
+
/* Make sure attribute cannot clobber */
|
|
14586
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
14587
|
+
return false;
|
|
14588
|
+
}
|
|
14589
|
+
|
|
14590
|
+
/* Allow valid data-* attributes: At least one character after "-"
|
|
14591
|
+
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
14592
|
+
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
14593
|
+
We don't need to check the value; it's always URI safe. */
|
|
14594
|
+
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]) {
|
|
14595
|
+
return false;
|
|
14596
|
+
|
|
14597
|
+
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
14598
|
+
} 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 {
|
|
14599
|
+
return false;
|
|
14600
|
+
}
|
|
14601
|
+
|
|
14602
|
+
return true;
|
|
14603
|
+
};
|
|
14604
|
+
|
|
14605
|
+
/**
|
|
14606
|
+
* _sanitizeAttributes
|
|
14607
|
+
*
|
|
14608
|
+
* @protect attributes
|
|
14609
|
+
* @protect nodeName
|
|
14610
|
+
* @protect removeAttribute
|
|
14611
|
+
* @protect setAttribute
|
|
14612
|
+
*
|
|
14613
|
+
* @param {Node} currentNode to sanitize
|
|
14614
|
+
*/
|
|
14615
|
+
var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
14616
|
+
var attr = void 0;
|
|
14617
|
+
var value = void 0;
|
|
14618
|
+
var lcName = void 0;
|
|
14619
|
+
var l = void 0;
|
|
14620
|
+
/* Execute a hook if present */
|
|
14621
|
+
_executeHook('beforeSanitizeAttributes', currentNode, null);
|
|
14622
|
+
|
|
14623
|
+
var attributes = currentNode.attributes;
|
|
14624
|
+
|
|
14625
|
+
/* Check if we have attributes; if not we might have a text node */
|
|
14626
|
+
|
|
14627
|
+
if (!attributes) {
|
|
14628
|
+
return;
|
|
14629
|
+
}
|
|
14630
|
+
|
|
14631
|
+
var hookEvent = {
|
|
14632
|
+
attrName: '',
|
|
14633
|
+
attrValue: '',
|
|
14634
|
+
keepAttr: true,
|
|
14635
|
+
allowedAttributes: ALLOWED_ATTR
|
|
14636
|
+
};
|
|
14637
|
+
l = attributes.length;
|
|
14638
|
+
|
|
14639
|
+
/* Go backwards over all attributes; safely remove bad ones */
|
|
14640
|
+
while (l--) {
|
|
14641
|
+
attr = attributes[l];
|
|
14642
|
+
var _attr = attr,
|
|
14643
|
+
name = _attr.name,
|
|
14644
|
+
namespaceURI = _attr.namespaceURI;
|
|
14645
|
+
|
|
14646
|
+
value = stringTrim(attr.value);
|
|
14647
|
+
lcName = transformCaseFunc(name);
|
|
14648
|
+
|
|
14649
|
+
/* Execute a hook if present */
|
|
14650
|
+
hookEvent.attrName = lcName;
|
|
14651
|
+
hookEvent.attrValue = value;
|
|
14652
|
+
hookEvent.keepAttr = true;
|
|
14653
|
+
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
14654
|
+
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
|
|
14655
|
+
value = hookEvent.attrValue;
|
|
14656
|
+
/* Did the hooks approve of the attribute? */
|
|
14657
|
+
if (hookEvent.forceKeepAttr) {
|
|
14658
|
+
continue;
|
|
14659
|
+
}
|
|
14660
|
+
|
|
14661
|
+
/* Remove attribute */
|
|
14662
|
+
_removeAttribute(name, currentNode);
|
|
14663
|
+
|
|
14664
|
+
/* Did the hooks approve of the attribute? */
|
|
14665
|
+
if (!hookEvent.keepAttr) {
|
|
14666
|
+
continue;
|
|
14667
|
+
}
|
|
14668
|
+
|
|
14669
|
+
/* Work around a security issue in jQuery 3.0 */
|
|
14670
|
+
if (regExpTest(/\/>/i, value)) {
|
|
14671
|
+
_removeAttribute(name, currentNode);
|
|
14672
|
+
continue;
|
|
14673
|
+
}
|
|
14674
|
+
|
|
14675
|
+
/* Sanitize attribute content to be template-safe */
|
|
14676
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
14677
|
+
value = stringReplace(value, MUSTACHE_EXPR$$1, ' ');
|
|
14678
|
+
value = stringReplace(value, ERB_EXPR$$1, ' ');
|
|
14679
|
+
}
|
|
14680
|
+
|
|
14681
|
+
/* Is `value` valid for this attribute? */
|
|
14682
|
+
var lcTag = transformCaseFunc(currentNode.nodeName);
|
|
14683
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
14684
|
+
continue;
|
|
14685
|
+
}
|
|
14686
|
+
|
|
14687
|
+
/* Handle invalid data-* attribute set by try-catching it */
|
|
14688
|
+
try {
|
|
14689
|
+
if (namespaceURI) {
|
|
14690
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
14691
|
+
} else {
|
|
14692
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
14693
|
+
currentNode.setAttribute(name, value);
|
|
14694
|
+
}
|
|
14695
|
+
|
|
14696
|
+
arrayPop(DOMPurify.removed);
|
|
14697
|
+
} catch (_) {}
|
|
14698
|
+
}
|
|
14699
|
+
|
|
14700
|
+
/* Execute a hook if present */
|
|
14701
|
+
_executeHook('afterSanitizeAttributes', currentNode, null);
|
|
14702
|
+
};
|
|
14703
|
+
|
|
14704
|
+
/**
|
|
14705
|
+
* _sanitizeShadowDOM
|
|
14706
|
+
*
|
|
14707
|
+
* @param {DocumentFragment} fragment to iterate over recursively
|
|
14708
|
+
*/
|
|
14709
|
+
var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
14710
|
+
var shadowNode = void 0;
|
|
14711
|
+
var shadowIterator = _createIterator(fragment);
|
|
14712
|
+
|
|
14713
|
+
/* Execute a hook if present */
|
|
14714
|
+
_executeHook('beforeSanitizeShadowDOM', fragment, null);
|
|
14715
|
+
|
|
14716
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
14717
|
+
/* Execute a hook if present */
|
|
14718
|
+
_executeHook('uponSanitizeShadowNode', shadowNode, null);
|
|
14719
|
+
|
|
14720
|
+
/* Sanitize tags and elements */
|
|
14721
|
+
if (_sanitizeElements(shadowNode)) {
|
|
14722
|
+
continue;
|
|
14723
|
+
}
|
|
14724
|
+
|
|
14725
|
+
/* Deep shadow DOM detected */
|
|
14726
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
14727
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
14728
|
+
}
|
|
14729
|
+
|
|
14730
|
+
/* Check attributes, sanitize if necessary */
|
|
14731
|
+
_sanitizeAttributes(shadowNode);
|
|
14732
|
+
}
|
|
14733
|
+
|
|
14734
|
+
/* Execute a hook if present */
|
|
14735
|
+
_executeHook('afterSanitizeShadowDOM', fragment, null);
|
|
14736
|
+
};
|
|
14737
|
+
|
|
14738
|
+
/**
|
|
14739
|
+
* Sanitize
|
|
14740
|
+
* Public method providing core sanitation functionality
|
|
14741
|
+
*
|
|
14742
|
+
* @param {String|Node} dirty string or DOM node
|
|
14743
|
+
* @param {Object} configuration object
|
|
14744
|
+
*/
|
|
14745
|
+
// eslint-disable-next-line complexity
|
|
14746
|
+
DOMPurify.sanitize = function (dirty, cfg) {
|
|
14747
|
+
var body = void 0;
|
|
14748
|
+
var importedNode = void 0;
|
|
14749
|
+
var currentNode = void 0;
|
|
14750
|
+
var oldNode = void 0;
|
|
14751
|
+
var returnNode = void 0;
|
|
14752
|
+
/* Make sure we have a string to sanitize.
|
|
14753
|
+
DO NOT return early, as this will return the wrong type if
|
|
14754
|
+
the user has requested a DOM object rather than a string */
|
|
14755
|
+
IS_EMPTY_INPUT = !dirty;
|
|
14756
|
+
if (IS_EMPTY_INPUT) {
|
|
14757
|
+
dirty = '<!-->';
|
|
14758
|
+
}
|
|
14759
|
+
|
|
14760
|
+
/* Stringify, in case dirty is an object */
|
|
14761
|
+
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
14762
|
+
// eslint-disable-next-line no-negated-condition
|
|
14763
|
+
if (typeof dirty.toString !== 'function') {
|
|
14764
|
+
throw typeErrorCreate('toString is not a function');
|
|
14765
|
+
} else {
|
|
14766
|
+
dirty = dirty.toString();
|
|
14767
|
+
if (typeof dirty !== 'string') {
|
|
14768
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
14769
|
+
}
|
|
14770
|
+
}
|
|
14771
|
+
}
|
|
14772
|
+
|
|
14773
|
+
/* Check we can run. Otherwise fall back or ignore */
|
|
14774
|
+
if (!DOMPurify.isSupported) {
|
|
14775
|
+
if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
|
|
14776
|
+
if (typeof dirty === 'string') {
|
|
14777
|
+
return window.toStaticHTML(dirty);
|
|
14778
|
+
}
|
|
14779
|
+
|
|
14780
|
+
if (_isNode(dirty)) {
|
|
14781
|
+
return window.toStaticHTML(dirty.outerHTML);
|
|
14782
|
+
}
|
|
14783
|
+
}
|
|
14784
|
+
|
|
14785
|
+
return dirty;
|
|
14786
|
+
}
|
|
14787
|
+
|
|
14788
|
+
/* Assign config vars */
|
|
14789
|
+
if (!SET_CONFIG) {
|
|
14790
|
+
_parseConfig(cfg);
|
|
14791
|
+
}
|
|
14792
|
+
|
|
14793
|
+
/* Clean up removed elements */
|
|
14794
|
+
DOMPurify.removed = [];
|
|
14795
|
+
|
|
14796
|
+
/* Check if dirty is correctly typed for IN_PLACE */
|
|
14797
|
+
if (typeof dirty === 'string') {
|
|
14798
|
+
IN_PLACE = false;
|
|
14799
|
+
}
|
|
14800
|
+
|
|
14801
|
+
if (IN_PLACE) ; else if (dirty instanceof Node) {
|
|
14802
|
+
/* If dirty is a DOM element, append to an empty document to avoid
|
|
14803
|
+
elements being stripped by the parser */
|
|
14804
|
+
body = _initDocument('<!---->');
|
|
14805
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
14806
|
+
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
|
|
14807
|
+
/* Node is already a body, use as is */
|
|
14808
|
+
body = importedNode;
|
|
14809
|
+
} else if (importedNode.nodeName === 'HTML') {
|
|
14810
|
+
body = importedNode;
|
|
14811
|
+
} else {
|
|
14812
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
14813
|
+
body.appendChild(importedNode);
|
|
14814
|
+
}
|
|
14815
|
+
} else {
|
|
14816
|
+
/* Exit directly if we have nothing to do */
|
|
14817
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
14818
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
14819
|
+
dirty.indexOf('<') === -1) {
|
|
14820
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
14821
|
+
}
|
|
14822
|
+
|
|
14823
|
+
/* Initialize the document to work on */
|
|
14824
|
+
body = _initDocument(dirty);
|
|
14825
|
+
|
|
14826
|
+
/* Check we have a DOM node from the data */
|
|
14827
|
+
if (!body) {
|
|
14828
|
+
return RETURN_DOM ? null : emptyHTML;
|
|
14829
|
+
}
|
|
14830
|
+
}
|
|
14831
|
+
|
|
14832
|
+
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
14833
|
+
if (body && FORCE_BODY) {
|
|
14834
|
+
_forceRemove(body.firstChild);
|
|
14835
|
+
}
|
|
14836
|
+
|
|
14837
|
+
/* Get node iterator */
|
|
14838
|
+
var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
|
|
14839
|
+
|
|
14840
|
+
/* Now start iterating over the created document */
|
|
14841
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
14842
|
+
/* Fix IE's strange behavior with manipulated textNodes #89 */
|
|
14843
|
+
if (currentNode.nodeType === 3 && currentNode === oldNode) {
|
|
14844
|
+
continue;
|
|
14845
|
+
}
|
|
14846
|
+
|
|
14847
|
+
/* Sanitize tags and elements */
|
|
14848
|
+
if (_sanitizeElements(currentNode)) {
|
|
14849
|
+
continue;
|
|
14850
|
+
}
|
|
14851
|
+
|
|
14852
|
+
/* Shadow DOM detected, sanitize it */
|
|
14853
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
14854
|
+
_sanitizeShadowDOM(currentNode.content);
|
|
14855
|
+
}
|
|
14856
|
+
|
|
14857
|
+
/* Check attributes, sanitize if necessary */
|
|
14858
|
+
_sanitizeAttributes(currentNode);
|
|
14859
|
+
|
|
14860
|
+
oldNode = currentNode;
|
|
14861
|
+
}
|
|
14862
|
+
|
|
14863
|
+
oldNode = null;
|
|
14864
|
+
|
|
14865
|
+
/* If we sanitized `dirty` in-place, return it. */
|
|
14866
|
+
if (IN_PLACE) {
|
|
14867
|
+
return dirty;
|
|
14868
|
+
}
|
|
14869
|
+
|
|
14870
|
+
/* Return sanitized string or DOM */
|
|
14871
|
+
if (RETURN_DOM) {
|
|
14872
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
14873
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
14874
|
+
|
|
14875
|
+
while (body.firstChild) {
|
|
14876
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
14877
|
+
returnNode.appendChild(body.firstChild);
|
|
14878
|
+
}
|
|
14879
|
+
} else {
|
|
14880
|
+
returnNode = body;
|
|
14881
|
+
}
|
|
14882
|
+
|
|
14883
|
+
if (RETURN_DOM_IMPORT) {
|
|
14884
|
+
/*
|
|
14885
|
+
AdoptNode() is not used because internal state is not reset
|
|
14886
|
+
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
14887
|
+
in theory but we would rather not risk another attack vector.
|
|
14888
|
+
The state that is cloned by importNode() is explicitly defined
|
|
14889
|
+
by the specs.
|
|
14890
|
+
*/
|
|
14891
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
14892
|
+
}
|
|
14893
|
+
|
|
14894
|
+
return returnNode;
|
|
14895
|
+
}
|
|
14896
|
+
|
|
14897
|
+
var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
14898
|
+
|
|
14899
|
+
/* Sanitize final string template-safe */
|
|
14900
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
14901
|
+
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' ');
|
|
14902
|
+
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' ');
|
|
14903
|
+
}
|
|
14904
|
+
|
|
14905
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
14906
|
+
};
|
|
14907
|
+
|
|
14908
|
+
/**
|
|
14909
|
+
* Public method to set the configuration once
|
|
14910
|
+
* setConfig
|
|
14911
|
+
*
|
|
14912
|
+
* @param {Object} cfg configuration object
|
|
14913
|
+
*/
|
|
14914
|
+
DOMPurify.setConfig = function (cfg) {
|
|
14915
|
+
_parseConfig(cfg);
|
|
14916
|
+
SET_CONFIG = true;
|
|
14917
|
+
};
|
|
14918
|
+
|
|
14919
|
+
/**
|
|
14920
|
+
* Public method to remove the configuration
|
|
14921
|
+
* clearConfig
|
|
14922
|
+
*
|
|
14923
|
+
*/
|
|
14924
|
+
DOMPurify.clearConfig = function () {
|
|
14925
|
+
CONFIG = null;
|
|
14926
|
+
SET_CONFIG = false;
|
|
14927
|
+
};
|
|
14928
|
+
|
|
14929
|
+
/**
|
|
14930
|
+
* Public method to check if an attribute value is valid.
|
|
14931
|
+
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
14932
|
+
* isValidAttribute
|
|
14933
|
+
*
|
|
14934
|
+
* @param {string} tag Tag name of containing element.
|
|
14935
|
+
* @param {string} attr Attribute name.
|
|
14936
|
+
* @param {string} value Attribute value.
|
|
14937
|
+
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
14938
|
+
*/
|
|
14939
|
+
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
14940
|
+
/* Initialize shared config vars if necessary. */
|
|
14941
|
+
if (!CONFIG) {
|
|
14942
|
+
_parseConfig({});
|
|
14943
|
+
}
|
|
14944
|
+
|
|
14945
|
+
var lcTag = transformCaseFunc(tag);
|
|
14946
|
+
var lcName = transformCaseFunc(attr);
|
|
14947
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
14948
|
+
};
|
|
14949
|
+
|
|
14950
|
+
/**
|
|
14951
|
+
* AddHook
|
|
14952
|
+
* Public method to add DOMPurify hooks
|
|
14953
|
+
*
|
|
14954
|
+
* @param {String} entryPoint entry point for the hook to add
|
|
14955
|
+
* @param {Function} hookFunction function to execute
|
|
14956
|
+
*/
|
|
14957
|
+
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
14958
|
+
if (typeof hookFunction !== 'function') {
|
|
14959
|
+
return;
|
|
14960
|
+
}
|
|
14961
|
+
|
|
14962
|
+
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
14963
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
14964
|
+
};
|
|
14965
|
+
|
|
14966
|
+
/**
|
|
14967
|
+
* RemoveHook
|
|
14968
|
+
* Public method to remove a DOMPurify hook at a given entryPoint
|
|
14969
|
+
* (pops it from the stack of hooks if more are present)
|
|
14970
|
+
*
|
|
14971
|
+
* @param {String} entryPoint entry point for the hook to remove
|
|
14972
|
+
*/
|
|
14973
|
+
DOMPurify.removeHook = function (entryPoint) {
|
|
14974
|
+
if (hooks[entryPoint]) {
|
|
14975
|
+
arrayPop(hooks[entryPoint]);
|
|
14976
|
+
}
|
|
14977
|
+
};
|
|
14978
|
+
|
|
14979
|
+
/**
|
|
14980
|
+
* RemoveHooks
|
|
14981
|
+
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
14982
|
+
*
|
|
14983
|
+
* @param {String} entryPoint entry point for the hooks to remove
|
|
14984
|
+
*/
|
|
14985
|
+
DOMPurify.removeHooks = function (entryPoint) {
|
|
14986
|
+
if (hooks[entryPoint]) {
|
|
14987
|
+
hooks[entryPoint] = [];
|
|
14988
|
+
}
|
|
14989
|
+
};
|
|
14990
|
+
|
|
14991
|
+
/**
|
|
14992
|
+
* RemoveAllHooks
|
|
14993
|
+
* Public method to remove all DOMPurify hooks
|
|
14994
|
+
*
|
|
14995
|
+
*/
|
|
14996
|
+
DOMPurify.removeAllHooks = function () {
|
|
14997
|
+
hooks = {};
|
|
14998
|
+
};
|
|
14999
|
+
|
|
15000
|
+
return DOMPurify;
|
|
13693
15001
|
}
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
15002
|
+
|
|
15003
|
+
var purify = createDOMPurify();
|
|
15004
|
+
|
|
15005
|
+
var CAN_BE_WHITE_TAG_LIST = ['iframe', 'embed'];
|
|
15006
|
+
var whiteTagList = [];
|
|
15007
|
+
function registerTagWhitelistIfPossible(tagName) {
|
|
15008
|
+
if (includes(CAN_BE_WHITE_TAG_LIST, tagName)) {
|
|
15009
|
+
whiteTagList.push(tagName.toLowerCase());
|
|
15010
|
+
}
|
|
15011
|
+
}
|
|
15012
|
+
function sanitizeHTML(html, options) {
|
|
15013
|
+
return purify.sanitize(html, __assign$1({ ADD_TAGS: whiteTagList, ADD_ATTR: ['rel', 'target', 'hreflang', 'type'], FORBID_TAGS: [
|
|
15014
|
+
'input',
|
|
15015
|
+
'script',
|
|
15016
|
+
'textarea',
|
|
15017
|
+
'form',
|
|
15018
|
+
'button',
|
|
15019
|
+
'select',
|
|
15020
|
+
'meta',
|
|
15021
|
+
'style',
|
|
15022
|
+
'link',
|
|
15023
|
+
'title',
|
|
15024
|
+
'object',
|
|
15025
|
+
'base',
|
|
15026
|
+
] }, options));
|
|
13697
15027
|
}
|
|
13698
15028
|
|
|
13699
15029
|
function getChildrenHTML(node, typeName) {
|
|
@@ -15945,7 +17275,7 @@ function getContentBetweenFragmentComments(html) {
|
|
|
15945
17275
|
if (startFragmentIndex > -1 && endFragmentIndex > -1) {
|
|
15946
17276
|
html = html.slice(startFragmentIndex + START_FRAGMENT_COMMENT.length, endFragmentIndex);
|
|
15947
17277
|
}
|
|
15948
|
-
return html;
|
|
17278
|
+
return html.replace(/<br[^>]*>/g, ALTERNATIVE_TAG_FOR_BR);
|
|
15949
17279
|
}
|
|
15950
17280
|
function convertMsoTableToCompletedTable(html) {
|
|
15951
17281
|
// wrap with <tr> if html contains dangling <td> tags
|
|
@@ -16033,9 +17363,9 @@ function createTableBody(tableBodyRows, maxColumnCount, schema) {
|
|
|
16033
17363
|
}
|
|
16034
17364
|
return schema.nodes.tableBody.create(null, copiedRows);
|
|
16035
17365
|
}
|
|
16036
|
-
function createTableFromPastingTable(rows, schema, startFromBody) {
|
|
17366
|
+
function createTableFromPastingTable(rows, schema, startFromBody, isInTable) {
|
|
16037
17367
|
var columnCount = getMaxColumnCount(rows);
|
|
16038
|
-
if (startFromBody) {
|
|
17368
|
+
if (startFromBody && isInTable) {
|
|
16039
17369
|
return schema.nodes.table.create(null, [createTableBody(rows, columnCount, schema)]);
|
|
16040
17370
|
}
|
|
16041
17371
|
var tableHeadRow = rows[0];
|
|
@@ -16046,15 +17376,16 @@ function createTableFromPastingTable(rows, schema, startFromBody) {
|
|
|
16046
17376
|
}
|
|
16047
17377
|
return schema.nodes.table.create(null, nodes);
|
|
16048
17378
|
}
|
|
16049
|
-
function changePastedSlice(slice, schema) {
|
|
17379
|
+
function changePastedSlice(slice, schema, isInTable) {
|
|
16050
17380
|
var nodes = [];
|
|
16051
|
-
slice.content.
|
|
17381
|
+
var content = slice.content, openStart = slice.openStart, openEnd = slice.openEnd;
|
|
17382
|
+
content.forEach(function (node) {
|
|
16052
17383
|
if (node.type.name === 'table') {
|
|
16053
17384
|
var tableContent = getTableContentFromSlice(new Slice(Fragment.from(node), 0, 0));
|
|
16054
17385
|
if (tableContent) {
|
|
16055
17386
|
var rows = createRowsFromPastingTable(tableContent);
|
|
16056
17387
|
var startFromBody = tableContent.firstChild.type.name === 'tableBody';
|
|
16057
|
-
var table = createTableFromPastingTable(rows, schema, startFromBody);
|
|
17388
|
+
var table = createTableFromPastingTable(rows, schema, startFromBody, isInTable);
|
|
16058
17389
|
nodes.push(table);
|
|
16059
17390
|
}
|
|
16060
17391
|
}
|
|
@@ -16062,7 +17393,7 @@ function changePastedSlice(slice, schema) {
|
|
|
16062
17393
|
nodes.push(node);
|
|
16063
17394
|
}
|
|
16064
17395
|
});
|
|
16065
|
-
return new Slice(Fragment.from(nodes),
|
|
17396
|
+
return new Slice(Fragment.from(nodes), openStart, openEnd);
|
|
16066
17397
|
}
|
|
16067
17398
|
|
|
16068
17399
|
var DUMMY_CELL_SIZE = 4;
|
|
@@ -17459,9 +18790,13 @@ var Image = /** @class */ (function (_super) {
|
|
|
17459
18790
|
{
|
|
17460
18791
|
tag: 'img[src]',
|
|
17461
18792
|
getAttrs: function (dom) {
|
|
17462
|
-
var
|
|
17463
|
-
|
|
17464
|
-
|
|
18793
|
+
var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
|
|
18794
|
+
.firstChild;
|
|
18795
|
+
var imageUrl = sanitizedDOM.getAttribute('src') || '';
|
|
18796
|
+
var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
|
|
18797
|
+
var altText = sanitizedDOM.getAttribute('alt');
|
|
18798
|
+
return __assign$1({ imageUrl: imageUrl,
|
|
18799
|
+
altText: altText }, (rawHTML && { rawHTML: rawHTML }));
|
|
17465
18800
|
},
|
|
17466
18801
|
},
|
|
17467
18802
|
],
|
|
@@ -17735,9 +19070,11 @@ var Link = /** @class */ (function (_super) {
|
|
|
17735
19070
|
{
|
|
17736
19071
|
tag: 'a[href]',
|
|
17737
19072
|
getAttrs: function (dom) {
|
|
17738
|
-
var
|
|
17739
|
-
|
|
17740
|
-
|
|
19073
|
+
var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
|
|
19074
|
+
.firstChild;
|
|
19075
|
+
var href = sanitizedDOM.getAttribute('href') || '';
|
|
19076
|
+
var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
|
|
19077
|
+
return __assign$1({ linkUrl: href, linkText: sanitizedDOM.textContent }, (rawHTML && { rawHTML: rawHTML }));
|
|
17741
19078
|
},
|
|
17742
19079
|
},
|
|
17743
19080
|
],
|
|
@@ -18041,7 +19378,9 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
18041
19378
|
_this.eventEmitter.emit('setFocusedNode', state.selection.$from.node(1));
|
|
18042
19379
|
},
|
|
18043
19380
|
transformPastedHTML: changePastedHTML,
|
|
18044
|
-
transformPasted: function (slice) {
|
|
19381
|
+
transformPasted: function (slice) {
|
|
19382
|
+
return changePastedSlice(slice, _this.schema, isInTableNode(_this.view.state.selection.$from));
|
|
19383
|
+
},
|
|
18045
19384
|
handlePaste: function (view, _, slice) { return pasteToTable(view, slice); },
|
|
18046
19385
|
handleKeyDown: function (_, ev) {
|
|
18047
19386
|
_this.eventEmitter.emit('keydown', _this.editorType, ev);
|
|
@@ -18050,8 +19389,8 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
18050
19389
|
handleDOMEvents: {
|
|
18051
19390
|
paste: function (_, ev) {
|
|
18052
19391
|
var clipboardData = ev.clipboardData || window.clipboardData;
|
|
18053
|
-
var items = clipboardData
|
|
18054
|
-
if (items) {
|
|
19392
|
+
var items = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.items;
|
|
19393
|
+
if ((items === null || items === void 0 ? void 0 : items.length) === 1) {
|
|
18055
19394
|
var imageBlob = pasteImageOnly(items);
|
|
18056
19395
|
if (imageBlob) {
|
|
18057
19396
|
ev.preventDefault();
|
|
@@ -18183,7 +19522,11 @@ var isNull = isNull_1;
|
|
|
18183
19522
|
* @returns {boolean} Is existy?
|
|
18184
19523
|
* @memberof module:type
|
|
18185
19524
|
* @example
|
|
18186
|
-
*
|
|
19525
|
+
* // ES6
|
|
19526
|
+
* import isExisty from 'tui-code-snippet/type/isExisty');
|
|
19527
|
+
*
|
|
19528
|
+
* // CommonJS
|
|
19529
|
+
* const isExisty = require('tui-code-snippet/type/isExisty');
|
|
18187
19530
|
*
|
|
18188
19531
|
* isExisty(''); //true
|
|
18189
19532
|
* isExisty(0); //true
|
|
@@ -18512,6 +19855,9 @@ function isInlineNode(_a) {
|
|
|
18512
19855
|
var type = _a.type;
|
|
18513
19856
|
return includes(['text', 'strong', 'emph', 'strike', 'image', 'link', 'code'], type);
|
|
18514
19857
|
}
|
|
19858
|
+
function isSoftbreak(mdNode) {
|
|
19859
|
+
return (mdNode === null || mdNode === void 0 ? void 0 : mdNode.type) === 'softbreak';
|
|
19860
|
+
}
|
|
18515
19861
|
function isListNode(_a) {
|
|
18516
19862
|
var type = _a.type, literal = _a.literal;
|
|
18517
19863
|
var matched = type === 'htmlInline' && literal.match(reHTMLTag);
|
|
@@ -18530,11 +19876,15 @@ function getListItemAttrs(_a) {
|
|
|
18530
19876
|
var checked = /data-task-checked/.test(literal);
|
|
18531
19877
|
return { task: task, checked: checked };
|
|
18532
19878
|
}
|
|
18533
|
-
function getMatchedAttributeValue(rawHTML
|
|
19879
|
+
function getMatchedAttributeValue(rawHTML) {
|
|
19880
|
+
var attrNames = [];
|
|
19881
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
19882
|
+
attrNames[_i - 1] = arguments[_i];
|
|
19883
|
+
}
|
|
18534
19884
|
var wrapper = document.createElement('div');
|
|
18535
|
-
wrapper.innerHTML = rawHTML;
|
|
19885
|
+
wrapper.innerHTML = sanitizeHTML(rawHTML);
|
|
18536
19886
|
var el = wrapper.firstChild;
|
|
18537
|
-
return el.getAttribute(attrName) || '';
|
|
19887
|
+
return attrNames.map(function (attrName) { return el.getAttribute(attrName) || ''; });
|
|
18538
19888
|
}
|
|
18539
19889
|
function createConvertors(convertors) {
|
|
18540
19890
|
var convertorMap = {};
|
|
@@ -18588,9 +19938,9 @@ var convertors = {
|
|
|
18588
19938
|
var tag = node.literal;
|
|
18589
19939
|
var link = state.schema.marks.link;
|
|
18590
19940
|
if (openTagName) {
|
|
18591
|
-
var linkUrl = getMatchedAttributeValue(tag, 'href');
|
|
19941
|
+
var linkUrl = getMatchedAttributeValue(tag, 'href')[0];
|
|
18592
19942
|
state.openMark(link.create({
|
|
18593
|
-
linkUrl:
|
|
19943
|
+
linkUrl: linkUrl,
|
|
18594
19944
|
rawHTML: openTagName,
|
|
18595
19945
|
}));
|
|
18596
19946
|
}
|
|
@@ -18600,11 +19950,10 @@ var convertors = {
|
|
|
18600
19950
|
},
|
|
18601
19951
|
img: function (state, node, openTagName) {
|
|
18602
19952
|
var tag = node.literal;
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
var altText = getMatchedAttributeValue(tag, 'alt');
|
|
19953
|
+
if (openTagName) {
|
|
19954
|
+
var _a = getMatchedAttributeValue(tag, 'src', 'alt'), imageUrl = _a[0], altText = _a[1];
|
|
18606
19955
|
var image = state.schema.nodes.image;
|
|
18607
|
-
state.addNode(image, __assign$1({ rawHTML: openTagName, imageUrl:
|
|
19956
|
+
state.addNode(image, __assign$1({ rawHTML: openTagName, imageUrl: imageUrl }, (altText && { altText: altText })));
|
|
18608
19957
|
}
|
|
18609
19958
|
},
|
|
18610
19959
|
hr: function (state, _, openTagName) {
|
|
@@ -18614,11 +19963,22 @@ var convertors = {
|
|
|
18614
19963
|
var paragraph = state.schema.nodes.paragraph;
|
|
18615
19964
|
var parent = node.parent, prev = node.prev, next = node.next;
|
|
18616
19965
|
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'paragraph') {
|
|
18617
|
-
|
|
19966
|
+
// should open a paragraph node when line text has only <br> tag
|
|
19967
|
+
// ex) first line\n\n<br>\nfourth line
|
|
19968
|
+
if (isSoftbreak(prev)) {
|
|
18618
19969
|
state.openNode(paragraph);
|
|
18619
19970
|
}
|
|
18620
|
-
|
|
19971
|
+
// should close a paragraph node when line text has only <br> tag
|
|
19972
|
+
// ex) first line\n\n<br>\nfourth line
|
|
19973
|
+
if (isSoftbreak(next)) {
|
|
19974
|
+
state.closeNode();
|
|
19975
|
+
// should close a paragraph node and open a paragraph node to separate between blocks
|
|
19976
|
+
// when <br> tag is in the middle of the paragraph
|
|
19977
|
+
// ex) first <br>line\nthird line
|
|
19978
|
+
}
|
|
19979
|
+
else if (next) {
|
|
18621
19980
|
state.closeNode();
|
|
19981
|
+
state.openNode(paragraph);
|
|
18622
19982
|
}
|
|
18623
19983
|
}
|
|
18624
19984
|
else if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'tableCell') {
|
|
@@ -18685,7 +20045,7 @@ var convertors = {
|
|
|
18685
20045
|
var htmlToWwConvertors = createConvertors(convertors);
|
|
18686
20046
|
|
|
18687
20047
|
function isBRTag(node) {
|
|
18688
|
-
return node.type === 'htmlInline' &&
|
|
20048
|
+
return node.type === 'htmlInline' && reBR.test(node.literal);
|
|
18689
20049
|
}
|
|
18690
20050
|
function addRawHTMLAttributeToDOM(parent) {
|
|
18691
20051
|
toArray_1(parent.childNodes).forEach(function (child) {
|
|
@@ -18933,10 +20293,11 @@ var toWwConvertors = {
|
|
|
18933
20293
|
var openTagName = matched[1], closeTagName = matched[3];
|
|
18934
20294
|
var typeName = (openTagName || closeTagName).toLowerCase();
|
|
18935
20295
|
var markType = state.schema.marks[typeName];
|
|
20296
|
+
var sanitizedHTML = sanitizeHTML(html);
|
|
18936
20297
|
// for user defined html schema
|
|
18937
20298
|
if (markType === null || markType === void 0 ? void 0 : markType.spec.attrs.htmlInline) {
|
|
18938
20299
|
if (openTagName) {
|
|
18939
|
-
var htmlAttrs = getHTMLAttrsByHTMLString(
|
|
20300
|
+
var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
|
|
18940
20301
|
state.openMark(markType.create({ htmlAttrs: htmlAttrs }));
|
|
18941
20302
|
}
|
|
18942
20303
|
else {
|
|
@@ -18957,14 +20318,15 @@ var toWwConvertors = {
|
|
|
18957
20318
|
var openTagName = matched[1], closeTagName = matched[3];
|
|
18958
20319
|
var typeName = (openTagName || closeTagName).toLowerCase();
|
|
18959
20320
|
var nodeType = state.schema.nodes[typeName];
|
|
20321
|
+
var sanitizedHTML = sanitizeHTML(html);
|
|
18960
20322
|
// for user defined html schema
|
|
18961
20323
|
if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
|
|
18962
|
-
var htmlAttrs = getHTMLAttrsByHTMLString(
|
|
20324
|
+
var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
|
|
18963
20325
|
var childrenHTML = getChildrenHTML(node, typeName);
|
|
18964
20326
|
state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
|
|
18965
20327
|
}
|
|
18966
20328
|
else {
|
|
18967
|
-
container.innerHTML =
|
|
20329
|
+
container.innerHTML = sanitizedHTML;
|
|
18968
20330
|
addRawHTMLAttributeToDOM(container);
|
|
18969
20331
|
state.convertByDOMParser(container);
|
|
18970
20332
|
}
|
|
@@ -20079,6 +21441,14 @@ function getPluginInfo(plugins, eventEmitter, usageStatistics) {
|
|
|
20079
21441
|
var TASK_ATTR_NAME = 'data-task';
|
|
20080
21442
|
var DISABLED_TASK_ATTR_NAME = 'data-task-disabled';
|
|
20081
21443
|
var TASK_CHECKED_CLASS_NAME = 'checked';
|
|
21444
|
+
function registerHTMLTagToWhitelist(convertorMap) {
|
|
21445
|
+
['htmlBlock', 'htmlInline'].forEach(function (htmlType) {
|
|
21446
|
+
if (convertorMap[htmlType]) {
|
|
21447
|
+
// register tag white list for preventing to remove the html in sanitizer
|
|
21448
|
+
Object.keys(convertorMap[htmlType]).forEach(function (type) { return registerTagWhitelistIfPossible(type); });
|
|
21449
|
+
}
|
|
21450
|
+
});
|
|
21451
|
+
}
|
|
20082
21452
|
/**
|
|
20083
21453
|
* Class ToastUIEditorViewer
|
|
20084
21454
|
* @param {object} options Option object
|
|
@@ -20124,6 +21494,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
|
|
|
20124
21494
|
frontMatter: frontMatter,
|
|
20125
21495
|
sanitizer: customHTMLSanitizer || sanitizeHTML,
|
|
20126
21496
|
};
|
|
21497
|
+
registerHTMLTagToWhitelist(rendererOptions.customHTMLRenderer);
|
|
20127
21498
|
if (this.options.events) {
|
|
20128
21499
|
forEachOwnProperties_1(this.options.events, function (fn, key) {
|
|
20129
21500
|
_this.on(key, fn);
|
|
@@ -20602,7 +21973,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
20602
21973
|
var ToastUIEditorCore = /** @class */ (function () {
|
|
20603
21974
|
function ToastUIEditorCore(options) {
|
|
20604
21975
|
var _this = this;
|
|
20605
|
-
this.
|
|
21976
|
+
this.initialHTML = options.el.innerHTML;
|
|
20606
21977
|
options.el.innerHTML = '';
|
|
20607
21978
|
this.options = extend_1({
|
|
20608
21979
|
previewStyle: 'tab',
|
|
@@ -20636,6 +22007,8 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
20636
22007
|
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;
|
|
20637
22008
|
this.mode = initialEditType || 'markdown';
|
|
20638
22009
|
this.mdPreviewStyle = this.options.previewStyle;
|
|
22010
|
+
this.i18n = i18n;
|
|
22011
|
+
this.i18n.setCode(this.options.language);
|
|
20639
22012
|
this.eventEmitter = new EventEmitter();
|
|
20640
22013
|
setWidgetRules(widgetRules);
|
|
20641
22014
|
var linkAttributes = sanitizeLinkAttribute(this.options.linkAttributes);
|
|
@@ -20651,8 +22024,6 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
20651
22024
|
};
|
|
20652
22025
|
var wwToDOMAdaptor = new WwToDOMAdaptor(linkAttributes, rendererOptions.customHTMLRenderer);
|
|
20653
22026
|
var htmlSchemaMap = createHTMLSchemaMap(rendererOptions.customHTMLRenderer, rendererOptions.sanitizer, wwToDOMAdaptor);
|
|
20654
|
-
this.i18n = i18n;
|
|
20655
|
-
this.i18n.setCode(this.options.language);
|
|
20656
22027
|
this.toastMark = new ToastMark('', {
|
|
20657
22028
|
disallowedHtmlBlockTags: ['br', 'img'],
|
|
20658
22029
|
extendedAutolinks: extendedAutolinks,
|
|
@@ -20683,7 +22054,7 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
20683
22054
|
this.setPlaceholder(this.options.placeholder);
|
|
20684
22055
|
}
|
|
20685
22056
|
if (!this.options.initialValue) {
|
|
20686
|
-
this.setHTML(this.
|
|
22057
|
+
this.setHTML(this.initialHTML, false);
|
|
20687
22058
|
}
|
|
20688
22059
|
this.commandManager = new CommandManager(this.eventEmitter, this.mdEditor.commands, this.wwEditor.commands, function () { return _this.mode; });
|
|
20689
22060
|
if (this.options.usageStatistics) {
|
|
@@ -20880,16 +22251,13 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
20880
22251
|
ToastUIEditorCore.prototype.getHTML = function () {
|
|
20881
22252
|
var _this = this;
|
|
20882
22253
|
this.eventEmitter.holdEventInvoke(function () {
|
|
20883
|
-
if (_this.
|
|
20884
|
-
_this.
|
|
22254
|
+
if (_this.isMarkdownMode()) {
|
|
22255
|
+
var mdNode = _this.toastMark.getRootNode();
|
|
22256
|
+
var wwNode = _this.convertor.toWysiwygModel(mdNode);
|
|
22257
|
+
_this.wwEditor.setModel(wwNode);
|
|
20885
22258
|
}
|
|
20886
22259
|
});
|
|
20887
|
-
|
|
20888
|
-
var mdRenderer = this.preview.getRenderer();
|
|
20889
|
-
return mdRenderer
|
|
20890
|
-
.render(mdNode)
|
|
20891
|
-
.replace(/\sdata-nodeid="\d{1,}"/g, '')
|
|
20892
|
-
.trim();
|
|
22260
|
+
return this.wwEditor.view.dom.innerHTML;
|
|
20893
22261
|
};
|
|
20894
22262
|
/**
|
|
20895
22263
|
* Insert text
|
|
@@ -21696,11 +23064,15 @@ var templateObject_1$h;
|
|
|
21696
23064
|
* @returns {function} debounced function.
|
|
21697
23065
|
* @memberof module:tricks
|
|
21698
23066
|
* @example
|
|
21699
|
-
*
|
|
23067
|
+
* // ES6
|
|
23068
|
+
* import debounce from 'tui-code-snippet/tricks/debounce';
|
|
23069
|
+
*
|
|
23070
|
+
* // CommonJS
|
|
23071
|
+
* const debounce = require('tui-code-snippet/tricks/debounce');
|
|
21700
23072
|
*
|
|
21701
23073
|
* function someMethodToInvokeDebounced() {}
|
|
21702
23074
|
*
|
|
21703
|
-
*
|
|
23075
|
+
* const debounced = debounce(someMethodToInvokeDebounced, 300);
|
|
21704
23076
|
*
|
|
21705
23077
|
* // invoke repeatedly
|
|
21706
23078
|
* debounced();
|
|
@@ -21748,11 +23120,15 @@ var debounce = debounce_1;
|
|
|
21748
23120
|
* @returns {function} throttled function
|
|
21749
23121
|
* @memberof module:tricks
|
|
21750
23122
|
* @example
|
|
21751
|
-
*
|
|
23123
|
+
* // ES6
|
|
23124
|
+
* import throttle from 'tui-code-snippet/tricks/throttle';
|
|
23125
|
+
*
|
|
23126
|
+
* // CommonJS
|
|
23127
|
+
* const throttle = require('tui-code-snippet/tricks/throttle');
|
|
21752
23128
|
*
|
|
21753
23129
|
* function someMethodToInvokeThrottled() {}
|
|
21754
23130
|
*
|
|
21755
|
-
*
|
|
23131
|
+
* const throttled = throttle(someMethodToInvokeThrottled, 300);
|
|
21756
23132
|
*
|
|
21757
23133
|
* // invoke repeatedly
|
|
21758
23134
|
* throttled(); // invoke (leading)
|
|
@@ -23042,10 +24418,8 @@ var templateObject_1$c, templateObject_2$6, templateObject_3$2, templateObject_4
|
|
|
23042
24418
|
|
|
23043
24419
|
var CustomPopupBody = /** @class */ (function (_super) {
|
|
23044
24420
|
__extends$1(CustomPopupBody, _super);
|
|
23045
|
-
function CustomPopupBody(
|
|
23046
|
-
|
|
23047
|
-
props.eventEmitter.listen('closePopup', _this.props.hidePopup);
|
|
23048
|
-
return _this;
|
|
24421
|
+
function CustomPopupBody() {
|
|
24422
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23049
24423
|
}
|
|
23050
24424
|
CustomPopupBody.prototype.mounted = function () {
|
|
23051
24425
|
// append the custom popup body element
|
|
@@ -23327,6 +24701,7 @@ var Popup = /** @class */ (function (_super) {
|
|
|
23327
24701
|
}
|
|
23328
24702
|
Popup.prototype.mounted = function () {
|
|
23329
24703
|
document.addEventListener('mousedown', this.handleMousedown);
|
|
24704
|
+
this.props.eventEmitter.listen('closePopup', this.props.hidePopup);
|
|
23330
24705
|
};
|
|
23331
24706
|
Popup.prototype.beforeDestroy = function () {
|
|
23332
24707
|
document.removeEventListener('mousedown', this.handleMousedown);
|