@atlaskit/editor-plugin-floating-toolbar 8.2.1 → 8.2.2
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 +9 -0
- package/dist/cjs/floatingToolbarPlugin.js +27 -8
- package/dist/cjs/pm-plugins/toolbar-data/commands.js +3 -2
- package/dist/cjs/pm-plugins/toolbar-data/reducer.js +2 -1
- package/dist/cjs/ui/Toolbar.js +24 -2
- package/dist/es2019/floatingToolbarPlugin.js +29 -9
- package/dist/es2019/pm-plugins/toolbar-data/commands.js +3 -2
- package/dist/es2019/pm-plugins/toolbar-data/reducer.js +2 -1
- package/dist/es2019/ui/Toolbar.js +22 -1
- package/dist/esm/floatingToolbarPlugin.js +27 -8
- package/dist/esm/pm-plugins/toolbar-data/commands.js +3 -2
- package/dist/esm/pm-plugins/toolbar-data/reducer.js +2 -1
- package/dist/esm/ui/Toolbar.js +23 -1
- package/dist/types/floatingToolbarPluginType.d.ts +1 -0
- package/dist/types/pm-plugins/toolbar-data/commands.d.ts +1 -1
- package/dist/types/pm-plugins/toolbar-data/types.d.ts +1 -0
- package/dist/types-ts4.5/floatingToolbarPluginType.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/toolbar-data/commands.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/toolbar-data/types.d.ts +1 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 8.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`94b21013815ad`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/94b21013815ad) -
|
|
8
|
+
[ux] ensure confirmation is required when removing a table with an associated chart (fixes bug
|
|
9
|
+
when platform_editor_controls is set to variant1)
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 8.2.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -228,7 +228,7 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
|
|
|
228
228
|
* @returns JSX element representing the floating toolbar or null if not visible
|
|
229
229
|
*/
|
|
230
230
|
function ContentComponent(_ref5) {
|
|
231
|
-
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
|
|
231
|
+
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
|
|
232
232
|
var pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
233
233
|
editorView = _ref5.editorView,
|
|
234
234
|
popupsMountPoint = _ref5.popupsMountPoint,
|
|
@@ -389,14 +389,33 @@ function ContentComponent(_ref5) {
|
|
|
389
389
|
};
|
|
390
390
|
|
|
391
391
|
// Confirm dialog
|
|
392
|
-
var
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
392
|
+
var confirmButtonItem;
|
|
393
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_confirm_table_removal')) {
|
|
394
|
+
var _ref7 = floatingToolbarData || {},
|
|
395
|
+
confirmDialogForItem = _ref7.confirmDialogForItem,
|
|
396
|
+
confirmDialogForItemOption = _ref7.confirmDialogForItemOption;
|
|
397
|
+
var matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
|
|
398
|
+
if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
|
|
399
|
+
confirmButtonItem = matchingItem;
|
|
400
|
+
}
|
|
401
|
+
if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
|
|
402
|
+
var matchingItemOption = matchingItem.options[confirmDialogForItemOption];
|
|
403
|
+
|
|
404
|
+
// OverflowDropdownOption is the only member of the union that does not have a 'type' property
|
|
405
|
+
if (!('type' in matchingItemOption)) {
|
|
406
|
+
confirmButtonItem = matchingItemOption;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
var _ref8 = floatingToolbarData || {},
|
|
411
|
+
_confirmDialogForItem = _ref8.confirmDialogForItem;
|
|
412
|
+
confirmButtonItem = _confirmDialogForItem ?
|
|
413
|
+
// Ignored via go/ees005
|
|
414
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
415
|
+
toolbarItems[_confirmDialogForItem] : undefined;
|
|
416
|
+
}
|
|
398
417
|
var scrollable = config.scrollable;
|
|
399
|
-
var confirmDialogOptions = typeof (confirmButtonItem === null ||
|
|
418
|
+
var confirmDialogOptions = typeof ((_confirmButtonItem = confirmButtonItem) === null || _confirmButtonItem === void 0 ? void 0 : _confirmButtonItem.confirmDialog) === 'function' ? (_confirmButtonItem2 = confirmButtonItem) === null || _confirmButtonItem2 === void 0 ? void 0 : _confirmButtonItem2.confirmDialog() : (_confirmButtonItem3 = confirmButtonItem) === null || _confirmButtonItem3 === void 0 ? void 0 : _confirmButtonItem3.confirmDialog;
|
|
400
419
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
401
420
|
component: _analytics.ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
|
|
402
421
|
componentId: (0, _camelCase.default)(title),
|
|
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.showConfirmDialog = exports.hideConfirmDialog = void 0;
|
|
7
7
|
var _pluginFactory = require("./plugin-factory");
|
|
8
|
-
var showConfirmDialog = exports.showConfirmDialog = function showConfirmDialog(buttonIndex) {
|
|
8
|
+
var showConfirmDialog = exports.showConfirmDialog = function showConfirmDialog(buttonIndex, optionIndex) {
|
|
9
9
|
return (0, _pluginFactory.createCommand)({
|
|
10
10
|
type: 'SHOW_CONFIRM_DIALOG',
|
|
11
11
|
data: {
|
|
12
|
-
buttonIndex: buttonIndex
|
|
12
|
+
buttonIndex: buttonIndex,
|
|
13
|
+
optionIndex: optionIndex
|
|
13
14
|
}
|
|
14
15
|
}, function (tr) {
|
|
15
16
|
return tr.setMeta('addToHistory', false);
|
|
@@ -12,7 +12,8 @@ var reducer = exports.reducer = function reducer(pluginState, action) {
|
|
|
12
12
|
switch (action.type) {
|
|
13
13
|
case 'SHOW_CONFIRM_DIALOG':
|
|
14
14
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
15
|
-
confirmDialogForItem: action.data.buttonIndex
|
|
15
|
+
confirmDialogForItem: action.data.buttonIndex,
|
|
16
|
+
confirmDialogForItemOption: action.data.optionIndex
|
|
16
17
|
});
|
|
17
18
|
case 'HIDE_CONFIRM_DIALOG':
|
|
18
19
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
package/dist/cjs/ui/Toolbar.js
CHANGED
|
@@ -26,6 +26,7 @@ var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
|
26
26
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
27
27
|
var _editorPalette = require("@atlaskit/editor-palette");
|
|
28
28
|
var _showMoreHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/show-more-horizontal"));
|
|
29
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
29
30
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
30
31
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
31
32
|
var _forceFocus = require("../pm-plugins/force-focus");
|
|
@@ -39,7 +40,9 @@ var _ScrollButtons = require("./ScrollButtons");
|
|
|
39
40
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
40
41
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
41
42
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
42
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
43
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
44
|
+
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; }
|
|
45
|
+
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; } /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation */ /**
|
|
43
46
|
* @jsxRuntime classic
|
|
44
47
|
* @jsx jsx
|
|
45
48
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
@@ -200,6 +203,25 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
200
203
|
return item.render(editorView, idx, dispatchAnalyticsEvent);
|
|
201
204
|
}
|
|
202
205
|
case 'overflow-dropdown':
|
|
206
|
+
var options;
|
|
207
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_confirm_table_removal')) {
|
|
208
|
+
// if an option has a confirmDialog, we need to replace its onClick handler
|
|
209
|
+
// to set the state to show the confirm dialog
|
|
210
|
+
|
|
211
|
+
// crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
|
|
212
|
+
// which would need knowledge of indexes, showConfirmDialog etc.
|
|
213
|
+
options = item.options.map(function (option, optionIndex) {
|
|
214
|
+
if (!('type' in option) && option.confirmDialog) {
|
|
215
|
+
var onClick = option.confirmDialog ? (0, _commands.showConfirmDialog)(idx, optionIndex) : option.onClick;
|
|
216
|
+
return _objectSpread(_objectSpread({}, option), {}, {
|
|
217
|
+
onClick: onClick
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return option;
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
options = item.options;
|
|
224
|
+
}
|
|
203
225
|
return (0, _react2.jsx)(_Dropdown.default, {
|
|
204
226
|
alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
|
|
205
227
|
key: idx,
|
|
@@ -209,7 +231,7 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
209
231
|
spacing: "spacious"
|
|
210
232
|
}),
|
|
211
233
|
dispatchCommand: dispatchCommand,
|
|
212
|
-
options:
|
|
234
|
+
options: options,
|
|
213
235
|
disabled: item.disabled,
|
|
214
236
|
tooltip: item.tooltip,
|
|
215
237
|
hideExpandIcon: true,
|
|
@@ -222,7 +222,7 @@ export function ContentComponent({
|
|
|
222
222
|
providerFactory,
|
|
223
223
|
dispatchAnalyticsEvent
|
|
224
224
|
}) {
|
|
225
|
-
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
|
|
225
|
+
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
|
|
226
226
|
const {
|
|
227
227
|
floatingToolbarState,
|
|
228
228
|
editorDisabledState,
|
|
@@ -373,15 +373,35 @@ export function ContentComponent({
|
|
|
373
373
|
const dispatchCommand = fn => fn && fn(editorView.state, editorView.dispatch, editorView);
|
|
374
374
|
|
|
375
375
|
// Confirm dialog
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
376
|
+
let confirmButtonItem;
|
|
377
|
+
if (fg('platform_editor_fix_confirm_table_removal')) {
|
|
378
|
+
const {
|
|
379
|
+
confirmDialogForItem,
|
|
380
|
+
confirmDialogForItemOption
|
|
381
|
+
} = floatingToolbarData || {};
|
|
382
|
+
const matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
|
|
383
|
+
if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
|
|
384
|
+
confirmButtonItem = matchingItem;
|
|
385
|
+
}
|
|
386
|
+
if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
|
|
387
|
+
const matchingItemOption = matchingItem.options[confirmDialogForItemOption];
|
|
388
|
+
|
|
389
|
+
// OverflowDropdownOption is the only member of the union that does not have a 'type' property
|
|
390
|
+
if (!('type' in matchingItemOption)) {
|
|
391
|
+
confirmButtonItem = matchingItemOption;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
const {
|
|
396
|
+
confirmDialogForItem
|
|
397
|
+
} = floatingToolbarData || {};
|
|
398
|
+
confirmButtonItem = confirmDialogForItem ?
|
|
399
|
+
// Ignored via go/ees005
|
|
400
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
401
|
+
toolbarItems[confirmDialogForItem] : undefined;
|
|
402
|
+
}
|
|
383
403
|
const scrollable = config.scrollable;
|
|
384
|
-
const confirmDialogOptions = typeof (confirmButtonItem === null ||
|
|
404
|
+
const confirmDialogOptions = typeof ((_confirmButtonItem = confirmButtonItem) === null || _confirmButtonItem === void 0 ? void 0 : _confirmButtonItem.confirmDialog) === 'function' ? (_confirmButtonItem2 = confirmButtonItem) === null || _confirmButtonItem2 === void 0 ? void 0 : _confirmButtonItem2.confirmDialog() : (_confirmButtonItem3 = confirmButtonItem) === null || _confirmButtonItem3 === void 0 ? void 0 : _confirmButtonItem3.confirmDialog;
|
|
385
405
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
386
406
|
component: ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
|
|
387
407
|
componentId: camelCase(title),
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createCommand } from './plugin-factory';
|
|
2
|
-
export const showConfirmDialog = buttonIndex => createCommand({
|
|
2
|
+
export const showConfirmDialog = (buttonIndex, optionIndex) => createCommand({
|
|
3
3
|
type: 'SHOW_CONFIRM_DIALOG',
|
|
4
4
|
data: {
|
|
5
|
-
buttonIndex
|
|
5
|
+
buttonIndex,
|
|
6
|
+
optionIndex
|
|
6
7
|
}
|
|
7
8
|
}, tr => tr.setMeta('addToHistory', false));
|
|
8
9
|
export const hideConfirmDialog = () => createCommand({
|
|
@@ -3,7 +3,8 @@ export const reducer = (pluginState, action) => {
|
|
|
3
3
|
case 'SHOW_CONFIRM_DIALOG':
|
|
4
4
|
return {
|
|
5
5
|
...pluginState,
|
|
6
|
-
confirmDialogForItem: action.data.buttonIndex
|
|
6
|
+
confirmDialogForItem: action.data.buttonIndex,
|
|
7
|
+
confirmDialogForItemOption: action.data.optionIndex
|
|
7
8
|
};
|
|
8
9
|
case 'HIDE_CONFIRM_DIALOG':
|
|
9
10
|
return {
|
|
@@ -19,6 +19,7 @@ import { backgroundPaletteTooltipMessages } from '@atlaskit/editor-common/ui-col
|
|
|
19
19
|
import { ColorPickerButton, ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
|
|
20
20
|
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
21
21
|
import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
|
|
22
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
22
23
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
23
24
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
24
25
|
import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
|
|
@@ -178,6 +179,26 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
|
|
|
178
179
|
return item.render(editorView, idx, dispatchAnalyticsEvent);
|
|
179
180
|
}
|
|
180
181
|
case 'overflow-dropdown':
|
|
182
|
+
let options;
|
|
183
|
+
if (fg('platform_editor_fix_confirm_table_removal')) {
|
|
184
|
+
// if an option has a confirmDialog, we need to replace its onClick handler
|
|
185
|
+
// to set the state to show the confirm dialog
|
|
186
|
+
|
|
187
|
+
// crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
|
|
188
|
+
// which would need knowledge of indexes, showConfirmDialog etc.
|
|
189
|
+
options = item.options.map((option, optionIndex) => {
|
|
190
|
+
if (!('type' in option) && option.confirmDialog) {
|
|
191
|
+
const onClick = option.confirmDialog ? showConfirmDialog(idx, optionIndex) : option.onClick;
|
|
192
|
+
return {
|
|
193
|
+
...option,
|
|
194
|
+
onClick
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return option;
|
|
198
|
+
});
|
|
199
|
+
} else {
|
|
200
|
+
options = item.options;
|
|
201
|
+
}
|
|
181
202
|
return jsx(Dropdown, {
|
|
182
203
|
alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
|
|
183
204
|
key: idx,
|
|
@@ -187,7 +208,7 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
|
|
|
187
208
|
spacing: "spacious"
|
|
188
209
|
}),
|
|
189
210
|
dispatchCommand: dispatchCommand,
|
|
190
|
-
options:
|
|
211
|
+
options: options,
|
|
191
212
|
disabled: item.disabled,
|
|
192
213
|
tooltip: item.tooltip,
|
|
193
214
|
hideExpandIcon: true,
|
|
@@ -219,7 +219,7 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
|
|
|
219
219
|
* @returns JSX element representing the floating toolbar or null if not visible
|
|
220
220
|
*/
|
|
221
221
|
export function ContentComponent(_ref5) {
|
|
222
|
-
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
|
|
222
|
+
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
|
|
223
223
|
var pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
224
224
|
editorView = _ref5.editorView,
|
|
225
225
|
popupsMountPoint = _ref5.popupsMountPoint,
|
|
@@ -380,14 +380,33 @@ export function ContentComponent(_ref5) {
|
|
|
380
380
|
};
|
|
381
381
|
|
|
382
382
|
// Confirm dialog
|
|
383
|
-
var
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
383
|
+
var confirmButtonItem;
|
|
384
|
+
if (fg('platform_editor_fix_confirm_table_removal')) {
|
|
385
|
+
var _ref7 = floatingToolbarData || {},
|
|
386
|
+
confirmDialogForItem = _ref7.confirmDialogForItem,
|
|
387
|
+
confirmDialogForItemOption = _ref7.confirmDialogForItemOption;
|
|
388
|
+
var matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
|
|
389
|
+
if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
|
|
390
|
+
confirmButtonItem = matchingItem;
|
|
391
|
+
}
|
|
392
|
+
if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
|
|
393
|
+
var matchingItemOption = matchingItem.options[confirmDialogForItemOption];
|
|
394
|
+
|
|
395
|
+
// OverflowDropdownOption is the only member of the union that does not have a 'type' property
|
|
396
|
+
if (!('type' in matchingItemOption)) {
|
|
397
|
+
confirmButtonItem = matchingItemOption;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
} else {
|
|
401
|
+
var _ref8 = floatingToolbarData || {},
|
|
402
|
+
_confirmDialogForItem = _ref8.confirmDialogForItem;
|
|
403
|
+
confirmButtonItem = _confirmDialogForItem ?
|
|
404
|
+
// Ignored via go/ees005
|
|
405
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
406
|
+
toolbarItems[_confirmDialogForItem] : undefined;
|
|
407
|
+
}
|
|
389
408
|
var scrollable = config.scrollable;
|
|
390
|
-
var confirmDialogOptions = typeof (confirmButtonItem === null ||
|
|
409
|
+
var confirmDialogOptions = typeof ((_confirmButtonItem = confirmButtonItem) === null || _confirmButtonItem === void 0 ? void 0 : _confirmButtonItem.confirmDialog) === 'function' ? (_confirmButtonItem2 = confirmButtonItem) === null || _confirmButtonItem2 === void 0 ? void 0 : _confirmButtonItem2.confirmDialog() : (_confirmButtonItem3 = confirmButtonItem) === null || _confirmButtonItem3 === void 0 ? void 0 : _confirmButtonItem3.confirmDialog;
|
|
391
410
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
392
411
|
component: ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
|
|
393
412
|
componentId: camelCase(title),
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createCommand } from './plugin-factory';
|
|
2
|
-
export var showConfirmDialog = function showConfirmDialog(buttonIndex) {
|
|
2
|
+
export var showConfirmDialog = function showConfirmDialog(buttonIndex, optionIndex) {
|
|
3
3
|
return createCommand({
|
|
4
4
|
type: 'SHOW_CONFIRM_DIALOG',
|
|
5
5
|
data: {
|
|
6
|
-
buttonIndex: buttonIndex
|
|
6
|
+
buttonIndex: buttonIndex,
|
|
7
|
+
optionIndex: optionIndex
|
|
7
8
|
}
|
|
8
9
|
}, function (tr) {
|
|
9
10
|
return tr.setMeta('addToHistory', false);
|
|
@@ -5,7 +5,8 @@ export var reducer = function reducer(pluginState, action) {
|
|
|
5
5
|
switch (action.type) {
|
|
6
6
|
case 'SHOW_CONFIRM_DIALOG':
|
|
7
7
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
8
|
-
confirmDialogForItem: action.data.buttonIndex
|
|
8
|
+
confirmDialogForItem: action.data.buttonIndex,
|
|
9
|
+
confirmDialogForItemOption: action.data.optionIndex
|
|
9
10
|
});
|
|
10
11
|
case 'HIDE_CONFIRM_DIALOG':
|
|
11
12
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
package/dist/esm/ui/Toolbar.js
CHANGED
|
@@ -7,6 +7,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
9
9
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
|
+
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; }
|
|
11
|
+
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) { _defineProperty(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; }
|
|
10
12
|
/* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation */
|
|
11
13
|
/**
|
|
12
14
|
* @jsxRuntime classic
|
|
@@ -26,6 +28,7 @@ import { backgroundPaletteTooltipMessages } from '@atlaskit/editor-common/ui-col
|
|
|
26
28
|
import { ColorPickerButton, ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
|
|
27
29
|
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
28
30
|
import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
|
|
31
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
29
32
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
30
33
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
31
34
|
import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
|
|
@@ -194,6 +197,25 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
194
197
|
return item.render(editorView, idx, dispatchAnalyticsEvent);
|
|
195
198
|
}
|
|
196
199
|
case 'overflow-dropdown':
|
|
200
|
+
var options;
|
|
201
|
+
if (fg('platform_editor_fix_confirm_table_removal')) {
|
|
202
|
+
// if an option has a confirmDialog, we need to replace its onClick handler
|
|
203
|
+
// to set the state to show the confirm dialog
|
|
204
|
+
|
|
205
|
+
// crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
|
|
206
|
+
// which would need knowledge of indexes, showConfirmDialog etc.
|
|
207
|
+
options = item.options.map(function (option, optionIndex) {
|
|
208
|
+
if (!('type' in option) && option.confirmDialog) {
|
|
209
|
+
var onClick = option.confirmDialog ? showConfirmDialog(idx, optionIndex) : option.onClick;
|
|
210
|
+
return _objectSpread(_objectSpread({}, option), {}, {
|
|
211
|
+
onClick: onClick
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return option;
|
|
215
|
+
});
|
|
216
|
+
} else {
|
|
217
|
+
options = item.options;
|
|
218
|
+
}
|
|
197
219
|
return jsx(Dropdown, {
|
|
198
220
|
alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
|
|
199
221
|
key: idx,
|
|
@@ -203,7 +225,7 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
203
225
|
spacing: "spacious"
|
|
204
226
|
}),
|
|
205
227
|
dispatchCommand: dispatchCommand,
|
|
206
|
-
options:
|
|
228
|
+
options: options,
|
|
207
229
|
disabled: item.disabled,
|
|
208
230
|
tooltip: item.tooltip,
|
|
209
231
|
hideExpandIcon: true,
|
|
@@ -24,6 +24,7 @@ export type FloatingToolbarPluginState = {
|
|
|
24
24
|
};
|
|
25
25
|
export type FloatingToolbarPluginData = {
|
|
26
26
|
confirmDialogForItem?: number;
|
|
27
|
+
confirmDialogForItemOption?: number;
|
|
27
28
|
};
|
|
28
29
|
export type ForceFocusSelector = (selector: string | null) => (tr: Transaction) => Transaction;
|
|
29
30
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
2
|
-
export declare const showConfirmDialog: (buttonIndex: number) => Command;
|
|
2
|
+
export declare const showConfirmDialog: (buttonIndex: number, optionIndex?: number) => Command;
|
|
3
3
|
export declare const hideConfirmDialog: () => Command;
|
|
@@ -24,6 +24,7 @@ export type FloatingToolbarPluginState = {
|
|
|
24
24
|
};
|
|
25
25
|
export type FloatingToolbarPluginData = {
|
|
26
26
|
confirmDialogForItem?: number;
|
|
27
|
+
confirmDialogForItemOption?: number;
|
|
27
28
|
};
|
|
28
29
|
export type ForceFocusSelector = (selector: string | null) => (tr: Transaction) => Transaction;
|
|
29
30
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
2
|
-
export declare const showConfirmDialog: (buttonIndex: number) => Command;
|
|
2
|
+
export declare const showConfirmDialog: (buttonIndex: number, optionIndex?: number) => Command;
|
|
3
3
|
export declare const hideConfirmDialog: () => Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-floating-toolbar",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.2",
|
|
4
4
|
"description": "Floating toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-user-intent": "^4.0.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
40
40
|
"@atlaskit/emoji": "^69.5.0",
|
|
41
|
-
"@atlaskit/icon": "^28.
|
|
41
|
+
"@atlaskit/icon": "^28.4.0",
|
|
42
42
|
"@atlaskit/menu": "^8.4.0",
|
|
43
43
|
"@atlaskit/modal-dialog": "^14.4.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/primitives": "^14.15.0",
|
|
46
46
|
"@atlaskit/select": "^21.3.0",
|
|
47
47
|
"@atlaskit/theme": "^21.0.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^13.2.0",
|
|
49
49
|
"@atlaskit/tokens": "^6.4.0",
|
|
50
50
|
"@atlaskit/tooltip": "^20.5.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
@@ -121,6 +121,9 @@
|
|
|
121
121
|
},
|
|
122
122
|
"platform_editor_block_menu_hide_floating_toolbar": {
|
|
123
123
|
"type": "boolean"
|
|
124
|
+
},
|
|
125
|
+
"platform_editor_fix_confirm_table_removal": {
|
|
126
|
+
"type": "boolean"
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
}
|