@atlaskit/editor-core 187.48.7 → 188.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.
Files changed (149) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/dist/cjs/index.js +3 -305
  3. package/dist/cjs/labs/next/presets/default.js +2 -2
  4. package/dist/cjs/plugins/index.js +0 -7
  5. package/dist/cjs/version-wrapper.js +1 -1
  6. package/dist/es2019/index.js +16 -45
  7. package/dist/es2019/labs/next/presets/default.js +1 -1
  8. package/dist/es2019/plugins/index.js +0 -1
  9. package/dist/es2019/version-wrapper.js +1 -1
  10. package/dist/esm/index.js +16 -45
  11. package/dist/esm/labs/next/presets/default.js +1 -1
  12. package/dist/esm/plugins/index.js +0 -1
  13. package/dist/esm/version-wrapper.js +1 -1
  14. package/dist/types/index.d.ts +19 -63
  15. package/dist/types/plugins/index.d.ts +0 -1
  16. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  17. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  18. package/dist/types-ts4.5/index.d.ts +19 -63
  19. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  20. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  21. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  22. package/package.json +4 -4
  23. package/report.api.md +8 -1116
  24. package/tmp/api-report-tmp.d.ts +8 -971
  25. package/dist/cjs/plugins/floating-toolbar/index.js +0 -386
  26. package/dist/cjs/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -73
  27. package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -26
  28. package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -16
  29. package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -9
  30. package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -16
  31. package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -25
  32. package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -5
  33. package/dist/cjs/plugins/floating-toolbar/ui/CheckboxModal.js +0 -83
  34. package/dist/cjs/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -22
  35. package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +0 -208
  36. package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +0 -205
  37. package/dist/cjs/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -32
  38. package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -120
  39. package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -179
  40. package/dist/cjs/plugins/floating-toolbar/ui/Input.js +0 -78
  41. package/dist/cjs/plugins/floating-toolbar/ui/ScrollButtons.js +0 -152
  42. package/dist/cjs/plugins/floating-toolbar/ui/Select.js +0 -74
  43. package/dist/cjs/plugins/floating-toolbar/ui/Separator.js +0 -9
  44. package/dist/cjs/plugins/floating-toolbar/ui/SimpleModal.js +0 -42
  45. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +0 -427
  46. package/dist/cjs/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -25
  47. package/dist/cjs/plugins/floating-toolbar/ui/messages.js +0 -55
  48. package/dist/cjs/plugins/floating-toolbar/ui/styles.js +0 -79
  49. package/dist/cjs/plugins/floating-toolbar/utils.js +0 -22
  50. package/dist/es2019/plugins/floating-toolbar/index.js +0 -368
  51. package/dist/es2019/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -63
  52. package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -10
  53. package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -8
  54. package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -2
  55. package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -9
  56. package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -16
  57. package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -1
  58. package/dist/es2019/plugins/floating-toolbar/ui/CheckboxModal.js +0 -71
  59. package/dist/es2019/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -13
  60. package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +0 -180
  61. package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +0 -191
  62. package/dist/es2019/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -25
  63. package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -107
  64. package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -100
  65. package/dist/es2019/plugins/floating-toolbar/ui/Input.js +0 -52
  66. package/dist/es2019/plugins/floating-toolbar/ui/ScrollButtons.js +0 -137
  67. package/dist/es2019/plugins/floating-toolbar/ui/Select.js +0 -62
  68. package/dist/es2019/plugins/floating-toolbar/ui/Separator.js +0 -2
  69. package/dist/es2019/plugins/floating-toolbar/ui/SimpleModal.js +0 -35
  70. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +0 -419
  71. package/dist/es2019/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -6
  72. package/dist/es2019/plugins/floating-toolbar/ui/messages.js +0 -48
  73. package/dist/es2019/plugins/floating-toolbar/ui/styles.js +0 -64
  74. package/dist/es2019/plugins/floating-toolbar/utils.js +0 -16
  75. package/dist/esm/plugins/floating-toolbar/index.js +0 -375
  76. package/dist/esm/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -64
  77. package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -18
  78. package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -8
  79. package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -2
  80. package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -9
  81. package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -17
  82. package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -1
  83. package/dist/esm/plugins/floating-toolbar/ui/CheckboxModal.js +0 -72
  84. package/dist/esm/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -14
  85. package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +0 -199
  86. package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +0 -197
  87. package/dist/esm/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -25
  88. package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -113
  89. package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -168
  90. package/dist/esm/plugins/floating-toolbar/ui/Input.js +0 -70
  91. package/dist/esm/plugins/floating-toolbar/ui/ScrollButtons.js +0 -141
  92. package/dist/esm/plugins/floating-toolbar/ui/Select.js +0 -64
  93. package/dist/esm/plugins/floating-toolbar/ui/Separator.js +0 -2
  94. package/dist/esm/plugins/floating-toolbar/ui/SimpleModal.js +0 -31
  95. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +0 -417
  96. package/dist/esm/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -12
  97. package/dist/esm/plugins/floating-toolbar/ui/messages.js +0 -48
  98. package/dist/esm/plugins/floating-toolbar/ui/styles.js +0 -68
  99. package/dist/esm/plugins/floating-toolbar/utils.js +0 -16
  100. package/dist/types/plugins/floating-toolbar/index.d.ts +0 -13
  101. package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +0 -21
  102. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +0 -3
  103. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -1
  104. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +0 -3
  105. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +0 -3
  106. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +0 -3
  107. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -8
  108. package/dist/types/plugins/floating-toolbar/ui/CheckboxModal.d.ts +0 -4
  109. package/dist/types/plugins/floating-toolbar/ui/ConfirmationModal.d.ts +0 -6
  110. package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +0 -41
  111. package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +0 -29
  112. package/dist/types/plugins/floating-toolbar/ui/EditorEmojiAddIcon.d.ts +0 -2
  113. package/dist/types/plugins/floating-toolbar/ui/EmojiPickerButton.d.ts +0 -15
  114. package/dist/types/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +0 -16
  115. package/dist/types/plugins/floating-toolbar/ui/Input.d.ts +0 -23
  116. package/dist/types/plugins/floating-toolbar/ui/ScrollButtons.d.ts +0 -13
  117. package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +0 -21
  118. package/dist/types/plugins/floating-toolbar/ui/Separator.d.ts +0 -2
  119. package/dist/types/plugins/floating-toolbar/ui/SimpleModal.d.ts +0 -4
  120. package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +0 -44
  121. package/dist/types/plugins/floating-toolbar/ui/ToolbarLoader.d.ts +0 -4
  122. package/dist/types/plugins/floating-toolbar/ui/messages.d.ts +0 -48
  123. package/dist/types/plugins/floating-toolbar/ui/styles.d.ts +0 -20
  124. package/dist/types/plugins/floating-toolbar/utils.d.ts +0 -2
  125. package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +0 -13
  126. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +0 -21
  127. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +0 -3
  128. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -1
  129. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +0 -3
  130. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +0 -3
  131. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +0 -3
  132. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -8
  133. package/dist/types-ts4.5/plugins/floating-toolbar/ui/CheckboxModal.d.ts +0 -4
  134. package/dist/types-ts4.5/plugins/floating-toolbar/ui/ConfirmationModal.d.ts +0 -6
  135. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Dropdown.d.ts +0 -41
  136. package/dist/types-ts4.5/plugins/floating-toolbar/ui/DropdownMenu.d.ts +0 -29
  137. package/dist/types-ts4.5/plugins/floating-toolbar/ui/EditorEmojiAddIcon.d.ts +0 -2
  138. package/dist/types-ts4.5/plugins/floating-toolbar/ui/EmojiPickerButton.d.ts +0 -15
  139. package/dist/types-ts4.5/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +0 -16
  140. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Input.d.ts +0 -23
  141. package/dist/types-ts4.5/plugins/floating-toolbar/ui/ScrollButtons.d.ts +0 -13
  142. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Select.d.ts +0 -21
  143. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Separator.d.ts +0 -2
  144. package/dist/types-ts4.5/plugins/floating-toolbar/ui/SimpleModal.d.ts +0 -4
  145. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +0 -44
  146. package/dist/types-ts4.5/plugins/floating-toolbar/ui/ToolbarLoader.d.ts +0 -4
  147. package/dist/types-ts4.5/plugins/floating-toolbar/ui/messages.d.ts +0 -48
  148. package/dist/types-ts4.5/plugins/floating-toolbar/ui/styles.d.ts +0 -20
  149. package/dist/types-ts4.5/plugins/floating-toolbar/utils.d.ts +0 -2
