@atlaskit/editor-common 71.0.3 → 72.0.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.
- package/CHANGELOG.md +71 -0
- package/dist/cjs/analytics/types/enums.js +20 -1
- package/dist/cjs/i18n/index.js +13 -5
- package/dist/cjs/i18n/languages.js +42 -0
- package/dist/cjs/keymaps/index.js +55 -3
- package/dist/cjs/styles/index.js +8 -2
- package/dist/cjs/styles/shared/annotation.js +4 -7
- package/dist/cjs/styles/shared/block-marks.js +1 -1
- package/dist/cjs/styles/shared/code-block.js +3 -4
- package/dist/cjs/styles/shared/lists.js +55 -4
- package/dist/cjs/styles/shared/panel.js +6 -12
- package/dist/cjs/styles/shared/shadow.js +3 -1
- package/dist/cjs/styles/shared/table.js +2 -2
- package/dist/cjs/types/next-editor-plugin.js +5 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/Emoji/index.js +11 -2
- package/dist/cjs/ui/Popup/index.js +72 -2
- package/dist/cjs/ui/Popup/utils.js +13 -6
- package/dist/cjs/ui/UnsupportedBlock/index.js +2 -2
- package/dist/cjs/ui/UnsupportedInline/index.js +2 -2
- package/dist/cjs/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +138 -0
- package/dist/cjs/ui-color/ColorPalette/index.js +19 -1
- package/dist/cjs/ui-menu/DropdownMenu/index.js +2 -0
- package/dist/cjs/ui-menu/ToolbarButton/index.js +3 -1
- package/dist/cjs/utils/analytics.js +1 -38
- package/dist/cjs/utils/builder.js +44 -0
- package/dist/cjs/utils/compareNodes.js +86 -33
- package/dist/cjs/utils/index.js +47 -1
- package/dist/cjs/utils/list.js +47 -0
- package/dist/cjs/utils/plugin-state-factory.js +9 -9
- package/dist/cjs/utils/referentiality.js +281 -2
- package/dist/cjs/utils/track-unsupported-content.js +19 -20
- package/dist/cjs/utils/validate-using-spec.js +8 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/types/enums.js +20 -1
- package/dist/es2019/i18n/index.js +4 -3
- package/dist/es2019/i18n/languages.js +34 -0
- package/dist/es2019/keymaps/index.js +47 -0
- package/dist/es2019/styles/index.js +1 -1
- package/dist/es2019/styles/shared/annotation.js +4 -7
- package/dist/es2019/styles/shared/block-marks.js +8 -1
- package/dist/es2019/styles/shared/code-block.js +7 -6
- package/dist/es2019/styles/shared/lists.js +44 -2
- package/dist/es2019/styles/shared/panel.js +6 -11
- package/dist/es2019/styles/shared/shadow.js +21 -6
- package/dist/es2019/styles/shared/table.js +2 -3
- package/dist/es2019/types/next-editor-plugin.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/Emoji/index.js +11 -2
- package/dist/es2019/ui/Popup/index.js +68 -2
- package/dist/es2019/ui/Popup/utils.js +13 -6
- package/dist/es2019/ui/UnsupportedBlock/index.js +1 -1
- package/dist/es2019/ui/UnsupportedInline/index.js +1 -1
- package/dist/es2019/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +120 -0
- package/dist/es2019/ui-color/ColorPalette/index.js +28 -12
- package/dist/es2019/ui-menu/DropdownMenu/index.js +2 -0
- package/dist/es2019/ui-menu/ToolbarButton/index.js +3 -1
- package/dist/es2019/utils/analytics.js +0 -33
- package/dist/es2019/utils/builder.js +16 -0
- package/dist/es2019/utils/compareNodes.js +79 -28
- package/dist/es2019/utils/index.js +4 -2
- package/dist/es2019/utils/list.js +31 -0
- package/dist/es2019/utils/plugin-state-factory.js +9 -9
- package/dist/es2019/utils/referentiality.js +240 -0
- package/dist/es2019/utils/track-unsupported-content.js +20 -16
- package/dist/es2019/utils/validate-using-spec.js +8 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/types/enums.js +20 -1
- package/dist/esm/i18n/index.js +4 -3
- package/dist/esm/i18n/languages.js +34 -0
- package/dist/esm/keymaps/index.js +48 -0
- package/dist/esm/styles/index.js +1 -1
- package/dist/esm/styles/shared/annotation.js +4 -7
- package/dist/esm/styles/shared/block-marks.js +1 -1
- package/dist/esm/styles/shared/code-block.js +3 -4
- package/dist/esm/styles/shared/lists.js +49 -2
- package/dist/esm/styles/shared/panel.js +6 -11
- package/dist/esm/styles/shared/shadow.js +2 -2
- package/dist/esm/styles/shared/table.js +2 -3
- package/dist/esm/types/next-editor-plugin.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/Emoji/index.js +11 -2
- package/dist/esm/ui/Popup/index.js +73 -2
- package/dist/esm/ui/Popup/utils.js +13 -6
- package/dist/esm/ui/UnsupportedBlock/index.js +1 -1
- package/dist/esm/ui/UnsupportedInline/index.js +1 -1
- package/dist/esm/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +124 -0
- package/dist/esm/ui-color/ColorPalette/index.js +18 -2
- package/dist/esm/ui-menu/DropdownMenu/index.js +2 -0
- package/dist/esm/ui-menu/ToolbarButton/index.js +3 -1
- package/dist/esm/utils/analytics.js +0 -33
- package/dist/esm/utils/builder.js +30 -0
- package/dist/esm/utils/compareNodes.js +83 -32
- package/dist/esm/utils/index.js +4 -2
- package/dist/esm/utils/list.js +31 -0
- package/dist/esm/utils/plugin-state-factory.js +9 -9
- package/dist/esm/utils/referentiality.js +269 -0
- package/dist/esm/utils/track-unsupported-content.js +19 -20
- package/dist/esm/utils/validate-using-spec.js +8 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/types/enums.d.ts +23 -4
- package/dist/types/collab/types.d.ts +1 -1
- package/dist/types/i18n/index.d.ts +4 -3
- package/dist/types/i18n/languages.d.ts +35 -0
- package/dist/types/keymaps/index.d.ts +1 -0
- package/dist/types/styles/index.d.ts +1 -1
- package/dist/types/styles/shared/lists.d.ts +3 -1
- package/dist/types/types/collab.d.ts +1 -1
- package/dist/types/types/copy-button.d.ts +4 -0
- package/dist/types/types/feature-flags.d.ts +30 -25
- package/dist/types/types/floating-toolbar.d.ts +26 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/next-editor-plugin.d.ts +61 -0
- package/dist/types/ui/Emoji/index.d.ts +2 -0
- package/dist/types/ui/Popup/index.d.ts +19 -0
- package/dist/types/ui/Popup/utils.d.ts +3 -3
- package/dist/types/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.d.ts +214 -0
- package/dist/types/ui-color/ColorPalette/index.d.ts +7 -0
- package/dist/types/ui-menu/DropdownMenu/types.d.ts +1 -0
- package/dist/types/ui-menu/ToolbarButton/index.d.ts +3 -1
- package/dist/types/utils/analytics.d.ts +1 -21
- package/dist/types/utils/builder.d.ts +8 -0
- package/dist/types/utils/compareNodes.d.ts +16 -0
- package/dist/types/utils/index.d.ts +3 -1
- package/dist/types/utils/list.d.ts +10 -0
- package/dist/types/utils/plugin-state-factory.d.ts +1 -1
- package/dist/types/utils/referentiality.d.ts +4 -0
- package/dist/types/utils/track-unsupported-content.d.ts +14 -2
- package/package.json +14 -11
- package/report.api.md +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import createFocusTrap from 'focus-trap';
|
|
3
4
|
import rafSchedule from 'raf-schd';
|
|
4
5
|
import { createPortal } from 'react-dom';
|
|
5
6
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -16,6 +17,8 @@ export default class Popup extends React.Component {
|
|
|
16
17
|
validPosition: true
|
|
17
18
|
});
|
|
18
19
|
|
|
20
|
+
_defineProperty(this, "popupRef", /*#__PURE__*/React.createRef());
|
|
21
|
+
|
|
19
22
|
_defineProperty(this, "placement", ['', '']);
|
|
20
23
|
|
|
21
24
|
_defineProperty(this, "handleRef", popup => {
|
|
@@ -35,6 +38,24 @@ export default class Popup extends React.Component {
|
|
|
35
38
|
_defineProperty(this, "resizeObserver", (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(() => {
|
|
36
39
|
this.scheduledUpdatePosition(this.props);
|
|
37
40
|
}) : undefined);
|
|
41
|
+
|
|
42
|
+
_defineProperty(this, "initFocusTrap", rafSchedule(() => {
|
|
43
|
+
const popup = this.popupRef.current;
|
|
44
|
+
|
|
45
|
+
if (!popup) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const trapConfig = {
|
|
50
|
+
clickOutsideDeactivates: true,
|
|
51
|
+
escapeDeactivates: true,
|
|
52
|
+
initialFocus: popup,
|
|
53
|
+
fallbackFocus: popup,
|
|
54
|
+
returnFocusOnDeactivate: false
|
|
55
|
+
};
|
|
56
|
+
this.focusTrap = createFocusTrap(popup, trapConfig);
|
|
57
|
+
this.focusTrap.activate();
|
|
58
|
+
}));
|
|
38
59
|
}
|
|
39
60
|
|
|
40
61
|
/**
|
|
@@ -54,14 +75,15 @@ export default class Popup extends React.Component {
|
|
|
54
75
|
stick,
|
|
55
76
|
forcePlacement,
|
|
56
77
|
allowOutOfBounds,
|
|
57
|
-
rect
|
|
78
|
+
rect,
|
|
79
|
+
preventOverflow
|
|
58
80
|
} = props;
|
|
59
81
|
|
|
60
82
|
if (!target || !popup) {
|
|
61
83
|
return {};
|
|
62
84
|
}
|
|
63
85
|
|
|
64
|
-
const placement = calculatePlacement(target, boundariesElement || document.body, fitWidth, fitHeight, alignX, alignY, forcePlacement);
|
|
86
|
+
const placement = calculatePlacement(target, boundariesElement || document.body, fitWidth, fitHeight, alignX, alignY, forcePlacement, preventOverflow);
|
|
65
87
|
|
|
66
88
|
if (onPlacementChanged && this.placement.join('') !== placement.join('')) {
|
|
67
89
|
onPlacementChanged(placement);
|
|
@@ -119,6 +141,7 @@ export default class Popup extends React.Component {
|
|
|
119
141
|
|
|
120
142
|
|
|
121
143
|
initPopup(popup) {
|
|
144
|
+
this.popupRef.current = popup;
|
|
122
145
|
const {
|
|
123
146
|
target
|
|
124
147
|
} = this.props;
|
|
@@ -144,6 +167,10 @@ export default class Popup extends React.Component {
|
|
|
144
167
|
*/
|
|
145
168
|
|
|
146
169
|
this.scheduledUpdatePosition(this.props);
|
|
170
|
+
|
|
171
|
+
if (this.props.focusTrap) {
|
|
172
|
+
this.initFocusTrap();
|
|
173
|
+
}
|
|
147
174
|
}
|
|
148
175
|
|
|
149
176
|
UNSAFE_componentWillReceiveProps(newProps) {
|
|
@@ -152,6 +179,44 @@ export default class Popup extends React.Component {
|
|
|
152
179
|
this.scheduledUpdatePosition(newProps);
|
|
153
180
|
}
|
|
154
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Cancels the initialisation of the focus trap if it has not yet occured
|
|
184
|
+
* Deactivates the focus trap if it exists
|
|
185
|
+
*/
|
|
186
|
+
destroyFocusTrap() {
|
|
187
|
+
var _this$focusTrap;
|
|
188
|
+
|
|
189
|
+
this.initFocusTrap.cancel();
|
|
190
|
+
(_this$focusTrap = this.focusTrap) === null || _this$focusTrap === void 0 ? void 0 : _this$focusTrap.deactivate();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Handle pausing, unpausing, and initialising (if not yet initialised) of the focus trap
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
handleChangedFocusTrapProp(prevProps) {
|
|
198
|
+
if (prevProps.focusTrap !== this.props.focusTrap) {
|
|
199
|
+
// If currently set to disable, then pause the trap if it exists
|
|
200
|
+
if (!this.props.focusTrap) {
|
|
201
|
+
var _this$focusTrap2;
|
|
202
|
+
|
|
203
|
+
return (_this$focusTrap2 = this.focusTrap) === null || _this$focusTrap2 === void 0 ? void 0 : _this$focusTrap2.pause();
|
|
204
|
+
} // If set to enabled and trap already exists, unpause
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
if (this.focusTrap) {
|
|
208
|
+
this.focusTrap.unpause();
|
|
209
|
+
} // Else initialise the focus trap
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
return this.initFocusTrap();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
componentDidUpdate(prevProps) {
|
|
217
|
+
this.handleChangedFocusTrapProp(prevProps);
|
|
218
|
+
}
|
|
219
|
+
|
|
155
220
|
componentDidMount() {
|
|
156
221
|
window.addEventListener('resize', this.onResize);
|
|
157
222
|
const {
|
|
@@ -186,6 +251,7 @@ export default class Popup extends React.Component {
|
|
|
186
251
|
}
|
|
187
252
|
|
|
188
253
|
this.scheduledUpdatePosition.cancel();
|
|
254
|
+
this.destroyFocusTrap();
|
|
189
255
|
}
|
|
190
256
|
|
|
191
257
|
renderPopup() {
|
|
@@ -8,7 +8,7 @@ export function isTextNode(elem) {
|
|
|
8
8
|
* Decides if given fitHeight fits below or above the target taking boundaries into account.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export function getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement) {
|
|
11
|
+
export function getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement, preventOverflow) {
|
|
12
12
|
if (forcePlacement && alignY) {
|
|
13
13
|
return alignY;
|
|
14
14
|
}
|
|
@@ -31,7 +31,13 @@ export function getVerticalPlacement(target, boundariesElement, fitHeight, align
|
|
|
31
31
|
height: targetHeight
|
|
32
32
|
} = target.getBoundingClientRect();
|
|
33
33
|
const spaceAbove = targetTop - (boundariesTop - boundariesElement.scrollTop);
|
|
34
|
-
const spaceBelow = boundariesTop + boundariesHeight - (targetTop + targetHeight);
|
|
34
|
+
const spaceBelow = boundariesTop + boundariesHeight - (targetTop + targetHeight); // Force vertical placement to bottom if the space above doesn't accomodate the fitHeight
|
|
35
|
+
|
|
36
|
+
if (preventOverflow) {
|
|
37
|
+
if (spaceAbove <= fitHeight) {
|
|
38
|
+
return 'bottom';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
35
41
|
|
|
36
42
|
if (spaceBelow >= fitHeight || spaceBelow >= spaceAbove) {
|
|
37
43
|
return 'bottom';
|
|
@@ -43,8 +49,9 @@ export function getVerticalPlacement(target, boundariesElement, fitHeight, align
|
|
|
43
49
|
* Decides if given fitWidth fits to the left or to the right of the target taking boundaries into account.
|
|
44
50
|
*/
|
|
45
51
|
|
|
46
|
-
export function getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement) {
|
|
47
|
-
|
|
52
|
+
export function getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement, preventOverflow) {
|
|
53
|
+
// force placement unless preventOverflow is enabled
|
|
54
|
+
if (forcePlacement && alignX && !preventOverflow) {
|
|
48
55
|
return alignX;
|
|
49
56
|
}
|
|
50
57
|
|
|
@@ -75,8 +82,8 @@ export function getHorizontalPlacement(target, boundariesElement, fitWidth, alig
|
|
|
75
82
|
|
|
76
83
|
return 'right';
|
|
77
84
|
}
|
|
78
|
-
export function calculatePlacement(target, boundariesElement, fitWidth, fitHeight, alignX, alignY, forcePlacement) {
|
|
79
|
-
return [getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement), getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement)];
|
|
85
|
+
export function calculatePlacement(target, boundariesElement, fitWidth, fitHeight, alignX, alignY, forcePlacement, preventOverflow) {
|
|
86
|
+
return [getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement, preventOverflow), getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement, preventOverflow)];
|
|
80
87
|
}
|
|
81
88
|
|
|
82
89
|
const calculateHorizontalPlacement = ({
|
|
@@ -8,8 +8,8 @@ import { N30, N50 } from '@atlaskit/theme/colors';
|
|
|
8
8
|
import { borderRadius, fontSize } from '@atlaskit/theme/constants';
|
|
9
9
|
import { token } from '@atlaskit/tokens';
|
|
10
10
|
import Tooltip from '@atlaskit/tooltip';
|
|
11
|
+
import { ACTION_SUBJECT_ID } from '../../analytics';
|
|
11
12
|
import { unsupportedContentMessages } from '../../messages/unsupportedContent';
|
|
12
|
-
import { ACTION_SUBJECT_ID } from '../../utils/analytics';
|
|
13
13
|
import { trackUnsupportedContentTooltipDisplayedFor } from '../../utils/track-unsupported-content';
|
|
14
14
|
import { getUnsupportedContent } from '../unsupported-content-helper';
|
|
15
15
|
const blockNodeStyle = css`
|
|
@@ -8,8 +8,8 @@ import { N30, N50 } from '@atlaskit/theme/colors';
|
|
|
8
8
|
import { borderRadius, fontSize } from '@atlaskit/theme/constants';
|
|
9
9
|
import { token } from '@atlaskit/tokens';
|
|
10
10
|
import Tooltip from '@atlaskit/tooltip';
|
|
11
|
+
import { ACTION_SUBJECT_ID } from '../../analytics';
|
|
11
12
|
import { unsupportedContentMessages } from '../../messages/unsupportedContent';
|
|
12
|
-
import { ACTION_SUBJECT_ID } from '../../utils/analytics';
|
|
13
13
|
import { trackUnsupportedContentTooltipDisplayedFor } from '../../utils/track-unsupported-content';
|
|
14
14
|
import { getUnsupportedContent } from '../unsupported-content-helper';
|
|
15
15
|
const inlineNodeStyle = css`
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next'; // These messages are only to be used when useSomewhatSemanticTextColorNames feature flag is true.
|
|
2
|
+
// They are used only in Jira and are part of work for https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3365994869/EXTERNAL+MAKE+PP+COMMIT-5058+Enable+dark+mode+usage+of+text+colors+in+UGC+and+non+custom+panels+in+Jira
|
|
3
|
+
|
|
4
|
+
export const newLightPalette = defineMessages({
|
|
5
|
+
'#FFFFFF': {
|
|
6
|
+
id: 'fabric.theme.white',
|
|
7
|
+
defaultMessage: 'White',
|
|
8
|
+
description: 'Name of a color'
|
|
9
|
+
},
|
|
10
|
+
'#B3D4FF': {
|
|
11
|
+
id: 'fabric.theme.subtle-blue',
|
|
12
|
+
defaultMessage: 'Subtle blue',
|
|
13
|
+
description: 'Name of a color'
|
|
14
|
+
},
|
|
15
|
+
'#B3F5FF': {
|
|
16
|
+
id: 'fabric.theme.subtle-teal',
|
|
17
|
+
defaultMessage: 'Subtle teal',
|
|
18
|
+
description: 'Name of a color'
|
|
19
|
+
},
|
|
20
|
+
'#ABF5D1': {
|
|
21
|
+
id: 'fabric.theme.subtle-green',
|
|
22
|
+
defaultMessage: 'Subtle green',
|
|
23
|
+
description: 'Name of a color'
|
|
24
|
+
},
|
|
25
|
+
'#FFF0B3': {
|
|
26
|
+
id: 'fabric.theme.subtle-yellow',
|
|
27
|
+
defaultMessage: 'Subtle yellow',
|
|
28
|
+
description: 'Name of a color'
|
|
29
|
+
},
|
|
30
|
+
'#FFBDAD': {
|
|
31
|
+
id: 'fabric.theme.subtle-red',
|
|
32
|
+
defaultMessage: 'Subtle red',
|
|
33
|
+
description: 'Name of a color'
|
|
34
|
+
},
|
|
35
|
+
'#EAE6FF': {
|
|
36
|
+
id: 'fabric.theme.subtle-purple',
|
|
37
|
+
defaultMessage: 'Subtle purple',
|
|
38
|
+
description: 'Name of a color'
|
|
39
|
+
},
|
|
40
|
+
'#97A0AF': {
|
|
41
|
+
id: 'fabric.theme.gray',
|
|
42
|
+
defaultMessage: 'Gray',
|
|
43
|
+
description: 'Name of a color'
|
|
44
|
+
},
|
|
45
|
+
'#4C9AFF': {
|
|
46
|
+
id: 'fabric.theme.blue',
|
|
47
|
+
defaultMessage: 'Blue',
|
|
48
|
+
description: 'Name of a color'
|
|
49
|
+
},
|
|
50
|
+
'#00B8D9': {
|
|
51
|
+
id: 'fabric.theme.teal',
|
|
52
|
+
defaultMessage: 'Teal',
|
|
53
|
+
description: 'Name of a color'
|
|
54
|
+
},
|
|
55
|
+
'#36B37E': {
|
|
56
|
+
id: 'fabric.theme.green',
|
|
57
|
+
defaultMessage: 'Green',
|
|
58
|
+
description: 'Name of a color'
|
|
59
|
+
},
|
|
60
|
+
'#FFC400': {
|
|
61
|
+
id: 'fabric.theme.yellow',
|
|
62
|
+
defaultMessage: 'Yellow',
|
|
63
|
+
description: 'Name of a color'
|
|
64
|
+
},
|
|
65
|
+
'#FF5630': {
|
|
66
|
+
id: 'fabric.theme.red',
|
|
67
|
+
defaultMessage: 'Red',
|
|
68
|
+
description: 'Name of a color'
|
|
69
|
+
},
|
|
70
|
+
'#FF991F': {
|
|
71
|
+
id: 'fabric.theme.bold-orange',
|
|
72
|
+
defaultMessage: 'Bold orange',
|
|
73
|
+
description: 'Name of a color.'
|
|
74
|
+
},
|
|
75
|
+
'#6554C0': {
|
|
76
|
+
id: 'fabric.theme.purple',
|
|
77
|
+
defaultMessage: 'Purple',
|
|
78
|
+
description: 'Name of a color'
|
|
79
|
+
},
|
|
80
|
+
'#0747A6': {
|
|
81
|
+
id: 'fabric.theme.bold-blue',
|
|
82
|
+
defaultMessage: 'Bold blue',
|
|
83
|
+
description: 'Name of a color'
|
|
84
|
+
},
|
|
85
|
+
'#008DA6': {
|
|
86
|
+
id: 'fabric.theme.bold-teal',
|
|
87
|
+
defaultMessage: 'Bold teal',
|
|
88
|
+
description: 'Name of a color'
|
|
89
|
+
},
|
|
90
|
+
'#006644': {
|
|
91
|
+
id: 'fabric.theme.bold-green',
|
|
92
|
+
defaultMessage: 'Bold green',
|
|
93
|
+
description: 'Name of a color'
|
|
94
|
+
},
|
|
95
|
+
'#BF2600': {
|
|
96
|
+
id: 'fabric.theme.bold-red',
|
|
97
|
+
defaultMessage: 'Bold red',
|
|
98
|
+
description: 'Name of a color'
|
|
99
|
+
},
|
|
100
|
+
'#403294': {
|
|
101
|
+
id: 'fabric.theme.bold-purple',
|
|
102
|
+
defaultMessage: 'Bold purple',
|
|
103
|
+
description: 'Name of a color'
|
|
104
|
+
},
|
|
105
|
+
'#172B4D': {
|
|
106
|
+
id: 'fabric.theme.default',
|
|
107
|
+
defaultMessage: 'Default',
|
|
108
|
+
description: 'Name of a color'
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
const darkModeWhite = defineMessages({
|
|
112
|
+
'#FFFFFF': {
|
|
113
|
+
id: 'fabric.theme.dark-gray',
|
|
114
|
+
defaultMessage: 'Dark gray',
|
|
115
|
+
description: 'Name of a color'
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
export const newDarkPalette = { ...newLightPalette,
|
|
119
|
+
...darkModeWhite
|
|
120
|
+
};
|
|
@@ -4,8 +4,10 @@ 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
|
+
import { token, useThemeObserver } from '@atlaskit/tokens';
|
|
8
8
|
import Color from './Color';
|
|
9
|
+
import getColorMessage from './Palettes/getColorMessage';
|
|
10
|
+
import { newDarkPalette, newLightPalette } from './Palettes/paletteMessagesTokenModeNames';
|
|
9
11
|
import { colorPaletteWrapper } from './styles';
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -40,8 +42,10 @@ const ColorPalette = props => {
|
|
|
40
42
|
intl: {
|
|
41
43
|
formatMessage
|
|
42
44
|
},
|
|
43
|
-
textPalette = false
|
|
45
|
+
textPalette = false,
|
|
46
|
+
useSomewhatSemanticTextColorNames = false
|
|
44
47
|
} = props;
|
|
48
|
+
const tokenTheme = useThemeObserver();
|
|
45
49
|
const colorsPerRow = React.useMemo(() => {
|
|
46
50
|
return palette.reduce((resultArray, item, index) => {
|
|
47
51
|
const chunkIndex = Math.floor(index / cols);
|
|
@@ -61,16 +65,28 @@ const ColorPalette = props => {
|
|
|
61
65
|
label,
|
|
62
66
|
border,
|
|
63
67
|
message
|
|
64
|
-
}, colorIdx) =>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
}, colorIdx) => {
|
|
69
|
+
if (textPalette === true && useSomewhatSemanticTextColorNames) {
|
|
70
|
+
if (tokenTheme === 'dark') {
|
|
71
|
+
message = getColorMessage(newDarkPalette, value.toUpperCase());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (tokenTheme === 'light') {
|
|
75
|
+
message = getColorMessage(newLightPalette, value.toUpperCase());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return jsx(Color, {
|
|
80
|
+
key: value,
|
|
81
|
+
value: value,
|
|
82
|
+
borderColor: border,
|
|
83
|
+
label: message ? formatMessage(message) : label,
|
|
84
|
+
onClick: onClick,
|
|
85
|
+
isSelected: value === selectedColor,
|
|
86
|
+
checkMarkColor: getCheckMarkColor(value, textPalette),
|
|
87
|
+
useDesignTokens: textPalette === true
|
|
88
|
+
});
|
|
89
|
+
}))));
|
|
74
90
|
};
|
|
75
91
|
|
|
76
92
|
export default injectIntl(ColorPalette);
|
|
@@ -244,6 +244,7 @@ function DropdownMenuItem({
|
|
|
244
244
|
}, jsx(CustomItem, {
|
|
245
245
|
item: item,
|
|
246
246
|
key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : String(item.content),
|
|
247
|
+
testId: `dropdown-item__${String(item.content)}`,
|
|
247
248
|
role: shouldUseDefaultRole ? 'button' : 'menuitem',
|
|
248
249
|
iconBefore: item.elemBefore,
|
|
249
250
|
iconAfter: item.elemAfter,
|
|
@@ -253,6 +254,7 @@ function DropdownMenuItem({
|
|
|
253
254
|
}),
|
|
254
255
|
"aria-label": item['aria-label'] || String(item.content),
|
|
255
256
|
"aria-pressed": shouldUseDefaultRole ? item.isActive : undefined,
|
|
257
|
+
"aria-keyshortcuts": item['aria-keyshortcuts'],
|
|
256
258
|
onMouseDown: e => {
|
|
257
259
|
e.preventDefault();
|
|
258
260
|
},
|
|
@@ -31,6 +31,7 @@ const ToolbarButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
31
31
|
'aria-haspopup': ariaHasPopup,
|
|
32
32
|
'aria-expanded': ariaExpanded,
|
|
33
33
|
'aria-pressed': ariaPressed,
|
|
34
|
+
'aria-keyshortcuts': ariaKeyShortcuts,
|
|
34
35
|
onClick,
|
|
35
36
|
onItemClick
|
|
36
37
|
} = props;
|
|
@@ -75,7 +76,8 @@ const ToolbarButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
75
76
|
"aria-expanded": ariaExpanded,
|
|
76
77
|
"aria-haspopup": ariaHasPopup,
|
|
77
78
|
"aria-label": ariaLabel,
|
|
78
|
-
"aria-pressed": ariaPressed
|
|
79
|
+
"aria-pressed": ariaPressed,
|
|
80
|
+
"aria-keyshortcuts": ariaKeyShortcuts
|
|
79
81
|
}, children);
|
|
80
82
|
|
|
81
83
|
if (!title) {
|
|
@@ -37,37 +37,4 @@ export let SEVERITY;
|
|
|
37
37
|
})(SEVERITY || (SEVERITY = {}));
|
|
38
38
|
|
|
39
39
|
export { UNSUPPORTED_CONTENT_LEVEL_SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS } from './unsupportedContent/get-unsupported-content-level-data';
|
|
40
|
-
export let EVENT_TYPE;
|
|
41
|
-
|
|
42
|
-
(function (EVENT_TYPE) {
|
|
43
|
-
EVENT_TYPE["TRACK"] = "track";
|
|
44
|
-
EVENT_TYPE["UI"] = "ui";
|
|
45
|
-
})(EVENT_TYPE || (EVENT_TYPE = {}));
|
|
46
|
-
|
|
47
|
-
export let ACTION;
|
|
48
|
-
|
|
49
|
-
(function (ACTION) {
|
|
50
|
-
ACTION["UNSUPPORTED_CONTENT_ENCOUNTERED"] = "unsupportedContentEncountered";
|
|
51
|
-
ACTION["UNSUPPORTED_TOOLTIP_VIEWED"] = "viewed";
|
|
52
|
-
})(ACTION || (ACTION = {}));
|
|
53
|
-
|
|
54
|
-
export let ACTION_SUBJECT;
|
|
55
|
-
|
|
56
|
-
(function (ACTION_SUBJECT) {
|
|
57
|
-
ACTION_SUBJECT["DOCUMENT"] = "document";
|
|
58
|
-
ACTION_SUBJECT["TOOLTIP"] = "tooltip";
|
|
59
|
-
})(ACTION_SUBJECT || (ACTION_SUBJECT = {}));
|
|
60
|
-
|
|
61
|
-
export let ACTION_SUBJECT_ID;
|
|
62
|
-
|
|
63
|
-
(function (ACTION_SUBJECT_ID) {
|
|
64
|
-
ACTION_SUBJECT_ID["UNSUPPORTED_BLOCK"] = "unsupportedBlock";
|
|
65
|
-
ACTION_SUBJECT_ID["UNSUPPORTED_INLINE"] = "unsupportedInline";
|
|
66
|
-
ACTION_SUBJECT_ID["UNSUPPORTED_MARK"] = "unsupportedMark";
|
|
67
|
-
ACTION_SUBJECT_ID["UNSUPPORTED_ERROR"] = "unsupportedUnhandled";
|
|
68
|
-
ACTION_SUBJECT_ID["UNSUPPORTED_NODE_ATTRIBUTE"] = "unsupportedNodeAttribute";
|
|
69
|
-
ACTION_SUBJECT_ID["ON_UNSUPPORTED_INLINE"] = "onUnsupportedInline";
|
|
70
|
-
ACTION_SUBJECT_ID["ON_UNSUPPORTED_BLOCK"] = "onUnsupportedBlock";
|
|
71
|
-
})(ACTION_SUBJECT_ID || (ACTION_SUBJECT_ID = {}));
|
|
72
|
-
|
|
73
40
|
export const analyticsEventKey = 'EDITOR_ANALYTICS_EVENT';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class Builder {
|
|
2
|
+
constructor(...more) {
|
|
3
|
+
this.data = [...more] || [];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
add(nextOrTuple) {
|
|
7
|
+
return new Builder(
|
|
8
|
+
/**
|
|
9
|
+
* re-cast this to NewPlugin as we've done all the type
|
|
10
|
+
* safety, dependency checking, narrowing, during
|
|
11
|
+
* `SafePresetCheck & VerifyPluginDependencies`
|
|
12
|
+
*/
|
|
13
|
+
nextOrTuple, ...this.data);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SortOrder } from '../types';
|
|
2
|
-
|
|
2
|
+
export let ContentType;
|
|
3
3
|
|
|
4
4
|
(function (ContentType) {
|
|
5
5
|
ContentType[ContentType["NUMBER"] = 0] = "NUMBER";
|
|
@@ -13,6 +13,83 @@ var ContentType;
|
|
|
13
13
|
function getLinkMark(node) {
|
|
14
14
|
const [linkMark] = node.marks.filter(mark => mark.type.name === 'link');
|
|
15
15
|
return linkMark || null;
|
|
16
|
+
} // Source: https://stackoverflow.com/questions/12004808/does-javascript-take-local-decimal-separators-into-account
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function parseLocaleNumber(stringNumber) {
|
|
20
|
+
if (stringNumber.trim() === '') {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const locale = window.navigator.language;
|
|
25
|
+
const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, '');
|
|
26
|
+
const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, '');
|
|
27
|
+
const maybeANumber = Number(stringNumber.replace(new RegExp('\\' + thousandSeparator, 'g'), '').replace(new RegExp('\\' + decimalSeparator), '.'));
|
|
28
|
+
const isANumber = !Number.isNaN(maybeANumber);
|
|
29
|
+
|
|
30
|
+
if (!isANumber) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return maybeANumber;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function extractFirstWordFromString(text) {
|
|
38
|
+
// Firefox is the only browser that doesn't support it
|
|
39
|
+
if (!Intl || !Intl.Segmenter) {
|
|
40
|
+
// If the Segment API is not available
|
|
41
|
+
// let's fallback to a dumb way to extract the first word.
|
|
42
|
+
// However, this method doesn't cover some languages like Japanase
|
|
43
|
+
const firstEmptySpace = text.indexOf(' ');
|
|
44
|
+
const firstWord = firstEmptySpace !== -1 ? text.substring(0, firstEmptySpace) : text;
|
|
45
|
+
return firstWord;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const languageSegment = new Intl.Segmenter(window.navigator.language, {
|
|
49
|
+
granularity: 'word'
|
|
50
|
+
});
|
|
51
|
+
const segmentsIterator = languageSegment.segment(text);
|
|
52
|
+
|
|
53
|
+
if (!segmentsIterator) {
|
|
54
|
+
return text;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const segmentsArray = Array.from(segmentsIterator);
|
|
58
|
+
|
|
59
|
+
if (segmentsArray.length === 0) {
|
|
60
|
+
return text;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return segmentsArray[0].segment;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function extractMetaFromTextNode(textNode) {
|
|
67
|
+
// treat as a link if contain a link
|
|
68
|
+
const linkMark = getLinkMark(textNode);
|
|
69
|
+
|
|
70
|
+
if (linkMark) {
|
|
71
|
+
const value = textNode.text || '';
|
|
72
|
+
return {
|
|
73
|
+
type: ContentType.LINK,
|
|
74
|
+
value
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const text = textNode.text || '';
|
|
79
|
+
const firstWord = extractFirstWordFromString(text);
|
|
80
|
+
const maybeANumber = parseLocaleNumber(firstWord);
|
|
81
|
+
|
|
82
|
+
if (maybeANumber !== null) {
|
|
83
|
+
return {
|
|
84
|
+
type: ContentType.NUMBER,
|
|
85
|
+
value: maybeANumber
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
type: ContentType.TEXT,
|
|
91
|
+
value: firstWord
|
|
92
|
+
};
|
|
16
93
|
}
|
|
17
94
|
|
|
18
95
|
function getMetaFromNode(node, options) {
|
|
@@ -61,33 +138,7 @@ function getMetaFromNode(node, options) {
|
|
|
61
138
|
|
|
62
139
|
case 'text':
|
|
63
140
|
{
|
|
64
|
-
|
|
65
|
-
const linkMark = getLinkMark(firstChild);
|
|
66
|
-
|
|
67
|
-
if (linkMark) {
|
|
68
|
-
const value = firstChild.text || '';
|
|
69
|
-
return {
|
|
70
|
-
type: ContentType.LINK,
|
|
71
|
-
value
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const text = firstChild.text || '';
|
|
76
|
-
const firstEmptySpace = text.indexOf(' ');
|
|
77
|
-
const firstWord = firstEmptySpace !== -1 ? text.substring(0, firstEmptySpace) : text;
|
|
78
|
-
const maybeANumber = Number.parseFloat(firstWord);
|
|
79
|
-
|
|
80
|
-
if (!Number.isNaN(maybeANumber)) {
|
|
81
|
-
return {
|
|
82
|
-
type: ContentType.NUMBER,
|
|
83
|
-
value: maybeANumber
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
type: ContentType.TEXT,
|
|
89
|
-
value: firstWord
|
|
90
|
-
};
|
|
141
|
+
return extractMetaFromTextNode(firstChild);
|
|
91
142
|
}
|
|
92
143
|
|
|
93
144
|
case 'status':
|
|
@@ -33,5 +33,7 @@ export { validateADFEntity, validationErrorHandler } from './validate-using-spec
|
|
|
33
33
|
export { getShallowPropsDifference, getPropsDifference } from './compare-props';
|
|
34
34
|
export { useComponentRenderTracking } from './performance/hooks/use-component-render-tracking';
|
|
35
35
|
export { isOutdatedBrowser } from './outdated-browsers';
|
|
36
|
-
export { isReferencedSource } from './referentiality';
|
|
37
|
-
export { sendLogs } from './sendLogs';
|
|
36
|
+
export { isReferencedSource, removeConnectedNodes, getChildrenInfo, getNodeName } from './referentiality';
|
|
37
|
+
export { sendLogs } from './sendLogs';
|
|
38
|
+
export { Builder } from './builder';
|
|
39
|
+
export { getItemCounterDigitsSize, getOrderFromOrderedListNode, resolveOrder } from './list';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const DEFAULT_ORDER = 1; // resolve "order" to a safe, 0+ integer, otherwise return undefined
|
|
2
|
+
// Note: Any changes to this function should also be made to "resolveStart"
|
|
3
|
+
// in packages/editor/adf-schema/src/schema/nodes/ordered-list.ts
|
|
4
|
+
|
|
5
|
+
export const resolveOrder = order => {
|
|
6
|
+
const num = Number(order);
|
|
7
|
+
|
|
8
|
+
if (Number.isNaN(num)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (num < 0) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return Math.floor(Math.max(num, 0));
|
|
17
|
+
};
|
|
18
|
+
export const getOrderFromOrderedListNode = orderedListNode => {
|
|
19
|
+
var _orderedListNode$attr, _resolveOrder;
|
|
20
|
+
|
|
21
|
+
const order = orderedListNode === null || orderedListNode === void 0 ? void 0 : (_orderedListNode$attr = orderedListNode.attrs) === null || _orderedListNode$attr === void 0 ? void 0 : _orderedListNode$attr.order;
|
|
22
|
+
return (_resolveOrder = resolveOrder(order)) !== null && _resolveOrder !== void 0 ? _resolveOrder : DEFAULT_ORDER;
|
|
23
|
+
};
|
|
24
|
+
export const getItemCounterDigitsSize = options => {
|
|
25
|
+
var _resolveOrder2, _String, _String$split, _String$split$;
|
|
26
|
+
|
|
27
|
+
const order = (_resolveOrder2 = resolveOrder(options.order)) !== null && _resolveOrder2 !== void 0 ? _resolveOrder2 : DEFAULT_ORDER;
|
|
28
|
+
const itemsCount = typeof options.itemsCount === 'number' ? options.itemsCount : 0;
|
|
29
|
+
const largestCounter = order + (itemsCount - 1);
|
|
30
|
+
return (_String = String(largestCounter)) === null || _String === void 0 ? void 0 : (_String$split = _String.split('.')) === null || _String$split === void 0 ? void 0 : (_String$split$ = _String$split[0]) === null || _String$split$ === void 0 ? void 0 : _String$split$.length;
|
|
31
|
+
};
|
|
@@ -58,26 +58,26 @@ export function pluginFactory(pluginKey, reducer, options = {}) {
|
|
|
58
58
|
createPluginState(dispatch, initialState) {
|
|
59
59
|
return {
|
|
60
60
|
init: (_, state) => isFunction(initialState) ? initialState(state) : initialState,
|
|
61
|
-
apply: (tr, _pluginState) => {
|
|
62
|
-
const
|
|
63
|
-
let
|
|
61
|
+
apply: (tr, _pluginState, _oldEditorState, newEditorState) => {
|
|
62
|
+
const oldPluginState = mapping ? mapping(tr, _pluginState, newEditorState) : _pluginState;
|
|
63
|
+
let newPluginState = oldPluginState;
|
|
64
64
|
const meta = tr.getMeta(pluginKey);
|
|
65
65
|
|
|
66
66
|
if (meta) {
|
|
67
|
-
|
|
67
|
+
newPluginState = reducer(oldPluginState, meta);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (onDocChanged && tr.docChanged) {
|
|
71
|
-
|
|
71
|
+
newPluginState = onDocChanged(tr, newPluginState, newEditorState);
|
|
72
72
|
} else if (onSelectionChanged && tr.selectionSet) {
|
|
73
|
-
|
|
73
|
+
newPluginState = onSelectionChanged(tr, newPluginState, newEditorState);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
if (
|
|
77
|
-
dispatch(pluginKey,
|
|
76
|
+
if (newPluginState !== oldPluginState) {
|
|
77
|
+
dispatch(pluginKey, newPluginState);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
return
|
|
80
|
+
return newPluginState;
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
},
|