@atlaskit/adf-schema 25.2.1 → 25.2.3

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,17 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 25.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`85f02a75990`](https://bitbucket.org/atlassian/atlassian-frontend/commits/85f02a75990) - [hot-102658] Dummy patch added to stabalise package build failures caused because of bad remote cache
8
+
9
+ ## 25.2.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`8c04b73312e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8c04b73312e) - ED-16758 Added data-cell-background attribute to store table cell background color information.
14
+
3
15
  ## 25.2.1
4
16
 
5
17
  ### Patch Changes
@@ -28,6 +28,16 @@ var getCellAttrs = function getCellAttrs(dom) {
28
28
  var colspan = Number(dom.getAttribute('colspan') || 1);
29
29
  var backgroundColor = dom.style.backgroundColor;
30
30
 
31
+ /**
32
+ * We have pivoted to store background color information in
33
+ * data-cell-background.
34
+ * We will have original hex code (which we map to DST token)
35
+ * stored in data-cell-background, use that.
36
+ * More details at https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3472556903/Tokenising+tableCell+background+colors#Update-toDom-and-parseDom-to-store-and-read-background-color-from-data-cell-background-attribute.4
37
+ */
38
+ var dataCellBackground = dom.getAttribute('data-cell-background');
39
+ var dataCellBackgroundHexCode = dataCellBackground && (0, _colors.isHex)(dataCellBackground) ? dataCellBackground : undefined;
40
+
31
41
  // ignore setting background attr if ds neutral token is detected
32
42
  if (backgroundColor.includes('--ds-background-neutral')) {
33
43
  backgroundColor = '';
@@ -39,11 +49,12 @@ var getCellAttrs = function getCellAttrs(dom) {
39
49
  }
40
50
  }
41
51
  }
52
+ var backgroundHexCode = dataCellBackgroundHexCode || (backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null);
42
53
  return {
43
54
  colspan: colspan,
44
55
  rowspan: Number(dom.getAttribute('rowspan') || 1),
45
56
  colwidth: width && width.length === colspan ? width : null,
46
- background: backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null
57
+ background: backgroundHexCode
47
58
  };
48
59
  };
49
60
  exports.getCellAttrs = getCellAttrs;
@@ -75,7 +86,25 @@ var getCellDomAttrs = function getCellDomAttrs(node) {
75
86
  attrs.style = '';
76
87
  } else {
77
88
  var color = (0, _colors.isRgb)(background) ? (0, _colors.rgbToHex)(background) : background;
78
- attrs.style = "".concat(attrs.style || '', "background-color: ").concat(color, ";");
89
+ attrs.style = "".concat(attrs.style || '', "background-color: ").concat(color);
90
+
91
+ /**
92
+ * Storing hex code in data-cell-background because
93
+ * we want to have DST token (css variable) or
94
+ * DST token value (value (hex code) of css variable) in
95
+ * inline style to correct render table cell background
96
+ * based on selected theme.
97
+ * Currently we rely on background color hex code stored in
98
+ * inline style.
99
+ * Because of that when we copy and paste table, we end up
100
+ * having DST token or DST token value in ADF instead of
101
+ * original hex code which we map to DST token.
102
+ * So, introducing data-cell-background.
103
+ * More details at https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3472556903/Tokenising+tableCell+background+colors#Update-toDom-and-parseDom-to-store-and-read-background-color-from-data-cell-background-attribute.4
104
+ */
105
+ if (color) {
106
+ attrs['data-cell-background'] = color;
107
+ }
79
108
  attrs.colorname = tableBackgroundColorPalette.get(color);
80
109
  }
81
110
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.2.1",
3
+ "version": "25.2.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { B100, B50, B75, G200, G50, G75, hexToRgba, isRgb, N0, N20, N60, N800, P100, P50, P75, R100, R50, R75, rgbToHex, T100, T50, T75, Y200, Y50, Y75 } from '../../utils/colors';
1
+ import { B100, B50, B75, G200, G50, G75, hexToRgba, isHex, isRgb, N0, N20, N60, N800, P100, P50, P75, R100, R50, R75, rgbToHex, T100, T50, T75, Y200, Y50, Y75 } from '../../utils/colors';
2
2
  import { uuid } from '../../utils/uuid';
3
3
  export const tablePrefixSelector = 'pm-table';
4
4
  export const tableCellSelector = `${tablePrefixSelector}-cell-content-wrap`;
@@ -14,6 +14,16 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
14
14
  backgroundColor
15
15
  } = dom.style;
16
16
 
17
+ /**
18
+ * We have pivoted to store background color information in
19
+ * data-cell-background.
20
+ * We will have original hex code (which we map to DST token)
21
+ * stored in data-cell-background, use that.
22
+ * More details at https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3472556903/Tokenising+tableCell+background+colors#Update-toDom-and-parseDom-to-store-and-read-background-color-from-data-cell-background-attribute.4
23
+ */
24
+ const dataCellBackground = dom.getAttribute('data-cell-background');
25
+ const dataCellBackgroundHexCode = dataCellBackground && isHex(dataCellBackground) ? dataCellBackground : undefined;
26
+
17
27
  // ignore setting background attr if ds neutral token is detected
18
28
  if (backgroundColor.includes('--ds-background-neutral')) {
19
29
  backgroundColor = '';
@@ -25,11 +35,12 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
25
35
  }
26
36
  }
27
37
  }
38
+ const backgroundHexCode = dataCellBackgroundHexCode || (backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null);
28
39
  return {
29
40
  colspan,
30
41
  rowspan: Number(dom.getAttribute('rowspan') || 1),
31
42
  colwidth: width && width.length === colspan ? width : null,
32
- background: backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null
43
+ background: backgroundHexCode
33
44
  };
