@contentful/field-editor-rich-text 3.14.2 → 3.15.0
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/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +4 -2
- package/dist/cjs/plugins/Hyperlink/components/UrlHyperlink.js +2 -1
- package/dist/cjs/plugins/Hyperlink/useResourceEntityInfo.js +1 -1
- package/dist/cjs/plugins/Hyperlink/utils.js +2 -10
- package/dist/cjs/plugins/shared/utils.js +17 -3
- package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +4 -2
- package/dist/esm/plugins/Hyperlink/components/UrlHyperlink.js +2 -1
- package/dist/esm/plugins/Hyperlink/useResourceEntityInfo.js +1 -1
- package/dist/esm/plugins/Hyperlink/utils.js +1 -6
- package/dist/esm/plugins/shared/utils.js +6 -0
- package/dist/types/plugins/Hyperlink/utils.d.ts +0 -1
- package/dist/types/plugins/shared/utils.d.ts +1 -0
- package/package.json +2 -2
|
@@ -13,6 +13,7 @@ const _f36components = require("@contentful/f36-components");
|
|
|
13
13
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
14
14
|
const _fieldeditorshared = require("@contentful/field-editor-shared");
|
|
15
15
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
16
|
+
const _utils = require("../../plugins/shared/utils");
|
|
16
17
|
function _getRequireWildcardCache(nodeInterop) {
|
|
17
18
|
if (typeof WeakMap !== "function") return null;
|
|
18
19
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -84,11 +85,12 @@ function FetchingWrappedResourceInlineCard(props) {
|
|
|
84
85
|
localeCode: defaultLocaleCode,
|
|
85
86
|
defaultTitle: 'Untitled'
|
|
86
87
|
});
|
|
87
|
-
const
|
|
88
|
+
const truncatedTitle = (0, _utils.truncateTitle)(title, 40);
|
|
89
|
+
const status = getEntryStatus(entry.sys);
|
|
88
90
|
return _react.createElement(_f36components.InlineEntryCard, {
|
|
89
91
|
testId: _richtexttypes.INLINES.EMBEDDED_RESOURCE,
|
|
90
92
|
isSelected: props.isSelected,
|
|
91
|
-
title: `${
|
|
93
|
+
title: `${contentType.name}: ${truncatedTitle} (Space: ${space.name} – Env.: ${entry.sys.environment.sys.id})`,
|
|
92
94
|
status: status,
|
|
93
95
|
actions: [
|
|
94
96
|
_react.createElement(_f36components.MenuItem, {
|
|
@@ -72,10 +72,11 @@ function UrlHyperlink(props) {
|
|
|
72
72
|
(0, _HyperlinkModal.addOrEditLink)(editor, sdk, editor.tracking.onViewportAction, p?.path);
|
|
73
73
|
}
|
|
74
74
|
return _react.createElement(_f36components.Tooltip, {
|
|
75
|
+
usePortal: true,
|
|
75
76
|
content: uri,
|
|
76
77
|
targetWrapperClassName: _styles.styles.hyperlinkWrapper,
|
|
77
78
|
placement: "bottom",
|
|
78
|
-
maxWidth: "
|
|
79
|
+
maxWidth: "min-content"
|
|
79
80
|
}, _react.createElement(_f36components.TextLink, {
|
|
80
81
|
as: "a",
|
|
81
82
|
href: uri,
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "useResourceEntityInfo", {
|
|
|
10
10
|
});
|
|
11
11
|
const _react = _interop_require_wildcard(require("react"));
|
|
12
12
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
13
|
-
const _utils = require("
|
|
13
|
+
const _utils = require("../../plugins/shared/utils");
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
15
|
if (typeof WeakMap !== "function") return null;
|
|
16
16
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -12,9 +12,6 @@ _export(exports, {
|
|
|
12
12
|
hasText: function() {
|
|
13
13
|
return hasText;
|
|
14
14
|
},
|
|
15
|
-
truncateTitle: function() {
|
|
16
|
-
return truncateTitle;
|
|
17
|
-
},
|
|
18
15
|
getEntityInfo: function() {
|
|
19
16
|
return getEntityInfo;
|
|
20
17
|
}
|
|
@@ -22,22 +19,17 @@ _export(exports, {
|
|
|
22
19
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
23
20
|
const _platecommon = require("@udecode/plate-common");
|
|
24
21
|
const _queries = require("../../internal/queries");
|
|
22
|
+
const _utils = require("../../plugins/shared/utils");
|
|
25
23
|
const hasText = (editor, entry)=>{
|
|
26
24
|
const [node, path] = entry;
|
|
27
25
|
return !(0, _platecommon.isAncestorEmpty)(editor, node) && (0, _queries.getText)(editor, path).trim() !== '';
|
|
28
26
|
};
|
|
29
|
-
function truncateTitle(str, length) {
|
|
30
|
-
if (typeof str === 'string' && str.length > length) {
|
|
31
|
-
return str && str.substr(0, length + 1).replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
|
|
32
|
-
}
|
|
33
|
-
return str;
|
|
34
|
-
}
|
|
35
27
|
function getEntityInfo(data) {
|
|
36
28
|
if (!data) {
|
|
37
29
|
return '';
|
|
38
30
|
}
|
|
39
31
|
const { entityTitle , contentTypeName , entityStatus , jobs } = data;
|
|
40
|
-
const title = truncateTitle(entityTitle, 60) || 'Untitled';
|
|
32
|
+
const title = (0, _utils.truncateTitle)(entityTitle, 60) || 'Untitled';
|
|
41
33
|
const scheduledActions = jobs.length > 0 ? (0, _fieldeditorreference.getScheduleTooltipContent)({
|
|
42
34
|
job: jobs[0],
|
|
43
35
|
jobsCount: jobs.length
|
|
@@ -2,11 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getLinkEntityId: function() {
|
|
8
13
|
return getLinkEntityId;
|
|
14
|
+
},
|
|
15
|
+
truncateTitle: function() {
|
|
16
|
+
return truncateTitle;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
11
19
|
const isResourceLink = (link)=>!!link.sys.urn;
|
|
12
20
|
const getLinkEntityId = (link)=>isResourceLink(link) ? link.sys.urn : link.sys.id;
|
|
21
|
+
function truncateTitle(str, length) {
|
|
22
|
+
if (typeof str === 'string' && str.length > length) {
|
|
23
|
+
return str && str.substr(0, length + 1).replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
|
|
24
|
+
}
|
|
25
|
+
return str;
|
|
26
|
+
}
|
|
@@ -3,6 +3,7 @@ import { InlineEntryCard, MenuItem, Text } from '@contentful/f36-components';
|
|
|
3
3
|
import { useResource } from '@contentful/field-editor-reference';
|
|
4
4
|
import { entityHelpers } from '@contentful/field-editor-shared';
|
|
5
5
|
import { INLINES } from '@contentful/rich-text-types';
|
|
6
|
+
import { truncateTitle } from '../../plugins/shared/utils';
|
|
6
7
|
const { getEntryTitle , getEntryStatus } = entityHelpers;
|
|
7
8
|
export function FetchingWrappedResourceInlineCard(props) {
|
|
8
9
|
const { link , onEntityFetchComplete } = props;
|
|
@@ -35,11 +36,12 @@ export function FetchingWrappedResourceInlineCard(props) {
|
|
|
35
36
|
localeCode: defaultLocaleCode,
|
|
36
37
|
defaultTitle: 'Untitled'
|
|
37
38
|
});
|
|
38
|
-
const
|
|
39
|
+
const truncatedTitle = truncateTitle(title, 40);
|
|
40
|
+
const status = getEntryStatus(entry.sys);
|
|
39
41
|
return React.createElement(InlineEntryCard, {
|
|
40
42
|
testId: INLINES.EMBEDDED_RESOURCE,
|
|
41
43
|
isSelected: props.isSelected,
|
|
42
|
-
title: `${
|
|
44
|
+
title: `${contentType.name}: ${truncatedTitle} (Space: ${space.name} – Env.: ${entry.sys.environment.sys.id})`,
|
|
43
45
|
status: status,
|
|
44
46
|
actions: [
|
|
45
47
|
React.createElement(MenuItem, {
|
|
@@ -23,10 +23,11 @@ export function UrlHyperlink(props) {
|
|
|
23
23
|
addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p?.path);
|
|
24
24
|
}
|
|
25
25
|
return React.createElement(Tooltip, {
|
|
26
|
+
usePortal: true,
|
|
26
27
|
content: uri,
|
|
27
28
|
targetWrapperClassName: styles.hyperlinkWrapper,
|
|
28
29
|
placement: "bottom",
|
|
29
|
-
maxWidth: "
|
|
30
|
+
maxWidth: "min-content"
|
|
30
31
|
}, React.createElement(TextLink, {
|
|
31
32
|
as: "a",
|
|
32
33
|
href: uri,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useResource } from '@contentful/field-editor-reference';
|
|
3
|
-
import { truncateTitle } from '
|
|
3
|
+
import { truncateTitle } from '../../plugins/shared/utils';
|
|
4
4
|
export function useResourceEntityInfo({ onEntityFetchComplete , target }) {
|
|
5
5
|
const { data , error , status } = useResource(target.sys.linkType, target.sys.urn);
|
|
6
6
|
React.useEffect(()=>{
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { getScheduleTooltipContent } from '@contentful/field-editor-reference';
|
|
2
2
|
import { isAncestorEmpty } from '@udecode/plate-common';
|
|
3
3
|
import { getText } from '../../internal/queries';
|
|
4
|
+
import { truncateTitle } from '../../plugins/shared/utils';
|
|
4
5
|
export const hasText = (editor, entry)=>{
|
|
5
6
|
const [node, path] = entry;
|
|
6
7
|
return !isAncestorEmpty(editor, node) && getText(editor, path).trim() !== '';
|
|
7
8
|
};
|
|
8
|
-
export function truncateTitle(str, length) {
|
|
9
|
-
if (typeof str === 'string' && str.length > length) {
|
|
10
|
-
return str && str.substr(0, length + 1).replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
|
|
11
|
-
}
|
|
12
|
-
return str;
|
|
13
|
-
}
|
|
14
9
|
export function getEntityInfo(data) {
|
|
15
10
|
if (!data) {
|
|
16
11
|
return '';
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
const isResourceLink = (link)=>!!link.sys.urn;
|
|
2
2
|
export const getLinkEntityId = (link)=>isResourceLink(link) ? link.sys.urn : link.sys.id;
|
|
3
|
+
export function truncateTitle(str, length) {
|
|
4
|
+
if (typeof str === 'string' && str.length > length) {
|
|
5
|
+
return str && str.substr(0, length + 1).replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
|
|
6
|
+
}
|
|
7
|
+
return str;
|
|
8
|
+
}
|
|
@@ -2,5 +2,4 @@ import { NodeEntry } from '../../internal/types';
|
|
|
2
2
|
import { PlateEditor } from '../../internal/types';
|
|
3
3
|
import { FetchedEntityData } from './useEntityInfo';
|
|
4
4
|
export declare const hasText: (editor: PlateEditor, entry: NodeEntry) => boolean;
|
|
5
|
-
export declare function truncateTitle(str: string, length: number): string;
|
|
6
5
|
export declare function getEntityInfo(data?: FetchedEntityData): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"prism-react-renderer": "2.0.5",
|
|
82
82
|
"react": ">=16.14.0"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "b84cacd208aa4de85e3e229455642fb451137828"
|
|
85
85
|
}
|