@atlaskit/editor-plugin-selection-toolbar 11.0.12 → 11.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/selectionToolbarPlugin.js +53 -23
- package/dist/es2019/selectionToolbarPlugin.js +53 -23
- package/dist/esm/selectionToolbarPlugin.js +53 -23
- package/dist/types/selectionToolbarPluginType.d.ts +8 -0
- package/dist/types-ts4.5/selectionToolbarPluginType.d.ts +8 -0
- package/editor-plugin-selection-toolbar.docs.tsx +5 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-toolbar
|
|
2
2
|
|
|
3
|
+
## 11.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 11.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`20c2faf5c3ca8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/20c2faf5c3ca8) -
|
|
14
|
+
CONFCLOUD-84107 add override for user preference
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 11.0.12
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -14,6 +14,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
|
14
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
18
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
19
|
var _commands = require("./pm-plugins/commands");
|
|
19
20
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
@@ -77,48 +78,77 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
77
78
|
return {
|
|
78
79
|
name: 'selectionToolbar',
|
|
79
80
|
actions: {
|
|
81
|
+
/**
|
|
82
|
+
* Overrides the user's toolbar docking position preference programmatically,
|
|
83
|
+
* bypassing the normal user-driven preference update flow.
|
|
84
|
+
*/
|
|
85
|
+
overrideToolbarDocking: function overrideToolbarDocking(toolbarDocking) {
|
|
86
|
+
var _api$userPreferences, _api$core$actions$exe;
|
|
87
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_user_preference_override', 'isEnabled', true)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
var command = api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.commands.overrideUserPreference('toolbarDockingPosition', toolbarDocking);
|
|
91
|
+
if (!command) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(command)) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* Clears the toolbar docking override and reverts to the current preference/state value.
|
|
98
|
+
*/
|
|
99
|
+
clearToolbarDockingOverride: function clearToolbarDockingOverride() {
|
|
100
|
+
var _api$userPreferences2, _api$core$actions$exe2;
|
|
101
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_user_preference_override', 'isEnabled', true)) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
var command = api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 ? void 0 : _api$userPreferences2.commands.clearOverrideUserPreference('toolbarDockingPosition');
|
|
105
|
+
if (!command) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(command)) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
109
|
+
},
|
|
80
110
|
suppressToolbar: function suppressToolbar() {
|
|
81
|
-
var _api$core$actions$
|
|
82
|
-
return (_api$core$actions$
|
|
111
|
+
var _api$core$actions$exe3;
|
|
112
|
+
return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.toggleToolbar)({
|
|
83
113
|
hide: true
|
|
84
|
-
}))) !== null && _api$core$actions$
|
|
114
|
+
}))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
|
|
85
115
|
},
|
|
86
116
|
unsuppressToolbar: function unsuppressToolbar() {
|
|
87
|
-
var _api$core$actions$
|
|
88
|
-
return (_api$core$actions$
|
|
117
|
+
var _api$core$actions$exe4;
|
|
118
|
+
return (_api$core$actions$exe4 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.toggleToolbar)({
|
|
89
119
|
hide: false
|
|
90
|
-
}))) !== null && _api$core$actions$
|
|
120
|
+
}))) !== null && _api$core$actions$exe4 !== void 0 ? _api$core$actions$exe4 : false;
|
|
91
121
|
},
|
|
92
122
|
setToolbarDocking: function setToolbarDocking(toolbarDocking) {
|
|
93
|
-
var _api$core$actions$
|
|
123
|
+
var _api$core$actions$exe6, _api$analytics;
|
|
94
124
|
if ((0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin')) {
|
|
95
|
-
var _api$core$actions$
|
|
96
|
-
return (_api$core$actions$
|
|
125
|
+
var _api$core$actions$exe5, _api$userPreferences3;
|
|
126
|
+
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;
|
|
97
127
|
}
|
|
98
|
-
return (_api$core$actions$
|
|
128
|
+
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.setToolbarDocking)({
|
|
99
129
|
toolbarDocking: toolbarDocking,
|
|
100
130
|
userPreferencesProvider: userPreferencesProvider,
|
|
101
131
|
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
102
|
-
}))) !== null && _api$core$actions$
|
|
132
|
+
}))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
103
133
|
},
|
|
104
134
|
forceToolbarDockingWithoutAnalytics: function forceToolbarDockingWithoutAnalytics(toolbarDocking) {
|
|
105
|
-
var _api$core$actions$
|
|
135
|
+
var _api$core$actions$exe8;
|
|
106
136
|
if ((0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin')) {
|
|
107
|
-
var _api$core$actions$
|
|
108
|
-
return (_api$core$actions$
|
|
137
|
+
var _api$core$actions$exe7, _api$userPreferences4;
|
|
138
|
+
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;
|
|
109
139
|
}
|
|
110
|
-
return (_api$core$actions$
|
|
140
|
+
return (_api$core$actions$exe8 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.forceToolbarDockingWithoutAnalytics)({
|
|
111
141
|
toolbarDocking: toolbarDocking,
|
|
112
142
|
userPreferencesProvider: userPreferencesProvider
|
|
113
|
-
}))) !== null && _api$core$actions$
|
|
143
|
+
}))) !== null && _api$core$actions$exe8 !== void 0 ? _api$core$actions$exe8 : false;
|
|
114
144
|
},
|
|
115
145
|
refreshToolbarDocking: function refreshToolbarDocking() {
|
|
116
146
|
if (userPreferencesProvider) {
|
|
117
|
-
var _api$core$actions$
|
|
147
|
+
var _api$core$actions$exe9;
|
|
118
148
|
var userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
119
|
-
return (_api$core$actions$
|
|
149
|
+
return (_api$core$actions$exe9 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.updateToolbarDocking)({
|
|
120
150
|
toolbarDocking: userToolbarDockingPref
|
|
121
|
-
}))) !== null && _api$core$actions$
|
|
151
|
+
}))) !== null && _api$core$actions$exe9 !== void 0 ? _api$core$actions$exe9 : false;
|
|
122
152
|
}
|
|
123
153
|
return false;
|
|
124
154
|
}
|
|
@@ -130,11 +160,11 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
130
160
|
return _pluginKey.selectionToolbarPluginKey.getState(editorState);
|
|
131
161
|
},
|
|
132
162
|
pmPlugins: function pmPlugins(selectionToolbarHandlers) {
|
|
133
|
-
var _api$
|
|
163
|
+
var _api$userPreferences5;
|
|
134
164
|
if (selectionToolbarHandlers) {
|
|
135
165
|
__selectionToolbarHandlers.push.apply(__selectionToolbarHandlers, (0, _toConsumableArray2.default)(selectionToolbarHandlers));
|
|
136
166
|
}
|
|
137
|
-
var initialToolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? getToolbarDockingV2(contextualFormattingEnabled, api === null || api === void 0 || (_api$
|
|
167
|
+
var initialToolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? 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) : getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
138
168
|
return [{
|
|
139
169
|
name: 'selection-tracker',
|
|
140
170
|
plugin: function plugin() {
|
|
@@ -338,8 +368,8 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
338
368
|
}
|
|
339
369
|
}
|
|
340
370
|
if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
|
|
341
|
-
var _api$
|
|
342
|
-
var toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences && (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$
|
|
371
|
+
var _api$userPreferences6;
|
|
372
|
+
var toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences && (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? 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;
|
|
343
373
|
items.push.apply(items, (0, _toConsumableArray2.default)((0, _pinToolbarConfig.getPinOptionToolbarConfig)({
|
|
344
374
|
api: api,
|
|
345
375
|
toolbarDocking: toolbarDockingPref,
|
|
@@ -5,6 +5,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
5
5
|
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionOnCellSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
10
|
import { setToolbarDocking, toggleToolbar, updateToolbarDocking, forceToolbarDockingWithoutAnalytics } from './pm-plugins/commands';
|
|
10
11
|
import { selectionToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
@@ -70,48 +71,77 @@ export const selectionToolbarPlugin = ({
|
|
|
70
71
|
return {
|
|
71
72
|
name: 'selectionToolbar',
|
|
72
73
|
actions: {
|
|
74
|
+
/**
|
|
75
|
+
* Overrides the user's toolbar docking position preference programmatically,
|
|
76
|
+
* bypassing the normal user-driven preference update flow.
|
|
77
|
+
*/
|
|
78
|
+
overrideToolbarDocking: toolbarDocking => {
|
|
79
|
+
var _api$userPreferences, _api$core$actions$exe;
|
|
80
|
+
if (!expValEquals('platform_editor_user_preference_override', 'isEnabled', true)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const command = api === null || api === void 0 ? void 0 : (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.commands.overrideUserPreference('toolbarDockingPosition', toolbarDocking);
|
|
84
|
+
if (!command) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(command)) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Clears the toolbar docking override and reverts to the current preference/state value.
|
|
91
|
+
*/
|
|
92
|
+
clearToolbarDockingOverride: () => {
|
|
93
|
+
var _api$userPreferences2, _api$core$actions$exe2;
|
|
94
|
+
if (!expValEquals('platform_editor_user_preference_override', 'isEnabled', true)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const command = api === null || api === void 0 ? void 0 : (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 ? void 0 : _api$userPreferences2.commands.clearOverrideUserPreference('toolbarDockingPosition');
|
|
98
|
+
if (!command) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(command)) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
102
|
+
},
|
|
73
103
|
suppressToolbar: () => {
|
|
74
|
-
var _api$core$actions$
|
|
75
|
-
return (_api$core$actions$
|
|
104
|
+
var _api$core$actions$exe3;
|
|
105
|
+
return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute(toggleToolbar({
|
|
76
106
|
hide: true
|
|
77
|
-
}))) !== null && _api$core$actions$
|
|
107
|
+
}))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
|
|
78
108
|
},
|
|
79
109
|
unsuppressToolbar: () => {
|
|
80
|
-
var _api$core$actions$
|
|
81
|
-
return (_api$core$actions$
|
|
110
|
+
var _api$core$actions$exe4;
|
|
111
|
+
return (_api$core$actions$exe4 = api === null || api === void 0 ? void 0 : api.core.actions.execute(toggleToolbar({
|
|
82
112
|
hide: false
|
|
83
|
-
}))) !== null && _api$core$actions$
|
|
113
|
+
}))) !== null && _api$core$actions$exe4 !== void 0 ? _api$core$actions$exe4 : false;
|
|
84
114
|
},
|
|
85
115
|
setToolbarDocking: toolbarDocking => {
|
|
86
|
-
var _api$core$actions$
|
|
116
|
+
var _api$core$actions$exe6, _api$analytics;
|
|
87
117
|
if (fg('platform_editor_use_preferences_plugin')) {
|
|
88
|
-
var _api$core$actions$
|
|
89
|
-
return (_api$core$actions$
|
|
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 ? 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;
|
|
90
120
|
}
|
|
91
|
-
return (_api$core$actions$
|
|
121
|
+
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute(setToolbarDocking({
|
|
92
122
|
toolbarDocking,
|
|
93
123
|
userPreferencesProvider,
|
|
94
124
|
editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
95
|
-
}))) !== null && _api$core$actions$
|
|
125
|
+
}))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
96
126
|
},
|
|
97
127
|
forceToolbarDockingWithoutAnalytics: toolbarDocking => {
|
|
98
|
-
var _api$core$actions$
|
|
128
|
+
var _api$core$actions$exe8;
|
|
99
129
|
if (fg('platform_editor_use_preferences_plugin')) {
|
|
100
|
-
var _api$core$actions$
|
|
101
|
-
return (_api$core$actions$
|
|
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 ? 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;
|
|
102
132
|
}
|
|
103
|
-
return (_api$core$actions$
|
|
133
|
+
return (_api$core$actions$exe8 = api === null || api === void 0 ? void 0 : api.core.actions.execute(forceToolbarDockingWithoutAnalytics({
|
|
104
134
|
toolbarDocking,
|
|
105
135
|
userPreferencesProvider
|
|
106
|
-
}))) !== null && _api$core$actions$
|
|
136
|
+
}))) !== null && _api$core$actions$exe8 !== void 0 ? _api$core$actions$exe8 : false;
|
|
107
137
|
},
|
|
108
138
|
refreshToolbarDocking: () => {
|
|
109
139
|
if (userPreferencesProvider) {
|
|
110
|
-
var _api$core$actions$
|
|
140
|
+
var _api$core$actions$exe9;
|
|
111
141
|
const userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
112
|
-
return (_api$core$actions$
|
|
142
|
+
return (_api$core$actions$exe9 = api === null || api === void 0 ? void 0 : api.core.actions.execute(updateToolbarDocking({
|
|
113
143
|
toolbarDocking: userToolbarDockingPref
|
|
114
|
-
}))) !== null && _api$core$actions$
|
|
144
|
+
}))) !== null && _api$core$actions$exe9 !== void 0 ? _api$core$actions$exe9 : false;
|
|
115
145
|
}
|
|
116
146
|
return false;
|
|
117
147
|
}
|
|
@@ -123,11 +153,11 @@ export const selectionToolbarPlugin = ({
|
|
|
123
153
|
return selectionToolbarPluginKey.getState(editorState);
|
|
124
154
|
},
|
|
125
155
|
pmPlugins(selectionToolbarHandlers) {
|
|
126
|
-
var _api$
|
|
156
|
+
var _api$userPreferences5, _api$userPreferences6, _api$userPreferences7;
|
|
127
157
|
if (selectionToolbarHandlers) {
|
|
128
158
|
__selectionToolbarHandlers.push(...selectionToolbarHandlers);
|
|
129
159
|
}
|
|
130
|
-
const initialToolbarDocking = fg('platform_editor_use_preferences_plugin') ? getToolbarDockingV2(contextualFormattingEnabled, api === null || api === void 0 ? void 0 : (_api$
|
|
160
|
+
const initialToolbarDocking = fg('platform_editor_use_preferences_plugin') ? 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) : getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
131
161
|
return [{
|
|
132
162
|
name: 'selection-tracker',
|
|
133
163
|
plugin: () => {
|
|
@@ -333,8 +363,8 @@ export const selectionToolbarPlugin = ({
|
|
|
333
363
|
}
|
|
334
364
|
}
|
|
335
365
|
if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
|
|
336
|
-
var _api$
|
|
337
|
-
const toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences && fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 ? void 0 : (_api$
|
|
366
|
+
var _api$userPreferences8, _api$userPreferences9, _api$userPreferences0;
|
|
367
|
+
const toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences && fg('platform_editor_use_preferences_plugin') ? 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;
|
|
338
368
|
items.push(...getPinOptionToolbarConfig({
|
|
339
369
|
api,
|
|
340
370
|
toolbarDocking: toolbarDockingPref,
|
|
@@ -9,6 +9,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
9
9
|
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionOnCellSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
14
|
import { setToolbarDocking as _setToolbarDocking, toggleToolbar, updateToolbarDocking, forceToolbarDockingWithoutAnalytics as _forceToolbarDockingWithoutAnalytics } from './pm-plugins/commands';
|
|
14
15
|
import { selectionToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
@@ -70,48 +71,77 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
70
71
|
return {
|
|
71
72
|
name: 'selectionToolbar',
|
|
72
73
|
actions: {
|
|
74
|
+
/**
|
|
75
|
+
* Overrides the user's toolbar docking position preference programmatically,
|
|
76
|
+
* bypassing the normal user-driven preference update flow.
|
|
77
|
+
*/
|
|
78
|
+
overrideToolbarDocking: function overrideToolbarDocking(toolbarDocking) {
|
|
79
|
+
var _api$userPreferences, _api$core$actions$exe;
|
|
80
|
+
if (!expValEquals('platform_editor_user_preference_override', 'isEnabled', true)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
var command = api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.commands.overrideUserPreference('toolbarDockingPosition', toolbarDocking);
|
|
84
|
+
if (!command) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(command)) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Clears the toolbar docking override and reverts to the current preference/state value.
|
|
91
|
+
*/
|
|
92
|
+
clearToolbarDockingOverride: function clearToolbarDockingOverride() {
|
|
93
|
+
var _api$userPreferences2, _api$core$actions$exe2;
|
|
94
|
+
if (!expValEquals('platform_editor_user_preference_override', 'isEnabled', true)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
var command = api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 ? void 0 : _api$userPreferences2.commands.clearOverrideUserPreference('toolbarDockingPosition');
|
|
98
|
+
if (!command) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(command)) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
|
|
102
|
+
},
|
|
73
103
|
suppressToolbar: function suppressToolbar() {
|
|
74
|
-
var _api$core$actions$
|
|
75
|
-
return (_api$core$actions$
|
|
104
|
+
var _api$core$actions$exe3;
|
|
105
|
+
return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute(toggleToolbar({
|
|
76
106
|
hide: true
|
|
77
|
-
}))) !== null && _api$core$actions$
|
|
107
|
+
}))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
|
|
78
108
|
},
|
|
79
109
|
unsuppressToolbar: function unsuppressToolbar() {
|
|
80
|
-
var _api$core$actions$
|
|
81
|
-
return (_api$core$actions$
|
|
110
|
+
var _api$core$actions$exe4;
|
|
111
|
+
return (_api$core$actions$exe4 = api === null || api === void 0 ? void 0 : api.core.actions.execute(toggleToolbar({
|
|
82
112
|
hide: false
|
|
83
|
-
}))) !== null && _api$core$actions$
|
|
113
|
+
}))) !== null && _api$core$actions$exe4 !== void 0 ? _api$core$actions$exe4 : false;
|
|
84
114
|
},
|
|
85
115
|
setToolbarDocking: function setToolbarDocking(toolbarDocking) {
|
|
86
|
-
var _api$core$actions$
|
|
116
|
+
var _api$core$actions$exe6, _api$analytics;
|
|
87
117
|
if (fg('platform_editor_use_preferences_plugin')) {
|
|
88
|
-
var _api$core$actions$
|
|
89
|
-
return (_api$core$actions$
|
|
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;
|
|
90
120
|
}
|
|
91
|
-
return (_api$core$actions$
|
|
121
|
+
return (_api$core$actions$exe6 = api === null || api === void 0 ? void 0 : api.core.actions.execute(_setToolbarDocking({
|
|
92
122
|
toolbarDocking: toolbarDocking,
|
|
93
123
|
userPreferencesProvider: userPreferencesProvider,
|
|
94
124
|
editorAnalyticsApi: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
95
|
-
}))) !== null && _api$core$actions$
|
|
125
|
+
}))) !== null && _api$core$actions$exe6 !== void 0 ? _api$core$actions$exe6 : false;
|
|
96
126
|
},
|
|
97
127
|
forceToolbarDockingWithoutAnalytics: function forceToolbarDockingWithoutAnalytics(toolbarDocking) {
|
|
98
|
-
var _api$core$actions$
|
|
128
|
+
var _api$core$actions$exe8;
|
|
99
129
|
if (fg('platform_editor_use_preferences_plugin')) {
|
|
100
|
-
var _api$core$actions$
|
|
101
|
-
return (_api$core$actions$
|
|
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;
|
|
102
132
|
}
|
|
103
|
-
return (_api$core$actions$
|
|
133
|
+
return (_api$core$actions$exe8 = api === null || api === void 0 ? void 0 : api.core.actions.execute(_forceToolbarDockingWithoutAnalytics({
|
|
104
134
|
toolbarDocking: toolbarDocking,
|
|
105
135
|
userPreferencesProvider: userPreferencesProvider
|
|
106
|
-
}))) !== null && _api$core$actions$
|
|
136
|
+
}))) !== null && _api$core$actions$exe8 !== void 0 ? _api$core$actions$exe8 : false;
|
|
107
137
|
},
|
|
108
138
|
refreshToolbarDocking: function refreshToolbarDocking() {
|
|
109
139
|
if (userPreferencesProvider) {
|
|
110
|
-
var _api$core$actions$
|
|
140
|
+
var _api$core$actions$exe9;
|
|
111
141
|
var userToolbarDockingPref = getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
112
|
-
return (_api$core$actions$
|
|
142
|
+
return (_api$core$actions$exe9 = api === null || api === void 0 ? void 0 : api.core.actions.execute(updateToolbarDocking({
|
|
113
143
|
toolbarDocking: userToolbarDockingPref
|
|
114
|
-
}))) !== null && _api$core$actions$
|
|
144
|
+
}))) !== null && _api$core$actions$exe9 !== void 0 ? _api$core$actions$exe9 : false;
|
|
115
145
|
}
|
|
116
146
|
return false;
|
|
117
147
|
}
|
|
@@ -123,11 +153,11 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
123
153
|
return selectionToolbarPluginKey.getState(editorState);
|
|
124
154
|
},
|
|
125
155
|
pmPlugins: function pmPlugins(selectionToolbarHandlers) {
|
|
126
|
-
var _api$
|
|
156
|
+
var _api$userPreferences5;
|
|
127
157
|
if (selectionToolbarHandlers) {
|
|
128
158
|
__selectionToolbarHandlers.push.apply(__selectionToolbarHandlers, _toConsumableArray(selectionToolbarHandlers));
|
|
129
159
|
}
|
|
130
|
-
var initialToolbarDocking = fg('platform_editor_use_preferences_plugin') ? getToolbarDockingV2(contextualFormattingEnabled, api === null || api === void 0 || (_api$
|
|
160
|
+
var initialToolbarDocking = fg('platform_editor_use_preferences_plugin') ? 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) : getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
|
|
131
161
|
return [{
|
|
132
162
|
name: 'selection-tracker',
|
|
133
163
|
plugin: function plugin() {
|
|
@@ -331,8 +361,8 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
331
361
|
}
|
|
332
362
|
}
|
|
333
363
|
if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
|
|
334
|
-
var _api$
|
|
335
|
-
var toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences && fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$
|
|
364
|
+
var _api$userPreferences6;
|
|
365
|
+
var toolbarDockingPref = api !== null && api !== void 0 && api.userPreferences && fg('platform_editor_use_preferences_plugin') ? 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;
|
|
336
366
|
items.push.apply(items, _toConsumableArray(getPinOptionToolbarConfig({
|
|
337
367
|
api: api,
|
|
338
368
|
toolbarDocking: toolbarDockingPref,
|
|
@@ -28,7 +28,15 @@ export type SelectionToolbarPluginOptions = {
|
|
|
28
28
|
};
|
|
29
29
|
export type SelectionToolbarPlugin = NextEditorPlugin<'selectionToolbar', {
|
|
30
30
|
actions?: {
|
|
31
|
+
/**
|
|
32
|
+
* Clears the toolbar docking override and reverts to the current preference/state value.
|
|
33
|
+
*/
|
|
34
|
+
clearToolbarDockingOverride?: () => boolean;
|
|
31
35
|
forceToolbarDockingWithoutAnalytics?: (toolbarDocking: ToolbarDocking) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Temporarily overrides the toolbar docking position without persisting to user preferences.
|
|
38
|
+
*/
|
|
39
|
+
overrideToolbarDocking?: (toolbarDocking: ToolbarDocking) => boolean;
|
|
32
40
|
/**
|
|
33
41
|
* @private
|
|
34
42
|
* @deprecated not in use
|
|
@@ -28,7 +28,15 @@ export type SelectionToolbarPluginOptions = {
|
|
|
28
28
|
};
|
|
29
29
|
export type SelectionToolbarPlugin = NextEditorPlugin<'selectionToolbar', {
|
|
30
30
|
actions?: {
|
|
31
|
+
/**
|
|
32
|
+
* Clears the toolbar docking override and reverts to the current preference/state value.
|
|
33
|
+
*/
|
|
34
|
+
clearToolbarDockingOverride?: () => boolean;
|
|
31
35
|
forceToolbarDockingWithoutAnalytics?: (toolbarDocking: ToolbarDocking) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Temporarily overrides the toolbar docking position without persisting to user preferences.
|
|
38
|
+
*/
|
|
39
|
+
overrideToolbarDocking?: (toolbarDocking: ToolbarDocking) => boolean;
|
|
32
40
|
/**
|
|
33
41
|
* @private
|
|
34
42
|
* @deprecated not in use
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
import type { ComponentStructuredContentSource } from '@atlassian/structured-docs-types';
|
|
10
9
|
|
|
11
10
|
import packageJson from './package.json';
|
|
@@ -30,7 +29,11 @@ const documentation: ComponentStructuredContentSource[] = [
|
|
|
30
29
|
keywords: ['editor', 'editor-plugin-selection-toolbar', 'atlaskit'],
|
|
31
30
|
categories: ['editor'],
|
|
32
31
|
examples: [
|
|
33
|
-
{
|
|
32
|
+
{
|
|
33
|
+
name: 'Basic',
|
|
34
|
+
description: 'Selection toolbar plugin in editor.',
|
|
35
|
+
source: path.resolve(packagePath, './examples/1-basic.tsx'),
|
|
36
|
+
},
|
|
34
37
|
],
|
|
35
38
|
},
|
|
36
39
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-toolbar",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.1.1",
|
|
4
4
|
"description": "@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@atlaskit/editor-plugin-editor-viewmode": "^12.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-primary-toolbar": "^11.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-toolbar": "^7.0.0",
|
|
39
|
-
"@atlaskit/editor-plugin-user-intent": "^8.
|
|
40
|
-
"@atlaskit/editor-plugin-user-preferences": "^8.
|
|
39
|
+
"@atlaskit/editor-plugin-user-intent": "^8.1.0",
|
|
40
|
+
"@atlaskit/editor-plugin-user-preferences": "^8.1.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
42
42
|
"@atlaskit/editor-toolbar": "^1.0.0",
|
|
43
43
|
"@atlaskit/editor-toolbar-model": "^0.4.0",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"@atlaskit/icon-lab": "^6.6.0",
|
|
46
46
|
"@atlaskit/menu": "^8.5.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^75.0.0",
|
|
49
49
|
"@atlaskit/tokens": "^13.0.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"bind-event-listener": "^3.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@atlaskit/editor-common": "^114.
|
|
54
|
+
"@atlaskit/editor-common": "^114.19.0",
|
|
55
55
|
"react": "^18.2.0",
|
|
56
56
|
"react-dom": "^18.2.0",
|
|
57
57
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|