@atlaskit/editor-plugin-floating-toolbar 4.1.9 → 4.1.12
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 +42 -0
- package/dist/cjs/floatingToolbarPlugin.js +6 -42
- package/dist/cjs/ui/Toolbar.js +5 -1
- package/dist/es2019/floatingToolbarPlugin.js +7 -39
- package/dist/es2019/ui/Toolbar.js +5 -1
- package/dist/esm/floatingToolbarPlugin.js +7 -43
- package/dist/esm/ui/Toolbar.js +5 -1
- package/package.json +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 4.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#160940](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/160940)
|
|
8
|
+
[`d63ae1c3f13d9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d63ae1c3f13d9) -
|
|
9
|
+
Hide loading of floating toolbar in SSR environment
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 4.1.11
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#159090](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/159090)
|
|
17
|
+
[`9cbae97c20f84`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9cbae97c20f84) -
|
|
18
|
+
Reduces rerenders of text formatting options and the toolbar when it is docked to top.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
21
|
+
## 4.1.10
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#159655](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/159655)
|
|
26
|
+
[`24f8c627d50f2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/24f8c627d50f2) - ##
|
|
27
|
+
WHAT? Remove experimental graceful edit mode from view mode plugin and associated props.
|
|
28
|
+
|
|
29
|
+
## WHY?
|
|
30
|
+
|
|
31
|
+
This experiment is being cleaned up and we are no longer proceeding in this direction.
|
|
32
|
+
|
|
33
|
+
## HOW to adjust?
|
|
34
|
+
|
|
35
|
+
This experiment was only enabled for Confluence and should not have been enabled in other places.
|
|
36
|
+
If for some reason any of the following props/state/methdos were used please remove them:
|
|
37
|
+
|
|
38
|
+
- isConsumption
|
|
39
|
+
- contentMode
|
|
40
|
+
- initialContentMode
|
|
41
|
+
- updateContentMode
|
|
42
|
+
|
|
43
|
+
- Updated dependencies
|
|
44
|
+
|
|
3
45
|
## 4.1.9
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
|
@@ -14,6 +14,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
14
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
16
16
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
17
|
+
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
17
18
|
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
18
19
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
19
20
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
@@ -31,7 +32,6 @@ var _plugin = require("./pm-plugins/toolbar-data/plugin");
|
|
|
31
32
|
var _pluginKey = require("./pm-plugins/toolbar-data/plugin-key");
|
|
32
33
|
var _utils2 = require("./pm-plugins/utils");
|
|
33
34
|
var _ConfirmationModal = require("./ui/ConfirmationModal");
|
|
34
|
-
var _ExpandButton = require("./ui/ExpandButton");
|
|
35
35
|
var _ToolbarLoader = require("./ui/ToolbarLoader");
|
|
36
36
|
var _utils3 = require("./ui/utils");
|
|
37
37
|
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); }
|
|
@@ -225,8 +225,6 @@ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (
|
|
|
225
225
|
|
|
226
226
|
// editorViewMode
|
|
227
227
|
var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.mode');
|
|
228
|
-
var contentMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.contentMode');
|
|
229
|
-
var isConsumption = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.isConsumption');
|
|
230
228
|
|
|
231
229
|
// userIntent
|
|
232
230
|
var currentUserIntent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'userIntent.currentUserIntent');
|
|
@@ -244,8 +242,6 @@ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (
|
|
|
244
242
|
floatingToolbarData: floatingToolbarData,
|
|
245
243
|
editorDisabled: editorDisabledState,
|
|
246
244
|
mode: mode,
|
|
247
|
-
contentMode: contentMode,
|
|
248
|
-
isConsumption: isConsumption,
|
|
249
245
|
currentUserIntent: currentUserIntent,
|
|
250
246
|
isDragging: isDragging,
|
|
251
247
|
isMenuOpen: isMenuOpen
|
|
@@ -264,8 +260,6 @@ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (
|
|
|
264
260
|
floatingToolbarData: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.floatingToolbarData,
|
|
265
261
|
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
|
|
266
262
|
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
267
|
-
contentMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.contentMode,
|
|
268
|
-
isConsumption: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.isConsumption,
|
|
269
263
|
currentUserIntent: userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent,
|
|
270
264
|
isDragging: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging,
|
|
271
265
|
isMenuOpen: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen
|
|
@@ -282,14 +276,17 @@ function ContentComponent(_ref5) {
|
|
|
282
276
|
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
283
277
|
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
284
278
|
configWithNodeInfo = _useSharedState.configWithNodeInfo,
|
|
285
|
-
contentMode = _useSharedState.contentMode,
|
|
286
279
|
currentUserIntent = _useSharedState.currentUserIntent,
|
|
287
280
|
editorDisabled = _useSharedState.editorDisabled,
|
|
288
281
|
floatingToolbarData = _useSharedState.floatingToolbarData,
|
|
289
|
-
isConsumption = _useSharedState.isConsumption,
|
|
290
282
|
isDragging = _useSharedState.isDragging,
|
|
291
283
|
isMenuOpen = _useSharedState.isMenuOpen,
|
|
292
284
|
mode = _useSharedState.mode;
|
|
285
|
+
if ((0, _coreUtils.isSSR)() && (0, _experiments.editorExperiment)('platform_editor_hide_floating_toolbar_in_ssr', true, {
|
|
286
|
+
exposure: true
|
|
287
|
+
})) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
293
290
|
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)) {
|
|
294
291
|
return null;
|
|
295
292
|
}
|
|
@@ -386,39 +383,6 @@ function ContentComponent(_ref5) {
|
|
|
386
383
|
}
|
|
387
384
|
var customPositionCalculation;
|
|
388
385
|
var toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
|
|
389
|
-
var viewModeToolbarEntry = (0, _experiments.unstable_editorExperimentParam)('live_pages_graceful_edit', 'toolbar-entry', {
|
|
390
|
-
defaultValue: 'none',
|
|
391
|
-
typeGuard: function typeGuard(value) {
|
|
392
|
-
return typeof value === 'string' && ['text', 'nodes'].includes(value);
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
if (!(0, _experiments.editorExperiment)('live_pages_graceful_edit', 'control') && viewModeToolbarEntry !== 'none') {
|
|
396
|
-
if (contentMode === 'live-edit' && isConsumption) {
|
|
397
|
-
var hasOtherToolbarItems = toolbarItems && toolbarItems.length !== 0;
|
|
398
|
-
var shouldAddToolbarItems = viewModeToolbarEntry === 'expand-existing-only' ? hasOtherToolbarItems : true;
|
|
399
|
-
if (shouldAddToolbarItems) {
|
|
400
|
-
if (toolbarItems && toolbarItems.length > 0) {
|
|
401
|
-
toolbarItems.unshift({
|
|
402
|
-
type: 'separator'
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
toolbarItems === null || toolbarItems === void 0 || toolbarItems.unshift({
|
|
406
|
-
type: 'button',
|
|
407
|
-
title: 'Edit',
|
|
408
|
-
onClick: function onClick() {
|
|
409
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$e;
|
|
410
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.actions) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.commands.updateContentMode({
|
|
411
|
-
type: 'intent-to-edit'
|
|
412
|
-
}));
|
|
413
|
-
return false;
|
|
414
|
-
},
|
|
415
|
-
icon: function icon() {
|
|
416
|
-
return /*#__PURE__*/_react.default.createElement(_ExpandButton.ExpandButton, null);
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
386
|
if (onPositionCalculated) {
|
|
423
387
|
customPositionCalculation = function customPositionCalculation(nextPos) {
|
|
424
388
|
return onPositionCalculated(editorView, nextPos);
|
package/dist/cjs/ui/Toolbar.js
CHANGED
|
@@ -571,6 +571,10 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
571
571
|
event.stopPropagation();
|
|
572
572
|
event.preventDefault();
|
|
573
573
|
});
|
|
574
|
+
(0, _defineProperty2.default)(_this, "isShortcutToFocusToolbar", function (event) {
|
|
575
|
+
//Alt + F10 to reach first element in this floating toolbar
|
|
576
|
+
return event.altKey && (event.key === 'F10' || event.keyCode === 121);
|
|
577
|
+
});
|
|
574
578
|
_this.scrollContainerRef = /*#__PURE__*/_react.default.createRef();
|
|
575
579
|
_this.mountRef = /*#__PURE__*/_react.default.createRef();
|
|
576
580
|
_this.toolbarContainerRef = /*#__PURE__*/_react.default.createRef();
|
|
@@ -699,7 +703,7 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
699
703
|
handleEscape: this.handleEscape,
|
|
700
704
|
disableArrowKeyNavigation: !this.shouldHandleArrowKeys(),
|
|
701
705
|
childComponentSelector: "[data-testid='editor-floating-toolbar']",
|
|
702
|
-
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
706
|
+
isShortcutToFocusToolbar: (0, _platformFeatureFlags.fg)('platform_editor_toolbar_rerender_optimization') ? this.isShortcutToFocusToolbar : isShortcutToFocusToolbar,
|
|
703
707
|
intl: intl
|
|
704
708
|
}, (0, _react2.jsx)("div", {
|
|
705
709
|
ref: this.toolbarContainerRef,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
4
5
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
5
6
|
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
7
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -10,7 +11,7 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
|
|
|
10
11
|
import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
11
12
|
import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
12
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
|
-
import { editorExperiment
|
|
14
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
15
|
import { copyNode } from './pm-plugins/commands';
|
|
15
16
|
import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
|
|
16
17
|
import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
|
|
@@ -18,7 +19,6 @@ import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/t
|
|
|
18
19
|
import { pluginKey as dataPluginKey } from './pm-plugins/toolbar-data/plugin-key';
|
|
19
20
|
import { findNode } from './pm-plugins/utils';
|
|
20
21
|
import { ConfirmationModal } from './ui/ConfirmationModal';
|
|
21
|
-
import { ExpandButton } from './ui/ExpandButton';
|
|
22
22
|
import { ToolbarLoader } from './ui/ToolbarLoader';
|
|
23
23
|
import { consolidateOverflowDropdownItems } from './ui/utils';
|
|
24
24
|
|
|
@@ -208,8 +208,6 @@ const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi =
|
|
|
208
208
|
|
|
209
209
|
// editorViewMode
|
|
210
210
|
const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
211
|
-
const contentMode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.contentMode');
|
|
212
|
-
const isConsumption = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.isConsumption');
|
|
213
211
|
|
|
214
212
|
// userIntent
|
|
215
213
|
const currentUserIntent = useSharedPluginStateSelector(pluginInjectionApi, 'userIntent.currentUserIntent');
|
|
@@ -227,8 +225,6 @@ const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi =
|
|
|
227
225
|
floatingToolbarData,
|
|
228
226
|
editorDisabled: editorDisabledState,
|
|
229
227
|
mode,
|
|
230
|
-
contentMode,
|
|
231
|
-
isConsumption,
|
|
232
228
|
currentUserIntent,
|
|
233
229
|
isDragging,
|
|
234
230
|
isMenuOpen
|
|
@@ -249,8 +245,6 @@ const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi =
|
|
|
249
245
|
floatingToolbarData: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.floatingToolbarData,
|
|
250
246
|
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
|
|
251
247
|
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
252
|
-
contentMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.contentMode,
|
|
253
|
-
isConsumption: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.isConsumption,
|
|
254
248
|
currentUserIntent: userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent,
|
|
255
249
|
isDragging: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging,
|
|
256
250
|
isMenuOpen: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen
|
|
@@ -268,15 +262,18 @@ export function ContentComponent({
|
|
|
268
262
|
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
|
|
269
263
|
const {
|
|
270
264
|
configWithNodeInfo,
|
|
271
|
-
contentMode,
|
|
272
265
|
currentUserIntent,
|
|
273
266
|
editorDisabled,
|
|
274
267
|
floatingToolbarData,
|
|
275
|
-
isConsumption,
|
|
276
268
|
isDragging,
|
|
277
269
|
isMenuOpen,
|
|
278
270
|
mode
|
|
279
271
|
} = useSharedState(pluginInjectionApi);
|
|
272
|
+
if (isSSR() && editorExperiment('platform_editor_hide_floating_toolbar_in_ssr', true, {
|
|
273
|
+
exposure: true
|
|
274
|
+
})) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
280
277
|
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)) {
|
|
281
278
|
return null;
|
|
282
279
|
}
|
|
@@ -368,35 +365,6 @@ export function ContentComponent({
|
|
|
368
365
|
}
|
|
369
366
|
let customPositionCalculation;
|
|
370
367
|
const toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
|
|
371
|
-
const viewModeToolbarEntry = unstable_editorExperimentParam('live_pages_graceful_edit', 'toolbar-entry', {
|
|
372
|
-
defaultValue: 'none',
|
|
373
|
-
typeGuard: value => typeof value === 'string' && ['text', 'nodes'].includes(value)
|
|
374
|
-
});
|
|
375
|
-
if (!editorExperiment('live_pages_graceful_edit', 'control') && viewModeToolbarEntry !== 'none') {
|
|
376
|
-
if (contentMode === 'live-edit' && isConsumption) {
|
|
377
|
-
const hasOtherToolbarItems = toolbarItems && toolbarItems.length !== 0;
|
|
378
|
-
const shouldAddToolbarItems = viewModeToolbarEntry === 'expand-existing-only' ? hasOtherToolbarItems : true;
|
|
379
|
-
if (shouldAddToolbarItems) {
|
|
380
|
-
if (toolbarItems && toolbarItems.length > 0) {
|
|
381
|
-
toolbarItems.unshift({
|
|
382
|
-
type: 'separator'
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems.unshift({
|
|
386
|
-
type: 'button',
|
|
387
|
-
title: 'Edit',
|
|
388
|
-
onClick: () => {
|
|
389
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$c3, _pluginInjectionApi$e;
|
|
390
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : (_pluginInjectionApi$c3 = _pluginInjectionApi$c2.actions) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.commands.updateContentMode({
|
|
391
|
-
type: 'intent-to-edit'
|
|
392
|
-
}));
|
|
393
|
-
return false;
|
|
394
|
-
},
|
|
395
|
-
icon: () => /*#__PURE__*/React.createElement(ExpandButton, null)
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
368
|
if (onPositionCalculated) {
|
|
401
369
|
customPositionCalculation = nextPos => {
|
|
402
370
|
return onPositionCalculated(editorView, nextPos);
|
|
@@ -531,6 +531,10 @@ class Toolbar extends Component {
|
|
|
531
531
|
event.stopPropagation();
|
|
532
532
|
event.preventDefault();
|
|
533
533
|
});
|
|
534
|
+
_defineProperty(this, "isShortcutToFocusToolbar", event => {
|
|
535
|
+
//Alt + F10 to reach first element in this floating toolbar
|
|
536
|
+
return event.altKey && (event.key === 'F10' || event.keyCode === 121);
|
|
537
|
+
});
|
|
534
538
|
this.scrollContainerRef = /*#__PURE__*/React.createRef();
|
|
535
539
|
this.mountRef = /*#__PURE__*/React.createRef();
|
|
536
540
|
this.toolbarContainerRef = /*#__PURE__*/React.createRef();
|
|
@@ -650,7 +654,7 @@ class Toolbar extends Component {
|
|
|
650
654
|
handleEscape: this.handleEscape,
|
|
651
655
|
disableArrowKeyNavigation: !this.shouldHandleArrowKeys(),
|
|
652
656
|
childComponentSelector: "[data-testid='editor-floating-toolbar']",
|
|
653
|
-
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
657
|
+
isShortcutToFocusToolbar: fg('platform_editor_toolbar_rerender_optimization') ? this.isShortcutToFocusToolbar : isShortcutToFocusToolbar,
|
|
654
658
|
intl: intl
|
|
655
659
|
}, jsx("div", {
|
|
656
660
|
ref: this.toolbarContainerRef,
|
|
@@ -5,6 +5,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
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
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
8
9
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
9
10
|
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
11
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -14,7 +15,7 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
|
|
|
14
15
|
import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
15
16
|
import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
16
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
|
-
import { editorExperiment
|
|
18
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
19
|
import { copyNode as _copyNode } from './pm-plugins/commands';
|
|
19
20
|
import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
|
|
20
21
|
import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
|
|
@@ -22,7 +23,6 @@ import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/t
|
|
|
22
23
|
import { pluginKey as dataPluginKey } from './pm-plugins/toolbar-data/plugin-key';
|
|
23
24
|
import { findNode } from './pm-plugins/utils';
|
|
24
25
|
import { ConfirmationModal } from './ui/ConfirmationModal';
|
|
25
|
-
import { ExpandButton } from './ui/ExpandButton';
|
|
26
26
|
import { ToolbarLoader } from './ui/ToolbarLoader';
|
|
27
27
|
import { consolidateOverflowDropdownItems } from './ui/utils';
|
|
28
28
|
|
|
@@ -213,8 +213,6 @@ var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInject
|
|
|
213
213
|
|
|
214
214
|
// editorViewMode
|
|
215
215
|
var mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
216
|
-
var contentMode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.contentMode');
|
|
217
|
-
var isConsumption = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.isConsumption');
|
|
218
216
|
|
|
219
217
|
// userIntent
|
|
220
218
|
var currentUserIntent = useSharedPluginStateSelector(pluginInjectionApi, 'userIntent.currentUserIntent');
|
|
@@ -232,8 +230,6 @@ var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInject
|
|
|
232
230
|
floatingToolbarData: floatingToolbarData,
|
|
233
231
|
editorDisabled: editorDisabledState,
|
|
234
232
|
mode: mode,
|
|
235
|
-
contentMode: contentMode,
|
|
236
|
-
isConsumption: isConsumption,
|
|
237
233
|
currentUserIntent: currentUserIntent,
|
|
238
234
|
isDragging: isDragging,
|
|
239
235
|
isMenuOpen: isMenuOpen
|
|
@@ -252,8 +248,6 @@ var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInject
|
|
|
252
248
|
floatingToolbarData: floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.floatingToolbarData,
|
|
253
249
|
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
|
|
254
250
|
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
255
|
-
contentMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.contentMode,
|
|
256
|
-
isConsumption: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.isConsumption,
|
|
257
251
|
currentUserIntent: userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent,
|
|
258
252
|
isDragging: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging,
|
|
259
253
|
isMenuOpen: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isMenuOpen
|
|
@@ -270,14 +264,17 @@ export function ContentComponent(_ref5) {
|
|
|
270
264
|
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
271
265
|
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
272
266
|
configWithNodeInfo = _useSharedState.configWithNodeInfo,
|
|
273
|
-
contentMode = _useSharedState.contentMode,
|
|
274
267
|
currentUserIntent = _useSharedState.currentUserIntent,
|
|
275
268
|
editorDisabled = _useSharedState.editorDisabled,
|
|
276
269
|
floatingToolbarData = _useSharedState.floatingToolbarData,
|
|
277
|
-
isConsumption = _useSharedState.isConsumption,
|
|
278
270
|
isDragging = _useSharedState.isDragging,
|
|
279
271
|
isMenuOpen = _useSharedState.isMenuOpen,
|
|
280
272
|
mode = _useSharedState.mode;
|
|
273
|
+
if (isSSR() && editorExperiment('platform_editor_hide_floating_toolbar_in_ssr', true, {
|
|
274
|
+
exposure: true
|
|
275
|
+
})) {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
281
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)) {
|
|
282
279
|
return null;
|
|
283
280
|
}
|
|
@@ -374,39 +371,6 @@ export function ContentComponent(_ref5) {
|
|
|
374
371
|
}
|
|
375
372
|
var customPositionCalculation;
|
|
376
373
|
var toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
|
|
377
|
-
var viewModeToolbarEntry = unstable_editorExperimentParam('live_pages_graceful_edit', 'toolbar-entry', {
|
|
378
|
-
defaultValue: 'none',
|
|
379
|
-
typeGuard: function typeGuard(value) {
|
|
380
|
-
return typeof value === 'string' && ['text', 'nodes'].includes(value);
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
if (!editorExperiment('live_pages_graceful_edit', 'control') && viewModeToolbarEntry !== 'none') {
|
|
384
|
-
if (contentMode === 'live-edit' && isConsumption) {
|
|
385
|
-
var hasOtherToolbarItems = toolbarItems && toolbarItems.length !== 0;
|
|
386
|
-
var shouldAddToolbarItems = viewModeToolbarEntry === 'expand-existing-only' ? hasOtherToolbarItems : true;
|
|
387
|
-
if (shouldAddToolbarItems) {
|
|
388
|
-
if (toolbarItems && toolbarItems.length > 0) {
|
|
389
|
-
toolbarItems.unshift({
|
|
390
|
-
type: 'separator'
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
toolbarItems === null || toolbarItems === void 0 || toolbarItems.unshift({
|
|
394
|
-
type: 'button',
|
|
395
|
-
title: 'Edit',
|
|
396
|
-
onClick: function onClick() {
|
|
397
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$e;
|
|
398
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.actions) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.commands.updateContentMode({
|
|
399
|
-
type: 'intent-to-edit'
|
|
400
|
-
}));
|
|
401
|
-
return false;
|
|
402
|
-
},
|
|
403
|
-
icon: function icon() {
|
|
404
|
-
return /*#__PURE__*/React.createElement(ExpandButton, null);
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
374
|
if (onPositionCalculated) {
|
|
411
375
|
customPositionCalculation = function customPositionCalculation(nextPos) {
|
|
412
376
|
return onPositionCalculated(editorView, nextPos);
|
package/dist/esm/ui/Toolbar.js
CHANGED
|
@@ -564,6 +564,10 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
564
564
|
event.stopPropagation();
|
|
565
565
|
event.preventDefault();
|
|
566
566
|
});
|
|
567
|
+
_defineProperty(_this, "isShortcutToFocusToolbar", function (event) {
|
|
568
|
+
//Alt + F10 to reach first element in this floating toolbar
|
|
569
|
+
return event.altKey && (event.key === 'F10' || event.keyCode === 121);
|
|
570
|
+
});
|
|
567
571
|
_this.scrollContainerRef = /*#__PURE__*/React.createRef();
|
|
568
572
|
_this.mountRef = /*#__PURE__*/React.createRef();
|
|
569
573
|
_this.toolbarContainerRef = /*#__PURE__*/React.createRef();
|
|
@@ -692,7 +696,7 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
692
696
|
handleEscape: this.handleEscape,
|
|
693
697
|
disableArrowKeyNavigation: !this.shouldHandleArrowKeys(),
|
|
694
698
|
childComponentSelector: "[data-testid='editor-floating-toolbar']",
|
|
695
|
-
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
699
|
+
isShortcutToFocusToolbar: fg('platform_editor_toolbar_rerender_optimization') ? this.isShortcutToFocusToolbar : isShortcutToFocusToolbar,
|
|
696
700
|
intl: intl
|
|
697
701
|
}, jsx("div", {
|
|
698
702
|
ref: this.toolbarContainerRef,
|
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.12",
|
|
4
4
|
"description": "Floating toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,32 +25,32 @@
|
|
|
25
25
|
".": "./src/index.ts"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@atlaskit/adf-utils": "^19.
|
|
28
|
+
"@atlaskit/adf-utils": "^19.20.0",
|
|
29
29
|
"@atlaskit/button": "^23.2.0",
|
|
30
30
|
"@atlaskit/checkbox": "^17.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^105.
|
|
31
|
+
"@atlaskit/editor-common": "^105.11.0",
|
|
32
32
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
33
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",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
38
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
39
|
-
"@atlaskit/editor-plugin-emoji": "^3.
|
|
38
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^4.0.0",
|
|
39
|
+
"@atlaskit/editor-plugin-emoji": "^3.7.0",
|
|
40
40
|
"@atlaskit/editor-plugin-extension": "^5.4.0",
|
|
41
41
|
"@atlaskit/editor-plugin-interaction": "^1.1.0",
|
|
42
|
-
"@atlaskit/editor-plugin-table": "^10.
|
|
42
|
+
"@atlaskit/editor-plugin-table": "^10.11.0",
|
|
43
43
|
"@atlaskit/editor-plugin-user-intent": "^0.1.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
45
45
|
"@atlaskit/emoji": "^69.2.0",
|
|
46
|
-
"@atlaskit/icon": "^26.
|
|
46
|
+
"@atlaskit/icon": "^26.3.0",
|
|
47
47
|
"@atlaskit/menu": "^8.0.0",
|
|
48
48
|
"@atlaskit/modal-dialog": "^14.2.0",
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
50
50
|
"@atlaskit/primitives": "^14.8.0",
|
|
51
51
|
"@atlaskit/select": "^20.6.0",
|
|
52
52
|
"@atlaskit/theme": "^18.0.0",
|
|
53
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
53
|
+
"@atlaskit/tmp-editor-statsig": "^5.1.0",
|
|
54
54
|
"@atlaskit/tokens": "^4.9.0",
|
|
55
55
|
"@atlaskit/tooltip": "^20.0.0",
|
|
56
56
|
"@babel/runtime": "^7.0.0",
|
|
@@ -154,6 +154,9 @@
|
|
|
154
154
|
},
|
|
155
155
|
"platform_editor_interaction_api_refactor": {
|
|
156
156
|
"type": "boolean"
|
|
157
|
+
},
|
|
158
|
+
"platform_editor_toolbar_rerender_optimization": {
|
|
159
|
+
"type": "boolean"
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
}
|