@atlaskit/editor-plugin-toolbar 3.2.1 → 3.3.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 +12 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-dev-agents/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-passionfruit/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/afm-rovo-extension/tsconfig.json +3 -0
- package/afm-townsquare/tsconfig.json +3 -0
- package/dist/cjs/toolbarPlugin.js +9 -0
- package/dist/cjs/ui/SelectionToolbar/index.js +63 -92
- package/dist/cjs/ui/SelectionToolbar/keyboard-config.js +70 -0
- package/dist/cjs/ui/SelectionToolbar/utils.js +42 -0
- package/dist/es2019/toolbarPlugin.js +10 -1
- package/dist/es2019/ui/SelectionToolbar/index.js +60 -90
- package/dist/es2019/ui/SelectionToolbar/keyboard-config.js +64 -0
- package/dist/es2019/ui/SelectionToolbar/utils.js +36 -0
- package/dist/esm/toolbarPlugin.js +10 -1
- package/dist/esm/ui/SelectionToolbar/index.js +61 -90
- package/dist/esm/ui/SelectionToolbar/keyboard-config.js +64 -0
- package/dist/esm/ui/SelectionToolbar/utils.js +36 -0
- package/dist/types/ui/SelectionToolbar/index.d.ts +2 -1
- package/dist/types/ui/SelectionToolbar/keyboard-config.d.ts +6 -0
- package/dist/types/ui/SelectionToolbar/utils.d.ts +3 -0
- package/dist/types-ts4.5/ui/SelectionToolbar/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/SelectionToolbar/keyboard-config.d.ts +6 -0
- package/dist/types-ts4.5/ui/SelectionToolbar/utils.d.ts +3 -0
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar
|
|
2
2
|
|
|
3
|
+
## 3.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`d3e3f3fdb9cee`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d3e3f3fdb9cee) -
|
|
8
|
+
Add new selection toolbar type to event, add errorboundary for selection toolbar and try/catch
|
|
9
|
+
blocks with log exceptions to sentry
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 3.2.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
{
|
|
45
45
|
"path": "../../editor-toolbar-model/afm-passionfruit/tsconfig.json"
|
|
46
46
|
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../../../platform/feature-flags/afm-passionfruit/tsconfig.json"
|
|
49
|
+
},
|
|
47
50
|
{
|
|
48
51
|
"path": "../../../platform/feature-flags-react/afm-passionfruit/tsconfig.json"
|
|
49
52
|
},
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
{
|
|
45
45
|
"path": "../../editor-toolbar-model/afm-post-office/tsconfig.json"
|
|
46
46
|
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../../../platform/feature-flags/afm-post-office/tsconfig.json"
|
|
49
|
+
},
|
|
47
50
|
{
|
|
48
51
|
"path": "../../../platform/feature-flags-react/afm-post-office/tsconfig.json"
|
|
49
52
|
},
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
{
|
|
45
45
|
"path": "../../editor-toolbar-model/afm-rovo-extension/tsconfig.json"
|
|
46
46
|
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../../../platform/feature-flags/afm-rovo-extension/tsconfig.json"
|
|
49
|
+
},
|
|
47
50
|
{
|
|
48
51
|
"path": "../../../platform/feature-flags-react/afm-rovo-extension/tsconfig.json"
|
|
49
52
|
},
|
|
@@ -12,6 +12,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
14
14
|
var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
17
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
17
18
|
var _consts = require("./ui/consts");
|
|
@@ -184,6 +185,14 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
184
185
|
if (!editorView) {
|
|
185
186
|
return null;
|
|
186
187
|
}
|
|
188
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_patch_7')) {
|
|
189
|
+
return /*#__PURE__*/_react.default.createElement(_SelectionToolbar.SelectionToolbarWithErrorBoundary, {
|
|
190
|
+
api: api,
|
|
191
|
+
editorView: editorView,
|
|
192
|
+
mountPoint: popupsMountPoint,
|
|
193
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
|
|
194
|
+
});
|
|
195
|
+
}
|
|
187
196
|
return /*#__PURE__*/_react.default.createElement(_SelectionToolbar.SelectionToolbar, {
|
|
188
197
|
api: api,
|
|
189
198
|
editorView: editorView,
|
|
@@ -4,26 +4,28 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.SelectionToolbar = void 0;
|
|
7
|
+
exports.SelectionToolbarWithErrorBoundary = exports.SelectionToolbar = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
|
-
var
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
12
|
+
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
12
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
|
-
var
|
|
14
|
+
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
14
15
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
15
16
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
16
17
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
17
18
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
19
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
|
-
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
20
20
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
21
21
|
var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
|
|
22
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
23
|
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
|
|
23
24
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
24
25
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
25
26
|
var _consts = require("../consts");
|
|
26
|
-
var
|
|
27
|
+
var _keyboardConfig = require("./keyboard-config");
|
|
28
|
+
var _utils2 = require("./utils");
|
|
27
29
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
28
30
|
var isToolbarComponent = function isToolbarComponent(component) {
|
|
29
31
|
return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
|
|
@@ -67,6 +69,42 @@ var usePluginState = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(fun
|
|
|
67
69
|
selectedNode: selectedNode
|
|
68
70
|
};
|
|
69
71
|
});
|
|
72
|
+
var useOnPositionCalculated = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(function () {
|
|
73
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_patch_7');
|
|
74
|
+
}, function (editorView) {
|
|
75
|
+
var onPositionCalculated = (0, _react.useCallback)(function (position) {
|
|
76
|
+
try {
|
|
77
|
+
var toolbarTitle = _consts.SELECTION_TOOLBAR_LABEL;
|
|
78
|
+
|
|
79
|
+
// Show special position on cell selection only when editor controls experiment is enabled
|
|
80
|
+
var isEditorControlsEnabled = (0, _expValEquals.expValEquals)('platform_editor_controls', 'cohort', 'variant1');
|
|
81
|
+
var isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
82
|
+
if (isCellSelection && isEditorControlsEnabled) {
|
|
83
|
+
return (0, _utils.calculateToolbarPositionOnCellSelection)(toolbarTitle)(editorView, position);
|
|
84
|
+
}
|
|
85
|
+
return (0, _utils.calculateToolbarPositionTrackHead)(toolbarTitle)(editorView, position);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
(0, _monitoring.logException)(error, {
|
|
88
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
89
|
+
});
|
|
90
|
+
return position;
|
|
91
|
+
}
|
|
92
|
+
}, [editorView]);
|
|
93
|
+
return onPositionCalculated;
|
|
94
|
+
}, function (editorView) {
|
|
95
|
+
var onPositionCalculated = (0, _react.useCallback)(function (position) {
|
|
96
|
+
var toolbarTitle = _consts.SELECTION_TOOLBAR_LABEL;
|
|
97
|
+
|
|
98
|
+
// Show special position on cell selection only when editor controls experiment is enabled
|
|
99
|
+
var isEditorControlsEnabled = (0, _expValEquals.expValEquals)('platform_editor_controls', 'cohort', 'variant1');
|
|
100
|
+
var isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
101
|
+
if (isCellSelection && isEditorControlsEnabled) {
|
|
102
|
+
return (0, _utils.calculateToolbarPositionOnCellSelection)(toolbarTitle)(editorView, position);
|
|
103
|
+
}
|
|
104
|
+
return (0, _utils.calculateToolbarPositionTrackHead)(toolbarTitle)(editorView, position);
|
|
105
|
+
}, [editorView]);
|
|
106
|
+
return onPositionCalculated;
|
|
107
|
+
});
|
|
70
108
|
var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref) {
|
|
71
109
|
var _api$toolbar;
|
|
72
110
|
var api = _ref.api,
|
|
@@ -86,7 +124,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
86
124
|
return isToolbarComponent(component);
|
|
87
125
|
});
|
|
88
126
|
var keyboardNavigation = (0, _react.useMemo)(function () {
|
|
89
|
-
return getKeyboardNavigationConfig(editorView, intl, api);
|
|
127
|
+
return (0, _keyboardConfig.getKeyboardNavigationConfig)(editorView, intl, api);
|
|
90
128
|
}, [editorView, intl, api]);
|
|
91
129
|
var _useToolbarUI = (0, _editorToolbar.useToolbarUI)(),
|
|
92
130
|
isDisabled = _useToolbarUI.isDisabled;
|
|
@@ -95,17 +133,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
95
133
|
var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof _state.TextSelection;
|
|
96
134
|
var isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof _state.AllSelection;
|
|
97
135
|
var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
98
|
-
var onPositionCalculated = (
|
|
99
|
-
var toolbarTitle = _consts.SELECTION_TOOLBAR_LABEL;
|
|
100
|
-
|
|
101
|
-
// Show special position on cell selection only when editor controls experiment is enabled
|
|
102
|
-
var isEditorControlsEnabled = (0, _expValEquals.expValEquals)('platform_editor_controls', 'cohort', 'variant1');
|
|
103
|
-
var isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
104
|
-
if (isCellSelection && isEditorControlsEnabled) {
|
|
105
|
-
return (0, _utils.calculateToolbarPositionOnCellSelection)(toolbarTitle)(editorView, position);
|
|
106
|
-
}
|
|
107
|
-
return (0, _utils.calculateToolbarPositionTrackHead)(toolbarTitle)(editorView, position);
|
|
108
|
-
}, [editorView]);
|
|
136
|
+
var onPositionCalculated = useOnPositionCalculated(editorView);
|
|
109
137
|
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
110
138
|
return null;
|
|
111
139
|
}
|
|
@@ -114,7 +142,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
114
142
|
}
|
|
115
143
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
116
144
|
offset: [0, 10],
|
|
117
|
-
target: getDomRefFromSelection(editorView),
|
|
145
|
+
target: (0, _utils2.getDomRefFromSelection)(editorView),
|
|
118
146
|
onPositionCalculated: onPositionCalculated,
|
|
119
147
|
mountTo: mountPoint
|
|
120
148
|
}, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
|
|
@@ -142,78 +170,21 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
142
170
|
}
|
|
143
171
|
}))));
|
|
144
172
|
};
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
// attributes: {
|
|
163
|
-
// component: CONTENT_COMPONENT.FLOATING_TOOLBAR,
|
|
164
|
-
// selection: view.state.selection.toJSON(),
|
|
165
|
-
// position: view.state.selection.from,
|
|
166
|
-
// docSize: view.state.doc.nodeSize,
|
|
167
|
-
// error: error.toString(),
|
|
168
|
-
// // @ts-expect-error - Object literal may only specify known properties, 'errorStack' does not exist in type
|
|
169
|
-
// // This error was introduced after upgrading to TypeScript 5
|
|
170
|
-
// errorStack: error.stack || undefined,
|
|
171
|
-
// },
|
|
172
|
-
// };
|
|
173
|
-
// dispatchAnalyticsEvent(payload);
|
|
174
|
-
// }
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
var getKeyboardNavigationConfig = function getKeyboardNavigationConfig(editorView, intl, api) {
|
|
178
|
-
if (!(editorView.dom instanceof HTMLElement)) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
var toolbarSelector = "[data-testid='editor-floating-toolbar']";
|
|
182
|
-
return {
|
|
183
|
-
childComponentSelector: toolbarSelector,
|
|
184
|
-
dom: editorView.dom,
|
|
185
|
-
isShortcutToFocusToolbar: _toolbar2.isShortcutToFocusToolbar,
|
|
186
|
-
handleFocus: function handleFocus(event) {
|
|
187
|
-
var _getDocument, _filteredFocusableEle, _filteredFocusableEle2, _filteredFocusableEle3;
|
|
188
|
-
var toolbar = (_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector(toolbarSelector);
|
|
189
|
-
if (!(toolbar instanceof HTMLElement)) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
var filteredFocusableElements = (0, _toolbar2.getFocusableElements)(toolbar);
|
|
193
|
-
(_filteredFocusableEle = filteredFocusableElements[0]) === null || _filteredFocusableEle === void 0 || _filteredFocusableEle.focus();
|
|
194
|
-
|
|
195
|
-
// the button element removes the focus ring so this class adds it back
|
|
196
|
-
if (((_filteredFocusableEle2 = filteredFocusableElements[0]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.tagName) === 'BUTTON') {
|
|
197
|
-
filteredFocusableElements[0].classList.add('first-floating-toolbar-button');
|
|
198
|
-
}
|
|
199
|
-
(_filteredFocusableEle3 = filteredFocusableElements[0]) === null || _filteredFocusableEle3 === void 0 || _filteredFocusableEle3.scrollIntoView({
|
|
200
|
-
behavior: 'smooth',
|
|
201
|
-
block: 'center',
|
|
202
|
-
inline: 'nearest'
|
|
203
|
-
});
|
|
204
|
-
event.preventDefault();
|
|
205
|
-
event.stopPropagation();
|
|
206
|
-
},
|
|
207
|
-
handleEscape: function handleEscape(event) {
|
|
208
|
-
var isDropdownOpen = !!document.querySelector('[data-toolbar-component="menu-section"]');
|
|
209
|
-
if (isDropdownOpen) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
api === null || api === void 0 || api.core.actions.focus();
|
|
213
|
-
event.preventDefault();
|
|
214
|
-
event.stopPropagation();
|
|
215
|
-
},
|
|
216
|
-
ariaControls: _ui.EDIT_AREA_ID,
|
|
217
|
-
ariaLabel: intl.formatMessage(_messages.fullPageMessages.toolbarLabel)
|
|
218
|
-
};
|
|
173
|
+
var SelectionToolbarWithErrorBoundary = exports.SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErrorBoundary(_ref2) {
|
|
174
|
+
var _api$analytics2;
|
|
175
|
+
var api = _ref2.api,
|
|
176
|
+
editorView = _ref2.editorView,
|
|
177
|
+
mountPoint = _ref2.mountPoint,
|
|
178
|
+
disableSelectionToolbarWhenPinned = _ref2.disableSelectionToolbarWhenPinned;
|
|
179
|
+
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
180
|
+
component: _analytics.ACTION_SUBJECT.TOOLBAR,
|
|
181
|
+
componentId: _analytics.ACTION_SUBJECT_ID.SELECTION_TOOLBAR,
|
|
182
|
+
dispatchAnalyticsEvent: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
183
|
+
fallbackComponent: null
|
|
184
|
+
}, /*#__PURE__*/_react.default.createElement(SelectionToolbar, {
|
|
185
|
+
api: api,
|
|
186
|
+
editorView: editorView,
|
|
187
|
+
mountPoint: mountPoint,
|
|
188
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
|
|
189
|
+
}));
|
|
219
190
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getKeyboardNavigationConfig = void 0;
|
|
7
|
+
var _browserApis = require("@atlaskit/browser-apis");
|
|
8
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
9
|
+
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
10
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
11
|
+
var _toolbar = require("../utils/toolbar");
|
|
12
|
+
var getKeyboardNavigationConfig = exports.getKeyboardNavigationConfig = function getKeyboardNavigationConfig(editorView, intl, api) {
|
|
13
|
+
if (!(editorView.dom instanceof HTMLElement)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
var toolbarSelector = "[data-testid='editor-floating-toolbar']";
|
|
17
|
+
return {
|
|
18
|
+
childComponentSelector: toolbarSelector,
|
|
19
|
+
dom: editorView.dom,
|
|
20
|
+
isShortcutToFocusToolbar: _toolbar.isShortcutToFocusToolbar,
|
|
21
|
+
handleFocus: function handleFocus(event) {
|
|
22
|
+
try {
|
|
23
|
+
var _getDocument, _filteredFocusableEle, _filteredFocusableEle2, _filteredFocusableEle3;
|
|
24
|
+
var toolbar = (_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector(toolbarSelector);
|
|
25
|
+
if (!(toolbar instanceof HTMLElement)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
var filteredFocusableElements = (0, _toolbar.getFocusableElements)(toolbar);
|
|
29
|
+
(_filteredFocusableEle = filteredFocusableElements[0]) === null || _filteredFocusableEle === void 0 || _filteredFocusableEle.focus();
|
|
30
|
+
|
|
31
|
+
// the button element removes the focus ring so this class adds it back
|
|
32
|
+
if (((_filteredFocusableEle2 = filteredFocusableElements[0]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.tagName) === 'BUTTON') {
|
|
33
|
+
filteredFocusableElements[0].classList.add('first-floating-toolbar-button');
|
|
34
|
+
}
|
|
35
|
+
(_filteredFocusableEle3 = filteredFocusableElements[0]) === null || _filteredFocusableEle3 === void 0 || _filteredFocusableEle3.scrollIntoView({
|
|
36
|
+
behavior: 'smooth',
|
|
37
|
+
block: 'center',
|
|
38
|
+
inline: 'nearest'
|
|
39
|
+
});
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error instanceof Error) {
|
|
44
|
+
(0, _monitoring.logException)(error, {
|
|
45
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
handleEscape: function handleEscape(event) {
|
|
51
|
+
try {
|
|
52
|
+
var isDropdownOpen = !!document.querySelector('[data-toolbar-component="menu-section"]');
|
|
53
|
+
if (isDropdownOpen) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
api === null || api === void 0 || api.core.actions.focus();
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (error instanceof Error) {
|
|
61
|
+
(0, _monitoring.logException)(error, {
|
|
62
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
ariaControls: _ui.EDIT_AREA_ID,
|
|
68
|
+
ariaLabel: intl.formatMessage(_messages.fullPageMessages.toolbarLabel)
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDomRefFromSelection = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
9
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
+
var getDomRefFromSelection = exports.getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
|
|
11
|
+
try {
|
|
12
|
+
var domRef = (0, _utils.findDomRefAtPos)(view.state.selection.from, view.domAtPos.bind(view));
|
|
13
|
+
if (domRef instanceof HTMLElement) {
|
|
14
|
+
return domRef;
|
|
15
|
+
}
|
|
16
|
+
throw new Error('Invalid DOM reference');
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (dispatchAnalyticsEvent) {
|
|
19
|
+
var payload = {
|
|
20
|
+
action: _analytics.ACTION.ERRORED,
|
|
21
|
+
actionSubject: _analytics.ACTION_SUBJECT.CONTENT_COMPONENT,
|
|
22
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
23
|
+
attributes: {
|
|
24
|
+
component: _analytics.CONTENT_COMPONENT.SELECTION_TOOLBAR,
|
|
25
|
+
selection: view.state.selection.toJSON(),
|
|
26
|
+
position: view.state.selection.from,
|
|
27
|
+
docSize: view.state.doc.nodeSize,
|
|
28
|
+
error: error instanceof Error ? error.toString() : String(error),
|
|
29
|
+
// @ts-expect-error - Object literal may only specify known properties, 'errorStack' does not exist in type
|
|
30
|
+
// This error was introduced after upgrading to TypeScript 5
|
|
31
|
+
errorStack: error instanceof Error ? error.stack : undefined
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
dispatchAnalyticsEvent(payload);
|
|
35
|
+
}
|
|
36
|
+
if (error instanceof Error) {
|
|
37
|
+
(0, _monitoring.logException)(error, {
|
|
38
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -4,10 +4,11 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
4
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findSelectedNodeOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
9
|
import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
9
10
|
import { DEFAULT_POPUP_SELECTORS } from './ui/consts';
|
|
10
|
-
import { SelectionToolbar } from './ui/SelectionToolbar';
|
|
11
|
+
import { SelectionToolbar, SelectionToolbarWithErrorBoundary } from './ui/SelectionToolbar';
|
|
11
12
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
12
13
|
import { isEventInContainer } from './ui/utils/toolbar';
|
|
13
14
|
function getSelectedNode(editorState) {
|
|
@@ -177,6 +178,14 @@ export const toolbarPlugin = ({
|
|
|
177
178
|
if (!editorView) {
|
|
178
179
|
return null;
|
|
179
180
|
}
|
|
181
|
+
if (fg('platform_editor_toolbar_aifc_patch_7')) {
|
|
182
|
+
return /*#__PURE__*/React.createElement(SelectionToolbarWithErrorBoundary, {
|
|
183
|
+
api: api,
|
|
184
|
+
editorView: editorView,
|
|
185
|
+
mountPoint: popupsMountPoint,
|
|
186
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
|
|
187
|
+
});
|
|
188
|
+
}
|
|
180
189
|
return /*#__PURE__*/React.createElement(SelectionToolbar, {
|
|
181
190
|
api: api,
|
|
182
191
|
editorView: editorView,
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
|
-
import {
|
|
3
|
+
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
5
|
+
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
5
6
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
6
|
-
import {
|
|
7
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
7
8
|
import { EditorToolbarProvider, EditorToolbarUIProvider } from '@atlaskit/editor-common/toolbar';
|
|
8
|
-
import { Popup
|
|
9
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
9
10
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
10
11
|
import { calculateToolbarPositionTrackHead, calculateToolbarPositionOnCellSelection } from '@atlaskit/editor-common/utils';
|
|
11
12
|
import { AllSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
13
13
|
import { ToolbarSection, ToolbarButtonGroup, ToolbarDropdownItemSection, useToolbarUI } from '@atlaskit/editor-toolbar';
|
|
14
14
|
import { ToolbarModelRenderer } from '@atlaskit/editor-toolbar-model';
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
16
|
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
16
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
18
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
18
19
|
import { SELECTION_TOOLBAR_LABEL } from '../consts';
|
|
19
|
-
import {
|
|
20
|
+
import { getKeyboardNavigationConfig } from './keyboard-config';
|
|
21
|
+
import { getDomRefFromSelection } from './utils';
|
|
20
22
|
const isToolbarComponent = component => {
|
|
21
23
|
return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
|
|
22
24
|
};
|
|
@@ -58,6 +60,40 @@ const usePluginState = conditionalHooksFactory(() => expValEquals('platform_edit
|
|
|
58
60
|
selectedNode
|
|
59
61
|
};
|
|
60
62
|
});
|
|
63
|
+
const useOnPositionCalculated = conditionalHooksFactory(() => fg('platform_editor_toolbar_aifc_patch_7'), editorView => {
|
|
64
|
+
const onPositionCalculated = useCallback(position => {
|
|
65
|
+
try {
|
|
66
|
+
const toolbarTitle = SELECTION_TOOLBAR_LABEL;
|
|
67
|
+
|
|
68
|
+
// Show special position on cell selection only when editor controls experiment is enabled
|
|
69
|
+
const isEditorControlsEnabled = expValEquals('platform_editor_controls', 'cohort', 'variant1');
|
|
70
|
+
const isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
71
|
+
if (isCellSelection && isEditorControlsEnabled) {
|
|
72
|
+
return calculateToolbarPositionOnCellSelection(toolbarTitle)(editorView, position);
|
|
73
|
+
}
|
|
74
|
+
return calculateToolbarPositionTrackHead(toolbarTitle)(editorView, position);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
logException(error, {
|
|
77
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
78
|
+
});
|
|
79
|
+
return position;
|
|
80
|
+
}
|
|
81
|
+
}, [editorView]);
|
|
82
|
+
return onPositionCalculated;
|
|
83
|
+
}, editorView => {
|
|
84
|
+
const onPositionCalculated = useCallback(position => {
|
|
85
|
+
const toolbarTitle = SELECTION_TOOLBAR_LABEL;
|
|
86
|
+
|
|
87
|
+
// Show special position on cell selection only when editor controls experiment is enabled
|
|
88
|
+
const isEditorControlsEnabled = expValEquals('platform_editor_controls', 'cohort', 'variant1');
|
|
89
|
+
const isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
90
|
+
if (isCellSelection && isEditorControlsEnabled) {
|
|
91
|
+
return calculateToolbarPositionOnCellSelection(toolbarTitle)(editorView, position);
|
|
92
|
+
}
|
|
93
|
+
return calculateToolbarPositionTrackHead(toolbarTitle)(editorView, position);
|
|
94
|
+
}, [editorView]);
|
|
95
|
+
return onPositionCalculated;
|
|
96
|
+
});
|
|
61
97
|
export const SelectionToolbar = ({
|
|
62
98
|
api,
|
|
63
99
|
editorView,
|
|
@@ -88,17 +124,7 @@ export const SelectionToolbar = ({
|
|
|
88
124
|
const isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
|
|
89
125
|
const isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof AllSelection;
|
|
90
126
|
const isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
91
|
-
const onPositionCalculated =
|
|
92
|
-
const toolbarTitle = SELECTION_TOOLBAR_LABEL;
|
|
93
|
-
|
|
94
|
-
// Show special position on cell selection only when editor controls experiment is enabled
|
|
95
|
-
const isEditorControlsEnabled = expValEquals('platform_editor_controls', 'cohort', 'variant1');
|
|
96
|
-
const isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
97
|
-
if (isCellSelection && isEditorControlsEnabled) {
|
|
98
|
-
return calculateToolbarPositionOnCellSelection(toolbarTitle)(editorView, position);
|
|
99
|
-
}
|
|
100
|
-
return calculateToolbarPositionTrackHead(toolbarTitle)(editorView, position);
|
|
101
|
-
}, [editorView]);
|
|
127
|
+
const onPositionCalculated = useOnPositionCalculated(editorView);
|
|
102
128
|
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
103
129
|
return null;
|
|
104
130
|
}
|
|
@@ -135,78 +161,22 @@ export const SelectionToolbar = ({
|
|
|
135
161
|
}
|
|
136
162
|
}))));
|
|
137
163
|
};
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// component: CONTENT_COMPONENT.FLOATING_TOOLBAR,
|
|
157
|
-
// selection: view.state.selection.toJSON(),
|
|
158
|
-
// position: view.state.selection.from,
|
|
159
|
-
// docSize: view.state.doc.nodeSize,
|
|
160
|
-
// error: error.toString(),
|
|
161
|
-
// // @ts-expect-error - Object literal may only specify known properties, 'errorStack' does not exist in type
|
|
162
|
-
// // This error was introduced after upgrading to TypeScript 5
|
|
163
|
-
// errorStack: error.stack || undefined,
|
|
164
|
-
// },
|
|
165
|
-
// };
|
|
166
|
-
// dispatchAnalyticsEvent(payload);
|
|
167
|
-
// }
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const getKeyboardNavigationConfig = (editorView, intl, api) => {
|
|
171
|
-
if (!(editorView.dom instanceof HTMLElement)) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const toolbarSelector = "[data-testid='editor-floating-toolbar']";
|
|
175
|
-
return {
|
|
176
|
-
childComponentSelector: toolbarSelector,
|
|
177
|
-
dom: editorView.dom,
|
|
178
|
-
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
179
|
-
handleFocus: event => {
|
|
180
|
-
var _getDocument, _filteredFocusableEle, _filteredFocusableEle2, _filteredFocusableEle3;
|
|
181
|
-
const toolbar = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector(toolbarSelector);
|
|
182
|
-
if (!(toolbar instanceof HTMLElement)) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
const filteredFocusableElements = getFocusableElements(toolbar);
|
|
186
|
-
(_filteredFocusableEle = filteredFocusableElements[0]) === null || _filteredFocusableEle === void 0 ? void 0 : _filteredFocusableEle.focus();
|
|
187
|
-
|
|
188
|
-
// the button element removes the focus ring so this class adds it back
|
|
189
|
-
if (((_filteredFocusableEle2 = filteredFocusableElements[0]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.tagName) === 'BUTTON') {
|
|
190
|
-
filteredFocusableElements[0].classList.add('first-floating-toolbar-button');
|
|
191
|
-
}
|
|
192
|
-
(_filteredFocusableEle3 = filteredFocusableElements[0]) === null || _filteredFocusableEle3 === void 0 ? void 0 : _filteredFocusableEle3.scrollIntoView({
|
|
193
|
-
behavior: 'smooth',
|
|
194
|
-
block: 'center',
|
|
195
|
-
inline: 'nearest'
|
|
196
|
-
});
|
|
197
|
-
event.preventDefault();
|
|
198
|
-
event.stopPropagation();
|
|
199
|
-
},
|
|
200
|
-
handleEscape: event => {
|
|
201
|
-
const isDropdownOpen = !!document.querySelector('[data-toolbar-component="menu-section"]');
|
|
202
|
-
if (isDropdownOpen) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
206
|
-
event.preventDefault();
|
|
207
|
-
event.stopPropagation();
|
|
208
|
-
},
|
|
209
|
-
ariaControls: EDIT_AREA_ID,
|
|
210
|
-
ariaLabel: intl.formatMessage(fullPageMessages.toolbarLabel)
|
|
211
|
-
};
|
|
164
|
+
export const SelectionToolbarWithErrorBoundary = ({
|
|
165
|
+
api,
|
|
166
|
+
editorView,
|
|
167
|
+
mountPoint,
|
|
168
|
+
disableSelectionToolbarWhenPinned
|
|
169
|
+
}) => {
|
|
170
|
+
var _api$analytics2;
|
|
171
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
172
|
+
component: ACTION_SUBJECT.TOOLBAR,
|
|
173
|
+
componentId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR,
|
|
174
|
+
dispatchAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
175
|
+
fallbackComponent: null
|
|
176
|
+
}, /*#__PURE__*/React.createElement(SelectionToolbar, {
|
|
177
|
+
api: api,
|
|
178
|
+
editorView: editorView,
|
|
179
|
+
mountPoint: mountPoint,
|
|
180
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
|
|
181
|
+
}));
|
|
212
182
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getDocument } from '@atlaskit/browser-apis';
|
|
2
|
+
import { fullPageMessages } from '@atlaskit/editor-common/messages';
|
|
3
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
+
import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { getFocusableElements, isShortcutToFocusToolbar } from '../utils/toolbar';
|
|
6
|
+
export const getKeyboardNavigationConfig = (editorView, intl, api) => {
|
|
7
|
+
if (!(editorView.dom instanceof HTMLElement)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const toolbarSelector = "[data-testid='editor-floating-toolbar']";
|
|
11
|
+
return {
|
|
12
|
+
childComponentSelector: toolbarSelector,
|
|
13
|
+
dom: editorView.dom,
|
|
14
|
+
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
15
|
+
handleFocus: event => {
|
|
16
|
+
try {
|
|
17
|
+
var _getDocument, _filteredFocusableEle, _filteredFocusableEle2, _filteredFocusableEle3;
|
|
18
|
+
const toolbar = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector(toolbarSelector);
|
|
19
|
+
if (!(toolbar instanceof HTMLElement)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const filteredFocusableElements = getFocusableElements(toolbar);
|
|
23
|
+
(_filteredFocusableEle = filteredFocusableElements[0]) === null || _filteredFocusableEle === void 0 ? void 0 : _filteredFocusableEle.focus();
|
|
24
|
+
|
|
25
|
+
// the button element removes the focus ring so this class adds it back
|
|
26
|
+
if (((_filteredFocusableEle2 = filteredFocusableElements[0]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.tagName) === 'BUTTON') {
|
|
27
|
+
filteredFocusableElements[0].classList.add('first-floating-toolbar-button');
|
|
28
|
+
}
|
|
29
|
+
(_filteredFocusableEle3 = filteredFocusableElements[0]) === null || _filteredFocusableEle3 === void 0 ? void 0 : _filteredFocusableEle3.scrollIntoView({
|
|
30
|
+
behavior: 'smooth',
|
|
31
|
+
block: 'center',
|
|
32
|
+
inline: 'nearest'
|
|
33
|
+
});
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
event.stopPropagation();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error instanceof Error) {
|
|
38
|
+
logException(error, {
|
|
39
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
handleEscape: event => {
|
|
45
|
+
try {
|
|
46
|
+
const isDropdownOpen = !!document.querySelector('[data-toolbar-component="menu-section"]');
|
|
47
|
+
if (isDropdownOpen) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
logException(error, {
|
|
56
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
ariaControls: EDIT_AREA_ID,
|
|
62
|
+
ariaLabel: intl.formatMessage(fullPageMessages.toolbarLabel)
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, CONTENT_COMPONENT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
|
+
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
export const getDomRefFromSelection = (view, dispatchAnalyticsEvent) => {
|
|
5
|
+
try {
|
|
6
|
+
const domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
|
|
7
|
+
if (domRef instanceof HTMLElement) {
|
|
8
|
+
return domRef;
|
|
9
|
+
}
|
|
10
|
+
throw new Error('Invalid DOM reference');
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (dispatchAnalyticsEvent) {
|
|
13
|
+
const payload = {
|
|
14
|
+
action: ACTION.ERRORED,
|
|
15
|
+
actionSubject: ACTION_SUBJECT.CONTENT_COMPONENT,
|
|
16
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
17
|
+
attributes: {
|
|
18
|
+
component: CONTENT_COMPONENT.SELECTION_TOOLBAR,
|
|
19
|
+
selection: view.state.selection.toJSON(),
|
|
20
|
+
position: view.state.selection.from,
|
|
21
|
+
docSize: view.state.doc.nodeSize,
|
|
22
|
+
error: error instanceof Error ? error.toString() : String(error),
|
|
23
|
+
// @ts-expect-error - Object literal may only specify known properties, 'errorStack' does not exist in type
|
|
24
|
+
// This error was introduced after upgrading to TypeScript 5
|
|
25
|
+
errorStack: error instanceof Error ? error.stack : undefined
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
dispatchAnalyticsEvent(payload);
|
|
29
|
+
}
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
logException(error, {
|
|
32
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -7,10 +7,11 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
7
7
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { findSelectedNodeOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
12
13
|
import { DEFAULT_POPUP_SELECTORS } from './ui/consts';
|
|
13
|
-
import { SelectionToolbar } from './ui/SelectionToolbar';
|
|
14
|
+
import { SelectionToolbar, SelectionToolbarWithErrorBoundary } from './ui/SelectionToolbar';
|
|
14
15
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
15
16
|
import { isEventInContainer } from './ui/utils/toolbar';
|
|
16
17
|
function getSelectedNode(editorState) {
|
|
@@ -177,6 +178,14 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
177
178
|
if (!editorView) {
|
|
178
179
|
return null;
|
|
179
180
|
}
|
|
181
|
+
if (fg('platform_editor_toolbar_aifc_patch_7')) {
|
|
182
|
+
return /*#__PURE__*/React.createElement(SelectionToolbarWithErrorBoundary, {
|
|
183
|
+
api: api,
|
|
184
|
+
editorView: editorView,
|
|
185
|
+
mountPoint: popupsMountPoint,
|
|
186
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
|
|
187
|
+
});
|
|
188
|
+
}
|
|
180
189
|
return /*#__PURE__*/React.createElement(SelectionToolbar, {
|
|
181
190
|
api: api,
|
|
182
191
|
editorView: editorView,
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
|
-
import {
|
|
3
|
+
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
5
|
+
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
5
6
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
6
|
-
import {
|
|
7
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
7
8
|
import { EditorToolbarProvider, EditorToolbarUIProvider } from '@atlaskit/editor-common/toolbar';
|
|
8
|
-
import { Popup
|
|
9
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
9
10
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
10
11
|
import { calculateToolbarPositionTrackHead, calculateToolbarPositionOnCellSelection } from '@atlaskit/editor-common/utils';
|
|
11
12
|
import { AllSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
13
13
|
import { ToolbarSection, ToolbarButtonGroup, ToolbarDropdownItemSection, useToolbarUI } from '@atlaskit/editor-toolbar';
|
|
14
14
|
import { ToolbarModelRenderer } from '@atlaskit/editor-toolbar-model';
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
16
|
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
16
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
18
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
18
19
|
import { SELECTION_TOOLBAR_LABEL } from '../consts';
|
|
19
|
-
import {
|
|
20
|
+
import { getKeyboardNavigationConfig } from './keyboard-config';
|
|
21
|
+
import { getDomRefFromSelection } from './utils';
|
|
20
22
|
var isToolbarComponent = function isToolbarComponent(component) {
|
|
21
23
|
return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
|
|
22
24
|
};
|
|
@@ -59,6 +61,42 @@ var usePluginState = conditionalHooksFactory(function () {
|
|
|
59
61
|
selectedNode: selectedNode
|
|
60
62
|
};
|
|
61
63
|
});
|
|
64
|
+
var useOnPositionCalculated = conditionalHooksFactory(function () {
|
|
65
|
+
return fg('platform_editor_toolbar_aifc_patch_7');
|
|
66
|
+
}, function (editorView) {
|
|
67
|
+
var onPositionCalculated = useCallback(function (position) {
|
|
68
|
+
try {
|
|
69
|
+
var toolbarTitle = SELECTION_TOOLBAR_LABEL;
|
|
70
|
+
|
|
71
|
+
// Show special position on cell selection only when editor controls experiment is enabled
|
|
72
|
+
var isEditorControlsEnabled = expValEquals('platform_editor_controls', 'cohort', 'variant1');
|
|
73
|
+
var isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
74
|
+
if (isCellSelection && isEditorControlsEnabled) {
|
|
75
|
+
return calculateToolbarPositionOnCellSelection(toolbarTitle)(editorView, position);
|
|
76
|
+
}
|
|
77
|
+
return calculateToolbarPositionTrackHead(toolbarTitle)(editorView, position);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
logException(error, {
|
|
80
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
81
|
+
});
|
|
82
|
+
return position;
|
|
83
|
+
}
|
|
84
|
+
}, [editorView]);
|
|
85
|
+
return onPositionCalculated;
|
|
86
|
+
}, function (editorView) {
|
|
87
|
+
var onPositionCalculated = useCallback(function (position) {
|
|
88
|
+
var toolbarTitle = SELECTION_TOOLBAR_LABEL;
|
|
89
|
+
|
|
90
|
+
// Show special position on cell selection only when editor controls experiment is enabled
|
|
91
|
+
var isEditorControlsEnabled = expValEquals('platform_editor_controls', 'cohort', 'variant1');
|
|
92
|
+
var isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
93
|
+
if (isCellSelection && isEditorControlsEnabled) {
|
|
94
|
+
return calculateToolbarPositionOnCellSelection(toolbarTitle)(editorView, position);
|
|
95
|
+
}
|
|
96
|
+
return calculateToolbarPositionTrackHead(toolbarTitle)(editorView, position);
|
|
97
|
+
}, [editorView]);
|
|
98
|
+
return onPositionCalculated;
|
|
99
|
+
});
|
|
62
100
|
export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
63
101
|
var _api$toolbar;
|
|
64
102
|
var api = _ref.api,
|
|
@@ -87,17 +125,7 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
87
125
|
var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
|
|
88
126
|
var isAllSelection = !editorView.state.selection.empty && editorView.state.selection instanceof AllSelection;
|
|
89
127
|
var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
|
|
90
|
-
var onPositionCalculated =
|
|
91
|
-
var toolbarTitle = SELECTION_TOOLBAR_LABEL;
|
|
92
|
-
|
|
93
|
-
// Show special position on cell selection only when editor controls experiment is enabled
|
|
94
|
-
var isEditorControlsEnabled = expValEquals('platform_editor_controls', 'cohort', 'variant1');
|
|
95
|
-
var isCellSelection = ('$anchorCell' in editorView.state.selection);
|
|
96
|
-
if (isCellSelection && isEditorControlsEnabled) {
|
|
97
|
-
return calculateToolbarPositionOnCellSelection(toolbarTitle)(editorView, position);
|
|
98
|
-
}
|
|
99
|
-
return calculateToolbarPositionTrackHead(toolbarTitle)(editorView, position);
|
|
100
|
-
}, [editorView]);
|
|
128
|
+
var onPositionCalculated = useOnPositionCalculated(editorView);
|
|
101
129
|
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
102
130
|
return null;
|
|
103
131
|
}
|
|
@@ -134,78 +162,21 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
134
162
|
}
|
|
135
163
|
}))));
|
|
136
164
|
};
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// attributes: {
|
|
155
|
-
// component: CONTENT_COMPONENT.FLOATING_TOOLBAR,
|
|
156
|
-
// selection: view.state.selection.toJSON(),
|
|
157
|
-
// position: view.state.selection.from,
|
|
158
|
-
// docSize: view.state.doc.nodeSize,
|
|
159
|
-
// error: error.toString(),
|
|
160
|
-
// // @ts-expect-error - Object literal may only specify known properties, 'errorStack' does not exist in type
|
|
161
|
-
// // This error was introduced after upgrading to TypeScript 5
|
|
162
|
-
// errorStack: error.stack || undefined,
|
|
163
|
-
// },
|
|
164
|
-
// };
|
|
165
|
-
// dispatchAnalyticsEvent(payload);
|
|
166
|
-
// }
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
var getKeyboardNavigationConfig = function getKeyboardNavigationConfig(editorView, intl, api) {
|
|
170
|
-
if (!(editorView.dom instanceof HTMLElement)) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
var toolbarSelector = "[data-testid='editor-floating-toolbar']";
|
|
174
|
-
return {
|
|
175
|
-
childComponentSelector: toolbarSelector,
|
|
176
|
-
dom: editorView.dom,
|
|
177
|
-
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
178
|
-
handleFocus: function handleFocus(event) {
|
|
179
|
-
var _getDocument, _filteredFocusableEle, _filteredFocusableEle2, _filteredFocusableEle3;
|
|
180
|
-
var toolbar = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector(toolbarSelector);
|
|
181
|
-
if (!(toolbar instanceof HTMLElement)) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
var filteredFocusableElements = getFocusableElements(toolbar);
|
|
185
|
-
(_filteredFocusableEle = filteredFocusableElements[0]) === null || _filteredFocusableEle === void 0 || _filteredFocusableEle.focus();
|
|
186
|
-
|
|
187
|
-
// the button element removes the focus ring so this class adds it back
|
|
188
|
-
if (((_filteredFocusableEle2 = filteredFocusableElements[0]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.tagName) === 'BUTTON') {
|
|
189
|
-
filteredFocusableElements[0].classList.add('first-floating-toolbar-button');
|
|
190
|
-
}
|
|
191
|
-
(_filteredFocusableEle3 = filteredFocusableElements[0]) === null || _filteredFocusableEle3 === void 0 || _filteredFocusableEle3.scrollIntoView({
|
|
192
|
-
behavior: 'smooth',
|
|
193
|
-
block: 'center',
|
|
194
|
-
inline: 'nearest'
|
|
195
|
-
});
|
|
196
|
-
event.preventDefault();
|
|
197
|
-
event.stopPropagation();
|
|
198
|
-
},
|
|
199
|
-
handleEscape: function handleEscape(event) {
|
|
200
|
-
var isDropdownOpen = !!document.querySelector('[data-toolbar-component="menu-section"]');
|
|
201
|
-
if (isDropdownOpen) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
api === null || api === void 0 || api.core.actions.focus();
|
|
205
|
-
event.preventDefault();
|
|
206
|
-
event.stopPropagation();
|
|
207
|
-
},
|
|
208
|
-
ariaControls: EDIT_AREA_ID,
|
|
209
|
-
ariaLabel: intl.formatMessage(fullPageMessages.toolbarLabel)
|
|
210
|
-
};
|
|
165
|
+
export var SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErrorBoundary(_ref2) {
|
|
166
|
+
var _api$analytics2;
|
|
167
|
+
var api = _ref2.api,
|
|
168
|
+
editorView = _ref2.editorView,
|
|
169
|
+
mountPoint = _ref2.mountPoint,
|
|
170
|
+
disableSelectionToolbarWhenPinned = _ref2.disableSelectionToolbarWhenPinned;
|
|
171
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
172
|
+
component: ACTION_SUBJECT.TOOLBAR,
|
|
173
|
+
componentId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR,
|
|
174
|
+
dispatchAnalyticsEvent: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
175
|
+
fallbackComponent: null
|
|
176
|
+
}, /*#__PURE__*/React.createElement(SelectionToolbar, {
|
|
177
|
+
api: api,
|
|
178
|
+
editorView: editorView,
|
|
179
|
+
mountPoint: mountPoint,
|
|
180
|
+
disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
|
|
181
|
+
}));
|
|
211
182
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getDocument } from '@atlaskit/browser-apis';
|
|
2
|
+
import { fullPageMessages } from '@atlaskit/editor-common/messages';
|
|
3
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
+
import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { getFocusableElements, isShortcutToFocusToolbar } from '../utils/toolbar';
|
|
6
|
+
export var getKeyboardNavigationConfig = function getKeyboardNavigationConfig(editorView, intl, api) {
|
|
7
|
+
if (!(editorView.dom instanceof HTMLElement)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
var toolbarSelector = "[data-testid='editor-floating-toolbar']";
|
|
11
|
+
return {
|
|
12
|
+
childComponentSelector: toolbarSelector,
|
|
13
|
+
dom: editorView.dom,
|
|
14
|
+
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
15
|
+
handleFocus: function handleFocus(event) {
|
|
16
|
+
try {
|
|
17
|
+
var _getDocument, _filteredFocusableEle, _filteredFocusableEle2, _filteredFocusableEle3;
|
|
18
|
+
var toolbar = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector(toolbarSelector);
|
|
19
|
+
if (!(toolbar instanceof HTMLElement)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var filteredFocusableElements = getFocusableElements(toolbar);
|
|
23
|
+
(_filteredFocusableEle = filteredFocusableElements[0]) === null || _filteredFocusableEle === void 0 || _filteredFocusableEle.focus();
|
|
24
|
+
|
|
25
|
+
// the button element removes the focus ring so this class adds it back
|
|
26
|
+
if (((_filteredFocusableEle2 = filteredFocusableElements[0]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.tagName) === 'BUTTON') {
|
|
27
|
+
filteredFocusableElements[0].classList.add('first-floating-toolbar-button');
|
|
28
|
+
}
|
|
29
|
+
(_filteredFocusableEle3 = filteredFocusableElements[0]) === null || _filteredFocusableEle3 === void 0 || _filteredFocusableEle3.scrollIntoView({
|
|
30
|
+
behavior: 'smooth',
|
|
31
|
+
block: 'center',
|
|
32
|
+
inline: 'nearest'
|
|
33
|
+
});
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
event.stopPropagation();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error instanceof Error) {
|
|
38
|
+
logException(error, {
|
|
39
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
handleEscape: function handleEscape(event) {
|
|
45
|
+
try {
|
|
46
|
+
var isDropdownOpen = !!document.querySelector('[data-toolbar-component="menu-section"]');
|
|
47
|
+
if (isDropdownOpen) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
api === null || api === void 0 || api.core.actions.focus();
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
logException(error, {
|
|
56
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
ariaControls: EDIT_AREA_ID,
|
|
62
|
+
ariaLabel: intl.formatMessage(fullPageMessages.toolbarLabel)
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, CONTENT_COMPONENT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
|
+
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
export var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
|
|
5
|
+
try {
|
|
6
|
+
var domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
|
|
7
|
+
if (domRef instanceof HTMLElement) {
|
|
8
|
+
return domRef;
|
|
9
|
+
}
|
|
10
|
+
throw new Error('Invalid DOM reference');
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (dispatchAnalyticsEvent) {
|
|
13
|
+
var payload = {
|
|
14
|
+
action: ACTION.ERRORED,
|
|
15
|
+
actionSubject: ACTION_SUBJECT.CONTENT_COMPONENT,
|
|
16
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
17
|
+
attributes: {
|
|
18
|
+
component: CONTENT_COMPONENT.SELECTION_TOOLBAR,
|
|
19
|
+
selection: view.state.selection.toJSON(),
|
|
20
|
+
position: view.state.selection.from,
|
|
21
|
+
docSize: view.state.doc.nodeSize,
|
|
22
|
+
error: error instanceof Error ? error.toString() : String(error),
|
|
23
|
+
// @ts-expect-error - Object literal may only specify known properties, 'errorStack' does not exist in type
|
|
24
|
+
// This error was introduced after upgrading to TypeScript 5
|
|
25
|
+
errorStack: error instanceof Error ? error.stack : undefined
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
dispatchAnalyticsEvent(payload);
|
|
29
|
+
}
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
logException(error, {
|
|
32
|
+
location: 'editor-plugin-toolbar/selectionToolbar'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import type
|
|
3
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { ToolbarPlugin } from '../../toolbarPluginType';
|
|
5
5
|
type SelectionToolbarProps = {
|
|
6
6
|
api?: ExtractInjectionAPI<ToolbarPlugin>;
|
|
@@ -9,4 +9,5 @@ type SelectionToolbarProps = {
|
|
|
9
9
|
mountPoint: HTMLElement | undefined;
|
|
10
10
|
};
|
|
11
11
|
export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
|
|
12
|
+
export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { type ToolbarKeyboardNavigationProviderConfig } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import type { ToolbarPlugin } from '../../toolbarPluginType';
|
|
6
|
+
export declare const getKeyboardNavigationConfig: (editorView: EditorView, intl: IntlShape, api?: ExtractInjectionAPI<ToolbarPlugin>) => ToolbarKeyboardNavigationProviderConfig | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
export declare const getDomRefFromSelection: (view: EditorView, dispatchAnalyticsEvent?: DispatchAnalyticsEvent) => HTMLElement | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import type
|
|
3
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { ToolbarPlugin } from '../../toolbarPluginType';
|
|
5
5
|
type SelectionToolbarProps = {
|
|
6
6
|
api?: ExtractInjectionAPI<ToolbarPlugin>;
|
|
@@ -9,4 +9,5 @@ type SelectionToolbarProps = {
|
|
|
9
9
|
mountPoint: HTMLElement | undefined;
|
|
10
10
|
};
|
|
11
11
|
export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
|
|
12
|
+
export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { type ToolbarKeyboardNavigationProviderConfig } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import type { ToolbarPlugin } from '../../toolbarPluginType';
|
|
6
|
+
export declare const getKeyboardNavigationConfig: (editorView: EditorView, intl: IntlShape, api?: ExtractInjectionAPI<ToolbarPlugin>) => ToolbarKeyboardNavigationProviderConfig | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
export declare const getDomRefFromSelection: (view: EditorView, dispatchAnalyticsEvent?: DispatchAnalyticsEvent) => HTMLElement | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
39
39
|
"@atlaskit/editor-toolbar": "^0.15.0",
|
|
40
40
|
"@atlaskit/editor-toolbar-model": "^0.2.0",
|
|
41
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
41
42
|
"@atlaskit/platform-feature-flags-react": "^0.3.0",
|
|
42
43
|
"@atlaskit/tmp-editor-statsig": "^13.10.0",
|
|
43
44
|
"@babel/runtime": "^7.0.0",
|
|
@@ -45,9 +46,14 @@
|
|
|
45
46
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"@atlaskit/editor-common": "^110.
|
|
49
|
+
"@atlaskit/editor-common": "^110.12.0",
|
|
49
50
|
"react": "^18.2.0"
|
|
50
51
|
},
|
|
52
|
+
"platform-feature-flags": {
|
|
53
|
+
"platform_editor_toolbar_aifc_patch_7": {
|
|
54
|
+
"type": "boolean"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
51
57
|
"techstack": {
|
|
52
58
|
"@atlassian/frontend": {
|
|
53
59
|
"code-structure": [
|