@atlaskit/editor-json-transformer 8.31.3 → 8.31.5

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,20 @@
1
1
  # @atlaskit/editor-json-transformer
2
2
 
3
+ ## 8.31.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1004093d5acc2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1004093d5acc2) -
8
+ EDITOR-5371 add util validator function
9
+
10
+ ## 8.31.4
11
+
12
+ ### Patch Changes
13
+
14
+ - [`e3779b75fdeca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3779b75fdeca) -
15
+ EDITOR-1643 Promote syncBlock and bodiedSyncBlock to full schema
16
+ - Updated dependencies
17
+
3
18
  ## 8.31.3
4
19
 
5
20
  ### Patch Changes
@@ -1,11 +1,12 @@
1
1
  {
2
- "extends": "../../../../tsconfig.entry-points.confluence.json",
2
+ "extends": "../../../../tsconfig.local-consumption.json",
3
3
  "compilerOptions": {
4
4
  "declaration": true,
5
5
  "target": "es5",
6
6
  "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-json-transformer",
7
7
  "rootDir": "../",
8
- "composite": true
8
+ "composite": true,
9
+ "noCheck": true
9
10
  },
10
11
  "include": [
11
12
  "../src/**/*.ts",
@@ -23,8 +24,14 @@
23
24
  "../src/**/stories/**/*"
24
25
  ],
25
26
  "references": [
27
+ {
28
+ "path": "../../adf-schema/afm-cc/tsconfig.json"
29
+ },
26
30
  {
27
31
  "path": "../../adf-utils/afm-cc/tsconfig.json"
32
+ },
33
+ {
34
+ "path": "../../editor-prosemirror/afm-cc/tsconfig.json"
28
35
  }
29
36
  ]
30
37
  }
@@ -1,11 +1,12 @@
1
1
  {
2
- "extends": "../../../../tsconfig.entry-points.jira.json",
2
+ "extends": "../../../../tsconfig.local-consumption.json",
3
3
  "compilerOptions": {
4
4
  "declaration": true,
5
5
  "target": "es5",
6
6
  "outDir": "../../../../../jira/tsDist/@atlaskit__editor-json-transformer/app",
7
7
  "rootDir": "../",
8
- "composite": true
8
+ "composite": true,
9
+ "noCheck": true
9
10
  },
10
11
  "include": [
11
12
  "../src/**/*.ts",
@@ -23,8 +24,14 @@
23
24
  "../src/**/stories/**/*"
24
25
  ],
25
26
  "references": [
27
+ {
28
+ "path": "../../adf-schema/afm-jira/tsconfig.json"
29
+ },
26
30
  {
27
31
  "path": "../../adf-utils/afm-jira/tsconfig.json"
32
+ },
33
+ {
34
+ "path": "../../editor-prosemirror/afm-jira/tsconfig.json"
28
35
  }
29
36
  ]
30
37
  }
@@ -1,11 +1,12 @@
1
1
  {
2
- "extends": "../../../../tsconfig.entry-points.products.json",
2
+ "extends": "../../../../tsconfig.local-consumption.json",
3
3
  "compilerOptions": {
4
4
  "declaration": true,
5
5
  "target": "es5",
6
6
  "outDir": "../../../../../tsDist/@atlaskit__editor-json-transformer/app",
7
7
  "rootDir": "../",
8
- "composite": true
8
+ "composite": true,
9
+ "noCheck": true
9
10
  },
10
11
  "include": [
11
12
  "../src/**/*.ts",
@@ -23,8 +24,14 @@
23
24
  "../src/**/stories/**/*"
24
25
  ],
25
26
  "references": [
27
+ {
28
+ "path": "../../adf-schema/afm-products/tsconfig.json"
29
+ },
26
30
  {
27
31
  "path": "../../adf-utils/afm-products/tsconfig.json"
32
+ },
33
+ {
34
+ "path": "../../editor-prosemirror/afm-products/tsconfig.json"
28
35
  }
29
36
  ]
30
37
  }
package/dist/cjs/index.js CHANGED
@@ -5,7 +5,9 @@ var _typeof3 = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.nodeToJSON = exports.SchemaStage = exports.JSONTransformer = void 0;
8
+ exports.SchemaStage = exports.JSONTransformer = void 0;
9
+ exports.isJSONDocNode = isJSONDocNode;
10
+ exports.nodeToJSON = void 0;
9
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
13
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
@@ -265,4 +267,30 @@ var JSONTransformer = exports.JSONTransformer = /*#__PURE__*/function () {
265
267
  return (0, _sanitizeNode.sanitizeNode)(_toJSON(node, this.mentionMap));
266
268
  }
267
269
  }]);
268
- }();
270
+ }();
271
+ /**
272
+ * Quick type guard to check if a value is a valid JSONDocNode
273
+ * This is only a basic structural check, does not validate the entire object nor the schema.
274
+ * @param value - The value to check
275
+ * @returns true if the value is a valid JSONDocNode structure
276
+ */
277
+ function isJSONDocNode(value) {
278
+ if (!value || (0, _typeof2.default)(value) !== 'object') {
279
+ return false;
280
+ }
281
+ var doc = value;
282
+
283
+ // Check required properties
284
+ if (doc.type !== 'doc') {
285
+ return false;
286
+ }
287
+ if (!Array.isArray(doc.content)) {
288
+ return false;
289
+ }
290
+
291
+ // Version is optional but if present should be a number
292
+ if (doc.version !== undefined && typeof doc.version !== 'number') {
293
+ return false;
294
+ }
295
+ return true;
296
+ }
@@ -239,4 +239,31 @@ export class JSONTransformer {
239
239
  encodeNode(node) {
240
240
  return sanitizeNode(toJSON(node, this.mentionMap));
241
241
  }
242
+ }
243
+
244
+ /**
245
+ * Quick type guard to check if a value is a valid JSONDocNode
246
+ * This is only a basic structural check, does not validate the entire object nor the schema.
247
+ * @param value - The value to check
248
+ * @returns true if the value is a valid JSONDocNode structure
249
+ */
250
+ export function isJSONDocNode(value) {
251
+ if (!value || typeof value !== 'object') {
252
+ return false;
253
+ }
254
+ const doc = value;
255
+
256
+ // Check required properties
257
+ if (doc.type !== 'doc') {
258
+ return false;
259
+ }
260
+ if (!Array.isArray(doc.content)) {
261
+ return false;
262
+ }
263
+
264
+ // Version is optional but if present should be a number
265
+ if (doc.version !== undefined && typeof doc.version !== 'number') {
266
+ return false;
267
+ }
268
+ return true;
242
269
  }
package/dist/esm/index.js CHANGED
@@ -260,4 +260,31 @@ export var JSONTransformer = /*#__PURE__*/function () {
260
260
  return sanitizeNode(_toJSON(node, this.mentionMap));
261
261
  }
262
262
  }]);
263
- }();
263
+ }();
264
+
265
+ /**
266
+ * Quick type guard to check if a value is a valid JSONDocNode
267
+ * This is only a basic structural check, does not validate the entire object nor the schema.
268
+ * @param value - The value to check
269
+ * @returns true if the value is a valid JSONDocNode structure
270
+ */
271
+ export function isJSONDocNode(value) {
272
+ if (!value || _typeof(value) !== 'object') {
273
+ return false;
274
+ }
275
+ var doc = value;
276
+
277
+ // Check required properties
278
+ if (doc.type !== 'doc') {
279
+ return false;
280
+ }
281
+ if (!Array.isArray(doc.content)) {
282
+ return false;
283
+ }
284
+
285
+ // Version is optional but if present should be a number
286
+ if (doc.version !== undefined && typeof doc.version !== 'number') {
287
+ return false;
288
+ }
289
+ return true;
290
+ }
@@ -37,3 +37,10 @@ export declare class JSONTransformer implements Transformer<JSONDocNode> {
37
37
  */
38
38
  encodeNode(node: PMNode): JSONNode;
39
39
  }
40
+ /**
41
+ * Quick type guard to check if a value is a valid JSONDocNode
42
+ * This is only a basic structural check, does not validate the entire object nor the schema.
43
+ * @param value - The value to check
44
+ * @returns true if the value is a valid JSONDocNode structure
45
+ */
46
+ export declare function isJSONDocNode(value: unknown): value is JSONDocNode;
@@ -37,3 +37,10 @@ export declare class JSONTransformer implements Transformer<JSONDocNode> {
37
37
  */
38
38
  encodeNode(node: PMNode): JSONNode;
39
39
  }
40
+ /**
41
+ * Quick type guard to check if a value is a valid JSONDocNode
42
+ * This is only a basic structural check, does not validate the entire object nor the schema.
43
+ * @param value - The value to check
44
+ * @returns true if the value is a valid JSONDocNode structure
45
+ */
46
+ export declare function isJSONDocNode(value: unknown): value is JSONDocNode;
package/docs/0-intro.tsx CHANGED
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  import { AtlassianInternalWarning, code, Example, md } from '@atlaskit/docs';
4
4
 
5
- export default md`
5
+ const _default_1: React.ReactElement = md`
6
6
  ${(<AtlassianInternalWarning />)}
7
7
 
8
8
  This transformer allows encoding ProseMirror Node in JSON format.
@@ -28,3 +28,4 @@ This transformer allows encoding ProseMirror Node in JSON format.
28
28
  />
29
29
  )}
30
30
  `;
31
+ export default _default_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-json-transformer",
3
- "version": "8.31.3",
3
+ "version": "8.31.5",
4
4
  "description": "JSON transformer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,13 +29,14 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@atlaskit/adf-schema": "^51.4.0",
33
- "@atlaskit/adf-utils": "^19.26.0",
34
- "@atlaskit/editor-prosemirror": "7.0.0",
32
+ "@atlaskit/adf-schema": "^51.5.0",
33
+ "@atlaskit/adf-utils": "^19.27.0",
34
+ "@atlaskit/editor-prosemirror": "^7.3.0",
35
35
  "@babel/runtime": "^7.0.0",
36
36
  "lodash": "^4.17.21"
37
37
  },
38
38
  "devDependencies": {
39
+ "@atlassian/a11y-jest-testing": "^0.10.0",
39
40
  "react": "^18.2.0"
40
41
  },
41
42
  "techstack": {
package/tsconfig.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "extends": "../../../tsconfig.json",
3
- "compilerOptions": {},
4
3
  "include": [
5
4
  "./src/**/*.ts",
6
5
  "./src/**/*.tsx",
@@ -1,23 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "target": "es5",
6
- "paths": {}
7
- },
8
- "include": [
9
- "../src/**/*.ts",
10
- "../src/**/*.tsx"
11
- ],
12
- "exclude": [
13
- "../src/**/__tests__/*",
14
- "../src/**/*.test.*",
15
- "../src/**/test.*",
16
- "../src/**/examples.*",
17
- "../src/**/examples/*",
18
- "../src/**/examples/**/*",
19
- "../src/**/*.stories.*",
20
- "../src/**/stories/*",
21
- "../src/**/stories/**/*"
22
- ]
23
- }