@atlaskit/editor-plugin-toolbar 11.0.5 → 12.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 +15 -0
- package/afm-cc/tsconfig.json +3 -0
- package/compass.yml +3 -3
- package/dist/cjs/toolbarPlugin.js +26 -3
- package/dist/cjs/ui/SelectionToolbar/index.js +20 -13
- package/dist/es2019/toolbarPlugin.js +26 -3
- package/dist/es2019/ui/SelectionToolbar/index.js +20 -13
- package/dist/esm/toolbarPlugin.js +26 -3
- package/dist/esm/ui/SelectionToolbar/index.js +20 -13
- package/dist/types/ui/SelectionToolbar/index.d.ts +3 -2
- package/docs/0-intro.tsx +0 -1
- package/package.json +10 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar
|
|
2
2
|
|
|
3
|
+
## 12.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`eec66a5b383e5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eec66a5b383e5) -
|
|
8
|
+
Scope selection toolbar interactions and dropdown refocus behavior to their owning editor behind
|
|
9
|
+
the `platform_editor_toolbar_multi_editor_fix` experiment.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 12.0.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 11.0.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/compass.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
configVersion: 1
|
|
2
2
|
id: ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:component/c5751cc6-3513-4070-9deb-af31e86aed34/0f961f0e-ea5b-4c29-8cb4-43f8e95ec14e
|
|
3
3
|
name: '@atlaskit/editor-plugin-toolbar'
|
|
4
|
-
ownerId: ari:cloud:identity::team/
|
|
4
|
+
ownerId: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb # Editor Developers
|
|
5
5
|
labels:
|
|
6
6
|
- platform-code
|
|
7
7
|
- platform-afm
|
|
@@ -16,14 +16,14 @@ links:
|
|
|
16
16
|
url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master
|
|
17
17
|
- name: Slack Channel
|
|
18
18
|
type: CHAT_CHANNEL
|
|
19
|
-
url: https://atlassian.enterprise.slack.com/archives/
|
|
19
|
+
url: https://atlassian.enterprise.slack.com/archives/CFG3PSQ9E # #help-editor
|
|
20
20
|
- name: Editor Plugin Toolbar
|
|
21
21
|
type: REPOSITORY
|
|
22
22
|
url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/editor/editor-plugin-toolbar
|
|
23
23
|
customFields:
|
|
24
24
|
- name: Department
|
|
25
25
|
type: text
|
|
26
|
-
value:
|
|
26
|
+
value: Editor Developers
|
|
27
27
|
- name: Trusted Reviewer Teams
|
|
28
28
|
type: text
|
|
29
29
|
value: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb
|
|
@@ -14,6 +14,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
|
14
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
15
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
16
16
|
var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
|
|
17
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
17
18
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
18
19
|
var _selectionToolbarOpenExperience = require("./pm-plugins/experiences/selection-toolbar-open-experience");
|
|
19
20
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
@@ -77,6 +78,9 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
77
78
|
disableSelectionToolbarWhenPinned: false
|
|
78
79
|
} : _ref$config;
|
|
79
80
|
var refs = {};
|
|
81
|
+
var handleToolbarMouseUp = function handleToolbarMouseUp(event) {
|
|
82
|
+
refs.toolbarMouseUpEvent = event.nativeEvent;
|
|
83
|
+
};
|
|
80
84
|
var disableSelectionToolbar = config.disableSelectionToolbar,
|
|
81
85
|
disableSelectionToolbarWhenPinned = config.disableSelectionToolbarWhenPinned,
|
|
82
86
|
_config$contextualFor = config.contextualFormattingEnabled,
|
|
@@ -186,16 +190,34 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
186
190
|
var unbind = (0, _bindEventListener.bind)(_view.root, {
|
|
187
191
|
type: 'mouseup',
|
|
188
192
|
listener: function listener(ev) {
|
|
189
|
-
var _api$
|
|
193
|
+
var _api$editorViewMode2;
|
|
190
194
|
mouseState.isMouseDown = false;
|
|
191
195
|
var event = ev;
|
|
196
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_toolbar_multi_editor_fix')) {
|
|
197
|
+
var _api$editorViewMode;
|
|
198
|
+
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
199
|
+
var isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
200
|
+
var isMouseUpInEditor = event.composedPath().includes(_view.dom);
|
|
201
|
+
refs.toolbarMouseUpEvent = undefined;
|
|
202
|
+
|
|
203
|
+
// Prevent outside clicks from reopening a blurred editor's toolbar.
|
|
204
|
+
var _editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
205
|
+
var _isViewModeEnabled = (_editorViewModePlugin === null || _editorViewModePlugin === void 0 ? void 0 : _editorViewModePlugin.mode) === 'view';
|
|
206
|
+
// Include focus in nested editable islands when enabled.
|
|
207
|
+
var _hasEditorFocus = (0, _fg.fg)('platform_editor_blocks_patch_7') ? _view.hasFocus() || _view.dom.contains(_view.root.activeElement) : _view.hasFocus();
|
|
208
|
+
var shouldShowToolbar = _isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : _hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
209
|
+
_view.dispatch(_view.state.tr.setMeta(_pluginKey.editorToolbarPluginKey, {
|
|
210
|
+
shouldShowToolbar: shouldShowToolbar
|
|
211
|
+
}));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
192
214
|
var isInToolbar = (0, _toolbar.isEventInContainer)(event, _consts.DEFAULT_POPUP_SELECTORS.toolbarContainer);
|
|
193
215
|
var isInPortal = (0, _toolbar.isEventInContainer)(event, _consts.DEFAULT_POPUP_SELECTORS.portal);
|
|
194
216
|
|
|
195
217
|
// We only want to set selectionStable to true if the editor has focus
|
|
196
218
|
// to prevent the toolbar from showing when the editor is blurred
|
|
197
219
|
// due to a click outside the editor.
|
|
198
|
-
var editorViewModePlugin = api === null || api === void 0 || (_api$
|
|
220
|
+
var editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.sharedState.currentState();
|
|
199
221
|
var isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
200
222
|
// Focus can sit inside a nested editable region ProseMirror does not own -
|
|
201
223
|
// such as a reference synced block's island - where `view.hasFocus()` is
|
|
@@ -263,7 +285,8 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
263
285
|
api: api,
|
|
264
286
|
editorView: editorView,
|
|
265
287
|
mountPoint: popupsMountPoint,
|
|
266
|
-
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
|
|
288
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false,
|
|
289
|
+
onToolbarMouseUp: handleToolbarMouseUp
|
|
267
290
|
});
|
|
268
291
|
} : undefined
|
|
269
292
|
};
|
|
@@ -20,6 +20,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
20
20
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
21
21
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
22
22
|
var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
|
|
23
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
23
24
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
24
25
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
25
26
|
var _consts = require("../consts");
|
|
@@ -68,7 +69,8 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
68
69
|
var api = _ref.api,
|
|
69
70
|
editorView = _ref.editorView,
|
|
70
71
|
mountPoint = _ref.mountPoint,
|
|
71
|
-
disableSelectionToolbarWhenPinned = _ref.disableSelectionToolbarWhenPinned
|
|
72
|
+
disableSelectionToolbarWhenPinned = _ref.disableSelectionToolbarWhenPinned,
|
|
73
|
+
onToolbarMouseUp = _ref.onToolbarMouseUp;
|
|
72
74
|
var _usePluginState = usePluginState(api),
|
|
73
75
|
connectivityStateMode = _usePluginState.connectivityStateMode,
|
|
74
76
|
editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference,
|
|
@@ -101,15 +103,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
101
103
|
currentUserIntent && currentUserIntent !== 'default' && !(currentUserIntent === 'dragHandleSelected' && !isCellSelection) || (0, _coreUtils.isSSR)()) {
|
|
102
104
|
return null;
|
|
103
105
|
}
|
|
104
|
-
|
|
105
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
106
|
-
, {
|
|
107
|
-
offset: [0, 10],
|
|
108
|
-
target: (0, _utils2.getDomRefFromSelection)(editorView),
|
|
109
|
-
onPositionCalculated: onPositionCalculated,
|
|
110
|
-
mountTo: mountPoint,
|
|
111
|
-
zIndex: _editorSharedStyles.akEditorFloatingDialogZIndex
|
|
112
|
-
}, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
|
|
106
|
+
var toolbarContent = /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
|
|
113
107
|
editorView: editorView,
|
|
114
108
|
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
115
109
|
editorViewMode: editorViewMode !== null && editorViewMode !== void 0 ? editorViewMode : 'edit',
|
|
@@ -134,14 +128,26 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
134
128
|
menuSection: _editorToolbar.ToolbarDropdownItemSection,
|
|
135
129
|
group: _editorToolbar.ToolbarButtonGroup
|
|
136
130
|
}
|
|
137
|
-
})))
|
|
131
|
+
})));
|
|
132
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Popup
|
|
133
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
134
|
+
, {
|
|
135
|
+
offset: [0, 10],
|
|
136
|
+
target: (0, _utils2.getDomRefFromSelection)(editorView),
|
|
137
|
+
onPositionCalculated: onPositionCalculated,
|
|
138
|
+
mountTo: mountPoint,
|
|
139
|
+
zIndex: _editorSharedStyles.akEditorFloatingDialogZIndex
|
|
140
|
+
}, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_toolbar_multi_editor_fix') ? /*#__PURE__*/_react.default.createElement("div", {
|
|
141
|
+
onMouseUpCapture: onToolbarMouseUp
|
|
142
|
+
}, toolbarContent) : toolbarContent);
|
|
138
143
|
};
|
|
139
144
|
var SelectionToolbarWithErrorBoundary = exports.SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErrorBoundary(_ref3) {
|
|
140
145
|
var _api$analytics2;
|
|
141
146
|
var api = _ref3.api,
|
|
142
147
|
editorView = _ref3.editorView,
|
|
143
148
|
mountPoint = _ref3.mountPoint,
|
|
144
|
-
disableSelectionToolbarWhenPinned = _ref3.disableSelectionToolbarWhenPinned
|
|
149
|
+
disableSelectionToolbarWhenPinned = _ref3.disableSelectionToolbarWhenPinned,
|
|
150
|
+
onToolbarMouseUp = _ref3.onToolbarMouseUp;
|
|
145
151
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
146
152
|
component: _analytics.ACTION_SUBJECT.TOOLBAR,
|
|
147
153
|
componentId: _analytics.ACTION_SUBJECT_ID.SELECTION_TOOLBAR,
|
|
@@ -151,6 +157,7 @@ var SelectionToolbarWithErrorBoundary = exports.SelectionToolbarWithErrorBoundar
|
|
|
151
157
|
api: api,
|
|
152
158
|
editorView: editorView,
|
|
153
159
|
mountPoint: mountPoint,
|
|
154
|
-
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
|
|
160
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned,
|
|
161
|
+
onToolbarMouseUp: onToolbarMouseUp
|
|
155
162
|
}));
|
|
156
163
|
};
|
|
@@ -4,6 +4,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
4
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
|
|
7
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
9
|
import { getSelectionToolbarOpenExperiencePlugin } from './pm-plugins/experiences/selection-toolbar-open-experience';
|
|
9
10
|
import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
@@ -60,6 +61,9 @@ export const toolbarPlugin = ({
|
|
|
60
61
|
}
|
|
61
62
|
}) => {
|
|
62
63
|
const refs = {};
|
|
64
|
+
const handleToolbarMouseUp = event => {
|
|
65
|
+
refs.toolbarMouseUpEvent = event.nativeEvent;
|
|
66
|
+
};
|
|
63
67
|
const {
|
|
64
68
|
disableSelectionToolbar,
|
|
65
69
|
disableSelectionToolbarWhenPinned,
|
|
@@ -178,16 +182,34 @@ export const toolbarPlugin = ({
|
|
|
178
182
|
const unbind = bind(view.root, {
|
|
179
183
|
type: 'mouseup',
|
|
180
184
|
listener: function (ev) {
|
|
181
|
-
var _api$
|
|
185
|
+
var _api$editorViewMode2;
|
|
182
186
|
mouseState.isMouseDown = false;
|
|
183
187
|
const event = ev;
|
|
188
|
+
if (isExperimentEnabled('platform_editor_toolbar_multi_editor_fix')) {
|
|
189
|
+
var _api$editorViewMode;
|
|
190
|
+
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
191
|
+
const isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
192
|
+
const isMouseUpInEditor = event.composedPath().includes(view.dom);
|
|
193
|
+
refs.toolbarMouseUpEvent = undefined;
|
|
194
|
+
|
|
195
|
+
// Prevent outside clicks from reopening a blurred editor's toolbar.
|
|
196
|
+
const editorViewModePlugin = api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
197
|
+
const isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
198
|
+
// Include focus in nested editable islands when enabled.
|
|
199
|
+
const hasEditorFocus = fg('platform_editor_blocks_patch_7') ? view.hasFocus() || view.dom.contains(view.root.activeElement) : view.hasFocus();
|
|
200
|
+
const shouldShowToolbar = isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
201
|
+
view.dispatch(view.state.tr.setMeta(editorToolbarPluginKey, {
|
|
202
|
+
shouldShowToolbar
|
|
203
|
+
}));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
184
206
|
const isInToolbar = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.toolbarContainer);
|
|
185
207
|
const isInPortal = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.portal);
|
|
186
208
|
|
|
187
209
|
// We only want to set selectionStable to true if the editor has focus
|
|
188
210
|
// to prevent the toolbar from showing when the editor is blurred
|
|
189
211
|
// due to a click outside the editor.
|
|
190
|
-
const editorViewModePlugin = api === null || api === void 0 ? void 0 : (_api$
|
|
212
|
+
const editorViewModePlugin = api === null || api === void 0 ? void 0 : (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.sharedState.currentState();
|
|
191
213
|
const isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
192
214
|
// Focus can sit inside a nested editable region ProseMirror does not own -
|
|
193
215
|
// such as a reference synced block's island - where `view.hasFocus()` is
|
|
@@ -254,7 +276,8 @@ export const toolbarPlugin = ({
|
|
|
254
276
|
api: api,
|
|
255
277
|
editorView: editorView,
|
|
256
278
|
mountPoint: popupsMountPoint,
|
|
257
|
-
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
|
|
279
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false,
|
|
280
|
+
onToolbarMouseUp: handleToolbarMouseUp
|
|
258
281
|
});
|
|
259
282
|
} : undefined
|
|
260
283
|
};
|
|
@@ -13,6 +13,7 @@ import { AllSelection, TextSelection } from '@atlaskit/editor-prosemirror/state'
|
|
|
13
13
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
14
14
|
import { ToolbarSection, ToolbarButtonGroup, ToolbarDropdownItemSection, useToolbarUI } from '@atlaskit/editor-toolbar';
|
|
15
15
|
import { ToolbarModelRenderer } from '@atlaskit/editor-toolbar-model';
|
|
16
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
16
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
18
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
19
|
import { SELECTION_TOOLBAR_LABEL } from '../consts';
|
|
@@ -59,7 +60,8 @@ export const SelectionToolbar = ({
|
|
|
59
60
|
api,
|
|
60
61
|
editorView,
|
|
61
62
|
mountPoint,
|
|
62
|
-
disableSelectionToolbarWhenPinned
|
|
63
|
+
disableSelectionToolbarWhenPinned,
|
|
64
|
+
onToolbarMouseUp
|
|
63
65
|
}) => {
|
|
64
66
|
var _ref, _api$toolbar, _api$toolbar2;
|
|
65
67
|
const {
|
|
@@ -94,15 +96,7 @@ export const SelectionToolbar = ({
|
|
|
94
96
|
currentUserIntent && currentUserIntent !== 'default' && !(currentUserIntent === 'dragHandleSelected' && !isCellSelection) || isSSR()) {
|
|
95
97
|
return null;
|
|
96
98
|
}
|
|
97
|
-
|
|
98
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
99
|
-
, {
|
|
100
|
-
offset: [0, 10],
|
|
101
|
-
target: getDomRefFromSelection(editorView),
|
|
102
|
-
onPositionCalculated: onPositionCalculated,
|
|
103
|
-
mountTo: mountPoint,
|
|
104
|
-
zIndex: akEditorFloatingDialogZIndex
|
|
105
|
-
}, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
99
|
+
const toolbarContent = /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
106
100
|
editorView: editorView,
|
|
107
101
|
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
108
102
|
editorViewMode: editorViewMode !== null && editorViewMode !== void 0 ? editorViewMode : 'edit',
|
|
@@ -127,13 +121,25 @@ export const SelectionToolbar = ({
|
|
|
127
121
|
menuSection: ToolbarDropdownItemSection,
|
|
128
122
|
group: ToolbarButtonGroup
|
|
129
123
|
}
|
|
130
|
-
})))
|
|
124
|
+
})));
|
|
125
|
+
return /*#__PURE__*/React.createElement(Popup
|
|
126
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
127
|
+
, {
|
|
128
|
+
offset: [0, 10],
|
|
129
|
+
target: getDomRefFromSelection(editorView),
|
|
130
|
+
onPositionCalculated: onPositionCalculated,
|
|
131
|
+
mountTo: mountPoint,
|
|
132
|
+
zIndex: akEditorFloatingDialogZIndex
|
|
133
|
+
}, isExperimentEnabled('platform_editor_toolbar_multi_editor_fix') ? /*#__PURE__*/React.createElement("div", {
|
|
134
|
+
onMouseUpCapture: onToolbarMouseUp
|
|
135
|
+
}, toolbarContent) : toolbarContent);
|
|
131
136
|
};
|
|
132
137
|
export const SelectionToolbarWithErrorBoundary = ({
|
|
133
138
|
api,
|
|
134
139
|
editorView,
|
|
135
140
|
mountPoint,
|
|
136
|
-
disableSelectionToolbarWhenPinned
|
|
141
|
+
disableSelectionToolbarWhenPinned,
|
|
142
|
+
onToolbarMouseUp
|
|
137
143
|
}) => {
|
|
138
144
|
var _api$analytics2;
|
|
139
145
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
@@ -145,6 +151,7 @@ export const SelectionToolbarWithErrorBoundary = ({
|
|
|
145
151
|
api: api,
|
|
146
152
|
editorView: editorView,
|
|
147
153
|
mountPoint: mountPoint,
|
|
148
|
-
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
|
|
154
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned,
|
|
155
|
+
onToolbarMouseUp: onToolbarMouseUp
|
|
149
156
|
}));
|
|
150
157
|
};
|
|
@@ -10,6 +10,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
10
10
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
12
12
|
import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
|
|
13
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
13
14
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
14
15
|
import { getSelectionToolbarOpenExperiencePlugin } from './pm-plugins/experiences/selection-toolbar-open-experience';
|
|
15
16
|
import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
@@ -70,6 +71,9 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
70
71
|
disableSelectionToolbarWhenPinned: false
|
|
71
72
|
} : _ref$config;
|
|
72
73
|
var refs = {};
|
|
74
|
+
var handleToolbarMouseUp = function handleToolbarMouseUp(event) {
|
|
75
|
+
refs.toolbarMouseUpEvent = event.nativeEvent;
|
|
76
|
+
};
|
|
73
77
|
var disableSelectionToolbar = config.disableSelectionToolbar,
|
|
74
78
|
disableSelectionToolbarWhenPinned = config.disableSelectionToolbarWhenPinned,
|
|
75
79
|
_config$contextualFor = config.contextualFormattingEnabled,
|
|
@@ -179,16 +183,34 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
179
183
|
var unbind = bind(_view.root, {
|
|
180
184
|
type: 'mouseup',
|
|
181
185
|
listener: function listener(ev) {
|
|
182
|
-
var _api$
|
|
186
|
+
var _api$editorViewMode2;
|
|
183
187
|
mouseState.isMouseDown = false;
|
|
184
188
|
var event = ev;
|
|
189
|
+
if (isExperimentEnabled('platform_editor_toolbar_multi_editor_fix')) {
|
|
190
|
+
var _api$editorViewMode;
|
|
191
|
+
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
192
|
+
var isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
193
|
+
var isMouseUpInEditor = event.composedPath().includes(_view.dom);
|
|
194
|
+
refs.toolbarMouseUpEvent = undefined;
|
|
195
|
+
|
|
196
|
+
// Prevent outside clicks from reopening a blurred editor's toolbar.
|
|
197
|
+
var _editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
198
|
+
var _isViewModeEnabled = (_editorViewModePlugin === null || _editorViewModePlugin === void 0 ? void 0 : _editorViewModePlugin.mode) === 'view';
|
|
199
|
+
// Include focus in nested editable islands when enabled.
|
|
200
|
+
var _hasEditorFocus = fg('platform_editor_blocks_patch_7') ? _view.hasFocus() || _view.dom.contains(_view.root.activeElement) : _view.hasFocus();
|
|
201
|
+
var shouldShowToolbar = _isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : _hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
202
|
+
_view.dispatch(_view.state.tr.setMeta(editorToolbarPluginKey, {
|
|
203
|
+
shouldShowToolbar: shouldShowToolbar
|
|
204
|
+
}));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
185
207
|
var isInToolbar = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.toolbarContainer);
|
|
186
208
|
var isInPortal = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.portal);
|
|
187
209
|
|
|
188
210
|
// We only want to set selectionStable to true if the editor has focus
|
|
189
211
|
// to prevent the toolbar from showing when the editor is blurred
|
|
190
212
|
// due to a click outside the editor.
|
|
191
|
-
var editorViewModePlugin = api === null || api === void 0 || (_api$
|
|
213
|
+
var editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.sharedState.currentState();
|
|
192
214
|
var isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
193
215
|
// Focus can sit inside a nested editable region ProseMirror does not own -
|
|
194
216
|
// such as a reference synced block's island - where `view.hasFocus()` is
|
|
@@ -256,7 +278,8 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
256
278
|
api: api,
|
|
257
279
|
editorView: editorView,
|
|
258
280
|
mountPoint: popupsMountPoint,
|
|
259
|
-
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
|
|
281
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false,
|
|
282
|
+
onToolbarMouseUp: handleToolbarMouseUp
|
|
260
283
|
});
|
|
261
284
|
} : undefined
|
|
262
285
|
};
|
|
@@ -13,6 +13,7 @@ import { AllSelection, TextSelection } from '@atlaskit/editor-prosemirror/state'
|
|
|
13
13
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
14
14
|
import { ToolbarSection, ToolbarButtonGroup, ToolbarDropdownItemSection, useToolbarUI } from '@atlaskit/editor-toolbar';
|
|
15
15
|
import { ToolbarModelRenderer } from '@atlaskit/editor-toolbar-model';
|
|
16
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
16
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
18
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
19
|
import { SELECTION_TOOLBAR_LABEL } from '../consts';
|
|
@@ -60,7 +61,8 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
60
61
|
var api = _ref.api,
|
|
61
62
|
editorView = _ref.editorView,
|
|
62
63
|
mountPoint = _ref.mountPoint,
|
|
63
|
-
disableSelectionToolbarWhenPinned = _ref.disableSelectionToolbarWhenPinned
|
|
64
|
+
disableSelectionToolbarWhenPinned = _ref.disableSelectionToolbarWhenPinned,
|
|
65
|
+
onToolbarMouseUp = _ref.onToolbarMouseUp;
|
|
64
66
|
var _usePluginState = usePluginState(api),
|
|
65
67
|
connectivityStateMode = _usePluginState.connectivityStateMode,
|
|
66
68
|
editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference,
|
|
@@ -93,15 +95,7 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
93
95
|
currentUserIntent && currentUserIntent !== 'default' && !(currentUserIntent === 'dragHandleSelected' && !isCellSelection) || isSSR()) {
|
|
94
96
|
return null;
|
|
95
97
|
}
|
|
96
|
-
|
|
97
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
98
|
-
, {
|
|
99
|
-
offset: [0, 10],
|
|
100
|
-
target: getDomRefFromSelection(editorView),
|
|
101
|
-
onPositionCalculated: onPositionCalculated,
|
|
102
|
-
mountTo: mountPoint,
|
|
103
|
-
zIndex: akEditorFloatingDialogZIndex
|
|
104
|
-
}, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
98
|
+
var toolbarContent = /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
105
99
|
editorView: editorView,
|
|
106
100
|
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
107
101
|
editorViewMode: editorViewMode !== null && editorViewMode !== void 0 ? editorViewMode : 'edit',
|
|
@@ -126,14 +120,26 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
126
120
|
menuSection: ToolbarDropdownItemSection,
|
|
127
121
|
group: ToolbarButtonGroup
|
|
128
122
|
}
|
|
129
|
-
})))
|
|
123
|
+
})));
|
|
124
|
+
return /*#__PURE__*/React.createElement(Popup
|
|
125
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
126
|
+
, {
|
|
127
|
+
offset: [0, 10],
|
|
128
|
+
target: getDomRefFromSelection(editorView),
|
|
129
|
+
onPositionCalculated: onPositionCalculated,
|
|
130
|
+
mountTo: mountPoint,
|
|
131
|
+
zIndex: akEditorFloatingDialogZIndex
|
|
132
|
+
}, isExperimentEnabled('platform_editor_toolbar_multi_editor_fix') ? /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
onMouseUpCapture: onToolbarMouseUp
|
|
134
|
+
}, toolbarContent) : toolbarContent);
|
|
130
135
|
};
|
|
131
136
|
export var SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErrorBoundary(_ref3) {
|
|
132
137
|
var _api$analytics2;
|
|
133
138
|
var api = _ref3.api,
|
|
134
139
|
editorView = _ref3.editorView,
|
|
135
140
|
mountPoint = _ref3.mountPoint,
|
|
136
|
-
disableSelectionToolbarWhenPinned = _ref3.disableSelectionToolbarWhenPinned
|
|
141
|
+
disableSelectionToolbarWhenPinned = _ref3.disableSelectionToolbarWhenPinned,
|
|
142
|
+
onToolbarMouseUp = _ref3.onToolbarMouseUp;
|
|
137
143
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
138
144
|
component: ACTION_SUBJECT.TOOLBAR,
|
|
139
145
|
componentId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR,
|
|
@@ -143,6 +149,7 @@ export var SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErro
|
|
|
143
149
|
api: api,
|
|
144
150
|
editorView: editorView,
|
|
145
151
|
mountPoint: mountPoint,
|
|
146
|
-
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
|
|
152
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned,
|
|
153
|
+
onToolbarMouseUp: onToolbarMouseUp
|
|
147
154
|
}));
|
|
148
155
|
};
|
|
@@ -7,7 +7,8 @@ type SelectionToolbarProps = {
|
|
|
7
7
|
disableSelectionToolbarWhenPinned: boolean;
|
|
8
8
|
editorView: EditorView;
|
|
9
9
|
mountPoint: HTMLElement | undefined;
|
|
10
|
+
onToolbarMouseUp?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
10
11
|
};
|
|
11
|
-
export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
|
|
12
|
-
export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element;
|
|
12
|
+
export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, onToolbarMouseUp, }: SelectionToolbarProps) => React.JSX.Element | null;
|
|
13
|
+
export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, onToolbarMouseUp, }: SelectionToolbarProps) => React.JSX.Element;
|
|
13
14
|
export {};
|
package/docs/0-intro.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { AtlassianInternalWarning, code, md } from '@atlaskit/docs';
|
|
4
|
-
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
4
|
import { createEditorUseOnlyNotice } from '@atlaskit/editor-common/doc-utils';
|
|
6
5
|
import { token } from '@atlaskit/tokens';
|
|
7
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "Toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,23 +21,24 @@
|
|
|
21
21
|
"atlaskit:src": "src/index.ts",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@atlaskit/browser-apis": "^1.2.0",
|
|
24
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
25
|
-
"@atlaskit/editor-plugin-connectivity": "^
|
|
26
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
27
|
-
"@atlaskit/editor-plugin-selection": "^
|
|
28
|
-
"@atlaskit/editor-plugin-user-intent": "^
|
|
29
|
-
"@atlaskit/editor-plugin-user-preferences": "^
|
|
24
|
+
"@atlaskit/editor-plugin-analytics": "^15.0.0",
|
|
25
|
+
"@atlaskit/editor-plugin-connectivity": "^15.0.0",
|
|
26
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^17.0.0",
|
|
27
|
+
"@atlaskit/editor-plugin-selection": "^15.0.0",
|
|
28
|
+
"@atlaskit/editor-plugin-user-intent": "^13.0.0",
|
|
29
|
+
"@atlaskit/editor-plugin-user-preferences": "^13.0.0",
|
|
30
30
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
31
31
|
"@atlaskit/editor-shared-styles": "^4.0.0",
|
|
32
32
|
"@atlaskit/editor-toolbar": "^2.4.0",
|
|
33
33
|
"@atlaskit/editor-toolbar-model": "^1.2.0",
|
|
34
|
+
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
34
35
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
35
|
-
"@atlaskit/tmp-editor-statsig": "^147.
|
|
36
|
+
"@atlaskit/tmp-editor-statsig": "^147.1.0",
|
|
36
37
|
"@babel/runtime": "^7.0.0",
|
|
37
38
|
"bind-event-listener": "^3.0.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^
|
|
41
|
+
"@atlaskit/editor-common": "^119.4.0",
|
|
41
42
|
"react": "^18.2.0 || ^19.2.0",
|
|
42
43
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
43
44
|
},
|