@squiz/formatted-text-editor 2.6.3 → 2.6.5

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.
@@ -0,0 +1,2 @@
1
+ ignores: ['@remirror/*', 'prosemirror-*']
2
+ ignorePatterns: ['*.scss']
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.6.5
4
+
5
+ ### Patch Changes
6
+
7
+ - ff44594: Update to pass dam variant
8
+
9
+ ## 2.6.4
10
+
11
+ ### Patch Changes
12
+
13
+ - a63dfe8: Revise dependencies
14
+ - Updated dependencies [a63dfe8]
15
+ - @squiz/dx-json-schema-lib@1.80.1
16
+
3
17
  ## 2.6.3
4
18
 
5
19
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import DamResourceBrowserPlugin from '@squiz/dam-resource-browser-plugin';
1
+ import DamResourceBrowserPlugin, { DamResourceBrowserSource } from '@squiz/dam-resource-browser-plugin';
2
2
  import { AiServiceProvider } from '@squiz/dxp-ai-client-react';
3
3
  import MatrixResourceBrowserPlugin, {
4
4
  Resource,
@@ -11,6 +11,7 @@ import { QueryClient, QueryClientProvider } from 'react-query';
11
11
  import { EditorContext, ResolveNodeType } from '../../src';
12
12
  import resources from './resources.json';
13
13
  import sources from './sources.json';
14
+ import contentApi from './contentApi.json';
14
15
 
15
16
  export type AppContextProps = PropsWithChildren;
16
17
 
@@ -38,9 +39,36 @@ export const AppContext = ({ children }: AppContextProps) => (
38
39
  id: 'matrixIdentifier',
39
40
  type: 'matrix',
40
41
  },
42
+ {
43
+ name: 'Bynder',
44
+ id: 'bynder',
45
+ type: 'dam',
46
+ configuration: {
47
+ externalType: 'bynder',
48
+ externalRootUrl: 'https://squiz-sandbox.bynder.com',
49
+ authUrl: 'authUrl - See readme for local authToken instructions',
50
+ clientId: 'clientId - See readme for local authToken instructions',
51
+ redirectUrl: 'http://localhost:6006/',
52
+ },
53
+ } as DamResourceBrowserSource,
41
54
  ]),
42
55
  plugins: [
43
- DamResourceBrowserPlugin(),
56
+ DamResourceBrowserPlugin({
57
+ onResourceRequestProxy: () => {
58
+ return Promise.resolve({
59
+ id: 'id1',
60
+ type: 'image',
61
+ fileSize: 300,
62
+ description: 'description1',
63
+ name: 'Bynder Image',
64
+ original: 'https://picsum.photos/300/250',
65
+ height: 100,
66
+ width: 200,
67
+ extension: ['jpeg'],
68
+ thumbnails: { thul: 'https://picsum.photos/300/250' },
69
+ });
70
+ },
71
+ }),
44
72
  MatrixResourceBrowserPlugin({
45
73
  onRequestSources: (): Promise<Source> => Promise.resolve(sources),
46
74
  onRequestChildren: (source: Source, resource: Resource | null): Promise<Resource[]> =>
@@ -72,6 +100,12 @@ export const AppContext = ({ children }: AppContextProps) => (
72
100
  nextStart: null,
73
101
  },
74
102
  }),
103
+ onRequestMatrixAsset: (assetId: string) => {
104
+ return Promise.resolve({
105
+ ...contentApi,
106
+ id: assetId,
107
+ });
108
+ },
75
109
  }),
76
110
  ],
77
111
  }}
@@ -0,0 +1,21 @@
1
+ {
2
+ "id": "3",
3
+ "type": "image",
4
+ "type_name": "Image",
5
+ "name": "Image",
6
+ "short_name": "Image",
7
+ "urls": ["https://picsum.photos/300/250"],
8
+ "url": "https://picsum.photos/300/250",
9
+ "attributes": {
10
+ "name": "Image",
11
+ "title": "Image",
12
+ "width": 640,
13
+ "height": 438,
14
+ "size": 99384,
15
+ "variety_count": 5,
16
+ "allow_unrestricted": true,
17
+ "caption": "",
18
+ "alt": ""
19
+ },
20
+ "children": []
21
+ }
@@ -1,5 +1,7 @@
1
+ @import '../../../../node_modules/@squiz/sds/lib/package.css';
1
2
  @import '../../../../node_modules/@squiz/resource-browser/lib/index.css';
