@atlaskit/editor-common 71.0.3 → 72.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 +78 -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 +56 -6
- package/dist/cjs/styles/index.js +8 -2
- package/dist/cjs/styles/shared/annotation.js +9 -14
- package/dist/cjs/styles/shared/block-marks.js +1 -1
- package/dist/cjs/styles/shared/blockquote.js +1 -3
- package/dist/cjs/styles/shared/code-block.js +13 -16
- package/dist/cjs/styles/shared/code-mark.js +2 -4
- package/dist/cjs/styles/shared/lists.js +55 -4
- package/dist/cjs/styles/shared/panel.js +29 -39
- package/dist/cjs/styles/shared/rule.js +2 -4
- package/dist/cjs/styles/shared/shadow.js +1 -1
- package/dist/cjs/styles/shared/table.js +24 -26
- package/dist/cjs/types/next-editor-plugin.js +5 -0
- package/dist/cjs/ui/Caption/index.js +2 -4
- package/dist/cjs/ui/DropList/index.js +5 -7
- package/dist/cjs/ui/Emoji/index.js +11 -2
- package/dist/cjs/ui/Expand/index.js +17 -19
- package/dist/cjs/ui/Messages/index.js +3 -5
- 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 +3 -5
- package/dist/cjs/ui/UnsupportedInline/index.js +3 -5
- package/dist/cjs/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +138 -0
- package/dist/cjs/ui-color/ColorPalette/index.js +20 -2
- package/dist/cjs/ui-menu/DropdownMenu/index.js +12 -12
- 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 +48 -2
- package/dist/es2019/styles/index.js +1 -1
- package/dist/es2019/styles/shared/annotation.js +9 -13
- package/dist/es2019/styles/shared/block-marks.js +8 -1
- package/dist/es2019/styles/shared/blockquote.js +1 -2
- package/dist/es2019/styles/shared/code-block.js +18 -18
- package/dist/es2019/styles/shared/code-mark.js +2 -3
- package/dist/es2019/styles/shared/lists.js +44 -2
- package/dist/es2019/styles/shared/panel.js +29 -37
- package/dist/es2019/styles/shared/rule.js +2 -3
- package/dist/es2019/styles/shared/shadow.js +20 -6
- package/dist/es2019/styles/shared/table.js +24 -26
- package/dist/es2019/types/next-editor-plugin.js +1 -0
- package/dist/es2019/ui/Caption/index.js +2 -3
- package/dist/es2019/ui/DropList/index.js +5 -6
- package/dist/es2019/ui/Emoji/index.js +11 -2
- package/dist/es2019/ui/Expand/index.js +17 -18
- package/dist/es2019/ui/Messages/index.js +3 -4
- 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 +3 -4
- package/dist/es2019/ui/UnsupportedInline/index.js +3 -4
- package/dist/es2019/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +120 -0
- package/dist/es2019/ui-color/ColorPalette/index.js +29 -13
- package/dist/es2019/ui-menu/DropdownMenu/index.js +13 -12
- 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 +49 -2
- package/dist/esm/styles/index.js +1 -1
- package/dist/esm/styles/shared/annotation.js +9 -13
- package/dist/esm/styles/shared/block-marks.js +1 -1
- package/dist/esm/styles/shared/blockquote.js +1 -2
- package/dist/esm/styles/shared/code-block.js +13 -15
- package/dist/esm/styles/shared/code-mark.js +2 -3
- package/dist/esm/styles/shared/lists.js +49 -2
- package/dist/esm/styles/shared/panel.js +29 -37
- package/dist/esm/styles/shared/rule.js +2 -3
- package/dist/esm/styles/shared/shadow.js +1 -2
- package/dist/esm/styles/shared/table.js +24 -26
- package/dist/esm/types/next-editor-plugin.js +1 -0
- package/dist/esm/ui/Caption/index.js +2 -3
- package/dist/esm/ui/DropList/index.js +5 -6
- package/dist/esm/ui/Emoji/index.js +11 -2
- package/dist/esm/ui/Expand/index.js +17 -18
- package/dist/esm/ui/Messages/index.js +3 -4
- 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 +2 -3
- package/dist/esm/ui/UnsupportedInline/index.js +2 -3
- package/dist/esm/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +124 -0
- package/dist/esm/ui-color/ColorPalette/index.js +19 -3
- package/dist/esm/ui-menu/DropdownMenu/index.js +12 -11
- 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 +15 -12
- package/report.api.md +1 -1
|
@@ -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 {
|
|
7
|
+
import { 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
|
/**
|
|
@@ -27,7 +29,7 @@ function getCheckMarkColor(color, textPalette) {
|
|
|
27
29
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
28
30
|
|
|
29
31
|
|
|
30
|
-
return contrastColor === N0 ?
|
|
32
|
+
return contrastColor === N0 ? `var(--ds-icon-inverse, ${N0})` : `var(--ds-icon, ${N500})`;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
const ColorPalette = props => {
|
|
@@ -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);
|
|
@@ -8,7 +8,6 @@ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
|
8
8
|
import { CustomItem, MenuGroup } from '@atlaskit/menu';
|
|
9
9
|
import { B100, DN600, DN80, N70, N900 } from '@atlaskit/theme/colors';
|
|
10
10
|
import { themed } from '@atlaskit/theme/components';
|
|
11
|
-
import { token } from '@atlaskit/tokens';
|
|
12
11
|
import Tooltip from '@atlaskit/tooltip';
|
|
13
12
|
import { withReactEditorViewOuterListeners } from '../../ui-react';
|
|
14
13
|
import DropList from '../../ui/DropList';
|
|
@@ -21,7 +20,7 @@ const wrapper = css`
|
|
|
21
20
|
}
|
|
22
21
|
`;
|
|
23
22
|
const focusedMenuItemStyle = css`
|
|
24
|
-
box-shadow: inset 0px 0px 0px 2px ${
|
|
23
|
+
box-shadow: inset 0px 0px 0px 2px ${`var(--ds-border-focused, ${B100})`};
|
|
25
24
|
outline: none;
|
|
26
25
|
`;
|
|
27
26
|
|
|
@@ -34,8 +33,8 @@ const buttonStyles = isActive => theme => {
|
|
|
34
33
|
> span,
|
|
35
34
|
> span:hover,
|
|
36
35
|
> span:active {
|
|
37
|
-
background: ${
|
|
38
|
-
color: ${
|
|
36
|
+
background: ${"var(--ds-background-selected, #6c798f)"};
|
|
37
|
+
color: ${"var(--ds-text, #fff)"};
|
|
39
38
|
}
|
|
40
39
|
:focus > span[aria-disabled='false'] {
|
|
41
40
|
${focusedMenuItemStyle};
|
|
@@ -49,24 +48,24 @@ const buttonStyles = isActive => theme => {
|
|
|
49
48
|
return css`
|
|
50
49
|
> span:hover[aria-disabled='false'] {
|
|
51
50
|
color: ${themed({
|
|
52
|
-
light:
|
|
53
|
-
dark:
|
|
51
|
+
light: `var(--ds-text, ${N900})`,
|
|
52
|
+
dark: `var(--ds-text, ${DN600})`
|
|
54
53
|
})(theme)};
|
|
55
54
|
background-color: ${themed({
|
|
56
|
-
light:
|
|
57
|
-
dark:
|
|
55
|
+
light: "var(--ds-background-neutral-subtle-hovered, rgb(244, 245, 247))",
|
|
56
|
+
dark: "var(--ds-background-neutral-subtle-hovered, rgb(59, 71, 92))"
|
|
58
57
|
})(theme)};
|
|
59
58
|
}
|
|
60
59
|
> span:active[aria-disabled='false'] {
|
|
61
60
|
background-color: ${themed({
|
|
62
|
-
light:
|
|
63
|
-
dark:
|
|
61
|
+
light: "var(--ds-background-neutral-subtle-pressed, rgb(179, 212, 255))",
|
|
62
|
+
dark: "var(--ds-background-neutral-subtle-pressed, rgb(179, 212, 255))"
|
|
64
63
|
})(theme)};
|
|
65
64
|
}
|
|
66
65
|
> span[aria-disabled='true'] {
|
|
67
66
|
color: ${themed({
|
|
68
|
-
light:
|
|
69
|
-
dark:
|
|
67
|
+
light: `var(--ds-text-disabled, ${N70})`,
|
|
68
|
+
dark: `var(--ds-text-disabled, ${DN80})`
|
|
70
69
|
})(theme)};
|
|
71
70
|
}
|
|
72
71
|
:focus > span[aria-disabled='false'] {
|
|
@@ -244,6 +243,7 @@ function DropdownMenuItem({
|
|
|
244
243
|
}, jsx(CustomItem, {
|
|
245
244
|
item: item,
|
|
246
245
|
key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : String(item.content),
|
|
246
|
+
testId: `dropdown-item__${String(item.content)}`,
|
|
247
247
|
role: shouldUseDefaultRole ? 'button' : 'menuitem',
|
|
248
248
|
iconBefore: item.elemBefore,
|
|
249
249
|
iconAfter: item.elemAfter,
|
|
@@ -253,6 +253,7 @@ function DropdownMenuItem({
|
|
|
253
253
|
}),
|
|
254
254
|
"aria-label": item['aria-label'] || String(item.content),
|
|
255
255
|
"aria-pressed": shouldUseDefaultRole ? item.isActive : undefined,
|
|
256
|
+
"aria-keyshortcuts": item['aria-keyshortcuts'],
|
|
256
257
|
onMouseDown: e => {
|
|
257
258
|
e.preventDefault();
|
|
258
259
|
},
|
|
@@ -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
|
},
|