@atlaskit/editor-json-transformer 8.24.4 → 8.24.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,14 @@
1
1
  # @atlaskit/editor-json-transformer
2
2
 
3
+ ## 8.24.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#191913](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191913)
8
+ [`6d1e56695e91d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6d1e56695e91d) -
9
+ EDITOR-1131 Bump adf-schema package to 50.0.0
10
+ - Updated dependencies
11
+
3
12
  ## 8.24.4
4
13
 
5
14
  ### Patch Changes
@@ -1,24 +1,24 @@
1
1
  {
2
- "extends": "../../../../tsconfig.entry-points.confluence.json",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "target": "es5",
6
- "composite": true,
7
- "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-json-transformer",
8
- "rootDir": "../"
9
- },
10
- "include": [
11
- "../src/**/*.ts",
12
- "../src/**/*.tsx"
13
- ],
14
- "exclude": [
15
- "../src/**/__tests__/*",
16
- "../src/**/*.test.*",
17
- "../src/**/test.*"
18
- ],
19
- "references": [
20
- {
21
- "path": "../../adf-utils/afm-cc/tsconfig.json"
22
- }
23
- ]
2
+ "extends": "../../../../tsconfig.entry-points.confluence.json",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "target": "es5",
6
+ "composite": true,
7
+ "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-json-transformer",
8
+ "rootDir": "../"
9
+ },
10
+ "include": [
11
+ "../src/**/*.ts",
12
+ "../src/**/*.tsx"
13
+ ],
14
+ "exclude": [
15
+ "../src/**/__tests__/*",
16
+ "../src/**/*.test.*",
17
+ "../src/**/test.*"
18
+ ],
19
+ "references": [
20
+ {
21
+ "path": "../../adf-utils/afm-cc/tsconfig.json"
22
+ }
23
+ ]
24
24
  }
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "../../../../tsconfig.entry-points.townsquare.json",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "target": "es5",
6
+ "outDir": "../../../../../townsquare/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
+ ],
19
+ "references": [
20
+ {
21
+ "path": "../../adf-utils/afm-townsquare/tsconfig.json"
22
+ }
23
+ ]
24
+ }
package/dist/cjs/index.js CHANGED
@@ -31,6 +31,9 @@ var isType = function isType(type) {
31
31
  return node.type.name === type;
32
32
  };
33
33
  };
34
+
35
+ // Create a Set of node types that should have empty attrs removed
36
+ var NODES_WITH_EMPTY_ATTRS_REMOVAL = new Set(['paragraph', 'layoutSection', 'blockquote', 'nestedExpand', 'bulletList', 'listItem', 'orderedList', 'rule', 'caption', 'tableRow', 'media', 'mediaSingle', 'mediaInline']);
34
37
  var isCodeBlock = isType('codeBlock');
35
38
  var isMediaNode = isType('media');
36
39
  var isMediaInline = isType('mediaInline');
@@ -123,15 +126,7 @@ var _toJSON = function toJSON(node, mentionMap) {
123
126
  text: !!text ? text : name
124
127
  });
125
128
  }
126
-
127
- // Remove the attrs property if it's empty, this is currently limited to paragraph nodes.
128
- if (isParagraph(node) && obj.attrs && !Object.keys(obj.attrs).length) {
129
- delete obj.attrs;
130
- }
131
-
132
- // Hard break has optional attr.text which was added for PM <-> ADF compatibility.
133
- // No need to preserve it.
134
- if (isHardBreak(node)) {
129
+ if (NODES_WITH_EMPTY_ATTRS_REMOVAL.has(node.type.name) && obj.attrs && !Object.keys(obj.attrs).length || isHardBreak(node)) {
135
130
  delete obj.attrs;
136
131
  }
137
132
  if (node.isText) {
@@ -12,6 +12,9 @@ export let SchemaStage = /*#__PURE__*/function (SchemaStage) {
12
12
  return SchemaStage;
13
13
  }({});
14
14
  const isType = type => node => node.type.name === type;
15
+
16
+ // Create a Set of node types that should have empty attrs removed
17
+ const NODES_WITH_EMPTY_ATTRS_REMOVAL = new Set(['paragraph', 'layoutSection', 'blockquote', 'nestedExpand', 'bulletList', 'listItem', 'orderedList', 'rule', 'caption', 'tableRow', 'media', 'mediaSingle', 'mediaInline']);
15
18
  const isCodeBlock = isType('codeBlock');
16
19
  const isMediaNode = isType('media');
17
20
  const isMediaInline = isType('mediaInline');
@@ -106,15 +109,7 @@ const toJSON = (node, mentionMap) => {
106
109
  text: !!text ? text : name
107
110
  };
108
111
  }
109
-
110
- // Remove the attrs property if it's empty, this is currently limited to paragraph nodes.
111
- if (isParagraph(node) && obj.attrs && !Object.keys(obj.attrs).length) {
112
- delete obj.attrs;
113
- }
114
-
115
- // Hard break has optional attr.text which was added for PM <-> ADF compatibility.
116
- // No need to preserve it.
117
- if (isHardBreak(node)) {
112
+ if (NODES_WITH_EMPTY_ATTRS_REMOVAL.has(node.type.name) && obj.attrs && !Object.keys(obj.attrs).length || isHardBreak(node)) {
118
113
  delete obj.attrs;
119
114
  }
120
115
  if (node.isText) {
package/dist/esm/index.js CHANGED
@@ -25,6 +25,9 @@ var isType = function isType(type) {
25
25
  return node.type.name === type;
26
26
  };
27
27
  };
28
+
29
+ // Create a Set of node types that should have empty attrs removed
30
+ var NODES_WITH_EMPTY_ATTRS_REMOVAL = new Set(['paragraph', 'layoutSection', 'blockquote', 'nestedExpand', 'bulletList', 'listItem', 'orderedList', 'rule', 'caption', 'tableRow', 'media', 'mediaSingle', 'mediaInline']);
28
31
  var isCodeBlock = isType('codeBlock');
29
32
  var isMediaNode = isType('media');
30
33
  var isMediaInline = isType('mediaInline');
@@ -117,15 +120,7 @@ var _toJSON = function toJSON(node, mentionMap) {
117
120
  text: !!text ? text : name
118
121
  });
119
122
  }
120
-
121
- // Remove the attrs property if it's empty, this is currently limited to paragraph nodes.
122
- if (isParagraph(node) && obj.attrs && !Object.keys(obj.attrs).length) {
123
- delete obj.attrs;
124
- }
125
-
126
- // Hard break has optional attr.text which was added for PM <-> ADF compatibility.
127
- // No need to preserve it.
128
- if (isHardBreak(node)) {
123
+ if (NODES_WITH_EMPTY_ATTRS_REMOVAL.has(node.type.name) && obj.attrs && !Object.keys(obj.attrs).length || isHardBreak(node)) {
129
124
  delete obj.attrs;
130
125
  }
131
126
  if (node.isText) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-json-transformer",
3
- "version": "8.24.4",
3
+ "version": "8.24.5",
4
4
  "description": "JSON transformer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -35,7 +35,7 @@
35
35
  "./types": "./src/types.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@atlaskit/adf-schema": "^49.0.6",
38
+ "@atlaskit/adf-schema": "^50.0.1",
39
39
  "@atlaskit/adf-utils": "^19.20.0",
40
40
  "@atlaskit/editor-prosemirror": "7.0.0",
41
41
  "@babel/runtime": "^7.0.0",