@contentful/field-editor-rich-text 3.12.7 → 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 (48) hide show
  1. package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +6 -0
  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/EmbeddedEntityInline/index.js +21 -4
  6. package/dist/cjs/plugins/{shared/FetchingWrappedResourceCard.js → EmbeddedResourceBlock/FetchingWrappedResourceBlockCard.js} +3 -3
  7. package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +2 -2
  8. package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +102 -0
  9. package/dist/cjs/plugins/EmbeddedResourceInline/LinkedResourceInline.js +51 -0
  10. package/dist/cjs/plugins/EmbeddedResourceInline/index.js +56 -0
  11. package/dist/cjs/plugins/index.js +2 -0
  12. package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +2 -4
  13. package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +3 -4
  14. package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +11 -6
  15. package/dist/cjs/plugins/shared/EmbeddedInlineUtil.js +66 -27
  16. package/dist/cjs/plugins/shared/ResourceNewBadge.js +57 -0
  17. package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +2 -2
  18. package/dist/esm/Toolbar/components/EmbedEntityWidget.js +6 -0
  19. package/dist/esm/constants/Schema.js +3 -0
  20. package/dist/esm/helpers/{newEntitySelectorConfigFromRichTextField.js → config.js} +8 -2
  21. package/dist/esm/plugins/DragAndDrop/index.js +4 -2
  22. package/dist/esm/plugins/EmbeddedEntityInline/index.js +22 -5
  23. package/dist/esm/plugins/{shared/FetchingWrappedResourceCard.js → EmbeddedResourceBlock/FetchingWrappedResourceBlockCard.js} +1 -1
  24. package/dist/esm/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +2 -2
  25. package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +53 -0
  26. package/dist/esm/plugins/EmbeddedResourceInline/LinkedResourceInline.js +36 -0
  27. package/dist/esm/plugins/EmbeddedResourceInline/index.js +46 -0
  28. package/dist/esm/plugins/index.js +2 -0
  29. package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +3 -5
  30. package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +1 -2
  31. package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +12 -7
  32. package/dist/esm/plugins/shared/EmbeddedInlineUtil.js +64 -25
  33. package/dist/esm/plugins/shared/ResourceNewBadge.js +8 -0
  34. package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +2 -2
  35. package/dist/types/constants/Schema.d.ts +3 -0
  36. package/dist/types/helpers/config.d.ts +33 -0
  37. package/dist/types/plugins/{shared/FetchingWrappedResourceCard.d.ts → EmbeddedResourceBlock/FetchingWrappedResourceBlockCard.d.ts} +2 -2
  38. package/dist/types/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.d.ts +13 -0
  39. package/dist/types/plugins/EmbeddedResourceInline/LinkedResourceInline.d.ts +13 -0
  40. package/dist/types/plugins/EmbeddedResourceInline/index.d.ts +3 -0
  41. package/dist/types/plugins/shared/EmbeddedInlineToolbarIcon.d.ts +2 -1
  42. package/dist/types/plugins/shared/EmbeddedInlineUtil.d.ts +3 -17
  43. package/dist/types/plugins/shared/ResourceNewBadge.d.ts +2 -0
  44. package/package.json +2 -2
  45. package/dist/cjs/helpers/newResourceEntitySelectorConfigFromRichTextField.js +0 -21
  46. package/dist/esm/helpers/newResourceEntitySelectorConfigFromRichTextField.js +0 -6
  47. package/dist/types/helpers/newEntitySelectorConfigFromRichTextField.d.ts +0 -14
  48. package/dist/types/helpers/newResourceEntitySelectorConfigFromRichTextField.d.ts +0 -16
