@contentful/field-editor-rich-text 3.12.6 → 3.13.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.
Files changed (67) hide show
  1. package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +8 -2
  2. package/dist/cjs/constants/Schema.js +3 -0
  3. package/dist/cjs/helpers/{newEntitySelectorConfigFromRichTextField.js → config.js} +19 -5
  4. package/dist/cjs/plugins/DragAndDrop/index.js +4 -2
  5. package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +1 -1
  6. package/dist/cjs/plugins/EmbeddedEntityInline/LinkedEntityInline.js +97 -0
  7. package/dist/cjs/plugins/EmbeddedEntityInline/index.js +27 -193
  8. package/dist/cjs/plugins/{shared/FetchingWrappedResourceCard.js → EmbeddedResourceBlock/FetchingWrappedResourceBlockCard.js} +3 -3
  9. package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +3 -3
  10. package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +102 -0
  11. package/dist/cjs/plugins/EmbeddedResourceInline/LinkedResourceInline.js +51 -0
  12. package/dist/cjs/plugins/EmbeddedResourceInline/index.js +56 -0
  13. package/dist/cjs/plugins/index.js +2 -0
  14. package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +2 -4
  15. package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +3 -4
  16. package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +105 -0
  17. package/dist/cjs/plugins/shared/EmbeddedInlineUtil.js +127 -0
  18. package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +4 -5
  19. package/dist/cjs/plugins/shared/LinkedInlineWrapper.js +85 -0
  20. package/dist/cjs/plugins/shared/ResourceNewBadge.js +57 -0
  21. package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +2 -2
  22. package/dist/cjs/plugins/shared/utils.js +12 -0
  23. package/dist/esm/Toolbar/components/EmbedEntityWidget.js +8 -2
  24. package/dist/esm/constants/Schema.js +3 -0
  25. package/dist/esm/helpers/{newEntitySelectorConfigFromRichTextField.js → config.js} +8 -2
  26. package/dist/esm/plugins/DragAndDrop/index.js +4 -2
  27. package/dist/esm/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +1 -1
  28. package/dist/esm/plugins/EmbeddedEntityInline/LinkedEntityInline.js +48 -0
  29. package/dist/esm/plugins/EmbeddedEntityInline/index.js +24 -138
  30. package/dist/esm/plugins/{shared/FetchingWrappedResourceCard.js → EmbeddedResourceBlock/FetchingWrappedResourceBlockCard.js} +1 -1
  31. package/dist/esm/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +3 -3
  32. package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +53 -0
  33. package/dist/esm/plugins/EmbeddedResourceInline/LinkedResourceInline.js +36 -0
  34. package/dist/esm/plugins/EmbeddedResourceInline/index.js +46 -0
  35. package/dist/esm/plugins/index.js +2 -0
  36. package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +3 -5
  37. package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +1 -2
  38. package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +51 -0
  39. package/dist/esm/plugins/shared/EmbeddedInlineUtil.js +101 -0
  40. package/dist/esm/plugins/shared/LinkedBlockWrapper.js +4 -5
  41. package/dist/esm/plugins/shared/LinkedInlineWrapper.js +31 -0
  42. package/dist/esm/plugins/shared/ResourceNewBadge.js +8 -0
  43. package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +2 -2
  44. package/dist/esm/plugins/shared/utils.js +2 -0
  45. package/dist/types/constants/Schema.d.ts +3 -0
  46. package/dist/types/helpers/config.d.ts +33 -0
  47. package/dist/types/plugins/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +2 -7
  48. package/dist/types/plugins/EmbeddedEntityInline/LinkedEntityInline.d.ts +14 -0
  49. package/dist/types/plugins/EmbeddedEntityInline/index.d.ts +0 -7
  50. package/dist/types/plugins/{shared/FetchingWrappedResourceCard.d.ts → EmbeddedResourceBlock/FetchingWrappedResourceBlockCard.d.ts} +2 -2
  51. package/dist/types/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.d.ts +13 -0
  52. package/dist/types/plugins/EmbeddedResourceInline/LinkedResourceInline.d.ts +13 -0
  53. package/dist/types/plugins/EmbeddedResourceInline/index.d.ts +3 -0
  54. package/dist/types/plugins/shared/EmbeddedInlineToolbarIcon.d.ts +8 -0
  55. package/dist/types/plugins/shared/EmbeddedInlineUtil.d.ts +8 -0
  56. package/dist/types/plugins/shared/LinkedBlockWrapper.d.ts +4 -19
  57. package/dist/types/plugins/shared/LinkedInlineWrapper.d.ts +10 -0
  58. package/dist/types/plugins/shared/ResourceNewBadge.d.ts +2 -0
  59. package/dist/types/plugins/shared/utils.d.ts +2 -0
  60. package/package.json +2 -2
  61. package/dist/cjs/helpers/newResourceEntitySelectorConfigFromRichTextField.js +0 -21
  62. package/dist/cjs/plugins/EmbeddedEntityInline/Util.js +0 -30
  63. package/dist/esm/helpers/newResourceEntitySelectorConfigFromRichTextField.js +0 -6
  64. package/dist/esm/plugins/EmbeddedEntityInline/Util.js +0 -20
  65. package/dist/types/helpers/newEntitySelectorConfigFromRichTextField.d.ts +0 -14
  66. package/dist/types/helpers/newResourceEntitySelectorConfigFromRichTextField.d.ts +0 -16
  67. package/dist/types/plugins/EmbeddedEntityInline/Util.d.ts +0 -16
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "createEmbeddedResourceInlinePlugin", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return createEmbeddedResourceInlinePlugin;
9
+ }
10
+ });
11
+ const _richtexttypes = require("@contentful/rich-text-types");
12
+ const _EmbeddedInlineUtil = require("../shared/EmbeddedInlineUtil");
13
+ const _LinkedResourceInline = require("./LinkedResourceInline");
14
+ function createEmbeddedResourceInlinePlugin(sdk) {
15
+ const htmlAttributeName = 'data-embedded-resource-inline-id';
16
+ const nodeType = _richtexttypes.INLINES.EMBEDDED_RESOURCE;
17
+ return {
18
+ key: nodeType,
19
+ type: nodeType,
20
+ isElement: true,
21
+ isInline: true,
22
+ isVoid: true,
23
+ component: _LinkedResourceInline.LinkedResourceInline,
24
+ options: {
25
+ hotkey: 'mod+shift+p'
26
+ },
27
+ handlers: {
28
+ onKeyDown: (0, _EmbeddedInlineUtil.getWithEmbeddedEntryInlineEvents)(nodeType, sdk)
29
+ },
30
+ deserializeHtml: {
31
+ rules: [
32
+ {
33
+ validAttribute: htmlAttributeName
34
+ }
35
+ ],
36
+ withoutChildren: true,
37
+ getNode: (el)=>({
38
+ type: nodeType,
39
+ children: [
40
+ {
41
+ text: ''
42
+ }
43
+ ],
44
+ data: {
45
+ target: {
46
+ sys: {
47
+ urn: el.getAttribute('data-entity-id'),
48
+ linkType: el.getAttribute('data-entity-type'),
49
+ type: 'ResourceLink'
50
+ }
51
+ }
52
+ }
53
+ })
54
+ }
55
+ };
56
+ }
@@ -24,6 +24,7 @@ const _DragAndDrop = require("./DragAndDrop");
24
24
  const _EmbeddedEntityBlock = require("./EmbeddedEntityBlock");
