@atlaskit/editor-plugin-selection-toolbar 19.0.9 → 19.0.11
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 +14 -0
- package/dist/cjs/pm-plugins/commands.js +1 -48
- package/dist/cjs/selectionToolbarPlugin.js +9 -59
- package/dist/cjs/ui/PrimaryToolbarComponent.js +3 -4
- package/dist/cjs/ui/overflow-toolbar-config.js +5 -14
- package/dist/es2019/pm-plugins/commands.js +0 -47
- package/dist/es2019/selectionToolbarPlugin.js +10 -58
- package/dist/es2019/ui/PrimaryToolbarComponent.js +3 -4
- package/dist/es2019/ui/overflow-toolbar-config.js +5 -14
- package/dist/esm/pm-plugins/commands.js +0 -47
- package/dist/esm/selectionToolbarPlugin.js +10 -60
- package/dist/esm/ui/PrimaryToolbarComponent.js +3 -4
- package/dist/esm/ui/overflow-toolbar-config.js +5 -14
- package/dist/types/pm-plugins/commands.d.ts +1 -11
- package/package.json +8 -8
- package/dist/cjs/ui/PageVisibilityWatcher.js +0 -60
- package/dist/es2019/ui/PageVisibilityWatcher.js +0 -31
- package/dist/esm/ui/PageVisibilityWatcher.js +0 -53
- package/dist/types/ui/PageVisibilityWatcher.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-toolbar
|
|
2
2
|
|
|
3
|
+
## 19.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0920715a6b9fc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0920715a6b9fc) -
|
|
8
|
+
Clean up feature gate `platform_editor_use_preferences_plugin`
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 19.0.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 19.0.9
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.updateToolbarDocking = exports.toggleToolbar =
|
|
7
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
6
|
+
exports.updateToolbarDocking = exports.toggleToolbar = void 0;
|
|
9
7
|
var _pluginKey = require("./plugin-key");
|
|
10
8
|
var toggleToolbar = exports.toggleToolbar = function toggleToolbar(_ref) {
|
|
11
9
|
var hide = _ref.hide;
|
|
@@ -26,49 +24,4 @@ var updateToolbarDocking = exports.updateToolbarDocking = function updateToolbar
|
|
|
26
24
|
});
|
|
27
25
|
return tr;
|
|
28
26
|
};
|
|
29
|
-
};
|
|
30
|
-
var setToolbarDocking = exports.setToolbarDocking = function setToolbarDocking(_ref5) {
|
|
31
|
-
var toolbarDocking = _ref5.toolbarDocking,
|
|
32
|
-
userPreferencesProvider = _ref5.userPreferencesProvider,
|
|
33
|
-
editorAnalyticsApi = _ref5.editorAnalyticsApi;
|
|
34
|
-
return function (_ref6) {
|
|
35
|
-
var tr = _ref6.tr;
|
|
36
|
-
// We currently ignore any update failures, need to confirm this is the desired behaviour
|
|
37
|
-
userPreferencesProvider === null || userPreferencesProvider === void 0 || userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
|
|
38
|
-
tr.setMeta(_pluginKey.selectionToolbarPluginKey, {
|
|
39
|
-
toolbarDocking: toolbarDocking
|
|
40
|
-
});
|
|
41
|
-
if (toolbarDocking === 'top') {
|
|
42
|
-
// Remove the selection if the toolbar is docked to the top
|
|
43
|
-
tr.setSelection(_state.TextSelection.create(tr.doc, tr.selection.head));
|
|
44
|
-
}
|
|
45
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
46
|
-
action: _analytics.ACTION.UPDATED,
|
|
47
|
-
actionSubject: _analytics.ACTION_SUBJECT.USER_PREFERENCES,
|
|
48
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
|
|
49
|
-
attributes: {
|
|
50
|
-
toolbarDocking: toolbarDocking
|
|
51
|
-
},
|
|
52
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
53
|
-
})(tr);
|
|
54
|
-
return tr;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// Performs similarly to `setToolbarDocking` with a couple of differences.
|
|
59
|
-
// 1) It does not fire any analytics.
|
|
60
|
-
// 2) It does not make any changes to the selection.
|
|
61
|
-
// This was required due to issues with the Confluence Legacy Content Extension which needs to manipulate the scrollbar position when editor controls are enabled
|
|
62
|
-
// but relies on the selection remaining stable.
|
|
63
|
-
var forceToolbarDockingWithoutAnalytics = exports.forceToolbarDockingWithoutAnalytics = function forceToolbarDockingWithoutAnalytics(_ref7) {
|
|
64
|
-
var toolbarDocking = _ref7.toolbarDocking,
|
|
65
|
-
userPreferencesProvider = _ref7.userPreferencesProvider;
|
|
66
|
-
return function (_ref8) {
|
|
67
|
-
var tr = _ref8.tr;
|
|
68
|
-
userPreferencesProvider === null || userPreferencesProvider === void 0 || userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
|
|
69
|
-
tr.setMeta(_pluginKey.selectionToolbarPluginKey, {
|
|
70
|
-
toolbarDocking: toolbarDocking
|
|
71
|
-
});
|
|
72
|
-
return tr;
|
|
73
|
-
};
|
|
74
27
|
};
|
|
@@ -9,15 +9,12 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _bindEventListener = require("bind-event-listener");
|
|
12
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
14
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
17
15
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
18
16
|
var _commands = require("./pm-plugins/commands");
|
|
19
17
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
20
|
-
var _PageVisibilityWatcher = require("./ui/PageVisibilityWatcher");
|
|
21
18
|
var _pinToolbarConfig = require("./ui/pin-toolbar-config");
|
|
22
19
|
var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
|
|
23
20
|
var _toolbarComponents = require("./ui/toolbar-components");
|
|
@@ -73,7 +70,6 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
72
|
var previousToolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || null;
|
|
76
|
-
var isPreferenceInitialized = false;
|
|
77
73
|
return {
|
|
78
74
|
name: 'selectionToolbar',
|
|
79
75
|
actions: {
|
|
@@ -113,35 +109,20 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
113
109
|
}))) !== null && _api$core$actions$exe4 !== void 0 ? _api$core$actions$exe4 : false;
|
|
114
110
|
},
|
|
115
111
|
setToolbarDocking: function setToolbarDocking(toolbarDocking) {
|
|
116
|
-
var _api$core$actions$
|
|
117
|
-
|
|
118
|
-
var _api$core$actions$exe5, _api$userPreferences3;
|
|
119
|
-
return (_api$core$actions$exe5 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences3 = api.userPreferences) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe5 !== void 0 ? _api$core$actions$exe5 : false;
|
|
120
|
-
}
|
|
121
|
-
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.setToolbarDocking)({
|
|
122
|
-
toolbarDocking: toolbarDocking,
|
|
123
|
-
userPreferencesProvider: userPreferencesProvider,
|
|
124
|
-
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
125
|
-
}))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
112
|
+
var _api$core$actions$exe5, _api$userPreferences3;
|
|
113
|
+
return (_api$core$actions$exe5 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences3 = api.userPreferences) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe5 !== void 0 ? _api$core$actions$exe5 : false;
|
|
126
114
|
},
|
|
127
115
|
forceToolbarDockingWithoutAnalytics: function forceToolbarDockingWithoutAnalytics(toolbarDocking) {
|
|
128
|
-
var _api$core$actions$
|
|
129
|
-
|
|
130
|
-
var _api$core$actions$exe7, _api$userPreferences4;
|
|
131
|
-
return (_api$core$actions$exe7 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences4 = api.userPreferences) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe7 !== void 0 ? _api$core$actions$exe7 : false;
|
|
132
|
-
}
|
|
133
|
-
return (_api$core$actions$exe8 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.forceToolbarDockingWithoutAnalytics)({
|
|
134
|
-
toolbarDocking: toolbarDocking,
|
|
135
|
-
userPreferencesProvider: userPreferencesProvider
|
|
136
|
-
}))) !== null && _api$core$actions$exe8 !== void 0 ? _api$core$actions$exe8 : false;
|
|
116
|
+
var _api$core$actions$exe6, _api$userPreferences4;
|
|
117
|
+
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences4 = api.userPreferences) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
137
118
|
},
|
|
138
119
|
refreshToolbarDocking: function refreshToolbarDocking() {
|
|
139
120
|
if (userPreferencesProvider) {
|
|
140
|
-
var _api$core$actions$
|
|
121
|
+
var _api$core$actions$exe7;
|
|
141
122
|
var userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
142
|
-
return (_api$core$actions$
|
|
123
|
+
return (_api$core$actions$exe7 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.updateToolbarDocking)({
|
|
143
124
|
toolbarDocking: userToolbarDockingPref
|
|
144
|
-
}))) !== null && _api$core$actions$
|
|
125
|
+
}))) !== null && _api$core$actions$exe7 !== void 0 ? _api$core$actions$exe7 : false;
|
|
145
126
|
}
|
|
146
127
|
return false;
|
|
147
128
|
}
|
|
@@ -157,7 +138,7 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
157
138
|
if (selectionToolbarHandlers) {
|
|
158
139
|
__selectionToolbarHandlers.push.apply(__selectionToolbarHandlers, (0, _toConsumableArray2.default)(selectionToolbarHandlers));
|
|
159
140
|
}
|
|
160
|
-
var initialToolbarDocking =
|
|
141
|
+
var initialToolbarDocking = getToolbarDockingV2(contextualFormattingEnabled, api === null || api === void 0 || (_api$userPreferences5 = api.userPreferences) === null || _api$userPreferences5 === void 0 || (_api$userPreferences5 = _api$userPreferences5.sharedState.currentState()) === null || _api$userPreferences5 === void 0 || (_api$userPreferences5 = _api$userPreferences5.preferences) === null || _api$userPreferences5 === void 0 ? void 0 : _api$userPreferences5.toolbarDockingPosition);
|
|
161
142
|
return [{
|
|
162
143
|
name: 'selection-tracker',
|
|
163
144
|
plugin: function plugin() {
|
|
@@ -242,31 +223,6 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
242
223
|
}
|
|
243
224
|
};
|
|
244
225
|
},
|
|
245
|
-
appendTransaction: function appendTransaction(_transactions, _oldState, newState) {
|
|
246
|
-
if ((0, _fg.fg)('platform_editor_use_preferences_plugin')) {
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
if (!isPreferenceInitialized && (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
250
|
-
var toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
|
|
251
|
-
if (toolbarDockingPreference !== undefined) {
|
|
252
|
-
var _api$analytics2;
|
|
253
|
-
isPreferenceInitialized = true;
|
|
254
|
-
var userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
255
|
-
var tr = newState.tr;
|
|
256
|
-
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
257
|
-
action: _analytics.ACTION.INITIALISED,
|
|
258
|
-
actionSubject: _analytics.ACTION_SUBJECT.USER_PREFERENCES,
|
|
259
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
|
|
260
|
-
attributes: {
|
|
261
|
-
toolbarDocking: userToolbarDockingPref
|
|
262
|
-
},
|
|
263
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
264
|
-
})(tr);
|
|
265
|
-
return tr;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return null;
|
|
269
|
-
},
|
|
270
226
|
props: {
|
|
271
227
|
handleDOMEvents: {
|
|
272
228
|
mousedown: function mousedown(view) {
|
|
@@ -362,7 +318,7 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
362
318
|
}
|
|
363
319
|
if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
|
|
364
320
|
var _api$userPreferences6;
|
|
365
|
-
var toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences
|
|
321
|
+
var toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences ? api === null || api === void 0 || (_api$userPreferences6 = api.userPreferences) === null || _api$userPreferences6 === void 0 || (_api$userPreferences6 = _api$userPreferences6.sharedState.currentState()) === null || _api$userPreferences6 === void 0 || (_api$userPreferences6 = _api$userPreferences6.preferences) === null || _api$userPreferences6 === void 0 ? void 0 : _api$userPreferences6.toolbarDockingPosition : toolbarDocking;
|
|
366
322
|
items.push.apply(items, (0, _toConsumableArray2.default)((0, _pinToolbarConfig.getPinOptionToolbarConfig)({
|
|
367
323
|
api: api,
|
|
368
324
|
toolbarDocking: toolbarDockingPref,
|
|
@@ -389,12 +345,6 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
389
345
|
});
|
|
390
346
|
}
|
|
391
347
|
},
|
|
392
|
-
contentComponent: (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') && !(0, _fg.fg)('platform_editor_use_preferences_plugin') ? function () {
|
|
393
|
-
return /*#__PURE__*/_react.default.createElement(_PageVisibilityWatcher.PageVisibilityWatcher, {
|
|
394
|
-
api: api,
|
|
395
|
-
userPreferencesProvider: userPreferencesProvider
|
|
396
|
-
});
|
|
397
|
-
} : undefined,
|
|
398
348
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1', {
|
|
399
349
|
exposure: true
|
|
400
350
|
}) ? primaryToolbarComponent : undefined
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* PrimaryToolbarComponent.tsx generated by @compiled/babel-plugin v3.0.
|
|
1
|
+
/* PrimaryToolbarComponent.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -17,7 +17,6 @@ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-
|
|
|
17
17
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
18
18
|
var _pin = _interopRequireDefault(require("@atlaskit/icon/core/pin"));
|
|
19
19
|
var _pinFilled = _interopRequireDefault(require("@atlaskit/icon/core/pin-filled"));
|
|
20
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
21
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
21
|
var buttonStyles = null;
|
|
23
22
|
/**
|
|
@@ -25,13 +24,13 @@ var buttonStyles = null;
|
|
|
25
24
|
* button to the toolbar to the or make it in-line.
|
|
26
25
|
*/
|
|
27
26
|
var PrimaryToolbarComponent = exports.PrimaryToolbarComponent = function PrimaryToolbarComponent(_ref) {
|
|
28
|
-
var _api$userPreferences
|
|
27
|
+
var _api$userPreferences;
|
|
29
28
|
var api = _ref.api,
|
|
30
29
|
disabled = _ref.disabled;
|
|
31
30
|
var intl = (0, _reactIntl.useIntl)();
|
|
32
31
|
var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'connectivity.mode');
|
|
33
32
|
var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(mode);
|
|
34
|
-
var isDockedToTop = (
|
|
33
|
+
var isDockedToTop = (api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition) === 'top';
|
|
35
34
|
if (isDockedToTop) {
|
|
36
35
|
return /*#__PURE__*/React.createElement(_uiMenu.ToolbarButton, {
|
|
37
36
|
"aria-label": intl.formatMessage(_messages.selectionToolbarMessages.toolbarPositionPinedAtTop)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* overflow-toolbar-config.tsx generated by @compiled/babel-plugin v3.0.
|
|
1
|
+
/* overflow-toolbar-config.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -14,7 +14,6 @@ var _dockToolbarTop = _interopRequireDefault(require("@atlaskit/icon-lab/core/do
|
|
|
14
14
|
var _checkMark = _interopRequireDefault(require("@atlaskit/icon/core/check-mark"));
|
|
15
15
|
var _minus = _interopRequireDefault(require("@atlaskit/icon/core/minus"));
|
|
16
16
|
var _headingItem = _interopRequireDefault(require("@atlaskit/menu/heading-item"));
|
|
17
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
18
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
18
|
var getOverflowPrimaryToolbarConfig = exports.getOverflowPrimaryToolbarConfig = function getOverflowPrimaryToolbarConfig(_ref) {
|
|
20
19
|
var api = _ref.api,
|
|
@@ -32,12 +31,8 @@ var getOverflowPrimaryToolbarConfig = exports.getOverflowPrimaryToolbarConfig =
|
|
|
32
31
|
name: 'contextual'
|
|
33
32
|
},
|
|
34
33
|
onClick: function onClick() {
|
|
35
|
-
var _api$
|
|
36
|
-
|
|
37
|
-
var _api$core$actions$exe, _api$userPreferences, _api$userPreferences$;
|
|
38
|
-
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.actions) === null || _api$userPreferences === void 0 || (_api$userPreferences$ = _api$userPreferences.updateUserPreference) === null || _api$userPreferences$ === void 0 ? void 0 : _api$userPreferences$.call(_api$userPreferences, 'toolbarDockingPosition', 'none'))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
39
|
-
}
|
|
40
|
-
return (_api$selectionToolbar = api === null || api === void 0 || (_api$selectionToolbar2 = api.selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 || (_api$selectionToolbar3 = _api$selectionToolbar2.setToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2, 'none')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
|
|
34
|
+
var _api$core$actions$exe, _api$userPreferences, _api$userPreferences$;
|
|
35
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.actions) === null || _api$userPreferences === void 0 || (_api$userPreferences$ = _api$userPreferences.updateUserPreference) === null || _api$userPreferences$ === void 0 ? void 0 : _api$userPreferences$.call(_api$userPreferences, 'toolbarDockingPosition', 'none'))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
41
36
|
},
|
|
42
37
|
elemBefore: (0, _minus.default)({
|
|
43
38
|
label: ''
|
|
@@ -48,12 +43,8 @@ var getOverflowPrimaryToolbarConfig = exports.getOverflowPrimaryToolbarConfig =
|
|
|
48
43
|
name: 'fixed'
|
|
49
44
|
},
|
|
50
45
|
onClick: function onClick() {
|
|
51
|
-
var _api$
|
|
52
|
-
|
|
53
|
-
var _api$core$actions$exe2, _api$userPreferences2, _api$userPreferences3;
|
|
54
|
-
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.actions) === null || _api$userPreferences2 === void 0 || (_api$userPreferences3 = _api$userPreferences2.updateUserPreference) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.call(_api$userPreferences2, 'toolbarDockingPosition', 'top'))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
55
|
-
}
|
|
56
|
-
return (_api$selectionToolbar4 = api === null || api === void 0 || (_api$selectionToolbar5 = api.selectionToolbar.actions) === null || _api$selectionToolbar5 === void 0 || (_api$selectionToolbar6 = _api$selectionToolbar5.setToolbarDocking) === null || _api$selectionToolbar6 === void 0 ? void 0 : _api$selectionToolbar6.call(_api$selectionToolbar5, 'top')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
|
|
46
|
+
var _api$core$actions$exe2, _api$userPreferences2, _api$userPreferences3;
|
|
47
|
+
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.actions) === null || _api$userPreferences2 === void 0 || (_api$userPreferences3 = _api$userPreferences2.updateUserPreference) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.call(_api$userPreferences2, 'toolbarDockingPosition', 'top'))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
57
48
|
},
|
|
58
49
|
isActive: true,
|
|
59
50
|
elemBefore: (0, _dockToolbarTop.default)({
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
1
|
import { selectionToolbarPluginKey } from './plugin-key';
|
|
4
2
|
export const toggleToolbar = ({
|
|
5
3
|
hide
|
|
@@ -20,49 +18,4 @@ export const updateToolbarDocking = ({
|
|
|
20
18
|
toolbarDocking
|
|
21
19
|
});
|
|
22
20
|
return tr;
|
|
23
|
-
};
|
|
24
|
-
export const setToolbarDocking = ({
|
|
25
|
-
toolbarDocking,
|
|
26
|
-
userPreferencesProvider,
|
|
27
|
-
editorAnalyticsApi
|
|
28
|
-
}) => ({
|
|
29
|
-
tr
|
|
30
|
-
}) => {
|
|
31
|
-
// We currently ignore any update failures, need to confirm this is the desired behaviour
|
|
32
|
-
userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
|
|
33
|
-
tr.setMeta(selectionToolbarPluginKey, {
|
|
34
|
-
toolbarDocking
|
|
35
|
-
});
|
|
36
|
-
if (toolbarDocking === 'top') {
|
|
37
|
-
// Remove the selection if the toolbar is docked to the top
|
|
38
|
-
tr.setSelection(TextSelection.create(tr.doc, tr.selection.head));
|
|
39
|
-
}
|
|
40
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
41
|
-
action: ACTION.UPDATED,
|
|
42
|
-
actionSubject: ACTION_SUBJECT.USER_PREFERENCES,
|
|
43
|
-
actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
|
|
44
|
-
attributes: {
|
|
45
|
-
toolbarDocking
|
|
46
|
-
},
|
|
47
|
-
eventType: EVENT_TYPE.TRACK
|
|
48
|
-
})(tr);
|
|
49
|
-
return tr;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Performs similarly to `setToolbarDocking` with a couple of differences.
|
|
53
|
-
// 1) It does not fire any analytics.
|
|
54
|
-
// 2) It does not make any changes to the selection.
|
|
55
|
-
// This was required due to issues with the Confluence Legacy Content Extension which needs to manipulate the scrollbar position when editor controls are enabled
|
|
56
|
-
// but relies on the selection remaining stable.
|
|
57
|
-
export const forceToolbarDockingWithoutAnalytics = ({
|
|
58
|
-
toolbarDocking,
|
|
59
|
-
userPreferencesProvider
|
|
60
|
-
}) => ({
|
|
61
|
-
tr
|
|
62
|
-
}) => {
|
|
63
|
-
userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
|
|
64
|
-
tr.setMeta(selectionToolbarPluginKey, {
|
|
65
|
-
toolbarDocking
|
|
66
|
-
});
|
|
67
|
-
return tr;
|
|
68
21
|
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { bind } from 'bind-event-listener';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
4
|
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionOnCellSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
|
|
6
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
9
|
-
import {
|
|
7
|
+
import { toggleToolbar, updateToolbarDocking } from './pm-plugins/commands';
|
|
10
8
|
import { selectionToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
11
|
-
import { PageVisibilityWatcher } from './ui/PageVisibilityWatcher';
|
|
12
9
|
import { getPinOptionToolbarConfig } from './ui/pin-toolbar-config';
|
|
13
10
|
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
14
11
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
@@ -66,7 +63,6 @@ export const selectionToolbarPlugin = ({
|
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
let previousToolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || null;
|
|
69
|
-
let isPreferenceInitialized = false;
|
|
70
66
|
return {
|
|
71
67
|
name: 'selectionToolbar',
|
|
72
68
|
actions: {
|
|
@@ -106,35 +102,20 @@ export const selectionToolbarPlugin = ({
|
|
|
106
102
|
}))) !== null && _api$core$actions$exe4 !== void 0 ? _api$core$actions$exe4 : false;
|
|
107
103
|
},
|
|
108
104
|
setToolbarDocking: toolbarDocking => {
|
|
109
|
-
var _api$core$actions$
|
|
110
|
-
|
|
111
|
-
var _api$core$actions$exe5, _api$userPreferences3;
|
|
112
|
-
return (_api$core$actions$exe5 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userPreferences3 = api.userPreferences) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe5 !== void 0 ? _api$core$actions$exe5 : false;
|
|
113
|
-
}
|
|
114
|
-
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute(setToolbarDocking({
|
|
115
|
-
toolbarDocking,
|
|
116
|
-
userPreferencesProvider,
|
|
117
|
-
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
118
|
-
}))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
105
|
+
var _api$core$actions$exe5, _api$userPreferences3;
|
|
106
|
+
return (_api$core$actions$exe5 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userPreferences3 = api.userPreferences) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe5 !== void 0 ? _api$core$actions$exe5 : false;
|
|
119
107
|
},
|
|
120
108
|
forceToolbarDockingWithoutAnalytics: toolbarDocking => {
|
|
121
|
-
var _api$core$actions$
|
|
122
|
-
|
|
123
|
-
var _api$core$actions$exe7, _api$userPreferences4;
|
|
124
|
-
return (_api$core$actions$exe7 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userPreferences4 = api.userPreferences) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe7 !== void 0 ? _api$core$actions$exe7 : false;
|
|
125
|
-
}
|
|
126
|
-
return (_api$core$actions$exe8 = api === null || api === void 0 ? void 0 : api.core.actions.execute(forceToolbarDockingWithoutAnalytics({
|
|
127
|
-
toolbarDocking,
|
|
128
|
-
userPreferencesProvider
|
|
129
|
-
}))) !== null && _api$core$actions$exe8 !== void 0 ? _api$core$actions$exe8 : false;
|
|
109
|
+
var _api$core$actions$exe6, _api$userPreferences4;
|
|
110
|
+
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userPreferences4 = api.userPreferences) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
130
111
|
},
|
|
131
112
|
refreshToolbarDocking: () => {
|
|
132
113
|
if (userPreferencesProvider) {
|
|
133
|
-
var _api$core$actions$
|
|
114
|
+
var _api$core$actions$exe7;
|
|
134
115
|
const userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
135
|
-
return (_api$core$actions$
|
|
116
|
+
return (_api$core$actions$exe7 = api === null || api === void 0 ? void 0 : api.core.actions.execute(updateToolbarDocking({
|
|
136
117
|
toolbarDocking: userToolbarDockingPref
|
|
137
|
-
}))) !== null && _api$core$actions$
|
|
118
|
+
}))) !== null && _api$core$actions$exe7 !== void 0 ? _api$core$actions$exe7 : false;
|
|
138
119
|
}
|
|
139
120
|
return false;
|
|
140
121
|
}
|
|
@@ -150,7 +131,7 @@ export const selectionToolbarPlugin = ({
|
|
|
150
131
|
if (selectionToolbarHandlers) {
|
|
151
132
|
__selectionToolbarHandlers.push(...selectionToolbarHandlers);
|
|
152
133
|
}
|
|
153
|
-
const initialToolbarDocking =
|
|
134
|
+
const initialToolbarDocking = getToolbarDockingV2(contextualFormattingEnabled, api === null || api === void 0 ? void 0 : (_api$userPreferences5 = api.userPreferences) === null || _api$userPreferences5 === void 0 ? void 0 : (_api$userPreferences6 = _api$userPreferences5.sharedState.currentState()) === null || _api$userPreferences6 === void 0 ? void 0 : (_api$userPreferences7 = _api$userPreferences6.preferences) === null || _api$userPreferences7 === void 0 ? void 0 : _api$userPreferences7.toolbarDockingPosition);
|
|
154
135
|
return [{
|
|
155
136
|
name: 'selection-tracker',
|
|
156
137
|
plugin: () => {
|
|
@@ -240,31 +221,6 @@ export const selectionToolbarPlugin = ({
|
|
|
240
221
|
}
|
|
241
222
|
};
|
|
242
223
|
},
|
|
243
|
-
appendTransaction(_transactions, _oldState, newState) {
|
|
244
|
-
if (fg('platform_editor_use_preferences_plugin')) {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
if (!isPreferenceInitialized && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
248
|
-
const toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
|
|
249
|
-
if (toolbarDockingPreference !== undefined) {
|
|
250
|
-
var _api$analytics2;
|
|
251
|
-
isPreferenceInitialized = true;
|
|
252
|
-
const userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
253
|
-
const tr = newState.tr;
|
|
254
|
-
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
|
|
255
|
-
action: ACTION.INITIALISED,
|
|
256
|
-
actionSubject: ACTION_SUBJECT.USER_PREFERENCES,
|
|
257
|
-
actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
|
|
258
|
-
attributes: {
|
|
259
|
-
toolbarDocking: userToolbarDockingPref
|
|
260
|
-
},
|
|
261
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
262
|
-
})(tr);
|
|
263
|
-
return tr;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return null;
|
|
267
|
-
},
|
|
268
224
|
props: {
|
|
269
225
|
handleDOMEvents: {
|
|
270
226
|
mousedown: view => {
|
|
@@ -357,7 +313,7 @@ export const selectionToolbarPlugin = ({
|
|
|
357
313
|
}
|
|
358
314
|
if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
|
|
359
315
|
var _api$userPreferences8, _api$userPreferences9, _api$userPreferences0;
|
|
360
|
-
const toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences
|
|
316
|
+
const toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences ? api === null || api === void 0 ? void 0 : (_api$userPreferences8 = api.userPreferences) === null || _api$userPreferences8 === void 0 ? void 0 : (_api$userPreferences9 = _api$userPreferences8.sharedState.currentState()) === null || _api$userPreferences9 === void 0 ? void 0 : (_api$userPreferences0 = _api$userPreferences9.preferences) === null || _api$userPreferences0 === void 0 ? void 0 : _api$userPreferences0.toolbarDockingPosition : toolbarDocking;
|
|
361
317
|
items.push(...getPinOptionToolbarConfig({
|
|
362
318
|
api,
|
|
363
319
|
toolbarDocking: toolbarDockingPref,
|
|
@@ -384,10 +340,6 @@ export const selectionToolbarPlugin = ({
|
|
|
384
340
|
};
|
|
385
341
|
}
|
|
386
342
|
},
|
|
387
|
-
contentComponent: editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_use_preferences_plugin') ? () => /*#__PURE__*/React.createElement(PageVisibilityWatcher, {
|
|
388
|
-
api: api,
|
|
389
|
-
userPreferencesProvider: userPreferencesProvider
|
|
390
|
-
}) : undefined,
|
|
391
343
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && editorExperiment('platform_editor_controls', 'variant1', {
|
|
392
344
|
exposure: true
|
|
393
345
|
}) ? primaryToolbarComponent : undefined
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* PrimaryToolbarComponent.tsx generated by @compiled/babel-plugin v3.0.
|
|
1
|
+
/* PrimaryToolbarComponent.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
import "./PrimaryToolbarComponent.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
@@ -9,7 +9,6 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
|
|
|
9
9
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
10
10
|
import PinIcon from '@atlaskit/icon/core/pin';
|
|
11
11
|
import PinFilledIcon from '@atlaskit/icon/core/pin-filled';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
13
12
|
const buttonStyles = null;
|
|
14
13
|
/**
|
|
15
14
|
* A component used to renderer a pin/unpin
|
|
@@ -19,11 +18,11 @@ export const PrimaryToolbarComponent = ({
|
|
|
19
18
|
api,
|
|
20
19
|
disabled
|
|
21
20
|
}) => {
|
|
22
|
-
var _api$userPreferences, _api$userPreferences$, _api$userPreferences$2
|
|
21
|
+
var _api$userPreferences, _api$userPreferences$, _api$userPreferences$2;
|
|
23
22
|
const intl = useIntl();
|
|
24
23
|
const mode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
25
24
|
const isOffline = isOfflineMode(mode);
|
|
26
|
-
const isDockedToTop =
|
|
25
|
+
const isDockedToTop = (api === null || api === void 0 ? void 0 : (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : (_api$userPreferences$ = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences$ === void 0 ? void 0 : (_api$userPreferences$2 = _api$userPreferences$.preferences) === null || _api$userPreferences$2 === void 0 ? void 0 : _api$userPreferences$2.toolbarDockingPosition) === 'top';
|
|
27
26
|
if (isDockedToTop) {
|
|
28
27
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
29
28
|
"aria-label": intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* overflow-toolbar-config.tsx generated by @compiled/babel-plugin v3.0.
|
|
1
|
+
/* overflow-toolbar-config.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -6,7 +6,6 @@ import DockToolbarTopIcon from '@atlaskit/icon-lab/core/dock-toolbar-top';
|
|
|
6
6
|
import CheckMarkIcon from '@atlaskit/icon/core/check-mark';
|
|
7
7
|
import MinusIcon from '@atlaskit/icon/core/minus';
|
|
8
8
|
import HeadingItem from '@atlaskit/menu/heading-item';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
10
9
|
export const getOverflowPrimaryToolbarConfig = ({
|
|
11
10
|
api,
|
|
12
11
|
intl
|
|
@@ -23,12 +22,8 @@ export const getOverflowPrimaryToolbarConfig = ({
|
|
|
23
22
|
name: 'contextual'
|
|
24
23
|
},
|
|
25
24
|
onClick: () => {
|
|
26
|
-
var _api$
|
|
27
|
-
|
|
28
|
-
var _api$core$actions$exe, _api$userPreferences, _api$userPreferences$, _api$userPreferences$2;
|
|
29
|
-
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : (_api$userPreferences$ = _api$userPreferences.actions) === null || _api$userPreferences$ === void 0 ? void 0 : (_api$userPreferences$2 = _api$userPreferences$.updateUserPreference) === null || _api$userPreferences$2 === void 0 ? void 0 : _api$userPreferences$2.call(_api$userPreferences$, 'toolbarDockingPosition', 'none'))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
30
|
-
}
|
|
31
|
-
return (_api$selectionToolbar = api === null || api === void 0 ? void 0 : (_api$selectionToolbar2 = api.selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.setToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2, 'none')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
|
|
25
|
+
var _api$core$actions$exe, _api$userPreferences, _api$userPreferences$, _api$userPreferences$2;
|
|
26
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : (_api$userPreferences$ = _api$userPreferences.actions) === null || _api$userPreferences$ === void 0 ? void 0 : (_api$userPreferences$2 = _api$userPreferences$.updateUserPreference) === null || _api$userPreferences$2 === void 0 ? void 0 : _api$userPreferences$2.call(_api$userPreferences$, 'toolbarDockingPosition', 'none'))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
32
27
|
},
|
|
33
28
|
elemBefore: MinusIcon({
|
|
34
29
|
label: ''
|
|
@@ -39,12 +34,8 @@ export const getOverflowPrimaryToolbarConfig = ({
|
|
|
39
34
|
name: 'fixed'
|
|
40
35
|
},
|
|
41
36
|
onClick: () => {
|
|
42
|
-
var _api$
|
|
43
|
-
|
|
44
|
-
var _api$core$actions$exe2, _api$userPreferences2, _api$userPreferences3, _api$userPreferences4;
|
|
45
|
-
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 ? void 0 : (_api$userPreferences3 = _api$userPreferences2.actions) === null || _api$userPreferences3 === void 0 ? void 0 : (_api$userPreferences4 = _api$userPreferences3.updateUserPreference) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.call(_api$userPreferences3, 'toolbarDockingPosition', 'top'))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
46
|
-
}
|
|
47
|
-
return (_api$selectionToolbar4 = api === null || api === void 0 ? void 0 : (_api$selectionToolbar5 = api.selectionToolbar.actions) === null || _api$selectionToolbar5 === void 0 ? void 0 : (_api$selectionToolbar6 = _api$selectionToolbar5.setToolbarDocking) === null || _api$selectionToolbar6 === void 0 ? void 0 : _api$selectionToolbar6.call(_api$selectionToolbar5, 'top')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
|
|
37
|
+
var _api$core$actions$exe2, _api$userPreferences2, _api$userPreferences3, _api$userPreferences4;
|
|
38
|
+
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 ? void 0 : (_api$userPreferences3 = _api$userPreferences2.actions) === null || _api$userPreferences3 === void 0 ? void 0 : (_api$userPreferences4 = _api$userPreferences3.updateUserPreference) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.call(_api$userPreferences3, 'toolbarDockingPosition', 'top'))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
48
39
|
},
|
|
49
40
|
isActive: true,
|
|
50
41
|
elemBefore: DockToolbarTopIcon({
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
1
|
import { selectionToolbarPluginKey } from './plugin-key';
|
|
4
2
|
export var toggleToolbar = function toggleToolbar(_ref) {
|
|
5
3
|
var hide = _ref.hide;
|
|
@@ -20,49 +18,4 @@ export var updateToolbarDocking = function updateToolbarDocking(_ref3) {
|
|
|
20
18
|
});
|
|
21
19
|
return tr;
|
|
22
20
|
};
|
|
23
|
-
};
|
|
24
|
-
export var setToolbarDocking = function setToolbarDocking(_ref5) {
|
|
25
|
-
var toolbarDocking = _ref5.toolbarDocking,
|
|
26
|
-
userPreferencesProvider = _ref5.userPreferencesProvider,
|
|
27
|
-
editorAnalyticsApi = _ref5.editorAnalyticsApi;
|
|
28
|
-
return function (_ref6) {
|
|
29
|
-
var tr = _ref6.tr;
|
|
30
|
-
// We currently ignore any update failures, need to confirm this is the desired behaviour
|
|
31
|
-
userPreferencesProvider === null || userPreferencesProvider === void 0 || userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
|
|
32
|
-
tr.setMeta(selectionToolbarPluginKey, {
|
|
33
|
-
toolbarDocking: toolbarDocking
|
|
34
|
-
});
|
|
35
|
-
if (toolbarDocking === 'top') {
|
|
36
|
-
// Remove the selection if the toolbar is docked to the top
|
|
37
|
-
tr.setSelection(TextSelection.create(tr.doc, tr.selection.head));
|
|
38
|
-
}
|
|
39
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
40
|
-
action: ACTION.UPDATED,
|
|
41
|
-
actionSubject: ACTION_SUBJECT.USER_PREFERENCES,
|
|
42
|
-
actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
|
|
43
|
-
attributes: {
|
|
44
|
-
toolbarDocking: toolbarDocking
|
|
45
|
-
},
|
|
46
|
-
eventType: EVENT_TYPE.TRACK
|
|
47
|
-
})(tr);
|
|
48
|
-
return tr;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Performs similarly to `setToolbarDocking` with a couple of differences.
|
|
53
|
-
// 1) It does not fire any analytics.
|
|
54
|
-
// 2) It does not make any changes to the selection.
|
|
55
|
-
// This was required due to issues with the Confluence Legacy Content Extension which needs to manipulate the scrollbar position when editor controls are enabled
|
|
56
|
-
// but relies on the selection remaining stable.
|
|
57
|
-
export var forceToolbarDockingWithoutAnalytics = function forceToolbarDockingWithoutAnalytics(_ref7) {
|
|
58
|
-
var toolbarDocking = _ref7.toolbarDocking,
|
|
59
|
-
userPreferencesProvider = _ref7.userPreferencesProvider;
|
|
60
|
-
return function (_ref8) {
|
|
61
|
-
var tr = _ref8.tr;
|
|
62
|
-
userPreferencesProvider === null || userPreferencesProvider === void 0 || userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
|
|
63
|
-
tr.setMeta(selectionToolbarPluginKey, {
|
|
64
|
-
toolbarDocking: toolbarDocking
|
|
65
|
-
});
|
|
66
|
-
return tr;
|
|
67
|
-
};
|
|
68
21
|
};
|
|
@@ -4,15 +4,12 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
4
4
|
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) { _defineProperty(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; }
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { bind } from 'bind-event-listener';
|
|
7
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
8
|
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionOnCellSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
|
|
10
9
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
12
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
13
|
-
import {
|
|
11
|
+
import { toggleToolbar, updateToolbarDocking } from './pm-plugins/commands';
|
|
14
12
|
import { selectionToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
15
|
-
import { PageVisibilityWatcher } from './ui/PageVisibilityWatcher';
|
|
16
13
|
import { getPinOptionToolbarConfig } from './ui/pin-toolbar-config';
|
|
17
14
|
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
18
15
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
@@ -66,7 +63,6 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
var previousToolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || null;
|
|
69
|
-
var isPreferenceInitialized = false;
|
|
70
66
|
return {
|
|
71
67
|
name: 'selectionToolbar',
|
|
72
68
|
actions: {
|
|
@@ -106,35 +102,20 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
106
102
|
}))) !== null && _api$core$actions$exe4 !== void 0 ? _api$core$actions$exe4 : false;
|
|
107
103
|
},
|
|
108
104
|
setToolbarDocking: function setToolbarDocking(toolbarDocking) {
|
|
109
|
-
var _api$core$actions$
|
|
110
|
-
|
|
111
|
-
var _api$core$actions$exe5, _api$userPreferences3;
|
|
112
|
-
return (_api$core$actions$exe5 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences3 = api.userPreferences) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe5 !== void 0 ? _api$core$actions$exe5 : false;
|
|
113
|
-
}
|
|
114
|
-
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute(_setToolbarDocking({
|
|
115
|
-
toolbarDocking: toolbarDocking,
|
|
116
|
-
userPreferencesProvider: userPreferencesProvider,
|
|
117
|
-
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
118
|
-
}))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
105
|
+
var _api$core$actions$exe5, _api$userPreferences3;
|
|
106
|
+
return (_api$core$actions$exe5 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences3 = api.userPreferences) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe5 !== void 0 ? _api$core$actions$exe5 : false;
|
|
119
107
|
},
|
|
120
108
|
forceToolbarDockingWithoutAnalytics: function forceToolbarDockingWithoutAnalytics(toolbarDocking) {
|
|
121
|
-
var _api$core$actions$
|
|
122
|
-
|
|
123
|
-
var _api$core$actions$exe7, _api$userPreferences4;
|
|
124
|
-
return (_api$core$actions$exe7 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences4 = api.userPreferences) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe7 !== void 0 ? _api$core$actions$exe7 : false;
|
|
125
|
-
}
|
|
126
|
-
return (_api$core$actions$exe8 = api === null || api === void 0 ? void 0 : api.core.actions.execute(_forceToolbarDockingWithoutAnalytics({
|
|
127
|
-
toolbarDocking: toolbarDocking,
|
|
128
|
-
userPreferencesProvider: userPreferencesProvider
|
|
129
|
-
}))) !== null && _api$core$actions$exe8 !== void 0 ? _api$core$actions$exe8 : false;
|
|
109
|
+
var _api$core$actions$exe6, _api$userPreferences4;
|
|
110
|
+
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences4 = api.userPreferences) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.actions.updateUserPreference('toolbarDockingPosition', toolbarDocking))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
130
111
|
},
|
|
131
112
|
refreshToolbarDocking: function refreshToolbarDocking() {
|
|
132
113
|
if (userPreferencesProvider) {
|
|
133
|
-
var _api$core$actions$
|
|
114
|
+
var _api$core$actions$exe7;
|
|
134
115
|
var userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
135
|
-
return (_api$core$actions$
|
|
116
|
+
return (_api$core$actions$exe7 = api === null || api === void 0 ? void 0 : api.core.actions.execute(updateToolbarDocking({
|
|
136
117
|
toolbarDocking: userToolbarDockingPref
|
|
137
|
-
}))) !== null && _api$core$actions$
|
|
118
|
+
}))) !== null && _api$core$actions$exe7 !== void 0 ? _api$core$actions$exe7 : false;
|
|
138
119
|
}
|
|
139
120
|
return false;
|
|
140
121
|
}
|
|
@@ -150,7 +131,7 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
150
131
|
if (selectionToolbarHandlers) {
|
|
151
132
|
__selectionToolbarHandlers.push.apply(__selectionToolbarHandlers, _toConsumableArray(selectionToolbarHandlers));
|
|
152
133
|
}
|
|
153
|
-
var initialToolbarDocking =
|
|
134
|
+
var initialToolbarDocking = getToolbarDockingV2(contextualFormattingEnabled, api === null || api === void 0 || (_api$userPreferences5 = api.userPreferences) === null || _api$userPreferences5 === void 0 || (_api$userPreferences5 = _api$userPreferences5.sharedState.currentState()) === null || _api$userPreferences5 === void 0 || (_api$userPreferences5 = _api$userPreferences5.preferences) === null || _api$userPreferences5 === void 0 ? void 0 : _api$userPreferences5.toolbarDockingPosition);
|
|
154
135
|
return [{
|
|
155
136
|
name: 'selection-tracker',
|
|
156
137
|
plugin: function plugin() {
|
|
@@ -235,31 +216,6 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
235
216
|
}
|
|
236
217
|
};
|
|
237
218
|
},
|
|
238
|
-
appendTransaction: function appendTransaction(_transactions, _oldState, newState) {
|
|
239
|
-
if (fg('platform_editor_use_preferences_plugin')) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
if (!isPreferenceInitialized && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
243
|
-
var toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
|
|
244
|
-
if (toolbarDockingPreference !== undefined) {
|
|
245
|
-
var _api$analytics2;
|
|
246
|
-
isPreferenceInitialized = true;
|
|
247
|
-
var userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
248
|
-
var tr = newState.tr;
|
|
249
|
-
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
250
|
-
action: ACTION.INITIALISED,
|
|
251
|
-
actionSubject: ACTION_SUBJECT.USER_PREFERENCES,
|
|
252
|
-
actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
|
|
253
|
-
attributes: {
|
|
254
|
-
toolbarDocking: userToolbarDockingPref
|
|
255
|
-
},
|
|
256
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
257
|
-
})(tr);
|
|
258
|
-
return tr;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return null;
|
|
262
|
-
},
|
|
263
219
|
props: {
|
|
264
220
|
handleDOMEvents: {
|
|
265
221
|
mousedown: function mousedown(view) {
|
|
@@ -355,7 +311,7 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
355
311
|
}
|
|
356
312
|
if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
|
|
357
313
|
var _api$userPreferences6;
|
|
358
|
-
var toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences
|
|
314
|
+
var toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences ? api === null || api === void 0 || (_api$userPreferences6 = api.userPreferences) === null || _api$userPreferences6 === void 0 || (_api$userPreferences6 = _api$userPreferences6.sharedState.currentState()) === null || _api$userPreferences6 === void 0 || (_api$userPreferences6 = _api$userPreferences6.preferences) === null || _api$userPreferences6 === void 0 ? void 0 : _api$userPreferences6.toolbarDockingPosition : toolbarDocking;
|
|
359
315
|
items.push.apply(items, _toConsumableArray(getPinOptionToolbarConfig({
|
|
360
316
|
api: api,
|
|
361
317
|
toolbarDocking: toolbarDockingPref,
|
|
@@ -382,12 +338,6 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
382
338
|
});
|
|
383
339
|
}
|
|
384
340
|
},
|
|
385
|
-
contentComponent: editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_use_preferences_plugin') ? function () {
|
|
386
|
-
return /*#__PURE__*/React.createElement(PageVisibilityWatcher, {
|
|
387
|
-
api: api,
|
|
388
|
-
userPreferencesProvider: userPreferencesProvider
|
|
389
|
-
});
|
|
390
|
-
} : undefined,
|
|
391
341
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && editorExperiment('platform_editor_controls', 'variant1', {
|
|
392
342
|
exposure: true
|
|
393
343
|
}) ? primaryToolbarComponent : undefined
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* PrimaryToolbarComponent.tsx generated by @compiled/babel-plugin v3.0.
|
|
1
|
+
/* PrimaryToolbarComponent.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
import "./PrimaryToolbarComponent.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
@@ -9,20 +9,19 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
|
|
|
9
9
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
10
10
|
import PinIcon from '@atlaskit/icon/core/pin';
|
|
11
11
|
import PinFilledIcon from '@atlaskit/icon/core/pin-filled';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
13
12
|
var buttonStyles = null;
|
|
14
13
|
/**
|
|
15
14
|
* A component used to renderer a pin/unpin
|
|
16
15
|
* button to the toolbar to the or make it in-line.
|
|
17
16
|
*/
|
|
18
17
|
export var PrimaryToolbarComponent = function PrimaryToolbarComponent(_ref) {
|
|
19
|
-
var _api$userPreferences
|
|
18
|
+
var _api$userPreferences;
|
|
20
19
|
var api = _ref.api,
|
|
21
20
|
disabled = _ref.disabled;
|
|
22
21
|
var intl = useIntl();
|
|
23
22
|
var mode = useSharedPluginStateSelector(api, 'connectivity.mode');
|
|
24
23
|
var isOffline = isOfflineMode(mode);
|
|
25
|
-
var isDockedToTop =
|
|
24
|
+
var isDockedToTop = (api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition) === 'top';
|
|
26
25
|
if (isDockedToTop) {
|
|
27
26
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
28
27
|
"aria-label": intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* overflow-toolbar-config.tsx generated by @compiled/babel-plugin v3.0.
|
|
1
|
+
/* overflow-toolbar-config.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -6,7 +6,6 @@ import DockToolbarTopIcon from '@atlaskit/icon-lab/core/dock-toolbar-top';
|
|
|
6
6
|
import CheckMarkIcon from '@atlaskit/icon/core/check-mark';
|
|
7
7
|
import MinusIcon from '@atlaskit/icon/core/minus';
|
|
8
8
|
import HeadingItem from '@atlaskit/menu/heading-item';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
10
9
|
export var getOverflowPrimaryToolbarConfig = function getOverflowPrimaryToolbarConfig(_ref) {
|
|
11
10
|
var api = _ref.api,
|
|
12
11
|
intl = _ref.intl;
|
|
@@ -23,12 +22,8 @@ export var getOverflowPrimaryToolbarConfig = function getOverflowPrimaryToolbarC
|
|
|
23
22
|
name: 'contextual'
|
|
24
23
|
},
|
|
25
24
|
onClick: function onClick() {
|
|
26
|
-
var _api$
|
|
27
|
-
|
|
28
|
-
var _api$core$actions$exe, _api$userPreferences, _api$userPreferences$;
|
|
29
|
-
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.actions) === null || _api$userPreferences === void 0 || (_api$userPreferences$ = _api$userPreferences.updateUserPreference) === null || _api$userPreferences$ === void 0 ? void 0 : _api$userPreferences$.call(_api$userPreferences, 'toolbarDockingPosition', 'none'))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
30
|
-
}
|
|
31
|
-
return (_api$selectionToolbar = api === null || api === void 0 || (_api$selectionToolbar2 = api.selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 || (_api$selectionToolbar3 = _api$selectionToolbar2.setToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2, 'none')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
|
|
25
|
+
var _api$core$actions$exe, _api$userPreferences, _api$userPreferences$;
|
|
26
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.actions) === null || _api$userPreferences === void 0 || (_api$userPreferences$ = _api$userPreferences.updateUserPreference) === null || _api$userPreferences$ === void 0 ? void 0 : _api$userPreferences$.call(_api$userPreferences, 'toolbarDockingPosition', 'none'))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
32
27
|
},
|
|
33
28
|
elemBefore: MinusIcon({
|
|
34
29
|
label: ''
|
|
@@ -39,12 +34,8 @@ export var getOverflowPrimaryToolbarConfig = function getOverflowPrimaryToolbarC
|
|
|
39
34
|
name: 'fixed'
|
|
40
35
|
},
|
|
41
36
|
onClick: function onClick() {
|
|
42
|
-
var _api$
|
|
43
|
-
|
|
44
|
-
var _api$core$actions$exe2, _api$userPreferences2, _api$userPreferences3;
|
|
45
|
-
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.actions) === null || _api$userPreferences2 === void 0 || (_api$userPreferences3 = _api$userPreferences2.updateUserPreference) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.call(_api$userPreferences2, 'toolbarDockingPosition', 'top'))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
46
|
-
}
|
|
47
|
-
return (_api$selectionToolbar4 = api === null || api === void 0 || (_api$selectionToolbar5 = api.selectionToolbar.actions) === null || _api$selectionToolbar5 === void 0 || (_api$selectionToolbar6 = _api$selectionToolbar5.setToolbarDocking) === null || _api$selectionToolbar6 === void 0 ? void 0 : _api$selectionToolbar6.call(_api$selectionToolbar5, 'top')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
|
|
37
|
+
var _api$core$actions$exe2, _api$userPreferences2, _api$userPreferences3;
|
|
38
|
+
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.actions) === null || _api$userPreferences2 === void 0 || (_api$userPreferences3 = _api$userPreferences2.updateUserPreference) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.call(_api$userPreferences2, 'toolbarDockingPosition', 'top'))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
48
39
|
},
|
|
49
40
|
isActive: true,
|
|
50
41
|
elemBefore: DockToolbarTopIcon({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { EditorCommand, UserPreferencesProvider } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorCommand } from '@atlaskit/editor-common/types';
|
|
3
2
|
import type { ToolbarDocking } from '../types';
|
|
4
3
|
export declare const toggleToolbar: ({ hide }: {
|
|
5
4
|
hide: boolean;
|
|
@@ -7,12 +6,3 @@ export declare const toggleToolbar: ({ hide }: {
|
|
|
7
6
|
export declare const updateToolbarDocking: ({ toolbarDocking }: {
|
|
8
7
|
toolbarDocking: ToolbarDocking;
|
|
9
8
|
}) => EditorCommand;
|
|
10
|
-
export declare const setToolbarDocking: ({ toolbarDocking, userPreferencesProvider, editorAnalyticsApi, }: {
|
|
11
|
-
editorAnalyticsApi?: EditorAnalyticsAPI | undefined;
|
|
12
|
-
toolbarDocking: ToolbarDocking;
|
|
13
|
-
userPreferencesProvider?: UserPreferencesProvider;
|
|
14
|
-
}) => EditorCommand;
|
|
15
|
-
export declare const forceToolbarDockingWithoutAnalytics: ({ toolbarDocking, userPreferencesProvider, }: {
|
|
16
|
-
toolbarDocking: ToolbarDocking;
|
|
17
|
-
userPreferencesProvider?: UserPreferencesProvider;
|
|
18
|
-
}) => EditorCommand;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-toolbar",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.11",
|
|
4
4
|
"description": "@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
|
+
"website": {
|
|
12
|
+
"tags": [
|
|
13
|
+
"platform-labs"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
11
16
|
"team": "Editor: AI",
|
|
12
17
|
"singleton": true
|
|
13
18
|
},
|
|
@@ -37,13 +42,13 @@
|
|
|
37
42
|
"@atlaskit/icon-lab": "^7.9.0",
|
|
38
43
|
"@atlaskit/menu": "^10.2.0",
|
|
39
44
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
40
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^198.0.0",
|
|
41
46
|
"@atlaskit/tokens": "^17.0.0",
|
|
42
47
|
"@babel/runtime": "^7.0.0",
|
|
43
48
|
"bind-event-listener": "^3.0.0"
|
|
44
49
|
},
|
|
45
50
|
"peerDependencies": {
|
|
46
|
-
"@atlaskit/editor-common": "^122.
|
|
51
|
+
"@atlaskit/editor-common": "^122.11.0",
|
|
47
52
|
"react": "^18.2.0 || ^19.2.0",
|
|
48
53
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
49
54
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -56,10 +61,5 @@
|
|
|
56
61
|
"react-dom": "^19.2.0",
|
|
57
62
|
"react-intl": "^7.0.0",
|
|
58
63
|
"wait-for-expect": "^1.2.0"
|
|
59
|
-
},
|
|
60
|
-
"platform-feature-flags": {
|
|
61
|
-
"platform_editor_use_preferences_plugin": {
|
|
62
|
-
"type": "boolean"
|
|
63
|
-
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.PageVisibilityWatcher = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
var _bindEventListener = require("bind-event-listener");
|
|
12
|
-
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
13
|
-
var PageVisibilityWatcher = exports.PageVisibilityWatcher = function PageVisibilityWatcher(_ref) {
|
|
14
|
-
var api = _ref.api,
|
|
15
|
-
userPreferencesProvider = _ref.userPreferencesProvider;
|
|
16
|
-
(0, _react.useEffect)(function () {
|
|
17
|
-
if (!userPreferencesProvider || !api) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
var refreshPrefrerence = /*#__PURE__*/function () {
|
|
21
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
22
|
-
var _api$selectionToolbar, _api$selectionToolbar2, _t;
|
|
23
|
-
return _regenerator.default.wrap(function (_context) {
|
|
24
|
-
while (1) switch (_context.prev = _context.next) {
|
|
25
|
-
case 0:
|
|
26
|
-
if (!(document.visibilityState === 'visible')) {
|
|
27
|
-
_context.next = 5;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
_context.prev = 1;
|
|
31
|
-
_context.next = 2;
|
|
32
|
-
return userPreferencesProvider.loadPreferences();
|
|
33
|
-
case 2:
|
|
34
|
-
_context.next = 4;
|
|
35
|
-
break;
|
|
36
|
-
case 3:
|
|
37
|
-
_context.prev = 3;
|
|
38
|
-
_t = _context["catch"](1);
|
|
39
|
-
(0, _monitoring.logException)(_t, {
|
|
40
|
-
location: 'editor-plugin-selection-toolbar/PageVisibilityWatcher'
|
|
41
|
-
});
|
|
42
|
-
case 4:
|
|
43
|
-
api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.actions) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar2 = _api$selectionToolbar.refreshToolbarDocking) === null || _api$selectionToolbar2 === void 0 || _api$selectionToolbar2.call(_api$selectionToolbar);
|
|
44
|
-
case 5:
|
|
45
|
-
case "end":
|
|
46
|
-
return _context.stop();
|
|
47
|
-
}
|
|
48
|
-
}, _callee, null, [[1, 3]]);
|
|
49
|
-
}));
|
|
50
|
-
return function refreshPrefrerence() {
|
|
51
|
-
return _ref2.apply(this, arguments);
|
|
52
|
-
};
|
|
53
|
-
}();
|
|
54
|
-
return (0, _bindEventListener.bind)(document, {
|
|
55
|
-
type: 'visibilitychange',
|
|
56
|
-
listener: refreshPrefrerence
|
|
57
|
-
});
|
|
58
|
-
}, [api, userPreferencesProvider]);
|
|
59
|
-
return null;
|
|
60
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { bind } from 'bind-event-listener';
|
|
3
|
-
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
-
export const PageVisibilityWatcher = ({
|
|
5
|
-
api,
|
|
6
|
-
userPreferencesProvider
|
|
7
|
-
}) => {
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (!userPreferencesProvider || !api) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const refreshPrefrerence = async () => {
|
|
13
|
-
if (document.visibilityState === 'visible') {
|
|
14
|
-
var _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
|
|
15
|
-
try {
|
|
16
|
-
await userPreferencesProvider.loadPreferences();
|
|
17
|
-
} catch (error) {
|
|
18
|
-
logException(error, {
|
|
19
|
-
location: 'editor-plugin-selection-toolbar/PageVisibilityWatcher'
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
api === null || api === void 0 ? void 0 : (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 ? void 0 : (_api$selectionToolbar2 = _api$selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.refreshToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
return bind(document, {
|
|
26
|
-
type: 'visibilitychange',
|
|
27
|
-
listener: refreshPrefrerence
|
|
28
|
-
});
|
|
29
|
-
}, [api, userPreferencesProvider]);
|
|
30
|
-
return null;
|
|
31
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
|
-
import { bind } from 'bind-event-listener';
|
|
5
|
-
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
6
|
-
export var PageVisibilityWatcher = function PageVisibilityWatcher(_ref) {
|
|
7
|
-
var api = _ref.api,
|
|
8
|
-
userPreferencesProvider = _ref.userPreferencesProvider;
|
|
9
|
-
useEffect(function () {
|
|
10
|
-
if (!userPreferencesProvider || !api) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
var refreshPrefrerence = /*#__PURE__*/function () {
|
|
14
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
15
|
-
var _api$selectionToolbar, _api$selectionToolbar2, _t;
|
|
16
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
17
|
-
while (1) switch (_context.prev = _context.next) {
|
|
18
|
-
case 0:
|
|
19
|
-
if (!(document.visibilityState === 'visible')) {
|
|
20
|
-
_context.next = 5;
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
_context.prev = 1;
|
|
24
|
-
_context.next = 2;
|
|
25
|
-
return userPreferencesProvider.loadPreferences();
|
|
26
|
-
case 2:
|
|
27
|
-
_context.next = 4;
|
|
28
|
-
break;
|
|
29
|
-
case 3:
|
|
30
|
-
_context.prev = 3;
|
|
31
|
-
_t = _context["catch"](1);
|
|
32
|
-
logException(_t, {
|
|
33
|
-
location: 'editor-plugin-selection-toolbar/PageVisibilityWatcher'
|
|
34
|
-
});
|
|
35
|
-
case 4:
|
|
36
|
-
api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.actions) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar2 = _api$selectionToolbar.refreshToolbarDocking) === null || _api$selectionToolbar2 === void 0 || _api$selectionToolbar2.call(_api$selectionToolbar);
|
|
37
|
-
case 5:
|
|
38
|
-
case "end":
|
|
39
|
-
return _context.stop();
|
|
40
|
-
}
|
|
41
|
-
}, _callee, null, [[1, 3]]);
|
|
42
|
-
}));
|
|
43
|
-
return function refreshPrefrerence() {
|
|
44
|
-
return _ref2.apply(this, arguments);
|
|
45
|
-
};
|
|
46
|
-
}();
|
|
47
|
-
return bind(document, {
|
|
48
|
-
type: 'visibilitychange',
|
|
49
|
-
listener: refreshPrefrerence
|
|
50
|
-
});
|
|
51
|
-
}, [api, userPreferencesProvider]);
|
|
52
|
-
return null;
|
|
53
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ExtractInjectionAPI, UserPreferencesProvider } from '@atlaskit/editor-common/types';
|
|
2
|
-
import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
|
|
3
|
-
export declare const PageVisibilityWatcher: ({ api, userPreferencesProvider, }: {
|
|
4
|
-
api: ExtractInjectionAPI<SelectionToolbarPlugin> | undefined;
|
|
5
|
-
userPreferencesProvider?: UserPreferencesProvider;
|
|
6
|
-
}) => null;
|