@atlaskit/adf-schema 35.2.0 → 35.4.0

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +12 -0
  3. package/dist/cjs/schema/create-schema.js +2 -2
  4. package/dist/cjs/schema/index.js +12 -0
  5. package/dist/cjs/schema/marks/text-color.js +1 -37
  6. package/dist/cjs/schema/nodes/index.js +12 -0
  7. package/dist/cjs/schema/nodes/list-item.js +20 -2
  8. package/dist/cjs/schema/nodes/panel.js +33 -2
  9. package/dist/cjs/schema/nodes/tableNodes.js +1 -37
  10. package/dist/es2019/index.js +1 -1
  11. package/dist/es2019/schema/create-schema.js +3 -3
  12. package/dist/es2019/schema/index.js +1 -1
  13. package/dist/es2019/schema/marks/text-color.js +2 -38
  14. package/dist/es2019/schema/nodes/index.js +2 -2
  15. package/dist/es2019/schema/nodes/list-item.js +17 -0
  16. package/dist/es2019/schema/nodes/panel.js +28 -0
  17. package/dist/es2019/schema/nodes/tableNodes.js +1 -37
  18. package/dist/esm/index.js +1 -1
  19. package/dist/esm/schema/create-schema.js +3 -3
  20. package/dist/esm/schema/index.js +1 -1
  21. package/dist/esm/schema/marks/text-color.js +2 -38
  22. package/dist/esm/schema/nodes/index.js +2 -2
  23. package/dist/esm/schema/nodes/list-item.js +17 -0
  24. package/dist/esm/schema/nodes/panel.js +30 -0
  25. package/dist/esm/schema/nodes/tableNodes.js +1 -37
  26. package/dist/json-schema/v1/full.json +217 -193
  27. package/dist/json-schema/v1/stage-0.json +224 -200
  28. package/dist/types/index.d.ts +1 -1
  29. package/dist/types/schema/index.d.ts +1 -1
  30. package/dist/types/schema/nodes/index.d.ts +2 -2
  31. package/dist/types/schema/nodes/list-item.d.ts +5 -0
  32. package/dist/types/schema/nodes/panel.d.ts +14 -1
  33. package/dist/types/schema/nodes/types/list.d.ts +2 -1
  34. package/json-schema/v1/full.json +217 -193
  35. package/json-schema/v1/stage-0.json +224 -200
  36. package/package.json +2 -3
@@ -2,8 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import { hexToEditorTextPaletteColor } from '../../utils/editor-palette';
4
4
  import { COLOR } from '../groups';
5
- import { rgbToHex, N0, N80, P50, P300, P500, T75, T300, T500, G75, G300, G500, R75, R300, R500, Y75, Y200, Y400, B75, B100, B500, isHex, isRgb } from '../../utils/colors';
6
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
+ import { rgbToHex, N0, N80, P50, P300, P500, T75, T300, T500, G75, G300, G500, R75, R300, R500, Y75, Y200, Y400, B75, B100, B500 } from '../../utils/colors';
7
6
  import { getDarkModeLCHColor } from '../../utils/lch-color-inversion';
8
7
 
9
8
  /**
@@ -66,36 +65,6 @@ colorArrayPalette.forEach(function (_ref) {
66
65
  return colorPalette.set(color.toLowerCase(), label);
67
66
  });
68
67
 
69
- /**
70
- * This function is duplicated in @atlaskit/renderer and ../nodes/tableNodes
71
- * it takes a color string, and if the color string is a hex or rgb value
72
- * it will invert the color and return the inverted color.
73
- */
74
- function invertCustomColor(customColor) {
75
- var hex;
76
- if (isHex(customColor)) {
77
- hex = customColor;
78
- } else if (isRgb(customColor)) {
79
- hex = rgbToHex(customColor);
80
- if (hex === null) {
81
- // in some cases the rgb color is invalid, in this case we just return the color
82
- // See https://product-fabric.atlassian.net/browse/DTR-2003 for a ticket to improve the isRgb function
83
- // to align with the rgbToHex function
84
- return customColor;
85
- }
86
- } else {
87
- return customColor;
88
- }
89
- var hexWithoutHash = hex.replace('#', '');
90
-
91
- // This inverts the hex color by
92
- // 1. converting the hex code to a number
93
- // 2. XORing it with 0xffffff
94
- // 3. Converting the result back to hex
95
- // 4. Removing the leading 1 from the result
96
- return "#".concat((Number("0x1".concat(hexWithoutHash)) ^ 0xffffff).toString(16).substring(1).toUpperCase());
97
- }
98
-
99
68
  // these are for test only
100
69
  var testGlobalTheme;
