@contentful/field-editor-rich-text 3.21.0 → 3.22.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/cjs/plugins/DeserializeDocx/cleanHtmlEmptyElements.js +36 -0
- package/dist/cjs/plugins/DeserializeDocx/createDeserializeDocxPlugin.js +2 -1
- package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +1 -1
- package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +1 -1
- package/dist/cjs/plugins/Hyperlink/useEntityInfo.js +1 -1
- package/dist/esm/plugins/DeserializeDocx/cleanHtmlEmptyElements.js +26 -0
- package/dist/esm/plugins/DeserializeDocx/createDeserializeDocxPlugin.js +2 -1
- package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +1 -1
- package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +1 -1
- package/dist/esm/plugins/Hyperlink/useEntityInfo.js +1 -1
- package/dist/types/plugins/DeserializeDocx/cleanHtmlEmptyElements.d.ts +2 -0
- package/package.json +4 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "cleanHtmlEmptyElements", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return cleanHtmlEmptyElements;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _platecommon = require("@udecode/plate-common");
|
|
12
|
+
const ALLOWED_EMPTY_ELEMENTS = new Set([
|
|
13
|
+
'BR',
|
|
14
|
+
'IMG',
|
|
15
|
+
'TH',
|
|
16
|
+
'TD',
|
|
17
|
+
'SPAN'
|
|
18
|
+
]);
|
|
19
|
+
const isEmpty = (element)=>{
|
|
20
|
+
return !ALLOWED_EMPTY_ELEMENTS.has(element.nodeName) && !element.innerHTML.trim();
|
|
21
|
+
};
|
|
22
|
+
const removeIfEmpty = (element)=>{
|
|
23
|
+
if (isEmpty(element)) {
|
|
24
|
+
const { parentElement } = element;
|
|
25
|
+
element.remove();
|
|
26
|
+
if (parentElement) {
|
|
27
|
+
removeIfEmpty(parentElement);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const cleanHtmlEmptyElements = (rootNode)=>{
|
|
32
|
+
(0, _platecommon.traverseHtmlElements)(rootNode, (element)=>{
|
|
33
|
+
removeIfEmpty(element);
|
|
34
|
+
return true;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "createDeserializeDocxPlugin", {
|
|
|
10
10
|
});
|
|
11
11
|
const _platecommon = require("@udecode/plate-common");
|
|
12
12
|
const _plateserializerdocx = require("@udecode/plate-serializer-docx");
|
|
13
|
+
const _cleanHtmlEmptyElements = require("./cleanHtmlEmptyElements");
|
|
13
14
|
const createDeserializeDocxPlugin = ()=>(0, _plateserializerdocx.createDeserializeDocxPlugin)({
|
|
14
15
|
inject: {
|
|
15
16
|
pluginsByKey: {
|
|
@@ -25,7 +26,7 @@ const createDeserializeDocxPlugin = ()=>(0, _plateserializerdocx.createDeseriali
|
|
|
25
26
|
}
|
|
26
27
|
(0, _plateserializerdocx.cleanDocxFootnotes)(body);
|
|
27
28
|
(0, _plateserializerdocx.cleanDocxImageElements)(document, rtf, body);
|
|
28
|
-
(0,
|
|
29
|
+
(0, _cleanHtmlEmptyElements.cleanHtmlEmptyElements)(body);
|
|
29
30
|
(0, _plateserializerdocx.cleanDocxEmptyParagraphs)(body);
|
|
30
31
|
(0, _plateserializerdocx.cleanDocxQuotes)(body);
|
|
31
32
|
(0, _plateserializerdocx.cleanDocxSpans)(body);
|
|
@@ -143,7 +143,7 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
143
143
|
isSelected: props.isSelected
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
const entryStatus = getEntryStatus(entry.sys);
|
|
146
|
+
const entryStatus = getEntryStatus(entry.sys, props.sdk.field.locale);
|
|
147
147
|
if (entryStatus === 'deleted') {
|
|
148
148
|
return _react.createElement(_f36components.InlineEntryCard, {
|
|
149
149
|
title: "Content missing or inaccessible",
|
|
@@ -88,7 +88,7 @@ function FetchingWrappedResourceInlineCard(props) {
|
|
|
88
88
|
defaultTitle: 'Untitled'
|
|
89
89
|
});
|
|
90
90
|
const truncatedTitle = (0, _utils.truncateTitle)(title, 40);
|
|
91
|
-
const status = getEntryStatus(entry.sys);
|
|
91
|
+
const status = getEntryStatus(entry.sys, props.sdk.field.locale);
|
|
92
92
|
return _react.createElement(_f36components.InlineEntryCard, {
|
|
93
93
|
testId: _richtexttypes.INLINES.EMBEDDED_RESOURCE,
|
|
94
94
|
isSelected: props.isSelected,
|
|
@@ -38,7 +38,7 @@ async function fetchAllData({ sdk, entityId, entityType, localeCode, defaultLoca
|
|
|
38
38
|
defaultLocaleCode
|
|
39
39
|
});
|
|
40
40
|
const jobs = await sdk.space.getEntityScheduledActions(entityType, entityId);
|
|
41
|
-
const entityStatus = _fieldeditorshared.entityHelpers.getEntryStatus(entity.sys);
|
|
41
|
+
const entityStatus = _fieldeditorshared.entityHelpers.getEntryStatus(entity.sys, sdk.field.locale);
|
|
42
42
|
return {
|
|
43
43
|
jobs,
|
|
44
44
|
entity,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { traverseHtmlElements } from '@udecode/plate-common';
|
|
2
|
+
const ALLOWED_EMPTY_ELEMENTS = new Set([
|
|
3
|
+
'BR',
|
|
4
|
+
'IMG',
|
|
5
|
+
'TH',
|
|
6
|
+
'TD',
|
|
7
|
+
'SPAN'
|
|
8
|
+
]);
|
|
9
|
+
const isEmpty = (element)=>{
|
|
10
|
+
return !ALLOWED_EMPTY_ELEMENTS.has(element.nodeName) && !element.innerHTML.trim();
|
|
11
|
+
};
|
|
12
|
+
const removeIfEmpty = (element)=>{
|
|
13
|
+
if (isEmpty(element)) {
|
|
14
|
+
const { parentElement } = element;
|
|
15
|
+
element.remove();
|
|
16
|
+
if (parentElement) {
|
|
17
|
+
removeIfEmpty(parentElement);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const cleanHtmlEmptyElements = (rootNode)=>{
|
|
22
|
+
traverseHtmlElements(rootNode, (element)=>{
|
|
23
|
+
removeIfEmpty(element);
|
|
24
|
+
return true;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { KEY_DESERIALIZE_HTML, cleanHtmlBrElements,
|
|
1
|
+
import { KEY_DESERIALIZE_HTML, cleanHtmlBrElements, cleanHtmlFontElements, cleanHtmlLinkElements, cleanHtmlTextNodes, copyBlockMarksToSpanChild, postCleanHtml, preCleanHtml } from '@udecode/plate-common';
|
|
2
2
|
import { cleanDocxBrComments, cleanDocxEmptyParagraphs, cleanDocxFootnotes, cleanDocxImageElements, cleanDocxListElements, cleanDocxQuotes, cleanDocxSpans, createDeserializeDocxPlugin as originalCreateDeserializeDocxPlugin, isDocxContent } from '@udecode/plate-serializer-docx';
|
|
3
|
+
import { cleanHtmlEmptyElements } from './cleanHtmlEmptyElements';
|
|
3
4
|
export const createDeserializeDocxPlugin = ()=>originalCreateDeserializeDocxPlugin({
|
|
4
5
|
inject: {
|
|
5
6
|
pluginsByKey: {
|
|
@@ -87,7 +87,7 @@ export function FetchingWrappedInlineEntryCard(props) {
|
|
|
87
87
|
isSelected: props.isSelected
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
const entryStatus = getEntryStatus(entry.sys);
|
|
90
|
+
const entryStatus = getEntryStatus(entry.sys, props.sdk.field.locale);
|
|
91
91
|
if (entryStatus === 'deleted') {
|
|
92
92
|
return React.createElement(InlineEntryCard, {
|
|
93
93
|
title: "Content missing or inaccessible",
|
|
@@ -37,7 +37,7 @@ export function FetchingWrappedResourceInlineCard(props) {
|
|
|
37
37
|
defaultTitle: 'Untitled'
|
|
38
38
|
});
|
|
39
39
|
const truncatedTitle = truncateTitle(title, 40);
|
|
40
|
-
const status = getEntryStatus(entry.sys);
|
|
40
|
+
const status = getEntryStatus(entry.sys, props.sdk.field.locale);
|
|
41
41
|
return React.createElement(InlineEntryCard, {
|
|
42
42
|
testId: INLINES.EMBEDDED_RESOURCE,
|
|
43
43
|
isSelected: props.isSelected,
|
|
@@ -28,7 +28,7 @@ async function fetchAllData({ sdk, entityId, entityType, localeCode, defaultLoca
|
|
|
28
28
|
defaultLocaleCode
|
|
29
29
|
});
|
|
30
30
|
const jobs = await sdk.space.getEntityScheduledActions(entityType, entityId);
|
|
31
|
-
const entityStatus = entityHelpers.getEntryStatus(entity.sys);
|
|
31
|
+
const entityStatus = entityHelpers.getEntryStatus(entity.sys, sdk.field.locale);
|
|
32
32
|
return {
|
|
33
33
|
jobs,
|
|
34
34
|
entity,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.1",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@contentful/f36-icons": "^4.1.1",
|
|
45
45
|
"@contentful/f36-tokens": "^4.0.0",
|
|
46
46
|
"@contentful/f36-utils": "^4.19.0",
|
|
47
|
-
"@contentful/field-editor-reference": "^5.
|
|
48
|
-
"@contentful/field-editor-shared": "^1.
|
|
47
|
+
"@contentful/field-editor-reference": "^5.28.0",
|
|
48
|
+
"@contentful/field-editor-shared": "^1.5.0",
|
|
49
49
|
"@contentful/rich-text-plain-text-renderer": "^16.0.4",
|
|
50
50
|
"@contentful/rich-text-types": "16.3.0",
|
|
51
51
|
"@popperjs/core": "^2.11.5",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"registry": "https://npm.pkg.github.com/"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "3eae20698bc9b6cc39bde7ec2285d014d7840879"
|
|
90
90
|
}
|