2
3
  @import '../../../../node_modules/@squiz/matrix-resource-browser-plugin/lib/index.css';
4
+ @import '../../../../node_modules/@squiz/dam-resource-browser-plugin/lib/index.css';
3
5
 
4
6
  body {
5
7
  font-family: 'Open Sans';
package/lib/index.css CHANGED
@@ -5654,7 +5654,7 @@
5654
5654
  top: -12px;
5655
5655
  width: 0;
5656
5656
  }
5657
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n + 2) {
5657
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n+2) {
5658
5658
  cursor: pointer;
5659
5659
  height: 12px;
5660
5660
  overflow: visible;
@@ -5662,7 +5662,7 @@
5662
5662
  position: relative;
5663
5663
  z-index: 15;
5664
5664
  }
5665
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n + 2) div.remirror-table-controller-wrapper {
5665
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n+2) div.remirror-table-controller-wrapper {
5666
5666
  align-items: flex-end;
5667
5667
  display: flex;
5668
5668
  flex-direction: row;
@@ -5671,16 +5671,16 @@
5671
5671
  overflow: visible;
5672
5672
  width: 100%;
5673
5673
  }
5674
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n + 2) div.remirror-table-controller-trigger-area {
5674
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n+2) div.remirror-table-controller-trigger-area {
5675
5675
  flex: 1;
5676
5676
  height: 36px;
5677
5677
  position: relative;
5678
5678
  z-index: 10;
5679
5679
  }
5680
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n + 2) div.remirror-table-controller-mark-row-corner {
5680
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n+2) div.remirror-table-controller-mark-row-corner {
5681
5681
  display: none;
5682
5682
  }
5683
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n + 2) div.remirror-table-controller-mark-column-corner {
5683
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:first-of-type th:nth-of-type(n+2) div.remirror-table-controller-mark-column-corner {
5684
5684
  border-color: var(--rmr-color-table-mark);
5685
5685
  border-radius: 50%;
5686
5686
  border-style: solid;
@@ -5691,7 +5691,7 @@
5691
5691
  top: -12px;
5692
5692
  width: 0;
5693
5693
  }
5694
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n + 2) th {
5694
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n+2) th {
5695
5695
  cursor: pointer;
5696
5696
  overflow: visible;
5697
5697
  padding: 0;
@@ -5699,7 +5699,7 @@
5699
5699
  width: 12px;
5700
5700
  z-index: 15;
5701
5701
  }
5702
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n + 2) th div.remirror-table-controller-wrapper {
5702
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n+2) th div.remirror-table-controller-wrapper {
5703
5703
  align-items: flex-end;
5704
5704
  display: flex;
5705
5705
  flex-direction: column;
@@ -5708,13 +5708,13 @@
5708
5708
  overflow: visible;
5709
5709
  width: 12px;
5710
5710
  }
5711
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n + 2) th div.remirror-table-controller-trigger-area {
5711
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n+2) th div.remirror-table-controller-trigger-area {
5712
5712
  flex: 1;
5713
5713
  position: relative;
5714
5714
  width: 36px;
5715
5715
  z-index: 10;
5716
5716
  }
5717
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n + 2) th div.remirror-table-controller-mark-row-corner {
5717
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n+2) th div.remirror-table-controller-mark-row-corner {
5718
5718
  border-color: var(--rmr-color-table-mark);
5719
5719
  border-radius: 50%;
5720
5720
  border-style: solid;
@@ -5725,7 +5725,7 @@
5725
5725
  position: absolute;
5726
5726
  width: 0;
5727
5727
  }
