@atlaskit/editor-plugin-type-ahead 1.10.7 → 1.11.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 +21 -0
- package/dist/cjs/pm-plugins/commands/update-selected-index.js +7 -1
- package/dist/cjs/pm-plugins/decorations.js +6 -3
- package/dist/cjs/pm-plugins/item-is-disabled.js +11 -0
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/cjs/pm-plugins/utils.js +33 -4
- package/dist/cjs/typeAheadPlugin.js +2 -1
- package/dist/cjs/ui/TypeAheadList.js +19 -9
- package/dist/cjs/ui/TypeAheadListItem.js +39 -13
- package/dist/cjs/ui/TypeAheadMenu.js +3 -3
- package/dist/cjs/ui/TypeAheadPopup.js +5 -2
- package/dist/cjs/ui/WrapperTypeAhead.js +18 -7
- package/dist/cjs/ui/hooks/use-item-insert.js +7 -2
- package/dist/es2019/pm-plugins/commands/update-selected-index.js +7 -1
- package/dist/es2019/pm-plugins/decorations.js +6 -3
- package/dist/es2019/pm-plugins/item-is-disabled.js +5 -0
- package/dist/es2019/pm-plugins/main.js +4 -2
- package/dist/es2019/pm-plugins/utils.js +30 -3
- package/dist/es2019/typeAheadPlugin.js +2 -1
- package/dist/es2019/ui/TypeAheadList.js +17 -9
- package/dist/es2019/ui/TypeAheadListItem.js +39 -13
- package/dist/es2019/ui/TypeAheadMenu.js +3 -3
- package/dist/es2019/ui/TypeAheadPopup.js +5 -2
- package/dist/es2019/ui/WrapperTypeAhead.js +17 -8
- package/dist/es2019/ui/hooks/use-item-insert.js +7 -2
- package/dist/esm/pm-plugins/commands/update-selected-index.js +7 -1
- package/dist/esm/pm-plugins/decorations.js +6 -3
- package/dist/esm/pm-plugins/item-is-disabled.js +5 -0
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/pm-plugins/utils.js +32 -3
- package/dist/esm/typeAheadPlugin.js +2 -1
- package/dist/esm/ui/TypeAheadList.js +19 -9
- package/dist/esm/ui/TypeAheadListItem.js +38 -13
- package/dist/esm/ui/TypeAheadMenu.js +3 -3
- package/dist/esm/ui/TypeAheadPopup.js +5 -2
- package/dist/esm/ui/WrapperTypeAhead.js +19 -8
- package/dist/esm/ui/hooks/use-item-insert.js +7 -2
- package/dist/types/pm-plugins/commands/update-selected-index.d.ts +3 -2
- package/dist/types/pm-plugins/decorations.d.ts +4 -1
- package/dist/types/pm-plugins/item-is-disabled.d.ts +4 -0
- package/dist/types/pm-plugins/main.d.ts +4 -1
- package/dist/types/pm-plugins/utils.d.ts +6 -1
- package/dist/types/typeAheadPluginType.d.ts +6 -1
- package/dist/types/ui/TypeAheadList.d.ts +4 -0
- package/dist/types/ui/TypeAheadListItem.d.ts +5 -1
- package/dist/types/ui/WrapperTypeAhead.d.ts +4 -1
- package/dist/types/ui/hooks/use-item-insert.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/commands/update-selected-index.d.ts +3 -2
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +4 -1
- package/dist/types-ts4.5/pm-plugins/item-is-disabled.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -1
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +6 -1
- package/dist/types-ts4.5/typeAheadPluginType.d.ts +3 -1
- package/dist/types-ts4.5/ui/TypeAheadList.d.ts +4 -0
- package/dist/types-ts4.5/ui/TypeAheadListItem.d.ts +5 -1
- package/dist/types-ts4.5/ui/WrapperTypeAhead.d.ts +4 -1
- package/dist/types-ts4.5/ui/hooks/use-item-insert.d.ts +3 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-type-ahead
|
|
2
2
|
|
|
3
|
+
## 1.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#171350](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171350)
|
|
8
|
+
[`436dfb28a4833`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/436dfb28a4833) -
|
|
9
|
+
[ux] Support disabled type-ahead items while user is offline for media, emoji, and mentions.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 1.10.8
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#165765](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165765)
|
|
20
|
+
[`3f441f30e6507`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f441f30e6507) -
|
|
21
|
+
Bump adf-schema to 46.0.0
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 1.10.7
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -5,13 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.updateSelectedIndex = void 0;
|
|
7
7
|
var _actions = require("../actions");
|
|
8
|
+
var _itemIsDisabled = require("../item-is-disabled");
|
|
8
9
|
var _key = require("../key");
|
|
9
|
-
var updateSelectedIndex = exports.updateSelectedIndex = function updateSelectedIndex(selectedIndex) {
|
|
10
|
+
var updateSelectedIndex = exports.updateSelectedIndex = function updateSelectedIndex(selectedIndex, api) {
|
|
10
11
|
return function (state, dispatch) {
|
|
11
12
|
var pluginState = _key.pluginKey.getState(state);
|
|
12
13
|
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectedIndex) === selectedIndex) {
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
16
|
+
|
|
17
|
+
// If the new index is disabled ignore this call, we can use the previous index
|
|
18
|
+
if ((0, _itemIsDisabled.itemIsDisabled)(pluginState === null || pluginState === void 0 ? void 0 : pluginState.items[selectedIndex], api)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
15
21
|
var tr = state.tr;
|
|
16
22
|
tr.setMeta(_key.pluginKey, {
|
|
17
23
|
action: _actions.ACTIONS.UPDATE_SELECTED_INDEX,
|
|
@@ -23,7 +23,8 @@ var _utils = require("./utils");
|
|
|
23
23
|
var factoryDecorations = exports.factoryDecorations = function factoryDecorations(_ref) {
|
|
24
24
|
var intl = _ref.intl,
|
|
25
25
|
popupMountRef = _ref.popupMountRef,
|
|
26
|
-
nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI
|
|
26
|
+
nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI,
|
|
27
|
+
api = _ref.api;
|
|
27
28
|
var createDecorations = function createDecorations(tr, _ref2) {
|
|
28
29
|
var triggerHandler = _ref2.triggerHandler,
|
|
29
30
|
inputMethod = _ref2.inputMethod,
|
|
@@ -96,7 +97,8 @@ var factoryDecorations = exports.factoryDecorations = function factoryDecoration
|
|
|
96
97
|
popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
|
|
97
98
|
popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
|
|
98
99
|
onUndoRedo: onUndoRedo,
|
|
99
|
-
reopenQuery: reopenQuery
|
|
100
|
+
reopenQuery: reopenQuery,
|
|
101
|
+
api: api
|
|
100
102
|
}));
|
|
101
103
|
}, typeaheadComponent, decorationId);
|
|
102
104
|
} else {
|
|
@@ -116,7 +118,8 @@ var factoryDecorations = exports.factoryDecorations = function factoryDecoration
|
|
|
116
118
|
popupsBoundariesElement: (_popupMountRef$curren5 = popupMountRef.current) === null || _popupMountRef$curren5 === void 0 ? void 0 : _popupMountRef$curren5.popupsBoundariesElement,
|
|
117
119
|
popupsScrollableElement: (_popupMountRef$curren6 = popupMountRef.current) === null || _popupMountRef$curren6 === void 0 ? void 0 : _popupMountRef$curren6.popupsScrollableElement,
|
|
118
120
|
onUndoRedo: onUndoRedo,
|
|
119
|
-
reopenQuery: reopenQuery
|
|
121
|
+
reopenQuery: reopenQuery,
|
|
122
|
+
api: api
|
|
120
123
|
})), typeaheadComponent);
|
|
121
124
|
}
|
|
122
125
|
shouldFocusCursorInsideQuery = false;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.itemIsDisabled = void 0;
|
|
7
|
+
var itemIsDisabled = exports.itemIsDisabled = function itemIsDisabled(item, api) {
|
|
8
|
+
var _api$connectivity;
|
|
9
|
+
var isOffline = (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
|
|
10
|
+
return isOffline && (item === null || item === void 0 ? void 0 : item.isDisabledOffline) === true;
|
|
11
|
+
};
|
|
@@ -31,12 +31,14 @@ function createPlugin(_ref) {
|
|
|
31
31
|
popupMountRef = _ref.popupMountRef,
|
|
32
32
|
typeAheadHandlers = _ref.typeAheadHandlers,
|
|
33
33
|
getIntl = _ref.getIntl,
|
|
34
|
-
nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI
|
|
34
|
+
nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI,
|
|
35
|
+
api = _ref.api;
|
|
35
36
|
var intl = getIntl();
|
|
36
37
|
var _factoryDecorations = (0, _decorations.factoryDecorations)({
|
|
37
38
|
intl: intl,
|
|
38
39
|
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
|
|
39
|
-
popupMountRef: popupMountRef
|
|
40
|
+
popupMountRef: popupMountRef,
|
|
41
|
+
api: api
|
|
40
42
|
}),
|
|
41
43
|
createDecorations = _factoryDecorations.createDecorations,
|
|
42
44
|
removeDecorations = _factoryDecorations.removeDecorations;
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.moveSelectedIndex = exports.isTypeAheadOpen = exports.isTypeAheadHandler = exports.isTypeAheadAllowed = exports.getTypeAheadQuery = exports.getTypeAheadListAriaLabels = exports.getTypeAheadHandler = exports.getPluginState = exports.findHandlerByTrigger = exports.findHandler = void 0;
|
|
6
|
+
exports.skipForwardToSafeItem = exports.skipBackwardToSafeItem = exports.moveSelectedIndex = exports.isTypeAheadOpen = exports.isTypeAheadHandler = exports.isTypeAheadAllowed = exports.getTypeAheadQuery = exports.getTypeAheadListAriaLabels = exports.getTypeAheadHandler = exports.getPluginState = exports.findHandlerByTrigger = exports.findHandler = void 0;
|
|
7
7
|
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
8
8
|
var _updateSelectedIndex = require("./commands/update-selected-index");
|
|
9
|
+
var _itemIsDisabled = require("./item-is-disabled");
|
|
9
10
|
var _key = require("./key");
|
|
10
11
|
var _statsModifier = require("./stats-modifier");
|
|
11
12
|
var isTypeAheadHandler = exports.isTypeAheadHandler = function isTypeAheadHandler(handler) {
|
|
@@ -44,6 +45,26 @@ var findHandler = exports.findHandler = function findHandler(id, state) {
|
|
|
44
45
|
return h.id === id;
|
|
45
46
|
}) || null;
|
|
46
47
|
};
|
|
48
|
+
var skipForwardToSafeItem = exports.skipForwardToSafeItem = function skipForwardToSafeItem(currentIndex, nextIndex, listSize, itemIsDisabled) {
|
|
49
|
+
// Use a loop to find the next selectable item
|
|
50
|
+
for (var idx = nextIndex; idx < listSize; idx++) {
|
|
51
|
+
if (!itemIsDisabled(idx)) {
|
|
52
|
+
return idx;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// If no selectable items are found, return currentIndex
|
|
56
|
+
return currentIndex;
|
|
57
|
+
};
|
|
58
|
+
var skipBackwardToSafeItem = exports.skipBackwardToSafeItem = function skipBackwardToSafeItem(currentIndex, nextIndex, itemIsDisabled) {
|
|
59
|
+
// Use a loop to find the next non-selectable item when going backwards
|
|
60
|
+
for (var idx = nextIndex; idx >= 0; idx--) {
|
|
61
|
+
if (!itemIsDisabled(idx)) {
|
|
62
|
+
return idx;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// If no non-selectable items are found, return currentIndex
|
|
66
|
+
return currentIndex;
|
|
67
|
+
};
|
|
47
68
|
var findHandlerByTrigger = exports.findHandlerByTrigger = function findHandlerByTrigger(_ref) {
|
|
48
69
|
var trigger = _ref.trigger,
|
|
49
70
|
editorState = _ref.editorState;
|
|
@@ -58,7 +79,8 @@ var findHandlerByTrigger = exports.findHandlerByTrigger = function findHandlerBy
|
|
|
58
79
|
};
|
|
59
80
|
var moveSelectedIndex = exports.moveSelectedIndex = function moveSelectedIndex(_ref2) {
|
|
60
81
|
var editorView = _ref2.editorView,
|
|
61
|
-
direction = _ref2.direction
|
|
82
|
+
direction = _ref2.direction,
|
|
83
|
+
api = _ref2.api;
|
|
62
84
|
return function () {
|
|
63
85
|
var typeAheadState = getPluginState(editorView.state);
|
|
64
86
|
if (!typeAheadState) {
|
|
@@ -68,6 +90,9 @@ var moveSelectedIndex = exports.moveSelectedIndex = function moveSelectedIndex(_
|
|
|
68
90
|
items = typeAheadState.items;
|
|
69
91
|
var stats = typeAheadState.stats instanceof _statsModifier.StatsModifier ? typeAheadState.stats : new _statsModifier.StatsModifier();
|
|
70
92
|
var nextIndex;
|
|
93
|
+
var isDisabled = function isDisabled(idx) {
|
|
94
|
+
return (0, _itemIsDisabled.itemIsDisabled)(items[idx], api);
|
|
95
|
+
};
|
|
71
96
|
if (direction === 'next') {
|
|
72
97
|
stats.increaseArrowDown();
|
|
73
98
|
|
|
@@ -83,15 +108,19 @@ var moveSelectedIndex = exports.moveSelectedIndex = function moveSelectedIndex(_
|
|
|
83
108
|
*
|
|
84
109
|
*/
|
|
85
110
|
if (selectedIndex === -1 && items.length > 1) {
|
|
86
|
-
|
|
111
|
+
// If the first item is disabled we actually want to skip to the 3rd item
|
|
112
|
+
// on the first arrow down
|
|
113
|
+
nextIndex = isDisabled(0) && items.length > 2 ? 2 : 1;
|
|
87
114
|
} else {
|
|
88
115
|
nextIndex = selectedIndex >= items.length - 1 ? 0 : selectedIndex + 1;
|
|
89
116
|
}
|
|
117
|
+
nextIndex = skipForwardToSafeItem(selectedIndex, nextIndex, items.length, isDisabled);
|
|
90
118
|
} else {
|
|
91
119
|
stats.increaseArrowUp();
|
|
92
120
|
nextIndex = selectedIndex <= 0 ? items.length - 1 : selectedIndex - 1;
|
|
121
|
+
nextIndex = skipBackwardToSafeItem(selectedIndex, nextIndex, isDisabled);
|
|
93
122
|
}
|
|
94
|
-
(0, _updateSelectedIndex.updateSelectedIndex)(nextIndex)(editorView.state, editorView.dispatch);
|
|
123
|
+
(0, _updateSelectedIndex.updateSelectedIndex)(nextIndex, api)(editorView.state, editorView.dispatch);
|
|
95
124
|
};
|
|
96
125
|
};
|
|
97
126
|
var getTypeAheadListAriaLabels = exports.getTypeAheadListAriaLabels = function getTypeAheadListAriaLabels(trigger, intl, item) {
|
|
@@ -170,7 +170,8 @@ var typeAheadPlugin = exports.typeAheadPlugin = function typeAheadPlugin(_ref) {
|
|
|
170
170
|
popupMountRef: popupMountRef,
|
|
171
171
|
reactDispatch: dispatch,
|
|
172
172
|
typeAheadHandlers: typeAhead,
|
|
173
|
-
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI
|
|
173
|
+
nodeViewPortalProviderAPI: nodeViewPortalProviderAPI,
|
|
174
|
+
api: api
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
177
|
}, {
|
|
@@ -59,7 +59,8 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
59
59
|
fitHeight = _ref2.fitHeight,
|
|
60
60
|
decorationElement = _ref2.decorationElement,
|
|
61
61
|
triggerHandler = _ref2.triggerHandler,
|
|
62
|
-
moreElementsInQuickInsertViewEnabled = _ref2.moreElementsInQuickInsertViewEnabled
|
|
62
|
+
moreElementsInQuickInsertViewEnabled = _ref2.moreElementsInQuickInsertViewEnabled,
|
|
63
|
+
api = _ref2.api;
|
|
63
64
|
var listRef = (0, _react.useRef)();
|
|
64
65
|
var listContainerRef = (0, _react.useRef)(null);
|
|
65
66
|
var lastVisibleIndexes = (0, _react.useRef)({
|
|
@@ -94,22 +95,24 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
94
95
|
var focusTargetElement = (0, _react.useCallback)(function () {
|
|
95
96
|
var _decorationElement$qu;
|
|
96
97
|
//To reset the selected index
|
|
97
|
-
(0, _updateSelectedIndex.updateSelectedIndex)(-1)(editorView.state, editorView.dispatch);
|
|
98
|
+
(0, _updateSelectedIndex.updateSelectedIndex)(-1, api)(editorView.state, editorView.dispatch);
|
|
98
99
|
listRef.current.scrollToRow(0);
|
|
99
100
|
decorationElement === null || decorationElement === void 0 || (_decorationElement$qu = decorationElement.querySelector("[role='combobox']")) === null || _decorationElement$qu === void 0 || _decorationElement$qu.focus();
|
|
100
|
-
}, [editorView, listRef, decorationElement]);
|
|
101
|
+
}, [editorView, listRef, decorationElement, api]);
|
|
101
102
|
var selectNextItem = (0, _react.useMemo)(function () {
|
|
102
103
|
return (0, _utils.moveSelectedIndex)({
|
|
103
104
|
editorView: editorView,
|
|
104
|
-
direction: 'next'
|
|
105
|
+
direction: 'next',
|
|
106
|
+
api: api
|
|
105
107
|
});
|
|
106
|
-
}, [editorView]);
|
|
108
|
+
}, [editorView, api]);
|
|
107
109
|
var selectPreviousItem = (0, _react.useMemo)(function () {
|
|
108
110
|
return (0, _utils.moveSelectedIndex)({
|
|
109
111
|
editorView: editorView,
|
|
110
|
-
direction: 'previous'
|
|
112
|
+
direction: 'previous',
|
|
113
|
+
api: api
|
|
111
114
|
});
|
|
112
|
-
}, [editorView]);
|
|
115
|
+
}, [editorView, api]);
|
|
113
116
|
var lastVisibleStartIndex = lastVisibleIndexes.current.startIndex;
|
|
114
117
|
var lastVisibleStopIndex = lastVisibleIndexes.current.stopIndex;
|
|
115
118
|
var onScroll = (0, _react.useCallback)(
|
|
@@ -149,7 +152,7 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
149
152
|
if (selectedIndex === index) {
|
|
150
153
|
return;
|
|
151
154
|
}
|
|
152
|
-
(0, _updateSelectedIndex.updateSelectedIndex)(index)(editorView.state, editorView.dispatch);
|
|
155
|
+
(0, _updateSelectedIndex.updateSelectedIndex)(index, api)(editorView.state, editorView.dispatch);
|
|
153
156
|
};
|
|
154
157
|
(0, _react.useLayoutEffect)(function () {
|
|
155
158
|
if (!listRef.current) {
|
|
@@ -235,6 +238,11 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
235
238
|
element === null || element === void 0 || element.removeEventListener('keydown', handleKeyDown);
|
|
236
239
|
};
|
|
237
240
|
}, [editorView.state, focusTargetElement, selectNextItem, selectPreviousItem, selectedIndex, onItemClick, items.length]);
|
|
241
|
+
var firstOnlineSupportedRow = (0, _react.useMemo)(function () {
|
|
242
|
+
return items.findIndex(function (item) {
|
|
243
|
+
return item.isDisabledOffline !== true;
|
|
244
|
+
});
|
|
245
|
+
}, [items]);
|
|
238
246
|
var renderRow = function renderRow(_ref4) {
|
|
239
247
|
var index = _ref4.index,
|
|
240
248
|
key = _ref4.key,
|
|
@@ -258,12 +266,14 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
258
266
|
}, (0, _react2.jsx)(_TypeAheadListItem.TypeAheadListItem, {
|
|
259
267
|
key: items[index].title,
|
|
260
268
|
item: currentItem,
|
|
269
|
+
firstOnlineSupportedIndex: firstOnlineSupportedRow,
|
|
261
270
|
itemsLength: items.length,
|
|
262
271
|
itemIndex: index,
|
|
263
272
|
selectedIndex: selectedIndex,
|
|
264
273
|
onItemClick: actions.onItemClick,
|
|
265
274
|
ariaLabel: (0, _utils.getTypeAheadListAriaLabels)(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger, intl, currentItem).listItemAriaLabel,
|
|
266
|
-
moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled
|
|
275
|
+
moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
|
|
276
|
+
api: api
|
|
267
277
|
}))));
|
|
268
278
|
};
|
|
269
279
|
var popupAriaLabel = (0, _utils.getTypeAheadListAriaLabels)(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger, intl).popupAriaLabel;
|
|
@@ -10,14 +10,14 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _reactIntlNext = require("react-intl-next");
|
|
13
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
14
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
14
15
|
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
15
16
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
16
17
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
17
18
|
var _menu = require("@atlaskit/menu");
|
|
18
19
|
var _colors = require("@atlaskit/theme/colors");
|
|
19
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
20
|
-
/* eslint-disable jsx-a11y/role-supports-aria-props */
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
21
21
|
/**
|
|
22
22
|
* @jsxRuntime classic
|
|
23
23
|
* @jsx jsx
|
|
@@ -111,6 +111,9 @@ var selectionFrame = {
|
|
|
111
111
|
|
|
112
112
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Ignored via go/DSP-18766
|
|
113
113
|
var selectedStyle = (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n\tbackground-color: ", ";\n\tbox-shadow: inset 2px 0px 0px ", ";\n"])), "var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N30, ")"), "var(--ds-border-focused, ".concat(_colors.B400, ")"));
|
|
114
|
+
var disabledStyle = (0, _react2.css)({
|
|
115
|
+
color: "var(--ds-text-disabled, #091E424F)"
|
|
116
|
+
});
|
|
114
117
|
var FallbackIcon = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
115
118
|
var label = _ref.label;
|
|
116
119
|
return (0, _react2.jsx)(_quickInsert.IconFallback, null);
|
|
@@ -119,6 +122,7 @@ var noop = function noop() {};
|
|
|
119
122
|
var CustomItemComponentWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
120
123
|
var customRenderItem = props.customRenderItem,
|
|
121
124
|
isSelected = props.isSelected,
|
|
125
|
+
itemIsDisabled = props.itemIsDisabled,
|
|
122
126
|
ariaLabel = props.ariaLabel,
|
|
123
127
|
itemsLength = props.itemsLength,
|
|
124
128
|
customItemRef = props.customItemRef,
|
|
@@ -126,8 +130,8 @@ var CustomItemComponentWrapper = /*#__PURE__*/_react.default.memo(function (prop
|
|
|
126
130
|
itemIndex = props.itemIndex;
|
|
127
131
|
var Comp = customRenderItem;
|
|
128
132
|
var listItemClasses = (0, _react.useMemo)(function () {
|
|
129
|
-
return [customRenderItemDivStyle, isSelected && selectedStyle];
|
|
130
|
-
}, [isSelected]);
|
|
133
|
+
return [customRenderItemDivStyle, isSelected && !itemIsDisabled && selectedStyle, itemIsDisabled && disabledStyle];
|
|
134
|
+
}, [isSelected, itemIsDisabled]);
|
|
131
135
|
return (0, _react2.jsx)("div", {
|
|
132
136
|
"aria-selected": isSelected,
|
|
133
137
|
role: "option",
|
|
@@ -160,12 +164,29 @@ var TypeAheadListItem = exports.TypeAheadListItem = /*#__PURE__*/_react.default.
|
|
|
160
164
|
onItemClick = _ref2.onItemClick,
|
|
161
165
|
itemIndex = _ref2.itemIndex,
|
|
162
166
|
ariaLabel = _ref2.ariaLabel,
|
|
163
|
-
moreElementsInQuickInsertViewEnabled = _ref2.moreElementsInQuickInsertViewEnabled
|
|
167
|
+
moreElementsInQuickInsertViewEnabled = _ref2.moreElementsInQuickInsertViewEnabled,
|
|
168
|
+
api = _ref2.api,
|
|
169
|
+
firstOnlineSupportedIndex = _ref2.firstOnlineSupportedIndex;
|
|
170
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['connectivity']),
|
|
171
|
+
connectivityState = _useSharedPluginState.connectivityState;
|
|
172
|
+
var isItemDisabled = function isItemDisabled(item) {
|
|
173
|
+
var _item$isDisabledOffli;
|
|
174
|
+
return (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline' && ((_item$isDisabledOffli = item === null || item === void 0 ? void 0 : item.isDisabledOffline) !== null && _item$isDisabledOffli !== void 0 ? _item$isDisabledOffli : false);
|
|
175
|
+
};
|
|
176
|
+
var itemIsDisabled = isItemDisabled(item);
|
|
177
|
+
var isFirstEnabledIndex = (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline' && itemIndex === firstOnlineSupportedIndex && selectedIndex === -1;
|
|
178
|
+
|
|
164
179
|
/**
|
|
165
180
|
* To select and highlight the first Item when no item is selected
|
|
166
181
|
* However selectedIndex remains -1, So that user does not skip the first item when down arrow key is used from typeahead query(inputQuery.tsx)
|
|
167
182
|
*/
|
|
168
|
-
var isSelected =
|
|
183
|
+
var isSelected = false;
|
|
184
|
+
// Feature gated - connectivity is only available on desktop and behind a feature gate on full page mode
|
|
185
|
+
if (connectivityState === undefined) {
|
|
186
|
+
isSelected = itemIndex === selectedIndex || selectedIndex === -1 && itemIndex === 0;
|
|
187
|
+
} else {
|
|
188
|
+
isSelected = itemIndex === selectedIndex || selectedIndex === -1 && (itemIndex === 0 || isFirstEnabledIndex) && !itemIsDisabled;
|
|
189
|
+
}
|
|
169
190
|
|
|
170
191
|
// Assistive text
|
|
171
192
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
@@ -182,14 +203,17 @@ var TypeAheadListItem = exports.TypeAheadListItem = /*#__PURE__*/_react.default.
|
|
|
182
203
|
}));
|
|
183
204
|
}, [icon, title, moreElementsInQuickInsertViewEnabled]);
|
|
184
205
|
var insertSelectedItem = (0, _react.useCallback)(function () {
|
|
206
|
+
if (itemIsDisabled) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
185
209
|
onItemClick(_typeAhead.SelectItemMode.SELECTED, itemIndex);
|
|
186
|
-
}, [onItemClick, itemIndex]);
|
|
210
|
+
}, [onItemClick, itemIndex, itemIsDisabled]);
|
|
187
211
|
var customItemRef = _react.default.useRef(null);
|
|
188
212
|
var buttonItemRef = _react.default.useRef(null);
|
|
189
|
-
var shouldUpdateFocus = selectedIndex === itemIndex;
|
|
213
|
+
var shouldUpdateFocus = selectedIndex === itemIndex && !isFirstEnabledIndex;
|
|
190
214
|
var listItemClasses = (0, _react.useMemo)(function () {
|
|
191
|
-
return [selectionFrame, isSelected && selectedStyle];
|
|
192
|
-
}, [isSelected]);
|
|
215
|
+
return [selectionFrame, isSelected && !itemIsDisabled && selectedStyle];
|
|
216
|
+
}, [isSelected, itemIsDisabled]);
|
|
193
217
|
(0, _react.useLayoutEffect)(function () {
|
|
194
218
|
if (shouldUpdateFocus) {
|
|
195
219
|
var _customItemRef$curren;
|
|
@@ -204,6 +228,7 @@ var TypeAheadListItem = exports.TypeAheadListItem = /*#__PURE__*/_react.default.
|
|
|
204
228
|
}, [buttonItemRef, shouldUpdateFocus]);
|
|
205
229
|
if (customRenderItem) {
|
|
206
230
|
return (0, _react2.jsx)(CustomItemComponentWrapper, {
|
|
231
|
+
itemIsDisabled: itemIsDisabled,
|
|
207
232
|
customRenderItem: customRenderItem,
|
|
208
233
|
isSelected: isSelected,
|
|
209
234
|
ariaLabel: ariaLabel,
|
|
@@ -231,7 +256,8 @@ var TypeAheadListItem = exports.TypeAheadListItem = /*#__PURE__*/_react.default.
|
|
|
231
256
|
"aria-setsize": itemsLength,
|
|
232
257
|
"aria-posinset": itemIndex,
|
|
233
258
|
role: "option",
|
|
234
|
-
ref: buttonItemRef
|
|
259
|
+
ref: buttonItemRef,
|
|
260
|
+
isDisabled: itemIsDisabled
|
|
235
261
|
// @ts-ignore
|
|
236
262
|
,
|
|
237
263
|
css: listItemClasses
|
|
@@ -242,13 +268,13 @@ var TypeAheadListItem = exports.TypeAheadListItem = /*#__PURE__*/_react.default.
|
|
|
242
268
|
}, (0, _react2.jsx)("div", {
|
|
243
269
|
css: itemBody
|
|
244
270
|
}, (0, _react2.jsx)("div", {
|
|
245
|
-
css: [itemTitle, moreElementsInQuickInsertViewEnabled && itemTitleOverride]
|
|
271
|
+
css: [itemTitle, moreElementsInQuickInsertViewEnabled && itemTitleOverride, itemIsDisabled && disabledStyle]
|
|
246
272
|
}, item.title), (0, _react2.jsx)("div", {
|
|
247
273
|
css: itemAfter
|
|
248
274
|
}, item.keyshortcut && (0, _react2.jsx)("div", {
|
|
249
275
|
css: _shortcut.shortcutStyle
|
|
250
276
|
}, item.keyshortcut))), (0, _react2.jsx)("div", {
|
|
251
|
-
css: [itemDescription, moreElementsInQuickInsertViewEnabled && itemDescriptionOverride]
|
|
277
|
+
css: [itemDescription, moreElementsInQuickInsertViewEnabled && itemDescriptionOverride, itemIsDisabled && disabledStyle]
|
|
252
278
|
}, item.description)))))
|
|
253
279
|
);
|
|
254
280
|
});
|
|
@@ -24,7 +24,7 @@ var TypeAheadMenu = exports.TypeAheadMenu = /*#__PURE__*/_react.default.memo(fun
|
|
|
24
24
|
decorationElement = typeAheadState.decorationElement,
|
|
25
25
|
decorationSet = typeAheadState.decorationSet,
|
|
26
26
|
query = typeAheadState.query;
|
|
27
|
-
var _useItemInsert = (0, _useItemInsert3.useItemInsert)(triggerHandler, editorView, items),
|
|
27
|
+
var _useItemInsert = (0, _useItemInsert3.useItemInsert)(triggerHandler, editorView, items, api),
|
|
28
28
|
_useItemInsert2 = (0, _slicedToArray2.default)(_useItemInsert, 3),
|
|
29
29
|
onItemInsert = _useItemInsert2[0],
|
|
30
30
|
onTextInsert = _useItemInsert2[1],
|
|
@@ -32,9 +32,9 @@ var TypeAheadMenu = exports.TypeAheadMenu = /*#__PURE__*/_react.default.memo(fun
|
|
|
32
32
|
var setSelectedItem = _react.default.useCallback(function (_ref2) {
|
|
33
33
|
var nextIndex = _ref2.index;
|
|
34
34
|
queueMicrotask(function () {
|
|
35
|
-
(0, _updateSelectedIndex.updateSelectedIndex)(nextIndex)(editorView.state, editorView.dispatch);
|
|
35
|
+
(0, _updateSelectedIndex.updateSelectedIndex)(nextIndex, api)(editorView.state, editorView.dispatch);
|
|
36
36
|
});
|
|
37
|
-
}, [editorView]);
|
|
37
|
+
}, [editorView, api]);
|
|
38
38
|
var insertItem = _react.default.useCallback(function () {
|
|
39
39
|
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _typeAhead.SelectItemMode.SELECTED;
|
|
40
40
|
var index = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -234,7 +234,9 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
|
|
|
234
234
|
ariaLabel: null,
|
|
235
235
|
preventOverflow: true
|
|
236
236
|
}, (0, _react2.jsx)("div", {
|
|
237
|
-
css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride]
|
|
237
|
+
css: [typeAheadContent, moreElementsInQuickInsertViewEnabled && typeAheadContentOverride]
|
|
238
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
239
|
+
,
|
|
238
240
|
tabIndex: 0
|
|
239
241
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
240
242
|
,
|
|
@@ -251,7 +253,8 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
|
|
|
251
253
|
editorView: editorView,
|
|
252
254
|
decorationElement: anchorElement,
|
|
253
255
|
triggerHandler: triggerHandler,
|
|
254
|
-
moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled
|
|
256
|
+
moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
|
|
257
|
+
api: api
|
|
255
258
|
})));
|
|
256
259
|
});
|
|
257
260
|
TypeAheadPopup.displayName = 'TypeAheadPopup';
|
|
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
12
12
|
var _updateQuery = require("../pm-plugins/commands/update-query");
|
|
13
|
+
var _itemIsDisabled = require("../pm-plugins/item-is-disabled");
|
|
13
14
|
var _utils = require("../pm-plugins/utils");
|
|
14
15
|
var _useItemInsert3 = require("./hooks/use-item-insert");
|
|
15
16
|
var _useLoadItems = require("./hooks/use-load-items");
|
|
@@ -28,7 +29,8 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
|
|
|
28
29
|
inputMethod = _ref.inputMethod,
|
|
29
30
|
getDecorationPosition = _ref.getDecorationPosition,
|
|
30
31
|
reopenQuery = _ref.reopenQuery,
|
|
31
|
-
onUndoRedo = _ref.onUndoRedo
|
|
32
|
+
onUndoRedo = _ref.onUndoRedo,
|
|
33
|
+
api = _ref.api;
|
|
32
34
|
var _useState = (0, _react.useState)(false),
|
|
33
35
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
34
36
|
closed = _useState2[0],
|
|
@@ -43,22 +45,24 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
|
|
|
43
45
|
(0, _react.useLayoutEffect)(function () {
|
|
44
46
|
queryRef.current = query;
|
|
45
47
|
}, [query]);
|
|
46
|
-
var _useItemInsert = (0, _useItemInsert3.useItemInsert)(triggerHandler, editorView, items),
|
|
48
|
+
var _useItemInsert = (0, _useItemInsert3.useItemInsert)(triggerHandler, editorView, items, api),
|
|
47
49
|
_useItemInsert2 = (0, _slicedToArray2.default)(_useItemInsert, 2),
|
|
48
50
|
onItemInsert = _useItemInsert2[0],
|
|
49
51
|
onTextInsert = _useItemInsert2[1];
|
|
50
52
|
var selectNextItem = (0, _react.useMemo)(function () {
|
|
51
53
|
return (0, _utils.moveSelectedIndex)({
|
|
52
54
|
editorView: editorView,
|
|
53
|
-
direction: 'next'
|
|
55
|
+
direction: 'next',
|
|
56
|
+
api: api
|
|
54
57
|
});
|
|
55
|
-
}, [editorView]);
|
|
58
|
+
}, [editorView, api]);
|
|
56
59
|
var selectPreviousItem = (0, _react.useMemo)(function () {
|
|
57
60
|
return (0, _utils.moveSelectedIndex)({
|
|
58
61
|
editorView: editorView,
|
|
59
|
-
direction: 'previous'
|
|
62
|
+
direction: 'previous',
|
|
63
|
+
api: api
|
|
60
64
|
});
|
|
61
|
-
}, [editorView]);
|
|
65
|
+
}, [editorView, api]);
|
|
62
66
|
var cancel = (0, _react.useCallback)(function (_ref2) {
|
|
63
67
|
var setSelectionAt = _ref2.setSelectionAt,
|
|
64
68
|
addPrefixTrigger = _ref2.addPrefixTrigger,
|
|
@@ -77,6 +81,13 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
|
|
|
77
81
|
var view = editorViewRef.current;
|
|
78
82
|
var _ref3 = (0, _utils.getPluginState)(view.state),
|
|
79
83
|
selectedIndex = _ref3.selectedIndex;
|
|
84
|
+
var safeSelectedIndex = (0, _utils.skipForwardToSafeItem)(selectedIndex, 1, items.length, function (idx) {
|
|
85
|
+
return (0, _itemIsDisabled.itemIsDisabled)(items[idx], api);
|
|
86
|
+
});
|
|
87
|
+
// If the only safe index is -1 then none are safe - do not insert item
|
|
88
|
+
if (safeSelectedIndex === -1) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
80
91
|
setClosed(true);
|
|
81
92
|
queueMicrotask(function () {
|
|
82
93
|
onItemInsert({
|
|
@@ -85,7 +96,7 @@ var WrapperTypeAhead = exports.WrapperTypeAhead = /*#__PURE__*/_react.default.me
|
|
|
85
96
|
query: queryRef.current
|
|
86
97
|
});
|
|
87
98
|
});
|
|
88
|
-
}, [onItemInsert]);
|
|
99
|
+
}, [onItemInsert, api, items]);
|
|
89
100
|
var showTypeAheadPopupList = (0, _react.useCallback)(function () {}, []);
|
|
90
101
|
var closePopup = (0, _react.useCallback)(function () {
|
|
91
102
|
setClosed(true);
|
|
@@ -10,6 +10,7 @@ var _closeTypeAhead = require("../../pm-plugins/commands/close-type-ahead");
|
|
|
10
10
|
var _insertTypeAheadItem = require("../../pm-plugins/commands/insert-type-ahead-item");
|
|
11
11
|
var _setSelectionBeforeQuery = require("../../pm-plugins/commands/set-selection-before-query");
|
|
12
12
|
var _constants = require("../../pm-plugins/constants");
|
|
13
|
+
var _itemIsDisabled = require("../../pm-plugins/item-is-disabled");
|
|
13
14
|
var insertRawQuery = function insertRawQuery(_ref) {
|
|
14
15
|
var view = _ref.view,
|
|
15
16
|
setSelectionAt = _ref.setSelectionAt,
|
|
@@ -30,7 +31,7 @@ var insertRawQuery = function insertRawQuery(_ref) {
|
|
|
30
31
|
view.focus();
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
|
-
var useItemInsert = exports.useItemInsert = function useItemInsert(triggerHandler, editorView, items) {
|
|
34
|
+
var useItemInsert = exports.useItemInsert = function useItemInsert(triggerHandler, editorView, items, api) {
|
|
34
35
|
var editorViewRef = (0, _react.useRef)(editorView);
|
|
35
36
|
var itemsRef = (0, _react.useRef)(items);
|
|
36
37
|
var onTextInsert = (0, _react.useCallback)(function (_ref2) {
|
|
@@ -66,6 +67,10 @@ var useItemInsert = exports.useItemInsert = function useItemInsert(triggerHandle
|
|
|
66
67
|
if (!itemToInsert) {
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
70
|
+
var isDisabled = (0, _itemIsDisabled.itemIsDisabled)(itemToInsert, api);
|
|
71
|
+
if (isDisabled) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
69
74
|
var view = editorViewRef.current;
|
|
70
75
|
(0, _insertTypeAheadItem.insertTypeAheadItem)(view)({
|
|
71
76
|
item: itemToInsert,
|
|
@@ -74,7 +79,7 @@ var useItemInsert = exports.useItemInsert = function useItemInsert(triggerHandle
|
|
|
74
79
|
query: query,
|
|
75
80
|
sourceListItem: sourceListItem
|
|
76
81
|
});
|
|
77
|
-
}, [triggerHandler, onTextInsert]);
|
|
82
|
+
}, [triggerHandler, onTextInsert, api]);
|
|
78
83
|
var onItemMatch = (0, _react.useCallback)(function (_ref4) {
|
|
79
84
|
var mode = _ref4.mode,
|
|
80
85
|
query = _ref4.query;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { ACTIONS } from '../actions';
|
|
2
|
+
import { itemIsDisabled } from '../item-is-disabled';
|
|
2
3
|
import { pluginKey as typeAheadPluginKey } from '../key';
|
|
3
|
-
export const updateSelectedIndex = selectedIndex => {
|
|
4
|
+
export const updateSelectedIndex = (selectedIndex, api) => {
|
|
4
5
|
return (state, dispatch) => {
|
|
5
6
|
const pluginState = typeAheadPluginKey.getState(state);
|
|
6
7
|
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectedIndex) === selectedIndex) {
|
|
7
8
|
return false;
|
|
8
9
|
}
|
|
10
|
+
|
|
11
|
+
// If the new index is disabled ignore this call, we can use the previous index
|
|
12
|
+
if (itemIsDisabled(pluginState === null || pluginState === void 0 ? void 0 : pluginState.items[selectedIndex], api)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
9
15
|
const tr = state.tr;
|
|
10
16
|
tr.setMeta(typeAheadPluginKey, {
|
|
11
17
|
action: ACTIONS.UPDATE_SELECTED_INDEX,
|
|
@@ -16,7 +16,8 @@ import { getTypeAheadQuery } from './utils';
|
|
|
16
16
|
export const factoryDecorations = ({
|
|
17
17
|
intl,
|
|
18
18
|
popupMountRef,
|
|
19
|
-
nodeViewPortalProviderAPI
|
|
19
|
+
nodeViewPortalProviderAPI,
|
|
20
|
+
api
|
|
20
21
|
}) => {
|
|
21
22
|
const createDecorations = (tr, {
|
|
22
23
|
triggerHandler,
|
|
@@ -95,7 +96,8 @@ export const factoryDecorations = ({
|
|
|
95
96
|
popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
|
|
96
97
|
popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
|
|
97
98
|
onUndoRedo: onUndoRedo,
|
|
98
|
-
reopenQuery: reopenQuery
|
|
99
|
+
reopenQuery: reopenQuery,
|
|
100
|
+
api: api
|
|
99
101
|
}));
|
|
100
102
|
}, typeaheadComponent, decorationId);
|
|
101
103
|
} else {
|
|
@@ -115,7 +117,8 @@ export const factoryDecorations = ({
|
|
|
115
117
|
popupsBoundariesElement: (_popupMountRef$curren5 = popupMountRef.current) === null || _popupMountRef$curren5 === void 0 ? void 0 : _popupMountRef$curren5.popupsBoundariesElement,
|
|
116
118
|
popupsScrollableElement: (_popupMountRef$curren6 = popupMountRef.current) === null || _popupMountRef$curren6 === void 0 ? void 0 : _popupMountRef$curren6.popupsScrollableElement,
|
|
117
119
|
onUndoRedo: onUndoRedo,
|
|
118
|
-
reopenQuery: reopenQuery
|
|
120
|
+
reopenQuery: reopenQuery,
|
|
121
|
+
api: api
|
|
119
122
|
})), typeaheadComponent);
|
|
120
123
|
}
|
|
121
124
|
shouldFocusCursorInsideQuery = false;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const itemIsDisabled = (item, api) => {
|
|
2
|
+
var _api$connectivity, _api$connectivity$sha;
|
|
3
|
+
const isOffline = (api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState.currentState()) === null || _api$connectivity$sha === void 0 ? void 0 : _api$connectivity$sha.mode) === 'offline';
|
|
4
|
+
return isOffline && (item === null || item === void 0 ? void 0 : item.isDisabledOffline) === true;
|
|
5
|
+
};
|
|
@@ -23,7 +23,8 @@ export function createPlugin({
|
|
|
23
23
|
popupMountRef,
|
|
24
24
|
typeAheadHandlers,
|
|
25
25
|
getIntl,
|
|
26
|
-
nodeViewPortalProviderAPI
|
|
26
|
+
nodeViewPortalProviderAPI,
|
|
27
|
+
api
|
|
27
28
|
}) {
|
|
28
29
|
const intl = getIntl();
|
|
29
30
|
const {
|
|
@@ -32,7 +33,8 @@ export function createPlugin({
|
|
|
32
33
|
} = factoryDecorations({
|
|
33
34
|
intl,
|
|
34
35
|
nodeViewPortalProviderAPI,
|
|
35
|
-
popupMountRef
|
|
36
|
+
popupMountRef,
|
|
37
|
+
api
|
|
36
38
|
});
|
|
37
39
|
const reducer = createReducer({
|
|
38
40
|
createDecorations,
|