@forge/react 12.2.0-next.3-experimental-cb8d386 → 12.2.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/CHANGELOG.md +9 -2
- package/out/__test__/components/utils/replaceUnsupportedDocumentNodes.test.js +27 -8
- package/out/components/utils/replaceUnsupportedDocumentNodes.d.ts +3 -1
- package/out/components/utils/replaceUnsupportedDocumentNodes.d.ts.map +1 -1
- package/package.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
# @forge/react
|
|
2
2
|
|
|
3
|
-
## 12.2.0
|
|
3
|
+
## 12.2.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
7
|
- 92f9eba: Add `MenuSection` to `@forge/react/global` for grouping sidebar menu items under an optional heading.
|
|
8
8
|
- 191cb4a: Bumped @forge/react package to 2.7.0 to include forYouMenuItem prop
|
|
9
|
+
- c71379f: fix adf type
|
|
9
10
|
|
|
10
11
|
### Patch Changes
|
|
11
12
|
|
|
12
13
|
- Updated dependencies [f1d1bd8]
|
|
13
14
|
- Updated dependencies [406407c]
|
|
14
15
|
- Updated dependencies [b844adb]
|
|
15
|
-
- @forge/bridge@7.0.0
|
|
16
|
+
- @forge/bridge@7.0.0
|
|
17
|
+
|
|
18
|
+
## 12.2.0-next.4
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- c71379f: fix adf type
|
|
16
23
|
|
|
17
24
|
## 12.2.0-next.3
|
|
18
25
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const expect_type_1 = require("expect-type");
|
|
4
|
+
const index_1 = require("../../../index");
|
|
3
5
|
const replaceUnsupportedDocumentNodes_1 = require("../../../components/utils/replaceUnsupportedDocumentNodes");
|
|
4
6
|
const emojiDocumentExample = {
|
|
5
7
|
type: 'doc',
|
|
@@ -138,6 +140,23 @@ const extensionDocumentExample = {
|
|
|
138
140
|
]
|
|
139
141
|
};
|
|
140
142
|
describe('replaceUnsupportedDocumentNodes', () => {
|
|
143
|
+
it.each([index_1.replaceUnsupportedDocumentNodes, replaceUnsupportedDocumentNodes_1.replaceUnsupportedMediaNodes])('accepts and returns the renderer document type without changing supported status nodes', (replaceNodes) => {
|
|
144
|
+
(0, expect_type_1.expectTypeOf)().toEqualTypeOf();
|
|
145
|
+
(0, expect_type_1.expectTypeOf)().toEqualTypeOf();
|
|
146
|
+
const document = {
|
|
147
|
+
type: 'doc',
|
|
148
|
+
version: 1,
|
|
149
|
+
content: [
|
|
150
|
+
{
|
|
151
|
+
type: 'paragraph',
|
|
152
|
+
content: [{ type: 'status', attrs: { text: 'In progress', color: 'blue' } }]
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
};
|
|
156
|
+
const replaceUnsupportedNode = jest.fn(() => false);
|
|
157
|
+
expect(replaceNodes(document, replaceUnsupportedNode)).toEqual(document);
|
|
158
|
+
expect(replaceUnsupportedNode).not.toHaveBeenCalled();
|
|
159
|
+
});
|
|
141
160
|
describe('replacing unsupported nodes with supported ones', () => {
|
|
142
161
|
const replaceUnsupportedNode = (node) => {
|
|
143
162
|
return {
|
|
@@ -151,7 +170,7 @@ describe('replaceUnsupportedDocumentNodes', () => {
|
|
|
151
170
|
};
|
|
152
171
|
};
|
|
153
172
|
it('should replace unsupported emoji with supported nodes', () => {
|
|
154
|
-
const replacedDocument = (0,
|
|
173
|
+
const replacedDocument = (0, index_1.replaceUnsupportedDocumentNodes)(emojiDocumentExample, replaceUnsupportedNode);
|
|
155
174
|
const expectedDocument = {
|
|
156
175
|
content: [
|
|
157
176
|
{
|
|
@@ -231,7 +250,7 @@ describe('replaceUnsupportedDocumentNodes', () => {
|
|
|
231
250
|
expect(replacedDocument).toEqual(expectedDocument);
|
|
232
251
|
});
|
|
233
252
|
it('should replace unsupported extension with supported nodes', () => {
|
|
234
|
-
const replacedDocument = (0,
|
|
253
|
+
const replacedDocument = (0, index_1.replaceUnsupportedDocumentNodes)(extensionDocumentExample, replaceUnsupportedNode);
|
|
235
254
|
const expectedDocument = {
|
|
236
255
|
type: 'doc',
|
|
237
256
|
version: 1,
|
|
@@ -302,13 +321,13 @@ describe('replaceUnsupportedDocumentNodes', () => {
|
|
|
302
321
|
}
|
|
303
322
|
]
|
|
304
323
|
};
|
|
305
|
-
const replacedDocument = (0,
|
|
324
|
+
const replacedDocument = (0, index_1.replaceUnsupportedDocumentNodes)(documentToRender, replaceUnsupportedNode);
|
|
306
325
|
expect(replacedDocument).toEqual(documentToRender);
|
|
307
326
|
});
|
|
308
327
|
describe('drop unsupported nodes when Visitor returns false', () => {
|
|
309
328
|
const replaceUnsupportedNode = () => false;
|
|
310
329
|
it('should drop unsupported emoji nodes', () => {
|
|
311
|
-
const replacedDocument = (0,
|
|
330
|
+
const replacedDocument = (0, index_1.replaceUnsupportedDocumentNodes)(emojiDocumentExample, replaceUnsupportedNode);
|
|
312
331
|
const expectedDocument = {
|
|
313
332
|
content: [
|
|
314
333
|
{
|
|
@@ -340,7 +359,7 @@ describe('replaceUnsupportedDocumentNodes', () => {
|
|
|
340
359
|
expect(replacedDocument).toEqual(expectedDocument);
|
|
341
360
|
});
|
|
342
361
|
it('should drop unsupported extension nodes', () => {
|
|
343
|
-
const replacedDocument = (0,
|
|
362
|
+
const replacedDocument = (0, index_1.replaceUnsupportedDocumentNodes)(extensionDocumentExample, replaceUnsupportedNode);
|
|
344
363
|
const expectedDocument = {
|
|
345
364
|
type: 'doc',
|
|
346
365
|
version: 1,
|
|
@@ -352,15 +371,15 @@ describe('replaceUnsupportedDocumentNodes', () => {
|
|
|
352
371
|
describe('Keep original nodes when Visitor returns undefined', () => {
|
|
353
372
|
const replaceUnsupportedNode = () => undefined;
|
|
354
373
|
it('should use original emoji nodes', () => {
|
|
355
|
-
const replacedDocument = (0,
|
|
374
|
+
const replacedDocument = (0, index_1.replaceUnsupportedDocumentNodes)(emojiDocumentExample, replaceUnsupportedNode);
|
|
356
375
|
expect(replacedDocument).toEqual(emojiDocumentExample);
|
|
357
376
|
});
|
|
358
377
|
it('should use original media node', () => {
|
|
359
|
-
const replacedDocument = (0,
|
|
378
|
+
const replacedDocument = (0, index_1.replaceUnsupportedDocumentNodes)(mediaDocumentExample, replaceUnsupportedNode);
|
|
360
379
|
expect(replacedDocument).toEqual(mediaDocumentExample);
|
|
361
380
|
});
|
|
362
381
|
it('should use original extension nodes', () => {
|
|
363
|
-
const replacedDocument = (0,
|
|
382
|
+
const replacedDocument = (0, index_1.replaceUnsupportedDocumentNodes)(extensionDocumentExample, replaceUnsupportedNode);
|
|
364
383
|
expect(replacedDocument).toEqual(extensionDocumentExample);
|
|
365
384
|
});
|
|
366
385
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AdfRendererProps } from '@atlaskit/forge-react-types';
|
|
2
2
|
import { type Visitor } from '@atlaskit/adf-utils';
|
|
3
|
+
type DocNode = AdfRendererProps['document'];
|
|
3
4
|
export declare const replaceUnsupportedDocumentNodes: (document: DocNode, replaceUnsupportedNode: Visitor) => DocNode;
|
|
4
5
|
export declare const replaceUnsupportedMediaNodes: (document: DocNode, replaceUnsupportedNode: Visitor) => DocNode;
|
|
6
|
+
export {};
|
|
5
7
|
//# sourceMappingURL=replaceUnsupportedDocumentNodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replaceUnsupportedDocumentNodes.d.ts","sourceRoot":"","sources":["../../../src/components/utils/replaceUnsupportedDocumentNodes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"replaceUnsupportedDocumentNodes.d.ts","sourceRoot":"","sources":["../../../src/components/utils/replaceUnsupportedDocumentNodes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG3E,KAAK,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAE5C,eAAO,MAAM,+BAA+B,GAAI,UAAU,OAAO,EAAE,wBAAwB,OAAO,KAAG,OAiCpG,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,UAAU,OAAO,EAAE,wBAAwB,OAAO,KAAG,OAYjG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/react",
|
|
3
|
-
"version": "12.2.0
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"description": "Forge React reconciler",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/adf-schema": "^56.7.0",
|
|
37
37
|
"@atlaskit/adf-utils": "^20.5.12",
|
|
38
38
|
"@atlaskit/forge-react-types": "^2.7.0",
|
|
39
|
-
"@forge/bridge": "^7.0.0
|
|
39
|
+
"@forge/bridge": "^7.0.0",
|
|
40
40
|
"@forge/egress": "^3.0.0",
|
|
41
41
|
"@forge/i18n": "1.0.0",
|
|
42
42
|
"@types/react": "^18.2.64",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@testing-library/react-hooks": "^8.0.1",
|
|
53
|
+
"expect-type": "^0.17.3",
|
|
53
54
|
"history": "5.3.0",
|
|
54
55
|
"ts-morph": "^22.0.0",
|
|
55
56
|
"ts-node": "^10.9.2",
|