@contentful/field-editor-rich-text 3.4.9 → 3.4.10
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/CHANGELOG.md +6 -0
- package/dist/field-editor-rich-text.cjs.development.js +31 -3
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +31 -3
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +2 -2
|
@@ -6167,15 +6167,43 @@ var stripStyleTags = function stripStyleTags(doc) {
|
|
|
6167
6167
|
});
|
|
6168
6168
|
return doc;
|
|
6169
6169
|
};
|
|
6170
|
+
/**
|
|
6171
|
+
* Remove all <meta /> tags
|
|
6172
|
+
*/
|
|
6173
|
+
|
|
6174
|
+
|
|
6175
|
+
var stripMetaTags = function stripMetaTags(doc) {
|
|
6176
|
+
doc.querySelectorAll('meta').forEach(function (el) {
|
|
6177
|
+
return el.remove();
|
|
6178
|
+
});
|
|
6179
|
+
return doc;
|
|
6180
|
+
}; // Attention: Order is important
|
|
6181
|
+
|
|
6170
6182
|
|
|
6171
|
-
var transformers = [stripStyleTags, sanitizeSheets];
|
|
6183
|
+
var transformers = [stripStyleTags, sanitizeSheets, stripMetaTags];
|
|
6172
6184
|
var sanitizeHTML = function sanitizeHTML(html) {
|
|
6173
6185
|
// Parse the HTML string and pipe it through our transformers
|
|
6174
6186
|
var doc = transformers.reduce(function (value, cb) {
|
|
6175
6187
|
return cb(value);
|
|
6176
6188
|
}, new DOMParser().parseFromString(html, 'text/html'));
|
|
6177
|
-
|
|
6178
|
-
|
|
6189
|
+
var previous;
|
|
6190
|
+
|
|
6191
|
+
do {
|
|
6192
|
+
// save previous first before doing modifications
|
|
6193
|
+
previous = doc.body.innerHTML; // Update the body with the cleaned up content
|
|
6194
|
+
|
|
6195
|
+
doc.body.innerHTML = doc.body.innerHTML // remove div container from tables
|
|
6196
|
+
// capture groups explained:
|
|
6197
|
+
// 1. and 3. every content/linebreaks before and after the div container
|
|
6198
|
+
// 2. the table inside the container, including content and linebreaks
|
|
6199
|
+
// The div container including attributes and possible linebreaks inside wil be removed
|
|
6200
|
+
.replace(/(.*\s)?<div.*>\s*(<table(?:.|\s)*<\/table>)\s*<\/div>(.*\s)?/g, '$1$2$3') // remove whitespaces between some tags, as this can lead to unwanted behaviour:
|
|
6201
|
+
// - table -> empty table cells
|
|
6202
|
+
// - list -> leading whitespaces
|
|
6203
|
+
.replace(/<(\/)?(table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)(.*)>\s+</g, '<$1$2$3><');
|
|
6204
|
+
} while (doc.body.innerHTML !== previous);
|
|
6205
|
+
|
|
6206
|
+
return doc.body.innerHTML;
|
|
6179
6207
|
};
|
|
6180
6208
|
|
|
6181
6209
|
/**
|