@atlaskit/editor-core 187.48.6 → 187.48.8
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 +13 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/package.json +7 -3
- package/dist/cjs/plugins/floating-toolbar/index.js +0 -386
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -73
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -26
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -16
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -9
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -16
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -25
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -5
- package/dist/cjs/plugins/floating-toolbar/ui/CheckboxModal.js +0 -83
- package/dist/cjs/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -22
- package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +0 -208
- package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +0 -205
- package/dist/cjs/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -32
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -120
- package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -179
- package/dist/cjs/plugins/floating-toolbar/ui/Input.js +0 -78
- package/dist/cjs/plugins/floating-toolbar/ui/ScrollButtons.js +0 -152
- package/dist/cjs/plugins/floating-toolbar/ui/Select.js +0 -74
- package/dist/cjs/plugins/floating-toolbar/ui/Separator.js +0 -9
- package/dist/cjs/plugins/floating-toolbar/ui/SimpleModal.js +0 -42
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +0 -427
- package/dist/cjs/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -25
- package/dist/cjs/plugins/floating-toolbar/ui/messages.js +0 -55
- package/dist/cjs/plugins/floating-toolbar/ui/styles.js +0 -79
- package/dist/cjs/plugins/floating-toolbar/utils.js +0 -22
- package/dist/es2019/plugins/floating-toolbar/index.js +0 -368
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -63
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -10
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -8
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -2
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -9
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -16
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -1
- package/dist/es2019/plugins/floating-toolbar/ui/CheckboxModal.js +0 -71
- package/dist/es2019/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -13
- package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +0 -180
- package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +0 -191
- package/dist/es2019/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -25
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -107
- package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -100
- package/dist/es2019/plugins/floating-toolbar/ui/Input.js +0 -52
- package/dist/es2019/plugins/floating-toolbar/ui/ScrollButtons.js +0 -137
- package/dist/es2019/plugins/floating-toolbar/ui/Select.js +0 -62
- package/dist/es2019/plugins/floating-toolbar/ui/Separator.js +0 -2
- package/dist/es2019/plugins/floating-toolbar/ui/SimpleModal.js +0 -35
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +0 -419
- package/dist/es2019/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -6
- package/dist/es2019/plugins/floating-toolbar/ui/messages.js +0 -48
- package/dist/es2019/plugins/floating-toolbar/ui/styles.js +0 -64
- package/dist/es2019/plugins/floating-toolbar/utils.js +0 -16
- package/dist/esm/plugins/floating-toolbar/index.js +0 -375
- package/dist/esm/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -64
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -18
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -8
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -2
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -9
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -17
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -1
- package/dist/esm/plugins/floating-toolbar/ui/CheckboxModal.js +0 -72
- package/dist/esm/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -14
- package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +0 -199
- package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +0 -197
- package/dist/esm/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -25
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -113
- package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -168
- package/dist/esm/plugins/floating-toolbar/ui/Input.js +0 -70
- package/dist/esm/plugins/floating-toolbar/ui/ScrollButtons.js +0 -141
- package/dist/esm/plugins/floating-toolbar/ui/Select.js +0 -64
- package/dist/esm/plugins/floating-toolbar/ui/Separator.js +0 -2
- package/dist/esm/plugins/floating-toolbar/ui/SimpleModal.js +0 -31
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +0 -417
- package/dist/esm/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -12
- package/dist/esm/plugins/floating-toolbar/ui/messages.js +0 -48
- package/dist/esm/plugins/floating-toolbar/ui/styles.js +0 -68
- package/dist/esm/plugins/floating-toolbar/utils.js +0 -16
- package/dist/types/plugins/floating-toolbar/index.d.ts +0 -13
- package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +0 -21
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -8
- package/dist/types/plugins/floating-toolbar/ui/CheckboxModal.d.ts +0 -4
- package/dist/types/plugins/floating-toolbar/ui/ConfirmationModal.d.ts +0 -6
- package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +0 -41
- package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +0 -29
- package/dist/types/plugins/floating-toolbar/ui/EditorEmojiAddIcon.d.ts +0 -2
- package/dist/types/plugins/floating-toolbar/ui/EmojiPickerButton.d.ts +0 -15
- package/dist/types/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +0 -16
- package/dist/types/plugins/floating-toolbar/ui/Input.d.ts +0 -23
- package/dist/types/plugins/floating-toolbar/ui/ScrollButtons.d.ts +0 -13
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +0 -21
- package/dist/types/plugins/floating-toolbar/ui/Separator.d.ts +0 -2
- package/dist/types/plugins/floating-toolbar/ui/SimpleModal.d.ts +0 -4
- package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +0 -44
- package/dist/types/plugins/floating-toolbar/ui/ToolbarLoader.d.ts +0 -4
- package/dist/types/plugins/floating-toolbar/ui/messages.d.ts +0 -48
- package/dist/types/plugins/floating-toolbar/ui/styles.d.ts +0 -20
- package/dist/types/plugins/floating-toolbar/utils.d.ts +0 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +0 -13
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +0 -21
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -8
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/CheckboxModal.d.ts +0 -4
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ConfirmationModal.d.ts +0 -6
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Dropdown.d.ts +0 -41
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/DropdownMenu.d.ts +0 -29
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/EditorEmojiAddIcon.d.ts +0 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/EmojiPickerButton.d.ts +0 -15
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +0 -16
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Input.d.ts +0 -23
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ScrollButtons.d.ts +0 -13
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Select.d.ts +0 -21
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Separator.d.ts +0 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/SimpleModal.d.ts +0 -4
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +0 -44
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ToolbarLoader.d.ts +0 -4
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/messages.d.ts +0 -48
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/styles.d.ts +0 -20
- package/dist/types-ts4.5/plugins/floating-toolbar/utils.d.ts +0 -2
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React, { useEffect, useState, useRef } from 'react';
|
|
3
|
-
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { N30 } from '@atlaskit/theme/colors';
|
|
5
|
-
import ChevronLeftLargeIcon from '@atlaskit/icon/glyph/chevron-left-large';
|
|
6
|
-
import ChevronRightLargeIcon from '@atlaskit/icon/glyph/chevron-right-large';
|
|
7
|
-
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
8
|
-
import messages from './messages';
|
|
9
|
-
import rafSchedule from 'raf-schd';
|
|
10
|
-
const toolbarScrollButtons = css`
|
|
11
|
-
display: grid;
|
|
12
|
-
grid-template-columns: 1fr 1fr;
|
|
13
|
-
grid-gap: ${"var(--ds-space-050, 4px)"};
|
|
14
|
-
padding: ${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"};
|
|
15
|
-
border-left: solid ${`var(--ds-border, ${N30})`} 1px;
|
|
16
|
-
flex-shrink: 0;
|
|
17
|
-
align-items: center;
|
|
18
|
-
`;
|
|
19
|
-
const LeftIcon = ChevronLeftLargeIcon;
|
|
20
|
-
const RightIcon = ChevronRightLargeIcon;
|
|
21
|
-
export const ScrollButtons = ({
|
|
22
|
-
intl,
|
|
23
|
-
scrollContainerRef,
|
|
24
|
-
node,
|
|
25
|
-
disabled
|
|
26
|
-
}) => {
|
|
27
|
-
const buttonsContainerRef = useRef(null);
|
|
28
|
-
const [needScroll, setNeedScroll] = useState(false);
|
|
29
|
-
const [canScrollLeft, setCanScrollLeft] = useState(true);
|
|
30
|
-
const [canScrollRight, setCanScrollRight] = useState(true);
|
|
31
|
-
const setCanScrollDebounced = rafSchedule(() => {
|
|
32
|
-
// Refs are null before mounting and after unmount
|
|
33
|
-
if (!scrollContainerRef.current) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const {
|
|
37
|
-
scrollLeft,
|
|
38
|
-
scrollWidth,
|
|
39
|
-
offsetWidth
|
|
40
|
-
} = scrollContainerRef.current;
|
|
41
|
-
setCanScrollLeft(scrollLeft > 0);
|
|
42
|
-
setCanScrollRight(scrollLeft + offsetWidth < scrollWidth - 1); // -1 to account for half pixel
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const onScroll = () => setCanScrollDebounced();
|
|
46
|
-
const scrollLeft = () => {
|
|
47
|
-
var _scrollContainerRef$c, _scrollContainerRef$c2, _scrollContainerRef$c3;
|
|
48
|
-
const {
|
|
49
|
-
width: scrollContainerWidth = 0
|
|
50
|
-
} = ((_scrollContainerRef$c = scrollContainerRef.current) === null || _scrollContainerRef$c === void 0 ? void 0 : _scrollContainerRef$c.getBoundingClientRect()) || {};
|
|
51
|
-
const scrollLeft = ((_scrollContainerRef$c2 = scrollContainerRef.current) === null || _scrollContainerRef$c2 === void 0 ? void 0 : _scrollContainerRef$c2.scrollLeft) || 0;
|
|
52
|
-
|
|
53
|
-
// scroll to current position - scroll container width
|
|
54
|
-
let scrollTo = scrollLeft - scrollContainerWidth;
|
|
55
|
-
(_scrollContainerRef$c3 = scrollContainerRef.current) === null || _scrollContainerRef$c3 === void 0 ? void 0 : _scrollContainerRef$c3.scrollTo({
|
|
56
|
-
top: 0,
|
|
57
|
-
left: scrollTo,
|
|
58
|
-
behavior: 'smooth'
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const scrollRight = () => {
|
|
62
|
-
var _scrollContainerRef$c4, _scrollContainerRef$c5, _scrollContainerRef$c6;
|
|
63
|
-
const {
|
|
64
|
-
width: scrollContainerWidth = 0
|
|
65
|
-
} = ((_scrollContainerRef$c4 = scrollContainerRef.current) === null || _scrollContainerRef$c4 === void 0 ? void 0 : _scrollContainerRef$c4.getBoundingClientRect()) || {};
|
|
66
|
-
const scrollLeft = ((_scrollContainerRef$c5 = scrollContainerRef.current) === null || _scrollContainerRef$c5 === void 0 ? void 0 : _scrollContainerRef$c5.scrollLeft) || 0;
|
|
67
|
-
|
|
68
|
-
// scroll to current position + scroll container width
|
|
69
|
-
let scrollTo = scrollLeft + scrollContainerWidth;
|
|
70
|
-
(_scrollContainerRef$c6 = scrollContainerRef.current) === null || _scrollContainerRef$c6 === void 0 ? void 0 : _scrollContainerRef$c6.scrollTo({
|
|
71
|
-
top: 0,
|
|
72
|
-
left: scrollTo,
|
|
73
|
-
behavior: 'smooth'
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
const resizeObserver = new ResizeObserver(t => {
|
|
77
|
-
var _scrollContainerRef$c7, _scrollContainerRef$c8, _scrollContainerRef$c9;
|
|
78
|
-
const widthNeededToShowAllItems = ((_scrollContainerRef$c7 = scrollContainerRef.current) === null || _scrollContainerRef$c7 === void 0 ? void 0 : _scrollContainerRef$c7.scrollWidth) || 0;
|
|
79
|
-
const availableSpace = (_scrollContainerRef$c8 = scrollContainerRef.current) === null || _scrollContainerRef$c8 === void 0 ? void 0 : (_scrollContainerRef$c9 = _scrollContainerRef$c8.parentNode) === null || _scrollContainerRef$c9 === void 0 ? void 0 : _scrollContainerRef$c9.offsetWidth;
|
|
80
|
-
if (availableSpace >= widthNeededToShowAllItems) {
|
|
81
|
-
setNeedScroll(false);
|
|
82
|
-
} else {
|
|
83
|
-
setNeedScroll(true);
|
|
84
|
-
onScroll();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
onScroll();
|
|
89
|
-
const scrollContainerRefCurrent = scrollContainerRef.current;
|
|
90
|
-
if (scrollContainerRefCurrent) {
|
|
91
|
-
// enable/disable scroll buttons depending on scroll position
|
|
92
|
-
scrollContainerRefCurrent.addEventListener('scroll', onScroll);
|
|
93
|
-
|
|
94
|
-
// watch for toolbar resize and show/hide scroll buttons if needed
|
|
95
|
-
resizeObserver.observe(scrollContainerRefCurrent);
|
|
96
|
-
}
|
|
97
|
-
return () => {
|
|
98
|
-
if (scrollContainerRefCurrent) {
|
|
99
|
-
scrollContainerRefCurrent.removeEventListener('scroll', onScroll);
|
|
100
|
-
resizeObserver.unobserve(scrollContainerRefCurrent);
|
|
101
|
-
}
|
|
102
|
-
setCanScrollDebounced.cancel();
|
|
103
|
-
};
|
|
104
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
|
-
}, []);
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
const scrollContainerRefCurrent = scrollContainerRef.current;
|
|
108
|
-
if (scrollContainerRefCurrent) {
|
|
109
|
-
var _scrollContainerRefCu;
|
|
110
|
-
// reset scroll position when switching from one node with toolbar to another
|
|
111
|
-
// scroll to made optional as it may not be rendered in testing env
|
|
112
|
-
(_scrollContainerRefCu = scrollContainerRefCurrent.scrollTo) === null || _scrollContainerRefCu === void 0 ? void 0 : _scrollContainerRefCu.call(scrollContainerRefCurrent, {
|
|
113
|
-
left: 0
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
117
|
-
}, [node.type]);
|
|
118
|
-
return needScroll ? jsx("div", {
|
|
119
|
-
ref: buttonsContainerRef,
|
|
120
|
-
css: toolbarScrollButtons,
|
|
121
|
-
className: "scroll-buttons"
|
|
122
|
-
}, jsx(Button, {
|
|
123
|
-
title: intl.formatMessage(messages.floatingToolbarScrollLeft),
|
|
124
|
-
icon: jsx(LeftIcon, {
|
|
125
|
-
label: intl.formatMessage(messages.floatingToolbarScrollLeft)
|
|
126
|
-
}),
|
|
127
|
-
onClick: scrollLeft,
|
|
128
|
-
disabled: !canScrollLeft || disabled
|
|
129
|
-
}), jsx(Button, {
|
|
130
|
-
title: intl.formatMessage(messages.floatingToolbarScrollRight),
|
|
131
|
-
icon: jsx(RightIcon, {
|
|
132
|
-
label: intl.formatMessage(messages.floatingToolbarScrollRight)
|
|
133
|
-
}),
|
|
134
|
-
onClick: scrollRight,
|
|
135
|
-
disabled: !canScrollRight || disabled
|
|
136
|
-
})) : null;
|
|
137
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import Select from '@atlaskit/select';
|
|
3
|
-
export default function Search(props) {
|
|
4
|
-
const selectRef = useRef(null);
|
|
5
|
-
const {
|
|
6
|
-
width = 200
|
|
7
|
-
} = props;
|
|
8
|
-
const style = React.useMemo(() => ({
|
|
9
|
-
container: base => ({
|
|
10
|
-
...base,
|
|
11
|
-
width
|
|
12
|
-
}),
|
|
13
|
-
menuPortal: base => {
|
|
14
|
-
var _selectRef$current, _selectRef$current$se, _selectRef$current$se2, _selectRef$current2, _selectRef$current2$s, _selectRef$current2$s2, _selectRef$current2$s3;
|
|
15
|
-
// ED:16095: We add two possible getter paths for safely reaching into the underlying
|
|
16
|
-
// react-select element. We first try a getter that conforms with react-select v5 APIs,
|
|
17
|
-
// Failing that, we try a getter consistent with react-select v4 APIs. (We
|
|
18
|
-
// handle both as consumers may control the time of the actual dependency version
|
|
19
|
-
// cutover).
|
|
20
|
-
const controlWrapper = (selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : (_selectRef$current$se = _selectRef$current.select) === null || _selectRef$current$se === void 0 ? void 0 : (_selectRef$current$se2 = _selectRef$current$se.controlRef) === null || _selectRef$current$se2 === void 0 ? void 0 : _selectRef$current$se2.parentNode) || (selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current2 = selectRef.current) === null || _selectRef$current2 === void 0 ? void 0 : (_selectRef$current2$s = _selectRef$current2.select) === null || _selectRef$current2$s === void 0 ? void 0 : (_selectRef$current2$s2 = _selectRef$current2$s.select) === null || _selectRef$current2$s2 === void 0 ? void 0 : (_selectRef$current2$s3 = _selectRef$current2$s2.controlRef) === null || _selectRef$current2$s3 === void 0 ? void 0 : _selectRef$current2$s3.parentNode);
|
|
21
|
-
const menuPortalStyles = controlWrapper && props.setDisableParentScroll ? {
|
|
22
|
-
// since the portal is now outside, we need to position it as before
|
|
23
|
-
top: controlWrapper.offsetTop,
|
|
24
|
-
left: controlWrapper.offsetLeft,
|
|
25
|
-
height: controlWrapper.offsetHeight,
|
|
26
|
-
width
|
|
27
|
-
} : {};
|
|
28
|
-
return {
|
|
29
|
-
...base,
|
|
30
|
-
...menuPortalStyles
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}),
|
|
34
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
-
[width]);
|
|
36
|
-
const onMenuOpen = () => {
|
|
37
|
-
if (props.setDisableParentScroll) {
|
|
38
|
-
props.setDisableParentScroll(true);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const onMenuClose = () => {
|
|
42
|
-
if (props.setDisableParentScroll) {
|
|
43
|
-
props.setDisableParentScroll(false);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
return /*#__PURE__*/React.createElement(Select, {
|
|
47
|
-
ref: selectRef,
|
|
48
|
-
options: props.options,
|
|
49
|
-
value: props.defaultValue,
|
|
50
|
-
onChange: props.onChange,
|
|
51
|
-
placeholder: props.placeholder,
|
|
52
|
-
spacing: "compact",
|
|
53
|
-
menuPlacement: "auto",
|
|
54
|
-
filterOption: props.filterOption,
|
|
55
|
-
styles: style,
|
|
56
|
-
menuPortalTarget: props.mountPoint,
|
|
57
|
-
onMenuOpen: onMenuOpen,
|
|
58
|
-
onMenuClose: onMenuClose,
|
|
59
|
-
"aria-label": props.ariaLabel,
|
|
60
|
-
classNamePrefix: props.classNamePrefix
|
|
61
|
-
});
|
|
62
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Button from '@atlaskit/button/standard-button';
|
|
3
|
-
import Modal, { ModalBody, ModalTitle, ModalHeader, ModalFooter } from '@atlaskit/modal-dialog';
|
|
4
|
-
import messages from './messages';
|
|
5
|
-
export const SimpleModal = props => {
|
|
6
|
-
const {
|
|
7
|
-
onConfirm,
|
|
8
|
-
onClose,
|
|
9
|
-
options,
|
|
10
|
-
intl: {
|
|
11
|
-
formatMessage
|
|
12
|
-
},
|
|
13
|
-
testId
|
|
14
|
-
} = props;
|
|
15
|
-
const heading = (options === null || options === void 0 ? void 0 : options.title) || formatMessage(messages.confirmModalDefaultHeading);
|
|
16
|
-
const okButtonLabel = (options === null || options === void 0 ? void 0 : options.okButtonLabel) || formatMessage(messages.confirmModalOK);
|
|
17
|
-
const cancelButtonLabel = (options === null || options === void 0 ? void 0 : options.cancelButtonLabel) || formatMessage(messages.confirmModalCancel);
|
|
18
|
-
return /*#__PURE__*/React.createElement(Modal, {
|
|
19
|
-
onClose: onClose,
|
|
20
|
-
testId: testId
|
|
21
|
-
}, /*#__PURE__*/React.createElement(ModalHeader, null, /*#__PURE__*/React.createElement(ModalTitle, {
|
|
22
|
-
appearance: "warning"
|
|
23
|
-
}, heading)), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement("p", null, options === null || options === void 0 ? void 0 : options.message)), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
24
|
-
appearance: "default",
|
|
25
|
-
onClick: onClose,
|
|
26
|
-
testId: testId ? `${testId}-cancel-button` : undefined
|
|
27
|
-
}, cancelButtonLabel), /*#__PURE__*/React.createElement(Button, {
|
|
28
|
-
appearance: "warning",
|
|
29
|
-
onClick: () => {
|
|
30
|
-
onConfirm();
|
|
31
|
-
onClose();
|
|
32
|
-
},
|
|
33
|
-
testId: testId ? `${testId}-confirm-button` : undefined
|
|
34
|
-
}, okButtonLabel)));
|
|
35
|
-
};
|
|
@@ -1,419 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
/** @jsx jsx */
|
|
4
|
-
import React, { Component } from 'react';
|
|
5
|
-
import { css, jsx } from '@emotion/react';
|
|
6
|
-
import ButtonGroup from '@atlaskit/button/button-group';
|
|
7
|
-
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
8
|
-
import { themed } from '@atlaskit/theme/components';
|
|
9
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
10
|
-
import { DN70 } from '@atlaskit/theme/colors';
|
|
11
|
-
import { showConfirmDialog } from '../pm-plugins/toolbar-data/commands';
|
|
12
|
-
import { FloatingToolbarButton as Button, Announcer } from '@atlaskit/editor-common/ui';
|
|
13
|
-
import Dropdown from './Dropdown';
|
|
14
|
-
import Select from './Select';
|
|
15
|
-
import Separator from './Separator';
|
|
16
|
-
import Input from './Input';
|
|
17
|
-
import { ExtensionsPlaceholder } from './ExtensionsPlaceholder';
|
|
18
|
-
import { areSameItems } from '@atlaskit/editor-common/floating-toolbar';
|
|
19
|
-
import { ColorPickerButton } from '@atlaskit/editor-common/ui-menu';
|
|
20
|
-
import { backgroundPaletteTooltipMessages } from '@atlaskit/editor-common/ui-color';
|
|
21
|
-
import { EmojiPickerButton } from './EmojiPickerButton';
|
|
22
|
-
import { injectIntl } from 'react-intl-next';
|
|
23
|
-
import messages from './messages';
|
|
24
|
-
import { clearHoverSelection } from '@atlaskit/editor-plugin-table/commands';
|
|
25
|
-
import { ScrollButtons } from './ScrollButtons';
|
|
26
|
-
import { ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
|
|
27
|
-
import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
|
|
28
|
-
const ToolbarItems = /*#__PURE__*/React.memo(({
|
|
29
|
-
items,
|
|
30
|
-
dispatchCommand,
|
|
31
|
-
popupsMountPoint,
|
|
32
|
-
popupsBoundariesElement,
|
|
33
|
-
editorView,
|
|
34
|
-
dispatchAnalyticsEvent,
|
|
35
|
-
popupsScrollableElement,
|
|
36
|
-
scrollable,
|
|
37
|
-
providerFactory,
|
|
38
|
-
extensionsProvider,
|
|
39
|
-
node,
|
|
40
|
-
setDisableScroll,
|
|
41
|
-
mountRef,
|
|
42
|
-
featureFlags,
|
|
43
|
-
api
|
|
44
|
-
}) => {
|
|
45
|
-
const emojiAndColourPickerMountPoint = scrollable ? popupsMountPoint || (editorView === null || editorView === void 0 ? void 0 : editorView.dom.closest('.fabric-editor-popup-scroll-parent')) || (editorView === null || editorView === void 0 ? void 0 : editorView.dom.closest('.ak-editor-content-area')) || undefined : popupsMountPoint;
|
|
46
|
-
return jsx(ButtonGroup, null, items.filter(item => !item.hidden).map((item, idx) => {
|
|
47
|
-
var _api$contextPanel, _api$extension;
|
|
48
|
-
switch (item.type) {
|
|
49
|
-
case 'button':
|
|
50
|
-
const ButtonIcon = item.icon;
|
|
51
|
-
const onClickHandler = () => {
|
|
52
|
-
if (item.confirmDialog) {
|
|
53
|
-
dispatchCommand(showConfirmDialog(idx));
|
|
54
|
-
} else {
|
|
55
|
-
dispatchCommand(item.onClick);
|
|
56
|
-
if (item.focusEditoronEnter && !(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
|
|
57
|
-
editorView === null || editorView === void 0 ? void 0 : editorView.focus();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
return jsx(Button, {
|
|
62
|
-
className: item.className,
|
|
63
|
-
key: idx,
|
|
64
|
-
title: item.title,
|
|
65
|
-
href: item.href,
|
|
66
|
-
icon: item.icon ? jsx(ButtonIcon, {
|
|
67
|
-
label: item.title
|
|
68
|
-
}) : undefined,
|
|
69
|
-
appearance: item.appearance,
|
|
70
|
-
target: item.target,
|
|
71
|
-
onClick: onClickHandler,
|
|
72
|
-
onMouseEnter: () => dispatchCommand(item.onMouseEnter),
|
|
73
|
-
onMouseLeave: () => dispatchCommand(item.onMouseLeave),
|
|
74
|
-
onFocus: () => dispatchCommand(item.onFocus),
|
|
75
|
-
onBlur: () => dispatchCommand(item.onBlur),
|
|
76
|
-
selected: item.selected,
|
|
77
|
-
disabled: item.disabled,
|
|
78
|
-
tooltipContent: item.tooltipContent,
|
|
79
|
-
testId: item.testId,
|
|
80
|
-
hideTooltipOnClick: item.hideTooltipOnClick,
|
|
81
|
-
ariaHasPopup: item.ariaHasPopup,
|
|
82
|
-
tabIndex: item.tabIndex
|
|
83
|
-
}, item.showTitle && item.title);
|
|
84
|
-
case 'input':
|
|
85
|
-
return jsx(Input, {
|
|
86
|
-
key: idx,
|
|
87
|
-
mountPoint: popupsMountPoint,
|
|
88
|
-
boundariesElement: popupsBoundariesElement,
|
|
89
|
-
defaultValue: item.defaultValue,
|
|
90
|
-
placeholder: item.placeholder,
|
|
91
|
-
onSubmit: value => dispatchCommand(item.onSubmit(value)),
|
|
92
|
-
onBlur: value => dispatchCommand(item.onBlur(value))
|
|
93
|
-
});
|
|
94
|
-
case 'custom':
|
|
95
|
-
{
|
|
96
|
-
return item.render(editorView, idx, dispatchAnalyticsEvent);
|
|
97
|
-
}
|
|
98
|
-
case 'dropdown':
|
|
99
|
-
const DropdownIcon = item.icon;
|
|
100
|
-
return jsx(Dropdown, {
|
|
101
|
-
key: idx,
|
|
102
|
-
title: item.title,
|
|
103
|
-
icon: DropdownIcon && jsx(DropdownIcon, {
|
|
104
|
-
label: item.title
|
|
105
|
-
}),
|
|
106
|
-
dispatchCommand: dispatchCommand,
|
|
107
|
-
options: item.options,
|
|
108
|
-
disabled: item.disabled,
|
|
109
|
-
tooltip: item.tooltip,
|
|
110
|
-
hideExpandIcon: item.hideExpandIcon,
|
|
111
|
-
mountPoint: popupsMountPoint,
|
|
112
|
-
boundariesElement: popupsBoundariesElement,
|
|
113
|
-
scrollableElement: popupsScrollableElement,
|
|
114
|
-
dropdownWidth: item.dropdownWidth,
|
|
115
|
-
showSelected: item.showSelected,
|
|
116
|
-
buttonTestId: item.testId,
|
|
117
|
-
editorView: editorView,
|
|
118
|
-
setDisableParentScroll: scrollable ? setDisableScroll : undefined,
|
|
119
|
-
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && `${item.id}-dropdownList`,
|
|
120
|
-
alignDropdownWithToolbar: items.length === 1
|
|
121
|
-
});
|
|
122
|
-
case 'select':
|
|
123
|
-
if (item.selectType === 'list') {
|
|
124
|
-
const ariaLabel = item.title || item.placeholder;
|
|
125
|
-
return jsx(Select, {
|
|
126
|
-
key: idx,
|
|
127
|
-
dispatchCommand: dispatchCommand,
|
|
128
|
-
options: item.options,
|
|
129
|
-
hideExpandIcon: item.hideExpandIcon,
|
|
130
|
-
mountPoint: scrollable ? mountRef.current : undefined,
|
|
131
|
-
boundariesElement: popupsBoundariesElement,
|
|
132
|
-
scrollableElement: popupsScrollableElement,
|
|
133
|
-
defaultValue: item.defaultValue,
|
|
134
|
-
placeholder: item.placeholder,
|
|
135
|
-
onChange: selected => dispatchCommand(item.onChange(selected)),
|
|
136
|
-
ariaLabel: ariaLabel,
|
|
137
|
-
filterOption: item.filterOption,
|
|
138
|
-
setDisableParentScroll: scrollable ? setDisableScroll : undefined,
|
|
139
|
-
classNamePrefix: 'floating-toolbar-select'
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
if (item.selectType === 'color') {
|
|
143
|
-
return jsx(ColorPickerButton, {
|
|
144
|
-
skipFocusButtonAfterPick: true,
|
|
145
|
-
key: idx,
|
|
146
|
-
title: item.title,
|
|
147
|
-
onChange: selected => {
|
|
148
|
-
dispatchCommand(item.onChange(selected));
|
|
149
|
-
},
|
|
150
|
-
colorPalette: item.options,
|
|
151
|
-
currentColor: item.defaultValue ? item.defaultValue.value : undefined,
|
|
152
|
-
placement: "Panels",
|
|
153
|
-
mountPoint: emojiAndColourPickerMountPoint,
|
|
154
|
-
setDisableParentScroll: scrollable ? setDisableScroll : undefined
|
|
155
|
-
// Currently in floating toolbar, color picker is only
|
|
156
|
-
// used in panel and table cell background color.
|
|
157
|
-
// Both uses same color palette.
|
|
158
|
-
// That's why hard-coding hexToEditorBackgroundPaletteColor
|
|
159
|
-
// and paletteColorTooltipMessages.
|
|
160
|
-
// When we need to support different color palette
|
|
161
|
-
// in floating toolbar, we need to set hexToPaletteColor
|
|
162
|
-
// and paletteColorTooltipMessages in item options.
|
|
163
|
-
,
|
|
164
|
-
hexToPaletteColor: hexToEditorBackgroundPaletteColor,
|
|
165
|
-
paletteColorTooltipMessages: backgroundPaletteTooltipMessages
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
if (item.selectType === 'emoji') {
|
|
169
|
-
return jsx(EmojiPickerButton, {
|
|
170
|
-
key: idx,
|
|
171
|
-
editorView: editorView,
|
|
172
|
-
title: item.title,
|
|
173
|
-
providerFactory: providerFactory,
|
|
174
|
-
isSelected: item.selected,
|
|
175
|
-
onChange: selected => dispatchCommand(item.onChange(selected)),
|
|
176
|
-
mountPoint: emojiAndColourPickerMountPoint,
|
|
177
|
-
setDisableParentScroll: scrollable ? setDisableScroll : undefined
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return null;
|
|
181
|
-
case 'extensions-placeholder':
|
|
182
|
-
if (!editorView || !extensionsProvider) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
const {
|
|
186
|
-
extendFloatingToolbar
|
|
187
|
-
} = featureFlags || {};
|
|
188
|
-
if (!extendFloatingToolbar) {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
return jsx(ExtensionsPlaceholder, {
|
|
192
|
-
key: idx,
|
|
193
|
-
node: node,
|
|
194
|
-
editorView: editorView,
|
|
195
|
-
extensionProvider: extensionsProvider,
|
|
196
|
-
separator: item.separator,
|
|
197
|
-
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange,
|
|
198
|
-
extensionApi: api === null || api === void 0 ? void 0 : (_api$extension = api.extension) === null || _api$extension === void 0 ? void 0 : _api$extension.actions.api()
|
|
199
|
-
});
|
|
200
|
-
case 'separator':
|
|
201
|
-
return jsx(Separator, {
|
|
202
|
-
key: idx
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}));
|
|
206
|
-
}, (prevProps, nextProps) => {
|
|
207
|
-
if (!nextProps.node) {
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
// only rerender toolbar items if the node is different
|
|
211
|
-
// otherwise it causes an issue where multiple popups stays open
|
|
212
|
-
return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !areSameItems(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
|
|
213
|
-
});
|
|
214
|
-
const toolbarContainer = (theme, scrollable, hasSelect, firstElementIsSelect) => css`
|
|
215
|
-
background-color: ${themed({
|
|
216
|
-
light: "var(--ds-surface-overlay, white)",
|
|
217
|
-
dark: `var(--ds-surface-overlay, ${DN70})`
|
|
218
|
-
})(theme)};
|
|
219
|
-
border-radius: ${borderRadius()}px;
|
|
220
|
-
box-shadow: ${`var(--ds-shadow-overlay, ${`0 0 1px rgba(9, 30, 66, 0.31), 0 4px 8px -2px rgba(9, 30, 66, 0.25)`})`};
|
|
221
|
-
display: flex;
|
|
222
|
-
line-height: 1;
|
|
223
|
-
box-sizing: border-box;
|
|
224
|
-
|
|
225
|
-
& > div > div {
|
|
226
|
-
align-items: center;
|
|
227
|
-
}
|
|
228
|
-
${scrollable ? css`
|
|
229
|
-
${hasSelect ? css`
|
|
230
|
-
height: 40px;
|
|
231
|
-
` : css`
|
|
232
|
-
height: 32px;
|
|
233
|
-
`}
|
|
234
|
-
overflow: hidden;
|
|
235
|
-
` : css`
|
|
236
|
-
padding: ${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"};
|
|
237
|
-
${firstElementIsSelect && css`
|
|
238
|
-
padding-left: ${"var(--ds-space-050, 4px)"};
|
|
239
|
-
`}
|
|
240
|
-
`}
|
|
241
|
-
`;
|
|
242
|
-
const toolbarOverflow = (scrollable, scrollDisabled, firstElementIsSelect) => css`
|
|
243
|
-
${scrollable ? css`
|
|
244
|
-
${scrollDisabled ? css`
|
|
245
|
-
overflow: hidden;
|
|
246
|
-
` : css`
|
|
247
|
-
overflow-x: auto;
|
|
248
|
-
overflow-y: hidden;
|
|
249
|
-
`}
|
|
250
|
-
-webkit-overflow-scrolling: touch;
|
|
251
|
-
padding: ${"var(--ds-space-050, 4px)"} 0 50px;
|
|
252
|
-
> div {
|
|
253
|
-
> div:first-child {
|
|
254
|
-
${firstElementIsSelect ? css`
|
|
255
|
-
margin-left: ${"var(--ds-space-050, 4px)"};
|
|
256
|
-
` : css`
|
|
257
|
-
margin-left: ${"var(--ds-space-100, 8px)"};
|
|
258
|
-
`}
|
|
259
|
-
}
|
|
260
|
-
> div:last-child {
|
|
261
|
-
margin-right: ${"var(--ds-space-100, 8px)"};
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
` : css`
|
|
265
|
-
display: flex;
|
|
266
|
-
`}
|
|
267
|
-
`;
|
|
268
|
-
class Toolbar extends Component {
|
|
269
|
-
constructor(props) {
|
|
270
|
-
super(props);
|
|
271
|
-
_defineProperty(this, "shouldHandleArrowKeys", () => {
|
|
272
|
-
var _this$props$items;
|
|
273
|
-
//To prevent the keydown handling of arrow keys for custom toolbar items with 'disableArrowNavigation' prop enabled,
|
|
274
|
-
//Usually the button which has menus or popups
|
|
275
|
-
return !((_this$props$items = this.props.items) !== null && _this$props$items !== void 0 && _this$props$items.find(item => item.type === 'custom' && item.disableArrowNavigation));
|
|
276
|
-
});
|
|
277
|
-
_defineProperty(this, "handleEscape", event => {
|
|
278
|
-
var _this$props$editorVie;
|
|
279
|
-
// If any menu is open inside the floating toolbar 'Esc' key should not
|
|
280
|
-
// focus the editorview.
|
|
281
|
-
// Event can't be stopped as they are not childnodes of floating toolbar
|
|
282
|
-
|
|
283
|
-
const isDropdownOpen = !!document.querySelector('[data-role="droplistContent"]');
|
|
284
|
-
const isSelectMenuOpen = !!document.querySelector('.floating-toolbar-select__menu');
|
|
285
|
-
if (isDropdownOpen || isSelectMenuOpen) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
(_this$props$editorVie = this.props.editorView) === null || _this$props$editorVie === void 0 ? void 0 : _this$props$editorVie.focus();
|
|
289
|
-
event.preventDefault();
|
|
290
|
-
event.stopPropagation();
|
|
291
|
-
});
|
|
292
|
-
this.scrollContainerRef = /*#__PURE__*/React.createRef();
|
|
293
|
-
this.mountRef = /*#__PURE__*/React.createRef();
|
|
294
|
-
this.toolbarContainerRef = /*#__PURE__*/React.createRef();
|
|
295
|
-
this.state = {
|
|
296
|
-
scrollDisabled: false,
|
|
297
|
-
mounted: false
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
// remove any decorations added by toolbar buttons i.e danger and selected styling
|
|
301
|
-
// this prevents https://product-fabric.atlassian.net/browse/ED-10207
|
|
302
|
-
resetStyling({
|
|
303
|
-
table
|
|
304
|
-
}) {
|
|
305
|
-
if (this.props.editorView) {
|
|
306
|
-
var _this$props$api;
|
|
307
|
-
const {
|
|
308
|
-
state,
|
|
309
|
-
dispatch
|
|
310
|
-
} = this.props.editorView;
|
|
311
|
-
if (table) {
|
|
312
|
-
return clearHoverSelection()(state, dispatch);
|
|
313
|
-
}
|
|
314
|
-
(_this$props$api = this.props.api) === null || _this$props$api === void 0 ? void 0 : _this$props$api.decorations.actions.removeDecoration(state, dispatch);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
setDisableScroll(disabled) {
|
|
318
|
-
// wait before setting disabled state incase users jumping from one popup to another
|
|
319
|
-
if (disabled) {
|
|
320
|
-
requestAnimationFrame(() => {
|
|
321
|
-
this.setState({
|
|
322
|
-
scrollDisabled: disabled
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
} else {
|
|
326
|
-
this.setState({
|
|
327
|
-
scrollDisabled: disabled
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
componentDidMount() {
|
|
332
|
-
this.setState({
|
|
333
|
-
mounted: true
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
componentDidUpdate(prevProps) {
|
|
337
|
-
var _this$props;
|
|
338
|
-
checkShouldForceFocusAndApply((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.editorView);
|
|
339
|
-
if (this.props.node !== prevProps.node) {
|
|
340
|
-
this.resetStyling({
|
|
341
|
-
table: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.node.type.name) === 'table'
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
componentWillUnmount() {
|
|
346
|
-
const {
|
|
347
|
-
editorView
|
|
348
|
-
} = this.props;
|
|
349
|
-
if (editorView) {
|
|
350
|
-
const {
|
|
351
|
-
state: {
|
|
352
|
-
tr
|
|
353
|
-
},
|
|
354
|
-
dispatch
|
|
355
|
-
} = editorView;
|
|
356
|
-
dispatch(forceFocusSelector(null)(tr));
|
|
357
|
-
}
|
|
358
|
-
this.resetStyling({
|
|
359
|
-
table: this.props.node.type.name === 'table'
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
render() {
|
|
363
|
-
const {
|
|
364
|
-
items,
|
|
365
|
-
className,
|
|
366
|
-
node,
|
|
367
|
-
intl,
|
|
368
|
-
scrollable
|
|
369
|
-
} = this.props;
|
|
370
|
-
if (!items || !items.length) {
|
|
371
|
-
return null;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// Select has left padding of 4px to the border, everything else 8px
|
|
375
|
-
const firstElementIsSelect = items[0].type === 'select';
|
|
376
|
-
const hasSelect = items.find(item => item.type === 'select' && item.selectType === 'list');
|
|
377
|
-
const isShortcutToFocusToolbar = event => {
|
|
378
|
-
//Alt + F10 to reach first element in this floating toolbar
|
|
379
|
-
return event.altKey && (event.key === 'F10' || event.keyCode === 121);
|
|
380
|
-
};
|
|
381
|
-
return jsx(React.Fragment, null, jsx(ToolbarArrowKeyNavigationProvider, {
|
|
382
|
-
editorView: this.props.editorView,
|
|
383
|
-
handleEscape: this.handleEscape,
|
|
384
|
-
disableArrowKeyNavigation: !this.shouldHandleArrowKeys(),
|
|
385
|
-
childComponentSelector: "[data-testid='editor-floating-toolbar']",
|
|
386
|
-
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
387
|
-
intl: intl
|
|
388
|
-
}, jsx("div", {
|
|
389
|
-
ref: this.toolbarContainerRef,
|
|
390
|
-
css: theme => [toolbarContainer({
|
|
391
|
-
theme
|
|
392
|
-
}, scrollable, hasSelect !== undefined, firstElementIsSelect)],
|
|
393
|
-
"aria-label": intl.formatMessage(messages.floatingToolbarAriaLabel),
|
|
394
|
-
role: "toolbar",
|
|
395
|
-
"data-testid": "editor-floating-toolbar",
|
|
396
|
-
className: className
|
|
397
|
-
}, jsx(Announcer, {
|
|
398
|
-
text: intl.formatMessage(messages.floatingToolbarAnnouncer),
|
|
399
|
-
delay: 250
|
|
400
|
-
}), jsx("div", {
|
|
401
|
-
"data-testid": "floating-toolbar-items",
|
|
402
|
-
ref: this.scrollContainerRef,
|
|
403
|
-
css: toolbarOverflow(scrollable, this.state.scrollDisabled, firstElementIsSelect)
|
|
404
|
-
}, jsx(ToolbarItems, _extends({}, this.props, {
|
|
405
|
-
setDisableScroll: this.setDisableScroll.bind(this),
|
|
406
|
-
mountRef: this.mountRef,
|
|
407
|
-
mounted: this.state.mounted,
|
|
408
|
-
featureFlags: this.props.featureFlags
|
|
409
|
-
}))), scrollable && jsx(ScrollButtons, {
|
|
410
|
-
intl: intl,
|
|
411
|
-
scrollContainerRef: this.scrollContainerRef,
|
|
412
|
-
node: node,
|
|
413
|
-
disabled: this.state.scrollDisabled
|
|
414
|
-
})), jsx("div", {
|
|
415
|
-
ref: this.mountRef
|
|
416
|
-
})));
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
export default injectIntl(Toolbar);
|