101
70
  export var setGlobalTheme = function setGlobalTheme(theme) {
@@ -190,12 +159,7 @@ export var textColor = {
190
159
  } else {
191
160
  if (getGlobalTheme().colorMode === 'dark') {
192
161
  // if we have a custom color, we need to check if we are in dark mode
193
- // and if the feature flag is enabled we need to use the LCH conversion method
194
- if (getBooleanFF('platform.editor.use-lch-for-color-inversion_1qv8ol')) {
195
- paletteColorValue = getDarkModeLCHColor(mark.attrs.color);
196
- } else {
197
- paletteColorValue = invertCustomColor(mark.attrs.color);
198
- }
162
+ paletteColorValue = getDarkModeLCHColor(mark.attrs.color);
199
163
  } else {
200
164
  // if we are in light mode, we can just set the color
201
165
  paletteColorValue = mark.attrs.color;
@@ -15,8 +15,8 @@ export { paragraph } from './paragraph';
15
15
  export { emoji } from './emoji';
16
16
  export { image } from './image';
17
17
  export { mention, toJSON as mentionToJSON } from './mention';
18
- export { listItem } from './list-item';
19
- export { panel, PanelType } from './panel';
18
+ export { listItem, listItemWithTask } from './list-item';
19
+ export { panel, extendedPanel, PanelType } from './panel';
20
20
  export { text } from './text';
21
21
  export { default as unknownBlock } from './unknown-block';
22
22
  export { caption } from './caption';
@@ -9,4 +9,21 @@ export var listItem = {
9
9
  toDOM: function toDOM() {
10
10
  return ['li', 0];
11
11
  }
12
+ };
13
+
14
+ /**
15
+ * @name list_item_with_task
16
+ * @description this node allows task-list to be nested inside list-item
17
+ */
18
+ export var listItemWithTask = {
19
+ content: '(paragraph | mediaSingle | codeBlock | unsupportedBlock) (paragraph | bulletList | orderedList | taskList | mediaSingle | codeBlock | unsupportedBlock)*',
20
+ marks: 'unsupportedMark unsupportedNodeAttribute',
21
+ defining: true,
22
+ selectable: false,
23
+ parseDOM: [{
24
+ tag: 'li'
25
+ }],
26
+ toDOM: function toDOM() {
27
+ return ['li', 0];
28
+ }
12
29
  };
@@ -84,4 +84,34 @@ export var panel = function panel(allowCustomPanel) {
84
84
  }
85
85
  };
86
86
  return panelNodeSpec;
87
+ };
88
+
89
+ /**
90
+ * @name extended_panel
91
+ * @description it allows more content to be nested as compared to panel node.
92
+ * Specifically, it allows Media, action, code-block, rule and decision nodes in
93
+ * addition to content allowed inside panel
94
+ */
95
+ export var extendedPanel = function extendedPanel(allowCustomPanel) {
96
+ var panelNodeSpec = {
97
+ group: 'block',
98
+ content: '(paragraph | heading | bulletList | orderedList | blockCard | mediaGroup | mediaSingle | codeBlock | taskList | rule | decisionList | unsupportedBlock)+',
99
+ marks: 'unsupportedMark unsupportedNodeAttribute',
100
+ attrs: getDefaultAttrs(),
101
+ selectable: true,
102
+ parseDOM: [{
103
+ tag: 'div[data-panel-type]',
104
+ getAttrs: function getAttrs(dom) {
105
+ return getParseDOMAttrs(allowCustomPanel, dom);
106
+ }
107
+ }],
108
+ toDOM: function toDOM(node) {
109
+ var attrs = getDomAttrs(node.attrs);
110
+ var contentAttrs = {
111
+ 'data-panel-content': 'true'
112
+ };
113
+ return ['div', attrs, ['div', contentAttrs, 0]];
114
+ }
115
+ };
116
+ return panelNodeSpec;
87
117
  };
@@ -5,7 +5,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  import { hexToEditorBackgroundPaletteRawValue } from '../../utils/editor-palette';
6
6
  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';
7
7
  import { uuid } from '../../utils/uuid';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
8
  import { getDarkModeLCHColor } from '../../utils/lch-color-inversion';
10
9
  export var tablePrefixSelector = 'pm-table';
11
10
  export var tableCellSelector = "".concat(tablePrefixSelector, "-cell-content-wrap");
@@ -51,36 +50,6 @@ export var getCellAttrs = function getCellAttrs(dom) {
51
50
  background: backgroundHexCode
52
51
  };
53
52
  };
54
- /**
55
- * This function is duplicated in @atlaskit/renderer
56
- * it takes a color string, and if the color string is a hex or rgb value
57
- * it will invert the color and return the inverted color.
58
- */
59
- function invertCustomColor(customColor) {
60
- var hex;
61
- if (isHex(customColor)) {
62
- hex = customColor;
63
- } else if (isRgb(customColor)) {
64
- hex = rgbToHex(customColor);
65
- if (hex === null) {
66
- // in some cases the rgb color is invalid, in this case we just return the color
67
- // See https://product-fabric.atlassian.net/browse/DTR-2003 for a ticket to improve the isRgb function
68
- // to align with the rgbToHex function
69
- return customColor;
70
- }
71
- } else {
72
- return customColor;
73
- }
74
- var hexWithoutHash = hex.replace('#', '');
75
-
76
- // This inverts the hex color by
77
- // 1. converting the hex code to a number
78
- // 2. XORing it with 0xffffff
79
- // 3. Converting the result back to hex
80
- // 4. Removing the leading 1 from the result
81
- return "#".concat((Number("0x1".concat(hexWithoutHash)) ^ 0xffffff).toString(16).substring(1).toUpperCase());
82
- }
83
-
84
53
  // these are for test only
85
54
  var testGlobalTheme;
86
55
  export var setGlobalTheme = function setGlobalTheme(theme) {
@@ -158,12 +127,7 @@ export var getCellDomAttrs = function getCellDomAttrs(node) {
158
127
  // if we have a custom color, we need to check if we are in dark mode
159
128
  if (getGlobalTheme().colorMode === 'dark') {
160
129
  // if we have a custom color, we need to check if we are in dark mode
161
- // and if the feature flag is enabled we need to use the LCH conversion method
162
- if (getBooleanFF('platform.editor.use-lch-for-color-inversion_1qv8ol')) {
163
- attrs.style = "background-color: ".concat(getDarkModeLCHColor(color), ";");
164
- } else {
165
- attrs.style = "background-color: ".concat(invertCustomColor(color), ";");
166
- }
130
+ attrs.style = "background-color: ".concat(getDarkModeLCHColor(color), ";");
167
131
  } else {
168
132
  // if we are in light mode, we can just set the color
169
133
  attrs.style = "background-color: ".concat(background, ";");