25
25
  const _EmbeddedEntityInline = require("./EmbeddedEntityInline");
26
26
  const _EmbeddedResourceBlock = require("./EmbeddedResourceBlock");
27
+ const _EmbeddedResourceInline = require("./EmbeddedResourceInline");
27
28
  const _Heading = require("./Heading");
28
29
  const _Hr = require("./Hr");
29
30
  const _Hyperlink = require("./Hyperlink");
@@ -57,6 +58,7 @@ const getPlugins = (sdk, onAction, restrictedMarks)=>[
57
58
  (0, _EmbeddedResourceBlock.createEmbeddedResourceBlockPlugin)(sdk),
58
59
  (0, _Hyperlink.createHyperlinkPlugin)(sdk),
59
60
  (0, _EmbeddedEntityInline.createEmbeddedEntityInlinePlugin)(sdk),
61
+ (0, _EmbeddedResourceInline.createEmbeddedResourceInlinePlugin)(sdk),
60
62
  (0, _Marks.createMarksPlugin)(),
61
63
  (0, _TrailingParagraph.createTrailingParagraphPlugin)(),
62
64
  (0, _Text.createTextPlugin)(restrictedMarks),
@@ -24,6 +24,7 @@ const _emotion = require("emotion");
24
24
  const _ContentfulEditorProvider = require("../../ContentfulEditorProvider");
25
25
  const _SdkProvider = require("../../SdkProvider");
26
26
  const _EmbeddedBlockUtil = require("../shared/EmbeddedBlockUtil");
27
+ const _ResourceNewBadge = require("./ResourceNewBadge");
27
28
  function _getRequireWildcardCache(nodeInterop) {
28
29
  if (typeof WeakMap !== "function") return null;
29
30
  var cacheBabelInterop = new WeakMap();
@@ -97,10 +98,7 @@ function EmbeddedBlockToolbarIcon({ isDisabled , nodeType , onClose }) {
97
98
  as: type === 'Asset' ? _f36icons.AssetIcon : _f36icons.EmbeddedEntryBlockIcon,
98
99
  className: `rich-text__embedded-entry-list-icon ${styles.icon}`,
99
100
  variant: "secondary"
100
- }), _react.createElement("span", null, type, nodeType == _richtexttypes.BLOCKS.EMBEDDED_RESOURCE && _react.createElement(_react.Fragment, null, ' ', "(different space)", ' ', _react.createElement(_f36components.Badge, {
101
- variant: "primary-filled",
102
- size: "small"
103
- }, "new")))));
101
+ }), _react.createElement("span", null, type, nodeType == _richtexttypes.BLOCKS.EMBEDDED_RESOURCE && _react.createElement(_ResourceNewBadge.ResourceNewBadge, null))));
104
102
  }
