@atlaskit/editor-json-transformer 9.3.0 → 9.4.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
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-json-transformer
|
|
2
2
|
|
|
3
|
+
## 9.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`710e3d9ec4c65`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/710e3d9ec4c65) -
|
|
8
|
+
Add `upgradeContainerNodes` to `@atlaskit/adf-utils/transforms` — a schema-driven, flag-free
|
|
9
|
+
transform that promotes `panel` nodes to their table-allowing `panel_c1` variant wherever the
|
|
10
|
+
schema allows it (document root, layout column, synced block), regardless of the panel's content.
|
|
11
|
+
|
|
12
|
+
`JSONTransformer.parse` now applies it so table-in-panel deserialises consistently for all
|
|
13
|
+
`JSONTransformer` consumers. It is a no-op for schemas that do not declare `panel_c1`, and it is
|
|
14
|
+
best-effort (malformed input still surfaces the canonical `nodeFromJSON` validation error).
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 9.3.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -9,6 +9,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
11
11
|
var _schemaDefault = require("@atlaskit/adf-schema/schema-default");
|
|
12
|
+
var _transforms = require("@atlaskit/adf-utils/transforms");
|
|
12
13
|
var _sanitizeNode = require("./sanitize/sanitize-node");
|
|
13
14
|
var _toJSON = require("./toJSON");
|
|
14
15
|
var createDocFromContent = function createDocFromContent(content) {
|
|
@@ -53,7 +54,21 @@ var JSONTransformer = exports.JSONTransformer = /*#__PURE__*/function () {
|
|
|
53
54
|
}, {
|
|
54
55
|
key: "internalParse",
|
|
55
56
|
value: function internalParse(content, schema) {
|
|
56
|
-
|
|
57
|
+
// Upgrade container nodes (e.g. `panel` -> `panel_c1`) wherever the schema allows it, so
|
|
58
|
+
// table-in-panel deserialises consistently for JSONTransformer consumers. Schema-driven and
|
|
59
|
+
// flag-free, and best-effort: malformed input falls through to `nodeFromJSON`, which stays
|
|
60
|
+
// the source of truth for validation errors.
|
|
61
|
+
var promoted = content;
|
|
62
|
+
try {
|
|
63
|
+
var _upgradeContainerNode = (0, _transforms.upgradeContainerNodes)(content, schema),
|
|
64
|
+
transformedAdf = _upgradeContainerNode.transformedAdf;
|
|
65
|
+
if (transformedAdf) {
|
|
66
|
+
promoted = transformedAdf;
|
|
67
|
+
}
|
|
68
|
+
} catch (_unused) {
|
|
69
|
+
// Malformed input — leave `promoted` as the original `content`.
|
|
70
|
+
}
|
|
71
|
+
var doc = schema.nodeFromJSON(promoted);
|
|
57
72
|
doc.check();
|
|
58
73
|
return doc;
|
|
59
74
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import isEqual from 'lodash/isEqual';
|
|
2
2
|
import { defaultSchema, getSchemaBasedOnStage } from '@atlaskit/adf-schema/schema-default';
|
|
3
|
+
import { upgradeContainerNodes } from '@atlaskit/adf-utils/transforms';
|
|
3
4
|
import { sanitizeNode } from './sanitize/sanitize-node';
|
|
4
5
|
import { toJSON } from './toJSON';
|
|
5
6
|
const createDocFromContent = content => {
|
|
@@ -35,7 +36,22 @@ export class JSONTransformer {
|
|
|
35
36
|
return createDocFromContent(content);
|
|
36
37
|
}
|
|
37
38
|
internalParse(content, schema) {
|
|
38
|
-
|
|
39
|
+
// Upgrade container nodes (e.g. `panel` -> `panel_c1`) wherever the schema allows it, so
|
|
40
|
+
// table-in-panel deserialises consistently for JSONTransformer consumers. Schema-driven and
|
|
41
|
+
// flag-free, and best-effort: malformed input falls through to `nodeFromJSON`, which stays
|
|
42
|
+
// the source of truth for validation errors.
|
|
43
|
+
let promoted = content;
|
|
44
|
+
try {
|
|
45
|
+
const {
|
|
46
|
+
transformedAdf
|
|
47
|
+
} = upgradeContainerNodes(content, schema);
|
|
48
|
+
if (transformedAdf) {
|
|
49
|
+
promoted = transformedAdf;
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
// Malformed input — leave `promoted` as the original `content`.
|
|
53
|
+
}
|
|
54
|
+
const doc = schema.nodeFromJSON(promoted);
|
|
39
55
|
doc.check();
|
|
40
56
|
return doc;
|
|
41
57
|
}
|
|
@@ -2,6 +2,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import isEqual from 'lodash/isEqual';
|
|
4
4
|
import { defaultSchema, getSchemaBasedOnStage } from '@atlaskit/adf-schema/schema-default';
|
|
5
|
+
import { upgradeContainerNodes } from '@atlaskit/adf-utils/transforms';
|
|
5
6
|
import { sanitizeNode } from './sanitize/sanitize-node';
|
|
6
7
|
import { toJSON } from './toJSON';
|
|
7
8
|
var createDocFromContent = function createDocFromContent(content) {
|
|
@@ -46,7 +47,21 @@ export var JSONTransformer = /*#__PURE__*/function () {
|
|
|
46
47
|
}, {
|
|
47
48
|
key: "internalParse",
|
|
48
49
|
value: function internalParse(content, schema) {
|
|
49
|
-
|
|
50
|
+
// Upgrade container nodes (e.g. `panel` -> `panel_c1`) wherever the schema allows it, so
|
|
51
|
+
// table-in-panel deserialises consistently for JSONTransformer consumers. Schema-driven and
|
|
52
|
+
// flag-free, and best-effort: malformed input falls through to `nodeFromJSON`, which stays
|
|
53
|
+
// the source of truth for validation errors.
|
|
54
|
+
var promoted = content;
|
|
55
|
+
try {
|
|
56
|
+
var _upgradeContainerNode = upgradeContainerNodes(content, schema),
|
|
57
|
+
transformedAdf = _upgradeContainerNode.transformedAdf;
|
|
58
|
+
if (transformedAdf) {
|
|
59
|
+
promoted = transformedAdf;
|
|
60
|
+
}
|
|
61
|
+
} catch (_unused) {
|
|
62
|
+
// Malformed input — leave `promoted` as the original `content`.
|
|
63
|
+
}
|
|
64
|
+
var doc = schema.nodeFromJSON(promoted);
|
|
50
65
|
doc.check();
|
|
51
66
|
return doc;
|
|
52
67
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-json-transformer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"description": "JSON transformer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaskit/adf-schema": "^
|
|
25
|
-
"@atlaskit/adf-utils": "^20.
|
|
24
|
+
"@atlaskit/adf-schema": "^57.0.0",
|
|
25
|
+
"@atlaskit/adf-utils": "^20.6.0",
|
|
26
26
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
27
27
|
"@babel/runtime": "^7.0.0",
|
|
28
28
|
"lodash": "^4.17.21"
|