@atlaskit/editor-core 172.3.2 → 173.0.1
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 +52 -0
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/plugins/base/index.js +8 -0
- package/dist/cjs/plugins/base/pm-plugins/composition.js +60 -0
- package/dist/cjs/plugins/breakout/index.js +5 -4
- package/dist/cjs/plugins/breakout/ui/LayoutButton.js +1 -3
- package/dist/cjs/plugins/card/pm-plugins/doc.js +8 -1
- package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +2 -36
- package/dist/cjs/plugins/collab-edit/plugin-state.js +16 -9
- package/dist/cjs/plugins/collab-edit/utils.js +16 -2
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
- package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +20 -15
- package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +3 -3
- package/dist/cjs/plugins/paste/actions.js +13 -0
- package/dist/cjs/plugins/paste/commands.js +44 -0
- package/dist/cjs/plugins/paste/handlers.js +48 -7
- package/dist/cjs/plugins/paste/index.js +3 -2
- package/dist/cjs/plugins/paste/pm-plugins/main.js +34 -9
- package/dist/cjs/plugins/paste/pm-plugins/plugin-factory.js +62 -0
- package/dist/cjs/plugins/paste/reducer.js +47 -0
- package/dist/cjs/plugins/paste/types.js +5 -0
- package/dist/cjs/plugins/placeholder/index.js +3 -1
- package/dist/cjs/plugins/placeholder-text/index.js +9 -3
- package/dist/cjs/plugins/status/ui/statusPicker.js +4 -1
- package/dist/cjs/plugins/table/commands-with-analytics.js +59 -52
- package/dist/cjs/plugins/table/index.js +53 -36
- package/dist/cjs/plugins/table/toolbar.js +136 -20
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/cjs/plugins/tasks-and-decisions/commands.js +1 -16
- package/dist/cjs/plugins/type-ahead/constants.js +3 -1
- package/dist/cjs/plugins/type-ahead/messages.js +16 -1
- package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +1 -1
- package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +2 -2
- package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +143 -0
- package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +59 -11
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +156 -31
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +55 -29
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
- package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
- package/dist/cjs/plugins/type-ahead/utils.js +1 -1
- package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +8 -0
- package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +2 -6
- package/dist/cjs/ui/PortalProvider/index.js +26 -32
- package/dist/cjs/utils/index.js +8 -1
- package/dist/cjs/utils/selection.js +6 -8
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/plugins/base/index.js +5 -0
- package/dist/es2019/plugins/base/pm-plugins/composition.js +45 -0
- package/dist/es2019/plugins/breakout/index.js +5 -4
- package/dist/es2019/plugins/breakout/ui/LayoutButton.js +1 -3
- package/dist/es2019/plugins/card/pm-plugins/doc.js +10 -1
- package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +3 -40
- package/dist/es2019/plugins/collab-edit/plugin-state.js +9 -3
- package/dist/es2019/plugins/collab-edit/utils.js +17 -3
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
- package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +15 -7
- package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +9 -5
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +3 -3
- package/dist/es2019/plugins/paste/actions.js +6 -0
- package/dist/es2019/plugins/paste/commands.js +27 -0
- package/dist/es2019/plugins/paste/handlers.js +50 -8
- package/dist/es2019/plugins/paste/index.js +3 -2
- package/dist/es2019/plugins/paste/pm-plugins/main.js +29 -6
- package/dist/es2019/plugins/paste/pm-plugins/plugin-factory.js +33 -0
- package/dist/es2019/plugins/paste/reducer.js +24 -0
- package/dist/es2019/plugins/paste/types.js +1 -0
- package/dist/es2019/plugins/placeholder/index.js +2 -1
- package/dist/es2019/plugins/placeholder-text/index.js +13 -3
- package/dist/es2019/plugins/status/ui/statusPicker.js +5 -1
- package/dist/es2019/plugins/table/commands-with-analytics.js +6 -3
- package/dist/es2019/plugins/table/index.js +22 -4
- package/dist/es2019/plugins/table/toolbar.js +118 -14
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/es2019/plugins/tasks-and-decisions/commands.js +0 -9
- package/dist/es2019/plugins/type-ahead/constants.js +1 -0
- package/dist/es2019/plugins/type-ahead/messages.js +16 -1
- package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +2 -2
- package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +95 -0
- package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +49 -12
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +143 -29
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +64 -31
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
- package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
- package/dist/es2019/plugins/type-ahead/utils.js +1 -1
- package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +17 -0
- package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
- package/dist/es2019/ui/PortalProvider/index.js +5 -8
- package/dist/es2019/utils/index.js +6 -0
- package/dist/es2019/utils/selection.js +1 -9
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugins/base/index.js +7 -0
- package/dist/esm/plugins/base/pm-plugins/composition.js +45 -0
- package/dist/esm/plugins/breakout/index.js +5 -4
- package/dist/esm/plugins/breakout/ui/LayoutButton.js +1 -3
- package/dist/esm/plugins/card/pm-plugins/doc.js +8 -1
- package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +3 -37
- package/dist/esm/plugins/collab-edit/plugin-state.js +9 -3
- package/dist/esm/plugins/collab-edit/utils.js +17 -3
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
- package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +20 -15
- package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +3 -3
- package/dist/esm/plugins/paste/actions.js +6 -0
- package/dist/esm/plugins/paste/commands.js +31 -0
- package/dist/esm/plugins/paste/handlers.js +46 -8
- package/dist/esm/plugins/paste/index.js +3 -2
- package/dist/esm/plugins/paste/pm-plugins/main.js +27 -6
- package/dist/esm/plugins/paste/pm-plugins/plugin-factory.js +46 -0
- package/dist/esm/plugins/paste/reducer.js +34 -0
- package/dist/esm/plugins/paste/types.js +1 -0
- package/dist/esm/plugins/placeholder/index.js +2 -1
- package/dist/esm/plugins/placeholder-text/index.js +9 -3
- package/dist/esm/plugins/status/ui/statusPicker.js +4 -1
- package/dist/esm/plugins/table/commands-with-analytics.js +56 -49
- package/dist/esm/plugins/table/index.js +54 -37
- package/dist/esm/plugins/table/toolbar.js +124 -15
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/esm/plugins/tasks-and-decisions/commands.js +0 -12
- package/dist/esm/plugins/type-ahead/constants.js +1 -0
- package/dist/esm/plugins/type-ahead/messages.js +16 -1
- package/dist/esm/plugins/type-ahead/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +2 -2
- package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +129 -0
- package/dist/esm/plugins/type-ahead/ui/InputQuery.js +56 -12
- package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +151 -32
- package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +54 -31
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
- package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
- package/dist/esm/plugins/type-ahead/utils.js +1 -1
- package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +7 -0
- package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
- package/dist/esm/ui/PortalProvider/index.js +26 -35
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/selection.js +1 -7
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugins/base/pm-plugins/composition.d.ts +8 -0
- package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
- package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
- package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
- package/dist/types/plugins/paste/actions.d.ts +15 -0
- package/dist/types/plugins/paste/commands.d.ts +16 -0
- package/dist/types/plugins/paste/handlers.d.ts +1 -1
- package/dist/types/plugins/paste/pm-plugins/main.d.ts +3 -3
- package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
- package/dist/types/plugins/paste/reducer.d.ts +3 -0
- package/dist/types/plugins/paste/types.d.ts +6 -0
- package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
- package/dist/types/plugins/tasks-and-decisions/commands.d.ts +0 -2
- package/dist/types/plugins/type-ahead/constants.d.ts +1 -0
- package/dist/types/plugins/type-ahead/messages.d.ts +15 -0
- package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
- package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
- package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
- package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
- package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/selection.d.ts +1 -2
- package/dist/types-ts4.0/index.d.ts +1 -1
- package/dist/types-ts4.0/plugins/base/pm-plugins/composition.d.ts +8 -0
- package/dist/types-ts4.0/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
- package/dist/types-ts4.0/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
- package/dist/types-ts4.0/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
- package/dist/types-ts4.0/plugins/paste/actions.d.ts +15 -0
- package/dist/types-ts4.0/plugins/paste/commands.d.ts +16 -0
- package/dist/types-ts4.0/plugins/paste/handlers.d.ts +1 -1
- package/dist/types-ts4.0/plugins/paste/pm-plugins/main.d.ts +3 -3
- package/dist/types-ts4.0/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
- package/dist/types-ts4.0/plugins/paste/reducer.d.ts +3 -0
- package/dist/types-ts4.0/plugins/paste/types.d.ts +6 -0
- package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
- package/dist/types-ts4.0/plugins/tasks-and-decisions/commands.d.ts +0 -2
- package/dist/types-ts4.0/plugins/type-ahead/constants.d.ts +1 -0
- package/dist/types-ts4.0/plugins/type-ahead/messages.d.ts +15 -0
- package/dist/types-ts4.0/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
- package/dist/types-ts4.0/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
- package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
- package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
- package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
- package/dist/types-ts4.0/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
- package/dist/types-ts4.0/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.0/utils/index.d.ts +1 -0
- package/dist/types-ts4.0/utils/selection.d.ts +1 -2
- package/package.json +30 -31
- package/report.api.md +161 -49
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
2
5
|
import { defineMessages } from 'react-intl-next';
|
|
3
6
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
4
7
|
import commonMessages from '@atlaskit/editor-common/messages';
|
|
5
8
|
import { clearHoverSelection, hoverTable } from './commands';
|
|
6
|
-
import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
9
|
+
import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics, sortColumnWithAnalytics, setColorWithAnalytics, distributeColumnsWidthsWithAnalytics } from './commands-with-analytics';
|
|
7
10
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
8
11
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
9
12
|
import { TableCssClassName } from './types';
|
|
13
|
+
import { getMergedCellsPositions } from './utils';
|
|
10
14
|
import { isReferencedSource } from './utils/referentiality';
|
|
11
15
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
12
16
|
import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
@@ -17,6 +21,12 @@ import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/
|
|
|
17
21
|
import { findParentDomRefOfType } from 'prosemirror-utils';
|
|
18
22
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
19
23
|
import { getCopyButtonConfig, showCopyButton } from '../copy-button/toolbar';
|
|
24
|
+
import { addColumnAfter, addRowAfter, tooltip, backspace } from '@atlaskit/editor-common/keymaps';
|
|
25
|
+
import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
|
|
26
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
27
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
28
|
+
import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
29
|
+
import { getFeatureFlags } from '../feature-flags-context';
|
|
20
30
|
// TODO: ED-14403 investigate why these translations don't work
|
|
21
31
|
export var messages = defineMessages({
|
|
22
32
|
tableOptions: {
|
|
@@ -94,6 +104,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
94
104
|
left = initialSelectionRect.left;
|
|
95
105
|
var numberOfColumns = right - left;
|
|
96
106
|
var numberOfRows = bottom - top;
|
|
107
|
+
var pluginState = getPluginState(editorState);
|
|
97
108
|
var options = [{
|
|
98
109
|
id: 'editor.table.insertColumn',
|
|
99
110
|
title: formatMessage(tableMessages.insertColumn),
|
|
@@ -108,7 +119,10 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
108
119
|
return true;
|
|
109
120
|
},
|
|
110
121
|
selected: false,
|
|
111
|
-
disabled: false
|
|
122
|
+
disabled: false,
|
|
123
|
+
elemAfter: jsx("div", {
|
|
124
|
+
css: shortcutStyle
|
|
125
|
+
}, tooltip(addColumnAfter))
|
|
112
126
|
}, {
|
|
113
127
|
id: 'editor.table.insertRow',
|
|
114
128
|
title: formatMessage(tableMessages.insertRow),
|
|
@@ -126,7 +140,10 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
126
140
|
return true;
|
|
127
141
|
},
|
|
128
142
|
selected: false,
|
|
129
|
-
disabled: false
|
|
143
|
+
disabled: false,
|
|
144
|
+
elemAfter: jsx("div", {
|
|
145
|
+
css: shortcutStyle
|
|
146
|
+
}, tooltip(addRowAfter))
|
|
130
147
|
}, {
|
|
131
148
|
id: 'editor.table.removeColumns',
|
|
132
149
|
title: formatMessage(tableMessages.removeColumns, {
|
|
@@ -162,16 +179,63 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
162
179
|
}, {
|
|
163
180
|
id: 'editor.table.mergeCells',
|
|
164
181
|
title: formatMessage(ContextualMenuMessages.mergeCells),
|
|
165
|
-
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI),
|
|
182
|
+
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
166
183
|
selected: false,
|
|
167
184
|
disabled: !canMergeCells(editorState.tr)
|
|
168
185
|
}, {
|
|
169
186
|
id: 'editor.table.splitCell',
|
|
170
187
|
title: formatMessage(ContextualMenuMessages.splitCell),
|
|
171
|
-
onClick: splitCellWithAnalytics(editorAnalyticsAPI),
|
|
188
|
+
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
172
189
|
selected: false,
|
|
173
190
|
disabled: !splitCell(editorState)
|
|
174
|
-
}
|
|
191
|
+
}];
|
|
192
|
+
|
|
193
|
+
if (pluginState.pluginConfig.allowDistributeColumns) {
|
|
194
|
+
var distributeColumnWidths = function distributeColumnWidths(state, dispatch, view) {
|
|
195
|
+
var newResizeStateWithAnalytics = view ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, view.domAtPos.bind(view), getEditorContainerWidth) : undefined;
|
|
196
|
+
|
|
197
|
+
if (newResizeStateWithAnalytics) {
|
|
198
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return false;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
options.push({
|
|
206
|
+
id: 'editor.table.distributeColumns',
|
|
207
|
+
title: formatMessage(ContextualMenuMessages.distributeColumns),
|
|
208
|
+
onClick: distributeColumnWidths,
|
|
209
|
+
selected: false,
|
|
210
|
+
disabled: numberOfColumns <= 1
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (pluginState.pluginConfig.allowColumnSorting) {
|
|
215
|
+
var hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
|
|
216
|
+
options.push({
|
|
217
|
+
id: 'editor.table.sortColumnAsc',
|
|
218
|
+
title: formatMessage(ContextualMenuMessages.sortColumnASC),
|
|
219
|
+
onClick: function onClick(state, dispatch) {
|
|
220
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.ASC)(state, dispatch);
|
|
221
|
+
return true;
|
|
222
|
+
},
|
|
223
|
+
selected: false,
|
|
224
|
+
disabled: hasMergedCellsInTable
|
|
225
|
+
});
|
|
226
|
+
options.push({
|
|
227
|
+
id: 'editor.table.sortColumnDesc',
|
|
228
|
+
title: formatMessage(ContextualMenuMessages.sortColumnDESC),
|
|
229
|
+
onClick: function onClick(state, dispatch) {
|
|
230
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
231
|
+
return true;
|
|
232
|
+
},
|
|
233
|
+
selected: false,
|
|
234
|
+
disabled: hasMergedCellsInTable
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
options.push({
|
|
175
239
|
id: 'editor.table.clearCells',
|
|
176
240
|
title: formatMessage(ContextualMenuMessages.clearCells, {
|
|
177
241
|
0: Math.max(numberOfColumns, numberOfRows)
|
|
@@ -184,14 +248,19 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
184
248
|
return true;
|
|
185
249
|
},
|
|
186
250
|
selected: false,
|
|
187
|
-
disabled: false
|
|
188
|
-
|
|
251
|
+
disabled: false,
|
|
252
|
+
elemAfter: jsx("div", {
|
|
253
|
+
css: shortcutStyle
|
|
254
|
+
}, tooltip(backspace))
|
|
255
|
+
});
|
|
189
256
|
return {
|
|
190
257
|
id: 'editor.table.cellOptions',
|
|
191
258
|
type: 'dropdown',
|
|
192
259
|
title: formatMessage(tableMessages.cellOptions),
|
|
193
|
-
|
|
194
|
-
|
|
260
|
+
options: options,
|
|
261
|
+
// Increased dropdown item width to prevent labels from being truncated
|
|
262
|
+
dropdownWidth: 230,
|
|
263
|
+
showSelected: false
|
|
195
264
|
};
|
|
196
265
|
};
|
|
197
266
|
|
|
@@ -210,7 +279,12 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
210
279
|
if (tableObject && pluginState.editorHasFocus) {
|
|
211
280
|
var nodeType = state.schema.nodes.table;
|
|
212
281
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
213
|
-
|
|
282
|
+
|
|
283
|
+
var _ref3 = getFeatureFlags(state) || {},
|
|
284
|
+
tableCellOptionsInFloatingToolbar = _ref3.tableCellOptionsInFloatingToolbar;
|
|
285
|
+
|
|
286
|
+
var cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
287
|
+
var colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar); // Check if we need to show confirm dialog for delete button
|
|
214
288
|
|
|
215
289
|
var confirmDialog;
|
|
216
290
|
var localId = tableObject.node.attrs.localId;
|
|
@@ -243,7 +317,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
243
317
|
getDomRef: getDomRef,
|
|
244
318
|
nodeType: nodeType,
|
|
245
319
|
offset: [0, 3],
|
|
246
|
-
items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), [{
|
|
320
|
+
items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), _toConsumableArray(colorPicker), [{
|
|
247
321
|
type: 'extensions-placeholder',
|
|
248
322
|
separator: 'end'
|
|
249
323
|
}], _toConsumableArray(state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, nodeType, hoverTable(false, true), clearHoverSelection()), {
|
|
@@ -275,10 +349,10 @@ var separator = function separator(hidden) {
|
|
|
275
349
|
};
|
|
276
350
|
};
|
|
277
351
|
|
|
278
|
-
var getCellItems = function getCellItems(pluginConfig, state,
|
|
279
|
-
var formatMessage =
|
|
352
|
+
var getCellItems = function getCellItems(pluginConfig, state, _ref4, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
|
|
353
|
+
var formatMessage = _ref4.formatMessage;
|
|
280
354
|
|
|
281
|
-
if (pluginConfig.allowCellOptionsInFloatingToolbar) {
|
|
355
|
+
if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
|
|
282
356
|
var initialSelectionRect = getClosestSelectionRect(state);
|
|
283
357
|
|
|
284
358
|
if (initialSelectionRect) {
|
|
@@ -290,4 +364,39 @@ var getCellItems = function getCellItems(pluginConfig, state, _ref3, getEditorCo
|
|
|
290
364
|
}
|
|
291
365
|
|
|
292
366
|
return [];
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
var getColorPicker = function getColorPicker(state, menu, _ref5, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
|
|
370
|
+
var _node$attrs;
|
|
371
|
+
|
|
372
|
+
var formatMessage = _ref5.formatMessage;
|
|
373
|
+
|
|
374
|
+
var _getPluginState2 = getPluginState(state),
|
|
375
|
+
targetCellPosition = _getPluginState2.targetCellPosition,
|
|
376
|
+
pluginConfig = _getPluginState2.pluginConfig;
|
|
377
|
+
|
|
378
|
+
if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
|
|
379
|
+
return [];
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
var node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
|
|
383
|
+
var currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
384
|
+
var defaultPalette = cellBackgroundColorPalette.find(function (item) {
|
|
385
|
+
return item.value === currentBackground;
|
|
386
|
+
}) || {
|
|
387
|
+
label: 'Custom',
|
|
388
|
+
value: currentBackground,
|
|
389
|
+
border: DEFAULT_BORDER_COLOR
|
|
390
|
+
};
|
|
391
|
+
return [{
|
|
392
|
+
id: 'editor.panel.colorPicker',
|
|
393
|
+
title: formatMessage(ContextualMenuMessages.cellBackground),
|
|
394
|
+
type: 'select',
|
|
395
|
+
selectType: 'color',
|
|
396
|
+
defaultValue: defaultPalette,
|
|
397
|
+
options: cellBackgroundColorPalette,
|
|
398
|
+
onChange: function onChange(option) {
|
|
399
|
+
return setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, option.value, targetCellPosition);
|
|
400
|
+
}
|
|
401
|
+
}, separator(menu.hidden)];
|
|
293
402
|
};
|
|
@@ -293,14 +293,14 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
293
293
|
break;
|
|
294
294
|
|
|
295
295
|
case 'merge':
|
|
296
|
-
mergeCellsWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
296
|
+
mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
|
|
297
297
|
|
|
298
298
|
_this.toggleOpen();
|
|
299
299
|
|
|
300
300
|
break;
|
|
301
301
|
|
|
302
302
|
case 'split':
|
|
303
|
-
splitCellWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
303
|
+
splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
|
|
304
304
|
|
|
305
305
|
_this.toggleOpen();
|
|
306
306
|
|
|
@@ -448,7 +448,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
448
448
|
|
|
449
449
|
var state = editorView.state,
|
|
450
450
|
dispatch = editorView.dispatch;
|
|
451
|
-
setColorWithAnalytics(editorAnalyticsAPI)(color, targetCellPosition)(state, dispatch);
|
|
451
|
+
setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
|
|
452
452
|
|
|
453
453
|
_this.toggleOpen();
|
|
454
454
|
});
|
|
@@ -68,18 +68,6 @@ export var getListTypes = function getListTypes(listType, schema) {
|
|
|
68
68
|
item: decisionItem
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
-
/*
|
|
72
|
-
* @deprecated - [ED-13182] insertTaskDecision has been depreciated in favor of insertTaskDecisionCommand
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
export var insertTaskDecision = function insertTaskDecision(view, listType) {
|
|
76
|
-
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.TOOLBAR;
|
|
77
|
-
var listLocalId = arguments.length > 3 ? arguments[3] : undefined;
|
|
78
|
-
var itemLocalId = arguments.length > 4 ? arguments[4] : undefined;
|
|
79
|
-
// eslint-disable-next-line no-console
|
|
80
|
-
console.warn('insertTaskDecision has been depreciated in favor of insertTaskDecisionCommand');
|
|
81
|
-
return insertTaskDecisionCommand(listType, inputMethod, undefined, listLocalId, itemLocalId);
|
|
82
|
-
};
|
|
83
71
|
export var insertTaskDecisionAction = function insertTaskDecisionAction(state, listType) {
|
|
84
72
|
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.TOOLBAR;
|
|
85
73
|
var addItem = arguments.length > 3 ? arguments[3] : undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export var TYPE_AHEAD_DECORATION_KEY = 'typeahead_decoration_key';
|
|
2
2
|
export var TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = 'typeaheadDecoration';
|
|
3
3
|
export var TYPE_AHEAD_POPUP_CONTENT_CLASS = 'fabric-editor-typeahead';
|
|
4
|
+
export var TYPE_AHEAD_DECORATION_ELEMENT_ID = 'typeahaed_decoration_element_id';
|
|
4
5
|
export var NavigationDirection;
|
|
5
6
|
|
|
6
7
|
(function (NavigationDirection) {
|
|
@@ -3,6 +3,21 @@ export var typeAheadListMessages = defineMessages({
|
|
|
3
3
|
typeAheadResultLabel: {
|
|
4
4
|
id: 'fabric.editor.typeAheadResultLabel',
|
|
5
5
|
defaultMessage: 'TypeAhead results',
|
|
6
|
-
description: 'the result of a
|
|
6
|
+
description: 'the result of a typeahead, similar to autocomplete results+'
|
|
7
|
+
},
|
|
8
|
+
inputQueryAssistiveLabel: {
|
|
9
|
+
id: 'fabric.editor.inputQueryAssistiveTxt',
|
|
10
|
+
defaultMessage: 'When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.',
|
|
11
|
+
description: 'Assitive text to the user when using typeahead shortcut'
|
|
12
|
+
},
|
|
13
|
+
searchResultsLabel: {
|
|
14
|
+
id: 'fabric.editor.searchResults',
|
|
15
|
+
defaultMessage: '{itemsLength, plural, one {# search result} other {# search results}} available',
|
|
16
|
+
description: 'Assitive text to the user when using typeahead shortcut and it preceeds with a number - Ex: 10 search results available'
|
|
17
|
+
},
|
|
18
|
+
noSearchResultsLabel: {
|
|
19
|
+
id: 'fabric.editor.noSearchResults',
|
|
20
|
+
defaultMessage: 'No search results',
|
|
21
|
+
description: 'Assitive text to the user when using typeahead shortcut'
|
|
7
22
|
}
|
|
8
23
|
});
|
|
@@ -73,7 +73,7 @@ export var createReducer = function createReducer(_ref) {
|
|
|
73
73
|
triggerHandler: triggerHandler,
|
|
74
74
|
decorationElement: decorationElement,
|
|
75
75
|
inputMethod: inputMethod,
|
|
76
|
-
selectedIndex: typeof selectedIndex === 'number' ? selectedIndex :
|
|
76
|
+
selectedIndex: typeof selectedIndex === 'number' ? selectedIndex : -1,
|
|
77
77
|
items: [],
|
|
78
78
|
query: reopenQuery || ''
|
|
79
79
|
});
|
|
@@ -138,7 +138,7 @@ export var createReducer = function createReducer(_ref) {
|
|
|
138
138
|
var selectedIndex = currentPluginState.selectedIndex;
|
|
139
139
|
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
140
140
|
items: items,
|
|
141
|
-
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex,
|
|
141
|
+
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, -1)
|
|
142
142
|
});
|
|
143
143
|
} else if (shouldUpdateSelectedIndex) {
|
|
144
144
|
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
|
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
+
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
|
|
13
|
+
/** @jsx jsx */
|
|
14
|
+
import debounce from 'lodash/debounce';
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { css, jsx } from '@emotion/react';
|
|
17
|
+
var statusDebounceMillis = 1400;
|
|
18
|
+
var assitiveTextStyles = css({
|
|
19
|
+
border: 0,
|
|
20
|
+
clip: 'rect(0 0 0 0)',
|
|
21
|
+
height: '1px',
|
|
22
|
+
marginbottom: '-1px',
|
|
23
|
+
marginright: '-1px',
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
padding: 0,
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
whitespace: 'nowrap',
|
|
28
|
+
width: '1px'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
|
|
32
|
+
_inherits(AssistveTextComponent, _React$Component);
|
|
33
|
+
|
|
34
|
+
var _super = _createSuper(AssistveTextComponent);
|
|
35
|
+
|
|
36
|
+
function AssistveTextComponent() {
|
|
37
|
+
var _this;
|
|
38
|
+
|
|
39
|
+
_classCallCheck(this, AssistveTextComponent);
|
|
40
|
+
|
|
41
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
42
|
+
args[_key] = arguments[_key];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
46
|
+
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
48
|
+
bump: false,
|
|
49
|
+
//when the same text needs to be read again, Hence it needs to be toggled between __status--A and __status--B
|
|
50
|
+
debounced: false,
|
|
51
|
+
silenced: false
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return _this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
_createClass(AssistveTextComponent, [{
|
|
58
|
+
key: "componentWillMount",
|
|
59
|
+
value: function componentWillMount() {
|
|
60
|
+
var _this2 = this;
|
|
61
|
+
|
|
62
|
+
this.debounceStatusUpdate = debounce(function () {
|
|
63
|
+
if (!_this2.state.debounced) {
|
|
64
|
+
var shouldSilence = !_this2.props.isInFocus;
|
|
65
|
+
|
|
66
|
+
_this2.setState(function (_ref) {
|
|
67
|
+
var bump = _ref.bump;
|
|
68
|
+
return {
|
|
69
|
+
bump: !bump,
|
|
70
|
+
debounced: true,
|
|
71
|
+
silenced: shouldSilence
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, statusDebounceMillis);
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "componentWillUnmount",
|
|
79
|
+
value: function componentWillUnmount() {}
|
|
80
|
+
}, {
|
|
81
|
+
key: "componentWillReceiveProps",
|
|
82
|
+
value: function componentWillReceiveProps() {
|
|
83
|
+
this.setState(function (_ref2) {
|
|
84
|
+
var bump = _ref2.bump;
|
|
85
|
+
return {
|
|
86
|
+
bump: !bump,
|
|
87
|
+
debounced: false
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "render",
|
|
93
|
+
value: function render() {
|
|
94
|
+
var _this$props = this.props,
|
|
95
|
+
assistiveText = _this$props.assistiveText,
|
|
96
|
+
id = _this$props.id;
|
|
97
|
+
var _this$state = this.state,
|
|
98
|
+
bump = _this$state.bump,
|
|
99
|
+
debounced = _this$state.debounced,
|
|
100
|
+
silenced = _this$state.silenced;
|
|
101
|
+
this.debounceStatusUpdate();
|
|
102
|
+
return jsx("div", {
|
|
103
|
+
css: assitiveTextStyles
|
|
104
|
+
}, jsx("div", {
|
|
105
|
+
id: id + '__status--A',
|
|
106
|
+
role: "status",
|
|
107
|
+
"aria-atomic": "true",
|
|
108
|
+
"aria-live": "polite"
|
|
109
|
+
}, "".concat(!silenced && debounced && bump ? assistiveText : '')), jsx("div", {
|
|
110
|
+
id: id + '__status--B',
|
|
111
|
+
role: "status",
|
|
112
|
+
"aria-atomic": "true",
|
|
113
|
+
"aria-live": "polite"
|
|
114
|
+
}, "".concat(!silenced && debounced && !bump ? assistiveText : '')));
|
|
115
|
+
}
|
|
116
|
+
}]);
|
|
117
|
+
|
|
118
|
+
return AssistveTextComponent;
|
|
119
|
+
}(React.Component);
|
|
120
|
+
|
|
121
|
+
_defineProperty(AssistveTextComponent, "defaultProps", {
|
|
122
|
+
statusDebounceMillis: 1400,
|
|
123
|
+
debounce: true,
|
|
124
|
+
assistiveText: '',
|
|
125
|
+
isInFocus: false,
|
|
126
|
+
id: ''
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export var AssistiveText = AssistveTextComponent;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
3
|
|
|
3
4
|
var _templateObject;
|
|
4
5
|
|
|
5
6
|
/** @jsx jsx */
|
|
6
|
-
import React, { useRef, useCallback, Fragment, useLayoutEffect } from 'react';
|
|
7
|
+
import React, { useRef, useCallback, Fragment, useLayoutEffect, useState } from 'react';
|
|
7
8
|
import { css, jsx } from '@emotion/react';
|
|
8
9
|
import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
9
10
|
import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
11
|
+
import { getPluginState } from '../utils';
|
|
10
12
|
import { CloseSelectionOptions, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
|
|
11
13
|
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
14
|
+
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../constants';
|
|
15
|
+
import { AssistiveText } from './AssistiveText';
|
|
16
|
+
import { typeAheadListMessages } from '../messages';
|
|
17
|
+
import { useIntl } from 'react-intl-next';
|
|
12
18
|
var querySpan = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n outline: none;\n"])));
|
|
13
19
|
|
|
14
20
|
var isNavigationKey = function isNavigationKey(event) {
|
|
@@ -43,7 +49,9 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
43
49
|
forceFocus = _ref.forceFocus,
|
|
44
50
|
reopenQuery = _ref.reopenQuery,
|
|
45
51
|
onQueryFocus = _ref.onQueryFocus,
|
|
46
|
-
onUndoRedo = _ref.onUndoRedo
|
|
52
|
+
onUndoRedo = _ref.onUndoRedo,
|
|
53
|
+
editorView = _ref.editorView,
|
|
54
|
+
items = _ref.items;
|
|
47
55
|
var ref = useRef(document.createElement('span'));
|
|
48
56
|
var cleanedInputContent = useCallback(function () {
|
|
49
57
|
var _ref$current;
|
|
@@ -55,6 +63,12 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
55
63
|
var text = cleanedInputContent();
|
|
56
64
|
onQueryChange(text);
|
|
57
65
|
}, [onQueryChange, cleanedInputContent]);
|
|
66
|
+
|
|
67
|
+
var _useState = useState(false),
|
|
68
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
69
|
+
isInFocus = _useState2[0],
|
|
70
|
+
setInFocus = _useState2[1];
|
|
71
|
+
|
|
58
72
|
var checkKeyEvent = useCallback(function (event) {
|
|
59
73
|
var _ref$current2;
|
|
60
74
|
|
|
@@ -64,6 +78,11 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
64
78
|
var text = cleanedInputContent();
|
|
65
79
|
var stopDefault = false;
|
|
66
80
|
|
|
81
|
+
var _getPluginState = getPluginState(editorView.state),
|
|
82
|
+
selectedIndex = _getPluginState.selectedIndex;
|
|
83
|
+
|
|
84
|
+
setInFocus(true);
|
|
85
|
+
|
|
67
86
|
switch (key) {
|
|
68
87
|
case ' ':
|
|
69
88
|
// space key
|
|
@@ -107,23 +126,29 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
107
126
|
// ED-14758 - Under the W3C specification, any keycode sent under IME would return a keycode 229
|
|
108
127
|
// event.isComposing can't be used alone as this also included a virtual keyboard under a keyboardless device, therefore, it seems the best practice would be intercepting the event as below.
|
|
109
128
|
// Some suggested the other workaround maybe listen on`keypress` instead of `keydown`
|
|
110
|
-
if (event.isComposing
|
|
111
|
-
|
|
129
|
+
if (!event.isComposing || event.which !== 229 && event.keyCode !== 229) {
|
|
130
|
+
if (selectedIndex === -1) {
|
|
131
|
+
selectNextItem();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
|
|
112
135
|
}
|
|
113
136
|
|
|
114
|
-
onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
|
|
115
137
|
break;
|
|
116
138
|
|
|
117
139
|
case 'Tab':
|
|
140
|
+
if (selectedIndex === -1) {
|
|
141
|
+
selectNextItem();
|
|
142
|
+
}
|
|
143
|
+
|
|
118
144
|
onItemSelect(SelectItemMode.TAB);
|
|
119
145
|
break;
|
|
120
146
|
|
|
121
147
|
case 'ArrowDown':
|
|
122
|
-
|
|
123
|
-
|
|
148
|
+
if (selectedIndex === -1) {
|
|
149
|
+
selectNextItem();
|
|
150
|
+
}
|
|
124
151
|
|
|
125
|
-
case 'ArrowUp':
|
|
126
|
-
selectPreviousItem();
|
|
127
152
|
break;
|
|
128
153
|
}
|
|
129
154
|
|
|
@@ -138,7 +163,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
138
163
|
event.preventDefault();
|
|
139
164
|
return false;
|
|
140
165
|
}
|
|
141
|
-
}, [onUndoRedo, onItemSelect, selectNextItem, cancel,
|
|
166
|
+
}, [onUndoRedo, onItemSelect, selectNextItem, cancel, cleanedInputContent, editorView.state]);
|
|
142
167
|
var onClick = useCallback(function (event) {
|
|
143
168
|
var _ref$current3;
|
|
144
169
|
|
|
@@ -229,6 +254,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
229
254
|
var beforeinput = function beforeinput(e) {
|
|
230
255
|
var _target$textContent;
|
|
231
256
|
|
|
257
|
+
setInFocus(false);
|
|
232
258
|
var target = e.target;
|
|
233
259
|
|
|
234
260
|
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
@@ -300,7 +326,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
300
326
|
element.removeEventListener('input', onInput);
|
|
301
327
|
}
|
|
302
328
|
};
|
|
303
|
-
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent]);
|
|
329
|
+
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent, editorView.state]);
|
|
304
330
|
useLayoutEffect(function () {
|
|
305
331
|
var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
306
332
|
|
|
@@ -323,9 +349,12 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
323
349
|
}
|
|
324
350
|
|
|
325
351
|
ref.current.focus();
|
|
352
|
+
setInFocus(true);
|
|
326
353
|
});
|
|
327
354
|
}
|
|
328
355
|
}, [forceFocus, reopenQuery]);
|
|
356
|
+
var assistiveHintID = TYPE_AHEAD_DECORATION_ELEMENT_ID + '__assistiveHint';
|
|
357
|
+
var intl = useIntl();
|
|
329
358
|
/**
|
|
330
359
|
When we migrated to emotion from styled component, we started getting this error.
|
|
331
360
|
jsx-a11y/interactive-supports-focus
|
|
@@ -338,9 +367,24 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
338
367
|
ref: ref,
|
|
339
368
|
onKeyUp: onKeyUp,
|
|
340
369
|
onClick: onClick,
|
|
341
|
-
role: "
|
|
370
|
+
role: "combobox",
|
|
371
|
+
"aria-controls": TYPE_AHEAD_DECORATION_ELEMENT_ID,
|
|
372
|
+
"aria-autocomplete": "list",
|
|
373
|
+
"aria-expanded": items.length !== 0,
|
|
374
|
+
"aria-labelledby": assistiveHintID,
|
|
342
375
|
suppressContentEditableWarning: true,
|
|
343
376
|
"data-query-prefix": triggerQueryPrefix
|
|
377
|
+
}), jsx("span", {
|
|
378
|
+
id: assistiveHintID,
|
|
379
|
+
style: {
|
|
380
|
+
display: 'none'
|
|
381
|
+
}
|
|
382
|
+
}, intl.formatMessage(typeAheadListMessages.inputQueryAssistiveLabel)), jsx(AssistiveText, {
|
|
383
|
+
assistiveText: items.length === 0 ? intl.formatMessage(typeAheadListMessages.noSearchResultsLabel, {
|
|
384
|
+
itemsLength: items.length
|
|
385
|
+
}) : '',
|
|
386
|
+
isInFocus: items.length === 0 || isInFocus,
|
|
387
|
+
id: TYPE_AHEAD_DECORATION_ELEMENT_ID
|
|
344
388
|
}));
|
|
345
389
|
});
|
|
346
390
|
InputQuery.displayName = 'InputQuery';
|