@toast-ui/editor 3.0.3 → 3.1.3
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 +10 -7
- 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 +2587 -887
- package/dist/esm/indexViewer.js +1674 -306
- package/dist/i18n/ar.js +5 -5
- package/dist/i18n/cs-cz.js +5 -5
- package/dist/i18n/de-de.js +5 -5
- package/dist/i18n/es-es.js +5 -5
- package/dist/i18n/fi-fi.js +5 -5
- package/dist/i18n/fr-fr.js +5 -5
- package/dist/i18n/gl-es.js +5 -5
- package/dist/i18n/hr-hr.js +5 -5
- package/dist/i18n/it-it.js +5 -5
- package/dist/i18n/ja-jp.js +5 -5
- package/dist/i18n/ko-kr.js +5 -5
- package/dist/i18n/nb-no.js +5 -5
- package/dist/i18n/nl-nl.js +5 -5
- package/dist/i18n/pl-pl.js +5 -5
- package/dist/i18n/pt-br.js +5 -5
- package/dist/i18n/ru-ru.js +5 -5
- package/dist/i18n/sv-se.js +5 -5
- package/dist/i18n/tr-tr.js +5 -5
- package/dist/i18n/uk-ua.js +5 -5
- package/dist/i18n/zh-cn.js +5 -5
- package/dist/i18n/zh-tw.js +5 -5
- package/dist/toastui-editor-only.css +1 -1
- package/dist/toastui-editor-viewer.css +6 -6
- package/dist/toastui-editor-viewer.js +1855 -395
- package/dist/toastui-editor.css +6 -6
- package/dist/toastui-editor.js +2486 -704
- package/package.json +5 -1
- package/types/editor.d.ts +6 -4
- package/types/event.d.ts +2 -0
- package/types/index.d.ts +4 -3
- package/types/spec.d.ts +1 -1
- package/types/toastui-editor-viewer.d.ts +39 -0
- package/types/ui.d.ts +22 -20
- package/types/wysiwyg.d.ts +2 -1
package/dist/toastui-editor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @toast-ui/editor
|
|
3
|
-
* @version 3.
|
|
3
|
+
* @version 3.1.3 | Thu Feb 10 2022
|
|
4
4
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -13,14 +13,1418 @@
|
|
|
13
13
|
exports["toastui"] = factory(require("prosemirror-commands"), require("prosemirror-history"), require("prosemirror-inputrules"), require("prosemirror-keymap"), require("prosemirror-model"), require("prosemirror-state"), require("prosemirror-transform"), require("prosemirror-view"));
|
|
14
14
|
else
|
|
15
15
|
root["toastui"] = root["toastui"] || {}, root["toastui"]["Editor"] = factory(root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined]);
|
|
16
|
-
})(self, function(
|
|
16
|
+
})(self, function(__WEBPACK_EXTERNAL_MODULE__695__, __WEBPACK_EXTERNAL_MODULE__412__, __WEBPACK_EXTERNAL_MODULE__479__, __WEBPACK_EXTERNAL_MODULE__481__, __WEBPACK_EXTERNAL_MODULE__43__, __WEBPACK_EXTERNAL_MODULE__814__, __WEBPACK_EXTERNAL_MODULE__785__, __WEBPACK_EXTERNAL_MODULE__311__) {
|
|
17
17
|
return /******/ (function() { // webpackBootstrap
|
|
18
|
-
/******/ "use strict";
|
|
19
18
|
/******/ var __webpack_modules__ = ({
|
|
20
19
|
|
|
20
|
+
/***/ 368:
|
|
21
|
+
/***/ (function(module) {
|
|
22
|
+
|
|
23
|
+
/*! @license DOMPurify 2.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.3/LICENSE */
|
|
24
|
+
|
|
25
|
+
(function (global, factory) {
|
|
26
|
+
true ? module.exports = factory() :
|
|
27
|
+
0;
|
|
28
|
+
}(this, function () { 'use strict';
|
|
29
|
+
|
|
30
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
31
|
+
|
|
32
|
+
var hasOwnProperty = Object.hasOwnProperty,
|
|
33
|
+
setPrototypeOf = Object.setPrototypeOf,
|
|
34
|
+
isFrozen = Object.isFrozen,
|
|
35
|
+
getPrototypeOf = Object.getPrototypeOf,
|
|
36
|
+
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
37
|
+
var freeze = Object.freeze,
|
|
38
|
+
seal = Object.seal,
|
|
39
|
+
create = Object.create; // eslint-disable-line import/no-mutable-exports
|
|
40
|
+
|
|
41
|
+
var _ref = typeof Reflect !== 'undefined' && Reflect,
|
|
42
|
+
apply = _ref.apply,
|
|
43
|
+
construct = _ref.construct;
|
|
44
|
+
|
|
45
|
+
if (!apply) {
|
|
46
|
+
apply = function apply(fun, thisValue, args) {
|
|
47
|
+
return fun.apply(thisValue, args);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!freeze) {
|
|
52
|
+
freeze = function freeze(x) {
|
|
53
|
+
return x;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!seal) {
|
|
58
|
+
seal = function seal(x) {
|
|
59
|
+
return x;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!construct) {
|
|
64
|
+
construct = function construct(Func, args) {
|
|
65
|
+
return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))();
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var arrayForEach = unapply(Array.prototype.forEach);
|
|
70
|
+
var arrayPop = unapply(Array.prototype.pop);
|
|
71
|
+
var arrayPush = unapply(Array.prototype.push);
|
|
72
|
+
|
|
73
|
+
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
74
|
+
var stringMatch = unapply(String.prototype.match);
|
|
75
|
+
var stringReplace = unapply(String.prototype.replace);
|
|
76
|
+
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
77
|
+
var stringTrim = unapply(String.prototype.trim);
|
|
78
|
+
|
|
79
|
+
var regExpTest = unapply(RegExp.prototype.test);
|
|
80
|
+
|
|
81
|
+
var typeErrorCreate = unconstruct(TypeError);
|
|
82
|
+
|
|
83
|
+
function unapply(func) {
|
|
84
|
+
return function (thisArg) {
|
|
85
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
86
|
+
args[_key - 1] = arguments[_key];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return apply(func, thisArg, args);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function unconstruct(func) {
|
|
94
|
+
return function () {
|
|
95
|
+
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
96
|
+
args[_key2] = arguments[_key2];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return construct(func, args);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Add properties to a lookup table */
|
|
104
|
+
function addToSet(set, array) {
|
|
105
|
+
if (setPrototypeOf) {
|
|
106
|
+
// Make 'in' and truthy checks like Boolean(set.constructor)
|
|
107
|
+
// independent of any properties defined on Object.prototype.
|
|
108
|
+
// Prevent prototype setters from intercepting set as a this value.
|
|
109
|
+
setPrototypeOf(set, null);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
var l = array.length;
|
|
113
|
+
while (l--) {
|
|
114
|
+
var element = array[l];
|
|
115
|
+
if (typeof element === 'string') {
|
|
116
|
+
var lcElement = stringToLowerCase(element);
|
|
117
|
+
if (lcElement !== element) {
|
|
118
|
+
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
119
|
+
if (!isFrozen(array)) {
|
|
120
|
+
array[l] = lcElement;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
element = lcElement;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
set[element] = true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return set;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Shallow clone an object */
|
|
134
|
+
function clone(object) {
|
|
135
|
+
var newObject = create(null);
|
|
136
|
+
|
|
137
|
+
var property = void 0;
|
|
138
|
+
for (property in object) {
|
|
139
|
+
if (apply(hasOwnProperty, object, [property])) {
|
|
140
|
+
newObject[property] = object[property];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return newObject;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* IE10 doesn't support __lookupGetter__ so lets'
|
|
148
|
+
* simulate it. It also automatically checks
|
|
149
|
+
* if the prop is function or getter and behaves
|
|
150
|
+
* accordingly. */
|
|
151
|
+
function lookupGetter(object, prop) {
|
|
152
|
+
while (object !== null) {
|
|
153
|
+
var desc = getOwnPropertyDescriptor(object, prop);
|
|
154
|
+
if (desc) {
|
|
155
|
+
if (desc.get) {
|
|
156
|
+
return unapply(desc.get);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (typeof desc.value === 'function') {
|
|
160
|
+
return unapply(desc.value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
object = getPrototypeOf(object);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function fallbackValue(element) {
|
|
168
|
+
console.warn('fallback value for', element);
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return fallbackValue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
|
|
176
|
+
|
|
177
|
+
// SVG
|
|
178
|
+
var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
179
|
+
|
|
180
|
+
var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
|
|
181
|
+
|
|
182
|
+
// List of SVG elements that are disallowed by default.
|
|
183
|
+
// We still need to know them so that we can do namespace
|
|
184
|
+
// checks properly in case one wants to add them to
|
|
185
|
+
// allow-list.
|
|
186
|
+
var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
|
|
187
|
+
|
|
188
|
+
var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']);
|
|
189
|
+
|
|
190
|
+
// Similarly to SVG, we want to know all MathML elements,
|
|
191
|
+
// even those that we disallow by default.
|
|
192
|
+
var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
193
|
+
|
|
194
|
+
var text = freeze(['#text']);
|
|
195
|
+
|
|
196
|
+
var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
|
|
197
|
+
|
|
198
|
+
var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
199
|
+
|
|
200
|
+
var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
|
201
|
+
|
|
202
|
+
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
203
|
+
|
|
204
|
+
// eslint-disable-next-line unicorn/better-regex
|
|
205
|
+
var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
206
|
+
var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm);
|
|
207
|
+
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
|
|
208
|
+
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
209
|
+
var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
|
|
210
|
+
);
|
|
211
|
+
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
212
|
+
var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
216
|
+
|
|
217
|
+
function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
218
|
+
|
|
219
|
+
var getGlobal = function getGlobal() {
|
|
220
|
+
return typeof window === 'undefined' ? null : window;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Creates a no-op policy for internal use only.
|
|
225
|
+
* Don't export this function outside this module!
|
|
226
|
+
* @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
|
|
227
|
+
* @param {Document} document The document object (to determine policy name suffix)
|
|
228
|
+
* @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
|
|
229
|
+
* are not supported).
|
|
230
|
+
*/
|
|
231
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
|
|
232
|
+
if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Allow the callers to control the unique policy name
|
|
237
|
+
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
238
|
+
// Policy creation with duplicate names throws in Trusted Types.
|
|
239
|
+
var suffix = null;
|
|
240
|
+
var ATTR_NAME = 'data-tt-policy-suffix';
|
|
241
|
+
if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
|
|
242
|
+
suffix = document.currentScript.getAttribute(ATTR_NAME);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
return trustedTypes.createPolicy(policyName, {
|
|
249
|
+
createHTML: function createHTML(html$$1) {
|
|
250
|
+
return html$$1;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
} catch (_) {
|
|
254
|
+
// Policy creation failed (most likely another DOMPurify script has
|
|
255
|
+
// already run). Skip creating the policy, as this will only cause errors
|
|
256
|
+
// if TT are enforced.
|
|
257
|
+
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
function createDOMPurify() {
|
|
263
|
+
var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
264
|
+
|
|
265
|
+
var DOMPurify = function DOMPurify(root) {
|
|
266
|
+
return createDOMPurify(root);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Version label, exposed for easier checks
|
|
271
|
+
* if DOMPurify is up to date or not
|
|
272
|
+
*/
|
|
273
|
+
DOMPurify.version = '2.3.3';
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Array of elements that DOMPurify removed during sanitation.
|
|
277
|
+
* Empty if nothing was removed.
|
|
278
|
+
*/
|
|
279
|
+
DOMPurify.removed = [];
|
|
280
|
+
|
|
281
|
+
if (!window || !window.document || window.document.nodeType !== 9) {
|
|
282
|
+
// Not running in a browser, provide a factory function
|
|
283
|
+
// so that you can pass your own Window
|
|
284
|
+
DOMPurify.isSupported = false;
|
|
285
|
+
|
|
286
|
+
return DOMPurify;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var originalDocument = window.document;
|
|
290
|
+
|
|
291
|
+
var document = window.document;
|
|
292
|
+
var DocumentFragment = window.DocumentFragment,
|
|
293
|
+
HTMLTemplateElement = window.HTMLTemplateElement,
|
|
294
|
+
Node = window.Node,
|
|
295
|
+
Element = window.Element,
|
|
296
|
+
NodeFilter = window.NodeFilter,
|
|
297
|
+
_window$NamedNodeMap = window.NamedNodeMap,
|
|
298
|
+
NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
|
|
299
|
+
Text = window.Text,
|
|
300
|
+
Comment = window.Comment,
|
|
301
|
+
DOMParser = window.DOMParser,
|
|
302
|
+
trustedTypes = window.trustedTypes;
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
var ElementPrototype = Element.prototype;
|
|
306
|
+
|
|
307
|
+
var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
308
|
+
var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
309
|
+
var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
310
|
+
var getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
311
|
+
|
|
312
|
+
// As per issue #47, the web-components registry is inherited by a
|
|
313
|
+
// new document created via createHTMLDocument. As per the spec
|
|
314
|
+
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
315
|
+
// a new empty registry is used when creating a template contents owner
|
|
316
|
+
// document, so we use that as our parent document to ensure nothing
|
|
317
|
+
// is inherited.
|
|
318
|
+
if (typeof HTMLTemplateElement === 'function') {
|
|
319
|
+
var template = document.createElement('template');
|
|
320
|
+
if (template.content && template.content.ownerDocument) {
|
|
321
|
+
document = template.content.ownerDocument;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
|
|
326
|
+
var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : '';
|
|
327
|
+
|
|
328
|
+
var _document = document,
|
|
329
|
+
implementation = _document.implementation,
|
|
330
|
+
createNodeIterator = _document.createNodeIterator,
|
|
331
|
+
createDocumentFragment = _document.createDocumentFragment,
|
|
332
|
+
getElementsByTagName = _document.getElementsByTagName;
|
|
333
|
+
var importNode = originalDocument.importNode;
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
var documentMode = {};
|
|
337
|
+
try {
|
|
338
|
+
documentMode = clone(document).documentMode ? document.documentMode : {};
|
|
339
|
+
} catch (_) {}
|
|
340
|
+
|
|
341
|
+
var hooks = {};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
345
|
+
*/
|
|
346
|
+
DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
|
|
347
|
+
|
|
348
|
+
var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR,
|
|
349
|
+
ERB_EXPR$$1 = ERB_EXPR,
|
|
350
|
+
DATA_ATTR$$1 = DATA_ATTR,
|
|
351
|
+
ARIA_ATTR$$1 = ARIA_ATTR,
|
|
352
|
+
IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA,
|
|
353
|
+
ATTR_WHITESPACE$$1 = ATTR_WHITESPACE;
|
|
354
|
+
var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
358
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
/* allowed element names */
|
|
362
|
+
|
|
363
|
+
var ALLOWED_TAGS = null;
|
|
364
|
+
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text)));
|
|
365
|
+
|
|
366
|
+
/* Allowed attribute names */
|
|
367
|
+
var ALLOWED_ATTR = null;
|
|
368
|
+
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml)));
|
|
369
|
+
|
|
370
|
+
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
371
|
+
var FORBID_TAGS = null;
|
|
372
|
+
|
|
373
|
+
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
374
|
+
var FORBID_ATTR = null;
|
|
375
|
+
|
|
376
|
+
/* Decide if ARIA attributes are okay */
|
|
377
|
+
var ALLOW_ARIA_ATTR = true;
|
|
378
|
+
|
|
379
|
+
/* Decide if custom data attributes are okay */
|
|
380
|
+
var ALLOW_DATA_ATTR = true;
|
|
381
|
+
|
|
382
|
+
/* Decide if unknown protocols are okay */
|
|
383
|
+
var ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
384
|
+
|
|
385
|
+
/* Output should be safe for common template engines.
|
|
386
|
+
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
387
|
+
*/
|
|
388
|
+
var SAFE_FOR_TEMPLATES = false;
|
|
389
|
+
|
|
390
|
+
/* Decide if document with <html>... should be returned */
|
|
391
|
+
var WHOLE_DOCUMENT = false;
|
|
392
|
+
|
|
393
|
+
/* Track whether config is already set on this instance of DOMPurify. */
|
|
394
|
+
var SET_CONFIG = false;
|
|
395
|
+
|
|
396
|
+
/* Decide if all elements (e.g. style, script) must be children of
|
|
397
|
+
* document.body. By default, browsers might move them to document.head */
|
|
398
|
+
var FORCE_BODY = false;
|
|
399
|
+
|
|
400
|
+
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
401
|
+
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
402
|
+
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
403
|
+
*/
|
|
404
|
+
var RETURN_DOM = false;
|
|
405
|
+
|
|
406
|
+
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
407
|
+
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
408
|
+
var RETURN_DOM_FRAGMENT = false;
|
|
409
|
+
|
|
410
|
+
/* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM
|
|
411
|
+
* `Node` is imported into the current `Document`. If this flag is not enabled the
|
|
412
|
+
* `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by
|
|
413
|
+
* DOMPurify.
|
|
414
|
+
*
|
|
415
|
+
* This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false`
|
|
416
|
+
* might cause XSS from attacks hidden in closed shadowroots in case the browser
|
|
417
|
+
* supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/
|
|
418
|
+
*/
|
|
419
|
+
var RETURN_DOM_IMPORT = true;
|
|
420
|
+
|
|
421
|
+
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
422
|
+
* case Trusted Types are not supported */
|
|
423
|
+
var RETURN_TRUSTED_TYPE = false;
|
|
424
|
+
|
|
425
|
+
/* Output should be free from DOM clobbering attacks? */
|
|
426
|
+
var SANITIZE_DOM = true;
|
|
427
|
+
|
|
428
|
+
/* Keep element content when removing element? */
|
|
429
|
+
var KEEP_CONTENT = true;
|
|
430
|
+
|
|
431
|
+
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
432
|
+
* of importing it into a new Document and returning a sanitized copy */
|
|
433
|
+
var IN_PLACE = false;
|
|
434
|
+
|
|
435
|
+
/* Allow usage of profiles like html, svg and mathMl */
|
|
436
|
+
var USE_PROFILES = {};
|
|
437
|
+
|
|
438
|
+
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
439
|
+
var FORBID_CONTENTS = null;
|
|
440
|
+
var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
441
|
+
|
|
442
|
+
/* Tags that are safe for data: URIs */
|
|
443
|
+
var DATA_URI_TAGS = null;
|
|
444
|
+
var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
445
|
+
|
|
446
|
+
/* Attributes safe for values like "javascript:" */
|
|
447
|
+
var URI_SAFE_ATTRIBUTES = null;
|
|
448
|
+
var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
449
|
+
|
|
450
|
+
var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
451
|
+
var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
452
|
+
var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
453
|
+
/* Document namespace */
|
|
454
|
+
var NAMESPACE = HTML_NAMESPACE;
|
|
455
|
+
var IS_EMPTY_INPUT = false;
|
|
456
|
+
|
|
457
|
+
/* Parsing of strict XHTML documents */
|
|
458
|
+
var PARSER_MEDIA_TYPE = void 0;
|
|
459
|
+
var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
460
|
+
var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
461
|
+
var transformCaseFunc = void 0;
|
|
462
|
+
|
|
463
|
+
/* Keep a reference to config to pass to hooks */
|
|
464
|
+
var CONFIG = null;
|
|
465
|
+
|
|
466
|
+
/* Ideally, do not touch anything below this line */
|
|
467
|
+
/* ______________________________________________ */
|
|
468
|
+
|
|
469
|
+
var formElement = document.createElement('form');
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* _parseConfig
|
|
473
|
+
*
|
|
474
|
+
* @param {Object} cfg optional config literal
|
|
475
|
+
*/
|
|
476
|
+
// eslint-disable-next-line complexity
|
|
477
|
+
var _parseConfig = function _parseConfig(cfg) {
|
|
478
|
+
if (CONFIG && CONFIG === cfg) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/* Shield configuration object from tampering */
|
|
483
|
+
if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') {
|
|
484
|
+
cfg = {};
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/* Shield configuration object from prototype pollution */
|
|
488
|
+
cfg = clone(cfg);
|
|
489
|
+
|
|
490
|
+
/* Set configuration parameters */
|
|
491
|
+
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS;
|
|
492
|
+
ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR;
|
|
493
|
+
URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
494
|
+
DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS;
|
|
495
|
+
FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS) : DEFAULT_FORBID_CONTENTS;
|
|
496
|
+
FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {};
|
|
497
|
+
FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {};
|
|
498
|
+
USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
|
|
499
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
500
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
501
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
502
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
|
503
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
|
504
|
+
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
|
505
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
|
506
|
+
RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true
|
|
507
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
|
508
|
+
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
|
509
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
510
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
511
|
+
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
512
|
+
IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1;
|
|
513
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
514
|
+
|
|
515
|
+
PARSER_MEDIA_TYPE =
|
|
516
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
517
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
|
|
518
|
+
|
|
519
|
+
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
520
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
|
|
521
|
+
return x;
|
|
522
|
+
} : stringToLowerCase;
|
|
523
|
+
|
|
524
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
525
|
+
ALLOW_DATA_ATTR = false;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
529
|
+
RETURN_DOM = true;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/* Parse profile info */
|
|
533
|
+
if (USE_PROFILES) {
|
|
534
|
+
ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text)));
|
|
535
|
+
ALLOWED_ATTR = [];
|
|
536
|
+
if (USE_PROFILES.html === true) {
|
|
537
|
+
addToSet(ALLOWED_TAGS, html);
|
|
538
|
+
addToSet(ALLOWED_ATTR, html$1);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (USE_PROFILES.svg === true) {
|
|
542
|
+
addToSet(ALLOWED_TAGS, svg);
|
|
543
|
+
addToSet(ALLOWED_ATTR, svg$1);
|
|
544
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
548
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
549
|
+
addToSet(ALLOWED_ATTR, svg$1);
|
|
550
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (USE_PROFILES.mathMl === true) {
|
|
554
|
+
addToSet(ALLOWED_TAGS, mathMl);
|
|
555
|
+
addToSet(ALLOWED_ATTR, mathMl$1);
|
|
556
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/* Merge configuration parameters */
|
|
561
|
+
if (cfg.ADD_TAGS) {
|
|
562
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
563
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (cfg.ADD_ATTR) {
|
|
570
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
571
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
578
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (cfg.FORBID_CONTENTS) {
|
|
582
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
583
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/* Add #text in case KEEP_CONTENT is set to true */
|
|
590
|
+
if (KEEP_CONTENT) {
|
|
591
|
+
ALLOWED_TAGS['#text'] = true;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
595
|
+
if (WHOLE_DOCUMENT) {
|
|
596
|
+
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
600
|
+
if (ALLOWED_TAGS.table) {
|
|
601
|
+
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
602
|
+
delete FORBID_TAGS.tbody;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// Prevent further manipulation of configuration.
|
|
606
|
+
// Not available in IE8, Safari 5, etc.
|
|
607
|
+
if (freeze) {
|
|
608
|
+
freeze(cfg);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
CONFIG = cfg;
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
615
|
+
|
|
616
|
+
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
|
|
617
|
+
|
|
618
|
+
/* Keep track of all possible SVG and MathML tags
|
|
619
|
+
* so that we can perform the namespace checks
|
|
620
|
+
* correctly. */
|
|
621
|
+
var ALL_SVG_TAGS = addToSet({}, svg);
|
|
622
|
+
addToSet(ALL_SVG_TAGS, svgFilters);
|
|
623
|
+
addToSet(ALL_SVG_TAGS, svgDisallowed);
|
|
624
|
+
|
|
625
|
+
var ALL_MATHML_TAGS = addToSet({}, mathMl);
|
|
626
|
+
addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
*
|
|
630
|
+
*
|
|
631
|
+
* @param {Element} element a DOM element whose namespace is being checked
|
|
632
|
+
* @returns {boolean} Return false if the element has a
|
|
633
|
+
* namespace that a spec-compliant parser would never
|
|
634
|
+
* return. Return true otherwise.
|
|
635
|
+
*/
|
|
636
|
+
var _checkValidNamespace = function _checkValidNamespace(element) {
|
|
637
|
+
var parent = getParentNode(element);
|
|
638
|
+
|
|
639
|
+
// In JSDOM, if we're inside shadow DOM, then parentNode
|
|
640
|
+
// can be null. We just simulate parent in this case.
|
|
641
|
+
if (!parent || !parent.tagName) {
|
|
642
|
+
parent = {
|
|
643
|
+
namespaceURI: HTML_NAMESPACE,
|
|
644
|
+
tagName: 'template'
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
var tagName = stringToLowerCase(element.tagName);
|
|
649
|
+
var parentTagName = stringToLowerCase(parent.tagName);
|
|
650
|
+
|
|
651
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
652
|
+
// The only way to switch from HTML namespace to SVG
|
|
653
|
+
// is via <svg>. If it happens via any other tag, then
|
|
654
|
+
// it should be killed.
|
|
655
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
656
|
+
return tagName === 'svg';
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// The only way to switch from MathML to SVG is via
|
|
660
|
+
// svg if parent is either <annotation-xml> or MathML
|
|
661
|
+
// text integration points.
|
|
662
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
663
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// We only allow elements that are defined in SVG
|
|
667
|
+
// spec. All others are disallowed in SVG namespace.
|
|
668
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
672
|
+
// The only way to switch from HTML namespace to MathML
|
|
673
|
+
// is via <math>. If it happens via any other tag, then
|
|
674
|
+
// it should be killed.
|
|
675
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
676
|
+
return tagName === 'math';
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// The only way to switch from SVG to MathML is via
|
|
680
|
+
// <math> and HTML integration points
|
|
681
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
682
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// We only allow elements that are defined in MathML
|
|
686
|
+
// spec. All others are disallowed in MathML namespace.
|
|
687
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
691
|
+
// The only way to switch from SVG to HTML is via
|
|
692
|
+
// HTML integration points, and from MathML to HTML
|
|
693
|
+
// is via MathML text integration points
|
|
694
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
695
|
+
return false;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// Certain elements are allowed in both SVG and HTML
|
|
703
|
+
// namespace. We need to specify them explicitly
|
|
704
|
+
// so that they don't get erronously deleted from
|
|
705
|
+
// HTML namespace.
|
|
706
|
+
var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
707
|
+
|
|
708
|
+
// We disallow tags that are specific for MathML
|
|
709
|
+
// or SVG and should never appear in HTML namespace
|
|
710
|
+
return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// The code should never reach this place (this means
|
|
714
|
+
// that the element somehow got namespace that is not
|
|
715
|
+
// HTML, SVG or MathML). Return false just in case.
|
|
716
|
+
return false;
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* _forceRemove
|
|
721
|
+
*
|
|
722
|
+
* @param {Node} node a DOM node
|
|
723
|
+
*/
|
|
724
|
+
var _forceRemove = function _forceRemove(node) {
|
|
725
|
+
arrayPush(DOMPurify.removed, { element: node });
|
|
726
|
+
try {
|
|
727
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
728
|
+
node.parentNode.removeChild(node);
|
|
729
|
+
} catch (_) {
|
|
730
|
+
try {
|
|
731
|
+
node.outerHTML = emptyHTML;
|
|
732
|
+
} catch (_) {
|
|
733
|
+
node.remove();
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* _removeAttribute
|
|
740
|
+
*
|
|
741
|
+
* @param {String} name an Attribute name
|
|
742
|
+
* @param {Node} node a DOM node
|
|
743
|
+
*/
|
|
744
|
+
var _removeAttribute = function _removeAttribute(name, node) {
|
|
745
|
+
try {
|
|
746
|
+
arrayPush(DOMPurify.removed, {
|
|
747
|
+
attribute: node.getAttributeNode(name),
|
|
748
|
+
from: node
|
|
749
|
+
});
|
|
750
|
+
} catch (_) {
|
|
751
|
+
arrayPush(DOMPurify.removed, {
|
|
752
|
+
attribute: null,
|
|
753
|
+
from: node
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
node.removeAttribute(name);
|
|
758
|
+
|
|
759
|
+
// We void attribute values for unremovable "is"" attributes
|
|
760
|
+
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
|
761
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
762
|
+
try {
|
|
763
|
+
_forceRemove(node);
|
|
764
|
+
} catch (_) {}
|
|
765
|
+
} else {
|
|
766
|
+
try {
|
|
767
|
+
node.setAttribute(name, '');
|
|
768
|
+
} catch (_) {}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* _initDocument
|
|
775
|
+
*
|
|
776
|
+
* @param {String} dirty a string of dirty markup
|
|
777
|
+
* @return {Document} a DOM, filled with the dirty markup
|
|
778
|
+
*/
|
|
779
|
+
var _initDocument = function _initDocument(dirty) {
|
|
780
|
+
/* Create a HTML document */
|
|
781
|
+
var doc = void 0;
|
|
782
|
+
var leadingWhitespace = void 0;
|
|
783
|
+
|
|
784
|
+
if (FORCE_BODY) {
|
|
785
|
+
dirty = '<remove></remove>' + dirty;
|
|
786
|
+
} else {
|
|
787
|
+
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
|
788
|
+
var matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
789
|
+
leadingWhitespace = matches && matches[0];
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
|
|
793
|
+
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
794
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
798
|
+
/*
|
|
799
|
+
* Use the DOMParser API by default, fallback later if needs be
|
|
800
|
+
* DOMParser not work for svg when has multiple root element.
|
|
801
|
+
*/
|
|
802
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
803
|
+
try {
|
|
804
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
805
|
+
} catch (_) {}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/* Use createHTMLDocument in case DOMParser is not available */
|
|
809
|
+
if (!doc || !doc.documentElement) {
|
|
810
|
+
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
811
|
+
try {
|
|
812
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
|
|
813
|
+
} catch (_) {
|
|
814
|
+
// Syntax error if dirtyPayload is invalid xml
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
var body = doc.body || doc.documentElement;
|
|
819
|
+
|
|
820
|
+
if (dirty && leadingWhitespace) {
|
|
821
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/* Work on whole document or just its body */
|
|
825
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
826
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* _createIterator
|
|
834
|
+
*
|
|
835
|
+
* @param {Document} root document/fragment to create iterator for
|
|
836
|
+
* @return {Iterator} iterator instance
|
|
837
|
+
*/
|
|
838
|
+
var _createIterator = function _createIterator(root) {
|
|
839
|
+
return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* _isClobbered
|
|
844
|
+
*
|
|
845
|
+
* @param {Node} elm element to check for clobbering attacks
|
|
846
|
+
* @return {Boolean} true if clobbered, false if safe
|
|
847
|
+
*/
|
|
848
|
+
var _isClobbered = function _isClobbered(elm) {
|
|
849
|
+
if (elm instanceof Text || elm instanceof Comment) {
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') {
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
return false;
|
|
858
|
+
};
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* _isNode
|
|
862
|
+
*
|
|
863
|
+
* @param {Node} obj object to check whether it's a DOM node
|
|
864
|
+
* @return {Boolean} true is object is a DOM node
|
|
865
|
+
*/
|
|
866
|
+
var _isNode = function _isNode(object) {
|
|
867
|
+
return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* _executeHook
|
|
872
|
+
* Execute user configurable hooks
|
|
873
|
+
*
|
|
874
|
+
* @param {String} entryPoint Name of the hook's entry point
|
|
875
|
+
* @param {Node} currentNode node to work on with the hook
|
|
876
|
+
* @param {Object} data additional hook parameters
|
|
877
|
+
*/
|
|
878
|
+
var _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
|
879
|
+
if (!hooks[entryPoint]) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
arrayForEach(hooks[entryPoint], function (hook) {
|
|
884
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
885
|
+
});
|
|
886
|
+
};
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* _sanitizeElements
|
|
890
|
+
*
|
|
891
|
+
* @protect nodeName
|
|
892
|
+
* @protect textContent
|
|
893
|
+
* @protect removeChild
|
|
894
|
+
*
|
|
895
|
+
* @param {Node} currentNode to check for permission to exist
|
|
896
|
+
* @return {Boolean} true if node was killed, false if left alive
|
|
897
|
+
*/
|
|
898
|
+
var _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
899
|
+
var content = void 0;
|
|
900
|
+
|
|
901
|
+
/* Execute a hook if present */
|
|
902
|
+
_executeHook('beforeSanitizeElements', currentNode, null);
|
|
903
|
+
|
|
904
|
+
/* Check if element is clobbered or can clobber */
|
|
905
|
+
if (_isClobbered(currentNode)) {
|
|
906
|
+
_forceRemove(currentNode);
|
|
907
|
+
return true;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/* Check if tagname contains Unicode */
|
|
911
|
+
if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) {
|
|
912
|
+
_forceRemove(currentNode);
|
|
913
|
+
return true;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/* Now let's check the element's type and name */
|
|
917
|
+
var tagName = transformCaseFunc(currentNode.nodeName);
|
|
918
|
+
|
|
919
|
+
/* Execute a hook if present */
|
|
920
|
+
_executeHook('uponSanitizeElement', currentNode, {
|
|
921
|
+
tagName: tagName,
|
|
922
|
+
allowedTags: ALLOWED_TAGS
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
926
|
+
if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
927
|
+
_forceRemove(currentNode);
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/* Mitigate a problem with templates inside select */
|
|
932
|
+
if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
|
|
933
|
+
_forceRemove(currentNode);
|
|
934
|
+
return true;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/* Remove element if anything forbids its presence */
|
|
938
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
939
|
+
/* Keep content except for bad-listed elements */
|
|
940
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
941
|
+
var parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
942
|
+
var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
943
|
+
|
|
944
|
+
if (childNodes && parentNode) {
|
|
945
|
+
var childCount = childNodes.length;
|
|
946
|
+
|
|
947
|
+
for (var i = childCount - 1; i >= 0; --i) {
|
|
948
|
+
parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
_forceRemove(currentNode);
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/* Check whether element has a valid namespace */
|
|
958
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
959
|
+
_forceRemove(currentNode);
|
|
960
|
+
return true;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
|
|
964
|
+
_forceRemove(currentNode);
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/* Sanitize element content to be template-safe */
|
|
969
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
|
|
970
|
+
/* Get the element's text content */
|
|
971
|
+
content = currentNode.textContent;
|
|
972
|
+
content = stringReplace(content, MUSTACHE_EXPR$$1, ' ');
|
|
973
|
+
content = stringReplace(content, ERB_EXPR$$1, ' ');
|
|
974
|
+
if (currentNode.textContent !== content) {
|
|
975
|
+
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
|
976
|
+
currentNode.textContent = content;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/* Execute a hook if present */
|
|
981
|
+
_executeHook('afterSanitizeElements', currentNode, null);
|
|
982
|
+
|
|
983
|
+
return false;
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* _isValidAttribute
|
|
988
|
+
*
|
|
989
|
+
* @param {string} lcTag Lowercase tag name of containing element.
|
|
990
|
+
* @param {string} lcName Lowercase attribute name.
|
|
991
|
+
* @param {string} value Attribute value.
|
|
992
|
+
* @return {Boolean} Returns true if `value` is valid, otherwise false.
|
|
993
|
+
*/
|
|
994
|
+
// eslint-disable-next-line complexity
|
|
995
|
+
var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
996
|
+
/* Make sure attribute cannot clobber */
|
|
997
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/* Allow valid data-* attributes: At least one character after "-"
|
|
1002
|
+
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
1003
|
+
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
1004
|
+
We don't need to check the value; it's always URI safe. */
|
|
1005
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
1006
|
+
return false;
|
|
1007
|
+
|
|
1008
|
+
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
1009
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else {
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
return true;
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* _sanitizeAttributes
|
|
1018
|
+
*
|
|
1019
|
+
* @protect attributes
|
|
1020
|
+
* @protect nodeName
|
|
1021
|
+
* @protect removeAttribute
|
|
1022
|
+
* @protect setAttribute
|
|
1023
|
+
*
|
|
1024
|
+
* @param {Node} currentNode to sanitize
|
|
1025
|
+
*/
|
|
1026
|
+
var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
1027
|
+
var attr = void 0;
|
|
1028
|
+
var value = void 0;
|
|
1029
|
+
var lcName = void 0;
|
|
1030
|
+
var l = void 0;
|
|
1031
|
+
/* Execute a hook if present */
|
|
1032
|
+
_executeHook('beforeSanitizeAttributes', currentNode, null);
|
|
1033
|
+
|
|
1034
|
+
var attributes = currentNode.attributes;
|
|
1035
|
+
|
|
1036
|
+
/* Check if we have attributes; if not we might have a text node */
|
|
1037
|
+
|
|
1038
|
+
if (!attributes) {
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
var hookEvent = {
|
|
1043
|
+
attrName: '',
|
|
1044
|
+
attrValue: '',
|
|
1045
|
+
keepAttr: true,
|
|
1046
|
+
allowedAttributes: ALLOWED_ATTR
|
|
1047
|
+
};
|
|
1048
|
+
l = attributes.length;
|
|
1049
|
+
|
|
1050
|
+
/* Go backwards over all attributes; safely remove bad ones */
|
|
1051
|
+
while (l--) {
|
|
1052
|
+
attr = attributes[l];
|
|
1053
|
+
var _attr = attr,
|
|
1054
|
+
name = _attr.name,
|
|
1055
|
+
namespaceURI = _attr.namespaceURI;
|
|
1056
|
+
|
|
1057
|
+
value = stringTrim(attr.value);
|
|
1058
|
+
lcName = transformCaseFunc(name);
|
|
1059
|
+
|
|
1060
|
+
/* Execute a hook if present */
|
|
1061
|
+
hookEvent.attrName = lcName;
|
|
1062
|
+
hookEvent.attrValue = value;
|
|
1063
|
+
hookEvent.keepAttr = true;
|
|
1064
|
+
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
1065
|
+
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
|
|
1066
|
+
value = hookEvent.attrValue;
|
|
1067
|
+
/* Did the hooks approve of the attribute? */
|
|
1068
|
+
if (hookEvent.forceKeepAttr) {
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/* Remove attribute */
|
|
1073
|
+
_removeAttribute(name, currentNode);
|
|
1074
|
+
|
|
1075
|
+
/* Did the hooks approve of the attribute? */
|
|
1076
|
+
if (!hookEvent.keepAttr) {
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/* Work around a security issue in jQuery 3.0 */
|
|
1081
|
+
if (regExpTest(/\/>/i, value)) {
|
|
1082
|
+
_removeAttribute(name, currentNode);
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/* Sanitize attribute content to be template-safe */
|
|
1087
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1088
|
+
value = stringReplace(value, MUSTACHE_EXPR$$1, ' ');
|
|
1089
|
+
value = stringReplace(value, ERB_EXPR$$1, ' ');
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/* Is `value` valid for this attribute? */
|
|
1093
|
+
var lcTag = transformCaseFunc(currentNode.nodeName);
|
|
1094
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/* Handle invalid data-* attribute set by try-catching it */
|
|
1099
|
+
try {
|
|
1100
|
+
if (namespaceURI) {
|
|
1101
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
1102
|
+
} else {
|
|
1103
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
1104
|
+
currentNode.setAttribute(name, value);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
arrayPop(DOMPurify.removed);
|
|
1108
|
+
} catch (_) {}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/* Execute a hook if present */
|
|
1112
|
+
_executeHook('afterSanitizeAttributes', currentNode, null);
|
|
1113
|
+
};
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* _sanitizeShadowDOM
|
|
1117
|
+
*
|
|
1118
|
+
* @param {DocumentFragment} fragment to iterate over recursively
|
|
1119
|
+
*/
|
|
1120
|
+
var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
1121
|
+
var shadowNode = void 0;
|
|
1122
|
+
var shadowIterator = _createIterator(fragment);
|
|
1123
|
+
|
|
1124
|
+
/* Execute a hook if present */
|
|
1125
|
+
_executeHook('beforeSanitizeShadowDOM', fragment, null);
|
|
1126
|
+
|
|
1127
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
1128
|
+
/* Execute a hook if present */
|
|
1129
|
+
_executeHook('uponSanitizeShadowNode', shadowNode, null);
|
|
1130
|
+
|
|
1131
|
+
/* Sanitize tags and elements */
|
|
1132
|
+
if (_sanitizeElements(shadowNode)) {
|
|
1133
|
+
continue;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/* Deep shadow DOM detected */
|
|
1137
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
1138
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/* Check attributes, sanitize if necessary */
|
|
1142
|
+
_sanitizeAttributes(shadowNode);
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
/* Execute a hook if present */
|
|
1146
|
+
_executeHook('afterSanitizeShadowDOM', fragment, null);
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Sanitize
|
|
1151
|
+
* Public method providing core sanitation functionality
|
|
1152
|
+
*
|
|
1153
|
+
* @param {String|Node} dirty string or DOM node
|
|
1154
|
+
* @param {Object} configuration object
|
|
1155
|
+
*/
|
|
1156
|
+
// eslint-disable-next-line complexity
|
|
1157
|
+
DOMPurify.sanitize = function (dirty, cfg) {
|
|
1158
|
+
var body = void 0;
|
|
1159
|
+
var importedNode = void 0;
|
|
1160
|
+
var currentNode = void 0;
|
|
1161
|
+
var oldNode = void 0;
|
|
1162
|
+
var returnNode = void 0;
|
|
1163
|
+
/* Make sure we have a string to sanitize.
|
|
1164
|
+
DO NOT return early, as this will return the wrong type if
|
|
1165
|
+
the user has requested a DOM object rather than a string */
|
|
1166
|
+
IS_EMPTY_INPUT = !dirty;
|
|
1167
|
+
if (IS_EMPTY_INPUT) {
|
|
1168
|
+
dirty = '<!-->';
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/* Stringify, in case dirty is an object */
|
|
1172
|
+
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
1173
|
+
// eslint-disable-next-line no-negated-condition
|
|
1174
|
+
if (typeof dirty.toString !== 'function') {
|
|
1175
|
+
throw typeErrorCreate('toString is not a function');
|
|
1176
|
+
} else {
|
|
1177
|
+
dirty = dirty.toString();
|
|
1178
|
+
if (typeof dirty !== 'string') {
|
|
1179
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/* Check we can run. Otherwise fall back or ignore */
|
|
1185
|
+
if (!DOMPurify.isSupported) {
|
|
1186
|
+
if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
|
|
1187
|
+
if (typeof dirty === 'string') {
|
|
1188
|
+
return window.toStaticHTML(dirty);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
if (_isNode(dirty)) {
|
|
1192
|
+
return window.toStaticHTML(dirty.outerHTML);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
return dirty;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/* Assign config vars */
|
|
1200
|
+
if (!SET_CONFIG) {
|
|
1201
|
+
_parseConfig(cfg);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/* Clean up removed elements */
|
|
1205
|
+
DOMPurify.removed = [];
|
|
1206
|
+
|
|
1207
|
+
/* Check if dirty is correctly typed for IN_PLACE */
|
|
1208
|
+
if (typeof dirty === 'string') {
|
|
1209
|
+
IN_PLACE = false;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
if (IN_PLACE) ; else if (dirty instanceof Node) {
|
|
1213
|
+
/* If dirty is a DOM element, append to an empty document to avoid
|
|
1214
|
+
elements being stripped by the parser */
|
|
1215
|
+
body = _initDocument('<!---->');
|
|
1216
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
1217
|
+
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
|
|
1218
|
+
/* Node is already a body, use as is */
|
|
1219
|
+
body = importedNode;
|
|
1220
|
+
} else if (importedNode.nodeName === 'HTML') {
|
|
1221
|
+
body = importedNode;
|
|
1222
|
+
} else {
|
|
1223
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
1224
|
+
body.appendChild(importedNode);
|
|
1225
|
+
}
|
|
1226
|
+
} else {
|
|
1227
|
+
/* Exit directly if we have nothing to do */
|
|
1228
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
1229
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
1230
|
+
dirty.indexOf('<') === -1) {
|
|
1231
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/* Initialize the document to work on */
|
|
1235
|
+
body = _initDocument(dirty);
|
|
1236
|
+
|
|
1237
|
+
/* Check we have a DOM node from the data */
|
|
1238
|
+
if (!body) {
|
|
1239
|
+
return RETURN_DOM ? null : emptyHTML;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
1244
|
+
if (body && FORCE_BODY) {
|
|
1245
|
+
_forceRemove(body.firstChild);
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/* Get node iterator */
|
|
1249
|
+
var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
|
|
1250
|
+
|
|
1251
|
+
/* Now start iterating over the created document */
|
|
1252
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
1253
|
+
/* Fix IE's strange behavior with manipulated textNodes #89 */
|
|
1254
|
+
if (currentNode.nodeType === 3 && currentNode === oldNode) {
|
|
1255
|
+
continue;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/* Sanitize tags and elements */
|
|
1259
|
+
if (_sanitizeElements(currentNode)) {
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/* Shadow DOM detected, sanitize it */
|
|
1264
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
1265
|
+
_sanitizeShadowDOM(currentNode.content);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/* Check attributes, sanitize if necessary */
|
|
1269
|
+
_sanitizeAttributes(currentNode);
|
|
1270
|
+
|
|
1271
|
+
oldNode = currentNode;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
oldNode = null;
|
|
1275
|
+
|
|
1276
|
+
/* If we sanitized `dirty` in-place, return it. */
|
|
1277
|
+
if (IN_PLACE) {
|
|
1278
|
+
return dirty;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/* Return sanitized string or DOM */
|
|
1282
|
+
if (RETURN_DOM) {
|
|
1283
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
1284
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
1285
|
+
|
|
1286
|
+
while (body.firstChild) {
|
|
1287
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
1288
|
+
returnNode.appendChild(body.firstChild);
|
|
1289
|
+
}
|
|
1290
|
+
} else {
|
|
1291
|
+
returnNode = body;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
if (RETURN_DOM_IMPORT) {
|
|
1295
|
+
/*
|
|
1296
|
+
AdoptNode() is not used because internal state is not reset
|
|
1297
|
+
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
1298
|
+
in theory but we would rather not risk another attack vector.
|
|
1299
|
+
The state that is cloned by importNode() is explicitly defined
|
|
1300
|
+
by the specs.
|
|
1301
|
+
*/
|
|
1302
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
return returnNode;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
1309
|
+
|
|
1310
|
+
/* Sanitize final string template-safe */
|
|
1311
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1312
|
+
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' ');
|
|
1313
|
+
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' ');
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* Public method to set the configuration once
|
|
1321
|
+
* setConfig
|
|
1322
|
+
*
|
|
1323
|
+
* @param {Object} cfg configuration object
|
|
1324
|
+
*/
|
|
1325
|
+
DOMPurify.setConfig = function (cfg) {
|
|
1326
|
+
_parseConfig(cfg);
|
|
1327
|
+
SET_CONFIG = true;
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Public method to remove the configuration
|
|
1332
|
+
* clearConfig
|
|
1333
|
+
*
|
|
1334
|
+
*/
|
|
1335
|
+
DOMPurify.clearConfig = function () {
|
|
1336
|
+
CONFIG = null;
|
|
1337
|
+
SET_CONFIG = false;
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Public method to check if an attribute value is valid.
|
|
1342
|
+
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
1343
|
+
* isValidAttribute
|
|
1344
|
+
*
|
|
1345
|
+
* @param {string} tag Tag name of containing element.
|
|
1346
|
+
* @param {string} attr Attribute name.
|
|
1347
|
+
* @param {string} value Attribute value.
|
|
1348
|
+
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
1349
|
+
*/
|
|
1350
|
+
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
1351
|
+
/* Initialize shared config vars if necessary. */
|
|
1352
|
+
if (!CONFIG) {
|
|
1353
|
+
_parseConfig({});
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
var lcTag = transformCaseFunc(tag);
|
|
1357
|
+
var lcName = transformCaseFunc(attr);
|
|
1358
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* AddHook
|
|
1363
|
+
* Public method to add DOMPurify hooks
|
|
1364
|
+
*
|
|
1365
|
+
* @param {String} entryPoint entry point for the hook to add
|
|
1366
|
+
* @param {Function} hookFunction function to execute
|
|
1367
|
+
*/
|
|
1368
|
+
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
1369
|
+
if (typeof hookFunction !== 'function') {
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
1374
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* RemoveHook
|
|
1379
|
+
* Public method to remove a DOMPurify hook at a given entryPoint
|
|
1380
|
+
* (pops it from the stack of hooks if more are present)
|
|
1381
|
+
*
|
|
1382
|
+
* @param {String} entryPoint entry point for the hook to remove
|
|
1383
|
+
*/
|
|
1384
|
+
DOMPurify.removeHook = function (entryPoint) {
|
|
1385
|
+
if (hooks[entryPoint]) {
|
|
1386
|
+
arrayPop(hooks[entryPoint]);
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* RemoveHooks
|
|
1392
|
+
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
1393
|
+
*
|
|
1394
|
+
* @param {String} entryPoint entry point for the hooks to remove
|
|
1395
|
+
*/
|
|
1396
|
+
DOMPurify.removeHooks = function (entryPoint) {
|
|
1397
|
+
if (hooks[entryPoint]) {
|
|
1398
|
+
hooks[entryPoint] = [];
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* RemoveAllHooks
|
|
1404
|
+
* Public method to remove all DOMPurify hooks
|
|
1405
|
+
*
|
|
1406
|
+
*/
|
|
1407
|
+
DOMPurify.removeAllHooks = function () {
|
|
1408
|
+
hooks = {};
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
return DOMPurify;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
var purify = createDOMPurify();
|
|
1415
|
+
|
|
1416
|
+
return purify;
|
|
1417
|
+
|
|
1418
|
+
}));
|
|
1419
|
+
//# sourceMappingURL=purify.js.map
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
/***/ }),
|
|
1423
|
+
|
|
21
1424
|
/***/ 928:
|
|
22
1425
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
23
1426
|
|
|
1427
|
+
"use strict";
|
|
24
1428
|
/* eslint-disable complexity */
|
|
25
1429
|
/**
|
|
26
1430
|
* @fileoverview Returns the first index at which a given element can be found in the array.
|
|
@@ -46,11 +1450,15 @@ var isArray = __webpack_require__(322);
|
|
|
46
1450
|
* @returns {number} the First index at which a given element, or -1 if it is not present
|
|
47
1451
|
* @memberof module:array
|
|
48
1452
|
* @example
|
|
49
|
-
*
|
|
1453
|
+
* // ES6
|
|
1454
|
+
* import inArray from 'tui-code-snippet/array/inArray';
|
|
1455
|
+
*
|
|
1456
|
+
* // CommonJS
|
|
1457
|
+
* const inArray = require('tui-code-snippet/array/inArray');
|
|
50
1458
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
1459
|
+
* const arr = ['one', 'two', 'three', 'four'];
|
|
1460
|
+
* const idx1 = inArray('one', arr, 3); // -1
|
|
1461
|
+
* const idx2 = inArray('one', arr); // 0
|
|
54
1462
|
*/
|
|
55
1463
|
function inArray(searchElement, array, startIndex) {
|
|
56
1464
|
var i;
|
|
@@ -83,6 +1491,7 @@ module.exports = inArray;
|
|
|
83
1491
|
/***/ 690:
|
|
84
1492
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
85
1493
|
|
|
1494
|
+
"use strict";
|
|
86
1495
|
/**
|
|
87
1496
|
* @fileoverview Execute the provided callback once for each property of object(or element of array) which actually exist.
|
|
88
1497
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -111,19 +1520,23 @@ var forEachOwnProperties = __webpack_require__(956);
|
|
|
111
1520
|
* @param {Object} [context] Context(this) of callback function
|
|
112
1521
|
* @memberof module:collection
|
|
113
1522
|
* @example
|
|
114
|
-
*
|
|
1523
|
+
* // ES6
|
|
1524
|
+
* import forEach from 'tui-code-snippet/collection/forEach';
|
|
1525
|
+
*
|
|
1526
|
+
* // CommonJS
|
|
1527
|
+
* const forEach = require('tui-code-snippet/collection/forEach');
|
|
115
1528
|
*
|
|
116
|
-
*
|
|
1529
|
+
* let sum = 0;
|
|
117
1530
|
*
|
|
118
1531
|
* forEach([1,2,3], function(value){
|
|
119
|
-
*
|
|
1532
|
+
* sum += value;
|
|
120
1533
|
* });
|
|
121
1534
|
* alert(sum); // 6
|
|
122
1535
|
*
|
|
123
1536
|
* // In case of Array-like object
|
|
124
|
-
*
|
|
1537
|
+
* const array = Array.prototype.slice.call(arrayLike); // change to array
|
|
125
1538
|
* forEach(array, function(value){
|
|
126
|
-
*
|
|
1539
|
+
* sum += value;
|
|
127
1540
|
* });
|
|
128
1541
|
*/
|
|
129
1542
|
function forEach(obj, iteratee, context) {
|
|
@@ -142,6 +1555,7 @@ module.exports = forEach;
|
|
|
142
1555
|
/***/ 893:
|
|
143
1556
|
/***/ (function(module) {
|
|
144
1557
|
|
|
1558
|
+
"use strict";
|
|
145
1559
|
/**
|
|
146
1560
|
* @fileoverview Execute the provided callback once for each element present in the array(or Array-like object) in ascending order.
|
|
147
1561
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -162,12 +1576,16 @@ module.exports = forEach;
|
|
|
162
1576
|
* @param {Object} [context] Context(this) of callback function
|
|
163
1577
|
* @memberof module:collection
|
|
164
1578
|
* @example
|
|
165
|
-
*
|
|
1579
|
+
* // ES6
|
|
1580
|
+
* import forEachArray from 'tui-code-snippet/collection/forEachArray';
|
|
1581
|
+
*
|
|
1582
|
+
* // CommonJS
|
|
1583
|
+
* const forEachArray = require('tui-code-snippet/collection/forEachArray');
|
|
166
1584
|
*
|
|
167
|
-
*
|
|
1585
|
+
* let sum = 0;
|
|
168
1586
|
*
|
|
169
1587
|
* forEachArray([1,2,3], function(value){
|
|
170
|
-
*
|
|
1588
|
+
* sum += value;
|
|
171
1589
|
* });
|
|
172
1590
|
* alert(sum); // 6
|
|
173
1591
|
*/
|
|
@@ -192,6 +1610,7 @@ module.exports = forEachArray;
|
|
|
192
1610
|
/***/ 956:
|
|
193
1611
|
/***/ (function(module) {
|
|
194
1612
|
|
|
1613
|
+
"use strict";
|
|
195
1614
|
/**
|
|
196
1615
|
* @fileoverview Execute the provided callback once for each property of object which actually exist.
|
|
197
1616
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -211,12 +1630,16 @@ module.exports = forEachArray;
|
|
|
211
1630
|
* @param {Object} [context] Context(this) of callback function
|
|
212
1631
|
* @memberof module:collection
|
|
213
1632
|
* @example
|
|
214
|
-
*
|
|
1633
|
+
* // ES6
|
|
1634
|
+
* import forEachOwnProperties from 'tui-code-snippet/collection/forEachOwnProperties';
|
|
1635
|
+
*
|
|
1636
|
+
* // CommonJS
|
|
1637
|
+
* const forEachOwnProperties = require('tui-code-snippet/collection/forEachOwnProperties');
|
|
215
1638
|
*
|
|
216
|
-
*
|
|
1639
|
+
* let sum = 0;
|
|
217
1640
|
*
|
|
218
1641
|
* forEachOwnProperties({a:1,b:2,c:3}, function(value){
|
|
219
|
-
*
|
|
1642
|
+
* sum += value;
|
|
220
1643
|
* });
|
|
221
1644
|
* alert(sum); // 6
|
|
222
1645
|
*/
|
|
@@ -242,6 +1665,7 @@ module.exports = forEachOwnProperties;
|
|
|
242
1665
|
/***/ 990:
|
|
243
1666
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
244
1667
|
|
|
1668
|
+
"use strict";
|
|
245
1669
|
/**
|
|
246
1670
|
* @fileoverview Transform the Array-like object to Array.
|
|
247
1671
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -258,16 +1682,20 @@ var forEachArray = __webpack_require__(893);
|
|
|
258
1682
|
* @returns {Array} Array
|
|
259
1683
|
* @memberof module:collection
|
|
260
1684
|
* @example
|
|
261
|
-
*
|
|
1685
|
+
* // ES6
|
|
1686
|
+
* import toArray from 'tui-code-snippet/collection/toArray';
|
|
1687
|
+
*
|
|
1688
|
+
* // CommonJS
|
|
1689
|
+
* const toArray = require('tui-code-snippet/collection/toArray');
|
|
262
1690
|
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
1691
|
+
* const arrayLike = {
|
|
1692
|
+
* 0: 'one',
|
|
1693
|
+
* 1: 'two',
|
|
1694
|
+
* 2: 'three',
|
|
1695
|
+
* 3: 'four',
|
|
1696
|
+
* length: 4
|
|
269
1697
|
* };
|
|
270
|
-
*
|
|
1698
|
+
* const result = toArray(arrayLike);
|
|
271
1699
|
*
|
|
272
1700
|
* alert(result instanceof Array); // true
|
|
273
1701
|
* alert(result); // one,two,three,four
|
|
@@ -294,6 +1722,7 @@ module.exports = toArray;
|
|
|
294
1722
|
/***/ 755:
|
|
295
1723
|
/***/ (function(module) {
|
|
296
1724
|
|
|
1725
|
+
"use strict";
|
|
297
1726
|
/**
|
|
298
1727
|
* @fileoverview Get event collection for specific HTML element
|
|
299
1728
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -334,6 +1763,7 @@ module.exports = safeEvent;
|
|
|
334
1763
|
/***/ 349:
|
|
335
1764
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
336
1765
|
|
|
1766
|
+
"use strict";
|
|
337
1767
|
/**
|
|
338
1768
|
* @fileoverview Unbind DOM events
|
|
339
1769
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -442,6 +1872,7 @@ module.exports = off;
|
|
|
442
1872
|
/***/ 348:
|
|
443
1873
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
444
1874
|
|
|
1875
|
+
"use strict";
|
|
445
1876
|
/**
|
|
446
1877
|
* @fileoverview Bind DOM events
|
|
447
1878
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -462,7 +1893,7 @@ var safeEvent = __webpack_require__(755);
|
|
|
462
1893
|
* @param {object} [context] context - context for handler method.
|
|
463
1894
|
* @memberof module:domEvent
|
|
464
1895
|
* @example
|
|
465
|
-
*
|
|
1896
|
+
* const div = document.querySelector('div');
|
|
466
1897
|
*
|
|
467
1898
|
* // Bind one event to an element.
|
|
468
1899
|
* on(div, 'click', toggle);
|
|
@@ -479,10 +1910,10 @@ var safeEvent = __webpack_require__(755);
|
|
|
479
1910
|
* });
|
|
480
1911
|
*
|
|
481
1912
|
* // Set a context for handler method.
|
|
482
|
-
*
|
|
483
|
-
*
|
|
1913
|
+
* const name = 'global';
|
|
1914
|
+
* const repository = {name: 'CodeSnippet'};
|
|
484
1915
|
* on(div, 'drag', function() {
|
|
485
|
-
*
|
|
1916
|
+
* console.log(this.name);
|
|
486
1917
|
* }, repository);
|
|
487
1918
|
* // Result when you drag a div: "CodeSnippet"
|
|
488
1919
|
*/
|
|
@@ -563,6 +1994,7 @@ module.exports = on;
|
|
|
563
1994
|
/***/ 24:
|
|
564
1995
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
565
1996
|
|
|
1997
|
+
"use strict";
|
|
566
1998
|
/**
|
|
567
1999
|
* @fileoverview Set className value
|
|
568
2000
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -601,6 +2033,7 @@ module.exports = setClassName;
|
|
|
601
2033
|
/***/ 204:
|
|
602
2034
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
603
2035
|
|
|
2036
|
+
"use strict";
|
|
604
2037
|
/**
|
|
605
2038
|
* @fileoverview Add css class to element
|
|
606
2039
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -661,6 +2094,7 @@ module.exports = addClass;
|
|
|
661
2094
|
/***/ 522:
|
|
662
2095
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
663
2096
|
|
|
2097
|
+
"use strict";
|
|
664
2098
|
/**
|
|
665
2099
|
* @fileoverview Setting element style
|
|
666
2100
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -700,6 +2134,7 @@ module.exports = css;
|
|
|
700
2134
|
/***/ 902:
|
|
701
2135
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
702
2136
|
|
|
2137
|
+
"use strict";
|
|
703
2138
|
/**
|
|
704
2139
|
* @fileoverview Get HTML element's design classes.
|
|
705
2140
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -735,6 +2170,7 @@ module.exports = getClass;
|
|
|
735
2170
|
/***/ 714:
|
|
736
2171
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
737
2172
|
|
|
2173
|
+
"use strict";
|
|
738
2174
|
/**
|
|
739
2175
|
* @fileoverview Check element has specific css class
|
|
740
2176
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -772,6 +2208,7 @@ module.exports = hasClass;
|
|
|
772
2208
|
/***/ 471:
|
|
773
2209
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
774
2210
|
|
|
2211
|
+
"use strict";
|
|
775
2212
|
/**
|
|
776
2213
|
* @fileoverview Check element match selector
|
|
777
2214
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -812,6 +2249,7 @@ module.exports = matches;
|
|
|
812
2249
|
/***/ 462:
|
|
813
2250
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
814
2251
|
|
|
2252
|
+
"use strict";
|
|
815
2253
|
/**
|
|
816
2254
|
* @fileoverview Remove css class from element
|
|
817
2255
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -862,6 +2300,7 @@ module.exports = removeClass;
|
|
|
862
2300
|
/***/ 969:
|
|
863
2301
|
/***/ (function(module) {
|
|
864
2302
|
|
|
2303
|
+
"use strict";
|
|
865
2304
|
/**
|
|
866
2305
|
* @fileoverview Extend the target object from other objects.
|
|
867
2306
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -904,6 +2343,7 @@ module.exports = extend;
|
|
|
904
2343
|
/***/ 254:
|
|
905
2344
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
906
2345
|
|
|
2346
|
+
"use strict";
|
|
907
2347
|
/**
|
|
908
2348
|
* @fileoverview Request image ping.
|
|
909
2349
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -924,15 +2364,19 @@ var forEachOwnProperties = __webpack_require__(956);
|
|
|
924
2364
|
* @returns {HTMLElement}
|
|
925
2365
|
* @memberof module:request
|
|
926
2366
|
* @example
|
|
927
|
-
*
|
|
2367
|
+
* // ES6
|
|
2368
|
+
* import imagePing from 'tui-code-snippet/request/imagePing';
|
|
2369
|
+
*
|
|
2370
|
+
* // CommonJS
|
|
2371
|
+
* const imagePing = require('tui-code-snippet/request/imagePing');
|
|
928
2372
|
*
|
|
929
2373
|
* imagePing('https://www.google-analytics.com/collect', {
|
|
930
|
-
*
|
|
931
|
-
*
|
|
932
|
-
*
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
*
|
|
2374
|
+
* v: 1,
|
|
2375
|
+
* t: 'event',
|
|
2376
|
+
* tid: 'trackingid',
|
|
2377
|
+
* cid: 'cid',
|
|
2378
|
+
* dp: 'dp',
|
|
2379
|
+
* dh: 'dh'
|
|
936
2380
|
* });
|
|
937
2381
|
*/
|
|
938
2382
|
function imagePing(url, trackingInfo) {
|
|
@@ -960,6 +2404,7 @@ module.exports = imagePing;
|
|
|
960
2404
|
/***/ 391:
|
|
961
2405
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
962
2406
|
|
|
2407
|
+
"use strict";
|
|
963
2408
|
/**
|
|
964
2409
|
* @fileoverview Send hostname on DOMContentLoaded.
|
|
965
2410
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1035,6 +2480,7 @@ module.exports = sendHostname;
|
|
|
1035
2480
|
/***/ 516:
|
|
1036
2481
|
/***/ (function(module) {
|
|
1037
2482
|
|
|
2483
|
+
"use strict";
|
|
1038
2484
|
/**
|
|
1039
2485
|
* @fileoverview Creates a debounced function that delays invoking fn until after delay milliseconds has elapsed since the last time the debouced function was invoked.
|
|
1040
2486
|
* @author NHN FE Development Lab <dl_javascript.nhn.com>
|
|
@@ -1054,11 +2500,15 @@ module.exports = sendHostname;
|
|
|
1054
2500
|
* @returns {function} debounced function.
|
|
1055
2501
|
* @memberof module:tricks
|
|
1056
2502
|
* @example
|
|
1057
|
-
*
|
|
2503
|
+
* // ES6
|
|
2504
|
+
* import debounce from 'tui-code-snippet/tricks/debounce';
|
|
2505
|
+
*
|
|
2506
|
+
* // CommonJS
|
|
2507
|
+
* const debounce = require('tui-code-snippet/tricks/debounce');
|
|
1058
2508
|
*
|
|
1059
2509
|
* function someMethodToInvokeDebounced() {}
|
|
1060
2510
|
*
|
|
1061
|
-
*
|
|
2511
|
+
* const debounced = debounce(someMethodToInvokeDebounced, 300);
|
|
1062
2512
|
*
|
|
1063
2513
|
* // invoke repeatedly
|
|
1064
2514
|
* debounced();
|
|
@@ -1096,6 +2546,7 @@ module.exports = debounce;
|
|
|
1096
2546
|
/***/ 423:
|
|
1097
2547
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1098
2548
|
|
|
2549
|
+
"use strict";
|
|
1099
2550
|
/**
|
|
1100
2551
|
* @fileoverview Creates a throttled function that only invokes fn at most once per every interval milliseconds.
|
|
1101
2552
|
* @author NHN FE Development Lab <dl_javascript.nhn.com>
|
|
@@ -1114,11 +2565,15 @@ var debounce = __webpack_require__(516);
|
|
|
1114
2565
|
* @returns {function} throttled function
|
|
1115
2566
|
* @memberof module:tricks
|
|
1116
2567
|
* @example
|
|
1117
|
-
*
|
|
2568
|
+
* // ES6
|
|
2569
|
+
* import throttle from 'tui-code-snippet/tricks/throttle';
|
|
2570
|
+
*
|
|
2571
|
+
* // CommonJS
|
|
2572
|
+
* const throttle = require('tui-code-snippet/tricks/throttle');
|
|
1118
2573
|
*
|
|
1119
2574
|
* function someMethodToInvokeThrottled() {}
|
|
1120
2575
|
*
|
|
1121
|
-
*
|
|
2576
|
+
* const throttled = throttle(someMethodToInvokeThrottled, 300);
|
|
1122
2577
|
*
|
|
1123
2578
|
* // invoke repeatedly
|
|
1124
2579
|
* throttled(); // invoke (leading)
|
|
@@ -1191,6 +2646,7 @@ module.exports = throttle;
|
|
|
1191
2646
|
/***/ 322:
|
|
1192
2647
|
/***/ (function(module) {
|
|
1193
2648
|
|
|
2649
|
+
"use strict";
|
|
1194
2650
|
/**
|
|
1195
2651
|
* @fileoverview Check whether the given variable is an instance of Array or not.
|
|
1196
2652
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1217,6 +2673,7 @@ module.exports = isArray;
|
|
|
1217
2673
|
/***/ 326:
|
|
1218
2674
|
/***/ (function(module) {
|
|
1219
2675
|
|
|
2676
|
+
"use strict";
|
|
1220
2677
|
/**
|
|
1221
2678
|
* @fileoverview Check whether the given variable is a string or not.
|
|
1222
2679
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1243,6 +2700,7 @@ module.exports = isBoolean;
|
|
|
1243
2700
|
/***/ 65:
|
|
1244
2701
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1245
2702
|
|
|
2703
|
+
"use strict";
|
|
1246
2704
|
/**
|
|
1247
2705
|
* @fileoverview Check whether the given variable is existing or not.
|
|
1248
2706
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1260,7 +2718,11 @@ var isNull = __webpack_require__(934);
|
|
|
1260
2718
|
* @returns {boolean} Is existy?
|
|
1261
2719
|
* @memberof module:type
|
|
1262
2720
|
* @example
|
|
1263
|
-
*
|
|
2721
|
+
* // ES6
|
|
2722
|
+
* import isExisty from 'tui-code-snippet/type/isExisty');
|
|
2723
|
+
*
|
|
2724
|
+
* // CommonJS
|
|
2725
|
+
* const isExisty = require('tui-code-snippet/type/isExisty');
|
|
1264
2726
|
*
|
|
1265
2727
|
* isExisty(''); //true
|
|
1266
2728
|
* isExisty(0); //true
|
|
@@ -1281,6 +2743,7 @@ module.exports = isExisty;
|
|
|
1281
2743
|
/***/ 404:
|
|
1282
2744
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1283
2745
|
|
|
2746
|
+
"use strict";
|
|
1284
2747
|
/**
|
|
1285
2748
|
* @fileoverview Check whether the given variable is falsy or not.
|
|
1286
2749
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1309,6 +2772,7 @@ module.exports = isFalsy;
|
|
|
1309
2772
|
/***/ 294:
|
|
1310
2773
|
/***/ (function(module) {
|
|
1311
2774
|
|
|
2775
|
+
"use strict";
|
|
1312
2776
|
/**
|
|
1313
2777
|
* @fileoverview Check whether the given variable is a function or not.
|
|
1314
2778
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1335,6 +2799,7 @@ module.exports = isFunction;
|
|
|
1335
2799
|
/***/ 934:
|
|
1336
2800
|
/***/ (function(module) {
|
|
1337
2801
|
|
|
2802
|
+
"use strict";
|
|
1338
2803
|
/**
|
|
1339
2804
|
* @fileoverview Check whether the given variable is null or not.
|
|
1340
2805
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1361,6 +2826,7 @@ module.exports = isNull;
|
|
|
1361
2826
|
/***/ 321:
|
|
1362
2827
|
/***/ (function(module) {
|
|
1363
2828
|
|
|
2829
|
+
"use strict";
|
|
1364
2830
|
/**
|
|
1365
2831
|
* @fileoverview Check whether the given variable is a number or not.
|
|
1366
2832
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1387,6 +2853,7 @@ module.exports = isNumber;
|
|
|
1387
2853
|
/***/ 73:
|
|
1388
2854
|
/***/ (function(module) {
|
|
1389
2855
|
|
|
2856
|
+
"use strict";
|
|
1390
2857
|
/**
|
|
1391
2858
|
* @fileoverview Check whether the given variable is an object or not.
|
|
1392
2859
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1413,6 +2880,7 @@ module.exports = isObject;
|
|
|
1413
2880
|
/***/ 758:
|
|
1414
2881
|
/***/ (function(module) {
|
|
1415
2882
|
|
|
2883
|
+
"use strict";
|
|
1416
2884
|
/**
|
|
1417
2885
|
* @fileoverview Check whether the given variable is a string or not.
|
|
1418
2886
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1439,6 +2907,7 @@ module.exports = isString;
|
|
|
1439
2907
|
/***/ 790:
|
|
1440
2908
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
1441
2909
|
|
|
2910
|
+
"use strict";
|
|
1442
2911
|
/**
|
|
1443
2912
|
* @fileoverview Check whether the given variable is truthy or not.
|
|
1444
2913
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1468,6 +2937,7 @@ module.exports = isTruthy;
|
|
|
1468
2937
|
/***/ 929:
|
|
1469
2938
|
/***/ (function(module) {
|
|
1470
2939
|
|
|
2940
|
+
"use strict";
|
|
1471
2941
|
/**
|
|
1472
2942
|
* @fileoverview Check whether the given variable is undefined or not.
|
|
1473
2943
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
@@ -1491,59 +2961,67 @@ module.exports = isUndefined;
|
|
|
1491
2961
|
|
|
1492
2962
|
/***/ }),
|
|
1493
2963
|
|
|
1494
|
-
/***/
|
|
2964
|
+
/***/ 695:
|
|
1495
2965
|
/***/ (function(module) {
|
|
1496
2966
|
|
|
1497
|
-
|
|
2967
|
+
"use strict";
|
|
2968
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__695__;
|
|
1498
2969
|
|
|
1499
2970
|
/***/ }),
|
|
1500
2971
|
|
|
1501
|
-
/***/
|
|
2972
|
+
/***/ 412:
|
|
1502
2973
|
/***/ (function(module) {
|
|
1503
2974
|
|
|
1504
|
-
|
|
2975
|
+
"use strict";
|
|
2976
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__412__;
|
|
1505
2977
|
|
|
1506
2978
|
/***/ }),
|
|
1507
2979
|
|
|
1508
|
-
/***/
|
|
2980
|
+
/***/ 479:
|
|
1509
2981
|
/***/ (function(module) {
|
|
1510
2982
|
|
|
1511
|
-
|
|
2983
|
+
"use strict";
|
|
2984
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__479__;
|
|
1512
2985
|
|
|
1513
2986
|
/***/ }),
|
|
1514
2987
|
|
|
1515
|
-
/***/
|
|
2988
|
+
/***/ 481:
|
|
1516
2989
|
/***/ (function(module) {
|
|
1517
2990
|
|
|
1518
|
-
|
|
2991
|
+
"use strict";
|
|
2992
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__481__;
|
|
1519
2993
|
|
|
1520
2994
|
/***/ }),
|
|
1521
2995
|
|
|
1522
|
-
/***/
|
|
2996
|
+
/***/ 43:
|
|
1523
2997
|
/***/ (function(module) {
|
|
1524
2998
|
|
|
1525
|
-
|
|
2999
|
+
"use strict";
|
|
3000
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__43__;
|
|
1526
3001
|
|
|
1527
3002
|
/***/ }),
|
|
1528
3003
|
|
|
1529
|
-
/***/
|
|
3004
|
+
/***/ 814:
|
|
1530
3005
|
/***/ (function(module) {
|
|
1531
3006
|
|
|
1532
|
-
|
|
3007
|
+
"use strict";
|
|
3008
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__814__;
|
|
1533
3009
|
|
|
1534
3010
|
/***/ }),
|
|
1535
3011
|
|
|
1536
|
-
/***/
|
|
3012
|
+
/***/ 785:
|
|
1537
3013
|
/***/ (function(module) {
|
|
1538
3014
|
|
|
1539
|
-
|
|
3015
|
+
"use strict";
|
|
3016
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__785__;
|
|
1540
3017
|
|
|
1541
3018
|
/***/ }),
|
|
1542
3019
|
|
|
1543
|
-
/***/
|
|
3020
|
+
/***/ 311:
|
|
1544
3021
|
/***/ (function(module) {
|
|
1545
3022
|
|
|
1546
|
-
|
|
3023
|
+
"use strict";
|
|
3024
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__311__;
|
|
1547
3025
|
|
|
1548
3026
|
/***/ })
|
|
1549
3027
|
|
|
@@ -1567,7 +3045,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
|
|
|
1567
3045
|
/******/ };
|
|
1568
3046
|
/******/
|
|
1569
3047
|
/******/ // Execute the module function
|
|
1570
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
3048
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
1571
3049
|
/******/
|
|
1572
3050
|
/******/ // Return the exports of the module
|
|
1573
3051
|
/******/ return module.exports;
|
|
@@ -1617,8 +3095,9 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
|
|
|
1617
3095
|
/******/
|
|
1618
3096
|
/************************************************************************/
|
|
1619
3097
|
var __webpack_exports__ = {};
|
|
1620
|
-
// This entry need to be wrapped in an IIFE because it need to be
|
|
3098
|
+
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
|
1621
3099
|
!function() {
|
|
3100
|
+
"use strict";
|
|
1622
3101
|
|
|
1623
3102
|
// EXPORTS
|
|
1624
3103
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -1792,10 +3271,14 @@ function __spreadArrays() {
|
|
|
1792
3271
|
return r;
|
|
1793
3272
|
}
|
|
1794
3273
|
|
|
1795
|
-
function __spreadArray(to, from) {
|
|
1796
|
-
for (var i = 0,
|
|
1797
|
-
|
|
1798
|
-
|
|
3274
|
+
function __spreadArray(to, from, pack) {
|
|
3275
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3276
|
+
if (ar || !(i in from)) {
|
|
3277
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
3278
|
+
ar[i] = from[i];
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1799
3282
|
}
|
|
1800
3283
|
|
|
1801
3284
|
function __await(v) {
|
|
@@ -1851,23 +3334,21 @@ function __importDefault(mod) {
|
|
|
1851
3334
|
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
1852
3335
|
}
|
|
1853
3336
|
|
|
1854
|
-
function __classPrivateFieldGet(receiver,
|
|
1855
|
-
if (!
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
return privateMap.get(receiver);
|
|
3337
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
3338
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3339
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
3340
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1859
3341
|
}
|
|
1860
3342
|
|
|
1861
|
-
function __classPrivateFieldSet(receiver,
|
|
1862
|
-
if (
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
return value;
|
|
3343
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
3344
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3345
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
3346
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3347
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1867
3348
|
}
|
|
1868
3349
|
|
|
1869
3350
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-model","commonjs2":"prosemirror-model","amd":"prosemirror-model"}
|
|
1870
|
-
var external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_ = __webpack_require__(
|
|
3351
|
+
var external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_ = __webpack_require__(43);
|
|
1871
3352
|
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/forEachOwnProperties.js
|
|
1872
3353
|
var forEachOwnProperties = __webpack_require__(956);
|
|
1873
3354
|
var forEachOwnProperties_default = /*#__PURE__*/__webpack_require__.n(forEachOwnProperties);
|
|
@@ -1910,6 +3391,30 @@ var reEscapeChars = /[>(){}[\]+-.!#|]/g;
|
|
|
1910
3391
|
var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\/>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>|<!--[^-]+-->|<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g;
|
|
1911
3392
|
var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
|
|
1912
3393
|
var reEscapePairedChars = /[*_~`]/g;
|
|
3394
|
+
var reMdImageSyntax = /!\[.*\]\(.*\)/g;
|
|
3395
|
+
var reEscapedCharInLinkSyntax = /[[\]]/g; //
|
|
3396
|
+
var XMLSPECIAL = '[&<>"]';
|
|
3397
|
+
var reXmlSpecial = new RegExp(XMLSPECIAL, 'g');
|
|
3398
|
+
function replaceUnsafeChar(char) {
|
|
3399
|
+
switch (char) {
|
|
3400
|
+
case '&':
|
|
3401
|
+
return '&';
|
|
3402
|
+
case '<':
|
|
3403
|
+
return '<';
|
|
3404
|
+
case '>':
|
|
3405
|
+
return '>';
|
|
3406
|
+
case '"':
|
|
3407
|
+
return '"';
|
|
3408
|
+
default:
|
|
3409
|
+
return char;
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
function escapeXml(text) {
|
|
3413
|
+
if (reXmlSpecial.test(text)) {
|
|
3414
|
+
return text.replace(reXmlSpecial, replaceUnsafeChar);
|
|
3415
|
+
}
|
|
3416
|
+
return text;
|
|
3417
|
+
}
|
|
1913
3418
|
function sendHostName() {
|
|
1914
3419
|
sendHostname_default()('editor', 'UA-129966929-1');
|
|
1915
3420
|
}
|
|
@@ -1959,6 +3464,18 @@ function isNeedEscapeText(text) {
|
|
|
1959
3464
|
});
|
|
1960
3465
|
return needEscape;
|
|
1961
3466
|
}
|
|
3467
|
+
function escapeTextForLink(text) {
|
|
3468
|
+
var imageSyntaxRanges = [];
|
|
3469
|
+
var result = reMdImageSyntax.exec(text);
|
|
3470
|
+
while (result) {
|
|
3471
|
+
imageSyntaxRanges.push([result.index, result.index + result[0].length]);
|
|
3472
|
+
result = reMdImageSyntax.exec(text);
|
|
3473
|
+
}
|
|
3474
|
+
return text.replace(reEscapedCharInLinkSyntax, function (matched, offset) {
|
|
3475
|
+
var isDelimiter = imageSyntaxRanges.some(function (range) { return offset > range[0] && offset < range[1]; });
|
|
3476
|
+
return isDelimiter ? matched : "\\" + matched;
|
|
3477
|
+
});
|
|
3478
|
+
}
|
|
1962
3479
|
function common_escape(text) {
|
|
1963
3480
|
var replacer = function (matched) { return "\\" + matched; };
|
|
1964
3481
|
var escapedText = text.replace(reSpaceMoreThanOne, ' ');
|
|
@@ -2082,19 +3599,22 @@ function getSortedNumPair(valueA, valueB) {
|
|
|
2082
3599
|
}
|
|
2083
3600
|
|
|
2084
3601
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-view","commonjs2":"prosemirror-view","amd":"prosemirror-view"}
|
|
2085
|
-
var external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_ = __webpack_require__(
|
|
3602
|
+
var external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_ = __webpack_require__(311);
|
|
2086
3603
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-transform","commonjs2":"prosemirror-transform","amd":"prosemirror-transform"}
|
|
2087
|
-
var external_commonjs_prosemirror_transform_commonjs2_prosemirror_transform_amd_prosemirror_transform_ = __webpack_require__(
|
|
3604
|
+
var external_commonjs_prosemirror_transform_commonjs2_prosemirror_transform_amd_prosemirror_transform_ = __webpack_require__(785);
|
|
3605
|
+
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/toArray.js
|
|
3606
|
+
var collection_toArray = __webpack_require__(990);
|
|
3607
|
+
var toArray_default = /*#__PURE__*/__webpack_require__.n(collection_toArray);
|
|
2088
3608
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-state","commonjs2":"prosemirror-state","amd":"prosemirror-state"}
|
|
2089
|
-
var external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_ = __webpack_require__(
|
|
3609
|
+
var external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_ = __webpack_require__(814);
|
|
2090
3610
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-keymap","commonjs2":"prosemirror-keymap","amd":"prosemirror-keymap"}
|
|
2091
|
-
var external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_ = __webpack_require__(
|
|
3611
|
+
var external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_ = __webpack_require__(481);
|
|
2092
3612
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-commands","commonjs2":"prosemirror-commands","amd":"prosemirror-commands"}
|
|
2093
|
-
var external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_ = __webpack_require__(
|
|
3613
|
+
var external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_ = __webpack_require__(695);
|
|
2094
3614
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-inputrules","commonjs2":"prosemirror-inputrules","amd":"prosemirror-inputrules"}
|
|
2095
|
-
var external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_ = __webpack_require__(
|
|
3615
|
+
var external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_ = __webpack_require__(479);
|
|
2096
3616
|
// EXTERNAL MODULE: external {"commonjs":"prosemirror-history","commonjs2":"prosemirror-history","amd":"prosemirror-history"}
|
|
2097
|
-
var external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_ = __webpack_require__(
|
|
3617
|
+
var external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_ = __webpack_require__(412);
|
|
2098
3618
|
;// CONCATENATED MODULE: ./src/helper/manipulation.ts
|
|
2099
3619
|
|
|
2100
3620
|
|
|
@@ -2453,22 +3973,275 @@ function placeholder(options) {
|
|
|
2453
3973
|
});
|
|
2454
3974
|
}
|
|
2455
3975
|
|
|
3976
|
+
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isArray.js
|
|
3977
|
+
var isArray = __webpack_require__(322);
|
|
3978
|
+
var isArray_default = /*#__PURE__*/__webpack_require__.n(isArray);
|
|
3979
|
+
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/domUtil/hasClass.js
|
|
3980
|
+
var hasClass = __webpack_require__(714);
|
|
3981
|
+
var hasClass_default = /*#__PURE__*/__webpack_require__.n(hasClass);
|
|
3982
|
+
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/domUtil/matches.js
|
|
3983
|
+
var matches = __webpack_require__(471);
|
|
3984
|
+
var matches_default = /*#__PURE__*/__webpack_require__.n(matches);
|
|
3985
|
+
;// CONCATENATED MODULE: ./src/utils/constants.ts
|
|
3986
|
+
var TAG_NAME = '[A-Za-z][A-Za-z0-9-]*';
|
|
3987
|
+
var ATTRIBUTE_NAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
|
|
3988
|
+
var UNQUOTED_VALUE = '[^"\'=<>`\\x00-\\x20]+';
|
|
3989
|
+
var SINGLE_QUOTED_VALUE = "'[^']*'";
|
|
3990
|
+
var DOUBLE_QUOTED_VALUE = '"[^"]*"';
|
|
3991
|
+
var ATTRIBUTE_VALUE = "(?:" + UNQUOTED_VALUE + "|" + SINGLE_QUOTED_VALUE + "|" + DOUBLE_QUOTED_VALUE + ")";
|
|
3992
|
+
var ATTRIBUTE_VALUE_SPEC = "" + '(?:\\s*=\\s*' + ATTRIBUTE_VALUE + ")";
|
|
3993
|
+
var ATTRIBUTE = "" + '(?:\\s+' + ATTRIBUTE_NAME + ATTRIBUTE_VALUE_SPEC + "?)";
|
|
3994
|
+
var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE + ")*\\s*/?>";
|
|
3995
|
+
var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
|
|
3996
|
+
var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
|
|
3997
|
+
var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
|
|
3998
|
+
var reBR = /<br\s*\/*>/i;
|
|
3999
|
+
var reHTMLComment = /<! ---->|<!--(?:-?[^>-])(?:-?[^-])*-->/;
|
|
4000
|
+
var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
|
|
4001
|
+
|
|
4002
|
+
;// CONCATENATED MODULE: ./src/utils/dom.ts
|
|
4003
|
+
|
|
4004
|
+
|
|
4005
|
+
|
|
4006
|
+
|
|
4007
|
+
|
|
4008
|
+
|
|
4009
|
+
|
|
4010
|
+
|
|
4011
|
+
|
|
4012
|
+
|
|
4013
|
+
function isPositionInBox(style, offsetX, offsetY) {
|
|
4014
|
+
var left = parseInt(style.left, 10);
|
|
4015
|
+
var top = parseInt(style.top, 10);
|
|
4016
|
+
var width = parseInt(style.width, 10) + parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
|
|
4017
|
+
var height = parseInt(style.height, 10) + parseInt(style.paddingTop, 10) + parseInt(style.paddingBottom, 10);
|
|
4018
|
+
return offsetX >= left && offsetX <= left + width && offsetY >= top && offsetY <= top + height;
|
|
4019
|
+
}
|
|
4020
|
+
var CLS_PREFIX = 'toastui-editor-';
|
|
4021
|
+
function cls() {
|
|
4022
|
+
var names = [];
|
|
4023
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
4024
|
+
names[_i] = arguments[_i];
|
|
4025
|
+
}
|
|
4026
|
+
var result = [];
|
|
4027
|
+
for (var _a = 0, names_1 = names; _a < names_1.length; _a++) {
|
|
4028
|
+
var name = names_1[_a];
|
|
4029
|
+
var className = void 0;
|
|
4030
|
+
if (Array.isArray(name)) {
|
|
4031
|
+
className = name[0] ? name[1] : null;
|
|
4032
|
+
}
|
|
4033
|
+
else {
|
|
4034
|
+
className = name;
|
|
4035
|
+
}
|
|
4036
|
+
if (className) {
|
|
4037
|
+
result.push("" + CLS_PREFIX + className);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
return result.join(' ');
|
|
4041
|
+
}
|
|
4042
|
+
function clsWithMdPrefix() {
|
|
4043
|
+
var names = [];
|
|
4044
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
4045
|
+
names[_i] = arguments[_i];
|
|
4046
|
+
}
|
|
4047
|
+
return names.map(function (className) { return CLS_PREFIX + "md-" + className; }).join(' ');
|
|
4048
|
+
}
|
|
4049
|
+
function isTextNode(node) {
|
|
4050
|
+
return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.TEXT_NODE;
|
|
4051
|
+
}
|
|
4052
|
+
function isElemNode(node) {
|
|
4053
|
+
return node && node.nodeType === Node.ELEMENT_NODE;
|
|
4054
|
+
}
|
|
4055
|
+
function findNodes(element, selector) {
|
|
4056
|
+
var nodeList = toArray_default()(element.querySelectorAll(selector));
|
|
4057
|
+
if (nodeList.length) {
|
|
4058
|
+
return nodeList;
|
|
4059
|
+
}
|
|
4060
|
+
return [];
|
|
4061
|
+
}
|
|
4062
|
+
function appendNodes(node, nodesToAppend) {
|
|
4063
|
+
nodesToAppend = isArray_default()(nodesToAppend) ? toArray_default()(nodesToAppend) : [nodesToAppend];
|
|
4064
|
+
nodesToAppend.forEach(function (nodeToAppend) {
|
|
4065
|
+
node.appendChild(nodeToAppend);
|
|
4066
|
+
});
|
|
4067
|
+
}
|
|
4068
|
+
function insertBeforeNode(insertedNode, node) {
|
|
4069
|
+
if (node.parentNode) {
|
|
4070
|
+
node.parentNode.insertBefore(insertedNode, node);
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
function removeNode(node) {
|
|
4074
|
+
if (node.parentNode) {
|
|
4075
|
+
node.parentNode.removeChild(node);
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
function unwrapNode(node) {
|
|
4079
|
+
var result = [];
|
|
4080
|
+
while (node.firstChild) {
|
|
4081
|
+
result.push(node.firstChild);
|
|
4082
|
+
if (node.parentNode) {
|
|
4083
|
+
node.parentNode.insertBefore(node.firstChild, node);
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4086
|
+
removeNode(node);
|
|
4087
|
+
return result;
|
|
4088
|
+
}
|
|
4089
|
+
function toggleClass(element, className, state) {
|
|
4090
|
+
if (isUndefined_default()(state)) {
|
|
4091
|
+
state = !hasClass_default()(element, className);
|
|
4092
|
+
}
|
|
4093
|
+
var toggleFn = state ? (addClass_default()) : (removeClass_default());
|
|
4094
|
+
toggleFn(element, className);
|
|
4095
|
+
}
|
|
4096
|
+
function createElementWith(contents, target) {
|
|
4097
|
+
var container = document.createElement('div');
|
|
4098
|
+
if (isString_default()(contents)) {
|
|
4099
|
+
container.innerHTML = contents;
|
|
4100
|
+
}
|
|
4101
|
+
else {
|
|
4102
|
+
container.appendChild(contents);
|
|
4103
|
+
}
|
|
4104
|
+
var firstChild = container.firstChild;
|
|
4105
|
+
if (target) {
|
|
4106
|
+
target.appendChild(firstChild);
|
|
4107
|
+
}
|
|
4108
|
+
return firstChild;
|
|
4109
|
+
}
|
|
4110
|
+
function getOuterWidth(el) {
|
|
4111
|
+
var computed = window.getComputedStyle(el);
|
|
4112
|
+
return (['margin-left', 'margin-right'].reduce(function (acc, type) { return acc + parseInt(computed.getPropertyValue(type), 10); }, 0) + el.offsetWidth);
|
|
4113
|
+
}
|
|
4114
|
+
function closest(node, found) {
|
|
4115
|
+
var condition;
|
|
4116
|
+
if (isString_default()(found)) {
|
|
4117
|
+
condition = function (target) { return matches_default()(target, found); };
|
|
4118
|
+
}
|
|
4119
|
+
else {
|
|
4120
|
+
condition = function (target) { return target === found; };
|
|
4121
|
+
}
|
|
4122
|
+
while (node && node !== document) {
|
|
4123
|
+
if (isElemNode(node) && condition(node)) {
|
|
4124
|
+
return node;
|
|
4125
|
+
}
|
|
4126
|
+
node = node.parentNode;
|
|
4127
|
+
}
|
|
4128
|
+
return null;
|
|
4129
|
+
}
|
|
4130
|
+
function getTotalOffset(el, root) {
|
|
4131
|
+
var offsetTop = 0;
|
|
4132
|
+
var offsetLeft = 0;
|
|
4133
|
+
while (el && el !== root) {
|
|
4134
|
+
var top = el.offsetTop, left = el.offsetLeft, offsetParent = el.offsetParent;
|
|
4135
|
+
offsetTop += top;
|
|
4136
|
+
offsetLeft += left;
|
|
4137
|
+
if (offsetParent === root.offsetParent) {
|
|
4138
|
+
break;
|
|
4139
|
+
}
|
|
4140
|
+
el = el.offsetParent;
|
|
4141
|
+
}
|
|
4142
|
+
return { offsetTop: offsetTop, offsetLeft: offsetLeft };
|
|
4143
|
+
}
|
|
4144
|
+
function finalizeHtml(html, needHtmlText) {
|
|
4145
|
+
var result;
|
|
4146
|
+
if (needHtmlText) {
|
|
4147
|
+
result = html.innerHTML;
|
|
4148
|
+
}
|
|
4149
|
+
else {
|
|
4150
|
+
var frag = document.createDocumentFragment();
|
|
4151
|
+
var childNodes = toArray(html.childNodes);
|
|
4152
|
+
var length = childNodes.length;
|
|
4153
|
+
for (var i = 0; i < length; i += 1) {
|
|
4154
|
+
frag.appendChild(childNodes[i]);
|
|
4155
|
+
}
|
|
4156
|
+
result = frag;
|
|
4157
|
+
}
|
|
4158
|
+
return result;
|
|
4159
|
+
}
|
|
4160
|
+
function empty(node) {
|
|
4161
|
+
while (node.firstChild) {
|
|
4162
|
+
node.removeChild(node.firstChild);
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
4165
|
+
function appendNode(node, appended) {
|
|
4166
|
+
if (isString(appended)) {
|
|
4167
|
+
node.insertAdjacentHTML('beforeend', appended);
|
|
4168
|
+
}
|
|
4169
|
+
else {
|
|
4170
|
+
var nodes = appended.length
|
|
4171
|
+
? toArray(appended)
|
|
4172
|
+
: [appended];
|
|
4173
|
+
for (var i = 0, len = nodes.length; i < len; i += 1) {
|
|
4174
|
+
node.appendChild(nodes[i]);
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
function prependNode(node, appended) {
|
|
4179
|
+
if (isString(appended)) {
|
|
4180
|
+
node.insertAdjacentHTML('afterbegin', appended);
|
|
4181
|
+
}
|
|
4182
|
+
else {
|
|
4183
|
+
var nodes = appended.length
|
|
4184
|
+
? toArray(appended)
|
|
4185
|
+
: [appended];
|
|
4186
|
+
for (var i = nodes.length - 1, len = 0; i >= len; i -= 1) {
|
|
4187
|
+
node.insertBefore(nodes[i], node.firstChild);
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
function setAttributes(attributes, element) {
|
|
4192
|
+
Object.keys(attributes).forEach(function (attrName) {
|
|
4193
|
+
if (isNil(attributes[attrName])) {
|
|
4194
|
+
element.removeAttribute(attrName);
|
|
4195
|
+
}
|
|
4196
|
+
else {
|
|
4197
|
+
element.setAttribute(attrName, attributes[attrName]);
|
|
4198
|
+
}
|
|
4199
|
+
});
|
|
4200
|
+
}
|
|
4201
|
+
function replaceBRWithEmptyBlock(html) {
|
|
4202
|
+
// remove br in paragraph to compatible with markdown
|
|
4203
|
+
var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
|
|
4204
|
+
var reHTMLTag = new RegExp(HTML_TAG, 'ig');
|
|
4205
|
+
var htmlTagMatched = replacedHTML.match(reHTMLTag);
|
|
4206
|
+
htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
|
|
4207
|
+
if (reBR.test(htmlTag)) {
|
|
4208
|
+
var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
|
|
4209
|
+
if (index) {
|
|
4210
|
+
var prevTag = htmlTagMatched[index - 1];
|
|
4211
|
+
var openTagMatched = prevTag.match(OPEN_TAG);
|
|
4212
|
+
if (openTagMatched && !/br/i.test(openTagMatched[1])) {
|
|
4213
|
+
var tagName = openTagMatched[1];
|
|
4214
|
+
alternativeTag = "</" + tagName + "><" + tagName + ">";
|
|
4215
|
+
}
|
|
4216
|
+
}
|
|
4217
|
+
replacedHTML = replacedHTML.replace(reBR, alternativeTag);
|
|
4218
|
+
}
|
|
4219
|
+
});
|
|
4220
|
+
return replacedHTML;
|
|
4221
|
+
}
|
|
4222
|
+
|
|
2456
4223
|
;// CONCATENATED MODULE: ./src/plugins/popupWidget.ts
|
|
2457
4224
|
|
|
2458
4225
|
|
|
4226
|
+
|
|
2459
4227
|
var pluginKey = new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.PluginKey('widget');
|
|
4228
|
+
var MARGIN = 5;
|
|
2460
4229
|
var PopupWidget = /** @class */ (function () {
|
|
2461
|
-
function PopupWidget(eventEmitter) {
|
|
4230
|
+
function PopupWidget(view, eventEmitter) {
|
|
2462
4231
|
var _this = this;
|
|
2463
4232
|
this.popup = null;
|
|
2464
4233
|
this.removeWidget = function () {
|
|
2465
4234
|
if (_this.popup) {
|
|
2466
|
-
|
|
4235
|
+
_this.rootEl.removeChild(_this.popup);
|
|
2467
4236
|
_this.popup = null;
|
|
2468
4237
|
}
|
|
2469
4238
|
};
|
|
4239
|
+
this.rootEl = view.dom.parentElement;
|
|
2470
4240
|
this.eventEmitter = eventEmitter;
|
|
2471
4241
|
this.eventEmitter.listen('blur', this.removeWidget);
|
|
4242
|
+
this.eventEmitter.listen('loadUI', function () {
|
|
4243
|
+
_this.rootEl = closest(view.dom.parentElement, "." + cls('defaultUI'));
|
|
4244
|
+
});
|
|
2472
4245
|
this.eventEmitter.listen('removePopupWidget', this.removeWidget);
|
|
2473
4246
|
}
|
|
2474
4247
|
PopupWidget.prototype.update = function (view) {
|
|
@@ -2478,10 +4251,14 @@ var PopupWidget = /** @class */ (function () {
|
|
|
2478
4251
|
var node = widget.node, style = widget.style;
|
|
2479
4252
|
var _a = view.coordsAtPos(widget.pos), top = _a.top, left = _a.left, bottom = _a.bottom;
|
|
2480
4253
|
var height = bottom - top;
|
|
2481
|
-
|
|
2482
|
-
|
|
4254
|
+
var rect = this.rootEl.getBoundingClientRect();
|
|
4255
|
+
var relTopPos = top - rect.top;
|
|
4256
|
+
css_default()(node, { opacity: '0' });
|
|
4257
|
+
this.rootEl.appendChild(node);
|
|
2483
4258
|
css_default()(node, {
|
|
2484
|
-
|
|
4259
|
+
position: 'absolute',
|
|
4260
|
+
left: left - rect.left + MARGIN + "px",
|
|
4261
|
+
top: (style === 'bottom' ? relTopPos + height - MARGIN : relTopPos - height) + "px",
|
|
2485
4262
|
opacity: '1',
|
|
2486
4263
|
});
|
|
2487
4264
|
this.popup = node;
|
|
@@ -2504,8 +4281,8 @@ function addWidget(eventEmitter) {
|
|
|
2504
4281
|
return tr.getMeta('widget');
|
|
2505
4282
|
},
|
|
2506
4283
|
},
|
|
2507
|
-
view: function () {
|
|
2508
|
-
return new PopupWidget(eventEmitter);
|
|
4284
|
+
view: function (editorView) {
|
|
4285
|
+
return new PopupWidget(editorView, eventEmitter);
|
|
2509
4286
|
},
|
|
2510
4287
|
});
|
|
2511
4288
|
}
|
|
@@ -2513,9 +4290,6 @@ function addWidget(eventEmitter) {
|
|
|
2513
4290
|
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/forEachArray.js
|
|
2514
4291
|
var forEachArray = __webpack_require__(893);
|
|
2515
4292
|
var forEachArray_default = /*#__PURE__*/__webpack_require__.n(forEachArray);
|
|
2516
|
-
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/toArray.js
|
|
2517
|
-
var collection_toArray = __webpack_require__(990);
|
|
2518
|
-
var toArray_default = /*#__PURE__*/__webpack_require__.n(collection_toArray);
|
|
2519
4293
|
;// CONCATENATED MODULE: ./src/helper/image.ts
|
|
2520
4294
|
|
|
2521
4295
|
function addDefaultImageBlobHook(eventEmitter) {
|
|
@@ -2677,6 +4451,7 @@ var Widget = /** @class */ (function (_super) {
|
|
|
2677
4451
|
|
|
2678
4452
|
var EditorBase = /** @class */ (function () {
|
|
2679
4453
|
function EditorBase(eventEmitter) {
|
|
4454
|
+
this.timer = null;
|
|
2680
4455
|
this.el = document.createElement('div');
|
|
2681
4456
|
this.el.className = 'toastui-editor';
|
|
2682
4457
|
this.eventEmitter = eventEmitter;
|
|
@@ -2701,10 +4476,9 @@ var EditorBase = /** @class */ (function () {
|
|
|
2701
4476
|
};
|
|
2702
4477
|
Object.defineProperty(EditorBase.prototype, "defaultPlugins", {
|
|
2703
4478
|
get: function () {
|
|
2704
|
-
var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
|
|
2705
4479
|
var rules = this.createInputRules();
|
|
2706
4480
|
var plugins = __spreadArray(__spreadArray([], this.keymaps), [
|
|
2707
|
-
(0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(__assign({ '
|
|
4481
|
+
(0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(__assign({ 'Shift-Enter': external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap.Enter }, external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap)),
|
|
2708
4482
|
(0,external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_.history)(),
|
|
2709
4483
|
placeholder(this.placeholder),
|
|
2710
4484
|
addWidget(this.eventEmitter),
|
|
@@ -2741,6 +4515,12 @@ var EditorBase = /** @class */ (function () {
|
|
|
2741
4515
|
});
|
|
2742
4516
|
return rules.length ? (0,external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_.inputRules)({ rules: rules }) : null;
|
|
2743
4517
|
};
|
|
4518
|
+
EditorBase.prototype.clearTimer = function () {
|
|
4519
|
+
if (this.timer) {
|
|
4520
|
+
clearTimeout(this.timer);
|
|
4521
|
+
this.timer = null;
|
|
4522
|
+
}
|
|
4523
|
+
};
|
|
2744
4524
|
EditorBase.prototype.createSchema = function () {
|
|
2745
4525
|
return new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Schema({
|
|
2746
4526
|
nodes: this.specs.nodes,
|
|
@@ -2748,7 +4528,13 @@ var EditorBase = /** @class */ (function () {
|
|
|
2748
4528
|
});
|
|
2749
4529
|
};
|
|
2750
4530
|
EditorBase.prototype.createKeymaps = function (useCommandShortcut) {
|
|
2751
|
-
|
|
4531
|
+
var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
|
|
4532
|
+
var allKeymaps = this.specs.keymaps(useCommandShortcut);
|
|
4533
|
+
var historyKeymap = {
|
|
4534
|
+
'Mod-z': undo(),
|
|
4535
|
+
'Shift-Mod-z': redo(),
|
|
4536
|
+
};
|
|
4537
|
+
return useCommandShortcut ? allKeymaps.concat((0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(historyKeymap)) : allKeymaps;
|
|
2752
4538
|
};
|
|
2753
4539
|
EditorBase.prototype.createCommands = function () {
|
|
2754
4540
|
return this.specs.commands(this.view);
|
|
@@ -2759,8 +4545,9 @@ var EditorBase = /** @class */ (function () {
|
|
|
2759
4545
|
};
|
|
2760
4546
|
EditorBase.prototype.focus = function () {
|
|
2761
4547
|
var _this = this;
|
|
4548
|
+
this.clearTimer();
|
|
2762
4549
|
// prevent the error for IE11
|
|
2763
|
-
setTimeout(function () {
|
|
4550
|
+
this.timer = setTimeout(function () {
|
|
2764
4551
|
_this.view.focus();
|
|
2765
4552
|
_this.view.dispatch(_this.view.state.tr.scrollIntoView());
|
|
2766
4553
|
});
|
|
@@ -2770,20 +4557,25 @@ var EditorBase = /** @class */ (function () {
|
|
|
2770
4557
|
};
|
|
2771
4558
|
EditorBase.prototype.destroy = function () {
|
|
2772
4559
|
var _this = this;
|
|
4560
|
+
this.clearTimer();
|
|
2773
4561
|
this.view.destroy();
|
|
2774
4562
|
Object.keys(this).forEach(function (prop) {
|
|
2775
4563
|
delete _this[prop];
|
|
2776
4564
|
});
|
|
2777
4565
|
};
|
|
2778
|
-
EditorBase.prototype.moveCursorToStart = function () {
|
|
4566
|
+
EditorBase.prototype.moveCursorToStart = function (focus) {
|
|
2779
4567
|
var tr = this.view.state.tr;
|
|
2780
4568
|
this.view.dispatch(tr.setSelection(createTextSelection(tr, 1)).scrollIntoView());
|
|
2781
|
-
|
|
4569
|
+
if (focus) {
|
|
4570
|
+
this.focus();
|
|
4571
|
+
}
|
|
2782
4572
|
};
|
|
2783
|
-
EditorBase.prototype.moveCursorToEnd = function () {
|
|
4573
|
+
EditorBase.prototype.moveCursorToEnd = function (focus) {
|
|
2784
4574
|
var tr = this.view.state.tr;
|
|
2785
4575
|
this.view.dispatch(tr.setSelection(createTextSelection(tr, tr.doc.content.size - 1)).scrollIntoView());
|
|
2786
|
-
|
|
4576
|
+
if (focus) {
|
|
4577
|
+
this.focus();
|
|
4578
|
+
}
|
|
2787
4579
|
};
|
|
2788
4580
|
EditorBase.prototype.setScrollTop = function (top) {
|
|
2789
4581
|
this.view.dom.scrollTop = top;
|
|
@@ -2816,6 +4608,26 @@ var isFunction_default = /*#__PURE__*/__webpack_require__.n(isFunction);
|
|
|
2816
4608
|
|
|
2817
4609
|
|
|
2818
4610
|
|
|
4611
|
+
|
|
4612
|
+
var defaultCommandShortcuts = [
|
|
4613
|
+
'Enter',
|
|
4614
|
+
'Shift-Enter',
|
|
4615
|
+
'Mod-Enter',
|
|
4616
|
+
'Tab',
|
|
4617
|
+
'Shift-Tab',
|
|
4618
|
+
'Delete',
|
|
4619
|
+
'Backspace',
|
|
4620
|
+
'Mod-Delete',
|
|
4621
|
+
'Mod-Backspace',
|
|
4622
|
+
'ArrowUp',
|
|
4623
|
+
'ArrowDown',
|
|
4624
|
+
'ArrowLeft',
|
|
4625
|
+
'ArrowRight',
|
|
4626
|
+
'Mod-d',
|
|
4627
|
+
'Mod-D',
|
|
4628
|
+
'Alt-ArrowUp',
|
|
4629
|
+
'Alt-ArrowDown',
|
|
4630
|
+
];
|
|
2819
4631
|
function execCommand(view, command, payload) {
|
|
2820
4632
|
view.focus();
|
|
2821
4633
|
return command(payload)(view.state, view.dispatch, view);
|
|
@@ -2880,260 +4692,27 @@ var SpecManager = /** @class */ (function () {
|
|
|
2880
4692
|
}
|
|
2881
4693
|
return specCommands;
|
|
2882
4694
|
};
|
|
2883
|
-
SpecManager.prototype.keymaps = function () {
|
|
4695
|
+
SpecManager.prototype.keymaps = function (useCommandShortcut) {
|
|
2884
4696
|
var specKeymaps = this.specs.filter(function (spec) { return spec.keymaps; }).map(function (spec) { return spec.keymaps(); });
|
|
2885
|
-
return specKeymaps.map(function (keys) {
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
4697
|
+
return specKeymaps.map(function (keys) {
|
|
4698
|
+
if (!useCommandShortcut) {
|
|
4699
|
+
Object.keys(keys).forEach(function (key) {
|
|
4700
|
+
if (!common_includes(defaultCommandShortcuts, key)) {
|
|
4701
|
+
delete keys[key];
|
|
4702
|
+
}
|
|
4703
|
+
});
|
|
4704
|
+
}
|
|
4705
|
+
return (0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(keys);
|
|
2890
4706
|
});
|
|
2891
4707
|
};
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
var hasClass = __webpack_require__(714);
|
|
2901
|
-
var hasClass_default = /*#__PURE__*/__webpack_require__.n(hasClass);
|
|
2902
|
-
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/domUtil/matches.js
|
|
2903
|
-
var matches = __webpack_require__(471);
|
|
2904
|
-
var matches_default = /*#__PURE__*/__webpack_require__.n(matches);
|
|
2905
|
-
;// CONCATENATED MODULE: ./src/utils/constants.ts
|
|
2906
|
-
var TAG_NAME = '[A-Za-z][A-Za-z0-9-]*';
|
|
2907
|
-
var ATTRIBUTE_NAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
|
|
2908
|
-
var UNQUOTED_VALUE = '[^"\'=<>`\\x00-\\x20]+';
|
|
2909
|
-
var SINGLE_QUOTED_VALUE = "'[^']*'";
|
|
2910
|
-
var DOUBLE_QUOTED_VALUE = '"[^"]*"';
|
|
2911
|
-
var ATTRIBUTE_VALUE = "(?:" + UNQUOTED_VALUE + "|" + SINGLE_QUOTED_VALUE + "|" + DOUBLE_QUOTED_VALUE + ")";
|
|
2912
|
-
var ATTRIBUTE_VALUE_SPEC = "" + '(?:\\s*=\\s*' + ATTRIBUTE_VALUE + ")";
|
|
2913
|
-
var ATTRIBUTE = "" + '(?:\\s+' + ATTRIBUTE_NAME + ATTRIBUTE_VALUE_SPEC + "?)";
|
|
2914
|
-
var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE + ")*\\s*/?>";
|
|
2915
|
-
var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
|
|
2916
|
-
var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
|
|
2917
|
-
var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
|
|
2918
|
-
|
|
2919
|
-
;// CONCATENATED MODULE: ./src/utils/dom.ts
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
function isPositionInBox(style, offsetX, offsetY) {
|
|
2930
|
-
var left = parseInt(style.left, 10);
|
|
2931
|
-
var top = parseInt(style.top, 10);
|
|
2932
|
-
var width = parseInt(style.width, 10) + parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
|
|
2933
|
-
var height = parseInt(style.height, 10) + parseInt(style.paddingTop, 10) + parseInt(style.paddingBottom, 10);
|
|
2934
|
-
return offsetX >= left && offsetX <= left + width && offsetY >= top && offsetY <= top + height;
|
|
2935
|
-
}
|
|
2936
|
-
var CLS_PREFIX = 'toastui-editor-';
|
|
2937
|
-
function cls() {
|
|
2938
|
-
var names = [];
|
|
2939
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2940
|
-
names[_i] = arguments[_i];
|
|
2941
|
-
}
|
|
2942
|
-
var result = [];
|
|
2943
|
-
for (var _a = 0, names_1 = names; _a < names_1.length; _a++) {
|
|
2944
|
-
var name = names_1[_a];
|
|
2945
|
-
var className = void 0;
|
|
2946
|
-
if (Array.isArray(name)) {
|
|
2947
|
-
className = name[0] ? name[1] : null;
|
|
2948
|
-
}
|
|
2949
|
-
else {
|
|
2950
|
-
className = name;
|
|
2951
|
-
}
|
|
2952
|
-
if (className) {
|
|
2953
|
-
result.push("" + CLS_PREFIX + className);
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
|
-
return result.join(' ');
|
|
2957
|
-
}
|
|
2958
|
-
function clsWithMdPrefix() {
|
|
2959
|
-
var names = [];
|
|
2960
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2961
|
-
names[_i] = arguments[_i];
|
|
2962
|
-
}
|
|
2963
|
-
return names.map(function (className) { return CLS_PREFIX + "md-" + className; }).join(' ');
|
|
2964
|
-
}
|
|
2965
|
-
function isTextNode(node) {
|
|
2966
|
-
return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.TEXT_NODE;
|
|
2967
|
-
}
|
|
2968
|
-
function isElemNode(node) {
|
|
2969
|
-
return node && node.nodeType === Node.ELEMENT_NODE;
|
|
2970
|
-
}
|
|
2971
|
-
function findNodes(element, selector) {
|
|
2972
|
-
var nodeList = toArray_default()(element.querySelectorAll(selector));
|
|
2973
|
-
if (nodeList.length) {
|
|
2974
|
-
return nodeList;
|
|
2975
|
-
}
|
|
2976
|
-
return [];
|
|
2977
|
-
}
|
|
2978
|
-
function appendNodes(node, nodesToAppend) {
|
|
2979
|
-
nodesToAppend = isArray_default()(nodesToAppend) ? toArray_default()(nodesToAppend) : [nodesToAppend];
|
|
2980
|
-
nodesToAppend.forEach(function (nodeToAppend) {
|
|
2981
|
-
node.appendChild(nodeToAppend);
|
|
2982
|
-
});
|
|
2983
|
-
}
|
|
2984
|
-
function insertBeforeNode(insertedNode, node) {
|
|
2985
|
-
if (node.parentNode) {
|
|
2986
|
-
node.parentNode.insertBefore(insertedNode, node);
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
function removeNode(node) {
|
|
2990
|
-
if (node.parentNode) {
|
|
2991
|
-
node.parentNode.removeChild(node);
|
|
2992
|
-
}
|
|
2993
|
-
}
|
|
2994
|
-
function unwrapNode(node) {
|
|
2995
|
-
var result = [];
|
|
2996
|
-
while (node.firstChild) {
|
|
2997
|
-
result.push(node.firstChild);
|
|
2998
|
-
if (node.parentNode) {
|
|
2999
|
-
node.parentNode.insertBefore(node.firstChild, node);
|
|
3000
|
-
}
|
|
3001
|
-
}
|
|
3002
|
-
removeNode(node);
|
|
3003
|
-
return result;
|
|
3004
|
-
}
|
|
3005
|
-
function toggleClass(element, className, state) {
|
|
3006
|
-
if (isUndefined_default()(state)) {
|
|
3007
|
-
state = !hasClass_default()(element, className);
|
|
3008
|
-
}
|
|
3009
|
-
var toggleFn = state ? (addClass_default()) : (removeClass_default());
|
|
3010
|
-
toggleFn(element, className);
|
|
3011
|
-
}
|
|
3012
|
-
function createElementWith(contents, target) {
|
|
3013
|
-
var container = document.createElement('div');
|
|
3014
|
-
if (isString_default()(contents)) {
|
|
3015
|
-
container.innerHTML = contents;
|
|
3016
|
-
}
|
|
3017
|
-
else {
|
|
3018
|
-
container.appendChild(contents);
|
|
3019
|
-
}
|
|
3020
|
-
var firstChild = container.firstChild;
|
|
3021
|
-
if (target) {
|
|
3022
|
-
target.appendChild(firstChild);
|
|
3023
|
-
}
|
|
3024
|
-
return firstChild;
|
|
3025
|
-
}
|
|
3026
|
-
function getOuterWidth(el) {
|
|
3027
|
-
var computed = window.getComputedStyle(el);
|
|
3028
|
-
return (['margin-left', 'margin-right'].reduce(function (acc, type) { return acc + parseInt(computed.getPropertyValue(type), 10); }, 0) + el.offsetWidth);
|
|
3029
|
-
}
|
|
3030
|
-
function closest(node, found) {
|
|
3031
|
-
var condition;
|
|
3032
|
-
if (isString_default()(found)) {
|
|
3033
|
-
condition = function (target) { return matches_default()(target, found); };
|
|
3034
|
-
}
|
|
3035
|
-
else {
|
|
3036
|
-
condition = function (target) { return target === found; };
|
|
3037
|
-
}
|
|
3038
|
-
while (node && node !== document) {
|
|
3039
|
-
if (isElemNode(node) && condition(node)) {
|
|
3040
|
-
return node;
|
|
3041
|
-
}
|
|
3042
|
-
node = node.parentNode;
|
|
3043
|
-
}
|
|
3044
|
-
return null;
|
|
3045
|
-
}
|
|
3046
|
-
function getTotalOffset(el, root) {
|
|
3047
|
-
var offsetTop = 0;
|
|
3048
|
-
var offsetLeft = 0;
|
|
3049
|
-
while (el && el !== root) {
|
|
3050
|
-
var top = el.offsetTop, left = el.offsetLeft, offsetParent = el.offsetParent;
|
|
3051
|
-
offsetTop += top;
|
|
3052
|
-
offsetLeft += left;
|
|
3053
|
-
if (offsetParent === root.offsetParent) {
|
|
3054
|
-
break;
|
|
3055
|
-
}
|
|
3056
|
-
el = el.offsetParent;
|
|
3057
|
-
}
|
|
3058
|
-
return { offsetTop: offsetTop, offsetLeft: offsetLeft };
|
|
3059
|
-
}
|
|
3060
|
-
function finalizeHtml(html, needHtmlText) {
|
|
3061
|
-
var result;
|
|
3062
|
-
if (needHtmlText) {
|
|
3063
|
-
result = html.innerHTML;
|
|
3064
|
-
}
|
|
3065
|
-
else {
|
|
3066
|
-
var frag = document.createDocumentFragment();
|
|
3067
|
-
var childNodes = toArray_default()(html.childNodes);
|
|
3068
|
-
var length = childNodes.length;
|
|
3069
|
-
for (var i = 0; i < length; i += 1) {
|
|
3070
|
-
frag.appendChild(childNodes[i]);
|
|
3071
|
-
}
|
|
3072
|
-
result = frag;
|
|
3073
|
-
}
|
|
3074
|
-
return result;
|
|
3075
|
-
}
|
|
3076
|
-
function empty(node) {
|
|
3077
|
-
while (node.firstChild) {
|
|
3078
|
-
node.removeChild(node.firstChild);
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
function appendNode(node, appended) {
|
|
3082
|
-
if (isString(appended)) {
|
|
3083
|
-
node.insertAdjacentHTML('beforeend', appended);
|
|
3084
|
-
}
|
|
3085
|
-
else {
|
|
3086
|
-
var nodes = appended.length
|
|
3087
|
-
? toArray(appended)
|
|
3088
|
-
: [appended];
|
|
3089
|
-
for (var i = 0, len = nodes.length; i < len; i += 1) {
|
|
3090
|
-
node.appendChild(nodes[i]);
|
|
3091
|
-
}
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
function prependNode(node, appended) {
|
|
3095
|
-
if (isString(appended)) {
|
|
3096
|
-
node.insertAdjacentHTML('afterbegin', appended);
|
|
3097
|
-
}
|
|
3098
|
-
else {
|
|
3099
|
-
var nodes = appended.length
|
|
3100
|
-
? toArray(appended)
|
|
3101
|
-
: [appended];
|
|
3102
|
-
for (var i = nodes.length - 1, len = 0; i >= len; i -= 1) {
|
|
3103
|
-
node.insertBefore(nodes[i], node.firstChild);
|
|
3104
|
-
}
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
function setAttributes(attributes, element) {
|
|
3108
|
-
Object.keys(attributes).forEach(function (attrName) {
|
|
3109
|
-
if (attributes[attrName]) {
|
|
3110
|
-
element.setAttribute(attrName, attributes[attrName]);
|
|
3111
|
-
}
|
|
3112
|
-
else {
|
|
3113
|
-
element.removeAttribute(attrName);
|
|
3114
|
-
}
|
|
3115
|
-
});
|
|
3116
|
-
}
|
|
3117
|
-
function replaceBRWithEmptyBlock(html) {
|
|
3118
|
-
var reBr = /<br\s*\/*>/i;
|
|
3119
|
-
var reHTMLTag = new RegExp(HTML_TAG, 'ig');
|
|
3120
|
-
var htmlTagMatched = html.match(reHTMLTag);
|
|
3121
|
-
htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
|
|
3122
|
-
if (reBr.test(htmlTag)) {
|
|
3123
|
-
var alternativeTag = '';
|
|
3124
|
-
if (index) {
|
|
3125
|
-
var prevTag = htmlTagMatched[index - 1];
|
|
3126
|
-
var openTagMatched = prevTag.match(OPEN_TAG);
|
|
3127
|
-
if (openTagMatched) {
|
|
3128
|
-
var tagName = openTagMatched[1];
|
|
3129
|
-
alternativeTag = "</" + tagName + "><" + tagName + ">";
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
html = html.replace(reBr, alternativeTag);
|
|
3133
|
-
}
|
|
3134
|
-
});
|
|
3135
|
-
return html;
|
|
3136
|
-
}
|
|
4708
|
+
SpecManager.prototype.setContext = function (context) {
|
|
4709
|
+
this.specs.forEach(function (spec) {
|
|
4710
|
+
spec.setContext(context);
|
|
4711
|
+
});
|
|
4712
|
+
};
|
|
4713
|
+
return SpecManager;
|
|
4714
|
+
}());
|
|
4715
|
+
/* harmony default export */ var specManager = (SpecManager);
|
|
3137
4716
|
|
|
3138
4717
|
;// CONCATENATED MODULE: ./src/markdown/helper/pos.ts
|
|
3139
4718
|
|
|
@@ -3610,34 +5189,61 @@ function getMarkForAdding(node, toastMark) {
|
|
|
3610
5189
|
;// CONCATENATED MODULE: ./src/markdown/plugins/previewHighlight.ts
|
|
3611
5190
|
|
|
3612
5191
|
|
|
5192
|
+
|
|
5193
|
+
var defaultToolbarStateKeys = [
|
|
5194
|
+
'taskList',
|
|
5195
|
+
'orderedList',
|
|
5196
|
+
'bulletList',
|
|
5197
|
+
'table',
|
|
5198
|
+
'strong',
|
|
5199
|
+
'emph',
|
|
5200
|
+
'strike',
|
|
5201
|
+
'heading',
|
|
5202
|
+
'thematicBreak',
|
|
5203
|
+
'blockQuote',
|
|
5204
|
+
'code',
|
|
5205
|
+
'codeBlock',
|
|
5206
|
+
'indent',
|
|
5207
|
+
'outdent',
|
|
5208
|
+
];
|
|
3613
5209
|
function getToolbarStateType(mdNode) {
|
|
5210
|
+
var type = mdNode.type;
|
|
3614
5211
|
if (isListNode(mdNode)) {
|
|
3615
5212
|
if (mdNode.listData.task) {
|
|
3616
5213
|
return 'taskList';
|
|
3617
5214
|
}
|
|
3618
5215
|
return mdNode.listData.type === 'ordered' ? 'orderedList' : 'bulletList';
|
|
3619
5216
|
}
|
|
3620
|
-
if (
|
|
5217
|
+
if (type.indexOf('table') !== -1) {
|
|
3621
5218
|
return 'table';
|
|
3622
5219
|
}
|
|
3623
|
-
|
|
5220
|
+
if (!common_includes(defaultToolbarStateKeys, type)) {
|
|
5221
|
+
return null;
|
|
5222
|
+
}
|
|
5223
|
+
return type;
|
|
3624
5224
|
}
|
|
3625
5225
|
function getToolbarState(targetNode) {
|
|
3626
|
-
var toolbarState = {
|
|
5226
|
+
var toolbarState = {
|
|
5227
|
+
indent: { active: false, disabled: true },
|
|
5228
|
+
outdent: { active: false, disabled: true },
|
|
5229
|
+
};
|
|
3627
5230
|
var listEnabled = true;
|
|
3628
5231
|
traverseParentNodes(targetNode, function (mdNode) {
|
|
3629
5232
|
var type = getToolbarStateType(mdNode);
|
|
3630
|
-
if (type
|
|
5233
|
+
if (!type) {
|
|
3631
5234
|
return;
|
|
3632
5235
|
}
|
|
3633
5236
|
if (type === 'bulletList' || type === 'orderedList') {
|
|
5237
|
+
// to apply the nearlist list state in the nested list
|
|
3634
5238
|
if (listEnabled) {
|
|
3635
|
-
toolbarState[type] = true;
|
|
5239
|
+
toolbarState[type] = { active: true };
|
|
5240
|
+
toolbarState.indent.disabled = false;
|
|
5241
|
+
toolbarState.outdent.disabled = false;
|
|
3636
5242
|
listEnabled = false;
|
|
3637
5243
|
}
|
|
3638
5244
|
}
|
|
3639
5245
|
else {
|
|
3640
|
-
toolbarState[type] = true;
|
|
5246
|
+
toolbarState[type] = { active: true };
|
|
3641
5247
|
}
|
|
3642
5248
|
});
|
|
3643
5249
|
return toolbarState;
|
|
@@ -4678,9 +6284,11 @@ var ThematicBreak = /** @class */ (function (_super) {
|
|
|
4678
6284
|
|
|
4679
6285
|
|
|
4680
6286
|
|
|
4681
|
-
function cannotBeListNode(_a) {
|
|
4682
|
-
var type = _a.type;
|
|
4683
|
-
|
|
6287
|
+
function cannotBeListNode(_a, line) {
|
|
6288
|
+
var type = _a.type, sourcepos = _a.sourcepos;
|
|
6289
|
+
// eslint-disable-next-line prefer-destructuring
|
|
6290
|
+
var startLine = sourcepos[0][0];
|
|
6291
|
+
return line <= startLine && (type === 'codeBlock' || type === 'heading' || type.match('table'));
|
|
4684
6292
|
}
|
|
4685
6293
|
var ListItem = /** @class */ (function (_super) {
|
|
4686
6294
|
__extends(ListItem, _super);
|
|
@@ -4783,7 +6391,7 @@ var ListItem = /** @class */ (function (_super) {
|
|
|
4783
6391
|
var skipLines = [];
|
|
4784
6392
|
for (var line = startLine; line <= endLine; line += 1) {
|
|
4785
6393
|
var mdNode = toastMark.findFirstNodeAtLine(line);
|
|
4786
|
-
if (mdNode && cannotBeListNode(mdNode)) {
|
|
6394
|
+
if (mdNode && cannotBeListNode(mdNode, line)) {
|
|
4787
6395
|
break;
|
|
4788
6396
|
}
|
|
4789
6397
|
// to skip unnecessary processing
|
|
@@ -5103,57 +6711,6 @@ var Code = /** @class */ (function (_super) {
|
|
|
5103
6711
|
}(mark));
|
|
5104
6712
|
|
|
5105
6713
|
|
|
5106
|
-
;// CONCATENATED MODULE: ./src/utils/encoder.ts
|
|
5107
|
-
var encoderList = [
|
|
5108
|
-
{
|
|
5109
|
-
regExp: /\(/g,
|
|
5110
|
-
encoded: '%28',
|
|
5111
|
-
escaped: '\\(',
|
|
5112
|
-
},
|
|
5113
|
-
{
|
|
5114
|
-
regExp: /\)/g,
|
|
5115
|
-
encoded: '%29',
|
|
5116
|
-
escaped: '\\)',
|
|
5117
|
-
},
|
|
5118
|
-
{
|
|
5119
|
-
regExp: /\[/g,
|
|
5120
|
-
encoded: '%5B',
|
|
5121
|
-
escaped: '\\[',
|
|
5122
|
-
},
|
|
5123
|
-
{
|
|
5124
|
-
regExp: /\]/g,
|
|
5125
|
-
encoded: '%5D',
|
|
5126
|
-
escaped: '\\]',
|
|
5127
|
-
},
|
|
5128
|
-
{
|
|
5129
|
-
regExp: /</g,
|
|
5130
|
-
encoded: '%3C',
|
|
5131
|
-
escaped: '\\<',
|
|
5132
|
-
},
|
|
5133
|
-
{
|
|
5134
|
-
regExp: />/g,
|
|
5135
|
-
encoded: '%3E',
|
|
5136
|
-
escaped: '\\>',
|
|
5137
|
-
},
|
|
5138
|
-
{
|
|
5139
|
-
regExp: / /g,
|
|
5140
|
-
encoded: '%20',
|
|
5141
|
-
escaped: ' ',
|
|
5142
|
-
},
|
|
5143
|
-
];
|
|
5144
|
-
function escapeMarkdownText(text) {
|
|
5145
|
-
return encoderList.reduce(function (result, _a) {
|
|
5146
|
-
var regExp = _a.regExp, escaped = _a.escaped;
|
|
5147
|
-
return result.replace(regExp, escaped);
|
|
5148
|
-
}, text);
|
|
5149
|
-
}
|
|
5150
|
-
function encodeMarkdownText(text) {
|
|
5151
|
-
return encoderList.reduce(function (result, _a) {
|
|
5152
|
-
var regExp = _a.regExp, encoded = _a.encoded;
|
|
5153
|
-
return result.replace(regExp, encoded);
|
|
5154
|
-
}, text);
|
|
5155
|
-
}
|
|
5156
|
-
|
|
5157
6714
|
;// CONCATENATED MODULE: ./src/markdown/marks/link.ts
|
|
5158
6715
|
|
|
5159
6716
|
|
|
@@ -5210,8 +6767,7 @@ var Link = /** @class */ (function (_super) {
|
|
|
5210
6767
|
url = imageUrl;
|
|
5211
6768
|
syntax = '!';
|
|
5212
6769
|
}
|
|
5213
|
-
text =
|
|
5214
|
-
url = encodeMarkdownText(url);
|
|
6770
|
+
text = escapeTextForLink(text);
|
|
5215
6771
|
syntax += "[" + text + "](" + url + ")";
|
|
5216
6772
|
dispatch(tr.replaceWith(from, to, createTextNode(schema, syntax)));
|
|
5217
6773
|
return true;
|
|
@@ -5397,6 +6953,9 @@ var Html = /** @class */ (function (_super) {
|
|
|
5397
6953
|
|
|
5398
6954
|
|
|
5399
6955
|
|
|
6956
|
+
|
|
6957
|
+
|
|
6958
|
+
var customBlockSyntax = '$$';
|
|
5400
6959
|
var CustomBlock = /** @class */ (function (_super) {
|
|
5401
6960
|
__extends(CustomBlock, _super);
|
|
5402
6961
|
function CustomBlock() {
|
|
@@ -5420,6 +6979,22 @@ var CustomBlock = /** @class */ (function (_super) {
|
|
|
5420
6979
|
enumerable: false,
|
|
5421
6980
|
configurable: true
|
|
5422
6981
|
});
|
|
6982
|
+
CustomBlock.prototype.commands = function () {
|
|
6983
|
+
return function (payload) { return function (state, dispatch) {
|
|
6984
|
+
var selection = state.selection, schema = state.schema, tr = state.tr;
|
|
6985
|
+
var _a = getRangeInfo(selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset;
|
|
6986
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.info)) {
|
|
6987
|
+
return false;
|
|
6988
|
+
}
|
|
6989
|
+
var customBlock = "" + customBlockSyntax + payload.info;
|
|
6990
|
+
var startNode = createTextNode(schema, customBlock);
|
|
6991
|
+
var endNode = createTextNode(schema, customBlockSyntax);
|
|
6992
|
+
tr.insert(startFromOffset, startNode).split(startFromOffset + customBlock.length);
|
|
6993
|
+
tr.split(tr.mapping.map(endToOffset)).insert(tr.mapping.map(endToOffset), endNode);
|
|
6994
|
+
dispatch(tr.setSelection(createTextSelection(tr, tr.mapping.map(endToOffset) - (customBlockSyntax.length + 2))));
|
|
6995
|
+
return true;
|
|
6996
|
+
}; };
|
|
6997
|
+
};
|
|
5423
6998
|
return CustomBlock;
|
|
5424
6999
|
}(mark));
|
|
5425
7000
|
|
|
@@ -5504,6 +7079,7 @@ function smartTask(_a) {
|
|
|
5504
7079
|
|
|
5505
7080
|
|
|
5506
7081
|
|
|
7082
|
+
|
|
5507
7083
|
|
|
5508
7084
|
|
|
5509
7085
|
var EVENT_TYPE = 'cut';
|
|
@@ -5525,15 +7101,20 @@ var MdEditor = /** @class */ (function (_super) {
|
|
|
5525
7101
|
_this.commands = _this.createCommands();
|
|
5526
7102
|
_this.specs.setContext(__assign(__assign({}, _this.context), { view: _this.view }));
|
|
5527
7103
|
_this.createClipboard();
|
|
5528
|
-
|
|
7104
|
+
// To prevent unnecessary focus setting during initial rendering
|
|
7105
|
+
_this.eventEmitter.listen('changePreviewTabWrite', function (isMarkdownTabMounted) {
|
|
7106
|
+
return _this.toggleActive(true, isMarkdownTabMounted);
|
|
7107
|
+
});
|
|
5529
7108
|
_this.eventEmitter.listen('changePreviewTabPreview', function () { return _this.toggleActive(false); });
|
|
5530
7109
|
_this.initEvent();
|
|
5531
7110
|
return _this;
|
|
5532
7111
|
}
|
|
5533
|
-
MdEditor.prototype.toggleActive = function (active) {
|
|
7112
|
+
MdEditor.prototype.toggleActive = function (active, isMarkdownTabMounted) {
|
|
5534
7113
|
toggleClass(this.el, 'active', active);
|
|
5535
7114
|
if (active) {
|
|
5536
|
-
|
|
7115
|
+
if (!isMarkdownTabMounted) {
|
|
7116
|
+
this.focus();
|
|
7117
|
+
}
|
|
5537
7118
|
}
|
|
5538
7119
|
else {
|
|
5539
7120
|
this.blur();
|
|
@@ -5547,10 +7128,14 @@ var MdEditor = /** @class */ (function (_super) {
|
|
|
5547
7128
|
var clipboardData = ev.clipboardData || window.clipboardData;
|
|
5548
7129
|
var items = clipboardData && clipboardData.items;
|
|
5549
7130
|
if (items) {
|
|
5550
|
-
var
|
|
5551
|
-
if
|
|
5552
|
-
|
|
5553
|
-
|
|
7131
|
+
var containRtfItem = toArray_default()(items).some(function (item) { return item.kind === 'string' && item.type === 'text/rtf'; });
|
|
7132
|
+
// if it contains rtf, it's most likely copy paste from office -> no image
|
|
7133
|
+
if (!containRtfItem) {
|
|
7134
|
+
var imageBlob = pasteImageOnly(items);
|
|
7135
|
+
if (imageBlob) {
|
|
7136
|
+
ev.preventDefault();
|
|
7137
|
+
emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type);
|
|
7138
|
+
}
|
|
5554
7139
|
}
|
|
5555
7140
|
}
|
|
5556
7141
|
});
|
|
@@ -5750,7 +7335,7 @@ var MdEditor = /** @class */ (function (_super) {
|
|
|
5750
7335
|
});
|
|
5751
7336
|
this.view.dispatch(tr.replaceWith(0, doc.content.size, nodes));
|
|
5752
7337
|
if (cursorToEnd) {
|
|
5753
|
-
this.moveCursorToEnd();
|
|
7338
|
+
this.moveCursorToEnd(true);
|
|
5754
7339
|
}
|
|
5755
7340
|
};
|
|
5756
7341
|
MdEditor.prototype.addWidget = function (node, style, mdPos) {
|
|
@@ -5837,10 +7422,16 @@ var esm_assign = function () {
|
|
|
5837
7422
|
};
|
|
5838
7423
|
return esm_assign.apply(this, arguments);
|
|
5839
7424
|
};
|
|
5840
|
-
function esm_spreadArray(to, from) {
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
7425
|
+
function esm_spreadArray(to, from, pack) {
|
|
7426
|
+
if (pack || arguments.length === 2)
|
|
7427
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
7428
|
+
if (ar || !(i in from)) {
|
|
7429
|
+
if (!ar)
|
|
7430
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
7431
|
+
ar[i] = from[i];
|
|
7432
|
+
}
|
|
7433
|
+
}
|
|
7434
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
5844
7435
|
}
|
|
5845
7436
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof self !== 'undefined' ? self : {};
|
|
5846
7437
|
var encodeCache = {};
|
|
@@ -10707,8 +12298,8 @@ var C_BACKSLASH$1 = 92;
|
|
|
10707
12298
|
var reBackslashOrAmp = /[\\&]/;
|
|
10708
12299
|
var ESCAPABLE = '[!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]';
|
|
10709
12300
|
var reEntityOrEscapedChar = new RegExp("\\\\" + ESCAPABLE + "|" + ENTITY, 'gi');
|
|
10710
|
-
var
|
|
10711
|
-
var
|
|
12301
|
+
var esm_XMLSPECIAL = '[&<>"]';
|
|
12302
|
+
var esm_reXmlSpecial = new RegExp(esm_XMLSPECIAL, 'g');
|
|
10712
12303
|
var unescapeChar = function (s) {
|
|
10713
12304
|
if (s.charCodeAt(0) === C_BACKSLASH$1) {
|
|
10714
12305
|
return s.charAt(1);
|
|
@@ -10730,7 +12321,7 @@ function normalizeURI(uri) {
|
|
|
10730
12321
|
return uri;
|
|
10731
12322
|
}
|
|
10732
12323
|
}
|
|
10733
|
-
function
|
|
12324
|
+
function esm_replaceUnsafeChar(s) {
|
|
10734
12325
|
switch (s) {
|
|
10735
12326
|
case '&':
|
|
10736
12327
|
return '&';
|
|
@@ -10744,9 +12335,9 @@ function replaceUnsafeChar(s) {
|
|
|
10744
12335
|
return s;
|
|
10745
12336
|
}
|
|
10746
12337
|
}
|
|
10747
|
-
function
|
|
10748
|
-
if (
|
|
10749
|
-
return s.replace(
|
|
12338
|
+
function esm_escapeXml(s) {
|
|
12339
|
+
if (esm_reXmlSpecial.test(s)) {
|
|
12340
|
+
return s.replace(esm_reXmlSpecial, esm_replaceUnsafeChar);
|
|
10750
12341
|
}
|
|
10751
12342
|
return s;
|
|
10752
12343
|
}
|
|
@@ -11791,7 +13382,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
11791
13382
|
var literal = textNode.literal || '';
|
|
11792
13383
|
var info = literal.split(/\s/)[0];
|
|
11793
13384
|
newNode.info = info;
|
|
11794
|
-
if (literal.length
|
|
13385
|
+
if (literal.length <= info.length) {
|
|
11795
13386
|
textNode.unlink();
|
|
11796
13387
|
}
|
|
11797
13388
|
else {
|
|
@@ -14352,7 +15943,7 @@ var baseConvertors = {
|
|
|
14352
15943
|
var infoWords = infoStr ? infoStr.split(/\s+/) : [];
|
|
14353
15944
|
var codeClassNames = [];
|
|
14354
15945
|
if (infoWords.length > 0 && infoWords[0].length > 0) {
|
|
14355
|
-
codeClassNames.push("language-" +
|
|
15946
|
+
codeClassNames.push("language-" + esm_escapeXml(infoWords[0]));
|
|
14356
15947
|
}
|
|
14357
15948
|
return [
|
|
14358
15949
|
{ type: 'openTag', tagName: 'pre', outerNewLine: true },
|
|
@@ -14369,7 +15960,7 @@ var baseConvertors = {
|
|
|
14369
15960
|
return {
|
|
14370
15961
|
type: 'openTag',
|
|
14371
15962
|
tagName: 'a',
|
|
14372
|
-
attributes: esm_assign({ href:
|
|
15963
|
+
attributes: esm_assign({ href: esm_escapeXml(destination) }, (title && { title: esm_escapeXml(title) })),
|
|
14373
15964
|
};
|
|
14374
15965
|
}
|
|
14375
15966
|
return { type: 'closeTag', tagName: 'a' };
|
|
@@ -14382,7 +15973,7 @@ var baseConvertors = {
|
|
|
14382
15973
|
type: 'openTag',
|
|
14383
15974
|
tagName: 'img',
|
|
14384
15975
|
selfClose: true,
|
|
14385
|
-
attributes: esm_assign({ src:
|
|
15976
|
+
attributes: esm_assign({ src: esm_escapeXml(destination), alt: getChildrenText(node) }, (title && { title: esm_escapeXml(title) })),
|
|
14386
15977
|
};
|
|
14387
15978
|
},
|
|
14388
15979
|
customBlock: function (node, context, convertors) {
|
|
@@ -14393,7 +15984,7 @@ var baseConvertors = {
|
|
|
14393
15984
|
return customConvertor(node, context);
|
|
14394
15985
|
}
|
|
14395
15986
|
catch (e) {
|
|
14396
|
-
console.warn(e);
|
|
15987
|
+
console.warn("[@toast-ui/editor] - The error occurred when " + info + " block node was parsed in markdown renderer: " + e);
|
|
14397
15988
|
}
|
|
14398
15989
|
}
|
|
14399
15990
|
return [
|
|
@@ -14416,15 +16007,27 @@ var baseConvertors = {
|
|
|
14416
16007
|
];
|
|
14417
16008
|
},
|
|
14418
16009
|
customInline: function (node, context, convertors) {
|
|
14419
|
-
var info =
|
|
14420
|
-
var
|
|
16010
|
+
var _a = node, info = _a.info, firstChild = _a.firstChild;
|
|
16011
|
+
var nomalizedInfo = info.trim().toLowerCase();
|
|
16012
|
+
var customConvertor = convertors[nomalizedInfo];
|
|
16013
|
+
var entering = context.entering;
|
|
14421
16014
|
if (customConvertor) {
|
|
14422
|
-
|
|
16015
|
+
try {
|
|
16016
|
+
return customConvertor(node, context);
|
|
16017
|
+
}
|
|
16018
|
+
catch (e) {
|
|
16019
|
+
console.warn("[@toast-ui/editor] - The error occurred when " + nomalizedInfo + " inline node was parsed in markdown renderer: " + e);
|
|
16020
|
+
}
|
|
14423
16021
|
}
|
|
14424
|
-
return
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
16022
|
+
return entering
|
|
16023
|
+
? [
|
|
16024
|
+
{ type: 'openTag', tagName: 'span' },
|
|
16025
|
+
{ type: 'text', content: "$$" + info + (firstChild ? ' ' : '') },
|
|
16026
|
+
]
|
|
16027
|
+
: [
|
|
16028
|
+
{ type: 'text', content: '$$' },
|
|
16029
|
+
{ type: 'closeTag', tagName: 'span' },
|
|
16030
|
+
];
|
|
14428
16031
|
},
|
|
14429
16032
|
};
|
|
14430
16033
|
var gfmConvertors = {
|
|
@@ -14587,8 +16190,8 @@ var Renderer = /** @class */ (function () {
|
|
|
14587
16190
|
? nodeType.toLowerCase()
|
|
14588
16191
|
: nodeType;
|
|
14589
16192
|
if (orgConvertor) {
|
|
14590
|
-
convertors[convertorType] = function (node, context) {
|
|
14591
|
-
context.origin = function () { return orgConvertor(node, context); };
|
|
16193
|
+
convertors[convertorType] = function (node, context, convertors) {
|
|
16194
|
+
context.origin = function () { return orgConvertor(node, context, convertors); };
|
|
14592
16195
|
return convertor(node, context);
|
|
14593
16196
|
};
|
|
14594
16197
|
}
|
|
@@ -14706,7 +16309,7 @@ var Renderer = /** @class */ (function () {
|
|
|
14706
16309
|
}
|
|
14707
16310
|
};
|
|
14708
16311
|
Renderer.prototype.renderTextNode = function (node) {
|
|
14709
|
-
this.buffer.push(
|
|
16312
|
+
this.buffer.push(esm_escapeXml(node.content));
|
|
14710
16313
|
};
|
|
14711
16314
|
Renderer.prototype.renderRawHtmlNode = function (node) {
|
|
14712
16315
|
this.addOuterNewLine(node);
|
|
@@ -14734,112 +16337,35 @@ var Renderer = /** @class */ (function () {
|
|
|
14734
16337
|
}());
|
|
14735
16338
|
|
|
14736
16339
|
|
|
16340
|
+
// EXTERNAL MODULE: ../../node_modules/dompurify/dist/purify.js
|
|
16341
|
+
var purify = __webpack_require__(368);
|
|
16342
|
+
var purify_default = /*#__PURE__*/__webpack_require__.n(purify);
|
|
14737
16343
|
;// CONCATENATED MODULE: ./src/sanitizer/htmlSanitizer.ts
|
|
14738
16344
|
|
|
14739
16345
|
|
|
14740
16346
|
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
|
|
14744
|
-
var reHTMLAttr = new RegExp('^(abbr|align|alt|axis|bgcolor|border|cellpadding|cellspacing|class|clear|' +
|
|
14745
|
-
'color|cols|compact|coords|dir|face|headers|height|hreflang|hspace|' +
|
|
14746
|
-
'ismap|lang|language|nohref|nowrap|rel|rev|rows|rules|' +
|
|
14747
|
-
'scope|scrolling|shape|size|span|start|summary|tabindex|target|title|type|' +
|
|
14748
|
-
'valign|value|vspace|width|checked|mathvariant|encoding|id|name|' +
|
|
14749
|
-
'background|cite|href|longdesc|src|usemap|xlink:href|data-+|checked|style)', 'g');
|
|
14750
|
-
var reSvgAttr = new RegExp('^(accent-height|accumulate|additive|alphabetic|arabic-form|ascent|' +
|
|
14751
|
-
'baseProfile|bbox|begin|by|calcMode|cap-height|class|color|color-rendering|content|' +
|
|
14752
|
-
'cx|cy|d|dx|dy|descent|display|dur|end|fill|fill-rule|font-family|font-size|font-stretch|' +
|
|
14753
|
-
'font-style|font-variant|font-weight|from|fx|fy|g1|g2|glyph-name|gradientUnits|hanging|' +
|
|
14754
|
-
'height|horiz-adv-x|horiz-origin-x|ideographic|k|keyPoints|keySplines|keyTimes|lang|' +
|
|
14755
|
-
'marker-end|marker-mid|marker-start|markerHeight|markerUnits|markerWidth|mathematical|' +
|
|
14756
|
-
'max|min|offset|opacity|orient|origin|overline-position|overline-thickness|panose-1|' +
|
|
14757
|
-
'path|pathLength|points|preserveAspectRatio|r|refX|refY|repeatCount|repeatDur|' +
|
|
14758
|
-
'requiredExtensions|requiredFeatures|restart|rotate|rx|ry|slope|stemh|stemv|stop-color|' +
|
|
14759
|
-
'stop-opacity|strikethrough-position|strikethrough-thickness|stroke|stroke-dasharray|' +
|
|
14760
|
-
'stroke-dashoffset|stroke-linecap|stroke-linejoin|stroke-miterlimit|stroke-opacity|' +
|
|
14761
|
-
'stroke-width|systemLanguage|target|text-anchor|to|transform|type|u1|u2|underline-position|' +
|
|
14762
|
-
'underline-thickness|unicode|unicode-range|units-per-em|values|version|viewBox|visibility|' +
|
|
14763
|
-
'width|widths|x|x-height|x1|x2|xlink:actuate|xlink:arcrole|xlink:role|xlink:show|xlink:title|' +
|
|
14764
|
-
'xlink:type|xml:base|xml:lang|xml:space|xmlns|xmlns:xlink|y|y1|y2|zoomAndPan)', 'g');
|
|
14765
|
-
var reXSSAttr = /href|src|background/i;
|
|
14766
|
-
var reXSSAttrValue = /((java|vb|live)script|x):/i;
|
|
14767
|
-
var reOnEvent = /^on\S+/i;
|
|
14768
|
-
var reXSSOnload = new RegExp("(<" + TAG_NAME + "[^>]*)(onload\\s*=)", 'ig');
|
|
14769
|
-
var reComment = /<!--[\s\S]*?-->/g;
|
|
14770
|
-
var reWhitespace = /[ \t\r\n]/g;
|
|
14771
|
-
var DEFAULT_TAG_BLACK_LIST = [
|
|
14772
|
-
'script',
|
|
14773
|
-
'iframe',
|
|
14774
|
-
'textarea',
|
|
14775
|
-
'form',
|
|
14776
|
-
'button',
|
|
14777
|
-
'select',
|
|
14778
|
-
'input',
|
|
14779
|
-
'meta',
|
|
14780
|
-
'style',
|
|
14781
|
-
'link',
|
|
14782
|
-
'title',
|
|
14783
|
-
'embed',
|
|
14784
|
-
'object',
|
|
14785
|
-
'details',
|
|
14786
|
-
'summary',
|
|
14787
|
-
'base',
|
|
14788
|
-
];
|
|
14789
|
-
var CAN_BE_TAG_WHITE_LIST = ['iframe', 'embed', 'details', 'summary'];
|
|
14790
|
-
var tagBlacklist = __spreadArray([], DEFAULT_TAG_BLACK_LIST);
|
|
16347
|
+
var CAN_BE_WHITE_TAG_LIST = ['iframe', 'embed'];
|
|
16348
|
+
var whiteTagList = [];
|
|
14791
16349
|
function registerTagWhitelistIfPossible(tagName) {
|
|
14792
|
-
if (common_includes(
|
|
14793
|
-
|
|
14794
|
-
|
|
14795
|
-
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
|
|
14810
|
-
|
|
14811
|
-
removedTags.forEach(function (node) {
|
|
14812
|
-
removeNode(node);
|
|
14813
|
-
});
|
|
14814
|
-
}
|
|
14815
|
-
function isXSSAttribute(attrName, attrValue) {
|
|
14816
|
-
return attrName.match(reXSSAttr) && attrValue.replace(reWhitespace, '').match(reXSSAttrValue);
|
|
14817
|
-
}
|
|
14818
|
-
function removeBlacklistAttributes(node, blacklistAttrs) {
|
|
14819
|
-
blacklistAttrs.forEach(function (_a) {
|
|
14820
|
-
var name = _a.name;
|
|
14821
|
-
if (reOnEvent.test(name)) {
|
|
14822
|
-
node[name] = null;
|
|
14823
|
-
}
|
|
14824
|
-
node.removeAttribute(name);
|
|
14825
|
-
});
|
|
14826
|
-
}
|
|
14827
|
-
function leaveOnlyWhitelistAttribute(html) {
|
|
14828
|
-
findNodes(html, '*').forEach(function (node) {
|
|
14829
|
-
var attributes = node.attributes;
|
|
14830
|
-
var blacklist = toArray_default()(attributes).filter(function (attr) {
|
|
14831
|
-
var name = attr.name, value = attr.value;
|
|
14832
|
-
var htmlAttr = name.match(reHTMLAttr);
|
|
14833
|
-
var svgAttr = name.match(reSvgAttr);
|
|
14834
|
-
var xssAttr = htmlAttr && isXSSAttribute(name, value);
|
|
14835
|
-
return (!htmlAttr && !svgAttr) || xssAttr;
|
|
14836
|
-
});
|
|
14837
|
-
removeBlacklistAttributes(node, blacklist);
|
|
14838
|
-
});
|
|
14839
|
-
}
|
|
14840
|
-
function sanitizeXSSAttributeValue(attrValue) {
|
|
14841
|
-
attrValue = attrValue.replace(reComment, '');
|
|
14842
|
-
return reXSSAttrValue.test(attrValue) ? '' : attrValue;
|
|
16350
|
+
if (common_includes(CAN_BE_WHITE_TAG_LIST, tagName)) {
|
|
16351
|
+
whiteTagList.push(tagName.toLowerCase());
|
|
16352
|
+
}
|
|
16353
|
+
}
|
|
16354
|
+
function sanitizeHTML(html, options) {
|
|
16355
|
+
return purify_default().sanitize(html, __assign({ ADD_TAGS: whiteTagList, ADD_ATTR: ['rel', 'target', 'hreflang', 'type'], FORBID_TAGS: [
|
|
16356
|
+
'input',
|
|
16357
|
+
'script',
|
|
16358
|
+
'textarea',
|
|
16359
|
+
'form',
|
|
16360
|
+
'button',
|
|
16361
|
+
'select',
|
|
16362
|
+
'meta',
|
|
16363
|
+
'style',
|
|
16364
|
+
'link',
|
|
16365
|
+
'title',
|
|
16366
|
+
'object',
|
|
16367
|
+
'base',
|
|
16368
|
+
] }, options));
|
|
14843
16369
|
}
|
|
14844
16370
|
|
|
14845
16371
|
;// CONCATENATED MODULE: ./src/wysiwyg/nodes/html.ts
|
|
@@ -14849,7 +16375,7 @@ function sanitizeXSSAttributeValue(attrValue) {
|
|
|
14849
16375
|
|
|
14850
16376
|
function getChildrenHTML(node, typeName) {
|
|
14851
16377
|
return node
|
|
14852
|
-
.literal.replace(new RegExp("(<\\s*" + typeName + "[^>]
|
|
16378
|
+
.literal.replace(new RegExp("(<\\s*" + typeName + "[^>]*>)|(</" + typeName + "\\s*[>])", 'ig'), '')
|
|
14853
16379
|
.trim();
|
|
14854
16380
|
}
|
|
14855
16381
|
function getHTMLAttrsByHTMLString(html) {
|
|
@@ -15107,14 +16633,6 @@ function isBlankLine(doc, index) {
|
|
|
15107
16633
|
var pmNode = doc.child(index);
|
|
15108
16634
|
return !pmNode.childCount || (pmNode.childCount === 1 && !((_a = pmNode.firstChild.text) === null || _a === void 0 ? void 0 : _a.trim()));
|
|
15109
16635
|
}
|
|
15110
|
-
function getNextNonBlankElement(mdNode) {
|
|
15111
|
-
var next = mdNode.next, parent = mdNode.parent;
|
|
15112
|
-
while (!next && parent) {
|
|
15113
|
-
next = parent.next;
|
|
15114
|
-
parent = parent.parent;
|
|
15115
|
-
}
|
|
15116
|
-
return next ? document.querySelector("[data-nodeid=\"" + next.id + "\"]") : null;
|
|
15117
|
-
}
|
|
15118
16636
|
function getEditorRangeHeightInfo(doc, mdNode, children) {
|
|
15119
16637
|
var start = getMdStartLine(mdNode) - 1;
|
|
15120
16638
|
var end = getMdEndLine(mdNode) - 1;
|
|
@@ -15182,11 +16700,11 @@ function getAdditionalPos(scrollTop, offsetTop, height, targetNodeHeight) {
|
|
|
15182
16700
|
var ratio = Math.min((scrollTop - offsetTop) / height, 1);
|
|
15183
16701
|
return ratio * targetNodeHeight;
|
|
15184
16702
|
}
|
|
15185
|
-
function getParentNodeObj(mdNode) {
|
|
15186
|
-
var el =
|
|
16703
|
+
function getParentNodeObj(previewContent, mdNode) {
|
|
16704
|
+
var el = previewContent.querySelector("[data-nodeid=\"" + mdNode.id + "\"]");
|
|
15187
16705
|
while (!el || isStyledInlineNode(mdNode)) {
|
|
15188
16706
|
mdNode = mdNode.parent;
|
|
15189
|
-
el =
|
|
16707
|
+
el = previewContent.querySelector("[data-nodeid=\"" + mdNode.id + "\"]");
|
|
15190
16708
|
}
|
|
15191
16709
|
return getNonNestableNodeObj({ mdNode: mdNode, el: el });
|
|
15192
16710
|
}
|
|
@@ -15291,10 +16809,16 @@ var MarkdownPreview = /** @class */ (function () {
|
|
|
15291
16809
|
this.sanitizer = sanitizer;
|
|
15292
16810
|
this.initEvent(highlight);
|
|
15293
16811
|
this.initContentSection();
|
|
16812
|
+
// To prevent overflowing contents in the viewer
|
|
16813
|
+
if (this.isViewer) {
|
|
16814
|
+
this.previewContent.style.overflowWrap = 'break-word';
|
|
16815
|
+
}
|
|
15294
16816
|
}
|
|
15295
16817
|
MarkdownPreview.prototype.initContentSection = function () {
|
|
15296
16818
|
this.previewContent = createElementWith("<div class=\"" + cls('contents') + "\"></div>");
|
|
15297
|
-
|
|
16819
|
+
if (!this.isViewer) {
|
|
16820
|
+
this.el.appendChild(this.previewContent);
|
|
16821
|
+
}
|
|
15298
16822
|
};
|
|
15299
16823
|
MarkdownPreview.prototype.toggleActive = function (active) {
|
|
15300
16824
|
toggleClass(this.el, 'active', active);
|
|
@@ -15302,6 +16826,9 @@ var MarkdownPreview = /** @class */ (function () {
|
|
|
15302
16826
|
MarkdownPreview.prototype.initEvent = function (highlight) {
|
|
15303
16827
|
var _this = this;
|
|
15304
16828
|
this.eventEmitter.listen('updatePreview', this.update.bind(this));
|
|
16829
|
+
if (this.isViewer) {
|
|
16830
|
+
return;
|
|
16831
|
+
}
|
|
15305
16832
|
if (highlight) {
|
|
15306
16833
|
this.eventEmitter.listen('changeToolbarState', function (_a) {
|
|
15307
16834
|
var mdNode = _a.mdNode, cursorPos = _a.cursorPos;
|
|
@@ -15911,7 +17438,10 @@ var TableOffsetMap = /** @class */ (function () {
|
|
|
15911
17438
|
};
|
|
15912
17439
|
TableOffsetMap.prototype.getNodeAndPos = function (rowIdx, colIdx) {
|
|
15913
17440
|
var cellInfo = this.rowInfo[rowIdx][colIdx];
|
|
15914
|
-
return {
|
|
17441
|
+
return {
|
|
17442
|
+
node: this.table.nodeAt(cellInfo.offset - this.tableStartOffset),
|
|
17443
|
+
pos: cellInfo.offset,
|
|
17444
|
+
};
|
|
15915
17445
|
};
|
|
15916
17446
|
TableOffsetMap.prototype.extendedRowspan = function (rowIdx, colIdx) {
|
|
15917
17447
|
return false;
|
|
@@ -16603,7 +18133,6 @@ function task() {
|
|
|
16603
18133
|
;// CONCATENATED MODULE: ./src/wysiwyg/plugins/toolbarState.ts
|
|
16604
18134
|
|
|
16605
18135
|
|
|
16606
|
-
|
|
16607
18136
|
var EXCEPT_TYPES = ['image', 'link', 'customBlock', 'frontMatter'];
|
|
16608
18137
|
var MARK_TYPES = ['strong', 'strike', 'emph', 'code'];
|
|
16609
18138
|
var LIST_TYPES = ['bulletList', 'orderedList', 'taskList'];
|
|
@@ -16618,47 +18147,49 @@ function toolbarState_getToolbarStateType(node, parentNode) {
|
|
|
16618
18147
|
return type;
|
|
16619
18148
|
}
|
|
16620
18149
|
function setListNodeToolbarState(type, nodeTypeState) {
|
|
16621
|
-
nodeTypeState[type] = true;
|
|
18150
|
+
nodeTypeState[type] = { active: true };
|
|
16622
18151
|
LIST_TYPES.filter(function (listName) { return listName !== type; }).forEach(function (listType) {
|
|
16623
18152
|
if (nodeTypeState[listType]) {
|
|
16624
18153
|
delete nodeTypeState[listType];
|
|
16625
18154
|
}
|
|
16626
18155
|
});
|
|
16627
18156
|
}
|
|
16628
|
-
function
|
|
16629
|
-
var markTypeState = {};
|
|
18157
|
+
function setMarkTypeStates(from, to, schema, toolbarState) {
|
|
16630
18158
|
MARK_TYPES.forEach(function (type) {
|
|
16631
18159
|
var mark = schema.marks[type];
|
|
16632
18160
|
var marksAtPos = from.marksAcross(to) || [];
|
|
16633
18161
|
var foundMark = !!mark.isInSet(marksAtPos);
|
|
16634
18162
|
if (foundMark) {
|
|
16635
|
-
|
|
18163
|
+
toolbarState[type] = { active: true };
|
|
16636
18164
|
}
|
|
16637
18165
|
});
|
|
16638
|
-
return markTypeState;
|
|
16639
18166
|
}
|
|
16640
18167
|
function toolbarState_getToolbarState(selection, doc, schema) {
|
|
16641
18168
|
var $from = selection.$from, $to = selection.$to, from = selection.from, to = selection.to;
|
|
16642
|
-
var
|
|
16643
|
-
|
|
18169
|
+
var toolbarState = {
|
|
18170
|
+
indent: { active: false, disabled: true },
|
|
18171
|
+
outdent: { active: false, disabled: true },
|
|
18172
|
+
};
|
|
16644
18173
|
doc.nodesBetween(from, to, function (node, _, parentNode) {
|
|
16645
18174
|
var type = toolbarState_getToolbarStateType(node, parentNode);
|
|
16646
18175
|
if (common_includes(EXCEPT_TYPES, type)) {
|
|
16647
18176
|
return;
|
|
16648
18177
|
}
|
|
16649
18178
|
if (common_includes(LIST_TYPES, type)) {
|
|
16650
|
-
setListNodeToolbarState(type,
|
|
18179
|
+
setListNodeToolbarState(type, toolbarState);
|
|
18180
|
+
toolbarState.indent.disabled = false;
|
|
18181
|
+
toolbarState.outdent.disabled = false;
|
|
16651
18182
|
}
|
|
16652
18183
|
else if (type === 'paragraph' || type === 'text') {
|
|
16653
|
-
|
|
18184
|
+
setMarkTypeStates($from, $to, schema, toolbarState);
|
|
16654
18185
|
}
|
|
16655
18186
|
else {
|
|
16656
|
-
|
|
18187
|
+
toolbarState[type] = { active: true };
|
|
16657
18188
|
}
|
|
16658
18189
|
});
|
|
16659
|
-
return
|
|
18190
|
+
return toolbarState;
|
|
16660
18191
|
}
|
|
16661
|
-
function
|
|
18192
|
+
function toolbarStateHighlight(eventEmitter) {
|
|
16662
18193
|
return new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Plugin({
|
|
16663
18194
|
view: function () {
|
|
16664
18195
|
return {
|
|
@@ -16690,6 +18221,7 @@ var CustomBlockView = /** @class */ (function () {
|
|
|
16690
18221
|
if (_this.innerEditorView) {
|
|
16691
18222
|
throw new Error('The editor is already opened.');
|
|
16692
18223
|
}
|
|
18224
|
+
_this.dom.draggable = false;
|
|
16693
18225
|
_this.wrapper.style.display = 'none';
|
|
16694
18226
|
_this.innerViewContainer.style.display = 'block';
|
|
16695
18227
|
_this.innerEditorView = new external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_.EditorView(_this.innerViewContainer, {
|
|
@@ -16944,6 +18476,7 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
16944
18476
|
this.dom = null;
|
|
16945
18477
|
this.contentDOM = null;
|
|
16946
18478
|
this.input = null;
|
|
18479
|
+
this.timer = null;
|
|
16947
18480
|
this.handleMousedown = function (ev) {
|
|
16948
18481
|
var target = ev.target;
|
|
16949
18482
|
var style = getComputedStyle(target, ':after');
|
|
@@ -16999,7 +18532,7 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
16999
18532
|
input.type = 'text';
|
|
17000
18533
|
input.value = this.node.attrs.language;
|
|
17001
18534
|
wrapper.appendChild(input);
|
|
17002
|
-
|
|
18535
|
+
this.view.dom.parentElement.appendChild(wrapper);
|
|
17003
18536
|
var wrpperWidth = wrapper.clientWidth;
|
|
17004
18537
|
css_default()(wrapper, {
|
|
17005
18538
|
top: top + 10 + "px",
|
|
@@ -17009,7 +18542,10 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
17009
18542
|
this.input = input;
|
|
17010
18543
|
this.input.addEventListener('blur', function () { return _this.changeLanguage(); });
|
|
17011
18544
|
this.input.addEventListener('keydown', this.handleKeydown);
|
|
17012
|
-
|
|
18545
|
+
this.clearTimer();
|
|
18546
|
+
this.timer = setTimeout(function () {
|
|
18547
|
+
_this.input.focus();
|
|
18548
|
+
});
|
|
17013
18549
|
};
|
|
17014
18550
|
CodeBlockView.prototype.bindDOMEvent = function () {
|
|
17015
18551
|
if (this.dom) {
|
|
@@ -17042,6 +18578,12 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
17042
18578
|
removeNode(parent);
|
|
17043
18579
|
}
|
|
17044
18580
|
};
|
|
18581
|
+
CodeBlockView.prototype.clearTimer = function () {
|
|
18582
|
+
if (this.timer) {
|
|
18583
|
+
clearTimeout(this.timer);
|
|
18584
|
+
this.timer = null;
|
|
18585
|
+
}
|
|
18586
|
+
};
|
|
17045
18587
|
CodeBlockView.prototype.stopEvent = function () {
|
|
17046
18588
|
return true;
|
|
17047
18589
|
};
|
|
@@ -17054,6 +18596,7 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
17054
18596
|
};
|
|
17055
18597
|
CodeBlockView.prototype.destroy = function () {
|
|
17056
18598
|
this.reset();
|
|
18599
|
+
this.clearTimer();
|
|
17057
18600
|
if (this.dom) {
|
|
17058
18601
|
this.dom.removeEventListener('click', this.handleMousedown);
|
|
17059
18602
|
}
|
|
@@ -17217,6 +18760,7 @@ function convertMsoParagraphsToList(html) {
|
|
|
17217
18760
|
|
|
17218
18761
|
|
|
17219
18762
|
|
|
18763
|
+
|
|
17220
18764
|
var START_FRAGMENT_COMMENT = '<!--StartFragment-->';
|
|
17221
18765
|
var END_FRAGMENT_COMMENT = '<!--EndFragment-->';
|
|
17222
18766
|
function getContentBetweenFragmentComments(html) {
|
|
@@ -17225,7 +18769,7 @@ function getContentBetweenFragmentComments(html) {
|
|
|
17225
18769
|
if (startFragmentIndex > -1 && endFragmentIndex > -1) {
|
|
17226
18770
|
html = html.slice(startFragmentIndex + START_FRAGMENT_COMMENT.length, endFragmentIndex);
|
|
17227
18771
|
}
|
|
17228
|
-
return html;
|
|
18772
|
+
return html.replace(/<br[^>]*>/g, ALTERNATIVE_TAG_FOR_BR);
|
|
17229
18773
|
}
|
|
17230
18774
|
function convertMsoTableToCompletedTable(html) {
|
|
17231
18775
|
// wrap with <tr> if html contains dangling <td> tags
|
|
@@ -17313,9 +18857,9 @@ function paste_createTableBody(tableBodyRows, maxColumnCount, schema) {
|
|
|
17313
18857
|
}
|
|
17314
18858
|
return schema.nodes.tableBody.create(null, copiedRows);
|
|
17315
18859
|
}
|
|
17316
|
-
function createTableFromPastingTable(rows, schema, startFromBody) {
|
|
18860
|
+
function createTableFromPastingTable(rows, schema, startFromBody, isInTable) {
|
|
17317
18861
|
var columnCount = getMaxColumnCount(rows);
|
|
17318
|
-
if (startFromBody) {
|
|
18862
|
+
if (startFromBody && isInTable) {
|
|
17319
18863
|
return schema.nodes.table.create(null, [paste_createTableBody(rows, columnCount, schema)]);
|
|
17320
18864
|
}
|
|
17321
18865
|
var tableHeadRow = rows[0];
|
|
@@ -17326,15 +18870,16 @@ function createTableFromPastingTable(rows, schema, startFromBody) {
|
|
|
17326
18870
|
}
|
|
17327
18871
|
return schema.nodes.table.create(null, nodes);
|
|
17328
18872
|
}
|
|
17329
|
-
function changePastedSlice(slice, schema) {
|
|
18873
|
+
function changePastedSlice(slice, schema, isInTable) {
|
|
17330
18874
|
var nodes = [];
|
|
17331
|
-
slice.content.
|
|
18875
|
+
var content = slice.content, openStart = slice.openStart, openEnd = slice.openEnd;
|
|
18876
|
+
content.forEach(function (node) {
|
|
17332
18877
|
if (node.type.name === 'table') {
|
|
17333
18878
|
var tableContent = getTableContentFromSlice(new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(node), 0, 0));
|
|
17334
18879
|
if (tableContent) {
|
|
17335
18880
|
var rows = createRowsFromPastingTable(tableContent);
|
|
17336
18881
|
var startFromBody = tableContent.firstChild.type.name === 'tableBody';
|
|
17337
|
-
var table = createTableFromPastingTable(rows, schema, startFromBody);
|
|
18882
|
+
var table = createTableFromPastingTable(rows, schema, startFromBody, isInTable);
|
|
17338
18883
|
nodes.push(table);
|
|
17339
18884
|
}
|
|
17340
18885
|
}
|
|
@@ -17342,7 +18887,7 @@ function changePastedSlice(slice, schema) {
|
|
|
17342
18887
|
nodes.push(node);
|
|
17343
18888
|
}
|
|
17344
18889
|
});
|
|
17345
|
-
return new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(nodes),
|
|
18890
|
+
return new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Slice(external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment.from(nodes), openStart, openEnd);
|
|
17346
18891
|
}
|
|
17347
18892
|
|
|
17348
18893
|
;// CONCATENATED MODULE: ./src/wysiwyg/clipboard/pasteToTable.ts
|
|
@@ -17570,7 +19115,7 @@ var paragraph_Paragraph = /** @class */ (function (_super) {
|
|
|
17570
19115
|
get: function () {
|
|
17571
19116
|
return {
|
|
17572
19117
|
content: 'inline*',
|
|
17573
|
-
group: 'block
|
|
19118
|
+
group: 'block',
|
|
17574
19119
|
attrs: __assign({}, getDefaultCustomAttrs()),
|
|
17575
19120
|
parseDOM: [{ tag: 'p' }],
|
|
17576
19121
|
toDOM: function (_a) {
|
|
@@ -17704,7 +19249,8 @@ var heading_Heading = /** @class */ (function (_super) {
|
|
|
17704
19249
|
});
|
|
17705
19250
|
Heading.prototype.commands = function () {
|
|
17706
19251
|
return function (payload) { return function (state, dispatch) {
|
|
17707
|
-
|
|
19252
|
+
var nodeType = state.schema.nodes[payload.level ? 'heading' : 'paragraph'];
|
|
19253
|
+
return (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.setBlockType)(nodeType, payload)(state, dispatch);
|
|
17708
19254
|
}; };
|
|
17709
19255
|
};
|
|
17710
19256
|
return Heading;
|
|
@@ -17825,7 +19371,7 @@ var BulletList = /** @class */ (function (_super) {
|
|
|
17825
19371
|
get: function () {
|
|
17826
19372
|
return {
|
|
17827
19373
|
content: 'listItem+',
|
|
17828
|
-
group: 'block
|
|
19374
|
+
group: 'block',
|
|
17829
19375
|
attrs: __assign({ rawHTML: { default: null } }, getDefaultCustomAttrs()),
|
|
17830
19376
|
parseDOM: [createDOMInfoParsedRawHTML('ul')],
|
|
17831
19377
|
toDOM: function (_a) {
|
|
@@ -17882,7 +19428,7 @@ var OrderedList = /** @class */ (function (_super) {
|
|
|
17882
19428
|
get: function () {
|
|
17883
19429
|
return {
|
|
17884
19430
|
content: 'listItem+',
|
|
17885
|
-
group: 'block
|
|
19431
|
+
group: 'block',
|
|
17886
19432
|
attrs: __assign({ order: { default: 1 }, rawHTML: { default: null } }, getDefaultCustomAttrs()),
|
|
17887
19433
|
parseDOM: [
|
|
17888
19434
|
{
|
|
@@ -17943,7 +19489,8 @@ var listItem_ListItem = /** @class */ (function (_super) {
|
|
|
17943
19489
|
Object.defineProperty(ListItem.prototype, "schema", {
|
|
17944
19490
|
get: function () {
|
|
17945
19491
|
return {
|
|
17946
|
-
content: 'paragraph
|
|
19492
|
+
content: 'paragraph block*',
|
|
19493
|
+
selectable: false,
|
|
17947
19494
|
attrs: {
|
|
17948
19495
|
task: { default: false },
|
|
17949
19496
|
checked: { default: false },
|
|
@@ -18155,9 +19702,10 @@ function addParagraphBeforeTable(tr, map, schema) {
|
|
|
18155
19702
|
}
|
|
18156
19703
|
return tr.setSelection(external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Selection.near(tableStartPos, -1));
|
|
18157
19704
|
}
|
|
18158
|
-
function addParagraphAfterTable(tr, map, schema) {
|
|
19705
|
+
function addParagraphAfterTable(tr, map, schema, forcedAddtion) {
|
|
19706
|
+
if (forcedAddtion === void 0) { forcedAddtion = false; }
|
|
18159
19707
|
var tableEndPos = tr.doc.resolve(map.tableEndOffset);
|
|
18160
|
-
if (!tableEndPos.nodeAfter) {
|
|
19708
|
+
if (forcedAddtion || !tableEndPos.nodeAfter) {
|
|
18161
19709
|
return addParagraph(tr, tableEndPos, schema);
|
|
18162
19710
|
}
|
|
18163
19711
|
return tr.setSelection(external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Selection.near(tableEndPos, 1));
|
|
@@ -18579,6 +20127,29 @@ var table_Table = /** @class */ (function (_super) {
|
|
|
18579
20127
|
return false;
|
|
18580
20128
|
};
|
|
18581
20129
|
};
|
|
20130
|
+
Table.prototype.exitTable = function () {
|
|
20131
|
+
return function (state, dispatch) {
|
|
20132
|
+
var selection = state.selection, tr = state.tr, schema = state.schema;
|
|
20133
|
+
var $from = selection.$from;
|
|
20134
|
+
var cell = findNodeBy($from, function (_a) {
|
|
20135
|
+
var type = _a.type;
|
|
20136
|
+
return type.name === 'tableHeadCell' || type.name === 'tableBodyCell';
|
|
20137
|
+
});
|
|
20138
|
+
if (cell) {
|
|
20139
|
+
var para = findNodeBy($from, function (_a) {
|
|
20140
|
+
var type = _a.type;
|
|
20141
|
+
return type.name === 'paragraph';
|
|
20142
|
+
});
|
|
20143
|
+
if (para) {
|
|
20144
|
+
var anchor = getResolvedSelection(selection).anchor;
|
|
20145
|
+
var map = TableOffsetMap.create(anchor);
|
|
20146
|
+
dispatch(addParagraphAfterTable(tr, map, schema, true));
|
|
20147
|
+
return true;
|
|
20148
|
+
}
|
|
20149
|
+
}
|
|
20150
|
+
return false;
|
|
20151
|
+
};
|
|
20152
|
+
};
|
|
18582
20153
|
Table.prototype.commands = function () {
|
|
18583
20154
|
return {
|
|
18584
20155
|
addTable: this.addTable(),
|
|
@@ -18605,6 +20176,7 @@ var table_Table = /** @class */ (function (_super) {
|
|
|
18605
20176
|
'Mod-Backspace': deleteCellContent,
|
|
18606
20177
|
Delete: deleteCellContent,
|
|
18607
20178
|
'Mod-Delete': deleteCellContent,
|
|
20179
|
+
'Mod-Enter': this.exitTable(),
|
|
18608
20180
|
};
|
|
18609
20181
|
};
|
|
18610
20182
|
return Table;
|
|
@@ -18851,9 +20423,13 @@ var Image = /** @class */ (function (_super) {
|
|
|
18851
20423
|
{
|
|
18852
20424
|
tag: 'img[src]',
|
|
18853
20425
|
getAttrs: function (dom) {
|
|
18854
|
-
var
|
|
18855
|
-
|
|
18856
|
-
|
|
20426
|
+
var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
|
|
20427
|
+
.firstChild;
|
|
20428
|
+
var imageUrl = sanitizedDOM.getAttribute('src') || '';
|
|
20429
|
+
var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
|
|
20430
|
+
var altText = sanitizedDOM.getAttribute('alt');
|
|
20431
|
+
return __assign({ imageUrl: imageUrl,
|
|
20432
|
+
altText: altText }, (rawHTML && { rawHTML: rawHTML }));
|
|
18857
20433
|
},
|
|
18858
20434
|
},
|
|
18859
20435
|
],
|
|
@@ -18861,7 +20437,7 @@ var Image = /** @class */ (function (_super) {
|
|
|
18861
20437
|
var attrs = _a.attrs;
|
|
18862
20438
|
return [
|
|
18863
20439
|
attrs.rawHTML || 'img',
|
|
18864
|
-
__assign(__assign({ src: attrs.imageUrl }, (attrs.altText && { alt: attrs.altText })), getCustomAttrs(attrs)),
|
|
20440
|
+
__assign(__assign({ src: escapeXml(attrs.imageUrl) }, (attrs.altText && { alt: attrs.altText })), getCustomAttrs(attrs)),
|
|
18865
20441
|
];
|
|
18866
20442
|
},
|
|
18867
20443
|
};
|
|
@@ -18876,7 +20452,7 @@ var Image = /** @class */ (function (_super) {
|
|
|
18876
20452
|
if (!imageUrl) {
|
|
18877
20453
|
return false;
|
|
18878
20454
|
}
|
|
18879
|
-
var node = schema.nodes.image.createAndFill(__assign({ imageUrl:
|
|
20455
|
+
var node = schema.nodes.image.createAndFill(__assign({ imageUrl: imageUrl }, (altText && { altText: altText })));
|
|
18880
20456
|
dispatch(tr.replaceSelectionWith(node).scrollIntoView());
|
|
18881
20457
|
return true;
|
|
18882
20458
|
}; };
|
|
@@ -19153,15 +20729,18 @@ var link_Link = /** @class */ (function (_super) {
|
|
|
19153
20729
|
get: function () {
|
|
19154
20730
|
var _this = this;
|
|
19155
20731
|
return {
|
|
19156
|
-
attrs: __assign({ linkUrl: { default: '' },
|
|
20732
|
+
attrs: __assign({ linkUrl: { default: '' }, title: { default: null }, rawHTML: { default: null } }, getDefaultCustomAttrs()),
|
|
19157
20733
|
inclusive: false,
|
|
19158
20734
|
parseDOM: [
|
|
19159
20735
|
{
|
|
19160
20736
|
tag: 'a[href]',
|
|
19161
20737
|
getAttrs: function (dom) {
|
|
19162
|
-
var
|
|
19163
|
-
|
|
19164
|
-
|
|
20738
|
+
var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
|
|
20739
|
+
.firstChild;
|
|
20740
|
+
var href = sanitizedDOM.getAttribute('href') || '';
|
|
20741
|
+
var title = sanitizedDOM.getAttribute('title') || '';
|
|
20742
|
+
var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
|
|
20743
|
+
return __assign({ linkUrl: href, title: title }, (rawHTML && { rawHTML: rawHTML }));
|
|
19165
20744
|
},
|
|
19166
20745
|
},
|
|
19167
20746
|
],
|
|
@@ -19169,7 +20748,7 @@ var link_Link = /** @class */ (function (_super) {
|
|
|
19169
20748
|
var attrs = _a.attrs;
|
|
19170
20749
|
return [
|
|
19171
20750
|
attrs.rawHTML || 'a',
|
|
19172
|
-
__assign(__assign({ href: attrs.linkUrl }, _this.linkAttributes), getCustomAttrs(attrs)),
|
|
20751
|
+
__assign(__assign({ href: escapeXml(attrs.linkUrl) }, _this.linkAttributes), getCustomAttrs(attrs)),
|
|
19173
20752
|
];
|
|
19174
20753
|
},
|
|
19175
20754
|
};
|
|
@@ -19183,10 +20762,7 @@ var link_Link = /** @class */ (function (_super) {
|
|
|
19183
20762
|
var schema = state.schema, tr = state.tr, selection = state.selection;
|
|
19184
20763
|
var empty = selection.empty, from = selection.from, to = selection.to;
|
|
19185
20764
|
if (from && to && linkUrl) {
|
|
19186
|
-
var attrs = {
|
|
19187
|
-
linkUrl: encodeMarkdownText(linkUrl),
|
|
19188
|
-
linkText: escapeMarkdownText(linkText),
|
|
19189
|
-
};
|
|
20765
|
+
var attrs = { linkUrl: linkUrl };
|
|
19190
20766
|
var mark = schema.mark('link', attrs);
|
|
19191
20767
|
if (empty && linkText) {
|
|
19192
20768
|
var node = createTextNode(schema, linkText, mark);
|
|
@@ -19272,6 +20848,7 @@ var code_Code = /** @class */ (function (_super) {
|
|
|
19272
20848
|
;// CONCATENATED MODULE: ./src/wysiwyg/nodes/customBlock.ts
|
|
19273
20849
|
|
|
19274
20850
|
|
|
20851
|
+
|
|
19275
20852
|
var customBlock_CustomBlock = /** @class */ (function (_super) {
|
|
19276
20853
|
__extends(CustomBlock, _super);
|
|
19277
20854
|
function CustomBlock() {
|
|
@@ -19313,6 +20890,13 @@ var customBlock_CustomBlock = /** @class */ (function (_super) {
|
|
|
19313
20890
|
enumerable: false,
|
|
19314
20891
|
configurable: true
|
|
19315
20892
|
});
|
|
20893
|
+
CustomBlock.prototype.commands = function () {
|
|
20894
|
+
return function (payload) { return function (state, dispatch) {
|
|
20895
|
+
return (payload === null || payload === void 0 ? void 0 : payload.info)
|
|
20896
|
+
? (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.setBlockType)(state.schema.nodes.customBlock, payload)(state, dispatch)
|
|
20897
|
+
: false;
|
|
20898
|
+
}; };
|
|
20899
|
+
};
|
|
19316
20900
|
return CustomBlock;
|
|
19317
20901
|
}(node));
|
|
19318
20902
|
|
|
@@ -19339,8 +20923,10 @@ var FrontMatter = /** @class */ (function (_super) {
|
|
|
19339
20923
|
content: 'text*',
|
|
19340
20924
|
group: 'block',
|
|
19341
20925
|
code: true,
|
|
20926
|
+
defining: true,
|
|
19342
20927
|
parseDOM: [
|
|
19343
20928
|
{
|
|
20929
|
+
preserveWhitespace: 'full',
|
|
19344
20930
|
tag: 'div[data-front-matter]',
|
|
19345
20931
|
},
|
|
19346
20932
|
],
|
|
@@ -19370,6 +20956,56 @@ var FrontMatter = /** @class */ (function (_super) {
|
|
|
19370
20956
|
}(node));
|
|
19371
20957
|
|
|
19372
20958
|
|
|
20959
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/nodes/htmlComment.ts
|
|
20960
|
+
|
|
20961
|
+
|
|
20962
|
+
|
|
20963
|
+
var HTMLComment = /** @class */ (function (_super) {
|
|
20964
|
+
__extends(HTMLComment, _super);
|
|
20965
|
+
function HTMLComment() {
|
|
20966
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
20967
|
+
}
|
|
20968
|
+
Object.defineProperty(HTMLComment.prototype, "name", {
|
|
20969
|
+
get: function () {
|
|
20970
|
+
return 'htmlComment';
|
|
20971
|
+
},
|
|
20972
|
+
enumerable: false,
|
|
20973
|
+
configurable: true
|
|
20974
|
+
});
|
|
20975
|
+
Object.defineProperty(HTMLComment.prototype, "schema", {
|
|
20976
|
+
get: function () {
|
|
20977
|
+
return {
|
|
20978
|
+
content: 'text*',
|
|
20979
|
+
group: 'block',
|
|
20980
|
+
code: true,
|
|
20981
|
+
defining: true,
|
|
20982
|
+
parseDOM: [{ preserveWhitespace: 'full', tag: 'div[data-html-comment]' }],
|
|
20983
|
+
toDOM: function () {
|
|
20984
|
+
return ['div', { 'data-html-comment': 'true' }, 0];
|
|
20985
|
+
},
|
|
20986
|
+
};
|
|
20987
|
+
},
|
|
20988
|
+
enumerable: false,
|
|
20989
|
+
configurable: true
|
|
20990
|
+
});
|
|
20991
|
+
HTMLComment.prototype.commands = function () {
|
|
20992
|
+
return function () { return function (state, dispatch, view) {
|
|
20993
|
+
var $from = state.selection.$from;
|
|
20994
|
+
if (view.endOfTextblock('down') && $from.node().type.name === 'htmlComment') {
|
|
20995
|
+
return (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.exitCode)(state, dispatch);
|
|
20996
|
+
}
|
|
20997
|
+
return false;
|
|
20998
|
+
}; };
|
|
20999
|
+
};
|
|
21000
|
+
HTMLComment.prototype.keymaps = function () {
|
|
21001
|
+
return {
|
|
21002
|
+
Enter: this.commands()(),
|
|
21003
|
+
};
|
|
21004
|
+
};
|
|
21005
|
+
return HTMLComment;
|
|
21006
|
+
}(node));
|
|
21007
|
+
|
|
21008
|
+
|
|
19373
21009
|
;// CONCATENATED MODULE: ./src/wysiwyg/specCreator.ts
|
|
19374
21010
|
|
|
19375
21011
|
|
|
@@ -19395,6 +21031,7 @@ var FrontMatter = /** @class */ (function (_super) {
|
|
|
19395
21031
|
|
|
19396
21032
|
|
|
19397
21033
|
|
|
21034
|
+
|
|
19398
21035
|
|
|
19399
21036
|
|
|
19400
21037
|
function createSpecs(linkAttributes) {
|
|
@@ -19424,6 +21061,7 @@ function createSpecs(linkAttributes) {
|
|
|
19424
21061
|
new customBlock_CustomBlock(),
|
|
19425
21062
|
new FrontMatter(),
|
|
19426
21063
|
new Widget(),
|
|
21064
|
+
new HTMLComment(),
|
|
19427
21065
|
]);
|
|
19428
21066
|
}
|
|
19429
21067
|
|
|
@@ -19447,6 +21085,8 @@ function createSpecs(linkAttributes) {
|
|
|
19447
21085
|
|
|
19448
21086
|
|
|
19449
21087
|
|
|
21088
|
+
|
|
21089
|
+
|
|
19450
21090
|
|
|
19451
21091
|
|
|
19452
21092
|
|
|
@@ -19492,7 +21132,7 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19492
21132
|
tableSelection(),
|
|
19493
21133
|
tableContextMenu(this.eventEmitter),
|
|
19494
21134
|
task(),
|
|
19495
|
-
|
|
21135
|
+
toolbarStateHighlight(this.eventEmitter)
|
|
19496
21136
|
], this.createPluginProps()));
|
|
19497
21137
|
};
|
|
19498
21138
|
WysiwygEditor.prototype.createPluginNodeViews = function () {
|
|
@@ -19531,7 +21171,9 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19531
21171
|
_this.eventEmitter.emit('setFocusedNode', state.selection.$from.node(1));
|
|
19532
21172
|
},
|
|
19533
21173
|
transformPastedHTML: changePastedHTML,
|
|
19534
|
-
transformPasted: function (slice) {
|
|
21174
|
+
transformPasted: function (slice) {
|
|
21175
|
+
return changePastedSlice(slice, _this.schema, isInTableNode(_this.view.state.selection.$from));
|
|
21176
|
+
},
|
|
19535
21177
|
handlePaste: function (view, _, slice) { return pasteToTable(view, slice); },
|
|
19536
21178
|
handleKeyDown: function (_, ev) {
|
|
19537
21179
|
_this.eventEmitter.emit('keydown', _this.editorType, ev);
|
|
@@ -19540,12 +21182,16 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19540
21182
|
handleDOMEvents: {
|
|
19541
21183
|
paste: function (_, ev) {
|
|
19542
21184
|
var clipboardData = ev.clipboardData || window.clipboardData;
|
|
19543
|
-
var items = clipboardData
|
|
21185
|
+
var items = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.items;
|
|
19544
21186
|
if (items) {
|
|
19545
|
-
var
|
|
19546
|
-
if
|
|
19547
|
-
|
|
19548
|
-
|
|
21187
|
+
var containRtfItem = toArray_default()(items).some(function (item) { return item.kind === 'string' && item.type === 'text/rtf'; });
|
|
21188
|
+
// if it contains rtf, it's most likely copy paste from office -> no image
|
|
21189
|
+
if (!containRtfItem) {
|
|
21190
|
+
var imageBlob = pasteImageOnly(items);
|
|
21191
|
+
if (imageBlob) {
|
|
21192
|
+
ev.preventDefault();
|
|
21193
|
+
emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type);
|
|
21194
|
+
}
|
|
19549
21195
|
}
|
|
19550
21196
|
}
|
|
19551
21197
|
return false;
|
|
@@ -19609,7 +21255,7 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19609
21255
|
var _a = this.view.state, tr = _a.tr, doc = _a.doc;
|
|
19610
21256
|
this.view.dispatch(tr.replaceWith(0, doc.content.size, newDoc));
|
|
19611
21257
|
if (cursorToEnd) {
|
|
19612
|
-
this.moveCursorToEnd();
|
|
21258
|
+
this.moveCursorToEnd(true);
|
|
19613
21259
|
}
|
|
19614
21260
|
};
|
|
19615
21261
|
WysiwygEditor.prototype.setSelection = function (start, end) {
|
|
@@ -19686,6 +21332,7 @@ var eventTypeList = [
|
|
|
19686
21332
|
'mixinTableOffsetMapPrototype',
|
|
19687
21333
|
'setFocusedNode',
|
|
19688
21334
|
'removePopupWidget',
|
|
21335
|
+
'query',
|
|
19689
21336
|
// provide event for user
|
|
19690
21337
|
'openPopup',
|
|
19691
21338
|
'closePopup',
|
|
@@ -19693,6 +21340,7 @@ var eventTypeList = [
|
|
|
19693
21340
|
'beforePreviewRender',
|
|
19694
21341
|
'beforeConvertWysiwygToMarkdown',
|
|
19695
21342
|
'load',
|
|
21343
|
+
'loadUI',
|
|
19696
21344
|
'change',
|
|
19697
21345
|
'caretChange',
|
|
19698
21346
|
'destroy',
|
|
@@ -19948,6 +21596,9 @@ function htmlToWwConvertors_isInlineNode(_a) {
|
|
|
19948
21596
|
var type = _a.type;
|
|
19949
21597
|
return common_includes(['text', 'strong', 'emph', 'strike', 'image', 'link', 'code'], type);
|
|
19950
21598
|
}
|
|
21599
|
+
function isSoftbreak(mdNode) {
|
|
21600
|
+
return (mdNode === null || mdNode === void 0 ? void 0 : mdNode.type) === 'softbreak';
|
|
21601
|
+
}
|
|
19951
21602
|
function htmlToWwConvertors_isListNode(_a) {
|
|
19952
21603
|
var type = _a.type, literal = _a.literal;
|
|
19953
21604
|
var matched = type === 'htmlInline' && literal.match(reHTMLTag);
|
|
@@ -19966,11 +21617,15 @@ function getListItemAttrs(_a) {
|
|
|
19966
21617
|
var checked = /data-task-checked/.test(literal);
|
|
19967
21618
|
return { task: task, checked: checked };
|
|
19968
21619
|
}
|
|
19969
|
-
function getMatchedAttributeValue(rawHTML
|
|
21620
|
+
function getMatchedAttributeValue(rawHTML) {
|
|
21621
|
+
var attrNames = [];
|
|
21622
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
21623
|
+
attrNames[_i - 1] = arguments[_i];
|
|
21624
|
+
}
|
|
19970
21625
|
var wrapper = document.createElement('div');
|
|
19971
|
-
wrapper.innerHTML = rawHTML;
|
|
21626
|
+
wrapper.innerHTML = sanitizeHTML(rawHTML);
|
|
19972
21627
|
var el = wrapper.firstChild;
|
|
19973
|
-
return el.getAttribute(attrName) || '';
|
|
21628
|
+
return attrNames.map(function (attrName) { return el.getAttribute(attrName) || ''; });
|
|
19974
21629
|
}
|
|
19975
21630
|
function createConvertors(convertors) {
|
|
19976
21631
|
var convertorMap = {};
|
|
@@ -20024,9 +21679,9 @@ var convertors = {
|
|
|
20024
21679
|
var tag = node.literal;
|
|
20025
21680
|
var link = state.schema.marks.link;
|
|
20026
21681
|
if (openTagName) {
|
|
20027
|
-
var linkUrl = getMatchedAttributeValue(tag, 'href');
|
|
21682
|
+
var linkUrl = getMatchedAttributeValue(tag, 'href')[0];
|
|
20028
21683
|
state.openMark(link.create({
|
|
20029
|
-
linkUrl:
|
|
21684
|
+
linkUrl: linkUrl,
|
|
20030
21685
|
rawHTML: openTagName,
|
|
20031
21686
|
}));
|
|
20032
21687
|
}
|
|
@@ -20036,11 +21691,10 @@ var convertors = {
|
|
|
20036
21691
|
},
|
|
20037
21692
|
img: function (state, node, openTagName) {
|
|
20038
21693
|
var tag = node.literal;
|
|
20039
|
-
|
|
20040
|
-
|
|
20041
|
-
var altText = getMatchedAttributeValue(tag, 'alt');
|
|
21694
|
+
if (openTagName) {
|
|
21695
|
+
var _a = getMatchedAttributeValue(tag, 'src', 'alt'), imageUrl = _a[0], altText = _a[1];
|
|
20042
21696
|
var image = state.schema.nodes.image;
|
|
20043
|
-
state.addNode(image, __assign({ rawHTML: openTagName, imageUrl:
|
|
21697
|
+
state.addNode(image, __assign({ rawHTML: openTagName, imageUrl: imageUrl }, (altText && { altText: altText })));
|
|
20044
21698
|
}
|
|
20045
21699
|
},
|
|
20046
21700
|
hr: function (state, _, openTagName) {
|
|
@@ -20050,11 +21704,22 @@ var convertors = {
|
|
|
20050
21704
|
var paragraph = state.schema.nodes.paragraph;
|
|
20051
21705
|
var parent = node.parent, prev = node.prev, next = node.next;
|
|
20052
21706
|
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'paragraph') {
|
|
20053
|
-
|
|
21707
|
+
// should open a paragraph node when line text has only <br> tag
|
|
21708
|
+
// ex) first line\n\n<br>\nfourth line
|
|
21709
|
+
if (isSoftbreak(prev)) {
|
|
20054
21710
|
state.openNode(paragraph);
|
|
20055
21711
|
}
|
|
20056
|
-
|
|
21712
|
+
// should close a paragraph node when line text has only <br> tag
|
|
21713
|
+
// ex) first line\n\n<br>\nfourth line
|
|
21714
|
+
if (isSoftbreak(next)) {
|
|
21715
|
+
state.closeNode();
|
|
21716
|
+
// should close a paragraph node and open a paragraph node to separate between blocks
|
|
21717
|
+
// when <br> tag is in the middle of the paragraph
|
|
21718
|
+
// ex) first <br>line\nthird line
|
|
21719
|
+
}
|
|
21720
|
+
else if (next) {
|
|
20057
21721
|
state.closeNode();
|
|
21722
|
+
state.openNode(paragraph);
|
|
20058
21723
|
}
|
|
20059
21724
|
}
|
|
20060
21725
|
else if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'tableCell') {
|
|
@@ -20130,8 +21795,9 @@ var htmlToWwConvertors = createConvertors(convertors);
|
|
|
20130
21795
|
|
|
20131
21796
|
|
|
20132
21797
|
|
|
21798
|
+
|
|
20133
21799
|
function isBRTag(node) {
|
|
20134
|
-
return node.type === 'htmlInline' &&
|
|
21800
|
+
return node.type === 'htmlInline' && reBR.test(node.literal);
|
|
20135
21801
|
}
|
|
20136
21802
|
function addRawHTMLAttributeToDOM(parent) {
|
|
20137
21803
|
toArray_default()(parent.childNodes).forEach(function (child) {
|
|
@@ -20256,7 +21922,7 @@ var toWwConvertors = {
|
|
|
20256
21922
|
var link = state.schema.marks.link;
|
|
20257
21923
|
var _b = node, destination = _b.destination, title = _b.title;
|
|
20258
21924
|
if (entering) {
|
|
20259
|
-
var attrs = __assign(
|
|
21925
|
+
var attrs = __assign({ linkUrl: destination, title: title }, customAttrs);
|
|
20260
21926
|
state.openMark(link.create(attrs));
|
|
20261
21927
|
}
|
|
20262
21928
|
else {
|
|
@@ -20322,7 +21988,7 @@ var toWwConvertors = {
|
|
|
20322
21988
|
var tablePart = node.parent.parent;
|
|
20323
21989
|
var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
|
|
20324
21990
|
var table = tablePart.parent;
|
|
20325
|
-
var align = table.columns[node.startIdx].align;
|
|
21991
|
+
var align = (table.columns[node.startIdx] || {}).align;
|
|
20326
21992
|
var attrs = __assign({}, node.attrs);
|
|
20327
21993
|
if (align) {
|
|
20328
21994
|
attrs.align = align;
|
|
@@ -20379,10 +22045,11 @@ var toWwConvertors = {
|
|
|
20379
22045
|
var openTagName = matched[1], closeTagName = matched[3];
|
|
20380
22046
|
var typeName = (openTagName || closeTagName).toLowerCase();
|
|
20381
22047
|
var markType = state.schema.marks[typeName];
|
|
22048
|
+
var sanitizedHTML = sanitizeHTML(html);
|
|
20382
22049
|
// for user defined html schema
|
|
20383
22050
|
if (markType === null || markType === void 0 ? void 0 : markType.spec.attrs.htmlInline) {
|
|
20384
22051
|
if (openTagName) {
|
|
20385
|
-
var htmlAttrs = getHTMLAttrsByHTMLString(
|
|
22052
|
+
var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
|
|
20386
22053
|
state.openMark(markType.create({ htmlAttrs: htmlAttrs }));
|
|
20387
22054
|
}
|
|
20388
22055
|
else {
|
|
@@ -20399,25 +22066,34 @@ var toWwConvertors = {
|
|
|
20399
22066
|
htmlBlock: function (state, node) {
|
|
20400
22067
|
var html = node.literal;
|
|
20401
22068
|
var container = document.createElement('div');
|
|
20402
|
-
var
|
|
20403
|
-
|
|
20404
|
-
|
|
20405
|
-
|
|
20406
|
-
|
|
20407
|
-
if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
|
|
20408
|
-
var htmlAttrs = getHTMLAttrsByHTMLString(html);
|
|
20409
|
-
var childrenHTML = getChildrenHTML(node, typeName);
|
|
20410
|
-
state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
|
|
22069
|
+
var isHTMLComment = reHTMLComment.test(html);
|
|
22070
|
+
if (isHTMLComment) {
|
|
22071
|
+
state.openNode(state.schema.nodes.htmlComment);
|
|
22072
|
+
state.addText(node.literal);
|
|
22073
|
+
state.closeNode();
|
|
20411
22074
|
}
|
|
20412
22075
|
else {
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
|
|
22076
|
+
var matched = html.match(reHTMLTag);
|
|
22077
|
+
var openTagName = matched[1], closeTagName = matched[3];
|
|
22078
|
+
var typeName = (openTagName || closeTagName).toLowerCase();
|
|
22079
|
+
var nodeType = state.schema.nodes[typeName];
|
|
22080
|
+
var sanitizedHTML = sanitizeHTML(html);
|
|
22081
|
+
// for user defined html schema
|
|
22082
|
+
if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
|
|
22083
|
+
var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
|
|
22084
|
+
var childrenHTML = getChildrenHTML(node, typeName);
|
|
22085
|
+
state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
|
|
22086
|
+
}
|
|
22087
|
+
else {
|
|
22088
|
+
container.innerHTML = sanitizedHTML;
|
|
22089
|
+
addRawHTMLAttributeToDOM(container);
|
|
22090
|
+
state.convertByDOMParser(container);
|
|
22091
|
+
}
|
|
20416
22092
|
}
|
|
20417
22093
|
},
|
|
20418
22094
|
customInline: function (state, node, _a) {
|
|
20419
22095
|
var entering = _a.entering, skipChildren = _a.skipChildren;
|
|
20420
|
-
var info =
|
|
22096
|
+
var _b = node, info = _b.info, firstChild = _b.firstChild;
|
|
20421
22097
|
var schema = state.schema;
|
|
20422
22098
|
if (info.indexOf('widget') !== -1 && entering) {
|
|
20423
22099
|
var content = getWidgetContent(node);
|
|
@@ -20426,6 +22102,13 @@ var toWwConvertors = {
|
|
|
20426
22102
|
schema.text(createWidgetContent(info, content)),
|
|
20427
22103
|
]);
|
|
20428
22104
|
}
|
|
22105
|
+
else {
|
|
22106
|
+
var text = '$$';
|
|
22107
|
+
if (entering) {
|
|
22108
|
+
text += firstChild ? info + " " : info;
|
|
22109
|
+
}
|
|
22110
|
+
state.addText(text);
|
|
22111
|
+
}
|
|
20429
22112
|
},
|
|
20430
22113
|
};
|
|
20431
22114
|
function createWwConvertors(customConvertors) {
|
|
@@ -20441,7 +22124,7 @@ function createWwConvertors(customConvertors) {
|
|
|
20441
22124
|
var wwConvertor = toWwConvertors[type];
|
|
20442
22125
|
if (wwConvertor && !common_includes(['htmlBlock', 'htmlInline'], type)) {
|
|
20443
22126
|
convertors[type] = function (state, node, context) {
|
|
20444
|
-
context.origin = function () { return orgConvertors[type](node, context); };
|
|
22127
|
+
context.origin = function () { return orgConvertors[type](node, context, orgConvertors); };
|
|
20445
22128
|
var tokens = customConvertors[type](node, context);
|
|
20446
22129
|
var attrs;
|
|
20447
22130
|
if (tokens) {
|
|
@@ -20525,6 +22208,27 @@ var ToWwConvertorState = /** @class */ (function () {
|
|
|
20525
22208
|
var doc = external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.DOMParser.fromSchema(this.schema).parse(root);
|
|
20526
22209
|
doc.content.forEach(function (node) { return _this.push(node); });
|
|
20527
22210
|
};
|
|
22211
|
+
ToWwConvertorState.prototype.closeUnmatchedHTMLInline = function (node, entering) {
|
|
22212
|
+
var _a;
|
|
22213
|
+
if (!entering && node.type !== 'htmlInline') {
|
|
22214
|
+
var length = this.stack.length - 1;
|
|
22215
|
+
for (var i = length; i >= 0; i -= 1) {
|
|
22216
|
+
var nodeInfo = this.stack[i];
|
|
22217
|
+
if ((_a = nodeInfo.attrs) === null || _a === void 0 ? void 0 : _a.rawHTML) {
|
|
22218
|
+
if (nodeInfo.content.length) {
|
|
22219
|
+
this.closeNode();
|
|
22220
|
+
}
|
|
22221
|
+
else {
|
|
22222
|
+
// just pop useless unmatched html inline node
|
|
22223
|
+
this.stack.pop();
|
|
22224
|
+
}
|
|
22225
|
+
}
|
|
22226
|
+
else {
|
|
22227
|
+
break;
|
|
22228
|
+
}
|
|
22229
|
+
}
|
|
22230
|
+
}
|
|
22231
|
+
};
|
|
20528
22232
|
ToWwConvertorState.prototype.convert = function (mdNode, infoForPosSync) {
|
|
20529
22233
|
var walker = mdNode.walker();
|
|
20530
22234
|
var event = walker.next();
|
|
@@ -20542,6 +22246,7 @@ var ToWwConvertorState = /** @class */ (function () {
|
|
|
20542
22246
|
skipped = true;
|
|
20543
22247
|
},
|
|
20544
22248
|
};
|
|
22249
|
+
this_1.closeUnmatchedHTMLInline(node, entering);
|
|
20545
22250
|
convertor(this_1, node, context);
|
|
20546
22251
|
if ((infoForPosSync === null || infoForPosSync === void 0 ? void 0 : infoForPosSync.node) === node) {
|
|
20547
22252
|
var pos = this_1.stack.reduce(function (nodeSize, stackItem) {
|
|
@@ -20617,7 +22322,13 @@ var nodeTypeWriters = {
|
|
|
20617
22322
|
text: function (state, _a) {
|
|
20618
22323
|
var _b;
|
|
20619
22324
|
var node = _a.node;
|
|
20620
|
-
|
|
22325
|
+
var text = (_b = node.text) !== null && _b !== void 0 ? _b : '';
|
|
22326
|
+
if ((node.marks || []).some(function (mark) { return mark.type.name === 'link'; })) {
|
|
22327
|
+
state.text(escapeTextForLink(text), false);
|
|
22328
|
+
}
|
|
22329
|
+
else {
|
|
22330
|
+
state.text(text);
|
|
22331
|
+
}
|
|
20621
22332
|
},
|
|
20622
22333
|
paragraph: function (state, _a) {
|
|
20623
22334
|
var node = _a.node, parent = _a.parent, _b = _a.index, index = _b === void 0 ? 0 : _b;
|
|
@@ -20782,9 +22493,19 @@ var nodeTypeWriters = {
|
|
|
20782
22493
|
var text = _a.text;
|
|
20783
22494
|
state.write(text);
|
|
20784
22495
|
},
|
|
20785
|
-
html: function (state,
|
|
20786
|
-
var
|
|
22496
|
+
html: function (state, _a, _b) {
|
|
22497
|
+
var node = _a.node;
|
|
22498
|
+
var text = _b.text;
|
|
22499
|
+
state.write(text);
|
|
22500
|
+
if (node.attrs.htmlBlock) {
|
|
22501
|
+
state.closeBlock(node);
|
|
22502
|
+
}
|
|
22503
|
+
},
|
|
22504
|
+
htmlComment: function (state, _a, _b) {
|
|
22505
|
+
var node = _a.node;
|
|
22506
|
+
var text = _b.text;
|
|
20787
22507
|
state.write(text);
|
|
22508
|
+
state.closeBlock(node);
|
|
20788
22509
|
},
|
|
20789
22510
|
};
|
|
20790
22511
|
function write(type, _a) {
|
|
@@ -20946,13 +22667,13 @@ var toMdConvertors = {
|
|
|
20946
22667
|
image: function (_a) {
|
|
20947
22668
|
var node = _a.node;
|
|
20948
22669
|
var attrs = node.attrs;
|
|
20949
|
-
var
|
|
20950
|
-
var imageUrl =
|
|
20951
|
-
var altAttr = altText ? " alt=\"" + altText + "\"" : '';
|
|
22670
|
+
var rawHTML = attrs.rawHTML, altText = attrs.altText;
|
|
22671
|
+
var imageUrl = attrs.imageUrl.replace(/&/g, '&');
|
|
22672
|
+
var altAttr = altText ? " alt=\"" + escapeXml(altText) + "\"" : '';
|
|
20952
22673
|
return {
|
|
20953
|
-
rawHTML:
|
|
22674
|
+
rawHTML: rawHTML ? "<" + rawHTML + " src=\"" + escapeXml(imageUrl) + "\"" + altAttr + ">" : null,
|
|
20954
22675
|
attrs: {
|
|
20955
|
-
altText: altText,
|
|
22676
|
+
altText: escapeTextForLink(altText || ''),
|
|
20956
22677
|
imageUrl: imageUrl,
|
|
20957
22678
|
},
|
|
20958
22679
|
};
|
|
@@ -21015,17 +22736,17 @@ var toMdConvertors = {
|
|
|
21015
22736
|
var node = _a.node;
|
|
21016
22737
|
var entering = _b.entering;
|
|
21017
22738
|
var attrs = node.attrs;
|
|
21018
|
-
var
|
|
21019
|
-
var
|
|
22739
|
+
var title = attrs.title, rawHTML = attrs.rawHTML;
|
|
22740
|
+
var linkUrl = attrs.linkUrl.replace(/&/g, '&');
|
|
22741
|
+
var titleAttr = title ? " title=\"" + escapeXml(title) + "\"" : '';
|
|
21020
22742
|
if (entering) {
|
|
21021
22743
|
return {
|
|
21022
22744
|
delim: '[',
|
|
21023
|
-
rawHTML: rawHTML ? "<" + rawHTML + " href=\"" + linkUrl + "\">" : null,
|
|
22745
|
+
rawHTML: rawHTML ? "<" + rawHTML + " href=\"" + escapeXml(linkUrl) + "\"" + titleAttr + ">" : null,
|
|
21024
22746
|
};
|
|
21025
22747
|
}
|
|
21026
|
-
var linkText = attrs.title ? " " + quote(attrs.linkText) : '';
|
|
21027
22748
|
return {
|
|
21028
|
-
delim: "](" +
|
|
22749
|
+
delim: "](" + linkUrl + (title ? " " + quote(escapeTextForLink(title)) : '') + ")",
|
|
21029
22750
|
rawHTML: getCloseRawHTML(rawHTML),
|
|
21030
22751
|
};
|
|
21031
22752
|
},
|
|
@@ -21043,6 +22764,12 @@ var toMdConvertors = {
|
|
|
21043
22764
|
rawHTML: rawHTML,
|
|
21044
22765
|
};
|
|
21045
22766
|
},
|
|
22767
|
+
htmlComment: function (_a) {
|
|
22768
|
+
var node = _a.node;
|
|
22769
|
+
return {
|
|
22770
|
+
text: node.textContent,
|
|
22771
|
+
};
|
|
22772
|
+
},
|
|
21046
22773
|
// html inline node, html block node
|
|
21047
22774
|
html: function (_a, _b) {
|
|
21048
22775
|
var node = _a.node;
|
|
@@ -21052,7 +22779,8 @@ var toMdConvertors = {
|
|
|
21052
22779
|
var openTag = "<" + tagName;
|
|
21053
22780
|
var closeTag = "</" + tagName + ">";
|
|
21054
22781
|
Object.keys(attrs).forEach(function (attrName) {
|
|
21055
|
-
|
|
22782
|
+
// To prevent broken converting when attributes has double quote string
|
|
22783
|
+
openTag += " " + attrName + "=\"" + attrs[attrName].replace(/"/g, "'") + "\"";
|
|
21056
22784
|
});
|
|
21057
22785
|
openTag += '>';
|
|
21058
22786
|
if (node.attrs.htmlInline) {
|
|
@@ -21547,6 +23275,14 @@ function getPluginInfo(plugins, eventEmitter, usageStatistics) {
|
|
|
21547
23275
|
var TASK_ATTR_NAME = 'data-task';
|
|
21548
23276
|
var DISABLED_TASK_ATTR_NAME = 'data-task-disabled';
|
|
21549
23277
|
var TASK_CHECKED_CLASS_NAME = 'checked';
|
|
23278
|
+
function registerHTMLTagToWhitelist(convertorMap) {
|
|
23279
|
+
['htmlBlock', 'htmlInline'].forEach(function (htmlType) {
|
|
23280
|
+
if (convertorMap[htmlType]) {
|
|
23281
|
+
// register tag white list for preventing to remove the html in sanitizer
|
|
23282
|
+
Object.keys(convertorMap[htmlType]).forEach(function (type) { return registerTagWhitelistIfPossible(type); });
|
|
23283
|
+
}
|
|
23284
|
+
});
|
|
23285
|
+
}
|
|
21550
23286
|
/**
|
|
21551
23287
|
* Class ToastUIEditorViewer
|
|
21552
23288
|
* @param {object} options Option object
|
|
@@ -21592,6 +23328,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
|
|
|
21592
23328
|
frontMatter: frontMatter,
|
|
21593
23329
|
sanitizer: customHTMLSanitizer || sanitizeHTML,
|
|
21594
23330
|
};
|
|
23331
|
+
registerHTMLTagToWhitelist(rendererOptions.customHTMLRenderer);
|
|
21595
23332
|
if (this.options.events) {
|
|
21596
23333
|
forEachOwnProperties_default()(this.options.events, function (fn, key) {
|
|
21597
23334
|
_this.on(key, fn);
|
|
@@ -21612,7 +23349,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
|
|
|
21612
23349
|
customParser: markdownParsers,
|
|
21613
23350
|
});
|
|
21614
23351
|
this.preview = new mdPreview(this.eventEmitter, __assign(__assign({}, rendererOptions), { isViewer: true }));
|
|
21615
|
-
on_default()(this.preview.
|
|
23352
|
+
on_default()(this.preview.previewContent, 'mousedown', this.toggleTask.bind(this));
|
|
21616
23353
|
if (initialValue) {
|
|
21617
23354
|
this.setMarkdown(initialValue);
|
|
21618
23355
|
}
|
|
@@ -21745,7 +23482,7 @@ function createMdLikeNode(node) {
|
|
|
21745
23482
|
};
|
|
21746
23483
|
var nodeTypeMap = {
|
|
21747
23484
|
heading: { level: attrs.level },
|
|
21748
|
-
link: { destination: attrs.linkUrl, title: attrs.
|
|
23485
|
+
link: { destination: attrs.linkUrl, title: attrs.title },
|
|
21749
23486
|
image: { destination: attrs.imageUrl },
|
|
21750
23487
|
codeBlock: { info: attrs.language },
|
|
21751
23488
|
bulletList: { type: 'list', listData: { type: 'bullet' } },
|
|
@@ -21898,6 +23635,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21898
23635
|
this.latestPreviewScrollTop = null;
|
|
21899
23636
|
this.blockedScroll = null;
|
|
21900
23637
|
this.active = true;
|
|
23638
|
+
this.timer = null;
|
|
21901
23639
|
var previewRoot = preview.previewContent, previewEl = preview.el;
|
|
21902
23640
|
this.previewRoot = previewRoot;
|
|
21903
23641
|
this.previewEl = previewEl;
|
|
@@ -21910,10 +23648,11 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21910
23648
|
ScrollSync.prototype.addScrollSyncEvent = function () {
|
|
21911
23649
|
var _this = this;
|
|
21912
23650
|
this.eventEmitter.listen('afterPreviewRender', function () {
|
|
23651
|
+
_this.clearTimer();
|
|
21913
23652
|
// Immediately after the 'afterPreviewRender' event has occurred,
|
|
21914
23653
|
// browser rendering is not yet complete.
|
|
21915
23654
|
// So the size of elements can not be accurately measured.
|
|
21916
|
-
setTimeout(function () {
|
|
23655
|
+
_this.timer = setTimeout(function () {
|
|
21917
23656
|
_this.syncPreviewScrollTop(true);
|
|
21918
23657
|
}, 200);
|
|
21919
23658
|
});
|
|
@@ -21940,7 +23679,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21940
23679
|
var pos = this.mdEditor.getSelection();
|
|
21941
23680
|
var firstMdNode = this.toastMark.findFirstNodeAtLine(pos[0][0]);
|
|
21942
23681
|
var previewHeight = this.previewEl.clientHeight;
|
|
21943
|
-
var el = getParentNodeObj(firstMdNode).el;
|
|
23682
|
+
var el = getParentNodeObj(this.previewRoot, firstMdNode).el;
|
|
21944
23683
|
var totalOffsetTop = getTotalOffsetTop(el, this.previewRoot) || el.offsetTop;
|
|
21945
23684
|
var nodeHeight = el.clientHeight;
|
|
21946
23685
|
// multiply 0.5 for calculating the position in the middle of preview area
|
|
@@ -21972,7 +23711,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21972
23711
|
targetScrollTop = scrollTopByEditing;
|
|
21973
23712
|
}
|
|
21974
23713
|
else {
|
|
21975
|
-
var _d = getParentNodeObj(firstMdNode), el = _d.el, mdNode = _d.mdNode;
|
|
23714
|
+
var _d = getParentNodeObj(this.previewRoot, firstMdNode), el = _d.el, mdNode = _d.mdNode;
|
|
21976
23715
|
var _e = getEditorRangeHeightInfo(doc, mdNode, children), height = _e.height, rect = _e.rect;
|
|
21977
23716
|
var totalOffsetTop = getTotalOffsetTop(el, previewRoot) || el.offsetTop;
|
|
21978
23717
|
var nodeHeight = el.clientHeight;
|
|
@@ -22000,7 +23739,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
22000
23739
|
}
|
|
22001
23740
|
var children = dom.children;
|
|
22002
23741
|
var mdNodeId = Number(targetNode.getAttribute('data-nodeid'));
|
|
22003
|
-
var _b = getParentNodeObj(toastMark.findNodeById(mdNodeId)), mdNode = _b.mdNode, el = _b.el;
|
|
23742
|
+
var _b = getParentNodeObj(this.previewRoot, toastMark.findNodeById(mdNodeId)), mdNode = _b.mdNode, el = _b.el;
|
|
22004
23743
|
var mdNodeStartLine = getMdStartLine(mdNode);
|
|
22005
23744
|
targetScrollTop = children[mdNodeStartLine - 1].offsetTop;
|
|
22006
23745
|
var height = getEditorRangeHeightInfo(state.doc, mdNode, children).height;
|
|
@@ -22039,7 +23778,14 @@ var ScrollSync = /** @class */ (function () {
|
|
|
22039
23778
|
};
|
|
22040
23779
|
animate(curScrollTop, targetScrollTop, syncCallbacks);
|
|
22041
23780
|
};
|
|
23781
|
+
ScrollSync.prototype.clearTimer = function () {
|
|
23782
|
+
if (this.timer) {
|
|
23783
|
+
clearTimeout(this.timer);
|
|
23784
|
+
this.timer = null;
|
|
23785
|
+
}
|
|
23786
|
+
};
|
|
22042
23787
|
ScrollSync.prototype.destroy = function () {
|
|
23788
|
+
this.clearTimer();
|
|
22043
23789
|
this.eventEmitter.removeEventHandler('scroll');
|
|
22044
23790
|
this.eventEmitter.removeEventHandler('afterPreviewRender');
|
|
22045
23791
|
};
|
|
@@ -22047,6 +23793,19 @@ var ScrollSync = /** @class */ (function () {
|
|
|
22047
23793
|
}());
|
|
22048
23794
|
|
|
22049
23795
|
|
|
23796
|
+
;// CONCATENATED MODULE: ./src/queries/queryManager.ts
|
|
23797
|
+
var queryMap = {
|
|
23798
|
+
getPopupInitialValues: function (editor, payload) {
|
|
23799
|
+
var popupName = payload.popupName;
|
|
23800
|
+
return popupName === 'link' ? { linkText: editor.getSelectedText() } : {};
|
|
23801
|
+
},
|
|
23802
|
+
};
|
|
23803
|
+
function buildQuery(editor) {
|
|
23804
|
+
editor.eventEmitter.listen('query', function (query, payload) {
|
|
23805
|
+
return queryMap[query](editor, payload);
|
|
23806
|
+
});
|
|
23807
|
+
}
|
|
23808
|
+
|
|
22050
23809
|
;// CONCATENATED MODULE: ./src/editorCore.ts
|
|
22051
23810
|
|
|
22052
23811
|
|
|
@@ -22074,6 +23833,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
22074
23833
|
|
|
22075
23834
|
|
|
22076
23835
|
|
|
23836
|
+
|
|
22077
23837
|
|
|
22078
23838
|
|
|
22079
23839
|
/**
|
|
@@ -22115,11 +23875,12 @@ var ScrollSync = /** @class */ (function () {
|
|
|
22115
23875
|
* @param {boolean} [options.frontMatter=false] - whether use the front matter
|
|
22116
23876
|
* @param {Array.<object>} [options.widgetRules=[]] - The rules for replacing the text with widget node
|
|
22117
23877
|
* @param {string} [options.theme] - The theme to style the editor with. The default is included in toastui-editor.css.
|
|
23878
|
+
* @param {autofocus} [options.autofocus=true] - automatically focus the editor on creation.
|
|
22118
23879
|
*/
|
|
22119
23880
|
var ToastUIEditorCore = /** @class */ (function () {
|
|
22120
23881
|
function ToastUIEditorCore(options) {
|
|
22121
23882
|
var _this = this;
|
|
22122
|
-
this.
|
|
23883
|
+
this.initialHTML = options.el.innerHTML;
|
|
22123
23884
|
options.el.innerHTML = '';
|
|
22124
23885
|
this.options = extend_default()({
|
|
22125
23886
|
previewStyle: 'tab',
|
|
@@ -22148,10 +23909,13 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22148
23909
|
frontMatter: false,
|
|
22149
23910
|
widgetRules: [],
|
|
22150
23911
|
theme: 'light',
|
|
23912
|
+
autofocus: true,
|
|
22151
23913
|
}, options);
|
|
22152
23914
|
var _a = this.options, customHTMLRenderer = _a.customHTMLRenderer, extendedAutolinks = _a.extendedAutolinks, referenceDefinition = _a.referenceDefinition, frontMatter = _a.frontMatter, customMarkdownRenderer = _a.customMarkdownRenderer, useCommandShortcut = _a.useCommandShortcut, initialEditType = _a.initialEditType, widgetRules = _a.widgetRules, customHTMLSanitizer = _a.customHTMLSanitizer;
|
|
22153
23915
|
this.mode = initialEditType || 'markdown';
|
|
22154
23916
|
this.mdPreviewStyle = this.options.previewStyle;
|
|
23917
|
+
this.i18n = i18n;
|
|
23918
|
+
this.i18n.setCode(this.options.language);
|
|
22155
23919
|
this.eventEmitter = new eventEmitter();
|
|
22156
23920
|
setWidgetRules(widgetRules);
|
|
22157
23921
|
var linkAttributes = sanitizeLinkAttribute(this.options.linkAttributes);
|
|
@@ -22167,8 +23931,6 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22167
23931
|
};
|
|
22168
23932
|
var wwToDOMAdaptor = new WwToDOMAdaptor(linkAttributes, rendererOptions.customHTMLRenderer);
|
|
22169
23933
|
var htmlSchemaMap = createHTMLSchemaMap(rendererOptions.customHTMLRenderer, rendererOptions.sanitizer, wwToDOMAdaptor);
|
|
22170
|
-
this.i18n = i18n;
|
|
22171
|
-
this.i18n.setCode(this.options.language);
|
|
22172
23934
|
this.toastMark = new ToastMark('', {
|
|
22173
23935
|
disallowedHtmlBlockTags: ['br', 'img'],
|
|
22174
23936
|
extendedAutolinks: extendedAutolinks,
|
|
@@ -22199,7 +23961,7 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22199
23961
|
this.setPlaceholder(this.options.placeholder);
|
|
22200
23962
|
}
|
|
22201
23963
|
if (!this.options.initialValue) {
|
|
22202
|
-
this.setHTML(this.
|
|
23964
|
+
this.setHTML(this.initialHTML, false);
|
|
22203
23965
|
}
|
|
22204
23966
|
this.commandManager = new commandManager(this.eventEmitter, this.mdEditor.commands, this.wwEditor.commands, function () { return _this.mode; });
|
|
22205
23967
|
if (this.options.usageStatistics) {
|
|
@@ -22208,6 +23970,7 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22208
23970
|
this.scrollSync = new ScrollSync(this.mdEditor, this.preview, this.eventEmitter);
|
|
22209
23971
|
this.addInitEvent();
|
|
22210
23972
|
this.addInitCommand(mdCommands, wwCommands);
|
|
23973
|
+
buildQuery(this);
|
|
22211
23974
|
if (this.options.hooks) {
|
|
22212
23975
|
forEachOwnProperties_default()(this.options.hooks, function (fn, key) { return _this.addHook(key, fn); });
|
|
22213
23976
|
}
|
|
@@ -22215,10 +23978,18 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22215
23978
|
forEachOwnProperties_default()(this.options.events, function (fn, key) { return _this.on(key, fn); });
|
|
22216
23979
|
}
|
|
22217
23980
|
this.eventEmitter.emit('load', this);
|
|
22218
|
-
this.moveCursorToStart();
|
|
23981
|
+
this.moveCursorToStart(this.options.autofocus);
|
|
22219
23982
|
}
|
|
22220
23983
|
ToastUIEditorCore.prototype.addInitEvent = function () {
|
|
23984
|
+
var _this = this;
|
|
22221
23985
|
this.on('needChangeMode', this.changeMode.bind(this));
|
|
23986
|
+
this.on('loadUI', function () {
|
|
23987
|
+
if (_this.height !== 'auto') {
|
|
23988
|
+
// 75px equals default editor ui height - the editing area height
|
|
23989
|
+
var minHeight = Math.min(parseInt(_this.minHeight, 10), parseInt(_this.height, 10) - 75) + "px";
|
|
23990
|
+
_this.setMinHeight(minHeight);
|
|
23991
|
+
}
|
|
23992
|
+
});
|
|
22222
23993
|
addDefaultImageBlobHook(this.eventEmitter);
|
|
22223
23994
|
};
|
|
22224
23995
|
ToastUIEditorCore.prototype.addInitCommand = function (mdCommands, wwCommands) {
|
|
@@ -22331,15 +24102,19 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22331
24102
|
};
|
|
22332
24103
|
/**
|
|
22333
24104
|
* Set cursor position to end
|
|
24105
|
+
* @param {boolean} [focus] - automatically focus the editor
|
|
22334
24106
|
*/
|
|
22335
|
-
ToastUIEditorCore.prototype.moveCursorToEnd = function () {
|
|
22336
|
-
|
|
24107
|
+
ToastUIEditorCore.prototype.moveCursorToEnd = function (focus) {
|
|
24108
|
+
if (focus === void 0) { focus = true; }
|
|
24109
|
+
this.getCurrentModeEditor().moveCursorToEnd(focus);
|
|
22337
24110
|
};
|
|
22338
24111
|
/**
|
|
22339
24112
|
* Set cursor position to start
|
|
24113
|
+
* @param {boolean} [focus] - automatically focus the editor
|
|
22340
24114
|
*/
|
|
22341
|
-
ToastUIEditorCore.prototype.moveCursorToStart = function () {
|
|
22342
|
-
|
|
24115
|
+
ToastUIEditorCore.prototype.moveCursorToStart = function (focus) {
|
|
24116
|
+
if (focus === void 0) { focus = true; }
|
|
24117
|
+
this.getCurrentModeEditor().moveCursorToStart(focus);
|
|
22343
24118
|
};
|
|
22344
24119
|
/**
|
|
22345
24120
|
* Set markdown syntax text.
|
|
@@ -22392,16 +24167,13 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22392
24167
|
ToastUIEditorCore.prototype.getHTML = function () {
|
|
22393
24168
|
var _this = this;
|
|
22394
24169
|
this.eventEmitter.holdEventInvoke(function () {
|
|
22395
|
-
if (_this.
|
|
22396
|
-
_this.
|
|
24170
|
+
if (_this.isMarkdownMode()) {
|
|
24171
|
+
var mdNode = _this.toastMark.getRootNode();
|
|
24172
|
+
var wwNode = _this.convertor.toWysiwygModel(mdNode);
|
|
24173
|
+
_this.wwEditor.setModel(wwNode);
|
|
22397
24174
|
}
|
|
22398
24175
|
});
|
|
22399
|
-
|
|
22400
|
-
var mdRenderer = this.preview.getRenderer();
|
|
22401
|
-
return mdRenderer
|
|
22402
|
-
.render(mdNode)
|
|
22403
|
-
.replace(/\sdata-nodeid="\d{1,}"/g, '')
|
|
22404
|
-
.trim();
|
|
24176
|
+
return this.wwEditor.view.dom.innerHTML;
|
|
22405
24177
|
};
|
|
22406
24178
|
/**
|
|
22407
24179
|
* Insert text
|
|
@@ -22489,12 +24261,11 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22489
24261
|
if (isString_default()(height)) {
|
|
22490
24262
|
if (height === 'auto') {
|
|
22491
24263
|
addClass_default()(el, 'auto-height');
|
|
22492
|
-
this.setMinHeight(this.getMinHeight());
|
|
22493
24264
|
}
|
|
22494
24265
|
else {
|
|
22495
24266
|
removeClass_default()(el, 'auto-height');
|
|
22496
|
-
this.setMinHeight(height);
|
|
22497
24267
|
}
|
|
24268
|
+
this.setMinHeight(this.getMinHeight());
|
|
22498
24269
|
}
|
|
22499
24270
|
css_default()(el, { height: height });
|
|
22500
24271
|
this.height = height;
|
|
@@ -22511,16 +24282,18 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22511
24282
|
* @param {string} minHeight - min content height in pixel
|
|
22512
24283
|
*/
|
|
22513
24284
|
ToastUIEditorCore.prototype.setMinHeight = function (minHeight) {
|
|
22514
|
-
|
|
22515
|
-
|
|
22516
|
-
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
|
|
22520
|
-
|
|
22521
|
-
|
|
22522
|
-
|
|
22523
|
-
|
|
24285
|
+
if (minHeight !== this.minHeight) {
|
|
24286
|
+
var height = this.height || this.options.height;
|
|
24287
|
+
if (height !== 'auto' && this.options.el.querySelector("." + cls('main'))) {
|
|
24288
|
+
// 75px equals default editor ui height - the editing area height
|
|
24289
|
+
minHeight = Math.min(parseInt(minHeight, 10), parseInt(height, 10) - 75) + "px";
|
|
24290
|
+
}
|
|
24291
|
+
var minHeightNum = parseInt(minHeight, 10);
|
|
24292
|
+
this.minHeight = minHeight;
|
|
24293
|
+
this.wwEditor.setMinHeight(minHeightNum);
|
|
24294
|
+
this.mdEditor.setMinHeight(minHeightNum);
|
|
24295
|
+
this.preview.setMinHeight(minHeightNum);
|
|
24296
|
+
}
|
|
22524
24297
|
};
|
|
22525
24298
|
/**
|
|
22526
24299
|
* Get minimum height of editor content
|
|
@@ -24467,15 +26240,17 @@ var tablePopupBody_templateObject_1, tablePopupBody_templateObject_2, templateOb
|
|
|
24467
26240
|
|
|
24468
26241
|
var CustomPopupBody = /** @class */ (function (_super) {
|
|
24469
26242
|
__extends(CustomPopupBody, _super);
|
|
24470
|
-
function CustomPopupBody(
|
|
24471
|
-
|
|
24472
|
-
props.eventEmitter.listen('closePopup', _this.props.hidePopup);
|
|
24473
|
-
return _this;
|
|
26243
|
+
function CustomPopupBody() {
|
|
26244
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24474
26245
|
}
|
|
24475
26246
|
CustomPopupBody.prototype.mounted = function () {
|
|
24476
26247
|
// append the custom popup body element
|
|
24477
26248
|
this.refs.el.appendChild(this.props.body);
|
|
24478
26249
|
};
|
|
26250
|
+
CustomPopupBody.prototype.updated = function (prevProps) {
|
|
26251
|
+
// update custom popup element
|
|
26252
|
+
this.refs.el.replaceChild(this.props.body, prevProps.body);
|
|
26253
|
+
};
|
|
24479
26254
|
CustomPopupBody.prototype.render = function () {
|
|
24480
26255
|
var _this = this;
|
|
24481
26256
|
return template(customPopupBody_templateObject_1 || (customPopupBody_templateObject_1 = __makeTemplateObject(["<div ref=", "></div>"], ["<div ref=", "></div>"])), function (el) { return (_this.refs.el = el); });
|
|
@@ -24658,6 +26433,7 @@ function createDefaultToolbarItemInfo(type) {
|
|
|
24658
26433
|
className: 'indent',
|
|
24659
26434
|
command: 'indent',
|
|
24660
26435
|
tooltip: i18n.get('Indent'),
|
|
26436
|
+
state: 'indent',
|
|
24661
26437
|
};
|
|
24662
26438
|
break;
|
|
24663
26439
|
case 'outdent':
|
|
@@ -24666,6 +26442,7 @@ function createDefaultToolbarItemInfo(type) {
|
|
|
24666
26442
|
className: 'outdent',
|
|
24667
26443
|
command: 'outdent',
|
|
24668
26444
|
tooltip: i18n.get('Outdent'),
|
|
26445
|
+
state: 'outdent',
|
|
24669
26446
|
};
|
|
24670
26447
|
break;
|
|
24671
26448
|
case 'scrollSync':
|
|
@@ -24773,6 +26550,7 @@ var Popup = /** @class */ (function (_super) {
|
|
|
24773
26550
|
}
|
|
24774
26551
|
Popup.prototype.mounted = function () {
|
|
24775
26552
|
document.addEventListener('mousedown', this.handleMousedown);
|
|
26553
|
+
this.props.eventEmitter.listen('closePopup', this.props.hidePopup);
|
|
24776
26554
|
};
|
|
24777
26555
|
Popup.prototype.beforeDestroy = function () {
|
|
24778
26556
|
document.removeEventListener('mousedown', this.handleMousedown);
|
|
@@ -24829,7 +26607,7 @@ function connectHOC(WrappedComponent) {
|
|
|
24829
26607
|
_this.hideTooltip = function () {
|
|
24830
26608
|
css_default()(_this.props.tooltipRef.current, 'display', 'none');
|
|
24831
26609
|
};
|
|
24832
|
-
_this.state = { active: false };
|
|
26610
|
+
_this.state = { active: false, disabled: props.disabled };
|
|
24833
26611
|
_this.addEvent();
|
|
24834
26612
|
return _this;
|
|
24835
26613
|
}
|
|
@@ -24838,9 +26616,10 @@ function connectHOC(WrappedComponent) {
|
|
|
24838
26616
|
var _a = this.props, item = _a.item, eventEmitter = _a.eventEmitter;
|
|
24839
26617
|
if (item.state) {
|
|
24840
26618
|
eventEmitter.listen('changeToolbarState', function (_a) {
|
|
26619
|
+
var _b;
|
|
24841
26620
|
var toolbarState = _a.toolbarState;
|
|
24842
|
-
var
|
|
24843
|
-
_this.setState({ active: active });
|
|
26621
|
+
var _c = (_b = toolbarState[item.state]) !== null && _b !== void 0 ? _b : {}, active = _c.active, disabled = _c.disabled;
|
|
26622
|
+
_this.setState({ active: !!active, disabled: disabled !== null && disabled !== void 0 ? disabled : _this.props.disabled });
|
|
24844
26623
|
});
|
|
24845
26624
|
}
|
|
24846
26625
|
};
|
|
@@ -24849,7 +26628,7 @@ function connectHOC(WrappedComponent) {
|
|
|
24849
26628
|
return { left: offsetLeft, top: el.offsetHeight + offsetTop };
|
|
24850
26629
|
};
|
|
24851
26630
|
ButtonHOC.prototype.render = function () {
|
|
24852
|
-
return template(buttonHoc_templateObject_1 || (buttonHoc_templateObject_1 = __makeTemplateObject(["\n <", "\n ...", "\n active=", "\n showTooltip=", "\n hideTooltip=", "\n getBound=", "\n />\n "], ["\n <", "\n ...", "\n active=", "\n showTooltip=", "\n hideTooltip=", "\n getBound=", "\n />\n "])), WrappedComponent, this.props, this.state.active, this.showTooltip, this.hideTooltip, this.getBound);
|
|
26631
|
+
return template(buttonHoc_templateObject_1 || (buttonHoc_templateObject_1 = __makeTemplateObject(["\n <", "\n ...", "\n active=", "\n showTooltip=", "\n hideTooltip=", "\n getBound=", "\n disabled=", "\n />\n "], ["\n <", "\n ...", "\n active=", "\n showTooltip=", "\n hideTooltip=", "\n getBound=", "\n disabled=", "\n />\n "])), WrappedComponent, this.props, this.state.active, this.showTooltip, this.hideTooltip, this.getBound, this.state.disabled || this.props.disabled);
|
|
24853
26632
|
};
|
|
24854
26633
|
return ButtonHOC;
|
|
24855
26634
|
}(Component));
|
|
@@ -24872,17 +26651,19 @@ var ToolbarButtonComp = /** @class */ (function (_super) {
|
|
|
24872
26651
|
_this.props.showTooltip(_this.refs.el);
|
|
24873
26652
|
};
|
|
24874
26653
|
_this.execCommand = function () {
|
|
24875
|
-
var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound;
|
|
26654
|
+
var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound, eventEmitter = _a.eventEmitter;
|
|
24876
26655
|
var command = item.command, name = item.name, popup = item.popup;
|
|
24877
26656
|
if (command) {
|
|
24878
26657
|
execCommand(command);
|
|
24879
26658
|
}
|
|
24880
26659
|
else {
|
|
24881
26660
|
var popupName = popup ? 'customPopupBody' : name;
|
|
26661
|
+
var initialValues = eventEmitter.emit('query', 'getPopupInitialValues', { popupName: popupName })[0];
|
|
24882
26662
|
var info = createPopupInfo(popupName, {
|
|
24883
26663
|
el: _this.refs.el,
|
|
24884
26664
|
pos: getBound(_this.refs.el),
|
|
24885
26665
|
popup: popup,
|
|
26666
|
+
initialValues: initialValues,
|
|
24886
26667
|
});
|
|
24887
26668
|
if (info) {
|
|
24888
26669
|
setPopupInfo(info);
|
|
@@ -25102,7 +26883,7 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
25102
26883
|
};
|
|
25103
26884
|
_this.openPopup = function (popupName, initialValues) {
|
|
25104
26885
|
if (initialValues === void 0) { initialValues = {}; }
|
|
25105
|
-
var el =
|
|
26886
|
+
var el = _this.refs.el.querySelector("." + cls('toolbar-group') + " ." + popupName);
|
|
25106
26887
|
if (el) {
|
|
25107
26888
|
var _a = getTotalOffset(el, closest(el, "." + cls('toolbar'))), offsetLeft = _a.offsetLeft, offsetTop = _a.offsetTop;
|
|
25108
26889
|
var info = createPopupInfo(popupName, {
|
|
@@ -25250,7 +27031,7 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
25250
27031
|
};
|
|
25251
27032
|
Toolbar.prototype.mounted = function () {
|
|
25252
27033
|
if (this.props.previewStyle === 'tab') {
|
|
25253
|
-
this.props.eventEmitter.emit('changePreviewTabWrite');
|
|
27034
|
+
this.props.eventEmitter.emit('changePreviewTabWrite', true);
|
|
25254
27035
|
}
|
|
25255
27036
|
// classify toolbar and dropdown toolbar after DOM has been rendered
|
|
25256
27037
|
this.setState(this.classifyToolbarItems());
|
|
@@ -25468,6 +27249,7 @@ var ToastUIEditor = /** @class */ (function (_super) {
|
|
|
25468
27249
|
var groupIndex = toolbarItem.groupIndex, itemIndex = toolbarItem.itemIndex, item = toolbarItem.item;
|
|
25469
27250
|
_this.defaultUI.insertToolbarItem({ groupIndex: groupIndex, itemIndex: itemIndex }, item);
|
|
25470
27251
|
});
|
|
27252
|
+
_this.eventEmitter.emit('loadUI', _this);
|
|
25471
27253
|
return _this;
|
|
25472
27254
|
}
|
|
25473
27255
|
/**
|
|
@@ -25575,7 +27357,7 @@ editorCore.setLanguage(['en', 'en-US'], {
|
|
|
25575
27357
|
|
|
25576
27358
|
|
|
25577
27359
|
}();
|
|
25578
|
-
__webpack_exports__ = __webpack_exports__
|
|
27360
|
+
__webpack_exports__ = __webpack_exports__["default"];
|
|
25579
27361
|
/******/ return __webpack_exports__;
|
|
25580
27362
|
/******/ })()
|
|
25581
27363
|
;
|