@atlaskit/editor-json-transformer 9.8.0 → 9.8.2

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,32 @@
1
1
  # @atlaskit/editor-json-transformer
2
2
 
3
+ ## 9.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8e4fd6774f6ec`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8e4fd6774f6ec) -
8
+ Add Stage-0 ADF schema support for the `annotation` mark on `extension` nodes (ADF Change 111).
9
+ Adds the `with_annotation` and `root_only_with_annotation` Stage-0 variants and wires them into
10
+ the approved root and nested placements (doc root, panel, blockquote, expand, nestedExpand,
11
+ listItem, blockTaskItem, table cells), registers the matching validator specs, and adds
12
+ valid/invalid reference fixtures, with regenerated PM/JSON/validator artifacts. Scoped to
13
+ `extension` only (not `bodiedExtension`/`multiBodiedExtension`); the full schema is unchanged.
14
+ Editor/renderer acceptance of the mark is gated by `cc_maui_annotations_on_extensions`.
15
+
16
+ Allowing the `annotation` mark on `extension` requires its container nodes (panel, table cells,
17
+ list items, etc.) to permit the mark too, so they can hold an annotated extension child. This made
18
+ the renderer's `getIndexMatch` double-count text inside those containers, corrupting inline
19
+ text-comment anchoring. Fixed by skipping block containers during serialisation (they are still
20
+ walked through so their inner text is counted once); leaf nodes and media are unaffected.
21
+
22
+ - Updated dependencies
23
+
24
+ ## 9.8.1
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies
29
+
3
30
  ## 9.8.0
4
31
 
5
32
  ### Minor Changes
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@atlaskit/editor-json-transformer/SchemaStage",
3
+ "main": "../dist/cjs/SchemaStage.js",
4
+ "module": "../dist/esm/SchemaStage.js",
5
+ "module:es2019": "../dist/es2019/SchemaStage.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/SchemaStage.d.ts"
8
+ }
@@ -10,6 +10,14 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _adfSchema = require("@atlaskit/adf-schema");
13
+ var _codeBlock = require("@atlaskit/adf-schema/code-block");
14
+ var _dataConsumer = require("@atlaskit/adf-schema/data-consumer");
15
+ var _expand = require("@atlaskit/adf-schema/expand");
16
+ var _fragment = require("@atlaskit/adf-schema/fragment");
17
+ var _mention = require("@atlaskit/adf-schema/mention");
18
+ var _tableNodes = require("@atlaskit/adf-schema/tableNodes");
19
+ var _toJson = require("@atlaskit/adf-schema/to-json");
20
+ var _toJson2 = require("@atlaskit/adf-schema/to-json-2");
13
21
  var _markOverrideRules = require("./markOverrideRules");
