@atlaskit/editor-plugin-selection-extension 6.0.13 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/pm-plugins/utils/index.js +1 -1
- package/dist/cjs/selectionExtensionPlugin.js +26 -66
- package/dist/cjs/ui/extensions.js +2 -2
- package/dist/cjs/ui/selectionToolbar.js +1 -2
- package/dist/es2019/pm-plugins/utils/index.js +1 -1
- package/dist/es2019/selectionExtensionPlugin.js +27 -66
- package/dist/es2019/ui/extensions.js +2 -2
- package/dist/es2019/ui/selectionToolbar.js +1 -2
- package/dist/esm/pm-plugins/utils/index.js +1 -1
- package/dist/esm/selectionExtensionPlugin.js +26 -66
- package/dist/esm/ui/extensions.js +2 -2
- package/dist/esm/ui/selectionToolbar.js +1 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/selectionExtensionPluginType.d.ts +2 -2
- package/dist/types/types/index.d.ts +2 -11
- package/dist/types/ui/extensions.d.ts +4 -4
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/selectionExtensionPluginType.d.ts +2 -2
- package/dist/types-ts4.5/types/index.d.ts +2 -11
- package/dist/types-ts4.5/ui/extensions.d.ts +4 -4
- package/package.json +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 7.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`d152779f27d4f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d152779f27d4f) -
|
|
8
|
+
Clean up feature gate platform_editor_selection_extension_api_v2 and unused code for extension
|
|
9
|
+
config as callback
|
|
10
|
+
|
|
3
11
|
## 6.0.13
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -73,7 +73,7 @@ var getSelectionTextInfo = exports.getSelectionTextInfo = function getSelectionT
|
|
|
73
73
|
var currentSelection = view.state.selection;
|
|
74
74
|
var toolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? 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 : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
|
|
75
75
|
var isEditMode = Boolean((api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit');
|
|
76
|
-
var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode
|
|
76
|
+
var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
77
77
|
var from = currentSelection.from,
|
|
78
78
|
to = currentSelection.to;
|
|
79
79
|
var text = view.state.doc.textBetween(from, to, '\n');
|
|
@@ -10,7 +10,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
12
|
var _usePluginStateEffect = require("@atlaskit/editor-common/use-plugin-state-effect");
|
|
13
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
13
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
14
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
16
15
|
var _insertAdfAtEndOfDoc2 = require("./pm-plugins/actions/insertAdfAtEndOfDoc");
|
|
@@ -43,7 +42,7 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
43
42
|
firstParty = _ref3$firstParty === void 0 ? [] : _ref3$firstParty,
|
|
44
43
|
_ref3$external = _ref3.external,
|
|
45
44
|
external = _ref3$external === void 0 ? [] : _ref3$external;
|
|
46
|
-
if (!isToolbarAIFCEnabled
|
|
45
|
+
if (!isToolbarAIFCEnabled) {
|
|
47
46
|
var primaryToolbarItemExtensions = (0, _extensions.getToolbarItemExtensions)(extensionList, 'primaryToolbar');
|
|
48
47
|
if (primaryToolbarItemExtensions !== null && primaryToolbarItemExtensions !== void 0 && primaryToolbarItemExtensions.length) {
|
|
49
48
|
var _api$primaryToolbar;
|
|
@@ -200,6 +199,7 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
200
199
|
}
|
|
201
200
|
var handleOnExtensionClick = function handleOnExtensionClick(view) {
|
|
202
201
|
return function (extension) {
|
|
202
|
+
var _extension$onClick, _api$core;
|
|
203
203
|
var selection = (0, _utils.getSelectionTextInfo)(view, api);
|
|
204
204
|
if (extension.component) {
|
|
205
205
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.selectionExtension.commands.setActiveExtension({
|
|
@@ -207,35 +207,25 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
207
207
|
selection: selection
|
|
208
208
|
}));
|
|
209
209
|
}
|
|
210
|
+
var _getSelectionAdfInfo2 = (0, _utils.getSelectionAdfInfo)(view.state),
|
|
211
|
+
selectedNodeAdf = _getSelectionAdfInfo2.selectedNodeAdf,
|
|
212
|
+
selectionRanges = _getSelectionAdfInfo2.selectionRanges,
|
|
213
|
+
selectedNode = _getSelectionAdfInfo2.selectedNode,
|
|
214
|
+
nodePos = _getSelectionAdfInfo2.nodePos;
|
|
210
215
|
var onClickCallbackOptions = {
|
|
211
|
-
|
|
216
|
+
selectedNodeAdf: selectedNodeAdf,
|
|
217
|
+
selectionRanges: selectionRanges
|
|
212
218
|
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
var
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
selectedNode
|
|
219
|
-
nodePos
|
|
220
|
-
onClickCallbackOptions = {
|
|
221
|
-
selectedNodeAdf: selectedNodeAdf,
|
|
222
|
-
selectionRanges: selectionRanges
|
|
223
|
-
};
|
|
224
|
-
(_extension$onClick = extension.onClick) === null || _extension$onClick === void 0 || _extension$onClick.call(extension, onClickCallbackOptions);
|
|
225
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref8) {
|
|
226
|
-
var tr = _ref8.tr;
|
|
227
|
-
tr.setMeta(_main.selectionExtensionPluginKey, {
|
|
228
|
-
type: _types.SelectionExtensionActionTypes.SET_SELECTED_NODE,
|
|
229
|
-
selectedNode: selectedNode,
|
|
230
|
-
nodePos: nodePos
|
|
231
|
-
});
|
|
232
|
-
return tr;
|
|
219
|
+
(_extension$onClick = extension.onClick) === null || _extension$onClick === void 0 || _extension$onClick.call(extension, onClickCallbackOptions);
|
|
220
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref8) {
|
|
221
|
+
var tr = _ref8.tr;
|
|
222
|
+
tr.setMeta(_main.selectionExtensionPluginKey, {
|
|
223
|
+
type: _types.SelectionExtensionActionTypes.SET_SELECTED_NODE,
|
|
224
|
+
selectedNode: selectedNode,
|
|
225
|
+
nodePos: nodePos
|
|
233
226
|
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
extension.onClick(onClickCallbackOptions);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
227
|
+
return tr;
|
|
228
|
+
});
|
|
239
229
|
};
|
|
240
230
|
};
|
|
241
231
|
var convertExtensionToDropdownMenuItem = function convertExtensionToDropdownMenuItem(extension, rank) {
|
|
@@ -256,44 +246,18 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
256
246
|
}
|
|
257
247
|
};
|
|
258
248
|
};
|
|
259
|
-
var getConfigFromExtensionCallback = function getConfigFromExtensionCallback(extension) {
|
|
260
|
-
if (typeof extension === 'function') {
|
|
261
|
-
var _getSelectionAdfInfo3 = (0, _utils.getSelectionAdfInfo)(state),
|
|
262
|
-
selectedNodeAdf = _getSelectionAdfInfo3.selectedNodeAdf,
|
|
263
|
-
selectionRanges = _getSelectionAdfInfo3.selectionRanges;
|
|
264
|
-
return extension({
|
|
265
|
-
selectedNodeAdf: selectedNodeAdf,
|
|
266
|
-
selectionRanges: selectionRanges
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return extension;
|
|
270
|
-
};
|
|
271
|
-
var prefilterExtensions = function prefilterExtensions(extensions) {
|
|
272
|
-
// this is to prevent integration issues when passing in a function as an extension
|
|
273
|
-
// but not having platform_editor_selection_extension_api_v2 FG on
|
|
274
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_selection_extension_api_v2')) {
|
|
275
|
-
return extensions.filter(function (ext) {
|
|
276
|
-
return typeof ext !== 'function';
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
return extensions;
|
|
280
|
-
};
|
|
281
249
|
var getFirstPartyExtensions = function getFirstPartyExtensions(extensions) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
var ext = (0, _platformFeatureFlags.fg)('platform_editor_selection_extension_api_v2') ? getConfigFromExtensionCallback(extension) : extension;
|
|
285
|
-
return convertExtensionToDropdownMenuItem(ext, 30);
|
|
250
|
+
return extensions.map(function (extension) {
|
|
251
|
+
return convertExtensionToDropdownMenuItem(extension, 30);
|
|
286
252
|
});
|
|
287
253
|
};
|
|
288
254
|
|
|
289
255
|
// Add a heading to the external extensions
|
|
290
256
|
var getExternalExtensions = function getExternalExtensions(extensions) {
|
|
291
|
-
var prefilteredExtensions = prefilterExtensions(extensions);
|
|
292
257
|
var externalExtensions = [];
|
|
293
|
-
if (
|
|
294
|
-
externalExtensions =
|
|
295
|
-
|
|
296
|
-
return convertExtensionToDropdownMenuItem(ext);
|
|
258
|
+
if (extensions !== null && extensions !== void 0 && extensions.length) {
|
|
259
|
+
externalExtensions = extensions.map(function (extension) {
|
|
260
|
+
return convertExtensionToDropdownMenuItem(extension);
|
|
297
261
|
});
|
|
298
262
|
var externalExtensionsHeading = {
|
|
299
263
|
type: 'overflow-dropdown-heading',
|
|
@@ -306,18 +270,14 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
306
270
|
|
|
307
271
|
// NEXT PR: Make sure we cache the whole generated selection toolbar
|
|
308
272
|
// also debug this to make sure it's actually preventing unnecessary re-renders / work
|
|
309
|
-
if (cachedOverflowMenuOptions && state.selection.eq(cachedSelection)
|
|
273
|
+
if (cachedOverflowMenuOptions && state.selection.eq(cachedSelection)) {
|
|
310
274
|
return (0, _selectionToolbar.selectionToolbar)({
|
|
311
275
|
overflowOptions: cachedOverflowMenuOptions,
|
|
312
276
|
extensionList: extensionList
|
|
313
277
|
});
|
|
314
278
|
}
|
|
315
|
-
var allFirstParty = (0, _toConsumableArray2.default)(firstParty);
|
|
316
|
-
var allExternal = (0, _toConsumableArray2.default)(external);
|
|
317
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_selection_extension_api_v2')) {
|
|
318
|
-
allFirstParty = [].concat((0, _toConsumableArray2.default)(firstParty), (0, _toConsumableArray2.default)((0, _extensions.getMenuItemExtensions)(extensionList, 'first-party')));
|
|
319
|
-
allExternal = [].concat((0, _toConsumableArray2.default)(external), (0, _toConsumableArray2.default)((0, _extensions.getMenuItemExtensions)(extensionList, 'external')));
|
|
320
|
-
}
|
|
279
|
+
var allFirstParty = [].concat((0, _toConsumableArray2.default)(firstParty), (0, _toConsumableArray2.default)((0, _extensions.getMenuItemExtensions)(extensionList, 'first-party')));
|
|
280
|
+
var allExternal = [].concat((0, _toConsumableArray2.default)(external), (0, _toConsumableArray2.default)((0, _extensions.getMenuItemExtensions)(extensionList, 'external')));
|
|
321
281
|
var groupedExtensionsArray = [].concat((0, _toConsumableArray2.default)(getFirstPartyExtensions(allFirstParty)), (0, _toConsumableArray2.default)(getExternalExtensions(allExternal)));
|
|
322
282
|
cachedOverflowMenuOptions = groupedExtensionsArray;
|
|
323
283
|
cachedSelection = state.selection;
|
|
@@ -30,11 +30,11 @@ var getToolbarItemExtensions = exports.getToolbarItemExtensions = function getTo
|
|
|
30
30
|
* From the full list of extensions, extract only those that have a menu item configuration
|
|
31
31
|
* for the specified source (either 'first-party' or 'external').
|
|
32
32
|
*
|
|
33
|
-
* Map each to the legacy format for
|
|
33
|
+
* Map each to the legacy format for SelectionExtension.
|
|
34
34
|
*
|
|
35
35
|
* @param extensionList - List of all extensions
|
|
36
36
|
* @param targetSource - Source of the extensions ('first-party' or 'external')
|
|
37
|
-
* @returns Array of
|
|
37
|
+
* @returns Array of SelectionExtension objects
|
|
38
38
|
* @example
|
|
39
39
|
*/
|
|
40
40
|
var getMenuItemExtensions = exports.getMenuItemExtensions = function getMenuItemExtensions(extensionList, targetSource) {
|
|
@@ -7,14 +7,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.selectionToolbar = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
var _extensions = require("./extensions");
|
|
12
11
|
var _LegacyToolbarComponent = require("./LegacyToolbarComponent");
|
|
13
12
|
var selectionToolbar = exports.selectionToolbar = function selectionToolbar(_ref) {
|
|
14
13
|
var overflowOptions = _ref.overflowOptions,
|
|
15
14
|
_ref$extensionList = _ref.extensionList,
|
|
16
15
|
extensionList = _ref$extensionList === void 0 ? [] : _ref$extensionList;
|
|
17
|
-
var inlineToolbarItemExtensions = (0,
|
|
16
|
+
var inlineToolbarItemExtensions = (0, _extensions.getToolbarItemExtensions)(extensionList, 'inlineToolbar');
|
|
18
17
|
return {
|
|
19
18
|
items: [].concat((0, _toConsumableArray2.default)(inlineToolbarItemExtensions.length ? [{
|
|
20
19
|
type: 'separator',
|
|
@@ -66,7 +66,7 @@ export const getSelectionTextInfo = (view, api) => {
|
|
|
66
66
|
} = view.state;
|
|
67
67
|
const toolbarDocking = fg('platform_editor_use_preferences_plugin') ? 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 : api === null || api === void 0 ? void 0 : (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 ? void 0 : (_api$selectionToolbar2 = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.currentState()) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.toolbarDocking;
|
|
68
68
|
const isEditMode = Boolean((api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'edit');
|
|
69
|
-
const shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode
|
|
69
|
+
const shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
70
70
|
const {
|
|
71
71
|
from,
|
|
72
72
|
to
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { selectionExtensionMessages } from '@atlaskit/editor-common/messages';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
6
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
8
7
|
import { insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
@@ -34,7 +33,7 @@ export const selectionExtensionPlugin = ({
|
|
|
34
33
|
firstParty = [],
|
|
35
34
|
external = []
|
|
36
35
|
} = extensions || {};
|
|
37
|
-
if (!isToolbarAIFCEnabled
|
|
36
|
+
if (!isToolbarAIFCEnabled) {
|
|
38
37
|
const primaryToolbarItemExtensions = getToolbarItemExtensions(extensionList, 'primaryToolbar');
|
|
39
38
|
if (primaryToolbarItemExtensions !== null && primaryToolbarItemExtensions !== void 0 && primaryToolbarItemExtensions.length) {
|
|
40
39
|
var _api$primaryToolbar, _api$primaryToolbar$a;
|
|
@@ -198,6 +197,7 @@ export const selectionExtensionPlugin = ({
|
|
|
198
197
|
return;
|
|
199
198
|
}
|
|
200
199
|
const handleOnExtensionClick = view => extension => {
|
|
200
|
+
var _extension$onClick, _api$core;
|
|
201
201
|
const selection = getSelectionTextInfo(view, api);
|
|
202
202
|
if (extension.component) {
|
|
203
203
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.selectionExtension.commands.setActiveExtension({
|
|
@@ -205,37 +205,27 @@ export const selectionExtensionPlugin = ({
|
|
|
205
205
|
selection
|
|
206
206
|
}));
|
|
207
207
|
}
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
const {
|
|
209
|
+
selectedNodeAdf,
|
|
210
|
+
selectionRanges,
|
|
211
|
+
selectedNode,
|
|
212
|
+
nodePos
|
|
213
|
+
} = getSelectionAdfInfo(view.state);
|
|
214
|
+
const onClickCallbackOptions = {
|
|
215
|
+
selectedNodeAdf,
|
|
216
|
+
selectionRanges
|
|
210
217
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
(_extension$onClick = extension.onClick) === null || _extension$onClick === void 0 ? void 0 : _extension$onClick.call(extension, onClickCallbackOptions);
|
|
219
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
220
|
+
tr
|
|
221
|
+
}) => {
|
|
222
|
+
tr.setMeta(selectionExtensionPluginKey, {
|
|
223
|
+
type: SelectionExtensionActionTypes.SET_SELECTED_NODE,
|
|
216
224
|
selectedNode,
|
|
217
225
|
nodePos
|
|
218
|
-
} = getSelectionAdfInfo(view.state);
|
|
219
|
-
onClickCallbackOptions = {
|
|
220
|
-
selectedNodeAdf,
|
|
221
|
-
selectionRanges
|
|
222
|
-
};
|
|
223
|
-
(_extension$onClick = extension.onClick) === null || _extension$onClick === void 0 ? void 0 : _extension$onClick.call(extension, onClickCallbackOptions);
|
|
224
|
-
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
225
|
-
tr
|
|
226
|
-
}) => {
|
|
227
|
-
tr.setMeta(selectionExtensionPluginKey, {
|
|
228
|
-
type: SelectionExtensionActionTypes.SET_SELECTED_NODE,
|
|
229
|
-
selectedNode,
|
|
230
|
-
nodePos
|
|
231
|
-
});
|
|
232
|
-
return tr;
|
|
233
226
|
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
extension.onClick(onClickCallbackOptions);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
227
|
+
return tr;
|
|
228
|
+
});
|
|
239
229
|
};
|
|
240
230
|
const convertExtensionToDropdownMenuItem = (extension, rank) => {
|
|
241
231
|
var _extension$isDisabled;
|
|
@@ -255,43 +245,18 @@ export const selectionExtensionPlugin = ({
|
|
|
255
245
|
}
|
|
256
246
|
};
|
|
257
247
|
};
|
|
258
|
-
const getConfigFromExtensionCallback = extension => {
|
|
259
|
-
if (typeof extension === 'function') {
|
|
260
|
-
const {
|
|
261
|
-
selectedNodeAdf,
|
|
262
|
-
selectionRanges
|
|
263
|
-
} = getSelectionAdfInfo(state);
|
|
264
|
-
return extension({
|
|
265
|
-
selectedNodeAdf,
|
|
266
|
-
selectionRanges
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return extension;
|
|
270
|
-
};
|
|
271
|
-
const prefilterExtensions = extensions => {
|
|
272
|
-
// this is to prevent integration issues when passing in a function as an extension
|
|
273
|
-
// but not having platform_editor_selection_extension_api_v2 FG on
|
|
274
|
-
if (!fg('platform_editor_selection_extension_api_v2')) {
|
|
275
|
-
return extensions.filter(ext => typeof ext !== 'function');
|
|
276
|
-
}
|
|
277
|
-
return extensions;
|
|
278
|
-
};
|
|
279
248
|
const getFirstPartyExtensions = extensions => {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const ext = fg('platform_editor_selection_extension_api_v2') ? getConfigFromExtensionCallback(extension) : extension;
|
|
283
|
-
return convertExtensionToDropdownMenuItem(ext, 30);
|
|
249
|
+
return extensions.map(extension => {
|
|
250
|
+
return convertExtensionToDropdownMenuItem(extension, 30);
|
|
284
251
|
});
|
|
285
252
|
};
|
|
286
253
|
|
|
287
254
|
// Add a heading to the external extensions
|
|
288
255
|
const getExternalExtensions = extensions => {
|
|
289
|
-
const prefilteredExtensions = prefilterExtensions(extensions);
|
|
290
256
|
let externalExtensions = [];
|
|
291
|
-
if (
|
|
292
|
-
externalExtensions =
|
|
293
|
-
|
|
294
|
-
return convertExtensionToDropdownMenuItem(ext);
|
|
257
|
+
if (extensions !== null && extensions !== void 0 && extensions.length) {
|
|
258
|
+
externalExtensions = extensions.map(extension => {
|
|
259
|
+
return convertExtensionToDropdownMenuItem(extension);
|
|
295
260
|
});
|
|
296
261
|
const externalExtensionsHeading = {
|
|
297
262
|
type: 'overflow-dropdown-heading',
|
|
@@ -304,18 +269,14 @@ export const selectionExtensionPlugin = ({
|
|
|
304
269
|
|
|
305
270
|
// NEXT PR: Make sure we cache the whole generated selection toolbar
|
|
306
271
|
// also debug this to make sure it's actually preventing unnecessary re-renders / work
|
|
307
|
-
if (cachedOverflowMenuOptions && state.selection.eq(cachedSelection)
|
|
272
|
+
if (cachedOverflowMenuOptions && state.selection.eq(cachedSelection)) {
|
|
308
273
|
return selectionToolbar({
|
|
309
274
|
overflowOptions: cachedOverflowMenuOptions,
|
|
310
275
|
extensionList
|
|
311
276
|
});
|
|
312
277
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
if (fg('platform_editor_selection_extension_api_v2')) {
|
|
316
|
-
allFirstParty = [...firstParty, ...getMenuItemExtensions(extensionList, 'first-party')];
|
|
317
|
-
allExternal = [...external, ...getMenuItemExtensions(extensionList, 'external')];
|
|
318
|
-
}
|
|
278
|
+
const allFirstParty = [...firstParty, ...getMenuItemExtensions(extensionList, 'first-party')];
|
|
279
|
+
const allExternal = [...external, ...getMenuItemExtensions(extensionList, 'external')];
|
|
319
280
|
const groupedExtensionsArray = [...getFirstPartyExtensions(allFirstParty), ...getExternalExtensions(allExternal)];
|
|
320
281
|
cachedOverflowMenuOptions = groupedExtensionsArray;
|
|
321
282
|
cachedSelection = state.selection;
|
|
@@ -24,11 +24,11 @@ export const getToolbarItemExtensions = (extensionList, toolbarType) => {
|
|
|
24
24
|
* From the full list of extensions, extract only those that have a menu item configuration
|
|
25
25
|
* for the specified source (either 'first-party' or 'external').
|
|
26
26
|
*
|
|
27
|
-
* Map each to the legacy format for
|
|
27
|
+
* Map each to the legacy format for SelectionExtension.
|
|
28
28
|
*
|
|
29
29
|
* @param extensionList - List of all extensions
|
|
30
30
|
* @param targetSource - Source of the extensions ('first-party' or 'external')
|
|
31
|
-
* @returns Array of
|
|
31
|
+
* @returns Array of SelectionExtension objects
|
|
32
32
|
* @example
|
|
33
33
|
*/
|
|
34
34
|
export const getMenuItemExtensions = (extensionList, targetSource) => {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { getToolbarItemExtensions } from './extensions';
|
|
4
3
|
import { LegacyExtensionToolbarItem } from './LegacyToolbarComponent';
|
|
5
4
|
export const selectionToolbar = ({
|
|
6
5
|
overflowOptions,
|
|
7
6
|
extensionList = []
|
|
8
7
|
}) => {
|
|
9
|
-
const inlineToolbarItemExtensions =
|
|
8
|
+
const inlineToolbarItemExtensions = getToolbarItemExtensions(extensionList, 'inlineToolbar');
|
|
10
9
|
return {
|
|
11
10
|
items: [...(inlineToolbarItemExtensions.length ? [{
|
|
12
11
|
type: 'separator',
|
|
@@ -63,7 +63,7 @@ export var getSelectionTextInfo = function getSelectionTextInfo(view, api) {
|
|
|
63
63
|
var currentSelection = view.state.selection;
|
|
64
64
|
var toolbarDocking = fg('platform_editor_use_preferences_plugin') ? 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 : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
|
|
65
65
|
var isEditMode = Boolean((api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit');
|
|
66
|
-
var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode
|
|
66
|
+
var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
67
67
|
var from = currentSelection.from,
|
|
68
68
|
to = currentSelection.to;
|
|
69
69
|
var text = view.state.doc.textBetween(from, to, '\n');
|
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
|
3
3
|
import { selectionExtensionMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
7
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
9
8
|
import { insertAdfAtEndOfDoc as _insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
@@ -36,7 +35,7 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
36
35
|
firstParty = _ref3$firstParty === void 0 ? [] : _ref3$firstParty,
|
|
37
36
|
_ref3$external = _ref3.external,
|
|
38
37
|
external = _ref3$external === void 0 ? [] : _ref3$external;
|
|
39
|
-
if (!isToolbarAIFCEnabled
|
|
38
|
+
if (!isToolbarAIFCEnabled) {
|
|
40
39
|
var primaryToolbarItemExtensions = getToolbarItemExtensions(extensionList, 'primaryToolbar');
|
|
41
40
|
if (primaryToolbarItemExtensions !== null && primaryToolbarItemExtensions !== void 0 && primaryToolbarItemExtensions.length) {
|
|
42
41
|
var _api$primaryToolbar;
|
|
@@ -193,6 +192,7 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
193
192
|
}
|
|
194
193
|
var handleOnExtensionClick = function handleOnExtensionClick(view) {
|
|
195
194
|
return function (extension) {
|
|
195
|
+
var _extension$onClick, _api$core;
|
|
196
196
|
var selection = getSelectionTextInfo(view, api);
|
|
197
197
|
if (extension.component) {
|
|
198
198
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.selectionExtension.commands.setActiveExtension({
|
|
@@ -200,35 +200,25 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
200
200
|
selection: selection
|
|
201
201
|
}));
|
|
202
202
|
}
|
|
203
|
+
var _getSelectionAdfInfo2 = getSelectionAdfInfo(view.state),
|
|
204
|
+
selectedNodeAdf = _getSelectionAdfInfo2.selectedNodeAdf,
|
|
205
|
+
selectionRanges = _getSelectionAdfInfo2.selectionRanges,
|
|
206
|
+
selectedNode = _getSelectionAdfInfo2.selectedNode,
|
|
207
|
+
nodePos = _getSelectionAdfInfo2.nodePos;
|
|
203
208
|
var onClickCallbackOptions = {
|
|
204
|
-
|
|
209
|
+
selectedNodeAdf: selectedNodeAdf,
|
|
210
|
+
selectionRanges: selectionRanges
|
|
205
211
|
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
var
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
selectedNode
|
|
212
|
-
nodePos
|
|
213
|
-
onClickCallbackOptions = {
|
|
214
|
-
selectedNodeAdf: selectedNodeAdf,
|
|
215
|
-
selectionRanges: selectionRanges
|
|
216
|
-
};
|
|
217
|
-
(_extension$onClick = extension.onClick) === null || _extension$onClick === void 0 || _extension$onClick.call(extension, onClickCallbackOptions);
|
|
218
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref8) {
|
|
219
|
-
var tr = _ref8.tr;
|
|
220
|
-
tr.setMeta(selectionExtensionPluginKey, {
|
|
221
|
-
type: SelectionExtensionActionTypes.SET_SELECTED_NODE,
|
|
222
|
-
selectedNode: selectedNode,
|
|
223
|
-
nodePos: nodePos
|
|
224
|
-
});
|
|
225
|
-
return tr;
|
|
212
|
+
(_extension$onClick = extension.onClick) === null || _extension$onClick === void 0 || _extension$onClick.call(extension, onClickCallbackOptions);
|
|
213
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref8) {
|
|
214
|
+
var tr = _ref8.tr;
|
|
215
|
+
tr.setMeta(selectionExtensionPluginKey, {
|
|
216
|
+
type: SelectionExtensionActionTypes.SET_SELECTED_NODE,
|
|
217
|
+
selectedNode: selectedNode,
|
|
218
|
+
nodePos: nodePos
|
|
226
219
|
});
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
extension.onClick(onClickCallbackOptions);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
220
|
+
return tr;
|
|
221
|
+
});
|
|
232
222
|
};
|
|
233
223
|
};
|
|
234
224
|
var convertExtensionToDropdownMenuItem = function convertExtensionToDropdownMenuItem(extension, rank) {
|
|
@@ -249,44 +239,18 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
249
239
|
}
|
|
250
240
|
};
|
|
251
241
|
};
|
|
252
|
-
var getConfigFromExtensionCallback = function getConfigFromExtensionCallback(extension) {
|
|
253
|
-
if (typeof extension === 'function') {
|
|
254
|
-
var _getSelectionAdfInfo3 = getSelectionAdfInfo(state),
|
|
255
|
-
selectedNodeAdf = _getSelectionAdfInfo3.selectedNodeAdf,
|
|
256
|
-
selectionRanges = _getSelectionAdfInfo3.selectionRanges;
|
|
257
|
-
return extension({
|
|
258
|
-
selectedNodeAdf: selectedNodeAdf,
|
|
259
|
-
selectionRanges: selectionRanges
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
return extension;
|
|
263
|
-
};
|
|
264
|
-
var prefilterExtensions = function prefilterExtensions(extensions) {
|
|
265
|
-
// this is to prevent integration issues when passing in a function as an extension
|
|
266
|
-
// but not having platform_editor_selection_extension_api_v2 FG on
|
|
267
|
-
if (!fg('platform_editor_selection_extension_api_v2')) {
|
|
268
|
-
return extensions.filter(function (ext) {
|
|
269
|
-
return typeof ext !== 'function';
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
return extensions;
|
|
273
|
-
};
|
|
274
242
|
var getFirstPartyExtensions = function getFirstPartyExtensions(extensions) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
var ext = fg('platform_editor_selection_extension_api_v2') ? getConfigFromExtensionCallback(extension) : extension;
|
|
278
|
-
return convertExtensionToDropdownMenuItem(ext, 30);
|
|
243
|
+
return extensions.map(function (extension) {
|
|
244
|
+
return convertExtensionToDropdownMenuItem(extension, 30);
|
|
279
245
|
});
|
|
280
246
|
};
|
|
281
247
|
|
|
282
248
|
// Add a heading to the external extensions
|
|
283
249
|
var getExternalExtensions = function getExternalExtensions(extensions) {
|
|
284
|
-
var prefilteredExtensions = prefilterExtensions(extensions);
|
|
285
250
|
var externalExtensions = [];
|
|
286
|
-
if (
|
|
287
|
-
externalExtensions =
|
|
288
|
-
|
|
289
|
-
return convertExtensionToDropdownMenuItem(ext);
|
|
251
|
+
if (extensions !== null && extensions !== void 0 && extensions.length) {
|
|
252
|
+
externalExtensions = extensions.map(function (extension) {
|
|
253
|
+
return convertExtensionToDropdownMenuItem(extension);
|
|
290
254
|
});
|
|
291
255
|
var externalExtensionsHeading = {
|
|
292
256
|
type: 'overflow-dropdown-heading',
|
|
@@ -299,18 +263,14 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
299
263
|
|
|
300
264
|
// NEXT PR: Make sure we cache the whole generated selection toolbar
|
|
301
265
|
// also debug this to make sure it's actually preventing unnecessary re-renders / work
|
|
302
|
-
if (cachedOverflowMenuOptions && state.selection.eq(cachedSelection)
|
|
266
|
+
if (cachedOverflowMenuOptions && state.selection.eq(cachedSelection)) {
|
|
303
267
|
return selectionToolbar({
|
|
304
268
|
overflowOptions: cachedOverflowMenuOptions,
|
|
305
269
|
extensionList: extensionList
|
|
306
270
|
});
|
|
307
271
|
}
|
|
308
|
-
var allFirstParty = _toConsumableArray(firstParty);
|
|
309
|
-
var allExternal = _toConsumableArray(external);
|
|
310
|
-
if (fg('platform_editor_selection_extension_api_v2')) {
|
|
311
|
-
allFirstParty = [].concat(_toConsumableArray(firstParty), _toConsumableArray(getMenuItemExtensions(extensionList, 'first-party')));
|
|
312
|
-
allExternal = [].concat(_toConsumableArray(external), _toConsumableArray(getMenuItemExtensions(extensionList, 'external')));
|
|
313
|
-
}
|
|
272
|
+
var allFirstParty = [].concat(_toConsumableArray(firstParty), _toConsumableArray(getMenuItemExtensions(extensionList, 'first-party')));
|
|
273
|
+
var allExternal = [].concat(_toConsumableArray(external), _toConsumableArray(getMenuItemExtensions(extensionList, 'external')));
|
|
314
274
|
var groupedExtensionsArray = [].concat(_toConsumableArray(getFirstPartyExtensions(allFirstParty)), _toConsumableArray(getExternalExtensions(allExternal)));
|
|
315
275
|
cachedOverflowMenuOptions = groupedExtensionsArray;
|
|
316
276
|
cachedSelection = state.selection;
|
|
@@ -24,11 +24,11 @@ export var getToolbarItemExtensions = function getToolbarItemExtensions(extensio
|
|
|
24
24
|
* From the full list of extensions, extract only those that have a menu item configuration
|
|
25
25
|
* for the specified source (either 'first-party' or 'external').
|
|
26
26
|
*
|
|
27
|
-
* Map each to the legacy format for
|
|
27
|
+
* Map each to the legacy format for SelectionExtension.
|
|
28
28
|
*
|
|
29
29
|
* @param extensionList - List of all extensions
|
|
30
30
|
* @param targetSource - Source of the extensions ('first-party' or 'external')
|
|
31
|
-
* @returns Array of
|
|
31
|
+
* @returns Array of SelectionExtension objects
|
|
32
32
|
* @example
|
|
33
33
|
*/
|
|
34
34
|
export var getMenuItemExtensions = function getMenuItemExtensions(extensionList, targetSource) {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { getToolbarItemExtensions } from './extensions';
|
|
5
4
|
import { LegacyExtensionToolbarItem } from './LegacyToolbarComponent';
|
|
6
5
|
export var selectionToolbar = function selectionToolbar(_ref) {
|
|
7
6
|
var overflowOptions = _ref.overflowOptions,
|
|
8
7
|
_ref$extensionList = _ref.extensionList,
|
|
9
8
|
extensionList = _ref$extensionList === void 0 ? [] : _ref$extensionList;
|
|
10
|
-
var inlineToolbarItemExtensions =
|
|
9
|
+
var inlineToolbarItemExtensions = getToolbarItemExtensions(extensionList, 'inlineToolbar');
|
|
11
10
|
return {
|
|
12
11
|
items: [].concat(_toConsumableArray(inlineToolbarItemExtensions.length ? [{
|
|
13
12
|
type: 'separator',
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { selectionExtensionPlugin } from './selectionExtensionPlugin';
|
|
2
2
|
export type { SelectionExtensionPlugin } from './selectionExtensionPluginType';
|
|
3
|
-
export type { BlockMenuExtensionConfiguration,
|
|
3
|
+
export type { BlockMenuExtensionConfiguration, ExtensionConfiguration, ExtensionMenuItemConfiguration, ExtensionToolbarItemConfiguration, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ToolbarExtensionConfiguration, SelectionAdfResult, SelectionExtensionCallbackOptions, } from './types';
|
|
@@ -9,7 +9,7 @@ import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-t
|
|
|
9
9
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
10
10
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
11
11
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
12
|
-
import type {
|
|
12
|
+
import type { SelectionAdfResult, InsertAdfAtEndOfDocResult, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ExtensionMenuItemConfiguration } from './types';
|
|
13
13
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
14
14
|
actions: {
|
|
15
15
|
getDocumentFromSelection: () => {
|
|
@@ -22,7 +22,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
22
22
|
commands: {
|
|
23
23
|
clearActiveExtension: () => EditorCommand;
|
|
24
24
|
setActiveExtension: ({ extension, selection, }: {
|
|
25
|
-
extension: SelectionExtension |
|
|
25
|
+
extension: SelectionExtension | ExtensionMenuItemConfiguration;
|
|
26
26
|
selection: SelectionExtensionSelectionInfo;
|
|
27
27
|
}) => EditorCommand;
|
|
28
28
|
};
|
|
@@ -35,9 +35,6 @@ export type SelectionExtension = {
|
|
|
35
35
|
name: string;
|
|
36
36
|
onClick?: (params: SelectionExtensionCallbackOptions) => void;
|
|
37
37
|
};
|
|
38
|
-
export type DynamicSelectionExtension = Omit<SelectionExtension, 'isDisabled'> & {
|
|
39
|
-
isDisabled?: boolean;
|
|
40
|
-
};
|
|
41
38
|
export type SelectionPointer = {
|
|
42
39
|
pointer: string;
|
|
43
40
|
position?: number;
|
|
@@ -46,15 +43,9 @@ export type SelectionRange = {
|
|
|
46
43
|
end: SelectionPointer;
|
|
47
44
|
start: SelectionPointer;
|
|
48
45
|
};
|
|
49
|
-
export type SelectionExtensionFnOptions = {
|
|
50
|
-
selectedNodeAdf: ADFEntity;
|
|
51
|
-
selectionRanges?: SelectionRange[];
|
|
52
|
-
};
|
|
53
|
-
export type SelectionExtensionFn = ({ selectedNodeAdf, selectionRanges, }: SelectionExtensionFnOptions) => DynamicSelectionExtension;
|
|
54
|
-
export type SelectionExtensionConfig = SelectionExtension | SelectionExtensionFn;
|
|
55
46
|
export type SelectionExtensions = {
|
|
56
|
-
external?:
|
|
57
|
-
firstParty?:
|
|
47
|
+
external?: SelectionExtension[];
|
|
48
|
+
firstParty?: SelectionExtension[];
|
|
58
49
|
};
|
|
59
50
|
type SelectionExtensionModes = ViewMode;
|
|
60
51
|
export type SelectionExtensionPluginOptions = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionConfiguration, ExtensionSource, GetBlockMenuItemFn, GetBlockMenuNestedItemsFn, GetMenuItemsFn, GetToolbarItemFn,
|
|
1
|
+
import type { ExtensionConfiguration, ExtensionSource, GetBlockMenuItemFn, GetBlockMenuNestedItemsFn, GetMenuItemsFn, GetToolbarItemFn, SelectionExtension } from '../types';
|
|
2
2
|
export type ToolbarItemExtension = {
|
|
3
3
|
getMenuItems?: GetMenuItemsFn;
|
|
4
4
|
getToolbarItem: GetToolbarItemFn;
|
|
@@ -17,14 +17,14 @@ export declare const getToolbarItemExtensions: (extensionList: ExtensionConfigur
|
|
|
17
17
|
* From the full list of extensions, extract only those that have a menu item configuration
|
|
18
18
|
* for the specified source (either 'first-party' or 'external').
|
|
19
19
|
*
|
|
20
|
-
* Map each to the legacy format for
|
|
20
|
+
* Map each to the legacy format for SelectionExtension.
|
|
21
21
|
*
|
|
22
22
|
* @param extensionList - List of all extensions
|
|
23
23
|
* @param targetSource - Source of the extensions ('first-party' or 'external')
|
|
24
|
-
* @returns Array of
|
|
24
|
+
* @returns Array of SelectionExtension objects
|
|
25
25
|
* @example
|
|
26
26
|
*/
|
|
27
|
-
export declare const getMenuItemExtensions: (extensionList: ExtensionConfiguration[], targetSource: ExtensionSource) =>
|
|
27
|
+
export declare const getMenuItemExtensions: (extensionList: ExtensionConfiguration[], targetSource: ExtensionSource) => SelectionExtension[];
|
|
28
28
|
type BlockMenuItems = {
|
|
29
29
|
menuItem: ReturnType<GetBlockMenuItemFn>;
|
|
30
30
|
nestedMenuItems?: ReturnType<GetBlockMenuNestedItemsFn>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { selectionExtensionPlugin } from './selectionExtensionPlugin';
|
|
2
2
|
export type { SelectionExtensionPlugin } from './selectionExtensionPluginType';
|
|
3
|
-
export type { BlockMenuExtensionConfiguration,
|
|
3
|
+
export type { BlockMenuExtensionConfiguration, ExtensionConfiguration, ExtensionMenuItemConfiguration, ExtensionToolbarItemConfiguration, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ToolbarExtensionConfiguration, SelectionAdfResult, SelectionExtensionCallbackOptions, } from './types';
|
|
@@ -9,7 +9,7 @@ import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-t
|
|
|
9
9
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
10
10
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
11
11
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
12
|
-
import type {
|
|
12
|
+
import type { SelectionAdfResult, InsertAdfAtEndOfDocResult, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ExtensionMenuItemConfiguration } from './types';
|
|
13
13
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
14
14
|
actions: {
|
|
15
15
|
getDocumentFromSelection: () => {
|
|
@@ -22,7 +22,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
22
22
|
commands: {
|
|
23
23
|
clearActiveExtension: () => EditorCommand;
|
|
24
24
|
setActiveExtension: ({ extension, selection, }: {
|
|
25
|
-
extension: SelectionExtension |
|
|
25
|
+
extension: SelectionExtension | ExtensionMenuItemConfiguration;
|
|
26
26
|
selection: SelectionExtensionSelectionInfo;
|
|
27
27
|
}) => EditorCommand;
|
|
28
28
|
};
|
|
@@ -35,9 +35,6 @@ export type SelectionExtension = {
|
|
|
35
35
|
name: string;
|
|
36
36
|
onClick?: (params: SelectionExtensionCallbackOptions) => void;
|
|
37
37
|
};
|
|
38
|
-
export type DynamicSelectionExtension = Omit<SelectionExtension, 'isDisabled'> & {
|
|
39
|
-
isDisabled?: boolean;
|
|
40
|
-
};
|
|
41
38
|
export type SelectionPointer = {
|
|
42
39
|
pointer: string;
|
|
43
40
|
position?: number;
|
|
@@ -46,15 +43,9 @@ export type SelectionRange = {
|
|
|
46
43
|
end: SelectionPointer;
|
|
47
44
|
start: SelectionPointer;
|
|
48
45
|
};
|
|
49
|
-
export type SelectionExtensionFnOptions = {
|
|
50
|
-
selectedNodeAdf: ADFEntity;
|
|
51
|
-
selectionRanges?: SelectionRange[];
|
|
52
|
-
};
|
|
53
|
-
export type SelectionExtensionFn = ({ selectedNodeAdf, selectionRanges, }: SelectionExtensionFnOptions) => DynamicSelectionExtension;
|
|
54
|
-
export type SelectionExtensionConfig = SelectionExtension | SelectionExtensionFn;
|
|
55
46
|
export type SelectionExtensions = {
|
|
56
|
-
external?:
|
|
57
|
-
firstParty?:
|
|
47
|
+
external?: SelectionExtension[];
|
|
48
|
+
firstParty?: SelectionExtension[];
|
|
58
49
|
};
|
|
59
50
|
type SelectionExtensionModes = ViewMode;
|
|
60
51
|
export type SelectionExtensionPluginOptions = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionConfiguration, ExtensionSource, GetBlockMenuItemFn, GetBlockMenuNestedItemsFn, GetMenuItemsFn, GetToolbarItemFn,
|
|
1
|
+
import type { ExtensionConfiguration, ExtensionSource, GetBlockMenuItemFn, GetBlockMenuNestedItemsFn, GetMenuItemsFn, GetToolbarItemFn, SelectionExtension } from '../types';
|
|
2
2
|
export type ToolbarItemExtension = {
|
|
3
3
|
getMenuItems?: GetMenuItemsFn;
|
|
4
4
|
getToolbarItem: GetToolbarItemFn;
|
|
@@ -17,14 +17,14 @@ export declare const getToolbarItemExtensions: (extensionList: ExtensionConfigur
|
|
|
17
17
|
* From the full list of extensions, extract only those that have a menu item configuration
|
|
18
18
|
* for the specified source (either 'first-party' or 'external').
|
|
19
19
|
*
|
|
20
|
-
* Map each to the legacy format for
|
|
20
|
+
* Map each to the legacy format for SelectionExtension.
|
|
21
21
|
*
|
|
22
22
|
* @param extensionList - List of all extensions
|
|
23
23
|
* @param targetSource - Source of the extensions ('first-party' or 'external')
|
|
24
|
-
* @returns Array of
|
|
24
|
+
* @returns Array of SelectionExtension objects
|
|
25
25
|
* @example
|
|
26
26
|
*/
|
|
27
|
-
export declare const getMenuItemExtensions: (extensionList: ExtensionConfiguration[], targetSource: ExtensionSource) =>
|
|
27
|
+
export declare const getMenuItemExtensions: (extensionList: ExtensionConfiguration[], targetSource: ExtensionSource) => SelectionExtension[];
|
|
28
28
|
type BlockMenuItems = {
|
|
29
29
|
menuItem: ReturnType<GetBlockMenuItemFn>;
|
|
30
30
|
nestedMenuItems?: ReturnType<GetBlockMenuNestedItemsFn>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-block-menu": "^5.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-primary-toolbar": "^7.0.0",
|
|
41
|
-
"@atlaskit/editor-plugin-selection-toolbar": "^7.
|
|
42
|
-
"@atlaskit/editor-plugin-toolbar": "^3.
|
|
41
|
+
"@atlaskit/editor-plugin-selection-toolbar": "^7.1.0",
|
|
42
|
+
"@atlaskit/editor-plugin-toolbar": "^3.4.0",
|
|
43
43
|
"@atlaskit/editor-plugin-user-preferences": "^4.0.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
45
45
|
"@atlaskit/editor-shared-styles": "^3.8.0",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags-react": "^0.3.0",
|
|
51
51
|
"@atlaskit/primitives": "^16.0.0",
|
|
52
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
52
|
+
"@atlaskit/tmp-editor-statsig": "^13.19.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"lodash": "^4.17.21",
|
|
55
55
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
56
56
|
"uuid": "^3.1.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^110.
|
|
59
|
+
"@atlaskit/editor-common": "^110.18.0",
|
|
60
60
|
"react": "^18.2.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
@@ -109,9 +109,6 @@
|
|
|
109
109
|
"platform_editor_clear_active_extension_fix": {
|
|
110
110
|
"type": "boolean"
|
|
111
111
|
},
|
|
112
|
-
"platform_editor_selection_extension_api_v2": {
|
|
113
|
-
"type": "boolean"
|
|
114
|
-
},
|
|
115
112
|
"platform_editor_use_preferences_plugin": {
|
|
116
113
|
"type": "boolean"
|
|
117
114
|
}
|