@atlaskit/editor-plugin-floating-toolbar 3.1.5 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/floatingToolbarPlugin.js +2 -2
- package/dist/cjs/ui/Dropdown.js +7 -3
- package/dist/cjs/ui/DropdownMenu.js +1 -1
- package/dist/cjs/ui/ExtensionsPlaceholder.js +54 -8
- package/dist/cjs/ui/Toolbar.js +8 -2
- package/dist/es2019/floatingToolbarPlugin.js +2 -2
- package/dist/es2019/ui/Dropdown.js +7 -3
- package/dist/es2019/ui/DropdownMenu.js +1 -1
- package/dist/es2019/ui/ExtensionsPlaceholder.js +54 -8
- package/dist/es2019/ui/Toolbar.js +8 -2
- package/dist/esm/floatingToolbarPlugin.js +2 -2
- package/dist/esm/ui/Dropdown.js +7 -3
- package/dist/esm/ui/DropdownMenu.js +1 -1
- package/dist/esm/ui/ExtensionsPlaceholder.js +54 -8
- package/dist/esm/ui/Toolbar.js +8 -2
- package/dist/types/ui/Dropdown.d.ts +3 -2
- package/dist/types/ui/ExtensionsPlaceholder.d.ts +8 -0
- package/dist/types-ts4.5/ui/Dropdown.d.ts +3 -2
- package/dist/types-ts4.5/ui/ExtensionsPlaceholder.d.ts +8 -0
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 3.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#122181](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/122181)
|
|
8
|
+
[`cf759849b38dc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cf759849b38dc) -
|
|
9
|
+
[ux] Added dropdown menu in floating toolbar for autoconverted extensions
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 3.1.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -34,7 +34,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
34
34
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
35
35
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
36
36
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
37
|
-
// AFP-2532
|
|
37
|
+
// TODO: AFP-2532 - Fix automatic suppressions below
|
|
38
38
|
var getRelevantConfig = exports.getRelevantConfig = function getRelevantConfig(selection, configs) {
|
|
39
39
|
// node selections always take precedence, see if
|
|
40
40
|
var configPair;
|
|
@@ -264,7 +264,7 @@ function ContentComponent(_ref5) {
|
|
|
264
264
|
return null;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
// TODO: MODES-3950 Update this view mode specific logic once we refactor view mode.
|
|
267
|
+
// TODO: MODES-3950 - Update this view mode specific logic once we refactor view mode.
|
|
268
268
|
// We should inverse the responsibility here: A blacklist for toolbar items in view mode, rather than this white list.
|
|
269
269
|
// Also consider moving this logic to the more specific toolbar plugins (media and selection).
|
|
270
270
|
var iterableItems = Array.isArray(items) ? items : (_items = items) === null || _items === void 0 ? void 0 : _items(node);
|
package/dist/cjs/ui/Dropdown.js
CHANGED
|
@@ -66,6 +66,10 @@ var Dropdown = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
66
66
|
isOpenedByKeyboard: false
|
|
67
67
|
});
|
|
68
68
|
(0, _defineProperty2.default)(_this, "triggerRef", /*#__PURE__*/_react.default.createRef());
|
|
69
|
+
(0, _defineProperty2.default)(_this, "makeArrayOptionsFromCallback", function (makeOptions) {
|
|
70
|
+
var options = makeOptions();
|
|
71
|
+
return options;
|
|
72
|
+
});
|
|
69
73
|
(0, _defineProperty2.default)(_this, "renderArrayOptions", function (options) {
|
|
70
74
|
var _this$props = _this.props,
|
|
71
75
|
showSelected = _this$props.showSelected,
|
|
@@ -200,8 +204,8 @@ var Dropdown = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
200
204
|
* not exactly when it hits the boundary.
|
|
201
205
|
*/
|
|
202
206
|
var fitTolerance = 10;
|
|
203
|
-
var fitWidth = Array.isArray(options) ? dropdownWidth || _DropdownMenu.menuItemDimensions.width : options.width;
|
|
204
|
-
var fitHeight = Array.isArray(options) ? options.length * _DropdownMenu.menuItemDimensions.height + _DropdownMenu.itemSpacing * 2 : options.height;
|
|
207
|
+
var fitWidth = Array.isArray(options) || typeof options === 'function' ? dropdownWidth || _DropdownMenu.menuItemDimensions.width : options.width;
|
|
208
|
+
var fitHeight = Array.isArray(options) ? options.length * _DropdownMenu.menuItemDimensions.height + _DropdownMenu.itemSpacing * 2 : typeof options === 'function' ? this.makeArrayOptionsFromCallback(options).length : options.height;
|
|
205
209
|
return (
|
|
206
210
|
/**
|
|
207
211
|
* At the moment footer diver is rendered along with footer, if it's provided
|
|
@@ -225,7 +229,7 @@ var Dropdown = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
225
229
|
arrowKeyNavigationProviderOptions: {
|
|
226
230
|
type: _uiMenu.ArrowKeyNavigationType.MENU
|
|
227
231
|
}
|
|
228
|
-
}, Array.isArray(options) ? this.renderArrayOptions(options) : options.render({
|
|
232
|
+
}, Array.isArray(options) ? this.renderArrayOptions(options) : typeof options === 'function' ? this.renderArrayOptions(this.makeArrayOptionsFromCallback(options)) : options.render({
|
|
229
233
|
hide: this.hide,
|
|
230
234
|
dispatchCommand: dispatchCommand
|
|
231
235
|
}), footer && (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_Divider.Divider, null), footer))
|
|
@@ -64,7 +64,7 @@ var labelStyles = (0, _react2.css)({
|
|
|
64
64
|
width: '100%'
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
// TODO: Migrate away from gridSize
|
|
67
|
+
// TODO: ED-26959 - Migrate away from gridSize
|
|
68
68
|
// Recommendation: Replace with 4 as itemSpacing is used in calculations expecting a number
|
|
69
69
|
var itemSpacing = exports.itemSpacing = (0, _constants.gridSize)() / 2;
|
|
70
70
|
|
|
@@ -17,6 +17,7 @@ var _nesting = require("@atlaskit/editor-common/nesting");
|
|
|
17
17
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
18
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
|
+
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
|
|
20
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
23
|
var noop = function noop() {
|
|
@@ -119,7 +120,14 @@ var ExtensionsPlaceholder = exports.ExtensionsPlaceholder = function ExtensionsP
|
|
|
119
120
|
extensionProvider = props.extensionProvider,
|
|
120
121
|
separator = props.separator,
|
|
121
122
|
applyChangeToContextPanel = props.applyChangeToContextPanel,
|
|
122
|
-
extensionApi = props.extensionApi
|
|
123
|
+
extensionApi = props.extensionApi,
|
|
124
|
+
scrollable = props.scrollable,
|
|
125
|
+
setDisableScroll = props.setDisableScroll,
|
|
126
|
+
dispatchCommand = props.dispatchCommand,
|
|
127
|
+
popupsMountPoint = props.popupsMountPoint,
|
|
128
|
+
popupsBoundariesElement = props.popupsBoundariesElement,
|
|
129
|
+
popupsScrollableElement = props.popupsScrollableElement,
|
|
130
|
+
alignDropdownWithToolbar = props.alignDropdownWithToolbar;
|
|
123
131
|
// Ignored via go/ees005
|
|
124
132
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
133
|
var _useState = (0, _react.useState)([]),
|
|
@@ -188,13 +196,51 @@ var ExtensionsPlaceholder = exports.ExtensionsPlaceholder = function ExtensionsP
|
|
|
188
196
|
if (isNestedTable && ['referentiality:connections', 'chart:insert-chart'].includes(item.key)) {
|
|
189
197
|
item.disabled = true;
|
|
190
198
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
if ((0, _platformFeatureFlags.fg)('forge-ui-macro-autoconvert')) {
|
|
200
|
+
if ('type' in item && item.type === 'dropdown') {
|
|
201
|
+
children.push( /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
|
|
202
|
+
key: item.id,
|
|
203
|
+
title: item.title,
|
|
204
|
+
icon: item.icon,
|
|
205
|
+
dispatchCommand: dispatchCommand || function () {},
|
|
206
|
+
options: item.options,
|
|
207
|
+
disabled: item.disabled,
|
|
208
|
+
tooltip: item.tooltip,
|
|
209
|
+
hideExpandIcon: item.hideExpandIcon,
|
|
210
|
+
mountPoint: popupsMountPoint,
|
|
211
|
+
boundariesElement: popupsBoundariesElement,
|
|
212
|
+
scrollableElement: popupsScrollableElement,
|
|
213
|
+
dropdownWidth: item.dropdownWidth,
|
|
214
|
+
showSelected: item.showSelected,
|
|
215
|
+
buttonTestId: item.testId,
|
|
216
|
+
editorView: editorView,
|
|
217
|
+
setDisableParentScroll: scrollable ? setDisableScroll : undefined,
|
|
218
|
+
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList"),
|
|
219
|
+
alignDropdownWithToolbar: alignDropdownWithToolbar,
|
|
220
|
+
onToggle: item.onToggle,
|
|
221
|
+
footer: item.footer,
|
|
222
|
+
onMount: item.onMount,
|
|
223
|
+
onClick: item.onClick,
|
|
224
|
+
pulse: item.pulse
|
|
225
|
+
}));
|
|
226
|
+
} else {
|
|
227
|
+
children.push( /*#__PURE__*/_react.default.createElement(ExtensionButton, {
|
|
228
|
+
node: node,
|
|
229
|
+
item: item,
|
|
230
|
+
editorView: editorView,
|
|
231
|
+
applyChangeToContextPanel: applyChangeToContextPanel,
|
|
232
|
+
extensionApi: extensionApi
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
children.push( /*#__PURE__*/_react.default.createElement(ExtensionButton, {
|
|
237
|
+
node: node,
|
|
238
|
+
item: item,
|
|
239
|
+
editorView: editorView,
|
|
240
|
+
applyChangeToContextPanel: applyChangeToContextPanel,
|
|
241
|
+
extensionApi: extensionApi
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
198
244
|
if (index < extensionItems.length - 1) {
|
|
199
245
|
children.push( /*#__PURE__*/_react.default.createElement(_ui.FloatingToolbarSeparator, null));
|
|
200
246
|
}
|
package/dist/cjs/ui/Toolbar.js
CHANGED
|
@@ -184,7 +184,7 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
184
184
|
case 'overflow-dropdown':
|
|
185
185
|
return (0, _react2.jsx)(_Dropdown.default, {
|
|
186
186
|
key: idx
|
|
187
|
-
// TODO: Find more appropriate copy
|
|
187
|
+
// TODO: ED-26959 - Find more appropriate copy
|
|
188
188
|
,
|
|
189
189
|
title: 'Show more items',
|
|
190
190
|
icon: (0, _react2.jsx)(_showMoreHorizontal.default, {
|
|
@@ -325,7 +325,13 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
325
325
|
extensionProvider: extensionsProvider,
|
|
326
326
|
separator: item.separator,
|
|
327
327
|
applyChangeToContextPanel: api === null || api === void 0 || (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange,
|
|
328
|
-
extensionApi: api === null || api === void 0 || (_api$extension = api.extension) === null || _api$extension === void 0 ? void 0 : _api$extension.actions.api()
|
|
328
|
+
extensionApi: api === null || api === void 0 || (_api$extension = api.extension) === null || _api$extension === void 0 ? void 0 : _api$extension.actions.api(),
|
|
329
|
+
dispatchCommand: dispatchCommand,
|
|
330
|
+
popupsMountPoint: popupsMountPoint,
|
|
331
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
332
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
333
|
+
alignDropdownWithToolbar: items.length === 1,
|
|
334
|
+
scrollable: scrollable
|
|
329
335
|
});
|
|
330
336
|
case 'separator':
|
|
331
337
|
return (0, _react2.jsx)(_ui.FloatingToolbarSeparator, {
|
|
@@ -19,7 +19,7 @@ import { ConfirmationModal } from './ui/ConfirmationModal';
|
|
|
19
19
|
import { ExpandButton } from './ui/ExpandButton';
|
|
20
20
|
import { ToolbarLoader } from './ui/ToolbarLoader';
|
|
21
21
|
|
|
22
|
-
// AFP-2532
|
|
22
|
+
// TODO: AFP-2532 - Fix automatic suppressions below
|
|
23
23
|
export const getRelevantConfig = (selection, configs) => {
|
|
24
24
|
// node selections always take precedence, see if
|
|
25
25
|
let configPair;
|
|
@@ -250,7 +250,7 @@ export function ContentComponent({
|
|
|
250
250
|
return null;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
// TODO: MODES-3950 Update this view mode specific logic once we refactor view mode.
|
|
253
|
+
// TODO: MODES-3950 - Update this view mode specific logic once we refactor view mode.
|
|
254
254
|
// We should inverse the responsibility here: A blacklist for toolbar items in view mode, rather than this white list.
|
|
255
255
|
// Also consider moving this logic to the more specific toolbar plugins (media and selection).
|
|
256
256
|
const iterableItems = Array.isArray(items) ? items : (_items = items) === null || _items === void 0 ? void 0 : _items(node);
|
|
@@ -46,6 +46,10 @@ export default class Dropdown extends Component {
|
|
|
46
46
|
isOpenedByKeyboard: false
|
|
47
47
|
});
|
|
48
48
|
_defineProperty(this, "triggerRef", /*#__PURE__*/React.createRef());
|
|
49
|
+
_defineProperty(this, "makeArrayOptionsFromCallback", makeOptions => {
|
|
50
|
+
const options = makeOptions();
|
|
51
|
+
return options;
|
|
52
|
+
});
|
|
49
53
|
_defineProperty(this, "renderArrayOptions", options => {
|
|
50
54
|
const {
|
|
51
55
|
showSelected,
|
|
@@ -181,8 +185,8 @@ export default class Dropdown extends Component {
|
|
|
181
185
|
* not exactly when it hits the boundary.
|
|
182
186
|
*/
|
|
183
187
|
const fitTolerance = 10;
|
|
184
|
-
const fitWidth = Array.isArray(options) ? dropdownWidth || menuItemDimensions.width : options.width;
|
|
185
|
-
const fitHeight = Array.isArray(options) ? options.length * menuItemDimensions.height + itemSpacing * 2 : options.height;
|
|
188
|
+
const fitWidth = Array.isArray(options) || typeof options === 'function' ? dropdownWidth || menuItemDimensions.width : options.width;
|
|
189
|
+
const fitHeight = Array.isArray(options) ? options.length * menuItemDimensions.height + itemSpacing * 2 : typeof options === 'function' ? this.makeArrayOptionsFromCallback(options).length : options.height;
|
|
186
190
|
return (
|
|
187
191
|
/**
|
|
188
192
|
* At the moment footer diver is rendered along with footer, if it's provided
|
|
@@ -206,7 +210,7 @@ export default class Dropdown extends Component {
|
|
|
206
210
|
arrowKeyNavigationProviderOptions: {
|
|
207
211
|
type: ArrowKeyNavigationType.MENU
|
|
208
212
|
}
|
|
209
|
-
}, Array.isArray(options) ? this.renderArrayOptions(options) : options.render({
|
|
213
|
+
}, Array.isArray(options) ? this.renderArrayOptions(options) : typeof options === 'function' ? this.renderArrayOptions(this.makeArrayOptionsFromCallback(options)) : options.render({
|
|
210
214
|
hide: this.hide,
|
|
211
215
|
dispatchCommand
|
|
212
216
|
}), footer && jsx(React.Fragment, null, jsx(Divider, null), footer))
|
|
@@ -54,7 +54,7 @@ const labelStyles = css({
|
|
|
54
54
|
width: '100%'
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
// TODO: Migrate away from gridSize
|
|
57
|
+
// TODO: ED-26959 - Migrate away from gridSize
|
|
58
58
|
// Recommendation: Replace with 4 as itemSpacing is used in calculations expecting a number
|
|
59
59
|
export const itemSpacing = gridSize() / 2;
|
|
60
60
|
|
|
@@ -6,6 +6,7 @@ import { isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
|
|
|
6
6
|
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
|
|
7
7
|
import { nodeToJSON } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import Dropdown from './Dropdown';
|
|
9
10
|
const noop = () => null;
|
|
10
11
|
const isDefaultExport = mod => {
|
|
11
12
|
return mod.hasOwnProperty('default');
|
|
@@ -69,7 +70,14 @@ export const ExtensionsPlaceholder = props => {
|
|
|
69
70
|
extensionProvider,
|
|
70
71
|
separator,
|
|
71
72
|
applyChangeToContextPanel,
|
|
72
|
-
extensionApi
|
|
73
|
+
extensionApi,
|
|
74
|
+
scrollable,
|
|
75
|
+
setDisableScroll,
|
|
76
|
+
dispatchCommand,
|
|
77
|
+
popupsMountPoint,
|
|
78
|
+
popupsBoundariesElement,
|
|
79
|
+
popupsScrollableElement,
|
|
80
|
+
alignDropdownWithToolbar
|
|
73
81
|
} = props;
|
|
74
82
|
// Ignored via go/ees005
|
|
75
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -110,13 +118,51 @@ export const ExtensionsPlaceholder = props => {
|
|
|
110
118
|
if (isNestedTable && ['referentiality:connections', 'chart:insert-chart'].includes(item.key)) {
|
|
111
119
|
item.disabled = true;
|
|
112
120
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
if (fg('forge-ui-macro-autoconvert')) {
|
|
122
|
+
if ('type' in item && item.type === 'dropdown') {
|
|
123
|
+
children.push( /*#__PURE__*/React.createElement(Dropdown, {
|
|
124
|
+
key: item.id,
|
|
125
|
+
title: item.title,
|
|
126
|
+
icon: item.icon,
|
|
127
|
+
dispatchCommand: dispatchCommand || (() => {}),
|
|
128
|
+
options: item.options,
|
|
129
|
+
disabled: item.disabled,
|
|
130
|
+
tooltip: item.tooltip,
|
|
131
|
+
hideExpandIcon: item.hideExpandIcon,
|
|
132
|
+
mountPoint: popupsMountPoint,
|
|
133
|
+
boundariesElement: popupsBoundariesElement,
|
|
134
|
+
scrollableElement: popupsScrollableElement,
|
|
135
|
+
dropdownWidth: item.dropdownWidth,
|
|
136
|
+
showSelected: item.showSelected,
|
|
137
|
+
buttonTestId: item.testId,
|
|
138
|
+
editorView: editorView,
|
|
139
|
+
setDisableParentScroll: scrollable ? setDisableScroll : undefined,
|
|
140
|
+
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && `${item.id}-dropdownList`,
|
|
141
|
+
alignDropdownWithToolbar: alignDropdownWithToolbar,
|
|
142
|
+
onToggle: item.onToggle,
|
|
143
|
+
footer: item.footer,
|
|
144
|
+
onMount: item.onMount,
|
|
145
|
+
onClick: item.onClick,
|
|
146
|
+
pulse: item.pulse
|
|
147
|
+
}));
|
|
148
|
+
} else {
|
|
149
|
+
children.push( /*#__PURE__*/React.createElement(ExtensionButton, {
|
|
150
|
+
node: node,
|
|
151
|
+
item: item,
|
|
152
|
+
editorView: editorView,
|
|
153
|
+
applyChangeToContextPanel: applyChangeToContextPanel,
|
|
154
|
+
extensionApi: extensionApi
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
children.push( /*#__PURE__*/React.createElement(ExtensionButton, {
|
|
159
|
+
node: node,
|
|
160
|
+
item: item,
|
|
161
|
+
editorView: editorView,
|
|
162
|
+
applyChangeToContextPanel: applyChangeToContextPanel,
|
|
163
|
+
extensionApi: extensionApi
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
120
166
|
if (index < extensionItems.length - 1) {
|
|
121
167
|
children.push( /*#__PURE__*/React.createElement(Separator, null));
|
|
122
168
|
}
|
|
@@ -161,7 +161,7 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
|
|
|
161
161
|
case 'overflow-dropdown':
|
|
162
162
|
return jsx(Dropdown, {
|
|
163
163
|
key: idx
|
|
164
|
-
// TODO: Find more appropriate copy
|
|
164
|
+
// TODO: ED-26959 - Find more appropriate copy
|
|
165
165
|
,
|
|
166
166
|
title: 'Show more items',
|
|
167
167
|
icon: jsx(ShowMoreHorizontalIcon, {
|
|
@@ -298,7 +298,13 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
|
|
|
298
298
|
extensionProvider: extensionsProvider,
|
|
299
299
|
separator: item.separator,
|
|
300
300
|
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange,
|
|
301
|
-
extensionApi: api === null || api === void 0 ? void 0 : (_api$extension = api.extension) === null || _api$extension === void 0 ? void 0 : _api$extension.actions.api()
|
|
301
|
+
extensionApi: api === null || api === void 0 ? void 0 : (_api$extension = api.extension) === null || _api$extension === void 0 ? void 0 : _api$extension.actions.api(),
|
|
302
|
+
dispatchCommand: dispatchCommand,
|
|
303
|
+
popupsMountPoint: popupsMountPoint,
|
|
304
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
305
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
306
|
+
alignDropdownWithToolbar: items.length === 1,
|
|
307
|
+
scrollable: scrollable
|
|
302
308
|
});
|
|
303
309
|
case 'separator':
|
|
304
310
|
return jsx(Separator, {
|
|
@@ -22,7 +22,7 @@ import { ConfirmationModal } from './ui/ConfirmationModal';
|
|
|
22
22
|
import { ExpandButton } from './ui/ExpandButton';
|
|
23
23
|
import { ToolbarLoader } from './ui/ToolbarLoader';
|
|
24
24
|
|
|
25
|
-
// AFP-2532
|
|
25
|
+
// TODO: AFP-2532 - Fix automatic suppressions below
|
|
26
26
|
export var getRelevantConfig = function getRelevantConfig(selection, configs) {
|
|
27
27
|
// node selections always take precedence, see if
|
|
28
28
|
var configPair;
|
|
@@ -252,7 +252,7 @@ export function ContentComponent(_ref5) {
|
|
|
252
252
|
return null;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
// TODO: MODES-3950 Update this view mode specific logic once we refactor view mode.
|
|
255
|
+
// TODO: MODES-3950 - Update this view mode specific logic once we refactor view mode.
|
|
256
256
|
// We should inverse the responsibility here: A blacklist for toolbar items in view mode, rather than this white list.
|
|
257
257
|
// Also consider moving this logic to the more specific toolbar plugins (media and selection).
|
|
258
258
|
var iterableItems = Array.isArray(items) ? items : (_items = items) === null || _items === void 0 ? void 0 : _items(node);
|
package/dist/esm/ui/Dropdown.js
CHANGED
|
@@ -61,6 +61,10 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
61
61
|
isOpenedByKeyboard: false
|
|
62
62
|
});
|
|
63
63
|
_defineProperty(_this, "triggerRef", /*#__PURE__*/React.createRef());
|
|
64
|
+
_defineProperty(_this, "makeArrayOptionsFromCallback", function (makeOptions) {
|
|
65
|
+
var options = makeOptions();
|
|
66
|
+
return options;
|
|
67
|
+
});
|
|
64
68
|
_defineProperty(_this, "renderArrayOptions", function (options) {
|
|
65
69
|
var _this$props = _this.props,
|
|
66
70
|
showSelected = _this$props.showSelected,
|
|
@@ -195,8 +199,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
195
199
|
* not exactly when it hits the boundary.
|
|
196
200
|
*/
|
|
197
201
|
var fitTolerance = 10;
|
|
198
|
-
var fitWidth = Array.isArray(options) ? dropdownWidth || menuItemDimensions.width : options.width;
|
|
199
|
-
var fitHeight = Array.isArray(options) ? options.length * menuItemDimensions.height + itemSpacing * 2 : options.height;
|
|
202
|
+
var fitWidth = Array.isArray(options) || typeof options === 'function' ? dropdownWidth || menuItemDimensions.width : options.width;
|
|
203
|
+
var fitHeight = Array.isArray(options) ? options.length * menuItemDimensions.height + itemSpacing * 2 : typeof options === 'function' ? this.makeArrayOptionsFromCallback(options).length : options.height;
|
|
200
204
|
return (
|
|
201
205
|
/**
|
|
202
206
|
* At the moment footer diver is rendered along with footer, if it's provided
|
|
@@ -220,7 +224,7 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
220
224
|
arrowKeyNavigationProviderOptions: {
|
|
221
225
|
type: ArrowKeyNavigationType.MENU
|
|
222
226
|
}
|
|
223
|
-
}, Array.isArray(options) ? this.renderArrayOptions(options) : options.render({
|
|
227
|
+
}, Array.isArray(options) ? this.renderArrayOptions(options) : typeof options === 'function' ? this.renderArrayOptions(this.makeArrayOptionsFromCallback(options)) : options.render({
|
|
224
228
|
hide: this.hide,
|
|
225
229
|
dispatchCommand: dispatchCommand
|
|
226
230
|
}), footer && jsx(React.Fragment, null, jsx(Divider, null), footer))
|
|
@@ -55,7 +55,7 @@ var labelStyles = css({
|
|
|
55
55
|
width: '100%'
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
// TODO: Migrate away from gridSize
|
|
58
|
+
// TODO: ED-26959 - Migrate away from gridSize
|
|
59
59
|
// Recommendation: Replace with 4 as itemSpacing is used in calculations expecting a number
|
|
60
60
|
export var itemSpacing = gridSize() / 2;
|
|
61
61
|
|
|
@@ -9,6 +9,7 @@ import { isSelectionTableNestedInTable } from '@atlaskit/editor-common/nesting';
|
|
|
9
9
|
import { FloatingToolbarButton as Button, FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
|
|
10
10
|
import { nodeToJSON } from '@atlaskit/editor-common/utils';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import Dropdown from './Dropdown';
|
|
12
13
|
var noop = function noop() {
|
|
13
14
|
return null;
|
|
14
15
|
};
|
|
@@ -109,7 +110,14 @@ export var ExtensionsPlaceholder = function ExtensionsPlaceholder(props) {
|
|
|
109
110
|
extensionProvider = props.extensionProvider,
|
|
110
111
|
separator = props.separator,
|
|
111
112
|
applyChangeToContextPanel = props.applyChangeToContextPanel,
|
|
112
|
-
extensionApi = props.extensionApi
|
|
113
|
+
extensionApi = props.extensionApi,
|
|
114
|
+
scrollable = props.scrollable,
|
|
115
|
+
setDisableScroll = props.setDisableScroll,
|
|
116
|
+
dispatchCommand = props.dispatchCommand,
|
|
117
|
+
popupsMountPoint = props.popupsMountPoint,
|
|
118
|
+
popupsBoundariesElement = props.popupsBoundariesElement,
|
|
119
|
+
popupsScrollableElement = props.popupsScrollableElement,
|
|
120
|
+
alignDropdownWithToolbar = props.alignDropdownWithToolbar;
|
|
113
121
|
// Ignored via go/ees005
|
|
114
122
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
123
|
var _useState = useState([]),
|
|
@@ -178,13 +186,51 @@ export var ExtensionsPlaceholder = function ExtensionsPlaceholder(props) {
|
|
|
178
186
|
if (isNestedTable && ['referentiality:connections', 'chart:insert-chart'].includes(item.key)) {
|
|
179
187
|
item.disabled = true;
|
|
180
188
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
if (fg('forge-ui-macro-autoconvert')) {
|
|
190
|
+
if ('type' in item && item.type === 'dropdown') {
|
|
191
|
+
children.push( /*#__PURE__*/React.createElement(Dropdown, {
|
|
192
|
+
key: item.id,
|
|
193
|
+
title: item.title,
|
|
194
|
+
icon: item.icon,
|
|
195
|
+
dispatchCommand: dispatchCommand || function () {},
|
|
196
|
+
options: item.options,
|
|
197
|
+
disabled: item.disabled,
|
|
198
|
+
tooltip: item.tooltip,
|
|
199
|
+
hideExpandIcon: item.hideExpandIcon,
|
|
200
|
+
mountPoint: popupsMountPoint,
|
|
201
|
+
boundariesElement: popupsBoundariesElement,
|
|
202
|
+
scrollableElement: popupsScrollableElement,
|
|
203
|
+
dropdownWidth: item.dropdownWidth,
|
|
204
|
+
showSelected: item.showSelected,
|
|
205
|
+
buttonTestId: item.testId,
|
|
206
|
+
editorView: editorView,
|
|
207
|
+
setDisableParentScroll: scrollable ? setDisableScroll : undefined,
|
|
208
|
+
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList"),
|
|
209
|
+
alignDropdownWithToolbar: alignDropdownWithToolbar,
|
|
210
|
+
onToggle: item.onToggle,
|
|
211
|
+
footer: item.footer,
|
|
212
|
+
onMount: item.onMount,
|
|
213
|
+
onClick: item.onClick,
|
|
214
|
+
pulse: item.pulse
|
|
215
|
+
}));
|
|
216
|
+
} else {
|
|
217
|
+
children.push( /*#__PURE__*/React.createElement(ExtensionButton, {
|
|
218
|
+
node: node,
|
|
219
|
+
item: item,
|
|
220
|
+
editorView: editorView,
|
|
221
|
+
applyChangeToContextPanel: applyChangeToContextPanel,
|
|
222
|
+
extensionApi: extensionApi
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
children.push( /*#__PURE__*/React.createElement(ExtensionButton, {
|
|
227
|
+
node: node,
|
|
228
|
+
item: item,
|
|
229
|
+
editorView: editorView,
|
|
230
|
+
applyChangeToContextPanel: applyChangeToContextPanel,
|
|
231
|
+
extensionApi: extensionApi
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
188
234
|
if (index < extensionItems.length - 1) {
|
|
189
235
|
children.push( /*#__PURE__*/React.createElement(Separator, null));
|
|
190
236
|
}
|
package/dist/esm/ui/Toolbar.js
CHANGED
|
@@ -177,7 +177,7 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
177
177
|
case 'overflow-dropdown':
|
|
178
178
|
return jsx(Dropdown, {
|
|
179
179
|
key: idx
|
|
180
|
-
// TODO: Find more appropriate copy
|
|
180
|
+
// TODO: ED-26959 - Find more appropriate copy
|
|
181
181
|
,
|
|
182
182
|
title: 'Show more items',
|
|
183
183
|
icon: jsx(ShowMoreHorizontalIcon, {
|
|
@@ -318,7 +318,13 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
318
318
|
extensionProvider: extensionsProvider,
|
|
319
319
|
separator: item.separator,
|
|
320
320
|
applyChangeToContextPanel: api === null || api === void 0 || (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange,
|
|
321
|
-
extensionApi: api === null || api === void 0 || (_api$extension = api.extension) === null || _api$extension === void 0 ? void 0 : _api$extension.actions.api()
|
|
321
|
+
extensionApi: api === null || api === void 0 || (_api$extension = api.extension) === null || _api$extension === void 0 ? void 0 : _api$extension.actions.api(),
|
|
322
|
+
dispatchCommand: dispatchCommand,
|
|
323
|
+
popupsMountPoint: popupsMountPoint,
|
|
324
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
325
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
326
|
+
alignDropdownWithToolbar: items.length === 1,
|
|
327
|
+
scrollable: scrollable
|
|
322
328
|
});
|
|
323
329
|
case 'separator':
|
|
324
330
|
return jsx(Separator, {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { ReactElement } from 'react';
|
|
7
7
|
import React, { Component } from 'react';
|
|
8
8
|
import { jsx } from '@emotion/react';
|
|
9
|
-
import type { CommandDispatch, DropdownOptions, FloatingToolbarOverflowDropdownOptions, FloatingToolbarButtonSpotlightConfig } from '@atlaskit/editor-common/types';
|
|
9
|
+
import type { CommandDispatch, DropdownOptions, FloatingToolbarOverflowDropdownOptions, FloatingToolbarButtonSpotlightConfig, ExtensionDropdownOptions } from '@atlaskit/editor-common/types';
|
|
10
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
12
12
|
export interface Props {
|
|
@@ -14,7 +14,7 @@ export interface Props {
|
|
|
14
14
|
icon?: ReactElement<any>;
|
|
15
15
|
iconBefore?: ReactElement<any>;
|
|
16
16
|
hideExpandIcon?: boolean;
|
|
17
|
-
options: DropdownOptions<Function> | FloatingToolbarOverflowDropdownOptions<Function
|
|
17
|
+
options: DropdownOptions<Function> | FloatingToolbarOverflowDropdownOptions<Function> | ExtensionDropdownOptions;
|
|
18
18
|
dispatchCommand: (command: Function) => void;
|
|
19
19
|
mountPoint?: HTMLElement;
|
|
20
20
|
boundariesElement?: HTMLElement;
|
|
@@ -44,6 +44,7 @@ export default class Dropdown extends Component<Props, State> {
|
|
|
44
44
|
state: State;
|
|
45
45
|
triggerRef: React.RefObject<HTMLDivElement>;
|
|
46
46
|
render(): jsx.JSX.Element;
|
|
47
|
+
private makeArrayOptionsFromCallback;
|
|
47
48
|
private renderArrayOptions;
|
|
48
49
|
private toggleOpen;
|
|
49
50
|
private toggleOpenByKeyboard;
|
|
@@ -10,6 +10,14 @@ interface Props {
|
|
|
10
10
|
separator?: 'start' | 'end' | 'both';
|
|
11
11
|
applyChangeToContextPanel: ApplyChangeHandler | undefined;
|
|
12
12
|
extensionApi: ExtensionAPI | undefined;
|
|
13
|
+
scrollable?: boolean;
|
|
14
|
+
setDisableScroll?: (disable: boolean) => void;
|
|
15
|
+
dispatchCommand?: (command: Function) => void;
|
|
16
|
+
popupsMountPoint?: HTMLElement;
|
|
17
|
+
popupsBoundariesElement?: HTMLElement;
|
|
18
|
+
popupsScrollableElement?: HTMLElement;
|
|
19
|
+
setDisableParentScroll?: (disable: boolean) => void;
|
|
20
|
+
alignDropdownWithToolbar?: boolean;
|
|
13
21
|
}
|
|
14
22
|
export declare const ExtensionsPlaceholder: (props: Props) => React.JSX.Element | null;
|
|
15
23
|
export {};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { ReactElement } from 'react';
|
|
7
7
|
import React, { Component } from 'react';
|
|
8
8
|
import { jsx } from '@emotion/react';
|
|
9
|
-
import type { CommandDispatch, DropdownOptions, FloatingToolbarOverflowDropdownOptions, FloatingToolbarButtonSpotlightConfig } from '@atlaskit/editor-common/types';
|
|
9
|
+
import type { CommandDispatch, DropdownOptions, FloatingToolbarOverflowDropdownOptions, FloatingToolbarButtonSpotlightConfig, ExtensionDropdownOptions } from '@atlaskit/editor-common/types';
|
|
10
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
12
12
|
export interface Props {
|
|
@@ -14,7 +14,7 @@ export interface Props {
|
|
|
14
14
|
icon?: ReactElement<any>;
|
|
15
15
|
iconBefore?: ReactElement<any>;
|
|
16
16
|
hideExpandIcon?: boolean;
|
|
17
|
-
options: DropdownOptions<Function> | FloatingToolbarOverflowDropdownOptions<Function
|
|
17
|
+
options: DropdownOptions<Function> | FloatingToolbarOverflowDropdownOptions<Function> | ExtensionDropdownOptions;
|
|
18
18
|
dispatchCommand: (command: Function) => void;
|
|
19
19
|
mountPoint?: HTMLElement;
|
|
20
20
|
boundariesElement?: HTMLElement;
|
|
@@ -44,6 +44,7 @@ export default class Dropdown extends Component<Props, State> {
|
|
|
44
44
|
state: State;
|
|
45
45
|
triggerRef: React.RefObject<HTMLDivElement>;
|
|
46
46
|
render(): jsx.JSX.Element;
|
|
47
|
+
private makeArrayOptionsFromCallback;
|
|
47
48
|
private renderArrayOptions;
|
|
48
49
|
private toggleOpen;
|
|
49
50
|
private toggleOpenByKeyboard;
|
|
@@ -10,6 +10,14 @@ interface Props {
|
|
|
10
10
|
separator?: 'start' | 'end' | 'both';
|
|
11
11
|
applyChangeToContextPanel: ApplyChangeHandler | undefined;
|
|
12
12
|
extensionApi: ExtensionAPI | undefined;
|
|
13
|
+
scrollable?: boolean;
|
|
14
|
+
setDisableScroll?: (disable: boolean) => void;
|
|
15
|
+
dispatchCommand?: (command: Function) => void;
|
|
16
|
+
popupsMountPoint?: HTMLElement;
|
|
17
|
+
popupsBoundariesElement?: HTMLElement;
|
|
18
|
+
popupsScrollableElement?: HTMLElement;
|
|
19
|
+
setDisableParentScroll?: (disable: boolean) => void;
|
|
20
|
+
alignDropdownWithToolbar?: boolean;
|
|
13
21
|
}
|
|
14
22
|
export declare const ExtensionsPlaceholder: (props: Props) => React.JSX.Element | null;
|
|
15
23
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-floating-toolbar",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Floating toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/adf-utils": "^19.19.0",
|
|
29
29
|
"@atlaskit/button": "^21.1.0",
|
|
30
30
|
"@atlaskit/checkbox": "^17.0.0",
|
|
31
|
-
"@atlaskit/editor-common": "^102.
|
|
31
|
+
"@atlaskit/editor-common": "^102.3.0",
|
|
32
32
|
"@atlaskit/editor-palette": "^2.0.0",
|
|
33
33
|
"@atlaskit/editor-plugin-block-controls": "^3.3.0",
|
|
34
34
|
"@atlaskit/editor-plugin-context-panel": "^4.0.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"@atlaskit/editor-plugin-decorations": "^2.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
|
|
39
|
-
"@atlaskit/editor-plugin-emoji": "^3.
|
|
39
|
+
"@atlaskit/editor-plugin-emoji": "^3.2.0",
|
|
40
40
|
"@atlaskit/editor-plugin-extension": "^5.0.0",
|
|
41
|
-
"@atlaskit/editor-plugin-table": "^10.
|
|
41
|
+
"@atlaskit/editor-plugin-table": "^10.4.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
43
43
|
"@atlaskit/emoji": "^68.0.0",
|
|
44
44
|
"@atlaskit/icon": "^24.1.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/primitives": "^14.1.0",
|
|
49
49
|
"@atlaskit/select": "^20.0.0",
|
|
50
50
|
"@atlaskit/theme": "^18.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^3.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^3.5.0",
|
|
52
52
|
"@atlaskit/tokens": "^4.3.0",
|
|
53
53
|
"@atlaskit/tooltip": "^20.0.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
@@ -121,6 +121,9 @@
|
|
|
121
121
|
},
|
|
122
122
|
"platform_editor_use_nested_table_pm_nodes": {
|
|
123
123
|
"type": "boolean"
|
|
124
|
+
},
|
|
125
|
+
"forge-ui-macro-autoconvert": {
|
|
126
|
+
"type": "boolean"
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
}
|