@atlaskit/editor-plugin-floating-toolbar 1.18.1 → 1.20.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 +21 -0
- package/dist/cjs/floatingToolbarPlugin.js +51 -27
- package/dist/cjs/pm-plugins/contextual-toolbar/plugin-key.js +8 -0
- package/dist/cjs/pm-plugins/contextual-toolbar/plugin.js +42 -0
- package/dist/cjs/pm-plugins/contextual-toolbar/types.js +1 -0
- package/dist/cjs/ui/DropdownMenu.js +8 -15
- package/dist/cjs/ui/Toolbar.js +112 -8
- package/dist/es2019/floatingToolbarPlugin.js +25 -4
- package/dist/es2019/pm-plugins/contextual-toolbar/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/contextual-toolbar/plugin.js +36 -0
- package/dist/es2019/pm-plugins/contextual-toolbar/types.js +0 -0
- package/dist/es2019/ui/DropdownMenu.js +9 -16
- package/dist/es2019/ui/Toolbar.js +106 -1
- package/dist/esm/floatingToolbarPlugin.js +48 -24
- package/dist/esm/pm-plugins/contextual-toolbar/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/contextual-toolbar/plugin.js +36 -0
- package/dist/esm/pm-plugins/contextual-toolbar/types.js +0 -0
- package/dist/esm/ui/DropdownMenu.js +9 -16
- package/dist/esm/ui/Toolbar.js +112 -8
- package/dist/types/floatingToolbarPluginType.d.ts +16 -1
- package/dist/types/pm-plugins/contextual-toolbar/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/contextual-toolbar/plugin.d.ts +4 -0
- package/dist/types/pm-plugins/contextual-toolbar/types.d.ts +8 -0
- package/dist/types/ui/Toolbar.d.ts +1 -0
- package/dist/types-ts4.5/floatingToolbarPluginType.d.ts +16 -1
- package/dist/types-ts4.5/pm-plugins/contextual-toolbar/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/contextual-toolbar/plugin.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/contextual-toolbar/types.d.ts +8 -0
- package/dist/types-ts4.5/ui/Toolbar.d.ts +1 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 1.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#117197](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117197)
|
|
8
|
+
[`d6202c120a039`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d6202c120a039) -
|
|
9
|
+
Remove @atlaskit/heading import which broke previous versions, replace with HeadingItem
|
|
10
|
+
|
|
11
|
+
## 1.19.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#115259](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115259)
|
|
16
|
+
[`a3150808f308a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a3150808f308a) -
|
|
17
|
+
Add new forceStaticToolbar config option to floating toolbar and add it to panel and table. Add
|
|
18
|
+
new contextual toolbar plugin which controls expand and collapse logic for toolbar options.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 1.18.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -21,10 +21,12 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
21
21
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
22
22
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
23
23
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
24
|
+
var _plugin = require("./pm-plugins/contextual-toolbar/plugin");
|
|
25
|
+
var _pluginKey = require("./pm-plugins/contextual-toolbar/plugin-key");
|
|
24
26
|
var _forceFocus = _interopRequireWildcard(require("./pm-plugins/force-focus"));
|
|
25
27
|
var _commands = require("./pm-plugins/toolbar-data/commands");
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
+
var _plugin2 = require("./pm-plugins/toolbar-data/plugin");
|
|
29
|
+
var _pluginKey2 = require("./pm-plugins/toolbar-data/plugin-key");
|
|
28
30
|
var _utils2 = require("./pm-plugins/utils");
|
|
29
31
|
var _ConfirmationModal = require("./ui/ConfirmationModal");
|
|
30
32
|
var _ExpandButton = require("./ui/ExpandButton");
|
|
@@ -135,7 +137,7 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
|
|
|
135
137
|
name: 'floatingToolbar',
|
|
136
138
|
pmPlugins: function pmPlugins() {
|
|
137
139
|
var floatingToolbarHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
138
|
-
|
|
140
|
+
var plugins = [{
|
|
139
141
|
// Should be after all toolbar plugins
|
|
140
142
|
name: 'floatingToolbar',
|
|
141
143
|
plugin: function plugin(_ref2) {
|
|
@@ -151,7 +153,7 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
|
|
|
151
153
|
name: 'floatingToolbarData',
|
|
152
154
|
plugin: function plugin(_ref3) {
|
|
153
155
|
var dispatch = _ref3.dispatch;
|
|
154
|
-
return (0,
|
|
156
|
+
return (0, _plugin2.createPlugin)(dispatch);
|
|
155
157
|
}
|
|
156
158
|
}, {
|
|
157
159
|
name: 'forceFocus',
|
|
@@ -159,6 +161,15 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
|
|
|
159
161
|
return (0, _forceFocus.default)();
|
|
160
162
|
}
|
|
161
163
|
}];
|
|
164
|
+
if (!(0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
|
|
165
|
+
plugins.push({
|
|
166
|
+
name: 'contextualToolbar',
|
|
167
|
+
plugin: function plugin() {
|
|
168
|
+
return (0, _plugin.contextualToolbarPlugin)();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return plugins;
|
|
162
173
|
},
|
|
163
174
|
actions: {
|
|
164
175
|
forceFocusSelector: _forceFocus.forceFocusSelector
|
|
@@ -171,16 +182,27 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
|
|
|
171
182
|
var configWithNodeInfo = (_pluginKey$getState$g = (_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 || (_pluginKey$getState$g2 = _pluginKey$getState.getConfigWithNodeInfo) === null || _pluginKey$getState$g2 === void 0 ? void 0 : _pluginKey$getState$g2.call(_pluginKey$getState, editorState)) !== null && _pluginKey$getState$g !== void 0 ? _pluginKey$getState$g : undefined;
|
|
172
183
|
return {
|
|
173
184
|
configWithNodeInfo: configWithNodeInfo,
|
|
174
|
-
floatingToolbarData:
|
|
185
|
+
floatingToolbarData: _pluginKey2.pluginKey.getState(editorState),
|
|
186
|
+
// Experimental - excluding this property from the external API whilst it's in development
|
|
187
|
+
contextualToolbar: _pluginKey.contextualToolbarPluginKey.getState(editorState)
|
|
175
188
|
};
|
|
176
189
|
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
commands: {
|
|
191
|
+
// Experimental
|
|
192
|
+
updateContextualToolbar: function updateContextualToolbar(action) {
|
|
193
|
+
return function (_ref4) {
|
|
194
|
+
var tr = _ref4.tr;
|
|
195
|
+
return tr.setMeta(_pluginKey.contextualToolbarPluginKey, action);
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
contentComponent: function contentComponent(_ref5) {
|
|
200
|
+
var popupsMountPoint = _ref5.popupsMountPoint,
|
|
201
|
+
popupsBoundariesElement = _ref5.popupsBoundariesElement,
|
|
202
|
+
popupsScrollableElement = _ref5.popupsScrollableElement,
|
|
203
|
+
editorView = _ref5.editorView,
|
|
204
|
+
providerFactory = _ref5.providerFactory,
|
|
205
|
+
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
184
206
|
return /*#__PURE__*/_react.default.createElement(ContentComponent, {
|
|
185
207
|
editorView: editorView,
|
|
186
208
|
pluginInjectionApi: api,
|
|
@@ -193,23 +215,23 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
|
|
|
193
215
|
}
|
|
194
216
|
};
|
|
195
217
|
};
|
|
196
|
-
function ContentComponent(
|
|
218
|
+
function ContentComponent(_ref6) {
|
|
197
219
|
var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
|
|
198
|
-
var pluginInjectionApi =
|
|
199
|
-
editorView =
|
|
200
|
-
popupsMountPoint =
|
|
201
|
-
popupsBoundariesElement =
|
|
202
|
-
popupsScrollableElement =
|
|
203
|
-
providerFactory =
|
|
204
|
-
dispatchAnalyticsEvent =
|
|
220
|
+
var pluginInjectionApi = _ref6.pluginInjectionApi,
|
|
221
|
+
editorView = _ref6.editorView,
|
|
222
|
+
popupsMountPoint = _ref6.popupsMountPoint,
|
|
223
|
+
popupsBoundariesElement = _ref6.popupsBoundariesElement,
|
|
224
|
+
popupsScrollableElement = _ref6.popupsScrollableElement,
|
|
225
|
+
providerFactory = _ref6.providerFactory,
|
|
226
|
+
dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent;
|
|
205
227
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'blockControls']),
|
|
206
228
|
floatingToolbarState = _useSharedPluginState.floatingToolbarState,
|
|
207
229
|
editorDisabledState = _useSharedPluginState.editorDisabledState,
|
|
208
230
|
editorViewModeState = _useSharedPluginState.editorViewModeState,
|
|
209
231
|
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
210
|
-
var
|
|
211
|
-
configWithNodeInfo =
|
|
212
|
-
floatingToolbarData =
|
|
232
|
+
var _ref7 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
|
|
233
|
+
configWithNodeInfo = _ref7.configWithNodeInfo,
|
|
234
|
+
floatingToolbarData = _ref7.floatingToolbarData;
|
|
213
235
|
if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
|
|
214
236
|
return null;
|
|
215
237
|
}
|
|
@@ -246,7 +268,8 @@ function ContentComponent(_ref5) {
|
|
|
246
268
|
_config$mediaAssistiv = config.mediaAssistiveMessage,
|
|
247
269
|
mediaAssistiveMessage = _config$mediaAssistiv === void 0 ? '' : _config$mediaAssistiv,
|
|
248
270
|
_config$stick = config.stick,
|
|
249
|
-
stick = _config$stick === void 0 ? true : _config$stick
|
|
271
|
+
stick = _config$stick === void 0 ? true : _config$stick,
|
|
272
|
+
forceStaticToolbar = config.forceStaticToolbar;
|
|
250
273
|
var targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
251
274
|
var isEditorDisabled = editorDisabledState && editorDisabledState.editorDisabled;
|
|
252
275
|
var isInViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
@@ -310,8 +333,8 @@ function ContentComponent(_ref5) {
|
|
|
310
333
|
};
|
|
311
334
|
|
|
312
335
|
// Confirm dialog
|
|
313
|
-
var
|
|
314
|
-
confirmDialogForItem =
|
|
336
|
+
var _ref8 = floatingToolbarData || {},
|
|
337
|
+
confirmDialogForItem = _ref8.confirmDialogForItem;
|
|
315
338
|
var confirmButtonItem = confirmDialogForItem ?
|
|
316
339
|
// Ignored via go/ees005
|
|
317
340
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -374,7 +397,8 @@ function ContentComponent(_ref5) {
|
|
|
374
397
|
extensionsProvider: providers.extensionProvider,
|
|
375
398
|
scrollable: scrollable,
|
|
376
399
|
api: pluginInjectionApi,
|
|
377
|
-
mediaAssistiveMessage: mediaAssistiveMessage
|
|
400
|
+
mediaAssistiveMessage: mediaAssistiveMessage,
|
|
401
|
+
forceStaticToolbar: forceStaticToolbar
|
|
378
402
|
});
|
|
379
403
|
}
|
|
380
404
|
})), /*#__PURE__*/_react.default.createElement(_ConfirmationModal.ConfirmationModal, {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.contextualToolbarPluginKey = void 0;
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var contextualToolbarPluginKey = exports.contextualToolbarPluginKey = new _state.PluginKey('contextualToolbar');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.contextualToolbarPlugin = void 0;
|
|
7
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
+
var _pluginKey = require("./plugin-key");
|
|
9
|
+
var defaultEditState = {
|
|
10
|
+
display: 'collapsed'
|
|
11
|
+
};
|
|
12
|
+
var contextualToolbarPlugin = exports.contextualToolbarPlugin = function contextualToolbarPlugin() {
|
|
13
|
+
return new _safePlugin.SafePlugin({
|
|
14
|
+
key: _pluginKey.contextualToolbarPluginKey,
|
|
15
|
+
state: {
|
|
16
|
+
init: function init() {
|
|
17
|
+
return defaultEditState;
|
|
18
|
+
},
|
|
19
|
+
apply: function apply(tr, pluginState) {
|
|
20
|
+
if (pluginState.display === 'static') {
|
|
21
|
+
return pluginState;
|
|
22
|
+
}
|
|
23
|
+
var action = tr.getMeta(_pluginKey.contextualToolbarPluginKey);
|
|
24
|
+
if (action) {
|
|
25
|
+
switch (action.type) {
|
|
26
|
+
case 'expand-toolbar':
|
|
27
|
+
return {
|
|
28
|
+
display: 'expanded'
|
|
29
|
+
};
|
|
30
|
+
case 'collapse-toolbar':
|
|
31
|
+
return {
|
|
32
|
+
display: 'collapsed'
|
|
33
|
+
};
|
|
34
|
+
default:
|
|
35
|
+
return pluginState;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return pluginState;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -10,7 +10,6 @@ var _react = require("react");
|
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
11
|
var _reactIntlNext = require("react-intl-next");
|
|
12
12
|
var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
|
|
13
|
-
var _heading = _interopRequireDefault(require("@atlaskit/heading"));
|
|
14
13
|
var _done = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/done"));
|
|
15
14
|
var _menu = require("@atlaskit/menu");
|
|
16
15
|
var _colors = require("@atlaskit/theme/colors");
|
|
@@ -39,7 +38,10 @@ var spacerStyles = (0, _react2.css)({
|
|
|
39
38
|
});
|
|
40
39
|
var separatorStyles = (0, _react2.css)({
|
|
41
40
|
background: "var(--ds-border, #091E4224)",
|
|
42
|
-
height:
|
|
41
|
+
height: "var(--ds-space-025, 1px)"
|
|
42
|
+
});
|
|
43
|
+
var headingStyles = (0, _react2.css)({
|
|
44
|
+
padding: "var(--ds-space-100, 8px)".concat(" 0")
|
|
43
45
|
});
|
|
44
46
|
|
|
45
47
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
@@ -268,22 +270,13 @@ var Dropdown = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
268
270
|
});
|
|
269
271
|
}
|
|
270
272
|
if (item.type === 'overflow-dropdown-heading') {
|
|
271
|
-
return (
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
style: {
|
|
276
|
-
padding: '10px'
|
|
277
|
-
}
|
|
278
|
-
}, (0, _react2.jsx)(_heading.default, {
|
|
279
|
-
size: "xxsmall"
|
|
280
|
-
}, item.title))
|
|
281
|
-
);
|
|
273
|
+
return (0, _react2.jsx)("div", {
|
|
274
|
+
key: item.title,
|
|
275
|
+
css: headingStyles
|
|
276
|
+
}, (0, _react2.jsx)(_menu.HeadingItem, null, item.title));
|
|
282
277
|
}
|
|
283
278
|
}));
|
|
284
279
|
}
|
|
285
|
-
|
|
286
|
-
// here to change based on dropdown type
|
|
287
280
|
return (0, _react2.jsx)("div", {
|
|
288
281
|
css: menuContainerStyles,
|
|
289
282
|
role: "menu"
|
package/dist/cjs/ui/Toolbar.js
CHANGED
|
@@ -22,10 +22,14 @@ var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
|
|
|
22
22
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
23
23
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
24
24
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
25
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
25
26
|
var _editorPalette = require("@atlaskit/editor-palette");
|
|
26
27
|
var _commands = require("@atlaskit/editor-plugin-table/commands");
|
|
28
|
+
var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
|
|
27
29
|
var _showMoreHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/show-more-horizontal"));
|
|
30
|
+
var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/utility/chevron-right"));
|
|
28
31
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
32
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
29
33
|
var _forceFocus = require("../pm-plugins/force-focus");
|
|
30
34
|
var _commands2 = require("../pm-plugins/toolbar-data/commands");
|
|
31
35
|
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
|
|
@@ -381,6 +385,99 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
381
385
|
// otherwise it causes an issue where multiple popups stays open
|
|
382
386
|
return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !(0, _floatingToolbar.areSameItems)(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
|
|
383
387
|
});
|
|
388
|
+
var ToolbarItemsCollapsable = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
389
|
+
var items = _ref2.items,
|
|
390
|
+
groupLabel = _ref2.groupLabel,
|
|
391
|
+
dispatchCommand = _ref2.dispatchCommand,
|
|
392
|
+
popupsMountPoint = _ref2.popupsMountPoint,
|
|
393
|
+
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
394
|
+
editorView = _ref2.editorView,
|
|
395
|
+
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
396
|
+
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
397
|
+
scrollable = _ref2.scrollable,
|
|
398
|
+
providerFactory = _ref2.providerFactory,
|
|
399
|
+
extensionsProvider = _ref2.extensionsProvider,
|
|
400
|
+
node = _ref2.node,
|
|
401
|
+
setDisableScroll = _ref2.setDisableScroll,
|
|
402
|
+
mountRef = _ref2.mountRef,
|
|
403
|
+
mounted = _ref2.mounted,
|
|
404
|
+
api = _ref2.api,
|
|
405
|
+
forceStaticToolbar = _ref2.forceStaticToolbar;
|
|
406
|
+
var contextualToolbarState = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'floatingToolbar.contextualToolbar');
|
|
407
|
+
var updatedItems = items.slice();
|
|
408
|
+
if (!forceStaticToolbar && (contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.display) === 'collapsed') {
|
|
409
|
+
var nonSeparatorItems = 0;
|
|
410
|
+
var slicedIndex = -1;
|
|
411
|
+
for (var i = items.length - 1; i > 0; i--) {
|
|
412
|
+
var item = items[i];
|
|
413
|
+
if (item.type !== 'separator') {
|
|
414
|
+
nonSeparatorItems += 1;
|
|
415
|
+
slicedIndex = i;
|
|
416
|
+
}
|
|
417
|
+
if (nonSeparatorItems > 2) {
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
updatedItems = updatedItems.slice(slicedIndex);
|
|
422
|
+
updatedItems.unshift({
|
|
423
|
+
type: 'separator'
|
|
424
|
+
});
|
|
425
|
+
updatedItems.unshift({
|
|
426
|
+
type: 'button',
|
|
427
|
+
icon: _edit.default,
|
|
428
|
+
title: 'Show items',
|
|
429
|
+
onClick: function onClick() {
|
|
430
|
+
if (api) {
|
|
431
|
+
api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
|
|
432
|
+
type: 'expand-toolbar'
|
|
433
|
+
}));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
if (!forceStaticToolbar && (contextualToolbarState === null || contextualToolbarState === void 0 ? void 0 : contextualToolbarState.display) === 'expanded') {
|
|
439
|
+
updatedItems.unshift({
|
|
440
|
+
type: 'separator'
|
|
441
|
+
});
|
|
442
|
+
updatedItems.unshift({
|
|
443
|
+
type: 'button',
|
|
444
|
+
icon: _chevronRight.default,
|
|
445
|
+
title: 'Hide items',
|
|
446
|
+
onClick: function onClick() {
|
|
447
|
+
if (api) {
|
|
448
|
+
api.core.actions.execute(api.floatingToolbar.commands.updateContextualToolbar({
|
|
449
|
+
type: 'collapse-toolbar'
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
return (0, _react2.jsx)(ToolbarItems, {
|
|
456
|
+
items: updatedItems,
|
|
457
|
+
groupLabel: groupLabel,
|
|
458
|
+
dispatchCommand: dispatchCommand,
|
|
459
|
+
popupsMountPoint: popupsMountPoint,
|
|
460
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
461
|
+
editorView: editorView,
|
|
462
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
463
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
464
|
+
scrollable: scrollable,
|
|
465
|
+
providerFactory: providerFactory,
|
|
466
|
+
extensionsProvider: extensionsProvider,
|
|
467
|
+
node: node,
|
|
468
|
+
setDisableScroll: setDisableScroll,
|
|
469
|
+
mountRef: mountRef,
|
|
470
|
+
mounted: mounted,
|
|
471
|
+
api: api
|
|
472
|
+
});
|
|
473
|
+
}, function (prevProps, nextProps) {
|
|
474
|
+
if (!nextProps.node) {
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
// only rerender toolbar items if the node is different
|
|
478
|
+
// otherwise it causes an issue where multiple popups stays open
|
|
479
|
+
return !(prevProps.node.type !== nextProps.node.type || prevProps.node.attrs.localId !== nextProps.node.attrs.localId || !(0, _floatingToolbar.areSameItems)(prevProps.items, nextProps.items) || !prevProps.mounted !== !nextProps.mounted);
|
|
480
|
+
});
|
|
384
481
|
var buttonGroupStyles = (0, _react2.css)({
|
|
385
482
|
display: 'flex',
|
|
386
483
|
gap: "var(--ds-space-050, 4px)"
|
|
@@ -430,11 +527,11 @@ var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstEle
|
|
|
430
527
|
};
|
|
431
528
|
|
|
432
529
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
433
|
-
var toolbarOverflow = function toolbarOverflow(
|
|
434
|
-
var scrollable =
|
|
435
|
-
scrollDisabled =
|
|
436
|
-
firstElementIsSelect =
|
|
437
|
-
paddingFeatureFlag =
|
|
530
|
+
var toolbarOverflow = function toolbarOverflow(_ref3) {
|
|
531
|
+
var scrollable = _ref3.scrollable,
|
|
532
|
+
scrollDisabled = _ref3.scrollDisabled,
|
|
533
|
+
firstElementIsSelect = _ref3.firstElementIsSelect,
|
|
534
|
+
paddingFeatureFlag = _ref3.paddingFeatureFlag;
|
|
438
535
|
return (0, _react2.css)(
|
|
439
536
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
440
537
|
scrollable ?
|
|
@@ -520,8 +617,8 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
520
617
|
(0, _inherits2.default)(Toolbar, _Component);
|
|
521
618
|
return (0, _createClass2.default)(Toolbar, [{
|
|
522
619
|
key: "resetStyling",
|
|
523
|
-
value: function resetStyling(
|
|
524
|
-
var table =
|
|
620
|
+
value: function resetStyling(_ref4) {
|
|
621
|
+
var table = _ref4.table;
|
|
525
622
|
if (this.props.editorView) {
|
|
526
623
|
var _this$props$api;
|
|
527
624
|
var _this$props$editorVie2 = this.props.editorView,
|
|
@@ -637,7 +734,14 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
637
734
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
|
|
638
735
|
paddingFeatureFlag: (0, _platformFeatureFlags.fg)('platform_editor_floating_toolbar_padding_fix')
|
|
639
736
|
})
|
|
640
|
-
}, (0, _react2.jsx)(ToolbarItems
|
|
737
|
+
}, (0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? (0, _react2.jsx)(ToolbarItems
|
|
738
|
+
// Ignored via go/ees005
|
|
739
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
740
|
+
, (0, _extends2.default)({}, this.props, {
|
|
741
|
+
setDisableScroll: this.setDisableScroll.bind(this),
|
|
742
|
+
mountRef: this.mountRef,
|
|
743
|
+
mounted: this.state.mounted
|
|
744
|
+
})) : (0, _react2.jsx)(ToolbarItemsCollapsable
|
|
641
745
|
// Ignored via go/ees005
|
|
642
746
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
643
747
|
, (0, _extends2.default)({}, this.props, {
|
|
@@ -9,6 +9,8 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
9
9
|
import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
11
11
|
import { editorExperiment, unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
|
+
import { contextualToolbarPlugin } from './pm-plugins/contextual-toolbar/plugin';
|
|
13
|
+
import { contextualToolbarPluginKey } from './pm-plugins/contextual-toolbar/plugin-key';
|
|
12
14
|
import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
|
|
13
15
|
import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
|
|
14
16
|
import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/toolbar-data/plugin';
|
|
@@ -122,7 +124,7 @@ export const floatingToolbarPlugin = ({
|
|
|
122
124
|
return {
|
|
123
125
|
name: 'floatingToolbar',
|
|
124
126
|
pmPlugins(floatingToolbarHandlers = []) {
|
|
125
|
-
|
|
127
|
+
const plugins = [{
|
|
126
128
|
// Should be after all toolbar plugins
|
|
127
129
|
name: 'floatingToolbar',
|
|
128
130
|
plugin: ({
|
|
@@ -142,6 +144,13 @@ export const floatingToolbarPlugin = ({
|
|
|
142
144
|
name: 'forceFocus',
|
|
143
145
|
plugin: () => forceFocusPlugin()
|
|
144
146
|
}];
|
|
147
|
+
if (!editorExperiment('platform_editor_controls', 'control')) {
|
|
148
|
+
plugins.push({
|
|
149
|
+
name: 'contextualToolbar',
|
|
150
|
+
plugin: () => contextualToolbarPlugin()
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return plugins;
|
|
145
154
|
},
|
|
146
155
|
actions: {
|
|
147
156
|
forceFocusSelector
|
|
@@ -154,9 +163,19 @@ export const floatingToolbarPlugin = ({
|
|
|
154
163
|
const configWithNodeInfo = (_pluginKey$getState$g = (_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : (_pluginKey$getState$g2 = _pluginKey$getState.getConfigWithNodeInfo) === null || _pluginKey$getState$g2 === void 0 ? void 0 : _pluginKey$getState$g2.call(_pluginKey$getState, editorState)) !== null && _pluginKey$getState$g !== void 0 ? _pluginKey$getState$g : undefined;
|
|
155
164
|
return {
|
|
156
165
|
configWithNodeInfo,
|
|
157
|
-
floatingToolbarData: dataPluginKey.getState(editorState)
|
|
166
|
+
floatingToolbarData: dataPluginKey.getState(editorState),
|
|
167
|
+
// Experimental - excluding this property from the external API whilst it's in development
|
|
168
|
+
contextualToolbar: contextualToolbarPluginKey.getState(editorState)
|
|
158
169
|
};
|
|
159
170
|
},
|
|
171
|
+
commands: {
|
|
172
|
+
// Experimental
|
|
173
|
+
updateContextualToolbar: action => ({
|
|
174
|
+
tr
|
|
175
|
+
}) => {
|
|
176
|
+
return tr.setMeta(contextualToolbarPluginKey, action);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
160
179
|
contentComponent({
|
|
161
180
|
popupsMountPoint,
|
|
162
181
|
popupsBoundariesElement,
|
|
@@ -233,7 +252,8 @@ export function ContentComponent({
|
|
|
233
252
|
},
|
|
234
253
|
focusTrap,
|
|
235
254
|
mediaAssistiveMessage = '',
|
|
236
|
-
stick = true
|
|
255
|
+
stick = true,
|
|
256
|
+
forceStaticToolbar
|
|
237
257
|
} = config;
|
|
238
258
|
const targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
239
259
|
const isEditorDisabled = editorDisabledState && editorDisabledState.editorDisabled;
|
|
@@ -353,7 +373,8 @@ export function ContentComponent({
|
|
|
353
373
|
extensionsProvider: providers.extensionProvider,
|
|
354
374
|
scrollable: scrollable,
|
|
355
375
|
api: pluginInjectionApi,
|
|
356
|
-
mediaAssistiveMessage: mediaAssistiveMessage
|
|
376
|
+
mediaAssistiveMessage: mediaAssistiveMessage,
|
|
377
|
+
forceStaticToolbar: forceStaticToolbar
|
|
357
378
|
});
|
|
358
379
|
}
|
|
359
380
|
})), /*#__PURE__*/React.createElement(ConfirmationModal, {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { contextualToolbarPluginKey } from './plugin-key';
|
|
3
|
+
const defaultEditState = {
|
|
4
|
+
display: 'collapsed'
|
|
5
|
+
};
|
|
6
|
+
export const contextualToolbarPlugin = () => {
|
|
7
|
+
return new SafePlugin({
|
|
8
|
+
key: contextualToolbarPluginKey,
|
|
9
|
+
state: {
|
|
10
|
+
init() {
|
|
11
|
+
return defaultEditState;
|
|
12
|
+
},
|
|
13
|
+
apply(tr, pluginState) {
|
|
14
|
+
if (pluginState.display === 'static') {
|
|
15
|
+
return pluginState;
|
|
16
|
+
}
|
|
17
|
+
const action = tr.getMeta(contextualToolbarPluginKey);
|
|
18
|
+
if (action) {
|
|
19
|
+
switch (action.type) {
|
|
20
|
+
case 'expand-toolbar':
|
|
21
|
+
return {
|
|
22
|
+
display: 'expanded'
|
|
23
|
+
};
|
|
24
|
+
case 'collapse-toolbar':
|
|
25
|
+
return {
|
|
26
|
+
display: 'collapsed'
|
|
27
|
+
};
|
|
28
|
+
default:
|
|
29
|
+
return pluginState;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return pluginState;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
File without changes
|
|
@@ -10,9 +10,8 @@ import { css, jsx } from '@emotion/react';
|
|
|
10
10
|
|
|
11
11
|
import { injectIntl } from 'react-intl-next';
|
|
12
12
|
import { messages } from '@atlaskit/editor-common/floating-toolbar';
|
|
13
|
-
import Heading from '@atlaskit/heading';
|
|
14
13
|
import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
|
|
15
|
-
import { ButtonItem } from '@atlaskit/menu';
|
|
14
|
+
import { ButtonItem, HeadingItem } from '@atlaskit/menu';
|
|
16
15
|
import { B400 } from '@atlaskit/theme/colors';
|
|
17
16
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
18
17
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
@@ -29,7 +28,10 @@ const spacerStyles = css({
|
|
|
29
28
|
});
|
|
30
29
|
const separatorStyles = css({
|
|
31
30
|
background: "var(--ds-border, #091E4224)",
|
|
32
|
-
height:
|
|
31
|
+
height: "var(--ds-space-025, 1px)"
|
|
32
|
+
});
|
|
33
|
+
const headingStyles = css({
|
|
34
|
+
padding: `${"var(--ds-space-100, 8px)"} 0`
|
|
33
35
|
});
|
|
34
36
|
|
|
35
37
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
@@ -259,22 +261,13 @@ const Dropdown = /*#__PURE__*/memo(props => {
|
|
|
259
261
|
});
|
|
260
262
|
}
|
|
261
263
|
if (item.type === 'overflow-dropdown-heading') {
|
|
262
|
-
return (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
style: {
|
|
267
|
-
padding: '10px'
|
|
268
|
-
}
|
|
269
|
-
}, jsx(Heading, {
|
|
270
|
-
size: "xxsmall"
|
|
271
|
-
}, item.title))
|
|
272
|
-
);
|
|
264
|
+
return jsx("div", {
|
|
265
|
+
key: item.title,
|
|
266
|
+
css: headingStyles
|
|
267
|
+
}, jsx(HeadingItem, null, item.title));
|
|
273
268
|
}
|
|
274
269
|
}));
|
|
275
270
|
}
|
|
276
|
-
|
|
277
|
-
// here to change based on dropdown type
|
|
278
271
|
return jsx("div", {
|
|
279
272
|
css: menuContainerStyles,
|
|
280
273
|
role: "menu"
|