@@ -0,0 +1,33 @@
1
+ import { FieldAPI } from '@contentful/app-sdk';
2
+ /**
3
+ * Returns a config for the entity selector based on a given rich text field and a
4
+ * rich text node type that the entity should be picked for. Takes the field
5
+ * validations for the given node type into account.
6
+ *
7
+ * @param {object} field
8
+ * @param {string} nodeType
9
+ * @returns {object}
10
+ */
11
+ type EntitySelectorConfig = {
12
+ entityType: string;
13
+ locale: string | null;
14
+ contentTypes: string[];
15
+ };
16
+ export declare const newEntitySelectorConfigFromRichTextField: (field: FieldAPI, nodeType: any) => EntitySelectorConfig;
17
+ /**
18
+ * Returns a config for the entity selector based on a given rich text field and a
19
+ * rich text node type that the entity should be picked for. Takes the field
20
+ * validations for the given node type into account.
21
+ *
22
+ * @param {object} field
23
+ * @param {string} nodeType
24
+ * @returns {object}
25
+ */
26
+ export declare const newResourceEntitySelectorConfigFromRichTextField: (field: any, nodeType: any) => {
27
+ allowedResources: {
28
+ type: "Contentful:Entry";
29
+ source: string;
30
+ contentTypes: string[];
31
+ }[];
32
+ };
33
+ export {};
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FieldAppSDK } from '@contentful/app-sdk';
3
3
  import { ResourceLink } from '@contentful/rich-text-types';
4
- interface FetchingWrappedResourceCardProps {
4
+ interface FetchingWrappedResourceBlockCardProps {
5
5
  link: ResourceLink['sys'];
6
6
  isDisabled: boolean;
7
7
  isSelected: boolean;
@@ -10,5 +10,5 @@ interface FetchingWrappedResourceCardProps {
10
10
  onEdit?: VoidFunction;
11
11
  onRemove?: VoidFunction;
12
12
  }
13
- export declare const FetchingWrappedResourceCard: (props: FetchingWrappedResourceCardProps) => React.JSX.Element;
13
+ export declare const FetchingWrappedResourceBlockCard: (props: FetchingWrappedResourceBlockCardProps) => React.JSX.Element;
14
14
  export {};
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { ResourceLink } from '@contentful/field-editor-reference';
3
+ import { FieldAppSDK } from '@contentful/field-editor-shared';
4
+ interface FetchingWrappedResourceInlineCardProps {
5
+ link: ResourceLink['sys'];
6
+ sdk: FieldAppSDK;
7
+ isSelected: boolean;
8
+ isDisabled: boolean;
9
+ onRemove: (event: React.MouseEvent<Element, MouseEvent>) => void;
10
+ onEntityFetchComplete?: VoidFunction;
11
+ }
12
+ export declare function FetchingWrappedResourceInlineCard(props: FetchingWrappedResourceInlineCardProps): React.JSX.Element;
13
+ export {};
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ResourceLink } from '@contentful/field-editor-reference';
3
+ import { Element, RenderElementProps } from '../../internal';
4
+ export type LinkedResourceInlineProps = {
5
+ element: Element & {
6
+ data: {
7
+ target: ResourceLink;
8
+ };
9
+ };
10
+ attributes: Pick<RenderElementProps, 'attributes'>;
11
+ children: Pick<RenderElementProps, 'children'>;
12
+ };
13
+ export declare function LinkedResourceInline(props: LinkedResourceInlineProps): React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { FieldAppSDK } from '@contentful/app-sdk';
2
+ import { PlatePlugin } from '../../internal';
3
+ export declare function createEmbeddedResourceInlinePlugin(sdk: FieldAppSDK): PlatePlugin;
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
2
  interface EmbeddedInlineToolbarIconProps {
3
3
  onClose: () => void;
4
+ nodeType: string;
4
5
  isDisabled: boolean;
5
6
  }
6
- export declare function EmbeddedInlineToolbarIcon(props: EmbeddedInlineToolbarIconProps): React.JSX.Element;
7
+ export declare function EmbeddedInlineToolbarIcon({ onClose, nodeType, isDisabled, }: EmbeddedInlineToolbarIconProps): React.JSX.Element;
7
8
  export {};
@@ -3,20 +3,6 @@ import { INLINES } from '@contentful/rich-text-types';
3
3
  import { HotkeyPlugin } from '@udecode/plate-common';
4
4
  import { KeyboardHandler } from '../../internal/types';
5
5
  import { TrackingPluginActions } from '../../plugins/Tracking';
6
- export declare function getWithEmbeddedEntryInlineEvents(sdk: FieldAppSDK): KeyboardHandler<HotkeyPlugin>;
7
- export declare function selectEntityAndInsert(editor: any, sdk: FieldAppSDK, logAction: TrackingPluginActions['onShortcutAction'] | TrackingPluginActions['onToolbarAction']): Promise<void>;
8
- export declare function createInlineEntryNode(id: string): {
9
- type: INLINES;
10
- children: {
11
- text: string;
12
- }[];
13
- data: {
14
- target: {
15
- sys: {
16
- id: string;
17
- type: string;
18
- linkType: string;
19
- };
20
- };
21
- };
22
- };
6
+ export declare function getWithEmbeddedEntryInlineEvents(nodeType: INLINES.EMBEDDED_ENTRY | INLINES.EMBEDDED_RESOURCE, sdk: FieldAppSDK): KeyboardHandler<HotkeyPlugin>;
7
+ export declare function selectEntityAndInsert(editor: any, sdk: any, logAction: TrackingPluginActions['onShortcutAction'] | TrackingPluginActions['onToolbarAction']): Promise<void>;
8
+ export declare function selectResourceEntityAndInsert(editor: any, sdk: any, logAction: TrackingPluginActions['onToolbarAction'] | TrackingPluginActions['onShortcutAction']): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const ResourceNewBadge: () => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "3.12.7",
3
+ "version": "3.13.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": "3ae9c46f02565c17a9323b1d319950bbb5adc900"
84
+ "gitHead": "8cbc98b0d9bd617de2199269659c6ce16807fbeb"
85
85
  }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return newResourceEntitySelectorConfigFromRichTextField;
