@atlaskit/editor-common 70.3.0 → 71.0.1
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 +50 -0
- package/dist/cjs/analytics/types/enums.js +1 -0
- package/dist/cjs/keymaps/index.js +5 -8
- package/dist/cjs/messages/insert-block.js +12 -7
- package/dist/cjs/panel.js +6 -0
- package/dist/cjs/styles/shared/code-block.js +5 -5
- package/dist/cjs/styles/shared/panel.js +54 -17
- package/dist/cjs/styles/shared/table.js +12 -7
- package/dist/cjs/styles/shared/text-color.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui-color/ColorPalette/Color/index.js +6 -2
- package/dist/cjs/ui-color/ColorPalette/index.js +21 -11
- package/dist/cjs/ui-menu/Dropdown/index.js +16 -2
- package/dist/cjs/ui-menu/DropdownMenu/index.js +27 -8
- package/dist/cjs/ui-menu/MenuArrowKeyNavigationProvider/index.js +162 -0
- package/dist/cjs/ui-react/with-react-editor-view-outer-listeners.js +22 -13
- package/dist/cjs/utils/index.js +6 -0
- package/dist/cjs/utils/performance/measure-render.js +44 -23
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/types/enums.js +1 -0
- package/dist/es2019/keymaps/index.js +4 -6
- package/dist/es2019/messages/insert-block.js +12 -7
- package/dist/es2019/panel.js +1 -1
- package/dist/es2019/styles/shared/code-block.js +39 -25
- package/dist/es2019/styles/shared/panel.js +48 -18
- package/dist/es2019/styles/shared/table.js +24 -13
- package/dist/es2019/styles/shared/text-color.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui-color/ColorPalette/Color/index.js +6 -3
- package/dist/es2019/ui-color/ColorPalette/index.js +19 -11
- package/dist/es2019/ui-menu/Dropdown/index.js +13 -2
- package/dist/es2019/ui-menu/DropdownMenu/index.js +41 -6
- package/dist/es2019/ui-menu/MenuArrowKeyNavigationProvider/index.js +146 -0
- package/dist/es2019/ui-react/with-react-editor-view-outer-listeners.js +20 -13
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/performance/measure-render.js +43 -23
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/types/enums.js +1 -0
- package/dist/esm/keymaps/index.js +3 -6
- package/dist/esm/messages/insert-block.js +12 -7
- package/dist/esm/panel.js +1 -1
- package/dist/esm/styles/shared/code-block.js +5 -5
- package/dist/esm/styles/shared/panel.js +49 -18
- package/dist/esm/styles/shared/table.js +12 -9
- package/dist/esm/styles/shared/text-color.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui-color/ColorPalette/Color/index.js +5 -2
- package/dist/esm/ui-color/ColorPalette/index.js +20 -11
- package/dist/esm/ui-menu/Dropdown/index.js +15 -2
- package/dist/esm/ui-menu/DropdownMenu/index.js +28 -9
- package/dist/esm/ui-menu/MenuArrowKeyNavigationProvider/index.js +147 -0
- package/dist/esm/ui-react/with-react-editor-view-outer-listeners.js +22 -13
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/performance/measure-render.js +42 -23
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/types/enums.d.ts +1 -0
- package/dist/types/analytics/types/general-events.d.ts +2 -1
- package/dist/types/keymaps/index.d.ts +0 -1
- package/dist/types/messages/insert-block.d.ts +7 -2
- package/dist/types/panel.d.ts +1 -1
- package/dist/types/styles/shared/code-block.d.ts +1 -0
- package/dist/types/styles/shared/panel.d.ts +1 -0
- package/dist/types/types/feature-flags.d.ts +27 -6
- package/dist/types/types/floating-toolbar.d.ts +4 -0
- package/dist/types/ui-color/ColorPalette/Color/index.d.ts +5 -0
- package/dist/types/ui-color/ColorPalette/index.d.ts +8 -0
- package/dist/types/ui-menu/Dropdown/index.d.ts +3 -0
- package/dist/types/ui-menu/DropdownMenu/index.d.ts +1 -0
- package/dist/types/ui-menu/DropdownMenu/types.d.ts +7 -0
- package/dist/types/ui-menu/MenuArrowKeyNavigationProvider/index.d.ts +15 -0
- package/dist/types/ui-react/with-react-editor-view-outer-listeners.d.ts +2 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/performance/measure-render.d.ts +12 -0
- package/package.json +8 -7
- package/report.api.md +12 -5
|
@@ -16,7 +16,15 @@ class WithOutsideClick extends PureComponent {
|
|
|
16
16
|
|
|
17
17
|
if (!domNode || evt.target instanceof Node && !domNode.contains(evt.target)) {
|
|
18
18
|
if (this.props.handleClickOutside) {
|
|
19
|
-
|
|
19
|
+
var _this$props$editorVie;
|
|
20
|
+
|
|
21
|
+
this.props.handleClickOutside(evt); //When the menus are closed by clicking outside the focus is set on editor.
|
|
22
|
+
|
|
23
|
+
if (!((_this$props$editorVie = this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
|
|
24
|
+
var _this$props$editorVie2;
|
|
25
|
+
|
|
26
|
+
(_this$props$editorVie2 = this.props.editorView) === null || _this$props$editorVie2 === void 0 ? void 0 : _this$props$editorVie2.focus();
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
});
|
|
@@ -27,21 +35,16 @@ class WithOutsideClick extends PureComponent {
|
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
if (evt.code === 'Escape' && this.props.handleEscapeKeydown) {
|
|
30
|
-
var _this$props$editorVie;
|
|
31
|
-
|
|
32
38
|
evt.preventDefault();
|
|
33
39
|
evt.stopPropagation();
|
|
34
|
-
this.props.handleEscapeKeydown(evt);
|
|
35
|
-
|
|
36
|
-
if (!((_this$props$editorVie = this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
|
|
37
|
-
var _this$props$editorVie2;
|
|
38
|
-
|
|
39
|
-
(_this$props$editorVie2 = this.props.editorView) === null || _this$props$editorVie2 === void 0 ? void 0 : _this$props$editorVie2.focus();
|
|
40
|
-
}
|
|
40
|
+
this.props.handleEscapeKeydown(evt); //on 'Esc', Focus is handled in 'handleEscapeKeydown'.
|
|
41
41
|
|
|
42
42
|
return false;
|
|
43
43
|
} else if (evt.code === 'Enter' && this.props.handleEnterKeydown) {
|
|
44
44
|
this.props.handleEnterKeydown(evt);
|
|
45
|
+
} else if (evt.code === 'Tab' && this.props.handleEscapeKeydown && this.props.closeonTab) {
|
|
46
|
+
//The menus should be closed when the tab is pressed as it takes the focus out of the menu
|
|
47
|
+
this.props.handleEscapeKeydown(evt);
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
}
|
|
@@ -54,7 +57,8 @@ class WithOutsideClick extends PureComponent {
|
|
|
54
57
|
if (this.props.handleEscapeKeydown) {
|
|
55
58
|
var _this$props$editorRef;
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
//Attached event to the menu so that 'ESC' events from the opened menu also will be handled.
|
|
61
|
+
(((_this$props$editorRef = this.props.editorRef) === null || _this$props$editorRef === void 0 ? void 0 : _this$props$editorRef.current) || this.props.targetRef || document).addEventListener('keydown', this.handleKeydown, false);
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -66,7 +70,7 @@ class WithOutsideClick extends PureComponent {
|
|
|
66
70
|
if (this.props.handleEscapeKeydown) {
|
|
67
71
|
var _this$props$editorRef2;
|
|
68
72
|
|
|
69
|
-
(((_this$props$editorRef2 = this.props.editorRef) === null || _this$props$editorRef2 === void 0 ? void 0 : _this$props$editorRef2.current) || document).removeEventListener('keydown', this.handleKeydown, false);
|
|
73
|
+
(((_this$props$editorRef2 = this.props.editorRef) === null || _this$props$editorRef2 === void 0 ? void 0 : _this$props$editorRef2.current) || this.props.targetRef || document).removeEventListener('keydown', this.handleKeydown, false);
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -85,6 +89,7 @@ export default function withReactEditorViewOuterListeners(Component) {
|
|
|
85
89
|
handleClickOutside,
|
|
86
90
|
handleEnterKeydown,
|
|
87
91
|
handleEscapeKeydown,
|
|
92
|
+
closeonTab,
|
|
88
93
|
...props
|
|
89
94
|
}) => {
|
|
90
95
|
const isActiveComponent = hasIsOpen(props) ? props.isOpen : true;
|
|
@@ -94,10 +99,12 @@ export default function withReactEditorViewOuterListeners(Component) {
|
|
|
94
99
|
}) => /*#__PURE__*/React.createElement(WithOutsideClick, {
|
|
95
100
|
editorView: editorView,
|
|
96
101
|
editorRef: editorRef,
|
|
102
|
+
targetRef: props.targetRef,
|
|
97
103
|
isActiveComponent: isActiveComponent,
|
|
98
104
|
handleClickOutside: handleClickOutside,
|
|
99
105
|
handleEnterKeydown: handleEnterKeydown,
|
|
100
|
-
handleEscapeKeydown: handleEscapeKeydown
|
|
106
|
+
handleEscapeKeydown: handleEscapeKeydown,
|
|
107
|
+
closeonTab: closeonTab
|
|
101
108
|
}, /*#__PURE__*/React.createElement(Component, props)));
|
|
102
109
|
};
|
|
103
110
|
}
|
|
@@ -13,7 +13,7 @@ export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, close
|
|
|
13
13
|
export { default as ADFTraversor } from './traversor';
|
|
14
14
|
export { analyticsEventKey, getAnalyticsAppearance, getAnalyticsEventSeverity, SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS } from './analytics';
|
|
15
15
|
export { findAndTrackUnsupportedContentNodes } from './track-unsupported-content';
|
|
16
|
-
export { measureRender } from './performance/measure-render';
|
|
16
|
+
export { getDistortedDurationMonitor, measureRender } from './performance/measure-render';
|
|
17
17
|
export { startMeasure, stopMeasure, clearMeasure } from './performance/measure';
|
|
18
18
|
export { measureTTI, getTTISeverity, TTI_SEVERITY_THRESHOLD_DEFAULTS, TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS } from './performance/measure-tti';
|
|
19
19
|
export { isPerformanceAPIAvailable, isPerformanceObserverAvailable } from './performance/is-performance-api-available';
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import { isPerformanceAPIAvailable } from './is-performance-api-available';
|
|
2
|
+
/**
|
|
3
|
+
* Monitors if a pages enters a visibility state which will lead to
|
|
4
|
+
* distorted duration measurements (where the measurement uses the
|
|
5
|
+
* requestAnimationFrame api).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function getDistortedDurationMonitor() {
|
|
9
|
+
// If an editor is rendered when the document is not visible -- the callback passed to
|
|
10
|
+
// requestAnimationFrame will not fire until the document becomes visible again.
|
|
11
|
+
//
|
|
12
|
+
// For the purposes of using performance measurement -- this behaviour means the events
|
|
13
|
+
// which have been fired in the background are not useful -- and lead to other events
|
|
14
|
+
// being hard to draw conclusions from.
|
|
15
|
+
//
|
|
16
|
+
// To mitigate this -- we detect this state -- and fire a seperate callback when the
|
|
17
|
+
// measurement has occured when the render was in the backgroun
|
|
18
|
+
let distortedDuration = document.visibilityState !== 'visible';
|
|
19
|
+
|
|
20
|
+
function handleVisibilityChange() {
|
|
21
|
+
if (document.visibilityState !== 'visible') {
|
|
22
|
+
distortedDuration = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
27
|
+
return {
|
|
28
|
+
distortedDuration,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Cleans up the document visibility event listener
|
|
32
|
+
*/
|
|
33
|
+
cleanup() {
|
|
34
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
};
|
|
38
|
+
}
|
|
2
39
|
/**
|
|
3
40
|
* Measures time it takes to render a frame including -> style, paint, layout and composition.
|
|
4
41
|
*
|
|
@@ -37,29 +74,12 @@ onMeasureComplete) {
|
|
|
37
74
|
const startMark = `[START]: ${measureName}`;
|
|
38
75
|
const endMark = `[END]: ${measureName}`;
|
|
39
76
|
const startTime = performance.now();
|
|
40
|
-
performance.mark(startMark);
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
// For the purposes of using performance measurement -- this behaviour means the events
|
|
44
|
-
// which have been fired in the background are not useful -- and lead to other events
|
|
45
|
-
// being hard to draw conclusions from.
|
|
46
|
-
//
|
|
47
|
-
// To mitigate this -- we detect this state -- and fire a seperate callback when the
|
|
48
|
-
// measurement has occured when the render was in the backgroun
|
|
49
|
-
|
|
50
|
-
let distortedDuration = document.visibilityState !== 'visible';
|
|
51
|
-
|
|
52
|
-
function handleVisibilityChange() {
|
|
53
|
-
if (document.visibilityState !== 'visible') {
|
|
54
|
-
distortedDuration = true;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
77
|
+
performance.mark(startMark);
|
|
78
|
+
let distortedDurationMonitor = getDistortedDurationMonitor();
|
|
59
79
|
requestAnimationFrame(() => {
|
|
60
80
|
requestAnimationFrame(() => {
|
|
61
81
|
performance.mark(endMark);
|
|
62
|
-
|
|
82
|
+
distortedDurationMonitor.cleanup();
|
|
63
83
|
const duration = performance.now() - startTime;
|
|
64
84
|
|
|
65
85
|
try {
|
|
@@ -70,20 +90,20 @@ onMeasureComplete) {
|
|
|
70
90
|
onMeasureComplete({
|
|
71
91
|
duration,
|
|
72
92
|
startTime,
|
|
73
|
-
distortedDuration
|
|
93
|
+
distortedDuration: distortedDurationMonitor.distortedDuration
|
|
74
94
|
});
|
|
75
95
|
} else {
|
|
76
96
|
onMeasureComplete({
|
|
77
97
|
duration: entry.duration,
|
|
78
98
|
startTime: entry.startTime,
|
|
79
|
-
distortedDuration
|
|
99
|
+
distortedDuration: distortedDurationMonitor.distortedDuration
|
|
80
100
|
});
|
|
81
101
|
}
|
|
82
102
|
} catch (e) {
|
|
83
103
|
onMeasureComplete({
|
|
84
104
|
duration,
|
|
85
105
|
startTime,
|
|
86
|
-
distortedDuration
|
|
106
|
+
distortedDuration: distortedDurationMonitor.distortedDuration
|
|
87
107
|
});
|
|
88
108
|
}
|
|
89
109
|
|
package/dist/es2019/version.json
CHANGED
|
@@ -92,6 +92,7 @@ export var ACTION;
|
|
|
92
92
|
ACTION["DEDUPE_MARKS_TRANSFORMED"] = "dedupeMarksTransformed";
|
|
93
93
|
ACTION["NODES_MISSING_CONTENT_TRANSFORMED"] = "nodesMissingContentTransformed";
|
|
94
94
|
ACTION["INDENTATION_MARKS_TRANSFORMED"] = "indentationMarksTransformed";
|
|
95
|
+
ACTION["INVALID_MEDIA_CONTENT_TRANSFORMED"] = "invalidMediaContentTransformed";
|
|
95
96
|
ACTION["TOGGLE_EXPAND"] = "toggleExpand";
|
|
96
97
|
ACTION["TRANSACTION_DISPATCHED"] = "transactionDispatched";
|
|
97
98
|
ACTION["TRANSACTION_MUTATED_AFTER_DISPATCH"] = "transactionMutatedAfterDispatched";
|
|
@@ -6,6 +6,7 @@ var _templateObject;
|
|
|
6
6
|
import React, { Fragment } from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import { N400 } from '@atlaskit/theme/colors';
|
|
9
|
+
import { token } from '@atlaskit/tokens';
|
|
9
10
|
import { browser } from '../utils';
|
|
10
11
|
export var addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
|
|
11
12
|
export var toggleBold = makeKeyMapWithCommon('Bold', 'Mod-b');
|
|
@@ -69,18 +70,14 @@ export var paste = makeKeyMapWithCommon('Paste', 'Mod-v');
|
|
|
69
70
|
export var altPaste = makeKeyMapWithCommon('Paste', 'Mod-Shift-v');
|
|
70
71
|
export var find = makeKeyMapWithCommon('Find', 'Mod-f');
|
|
71
72
|
export var alignLeft = makeKeyMapWithCommon('Align Left', 'Mod-Shift-l');
|
|
72
|
-
export var alignRight = makeKeyMapWithCommon('Align Right', 'Mod-Shift-r');
|
|
73
73
|
var arrowKeysMap = {
|
|
74
74
|
// for reference: https://wincent.com/wiki/Unicode_representations_of_modifier_keys
|
|
75
75
|
ARROWLEFT: "\u2190",
|
|
76
76
|
ARROWRIGHT: "\u2192",
|
|
77
77
|
ARROWUP: "\u2191",
|
|
78
78
|
ARROWDOWN: "\u2193"
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
82
|
-
|
|
83
|
-
var tooltipShortcutStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-radius: 2px;\n background-color: ", ";\n padding: 0 2px;\n /* TODO: fix in develop: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E */\n /* stylelint-disable-next-line */\n label: tooltip-shortcut;\n"])), N400);
|
|
79
|
+
};
|
|
80
|
+
var tooltipShortcutStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-radius: 2px;\n background-color: ", ";\n padding: 0 2px;\n\n /* TODO: fix in develop: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E */\n /* stylelint-disable-next-line */\n label: tooltip-shortcut;\n"])), token('color.background.inverse.subtle', N400));
|
|
84
81
|
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
85
82
|
|
|
86
83
|
function formatShortcut(keymap) {
|
|
@@ -20,13 +20,18 @@ export var toolbarInsertBlockMessages = defineMessages({
|
|
|
20
20
|
defaultMessage: 'Insert a link',
|
|
21
21
|
description: 'Insert a hyperlink'
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
id: 'fabric.editor.
|
|
25
|
-
defaultMessage: '
|
|
26
|
-
description: 'Insert one or more files or images'
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
id: 'fabric.editor.
|
|
23
|
+
mediaFiles: {
|
|
24
|
+
id: 'fabric.editor.mediaFiles',
|
|
25
|
+
defaultMessage: 'Image, video, or file',
|
|
26
|
+
description: 'Insert one or more files, videos or images'
|
|
27
|
+
},
|
|
28
|
+
addMediaFiles: {
|
|
29
|
+
id: 'fabric.editor.addMediaFiles',
|
|
30
|
+
defaultMessage: 'Add image, video, or file',
|
|
31
|
+
description: 'Insert one or more files, videos or images'
|
|
32
|
+
},
|
|
33
|
+
mediaFilesDescription: {
|
|
34
|
+
id: 'fabric.editor.mediaFiles.description',
|
|
30
35
|
defaultMessage: 'Add images and other files to your page',
|
|
31
36
|
description: 'Insert one or more files or images'
|
|
32
37
|
},
|
package/dist/esm/panel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getPanelTypeBackground, darkPanelColors, getPanelDarkColor, panelSharedStyles, panelSharedStylesWithoutPrefix, PanelSharedCssClassName, PanelSharedSelectors, getPanelBackgroundDarkModeColors } from './styles/shared/panel';
|
|
1
|
+
export { getPanelTypeBackground, getPanelTypeBackgroundNoTokens, darkPanelColors, getPanelDarkColor, panelSharedStyles, panelSharedStylesWithoutPrefix, PanelSharedCssClassName, PanelSharedSelectors, getPanelBackgroundDarkModeColors } from './styles/shared/panel';
|
|
@@ -12,23 +12,23 @@ export var CodeBlockSharedCssClassName = {
|
|
|
12
12
|
CODEBLOCK_CONTAINER: 'code-block',
|
|
13
13
|
CODEBLOCK_START: 'code-block--start',
|
|
14
14
|
CODEBLOCK_END: 'code-block--end',
|
|
15
|
+
CODEBLOCK_CONTENT_WRAPPER: 'code-block-content-wrapper',
|
|
15
16
|
CODEBLOCK_LINE_NUMBER_GUTTER: 'line-number-gutter',
|
|
16
17
|
CODEBLOCK_CONTENT: 'code-content',
|
|
17
18
|
DS_CODEBLOCK: '[data-ds--code--code-block]'
|
|
18
19
|
};
|
|
19
20
|
export var codeBlockSharedStyles = function codeBlockSharedStyles(props) {
|
|
20
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n position: relative;\n background-color: ", ";\n border-radius: ", "px;\n
|
|
21
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n position: relative;\n background-color: ", ";\n border-radius: ", "px;\n margin: ", " 0 0 0;\n font-family: ", ";\n min-width: ", "px;\n cursor: pointer;\n\n --ds--code--bg-color: transparent;\n\n /* This is necessary to allow for arrow key navigation in/out of code blocks in Firefox. */\n white-space: normal;\n\n .", " {\n position: absolute;\n visibility: hidden;\n height: 1.5rem;\n top: 0px;\n left: 0px;\n }\n\n .", " {\n position: absolute;\n visibility: hidden;\n height: 1.5rem;\n bottom: 0px;\n right: 0px;\n }\n\n .", " {\n background-color: ", ";\n display: flex;\n border-radius: ", "px;\n width: 100%;\n counter-reset: line;\n overflow-x: auto;\n\n background-image: ", ";\n\n background-repeat: no-repeat;\n background-attachment: local, local, local, local, scroll, scroll;\n background-size: 8px 100%, 8px 100%, 8px 100%, 8px 100%, 8px 100%,\n 8px 100%;\n background-position: 0 0, 0 0, 100% 0, 100% 0, 100% 0, 0 0;\n\n /* Be careful if refactoring this; it is needed to keep arrow key navigation in Firefox consistent with other browsers. */\n overflow-y: hidden;\n }\n\n .", " {\n flex-shrink: 0;\n text-align: right;\n background-color: ", ";\n padding: ", "px;\n position: relative;\n\n span {\n display: block;\n line-height: 0;\n font-size: 0;\n\n ::before {\n display: inline-block;\n content: counter(line);\n counter-increment: line;\n color: ", ";\n font-size: ", ";\n line-height: 1.5rem;\n }\n }\n }\n\n .", " {\n display: flex;\n flex: 1;\n\n code {\n flex-grow: 1;\n tab-size: 4;\n cursor: text;\n color: ", ";\n border-radius: ", "px;\n margin: ", "px;\n white-space: pre;\n font-size: ", ";\n line-height: 1.5rem;\n }\n }\n }\n"])), CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER, token('elevation.surface.raised', 'transparent'), borderRadius(), blockNodesVerticalMargin, akEditorCodeFontFamily, akEditorTableCellMinWidth, CodeBlockSharedCssClassName.CODEBLOCK_START, CodeBlockSharedCssClassName.CODEBLOCK_END, CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER, themed({
|
|
21
22
|
light: token('color.background.neutral', N20),
|
|
22
23
|
dark: token('color.background.neutral', DN50)
|
|
23
24
|
})(props), borderRadius(), overflowShadow({
|
|
24
25
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4118
|
|
25
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
26
26
|
background: themed({
|
|
27
|
-
light: N20,
|
|
28
|
-
dark: DN50
|
|
27
|
+
light: token('color.background.neutral', N20),
|
|
28
|
+
dark: token('color.background.neutral', DN50)
|
|
29
29
|
})(props),
|
|
30
30
|
width: '8px'
|
|
31
|
-
}),
|
|
31
|
+
}), CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER, themed({
|
|
32
32
|
light: token('color.background.neutral', N30),
|
|
33
33
|
dark: token('color.background.neutral', DN20)
|
|
34
34
|
})(props), gridSize(), themed({
|
|
@@ -3,8 +3,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
|
|
4
4
|
var _templateObject, _templateObject2;
|
|
5
5
|
|
|
6
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
7
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4066
|
|
8
6
|
import { css } from '@emotion/react';
|
|
9
7
|
import { PanelType } from '@atlaskit/adf-schema';
|
|
10
8
|
import { akEditorTableCellMinWidth, blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
@@ -13,7 +11,19 @@ import { emojiImage, emojiSprite } from '@atlaskit/emoji';
|
|
|
13
11
|
import * as colors from '@atlaskit/theme/colors';
|
|
14
12
|
import { themed } from '@atlaskit/theme/components';
|
|
15
13
|
import { borderRadius, gridSize } from '@atlaskit/theme/constants';
|
|
14
|
+
import { token } from '@atlaskit/tokens';
|
|
15
|
+
var tokenPanelColor = {
|
|
16
|
+
info: 'color.background.information',
|
|
17
|
+
note: 'color.background.discovery',
|
|
18
|
+
tip: 'color.background.success',
|
|
19
|
+
success: 'color.background.success',
|
|
20
|
+
warning: 'color.background.warning',
|
|
21
|
+
error: 'color.background.danger'
|
|
22
|
+
};
|
|
16
23
|
var lightPanelColor = {
|
|
24
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-4066
|
|
25
|
+
|
|
26
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
17
27
|
info: colors.B50,
|
|
18
28
|
note: colors.P50,
|
|
19
29
|
tip: colors.G50,
|
|
@@ -23,7 +33,7 @@ var lightPanelColor = {
|
|
|
23
33
|
};
|
|
24
34
|
export var darkPanelColors = {
|
|
25
35
|
// standard panels
|
|
26
|
-
info:
|
|
36
|
+
info: "#0C294F",
|
|
27
37
|
error: "#441C13",
|
|
28
38
|
warning: "#413001",
|
|
29
39
|
tip: "#052E21",
|
|
@@ -83,26 +93,31 @@ export var darkPanelColors = {
|
|
|
83
93
|
LightGray: '#5A6977',
|
|
84
94
|
TextColor: '#D9DDE3'
|
|
85
95
|
};
|
|
96
|
+
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
97
|
+
|
|
86
98
|
var lightIconColor = {
|
|
87
|
-
info: colors.B400,
|
|
88
|
-
note: colors.P400,
|
|
89
|
-
tip: colors.G400,
|
|
90
|
-
success: colors.G400,
|
|
91
|
-
warning: colors.Y400,
|
|
92
|
-
error: colors.R400
|
|
99
|
+
info: token('color.icon.information', colors.B400),
|
|
100
|
+
note: token('color.icon.discovery', colors.P400),
|
|
101
|
+
tip: token('color.icon.success', colors.G400),
|
|
102
|
+
success: token('color.icon.success', colors.G400),
|
|
103
|
+
warning: token('color.icon.warning', colors.Y400),
|
|
104
|
+
error: token('color.icon.danger', colors.R400)
|
|
93
105
|
};
|
|
94
106
|
var darkIconColor = {
|
|
95
|
-
info: colors.B100,
|
|
96
|
-
note: colors.P100,
|
|
97
|
-
tip: colors.G200,
|
|
98
|
-
success: colors.G200,
|
|
99
|
-
warning: colors.Y100,
|
|
100
|
-
error: colors.R200
|
|
107
|
+
info: token('color.icon.information', colors.B100),
|
|
108
|
+
note: token('color.icon.discovery', colors.P100),
|
|
109
|
+
tip: token('color.icon.success', colors.G200),
|
|
110
|
+
success: token('color.icon.success', colors.G200),
|
|
111
|
+
warning: token('color.icon.warning', colors.Y100),
|
|
112
|
+
error: token('color.icon.danger', colors.R200)
|
|
101
113
|
}; // New custom icons are a little smaller than predefined icons.
|
|
102
114
|
// To fix alignment issues with custom icons, vertical alignment is updated.
|
|
103
115
|
|
|
104
116
|
var panelEmojiSpriteVerticalAlignment = -(gridSize() * 3 - akEditorCustomIconSize) / 2;
|
|
105
|
-
var panelEmojiImageVerticalAlignment = panelEmojiSpriteVerticalAlignment - 1;
|
|
117
|
+
var panelEmojiImageVerticalAlignment = panelEmojiSpriteVerticalAlignment - 1; // TODO: https://product-fabric.atlassian.net/browse/DSP-4066
|
|
118
|
+
|
|
119
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
120
|
+
|
|
106
121
|
var panelDarkModeColors = [[colors.B50, darkPanelColors.B1200S], [colors.B75, darkPanelColors.B900], [colors.B100, darkPanelColors.B800S], [colors.N0, darkPanelColors.LightGray], [colors.N20, darkPanelColors.Gray], [colors.N60, darkPanelColors.DarkGray], [colors.T50, darkPanelColors.T1200S], [colors.T75, darkPanelColors.T900], [colors.T100, darkPanelColors.T900S], [colors.G50, darkPanelColors.G1200S], [colors.G75, darkPanelColors.G900], [colors.G200, darkPanelColors.G900S], [colors.Y50, darkPanelColors.Y1200S], [colors.Y75, darkPanelColors.Y900], [colors.Y200, darkPanelColors.Y800S], [colors.R50, darkPanelColors.R1200S], [colors.R75, darkPanelColors.R900], [colors.R100, darkPanelColors.R800S], [colors.P50, darkPanelColors.P1200S], [colors.P75, darkPanelColors.P900], [colors.P100, darkPanelColors.P800S]];
|
|
107
122
|
export var getPanelDarkColor = function getPanelDarkColor(panelColor) {
|
|
108
123
|
var colorObject = panelDarkModeColors.find(function (color) {
|
|
@@ -160,9 +175,10 @@ var iconDynamicStyles = function iconDynamicStyles(panelType) {
|
|
|
160
175
|
})(props);
|
|
161
176
|
return "\n color: ".concat(color, ";\n ");
|
|
162
177
|
};
|
|
163
|
-
};
|
|
178
|
+
}; // Provides the color without tokens, used when converting to a custom panel
|
|
164
179
|
|
|
165
|
-
|
|
180
|
+
|
|
181
|
+
export var getPanelTypeBackgroundNoTokens = function getPanelTypeBackgroundNoTokens(panelType) {
|
|
166
182
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
167
183
|
var light = lightPanelColor[panelType];
|
|
168
184
|
var dark = darkPanelColors[panelType];
|
|
@@ -172,6 +188,21 @@ export var getPanelTypeBackground = function getPanelTypeBackground(panelType) {
|
|
|
172
188
|
})(props);
|
|
173
189
|
return background || 'none';
|
|
174
190
|
};
|
|
191
|
+
export var getPanelTypeBackground = function getPanelTypeBackground(panelType) {
|
|
192
|
+
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
193
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-4066
|
|
194
|
+
|
|
195
|
+
/* eslint-disable @atlaskit/design-system/no-unsafe-design-token-usage */
|
|
196
|
+
var light = token(tokenPanelColor[panelType], lightPanelColor[panelType]);
|
|
197
|
+
var dark = token(tokenPanelColor[panelType], darkPanelColors[panelType]);
|
|
198
|
+
/* eslint-disable @atlaskit/design-system/no-unsafe-design-token-usage */
|
|
199
|
+
|
|
200
|
+
var background = themed({
|
|
201
|
+
light: light,
|
|
202
|
+
dark: dark
|
|
203
|
+
})(props);
|
|
204
|
+
return background || 'none';
|
|
205
|
+
};
|
|
175
206
|
|
|
176
207
|
var mainDynamicStyles = function mainDynamicStyles(panelType) {
|
|
177
208
|
return function (props) {
|
|
@@ -4,15 +4,15 @@ var _templateObject;
|
|
|
4
4
|
|
|
5
5
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
6
6
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4118
|
|
7
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4153
|
|
8
7
|
import { css } from '@emotion/react';
|
|
9
8
|
import { tableCellContentDomSelector, tableCellSelector, tableHeaderSelector, tablePrefixSelector } from '@atlaskit/adf-schema';
|
|
10
|
-
import { akEditorBreakoutPadding, akEditorFullWidthLayoutWidth, akEditorTableBorder, akEditorTableBorderDark, akEditorTableNumberColumnWidth, akEditorTableToolbar, akEditorTableToolbarDark, akEditorWideLayoutWidth, getTableCellBackgroundDarkModeColors, overflowShadow } from '@atlaskit/editor-shared-styles';
|
|
9
|
+
import { akEditorBreakoutPadding, akEditorFullWidthLayoutWidth, akEditorSelectedNodeClassName, akEditorTableBorder, akEditorTableBorderDark, akEditorTableNumberColumnWidth, akEditorTableToolbar, akEditorTableToolbarDark, akEditorWideLayoutWidth, getTableCellBackgroundDarkModeColors, overflowShadow } from '@atlaskit/editor-shared-styles';
|
|
11
10
|
import { DN20 } from '@atlaskit/theme/colors';
|
|
12
11
|
import { themed } from '@atlaskit/theme/components';
|
|
13
12
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
14
13
|
import { token } from '@atlaskit/tokens';
|
|
15
14
|
import browser from '../../utils/browser';
|
|
15
|
+
import { CodeBlockSharedCssClassName } from './code-block';
|
|
16
16
|
export var tableMarginTop = 24;
|
|
17
17
|
export var tableMarginBottom = 16;
|
|
18
18
|
export var tableMarginSides = 8;
|
|
@@ -38,7 +38,7 @@ export var TableSharedCssClassName = {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
var tableSharedStyle = function tableSharedStyle(props) {
|
|
41
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n position: relative;\n margin: 0 auto ", "px;\n box-sizing: border-box;\n\n /**\n * Fix block top alignment inside table cells.\n */\n .decisionItemView-content-wrap:first-of-type > div {\n margin-top: 0;\n }\n }\n .", "[data-number-column='true'] {\n padding-left: ", "px;\n clear: both;\n }\n .", " > table {\n margin: ", "px 0 0 0;\n }\n\n .", " > table,\n .", " > table {\n margin: ", "px ", "px 0 0;\n }\n\n /* avoid applying styles to nested tables (possible via extensions) */\n .", " > table,\n .", " > table,\n .", " > table {\n border-collapse: collapse;\n border: ", "px solid\n ", ";\n table-layout: fixed;\n font-size: 1em;\n width: 100%;\n\n &[data-autosize='true'] {\n table-layout: auto;\n }\n\n & {\n * {\n box-sizing: border-box;\n }\n hr {\n box-sizing: content-box;\n }\n\n tbody {\n border-bottom: none;\n }\n th td {\n background-color: ", ";\n }\n th,\n td {\n min-width: ", "px;\n font-weight: normal;\n vertical-align: top;\n border: 1px solid\n ", ";\n border-right-width: 0;\n border-bottom-width: 0;\n padding: ", "px;\n /* https://stackoverflow.com/questions/7517127/borders-not-shown-in-firefox-with-border-collapse-on-table-position-relative-o */\n ", "\n\n ", ";\n\n > :first-child:not(style),\n > style:first-child + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + *,\n > style:first-child + .ProseMirror-gapcursor + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + span + *,\n > style:first-child + .ProseMirror-gapcursor + span + * {\n margin-top: 0;\n }\n\n th p:not(:first-of-type),\n td p:not(:first-of-type) {\n margin-top: 12px;\n }\n }\n th {\n background-color: ", ";\n text-align: left;\n\n /* only apply this styling to codeblocks in default background headercells */\n /* TODO this needs to be overhauled as it relies on unsafe selectors */\n &:not([style]) {\n .
|
|
41
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n position: relative;\n margin: 0 auto ", "px;\n box-sizing: border-box;\n\n /**\n * Fix block top alignment inside table cells.\n */\n .decisionItemView-content-wrap:first-of-type > div {\n margin-top: 0;\n }\n }\n .", "[data-number-column='true'] {\n padding-left: ", "px;\n clear: both;\n }\n .", " > table {\n margin: ", "px 0 0 0;\n }\n\n .", " > table,\n .", " > table {\n margin: ", "px ", "px 0 0;\n }\n\n /* avoid applying styles to nested tables (possible via extensions) */\n .", " > table,\n .", " > table,\n .", " > table {\n border-collapse: collapse;\n border: ", "px solid\n ", ";\n table-layout: fixed;\n font-size: 1em;\n width: 100%;\n\n &[data-autosize='true'] {\n table-layout: auto;\n }\n\n & {\n * {\n box-sizing: border-box;\n }\n hr {\n box-sizing: content-box;\n }\n\n tbody {\n border-bottom: none;\n }\n th td {\n background-color: ", ";\n }\n th,\n td {\n min-width: ", "px;\n font-weight: normal;\n vertical-align: top;\n border: 1px solid\n ", ";\n border-right-width: 0;\n border-bottom-width: 0;\n padding: ", "px;\n /* https://stackoverflow.com/questions/7517127/borders-not-shown-in-firefox-with-border-collapse-on-table-position-relative-o */\n ", "\n\n ", ";\n\n > :first-child:not(style),\n > style:first-child + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + *,\n > style:first-child + .ProseMirror-gapcursor + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + span + *,\n > style:first-child + .ProseMirror-gapcursor + span + * {\n margin-top: 0;\n }\n\n th p:not(:first-of-type),\n td p:not(:first-of-type) {\n margin-top: 12px;\n }\n }\n th {\n background-color: ", ";\n text-align: left;\n\n /* only apply this styling to codeblocks in default background headercells */\n /* TODO this needs to be overhauled as it relies on unsafe selectors */\n &:not([style]):not(.danger) {\n .", ":not(.danger) {\n background-color: ", ";\n\n :not(.", ") {\n box-shadow: 0px 0px 0px 1px\n ", ";\n }\n\n .", " {\n background-image: ", ";\n\n background-color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n\n /* this is only relevant to the element taken care of by renderer */\n > [data-ds--code--code-block] {\n background-image: ", "!important;\n\n background-color: ", "!important;\n\n // selector lives inside @atlaskit/code\n --ds--code--line-number-bg-color: ", ";\n }\n }\n }\n }\n }\n }\n"])), TableSharedCssClassName.TABLE_CONTAINER, tableMarginBottom, TableSharedCssClassName.TABLE_CONTAINER, akEditorTableNumberColumnWidth - 1, TableSharedCssClassName.TABLE_NODE_WRAPPER, tableMarginTop, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableMarginTop, tableMarginSides, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_NODE_WRAPPER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableCellBorderWidth, themed({
|
|
42
42
|
light: token('color.border', akEditorTableBorder),
|
|
43
43
|
dark: token('color.border', akEditorTableBorderDark)
|
|
44
44
|
})(props), token('color.background.neutral.subtle', 'white'), tableCellMinWidth, themed({
|
|
@@ -49,22 +49,25 @@ var tableSharedStyle = function tableSharedStyle(props) {
|
|
|
49
49
|
})(props), themed({
|
|
50
50
|
light: token('color.background.neutral', akEditorTableToolbar),
|
|
51
51
|
dark: token('color.background.neutral', akEditorTableToolbarDark)
|
|
52
|
-
})(props),
|
|
52
|
+
})(props), CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER, themed({
|
|
53
|
+
light: token('elevation.surface.raised', 'rgb(235, 237, 240)'),
|
|
54
|
+
dark: token('elevation.surface.raised', 'rgb(36, 47, 66)')
|
|
55
|
+
})(props), akEditorSelectedNodeClassName, token('color.border', 'transparent'), CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER, overflowShadow({
|
|
53
56
|
background: themed({
|
|
54
|
-
light: 'rgb(235, 237, 240)',
|
|
55
|
-
dark: 'rgb(36, 47, 66)'
|
|
57
|
+
light: token('color.background.neutral', 'rgb(235, 237, 240)'),
|
|
58
|
+
dark: token('color.background.neutral', 'rgb(36, 47, 66)')
|
|
56
59
|
})(props),
|
|
57
60
|
width: "".concat(gridSize(), "px")
|
|
58
61
|
}), themed({
|
|
59
62
|
light: token('color.background.neutral', 'rgb(235, 237, 240)'),
|
|
60
63
|
dark: token('color.background.neutral', 'rgb(36, 47, 66)')
|
|
61
|
-
})(props), themed({
|
|
64
|
+
})(props), CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER, themed({
|
|
62
65
|
light: token('color.background.neutral', 'rgb(226, 229, 233)'),
|
|
63
66
|
dark: token('color.background.neutral', DN20)
|
|
64
67
|
})(props), overflowShadow({
|
|
65
68
|
background: themed({
|
|
66
|
-
light: 'rgb(235, 237, 240)',
|
|
67
|
-
dark: 'rgb(36, 47, 66)'
|
|
69
|
+
light: token('color.background.neutral', 'rgb(235, 237, 240)'),
|
|
70
|
+
dark: token('color.background.neutral', 'rgb(36, 47, 66)')
|
|
68
71
|
})(props),
|
|
69
72
|
width: "".concat(gridSize(), "px")
|
|
70
73
|
}), themed({
|
|
@@ -3,4 +3,4 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
|
|
|
3
3
|
var _templateObject;
|
|
4
4
|
|
|
5
5
|
import { css } from '@emotion/react';
|
|
6
|
-
export var textColorStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .fabric-text-color-mark {\n color: var(--custom-
|
|
6
|
+
export var textColorStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .fabric-text-color-mark {\n color: var(--custom-palette-color, inherit);\n }\n\n a .fabric-text-color-mark {\n color: unset;\n }\n"])));
|
|
@@ -23,7 +23,7 @@ import { borderRadius, gridSize } from '@atlaskit/theme/constants';
|
|
|
23
23
|
import { token } from '@atlaskit/tokens';
|
|
24
24
|
import Layer from '../Layer';
|
|
25
25
|
var packageName = "@atlaskit/editor-common";
|
|
26
|
-
var packageVersion = "
|
|
26
|
+
var packageVersion = "71.0.1";
|
|
27
27
|
var halfFocusRing = 1;
|
|
28
28
|
var dropOffset = "0, ".concat(gridSize(), "px");
|
|
29
29
|
|
|
@@ -13,6 +13,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
13
13
|
/** @jsx jsx */
|
|
14
14
|
import React, { PureComponent } from 'react';
|
|
15
15
|
import { jsx } from '@emotion/react';
|
|
16
|
+
import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
|
|
16
17
|
import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
|
|
17
18
|
import { N0 } from '@atlaskit/theme/colors';
|
|
18
19
|
import Tooltip from '@atlaskit/tooltip';
|
|
@@ -61,7 +62,9 @@ var Color = /*#__PURE__*/function (_PureComponent) {
|
|
|
61
62
|
isSelected = _this$props2.isSelected,
|
|
62
63
|
borderColor = _this$props2.borderColor,
|
|
63
64
|
_this$props2$checkMar = _this$props2.checkMarkColor,
|
|
64
|
-
checkMarkColor = _this$props2$checkMar === void 0 ? N0 : _this$props2$checkMar
|
|
65
|
+
checkMarkColor = _this$props2$checkMar === void 0 ? N0 : _this$props2$checkMar,
|
|
66
|
+
useDesignTokens = _this$props2.useDesignTokens;
|
|
67
|
+
var colorStyle = useDesignTokens ? hexToEditorTextPaletteColor(value) : value;
|
|
65
68
|
return jsx(Tooltip, {
|
|
66
69
|
content: label
|
|
67
70
|
}, jsx("span", {
|
|
@@ -76,7 +79,7 @@ var Color = /*#__PURE__*/function (_PureComponent) {
|
|
|
76
79
|
tabIndex: tabIndex,
|
|
77
80
|
className: "".concat(isSelected ? 'selected' : ''),
|
|
78
81
|
style: {
|
|
79
|
-
backgroundColor:
|
|
82
|
+
backgroundColor: colorStyle || 'transparent',
|
|
80
83
|
border: "1px solid ".concat(borderColor)
|
|
81
84
|
},
|
|
82
85
|
autoFocus: autoFocus
|
|
@@ -4,6 +4,7 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import chromatism from 'chromatism';
|
|
5
5
|
import { injectIntl } from 'react-intl-next';
|
|
6
6
|
import { N0, N500 } from '@atlaskit/theme/colors';
|
|
7
|
+
import { token } from '@atlaskit/tokens';
|
|
7
8
|
import Color from './Color';
|
|
8
9
|
import { colorPaletteWrapper } from './styles';
|
|
9
10
|
|
|
@@ -14,10 +15,21 @@ import { colorPaletteWrapper } from './styles';
|
|
|
14
15
|
* @param color color string, suppports HEX, RGB, RGBA etc.
|
|
15
16
|
* @return Highest contrast color in pool
|
|
16
17
|
*/
|
|
17
|
-
function
|
|
18
|
-
|
|
18
|
+
function getCheckMarkColor(color, textPalette) {
|
|
19
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
20
|
+
var contrastColor = [N0, N500].sort(function (a, b) {
|
|
19
21
|
return chromatism.difference(b, color) - chromatism.difference(a, color);
|
|
20
22
|
})[0];
|
|
23
|
+
|
|
24
|
+
if (!textPalette) {
|
|
25
|
+
return contrastColor;
|
|
26
|
+
} // Use of these token comes from guidance from designers in the Design System team
|
|
27
|
+
// they are only intended for use with text colors (and there are different tokens
|
|
28
|
+
// planned to be used when this extended to be used with other palettes).
|
|
29
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
return contrastColor === N0 ? token('color.icon.inverse', N0) : token('color.icon', N500);
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
var ColorPalette = function ColorPalette(props) {
|
|
@@ -27,7 +39,9 @@ var ColorPalette = function ColorPalette(props) {
|
|
|
27
39
|
onClick = props.onClick,
|
|
28
40
|
selectedColor = props.selectedColor,
|
|
29
41
|
className = props.className,
|
|
30
|
-
formatMessage = props.intl.formatMessage
|
|
42
|
+
formatMessage = props.intl.formatMessage,
|
|
43
|
+
_props$textPalette = props.textPalette,
|
|
44
|
+
textPalette = _props$textPalette === void 0 ? false : _props$textPalette;
|
|
31
45
|
var colorsPerRow = React.useMemo(function () {
|
|
32
46
|
return palette.reduce(function (resultArray, item, index) {
|
|
33
47
|
var chunkIndex = Math.floor(index / cols);
|
|
@@ -54,14 +68,9 @@ var ColorPalette = function ColorPalette(props) {
|
|
|
54
68
|
borderColor: border,
|
|
55
69
|
label: message ? formatMessage(message) : label,
|
|
56
70
|
onClick: onClick,
|
|
57
|
-
isSelected: value === selectedColor
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
61
|
-
,
|
|
62
|
-
checkMarkColor: getContrastColor(value, [N0, N500])
|
|
63
|
-
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
64
|
-
|
|
71
|
+
isSelected: value === selectedColor,
|
|
72
|
+
checkMarkColor: getCheckMarkColor(value, textPalette),
|
|
73
|
+
useDesignTokens: textPalette === true
|
|
65
74
|
});
|
|
66
75
|
}));
|
|
67
76
|
}));
|