105
103
  function getEntityTypeFromNodeType(nodeType) {
106
104
  const words = nodeType.toLowerCase().split('-');
@@ -21,9 +21,8 @@ _export(exports, {
21
21
  });
22
22
  const _richtexttypes = require("@contentful/rich-text-types");
23
23
  const _ishotkey = _interop_require_default(require("is-hotkey"));
24
+ const _config = require("../../helpers/config");
24
25
  const _editor = require("../../helpers/editor");
25
- const _newEntitySelectorConfigFromRichTextField = _interop_require_default(require("../../helpers/newEntitySelectorConfigFromRichTextField"));
26
- const _newResourceEntitySelectorConfigFromRichTextField = _interop_require_default(require("../../helpers/newResourceEntitySelectorConfigFromRichTextField"));
27
26
  const _sdkNavigatorSlideIn = require("../../helpers/sdkNavigatorSlideIn");
28
27
  const _internal = require("../../internal");
29
28
  function _interop_require_default(obj) {
@@ -59,7 +58,7 @@ async function selectEntityAndInsert(nodeType, sdk, editor, logAction) {
59
58
  nodeType
60
59
  });
61
60
  const { field , dialogs } = sdk;
62
- const baseConfig = (0, _newEntitySelectorConfigFromRichTextField.default)(field, nodeType);
61
+ const baseConfig = (0, _config.newEntitySelectorConfigFromRichTextField)(field, nodeType);
63
62
  const selectEntity = baseConfig.entityType === 'Asset' ? dialogs.selectSingleAsset : dialogs.selectSingleEntry;
64
63
  const config = {
65
64
  ...baseConfig,
@@ -93,7 +92,7 @@ async function selectResourceEntityAndInsert(sdk, editor, logAction) {
93
92
  nodeType: _richtexttypes.BLOCKS.EMBEDDED_RESOURCE
94
93
  });
95
94
  const { field , dialogs } = sdk;
96
- const config = (0, _newResourceEntitySelectorConfigFromRichTextField.default)(field, _richtexttypes.BLOCKS.EMBEDDED_RESOURCE);
95
+ const config = (0, _config.newResourceEntitySelectorConfigFromRichTextField)(field, _richtexttypes.BLOCKS.EMBEDDED_RESOURCE);
97
96
  const { selection } = editor;
98
97
  const entity = await dialogs.selectSingleResourceEntry(config);
99
98
  if (!entity) {
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "EmbeddedInlineToolbarIcon", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return EmbeddedInlineToolbarIcon;
9
+ }
10
+ });
11
+ const _react = _interop_require_wildcard(require("react"));
12
+ const _f36components = require("@contentful/f36-components");
13
+ const _f36icons = require("@contentful/f36-icons");
14
+ const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
15
+ const _richtexttypes = require("@contentful/rich-text-types");
16
+ const _emotion = require("emotion");
17
+ const _ContentfulEditorProvider = require("../../ContentfulEditorProvider");
18
+ const _editor = require("../../helpers/editor");
19
+ const _SdkProvider = require("../../SdkProvider");
20
+ const _EmbeddedInlineUtil = require("../shared/EmbeddedInlineUtil");
21
+ const _ResourceNewBadge = require("./ResourceNewBadge");
22
+ function _interop_require_default(obj) {
23
+ return obj && obj.__esModule ? obj : {
24
+ default: obj
25
+ };
26
+ }
27
+ function _getRequireWildcardCache(nodeInterop) {
28
+ if (typeof WeakMap !== "function") return null;
29
+ var cacheBabelInterop = new WeakMap();
30
+ var cacheNodeInterop = new WeakMap();
31
+ return (_getRequireWildcardCache = function(nodeInterop) {
32
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
33
+ })(nodeInterop);
34
+ }
35
+ function _interop_require_wildcard(obj, nodeInterop) {
36
+ if (!nodeInterop && obj && obj.__esModule) {
37
+ return obj;
38
+ }
39
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
40
+ return {
41
+ default: obj
42
+ };
43
+ }
44
+ var cache = _getRequireWildcardCache(nodeInterop);
45
+ if (cache && cache.has(obj)) {
46
+ return cache.get(obj);
47
+ }
48
+ var newObj = {};
49
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
50
+ for(var key in obj){
51
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
52
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
53
+ if (desc && (desc.get || desc.set)) {
54
+ Object.defineProperty(newObj, key, desc);
55
+ } else {
56
+ newObj[key] = obj[key];
57
+ }
58
+ }
59
+ }
60
+ newObj.default = obj;
61
+ if (cache) {
62
+ cache.set(obj, newObj);
63
+ }
64
+ return newObj;
65
+ }
66
+ const styles = {
67
+ icon: (0, _emotion.css)({
68
+ marginRight: '10px'
69
+ }),
70
+ root: (0, _emotion.css)({
71
+ display: 'inline-block',
72
+ margin: `0 ${_f36tokens.default.spacing2Xs}`,
73
+ fontSize: 'inherit',
74
+ span: {
75
+ userSelect: 'none'
76
+ }
77
+ })
78
+ };
79
+ function EmbeddedInlineToolbarIcon({ onClose , nodeType , isDisabled }) {
80
+ const editor = (0, _ContentfulEditorProvider.useContentfulEditor)();
81
+ const sdk = (0, _SdkProvider.useSdkContext)();
82
+ async function handleClick(event) {
83
+ event.preventDefault();
84
+ if (!editor) return;
85
+ onClose();
86
+ if (nodeType === _richtexttypes.INLINES.EMBEDDED_RESOURCE) {
87
+ await (0, _EmbeddedInlineUtil.selectResourceEntityAndInsert)(editor, sdk, editor.tracking.onToolbarAction);
88
+ } else {
89
+ await (0, _EmbeddedInlineUtil.selectEntityAndInsert)(editor, sdk, editor.tracking.onToolbarAction);
90
+ }
91
+ (0, _editor.moveToTheNextChar)(editor);
92
+ }
93
+ return _react.createElement(_f36components.Menu.Item, {
94
+ disabled: isDisabled,
95
+ className: "rich-text__entry-link-block-button",
96
+ testId: `toolbar-toggle-${nodeType}`,
97
+ onClick: handleClick
98
+ }, _react.createElement(_f36components.Flex, {
99
+ alignItems: "center",
100
+ flexDirection: "row"
101
+ }, _react.createElement(_f36icons.EmbeddedEntryInlineIcon, {
102
+ variant: "secondary",
103
+ className: `rich-text__embedded-entry-list-icon ${styles.icon}`
104
+ }), _react.createElement("span", null, "Inline entry", nodeType == _richtexttypes.INLINES.EMBEDDED_RESOURCE && _react.createElement(_ResourceNewBadge.ResourceNewBadge, null))));
105
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
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
+ getWithEmbeddedEntryInlineEvents: function() {
13
+ return getWithEmbeddedEntryInlineEvents;
14
+ },
15
+ selectEntityAndInsert: function() {
16
+ return selectEntityAndInsert;
17
+ },
18
+ selectResourceEntityAndInsert: function() {
19
+ return selectResourceEntityAndInsert;
20
+ }
21
+ });
22
+ const _richtexttypes = require("@contentful/rich-text-types");
23
+ const _ishotkey = _interop_require_default(require("is-hotkey"));
24
+ const _config = require("../../helpers/config");
25
+ const _editor = require("../../helpers/editor");
26
+ const _sdkNavigatorSlideIn = require("../../helpers/sdkNavigatorSlideIn");
27
+ const _transforms = require("../../internal/transforms");
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ function getWithEmbeddedEntryInlineEvents(nodeType, sdk) {
34
+ return function withEmbeddedEntryInlineEvents(editor, { options: { hotkey } }) {
35
+ return function handleEvent(event) {
36
+ if (!editor) return;
37
+ if (hotkey && (0, _ishotkey.default)(hotkey, event)) {
38
+ if (nodeType === _richtexttypes.INLINES.EMBEDDED_RESOURCE) {
39
+ selectResourceEntityAndInsert(editor, sdk, editor.tracking.onShortcutAction);
40
+ } else {
41
+ selectEntityAndInsert(editor, sdk, editor.tracking.onShortcutAction);
42
+ }
43
+ }
44
+ };
45
+ };
46
+ }
47
+ const getLink = (nodeType, entity)=>{
48
+ if (nodeType === _richtexttypes.INLINES.EMBEDDED_RESOURCE) {
49
+ return {
50
+ urn: entity.sys.urn,
51
+ type: 'ResourceLink',
52
+ linkType: 'Contentful:Entry'
53
+ };
54
+ }
55
+ return {
56
+ id: entity.sys.id,
57
+ type: 'Link',
58
+ linkType: entity.sys.type
59
+ };
60
+ };
61
+ const createInlineEntryNode = (nodeType, entity)=>{
62
+ return {
63
+ type: nodeType,
64
+ children: [
65
+ {
66
+ text: ''
67
+ }
68
+ ],
69
+ data: {
70
+ target: {
71
+ sys: getLink(nodeType, entity)
72
+ }
73
+ }
74
+ };
75
+ };
76
+ async function selectEntityAndInsert(editor, sdk, logAction) {
77
+ const nodeType = _richtexttypes.INLINES.EMBEDDED_ENTRY;
78
+ logAction('openCreateEmbedDialog', {
79
+ nodeType
80
+ });
81
+ const config = {
82
+ ...(0, _config.newEntitySelectorConfigFromRichTextField)(sdk.field, nodeType),
83
+ withCreate: true
84
+ };
85
+ const { selection } = editor;
86
+ const rteSlide = (0, _sdkNavigatorSlideIn.watchCurrentSlide)(sdk.navigator);
87
+ const entry = await sdk.dialogs.selectSingleEntry(config);
88
+ if (!entry) {
89
+ logAction('cancelCreateEmbedDialog', {
90
+ nodeType
91
+ });
92
+ } else {
93
+ (0, _transforms.select)(editor, selection);
94
+ (0, _transforms.insertNodes)(editor, createInlineEntryNode(nodeType, entry));
95
+ logAction('insert', {
96
+ nodeType
97
+ });
98
+ }
99
+ rteSlide.onActive(()=>{
100
+ rteSlide.unwatch();
101
+ (0, _editor.focus)(editor);
102
+ });
103
+ }
104
+ async function selectResourceEntityAndInsert(editor, sdk, logAction) {
105
+ const nodeType = _richtexttypes.INLINES.EMBEDDED_RESOURCE;
106
+ logAction('openCreateEmbedDialog', {
107
+ nodeType
108
+ });
109
+ const { dialogs , field } = sdk;
110
+ const config = {
111
+ ...(0, _config.newResourceEntitySelectorConfigFromRichTextField)(field, nodeType),
112
+ withCreate: true
113
+ };
114
+ const { selection } = editor;
115
+ const entry = await dialogs.selectSingleResourceEntry(config);
116
+ if (!entry) {
117
+ logAction('cancelCreateEmbedDialog', {
118
+ nodeType
119
+ });
120
+ } else {
121
+ (0, _transforms.select)(editor, selection);
122
+ (0, _transforms.insertNodes)(editor, createInlineEntryNode(nodeType, entry));
123
+ logAction('insert', {
124
+ nodeType
125
+ });
126
+ }
127
+ }
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "LinkedBlockWrapper", {
11
11
  const _react = _interop_require_default(require("react"));
12
12
  const _emotion = require("emotion");
13
13
  const _environment = require("../../helpers/environment");
14
+ const _utils = require("./utils");
14
15
  function _interop_require_default(obj) {
15
16
  return obj && obj.__esModule ? obj : {
16
17
  default: obj
@@ -27,14 +28,12 @@ const styles = {
27
28
  width: '100%'
28
29
  })
29
30
  };
30
- const isResourceLink = (link)=>!!link.urn;
31
- function LinkedBlockWrapper({ attributes , card , children , element }) {
32
- const link = element.data.target.sys;
31
+ function LinkedBlockWrapper({ attributes , card , children , link }) {
33
32
  return _react.default.createElement("div", {
34
33
  ...attributes,
35
34
  className: styles.root,
36
- "data-entity-type": link.linkType,
37
- "data-entity-id": isResourceLink(link) ? link.urn : link.id,
35
+ "data-entity-type": link.sys.linkType,
36
+ "data-entity-id": (0, _utils.getLinkEntityId)(link),
38
37
  contentEditable: _environment.IS_CHROME ? undefined : false,
39
38
  draggable: _environment.IS_CHROME ? true : undefined
40
39
  }, _react.default.createElement("div", {
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "LinkedInlineWrapper", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return LinkedInlineWrapper;
9
+ }
10
+ });
11
+ const _react = _interop_require_wildcard(require("react"));
12
+ const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
13
+ const _emotion = require("emotion");
14
+ const _environment = require("../../helpers/environment");
15
+ const _utils = require("./utils");
16
+ function _interop_require_default(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ function _getRequireWildcardCache(nodeInterop) {
22
+ if (typeof WeakMap !== "function") return null;
23
+ var cacheBabelInterop = new WeakMap();
24
+ var cacheNodeInterop = new WeakMap();
25
+ return (_getRequireWildcardCache = function(nodeInterop) {
26
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
27
+ })(nodeInterop);
28
+ }
29
+ function _interop_require_wildcard(obj, nodeInterop) {
30
+ if (!nodeInterop && obj && obj.__esModule) {
31
+ return obj;
32
+ }
33
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
34
+ return {
35
+ default: obj
36
+ };
37
+ }
38
+ var cache = _getRequireWildcardCache(nodeInterop);
39
+ if (cache && cache.has(obj)) {
40
+ return cache.get(obj);
41
+ }
42
+ var newObj = {};
43
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
44
+ for(var key in obj){
45
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
46
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
47
+ if (desc && (desc.get || desc.set)) {
48
+ Object.defineProperty(newObj, key, desc);
49
+ } else {
50
+ newObj[key] = obj[key];
51
+ }
52
+ }
53
+ }
54
+ newObj.default = obj;
55
+ if (cache) {
56
+ cache.set(obj, newObj);
57
+ }
58
+ return newObj;
59
+ }
60
+ const styles = {
61
+ icon: (0, _emotion.css)({
62
+ marginRight: '10px'
63
+ }),
64
+ root: (0, _emotion.css)({
65
+ display: 'inline-block',
66
+ margin: `0 ${_f36tokens.default.spacing2Xs}`,
67
+ fontSize: 'inherit',
68
+ span: {
69
+ userSelect: 'none'
70
+ }
71
+ })
72
+ };
73
+ function LinkedInlineWrapper({ attributes , card , children , link }) {
74
+ return _react.createElement("span", {
75
+ ...attributes,
76
+ className: styles.root,
77
+ "data-entity-type": link.sys.linkType,
78
+ "data-entity-id": (0, _utils.getLinkEntityId)(link),
79
+ contentEditable: _environment.IS_CHROME ? undefined : false,
80
+ draggable: _environment.IS_CHROME ? true : undefined
81
+ }, _react.createElement("span", {
82
+ contentEditable: _environment.IS_CHROME ? false : undefined,
83
+ draggable: _environment.IS_CHROME ? true : undefined
84
+ }, card), children);
85
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ResourceNewBadge", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ResourceNewBadge;
9
+ }
10
+ });
11
+ const _react = _interop_require_wildcard(require("react"));
12
+ const _f36components = require("@contentful/f36-components");
13
+ function _getRequireWildcardCache(nodeInterop) {
14
+ if (typeof WeakMap !== "function") return null;
15
+ var cacheBabelInterop = new WeakMap();
16
+ var cacheNodeInterop = new WeakMap();
17
+ return (_getRequireWildcardCache = function(nodeInterop) {
18
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
19
+ })(nodeInterop);
20
+ }
21
+ function _interop_require_wildcard(obj, nodeInterop) {
22
+ if (!nodeInterop && obj && obj.__esModule) {
23
+ return obj;
24
+ }
25
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
26
+ return {
27
+ default: obj
28
+ };
29
+ }
30
+ var cache = _getRequireWildcardCache(nodeInterop);
31
+ if (cache && cache.has(obj)) {
32
+ return cache.get(obj);
33
+ }
34
+ var newObj = {};
35
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
36
+ for(var key in obj){
37
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
38
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
39
+ if (desc && (desc.get || desc.set)) {
40
+ Object.defineProperty(newObj, key, desc);
41
+ } else {
42
+ newObj[key] = obj[key];
43
+ }
44
+ }
45
+ }
46
+ newObj.default = obj;
47
+ if (cache) {
48
+ cache.set(obj, newObj);
49
+ }
50
+ return newObj;
51
+ }
52
+ const ResourceNewBadge = ()=>{
53
+ return _react.createElement(_react.Fragment, null, ' ', "(different space)", ' ', _react.createElement(_f36components.Badge, {
54
+ variant: "primary-filled",
55
+ size: "small"
56
+ }, "new"));
57
+ };
@@ -10,7 +10,7 @@ const _react1 = require("@testing-library/react");
10
10
  const _published_content_typejson = _interop_require_default(require("../__fixtures__/published_content_type.json"));
