@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
|
@@ -44,7 +44,7 @@ export const emptyMultipleCellsWithAnalytics = editorAnalyticsAPI => (inputMetho
|
|
|
44
44
|
eventType: EVENT_TYPE.TRACK
|
|
45
45
|
};
|
|
46
46
|
})(editorAnalyticsAPI)(clearMultipleCells(targetCellPosition));
|
|
47
|
-
export const mergeCellsWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI(({
|
|
47
|
+
export const mergeCellsWithAnalytics = editorAnalyticsAPI => inputMethod => withEditorAnalyticsAPI(({
|
|
48
48
|
selection
|
|
49
49
|
}) => {
|
|
50
50
|
const {
|
|
@@ -59,6 +59,7 @@ export const mergeCellsWithAnalytics = editorAnalyticsAPI => withEditorAnalytics
|
|
|
59
59
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
60
60
|
actionSubjectId: null,
|
|
61
61
|
attributes: {
|
|
62
|
+
inputMethod,
|
|
62
63
|
horizontalCells,
|
|
63
64
|
verticalCells,
|
|
64
65
|
totalCells,
|
|
@@ -74,7 +75,7 @@ export const mergeCellsWithAnalytics = editorAnalyticsAPI => withEditorAnalytics
|
|
|
74
75
|
|
|
75
76
|
return true;
|
|
76
77
|
});
|
|
77
|
-
export const splitCellWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI(({
|
|
78
|
+
export const splitCellWithAnalytics = editorAnalyticsAPI => inputMethod => withEditorAnalyticsAPI(({
|
|
78
79
|
selection
|
|
79
80
|
}) => {
|
|
80
81
|
const {
|
|
@@ -93,6 +94,7 @@ export const splitCellWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsA
|
|
|
93
94
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
94
95
|
actionSubjectId: null,
|
|
95
96
|
attributes: {
|
|
97
|
+
inputMethod,
|
|
96
98
|
horizontalCells,
|
|
97
99
|
verticalCells,
|
|
98
100
|
totalCells: horizontalCells * verticalCells,
|
|
@@ -105,7 +107,7 @@ export const splitCellWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsA
|
|
|
105
107
|
|
|
106
108
|
return;
|
|
107
109
|
})(editorAnalyticsAPI)(splitCell);
|
|
108
|
-
export const setColorWithAnalytics = editorAnalyticsAPI => (cellColor, targetCellPosition) => withEditorAnalyticsAPI(({
|
|
110
|
+
export const setColorWithAnalytics = editorAnalyticsAPI => (inputMethod, cellColor, targetCellPosition) => withEditorAnalyticsAPI(({
|
|
109
111
|
selection
|
|
110
112
|
}) => {
|
|
111
113
|
const {
|
|
@@ -120,6 +122,7 @@ export const setColorWithAnalytics = editorAnalyticsAPI => (cellColor, targetCel
|
|
|
120
122
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
121
123
|
actionSubjectId: null,
|
|
122
124
|
attributes: {
|
|
125
|
+
inputMethod,
|
|
123
126
|
cellColor: (tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
|
|
124
127
|
horizontalCells,
|
|
125
128
|
verticalCells,
|
|
@@ -5,7 +5,7 @@ import { createTable } from '@atlaskit/editor-tables/utils';
|
|
|
5
5
|
import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
6
6
|
import { toggleTable, tooltip } from '../../keymaps';
|
|
7
7
|
import WithPluginState from '../../ui/WithPluginState';
|
|
8
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
9
9
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
10
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
11
11
|
import { pluginConfig } from './create-plugin-config';
|
|
@@ -108,7 +108,25 @@ const tablesPlugin = options => ({
|
|
|
108
108
|
plugin: () => tableSelectionKeymapPlugin(options === null || options === void 0 ? void 0 : options.editorSelectionAPI)
|
|
109
109
|
}, {
|
|
110
110
|
name: 'tableEditing',
|
|
111
|
-
plugin: () => tableEditing(
|
|
111
|
+
plugin: () => tableEditing({
|
|
112
|
+
reportFixedTable: ({
|
|
113
|
+
state,
|
|
114
|
+
tr,
|
|
115
|
+
reason
|
|
116
|
+
}) => {
|
|
117
|
+
var _options$editorAnalyt;
|
|
118
|
+
|
|
119
|
+
options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
|
|
120
|
+
action: TABLE_ACTION.FIXED,
|
|
121
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
122
|
+
actionSubjectId: null,
|
|
123
|
+
attributes: {
|
|
124
|
+
reason
|
|
125
|
+
},
|
|
126
|
+
eventType: EVENT_TYPE.TRACK
|
|
127
|
+
})(tr);
|
|
128
|
+
}
|
|
129
|
+
})
|
|
112
130
|
}, {
|
|
113
131
|
name: 'tableStickyHeaders',
|
|
114
132
|
plugin: ({
|
|
@@ -282,12 +300,12 @@ const tablesPlugin = options => ({
|
|
|
282
300
|
icon: () => /*#__PURE__*/React.createElement(IconTable, null),
|
|
283
301
|
|
|
284
302
|
action(insert, state) {
|
|
285
|
-
var _options$
|
|
303
|
+
var _options$editorAnalyt2;
|
|
286
304
|
|
|
287
305
|
const tr = insert(createTable({
|
|
288
306
|
schema: state.schema
|
|
289
307
|
}));
|
|
290
|
-
options === null || options === void 0 ? void 0 : (_options$
|
|
308
|
+
options === null || options === void 0 ? void 0 : (_options$editorAnalyt2 = options.editorAnalyticsAPI) === null || _options$editorAnalyt2 === void 0 ? void 0 : _options$editorAnalyt2.attachAnalyticsEvent({
|
|
291
309
|
action: ACTION.INSERTED,
|
|
292
310
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
293
311
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
1
3
|
import { defineMessages } from 'react-intl-next';
|
|
2
4
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
3
5
|
import commonMessages from '@atlaskit/editor-common/messages';
|
|
4
6
|
import { clearHoverSelection, hoverTable } from './commands';
|
|
5
|
-
import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
7
|
+
import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics, sortColumnWithAnalytics, setColorWithAnalytics, distributeColumnsWidthsWithAnalytics } from './commands-with-analytics';
|
|
6
8
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
7
9
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
8
10
|
import { TableCssClassName } from './types';
|
|
11
|
+
import { getMergedCellsPositions } from './utils';
|
|
9
12
|
import { isReferencedSource } from './utils/referentiality';
|
|
10
13
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
14
|
import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
@@ -16,6 +19,12 @@ import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/
|
|
|
16
19
|
import { findParentDomRefOfType } from 'prosemirror-utils';
|
|
17
20
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
18
21
|
import { getCopyButtonConfig, showCopyButton } from '../copy-button/toolbar';
|
|
22
|
+
import { addColumnAfter, addRowAfter, tooltip, backspace } from '@atlaskit/editor-common/keymaps';
|
|
23
|
+
import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
|
|
24
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
25
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
26
|
+
import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
27
|
+
import { getFeatureFlags } from '../feature-flags-context';
|
|
19
28
|
// TODO: ED-14403 investigate why these translations don't work
|
|
20
29
|
export const messages = defineMessages({
|
|
21
30
|
tableOptions: {
|
|
@@ -95,6 +104,7 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
95
104
|
} = initialSelectionRect;
|
|
96
105
|
const numberOfColumns = right - left;
|
|
97
106
|
const numberOfRows = bottom - top;
|
|
107
|
+
const pluginState = getPluginState(editorState);
|
|
98
108
|
const options = [{
|
|
99
109
|
id: 'editor.table.insertColumn',
|
|
100
110
|
title: formatMessage(tableMessages.insertColumn),
|
|
@@ -109,7 +119,10 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
109
119
|
return true;
|
|
110
120
|
},
|
|
111
121
|
selected: false,
|
|
112
|
-
disabled: false
|
|
122
|
+
disabled: false,
|
|
123
|
+
elemAfter: jsx("div", {
|
|
124
|
+
css: shortcutStyle
|
|
125
|
+
}, tooltip(addColumnAfter))
|
|
113
126
|
}, {
|
|
114
127
|
id: 'editor.table.insertRow',
|
|
115
128
|
title: formatMessage(tableMessages.insertRow),
|
|
@@ -127,7 +140,10 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
127
140
|
return true;
|
|
128
141
|
},
|
|
129
142
|
selected: false,
|
|
130
|
-
disabled: false
|
|
143
|
+
disabled: false,
|
|
144
|
+
elemAfter: jsx("div", {
|
|
145
|
+
css: shortcutStyle
|
|
146
|
+
}, tooltip(addRowAfter))
|
|
131
147
|
}, {
|
|
132
148
|
id: 'editor.table.removeColumns',
|
|
133
149
|
title: formatMessage(tableMessages.removeColumns, {
|
|
@@ -163,16 +179,63 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
163
179
|
}, {
|
|
164
180
|
id: 'editor.table.mergeCells',
|
|
165
181
|
title: formatMessage(ContextualMenuMessages.mergeCells),
|
|
166
|
-
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI),
|
|
182
|
+
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
167
183
|
selected: false,
|
|
168
184
|
disabled: !canMergeCells(editorState.tr)
|
|
169
185
|
}, {
|
|
170
186
|
id: 'editor.table.splitCell',
|
|
171
187
|
title: formatMessage(ContextualMenuMessages.splitCell),
|
|
172
|
-
onClick: splitCellWithAnalytics(editorAnalyticsAPI),
|
|
188
|
+
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
173
189
|
selected: false,
|
|
174
190
|
disabled: !splitCell(editorState)
|
|
175
|
-
}
|
|
191
|
+
}];
|
|
192
|
+
|
|
193
|
+
if (pluginState.pluginConfig.allowDistributeColumns) {
|
|
194
|
+
const distributeColumnWidths = (state, dispatch, view) => {
|
|
195
|
+
const 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
|
+
const hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
|
|
216
|
+
options.push({
|
|
217
|
+
id: 'editor.table.sortColumnAsc',
|
|
218
|
+
title: formatMessage(ContextualMenuMessages.sortColumnASC),
|
|
219
|
+
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: (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({
|
|
176
239
|
id: 'editor.table.clearCells',
|
|
177
240
|
title: formatMessage(ContextualMenuMessages.clearCells, {
|
|
178
241
|
0: Math.max(numberOfColumns, numberOfRows)
|
|
@@ -185,14 +248,19 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
185
248
|
return true;
|
|
186
249
|
},
|
|
187
250
|
selected: false,
|
|
188
|
-
disabled: false
|
|
189
|
-
|
|
251
|
+
disabled: false,
|
|
252
|
+
elemAfter: jsx("div", {
|
|
253
|
+
css: shortcutStyle
|
|
254
|
+
}, tooltip(backspace))
|
|
255
|
+
});
|
|
190
256
|
return {
|
|
191
257
|
id: 'editor.table.cellOptions',
|
|
192
258
|
type: 'dropdown',
|
|
193
259
|
title: formatMessage(tableMessages.cellOptions),
|
|
194
|
-
|
|
195
|
-
|
|
260
|
+
options,
|
|
261
|
+
// Increased dropdown item width to prevent labels from being truncated
|
|
262
|
+
dropdownWidth: 230,
|
|
263
|
+
showSelected: false
|
|
196
264
|
};
|
|
197
265
|
};
|
|
198
266
|
|
|
@@ -209,7 +277,11 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI) =>
|
|
|
209
277
|
if (tableObject && pluginState.editorHasFocus) {
|
|
210
278
|
const nodeType = state.schema.nodes.table;
|
|
211
279
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
212
|
-
const
|
|
280
|
+
const {
|
|
281
|
+
tableCellOptionsInFloatingToolbar
|
|
282
|
+
} = getFeatureFlags(state) || {};
|
|
283
|
+
const cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
284
|
+
const colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar); // Check if we need to show confirm dialog for delete button
|
|
213
285
|
|
|
214
286
|
let confirmDialog;
|
|
215
287
|
const localId = tableObject.node.attrs.localId;
|
|
@@ -242,7 +314,7 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI) =>
|
|
|
242
314
|
getDomRef,
|
|
243
315
|
nodeType,
|
|
244
316
|
offset: [0, 3],
|
|
245
|
-
items: [menu, separator(menu.hidden), ...cellItems, {
|
|
317
|
+
items: [menu, separator(menu.hidden), ...cellItems, ...colorPicker, {
|
|
246
318
|
type: 'extensions-placeholder',
|
|
247
319
|
separator: 'end'
|
|
248
320
|
}, ...(state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, nodeType, hoverTable(false, true), clearHoverSelection()), {
|
|
@@ -274,8 +346,8 @@ const separator = hidden => {
|
|
|
274
346
|
|
|
275
347
|
const getCellItems = (pluginConfig, state, {
|
|
276
348
|
formatMessage
|
|
277
|
-
}, getEditorContainerWidth, editorAnalyticsAPI) => {
|
|
278
|
-
if (pluginConfig.allowCellOptionsInFloatingToolbar) {
|
|
349
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
|
|
350
|
+
if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
|
|
279
351
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
280
352
|
|
|
281
353
|
if (initialSelectionRect) {
|
|
@@ -287,4 +359,36 @@ const getCellItems = (pluginConfig, state, {
|
|
|
287
359
|
}
|
|
288
360
|
|
|
289
361
|
return [];
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const getColorPicker = (state, menu, {
|
|
365
|
+
formatMessage
|
|
366
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
|
|
367
|
+
var _node$attrs;
|
|
368
|
+
|
|
369
|
+
const {
|
|
370
|
+
targetCellPosition,
|
|
371
|
+
pluginConfig
|
|
372
|
+
} = getPluginState(state);
|
|
373
|
+
|
|
374
|
+
if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
|
|
375
|
+
return [];
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
|
|
379
|
+
const currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
380
|
+
const defaultPalette = cellBackgroundColorPalette.find(item => item.value === currentBackground) || {
|
|
381
|
+
label: 'Custom',
|
|
382
|
+
value: currentBackground,
|
|
383
|
+
border: DEFAULT_BORDER_COLOR
|
|
384
|
+
};
|
|
385
|
+
return [{
|
|
386
|
+
id: 'editor.panel.colorPicker',
|
|
387
|
+
title: formatMessage(ContextualMenuMessages.cellBackground),
|
|
388
|
+
type: 'select',
|
|
389
|
+
selectType: 'color',
|
|
390
|
+
defaultValue: defaultPalette,
|
|
391
|
+
options: cellBackgroundColorPalette,
|
|
392
|
+
onChange: option => setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, option.value, targetCellPosition)
|
|
393
|
+
}, separator(menu.hidden)];
|
|
290
394
|
};
|
|
@@ -281,12 +281,12 @@ export class ContextualMenu extends Component {
|
|
|
281
281
|
break;
|
|
282
282
|
|
|
283
283
|
case 'merge':
|
|
284
|
-
mergeCellsWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
284
|
+
mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
|
|
285
285
|
this.toggleOpen();
|
|
286
286
|
break;
|
|
287
287
|
|
|
288
288
|
case 'split':
|
|
289
|
-
splitCellWithAnalytics(editorAnalyticsAPI)(state, dispatch);
|
|
289
|
+
splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
|
|
290
290
|
this.toggleOpen();
|
|
291
291
|
break;
|
|
292
292
|
|
|
@@ -435,7 +435,7 @@ export class ContextualMenu extends Component {
|
|
|
435
435
|
state,
|
|
436
436
|
dispatch
|
|
437
437
|
} = editorView;
|
|
438
|
-
setColorWithAnalytics(editorAnalyticsAPI)(color, targetCellPosition)(state, dispatch);
|
|
438
|
+
setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
|
|
439
439
|
this.toggleOpen();
|
|
440
440
|
});
|
|
441
441
|
}
|
|
@@ -72,15 +72,6 @@ export const getListTypes = (listType, schema) => {
|
|
|
72
72
|
item: decisionItem
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
|
-
/*
|
|
76
|
-
* @deprecated - [ED-13182] insertTaskDecision has been depreciated in favor of insertTaskDecisionCommand
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
export const insertTaskDecision = (view, listType, inputMethod = INPUT_METHOD.TOOLBAR, listLocalId, itemLocalId) => {
|
|
80
|
-
// eslint-disable-next-line no-console
|
|
81
|
-
console.warn('insertTaskDecision has been depreciated in favor of insertTaskDecisionCommand');
|
|
82
|
-
return insertTaskDecisionCommand(listType, inputMethod, undefined, listLocalId, itemLocalId);
|
|
83
|
-
};
|
|
84
75
|
export const insertTaskDecisionAction = (state, listType, inputMethod = INPUT_METHOD.TOOLBAR, addItem, listLocalId, itemLocalId) => {
|
|
85
76
|
const {
|
|
86
77
|
schema
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const TYPE_AHEAD_DECORATION_KEY = 'typeahead_decoration_key';
|
|
2
2
|
export const TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = 'typeaheadDecoration';
|
|
3
3
|
export const TYPE_AHEAD_POPUP_CONTENT_CLASS = 'fabric-editor-typeahead';
|
|
4
|
+
export const TYPE_AHEAD_DECORATION_ELEMENT_ID = 'typeahaed_decoration_element_id';
|
|
4
5
|
export let NavigationDirection;
|
|
5
6
|
|
|
6
7
|
(function (NavigationDirection) {
|
|
@@ -3,6 +3,21 @@ export const 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
|
});
|
|
@@ -64,7 +64,7 @@ export const createReducer = ({
|
|
|
64
64
|
triggerHandler,
|
|
65
65
|
decorationElement,
|
|
66
66
|
inputMethod,
|
|
67
|
-
selectedIndex: typeof selectedIndex === 'number' ? selectedIndex :
|
|
67
|
+
selectedIndex: typeof selectedIndex === 'number' ? selectedIndex : -1,
|
|
68
68
|
items: [],
|
|
69
69
|
query: reopenQuery || ''
|
|
70
70
|
};
|
|
@@ -133,7 +133,7 @@ export const createReducer = ({
|
|
|
133
133
|
} = currentPluginState;
|
|
134
134
|
return { ...currentPluginState,
|
|
135
135
|
items,
|
|
136
|
-
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex,
|
|
136
|
+
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, -1)
|
|
137
137
|
};
|
|
138
138
|
} else if (shouldUpdateSelectedIndex) {
|
|
139
139
|
return { ...currentPluginState,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import debounce from 'lodash/debounce';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
const statusDebounceMillis = 1400;
|
|
8
|
+
const assitiveTextStyles = css({
|
|
9
|
+
border: 0,
|
|
10
|
+
clip: 'rect(0 0 0 0)',
|
|
11
|
+
height: '1px',
|
|
12
|
+
marginbottom: '-1px',
|
|
13
|
+
marginright: '-1px',
|
|
14
|
+
overflow: 'hidden',
|
|
15
|
+
padding: 0,
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
whitespace: 'nowrap',
|
|
18
|
+
width: '1px'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
class AssistveTextComponent extends React.Component {
|
|
22
|
+
constructor(...args) {
|
|
23
|
+
super(...args);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "state", {
|
|
26
|
+
bump: false,
|
|
27
|
+
//when the same text needs to be read again, Hence it needs to be toggled between __status--A and __status--B
|
|
28
|
+
debounced: false,
|
|
29
|
+
silenced: false
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
componentWillMount() {
|
|
34
|
+
this.debounceStatusUpdate = debounce(() => {
|
|
35
|
+
if (!this.state.debounced) {
|
|
36
|
+
const shouldSilence = !this.props.isInFocus;
|
|
37
|
+
this.setState(({
|
|
38
|
+
bump
|
|
39
|
+
}) => ({
|
|
40
|
+
bump: !bump,
|
|
41
|
+
debounced: true,
|
|
42
|
+
silenced: shouldSilence
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
}, statusDebounceMillis);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
componentWillUnmount() {}
|
|
49
|
+
|
|
50
|
+
componentWillReceiveProps() {
|
|
51
|
+
this.setState(({
|
|
52
|
+
bump
|
|
53
|
+
}) => ({
|
|
54
|
+
bump: !bump,
|
|
55
|
+
debounced: false
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
render() {
|
|
60
|
+
const {
|
|
61
|
+
assistiveText,
|
|
62
|
+
id
|
|
63
|
+
} = this.props;
|
|
64
|
+
const {
|
|
65
|
+
bump,
|
|
66
|
+
debounced,
|
|
67
|
+
silenced
|
|
68
|
+
} = this.state;
|
|
69
|
+
this.debounceStatusUpdate();
|
|
70
|
+
return jsx("div", {
|
|
71
|
+
css: assitiveTextStyles
|
|
72
|
+
}, jsx("div", {
|
|
73
|
+
id: id + '__status--A',
|
|
74
|
+
role: "status",
|
|
75
|
+
"aria-atomic": "true",
|
|
76
|
+
"aria-live": "polite"
|
|
77
|
+
}, `${!silenced && debounced && bump ? assistiveText : ''}`), jsx("div", {
|
|
78
|
+
id: id + '__status--B',
|
|
79
|
+
role: "status",
|
|
80
|
+
"aria-atomic": "true",
|
|
81
|
+
"aria-live": "polite"
|
|
82
|
+
}, `${!silenced && debounced && !bump ? assistiveText : ''}`));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_defineProperty(AssistveTextComponent, "defaultProps", {
|
|
88
|
+
statusDebounceMillis: 1400,
|
|
89
|
+
debounce: true,
|
|
90
|
+
assistiveText: '',
|
|
91
|
+
isInFocus: false,
|
|
92
|
+
id: ''
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export const AssistiveText = AssistveTextComponent;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import React, { useRef, useCallback, Fragment, useLayoutEffect } from 'react';
|
|
2
|
+
import React, { useRef, useCallback, Fragment, useLayoutEffect, useState } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
5
5
|
import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { getPluginState } from '../utils';
|
|
6
7
|
import { CloseSelectionOptions, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
|
|
7
8
|
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
9
|
+
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../constants';
|
|
10
|
+
import { AssistiveText } from './AssistiveText';
|
|
11
|
+
import { typeAheadListMessages } from '../messages';
|
|
12
|
+
import { useIntl } from 'react-intl-next';
|
|
8
13
|
const querySpan = css`
|
|
9
14
|
outline: none;
|
|
10
15
|
`;
|
|
@@ -41,7 +46,9 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
41
46
|
forceFocus,
|
|
42
47
|
reopenQuery,
|
|
43
48
|
onQueryFocus,
|
|
44
|
-
onUndoRedo
|
|
49
|
+
onUndoRedo,
|
|
50
|
+
editorView,
|
|
51
|
+
items
|
|
45
52
|
}) => {
|
|
46
53
|
const ref = useRef(document.createElement('span'));
|
|
47
54
|
const cleanedInputContent = useCallback(() => {
|
|
@@ -54,6 +61,7 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
54
61
|
const text = cleanedInputContent();
|
|
55
62
|
onQueryChange(text);
|
|
56
63
|
}, [onQueryChange, cleanedInputContent]);
|
|
64
|
+
const [isInFocus, setInFocus] = useState(false);
|
|
57
65
|
const checkKeyEvent = useCallback(event => {
|
|
58
66
|
var _ref$current2;
|
|
59
67
|
|
|
@@ -62,6 +70,10 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
62
70
|
const raw = ((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.textContent) || '';
|
|
63
71
|
const text = cleanedInputContent();
|
|
64
72
|
let stopDefault = false;
|
|
73
|
+
const {
|
|
74
|
+
selectedIndex
|
|
75
|
+
} = getPluginState(editorView.state);
|
|
76
|
+
setInFocus(true);
|
|
65
77
|
|
|
66
78
|
switch (key) {
|
|
67
79
|
case ' ':
|
|
@@ -106,23 +118,29 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
106
118
|
// ED-14758 - Under the W3C specification, any keycode sent under IME would return a keycode 229
|
|
107
119
|
// 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.
|
|
108
120
|
// Some suggested the other workaround maybe listen on`keypress` instead of `keydown`
|
|
109
|
-
if (event.isComposing
|
|
110
|
-
|
|
121
|
+
if (!event.isComposing || event.which !== 229 && event.keyCode !== 229) {
|
|
122
|
+
if (selectedIndex === -1) {
|
|
123
|
+
selectNextItem();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
|
|
111
127
|
}
|
|
112
128
|
|
|
113
|
-
onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
|
|
114
129
|
break;
|
|
115
130
|
|
|
116
131
|
case 'Tab':
|
|
132
|
+
if (selectedIndex === -1) {
|
|
133
|
+
selectNextItem();
|
|
134
|
+
}
|
|
135
|
+
|
|
117
136
|
onItemSelect(SelectItemMode.TAB);
|
|
118
137
|
break;
|
|
119
138
|
|
|
120
139
|
case 'ArrowDown':
|
|
121
|
-
|
|
122
|
-
|
|
140
|
+
if (selectedIndex === -1) {
|
|
141
|
+
selectNextItem();
|
|
142
|
+
}
|
|
123
143
|
|
|
124
|
-
case 'ArrowUp':
|
|
125
|
-
selectPreviousItem();
|
|
126
144
|
break;
|
|
127
145
|
}
|
|
128
146
|
|
|
@@ -137,7 +155,7 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
137
155
|
event.preventDefault();
|
|
138
156
|
return false;
|
|
139
157
|
}
|
|
140
|
-
}, [onUndoRedo, onItemSelect, selectNextItem, cancel,
|
|
158
|
+
}, [onUndoRedo, onItemSelect, selectNextItem, cancel, cleanedInputContent, editorView.state]);
|
|
141
159
|
const onClick = useCallback(event => {
|
|
142
160
|
var _ref$current3;
|
|
143
161
|
|
|
@@ -232,6 +250,7 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
232
250
|
const beforeinput = e => {
|
|
233
251
|
var _target$textContent;
|
|
234
252
|
|
|
253
|
+
setInFocus(false);
|
|
235
254
|
const {
|
|
236
255
|
target
|
|
237
256
|
} = e;
|
|
@@ -307,7 +326,7 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
307
326
|
element.removeEventListener('input', onInput);
|
|
308
327
|
}
|
|
309
328
|
};
|
|
310
|
-
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent]);
|
|
329
|
+
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent, editorView.state]);
|
|
311
330
|
useLayoutEffect(() => {
|
|
312
331
|
const hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
313
332
|
|
|
@@ -330,9 +349,12 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
330
349
|
}
|
|
331
350
|
|
|
332
351
|
ref.current.focus();
|
|
352
|
+
setInFocus(true);
|
|
333
353
|
});
|
|
334
354
|
}
|
|
335
355
|
}, [forceFocus, reopenQuery]);
|
|
356
|
+
const assistiveHintID = TYPE_AHEAD_DECORATION_ELEMENT_ID + '__assistiveHint';
|
|
357
|
+
const intl = useIntl();
|
|
336
358
|
/**
|
|
337
359
|
When we migrated to emotion from styled component, we started getting this error.
|
|
338
360
|
jsx-a11y/interactive-supports-focus
|
|
@@ -345,9 +367,24 @@ export const InputQuery = /*#__PURE__*/React.memo(({
|
|
|
345
367
|
ref: ref,
|
|
346
368
|
onKeyUp: onKeyUp,
|
|
347
369
|
onClick: onClick,
|
|
348
|
-
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,
|
|
349
375
|
suppressContentEditableWarning: true,
|
|
350
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
|
|
351
388
|
}));
|
|
352
389
|
});
|
|
353
390
|
InputQuery.displayName = 'InputQuery';
|