9
- }
10
- });
11
- const _getAllowedResourcesForNodeType = _interop_require_default(require("./getAllowedResourcesForNodeType"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
- function newResourceEntitySelectorConfigFromRichTextField(field, nodeType) {
18
- return {
19
- allowedResources: (0, _getAllowedResourcesForNodeType.default)(field, nodeType)
20
- };
21
- }
@@ -1,6 +0,0 @@
1
- import getAllowedResourcesForNodeType from './getAllowedResourcesForNodeType';
2
- export default function newResourceEntitySelectorConfigFromRichTextField(field, nodeType) {
3
- return {
4
- allowedResources: getAllowedResourcesForNodeType(field, nodeType)
5
- };
6
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Returns a config for the entity selector based on a given rich text field and a
3
- * rich text node type that the entity should be picked for. Takes the field
4
- * validations for the given node type into account.
5
- *
6
- * @param {object} field
7
- * @param {string} nodeType
8
- * @returns {object}
9
- */
10
- export default function newEntitySelectorConfigFromRichTextField(field: any, nodeType: any): {
11
- entityType: "Entry" | "Asset";
12
- locale: any;
13
- contentTypes: string[];
14
- };
@@ -1,16 +0,0 @@
1
- /**
2
- * Returns a config for the entity selector based on a given rich text field and a
3
- * rich text node type that the entity should be picked for. Takes the field
4
- * validations for the given node type into account.
5
- *
6
- * @param {object} field
7
- * @param {string} nodeType
8
- * @returns {object}
9
- */
10
- export default function newResourceEntitySelectorConfigFromRichTextField(field: any, nodeType: any): {
11
- allowedResources: {
12
- type: "Contentful:Entry";
13
- source: string;
14
- contentTypes: string[];
15
- }[];
16
- };