@contentful/field-editor-rich-text 3.4.16 → 3.4.18
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 +12 -0
- package/dist/field-editor-rich-text.cjs.development.js +27 -13
- 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 +27 -13
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/Tracking/createTrackingPlugin.d.ts +1 -0
- package/package.json +2 -2
|
@@ -6237,6 +6237,16 @@ var stripMetaTags = function stripMetaTags(doc) {
|
|
|
6237
6237
|
|
|
6238
6238
|
|
|
6239
6239
|
var transformers = [stripStyleTags, sanitizeSheets, stripMetaTags, sanitizeAnchors];
|
|
6240
|
+
|
|
6241
|
+
function removeTableWrappers(table) {
|
|
6242
|
+
var parent = table.parentElement;
|
|
6243
|
+
|
|
6244
|
+
if (parent && parent.tagName === 'DIV' && parent.children.length === 1) {
|
|
6245
|
+
parent.replaceWith(table);
|
|
6246
|
+
removeTableWrappers(table);
|
|
6247
|
+
}
|
|
6248
|
+
}
|
|
6249
|
+
|
|
6240
6250
|
var sanitizeHTML = function sanitizeHTML(html) {
|
|
6241
6251
|
// Parse the HTML string and pipe it through our transformers
|
|
6242
6252
|
var doc = transformers.reduce(function (value, cb) {
|
|
@@ -6253,17 +6263,7 @@ var sanitizeHTML = function sanitizeHTML(html) {
|
|
|
6253
6263
|
}, // remove whitespaces before the ending block element tag
|
|
6254
6264
|
function (innerHTML) {
|
|
6255
6265
|
return innerHTML.replace(/\s*<\/(div|p|table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)/g, '</$1');
|
|
6256
|
-
}];
|
|
6257
|
-
|
|
6258
|
-
if (doc.querySelector('table')) {
|
|
6259
|
-
// remove div container from tables
|
|
6260
|
-
// The div container including attributes and possible linebreaks inside wil be removed
|
|
6261
|
-
replacers.unshift(function (innerHtml) {
|
|
6262
|
-
var result = innerHtml.replace(/<div[^>]*>\s*(<table(?:.|\s)*<\/table>)\s*<\/div>/g, '$1');
|
|
6263
|
-
return result;
|
|
6264
|
-
});
|
|
6265
|
-
}
|
|
6266
|
-
|
|
6266
|
+
}];
|
|
6267
6267
|
var previous;
|
|
6268
6268
|
|
|
6269
6269
|
do {
|
|
@@ -6272,8 +6272,12 @@ var sanitizeHTML = function sanitizeHTML(html) {
|
|
|
6272
6272
|
doc.body.innerHTML = replacers.reduce(function (innerHTML, replacer) {
|
|
6273
6273
|
return replacer(innerHTML);
|
|
6274
6274
|
}, doc.body.innerHTML);
|
|
6275
|
-
} while (doc.body.innerHTML !== previous);
|
|
6275
|
+
} while (doc.body.innerHTML !== previous); // Removing the div container wrappers from tables
|
|
6276
|
+
// The div container including attributes and possible linebreaks inside wil be removed
|
|
6277
|
+
// TODO: can be removed with plate >= 20
|
|
6276
6278
|
|
|
6279
|
+
|
|
6280
|
+
doc.querySelectorAll('table').forEach(removeTableWrappers);
|
|
6277
6281
|
return doc.body.innerHTML;
|
|
6278
6282
|
};
|
|
6279
6283
|
|
|
@@ -7174,6 +7178,7 @@ var actionOrigin = {
|
|
|
7174
7178
|
TOOLBAR: 'toolbar-icon',
|
|
7175
7179
|
SHORTCUT: 'shortcut',
|
|
7176
7180
|
VIEWPORT: 'viewport-interaction',
|
|
7181
|
+
SHORTCUT_OR_VIEWPORT: 'shortcut-or-viewport',
|
|
7177
7182
|
COMMAND_PALETTE: 'command-palette'
|
|
7178
7183
|
};
|
|
7179
7184
|
function getPastingSource(data) {
|
|
@@ -7231,6 +7236,15 @@ var createTrackingPlugin = function createTrackingPlugin(onAction) {
|
|
|
7231
7236
|
origin: actionOrigin.SHORTCUT
|
|
7232
7237
|
}, data));
|
|
7233
7238
|
},
|
|
7239
|
+
onShortcutOrViewportAction: function onShortcutOrViewportAction(actionName, data) {
|
|
7240
|
+
if (data === void 0) {
|
|
7241
|
+
data = {};
|
|
7242
|
+
}
|
|
7243
|
+
|
|
7244
|
+
return onAction(actionName, _extends({
|
|
7245
|
+
origin: actionOrigin.SHORTCUT_OR_VIEWPORT
|
|
7246
|
+
}, data));
|
|
7247
|
+
},
|
|
7234
7248
|
onToolbarAction: function onToolbarAction(actionName, data) {
|
|
7235
7249
|
if (data === void 0) {
|
|
7236
7250
|
data = {};
|
|
@@ -7266,7 +7280,7 @@ var createTrackingPlugin = function createTrackingPlugin(onAction) {
|
|
|
7266
7280
|
var characterCountBefore = getCharacterCount(editor);
|
|
7267
7281
|
setTimeout(function () {
|
|
7268
7282
|
var characterCountAfter = getCharacterCount(editor);
|
|
7269
|
-
trackingActions.
|
|
7283
|
+
trackingActions.onShortcutOrViewportAction('paste', {
|
|
7270
7284
|
characterCountAfter: characterCountAfter,
|
|
7271
7285
|
characterCountBefore: characterCountBefore,
|
|
7272
7286
|
characterCountSelection: characterCountSelection,
|