@atlaskit/editor-json-transformer 8.25.1 → 8.26.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 +8 -0
- package/afm-passionfruit/tsconfig.json +30 -0
- package/afm-volt/tsconfig.json +7 -1
- package/dist/cjs/index.js +11 -2
- package/dist/es2019/index.js +10 -0
- package/dist/esm/index.js +10 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/sanitize/remove-marks.d.ts +8 -8
- package/dist/types-ts4.5/index.d.ts +10 -0
- package/dist/types-ts4.5/sanitize/remove-marks.d.ts +8 -8
- package/markOverrideRules/package.json +1 -1
- package/package.json +3 -4
- package/sanitize/package.json +1 -1
- package/types/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-json-transformer
|
|
2
2
|
|
|
3
|
+
## 8.26.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`7b86b50272e47`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7b86b50272e47) -
|
|
8
|
+
Expose new utility function, `nodeToJSON` which can be used to safely return a JSON object from a
|
|
9
|
+
node.
|
|
10
|
+
|
|
3
11
|
## 8.25.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.entry-points.passionfruit.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"target": "es5",
|
|
6
|
+
"outDir": "../../../../../passionfruit/tsDist/@atlaskit__editor-json-transformer/app",
|
|
7
|
+
"rootDir": "../",
|
|
8
|
+
"composite": true
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"../src/**/*.ts",
|
|
12
|
+
"../src/**/*.tsx"
|
|
13
|
+
],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"../src/**/__tests__/*",
|
|
16
|
+
"../src/**/*.test.*",
|
|
17
|
+
"../src/**/test.*",
|
|
18
|
+
"../src/**/examples.*",
|
|
19
|
+
"../src/**/examples/*",
|
|
20
|
+
"../src/**/examples/**/*",
|
|
21
|
+
"../src/**/*.stories.*",
|
|
22
|
+
"../src/**/stories/*",
|
|
23
|
+
"../src/**/stories/**/*"
|
|
24
|
+
],
|
|
25
|
+
"references": [
|
|
26
|
+
{
|
|
27
|
+
"path": "../../adf-utils/afm-passionfruit/tsconfig.json"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
package/afm-volt/tsconfig.json
CHANGED
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
"exclude": [
|
|
15
15
|
"../src/**/__tests__/*",
|
|
16
16
|
"../src/**/*.test.*",
|
|
17
|
-
"../src/**/test.*"
|
|
17
|
+
"../src/**/test.*",
|
|
18
|
+
"../src/**/examples.*",
|
|
19
|
+
"../src/**/examples/*",
|
|
20
|
+
"../src/**/examples/**/*",
|
|
21
|
+
"../src/**/*.stories.*",
|
|
22
|
+
"../src/**/stories/*",
|
|
23
|
+
"../src/**/stories/**/*"
|
|
18
24
|
],
|
|
19
25
|
"references": [
|
|
20
26
|
{
|
package/dist/cjs/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.SchemaStage = exports.JSONTransformer = void 0;
|
|
8
|
+
exports.nodeToJSON = exports.SchemaStage = exports.JSONTransformer = void 0;
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
@@ -84,7 +84,16 @@ var emptyDoc = createDocFromContent([{
|
|
|
84
84
|
type: 'paragraph',
|
|
85
85
|
content: []
|
|
86
86
|
}]);
|
|
87
|
-
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Transforms a Prosemirror node into a JSON representation. Compared with
|
|
90
|
+
* native Prosemirror JSON, this representation ensures we have valid ADF attrs.
|
|
91
|
+
*
|
|
92
|
+
* @param node The Prosemirror node to transform.
|
|
93
|
+
* @param mentionMap A map of mention IDs to their display names.
|
|
94
|
+
* @returns The JSON representation of the node.
|
|
95
|
+
*/
|
|
96
|
+
var _toJSON = exports.nodeToJSON = function toJSON(node, mentionMap) {
|
|
88
97
|
var obj = {
|
|
89
98
|
type: node.type.name
|
|
90
99
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -66,6 +66,15 @@ const emptyDoc = createDocFromContent([{
|
|
|
66
66
|
type: 'paragraph',
|
|
67
67
|
content: []
|
|
68
68
|
}]);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Transforms a Prosemirror node into a JSON representation. Compared with
|
|
72
|
+
* native Prosemirror JSON, this representation ensures we have valid ADF attrs.
|
|
73
|
+
*
|
|
74
|
+
* @param node The Prosemirror node to transform.
|
|
75
|
+
* @param mentionMap A map of mention IDs to their display names.
|
|
76
|
+
* @returns The JSON representation of the node.
|
|
77
|
+
*/
|
|
69
78
|
const toJSON = (node, mentionMap) => {
|
|
70
79
|
const obj = {
|
|
71
80
|
type: node.type.name
|
|
@@ -158,6 +167,7 @@ const toJSON = (node, mentionMap) => {
|
|
|
158
167
|
}
|
|
159
168
|
return obj;
|
|
160
169
|
};
|
|
170
|
+
export { toJSON as nodeToJSON };
|
|
161
171
|
const canOverrideMark = (mark, existingMarks) => {
|
|
162
172
|
if (existingMarks.some(e => mark.attrs.originalValue.type === e.type.name)) {
|
|
163
173
|
return markOverrideRuleFor(mark.attrs.originalValue.type).canOverrideUnsupportedMark();
|
package/dist/esm/index.js
CHANGED
|
@@ -78,6 +78,15 @@ var emptyDoc = createDocFromContent([{
|
|
|
78
78
|
type: 'paragraph',
|
|
79
79
|
content: []
|
|
80
80
|
}]);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Transforms a Prosemirror node into a JSON representation. Compared with
|
|
84
|
+
* native Prosemirror JSON, this representation ensures we have valid ADF attrs.
|
|
85
|
+
*
|
|
86
|
+
* @param node The Prosemirror node to transform.
|
|
87
|
+
* @param mentionMap A map of mention IDs to their display names.
|
|
88
|
+
* @returns The JSON representation of the node.
|
|
89
|
+
*/
|
|
81
90
|
var _toJSON = function toJSON(node, mentionMap) {
|
|
82
91
|
var obj = {
|
|
83
92
|
type: node.type.name
|
|
@@ -169,6 +178,7 @@ var _toJSON = function toJSON(node, mentionMap) {
|
|
|
169
178
|
}
|
|
170
179
|
return obj;
|
|
171
180
|
};
|
|
181
|
+
export { _toJSON as nodeToJSON };
|
|
172
182
|
var canOverrideMark = function canOverrideMark(mark, existingMarks) {
|
|
173
183
|
if (existingMarks.some(function (e) {
|
|
174
184
|
return mark.attrs.originalValue.type === e.type.name;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,6 +10,16 @@ export declare enum SchemaStage {
|
|
|
10
10
|
FINAL = "final",
|
|
11
11
|
STAGE_0 = "stage0"
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Transforms a Prosemirror node into a JSON representation. Compared with
|
|
15
|
+
* native Prosemirror JSON, this representation ensures we have valid ADF attrs.
|
|
16
|
+
*
|
|
17
|
+
* @param node The Prosemirror node to transform.
|
|
18
|
+
* @param mentionMap A map of mention IDs to their display names.
|
|
19
|
+
* @returns The JSON representation of the node.
|
|
20
|
+
*/
|
|
21
|
+
declare const toJSON: (node: PMNode, mentionMap?: Record<string, string | undefined>) => JSONNode;
|
|
22
|
+
export { toJSON as nodeToJSON };
|
|
13
23
|
export declare class JSONTransformer implements Transformer<JSONDocNode> {
|
|
14
24
|
private schema;
|
|
15
25
|
private mentionMap;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { JSONNode } from '../index';
|
|
2
2
|
export declare function removeMarks(node: JSONNode): {
|
|
3
3
|
type: string;
|
|
4
|
-
attrs?: object
|
|
5
|
-
content?:
|
|
6
|
-
marks?: any[]
|
|
7
|
-
text?: string
|
|
4
|
+
attrs?: object;
|
|
5
|
+
content?: Array<JSONNode | undefined>;
|
|
6
|
+
marks?: any[];
|
|
7
|
+
text?: string;
|
|
8
8
|
};
|
|
9
9
|
export declare function removeNonAnnotationMarks(node: JSONNode): {
|
|
10
10
|
type: string;
|
|
11
|
-
attrs?: object
|
|
12
|
-
content?:
|
|
13
|
-
marks?: any[]
|
|
14
|
-
text?: string
|
|
11
|
+
attrs?: object;
|
|
12
|
+
content?: Array<JSONNode | undefined>;
|
|
13
|
+
marks?: any[];
|
|
14
|
+
text?: string;
|
|
15
15
|
};
|
|
@@ -10,6 +10,16 @@ export declare enum SchemaStage {
|
|
|
10
10
|
FINAL = "final",
|
|
11
11
|
STAGE_0 = "stage0"
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Transforms a Prosemirror node into a JSON representation. Compared with
|
|
15
|
+
* native Prosemirror JSON, this representation ensures we have valid ADF attrs.
|
|
16
|
+
*
|
|
17
|
+
* @param node The Prosemirror node to transform.
|
|
18
|
+
* @param mentionMap A map of mention IDs to their display names.
|
|
19
|
+
* @returns The JSON representation of the node.
|
|
20
|
+
*/
|
|
21
|
+
declare const toJSON: (node: PMNode, mentionMap?: Record<string, string | undefined>) => JSONNode;
|
|
22
|
+
export { toJSON as nodeToJSON };
|
|
13
23
|
export declare class JSONTransformer implements Transformer<JSONDocNode> {
|
|
14
24
|
private schema;
|
|
15
25
|
private mentionMap;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { JSONNode } from '../index';
|
|
2
2
|
export declare function removeMarks(node: JSONNode): {
|
|
3
3
|
type: string;
|
|
4
|
-
attrs?: object
|
|
5
|
-
content?:
|
|
6
|
-
marks?: any[]
|
|
7
|
-
text?: string
|
|
4
|
+
attrs?: object;
|
|
5
|
+
content?: Array<JSONNode | undefined>;
|
|
6
|
+
marks?: any[];
|
|
7
|
+
text?: string;
|
|
8
8
|
};
|
|
9
9
|
export declare function removeNonAnnotationMarks(node: JSONNode): {
|
|
10
10
|
type: string;
|
|
11
|
-
attrs?: object
|
|
12
|
-
content?:
|
|
13
|
-
marks?: any[]
|
|
14
|
-
text?: string
|
|
11
|
+
attrs?: object;
|
|
12
|
+
content?: Array<JSONNode | undefined>;
|
|
13
|
+
marks?: any[];
|
|
14
|
+
text?: string;
|
|
15
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-json-transformer",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.26.0",
|
|
4
4
|
"description": "JSON transformer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -36,14 +36,13 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@atlaskit/adf-schema": "^50.2.0",
|
|
39
|
-
"@atlaskit/adf-utils": "^19.
|
|
39
|
+
"@atlaskit/adf-utils": "^19.21.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
41
|
"@babel/runtime": "^7.0.0",
|
|
42
42
|
"lodash": "^4.17.21"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"react": "^18.2.0"
|
|
46
|
-
"typescript": "~5.4.2"
|
|
45
|
+
"react": "^18.2.0"
|
|
47
46
|
},
|
|
48
47
|
"techstack": {
|
|
49
48
|
"@atlassian/frontend": {
|
package/sanitize/package.json
CHANGED