@progress/kendo-editor-common 1.12.0-develop.1 → 1.12.1-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/js/kendo-editor-common.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/flatten-spans.js +12 -9
- package/dist/es/listConvert.js +2 -6
- package/dist/es/main.js +2 -2
- package/dist/es/paste.js +6 -8
- package/dist/es/source.js +19 -2
- package/dist/es/utils.js +1 -1
- package/dist/es2015/flatten-spans.js +12 -9
- package/dist/es2015/listConvert.js +2 -6
- package/dist/es2015/main.js +2 -2
- package/dist/es2015/paste.js +6 -8
- package/dist/es2015/source.js +19 -2
- package/dist/es2015/utils.js +1 -1
- package/dist/npm/flatten-spans.js +12 -9
- package/dist/npm/listConvert.js +2 -6
- package/dist/npm/main.d.ts +2 -2
- package/dist/npm/main.js +1 -1
- package/dist/npm/paste.d.ts +1 -5
- package/dist/npm/paste.js +5 -8
- package/dist/npm/source.d.ts +5 -1
- package/dist/npm/source.js +19 -1
- package/dist/npm/utils.js +1 -1
- package/package.json +1 -1
|
@@ -52,8 +52,7 @@ const getInnerSpan = (dom) => {
|
|
|
52
52
|
return dom.querySelector('span span');
|
|
53
53
|
};
|
|
54
54
|
const isEmptySpan = (fragment) => {
|
|
55
|
-
|
|
56
|
-
return fragment.childNodes.length === 1 && ((_a = fragment.firstChild) === null || _a === void 0 ? void 0 : _a.nodeName) === 'SPAN' && fragment.firstChild.childNodes.length === 0;
|
|
55
|
+
return fragment.childNodes.length === 1 && fragment.firstChild.nodeName === 'SPAN' && fragment.firstChild.childNodes.length === 0;
|
|
57
56
|
};
|
|
58
57
|
/**
|
|
59
58
|
* Flattens nested <span> elements in the given HTML string while preserving
|
|
@@ -63,7 +62,6 @@ const isEmptySpan = (fragment) => {
|
|
|
63
62
|
* @returns The normalized HTML content with flattened <span> elements.
|
|
64
63
|
*/
|
|
65
64
|
const flattenNestedSpans = (content) => {
|
|
66
|
-
var _a, _b, _c;
|
|
67
65
|
const dom = htmlToFragment(content);
|
|
68
66
|
let innerSpan = getInnerSpan(dom);
|
|
69
67
|
while (innerSpan) {
|
|
@@ -73,7 +71,8 @@ const flattenNestedSpans = (content) => {
|
|
|
73
71
|
const right = extractor.extractAfter(innerSpan);
|
|
74
72
|
const left = extractor.extractBefore(innerSpan);
|
|
75
73
|
for (let i = 0; i < innerSpan.style.length; i++) {
|
|
76
|
-
|
|
74
|
+
const prop = innerSpan.style.item(i);
|
|
75
|
+
parentSpan.style[prop] = innerSpan.style.getPropertyValue(prop);
|
|
77
76
|
}
|
|
78
77
|
innerSpan.removeAttribute('style');
|
|
79
78
|
if (innerSpan.classList.length) {
|
|
@@ -93,12 +92,16 @@ const flattenNestedSpans = (content) => {
|
|
|
93
92
|
while (innerSpan.firstChild && innerSpan.parentNode) {
|
|
94
93
|
innerSpan.parentNode.insertBefore(innerSpan.firstChild, innerSpan);
|
|
95
94
|
}
|
|
96
|
-
(
|
|
97
|
-
|
|
98
|
-
(_b = parentSpan.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(left, parentSpan);
|
|
95
|
+
if (innerSpan.parentNode) {
|
|
96
|
+
innerSpan.parentNode.removeChild(innerSpan);
|
|
99
97
|
}
|
|
100
|
-
if (
|
|
101
|
-
(
|
|
98
|
+
if (parentSpan.parentNode) {
|
|
99
|
+
if (!isEmptySpan(left)) {
|
|
100
|
+
parentSpan.parentNode.insertBefore(left, parentSpan);
|
|
101
|
+
}
|
|
102
|
+
if (!isEmptySpan(right)) {
|
|
103
|
+
parentSpan.parentNode.insertBefore(right, parentSpan.nextSibling);
|
|
104
|
+
}
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
innerSpan = getInnerSpan(dom);
|
|
@@ -11,10 +11,7 @@ const isPartOfListItem = (element) => {
|
|
|
11
11
|
return /^MsoListParagraph/.test(element.className);
|
|
12
12
|
};
|
|
13
13
|
const innerText = (node) => {
|
|
14
|
-
|
|
15
|
-
text = text.replace(/<!--(.|\s)*?-->/gi, '');
|
|
16
|
-
text = text.replace(/<\/?[^>]+?\/?>/gm, '');
|
|
17
|
-
return text;
|
|
14
|
+
return node.textContent;
|
|
18
15
|
};
|
|
19
16
|
const createList = (type, styleType) => {
|
|
20
17
|
const list = document.createElement(type);
|
|
@@ -68,11 +65,10 @@ const mapListsCandidates = (nodes, groups) => {
|
|
|
68
65
|
});
|
|
69
66
|
};
|
|
70
67
|
const listTypes = (p) => {
|
|
71
|
-
|
|
68
|
+
const html = p.textContent;
|
|
72
69
|
const trimStartText = (t) => {
|
|
73
70
|
return t.replace(/^(?: |[\u00a0\n\r\s])+/, '');
|
|
74
71
|
};
|
|
75
|
-
html = html.replace(/<\/?\w+[^>]*>/g, '').replace(/ /g, '\u00a0');
|
|
76
72
|
if ((/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(html))) {
|
|
77
73
|
return {
|
|
78
74
|
tag: 'ul',
|
package/dist/es2015/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, setHtml, trimWhitespace } from './source.js';
|
|
1
|
+
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, removeComments, setHtml, trimWhitespace } from './source.js';
|
|
2
2
|
export { flattenNestedSpans } from './flatten-spans.js';
|
|
3
3
|
export { applyInlineStyle, getInlineStyles, toggleInlineFormat } from './inline-style.js';
|
|
4
4
|
export { applyLink, removeLink } from './link.js';
|
|
@@ -17,7 +17,7 @@ export { indentRules, outdentRules } from './config/indent-rules.js';
|
|
|
17
17
|
export { marks, nodes } from './config/schema.js';
|
|
18
18
|
export { buildKeymap, buildListKeymap } from './config/keymap.js';
|
|
19
19
|
export { bold, italic, link, strikethrough, subscript, superscript, underline } from './config/commands.js';
|
|
20
|
-
export { pasteCleanup, removeAttribute,
|
|
20
|
+
export { pasteCleanup, removeAttribute, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr } from './paste.js';
|
|
21
21
|
export { convertMsLists } from './listConvert.js';
|
|
22
22
|
export { find, findAll, findAt, replace, replaceAll } from './find-replace.js';
|
|
23
23
|
export { placeholder } from './plugins/placeholder.js';
|
package/dist/es2015/paste.js
CHANGED
|
@@ -10,7 +10,11 @@ const sanitize = (html) => {
|
|
|
10
10
|
html = html.replace(/<\/?[ovw]:[^>]*?>/gi, ''); // MS elements, e.g. <o:p>, <w:sdtPr>, <v:
|
|
11
11
|
html = html.replace(/<\\?\??xml[^>]*>/gi, ''); // XML namespaces
|
|
12
12
|
html = html.replace(/<(?:link|meta) [^>]+?>/ig, '');
|
|
13
|
-
|
|
13
|
+
let previousHtml;
|
|
14
|
+
do {
|
|
15
|
+
previousHtml = html;
|
|
16
|
+
html = html.replace(/<style[^>]*?>\s*<\/style>/ig, '');
|
|
17
|
+
} while (html !== previousHtml);
|
|
14
18
|
html = html.replace(/<\/?st1:.*?>/gi, '');
|
|
15
19
|
html = html.replace(/<a name="[a-zA-Z0-9_]+">/gmi, '');
|
|
16
20
|
html = html.replace(/v:shapes?="[^"]+"/ig, '');
|
|
@@ -18,12 +22,6 @@ const sanitize = (html) => {
|
|
|
18
22
|
html = html.replace(/<!\[endif\]>/ig, '');
|
|
19
23
|
return html;
|
|
20
24
|
};
|
|
21
|
-
/**
|
|
22
|
-
* Removes comments in HTML.
|
|
23
|
-
*/
|
|
24
|
-
const removeComments = (html) => {
|
|
25
|
-
return html.replace(/<!--[\s\S]+?-->/g, '');
|
|
26
|
-
};
|
|
27
25
|
/**
|
|
28
26
|
* Removes the specified tag(s).
|
|
29
27
|
*/
|
|
@@ -161,4 +159,4 @@ const replaceImageSourcesFromRtf = (html, clipboardData) => {
|
|
|
161
159
|
});
|
|
162
160
|
};
|
|
163
161
|
|
|
164
|
-
export { pasteCleanup, removeAttribute,
|
|
162
|
+
export { pasteCleanup, removeAttribute, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr };
|
package/dist/es2015/source.js
CHANGED
|
@@ -157,7 +157,7 @@ const htmlToFragment = (html) => {
|
|
|
157
157
|
const template = document.createElement('template');
|
|
158
158
|
template.innerHTML = replaceStyleAttr(html);
|
|
159
159
|
restoreStyleAttr(template.content);
|
|
160
|
-
return template.content;
|
|
160
|
+
return template.content.cloneNode(true);
|
|
161
161
|
};
|
|
162
162
|
/**
|
|
163
163
|
* @hidden
|
|
@@ -230,5 +230,22 @@ const hasSameMarkup = (dom1, dom2, schema, parseOptions) => {
|
|
|
230
230
|
const fragment2 = Fragment.from(parseContent(dom2, schema, parseOptions));
|
|
231
231
|
return fragment1.eq(fragment2);
|
|
232
232
|
};
|
|
233
|
+
/**
|
|
234
|
+
* Removes comments in HTML.
|
|
235
|
+
*/
|
|
236
|
+
const removeComments = (html) => {
|
|
237
|
+
const fragment = htmlToFragment(html);
|
|
238
|
+
removeCommentsFromDom(fragment);
|
|
239
|
+
return fragmentToHtml(fragment);
|
|
240
|
+
};
|
|
241
|
+
const removeCommentsFromDom = (dom) => {
|
|
242
|
+
var _a;
|
|
243
|
+
const iterator = dom.ownerDocument.createNodeIterator(dom, NodeFilter.SHOW_COMMENT);
|
|
244
|
+
let commentNode = iterator.nextNode();
|
|
245
|
+
while (commentNode) {
|
|
246
|
+
(_a = commentNode.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(commentNode);
|
|
247
|
+
commentNode = iterator.nextNode();
|
|
248
|
+
}
|
|
249
|
+
};
|
|
233
250
|
|
|
234
|
-
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, setHtml, trimWhitespace };
|
|
251
|
+
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, removeComments, setHtml, trimWhitespace };
|
package/dist/es2015/utils.js
CHANGED
|
@@ -265,7 +265,7 @@ const applyStyle = (styleText, styleType, styleValue) => {
|
|
|
265
265
|
const setStyleAttr = (element, styleString) => {
|
|
266
266
|
const styles = parseStyle(styleString);
|
|
267
267
|
for (const style in styles) {
|
|
268
|
-
if (style &&
|
|
268
|
+
if (style && element.style[style] !== undefined) {
|
|
269
269
|
element.style[style] = styles[style];
|
|
270
270
|
}
|
|
271
271
|
}
|
|
@@ -54,8 +54,7 @@ const getInnerSpan = (dom) => {
|
|
|
54
54
|
return dom.querySelector('span span');
|
|
55
55
|
};
|
|
56
56
|
const isEmptySpan = (fragment) => {
|
|
57
|
-
|
|
58
|
-
return fragment.childNodes.length === 1 && ((_a = fragment.firstChild) === null || _a === void 0 ? void 0 : _a.nodeName) === 'SPAN' && fragment.firstChild.childNodes.length === 0;
|
|
57
|
+
return fragment.childNodes.length === 1 && fragment.firstChild.nodeName === 'SPAN' && fragment.firstChild.childNodes.length === 0;
|
|
59
58
|
};
|
|
60
59
|
/**
|
|
61
60
|
* Flattens nested <span> elements in the given HTML string while preserving
|
|
@@ -65,7 +64,6 @@ const isEmptySpan = (fragment) => {
|
|
|
65
64
|
* @returns The normalized HTML content with flattened <span> elements.
|
|
66
65
|
*/
|
|
67
66
|
const flattenNestedSpans = (content) => {
|
|
68
|
-
var _a, _b, _c;
|
|
69
67
|
const dom = source.htmlToFragment(content);
|
|
70
68
|
let innerSpan = getInnerSpan(dom);
|
|
71
69
|
while (innerSpan) {
|
|
@@ -75,7 +73,8 @@ const flattenNestedSpans = (content) => {
|
|
|
75
73
|
const right = extractor.extractAfter(innerSpan);
|
|
76
74
|
const left = extractor.extractBefore(innerSpan);
|
|
77
75
|
for (let i = 0; i < innerSpan.style.length; i++) {
|
|
78
|
-
|
|
76
|
+
const prop = innerSpan.style.item(i);
|
|
77
|
+
parentSpan.style[prop] = innerSpan.style.getPropertyValue(prop);
|
|
79
78
|
}
|
|
80
79
|
innerSpan.removeAttribute('style');
|
|
81
80
|
if (innerSpan.classList.length) {
|
|
@@ -95,12 +94,16 @@ const flattenNestedSpans = (content) => {
|
|
|
95
94
|
while (innerSpan.firstChild && innerSpan.parentNode) {
|
|
96
95
|
innerSpan.parentNode.insertBefore(innerSpan.firstChild, innerSpan);
|
|
97
96
|
}
|
|
98
|
-
(
|
|
99
|
-
|
|
100
|
-
(_b = parentSpan.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(left, parentSpan);
|
|
97
|
+
if (innerSpan.parentNode) {
|
|
98
|
+
innerSpan.parentNode.removeChild(innerSpan);
|
|
101
99
|
}
|
|
102
|
-
if (
|
|
103
|
-
(
|
|
100
|
+
if (parentSpan.parentNode) {
|
|
101
|
+
if (!isEmptySpan(left)) {
|
|
102
|
+
parentSpan.parentNode.insertBefore(left, parentSpan);
|
|
103
|
+
}
|
|
104
|
+
if (!isEmptySpan(right)) {
|
|
105
|
+
parentSpan.parentNode.insertBefore(right, parentSpan.nextSibling);
|
|
106
|
+
}
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
innerSpan = getInnerSpan(dom);
|
package/dist/npm/listConvert.js
CHANGED
|
@@ -13,10 +13,7 @@ const isPartOfListItem = (element) => {
|
|
|
13
13
|
return /^MsoListParagraph/.test(element.className);
|
|
14
14
|
};
|
|
15
15
|
const innerText = (node) => {
|
|
16
|
-
|
|
17
|
-
text = text.replace(/<!--(.|\s)*?-->/gi, '');
|
|
18
|
-
text = text.replace(/<\/?[^>]+?\/?>/gm, '');
|
|
19
|
-
return text;
|
|
16
|
+
return node.textContent;
|
|
20
17
|
};
|
|
21
18
|
const createList = (type, styleType) => {
|
|
22
19
|
const list = document.createElement(type);
|
|
@@ -70,11 +67,10 @@ const mapListsCandidates = (nodes, groups) => {
|
|
|
70
67
|
});
|
|
71
68
|
};
|
|
72
69
|
const listTypes = (p) => {
|
|
73
|
-
|
|
70
|
+
const html = p.textContent;
|
|
74
71
|
const trimStartText = (t) => {
|
|
75
72
|
return t.replace(/^(?: |[\u00a0\n\r\s])+/, '');
|
|
76
73
|
};
|
|
77
|
-
html = html.replace(/<\/?\w+[^>]*>/g, '').replace(/ /g, '\u00a0');
|
|
78
74
|
if ((/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(html))) {
|
|
79
75
|
return {
|
|
80
76
|
tag: 'ul',
|
package/dist/npm/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, setHtml, trimWhitespace } from './source.js';
|
|
1
|
+
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, removeComments, setHtml, trimWhitespace } from './source.js';
|
|
2
2
|
export { flattenNestedSpans } from './flatten-spans.js';
|
|
3
3
|
export { applyInlineStyle, getInlineStyles, toggleInlineFormat } from './inline-style.js';
|
|
4
4
|
export { applyLink, removeLink } from './link.js';
|
|
@@ -19,7 +19,7 @@ export { PasteCleanupSettings } from './types/paste-cleanup-settings.js';
|
|
|
19
19
|
export { marks, nodes } from './config/schema.js';
|
|
20
20
|
export { buildKeymap, buildListKeymap } from './config/keymap.js';
|
|
21
21
|
export { InlineFormatOptions, bold, italic, link, strikethrough, subscript, superscript, underline } from './config/commands.js';
|
|
22
|
-
export { pasteCleanup, removeAttribute,
|
|
22
|
+
export { pasteCleanup, removeAttribute, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr } from './paste.js';
|
|
23
23
|
export { convertMsLists } from './listConvert.js';
|
|
24
24
|
export { SearchOptions, find, findAll, findAt, replace, replaceAll } from './find-replace.js';
|
|
25
25
|
export { placeholder } from './plugins/placeholder.js';
|
package/dist/npm/main.js
CHANGED
|
@@ -54,6 +54,7 @@ exports.hasSameMarkup = source.hasSameMarkup;
|
|
|
54
54
|
exports.htmlToFragment = source.htmlToFragment;
|
|
55
55
|
exports.parseContent = source.parseContent;
|
|
56
56
|
exports.pmDocToFragment = source.pmDocToFragment;
|
|
57
|
+
exports.removeComments = source.removeComments;
|
|
57
58
|
exports.setHtml = source.setHtml;
|
|
58
59
|
exports.trimWhitespace = source.trimWhitespace;
|
|
59
60
|
exports.flattenNestedSpans = flattenSpans.flattenNestedSpans;
|
|
@@ -123,7 +124,6 @@ exports.superscript = commands.superscript;
|
|
|
123
124
|
exports.underline = commands.underline;
|
|
124
125
|
exports.pasteCleanup = paste.pasteCleanup;
|
|
125
126
|
exports.removeAttribute = paste.removeAttribute;
|
|
126
|
-
exports.removeComments = paste.removeComments;
|
|
127
127
|
exports.removeTag = paste.removeTag;
|
|
128
128
|
exports.replaceImageSourcesFromRtf = paste.replaceImageSourcesFromRtf;
|
|
129
129
|
exports.sanitize = paste.sanitize;
|
package/dist/npm/paste.d.ts
CHANGED
|
@@ -4,10 +4,6 @@ import { PasteCleanupSettings } from './types/paste-cleanup-settings.js';
|
|
|
4
4
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
5
5
|
*/
|
|
6
6
|
declare const sanitize: (html: string) => string;
|
|
7
|
-
/**
|
|
8
|
-
* Removes comments in HTML.
|
|
9
|
-
*/
|
|
10
|
-
declare const removeComments: (html: string) => string;
|
|
11
7
|
/**
|
|
12
8
|
* Removes the specified tag(s).
|
|
13
9
|
*/
|
|
@@ -39,4 +35,4 @@ declare const pasteCleanup: (html: string, settings: PasteCleanupSettings) => st
|
|
|
39
35
|
*/
|
|
40
36
|
declare const replaceImageSourcesFromRtf: (html: string, clipboardData: DataTransfer) => string;
|
|
41
37
|
|
|
42
|
-
export { pasteCleanup, removeAttribute,
|
|
38
|
+
export { pasteCleanup, removeAttribute, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr };
|
package/dist/npm/paste.js
CHANGED
|
@@ -12,7 +12,11 @@ const sanitize = (html) => {
|
|
|
12
12
|
html = html.replace(/<\/?[ovw]:[^>]*?>/gi, ''); // MS elements, e.g. <o:p>, <w:sdtPr>, <v:
|
|
13
13
|
html = html.replace(/<\\?\??xml[^>]*>/gi, ''); // XML namespaces
|
|
14
14
|
html = html.replace(/<(?:link|meta) [^>]+?>/ig, '');
|
|
15
|
-
|
|
15
|
+
let previousHtml;
|
|
16
|
+
do {
|
|
17
|
+
previousHtml = html;
|
|
18
|
+
html = html.replace(/<style[^>]*?>\s*<\/style>/ig, '');
|
|
19
|
+
} while (html !== previousHtml);
|
|
16
20
|
html = html.replace(/<\/?st1:.*?>/gi, '');
|
|
17
21
|
html = html.replace(/<a name="[a-zA-Z0-9_]+">/gmi, '');
|
|
18
22
|
html = html.replace(/v:shapes?="[^"]+"/ig, '');
|
|
@@ -20,12 +24,6 @@ const sanitize = (html) => {
|
|
|
20
24
|
html = html.replace(/<!\[endif\]>/ig, '');
|
|
21
25
|
return html;
|
|
22
26
|
};
|
|
23
|
-
/**
|
|
24
|
-
* Removes comments in HTML.
|
|
25
|
-
*/
|
|
26
|
-
const removeComments = (html) => {
|
|
27
|
-
return html.replace(/<!--[\s\S]+?-->/g, '');
|
|
28
|
-
};
|
|
29
27
|
/**
|
|
30
28
|
* Removes the specified tag(s).
|
|
31
29
|
*/
|
|
@@ -165,7 +163,6 @@ const replaceImageSourcesFromRtf = (html, clipboardData) => {
|
|
|
165
163
|
|
|
166
164
|
exports.pasteCleanup = pasteCleanup;
|
|
167
165
|
exports.removeAttribute = removeAttribute;
|
|
168
|
-
exports.removeComments = removeComments;
|
|
169
166
|
exports.removeTag = removeTag;
|
|
170
167
|
exports.replaceImageSourcesFromRtf = replaceImageSourcesFromRtf;
|
|
171
168
|
exports.sanitize = sanitize;
|
package/dist/npm/source.d.ts
CHANGED
|
@@ -73,5 +73,9 @@ declare const setHtml: (content: string, command?: string, parseOptions?: ParseO
|
|
|
73
73
|
* @hidden
|
|
74
74
|
*/
|
|
75
75
|
declare const hasSameMarkup: (dom1: string, dom2: string, schema: Schema, parseOptions?: ParseOptions) => boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Removes comments in HTML.
|
|
78
|
+
*/
|
|
79
|
+
declare const removeComments: (html: string) => string;
|
|
76
80
|
|
|
77
|
-
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, setHtml, trimWhitespace };
|
|
81
|
+
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, removeComments, setHtml, trimWhitespace };
|
package/dist/npm/source.js
CHANGED
|
@@ -159,7 +159,7 @@ const htmlToFragment = (html) => {
|
|
|
159
159
|
const template = document.createElement('template');
|
|
160
160
|
template.innerHTML = replaceStyleAttr(html);
|
|
161
161
|
restoreStyleAttr(template.content);
|
|
162
|
-
return template.content;
|
|
162
|
+
return template.content.cloneNode(true);
|
|
163
163
|
};
|
|
164
164
|
/**
|
|
165
165
|
* @hidden
|
|
@@ -232,6 +232,23 @@ const hasSameMarkup = (dom1, dom2, schema, parseOptions) => {
|
|
|
232
232
|
const fragment2 = prosemirrorModel.Fragment.from(parseContent(dom2, schema, parseOptions));
|
|
233
233
|
return fragment1.eq(fragment2);
|
|
234
234
|
};
|
|
235
|
+
/**
|
|
236
|
+
* Removes comments in HTML.
|
|
237
|
+
*/
|
|
238
|
+
const removeComments = (html) => {
|
|
239
|
+
const fragment = htmlToFragment(html);
|
|
240
|
+
removeCommentsFromDom(fragment);
|
|
241
|
+
return fragmentToHtml(fragment);
|
|
242
|
+
};
|
|
243
|
+
const removeCommentsFromDom = (dom) => {
|
|
244
|
+
var _a;
|
|
245
|
+
const iterator = dom.ownerDocument.createNodeIterator(dom, NodeFilter.SHOW_COMMENT);
|
|
246
|
+
let commentNode = iterator.nextNode();
|
|
247
|
+
while (commentNode) {
|
|
248
|
+
(_a = commentNode.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(commentNode);
|
|
249
|
+
commentNode = iterator.nextNode();
|
|
250
|
+
}
|
|
251
|
+
};
|
|
235
252
|
|
|
236
253
|
exports.domToPmDoc = domToPmDoc;
|
|
237
254
|
exports.fragmentToHtml = fragmentToHtml;
|
|
@@ -240,5 +257,6 @@ exports.hasSameMarkup = hasSameMarkup;
|
|
|
240
257
|
exports.htmlToFragment = htmlToFragment;
|
|
241
258
|
exports.parseContent = parseContent;
|
|
242
259
|
exports.pmDocToFragment = pmDocToFragment;
|
|
260
|
+
exports.removeComments = removeComments;
|
|
243
261
|
exports.setHtml = setHtml;
|
|
244
262
|
exports.trimWhitespace = trimWhitespace;
|
package/dist/npm/utils.js
CHANGED
|
@@ -267,7 +267,7 @@ const applyStyle = (styleText, styleType, styleValue) => {
|
|
|
267
267
|
const setStyleAttr = (element, styleString) => {
|
|
268
268
|
const styles = parseStyle(styleString);
|
|
269
269
|
for (const style in styles) {
|
|
270
|
-
if (style &&
|
|
270
|
+
if (style && element.style[style] !== undefined) {
|
|
271
271
|
element.style[style] = styles[style];
|
|
272
272
|
}
|
|
273
273
|
}
|