@atlaskit/editor-plugin-toolbar 27.0.16 → 27.0.17
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 +9 -0
- package/compass.yml +1 -1
- package/dist/cjs/toolbarPlugin.js +15 -35
- package/dist/cjs/ui/SelectionToolbar/index.js +2 -3
- package/dist/cjs/ui/consts.js +2 -6
- package/dist/cjs/ui/utils/toolbar.js +1 -8
- package/dist/es2019/toolbarPlugin.js +15 -35
- package/dist/es2019/ui/SelectionToolbar/index.js +2 -3
- package/dist/es2019/ui/consts.js +1 -5
- package/dist/es2019/ui/utils/toolbar.js +0 -7
- package/dist/esm/toolbarPlugin.js +15 -35
- package/dist/esm/ui/SelectionToolbar/index.js +2 -3
- package/dist/esm/ui/consts.js +1 -5
- package/dist/esm/ui/utils/toolbar.js +0 -7
- package/dist/types/ui/consts.d.ts +0 -4
- package/dist/types/ui/utils/toolbar.d.ts +0 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar
|
|
2
2
|
|
|
3
|
+
## 27.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6bc3894066dc8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6bc3894066dc8) -
|
|
8
|
+
Clean up the `platform_editor_toolbar_multi_editor_fix` experiment. The selection toolbar now
|
|
9
|
+
always scopes mouseups to its own editor, so it closes correctly when multiple editors are open.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 27.0.16
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/compass.yml
CHANGED
|
@@ -17,10 +17,8 @@ var _createRegistry = require("@atlaskit/editor-toolbar-model/create-registry");
|
|
|
17
17
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
18
18
|
var _selectionToolbarOpenExperience = require("./pm-plugins/experiences/selection-toolbar-open-experience");
|
|
19
19
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
20
|
-
var _consts = require("./ui/consts");
|
|
21
20
|
var _SelectionToolbar = require("./ui/SelectionToolbar");
|
|
22
21
|
var _toolbarComponents = require("./ui/toolbar-components");
|
|
23
|
-
var _toolbar = require("./ui/utils/toolbar");
|
|
24
22
|
var _excluded = ["contextualFormattingModeOverride"];
|
|
25
23
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
24
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -189,45 +187,27 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
189
187
|
var unbind = (0, _bindEventListener.bind)(_view.root, {
|
|
190
188
|
type: 'mouseup',
|
|
191
189
|
listener: function listener(ev) {
|
|
192
|
-
var _api$
|
|
190
|
+
var _api$editorViewMode, _api$toolbar;
|
|
193
191
|
mouseState.isMouseDown = false;
|
|
194
192
|
var event = ev;
|
|
195
|
-
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_toolbar_multi_editor_fix')) {
|
|
196
|
-
var _api$editorViewMode, _api$toolbar;
|
|
197
|
-
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
198
|
-
var isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
199
|
-
var isMouseUpInEditor = event.composedPath().includes(_view.dom);
|
|
200
|
-
refs.toolbarMouseUpEvent = undefined;
|
|
201
193
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
var _hasEditorFocus = _view.hasFocus() || _view.dom.contains(_view.root.activeElement);
|
|
207
|
-
var shouldShowToolbar = _isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : _hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
208
|
-
var currentShouldShowToolbar = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || (_api$toolbar = _api$toolbar.sharedState.currentState()) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.shouldShowToolbar;
|
|
209
|
-
if (currentShouldShowToolbar !== shouldShowToolbar) {
|
|
210
|
-
_view.dispatch(_view.state.tr.setMeta(_pluginKey.editorToolbarPluginKey, {
|
|
211
|
-
shouldShowToolbar: shouldShowToolbar
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
var isInToolbar = (0, _toolbar.isEventInContainer)(event, _consts.DEFAULT_POPUP_SELECTORS.toolbarContainer);
|
|
217
|
-
var isInPortal = (0, _toolbar.isEventInContainer)(event, _consts.DEFAULT_POPUP_SELECTORS.portal);
|
|
194
|
+
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
195
|
+
var isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
196
|
+
var isMouseUpInEditor = event.composedPath().includes(_view.dom);
|
|
197
|
+
refs.toolbarMouseUpEvent = undefined;
|
|
218
198
|
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
// due to a click outside the editor.
|
|
222
|
-
var editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.sharedState.currentState();
|
|
199
|
+
// Prevent outside clicks from reopening a blurred editor's toolbar.
|
|
200
|
+
var editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
223
201
|
var isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
224
|
-
//
|
|
225
|
-
// such as a reference synced block's island - where `view.hasFocus()` is
|
|
226
|
-
// false but the user is still interacting with the editor.
|
|
202
|
+
// Include focus in nested editable islands.
|
|
227
203
|
var hasEditorFocus = _view.hasFocus() || _view.dom.contains(_view.root.activeElement);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
204
|
+
var shouldShowToolbar = isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
205
|
+
var currentShouldShowToolbar = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || (_api$toolbar = _api$toolbar.sharedState.currentState()) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.shouldShowToolbar;
|
|
206
|
+
if (currentShouldShowToolbar !== shouldShowToolbar) {
|
|
207
|
+
_view.dispatch(_view.state.tr.setMeta(_pluginKey.editorToolbarPluginKey, {
|
|
208
|
+
shouldShowToolbar: shouldShowToolbar
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
231
211
|
}
|
|
232
212
|
});
|
|
233
213
|
var unbindEditorViewFocus = (0, _bindEventListener.bind)(_view.dom, {
|
|
@@ -26,7 +26,6 @@ var _toolbarButtonGroup = require("@atlaskit/editor-toolbar/toolbar-button-group
|
|
|
26
26
|
var _toolbarDropdownItemSection = require("@atlaskit/editor-toolbar/toolbar-dropdown-item-section");
|
|
27
27
|
var _toolbarSection = require("@atlaskit/editor-toolbar/toolbar-section");
|
|
28
28
|
var _uiContext = require("@atlaskit/editor-toolbar/ui-context");
|
|
29
|
-
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
30
29
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
31
30
|
var _consts = require("../consts");
|
|
32
31
|
var _keyboardConfig = require("./keyboard-config");
|
|
@@ -145,9 +144,9 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
145
144
|
onPositionCalculated: onPositionCalculated,
|
|
146
145
|
mountTo: mountPoint,
|
|
147
146
|
zIndex: _constants.akEditorFloatingDialogZIndex
|
|
148
|
-
},
|
|
147
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
149
148
|
onMouseUpCapture: onToolbarMouseUp
|
|
150
|
-
}, toolbarContent)
|
|
149
|
+
}, toolbarContent));
|
|
151
150
|
};
|
|
152
151
|
var SelectionToolbarWithErrorBoundary = exports.SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErrorBoundary(_ref3) {
|
|
153
152
|
var _api$analytics2;
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -3,9 +3,5 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SELECTION_TOOLBAR_LABEL =
|
|
7
|
-
var SELECTION_TOOLBAR_LABEL = exports.SELECTION_TOOLBAR_LABEL = 'Selection toolbar';
|
|
8
|
-
var DEFAULT_POPUP_SELECTORS = exports.DEFAULT_POPUP_SELECTORS = {
|
|
9
|
-
toolbarContainer: '[role="toolbar"]',
|
|
10
|
-
portal: '.atlaskit-portal'
|
|
11
|
-
};
|
|
6
|
+
exports.SELECTION_TOOLBAR_LABEL = void 0;
|
|
7
|
+
var SELECTION_TOOLBAR_LABEL = exports.SELECTION_TOOLBAR_LABEL = 'Selection toolbar';
|
|
@@ -3,14 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isShortcutToFocusToolbar = exports.
|
|
7
|
-
var isEventInContainer = exports.isEventInContainer = function isEventInContainer(event, containerSelector) {
|
|
8
|
-
var target = event.target instanceof Element ? event.target : null;
|
|
9
|
-
if (!target) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return !!target.closest(containerSelector);
|
|
13
|
-
};
|
|
6
|
+
exports.isShortcutToFocusToolbar = exports.getFocusableElements = void 0;
|
|
14
7
|
var isShortcutToFocusToolbar = exports.isShortcutToFocusToolbar = function isShortcutToFocusToolbar(event) {
|
|
15
8
|
return event.altKey && event.key === 'F10';
|
|
16
9
|
};
|
|
@@ -7,10 +7,8 @@ import { createComponentRegistry } from '@atlaskit/editor-toolbar-model/create-r
|
|
|
7
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
8
|
import { getSelectionToolbarOpenExperiencePlugin } from './pm-plugins/experiences/selection-toolbar-open-experience';
|
|
9
9
|
import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
10
|
-
import { DEFAULT_POPUP_SELECTORS } from './ui/consts';
|
|
11
10
|
import { SelectionToolbarWithErrorBoundary } from './ui/SelectionToolbar';
|
|
12
11
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
13
|
-
import { isEventInContainer } from './ui/utils/toolbar';
|
|
14
12
|
function getSelectedNode(editorState) {
|
|
15
13
|
const {
|
|
16
14
|
selection
|
|
@@ -181,45 +179,27 @@ export const toolbarPlugin = ({
|
|
|
181
179
|
const unbind = bind(view.root, {
|
|
182
180
|
type: 'mouseup',
|
|
183
181
|
listener: function (ev) {
|
|
184
|
-
var _api$
|
|
182
|
+
var _api$editorViewMode, _api$toolbar, _api$toolbar$sharedSt;
|
|
185
183
|
mouseState.isMouseDown = false;
|
|
186
184
|
const event = ev;
|
|
187
|
-
if (isExperimentEnabled('platform_editor_toolbar_multi_editor_fix')) {
|
|
188
|
-
var _api$editorViewMode, _api$toolbar, _api$toolbar$sharedSt;
|
|
189
|
-
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
190
|
-
const isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
191
|
-
const isMouseUpInEditor = event.composedPath().includes(view.dom);
|
|
192
|
-
refs.toolbarMouseUpEvent = undefined;
|
|
193
185
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const hasEditorFocus = view.hasFocus() || view.dom.contains(view.root.activeElement);
|
|
199
|
-
const shouldShowToolbar = isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
200
|
-
const currentShouldShowToolbar = api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : (_api$toolbar$sharedSt = _api$toolbar.sharedState.currentState()) === null || _api$toolbar$sharedSt === void 0 ? void 0 : _api$toolbar$sharedSt.shouldShowToolbar;
|
|
201
|
-
if (currentShouldShowToolbar !== shouldShowToolbar) {
|
|
202
|
-
view.dispatch(view.state.tr.setMeta(editorToolbarPluginKey, {
|
|
203
|
-
shouldShowToolbar
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
const isInToolbar = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.toolbarContainer);
|
|
209
|
-
const isInPortal = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.portal);
|
|
186
|
+
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
187
|
+
const isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
188
|
+
const isMouseUpInEditor = event.composedPath().includes(view.dom);
|
|
189
|
+
refs.toolbarMouseUpEvent = undefined;
|
|
210
190
|
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
// due to a click outside the editor.
|
|
214
|
-
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
|
+
// Prevent outside clicks from reopening a blurred editor's toolbar.
|
|
192
|
+
const editorViewModePlugin = api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
215
193
|
const isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
216
|
-
//
|
|
217
|
-
// such as a reference synced block's island - where `view.hasFocus()` is
|
|
218
|
-
// false but the user is still interacting with the editor.
|
|
194
|
+
// Include focus in nested editable islands.
|
|
219
195
|
const hasEditorFocus = view.hasFocus() || view.dom.contains(view.root.activeElement);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
196
|
+
const shouldShowToolbar = isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
197
|
+
const currentShouldShowToolbar = api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : (_api$toolbar$sharedSt = _api$toolbar.sharedState.currentState()) === null || _api$toolbar$sharedSt === void 0 ? void 0 : _api$toolbar$sharedSt.shouldShowToolbar;
|
|
198
|
+
if (currentShouldShowToolbar !== shouldShowToolbar) {
|
|
199
|
+
view.dispatch(view.state.tr.setMeta(editorToolbarPluginKey, {
|
|
200
|
+
shouldShowToolbar
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
223
203
|
}
|
|
224
204
|
});
|
|
225
205
|
const unbindEditorViewFocus = bind(view.dom, {
|
|
@@ -18,7 +18,6 @@ import { ToolbarButtonGroup } from '@atlaskit/editor-toolbar/toolbar-button-grou
|
|
|
18
18
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar/toolbar-dropdown-item-section';
|
|
19
19
|
import { ToolbarSection } from '@atlaskit/editor-toolbar/toolbar-section';
|
|
20
20
|
import { useToolbarUI } from '@atlaskit/editor-toolbar/ui-context';
|
|
21
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
22
21
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
23
22
|
import { SELECTION_TOOLBAR_LABEL } from '../consts';
|
|
24
23
|
import { getKeyboardNavigationConfig } from './keyboard-config';
|
|
@@ -137,9 +136,9 @@ export const SelectionToolbar = ({
|
|
|
137
136
|
onPositionCalculated: onPositionCalculated,
|
|
138
137
|
mountTo: mountPoint,
|
|
139
138
|
zIndex: akEditorFloatingDialogZIndex
|
|
140
|
-
},
|
|
139
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
141
140
|
onMouseUpCapture: onToolbarMouseUp
|
|
142
|
-
}, toolbarContent)
|
|
141
|
+
}, toolbarContent));
|
|
143
142
|
};
|
|
144
143
|
export const SelectionToolbarWithErrorBoundary = ({
|
|
145
144
|
api,
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export const isEventInContainer = (event, containerSelector) => {
|
|
2
|
-
const target = event.target instanceof Element ? event.target : null;
|
|
3
|
-
if (!target) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
return !!target.closest(containerSelector);
|
|
7
|
-
};
|
|
8
1
|
export const isShortcutToFocusToolbar = event => {
|
|
9
2
|
return event.altKey && event.key === 'F10';
|
|
10
3
|
};
|
|
@@ -13,10 +13,8 @@ import { createComponentRegistry } from '@atlaskit/editor-toolbar-model/create-r
|
|
|
13
13
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
14
14
|
import { getSelectionToolbarOpenExperiencePlugin } from './pm-plugins/experiences/selection-toolbar-open-experience';
|
|
15
15
|
import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
16
|
-
import { DEFAULT_POPUP_SELECTORS } from './ui/consts';
|
|
17
16
|
import { SelectionToolbarWithErrorBoundary } from './ui/SelectionToolbar';
|
|
18
17
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
19
|
-
import { isEventInContainer } from './ui/utils/toolbar';
|
|
20
18
|
function getSelectedNode(editorState) {
|
|
21
19
|
var selection = editorState.selection;
|
|
22
20
|
if (selection instanceof NodeSelection) {
|
|
@@ -182,45 +180,27 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
182
180
|
var unbind = bind(_view.root, {
|
|
183
181
|
type: 'mouseup',
|
|
184
182
|
listener: function listener(ev) {
|
|
185
|
-
var _api$
|
|
183
|
+
var _api$editorViewMode, _api$toolbar;
|
|
186
184
|
mouseState.isMouseDown = false;
|
|
187
185
|
var event = ev;
|
|
188
|
-
if (isExperimentEnabled('platform_editor_toolbar_multi_editor_fix')) {
|
|
189
|
-
var _api$editorViewMode, _api$toolbar;
|
|
190
|
-
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
191
|
-
var isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
192
|
-
var isMouseUpInEditor = event.composedPath().includes(_view.dom);
|
|
193
|
-
refs.toolbarMouseUpEvent = undefined;
|
|
194
186
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var _hasEditorFocus = _view.hasFocus() || _view.dom.contains(_view.root.activeElement);
|
|
200
|
-
var shouldShowToolbar = _isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : _hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
201
|
-
var currentShouldShowToolbar = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || (_api$toolbar = _api$toolbar.sharedState.currentState()) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.shouldShowToolbar;
|
|
202
|
-
if (currentShouldShowToolbar !== shouldShowToolbar) {
|
|
203
|
-
_view.dispatch(_view.state.tr.setMeta(editorToolbarPluginKey, {
|
|
204
|
-
shouldShowToolbar: shouldShowToolbar
|
|
205
|
-
}));
|
|
206
|
-
}
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
var isInToolbar = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.toolbarContainer);
|
|
210
|
-
var isInPortal = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.portal);
|
|
187
|
+
// Scope mouseups to this editor and its React-portaled toolbar.
|
|
188
|
+
var isMouseUpInOwnedToolbar = refs.toolbarMouseUpEvent === event;
|
|
189
|
+
var isMouseUpInEditor = event.composedPath().includes(_view.dom);
|
|
190
|
+
refs.toolbarMouseUpEvent = undefined;
|
|
211
191
|
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
// due to a click outside the editor.
|
|
215
|
-
var editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.sharedState.currentState();
|
|
192
|
+
// Prevent outside clicks from reopening a blurred editor's toolbar.
|
|
193
|
+
var editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
216
194
|
var isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
217
|
-
//
|
|
218
|
-
// such as a reference synced block's island - where `view.hasFocus()` is
|
|
219
|
-
// false but the user is still interacting with the editor.
|
|
195
|
+
// Include focus in nested editable islands.
|
|
220
196
|
var hasEditorFocus = _view.hasFocus() || _view.dom.contains(_view.root.activeElement);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
197
|
+
var shouldShowToolbar = isViewModeEnabled ? isMouseUpInEditor || isMouseUpInOwnedToolbar : hasEditorFocus || isMouseUpInOwnedToolbar;
|
|
198
|
+
var currentShouldShowToolbar = api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || (_api$toolbar = _api$toolbar.sharedState.currentState()) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.shouldShowToolbar;
|
|
199
|
+
if (currentShouldShowToolbar !== shouldShowToolbar) {
|
|
200
|
+
_view.dispatch(_view.state.tr.setMeta(editorToolbarPluginKey, {
|
|
201
|
+
shouldShowToolbar: shouldShowToolbar
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
224
204
|
}
|
|
225
205
|
});
|
|
226
206
|
var unbindEditorViewFocus = bind(_view.dom, {
|
|
@@ -18,7 +18,6 @@ import { ToolbarButtonGroup } from '@atlaskit/editor-toolbar/toolbar-button-grou
|
|
|
18
18
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar/toolbar-dropdown-item-section';
|
|
19
19
|
import { ToolbarSection } from '@atlaskit/editor-toolbar/toolbar-section';
|
|
20
20
|
import { useToolbarUI } from '@atlaskit/editor-toolbar/ui-context';
|
|
21
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
22
21
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
23
22
|
import { SELECTION_TOOLBAR_LABEL } from '../consts';
|
|
24
23
|
import { getKeyboardNavigationConfig } from './keyboard-config';
|
|
@@ -136,9 +135,9 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
136
135
|
onPositionCalculated: onPositionCalculated,
|
|
137
136
|
mountTo: mountPoint,
|
|
138
137
|
zIndex: akEditorFloatingDialogZIndex
|
|
139
|
-
},
|
|
138
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
140
139
|
onMouseUpCapture: onToolbarMouseUp
|
|
141
|
-
}, toolbarContent)
|
|
140
|
+
}, toolbarContent));
|
|
142
141
|
};
|
|
143
142
|
export var SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErrorBoundary(_ref3) {
|
|
144
143
|
var _api$analytics2;
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export var isEventInContainer = function isEventInContainer(event, containerSelector) {
|
|
2
|
-
var target = event.target instanceof Element ? event.target : null;
|
|
3
|
-
if (!target) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
return !!target.closest(containerSelector);
|
|
7
|
-
};
|
|
8
1
|
export var isShortcutToFocusToolbar = function isShortcutToFocusToolbar(event) {
|
|
9
2
|
return event.altKey && event.key === 'F10';
|
|
10
3
|
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export declare const isEventInContainer: (event: Event, containerSelector: string) => boolean;
|
|
2
1
|
export declare const isShortcutToFocusToolbar: (event: KeyboardEvent) => boolean;
|
|
3
2
|
export declare const getFocusableElements: (rootNode: HTMLElement | null) => Array<HTMLElement>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar",
|
|
3
|
-
"version": "27.0.
|
|
3
|
+
"version": "27.0.17",
|
|
4
4
|
"description": "Toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"bind-event-listener": "^3.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^134.
|
|
40
|
+
"@atlaskit/editor-common": "^134.16.0",
|
|
41
41
|
"react": "^18.2.0 || ^19.2.0",
|
|
42
42
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@atlaskit/editor-common": "^134.
|
|
45
|
+
"@atlaskit/editor-common": "^134.16.0",
|
|
46
46
|
"react": "^19.2.0",
|
|
47
47
|
"react-intl": "^7.0.0"
|
|
48
48
|
}
|