5728
- .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n + 2) th div.remirror-table-controller-mark-column-corner {
5728
+ .squiz-fte-scope .remirror-table-tbody-with-controllers > tr:nth-of-type(n+2) th div.remirror-table-controller-mark-column-corner {
5729
5729
  display: none;
5730
5730
  }
5731
5731
  .squiz-fte-scope .remirror-table-tbody-with-controllers th.remirror-table-controller {
@@ -9,6 +9,9 @@ type DAMAsset = {
9
9
  damSystemIdentifier?: string;
10
10
  damObjectId?: string;
11
11
  damSystemType?: string;
12
+ damAdditional?: {
13
+ variant: string;
14
+ };
12
15
  };
13
16
  type ResourceBrowserSelectorValue = MatrixAsset & DAMAsset & {
14
17
  nodeType?: NodeName;
@@ -40,6 +40,7 @@ const ResourceBrowserSelector = ({ modalTitle, allowedTypes, value, onChange, ..
40
40
  return {
41
41
  sourceId: value.damSystemIdentifier,
42
42
  resourceId: value.damObjectId,
43
+ variant: value.damAdditional?.variant,
43
44
  };
44
45
  }
45
46
  return null;
@@ -53,6 +54,7 @@ const ResourceBrowserSelector = ({ modalTitle, allowedTypes, value, onChange, ..
53
54
  damSystemIdentifier: undefined,
54
55
  damObjectId: undefined,
55
56
  damSystemType: undefined,
57
+ damAdditional: undefined,
56
58
  url: undefined,
57
59
  };
58
60
  if (resource?.source?.type === 'matrix') {
@@ -65,11 +67,17 @@ const ResourceBrowserSelector = ({ modalTitle, allowedTypes, value, onChange, ..
65
67
  };
66
68
  }
67
69
  else if (resource?.source?.type === 'dam') {
70
+ const damResource = resource;
68
71
  onChangeData = {
69
72
  ...value,
70
73
  damSystemIdentifier: resource?.source?.id,
71
74
  damObjectId: resource?.id,
72
75
  damSystemType: (resource?.source).configuration.externalType,
76
+ damAdditional: damResource.variant
77
+ ? {
78
+ variant: damResource.variant,
79
+ }
80
+ : undefined,
73
81
  url: resource?.url,
74
82
  nodeType: Extensions_1.NodeName.DAMImage,
75
83
  };
@@ -115,12 +115,16 @@ const transformNode = (node) => {
115
115
  };
116
116
  }
117
117
  if (node.type.name === Extensions_1.NodeName.DAMImage) {
118
+ let damAdditional = node.attrs.damAdditional;
119
+ if (damAdditional && typeof node.attrs.damAdditional === 'string') {
120
+ damAdditional = JSON.parse(node.attrs.damAdditional);
121
+ }
118
122
  transformedNode = {
119
123
  type: 'dam-image',
120
124
  damObjectId: node.attrs.damObjectId,
121
125
  damSystemIdentifier: node.attrs.damSystemIdentifier,
122
126
  damSystemType: node.attrs.damSystemType,
123
- damAdditional: node.attrs.damAdditional ? JSON.parse(node.attrs.damAdditional) : undefined,
127
+ damAdditional,
124
128
  };
125
129
  }
126
130
  node.marks.forEach((mark) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/formatted-text-editor",
3
- "version": "2.6.3",
3
+ "version": "2.6.5",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "private": false,
@@ -25,7 +25,7 @@
25
25
  "@mui/icons-material": "5.15.18",
26
26
  "@remirror/extension-react-tables": "^2.2.21",
27
27
  "@remirror/react": "2.0.35",
28
- "@squiz/dx-json-schema-lib": "^1.74.1",
28
+ "@squiz/dx-json-schema-lib": "^1.80.1",
29
29
  "@squiz/dxp-content-tools-modal": "^0.4.0",
30
30
  "clsx": "2.1.1",
31
31
  "react-hook-form": "7.51.4",
@@ -33,28 +33,29 @@
33
33
  "remirror": "2.0.39"
34
34
  },
35
35
  "devDependencies": {
36
- "@squiz/dam-resource-browser-plugin": "^3.1.0-rc.1",
36
+ "@squiz/dam-resource-browser-plugin": "^3.2.7",
37
37
  "@squiz/dxp-ai-client-react": "^1.0.0",
38
- "@squiz/matrix-resource-browser-plugin": "^3.1.0-rc.5",
39
- "@squiz/resource-browser": "^3.1.0-rc.0",
38
+ "@squiz/matrix-resource-browser-plugin": "^3.3.1",
39
+ "@squiz/resource-browser": "^3.2.2",
40
40
  "@squiz/sds": "^1.5.0",
41
- "@testing-library/cypress": "9.0.0",
41
+ "@testing-library/cypress": "^10.0.2",
42
42
  "@testing-library/jest-dom": "5.16.5",
43
43
  "@testing-library/react": "14.0.0",
44
44
  "@testing-library/user-event": "14.4.3",
45
- "@types/node": "20.12.4",
45
+ "@types/node": "22.10.5",
46
46
  "@types/react": "^18.2.45",
47
47
  "@types/react-dom": "^18.2.18",
48
48
  "@vitejs/plugin-react": "3.0.0",
49
49
  "autoprefixer": "10.4.13",
50
- "cypress": "12.5.1",
50
+ "cypress": "^13.17.0",
51
51
  "deepmerge": "4.3.0",
52
+ "esbuild": "^0.24.2",
52
53
  "esbuild-sass-plugin": "^2.8.0",
53
54
  "eslint-plugin-cypress": "2.12.1",
55
+ "eslint-plugin-jest": "^27.2.1",
54
56
  "eslint-plugin-jsx-a11y": "6.7.1",
55
57
  "eslint-plugin-react": "7.32.2",
56
58
  "jest": "29.4.1",
57
- "jest-environment-jsdom": "29.4.1",
58
59
  "jest-remirror": "2.1.5",
59
60
  "postcss": "8.4.31",
60
61
  "postcss-nested": "6.0.0",
@@ -63,17 +64,16 @@
63
64
  "react-diff-viewer-continued": "3.2.6",
64
65
  "react-dom": "18.2.0",
65
66
  "react-query": "^3.19.6",
66
- "rimraf": "5.0.7",
67
67
  "tailwindcss": "3.2.6",
68
68
  "ts-jest": "29.0.5",
69
69
  "typescript": "4.9.3",
70
70
  "vite": "^4.5.3"
71
71
  },
72
72
  "peerDependencies": {
73
- "@squiz/dam-resource-browser-plugin": "^3.1.0-rc.1",
73
+ "@squiz/dam-resource-browser-plugin": "^3.1.0",
74
74
  "@squiz/dxp-ai-client-react": "^1.0.0",
75
- "@squiz/matrix-resource-browser-plugin": "^3.1.0-rc.5",
76
- "@squiz/resource-browser": "^3.1.0-rc.0",
75
+ "@squiz/matrix-resource-browser-plugin": "^3.1.0",
76
+ "@squiz/resource-browser": "^3.1.0",
77
77
  "@squiz/sds": "^1.5.0",
78
78
  "@types/react": "^16.14.0 || ^17 || ^18",
79
79
  "@types/react-dom": "^16.9.0 || ^17 || ^18",
@@ -442,6 +442,7 @@ describe('Formatted text editor', () => {
442
442
  onRequestChildren,
443
443
  onRequestResource,
444
444
  onSearchRequest: jest.fn(),
445
+ onRequestMatrixAsset: jest.fn(),
445
446
  } as MatrixResourceBrowserPluginProps,
446
447
  });
447
448
 
@@ -57,7 +57,6 @@ describe('ResourceBrowserSelector', () => {
57
57
  value={{
58
58
  damObjectId: '123-456-789',
59
59
  damSystemIdentifier: 'zzz-xxx-ccc',
60
- additional: 'addditional data',
61
60
  }}
62
61
  onChange={jest.fn()}
63
62
  />,
@@ -71,6 +70,30 @@ describe('ResourceBrowserSelector', () => {
71
70
  },
72
71
  }),
73
72
  );
73
+
74
+ render(
75
+ <ResourceBrowserSelector
76
+ modalTitle="Insert asset"
77
+ value={{
78
+ damObjectId: '123-456-789',
79
+ damSystemIdentifier: 'zzz-xxx-ccc',
80
+ damAdditional: {
81
+ variant: 'v1',
82
+ },
83
+ }}
84
+ onChange={jest.fn()}
85
+ />,
86
+ );
87
+
88
+ expect(resourceBrowserSpy).toHaveBeenCalledWith(
89
+ expect.objectContaining({
90
+ value: {
91
+ resourceId: '123-456-789',
92
+ sourceId: 'zzz-xxx-ccc',
93
+ variant: 'v1',
94
+ },
95
+ }),
96
+ );
74
97
  });
75
98
 
76
99
  it('AssetImage: Calls onChange with expected value when resources is selected', async () => {
@@ -155,6 +178,53 @@ describe('ResourceBrowserSelector', () => {
155
178
  });
156
179
  });
157
180
 
181
+ it('DAMImage: Calls onChange with expected value when variant resources is selected', async () => {
182
+ const handleChange = jest.fn();
183
+ setSelectedResource({
184
+ id: 'my-resource-id',
185
+ name: 'My resource',
186
+ url: 'myResourceUrl',
187
+ source: {
188
+ id: 'my-source-id',
189
+ type: 'dam',
190
+ configuration: {
191
+ externalType: 'bynder',
192
+ },
193
+ },
194
+ variant: 'v1',
195
+ } as unknown as ResourceBrowserResource);
196
+
197
+ render(
198
+ <ResourceBrowserSelector
199
+ modalTitle="Insert asset"
200
+ value={{ matrixIdentifier: undefined, matrixAssetId: undefined, additional: 'additional data' }}
201
+ onChange={handleChange}
202
+ />,
203
+ );
204
+
205
+ // Trigger the onChange handler to be called
206
+ await waitFor(() => {
207
+ expect(screen.getByRole('button', { name: 'Select ResourceBrowser Resource' })).toBeInTheDocument();
208
+ });
209
+ fireEvent.click(await screen.findByRole('button', { name: 'Select ResourceBrowser Resource' }));
210
+
211
+ expect(handleChange).toHaveBeenCalledWith({
212
+ target: {
213
+ value: {
214
+ additional: 'additional data',
215
+ damObjectId: 'my-resource-id',
216
+ damSystemIdentifier: 'my-source-id',
217
+ damSystemType: 'bynder',
218
+ damAdditional: {
219
+ variant: 'v1',
220
+ },
221
+ url: 'myResourceUrl',
222
+ nodeType: 'DAMImage',
223
+ },
224
+ },
225
+ });
226
+ });
227
+
158
228
  it('ImageAsset: Calls onChange with expected value when resources is cleared', async () => {
159
229
  const handleChange = jest.fn();
160
230
  setSelectedResource(null);
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
- import { ResourceBrowserResource, ResourceBrowser } from '@squiz/resource-browser';
3
- import { DamResourceBrowserSource } from '@squiz/dam-resource-browser-plugin';
2
+ import { ResourceBrowserUnresolvedResource, ResourceBrowserResource, ResourceBrowser } from '@squiz/resource-browser';
3
+ import { DamResourceBrowserSource, DAMResource } from '@squiz/dam-resource-browser-plugin';
4
4
  import { InputContainer, InputContainerProps } from '../InputContainer/InputContainer';
5
5
  import { NodeName } from '../../../Extensions/Extensions';
6
6
 
@@ -12,6 +12,9 @@ type DAMAsset = {
12
12
  damSystemIdentifier?: string;
13
13
  damObjectId?: string;
14
14
  damSystemType?: string;
15
+ damAdditional?: {
16
+ variant: string;
17
+ };
15
18
  };
16
19
  type ResourceBrowserSelectorValue = MatrixAsset &
17
20
  DAMAsset & {
@@ -40,21 +43,25 @@ export const ResourceBrowserSelector = <T extends ResourceBrowserSelectorValue>(
40
43
  onChange,
41
44
  ...props
42
45
  }: ResourceBrowserSelectorProps<T>) => {
43
- const convertFormDataToResourceBrowserValue = useCallback((value: T | null) => {
44
- if (value?.matrixIdentifier && value?.matrixAssetId) {
45
- return {
46
- sourceId: value.matrixIdentifier,
47
- resourceId: value.matrixAssetId,
48
- };
49
- } else if (value?.damSystemIdentifier && value?.damObjectId) {
50
- return {
51
- sourceId: value.damSystemIdentifier,
52
- resourceId: value.damObjectId,
53
- };
54
- }
46
+ const convertFormDataToResourceBrowserValue = useCallback(
47
+ (value: T | null): ResourceBrowserUnresolvedResource | null => {
48
+ if (value?.matrixIdentifier && value?.matrixAssetId) {
49
+ return {
50
+ sourceId: value.matrixIdentifier,
51
+ resourceId: value.matrixAssetId,
52
+ };
53
+ } else if (value?.damSystemIdentifier && value?.damObjectId) {
54
+ return {
55
+ sourceId: value.damSystemIdentifier,
56
+ resourceId: value.damObjectId,
57
+ variant: value.damAdditional?.variant,
58
+ };
59
+ }
55
60
 
56
- return null;
57
- }, []);
61
+ return null;
62
+ },
63
+ [],
64
+ );
58
65
 
59
66
  const handleResourceChange = useCallback((resource: ResourceBrowserResource | null) => {
60
67
  // Clear out any key properties for clear resource use case
@@ -65,6 +72,7 @@ export const ResourceBrowserSelector = <T extends ResourceBrowserSelectorValue>(
65
72
  damSystemIdentifier: undefined,
66
73
  damObjectId: undefined,
67
74
  damSystemType: undefined,
75
+ damAdditional: undefined,
68
76
  url: undefined,
69
77
  };
70
78
 
@@ -77,11 +85,17 @@ export const ResourceBrowserSelector = <T extends ResourceBrowserSelectorValue>(
77
85
  nodeType: NodeName.AssetImage,
78
86
  };
79
87
  } else if (resource?.source?.type === 'dam') {
88
+ const damResource = resource as DAMResource;
80
89
  onChangeData = {
81
90
  ...value,
82
91
  damSystemIdentifier: resource?.source?.id,
83
92
  damObjectId: resource?.id,
84
93
  damSystemType: (resource?.source as DamResourceBrowserSource).configuration.externalType,
94
+ damAdditional: damResource.variant
95
+ ? {
96
+ variant: damResource.variant,
97
+ }
98
+ : undefined,
85
99
  url: resource?.url,
86
100
  nodeType: NodeName.DAMImage,
87
101
  };
@@ -154,12 +154,17 @@ const transformNode = (node: ProsemirrorNode): FormattedNode => {
154
154
  }
155
155
 
156
156
  if (node.type.name === NodeName.DAMImage) {
157
+ let damAdditional = node.attrs.damAdditional;
158
+ if (damAdditional && typeof node.attrs.damAdditional === 'string') {
159
+ damAdditional = JSON.parse(node.attrs.damAdditional);
160
+ }
161
+
157
162
  transformedNode = {
158
163
  type: 'dam-image',
159
164
  damObjectId: node.attrs.damObjectId,
160
165
  damSystemIdentifier: node.attrs.damSystemIdentifier,
161
166
  damSystemType: node.attrs.damSystemType,
162
- damAdditional: node.attrs.damAdditional ? JSON.parse(node.attrs.damAdditional) : undefined,
167
+ damAdditional,
163
168
  };
164
169
  }
165
170
 
@@ -46,6 +46,7 @@ export const renderWithContext = (ui: ReactElement | null, options?: ContextRend
46
46
  const onRequestChildren = jest.fn().mockResolvedValue(resources);
47
47
  const onRequestResource = jest.fn(() => Promise.resolve(resources[0]));
48
48
  const onSearchRequest = jest.fn();
49
+ const onRequestMatrixAsset = jest.fn();
49
50
  editorContext.resolveNodeToUrl = jest.fn(() => Promise.resolve(resources[0].url));
50
51
 
51
52
  return render(
@@ -67,6 +68,7 @@ export const renderWithContext = (ui: ReactElement | null, options?: ContextRend
67
68
  onRequestChildren: onRequestChildren,
68
69
  onRequestResource: onRequestResource,
69
70
  onSearchRequest,
71
+ onRequestMatrixAsset,
70
72
  }),
71
73
  ],
72
74
  }}