@contentful/field-editor-rich-text 3.4.8 → 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 +12 -0
- package/dist/field-editor-rich-text.cjs.development.js +59 -33
- 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 +59 -33
- 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
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.10](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.9...@contentful/field-editor-rich-text@3.4.10) (2023-03-09)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **RTE:** remove whitespaces only in tables and lists [TOL-104] ([#1362](https://github.com/contentful/field-editors/issues/1362)) ([8b106c8](https://github.com/contentful/field-editors/commit/8b106c8eb08d79cb6c5ae8353d5a1fcf7afab1cf))
|
|
11
|
+
|
|
12
|
+
## [3.4.9](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.8...@contentful/field-editor-rich-text@3.4.9) (2023-03-03)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- 🐛 do not focus RTE on inline embed + create entry ([#1354](https://github.com/contentful/field-editors/issues/1354)) ([3c54787](https://github.com/contentful/field-editors/commit/3c54787d740f7220e55976bac97fb8d542f26d4d))
|
|
17
|
+
|
|
6
18
|
## [3.4.8](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.4.7...@contentful/field-editor-rich-text@3.4.8) (2023-03-01)
|
|
7
19
|
|
|
8
20
|
### Bug Fixes
|
|
@@ -2779,21 +2779,24 @@ function watchCurrentSlide(navigator) {
|
|
|
2779
2779
|
};
|
|
2780
2780
|
};
|
|
2781
2781
|
|
|
2782
|
-
var off = navigator.onSlideInNavigation(function (
|
|
2782
|
+
var off = navigator.onSlideInNavigation(function (_ref) {
|
|
2783
|
+
var oldSlideLevel = _ref.oldSlideLevel,
|
|
2784
|
+
newSlideLevel = _ref.newSlideLevel;
|
|
2785
|
+
|
|
2783
2786
|
if (initialSlideLevel === undefined) {
|
|
2784
|
-
initialSlideLevel =
|
|
2787
|
+
initialSlideLevel = oldSlideLevel;
|
|
2785
2788
|
}
|
|
2786
2789
|
|
|
2787
|
-
lastSlideLevel =
|
|
2790
|
+
lastSlideLevel = newSlideLevel;
|
|
2788
2791
|
|
|
2789
|
-
if (
|
|
2792
|
+
if (newSlideLevel < initialSlideLevel) {
|
|
2790
2793
|
wasSlideClosed = true;
|
|
2791
2794
|
off(); // No more point in watching, slide got closed.
|
|
2792
2795
|
|
|
2793
2796
|
onActiveCallbacks.clear();
|
|
2794
2797
|
}
|
|
2795
2798
|
|
|
2796
|
-
if (status().isActive) {
|
|
2799
|
+
if (status().isActive && newSlideLevel !== oldSlideLevel) {
|
|
2797
2800
|
onActiveCallbacks.forEach(function (cb) {
|
|
2798
2801
|
return cb();
|
|
2799
2802
|
});
|
|
@@ -3244,7 +3247,11 @@ function EmbeddedEntityInline(props) {
|
|
|
3244
3247
|
|
|
3245
3248
|
function handleEditClick() {
|
|
3246
3249
|
return sdk.navigator.openEntry(entryId, {
|
|
3247
|
-
slideIn:
|
|
3250
|
+
slideIn: {
|
|
3251
|
+
waitForClose: true
|
|
3252
|
+
}
|
|
3253
|
+
}).then(function () {
|
|
3254
|
+
editor && focus(editor);
|
|
3248
3255
|
});
|
|
3249
3256
|
}
|
|
3250
3257
|
|
|
@@ -3283,7 +3290,7 @@ function selectEntityAndInsert$1(_x, _x2, _x3) {
|
|
|
3283
3290
|
|
|
3284
3291
|
function _selectEntityAndInsert$1() {
|
|
3285
3292
|
_selectEntityAndInsert$1 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(editor, sdk, logAction) {
|
|
3286
|
-
var config,
|
|
3293
|
+
var config, rteSlide, entry;
|
|
3287
3294
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3288
3295
|
while (1) {
|
|
3289
3296
|
switch (_context2.prev = _context2.next) {
|
|
@@ -3294,39 +3301,30 @@ function _selectEntityAndInsert$1() {
|
|
|
3294
3301
|
config = _extends({}, newEntitySelectorConfigFromRichTextField(sdk.field, Contentful.INLINES.EMBEDDED_ENTRY), {
|
|
3295
3302
|
withCreate: true
|
|
3296
3303
|
});
|
|
3297
|
-
|
|
3304
|
+
rteSlide = watchCurrentSlide(sdk.navigator);
|
|
3298
3305
|
_context2.next = 5;
|
|
3299
3306
|
return sdk.dialogs.selectSingleEntry(config);
|
|
3300
3307
|
|
|
3301
3308
|
case 5:
|
|
3302
3309
|
entry = _context2.sent;
|
|
3303
|
-
focus(editor); // Dialog steals focus from editor, return it.
|
|
3304
3310
|
|
|
3305
|
-
if (entry) {
|
|
3306
|
-
|
|
3307
|
-
|
|
3311
|
+
if (!entry) {
|
|
3312
|
+
logAction('cancelCreateEmbedDialog', {
|
|
3313
|
+
nodeType: Contentful.INLINES.EMBEDDED_ENTRY
|
|
3314
|
+
});
|
|
3315
|
+
} else {
|
|
3316
|
+
insertNodes(editor, createInlineEntryNode$1(entry.sys.id));
|
|
3317
|
+
logAction('insert', {
|
|
3318
|
+
nodeType: Contentful.INLINES.EMBEDDED_ENTRY
|
|
3319
|
+
});
|
|
3308
3320
|
}
|
|
3309
3321
|
|
|
3310
|
-
|
|
3311
|
-
|
|
3322
|
+
rteSlide.onActive(function () {
|
|
3323
|
+
rteSlide.unwatch();
|
|
3324
|
+
focus(editor);
|
|
3312
3325
|
});
|
|
3313
|
-
return _context2.abrupt("return");
|
|
3314
3326
|
|
|
3315
|
-
case
|
|
3316
|
-
inlineEntryNode = createInlineEntryNode$1(entry.sys.id);
|
|
3317
|
-
logAction('insert', {
|
|
3318
|
-
nodeType: Contentful.INLINES.EMBEDDED_ENTRY
|
|
3319
|
-
}); // Got to wait until focus is really back on the editor or setSelection() won't work.
|
|
3320
|
-
|
|
3321
|
-
return _context2.abrupt("return", new Promise(function (resolve) {
|
|
3322
|
-
setTimeout(function () {
|
|
3323
|
-
setSelection(editor, selection);
|
|
3324
|
-
insertNodes(editor, inlineEntryNode);
|
|
3325
|
-
resolve();
|
|
3326
|
-
}, 0);
|
|
3327
|
-
}));
|
|
3328
|
-
|
|
3329
|
-
case 13:
|
|
3327
|
+
case 8:
|
|
3330
3328
|
case "end":
|
|
3331
3329
|
return _context2.stop();
|
|
3332
3330
|
}
|
|
@@ -6176,15 +6174,43 @@ var stripStyleTags = function stripStyleTags(doc) {
|
|
|
6176
6174
|
});
|
|
6177
6175
|
return doc;
|
|
6178
6176
|
};
|
|
6177
|
+
/**
|
|
6178
|
+
* Remove all <meta /> tags
|
|
6179
|
+
*/
|
|
6180
|
+
|
|
6181
|
+
|
|
6182
|
+
var stripMetaTags = function stripMetaTags(doc) {
|
|
6183
|
+
doc.querySelectorAll('meta').forEach(function (el) {
|
|
6184
|
+
return el.remove();
|
|
6185
|
+
});
|
|
6186
|
+
return doc;
|
|
6187
|
+
}; // Attention: Order is important
|
|
6188
|
+
|
|
6179
6189
|
|
|
6180
|
-
var transformers = [stripStyleTags, sanitizeSheets];
|
|
6190
|
+
var transformers = [stripStyleTags, sanitizeSheets, stripMetaTags];
|
|
6181
6191
|
var sanitizeHTML = function sanitizeHTML(html) {
|
|
6182
6192
|
// Parse the HTML string and pipe it through our transformers
|
|
6183
6193
|
var doc = transformers.reduce(function (value, cb) {
|
|
6184
6194
|
return cb(value);
|
|
6185
6195
|
}, new DOMParser().parseFromString(html, 'text/html'));
|
|
6186
|
-
|
|
6187
|
-
|
|
6196
|
+
var previous;
|
|
6197
|
+
|
|
6198
|
+
do {
|
|
6199
|
+
// save previous first before doing modifications
|
|
6200
|
+
previous = doc.body.innerHTML; // Update the body with the cleaned up content
|
|
6201
|
+
|
|
6202
|
+
doc.body.innerHTML = doc.body.innerHTML // remove div container from tables
|
|
6203
|
+
// capture groups explained:
|
|
6204
|
+
// 1. and 3. every content/linebreaks before and after the div container
|
|
6205
|
+
// 2. the table inside the container, including content and linebreaks
|
|
6206
|
+
// The div container including attributes and possible linebreaks inside wil be removed
|
|
6207
|
+
.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:
|
|
6208
|
+
// - table -> empty table cells
|
|
6209
|
+
// - list -> leading whitespaces
|
|
6210
|
+
.replace(/<(\/)?(table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)(.*)>\s+</g, '<$1$2$3><');
|
|
6211
|
+
} while (doc.body.innerHTML !== previous);
|
|
6212
|
+
|
|
6213
|
+
return doc.body.innerHTML;
|
|
6188
6214
|
};
|
|
6189
6215
|
|
|
6190
6216
|
/**
|