@atlaskit/adf-schema 57.7.18 → 57.7.20

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,19 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 57.7.20
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 57.7.19
10
+
11
+ ### Patch Changes
12
+
13
+ - [`db9a31339d0d5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/db9a31339d0d5) -
14
+ [EDITOR-9512] prevent table cell background color from being parsed as text highlight color when
15
+ `platform_editor_fix_table_cell_background` is enabled.
16
+
3
17
  ## 57.7.18
4
18
 
5
19
  ### Patch Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.backgroundColorPaletteNew = exports.backgroundColorPalette = exports.backgroundColor = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
10
11
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
11
12
  var _markTypes = require("../../next-schema/generated/markTypes");
12
13
  var _colors = require("../../utils/colors");
@@ -75,21 +76,38 @@ var isSupportedBackgroundColor = function isSupportedBackgroundColor(hexColor) {
75
76
  }
76
77
  return (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_text_bg_color', 'isEnabled', true) && backgroundColorPaletteNew.has(hexColor);
77
78
  };
79
+ var getBackgroundColor = function getBackgroundColor(value) {
80
+ var hexColor;
81
+ if (value.match(RGB_PREFIX_BG_COLOR_REGEX)) {
82
+ hexColor = (0, _rgbToHex.rgbToHex)(value);
83
+ } else if (value[0] === '#') {
84
+ hexColor = value.toLowerCase();
85
+ }
86
+ // else handle other colour formats
87
+ return hexColor && isSupportedBackgroundColor(hexColor) ? {
88
+ color: hexColor
89
+ } : false;
90
+ };
78
91
  var backgroundColor = exports.backgroundColor = (0, _markTypes.backgroundColor)({
79
92
  parseDOM: [{
80
93
  style: 'background-color',
81
94
  getAttrs: function getAttrs(maybeValue) {
82
- var value = maybeValue;
83
- var hexColor;
84
- if (value.match(RGB_PREFIX_BG_COLOR_REGEX)) {
85
- hexColor = (0, _rgbToHex.rgbToHex)(value);
86
- } else if (value[0] === '#') {
87
- hexColor = value.toLowerCase();
95
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_fix_table_cell_background')) {
96
+ return false;
88
97
  }
89
- // else handle other colour formats
90
- return hexColor && isSupportedBackgroundColor(hexColor) ? {
91
- color: hexColor
92
- } : false;
98
+ return getBackgroundColor(maybeValue);
99
+ }
100
+ }, {
101
+ // the table cell and background color palettes overlap on Blue and Green, so
102
+ // we need to exclude table cells to avoid parsing table cell background as background color
103
+ tag: '[style]:not(td):not(th)',
104
+ consuming: false,
105
+ priority: 60,
106
+ getAttrs: function getAttrs(maybeElement) {
107
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_fix_table_cell_background') || !(maybeElement instanceof HTMLElement)) {
108
+ return false;
109
+ }
110
+ return getBackgroundColor(maybeElement.style.backgroundColor);
93
111
  }
94
112
  },
95
113
  // This rule ensures when loading from a renderer or editor where the
@@ -1,3 +1,4 @@
1
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
1
2
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
2
3
  import { backgroundColor as backgroundColorFactory } from '../../next-schema/generated/markTypes';
3
4
  import { B75, G75, L200, M200, Neutral300, O200, P200, R200, T200, Yellow200 } from '../../utils/colors';
@@ -57,21 +58,38 @@ const isSupportedBackgroundColor = hexColor => {
57
58
  }
58
59
  return expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && backgroundColorPaletteNew.has(hexColor);
59
60
  };
61
+ const getBackgroundColor = value => {
62
+ let hexColor;
63
+ if (value.match(RGB_PREFIX_BG_COLOR_REGEX)) {
64
+ hexColor = rgbToHex(value);
65
+ } else if (value[0] === '#') {
66
+ hexColor = value.toLowerCase();
67
+ }
68
+ // else handle other colour formats
69
+ return hexColor && isSupportedBackgroundColor(hexColor) ? {
70
+ color: hexColor
71
+ } : false;
72
+ };
60
73
  export const backgroundColor = backgroundColorFactory({
61
74
  parseDOM: [{
62
75
  style: 'background-color',
63
76
  getAttrs: maybeValue => {
64
- const value = maybeValue;
65
- let hexColor;
66
- if (value.match(RGB_PREFIX_BG_COLOR_REGEX)) {
67
- hexColor = rgbToHex(value);
68
- } else if (value[0] === '#') {
69
- hexColor = value.toLowerCase();
77
+ if (isExperimentEnabled('platform_editor_fix_table_cell_background')) {
78
+ return false;
70
79
  }
71
- // else handle other colour formats
72
- return hexColor && isSupportedBackgroundColor(hexColor) ? {
73
- color: hexColor
74
- } : false;
80
+ return getBackgroundColor(maybeValue);
81
+ }
82
+ }, {
83
+ // the table cell and background color palettes overlap on Blue and Green, so
84
+ // we need to exclude table cells to avoid parsing table cell background as background color
85
+ tag: '[style]:not(td):not(th)',
86
+ consuming: false,
87
+ priority: 60,
88
+ getAttrs: maybeElement => {
89
+ if (!isExperimentEnabled('platform_editor_fix_table_cell_background') || !(maybeElement instanceof HTMLElement)) {
90
+ return false;
91
+ }
92
+ return getBackgroundColor(maybeElement.style.backgroundColor);
75
93
  }
76
94
  },
77
95
  // This rule ensures when loading from a renderer or editor where the
@@ -1,5 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
4
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
4
5
  import { backgroundColor as backgroundColorFactory } from '../../next-schema/generated/markTypes';
5
6
  import { B75, G75, L200, M200, Neutral300, O200, P200, R200, T200, Yellow200 } from '../../utils/colors';
@@ -69,21 +70,38 @@ var isSupportedBackgroundColor = function isSupportedBackgroundColor(hexColor) {
69
70
  }
70
71
  return expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && backgroundColorPaletteNew.has(hexColor);
71
72
  };
73
+ var getBackgroundColor = function getBackgroundColor(value) {
74
+ var hexColor;
75
+ if (value.match(RGB_PREFIX_BG_COLOR_REGEX)) {
76
+ hexColor = rgbToHex(value);
77
+ } else if (value[0] === '#') {
78
+ hexColor = value.toLowerCase();
79
+ }
80
+ // else handle other colour formats
81
+ return hexColor && isSupportedBackgroundColor(hexColor) ? {
82
+ color: hexColor
83
+ } : false;
84
+ };
72
85
  export var backgroundColor = backgroundColorFactory({
73
86
  parseDOM: [{
74
87
  style: 'background-color',
75
88
  getAttrs: function getAttrs(maybeValue) {
76
- var value = maybeValue;
77
- var hexColor;
78
- if (value.match(RGB_PREFIX_BG_COLOR_REGEX)) {
79
- hexColor = rgbToHex(value);
80
- } else if (value[0] === '#') {
81
- hexColor = value.toLowerCase();
89
+ if (isExperimentEnabled('platform_editor_fix_table_cell_background')) {
90
+ return false;
82
91
  }
83
- // else handle other colour formats
84
- return hexColor && isSupportedBackgroundColor(hexColor) ? {
85
- color: hexColor
86
- } : false;
92
+ return getBackgroundColor(maybeValue);
93
+ }
94
+ }, {
95
+ // the table cell and background color palettes overlap on Blue and Green, so
96
+ // we need to exclude table cells to avoid parsing table cell background as background color
97
+ tag: '[style]:not(td):not(th)',
98
+ consuming: false,
99
+ priority: 60,
100
+ getAttrs: function getAttrs(maybeElement) {
101
+ if (!isExperimentEnabled('platform_editor_fix_table_cell_background') || !(maybeElement instanceof HTMLElement)) {
102
+ return false;
103
+ }
104
+ return getBackgroundColor(maybeElement.style.backgroundColor);
87
105
  }
88
106
  },
89
107
  // This rule ensures when loading from a renderer or editor where the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "57.7.18",
3
+ "version": "57.7.20",
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/"
@@ -39,8 +39,9 @@
39
39
  "dependencies": {
40
40
  "@atlaskit/adf-schema-generator": "^4.0.0",
41
41
  "@atlaskit/editor-prosemirror": "^9.0.0",
42
+ "@atlaskit/platform-feature-experiments": "^0.3.0",
42
43
  "@atlaskit/platform-feature-flags": "^2.2.0",
43
- "@atlaskit/tmp-editor-statsig": "^242.0.0",
44
+ "@atlaskit/tmp-editor-statsig": "^243.0.0",
44
45
  "@babel/runtime": "^7.0.0",
45
46
  "css-color-names": "0.0.4",
46
47
  "linkify-it": "^5.0.2",
@@ -60,6 +61,7 @@
60
61
  "@atlaskit/codemod-utils": "^5.1.0",
61
62
  "@atlassian/adf-schema-json": "^1.35.0",
62
63
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
64
+ "@atlassian/experiment-test-utils": "^0.2.0",
63
65
  "@atlassian/ts-loader": "^0.1.0",
64
66
  "@babel/cli": "^7.20.0",
65
67
  "@babel/core": "7.24.9",