@contentful/field-editor-rich-text 3.20.7 → 3.22.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/Toolbar/components/ButtonRedo.js +4 -1
- package/dist/cjs/Toolbar/components/ButtonUndo.js +4 -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/cjs/plugins/Tracking/createTrackingPlugin.js +17 -1
- package/dist/esm/Toolbar/components/ButtonRedo.js +4 -1
- package/dist/esm/Toolbar/components/ButtonUndo.js +4 -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/esm/plugins/Tracking/createTrackingPlugin.js +17 -1
- package/dist/types/internal/types/editor.d.ts +8 -0
- package/dist/types/plugins/Tracking/createTrackingPlugin.d.ts +1 -1
- package/package.json +4 -4
|
@@ -19,10 +19,13 @@ function _interop_require_default(obj) {
|
|
|
19
19
|
}
|
|
20
20
|
const ButtonRedo = ()=>{
|
|
21
21
|
const editor = (0, _ContentfulEditorProvider.useContentfulEditor)();
|
|
22
|
+
const onClickHandler = ()=>{
|
|
23
|
+
editor.redo('toolbar');
|
|
24
|
+
};
|
|
22
25
|
return _react.default.createElement(_ToolbarButton.ToolbarButton, {
|
|
23
26
|
title: "Redo",
|
|
24
27
|
testId: "redo-toolbar-button",
|
|
25
|
-
onClick:
|
|
28
|
+
onClick: onClickHandler,
|
|
26
29
|
isActive: false,
|
|
27
30
|
isDisabled: editor.history.redos.length === 0
|
|
28
31
|
}, _react.default.createElement(_f36components.Icon, {
|
|
@@ -19,10 +19,13 @@ function _interop_require_default(obj) {
|
|
|
19
19
|
}
|
|
20
20
|
const ButtonUndo = ()=>{
|
|
21
21
|
const editor = (0, _ContentfulEditorProvider.useContentfulEditor)();
|
|
22
|
+
const onClickHandler = ()=>{
|
|
23
|
+
editor.undo('toolbar');
|
|
24
|
+
};
|
|
22
25
|
return _react.default.createElement(_ToolbarButton.ToolbarButton, {
|
|
23
26
|
title: "Undo",
|
|
24
27
|
testId: "undo-toolbar-button",
|
|
25
|
-
onClick:
|
|
28
|
+
onClick: onClickHandler,
|
|
26
29
|
isActive: false,
|
|
27
30
|
isDisabled: editor.history.undos.length === 0
|
|
28
31
|
}, _react.default.createElement(_f36components.Icon, {
|
|
@@ -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,
|
|
@@ -76,7 +76,7 @@ const createTrackingPlugin = (onAction)=>{
|
|
|
76
76
|
return {
|
|
77
77
|
key: 'TrackingPlugin',
|
|
78
78
|
withOverrides: (editor)=>{
|
|
79
|
-
const { insertData } = editor;
|
|
79
|
+
const { insertData, undo, redo } = editor;
|
|
80
80
|
editor.tracking = trackingActions;
|
|
81
81
|
editor.insertData = (data)=>{
|
|
82
82
|
const isCopyAndPaste = data.types.length !== 0;
|
|
@@ -95,6 +95,22 @@ const createTrackingPlugin = (onAction)=>{
|
|
|
95
95
|
}
|
|
96
96
|
insertData(data);
|
|
97
97
|
};
|
|
98
|
+
editor.undo = (source)=>{
|
|
99
|
+
undo();
|
|
100
|
+
if (source === 'toolbar') {
|
|
101
|
+
editor.tracking.onToolbarAction('undo');
|
|
102
|
+
} else {
|
|
103
|
+
editor.tracking.onShortcutAction('undo');
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
editor.redo = (source)=>{
|
|
107
|
+
redo();
|
|
108
|
+
if (source === 'toolbar') {
|
|
109
|
+
editor.tracking.onToolbarAction('redo');
|
|
110
|
+
} else {
|
|
111
|
+
editor.tracking.onShortcutAction('redo');
|
|
112
|
+
}
|
|
113
|
+
};
|
|
98
114
|
return editor;
|
|
99
115
|
}
|
|
100
116
|
};
|
|
@@ -4,10 +4,13 @@ import { useContentfulEditor } from '../../ContentfulEditorProvider';
|
|
|
4
4
|
import { ToolbarButton } from '../../plugins/shared/ToolbarButton';
|
|
5
5
|
export const ButtonRedo = ()=>{
|
|
6
6
|
const editor = useContentfulEditor();
|
|
7
|
+
const onClickHandler = ()=>{
|
|
8
|
+
editor.redo('toolbar');
|
|
9
|
+
};
|
|
7
10
|
return React.createElement(ToolbarButton, {
|
|
8
11
|
title: "Redo",
|
|
9
12
|
testId: "redo-toolbar-button",
|
|
10
|
-
onClick:
|
|
13
|
+
onClick: onClickHandler,
|
|
11
14
|
isActive: false,
|
|
12
15
|
isDisabled: editor.history.redos.length === 0
|
|
13
16
|
}, React.createElement(Icon, {
|
|
@@ -4,10 +4,13 @@ import { useContentfulEditor } from '../../ContentfulEditorProvider';
|
|
|
4
4
|
import { ToolbarButton } from '../../plugins/shared/ToolbarButton';
|
|
5
5
|
export const ButtonUndo = ()=>{
|
|
6
6
|
const editor = useContentfulEditor();
|
|
7
|
+
const onClickHandler = ()=>{
|
|
8
|
+
editor.undo('toolbar');
|
|
9
|
+
};
|
|
7
10
|
return React.createElement(ToolbarButton, {
|
|
8
11
|
title: "Undo",
|
|
9
12
|
testId: "undo-toolbar-button",
|
|
10
|
-
onClick:
|
|
13
|
+
onClick: onClickHandler,
|
|
11
14
|
isActive: false,
|
|
12
15
|
isDisabled: editor.history.undos.length === 0
|
|
13
16
|
}, React.createElement(Icon, {
|
|
@@ -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,
|
|
@@ -58,7 +58,7 @@ export const createTrackingPlugin = (onAction)=>{
|
|
|
58
58
|
return {
|
|
59
59
|
key: 'TrackingPlugin',
|
|
60
60
|
withOverrides: (editor)=>{
|
|
61
|
-
const { insertData } = editor;
|
|
61
|
+
const { insertData, undo, redo } = editor;
|
|
62
62
|
editor.tracking = trackingActions;
|
|
63
63
|
editor.insertData = (data)=>{
|
|
64
64
|
const isCopyAndPaste = data.types.length !== 0;
|
|
@@ -77,6 +77,22 @@ export const createTrackingPlugin = (onAction)=>{
|
|
|
77
77
|
}
|
|
78
78
|
insertData(data);
|
|
79
79
|
};
|
|
80
|
+
editor.undo = (source)=>{
|
|
81
|
+
undo();
|
|
82
|
+
if (source === 'toolbar') {
|
|
83
|
+
editor.tracking.onToolbarAction('undo');
|
|
84
|
+
} else {
|
|
85
|
+
editor.tracking.onShortcutAction('undo');
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
editor.redo = (source)=>{
|
|
89
|
+
redo();
|
|
90
|
+
if (source === 'toolbar') {
|
|
91
|
+
editor.tracking.onToolbarAction('redo');
|
|
92
|
+
} else {
|
|
93
|
+
editor.tracking.onShortcutAction('redo');
|
|
94
|
+
}
|
|
95
|
+
};
|
|
80
96
|
return editor;
|
|
81
97
|
}
|
|
82
98
|
};
|
|
@@ -26,6 +26,14 @@ export type Value = Element[];
|
|
|
26
26
|
export type ReactEditor = p.TReactEditor<Value>;
|
|
27
27
|
export interface PlateEditor extends p.PlateEditor<Value> {
|
|
28
28
|
tracking: TrackingPluginActions;
|
|
29
|
+
undo: {
|
|
30
|
+
(): void;
|
|
31
|
+
(source: 'toolbar' | 'shortcut'): void;
|
|
32
|
+
};
|
|
33
|
+
redo: {
|
|
34
|
+
(): void;
|
|
35
|
+
(source: 'toolbar' | 'shortcut'): void;
|
|
36
|
+
};
|
|
29
37
|
}
|
|
30
38
|
export type Node = p.ElementOf<PlateEditor> | p.TextOf<PlateEditor>;
|
|
31
39
|
export type Path = p.TPath;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlatePlugin } from '../../internal/types';
|
|
2
|
-
export type RichTextTrackingActionName = 'edit' | 'insert' | 'remove' | 'mark' | 'unmark' | 'insertTable' | 'insertTableRow' | 'insertTableColumn' | 'removeTable' | 'removeTableRow' | 'removeTableColumn' | 'paste' | 'invalidTablePaste' | 'cancelCreateHyperlinkDialog' | 'cancelEditHyperlinkDialog' | 'linkRendered' | 'openCreateHyperlinkDialog' | 'openEditHyperlinkDialog' | 'unlinkHyperlinks' | 'openCreateEmbedDialog' | 'cancelCreateEmbedDialog' | 'openRichTextCommandPalette' | 'cancelRichTextCommandPalette';
|
|
2
|
+
export type RichTextTrackingActionName = 'edit' | 'insert' | 'remove' | 'mark' | 'unmark' | 'insertTable' | 'insertTableRow' | 'insertTableColumn' | 'removeTable' | 'removeTableRow' | 'removeTableColumn' | 'paste' | 'invalidTablePaste' | 'undo' | 'redo' | 'cancelCreateHyperlinkDialog' | 'cancelEditHyperlinkDialog' | 'linkRendered' | 'openCreateHyperlinkDialog' | 'openEditHyperlinkDialog' | 'unlinkHyperlinks' | 'openCreateEmbedDialog' | 'cancelCreateEmbedDialog' | 'openRichTextCommandPalette' | 'cancelRichTextCommandPalette';
|
|
3
3
|
export type RichTextTrackingActionHandler = (name: RichTextTrackingActionName, data: Record<string, unknown>) => unknown;
|
|
4
4
|
export interface TrackingPluginActions {
|
|
5
5
|
onViewportAction: (actionName: RichTextTrackingActionName, data?: Record<string, unknown>) => ReturnType<RichTextTrackingActionHandler>;
|
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.0",
|
|
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": "843655f104af6fb8c116869d59cd9f20e6f1ab14"
|
|
90
90
|
}
|