@atlaskit/editor-json-transformer 8.25.1 → 8.26.1

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,21 @@
1
1
  # @atlaskit/editor-json-transformer
2
2
 
3
+ ## 8.26.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`57b19274b9fdd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/57b19274b9fdd) -
8
+ EDITOR-1373 Bump adf-schema version
9
+ - Updated dependencies
10
+
11
+ ## 8.26.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`7b86b50272e47`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7b86b50272e47) -
16
+ Expose new utility function, `nodeToJSON` which can be used to safely return a JSON object from a
17
+ node.
18
+
3
19
  ## 8.25.1
4
20
 
5
21
  ### 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
+ }
@@ -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
- var _toJSON = function toJSON(node, mentionMap) {
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
  };
@@ -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;
@@ -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 | undefined;
5
- content?: (JSONNode | undefined)[] | undefined;
6
- marks?: any[] | undefined;
7
- text?: string | undefined;
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 | undefined;
12
- content?: (JSONNode | undefined)[] | undefined;
13
- marks?: any[] | undefined;
14
- text?: string | undefined;
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 | undefined;
5
- content?: (JSONNode | undefined)[] | undefined;
6
- marks?: any[] | undefined;
7
- text?: string | undefined;
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 | undefined;
12
- content?: (JSONNode | undefined)[] | undefined;
13
- marks?: any[] | undefined;
14
- text?: string | undefined;
11
+ attrs?: object;
12
+ content?: Array<JSONNode | undefined>;
13
+ marks?: any[];
14
+ text?: string;
15
15
  };
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/markOverrideRules.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <5.4": {
9
+ ">=4.5 <5.9": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/markOverrideRules.d.ts"
12
12
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-json-transformer",
3
- "version": "8.25.1",
3
+ "version": "8.26.1",
4
4
  "description": "JSON transformer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -35,15 +35,14 @@
35
35
  "./types": "./src/types.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@atlaskit/adf-schema": "^50.2.0",
39
- "@atlaskit/adf-utils": "^19.20.0",
38
+ "@atlaskit/adf-schema": "^50.2.1",
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": {
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/sanitize.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <5.4": {
9
+ ">=4.5 <5.9": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/sanitize.d.ts"
12
12
  ]
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/types.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <5.4": {
9
+ ">=4.5 <5.9": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/types.d.ts"
12
12
  ]