@atlaskit/editor-plugin-toolbar 1.0.0 → 1.0.1
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 +7 -0
- package/dist/cjs/ui/SelectionToolbar/index.js +5 -4
- package/dist/es2019/ui/SelectionToolbar/index.js +6 -5
- package/dist/esm/ui/SelectionToolbar/index.js +6 -5
- package/dist/types/ui/SelectionToolbar/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/SelectionToolbar/index.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`cb63aae8c8554`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cb63aae8c8554) -
|
|
8
|
+
Add a check to ensure selection toolbar renders when all doc is selected
|
|
9
|
+
|
|
3
10
|
## 1.0.0
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -24,7 +24,7 @@ var isToolbarComponent = function isToolbarComponent(component) {
|
|
|
24
24
|
return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
|
|
25
25
|
};
|
|
26
26
|
var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref) {
|
|
27
|
-
var _api$toolbar
|
|
27
|
+
var _api$toolbar;
|
|
28
28
|
var api = _ref.api,
|
|
29
29
|
editorView = _ref.editorView,
|
|
30
30
|
mountPoint = _ref.mountPoint,
|
|
@@ -36,19 +36,20 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
36
36
|
};
|
|
37
37
|
}),
|
|
38
38
|
shouldShowToolbar = _useSharedPluginState.shouldShowToolbar;
|
|
39
|
-
var components = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0
|
|
39
|
+
var components = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.getComponents();
|
|
40
40
|
var toolbar = components === null || components === void 0 ? void 0 : components.find(function (component) {
|
|
41
41
|
return isToolbarComponent(component);
|
|
42
42
|
});
|
|
43
43
|
var currentUserIntent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userIntent.currentUserIntent');
|
|
44
44
|
var connectivityStateMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'connectivity.mode');
|
|
45
|
+
var toolbarDocking = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
45
46
|
var isOffline = connectivityStateMode === 'offline';
|
|
46
47
|
// TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
|
|
47
48
|
// @ts-expect-error
|
|
48
49
|
var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
|
|
49
50
|
var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof _state.TextSelection;
|
|
51
|
+
var isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof _state.AllSelection && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true);
|
|
50
52
|
var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
51
|
-
var toolbarDocking = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
52
53
|
var onPositionCalculated = (0, _react.useCallback)(function (position) {
|
|
53
54
|
var toolbarTitle = _consts.SELECTION_TOOLBAR_LABEL;
|
|
54
55
|
|
|
@@ -64,7 +65,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
64
65
|
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && toolbarDocking === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
65
66
|
return null;
|
|
66
67
|
}
|
|
67
|
-
if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || (0, _coreUtils.isSSR)()) {
|
|
68
|
+
if (!(isTextSelection || isCellSelection || isAllSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || (0, _coreUtils.isSSR)()) {
|
|
68
69
|
return null;
|
|
69
70
|
}
|
|
70
71
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
@@ -5,7 +5,7 @@ import { EditorToolbarProvider, EditorToolbarUIProvider } from '@atlaskit/editor
|
|
|
5
5
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
7
|
import { calculateToolbarPositionTrackHead, calculateToolbarPositionOnCellSelection } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
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';
|
|
@@ -21,7 +21,7 @@ export const SelectionToolbar = ({
|
|
|
21
21
|
mountPoint,
|
|
22
22
|
disableSelectionToolbarWhenPinned
|
|
23
23
|
}) => {
|
|
24
|
-
var _api$toolbar
|
|
24
|
+
var _api$toolbar;
|
|
25
25
|
const {
|
|
26
26
|
shouldShowToolbar
|
|
27
27
|
} = useSharedPluginStateWithSelector(api, ['toolbar'], state => {
|
|
@@ -30,17 +30,18 @@ export const SelectionToolbar = ({
|
|
|
30
30
|
shouldShowToolbar: (_state$toolbarState = state.toolbarState) === null || _state$toolbarState === void 0 ? void 0 : _state$toolbarState.shouldShowToolbar
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
|
-
const components = api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 :
|
|
33
|
+
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
34
|
const toolbar = components === null || components === void 0 ? void 0 : components.find(component => isToolbarComponent(component));
|
|
35
35
|
const currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
|
|
36
36
|
const connectivityStateMode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
37
|
+
const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
37
38
|
const isOffline = connectivityStateMode === 'offline';
|
|
38
39
|
// TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
|
|
39
40
|
// @ts-expect-error
|
|
40
41
|
const selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
41
42
|
const isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
|
|
43
|
+
const isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof AllSelection && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true);
|
|
42
44
|
const isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
43
|
-
const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
44
45
|
const onPositionCalculated = useCallback(position => {
|
|
45
46
|
const toolbarTitle = SELECTION_TOOLBAR_LABEL;
|
|
46
47
|
|
|
@@ -56,7 +57,7 @@ export const SelectionToolbar = ({
|
|
|
56
57
|
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && toolbarDocking === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
|
-
if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isSSR()) {
|
|
60
|
+
if (!(isTextSelection || isCellSelection || isAllSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isSSR()) {
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
62
63
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
@@ -5,7 +5,7 @@ import { EditorToolbarProvider, EditorToolbarUIProvider } from '@atlaskit/editor
|
|
|
5
5
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
7
|
import { calculateToolbarPositionTrackHead, calculateToolbarPositionOnCellSelection } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
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';
|
|
@@ -16,7 +16,7 @@ var isToolbarComponent = function isToolbarComponent(component) {
|
|
|
16
16
|
return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
|
|
17
17
|
};
|
|
18
18
|
export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
19
|
-
var _api$toolbar
|
|
19
|
+
var _api$toolbar;
|
|
20
20
|
var api = _ref.api,
|
|
21
21
|
editorView = _ref.editorView,
|
|
22
22
|
mountPoint = _ref.mountPoint,
|
|
@@ -28,19 +28,20 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
28
28
|
};
|
|
29
29
|
}),
|
|
30
30
|
shouldShowToolbar = _useSharedPluginState.shouldShowToolbar;
|
|
31
|
-
var components = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0
|
|
31
|
+
var components = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.getComponents();
|
|
32
32
|
var toolbar = components === null || components === void 0 ? void 0 : components.find(function (component) {
|
|
33
33
|
return isToolbarComponent(component);
|
|
34
34
|
});
|
|
35
35
|
var currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
|
|
36
36
|
var connectivityStateMode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
37
|
+
var toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
37
38
|
var isOffline = connectivityStateMode === 'offline';
|
|
38
39
|
// TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
|
|
39
40
|
// @ts-expect-error
|
|
40
41
|
var selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
41
42
|
var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
|
|
43
|
+
var isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof AllSelection && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true);
|
|
42
44
|
var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
43
|
-
var toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
44
45
|
var onPositionCalculated = useCallback(function (position) {
|
|
45
46
|
var toolbarTitle = SELECTION_TOOLBAR_LABEL;
|
|
46
47
|
|
|
@@ -56,7 +57,7 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
56
57
|
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && toolbarDocking === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
|
-
if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isSSR()) {
|
|
60
|
+
if (!(isTextSelection || isCellSelection || isAllSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isSSR()) {
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
62
63
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
@@ -4,9 +4,9 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
4
4
|
import type { ToolbarPlugin } from '../../toolbarPluginType';
|
|
5
5
|
type SelectionToolbarProps = {
|
|
6
6
|
api?: ExtractInjectionAPI<ToolbarPlugin>;
|
|
7
|
+
disableSelectionToolbarWhenPinned: boolean;
|
|
7
8
|
editorView: EditorView;
|
|
8
9
|
mountPoint: HTMLElement | undefined;
|
|
9
|
-
disableSelectionToolbarWhenPinned: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
|
|
12
12
|
export {};
|
|
@@ -4,9 +4,9 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
4
4
|
import type { ToolbarPlugin } from '../../toolbarPluginType';
|
|
5
5
|
type SelectionToolbarProps = {
|
|
6
6
|
api?: ExtractInjectionAPI<ToolbarPlugin>;
|
|
7
|
+
disableSelectionToolbarWhenPinned: boolean;
|
|
7
8
|
editorView: EditorView;
|
|
8
9
|
mountPoint: HTMLElement | undefined;
|
|
9
|
-
disableSelectionToolbarWhenPinned: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
|
|
12
12
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
37
37
|
"@atlaskit/editor-toolbar": "^0.6.0",
|
|
38
38
|
"@atlaskit/editor-toolbar-model": "^0.2.0",
|
|
39
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^12.1.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
41
|
"bind-event-listener": "^3.0.0",
|
|
42
42
|
"react-intl-next": "npm:react-intl@^5.18.1"
|