11
11
  const _published_entryjson = _interop_require_default(require("../__fixtures__/published_entry.json"));
12
12
  const _spacejson = _interop_require_default(require("../__fixtures__/space.json"));
13
- const _FetchingWrappedResourceCard = require("../FetchingWrappedResourceCard");
13
+ const _FetchingWrappedResourceBlockCard = require("../../EmbeddedResourceBlock/FetchingWrappedResourceBlockCard");
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
16
16
  default: obj
@@ -111,7 +111,7 @@ beforeEach(()=>{
111
111
  function renderResourceCard({ linkType ='Contentful:Entry' , entryUrn =resolvableEntryUrn } = {}) {
112
112
  return (0, _react1.render)(_react.createElement(_fieldeditorreference.EntityProvider, {
113
113
  sdk: sdk
114
- }, _react.createElement(_FetchingWrappedResourceCard.FetchingWrappedResourceCard, {
114
+ }, _react.createElement(_FetchingWrappedResourceBlockCard.FetchingWrappedResourceBlockCard, {
115
115
  isDisabled: false,
116
116
  isSelected: false,
117
117
  sdk: sdk,
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getLinkEntityId", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getLinkEntityId;
9
+ }
10
+ });
11
+ const isResourceLink = (link)=>!!link.sys.urn;
12
+ const getLinkEntityId = (link)=>isResourceLink(link) ? link.sys.urn : link.sys.id;
@@ -3,8 +3,8 @@ import { BLOCKS, INLINES } from '@contentful/rich-text-types';
3
3
  import { useContentfulEditor } from '../../ContentfulEditorProvider';
4
4
  import { isLinkActive } from '../../helpers/editor';
5
5
  import { isNodeTypeEnabled } from '../../helpers/validations';
6
- import { ToolbarEmbeddedEntityInlineButton } from '../../plugins/EmbeddedEntityInline';
7
6
  import { EmbeddedBlockToolbarIcon } from '../../plugins/shared/EmbeddedBlockToolbarIcon';
7
+ import { EmbeddedInlineToolbarIcon } from '../../plugins/shared/EmbeddedInlineToolbarIcon';
8
8
  import { useSdkContext } from '../../SdkProvider';
9
9
  import { EmbeddedEntityDropdownButton } from './EmbeddedEntityDropdownButton';
10
10
  export const EmbedEntityWidget = ({ isDisabled , canInsertBlocks })=>{
@@ -14,6 +14,7 @@ export const EmbedEntityWidget = ({ isDisabled , canInsertBlocks })=>{
14
14
  const onCloseEntityDropdown = ()=>setEmbedDropdownOpen(false);
15
15
  const onToggleEntityDropdown = ()=>setEmbedDropdownOpen(!isEmbedDropdownOpen);
16
16
  const inlineEntryEmbedEnabled = isNodeTypeEnabled(sdk.field, INLINES.EMBEDDED_ENTRY);
17
+ const inlineResourceEmbedEnabled = isNodeTypeEnabled(sdk.field, INLINES.EMBEDDED_RESOURCE);
17
18
  const blockEntryEmbedEnabled = isNodeTypeEnabled(sdk.field, BLOCKS.EMBEDDED_ENTRY) && canInsertBlocks;
18
19
  const blockResourceEmbedEnabled = isNodeTypeEnabled(sdk.field, BLOCKS.EMBEDDED_RESOURCE) && canInsertBlocks;
19
20
  const blockAssetEmbedEnabled = isNodeTypeEnabled(sdk.field, BLOCKS.EMBEDDED_ASSET) && canInsertBlocks;
@@ -25,7 +26,12 @@ export const EmbedEntityWidget = ({ isDisabled , canInsertBlocks })=>{
25
26
  isDisabled: !!isDisabled,
26
27
  nodeType: BLOCKS.EMBEDDED_RESOURCE,
27
28
  onClose: onCloseEntityDropdown
28
- }), inlineEntryEmbedEnabled && React.createElement(ToolbarEmbeddedEntityInlineButton, {
29
+ }), inlineEntryEmbedEnabled && React.createElement(EmbeddedInlineToolbarIcon, {
30
+ nodeType: INLINES.EMBEDDED_ENTRY,
31
+ isDisabled: !!isDisabled || isLinkActive(editor),
32
+ onClose: onCloseEntityDropdown
33
+ }), inlineResourceEmbedEnabled && React.createElement(EmbeddedInlineToolbarIcon, {
34
+ nodeType: INLINES.EMBEDDED_RESOURCE,
29
35
  isDisabled: !!isDisabled || isLinkActive(editor),
30
36
  onClose: onCloseEntityDropdown
31
37
  }), blockAssetEmbedEnabled && React.createElement(EmbeddedBlockToolbarIcon, {
@@ -157,6 +157,9 @@ export default {
157
157
  },
158
158
  [INLINES.EMBEDDED_ENTRY]: {
159
159
  isVoid: true
160
+ },
161
+ [INLINES.EMBEDDED_RESOURCE]: {
162
+ isVoid: true
160
163
  }
161
164
  }
162
165
  };
@@ -1,11 +1,12 @@
1
+ import getAllowedResourcesForNodeType from './getAllowedResourcesForNodeType';
1
2
  import getLinkedContentTypeIdsForNodeType from './getLinkedContentTypeIdsForNodeType';
2
- export default function newEntitySelectorConfigFromRichTextField(field, nodeType) {
3
+ export const newEntitySelectorConfigFromRichTextField = (field, nodeType)=>{
3
4
  return {
4
5
  entityType: getEntityTypeFromRichTextNode(nodeType),
5
6
  locale: field.locale || null,
6
7
  contentTypes: getLinkedContentTypeIdsForNodeType(field, nodeType)
7
8
  };
8
- }
9
+ };
9
10
  function getEntityTypeFromRichTextNode(nodeType) {
10
11
  const words = nodeType.split('-');
11
12
  if (words.indexOf('entry') !== -1) {
@@ -16,3 +17,8 @@ function getEntityTypeFromRichTextNode(nodeType) {
16
17
  }
17
18
  throw new Error(`RichText node type \`${nodeType}\` has no associated \`entityType\``);
18
19
  }
20
+ export const newResourceEntitySelectorConfigFromRichTextField = (field, nodeType)=>{
21
+ return {
22
+ allowedResources: getAllowedResourcesForNodeType(field, nodeType)
23
+ };
24
+ };
@@ -6,11 +6,13 @@ export function createDragAndDropPlugin() {
6
6
  BLOCKS.EMBEDDED_ASSET,
7
7
  BLOCKS.EMBEDDED_RESOURCE,
8
8
  BLOCKS.HR,
9
- INLINES.EMBEDDED_ENTRY
9
+ INLINES.EMBEDDED_ENTRY,
10
+ INLINES.EMBEDDED_RESOURCE
10
11
  ];
11
12
  const ON_DROP_ALLOWED_TYPES = {
12
13
  TABLE: [
13
- INLINES.EMBEDDED_ENTRY
14
+ INLINES.EMBEDDED_ENTRY,
15
+ INLINES.EMBEDDED_RESOURCE
14
16
  ]
15
17
  };
16
18
  return {
@@ -57,6 +57,6 @@ export function LinkedEntityBlock(props) {
57
57
  onEdit: handleEditClick,
58
58
  onEntityFetchComplete: onEntityFetchComplete
59
59
  })),
60
- element: element
60
+ link: element.data.target
61
61
  }, children);
62
62
  }