@atlaskit/editor-plugin-floating-toolbar 4.1.4 → 4.1.6
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 +15 -0
- package/dist/cjs/floatingToolbarPlugin.js +75 -20
- package/dist/cjs/ui/EmojiPickerButton.js +10 -3
- package/dist/cjs/ui/Toolbar.js +33 -9
- package/dist/es2019/floatingToolbarPlugin.js +75 -20
- package/dist/es2019/ui/EmojiPickerButton.js +11 -4
- package/dist/es2019/ui/Toolbar.js +31 -8
- package/dist/esm/floatingToolbarPlugin.js +76 -21
- package/dist/esm/ui/EmojiPickerButton.js +11 -4
- package/dist/esm/ui/Toolbar.js +33 -9
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 4.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 4.1.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#147357](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/147357)
|
|
14
|
+
[`1eab8cfeaf029`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1eab8cfeaf029) -
|
|
15
|
+
Migrate extensions and floating toolbar plugins to use useSharedPluginStateSelector hook
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 4.1.4
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -19,6 +19,7 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
19
19
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
20
20
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
21
21
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
22
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
22
23
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
23
24
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
24
25
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -212,6 +213,62 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
|
|
|
212
213
|
}
|
|
213
214
|
};
|
|
214
215
|
};
|
|
216
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
|
|
217
|
+
// floatingToolbar
|
|
218
|
+
var configWithNodeInfo = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'floatingToolbar.configWithNodeInfo');
|
|
219
|
+
var floatingToolbarData = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'floatingToolbar.floatingToolbarData');
|
|
220
|
+
|
|
221
|
+
// editorDisabled
|
|
222
|
+
var editorDisabledState = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorDisabled.editorDisabled');
|
|
223
|
+
|
|
224
|
+
// editorViewMode
|
|
225
|
+
var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.mode');
|
|
226
|
+
var contentMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.contentMode');
|
|
227
|
+
var isConsumption = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.isConsumption');
|
|
228
|
+
|
|
229
|
+
// userIntent
|
|
230
|
+
var currentUserIntent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'userIntent.currentUserIntent');
|
|
231
|
+
|
|
232
|
+
// blockControls
|
|
233
|
+
var isDragging = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi,
|
|
234
|
+
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
235
|
+
'blockControls.isDragging');
|
|
236
|
+
// isMenuOpen
|
|
237
|
+
var isMenuOpen = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi,
|
|
238
|
+
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
239
|
+
'blockControls.isMenuOpen');
|
|
240
|
+
return {
|
|
241
|
+
configWithNodeInfo: configWithNodeInfo,
|
|
242
|
+
floatingToolbarData: floatingToolbarData,
|
|
243
|
+
editorDisabled: editorDisabledState,
|
|
244
|
+
mode: mode,
|
|
245
|
+
contentMode: contentMode,
|
|
246
|
+
isConsumption: isConsumption,
|
|
247
|
+
currentUserIntent: currentUserIntent,
|
|
248
|
+
isDragging: isDragging,
|
|
249
|
+
isMenuOpen: isMenuOpen
|
|
250
|
+
};
|
|
251
|
+
}, function (pluginInjectionApi) {
|
|
252
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent',
|
|
253
|
+
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
254
|
+
'blockControls']),
|
|
255
|
+
floatingToolbarState = _useSharedPluginState.floatingToolbarState,
|
|
256
|
+
editorDisabledState = _useSharedPluginState.editorDisabledState,
|
|
257
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState,
|
|
258
|
+
userIntentState = _useSharedPluginState.userIntentState,
|
|
259
|
+
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
260
|
+
return {
|
|
261
|
+
configWithNodeInfo: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.configWithNodeInfo,
|
|
262
|
+
floatingToolbarData: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.floatingToolbarData,
|
|
263
|
+
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
|
|
264
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
265
|
+
contentMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.contentMode,
|
|
266
|
+
isConsumption: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.isConsumption,
|
|
267
|
+
currentUserIntent: userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent,
|
|
268
|
+
isDragging: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging,
|
|
269
|
+
isMenuOpen: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen
|
|
270
|
+
};
|
|
271
|
+
});
|
|
215
272
|
function ContentComponent(_ref5) {
|
|
216
273
|
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
|
|
217
274
|
var pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
@@ -221,22 +278,21 @@ function ContentComponent(_ref5) {
|
|
|
221
278
|
popupsScrollableElement = _ref5.popupsScrollableElement,
|
|
222
279
|
providerFactory = _ref5.providerFactory,
|
|
223
280
|
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
224
|
-
var
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
floatingToolbarData = _ref6.floatingToolbarData;
|
|
281
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
282
|
+
configWithNodeInfo = _useSharedState.configWithNodeInfo,
|
|
283
|
+
contentMode = _useSharedState.contentMode,
|
|
284
|
+
currentUserIntent = _useSharedState.currentUserIntent,
|
|
285
|
+
editorDisabled = _useSharedState.editorDisabled,
|
|
286
|
+
floatingToolbarData = _useSharedState.floatingToolbarData,
|
|
287
|
+
isConsumption = _useSharedState.isConsumption,
|
|
288
|
+
isDragging = _useSharedState.isDragging,
|
|
289
|
+
isMenuOpen = _useSharedState.isMenuOpen,
|
|
290
|
+
mode = _useSharedState.mode;
|
|
235
291
|
if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
|
|
236
292
|
return null;
|
|
237
293
|
}
|
|
238
294
|
if ((0, _platformFeatureFlags.fg)('platform_editor_user_intent_plugin')) {
|
|
239
|
-
if (
|
|
295
|
+
if (currentUserIntent === 'dragging') {
|
|
240
296
|
return null;
|
|
241
297
|
}
|
|
242
298
|
|
|
@@ -245,10 +301,10 @@ function ContentComponent(_ref5) {
|
|
|
245
301
|
// return null;
|
|
246
302
|
// }
|
|
247
303
|
} else {
|
|
248
|
-
if (
|
|
304
|
+
if (isDragging) {
|
|
249
305
|
return null;
|
|
250
306
|
}
|
|
251
|
-
if (
|
|
307
|
+
if (isMenuOpen && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
252
308
|
return null;
|
|
253
309
|
}
|
|
254
310
|
}
|
|
@@ -284,9 +340,8 @@ function ContentComponent(_ref5) {
|
|
|
284
340
|
_config$stick = config.stick,
|
|
285
341
|
stick = _config$stick === void 0 ? true : _config$stick;
|
|
286
342
|
var targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
287
|
-
var
|
|
288
|
-
|
|
289
|
-
if (!targetRef || isEditorDisabled && !isInViewMode) {
|
|
343
|
+
var isInViewMode = mode === 'view';
|
|
344
|
+
if (!targetRef || editorDisabled && !isInViewMode) {
|
|
290
345
|
return null;
|
|
291
346
|
}
|
|
292
347
|
|
|
@@ -336,7 +391,7 @@ function ContentComponent(_ref5) {
|
|
|
336
391
|
}
|
|
337
392
|
});
|
|
338
393
|
if (!(0, _experiments.editorExperiment)('live_pages_graceful_edit', 'control') && viewModeToolbarEntry !== 'none') {
|
|
339
|
-
if (
|
|
394
|
+
if (contentMode === 'live-edit' && isConsumption) {
|
|
340
395
|
var hasOtherToolbarItems = toolbarItems && toolbarItems.length !== 0;
|
|
341
396
|
var shouldAddToolbarItems = viewModeToolbarEntry === 'expand-existing-only' ? hasOtherToolbarItems : true;
|
|
342
397
|
if (shouldAddToolbarItems) {
|
|
@@ -372,8 +427,8 @@ function ContentComponent(_ref5) {
|
|
|
372
427
|
};
|
|
373
428
|
|
|
374
429
|
// Confirm dialog
|
|
375
|
-
var
|
|
376
|
-
confirmDialogForItem =
|
|
430
|
+
var _ref6 = floatingToolbarData || {},
|
|
431
|
+
confirmDialogForItem = _ref6.confirmDialogForItem;
|
|
377
432
|
var confirmButtonItem = confirmDialogForItem ?
|
|
378
433
|
// Ignored via go/ees005
|
|
379
434
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -13,6 +13,7 @@ var _new = require("@atlaskit/button/new");
|
|
|
13
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
14
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
15
15
|
var _uiReact = require("@atlaskit/editor-common/ui-react");
|
|
16
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
16
17
|
var _emoji = require("@atlaskit/emoji");
|
|
17
18
|
var _emojiAdd = _interopRequireDefault(require("@atlaskit/icon/core/emoji-add"));
|
|
18
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -62,11 +63,17 @@ var emojiPickerButtonWrapperVisualRefresh = (0, _react2.css)({
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
|
-
var
|
|
66
|
-
var
|
|
66
|
+
var useEmojiProvider = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
|
67
|
+
var emojiProvider = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'emoji.emojiProvider');
|
|
68
|
+
return emojiProvider ? Promise.resolve(emojiProvider) : undefined;
|
|
69
|
+
}, function (api) {
|
|
70
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['emoji']),
|
|
67
71
|
emojiState = _useSharedPluginState.emojiState;
|
|
72
|
+
return emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider ? Promise.resolve(emojiState.emojiProvider) : undefined;
|
|
73
|
+
});
|
|
74
|
+
var EmojiPickerWithProvider = function EmojiPickerWithProvider(props) {
|
|
75
|
+
var emojiProvider = useEmojiProvider(props.pluginInjectionApi);
|
|
68
76
|
var setOutsideClickTargetRef = (0, _react.useContext)(_uiReact.OutsideClickTargetRefContext);
|
|
69
|
-
var emojiProvider = emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider ? Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider) : undefined;
|
|
70
77
|
if (!emojiProvider) {
|
|
71
78
|
return null;
|
|
72
79
|
}
|
package/dist/cjs/ui/Toolbar.js
CHANGED
|
@@ -584,8 +584,8 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
584
584
|
// this prevents https://product-fabric.atlassian.net/browse/ED-10207
|
|
585
585
|
(0, _inherits2.default)(Toolbar, _Component);
|
|
586
586
|
return (0, _createClass2.default)(Toolbar, [{
|
|
587
|
-
key: "
|
|
588
|
-
value: function
|
|
587
|
+
key: "resetStylingLegacy",
|
|
588
|
+
value: function resetStylingLegacy(_ref3) {
|
|
589
589
|
var table = _ref3.table;
|
|
590
590
|
if (this.props.editorView) {
|
|
591
591
|
var _this$props$api;
|
|
@@ -598,6 +598,20 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
598
598
|
(_this$props$api = this.props.api) === null || _this$props$api === void 0 || (_this$props$api = _this$props$api.decorations) === null || _this$props$api === void 0 || _this$props$api.actions.removeDecoration(state, dispatch);
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
|
+
|
|
602
|
+
// remove any decorations added by toolbar buttons i.e danger and selected styling
|
|
603
|
+
// this prevents https://product-fabric.atlassian.net/browse/ED-10207
|
|
604
|
+
}, {
|
|
605
|
+
key: "resetStyling",
|
|
606
|
+
value: function resetStyling() {
|
|
607
|
+
if (this.props.editorView) {
|
|
608
|
+
var _this$props$api2;
|
|
609
|
+
var _this$props$editorVie3 = this.props.editorView,
|
|
610
|
+
state = _this$props$editorVie3.state,
|
|
611
|
+
dispatch = _this$props$editorVie3.dispatch;
|
|
612
|
+
(_this$props$api2 = this.props.api) === null || _this$props$api2 === void 0 || (_this$props$api2 = _this$props$api2.decorations) === null || _this$props$api2 === void 0 || _this$props$api2.actions.removeDecoration(state, dispatch);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
601
615
|
}, {
|
|
602
616
|
key: "setDisableScroll",
|
|
603
617
|
value: function setDisableScroll(disabled) {
|
|
@@ -627,10 +641,16 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
627
641
|
value: function componentDidUpdate(prevProps) {
|
|
628
642
|
var _this$props;
|
|
629
643
|
(0, _forceFocus.checkShouldForceFocusAndApply)((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.editorView);
|
|
630
|
-
if (
|
|
631
|
-
this.
|
|
632
|
-
|
|
633
|
-
}
|
|
644
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_remove_slow_table_transactions')) {
|
|
645
|
+
if (this.props.node !== prevProps.node) {
|
|
646
|
+
this.resetStyling();
|
|
647
|
+
}
|
|
648
|
+
} else {
|
|
649
|
+
if (this.props.node !== prevProps.node) {
|
|
650
|
+
this.resetStylingLegacy({
|
|
651
|
+
table: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.node.type.name) === 'table'
|
|
652
|
+
});
|
|
653
|
+
}
|
|
634
654
|
}
|
|
635
655
|
}
|
|
636
656
|
}, {
|
|
@@ -642,9 +662,13 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
642
662
|
dispatch = editorView.dispatch;
|
|
643
663
|
dispatch((0, _forceFocus.forceFocusSelector)(null)(tr));
|
|
644
664
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}
|
|
665
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_remove_slow_table_transactions')) {
|
|
666
|
+
this.resetStyling();
|
|
667
|
+
} else {
|
|
668
|
+
this.resetStylingLegacy({
|
|
669
|
+
table: this.props.node.type.name === 'table'
|
|
670
|
+
});
|
|
671
|
+
}
|
|
648
672
|
}
|
|
649
673
|
}, {
|
|
650
674
|
key: "render",
|
|
@@ -2,10 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import camelCase from 'lodash/camelCase';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, CONTENT_COMPONENT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
5
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
7
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
8
8
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
9
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
9
10
|
import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
10
11
|
import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
11
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -195,16 +196,42 @@ export const floatingToolbarPlugin = ({
|
|
|
195
196
|
}
|
|
196
197
|
};
|
|
197
198
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
199
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
200
|
+
// floatingToolbar
|
|
201
|
+
const configWithNodeInfo = useSharedPluginStateSelector(pluginInjectionApi, 'floatingToolbar.configWithNodeInfo');
|
|
202
|
+
const floatingToolbarData = useSharedPluginStateSelector(pluginInjectionApi, 'floatingToolbar.floatingToolbarData');
|
|
203
|
+
|
|
204
|
+
// editorDisabled
|
|
205
|
+
const editorDisabledState = useSharedPluginStateSelector(pluginInjectionApi, 'editorDisabled.editorDisabled');
|
|
206
|
+
|
|
207
|
+
// editorViewMode
|
|
208
|
+
const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
209
|
+
const contentMode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.contentMode');
|
|
210
|
+
const isConsumption = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.isConsumption');
|
|
211
|
+
|
|
212
|
+
// userIntent
|
|
213
|
+
const currentUserIntent = useSharedPluginStateSelector(pluginInjectionApi, 'userIntent.currentUserIntent');
|
|
214
|
+
|
|
215
|
+
// blockControls
|
|
216
|
+
const isDragging = useSharedPluginStateSelector(pluginInjectionApi,
|
|
217
|
+
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
218
|
+
'blockControls.isDragging');
|
|
219
|
+
// isMenuOpen
|
|
220
|
+
const isMenuOpen = useSharedPluginStateSelector(pluginInjectionApi,
|
|
221
|
+
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
222
|
+
'blockControls.isMenuOpen');
|
|
223
|
+
return {
|
|
224
|
+
configWithNodeInfo,
|
|
225
|
+
floatingToolbarData,
|
|
226
|
+
editorDisabled: editorDisabledState,
|
|
227
|
+
mode,
|
|
228
|
+
contentMode,
|
|
229
|
+
isConsumption,
|
|
230
|
+
currentUserIntent,
|
|
231
|
+
isDragging,
|
|
232
|
+
isMenuOpen
|
|
233
|
+
};
|
|
234
|
+
}, pluginInjectionApi => {
|
|
208
235
|
const {
|
|
209
236
|
floatingToolbarState,
|
|
210
237
|
editorDisabledState,
|
|
@@ -215,15 +242,44 @@ export function ContentComponent({
|
|
|
215
242
|
} = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent',
|
|
216
243
|
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
217
244
|
'blockControls']);
|
|
245
|
+
return {
|
|
246
|
+
configWithNodeInfo: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.configWithNodeInfo,
|
|
247
|
+
floatingToolbarData: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.floatingToolbarData,
|
|
248
|
+
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
|
|
249
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
250
|
+
contentMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.contentMode,
|
|
251
|
+
isConsumption: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.isConsumption,
|
|
252
|
+
currentUserIntent: userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent,
|
|
253
|
+
isDragging: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging,
|
|
254
|
+
isMenuOpen: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
export function ContentComponent({
|
|
258
|
+
pluginInjectionApi,
|
|
259
|
+
editorView,
|
|
260
|
+
popupsMountPoint,
|
|
261
|
+
popupsBoundariesElement,
|
|
262
|
+
popupsScrollableElement,
|
|
263
|
+
providerFactory,
|
|
264
|
+
dispatchAnalyticsEvent
|
|
265
|
+
}) {
|
|
266
|
+
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
|
|
218
267
|
const {
|
|
219
268
|
configWithNodeInfo,
|
|
220
|
-
|
|
221
|
-
|
|
269
|
+
contentMode,
|
|
270
|
+
currentUserIntent,
|
|
271
|
+
editorDisabled,
|
|
272
|
+
floatingToolbarData,
|
|
273
|
+
isConsumption,
|
|
274
|
+
isDragging,
|
|
275
|
+
isMenuOpen,
|
|
276
|
+
mode
|
|
277
|
+
} = useSharedState(pluginInjectionApi);
|
|
222
278
|
if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
|
|
223
279
|
return null;
|
|
224
280
|
}
|
|
225
281
|
if (fg('platform_editor_user_intent_plugin')) {
|
|
226
|
-
if (
|
|
282
|
+
if (currentUserIntent === 'dragging') {
|
|
227
283
|
return null;
|
|
228
284
|
}
|
|
229
285
|
|
|
@@ -232,10 +288,10 @@ export function ContentComponent({
|
|
|
232
288
|
// return null;
|
|
233
289
|
// }
|
|
234
290
|
} else {
|
|
235
|
-
if (
|
|
291
|
+
if (isDragging) {
|
|
236
292
|
return null;
|
|
237
293
|
}
|
|
238
|
-
if (
|
|
294
|
+
if (isMenuOpen && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
239
295
|
return null;
|
|
240
296
|
}
|
|
241
297
|
}
|
|
@@ -272,9 +328,8 @@ export function ContentComponent({
|
|
|
272
328
|
stick = true
|
|
273
329
|
} = config;
|
|
274
330
|
const targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
if (!targetRef || isEditorDisabled && !isInViewMode) {
|
|
331
|
+
const isInViewMode = mode === 'view';
|
|
332
|
+
if (!targetRef || editorDisabled && !isInViewMode) {
|
|
278
333
|
return null;
|
|
279
334
|
}
|
|
280
335
|
|
|
@@ -316,7 +371,7 @@ export function ContentComponent({
|
|
|
316
371
|
typeGuard: value => typeof value === 'string' && ['text', 'nodes'].includes(value)
|
|
317
372
|
});
|
|
318
373
|
if (!editorExperiment('live_pages_graceful_edit', 'control') && viewModeToolbarEntry !== 'none') {
|
|
319
|
-
if (
|
|
374
|
+
if (contentMode === 'live-edit' && isConsumption) {
|
|
320
375
|
const hasOtherToolbarItems = toolbarItems && toolbarItems.length !== 0;
|
|
321
376
|
const shouldAddToolbarItems = viewModeToolbarEntry === 'expand-existing-only' ? hasOtherToolbarItems : true;
|
|
322
377
|
if (shouldAddToolbarItems) {
|
|
@@ -7,9 +7,10 @@ import React, { useCallback, useContext } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { IconButton } from '@atlaskit/button/new';
|
|
10
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
11
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
12
12
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
13
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
13
14
|
import { EmojiPicker } from '@atlaskit/emoji';
|
|
14
15
|
import EmojiAddIcon from '@atlaskit/icon/core/emoji-add';
|
|
15
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -51,12 +52,18 @@ const emojiPickerButtonWrapperVisualRefresh = css({
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
});
|
|
54
|
-
const
|
|
55
|
+
const useEmojiProvider = sharedPluginStateHookMigratorFactory(api => {
|
|
56
|
+
const emojiProvider = useSharedPluginStateSelector(api, 'emoji.emojiProvider');
|
|
57
|
+
return emojiProvider ? Promise.resolve(emojiProvider) : undefined;
|
|
58
|
+
}, api => {
|
|
55
59
|
const {
|
|
56
60
|
emojiState
|
|
57
|
-
} = useSharedPluginState(
|
|
61
|
+
} = useSharedPluginState(api, ['emoji']);
|
|
62
|
+
return emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider ? Promise.resolve(emojiState.emojiProvider) : undefined;
|
|
63
|
+
});
|
|
64
|
+
const EmojiPickerWithProvider = props => {
|
|
65
|
+
const emojiProvider = useEmojiProvider(props.pluginInjectionApi);
|
|
58
66
|
const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
59
|
-
const emojiProvider = emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider ? Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider) : undefined;
|
|
60
67
|
if (!emojiProvider) {
|
|
61
68
|
return null;
|
|
62
69
|
}
|
|
@@ -541,7 +541,7 @@ class Toolbar extends Component {
|
|
|
541
541
|
}
|
|
542
542
|
// remove any decorations added by toolbar buttons i.e danger and selected styling
|
|
543
543
|
// this prevents https://product-fabric.atlassian.net/browse/ED-10207
|
|
544
|
-
|
|
544
|
+
resetStylingLegacy({
|
|
545
545
|
table
|
|
546
546
|
}) {
|
|
547
547
|
if (this.props.editorView) {
|
|
@@ -556,6 +556,19 @@ class Toolbar extends Component {
|
|
|
556
556
|
(_this$props$api = this.props.api) === null || _this$props$api === void 0 ? void 0 : (_this$props$api$decor = _this$props$api.decorations) === null || _this$props$api$decor === void 0 ? void 0 : _this$props$api$decor.actions.removeDecoration(state, dispatch);
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
+
|
|
560
|
+
// remove any decorations added by toolbar buttons i.e danger and selected styling
|
|
561
|
+
// this prevents https://product-fabric.atlassian.net/browse/ED-10207
|
|
562
|
+
resetStyling() {
|
|
563
|
+
if (this.props.editorView) {
|
|
564
|
+
var _this$props$api2, _this$props$api2$deco;
|
|
565
|
+
const {
|
|
566
|
+
state,
|
|
567
|
+
dispatch
|
|
568
|
+
} = this.props.editorView;
|
|
569
|
+
(_this$props$api2 = this.props.api) === null || _this$props$api2 === void 0 ? void 0 : (_this$props$api2$deco = _this$props$api2.decorations) === null || _this$props$api2$deco === void 0 ? void 0 : _this$props$api2$deco.actions.removeDecoration(state, dispatch);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
559
572
|
setDisableScroll(disabled) {
|
|
560
573
|
// wait before setting disabled state incase users jumping from one popup to another
|
|
561
574
|
if (disabled) {
|
|
@@ -578,10 +591,16 @@ class Toolbar extends Component {
|
|
|
578
591
|
componentDidUpdate(prevProps) {
|
|
579
592
|
var _this$props;
|
|
580
593
|
checkShouldForceFocusAndApply((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.editorView);
|
|
581
|
-
if (
|
|
582
|
-
this.
|
|
583
|
-
|
|
584
|
-
}
|
|
594
|
+
if (fg('platform_editor_remove_slow_table_transactions')) {
|
|
595
|
+
if (this.props.node !== prevProps.node) {
|
|
596
|
+
this.resetStyling();
|
|
597
|
+
}
|
|
598
|
+
} else {
|
|
599
|
+
if (this.props.node !== prevProps.node) {
|
|
600
|
+
this.resetStylingLegacy({
|
|
601
|
+
table: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.node.type.name) === 'table'
|
|
602
|
+
});
|
|
603
|
+
}
|
|
585
604
|
}
|
|
586
605
|
}
|
|
587
606
|
componentWillUnmount() {
|
|
@@ -597,9 +616,13 @@ class Toolbar extends Component {
|
|
|
597
616
|
} = editorView;
|
|
598
617
|
dispatch(forceFocusSelector(null)(tr));
|
|
599
618
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
}
|
|
619
|
+
if (fg('platform_editor_remove_slow_table_transactions')) {
|
|
620
|
+
this.resetStyling();
|
|
621
|
+
} else {
|
|
622
|
+
this.resetStylingLegacy({
|
|
623
|
+
table: this.props.node.type.name === 'table'
|
|
624
|
+
});
|
|
625
|
+
}
|
|
603
626
|
}
|
|
604
627
|
render() {
|
|
605
628
|
const {
|
|
@@ -6,10 +6,11 @@ import React from 'react';
|
|
|
6
6
|
import camelCase from 'lodash/camelCase';
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, CONTENT_COMPONENT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
9
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
9
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
10
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
11
11
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
12
12
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
13
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
13
14
|
import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
14
15
|
import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
15
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -200,6 +201,62 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
|
|
|
200
201
|
}
|
|
201
202
|
};
|
|
202
203
|
};
|
|
204
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInjectionApi) {
|
|
205
|
+
// floatingToolbar
|
|
206
|
+
var configWithNodeInfo = useSharedPluginStateSelector(pluginInjectionApi, 'floatingToolbar.configWithNodeInfo');
|
|
207
|
+
var floatingToolbarData = useSharedPluginStateSelector(pluginInjectionApi, 'floatingToolbar.floatingToolbarData');
|
|
208
|
+
|
|
209
|
+
// editorDisabled
|
|
210
|
+
var editorDisabledState = useSharedPluginStateSelector(pluginInjectionApi, 'editorDisabled.editorDisabled');
|
|
211
|
+
|
|
212
|
+
// editorViewMode
|
|
213
|
+
var mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
214
|
+
var contentMode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.contentMode');
|
|
215
|
+
var isConsumption = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.isConsumption');
|
|
216
|
+
|
|
217
|
+
// userIntent
|
|
218
|
+
var currentUserIntent = useSharedPluginStateSelector(pluginInjectionApi, 'userIntent.currentUserIntent');
|
|
219
|
+
|
|
220
|
+
// blockControls
|
|
221
|
+
var isDragging = useSharedPluginStateSelector(pluginInjectionApi,
|
|
222
|
+
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
223
|
+
'blockControls.isDragging');
|
|
224
|
+
// isMenuOpen
|
|
225
|
+
var isMenuOpen = useSharedPluginStateSelector(pluginInjectionApi,
|
|
226
|
+
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
227
|
+
'blockControls.isMenuOpen');
|
|
228
|
+
return {
|
|
229
|
+
configWithNodeInfo: configWithNodeInfo,
|
|
230
|
+
floatingToolbarData: floatingToolbarData,
|
|
231
|
+
editorDisabled: editorDisabledState,
|
|
232
|
+
mode: mode,
|
|
233
|
+
contentMode: contentMode,
|
|
234
|
+
isConsumption: isConsumption,
|
|
235
|
+
currentUserIntent: currentUserIntent,
|
|
236
|
+
isDragging: isDragging,
|
|
237
|
+
isMenuOpen: isMenuOpen
|
|
238
|
+
};
|
|
239
|
+
}, function (pluginInjectionApi) {
|
|
240
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent',
|
|
241
|
+
// @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
|
|
242
|
+
'blockControls']),
|
|
243
|
+
floatingToolbarState = _useSharedPluginState.floatingToolbarState,
|
|
244
|
+
editorDisabledState = _useSharedPluginState.editorDisabledState,
|
|
245
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState,
|
|
246
|
+
userIntentState = _useSharedPluginState.userIntentState,
|
|
247
|
+
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
248
|
+
return {
|
|
249
|
+
configWithNodeInfo: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.configWithNodeInfo,
|
|
250
|
+
floatingToolbarData: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.floatingToolbarData,
|
|
251
|
+
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
|
|
252
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
253
|
+
contentMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.contentMode,
|
|
254
|
+
isConsumption: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.isConsumption,
|
|
255
|
+
currentUserIntent: userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent,
|
|
256
|
+
isDragging: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging,
|
|
257
|
+
isMenuOpen: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen
|
|
258
|
+
};
|
|
259
|
+
});
|
|
203
260
|
export function ContentComponent(_ref5) {
|
|
204
261
|
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
|
|
205
262
|
var pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
@@ -209,22 +266,21 @@ export function ContentComponent(_ref5) {
|
|
|
209
266
|
popupsScrollableElement = _ref5.popupsScrollableElement,
|
|
210
267
|
providerFactory = _ref5.providerFactory,
|
|
211
268
|
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
212
|
-
var
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
floatingToolbarData = _ref6.floatingToolbarData;
|
|
269
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
270
|
+
configWithNodeInfo = _useSharedState.configWithNodeInfo,
|
|
271
|
+
contentMode = _useSharedState.contentMode,
|
|
272
|
+
currentUserIntent = _useSharedState.currentUserIntent,
|
|
273
|
+
editorDisabled = _useSharedState.editorDisabled,
|
|
274
|
+
floatingToolbarData = _useSharedState.floatingToolbarData,
|
|
275
|
+
isConsumption = _useSharedState.isConsumption,
|
|
276
|
+
isDragging = _useSharedState.isDragging,
|
|
277
|
+
isMenuOpen = _useSharedState.isMenuOpen,
|
|
278
|
+
mode = _useSharedState.mode;
|
|
223
279
|
if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
|
|
224
280
|
return null;
|
|
225
281
|
}
|
|
226
282
|
if (fg('platform_editor_user_intent_plugin')) {
|
|
227
|
-
if (
|
|
283
|
+
if (currentUserIntent === 'dragging') {
|
|
228
284
|
return null;
|
|
229
285
|
}
|
|
230
286
|
|
|
@@ -233,10 +289,10 @@ export function ContentComponent(_ref5) {
|
|
|
233
289
|
// return null;
|
|
234
290
|
// }
|
|
235
291
|
} else {
|
|
236
|
-
if (
|
|
292
|
+
if (isDragging) {
|
|
237
293
|
return null;
|
|
238
294
|
}
|
|
239
|
-
if (
|
|
295
|
+
if (isMenuOpen && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
240
296
|
return null;
|
|
241
297
|
}
|
|
242
298
|
}
|
|
@@ -272,9 +328,8 @@ export function ContentComponent(_ref5) {
|
|
|
272
328
|
_config$stick = config.stick,
|
|
273
329
|
stick = _config$stick === void 0 ? true : _config$stick;
|
|
274
330
|
var targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
if (!targetRef || isEditorDisabled && !isInViewMode) {
|
|
331
|
+
var isInViewMode = mode === 'view';
|
|
332
|
+
if (!targetRef || editorDisabled && !isInViewMode) {
|
|
278
333
|
return null;
|
|
279
334
|
}
|
|
280
335
|
|
|
@@ -324,7 +379,7 @@ export function ContentComponent(_ref5) {
|
|
|
324
379
|
}
|
|
325
380
|
});
|
|
326
381
|
if (!editorExperiment('live_pages_graceful_edit', 'control') && viewModeToolbarEntry !== 'none') {
|
|
327
|
-
if (
|
|
382
|
+
if (contentMode === 'live-edit' && isConsumption) {
|
|
328
383
|
var hasOtherToolbarItems = toolbarItems && toolbarItems.length !== 0;
|
|
329
384
|
var shouldAddToolbarItems = viewModeToolbarEntry === 'expand-existing-only' ? hasOtherToolbarItems : true;
|
|
330
385
|
if (shouldAddToolbarItems) {
|
|
@@ -360,8 +415,8 @@ export function ContentComponent(_ref5) {
|
|
|
360
415
|
};
|
|
361
416
|
|
|
362
417
|
// Confirm dialog
|
|
363
|
-
var
|
|
364
|
-
confirmDialogForItem =
|
|
418
|
+
var _ref6 = floatingToolbarData || {},
|
|
419
|
+
confirmDialogForItem = _ref6.confirmDialogForItem;
|
|
365
420
|
var confirmButtonItem = confirmDialogForItem ?
|
|
366
421
|
// Ignored via go/ees005
|
|
367
422
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -8,9 +8,10 @@ import React, { useCallback, useContext } from 'react';
|
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
10
10
|
import { IconButton } from '@atlaskit/button/new';
|
|
11
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
12
12
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
13
13
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
14
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
14
15
|
import { EmojiPicker } from '@atlaskit/emoji';
|
|
15
16
|
import EmojiAddIcon from '@atlaskit/icon/core/emoji-add';
|
|
16
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -52,11 +53,17 @@ var emojiPickerButtonWrapperVisualRefresh = css({
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
});
|
|
55
|
-
var
|
|
56
|
-
var
|
|
56
|
+
var useEmojiProvider = sharedPluginStateHookMigratorFactory(function (api) {
|
|
57
|
+
var emojiProvider = useSharedPluginStateSelector(api, 'emoji.emojiProvider');
|
|
58
|
+
return emojiProvider ? Promise.resolve(emojiProvider) : undefined;
|
|
59
|
+
}, function (api) {
|
|
60
|
+
var _useSharedPluginState = useSharedPluginState(api, ['emoji']),
|
|
57
61
|
emojiState = _useSharedPluginState.emojiState;
|
|
62
|
+
return emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider ? Promise.resolve(emojiState.emojiProvider) : undefined;
|
|
63
|
+
});
|
|
64
|
+
var EmojiPickerWithProvider = function EmojiPickerWithProvider(props) {
|
|
65
|
+
var emojiProvider = useEmojiProvider(props.pluginInjectionApi);
|
|
58
66
|
var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
59
|
-
var emojiProvider = emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider ? Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider) : undefined;
|
|
60
67
|
if (!emojiProvider) {
|
|
61
68
|
return null;
|
|
62
69
|
}
|
package/dist/esm/ui/Toolbar.js
CHANGED
|
@@ -577,8 +577,8 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
577
577
|
// this prevents https://product-fabric.atlassian.net/browse/ED-10207
|
|
578
578
|
_inherits(Toolbar, _Component);
|
|
579
579
|
return _createClass(Toolbar, [{
|
|
580
|
-
key: "
|
|
581
|
-
value: function
|
|
580
|
+
key: "resetStylingLegacy",
|
|
581
|
+
value: function resetStylingLegacy(_ref3) {
|
|
582
582
|
var table = _ref3.table;
|
|
583
583
|
if (this.props.editorView) {
|
|
584
584
|
var _this$props$api;
|
|
@@ -591,6 +591,20 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
591
591
|
(_this$props$api = this.props.api) === null || _this$props$api === void 0 || (_this$props$api = _this$props$api.decorations) === null || _this$props$api === void 0 || _this$props$api.actions.removeDecoration(state, dispatch);
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
|
+
|
|
595
|
+
// remove any decorations added by toolbar buttons i.e danger and selected styling
|
|
596
|
+
// this prevents https://product-fabric.atlassian.net/browse/ED-10207
|
|
597
|
+
}, {
|
|
598
|
+
key: "resetStyling",
|
|
599
|
+
value: function resetStyling() {
|
|
600
|
+
if (this.props.editorView) {
|
|
601
|
+
var _this$props$api2;
|
|
602
|
+
var _this$props$editorVie3 = this.props.editorView,
|
|
603
|
+
state = _this$props$editorVie3.state,
|
|
604
|
+
dispatch = _this$props$editorVie3.dispatch;
|
|
605
|
+
(_this$props$api2 = this.props.api) === null || _this$props$api2 === void 0 || (_this$props$api2 = _this$props$api2.decorations) === null || _this$props$api2 === void 0 || _this$props$api2.actions.removeDecoration(state, dispatch);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
594
608
|
}, {
|
|
595
609
|
key: "setDisableScroll",
|
|
596
610
|
value: function setDisableScroll(disabled) {
|
|
@@ -620,10 +634,16 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
620
634
|
value: function componentDidUpdate(prevProps) {
|
|
621
635
|
var _this$props;
|
|
622
636
|
checkShouldForceFocusAndApply((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.editorView);
|
|
623
|
-
if (
|
|
624
|
-
this.
|
|
625
|
-
|
|
626
|
-
}
|
|
637
|
+
if (fg('platform_editor_remove_slow_table_transactions')) {
|
|
638
|
+
if (this.props.node !== prevProps.node) {
|
|
639
|
+
this.resetStyling();
|
|
640
|
+
}
|
|
641
|
+
} else {
|
|
642
|
+
if (this.props.node !== prevProps.node) {
|
|
643
|
+
this.resetStylingLegacy({
|
|
644
|
+
table: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.node.type.name) === 'table'
|
|
645
|
+
});
|
|
646
|
+
}
|
|
627
647
|
}
|
|
628
648
|
}
|
|
629
649
|
}, {
|
|
@@ -635,9 +655,13 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
635
655
|
dispatch = editorView.dispatch;
|
|
636
656
|
dispatch(forceFocusSelector(null)(tr));
|
|
637
657
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
658
|
+
if (fg('platform_editor_remove_slow_table_transactions')) {
|
|
659
|
+
this.resetStyling();
|
|
660
|
+
} else {
|
|
661
|
+
this.resetStylingLegacy({
|
|
662
|
+
table: this.props.node.type.name === 'table'
|
|
663
|
+
});
|
|
664
|
+
}
|
|
641
665
|
}
|
|
642
666
|
}, {
|
|
643
667
|
key: "render",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-floating-toolbar",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.6",
|
|
4
4
|
"description": "Floating toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"@atlaskit/adf-utils": "^19.19.0",
|
|
29
29
|
"@atlaskit/button": "^23.0.0",
|
|
30
30
|
"@atlaskit/checkbox": "^17.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^105.
|
|
31
|
+
"@atlaskit/editor-common": "^105.5.0",
|
|
32
32
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
33
|
-
"@atlaskit/editor-plugin-analytics": "^2.
|
|
33
|
+
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
34
34
|
"@atlaskit/editor-plugin-context-panel": "^4.1.0",
|
|
35
35
|
"@atlaskit/editor-plugin-copy-button": "^2.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-decorations": "^2.0.0",
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"@atlaskit/editor-plugin-table": "^10.9.0",
|
|
43
43
|
"@atlaskit/editor-plugin-user-intent": "^0.1.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
45
|
-
"@atlaskit/emoji": "^69.
|
|
45
|
+
"@atlaskit/emoji": "^69.2.0",
|
|
46
46
|
"@atlaskit/icon": "^26.0.0",
|
|
47
|
-
"@atlaskit/menu": "^
|
|
48
|
-
"@atlaskit/modal-dialog": "^14.
|
|
47
|
+
"@atlaskit/menu": "^6.0.0",
|
|
48
|
+
"@atlaskit/modal-dialog": "^14.2.0",
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
50
50
|
"@atlaskit/primitives": "^14.7.0",
|
|
51
51
|
"@atlaskit/select": "^20.4.0",
|
|
52
52
|
"@atlaskit/theme": "^18.0.0",
|
|
53
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
53
|
+
"@atlaskit/tmp-editor-statsig": "^4.22.0",
|
|
54
54
|
"@atlaskit/tokens": "^4.8.0",
|
|
55
55
|
"@atlaskit/tooltip": "^20.0.0",
|
|
56
56
|
"@babel/runtime": "^7.0.0",
|
|
@@ -137,6 +137,9 @@
|
|
|
137
137
|
"platform_editor_no_selection_until_interaction": {
|
|
138
138
|
"type": "boolean"
|
|
139
139
|
},
|
|
140
|
+
"platform_editor_remove_slow_table_transactions": {
|
|
141
|
+
"type": "boolean"
|
|
142
|
+
},
|
|
140
143
|
"platform_editor_user_intent_plugin": {
|
|
141
144
|
"type": "boolean"
|
|
142
145
|
},
|