@atlaskit/editor-plugin-selection-toolbar 4.3.6 → 4.3.8
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
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-toolbar
|
|
2
2
|
|
|
3
|
+
## 4.3.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1dc35286ebb8a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1dc35286ebb8a) -
|
|
8
|
+
[ux] [EDITOR-1064] Added rovo menu on current selection toolbar
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 4.3.7
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 4.3.6
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -173,7 +173,7 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
173
173
|
view: function view(_view) {
|
|
174
174
|
var unbind = (0, _bindEventListener.bind)(_view.root, {
|
|
175
175
|
type: 'mouseup',
|
|
176
|
-
listener: function listener() {
|
|
176
|
+
listener: function listener(event) {
|
|
177
177
|
var _api$editorViewMode;
|
|
178
178
|
// We only want to set selectionStable to true if the editor has focus
|
|
179
179
|
// to prevent the toolbar from showing when the editor is blurred
|
|
@@ -181,6 +181,14 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
|
|
|
181
181
|
|
|
182
182
|
var editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
183
183
|
var isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
184
|
+
if ((0, _experiments.editorExperiment)('platform_editor_ai_aifc', true)) {
|
|
185
|
+
var target = event.target;
|
|
186
|
+
var isRovoChangeToneButton = (target === null || target === void 0 ? void 0 : target.tagName) === 'BUTTON' && _hasNestedSpanWithText(target, 'Change tone') || target.getAttribute('aria-label') === 'Change tone' || target.innerHTML === 'Change tone';
|
|
187
|
+
var isRovoTranslateButton = (target === null || target === void 0 ? void 0 : target.tagName) === 'BUTTON' && _hasNestedSpanWithText(target, 'Translate options') || target.getAttribute('aria-label') === 'Translate options' || target.innerHTML === 'Translate options';
|
|
188
|
+
if (isRovoChangeToneButton || isRovoTranslateButton) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
184
192
|
_view.dispatch(_view.state.tr.setMeta(_pluginKey.selectionToolbarPluginKey, {
|
|
185
193
|
selectionStable: !isViewModeEnabled ? _view.hasFocus() : true
|
|
186
194
|
}));
|
|
@@ -367,4 +375,16 @@ function getSelectionNodeTypes(state) {
|
|
|
367
375
|
}
|
|
368
376
|
});
|
|
369
377
|
return selectionNodeTypes;
|
|
370
|
-
}
|
|
378
|
+
}
|
|
379
|
+
var _hasNestedSpanWithText = function hasNestedSpanWithText(element, text) {
|
|
380
|
+
if (element.tagName === 'SPAN' && element.innerHTML === text) {
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
for (var _i = 0, _Array$from = Array.from(element.children); _i < _Array$from.length; _i++) {
|
|
384
|
+
var child = _Array$from[_i];
|
|
385
|
+
if (_hasNestedSpanWithText(child, text)) {
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return false;
|
|
390
|
+
};
|
|
@@ -171,7 +171,7 @@ export const selectionToolbarPlugin = ({
|
|
|
171
171
|
view(view) {
|
|
172
172
|
const unbind = bind(view.root, {
|
|
173
173
|
type: 'mouseup',
|
|
174
|
-
listener:
|
|
174
|
+
listener: event => {
|
|
175
175
|
var _api$editorViewMode;
|
|
176
176
|
// We only want to set selectionStable to true if the editor has focus
|
|
177
177
|
// to prevent the toolbar from showing when the editor is blurred
|
|
@@ -179,6 +179,14 @@ export const selectionToolbarPlugin = ({
|
|
|
179
179
|
|
|
180
180
|
const editorViewModePlugin = api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
181
181
|
const isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
182
|
+
if (editorExperiment('platform_editor_ai_aifc', true)) {
|
|
183
|
+
const target = event.target;
|
|
184
|
+
const isRovoChangeToneButton = (target === null || target === void 0 ? void 0 : target.tagName) === 'BUTTON' && hasNestedSpanWithText(target, 'Change tone') || target.getAttribute('aria-label') === 'Change tone' || target.innerHTML === 'Change tone';
|
|
185
|
+
const isRovoTranslateButton = (target === null || target === void 0 ? void 0 : target.tagName) === 'BUTTON' && hasNestedSpanWithText(target, 'Translate options') || target.getAttribute('aria-label') === 'Translate options' || target.innerHTML === 'Translate options';
|
|
186
|
+
if (isRovoChangeToneButton || isRovoTranslateButton) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
182
190
|
view.dispatch(view.state.tr.setMeta(selectionToolbarPluginKey, {
|
|
183
191
|
selectionStable: !isViewModeEnabled ? view.hasFocus() : true
|
|
184
192
|
}));
|
|
@@ -360,4 +368,15 @@ function getSelectionNodeTypes(state) {
|
|
|
360
368
|
}
|
|
361
369
|
});
|
|
362
370
|
return selectionNodeTypes;
|
|
363
|
-
}
|
|
371
|
+
}
|
|
372
|
+
const hasNestedSpanWithText = (element, text) => {
|
|
373
|
+
if (element.tagName === 'SPAN' && element.innerHTML === text) {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
for (const child of Array.from(element.children)) {
|
|
377
|
+
if (hasNestedSpanWithText(child, text)) {
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return false;
|
|
382
|
+
};
|
|
@@ -166,7 +166,7 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
166
166
|
view: function view(_view) {
|
|
167
167
|
var unbind = bind(_view.root, {
|
|
168
168
|
type: 'mouseup',
|
|
169
|
-
listener: function listener() {
|
|
169
|
+
listener: function listener(event) {
|
|
170
170
|
var _api$editorViewMode;
|
|
171
171
|
// We only want to set selectionStable to true if the editor has focus
|
|
172
172
|
// to prevent the toolbar from showing when the editor is blurred
|
|
@@ -174,6 +174,14 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
|
|
|
174
174
|
|
|
175
175
|
var editorViewModePlugin = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState();
|
|
176
176
|
var isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
|
|
177
|
+
if (editorExperiment('platform_editor_ai_aifc', true)) {
|
|
178
|
+
var target = event.target;
|
|
179
|
+
var isRovoChangeToneButton = (target === null || target === void 0 ? void 0 : target.tagName) === 'BUTTON' && _hasNestedSpanWithText(target, 'Change tone') || target.getAttribute('aria-label') === 'Change tone' || target.innerHTML === 'Change tone';
|
|
180
|
+
var isRovoTranslateButton = (target === null || target === void 0 ? void 0 : target.tagName) === 'BUTTON' && _hasNestedSpanWithText(target, 'Translate options') || target.getAttribute('aria-label') === 'Translate options' || target.innerHTML === 'Translate options';
|
|
181
|
+
if (isRovoChangeToneButton || isRovoTranslateButton) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
177
185
|
_view.dispatch(_view.state.tr.setMeta(selectionToolbarPluginKey, {
|
|
178
186
|
selectionStable: !isViewModeEnabled ? _view.hasFocus() : true
|
|
179
187
|
}));
|
|
@@ -360,4 +368,16 @@ function getSelectionNodeTypes(state) {
|
|
|
360
368
|
}
|
|
361
369
|
});
|
|
362
370
|
return selectionNodeTypes;
|
|
363
|
-
}
|
|
371
|
+
}
|
|
372
|
+
var _hasNestedSpanWithText = function hasNestedSpanWithText(element, text) {
|
|
373
|
+
if (element.tagName === 'SPAN' && element.innerHTML === text) {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
for (var _i = 0, _Array$from = Array.from(element.children); _i < _Array$from.length; _i++) {
|
|
377
|
+
var child = _Array$from[_i];
|
|
378
|
+
if (_hasNestedSpanWithText(child, text)) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return false;
|
|
383
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-toolbar",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.8",
|
|
4
4
|
"description": "@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
45
45
|
"@atlaskit/editor-toolbar": "^0.3.0",
|
|
46
46
|
"@atlaskit/editor-toolbar-model": "^0.1.0",
|
|
47
|
-
"@atlaskit/icon": "^
|
|
47
|
+
"@atlaskit/icon": "^28.0.0",
|
|
48
48
|
"@atlaskit/icon-lab": "^5.6.0",
|
|
49
49
|
"@atlaskit/menu": "^8.3.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"bind-event-listener": "^3.0.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@atlaskit/editor-common": "^107.
|
|
57
|
+
"@atlaskit/editor-common": "^107.27.0",
|
|
58
58
|
"react": "^18.2.0",
|
|
59
59
|
"react-dom": "^18.2.0",
|
|
60
60
|
"react-intl-next": "npm:react-intl@^5.18.1"
|