@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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.4.18](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.17...@contentful/field-editor-rich-text@3.4.18) (2023-04-17)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **RTE:** copy-paste perf issues on larger documents ([#1394](https://github.com/contentful/field-editors/issues/1394)) ([af6f3b1](https://github.com/contentful/field-editors/commit/af6f3b14e9cc3f38ae1337f32f8c0480da616659))
|
|
11
|
+
|
|
12
|
+
## [3.4.17](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.16...@contentful/field-editor-rich-text@3.4.17) (2023-04-04)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- correct misleading action origin on paste event - rich text ([#1385](https://github.com/contentful/field-editors/issues/1385)) ([23e313f](https://github.com/contentful/field-editors/commit/23e313f4158de0205dfb5415f4334c5b906dc2c7))
|
|
17
|
+
|
|
6
18
|
## [3.4.16](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.15...@contentful/field-editor-rich-text@3.4.16) (2023-03-31)
|
|
7
19
|
|
|
8
20
|
### Bug Fixes
|
|
@@ -6244,6 +6244,16 @@ var stripMetaTags = function stripMetaTags(doc) {
|
|
|
6244
6244
|
|
|
6245
6245
|
|
|
6246
6246
|
var transformers = [stripStyleTags, sanitizeSheets, stripMetaTags, sanitizeAnchors];
|
|
6247
|
+
|
|
6248
|
+
function removeTableWrappers(table) {
|
|
6249
|
+
var parent = table.parentElement;
|
|
6250
|
+
|
|
6251
|
+
if (parent && parent.tagName === 'DIV' && parent.children.length === 1) {
|
|
6252
|
+
parent.replaceWith(table);
|
|
6253
|
+
removeTableWrappers(table);
|
|
6254
|
+
}
|
|
6255
|
+
}
|
|
6256
|
+
|
|
6247
6257
|
var sanitizeHTML = function sanitizeHTML(html) {
|
|
6248
6258
|
// Parse the HTML string and pipe it through our transformers
|
|
6249
6259
|
var doc = transformers.reduce(function (value, cb) {
|
|
@@ -6260,17 +6270,7 @@ var sanitizeHTML = function sanitizeHTML(html) {
|
|
|
6260
6270
|
}, // remove whitespaces before the ending block element tag
|
|
6261
6271
|
function (innerHTML) {
|
|
6262
6272
|
return innerHTML.replace(/\s*<\/(div|p|table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)/g, '</$1');
|
|
6263
|
-
}];
|
|
6264
|
-
|
|
6265
|
-
if (doc.querySelector('table')) {
|
|
6266
|
-
// remove div container from tables
|
|
6267
|
-
// The div container including attributes and possible linebreaks inside wil be removed
|
|
6268
|
-
replacers.unshift(function (innerHtml) {
|
|
6269
|
-
var result = innerHtml.replace(/<div[^>]*>\s*(<table(?:.|\s)*<\/table>)\s*<\/div>/g, '$1');
|
|
6270
|
-
return result;
|
|
6271
|
-
});
|
|
6272
|
-
}
|
|
6273
|
-
|
|
6273
|
+
}];
|
|
6274
6274
|
var previous;
|
|
6275
6275
|
|
|
6276
6276
|
do {
|
|
@@ -6279,8 +6279,12 @@ var sanitizeHTML = function sanitizeHTML(html) {
|
|
|
6279
6279
|
doc.body.innerHTML = replacers.reduce(function (innerHTML, replacer) {
|
|
6280
6280
|
return replacer(innerHTML);
|
|
6281
6281
|
}, doc.body.innerHTML);
|
|
6282
|
-
} while (doc.body.innerHTML !== previous);
|
|
6282
|
+
} while (doc.body.innerHTML !== previous); // Removing the div container wrappers from tables
|
|
6283
|
+
// The div container including attributes and possible linebreaks inside wil be removed
|
|
6284
|
+
// TODO: can be removed with plate >= 20
|
|
6283
6285
|
|
|
6286
|
+
|
|
6287
|
+
doc.querySelectorAll('table').forEach(removeTableWrappers);
|
|
6284
6288
|
return doc.body.innerHTML;
|
|
6285
6289
|
};
|
|
6286
6290
|
|
|
@@ -7181,6 +7185,7 @@ var actionOrigin = {
|
|
|
7181
7185
|
TOOLBAR: 'toolbar-icon',
|
|
7182
7186
|
SHORTCUT: 'shortcut',
|
|
7183
7187
|
VIEWPORT: 'viewport-interaction',
|
|
7188
|
+
SHORTCUT_OR_VIEWPORT: 'shortcut-or-viewport',
|
|
7184
7189
|
COMMAND_PALETTE: 'command-palette'
|
|
7185
7190
|
};
|
|
7186
7191
|
function getPastingSource(data) {
|
|
@@ -7238,6 +7243,15 @@ var createTrackingPlugin = function createTrackingPlugin(onAction) {
|
|
|
7238
7243
|
origin: actionOrigin.SHORTCUT
|
|
7239
7244
|
}, data));
|
|
7240
7245
|
},
|
|
7246
|
+
onShortcutOrViewportAction: function onShortcutOrViewportAction(actionName, data) {
|
|
7247
|
+
if (data === void 0) {
|
|
7248
|
+
data = {};
|
|
7249
|
+
}
|
|
7250
|
+
|
|
7251
|
+
return onAction(actionName, _extends({
|
|
7252
|
+
origin: actionOrigin.SHORTCUT_OR_VIEWPORT
|
|
7253
|
+
}, data));
|
|
7254
|
+
},
|
|
7241
7255
|
onToolbarAction: function onToolbarAction(actionName, data) {
|
|
7242
7256
|
if (data === void 0) {
|
|
7243
7257
|
data = {};
|
|
@@ -7273,7 +7287,7 @@ var createTrackingPlugin = function createTrackingPlugin(onAction) {
|
|
|
7273
7287
|
var characterCountBefore = getCharacterCount(editor);
|
|
7274
7288
|
setTimeout(function () {
|
|
7275
7289
|
var characterCountAfter = getCharacterCount(editor);
|
|
7276
|
-
trackingActions.
|
|
7290
|
+
trackingActions.onShortcutOrViewportAction('paste', {
|
|
7277
7291
|
characterCountAfter: characterCountAfter,
|
|
7278
7292
|
characterCountBefore: characterCountBefore,
|
|
7279
7293
|
characterCountSelection: characterCountSelection,
|