@@ -1,180 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /** @jsx jsx */
3
-
4
- import React, { Component } from 'react';
5
- import { css, jsx } from '@emotion/react';
6
- import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
7
- import { ArrowKeyNavigationType, DropdownContainer as UiDropdown } from '@atlaskit/editor-common/ui-menu';
8
- import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
9
- import DropdownMenu, { itemSpacing, menuItemDimensions } from './DropdownMenu';
10
- const dropdownExpandContainer = css`
11
- margin: 0px ${"var(--ds-space-negative-050, -4px)"};
12
- `;
13
- const iconGroup = css`
14
- display: flex;
15
- `;
16
- const CompositeIcon = ({
17
- icon
18
- }) => jsx("div", {
19
- css: iconGroup
20
- }, icon, jsx("span", {
21
- css: dropdownExpandContainer
22
- }, jsx(ExpandIcon, {
23
- label: "Expand dropdown menu"
24
- })));
25
- export default class Dropdown extends Component {
26
- constructor(...args) {
27
- super(...args);
28
- _defineProperty(this, "state", {
29
- isOpen: false,
30
- isOpenedByKeyboard: false
31
- });
32
- _defineProperty(this, "triggerRef", /*#__PURE__*/React.createRef());
33
- _defineProperty(this, "renderArrayOptions", options => {
34
- const {
35
- showSelected,
36
- dispatchCommand,
37
- editorView
38
- } = this.props;
39
- return jsx(DropdownMenu, {
40
- hide: this.hide,
41
- dispatchCommand: dispatchCommand,
42
- items: options,
43
- showSelected: showSelected,
44
- editorView: editorView
45
- });
46
- });
47
- _defineProperty(this, "toggleOpen", () => {
48
- this.setState({
49
- isOpen: !this.state.isOpen,
50
- isOpenedByKeyboard: false
51
- });
52
- });
53
- _defineProperty(this, "toggleOpenByKeyboard", event => {
54
- if (event.key === 'Enter' || event.key === ' ') {
55
- event.preventDefault();
56
- this.setState({
57
- isOpen: !this.state.isOpen,
58
- isOpenedByKeyboard: true
59
- });
60
- }
61
- });
62
- _defineProperty(this, "hide", () => {
63
- this.setState({
64
- ...this.state,
65
- isOpen: false
66
- });
67
- });
68
- _defineProperty(this, "hideOnEsc", () => {
69
- var _document$querySelect;
70
- // Focus the trigger button only on Escape
71
- // Focus is done before hiding to ensure onBlur is called
72
- (_document$querySelect = document.querySelector(`[data-testid=${this.props.buttonTestId}]`)) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.focus();
73
- this.hide();
74
- });
75
- _defineProperty(this, "onOpenChanged", openChangedEvent => {
76
- if (!openChangedEvent.isOpen && openChangedEvent.event instanceof KeyboardEvent) {
77
- var _openChangedEvent$eve;
78
- ((_openChangedEvent$eve = openChangedEvent.event) === null || _openChangedEvent$eve === void 0 ? void 0 : _openChangedEvent$eve.key) === 'Escape' ? this.hideOnEsc() : this.hide();
79
- }
80
- });
81
- }
82
- render() {
83
- const {
84
- isOpen
85
- } = this.state;
86
- const {
87
- title,
88
- icon,
89
- options,
90
- dispatchCommand,
91
- mountPoint,
92
- boundariesElement,
93
- scrollableElement,
94
- hideExpandIcon,
95
- disabled,
96
- tooltip,
97
- buttonTestId,
98
- dropdownWidth,
99
- dropdownListId,
100
- alignDropdownWithToolbar
101
- } = this.props;
102
- let trigger;
103
- if (icon) {
104
- const TriggerIcon = hideExpandIcon ? icon : jsx(CompositeIcon, {
105
- icon: icon
106
- });
107
- trigger = jsx(Button, {
108
- testId: buttonTestId,
109
- title: title,
110
- icon: TriggerIcon,
111
- onClick: this.toggleOpen,
112
- onKeyDown: this.toggleOpenByKeyboard,
113
- selected: isOpen,
114
- disabled: disabled,
115
- tooltipContent: tooltip
116
- });
117
- } else {
118
- trigger = jsx(Button, {
119
- testId: buttonTestId,
120
- iconAfter: jsx("span", {
121
- css: dropdownExpandContainer
122
- }, jsx(ExpandIcon, {
123
- label: "Expand dropdown menu"
124
- })),
125
- onClick: this.toggleOpen,
126
- onKeyDown: this.toggleOpenByKeyboard,
127
- selected: isOpen,
128
- disabled: disabled,
129
- tooltipContent: tooltip,
130
- ariaHasPopup: true,
131
- areaControls: dropdownListId
132
- }, title);
133
- }
134
-
135
- /**
136
- * We want to change direction of our dropdowns a bit early,
137
- * not exactly when it hits the boundary.
138
- */
139
- const fitTolerance = 10;
140
- const fitWidth = Array.isArray(options) ? dropdownWidth || menuItemDimensions.width : options.width;
141
- const fitHeight = Array.isArray(options) ? options.length * menuItemDimensions.height + itemSpacing * 2 : options.height;
142
- return jsx(UiDropdown, {
143
- mountTo: mountPoint,
144
- boundariesElement: boundariesElement,
145
- scrollableElement: scrollableElement,
146
- isOpen: isOpen,
147
- handleClickOutside: this.hide,
148
- handleEscapeKeydown: this.hideOnEsc,
149
- onOpenChange: this.onOpenChanged,
150
- fitWidth: fitWidth + fitTolerance,
151
- fitHeight: fitHeight + fitTolerance,
152
- trigger: trigger,
153
- dropdownListId: dropdownListId,
154
- alignDropdownWithParentElement: alignDropdownWithToolbar,
155
- arrowKeyNavigationProviderOptions: {
156
- type: ArrowKeyNavigationType.MENU
157
- }
158
- }, Array.isArray(options) ? this.renderArrayOptions(options) : options.render({
159
- hide: this.hide,
160
- dispatchCommand
161
- }));
162
- }
163
- componentDidUpdate(prevProps, prevState) {
164
- if (prevState.isOpen !== this.state.isOpen) {
165
- if (this.props.setDisableParentScroll) {
166
- this.props.setDisableParentScroll(this.state.isOpen);
167
- }
168
- if (this.state.isOpen && this.state.isOpenedByKeyboard) {
169
- const dropList = document.querySelector('[data-role="droplistContent"]');
170
- if (dropList) {
171
- const keyboardEvent = new KeyboardEvent('keydown', {
172
- bubbles: true,
173
- key: 'ArrowDown'
174
- });
175
- dropList.dispatchEvent(keyboardEvent);
176
- }
177
- }
178
- }
179
- }
180
- }
@@ -1,191 +0,0 @@
1
- /** @jsx jsx */
2
- import { useState, useCallback, useEffect, createRef } from 'react';
3
- import { css, jsx } from '@emotion/react';
4
- import { Component } from 'react';
5
- // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
6
- import { gridSize } from '@atlaskit/theme/constants';
7
- import { B400 } from '@atlaskit/theme/colors';
8
- import { ButtonItem } from '@atlaskit/menu';
9
- import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
10
- import Tooltip from '@atlaskit/tooltip';
11
- import { injectIntl } from 'react-intl-next';
12
- import messages from './messages';
13
- export const menuItemDimensions = {
14
- width: 175,
15
- height: 32
16
- };
17
- const spacer = css`
18
- display: flex;
19
- flex: 1;
20
- padding: ${"var(--ds-space-100, 8px)"};
21
- `;
22
- const menuContainer = css`
23
- min-width: ${menuItemDimensions.width}px;
24
-
25
- // temporary solution to retain spacing defined by @atlaskit/Item
26
- & button {
27
- min-height: ${"var(--ds-space-400, 32px)"};
28
- padding: ${"var(--ds-space-100, 8px)"} ${"var(--ds-space-100, 8px)"} 7px;
29
-
30
- & > [data-item-elem-before] {
31
- margin-right: ${"var(--ds-space-050, 4px)"};
32
- }
33
- }
34
- `;
35
- const label = css`
36
- display: inline-block;
37
- width: 100%;
38
- `;
39
-
40
- // TODO: Migrate away from gridSize
41
- // Recommendation: Replace with 4 as itemSpacing is used in calculations expecting a number
42
- export const itemSpacing = gridSize() / 2;
43
-
44
- // Extend the ButtonItem component type to allow mouse events to be accepted from the Typescript check
45
-
46
- const DropdownButtonItem = ButtonItem;
47
- const DropdownMenuItem = ({
48
- item,
49
- hide,
50
- dispatchCommand,
51
- editorView,
52
- iconBefore
53
- }) => {
54
- const [tooltipContent, setTooltipContent] = useState(item.tooltip || '');
55
- const handleItemMouseOut = useCallback(() => {
56
- setTooltipContent('');
57
- if (item.onMouseOut) {
58
- dispatchCommand(item.onMouseOut);
59
- }
60
- }, [item.onMouseOut, dispatchCommand]);
61
- const handleItemMouseDown = useCallback(e => {
62
- e.preventDefault(); // ED-16204 - This is needed for safari to get handleItemClick() to work
63
- if (item.onMouseDown) {
64
- dispatchCommand(item.onMouseDown);
65
- }
66
- }, [item.onMouseDown, dispatchCommand]);
67
- const handleItemMouseOver = useCallback(() => {
68
- setTooltipContent(item.tooltip || '');
69
- if (item.onMouseOver) {
70
- dispatchCommand(item.onMouseOver);
71
- }
72
- }, [item.tooltip, item.onMouseOver, dispatchCommand]);
73
- const handleItemMouseEnter = useCallback(e => {
74
- if (item.onMouseEnter) {
75
- e.preventDefault();
76
- dispatchCommand(item.onMouseEnter);
77
- }
78
- }, [item.onMouseEnter, dispatchCommand]);
79
- const handleItemMouseLeave = useCallback(e => {
80
- if (item.onMouseLeave) {
81
- e.preventDefault();
82
- dispatchCommand(item.onMouseLeave);
83
- }
84
- }, [item.onMouseLeave, dispatchCommand]);
85
- const handleItemOnFocus = useCallback(e => {
86
- if (item.onFocus) {
87
- e.preventDefault();
88
- dispatchCommand(item.onFocus);
89
- }
90
- }, [item.onFocus, dispatchCommand]);
91
- const handleItemOnBlur = useCallback(e => {
92
- if (item.onBlur) {
93
- e.preventDefault();
94
- dispatchCommand(item.onBlur);
95
- }
96
- }, [item.onBlur, dispatchCommand]);
97
- const handleItemClick = useCallback(() => {
98
- /**
99
- * The order of dispatching the event and hide() is important, because
100
- * the ClickAreaBlock will be relying on the element to calculate the
101
- * click coordinate.
102
- * For more details, please visit the comment in this PR https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/5328/edm-1321-set-selection-near-smart-link?link_source=email#chg-packages/editor/editor-core/src/plugins/floating-toolbar/ui/DropdownMenu.tsx
103
- */
104
- dispatchCommand(item.onClick);
105
- hide();
106
- if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
107
- editorView === null || editorView === void 0 ? void 0 : editorView.focus();
108
- }
109
- }, [dispatchCommand, item.onClick, hide, editorView]);
110
-
111
- /* ED-16704 - Native mouse event handler to overcome firefox issue on disabled <button> - https://github.com/whatwg/html/issues/5886 */
112
- const labelRef = /*#__PURE__*/createRef();
113
- const handleTitleWrapperMouseEvent = useCallback(e => {
114
- if (item.disabled) {
115
- e.stopPropagation();
116
- e.preventDefault();
117
- }
118
- }, [item.disabled]);
119
- useEffect(() => {
120
- const labelRefCurrent = labelRef.current;
121
- labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.addEventListener('click', handleTitleWrapperMouseEvent);
122
- labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.addEventListener('mousedown', handleTitleWrapperMouseEvent);
123
- return () => {
124
- labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.removeEventListener('click', handleTitleWrapperMouseEvent);
125
- labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.removeEventListener('mousedown', handleTitleWrapperMouseEvent);
126
- };
127
- });
128
- const itemContent = jsx(DropdownButtonItem, {
129
- iconBefore: iconBefore,
130
- iconAfter: item.elemAfter,
131
- onClick: handleItemClick,
132
- "data-testid": item.testId,
133
- isDisabled: item.disabled,
134
- onMouseDown: handleItemMouseDown,
135
- onMouseOver: handleItemMouseOver,
136
- onMouseEnter: handleItemMouseEnter,
137
- onMouseLeave: handleItemMouseLeave,
138
- onMouseOut: handleItemMouseOut,
139
- onFocus: handleItemOnFocus,
140
- onBlur: handleItemOnBlur
141
- }, jsx("span", {
142
- ref: labelRef,
143
- css: label
144
- }, item.title));
145
- if (tooltipContent) {
146
- return jsx(Tooltip, {
147
- content: tooltipContent
148
- }, itemContent);
149
- }
150
- return itemContent;
151
- };
152
- class Dropdown extends Component {
153
- render() {
154
- const {
155
- hide,
156
- dispatchCommand,
157
- items,
158
- intl,
159
- editorView
160
- } = this.props;
161
- return jsx("div", {
162
- css: menuContainer
163
- }, items.filter(item => !item.hidden).map((item, idx) => jsx(DropdownMenuItem, {
164
- key: idx,
165
- item: item,
166
- hide: hide,
167
- dispatchCommand: dispatchCommand,
168
- editorView: editorView,
169
- iconBefore: this.renderSelected(item, intl)
170
- })));
171
- }
172
- renderSelected(item, intl) {
173
- const {
174
- showSelected = true
175
- } = this.props;
176
- const {
177
- selected
178
- } = item;
179
- if (showSelected && selected) {
180
- return jsx(EditorDoneIcon, {
181
- primaryColor: `var(--ds-icon-selected, ${B400})`,
182
- size: "small",
183
- label: intl.formatMessage(messages.confirmModalOK)
184
- });
185
- }
186
- return jsx("span", {
187
- css: spacer
188
- });
189
- }
190
- }
191
- export default injectIntl(Dropdown);
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- export default function EditorEmojiAddIcon() {
3
- return /*#__PURE__*/React.createElement("svg", {
4
- width: 24,
5
- height: 24,
6
- viewBox: "0 0 24 24",
7
- fill: "none",
8
- "aria-label": "editor-add-emoji"
9
- }, /*#__PURE__*/React.createElement("rect", {
10
- width: 24,
11
- height: 24,
12
- fill: "var(--ds-background-neutral-subtle, white)",
13
- fillOpacity: "0.01"
14
- }), /*#__PURE__*/React.createElement("path", {
15
- fillRule: "evenodd",
16
- clipRule: "evenodd",
17
- d: "M14.5715 6.20367C13.7531 5.88041 12.8807 5.71423 12 5.71423C10.1435 5.71423 8.36301 6.45173 7.05025 7.76449C5.7375 9.07724 5 10.8577 5 12.7142C5 14.5708 5.7375 16.3512 7.05025 17.664C8.36301 18.9767 10.1435 19.7142 12 19.7142C12.9193 19.7142 13.8295 19.5332 14.6788 19.1814C15.5281 18.8296 16.2997 18.314 16.9497 17.664C17.5998 17.014 18.1154 16.2423 18.4672 15.393C18.8189 14.5437 19 13.6335 19 12.7142C19 12.1349 18.9281 11.5591 18.7868 10.9999H17.2266C17.404 11.5396 17.5 12.1159 17.5 12.7142C17.5 15.7472 15.033 18.2142 12 18.2142C8.967 18.2142 6.5 15.7472 6.5 12.7142C6.50159 11.256 7.08156 9.85801 8.11267 8.8269C9.14377 7.79579 10.5418 7.21582 12 7.21423C12.9284 7.21423 13.8037 7.44537 14.5715 7.85312V6.20367ZM9.79289 11.9213C9.98043 12.1089 10.2348 12.2142 10.5 12.2142C10.7652 12.2142 11.0196 12.1089 11.2071 11.9213C11.3946 11.7338 11.5 11.4795 11.5 11.2142C11.5 10.949 11.3946 10.6947 11.2071 10.5071C11.0196 10.3196 10.7652 10.2142 10.5 10.2142C10.2348 10.2142 9.98043 10.3196 9.79289 10.5071C9.60536 10.6947 9.5 10.949 9.5 11.2142C9.5 11.4795 9.60536 11.7338 9.79289 11.9213ZM12.7929 11.9213C12.9804 12.1089 13.2348 12.2142 13.5 12.2142C13.7652 12.2142 14.0196 12.1089 14.2071 11.9213C14.3946 11.7338 14.5 11.4795 14.5 11.2142C14.5 10.949 14.3946 10.6947 14.2071 10.5071C14.0196 10.3196 13.7652 10.2142 13.5 10.2142C13.2348 10.2142 12.9804 10.3196 12.7929 10.5071C12.6054 10.6947 12.5 10.949 12.5 11.2142C12.5 11.4795 12.6054 11.7338 12.7929 11.9213ZM14.1965 13.61C14.0355 13.6153 13.8828 13.6823 13.77 13.7972C12.871 14.8032 11.133 14.8032 10.232 13.8002C10.1205 13.6799 9.96614 13.6082 9.80223 13.6006C9.63832 13.5931 9.47801 13.6503 9.35592 13.7599C9.23383 13.8695 9.15974 14.0227 9.14965 14.1865C9.13956 14.3503 9.19428 14.5115 9.302 14.6352C9.64217 15.0139 10.0582 15.3167 10.523 15.5241C10.9878 15.7316 11.491 15.8389 12 15.8392C12.51 15.839 13.0142 15.7313 13.4797 15.5231C13.9453 15.315 14.3617 15.0111 14.702 14.6312C14.8037 14.5064 14.8535 14.3472 14.8409 14.1866C14.8282 14.0261 14.7542 13.8766 14.6342 13.7692C14.5142 13.6618 14.3574 13.6048 14.1965 13.61Z",
18
- fill: "currentColor"
19
- }), /*#__PURE__*/React.createElement("path", {
20
- fillRule: "evenodd",
21
- clipRule: "evenodd",
22
- d: "M16.2856 8.31714H17.0228V9.05429C17.0228 9.28161 17.1131 9.49963 17.2738 9.66038C17.4345 9.82112 17.6526 9.91143 17.8799 9.91143C18.1072 9.91143 18.3252 9.82112 18.486 9.66038C18.6467 9.49963 18.737 9.28161 18.737 9.05429V8.31714H19.4828C19.7101 8.31714 19.9281 8.22684 20.0888 8.06609C20.2496 7.90535 20.3399 7.68733 20.3399 7.46C20.3399 7.23267 20.2496 7.01465 20.0888 6.85391C19.9281 6.69316 19.7101 6.60286 19.4828 6.60286H18.737V5.85714C18.737 5.62981 18.6467 5.4118 18.486 5.25105C18.3252 5.09031 18.1072 5 17.8799 5C17.6526 5 17.4345 5.09031 17.2738 5.25105C17.1131 5.4118 17.0228 5.62981 17.0228 5.85714V6.60286H16.2856C16.0583 6.60286 15.8403 6.69316 15.6795 6.85391C15.5188 7.01465 15.4285 7.23267 15.4285 7.46C15.4285 7.68733 15.5188 7.90535 15.6795 8.06609C15.8403 8.22684 16.0583 8.31714 16.2856 8.31714Z",
23
- fill: "currentColor"
24
- }));
25
- }
@@ -1,107 +0,0 @@
1
- /** @jsx jsx */
2
- import { css, jsx } from '@emotion/react';
3
- import React from 'react';
4
- import Button from '@atlaskit/button';
5
- import { WithProviders } from '@atlaskit/editor-common/provider-factory';
6
- import { Popup } from '@atlaskit/editor-common/ui';
7
- import { EmojiPicker } from '@atlaskit/emoji';
8
- import Tooltip from '@atlaskit/tooltip';
9
- import EditorEmojiAddIcon from './EditorEmojiAddIcon';
10
- import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
11
-
12
- // helps adjusts position of popup
13
- const emojiPickerButtonWrapper = css`
14
- position: relative;
15
- `;
16
- const EmojiPickerWithListener = withReactEditorViewOuterListeners(EmojiPicker);
17
- export const EmojiPickerButton = props => {
18
- const buttonRef = React.useRef(null);
19
- const [isPopupOpen, setIsPopupOpen] = React.useState(false);
20
- React.useEffect(() => {
21
- if (props.setDisableParentScroll) {
22
- props.setDisableParentScroll(isPopupOpen);
23
- }
24
- // eslint-disable-next-line react-hooks/exhaustive-deps
25
- }, [isPopupOpen]);
26
- const togglePopup = () => {
27
- setIsPopupOpen(!isPopupOpen);
28
- };
29
- const updateEmoji = emoji => {
30
- setIsPopupOpen(false);
31
- props.onChange && props.onChange(emoji);
32
- requestAnimationFrame(() => {
33
- var _props$editorView;
34
- (_props$editorView = props.editorView) === null || _props$editorView === void 0 ? void 0 : _props$editorView.focus();
35
- });
36
- };
37
- const isDetachedElement = el => !document.body.contains(el);
38
- const handleEmojiClickOutside = e => {
39
- // Ignore click events for detached elements.
40
- // Workaround for CETI-240 - where two onClicks fire - one when the upload button is
41
- // still in the document, and one once it's detached. Does not always occur, and
42
- // may be a side effect of a react render optimisation
43
- if (e && e.target && !isDetachedElement(e.target)) {
44
- togglePopup();
45
- }
46
- };
47
- const handleEmojiPressEscape = () => {
48
- var _buttonRef$current;
49
- setIsPopupOpen(false);
50
- (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
51
- };
52
- const renderPicker = providers => {
53
- if (!providers.emojiProvider) {
54
- return null;
55
- }
56
- return jsx(EmojiPickerWithListener, {
57
- emojiProvider: providers.emojiProvider,
58
- onSelection: updateEmoji,
59
- onPickerRef: () => {},
60
- handleClickOutside: handleEmojiClickOutside,
61
- handleEscapeKeydown: handleEmojiPressEscape
62
- });
63
- };
64
- const renderPopup = () => {
65
- if (!buttonRef.current || !isPopupOpen) {
66
- return;
67
- }
68
- return jsx(Popup, {
69
- target: buttonRef.current,
70
- mountTo: props.setDisableParentScroll ? props.mountPoint : buttonRef.current.parentElement,
71
- fitHeight: 350,
72
- fitWidth: 350,
73
- offset: [0, 10]
74
- // Confluence inline comment editor has z-index: 500
75
- // if the toolbar is scrollable, this will be mounted in the root editor
76
- // we need an index of > 500 to display over it
77
- ,
78
- zIndex: props.setDisableParentScroll ? 600 : undefined,
79
- focusTrap: true
80
- }, jsx(WithProviders, {
81
- providers: ['emojiProvider'],
82
- providerFactory: props.providerFactory,
83
- renderNode: renderPicker
84
- }));
85
- };
86
- const title = props.title || '';
87
- return jsx("div", {
88
- css: emojiPickerButtonWrapper
89
- }, jsx(Tooltip, {
90
- content: title,
91
- position: "top"
92
- }, jsx(Button, {
93
- appearance: 'subtle',
94
- key: props.idx,
95
- style: {
96
- padding: 0,
97
- margin: 0,
98
- display: 'flex',
99
- height: '24px',
100
- width: '24px'
101
- },
102
- onClick: togglePopup,
103
- ref: buttonRef,
104
- isSelected: props.isSelected,
105
- iconBefore: jsx(EditorEmojiAddIcon, null)
106
- })), renderPopup());
107
- };
@@ -1,100 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import Loadable from 'react-loadable';
3
- import { getContextualToolbarItemsFromModule } from '@atlaskit/editor-common/extensions';
4
- import ButtonGroup from '@atlaskit/button/button-group';
5
- import { nodeToJSON } from '@atlaskit/editor-common/utils';
6
- import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
7
- import Separator from './Separator';
8
- const noop = () => null;
9
- const isDefaultExport = mod => {
10
- return mod.hasOwnProperty('default');
11
- };
12
- const resolveExtensionIcon = async getIcon => {
13
- if (!getIcon) {
14
- return noop;
15
- }
16
- const maybeIcon = await getIcon();
17
- return isDefaultExport(maybeIcon) ? maybeIcon.default : maybeIcon;
18
- };
19
- const ExtensionButton = props => {
20
- const {
21
- item,
22
- node,
23
- extensionApi
24
- } = props;
25
- const ButtonIcon = React.useMemo(() => item.icon ? Loadable({
26
- loader: async () => resolveExtensionIcon(item.icon),
27
- loading: noop
28
- }) : undefined, [item.icon]);
29
- const onClick = () => {
30
- if (typeof item.action !== 'function') {
31
- throw new Error(`'action' of context toolbar item '${item.key}' is not a function`);
32
- }
33
- const targetNodeAdf = nodeToJSON(node);
34
- item.action(targetNodeAdf, extensionApi);
35
- };
36
- return /*#__PURE__*/React.createElement(Button, {
37
- title: item.label,
38
- ariaLabel: item.tooltip,
39
- icon: ButtonIcon ? /*#__PURE__*/React.createElement(ButtonIcon, {
40
- label: item.label || ''
41
- }) : undefined,
42
- onClick: onClick,
43
- tooltipContent: item.tooltip,
44
- disabled: item.disabled
45
- }, item.label);
46
- };
47
- export const ExtensionsPlaceholder = props => {
48
- const {
49
- node,
50
- editorView,
51
- extensionProvider,
52
- separator,
53
- applyChangeToContextPanel,
54
- extensionApi
55
- } = props;
56
- const [extensions, setExtensions] = useState([]);
57
- useEffect(() => {
58
- getExtensions();
59
- async function getExtensions() {
60
- const provider = await extensionProvider;
61
- if (provider) {
62
- setExtensions(await provider.getExtensions());
63
- }
64
- }
65
- // leaving dependencies array empty so that this effect runs just once on component mount
66
- // eslint-disable-next-line react-hooks/exhaustive-deps
67
- }, []);
68
- const nodeAdf = React.useMemo(() => nodeToJSON(node), [node]);
69
- const extensionItems = React.useMemo(() => {
70
- return getContextualToolbarItemsFromModule(extensions, nodeAdf, extensionApi);
71
- }, [extensions, nodeAdf, extensionApi]);
72
- if (!extensionItems.length) {
73
- return null;
74
- }
75
-
76
- // ButtonGroup wraps each child with another layer
77
- // but count fragment as 1 child, so here we create the children manually.
78
- const children = [];
79
- if (separator && ['start', 'both'].includes(separator)) {
80
- children.push( /*#__PURE__*/React.createElement(Separator, null));
81
- }
82
- extensionItems.forEach((item, index) => {
83
- children.push( /*#__PURE__*/React.createElement(ExtensionButton, {
84
- node: node,
85
- item: item,
86
- editorView: editorView,
87
- applyChangeToContextPanel: applyChangeToContextPanel,
88
- extensionApi: extensionApi
89
- }));
90
- if (index < extensionItems.length - 1) {
91
- children.push( /*#__PURE__*/React.createElement(Separator, null));
92
- }
93
- });
94
- if (separator && ['end', 'both'].includes(separator)) {
95
- children.push( /*#__PURE__*/React.createElement(Separator, null));
96
- }
97
- return /*#__PURE__*/React.createElement(ButtonGroup, {
98
- children: children
99
- });
100
- };
@@ -1,52 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /** @jsx jsx */
3
- import React from 'react';
4
- import { jsx } from '@emotion/react';
5
- import { Component } from 'react';
6
- import { panelTextInput } from '@atlaskit/editor-common/ui';
7
- export default class TextField extends Component {
8
- constructor(props) {
9
- super(props);
10
- _defineProperty(this, "handleChange", e => {
11
- this.setState({
12
- text: e.target.value
13
- });
14
- });
15
- _defineProperty(this, "handleSubmit", e => {
16
- e.preventDefault();
17
- if (this.props.onSubmit) {
18
- this.props.onSubmit(this.state.text);
19
- }
20
- });
21
- _defineProperty(this, "handleBlur", e => {
22
- e.preventDefault();
23
- if (this.props.onBlur) {
24
- this.props.onBlur(this.state.text);
25
- }
26
- });
27
- this.state = {
28
- text: props.defaultValue || ''
29
- };
30
- }
31
- UNSAFE_componentWillReceiveProps(nextProps) {
32
- if (this.state.text !== nextProps.defaultValue) {
33
- this.setState({
34
- text: nextProps.defaultValue || ''
35
- });
36
- }
37
- }
38
- render() {
39
- const {
40
- placeholder
41
- } = this.props;
42
- return jsx("form", {
43
- onSubmit: this.handleSubmit
44
- }, jsx("input", {
45
- css: panelTextInput,
46
- value: this.state.text,
47
- onChange: this.handleChange,
48
- placeholder: placeholder,
49
- onBlur: this.handleBlur
50
- }));
51
- }
52
- }