34
45
  };
35
46
  /**
@@ -62,7 +73,25 @@ export const getCellDomAttrs = node => {
62
73
  attrs.style = '';
63
74
  } else {
64
75
  const color = isRgb(background) ? rgbToHex(background) : background;
65
- attrs.style = `${attrs.style || ''}background-color: ${color};`;
76
+ attrs.style = `${attrs.style || ''}background-color: ${color}`;
77
+
78
+ /**
79
+ * Storing hex code in data-cell-background because
80
+ * we want to have DST token (css variable) or
81
+ * DST token value (value (hex code) of css variable) in
82
+ * inline style to correct render table cell background
83
+ * based on selected theme.
84
+ * Currently we rely on background color hex code stored in
85
+ * inline style.
86
+ * Because of that when we copy and paste table, we end up
87
+ * having DST token or DST token value in ADF instead of
88
+ * original hex code which we map to DST token.
89
+ * So, introducing data-cell-background.
90
+ * More details at https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3472556903/Tokenising+tableCell+background+colors#Update-toDom-and-parseDom-to-store-and-read-background-color-from-data-cell-background-attribute.4
91
+ */
92
+ if (color) {
93
+ attrs['data-cell-background'] = color;
94
+ }
66
95
  attrs.colorname = tableBackgroundColorPalette.get(color);
67
96
  }
68
97
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.2.1",
3
+ "version": "25.2.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { B100, B50, B75, G200, G50, G75, hexToRgba, isRgb, N0, N20, N60, N800, P100, P50, P75, R100, R50, R75, rgbToHex, T100, T50, T75, Y200, Y50, Y75 } from '../../utils/colors';
2
+ import { B100, B50, B75, G200, G50, G75, hexToRgba, isHex, isRgb, N0, N20, N60, N800, P100, P50, P75, R100, R50, R75, rgbToHex, T100, T50, T75, Y200, Y50, Y75 } from '../../utils/colors';
3
3
  import { uuid } from '../../utils/uuid';
4
4
  export var tablePrefixSelector = 'pm-table';
5
5
  export var tableCellSelector = "".concat(tablePrefixSelector, "-cell-content-wrap");
@@ -16,6 +16,16 @@ export var getCellAttrs = function getCellAttrs(dom) {
16
16
  var colspan = Number(dom.getAttribute('colspan') || 1);
17
17
  var backgroundColor = dom.style.backgroundColor;
18
18
 
19
+ /**
20
+ * We have pivoted to store background color information in
21
+ * data-cell-background.
22
+ * We will have original hex code (which we map to DST token)
23
+ * stored in data-cell-background, use that.
24
+ * More details at https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3472556903/Tokenising+tableCell+background+colors#Update-toDom-and-parseDom-to-store-and-read-background-color-from-data-cell-background-attribute.4
25
+ */
26
+ var dataCellBackground = dom.getAttribute('data-cell-background');
27
+ var dataCellBackgroundHexCode = dataCellBackground && isHex(dataCellBackground) ? dataCellBackground : undefined;
28
+
19
29
  // ignore setting background attr if ds neutral token is detected
20
30
  if (backgroundColor.includes('--ds-background-neutral')) {
21
31
  backgroundColor = '';
@@ -27,11 +37,12 @@ export var getCellAttrs = function getCellAttrs(dom) {
27
37
  }
28
38
  }
29
39
  }
40
+ var backgroundHexCode = dataCellBackgroundHexCode || (backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null);
30
41
  return {
31
42
  colspan: colspan,
32
43
  rowspan: Number(dom.getAttribute('rowspan') || 1),
33
44
  colwidth: width && width.length === colspan ? width : null,
34
- background: backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null
45
+ background: backgroundHexCode
35
46
  };
36
47
  };
37
48
  /**
@@ -62,7 +73,25 @@ export var getCellDomAttrs = function getCellDomAttrs(node) {
62
73
  attrs.style = '';
63
74
  } else {
64
75
  var color = isRgb(background) ? rgbToHex(background) : background;
65
- attrs.style = "".concat(attrs.style || '', "background-color: ").concat(color, ";");
76
+ attrs.style = "".concat(attrs.style || '', "background-color: ").concat(color);
77
+
78
+ /**
79
+ * Storing hex code in data-cell-background because
80
+ * we want to have DST token (css variable) or
81
+ * DST token value (value (hex code) of css variable) in
82
+ * inline style to correct render table cell background
83
+ * based on selected theme.
84
+ * Currently we rely on background color hex code stored in
85
+ * inline style.
86
+ * Because of that when we copy and paste table, we end up
87
+ * having DST token or DST token value in ADF instead of
88
+ * original hex code which we map to DST token.
89
+ * So, introducing data-cell-background.
90
+ * More details at https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3472556903/Tokenising+tableCell+background+colors#Update-toDom-and-parseDom-to-store-and-read-background-color-from-data-cell-background-attribute.4
91
+ */
92
+ if (color) {
93
+ attrs['data-cell-background'] = color;
94
+ }
66
95
  attrs.colorname = tableBackgroundColorPalette.get(color);
67
96
  }
68
97
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.2.1",
3
+ "version": "25.2.3",
4
4
  "sideEffects": false
5
5
  }
@@ -35,6 +35,7 @@ export declare type CellDomAttrs = {
35
35
  style?: string;
36
36
  colorname?: string;
37
37
  'data-colwidth'?: string;
38
+ 'data-cell-background'?: string;
38
39
  class?: string;
39
40
  };
40
41
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.2.1",
3
+ "version": "25.2.3",
4
4
  "description": "Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"