@atlaskit/editor-json-transformer 9.4.0 → 9.6.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,39 @@
1
1
  # @atlaskit/editor-json-transformer
2
2
 
3
+ ## 9.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1ba964c23baef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1ba964c23baef) -
8
+ `JSONTransformer.parse` no longer upgrades container nodes (`panel` -> `panel_c1`) while
9
+ deserialising — it is again a plain `schema.nodeFromJSON`, so the ProseMirror node types it
10
+ produces match the input ADF exactly.
11
+
12
+ Removed under HOT-305774, which impacted FedRAMP customers. The upgrade was unconditional: a
13
+ `panel` at the root of the document became a `panel_c1` whenever the supplied schema declared that
14
+ node. That is unsafe across a service boundary, because the two sides do not agree on the schema —
15
+ pf-collab-service (NCS) unconditionally uses the stage-0 schema, which does declare `panel_c1`,
16
+ while the editor does not support `panel_c1` unless the `platform_editor_nest_table_in_panel`
17
+ experiment is enabled. NCS therefore produced drafts whose panels had been converted to
18
+ `panel_c1`, which the editor does not unconditionally support.
19
+
20
+ Consumers that need to deserialise table-in-panel ADF (`{ type: 'panel' }` containing a `table`,
21
+ which ProseMirror models as the separate `panel_c1` node) should apply `transformContainerNodes`
22
+ from `@atlaskit/adf-utils/transforms` to the document before calling `parse`, as the editor and
23
+ renderer already do.
24
+
25
+ ## 9.5.0
26
+
27
+ ### Minor Changes
28
+
29
+ - [`52e80c8d44e5f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/52e80c8d44e5f) -
30
+ Behind `platform_editor_sanitize_selection_fragments`, `getFragmentsFromSelection` now sanitises
31
+ selection fragments via `JSONTransformer.encodeNode` instead of the raw `nodeToJSON`, so the
32
+ schema-only `panel_c1` container variant no longer leaks to Remix and other AI selection-context
33
+ consumers when `platform_editor_nest_table_in_panel` is enabled. `keepNestedTables: true` is
34
+ passed to keep nested tables intact. `encodeNode` and editor-common's `nodeToJSON` now accept
35
+ `SanitizeNodeOptions`, matching `encode`.
36
+
3
37
  ## 9.4.0
4
38
 
5
39
  ### Minor Changes
@@ -9,7 +9,6 @@ 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");
13
12
  var _sanitizeNode = require("./sanitize/sanitize-node");
14
13
  var _toJSON = require("./toJSON");
15
14
  var createDocFromContent = function createDocFromContent(content) {
@@ -54,21 +53,7 @@ var JSONTransformer = exports.JSONTransformer = /*#__PURE__*/function () {
54
53
  }, {
55
54
  key: "internalParse",
56
55
  value: function internalParse(content, schema) {
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);
56
+ var doc = schema.nodeFromJSON(content);
72
57
  doc.check();
73
58
  return doc;
74
59
  }
@@ -91,7 +76,8 @@ var JSONTransformer = exports.JSONTransformer = /*#__PURE__*/function () {
91
76
  }, {
92
77
  key: "encodeNode",
93
78
  value: function encodeNode(node) {
94
- return (0, _sanitizeNode.sanitizeNode)((0, _toJSON.toJSON)(node, this.mentionMap));
79
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
80
+ return (0, _sanitizeNode.sanitizeNode)((0, _toJSON.toJSON)(node, this.mentionMap), options);
95
81
  }
96
82
  }]);
97
83
  }();
@@ -1,6 +1,5 @@
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';
4
3
  import { sanitizeNode } from './sanitize/sanitize-node';
5
4
  import { toJSON } from './toJSON';
6
5
  const createDocFromContent = content => {
@@ -36,22 +35,7 @@ export class JSONTransformer {
36
35
  return createDocFromContent(content);
37
36
  }
38
37
  internalParse(content, schema) {
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);
38
+ const doc = schema.nodeFromJSON(content);
55
39
  doc.check();
56
40
  return doc;
57
41
  }
@@ -69,7 +53,7 @@ export class JSONTransformer {
69
53
  /**
70
54
  * This method is used to encode a single node
71
55
  */
72
- encodeNode(node) {
73
- return sanitizeNode(toJSON(node, this.mentionMap));
56
+ encodeNode(node, options = {}) {
57
+ return sanitizeNode(toJSON(node, this.mentionMap), options);
74
58
  }
75
59
  }
@@ -2,7 +2,6 @@ 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';
6
5
  import { sanitizeNode } from './sanitize/sanitize-node';
7
6
  import { toJSON } from './toJSON';
8
7
  var createDocFromContent = function createDocFromContent(content) {
@@ -47,21 +46,7 @@ export var JSONTransformer = /*#__PURE__*/function () {
47
46
  }, {
48
47
  key: "internalParse",
49
48
  value: function internalParse(content, schema) {
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);
49
+ var doc = schema.nodeFromJSON(content);
65
50
  doc.check();
66
51
  return doc;
67
52
  }
@@ -84,7 +69,8 @@ export var JSONTransformer = /*#__PURE__*/function () {
84
69
  }, {
85
70
  key: "encodeNode",
86
71
  value: function encodeNode(node) {
87
- return sanitizeNode(toJSON(node, this.mentionMap));
72
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
73
+ return sanitizeNode(toJSON(node, this.mentionMap), options);
88
74
  }
89
75
  }]);
90
76
  }();
@@ -22,6 +22,6 @@ export declare class JSONTransformer implements Transformer<JSONDocNode> {
22
22
  /**
23
23
  * This method is used to encode a single node
24
24
  */
25
- encodeNode(node: PMNode): JSONNode;
25
+ encodeNode(node: PMNode, options?: SanitizeNodeOptions): JSONNode;
26
26
  }
27
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-json-transformer",
3
- "version": "9.4.0",
3
+ "version": "9.6.0",
4
4
  "description": "JSON transformer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@atlaskit/adf-schema": "^57.0.0",
25
- "@atlaskit/adf-utils": "^20.6.0",
25
+ "@atlaskit/adf-utils": "^20.7.0",
26
26
  "@atlaskit/editor-prosemirror": "^8.0.0",
27
27
  "@babel/runtime": "^7.0.0",
28
28
  "lodash": "^4.17.21"
29
29
  },
30
30
  "devDependencies": {
31
- "@atlassian/a11y-jest-testing": "^0.15.0",
31
+ "@atlassian/a11y-jest-testing": "^0.16.0",
32
32
  "@atlassian/structured-docs-types": "workspace:^",
33
33
  "react": "^19.2.0"
34
34
  },