14
22
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof3(i) ? i : i + ""; }
15
23
  function _toPrimitive(t, r) { if ("object" != _typeof3(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof3(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -38,11 +46,16 @@ var isUnsupportedMark = isType('unsupportedMark');
38
46
  var isUnsupportedNodeAttributeMark = isType('unsupportedNodeAttribute');
39
47
  var isExpand = isType('expand');
40
48
  var isNestedExpand = isType('nestedExpand');
49
+ var isExtensionNode = isType('extension');
41
50
  var isUnsupportedNode = function isUnsupportedNode(node) {
42
51
  return isType('unsupportedBlock')(node) || isType('unsupportedInline')(node);
43
52
  };
44
53
  var isDataConsumer = isType('dataConsumer');
45
54
  var isFragmentMark = isType('fragment');
55
+ var isAnnotationMark = isType('annotation');
56
+ var isAllowedNodeForAnnotation = function isAllowedNodeForAnnotation(node) {
57
+ return !node.type.isBlock || isMediaNode(node) || isExtensionNode(node);
58
+ };
46
59
  var isHardBreak = isType('hardBreak');
47
60
 
48
61
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -103,23 +116,23 @@ var _toJSON = exports.toJSON = function toJSON(node, mentionMap) {
103
116
  if (isUnsupportedNode(node)) {
104
117
  return node.attrs.originalValue;
105
118
  } else if (isMediaNode(node)) {
106
- obj.attrs = (0, _adfSchema.mediaToJSON)(node).attrs;
119
+ obj.attrs = (0, _toJson2.toJSON)(node).attrs;
107
120
  } else if (isMediaSingleNode(node)) {
108
- obj.attrs = (0, _adfSchema.mediaSingleToJSON)(node).attrs;
121
+ obj.attrs = (0, _toJson.toJSON)(node).attrs;
109
122
  } else if (isMediaInline(node)) {
110
- obj.attrs = (0, _adfSchema.mediaToJSON)(node).attrs;
123
+ obj.attrs = (0, _toJson2.toJSON)(node).attrs;
111
124
  } else if (isMentionNode(node)) {
112
- obj.attrs = (0, _adfSchema.mentionToJSON)(node).attrs;
125
+ obj.attrs = (0, _mention.toJSON)(node).attrs;
113
126
  } else if (isCodeBlock(node)) {
114
- obj.attrs = (0, _adfSchema.codeBlockToJSON)(node).attrs;
127
+ obj.attrs = (0, _codeBlock.toJSON)(node).attrs;
115
128
  } else if (isTable(node)) {
116
- obj.attrs = (0, _adfSchema.tableToJSON)(node).attrs;
129
+ obj.attrs = (0, _tableNodes.tableToJSON)(node).attrs;
117
130
  } else if (isTableCell(node)) {
118
- obj.attrs = (0, _adfSchema.toJSONTableCell)(node).attrs;
131
+ obj.attrs = (0, _tableNodes.toJSONTableCell)(node).attrs;
119
132
  } else if (isTableHeader(node)) {
120
- obj.attrs = (0, _adfSchema.toJSONTableHeader)(node).attrs;
133
+ obj.attrs = (0, _tableNodes.toJSONTableHeader)(node).attrs;
121
134
  } else if (isExpand(node) || isNestedExpand(node)) {
122
- obj.attrs = (0, _adfSchema.expandToJSON)(node).attrs;
135
+ obj.attrs = (0, _expand.toJSON)(node).attrs;
123
136
  } else if (node.attrs && Object.keys(node.attrs).length) {
124
137
  obj.attrs = node.attrs;
125
138
  }
@@ -155,7 +168,9 @@ var _toJSON = exports.toJSON = function toJSON(node, mentionMap) {
155
168
  if (node.marks.length) {
156
169
  // Run any custom mark serialisers
157
170
  var parsedMarks = node.marks.map(function (mark) {
158
- if (isUnsupportedMark(mark)) {
171
+ if (isAnnotationMark(mark) && !isAllowedNodeForAnnotation(node)) {
172
+ return null;
173
+ } else if (isUnsupportedMark(mark)) {
159
174
  return canOverrideMark(mark, node.marks) ? null : mark.attrs.originalValue;
160
175
  } else if (isUnsupportedNodeAttributeMark(mark)) {
161
176
  return null;
@@ -163,10 +178,10 @@ var _toJSON = exports.toJSON = function toJSON(node, mentionMap) {
163
178
  return (0, _adfSchema.linkToJSON)(mark);
164
179
  } else if (isDataConsumer(mark)) {
165
180
  var _serialised$attrs$sou;
166
- var serialised = (0, _adfSchema.dataConsumerToJSON)(mark);
181
+ var serialised = (0, _dataConsumer.toJSON)(mark);
167
182
  return !serialised.attrs.sources || ((_serialised$attrs$sou = serialised.attrs.sources) === null || _serialised$attrs$sou === void 0 ? void 0 : _serialised$attrs$sou.length) === 0 ? null : serialised;
168
183
  } else if (isFragmentMark(mark)) {
169
- var fragmentMark = (0, _adfSchema.fragmentToJSON)(mark);
184
+ var fragmentMark = (0, _fragment.toJSON)(mark);
170
185
  if (!fragmentMark.attrs.localId) {
171
186
  return null;
172
187
  }
@@ -5,6 +5,7 @@
5
5
  /**
6
6
  * @deprecated Use `import { SchemaStage } from '@atlaskit/editor-json-transformer'` instead.
7
7
  */
8
+
8
9
  export { SchemaStage } from './SchemaStage';
9
10
  /**
10
11
  * @deprecated Use `import { toJSON } from '@atlaskit/editor-json-transformer/jsonTransformer'` instead.
@@ -5,6 +5,7 @@
5
5
  /**
6
6
  * @deprecated Use `import { sanitizeNode } from '@atlaskit/editor-json-transformer/sanitize/sanitize-node'` instead.
7
7
  */
8
+
8
9
  export { sanitizeNode } from './sanitize/sanitize-node';
9
10
  /**
10
11
  * @deprecated Use `import { removeMarks } from '@atlaskit/editor-json-transformer/sanitize/remove-marks'` instead.
@@ -1,4 +1,12 @@
1
- import { codeBlockToJSON, dataConsumerToJSON, expandToJSON, fragmentToJSON, linkToJSON, mediaSingleToJSON, mediaToJSON, mentionToJSON, tableToJSON, toJSONTableCell, toJSONTableHeader } from '@atlaskit/adf-schema';
1
+ import { linkToJSON } from '@atlaskit/adf-schema';
2
+ import { toJSON as codeBlockToJSON } from '@atlaskit/adf-schema/code-block';
3
+ import { toJSON as dataConsumerToJSON } from '@atlaskit/adf-schema/data-consumer';
4
+ import { toJSON as expandToJSON } from '@atlaskit/adf-schema/expand';
5
+ import { toJSON as fragmentToJSON } from '@atlaskit/adf-schema/fragment';
6
+ import { toJSON as mentionToJSON } from '@atlaskit/adf-schema/mention';
7
+ import { tableToJSON, toJSONTableCell, toJSONTableHeader } from '@atlaskit/adf-schema/tableNodes';
8
+ import { toJSON as mediaSingleToJSON } from '@atlaskit/adf-schema/to-json';
9
+ import { toJSON as mediaToJSON } from '@atlaskit/adf-schema/to-json-2';
2
10
  import { markOverrideRuleFor } from './markOverrideRules';
3
11
  const isType = type => node => node.type.name === type;
4
12
 
@@ -19,9 +27,12 @@ const isUnsupportedMark = isType('unsupportedMark');
19
27
  const isUnsupportedNodeAttributeMark = isType('unsupportedNodeAttribute');
20
28
  const isExpand = isType('expand');
21
29
  const isNestedExpand = isType('nestedExpand');
30
+ const isExtensionNode = isType('extension');
22
31
  const isUnsupportedNode = node => isType('unsupportedBlock')(node) || isType('unsupportedInline')(node);
23
32
  const isDataConsumer = isType('dataConsumer');
24
33
  const isFragmentMark = isType('fragment');
34
+ const isAnnotationMark = isType('annotation');
35
+ const isAllowedNodeForAnnotation = node => !node.type.isBlock || isMediaNode(node) || isExtensionNode(node);
25
36
  const isHardBreak = isType('hardBreak');
26
37
 
27
38
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -142,7 +153,9 @@ export const toJSON = (node, mentionMap) => {
142
153
  if (node.marks.length) {
143
154
  // Run any custom mark serialisers
144
155
  const parsedMarks = node.marks.map(mark => {
145
- if (isUnsupportedMark(mark)) {
156
+ if (isAnnotationMark(mark) && !isAllowedNodeForAnnotation(node)) {
157
+ return null;
158
+ } else if (isUnsupportedMark(mark)) {
146
159
  return canOverrideMark(mark, node.marks) ? null : mark.attrs.originalValue;
147
160
  } else if (isUnsupportedNodeAttributeMark(mark)) {
148
161
  return null;
@@ -5,6 +5,7 @@
5
5
  /**
6
6
  * @deprecated Use `import { SchemaStage } from '@atlaskit/editor-json-transformer'` instead.
7
7
  */
8
+
8
9
  export { SchemaStage } from './SchemaStage';
9
10
  /**
10
11
  * @deprecated Use `import { toJSON } from '@atlaskit/editor-json-transformer/jsonTransformer'` instead.
@@ -5,6 +5,7 @@
5
5
  /**
6
6
  * @deprecated Use `import { sanitizeNode } from '@atlaskit/editor-json-transformer/sanitize/sanitize-node'` instead.
7
7
  */
8
+
8
9
  export { sanitizeNode } from './sanitize/sanitize-node';
9
10
  /**
10
11
  * @deprecated Use `import { removeMarks } from '@atlaskit/editor-json-transformer/sanitize/remove-marks'` instead.
@@ -5,7 +5,15 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
5
5
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
- import { codeBlockToJSON, dataConsumerToJSON, expandToJSON, fragmentToJSON, linkToJSON, mediaSingleToJSON, mediaToJSON, mentionToJSON, tableToJSON, toJSONTableCell, toJSONTableHeader } from '@atlaskit/adf-schema';
8
+ import { linkToJSON } from '@atlaskit/adf-schema';
9
+ import { toJSON as codeBlockToJSON } from '@atlaskit/adf-schema/code-block';
10
+ import { toJSON as dataConsumerToJSON } from '@atlaskit/adf-schema/data-consumer';
11
+ import { toJSON as expandToJSON } from '@atlaskit/adf-schema/expand';
12
+ import { toJSON as fragmentToJSON } from '@atlaskit/adf-schema/fragment';
13
+ import { toJSON as mentionToJSON } from '@atlaskit/adf-schema/mention';
14
+ import { tableToJSON, toJSONTableCell, toJSONTableHeader } from '@atlaskit/adf-schema/tableNodes';
15
+ import { toJSON as mediaSingleToJSON } from '@atlaskit/adf-schema/to-json';
16
+ import { toJSON as mediaToJSON } from '@atlaskit/adf-schema/to-json-2';
9
17
  import { markOverrideRuleFor } from './markOverrideRules';
10
18
  var isType = function isType(type) {
11
19
  return function (node) {
@@ -30,11 +38,16 @@ var isUnsupportedMark = isType('unsupportedMark');
30
38
  var isUnsupportedNodeAttributeMark = isType('unsupportedNodeAttribute');
31
39
  var isExpand = isType('expand');
32
40
  var isNestedExpand = isType('nestedExpand');
41
+ var isExtensionNode = isType('extension');
33
42
  var isUnsupportedNode = function isUnsupportedNode(node) {
34
43
  return isType('unsupportedBlock')(node) || isType('unsupportedInline')(node);
35
44
  };
36
45
  var isDataConsumer = isType('dataConsumer');
37
46
  var isFragmentMark = isType('fragment');
47
+ var isAnnotationMark = isType('annotation');
48
+ var isAllowedNodeForAnnotation = function isAllowedNodeForAnnotation(node) {
49
+ return !node.type.isBlock || isMediaNode(node) || isExtensionNode(node);
50
+ };
38
51
  var isHardBreak = isType('hardBreak');
39
52
 
40
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -147,7 +160,9 @@ var _toJSON = function toJSON(node, mentionMap) {
147
160
  if (node.marks.length) {
148
161
  // Run any custom mark serialisers
149
162
  var parsedMarks = node.marks.map(function (mark) {
150
- if (isUnsupportedMark(mark)) {
163
+ if (isAnnotationMark(mark) && !isAllowedNodeForAnnotation(node)) {
164
+ return null;
165
+ } else if (isUnsupportedMark(mark)) {
151
166
  return canOverrideMark(mark, node.marks) ? null : mark.attrs.originalValue;
152
167
  } else if (isUnsupportedNodeAttributeMark(mark)) {
153
168
  return null;
@@ -1,6 +1,6 @@
1
1
  import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
- import type { SchemaStage } from './SchemaStage';
3
2
  import type { SanitizeNodeOptions } from './sanitize/sanitize-node';
3
+ import type { SchemaStage } from './SchemaStage';
4
4
  import type { JSONDocNode, JSONNode } from './types';
5
5
  interface Transformer<T> {
6
6
  encode: (node: PMNode) => T;
@@ -1,4 +1,4 @@
1
- import type { JSONNode } from '../index';
1
+ import type { JSONNode } from '../types';
2
2
  export declare function removeMarks(node: JSONNode): {
3
3
  attrs?: object;
4
4
  content?: Array<JSONNode | undefined>;
@@ -1,4 +1,4 @@
1
- import type { JSONNode } from '../index';
1
+ import type { JSONNode } from '../types';
2
2
  export declare function removeNonAnnotationMarks(node: JSONNode): {
3
3
  attrs?: object;
4
4
  content?: Array<JSONNode | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-json-transformer",
3
- "version": "9.8.0",
3
+ "version": "9.8.2",
4
4
  "description": "JSON transformer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -17,33 +17,32 @@
17
17
  "atlassian": {
18
18
  "team": "Editor: Collaboration",
19
19
  "website": {
20
+ "tags": [
21
+ "platform-labs"
22
+ ],
20
23
  "name": "Editor Json Transformer"
21
24
  }
22
25
  },
23
26
  "dependencies": {
24
- "@atlaskit/adf-schema": "^57.2.0",
25
- "@atlaskit/adf-utils": "^20.8.0",
26
- "@atlaskit/editor-prosemirror": "^8.0.0",
27
+ "@atlaskit/adf-schema": "^57.6.0",
28
+ "@atlaskit/adf-utils": "^20.9.0",
29
+ "@atlaskit/editor-prosemirror": "^9.0.0",
27
30
  "@babel/runtime": "^7.0.0",
28
31
  "lodash": "^4.17.21"
29
32
  },
30
33
  "devDependencies": {
34
+ "@atlaskit/editor-common": "^123.4.0",
35
+ "@atlaskit/editor-core": "^229.1.0",
36
+ "@atlaskit/editor-plugin-grid": "^19.0.0",
37
+ "@atlaskit/editor-plugin-media": "^21.0.0",
38
+ "@atlaskit/editor-plugins": "^16.1.0",
39
+ "@atlaskit/editor-test-helpers": "workspace:^",
40
+ "@atlaskit/platform-feature-flags": "^2.2.0",
41
+ "@atlaskit/tokens": "^18.2.0",
42
+ "@atlaskit/util-data-test": "^19.1.0",
31
43
  "@atlassian/a11y-jest-testing": "^0.17.0",
32
44
  "@atlassian/structured-docs-types": "workspace:^",
45
+ "@atlassian/workbench": "workspace:*",
33
46
  "react": "^19.2.0"
34
- },
35
- "techstack": {
36
- "@atlassian/frontend": {
37
- "import-structure": "atlassian-conventions"
38
- },
39
- "@repo/internal": {
40
- "deprecation": "no-deprecated-imports",
41
- "design-tokens": [
42
- "color"
43
- ],
44
- "styling": [
45
- "emotion"
46
- ]
47
- }
48
47
  }
49
48
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@atlaskit/editor-json-transformer/remove-non-annotation-marks",
3
+ "main": "../dist/cjs/sanitize/remove-non-annotation-marks.js",
4
+ "module": "../dist/esm/sanitize/remove-non-annotation-marks.js",
5
+ "module:es2019": "../dist/es2019/sanitize/remove-non-annotation-marks.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/sanitize/remove-non-annotation-marks.d.ts"
8
+ }
@@ -1,35 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.local-consumption.json",
3
- "compilerOptions": {
4
- "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-json-transformer",
5
- "rootDir": "../",
6
- "composite": true,
7
- "noCheck": true
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../src/**/*.test.*",
16
- "../src/**/test.*",
17
- "../src/**/examples.*",
18
- "../src/**/examples/*",
19
- "../src/**/examples/**/*",
20
- "../src/**/*.stories.*",
21
- "../src/**/stories/*",
22
- "../src/**/stories/**/*"
23
- ],
24
- "references": [
25
- {
26
- "path": "../../adf-schema/afm-cc/tsconfig.json"
27
- },
28
- {
29
- "path": "../../adf-utils/afm-cc/tsconfig.json"
30
- },
31
- {
32
- "path": "../../editor-prosemirror/afm-cc/tsconfig.json"
33
- }
34
- ]
35
- }