@atlaskit/editor-plugin-selection-extension 9.0.2 → 9.0.4
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 +16 -0
- package/dist/cjs/pm-plugins/utils/index.js +58 -4
- package/dist/cjs/selectionExtensionPlugin.js +18 -10
- package/dist/es2019/pm-plugins/utils/index.js +60 -2
- package/dist/es2019/selectionExtensionPlugin.js +15 -8
- package/dist/esm/pm-plugins/utils/index.js +56 -2
- package/dist/esm/selectionExtensionPlugin.js +19 -11
- package/dist/types/pm-plugins/utils/index.d.ts +16 -0
- package/dist/types/selectionExtensionPluginType.d.ts +3 -1
- package/dist/types/ui/toolbar-components/ToolbarMenu.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/index.d.ts +16 -0
- package/dist/types-ts4.5/selectionExtensionPluginType.d.ts +3 -1
- package/dist/types-ts4.5/ui/toolbar-components/ToolbarMenu.d.ts +1 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 9.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b831109342cdf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b831109342cdf) -
|
|
8
|
+
EDITOR-3880 Register block menu selection extensions statically
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 9.0.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`5a3efdfff9617`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5a3efdfff9617) -
|
|
16
|
+
EDITOR-3911 Fix selection extension plugin to use preserved selection for block menu actions
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 9.0.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getFragmentInfoFromSelection = void 0;
|
|
7
|
+
exports.getFragmentInfoFromSelectionNew = exports.getFragmentInfoFromSelection = void 0;
|
|
8
8
|
exports.getSelectionAdfInfo = getSelectionAdfInfo;
|
|
9
9
|
exports.getSelectionAdfInfoNew = getSelectionAdfInfoNew;
|
|
10
|
-
exports.getSelectionTextInfo = void 0;
|
|
10
|
+
exports.getSelectionTextInfoNew = exports.getSelectionTextInfo = void 0;
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
12
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
13
13
|
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
@@ -51,10 +51,15 @@ var getSelectionInfoFromCellSelection = function getSelectionInfoFromCellSelecti
|
|
|
51
51
|
nodePos: nodePos
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
58
|
+
*/
|
|
54
59
|
var getSelectionTextInfo = exports.getSelectionTextInfo = function getSelectionTextInfo(view, api) {
|
|
55
|
-
var _api$userPreferences, _api$
|
|
60
|
+
var _api$userPreferences, _api$editorViewMode;
|
|
56
61
|
var currentSelection = view.state.selection;
|
|
57
|
-
var toolbarDocking =
|
|
62
|
+
var toolbarDocking = 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;
|
|
58
63
|
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');
|
|
59
64
|
var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
60
65
|
var from = currentSelection.from,
|
|
@@ -71,6 +76,30 @@ var getSelectionTextInfo = exports.getSelectionTextInfo = function getSelectionT
|
|
|
71
76
|
coords: coords
|
|
72
77
|
};
|
|
73
78
|
};
|
|
79
|
+
var getSelectionTextInfoNew = exports.getSelectionTextInfoNew = function getSelectionTextInfoNew(selection, view, api) {
|
|
80
|
+
var _api$userPreferences2, _api$selectionToolbar, _api$editorViewMode2;
|
|
81
|
+
var toolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.sharedState.currentState()) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.preferences) === null || _api$userPreferences2 === void 0 ? void 0 : _api$userPreferences2.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;
|
|
82
|
+
var isEditMode = Boolean((api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) === 'edit');
|
|
83
|
+
var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
84
|
+
var from = selection.from,
|
|
85
|
+
to = selection.to;
|
|
86
|
+
var text = view.state.doc.textBetween(from, to, '\n');
|
|
87
|
+
var coords = (0, _getBoundingBoxFromSelection.getBoundingBoxFromSelection)(view, from, to, {
|
|
88
|
+
top: shouldOffsetToolbarHeight ? _editorSharedStyles.akEditorFullPageToolbarHeight : 0,
|
|
89
|
+
bottom: shouldOffsetToolbarHeight ? _editorSharedStyles.akEditorFullPageToolbarHeight : 0
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
text: text,
|
|
93
|
+
from: from,
|
|
94
|
+
to: to,
|
|
95
|
+
coords: coords
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @private
|
|
101
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
102
|
+
*/
|
|
74
103
|
var getFragmentInfoFromSelection = exports.getFragmentInfoFromSelection = function getFragmentInfoFromSelection(state) {
|
|
75
104
|
var schema = state.schema,
|
|
76
105
|
selection = state.selection;
|
|
@@ -93,6 +122,31 @@ var getFragmentInfoFromSelection = exports.getFragmentInfoFromSelection = functi
|
|
|
93
122
|
selectedNodeAdf: selectedNodeAdf
|
|
94
123
|
};
|
|
95
124
|
};
|
|
125
|
+
var getFragmentInfoFromSelectionNew = exports.getFragmentInfoFromSelectionNew = function getFragmentInfoFromSelectionNew(selection) {
|
|
126
|
+
var schema = selection.$from.doc.type.schema;
|
|
127
|
+
var slice = selection.content();
|
|
128
|
+
var newDoc;
|
|
129
|
+
try {
|
|
130
|
+
var doc = schema.node('doc', null, [schema.node('paragraph', null, [])]);
|
|
131
|
+
var transform = new _transform.Transform(doc);
|
|
132
|
+
newDoc = transform.replaceRange(0, 2, slice).doc;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
newDoc = schema.nodes.doc.createChecked({}, _model.Fragment.empty);
|
|
135
|
+
(0, _monitoring.logException)(error, {
|
|
136
|
+
location: 'editor-plugin-selection-extension'
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
var serializer = new _editorJsonTransformer.JSONTransformer();
|
|
140
|
+
var selectedNodeAdf = serializer.encodeNode(newDoc);
|
|
141
|
+
return {
|
|
142
|
+
selectedNodeAdf: selectedNodeAdf
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @private
|
|
148
|
+
* @deprecated use getSelectionAdfInfoNew instead
|
|
149
|
+
*/
|
|
96
150
|
function getSelectionAdfInfo(state) {
|
|
97
151
|
var selection = state.selection;
|
|
98
152
|
var selectionInfo = {
|
|
@@ -12,7 +12,6 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
12
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
13
|
var _usePluginStateEffect = require("@atlaskit/editor-common/use-plugin-state-effect");
|
|
14
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
|
-
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
16
15
|
var _insertAdfAtEndOfDoc2 = require("./pm-plugins/actions/insertAdfAtEndOfDoc");
|
|
17
16
|
var _replaceWithAdf2 = require("./pm-plugins/actions/replaceWithAdf");
|
|
18
17
|
var _main = require("./pm-plugins/main");
|
|
@@ -57,6 +56,9 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
58
|
}
|
|
59
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
60
|
+
(0, _registerBlockMenuItems.registerBlockMenuItems)(extensionList, api);
|
|
61
|
+
}
|
|
60
62
|
return {
|
|
61
63
|
name: 'selectionExtension',
|
|
62
64
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -112,6 +114,11 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
112
114
|
return null;
|
|
113
115
|
}
|
|
114
116
|
var state = editorViewRef.current.state;
|
|
117
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
118
|
+
var _api$blockControls;
|
|
119
|
+
var selection = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection) || state.selection;
|
|
120
|
+
return (0, _utils.getSelectionAdfInfoNew)(selection);
|
|
121
|
+
}
|
|
115
122
|
var _getSelectionAdfInfo = (0, _utils.getSelectionAdfInfo)(state),
|
|
116
123
|
selectionRanges = _getSelectionAdfInfo.selectionRanges,
|
|
117
124
|
selectedNodeAdf = _getSelectionAdfInfo.selectedNodeAdf;
|
|
@@ -125,6 +132,11 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
125
132
|
return null;
|
|
126
133
|
}
|
|
127
134
|
var state = editorViewRef.current.state;
|
|
135
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
136
|
+
var _api$blockControls2;
|
|
137
|
+
var selection = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.preservedSelection) || state.selection;
|
|
138
|
+
return (0, _utils.getFragmentInfoFromSelectionNew)(selection);
|
|
139
|
+
}
|
|
128
140
|
var _getFragmentInfoFromS = (0, _utils.getFragmentInfoFromSelection)(state),
|
|
129
141
|
selectedNodeAdf = _getFragmentInfoFromS.selectedNodeAdf;
|
|
130
142
|
return {
|
|
@@ -133,14 +145,10 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
133
145
|
}
|
|
134
146
|
},
|
|
135
147
|
usePluginHook: function usePluginHook() {
|
|
136
|
-
(0, _usePluginStateEffect.usePluginStateEffect)(api, ['
|
|
137
|
-
var userIntentState = _ref6.userIntentState;
|
|
148
|
+
(0, _usePluginStateEffect.usePluginStateEffect)(api, ['selection'], function () {
|
|
138
149
|
if ((0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) && (0, _coreUtils.isSSR)()) {
|
|
139
150
|
return;
|
|
140
151
|
}
|
|
141
|
-
if ((userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'blockMenuOpen' && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
142
|
-
(0, _registerBlockMenuItems.registerBlockMenuItems)(extensionList, api);
|
|
143
|
-
}
|
|
144
152
|
if (isToolbarAIFCEnabled && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_selection_extension', 'isEnabled', true)) {
|
|
145
153
|
var _api$toolbar;
|
|
146
154
|
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)({
|
|
@@ -150,9 +158,9 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
150
158
|
}
|
|
151
159
|
});
|
|
152
160
|
},
|
|
153
|
-
contentComponent: function contentComponent(
|
|
161
|
+
contentComponent: function contentComponent(_ref6) {
|
|
154
162
|
var _api$analytics;
|
|
155
|
-
var editorView =
|
|
163
|
+
var editorView = _ref6.editorView;
|
|
156
164
|
if (!editorView || (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) && (0, _coreUtils.isSSR)()) {
|
|
157
165
|
return null;
|
|
158
166
|
}
|
|
@@ -221,8 +229,8 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
221
229
|
selectionRanges: selectionRanges
|
|
222
230
|
};
|
|
223
231
|
(_extension$onClick = extension.onClick) === null || _extension$onClick === void 0 || _extension$onClick.call(extension, onClickCallbackOptions);
|
|
224
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (
|
|
225
|
-
var tr =
|
|
232
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref7) {
|
|
233
|
+
var tr = _ref7.tr;
|
|
226
234
|
tr.setMeta(_main.selectionExtensionPluginKey, {
|
|
227
235
|
type: _types.SelectionExtensionActionTypes.SET_SELECTED_NODE,
|
|
228
236
|
selectedNode: selectedNode,
|
|
@@ -40,12 +40,17 @@ const getSelectionInfoFromCellSelection = selection => {
|
|
|
40
40
|
nodePos
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
47
|
+
*/
|
|
43
48
|
export const getSelectionTextInfo = (view, api) => {
|
|
44
|
-
var _api$userPreferences, _api$userPreferences$, _api$userPreferences$2, _api$
|
|
49
|
+
var _api$userPreferences, _api$userPreferences$, _api$userPreferences$2, _api$editorViewMode, _api$editorViewMode$s;
|
|
45
50
|
const {
|
|
46
51
|
selection: currentSelection
|
|
47
52
|
} = view.state;
|
|
48
|
-
const toolbarDocking =
|
|
53
|
+
const toolbarDocking = 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;
|
|
49
54
|
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');
|
|
50
55
|
const shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
51
56
|
const {
|
|
@@ -64,6 +69,32 @@ export const getSelectionTextInfo = (view, api) => {
|
|
|
64
69
|
coords
|
|
65
70
|
};
|
|
66
71
|
};
|
|
72
|
+
export const getSelectionTextInfoNew = (selection, view, api) => {
|
|
73
|
+
var _api$userPreferences2, _api$userPreferences3, _api$userPreferences4, _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3, _api$editorViewMode2, _api$editorViewMode2$;
|
|
74
|
+
const toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 ? void 0 : (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 ? void 0 : (_api$userPreferences3 = _api$userPreferences2.sharedState.currentState()) === null || _api$userPreferences3 === void 0 ? void 0 : (_api$userPreferences4 = _api$userPreferences3.preferences) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.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;
|
|
75
|
+
const isEditMode = Boolean((api === null || api === void 0 ? void 0 : (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : (_api$editorViewMode2$ = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2$ === void 0 ? void 0 : _api$editorViewMode2$.mode) === 'edit');
|
|
76
|
+
const shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
77
|
+
const {
|
|
78
|
+
from,
|
|
79
|
+
to
|
|
80
|
+
} = selection;
|
|
81
|
+
const text = view.state.doc.textBetween(from, to, '\n');
|
|
82
|
+
const coords = getBoundingBoxFromSelection(view, from, to, {
|
|
83
|
+
top: shouldOffsetToolbarHeight ? akEditorFullPageToolbarHeight : 0,
|
|
84
|
+
bottom: shouldOffsetToolbarHeight ? akEditorFullPageToolbarHeight : 0
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
text,
|
|
88
|
+
from,
|
|
89
|
+
to,
|
|
90
|
+
coords
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @private
|
|
96
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
97
|
+
*/
|
|
67
98
|
export const getFragmentInfoFromSelection = state => {
|
|
68
99
|
const {
|
|
69
100
|
schema,
|
|
@@ -90,6 +121,33 @@ export const getFragmentInfoFromSelection = state => {
|
|
|
90
121
|
selectedNodeAdf
|
|
91
122
|
};
|
|
92
123
|
};
|
|
124
|
+
export const getFragmentInfoFromSelectionNew = selection => {
|
|
125
|
+
const {
|
|
126
|
+
schema
|
|
127
|
+
} = selection.$from.doc.type;
|
|
128
|
+
const slice = selection.content();
|
|
129
|
+
let newDoc;
|
|
130
|
+
try {
|
|
131
|
+
const doc = schema.node('doc', null, [schema.node('paragraph', null, [])]);
|
|
132
|
+
const transform = new Transform(doc);
|
|
133
|
+
newDoc = transform.replaceRange(0, 2, slice).doc;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
newDoc = schema.nodes.doc.createChecked({}, Fragment.empty);
|
|
136
|
+
logException(error, {
|
|
137
|
+
location: 'editor-plugin-selection-extension'
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const serializer = new JSONTransformer();
|
|
141
|
+
const selectedNodeAdf = serializer.encodeNode(newDoc);
|
|
142
|
+
return {
|
|
143
|
+
selectedNodeAdf
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @private
|
|
149
|
+
* @deprecated use getSelectionAdfInfoNew instead
|
|
150
|
+
*/
|
|
93
151
|
export function getSelectionAdfInfo(state) {
|
|
94
152
|
const selection = state.selection;
|
|
95
153
|
let selectionInfo = {
|
|
@@ -4,11 +4,10 @@ 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
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
8
7
|
import { insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
9
8
|
import { replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
|
|
10
9
|
import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
|
|
11
|
-
import { getFragmentInfoFromSelection, getSelectionAdfInfo, getSelectionTextInfo } from './pm-plugins/utils';
|
|
10
|
+
import { getFragmentInfoFromSelection, getFragmentInfoFromSelectionNew, getSelectionAdfInfo, getSelectionAdfInfoNew, getSelectionTextInfo } from './pm-plugins/utils';
|
|
12
11
|
import { SelectionExtensionActionTypes } from './types';
|
|
13
12
|
import { SelectionExtensionComponentWrapper } from './ui/extension/SelectionExtensionComponentWrapper';
|
|
14
13
|
import { getMenuItemExtensions, getToolbarItemExtensions } from './ui/extensions';
|
|
@@ -46,6 +45,9 @@ export const selectionExtensionPlugin = ({
|
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
47
|
}
|
|
48
|
+
if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
|
|
49
|
+
registerBlockMenuItems(extensionList, api);
|
|
50
|
+
}
|
|
49
51
|
return {
|
|
50
52
|
name: 'selectionExtension',
|
|
51
53
|
getSharedState(editorState) {
|
|
@@ -103,6 +105,11 @@ export const selectionExtensionPlugin = ({
|
|
|
103
105
|
const {
|
|
104
106
|
state
|
|
105
107
|
} = editorViewRef.current;
|
|
108
|
+
if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
|
|
109
|
+
var _api$blockControls, _api$blockControls$sh;
|
|
110
|
+
const selection = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection) || state.selection;
|
|
111
|
+
return getSelectionAdfInfoNew(selection);
|
|
112
|
+
}
|
|
106
113
|
const {
|
|
107
114
|
selectionRanges,
|
|
108
115
|
selectedNodeAdf
|
|
@@ -119,6 +126,11 @@ export const selectionExtensionPlugin = ({
|
|
|
119
126
|
const {
|
|
120
127
|
state
|
|
121
128
|
} = editorViewRef.current;
|
|
129
|
+
if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
|
|
130
|
+
var _api$blockControls2, _api$blockControls2$s;
|
|
131
|
+
const selection = (api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$s = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2$s === void 0 ? void 0 : _api$blockControls2$s.preservedSelection) || state.selection;
|
|
132
|
+
return getFragmentInfoFromSelectionNew(selection);
|
|
133
|
+
}
|
|
122
134
|
const {
|
|
123
135
|
selectedNodeAdf
|
|
124
136
|
} = getFragmentInfoFromSelection(state);
|
|
@@ -128,15 +140,10 @@ export const selectionExtensionPlugin = ({
|
|
|
128
140
|
}
|
|
129
141
|
},
|
|
130
142
|
usePluginHook: () => {
|
|
131
|
-
usePluginStateEffect(api, ['
|
|
132
|
-
userIntentState
|
|
133
|
-
}) => {
|
|
143
|
+
usePluginStateEffect(api, ['selection'], () => {
|
|
134
144
|
if (expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) && isSSR()) {
|
|
135
145
|
return;
|
|
136
146
|
}
|
|
137
|
-
if ((userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
138
|
-
registerBlockMenuItems(extensionList, api);
|
|
139
|
-
}
|
|
140
147
|
if (isToolbarAIFCEnabled && expValEquals('platform_editor_toolbar_aifc_selection_extension', 'isEnabled', true)) {
|
|
141
148
|
var _api$toolbar;
|
|
142
149
|
api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.registerComponents(getToolbarComponents({
|
|
@@ -41,10 +41,15 @@ var getSelectionInfoFromCellSelection = function getSelectionInfoFromCellSelecti
|
|
|
41
41
|
nodePos: nodePos
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @private
|
|
47
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
48
|
+
*/
|
|
44
49
|
export var getSelectionTextInfo = function getSelectionTextInfo(view, api) {
|
|
45
|
-
var _api$userPreferences, _api$
|
|
50
|
+
var _api$userPreferences, _api$editorViewMode;
|
|
46
51
|
var currentSelection = view.state.selection;
|
|
47
|
-
var toolbarDocking =
|
|
52
|
+
var toolbarDocking = 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;
|
|
48
53
|
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');
|
|
49
54
|
var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
50
55
|
var from = currentSelection.from,
|
|
@@ -61,6 +66,30 @@ export var getSelectionTextInfo = function getSelectionTextInfo(view, api) {
|
|
|
61
66
|
coords: coords
|
|
62
67
|
};
|
|
63
68
|
};
|
|
69
|
+
export var getSelectionTextInfoNew = function getSelectionTextInfoNew(selection, view, api) {
|
|
70
|
+
var _api$userPreferences2, _api$selectionToolbar, _api$editorViewMode2;
|
|
71
|
+
var toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.sharedState.currentState()) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.preferences) === null || _api$userPreferences2 === void 0 ? void 0 : _api$userPreferences2.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;
|
|
72
|
+
var isEditMode = Boolean((api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) === 'edit');
|
|
73
|
+
var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
|
|
74
|
+
var from = selection.from,
|
|
75
|
+
to = selection.to;
|
|
76
|
+
var text = view.state.doc.textBetween(from, to, '\n');
|
|
77
|
+
var coords = getBoundingBoxFromSelection(view, from, to, {
|
|
78
|
+
top: shouldOffsetToolbarHeight ? akEditorFullPageToolbarHeight : 0,
|
|
79
|
+
bottom: shouldOffsetToolbarHeight ? akEditorFullPageToolbarHeight : 0
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
text: text,
|
|
83
|
+
from: from,
|
|
84
|
+
to: to,
|
|
85
|
+
coords: coords
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @private
|
|
91
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
92
|
+
*/
|
|
64
93
|
export var getFragmentInfoFromSelection = function getFragmentInfoFromSelection(state) {
|
|
65
94
|
var schema = state.schema,
|
|
66
95
|
selection = state.selection;
|
|
@@ -83,6 +112,31 @@ export var getFragmentInfoFromSelection = function getFragmentInfoFromSelection(
|
|
|
83
112
|
selectedNodeAdf: selectedNodeAdf
|
|
84
113
|
};
|
|
85
114
|
};
|
|
115
|
+
export var getFragmentInfoFromSelectionNew = function getFragmentInfoFromSelectionNew(selection) {
|
|
116
|
+
var schema = selection.$from.doc.type.schema;
|
|
117
|
+
var slice = selection.content();
|
|
118
|
+
var newDoc;
|
|
119
|
+
try {
|
|
120
|
+
var doc = schema.node('doc', null, [schema.node('paragraph', null, [])]);
|
|
121
|
+
var transform = new Transform(doc);
|
|
122
|
+
newDoc = transform.replaceRange(0, 2, slice).doc;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
newDoc = schema.nodes.doc.createChecked({}, Fragment.empty);
|
|
125
|
+
logException(error, {
|
|
126
|
+
location: 'editor-plugin-selection-extension'
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
var serializer = new JSONTransformer();
|
|
130
|
+
var selectedNodeAdf = serializer.encodeNode(newDoc);
|
|
131
|
+
return {
|
|
132
|
+
selectedNodeAdf: selectedNodeAdf
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @private
|
|
138
|
+
* @deprecated use getSelectionAdfInfoNew instead
|
|
139
|
+
*/
|
|
86
140
|
export function getSelectionAdfInfo(state) {
|
|
87
141
|
var selection = state.selection;
|
|
88
142
|
var selectionInfo = {
|
|
@@ -5,11 +5,10 @@ import { selectionExtensionMessages } from '@atlaskit/editor-common/messages';
|
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
7
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
9
8
|
import { insertAdfAtEndOfDoc as _insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
10
9
|
import { replaceWithAdf as _replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
|
|
11
10
|
import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
|
|
12
|
-
import { getFragmentInfoFromSelection, getSelectionAdfInfo, getSelectionTextInfo } from './pm-plugins/utils';
|
|
11
|
+
import { getFragmentInfoFromSelection, getFragmentInfoFromSelectionNew, getSelectionAdfInfo, getSelectionAdfInfoNew, getSelectionTextInfo } from './pm-plugins/utils';
|
|
13
12
|
import { SelectionExtensionActionTypes } from './types';
|
|
14
13
|
import { SelectionExtensionComponentWrapper } from './ui/extension/SelectionExtensionComponentWrapper';
|
|
15
14
|
import { getMenuItemExtensions, getToolbarItemExtensions } from './ui/extensions';
|
|
@@ -50,6 +49,9 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
}
|
|
52
|
+
if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
|
|
53
|
+
registerBlockMenuItems(extensionList, api);
|
|
54
|
+
}
|
|
53
55
|
return {
|
|
54
56
|
name: 'selectionExtension',
|
|
55
57
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -105,6 +107,11 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
105
107
|
return null;
|
|
106
108
|
}
|
|
107
109
|
var state = editorViewRef.current.state;
|
|
110
|
+
if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
|
|
111
|
+
var _api$blockControls;
|
|
112
|
+
var selection = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection) || state.selection;
|
|
113
|
+
return getSelectionAdfInfoNew(selection);
|
|
114
|
+
}
|
|
108
115
|
var _getSelectionAdfInfo = getSelectionAdfInfo(state),
|
|
109
116
|
selectionRanges = _getSelectionAdfInfo.selectionRanges,
|
|
110
117
|
selectedNodeAdf = _getSelectionAdfInfo.selectedNodeAdf;
|
|
@@ -118,6 +125,11 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
118
125
|
return null;
|
|
119
126
|
}
|
|
120
127
|
var state = editorViewRef.current.state;
|
|
128
|
+
if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
|
|
129
|
+
var _api$blockControls2;
|
|
130
|
+
var selection = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.preservedSelection) || state.selection;
|
|
131
|
+
return getFragmentInfoFromSelectionNew(selection);
|
|
132
|
+
}
|
|
121
133
|
var _getFragmentInfoFromS = getFragmentInfoFromSelection(state),
|
|
122
134
|
selectedNodeAdf = _getFragmentInfoFromS.selectedNodeAdf;
|
|
123
135
|
return {
|
|
@@ -126,14 +138,10 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
126
138
|
}
|
|
127
139
|
},
|
|
128
140
|
usePluginHook: function usePluginHook() {
|
|
129
|
-
usePluginStateEffect(api, ['
|
|
130
|
-
var userIntentState = _ref6.userIntentState;
|
|
141
|
+
usePluginStateEffect(api, ['selection'], function () {
|
|
131
142
|
if (expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) && isSSR()) {
|
|
132
143
|
return;
|
|
133
144
|
}
|
|
134
|
-
if ((userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
135
|
-
registerBlockMenuItems(extensionList, api);
|
|
136
|
-
}
|
|
137
145
|
if (isToolbarAIFCEnabled && expValEquals('platform_editor_toolbar_aifc_selection_extension', 'isEnabled', true)) {
|
|
138
146
|
var _api$toolbar;
|
|
139
147
|
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getToolbarComponents({
|
|
@@ -143,9 +151,9 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
143
151
|
}
|
|
144
152
|
});
|
|
145
153
|
},
|
|
146
|
-
contentComponent: function contentComponent(
|
|
154
|
+
contentComponent: function contentComponent(_ref6) {
|
|
147
155
|
var _api$analytics;
|
|
148
|
-
var editorView =
|
|
156
|
+
var editorView = _ref6.editorView;
|
|
149
157
|
if (!editorView || expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) && isSSR()) {
|
|
150
158
|
return null;
|
|
151
159
|
}
|
|
@@ -214,8 +222,8 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
214
222
|
selectionRanges: selectionRanges
|
|
215
223
|
};
|
|
216
224
|
(_extension$onClick = extension.onClick) === null || _extension$onClick === void 0 || _extension$onClick.call(extension, onClickCallbackOptions);
|
|
217
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (
|
|
218
|
-
var tr =
|
|
225
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref7) {
|
|
226
|
+
var tr = _ref7.tr;
|
|
219
227
|
tr.setMeta(selectionExtensionPluginKey, {
|
|
220
228
|
type: SelectionExtensionActionTypes.SET_SELECTED_NODE,
|
|
221
229
|
selectedNode: selectedNode,
|
|
@@ -12,10 +12,26 @@ type SelectionInfo = {
|
|
|
12
12
|
selectedNodeAdf: ADFEntity;
|
|
13
13
|
selectionRanges?: SelectionRange[];
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
18
|
+
*/
|
|
15
19
|
export declare const getSelectionTextInfo: (view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
|
|
20
|
+
export declare const getSelectionTextInfoNew: (selection: Selection, view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
24
|
+
*/
|
|
16
25
|
export declare const getFragmentInfoFromSelection: (state: EditorState) => {
|
|
17
26
|
selectedNodeAdf: ADFEntity;
|
|
18
27
|
};
|
|
28
|
+
export declare const getFragmentInfoFromSelectionNew: (selection: Selection) => {
|
|
29
|
+
selectedNodeAdf: ADFEntity;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
* @deprecated use getSelectionAdfInfoNew instead
|
|
34
|
+
*/
|
|
19
35
|
export declare function getSelectionAdfInfo(state: EditorState): SelectionInfo;
|
|
20
36
|
export declare function getSelectionAdfInfoNew(selection: Selection): SelectionInfo;
|
|
21
37
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
|
|
4
5
|
import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
|
|
5
6
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
6
7
|
import type { EditorViewModeEffectsPlugin } from '@atlaskit/editor-plugin-editor-viewmode-effects';
|
|
@@ -10,7 +11,7 @@ import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-t
|
|
|
10
11
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
11
12
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
12
13
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
13
|
-
import type {
|
|
14
|
+
import type { ExtensionMenuItemConfiguration, InsertAdfAtEndOfDocResult, ReplaceWithAdfResult, SelectionAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
14
15
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
15
16
|
actions: {
|
|
16
17
|
getDocumentFromSelection: () => {
|
|
@@ -35,6 +36,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
35
36
|
OptionalPlugin<UserPreferencesPlugin>,
|
|
36
37
|
OptionalPlugin<UserIntentPlugin>,
|
|
37
38
|
OptionalPlugin<SelectionPlugin>,
|
|
39
|
+
OptionalPlugin<BlockControlsPlugin>,
|
|
38
40
|
OptionalPlugin<BlockMenuPlugin>,
|
|
39
41
|
OptionalPlugin<ToolbarPlugin>,
|
|
40
42
|
SelectionToolbarPlugin
|
|
@@ -6,5 +6,5 @@ type ToolbarMenuProps = React.PropsWithChildren<{
|
|
|
6
6
|
api: ExtractInjectionAPI<SelectionExtensionPlugin> | undefined;
|
|
7
7
|
config: ExtensionToolbarItemConfiguration;
|
|
8
8
|
}>;
|
|
9
|
-
export declare const ToolbarMenu: ({ api, config, children }: ToolbarMenuProps) => React.JSX.Element | null;
|
|
9
|
+
export declare const ToolbarMenu: ({ api, config, children, }: ToolbarMenuProps) => React.JSX.Element | null;
|
|
10
10
|
export {};
|
|
@@ -12,10 +12,26 @@ type SelectionInfo = {
|
|
|
12
12
|
selectedNodeAdf: ADFEntity;
|
|
13
13
|
selectionRanges?: SelectionRange[];
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
18
|
+
*/
|
|
15
19
|
export declare const getSelectionTextInfo: (view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
|
|
20
|
+
export declare const getSelectionTextInfoNew: (selection: Selection, view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
* @deprecated use getFragmentInfoFromSelectionNew instead
|
|
24
|
+
*/
|
|
16
25
|
export declare const getFragmentInfoFromSelection: (state: EditorState) => {
|
|
17
26
|
selectedNodeAdf: ADFEntity;
|
|
18
27
|
};
|
|
28
|
+
export declare const getFragmentInfoFromSelectionNew: (selection: Selection) => {
|
|
29
|
+
selectedNodeAdf: ADFEntity;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
* @deprecated use getSelectionAdfInfoNew instead
|
|
34
|
+
*/
|
|
19
35
|
export declare function getSelectionAdfInfo(state: EditorState): SelectionInfo;
|
|
20
36
|
export declare function getSelectionAdfInfoNew(selection: Selection): SelectionInfo;
|
|
21
37
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
|
|
4
5
|
import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
|
|
5
6
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
6
7
|
import type { EditorViewModeEffectsPlugin } from '@atlaskit/editor-plugin-editor-viewmode-effects';
|
|
@@ -10,7 +11,7 @@ import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-t
|
|
|
10
11
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
11
12
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
12
13
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
13
|
-
import type {
|
|
14
|
+
import type { ExtensionMenuItemConfiguration, InsertAdfAtEndOfDocResult, ReplaceWithAdfResult, SelectionAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
14
15
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
15
16
|
actions: {
|
|
16
17
|
getDocumentFromSelection: () => {
|
|
@@ -35,6 +36,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
35
36
|
OptionalPlugin<UserPreferencesPlugin>,
|
|
36
37
|
OptionalPlugin<UserIntentPlugin>,
|
|
37
38
|
OptionalPlugin<SelectionPlugin>,
|
|
39
|
+
OptionalPlugin<BlockControlsPlugin>,
|
|
38
40
|
OptionalPlugin<BlockMenuPlugin>,
|
|
39
41
|
OptionalPlugin<ToolbarPlugin>,
|
|
40
42
|
SelectionToolbarPlugin
|
|
@@ -6,5 +6,5 @@ type ToolbarMenuProps = React.PropsWithChildren<{
|
|
|
6
6
|
api: ExtractInjectionAPI<SelectionExtensionPlugin> | undefined;
|
|
7
7
|
config: ExtensionToolbarItemConfiguration;
|
|
8
8
|
}>;
|
|
9
|
-
export declare const ToolbarMenu: ({ api, config, children }: ToolbarMenuProps) => React.JSX.Element | null;
|
|
9
|
+
export declare const ToolbarMenu: ({ api, config, children, }: ToolbarMenuProps) => React.JSX.Element | null;
|
|
10
10
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.4",
|
|
4
4
|
"description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,34 +35,35 @@
|
|
|
35
35
|
"@atlaskit/adf-utils": "^19.26.0",
|
|
36
36
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^6.2.0",
|
|
38
|
-
"@atlaskit/editor-plugin-block-
|
|
38
|
+
"@atlaskit/editor-plugin-block-controls": "^7.14.0",
|
|
39
|
+
"@atlaskit/editor-plugin-block-menu": "^5.2.0",
|
|
39
40
|
"@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
|
|
40
41
|
"@atlaskit/editor-plugin-editor-viewmode-effects": "^6.1.0",
|
|
41
42
|
"@atlaskit/editor-plugin-primary-toolbar": "^7.0.0",
|
|
42
43
|
"@atlaskit/editor-plugin-selection-toolbar": "^7.1.0",
|
|
43
44
|
"@atlaskit/editor-plugin-toolbar": "^3.4.0",
|
|
44
45
|
"@atlaskit/editor-plugin-user-preferences": "^4.0.0",
|
|
45
|
-
"@atlaskit/editor-prosemirror": "7.
|
|
46
|
+
"@atlaskit/editor-prosemirror": "^7.2.0",
|
|
46
47
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
47
48
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
48
49
|
"@atlaskit/editor-toolbar": "^0.18.0",
|
|
49
|
-
"@atlaskit/icon": "^29.
|
|
50
|
+
"@atlaskit/icon": "^29.1.0",
|
|
50
51
|
"@atlaskit/lozenge": "^13.1.0",
|
|
51
52
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
52
53
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
53
54
|
"@atlaskit/primitives": "^16.4.0",
|
|
54
|
-
"@atlaskit/tmp-editor-statsig": "^15.
|
|
55
|
+
"@atlaskit/tmp-editor-statsig": "^15.10.0",
|
|
55
56
|
"@babel/runtime": "^7.0.0",
|
|
56
57
|
"lodash": "^4.17.21",
|
|
57
58
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
58
59
|
"uuid": "^3.1.0"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
|
-
"@atlaskit/editor-common": "^110.
|
|
62
|
+
"@atlaskit/editor-common": "^110.42.0",
|
|
62
63
|
"react": "^18.2.0"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
|
-
"@testing-library/react": "^
|
|
66
|
+
"@testing-library/react": "^16.3.0",
|
|
66
67
|
"react-dom": "^18.2.0",
|
|
67
68
|
"wait-for-expect": "^1.2.0"
|
|
68
69
|
},
|