@atlaskit/editor-plugin-toolbar 1.2.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-dev-agents/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-passionfruit/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/afm-rovo-extension/tsconfig.json +3 -0
- package/afm-townsquare/tsconfig.json +3 -0
- package/dist/cjs/ui/Section.js +30 -5
- package/dist/cjs/ui/SelectionToolbar/index.js +47 -15
- package/dist/es2019/ui/Section.js +30 -5
- package/dist/es2019/ui/SelectionToolbar/index.js +47 -15
- package/dist/esm/ui/Section.js +30 -5
- package/dist/esm/ui/SelectionToolbar/index.js +47 -15
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`4edb2aee0da9c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4edb2aee0da9c) -
|
|
8
|
+
Add conditionalHooksFactory and migrate usage of useSharedPluginStateSelector to useEditorToolbar
|
|
9
|
+
and useSharedPluginStateWithSelector
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 2.0.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 1.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
{
|
|
39
39
|
"path": "../../editor-toolbar-model/afm-rovo-extension/tsconfig.json"
|
|
40
40
|
},
|
|
41
|
+
{
|
|
42
|
+
"path": "../../../platform/feature-flags-react/afm-rovo-extension/tsconfig.json"
|
|
43
|
+
},
|
|
41
44
|
{
|
|
42
45
|
"path": "../../tmp-editor-statsig/afm-rovo-extension/tsconfig.json"
|
|
43
46
|
},
|
package/dist/cjs/ui/Section.js
CHANGED
|
@@ -9,6 +9,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
10
10
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
11
11
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
|
+
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
|
|
13
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
14
|
var shouldShowSection = function shouldShowSection(editMode, toolbar, toolbarDocking, disableSelectionToolbar) {
|
|
13
15
|
if (editMode === 'view') {
|
|
14
16
|
return false;
|
|
@@ -24,6 +26,29 @@ var shouldShowSection = function shouldShowSection(editMode, toolbar, toolbarDoc
|
|
|
24
26
|
}
|
|
25
27
|
return false;
|
|
26
28
|
};
|
|
29
|
+
var usePluginState = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(function () {
|
|
30
|
+
return (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
|
|
31
|
+
}, function (api) {
|
|
32
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
33
|
+
editorViewMode = _useEditorToolbar.editorViewMode,
|
|
34
|
+
editorToolbarDockingPreference = _useEditorToolbar.editorToolbarDockingPreference,
|
|
35
|
+
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
36
|
+
return {
|
|
37
|
+
editorViewMode: editorViewMode,
|
|
38
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
39
|
+
editorAppearance: editorAppearance
|
|
40
|
+
};
|
|
41
|
+
}, function (api) {
|
|
42
|
+
var editorViewMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
|
|
43
|
+
var editorToolbarDockingPreference = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
44
|
+
var _useEditorToolbar2 = (0, _toolbar.useEditorToolbar)(),
|
|
45
|
+
editorAppearance = _useEditorToolbar2.editorAppearance;
|
|
46
|
+
return {
|
|
47
|
+
editorViewMode: editorViewMode,
|
|
48
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
49
|
+
editorAppearance: editorAppearance
|
|
50
|
+
};
|
|
51
|
+
});
|
|
27
52
|
var Section = exports.Section = function Section(_ref) {
|
|
28
53
|
var children = _ref.children,
|
|
29
54
|
parents = _ref.parents,
|
|
@@ -33,14 +58,14 @@ var Section = exports.Section = function Section(_ref) {
|
|
|
33
58
|
_ref$isSharedSection = _ref.isSharedSection,
|
|
34
59
|
isSharedSection = _ref$isSharedSection === void 0 ? true : _ref$isSharedSection,
|
|
35
60
|
disableSelectionToolbar = _ref.disableSelectionToolbar;
|
|
36
|
-
var
|
|
37
|
-
|
|
61
|
+
var _usePluginState = usePluginState(api),
|
|
62
|
+
editorViewMode = _usePluginState.editorViewMode,
|
|
63
|
+
editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference,
|
|
64
|
+
editorAppearance = _usePluginState.editorAppearance;
|
|
38
65
|
var toolbar = parents.find(function (parent) {
|
|
39
66
|
return parent.type === 'toolbar';
|
|
40
67
|
});
|
|
41
|
-
|
|
42
|
-
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
43
|
-
if (isSharedSection && !shouldShowSection(editMode, toolbar, toolbarDocking, disableSelectionToolbar)) {
|
|
68
|
+
if (isSharedSection && !shouldShowSection(editorViewMode, toolbar, editorToolbarDockingPreference, disableSelectionToolbar)) {
|
|
44
69
|
return null;
|
|
45
70
|
}
|
|
46
71
|
var isFullPage = editorAppearance === 'full-page';
|
|
@@ -16,6 +16,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
16
16
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
17
17
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
18
18
|
var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
|
|
19
|
+
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
|
|
19
20
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
20
21
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
21
22
|
var _consts = require("../consts");
|
|
@@ -23,30 +24,59 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
23
24
|
var isToolbarComponent = function isToolbarComponent(component) {
|
|
24
25
|
return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
|
|
25
26
|
};
|
|
27
|
+
var usePluginState = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(function () {
|
|
28
|
+
return (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
|
|
29
|
+
}, function (api) {
|
|
30
|
+
return (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity', 'userPreferences', 'toolbar', 'selection', 'userIntent', 'editorViewMode'], function (state) {
|
|
31
|
+
var _state$connectivitySt, _state$userPreference, _state$toolbarState, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
32
|
+
return {
|
|
33
|
+
connectivityStateMode: (_state$connectivitySt = state.connectivityState) === null || _state$connectivitySt === void 0 ? void 0 : _state$connectivitySt.mode,
|
|
34
|
+
editorToolbarDockingPreference: (_state$userPreference = state.userPreferencesState) === null || _state$userPreference === void 0 || (_state$userPreference = _state$userPreference.preferences) === null || _state$userPreference === void 0 ? void 0 : _state$userPreference.toolbarDockingPosition,
|
|
35
|
+
shouldShowToolbar: (_state$toolbarState = state.toolbarState) === null || _state$toolbarState === void 0 ? void 0 : _state$toolbarState.shouldShowToolbar,
|
|
36
|
+
selection: (_state$selectionState = state.selectionState) === null || _state$selectionState === void 0 ? void 0 : _state$selectionState.selection,
|
|
37
|
+
currentUserIntent: (_state$userIntentStat = state.userIntentState) === null || _state$userIntentStat === void 0 ? void 0 : _state$userIntentStat.currentUserIntent,
|
|
38
|
+
editorViewMode: (_state$editorViewMode = state.editorViewModeState) === null || _state$editorViewMode === void 0 ? void 0 : _state$editorViewMode.mode
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}, function (api) {
|
|
42
|
+
var connectivityStateMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'connectivity.mode');
|
|
43
|
+
var editorToolbarDockingPreference = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
44
|
+
var currentUserIntent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userIntent.currentUserIntent');
|
|
45
|
+
var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
|
|
46
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['toolbar'], function (state) {
|
|
47
|
+
var _state$toolbarState2;
|
|
48
|
+
return {
|
|
49
|
+
shouldShowToolbar: (_state$toolbarState2 = state.toolbarState) === null || _state$toolbarState2 === void 0 ? void 0 : _state$toolbarState2.shouldShowToolbar
|
|
50
|
+
};
|
|
51
|
+
}),
|
|
52
|
+
shouldShowToolbar = _useSharedPluginState.shouldShowToolbar;
|
|
53
|
+
return {
|
|
54
|
+
connectivityStateMode: connectivityStateMode,
|
|
55
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
56
|
+
currentUserIntent: currentUserIntent,
|
|
57
|
+
shouldShowToolbar: shouldShowToolbar,
|
|
58
|
+
selection: selection,
|
|
59
|
+
editorViewMode: undefined
|
|
60
|
+
};
|
|
61
|
+
});
|
|
26
62
|
var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref) {
|
|
27
63
|
var _api$toolbar;
|
|
28
64
|
var api = _ref.api,
|
|
29
65
|
editorView = _ref.editorView,
|
|
30
66
|
mountPoint = _ref.mountPoint,
|
|
31
67
|
disableSelectionToolbarWhenPinned = _ref.disableSelectionToolbarWhenPinned;
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
68
|
+
var _usePluginState = usePluginState(api),
|
|
69
|
+
connectivityStateMode = _usePluginState.connectivityStateMode,
|
|
70
|
+
editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference,
|
|
71
|
+
currentUserIntent = _usePluginState.currentUserIntent,
|
|
72
|
+
shouldShowToolbar = _usePluginState.shouldShowToolbar,
|
|
73
|
+
editorViewMode = _usePluginState.editorViewMode,
|
|
74
|
+
selection = _usePluginState.selection;
|
|
39
75
|
var components = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.getComponents();
|
|
40
76
|
var toolbar = components === null || components === void 0 ? void 0 : components.find(function (component) {
|
|
41
77
|
return isToolbarComponent(component);
|
|
42
78
|
});
|
|
43
|
-
var currentUserIntent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userIntent.currentUserIntent');
|
|
44
|
-
var connectivityStateMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'connectivity.mode');
|
|
45
|
-
var toolbarDocking = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
46
79
|
var isOffline = connectivityStateMode === 'offline';
|
|
47
|
-
// TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
|
|
48
|
-
// @ts-expect-error
|
|
49
|
-
var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
|
|
50
80
|
var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof _state.TextSelection;
|
|
51
81
|
var isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof _state.AllSelection && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true);
|
|
52
82
|
var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
@@ -62,7 +92,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
62
92
|
var calc = _utils.calculateToolbarPositionTrackHead;
|
|
63
93
|
return calc(toolbarTitle)(editorView, position);
|
|
64
94
|
}, [editorView]);
|
|
65
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) &&
|
|
95
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
66
96
|
return null;
|
|
67
97
|
}
|
|
68
98
|
if (!(isTextSelection || isCellSelection || isAllSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || currentUserIntent && currentUserIntent !== 'default' && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true) || (0, _coreUtils.isSSR)()) {
|
|
@@ -74,7 +104,9 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
74
104
|
onPositionCalculated: onPositionCalculated,
|
|
75
105
|
mountTo: mountPoint
|
|
76
106
|
}, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
|
|
77
|
-
editorView: editorView
|
|
107
|
+
editorView: editorView,
|
|
108
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
109
|
+
editorViewMode: editorViewMode
|
|
78
110
|
}, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarUIProvider, {
|
|
79
111
|
api: api,
|
|
80
112
|
isDisabled: isOffline
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { TOOLBARS, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
4
|
import { ToolbarSection } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
7
|
const shouldShowSection = (editMode, toolbar, toolbarDocking, disableSelectionToolbar) => {
|
|
6
8
|
if (editMode === 'view') {
|
|
7
9
|
return false;
|
|
@@ -17,6 +19,29 @@ const shouldShowSection = (editMode, toolbar, toolbarDocking, disableSelectionTo
|
|
|
17
19
|
}
|
|
18
20
|
return false;
|
|
19
21
|
};
|
|
22
|
+
const usePluginState = conditionalHooksFactory(() => expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true), api => {
|
|
23
|
+
const {
|
|
24
|
+
editorViewMode,
|
|
25
|
+
editorToolbarDockingPreference,
|
|
26
|
+
editorAppearance
|
|
27
|
+
} = useEditorToolbar();
|
|
28
|
+
return {
|
|
29
|
+
editorViewMode,
|
|
30
|
+
editorToolbarDockingPreference,
|
|
31
|
+
editorAppearance
|
|
32
|
+
};
|
|
33
|
+
}, api => {
|
|
34
|
+
const editorViewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
35
|
+
const editorToolbarDockingPreference = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
36
|
+
const {
|
|
37
|
+
editorAppearance
|
|
38
|
+
} = useEditorToolbar();
|
|
39
|
+
return {
|
|
40
|
+
editorViewMode,
|
|
41
|
+
editorToolbarDockingPreference,
|
|
42
|
+
editorAppearance
|
|
43
|
+
};
|
|
44
|
+
});
|
|
20
45
|
export const Section = ({
|
|
21
46
|
children,
|
|
22
47
|
parents,
|
|
@@ -26,13 +51,13 @@ export const Section = ({
|
|
|
26
51
|
isSharedSection = true,
|
|
27
52
|
disableSelectionToolbar
|
|
28
53
|
}) => {
|
|
29
|
-
const editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
30
|
-
const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
31
|
-
const toolbar = parents.find(parent => parent.type === 'toolbar');
|
|
32
54
|
const {
|
|
55
|
+
editorViewMode,
|
|
56
|
+
editorToolbarDockingPreference,
|
|
33
57
|
editorAppearance
|
|
34
|
-
} =
|
|
35
|
-
|
|
58
|
+
} = usePluginState(api);
|
|
59
|
+
const toolbar = parents.find(parent => parent.type === 'toolbar');
|
|
60
|
+
if (isSharedSection && !shouldShowSection(editorViewMode, toolbar, editorToolbarDockingPreference, disableSelectionToolbar)) {
|
|
36
61
|
return null;
|
|
37
62
|
}
|
|
38
63
|
const isFullPage = editorAppearance === 'full-page';
|
|
@@ -9,12 +9,47 @@ import { AllSelection, TextSelection } from '@atlaskit/editor-prosemirror/state'
|
|
|
9
9
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { ToolbarSection, ToolbarButtonGroup, ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
11
11
|
import { ToolbarModelRenderer } from '@atlaskit/editor-toolbar-model';
|
|
12
|
+
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
12
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
14
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
14
15
|
import { SELECTION_TOOLBAR_LABEL } from '../consts';
|
|
15
16
|
const isToolbarComponent = component => {
|
|
16
17
|
return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
|
|
17
18
|
};
|
|
19
|
+
const usePluginState = conditionalHooksFactory(() => expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true), api => {
|
|
20
|
+
return useSharedPluginStateWithSelector(api, ['connectivity', 'userPreferences', 'toolbar', 'selection', 'userIntent', 'editorViewMode'], state => {
|
|
21
|
+
var _state$connectivitySt, _state$userPreference, _state$userPreference2, _state$toolbarState, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
22
|
+
return {
|
|
23
|
+
connectivityStateMode: (_state$connectivitySt = state.connectivityState) === null || _state$connectivitySt === void 0 ? void 0 : _state$connectivitySt.mode,
|
|
24
|
+
editorToolbarDockingPreference: (_state$userPreference = state.userPreferencesState) === null || _state$userPreference === void 0 ? void 0 : (_state$userPreference2 = _state$userPreference.preferences) === null || _state$userPreference2 === void 0 ? void 0 : _state$userPreference2.toolbarDockingPosition,
|
|
25
|
+
shouldShowToolbar: (_state$toolbarState = state.toolbarState) === null || _state$toolbarState === void 0 ? void 0 : _state$toolbarState.shouldShowToolbar,
|
|
26
|
+
selection: (_state$selectionState = state.selectionState) === null || _state$selectionState === void 0 ? void 0 : _state$selectionState.selection,
|
|
27
|
+
currentUserIntent: (_state$userIntentStat = state.userIntentState) === null || _state$userIntentStat === void 0 ? void 0 : _state$userIntentStat.currentUserIntent,
|
|
28
|
+
editorViewMode: (_state$editorViewMode = state.editorViewModeState) === null || _state$editorViewMode === void 0 ? void 0 : _state$editorViewMode.mode
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}, api => {
|
|
32
|
+
const connectivityStateMode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
33
|
+
const editorToolbarDockingPreference = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
34
|
+
const currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
|
|
35
|
+
const selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
36
|
+
const {
|
|
37
|
+
shouldShowToolbar
|
|
38
|
+
} = useSharedPluginStateWithSelector(api, ['toolbar'], state => {
|
|
39
|
+
var _state$toolbarState2;
|
|
40
|
+
return {
|
|
41
|
+
shouldShowToolbar: (_state$toolbarState2 = state.toolbarState) === null || _state$toolbarState2 === void 0 ? void 0 : _state$toolbarState2.shouldShowToolbar
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
connectivityStateMode,
|
|
46
|
+
editorToolbarDockingPreference,
|
|
47
|
+
currentUserIntent,
|
|
48
|
+
shouldShowToolbar,
|
|
49
|
+
selection,
|
|
50
|
+
editorViewMode: undefined
|
|
51
|
+
};
|
|
52
|
+
});
|
|
18
53
|
export const SelectionToolbar = ({
|
|
19
54
|
api,
|
|
20
55
|
editorView,
|
|
@@ -23,22 +58,17 @@ export const SelectionToolbar = ({
|
|
|
23
58
|
}) => {
|
|
24
59
|
var _api$toolbar;
|
|
25
60
|
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
61
|
+
connectivityStateMode,
|
|
62
|
+
editorToolbarDockingPreference,
|
|
63
|
+
currentUserIntent,
|
|
64
|
+
shouldShowToolbar,
|
|
65
|
+
editorViewMode,
|
|
66
|
+
// @ts-expect-error
|
|
67
|
+
selection
|
|
68
|
+
} = usePluginState(api);
|
|
33
69
|
const components = api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.getComponents();
|
|
34
70
|
const toolbar = components === null || components === void 0 ? void 0 : components.find(component => isToolbarComponent(component));
|
|
35
|
-
const currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
|
|
36
|
-
const connectivityStateMode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
37
|
-
const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
38
71
|
const isOffline = connectivityStateMode === 'offline';
|
|
39
|
-
// TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
|
|
40
|
-
// @ts-expect-error
|
|
41
|
-
const selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
42
72
|
const isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
|
|
43
73
|
const isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof AllSelection && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true);
|
|
44
74
|
const isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
@@ -54,7 +84,7 @@ export const SelectionToolbar = ({
|
|
|
54
84
|
const calc = calculateToolbarPositionTrackHead;
|
|
55
85
|
return calc(toolbarTitle)(editorView, position);
|
|
56
86
|
}, [editorView]);
|
|
57
|
-
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) &&
|
|
87
|
+
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
58
88
|
return null;
|
|
59
89
|
}
|
|
60
90
|
if (!(isTextSelection || isCellSelection || isAllSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || currentUserIntent && currentUserIntent !== 'default' && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true) || isSSR()) {
|
|
@@ -66,7 +96,9 @@ export const SelectionToolbar = ({
|
|
|
66
96
|
onPositionCalculated: onPositionCalculated,
|
|
67
97
|
mountTo: mountPoint
|
|
68
98
|
}, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
69
|
-
editorView: editorView
|
|
99
|
+
editorView: editorView,
|
|
100
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
101
|
+
editorViewMode: editorViewMode
|
|
70
102
|
}, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
|
|
71
103
|
api: api,
|
|
72
104
|
isDisabled: isOffline
|
package/dist/esm/ui/Section.js
CHANGED
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { TOOLBARS, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
4
|
import { ToolbarSection } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
7
|
var shouldShowSection = function shouldShowSection(editMode, toolbar, toolbarDocking, disableSelectionToolbar) {
|
|
6
8
|
if (editMode === 'view') {
|
|
7
9
|
return false;
|
|
@@ -17,6 +19,29 @@ var shouldShowSection = function shouldShowSection(editMode, toolbar, toolbarDoc
|
|
|
17
19
|
}
|
|
18
20
|
return false;
|
|
19
21
|
};
|
|
22
|
+
var usePluginState = conditionalHooksFactory(function () {
|
|
23
|
+
return expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
|
|
24
|
+
}, function (api) {
|
|
25
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
26
|
+
editorViewMode = _useEditorToolbar.editorViewMode,
|
|
27
|
+
editorToolbarDockingPreference = _useEditorToolbar.editorToolbarDockingPreference,
|
|
28
|
+
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
29
|
+
return {
|
|
30
|
+
editorViewMode: editorViewMode,
|
|
31
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
32
|
+
editorAppearance: editorAppearance
|
|
33
|
+
};
|
|
34
|
+
}, function (api) {
|
|
35
|
+
var editorViewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
36
|
+
var editorToolbarDockingPreference = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
37
|
+
var _useEditorToolbar2 = useEditorToolbar(),
|
|
38
|
+
editorAppearance = _useEditorToolbar2.editorAppearance;
|
|
39
|
+
return {
|
|
40
|
+
editorViewMode: editorViewMode,
|
|
41
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
42
|
+
editorAppearance: editorAppearance
|
|
43
|
+
};
|
|
44
|
+
});
|
|
20
45
|
export var Section = function Section(_ref) {
|
|
21
46
|
var children = _ref.children,
|
|
22
47
|
parents = _ref.parents,
|
|
@@ -26,14 +51,14 @@ export var Section = function Section(_ref) {
|
|
|
26
51
|
_ref$isSharedSection = _ref.isSharedSection,
|
|
27
52
|
isSharedSection = _ref$isSharedSection === void 0 ? true : _ref$isSharedSection,
|
|
28
53
|
disableSelectionToolbar = _ref.disableSelectionToolbar;
|
|
29
|
-
var
|
|
30
|
-
|
|
54
|
+
var _usePluginState = usePluginState(api),
|
|
55
|
+
editorViewMode = _usePluginState.editorViewMode,
|
|
56
|
+
editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference,
|
|
57
|
+
editorAppearance = _usePluginState.editorAppearance;
|
|
31
58
|
var toolbar = parents.find(function (parent) {
|
|
32
59
|
return parent.type === 'toolbar';
|
|
33
60
|
});
|
|
34
|
-
|
|
35
|
-
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
36
|
-
if (isSharedSection && !shouldShowSection(editMode, toolbar, toolbarDocking, disableSelectionToolbar)) {
|
|
61
|
+
if (isSharedSection && !shouldShowSection(editorViewMode, toolbar, editorToolbarDockingPreference, disableSelectionToolbar)) {
|
|
37
62
|
return null;
|
|
38
63
|
}
|
|
39
64
|
var isFullPage = editorAppearance === 'full-page';
|
|
@@ -9,36 +9,66 @@ import { AllSelection, TextSelection } from '@atlaskit/editor-prosemirror/state'
|
|
|
9
9
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { ToolbarSection, ToolbarButtonGroup, ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
11
11
|
import { ToolbarModelRenderer } from '@atlaskit/editor-toolbar-model';
|
|
12
|
+
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
12
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
14
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
14
15
|
import { SELECTION_TOOLBAR_LABEL } from '../consts';
|
|
15
16
|
var isToolbarComponent = function isToolbarComponent(component) {
|
|
16
17
|
return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
|
|
17
18
|
};
|
|
19
|
+
var usePluginState = conditionalHooksFactory(function () {
|
|
20
|
+
return expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
|
|
21
|
+
}, function (api) {
|
|
22
|
+
return useSharedPluginStateWithSelector(api, ['connectivity', 'userPreferences', 'toolbar', 'selection', 'userIntent', 'editorViewMode'], function (state) {
|
|
23
|
+
var _state$connectivitySt, _state$userPreference, _state$toolbarState, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
24
|
+
return {
|
|
25
|
+
connectivityStateMode: (_state$connectivitySt = state.connectivityState) === null || _state$connectivitySt === void 0 ? void 0 : _state$connectivitySt.mode,
|
|
26
|
+
editorToolbarDockingPreference: (_state$userPreference = state.userPreferencesState) === null || _state$userPreference === void 0 || (_state$userPreference = _state$userPreference.preferences) === null || _state$userPreference === void 0 ? void 0 : _state$userPreference.toolbarDockingPosition,
|
|
27
|
+
shouldShowToolbar: (_state$toolbarState = state.toolbarState) === null || _state$toolbarState === void 0 ? void 0 : _state$toolbarState.shouldShowToolbar,
|
|
28
|
+
selection: (_state$selectionState = state.selectionState) === null || _state$selectionState === void 0 ? void 0 : _state$selectionState.selection,
|
|
29
|
+
currentUserIntent: (_state$userIntentStat = state.userIntentState) === null || _state$userIntentStat === void 0 ? void 0 : _state$userIntentStat.currentUserIntent,
|
|
30
|
+
editorViewMode: (_state$editorViewMode = state.editorViewModeState) === null || _state$editorViewMode === void 0 ? void 0 : _state$editorViewMode.mode
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}, function (api) {
|
|
34
|
+
var connectivityStateMode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
35
|
+
var editorToolbarDockingPreference = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
36
|
+
var currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
|
|
37
|
+
var selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
38
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['toolbar'], function (state) {
|
|
39
|
+
var _state$toolbarState2;
|
|
40
|
+
return {
|
|
41
|
+
shouldShowToolbar: (_state$toolbarState2 = state.toolbarState) === null || _state$toolbarState2 === void 0 ? void 0 : _state$toolbarState2.shouldShowToolbar
|
|
42
|
+
};
|
|
43
|
+
}),
|
|
44
|
+
shouldShowToolbar = _useSharedPluginState.shouldShowToolbar;
|
|
45
|
+
return {
|
|
46
|
+
connectivityStateMode: connectivityStateMode,
|
|
47
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
48
|
+
currentUserIntent: currentUserIntent,
|
|
49
|
+
shouldShowToolbar: shouldShowToolbar,
|
|
50
|
+
selection: selection,
|
|
51
|
+
editorViewMode: undefined
|
|
52
|
+
};
|
|
53
|
+
});
|
|
18
54
|
export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
19
55
|
var _api$toolbar;
|
|
20
56
|
var api = _ref.api,
|
|
21
57
|
editorView = _ref.editorView,
|
|
22
58
|
mountPoint = _ref.mountPoint,
|
|
23
59
|
disableSelectionToolbarWhenPinned = _ref.disableSelectionToolbarWhenPinned;
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
60
|
+
var _usePluginState = usePluginState(api),
|
|
61
|
+
connectivityStateMode = _usePluginState.connectivityStateMode,
|
|
62
|
+
editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference,
|
|
63
|
+
currentUserIntent = _usePluginState.currentUserIntent,
|
|
64
|
+
shouldShowToolbar = _usePluginState.shouldShowToolbar,
|
|
65
|
+
editorViewMode = _usePluginState.editorViewMode,
|
|
66
|
+
selection = _usePluginState.selection;
|
|
31
67
|
var components = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.getComponents();
|
|
32
68
|
var toolbar = components === null || components === void 0 ? void 0 : components.find(function (component) {
|
|
33
69
|
return isToolbarComponent(component);
|
|
34
70
|
});
|
|
35
|
-
var currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
|
|
36
|
-
var connectivityStateMode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
37
|
-
var toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
38
71
|
var isOffline = connectivityStateMode === 'offline';
|
|
39
|
-
// TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
|
|
40
|
-
// @ts-expect-error
|
|
41
|
-
var selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
42
72
|
var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
|
|
43
73
|
var isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof AllSelection && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true);
|
|
44
74
|
var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
@@ -54,7 +84,7 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
54
84
|
var calc = calculateToolbarPositionTrackHead;
|
|
55
85
|
return calc(toolbarTitle)(editorView, position);
|
|
56
86
|
}, [editorView]);
|
|
57
|
-
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) &&
|
|
87
|
+
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
58
88
|
return null;
|
|
59
89
|
}
|
|
60
90
|
if (!(isTextSelection || isCellSelection || isAllSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || currentUserIntent && currentUserIntent !== 'default' && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true) || isSSR()) {
|
|
@@ -66,7 +96,9 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
66
96
|
onPositionCalculated: onPositionCalculated,
|
|
67
97
|
mountTo: mountPoint
|
|
68
98
|
}, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
69
|
-
editorView: editorView
|
|
99
|
+
editorView: editorView,
|
|
100
|
+
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
101
|
+
editorViewMode: editorViewMode
|
|
70
102
|
}, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
|
|
71
103
|
api: api,
|
|
72
104
|
isDisabled: isOffline
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,21 +28,22 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/editor-plugin-connectivity": "^
|
|
32
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
33
|
-
"@atlaskit/editor-plugin-selection": "^
|
|
34
|
-
"@atlaskit/editor-plugin-user-intent": "^
|
|
35
|
-
"@atlaskit/editor-plugin-user-preferences": "^
|
|
31
|
+
"@atlaskit/editor-plugin-connectivity": "^5.0.0",
|
|
32
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^7.0.0",
|
|
33
|
+
"@atlaskit/editor-plugin-selection": "^5.0.0",
|
|
34
|
+
"@atlaskit/editor-plugin-user-intent": "^3.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-user-preferences": "^3.0.0",
|
|
36
36
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
37
37
|
"@atlaskit/editor-toolbar": "^0.8.0",
|
|
38
38
|
"@atlaskit/editor-toolbar-model": "^0.2.0",
|
|
39
|
-
"@atlaskit/
|
|
39
|
+
"@atlaskit/platform-feature-flags-react": "^0.3.0",
|
|
40
|
+
"@atlaskit/tmp-editor-statsig": "^12.10.0",
|
|
40
41
|
"@babel/runtime": "^7.0.0",
|
|
41
42
|
"bind-event-listener": "^3.0.0",
|
|
42
43
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"@atlaskit/editor-common": "^
|
|
46
|
+
"@atlaskit/editor-common": "^109.1.0",
|
|
46
47
|
"react": "^18.2.0"
|
|
47
48
|
},
|
|
48
49
|
"techstack": {
|