@atlaskit/editor-json-transformer 9.8.1 → 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 +21 -0
- package/dist/cjs/toJSON.js +11 -4
- package/dist/es2019/jsonTransformer.js +1 -0
- package/dist/es2019/sanitize.js +1 -0
- package/dist/es2019/toJSON.js +9 -4
- package/dist/esm/jsonTransformer.js +1 -0
- package/dist/esm/sanitize.js +1 -0
- package/dist/esm/toJSON.js +11 -4
- package/dist/types/JSONTransformer-2.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
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
|
+
|
|
3
24
|
## 9.8.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/cjs/toJSON.js
CHANGED
|
@@ -9,15 +9,15 @@ exports.toJSON = void 0;
|
|
|
9
9
|
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
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
12
13
|
var _codeBlock = require("@atlaskit/adf-schema/code-block");
|
|
13
14
|
var _dataConsumer = require("@atlaskit/adf-schema/data-consumer");
|
|
14
15
|
var _expand = require("@atlaskit/adf-schema/expand");
|
|
15
16
|
var _fragment = require("@atlaskit/adf-schema/fragment");
|
|
16
|
-
var _toJson = require("@atlaskit/adf-schema/to-json");
|
|
17
|
-
var _toJson2 = require("@atlaskit/adf-schema/to-json-2");
|
|
18
17
|
var _mention = require("@atlaskit/adf-schema/mention");
|
|
19
18
|
var _tableNodes = require("@atlaskit/adf-schema/tableNodes");
|
|
20
|
-
var
|
|
19
|
+
var _toJson = require("@atlaskit/adf-schema/to-json");
|
|
20
|
+
var _toJson2 = require("@atlaskit/adf-schema/to-json-2");
|
|
21
21
|
var _markOverrideRules = require("./markOverrideRules");
|
|
22
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof3(i) ? i : i + ""; }
|
|
23
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); }
|
|
@@ -46,11 +46,16 @@ var isUnsupportedMark = isType('unsupportedMark');
|
|
|
46
46
|
var isUnsupportedNodeAttributeMark = isType('unsupportedNodeAttribute');
|
|
47
47
|
var isExpand = isType('expand');
|
|
48
48
|
var isNestedExpand = isType('nestedExpand');
|
|
49
|
+
var isExtensionNode = isType('extension');
|
|
49
50
|
var isUnsupportedNode = function isUnsupportedNode(node) {
|
|
50
51
|
return isType('unsupportedBlock')(node) || isType('unsupportedInline')(node);
|
|
51
52
|
};
|
|
52
53
|
var isDataConsumer = isType('dataConsumer');
|
|
53
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
|
+
};
|
|
54
59
|
var isHardBreak = isType('hardBreak');
|
|
55
60
|
|
|
56
61
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -163,7 +168,9 @@ var _toJSON = exports.toJSON = function toJSON(node, mentionMap) {
|
|
|
163
168
|
if (node.marks.length) {
|
|
164
169
|
// Run any custom mark serialisers
|
|
165
170
|
var parsedMarks = node.marks.map(function (mark) {
|
|
166
|
-
if (
|
|
171
|
+
if (isAnnotationMark(mark) && !isAllowedNodeForAnnotation(node)) {
|
|
172
|
+
return null;
|
|
173
|
+
} else if (isUnsupportedMark(mark)) {
|
|
167
174
|
return canOverrideMark(mark, node.marks) ? null : mark.attrs.originalValue;
|
|
168
175
|
} else if (isUnsupportedNodeAttributeMark(mark)) {
|
|
169
176
|
return null;
|
package/dist/es2019/sanitize.js
CHANGED
|
@@ -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.
|
package/dist/es2019/toJSON.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { linkToJSON } from '@atlaskit/adf-schema';
|
|
1
2
|
import { toJSON as codeBlockToJSON } from '@atlaskit/adf-schema/code-block';
|
|
2
3
|
import { toJSON as dataConsumerToJSON } from '@atlaskit/adf-schema/data-consumer';
|
|
3
4
|
import { toJSON as expandToJSON } from '@atlaskit/adf-schema/expand';
|
|
4
5
|
import { toJSON as fragmentToJSON } from '@atlaskit/adf-schema/fragment';
|
|
5
|
-
import { toJSON as mediaSingleToJSON } from '@atlaskit/adf-schema/to-json';
|
|
6
|
-
import { toJSON as mediaToJSON } from '@atlaskit/adf-schema/to-json-2';
|
|
7
6
|
import { toJSON as mentionToJSON } from '@atlaskit/adf-schema/mention';
|
|
8
7
|
import { tableToJSON, toJSONTableCell, toJSONTableHeader } from '@atlaskit/adf-schema/tableNodes';
|
|
9
|
-
import {
|
|
8
|
+
import { toJSON as mediaSingleToJSON } from '@atlaskit/adf-schema/to-json';
|
|
9
|
+
import { toJSON as mediaToJSON } from '@atlaskit/adf-schema/to-json-2';
|
|
10
10
|
import { markOverrideRuleFor } from './markOverrideRules';
|
|
11
11
|
const isType = type => node => node.type.name === type;
|
|
12
12
|
|
|
@@ -27,9 +27,12 @@ const isUnsupportedMark = isType('unsupportedMark');
|
|
|
27
27
|
const isUnsupportedNodeAttributeMark = isType('unsupportedNodeAttribute');
|
|
28
28
|
const isExpand = isType('expand');
|
|
29
29
|
const isNestedExpand = isType('nestedExpand');
|
|
30
|
+
const isExtensionNode = isType('extension');
|
|
30
31
|
const isUnsupportedNode = node => isType('unsupportedBlock')(node) || isType('unsupportedInline')(node);
|
|
31
32
|
const isDataConsumer = isType('dataConsumer');
|
|
32
33
|
const isFragmentMark = isType('fragment');
|
|
34
|
+
const isAnnotationMark = isType('annotation');
|
|
35
|
+
const isAllowedNodeForAnnotation = node => !node.type.isBlock || isMediaNode(node) || isExtensionNode(node);
|
|
33
36
|
const isHardBreak = isType('hardBreak');
|
|
34
37
|
|
|
35
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -150,7 +153,9 @@ export const toJSON = (node, mentionMap) => {
|
|
|
150
153
|
if (node.marks.length) {
|
|
151
154
|
// Run any custom mark serialisers
|
|
152
155
|
const parsedMarks = node.marks.map(mark => {
|
|
153
|
-
if (
|
|
156
|
+
if (isAnnotationMark(mark) && !isAllowedNodeForAnnotation(node)) {
|
|
157
|
+
return null;
|
|
158
|
+
} else if (isUnsupportedMark(mark)) {
|
|
154
159
|
return canOverrideMark(mark, node.marks) ? null : mark.attrs.originalValue;
|
|
155
160
|
} else if (isUnsupportedNodeAttributeMark(mark)) {
|
|
156
161
|
return null;
|
package/dist/esm/sanitize.js
CHANGED
|
@@ -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.
|
package/dist/esm/toJSON.js
CHANGED
|
@@ -5,15 +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 { linkToJSON } from '@atlaskit/adf-schema';
|
|
8
9
|
import { toJSON as codeBlockToJSON } from '@atlaskit/adf-schema/code-block';
|
|
9
10
|
import { toJSON as dataConsumerToJSON } from '@atlaskit/adf-schema/data-consumer';
|
|
10
11
|
import { toJSON as expandToJSON } from '@atlaskit/adf-schema/expand';
|
|
11
12
|
import { toJSON as fragmentToJSON } from '@atlaskit/adf-schema/fragment';
|
|
12
|
-
import { toJSON as mediaSingleToJSON } from '@atlaskit/adf-schema/to-json';
|
|
13
|
-
import { toJSON as mediaToJSON } from '@atlaskit/adf-schema/to-json-2';
|
|
14
13
|
import { toJSON as mentionToJSON } from '@atlaskit/adf-schema/mention';
|
|
15
14
|
import { tableToJSON, toJSONTableCell, toJSONTableHeader } from '@atlaskit/adf-schema/tableNodes';
|
|
16
|
-
import {
|
|
15
|
+
import { toJSON as mediaSingleToJSON } from '@atlaskit/adf-schema/to-json';
|
|
16
|
+
import { toJSON as mediaToJSON } from '@atlaskit/adf-schema/to-json-2';
|
|
17
17
|
import { markOverrideRuleFor } from './markOverrideRules';
|
|
18
18
|
var isType = function isType(type) {
|
|
19
19
|
return function (node) {
|
|
@@ -38,11 +38,16 @@ var isUnsupportedMark = isType('unsupportedMark');
|
|
|
38
38
|
var isUnsupportedNodeAttributeMark = isType('unsupportedNodeAttribute');
|
|
39
39
|
var isExpand = isType('expand');
|
|
40
40
|
var isNestedExpand = isType('nestedExpand');
|
|
41
|
+
var isExtensionNode = isType('extension');
|
|
41
42
|
var isUnsupportedNode = function isUnsupportedNode(node) {
|
|
42
43
|
return isType('unsupportedBlock')(node) || isType('unsupportedInline')(node);
|
|
43
44
|
};
|
|
44
45
|
var isDataConsumer = isType('dataConsumer');
|
|
45
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
|
+
};
|
|
46
51
|
var isHardBreak = isType('hardBreak');
|
|
47
52
|
|
|
48
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -155,7 +160,9 @@ var _toJSON = function toJSON(node, mentionMap) {
|
|
|
155
160
|
if (node.marks.length) {
|
|
156
161
|
// Run any custom mark serialisers
|
|
157
162
|
var parsedMarks = node.marks.map(function (mark) {
|
|
158
|
-
if (
|
|
163
|
+
if (isAnnotationMark(mark) && !isAllowedNodeForAnnotation(node)) {
|
|
164
|
+
return null;
|
|
165
|
+
} else if (isUnsupportedMark(mark)) {
|
|
159
166
|
return canOverrideMark(mark, node.marks) ? null : mark.attrs.originalValue;
|
|
160
167
|
} else if (isUnsupportedNodeAttributeMark(mark)) {
|
|
161
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-json-transformer",
|
|
3
|
-
"version": "9.8.
|
|
3
|
+
"version": "9.8.2",
|
|
4
4
|
"description": "JSON transformer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atlaskit/adf-schema": "^57.
|
|
27
|
+
"@atlaskit/adf-schema": "^57.6.0",
|
|
28
28
|
"@atlaskit/adf-utils": "^20.9.0",
|
|
29
29
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
30
30
|
"@babel/runtime": "^7.0.0",
|
|
31
31
|
"lodash": "^4.17.21"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^123.
|
|
35
|
-
"@atlaskit/editor-core": "^229.
|
|
34
|
+
"@atlaskit/editor-common": "^123.4.0",
|
|
35
|
+
"@atlaskit/editor-core": "^229.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-grid": "^19.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-media": "^21.0.0",
|
|
38
38
|
"@atlaskit/editor-plugins": "^16.1.0",
|