@atlaskit/editor-core 188.9.0 → 188.9.5
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 +13 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/insert-block/index.js +4 -6
- package/dist/cjs/plugins/tasks-and-decisions/index.js +4 -3
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +45 -13
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +15 -7
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/insert-block/index.js +4 -6
- package/dist/es2019/plugins/tasks-and-decisions/index.js +4 -3
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +43 -10
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +13 -6
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/insert-block/index.js +4 -6
- package/dist/esm/plugins/tasks-and-decisions/index.js +4 -3
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +45 -12
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +14 -7
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/labs/next/presets/default.d.ts +43 -43
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +2 -0
- package/dist/types/plugins/tasks-and-decisions/index.d.ts +2 -5
- package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +9 -4
- package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +9 -4
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +4 -2
- package/dist/types/plugins/tasks-and-decisions/types.d.ts +6 -1
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +43 -43
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/index.d.ts +2 -5
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +9 -4
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +9 -4
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +4 -2
- package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +8 -1
- package/package.json +10 -8
- package/dist/cjs/plugins/type-ahead/api.js +0 -215
- package/dist/cjs/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -205
- package/dist/cjs/plugins/type-ahead/commands/update-list-items.js +0 -23
- package/dist/cjs/plugins/type-ahead/commands/update-query.js +0 -27
- package/dist/cjs/plugins/type-ahead/commands/update-selected-index.js +0 -27
- package/dist/cjs/plugins/type-ahead/constants.js +0 -15
- package/dist/cjs/plugins/type-ahead/index.js +0 -14
- package/dist/cjs/plugins/type-ahead/insert-utils.js +0 -107
- package/dist/cjs/plugins/type-ahead/messages.js +0 -79
- package/dist/cjs/plugins/type-ahead/plugin.js +0 -382
- package/dist/cjs/plugins/type-ahead/pm-plugins/actions.js +0 -16
- package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +0 -148
- package/dist/cjs/plugins/type-ahead/pm-plugins/input-rules.js +0 -36
- package/dist/cjs/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -22
- package/dist/cjs/plugins/type-ahead/pm-plugins/key.js +0 -8
- package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +0 -110
- package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +0 -158
- package/dist/cjs/plugins/type-ahead/pm-plugins/utils.js +0 -18
- package/dist/cjs/plugins/type-ahead/stats-modifier.js +0 -42
- package/dist/cjs/plugins/type-ahead/transforms/close-type-ahead.js +0 -13
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -75
- package/dist/cjs/plugins/type-ahead/transforms/set-selection-before-query.js +0 -18
- package/dist/cjs/plugins/type-ahead/types.js +0 -5
- package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +0 -120
- package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +0 -400
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +0 -285
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +0 -179
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +0 -230
- package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -127
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -109
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-load-items.js +0 -50
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -41
- package/dist/cjs/plugins/type-ahead/utils.js +0 -130
- package/dist/es2019/plugins/type-ahead/api.js +0 -205
- package/dist/es2019/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -204
- package/dist/es2019/plugins/type-ahead/commands/update-list-items.js +0 -17
- package/dist/es2019/plugins/type-ahead/commands/update-query.js +0 -21
- package/dist/es2019/plugins/type-ahead/commands/update-selected-index.js +0 -21
- package/dist/es2019/plugins/type-ahead/constants.js +0 -9
- package/dist/es2019/plugins/type-ahead/index.js +0 -3
- package/dist/es2019/plugins/type-ahead/insert-utils.js +0 -106
- package/dist/es2019/plugins/type-ahead/messages.js +0 -73
- package/dist/es2019/plugins/type-ahead/plugin.js +0 -381
- package/dist/es2019/plugins/type-ahead/pm-plugins/actions.js +0 -10
- package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +0 -148
- package/dist/es2019/plugins/type-ahead/pm-plugins/input-rules.js +0 -29
- package/dist/es2019/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -16
- package/dist/es2019/plugins/type-ahead/pm-plugins/key.js +0 -2
- package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +0 -106
- package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +0 -160
- package/dist/es2019/plugins/type-ahead/pm-plugins/utils.js +0 -12
- package/dist/es2019/plugins/type-ahead/stats-modifier.js +0 -33
- package/dist/es2019/plugins/type-ahead/transforms/close-type-ahead.js +0 -7
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -71
- package/dist/es2019/plugins/type-ahead/transforms/set-selection-before-query.js +0 -10
- package/dist/es2019/plugins/type-ahead/types.js +0 -1
- package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +0 -88
- package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +0 -393
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +0 -273
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +0 -214
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +0 -233
- package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -109
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -112
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-load-items.js +0 -41
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -38
- package/dist/es2019/plugins/type-ahead/utils.js +0 -126
- package/dist/esm/plugins/type-ahead/api.js +0 -209
- package/dist/esm/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -198
- package/dist/esm/plugins/type-ahead/commands/update-list-items.js +0 -17
- package/dist/esm/plugins/type-ahead/commands/update-query.js +0 -21
- package/dist/esm/plugins/type-ahead/commands/update-selected-index.js +0 -21
- package/dist/esm/plugins/type-ahead/constants.js +0 -9
- package/dist/esm/plugins/type-ahead/index.js +0 -3
- package/dist/esm/plugins/type-ahead/insert-utils.js +0 -101
- package/dist/esm/plugins/type-ahead/messages.js +0 -73
- package/dist/esm/plugins/type-ahead/plugin.js +0 -374
- package/dist/esm/plugins/type-ahead/pm-plugins/actions.js +0 -10
- package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +0 -141
- package/dist/esm/plugins/type-ahead/pm-plugins/input-rules.js +0 -29
- package/dist/esm/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -16
- package/dist/esm/plugins/type-ahead/pm-plugins/key.js +0 -2
- package/dist/esm/plugins/type-ahead/pm-plugins/main.js +0 -104
- package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +0 -151
- package/dist/esm/plugins/type-ahead/pm-plugins/utils.js +0 -12
- package/dist/esm/plugins/type-ahead/stats-modifier.js +0 -35
- package/dist/esm/plugins/type-ahead/transforms/close-type-ahead.js +0 -7
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -69
- package/dist/esm/plugins/type-ahead/transforms/set-selection-before-query.js +0 -12
- package/dist/esm/plugins/type-ahead/types.js +0 -1
- package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +0 -115
- package/dist/esm/plugins/type-ahead/ui/InputQuery.js +0 -390
- package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +0 -276
- package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +0 -169
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +0 -220
- package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -117
- package/dist/esm/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -103
- package/dist/esm/plugins/type-ahead/ui/hooks/use-load-items.js +0 -43
- package/dist/esm/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -35
- package/dist/esm/plugins/type-ahead/utils.js +0 -124
- package/dist/types/plugins/type-ahead/api.d.ts +0 -61
- package/dist/types/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +0 -12
- package/dist/types/plugins/type-ahead/commands/update-list-items.d.ts +0 -3
- package/dist/types/plugins/type-ahead/commands/update-query.d.ts +0 -2
- package/dist/types/plugins/type-ahead/commands/update-selected-index.d.ts +0 -2
- package/dist/types/plugins/type-ahead/constants.d.ts +0 -8
- package/dist/types/plugins/type-ahead/index.d.ts +0 -4
- package/dist/types/plugins/type-ahead/insert-utils.d.ts +0 -18
- package/dist/types/plugins/type-ahead/messages.d.ts +0 -72
- package/dist/types/plugins/type-ahead/plugin.d.ts +0 -10
- package/dist/types/plugins/type-ahead/pm-plugins/actions.d.ts +0 -9
- package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -14
- package/dist/types/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -6
- package/dist/types/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +0 -2
- package/dist/types/plugins/type-ahead/pm-plugins/key.d.ts +0 -3
- package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +0 -14
- package/dist/types/plugins/type-ahead/pm-plugins/reducer.d.ts +0 -10
- package/dist/types/plugins/type-ahead/pm-plugins/utils.d.ts +0 -4
- package/dist/types/plugins/type-ahead/stats-modifier.d.ts +0 -20
- package/dist/types/plugins/type-ahead/transforms/close-type-ahead.d.ts +0 -2
- package/dist/types/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +0 -11
- package/dist/types/plugins/type-ahead/transforms/set-selection-before-query.d.ts +0 -2
- package/dist/types/plugins/type-ahead/types.d.ts +0 -109
- package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +0 -33
- package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +0 -26
- package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +0 -25
- package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -18
- package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +0 -29
- package/dist/types/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +0 -20
- package/dist/types/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +0 -3
- package/dist/types/plugins/type-ahead/ui/hooks/use-load-items.d.ts +0 -3
- package/dist/types/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +0 -11
- package/dist/types/plugins/type-ahead/utils.d.ts +0 -27
- package/dist/types-ts4.5/plugins/type-ahead/api.d.ts +0 -61
- package/dist/types-ts4.5/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +0 -12
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-list-items.d.ts +0 -3
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-query.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-selected-index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/constants.d.ts +0 -8
- package/dist/types-ts4.5/plugins/type-ahead/index.d.ts +0 -4
- package/dist/types-ts4.5/plugins/type-ahead/insert-utils.d.ts +0 -18
- package/dist/types-ts4.5/plugins/type-ahead/messages.d.ts +0 -72
- package/dist/types-ts4.5/plugins/type-ahead/plugin.d.ts +0 -10
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/actions.d.ts +0 -9
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -14
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -6
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/main.d.ts +0 -14
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/reducer.d.ts +0 -10
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/utils.d.ts +0 -4
- package/dist/types-ts4.5/plugins/type-ahead/stats-modifier.d.ts +0 -20
- package/dist/types-ts4.5/plugins/type-ahead/transforms/close-type-ahead.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +0 -11
- package/dist/types-ts4.5/plugins/type-ahead/transforms/set-selection-before-query.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +0 -111
- package/dist/types-ts4.5/plugins/type-ahead/ui/AssistiveText.d.ts +0 -33
- package/dist/types-ts4.5/plugins/type-ahead/ui/InputQuery.d.ts +0 -26
- package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadList.d.ts +0 -25
- package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -18
- package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadPopup.d.ts +0 -29
- package/dist/types-ts4.5/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +0 -20
- package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +0 -7
- package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-load-items.d.ts +0 -3
- package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +0 -11
- package/dist/types-ts4.5/plugins/type-ahead/utils.d.ts +0 -27
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
/** @jsx jsx */
|
|
3
|
-
|
|
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
|
-
class AssistveTextComponent extends React.Component {
|
|
21
|
-
constructor(...args) {
|
|
22
|
-
super(...args);
|
|
23
|
-
_defineProperty(this, "state", {
|
|
24
|
-
bump: false,
|
|
25
|
-
//when the same text needs to be read again, Hence it needs to be toggled between __status--A and __status--B
|
|
26
|
-
debounced: false,
|
|
27
|
-
silenced: false
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
componentWillMount() {
|
|
31
|
-
this.debounceStatusUpdate = debounce(() => {
|
|
32
|
-
if (!this.state.debounced) {
|
|
33
|
-
const shouldSilence = !this.props.isInFocus;
|
|
34
|
-
this.setState(({
|
|
35
|
-
bump
|
|
36
|
-
}) => ({
|
|
37
|
-
bump: !bump,
|
|
38
|
-
debounced: true,
|
|
39
|
-
silenced: shouldSilence
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
}, statusDebounceMillis);
|
|
43
|
-
}
|
|
44
|
-
componentWillUnmount() {
|
|
45
|
-
this.debounceStatusUpdate.cancel();
|
|
46
|
-
}
|
|
47
|
-
componentWillReceiveProps() {
|
|
48
|
-
this.setState(({
|
|
49
|
-
bump
|
|
50
|
-
}) => ({
|
|
51
|
-
bump: !bump,
|
|
52
|
-
debounced: false
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
render() {
|
|
56
|
-
const {
|
|
57
|
-
assistiveText,
|
|
58
|
-
id
|
|
59
|
-
} = this.props;
|
|
60
|
-
const {
|
|
61
|
-
bump,
|
|
62
|
-
debounced,
|
|
63
|
-
silenced
|
|
64
|
-
} = this.state;
|
|
65
|
-
this.debounceStatusUpdate();
|
|
66
|
-
return jsx("div", {
|
|
67
|
-
css: assitiveTextStyles
|
|
68
|
-
}, jsx("div", {
|
|
69
|
-
id: id + '__status--A',
|
|
70
|
-
role: "status",
|
|
71
|
-
"aria-atomic": "true",
|
|
72
|
-
"aria-live": "polite"
|
|
73
|
-
}, `${!silenced && debounced && bump ? assistiveText : ''}`), jsx("div", {
|
|
74
|
-
id: id + '__status--B',
|
|
75
|
-
role: "status",
|
|
76
|
-
"aria-atomic": "true",
|
|
77
|
-
"aria-live": "polite"
|
|
78
|
-
}, `${!silenced && debounced && !bump ? assistiveText : ''}`));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
_defineProperty(AssistveTextComponent, "defaultProps", {
|
|
82
|
-
statusDebounceMillis: 1400,
|
|
83
|
-
debounce: true,
|
|
84
|
-
assistiveText: '',
|
|
85
|
-
isInFocus: false,
|
|
86
|
-
id: ''
|
|
87
|
-
});
|
|
88
|
-
export const AssistiveText = AssistveTextComponent;
|
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React, { useRef, useCallback, Fragment, useLayoutEffect, useState } from 'react';
|
|
3
|
-
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
5
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { getPluginState } from '../utils';
|
|
7
|
-
import { CloseSelectionOptions, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../constants';
|
|
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';
|
|
13
|
-
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
14
|
-
const querySpan = css({
|
|
15
|
-
outline: 'none',
|
|
16
|
-
'& input': {
|
|
17
|
-
width: '5px',
|
|
18
|
-
border: 'none',
|
|
19
|
-
background: 'transparent',
|
|
20
|
-
padding: 0,
|
|
21
|
-
margin: 0,
|
|
22
|
-
// ED-17022 Fixes firefox caret position
|
|
23
|
-
fontSize: '1em',
|
|
24
|
-
height: blockNodesVerticalMargin,
|
|
25
|
-
caretColor: "var(--ds-text-accent-blue, #0052CC)"
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const isNavigationKey = event => {
|
|
29
|
-
return ['Enter', 'Tab', 'ArrowDown', 'ArrowUp'].includes(event.key);
|
|
30
|
-
};
|
|
31
|
-
const isUndoRedoShortcut = event => {
|
|
32
|
-
const key = keyNameNormalized(event);
|
|
33
|
-
if (event.ctrlKey && key === 'y') {
|
|
34
|
-
return 'historyRedo';
|
|
35
|
-
}
|
|
36
|
-
if ((event.ctrlKey || event.metaKey) && event.shiftKey && key === 'Z') {
|
|
37
|
-
return 'historyRedo';
|
|
38
|
-
}
|
|
39
|
-
if ((event.ctrlKey || event.metaKey) && key === 'z') {
|
|
40
|
-
return 'historyUndo';
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
43
|
-
};
|
|
44
|
-
const getAriaLabel = (triggerPrefix, intl) => {
|
|
45
|
-
switch (triggerPrefix) {
|
|
46
|
-
case '@':
|
|
47
|
-
return typeAheadListMessages.mentionInputLabel;
|
|
48
|
-
case '/':
|
|
49
|
-
return typeAheadListMessages.quickInsertInputLabel;
|
|
50
|
-
case ':':
|
|
51
|
-
return typeAheadListMessages.emojiInputLabel;
|
|
52
|
-
default:
|
|
53
|
-
return typeAheadListMessages.quickInsertInputLabel;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
export const InputQuery = /*#__PURE__*/React.memo(({
|
|
57
|
-
triggerQueryPrefix,
|
|
58
|
-
cancel,
|
|
59
|
-
onQueryChange,
|
|
60
|
-
onItemSelect,
|
|
61
|
-
selectNextItem,
|
|
62
|
-
selectPreviousItem,
|
|
63
|
-
forceFocus,
|
|
64
|
-
reopenQuery,
|
|
65
|
-
onQueryFocus,
|
|
66
|
-
onUndoRedo,
|
|
67
|
-
editorView,
|
|
68
|
-
items
|
|
69
|
-
}) => {
|
|
70
|
-
const ref = useRef(document.createElement('span'));
|
|
71
|
-
const inputRef = useRef(null);
|
|
72
|
-
const [query, setQuery] = useState(null);
|
|
73
|
-
const cleanedInputContent = useCallback(() => {
|
|
74
|
-
var _ref$current;
|
|
75
|
-
const raw = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.textContent) || '';
|
|
76
|
-
return raw;
|
|
77
|
-
}, []);
|
|
78
|
-
const onKeyUp = useCallback(event => {
|
|
79
|
-
const text = cleanedInputContent();
|
|
80
|
-
onQueryChange(text);
|
|
81
|
-
}, [onQueryChange, cleanedInputContent]);
|
|
82
|
-
const [isInFocus, setInFocus] = useState(false);
|
|
83
|
-
const checkKeyEvent = useCallback(event => {
|
|
84
|
-
var _ref$current2;
|
|
85
|
-
const key = keyNameNormalized(event);
|
|
86
|
-
const sel = document.getSelection();
|
|
87
|
-
const raw = ((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.textContent) || '';
|
|
88
|
-
const text = cleanedInputContent();
|
|
89
|
-
let stopDefault = false;
|
|
90
|
-
const {
|
|
91
|
-
selectedIndex
|
|
92
|
-
} = getPluginState(editorView.state) || {};
|
|
93
|
-
setInFocus(true);
|
|
94
|
-
switch (key) {
|
|
95
|
-
case ' ':
|
|
96
|
-
// space key
|
|
97
|
-
if (text.length === 0) {
|
|
98
|
-
cancel({
|
|
99
|
-
forceFocusOnEditor: true,
|
|
100
|
-
text: ' ',
|
|
101
|
-
addPrefixTrigger: true,
|
|
102
|
-
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
103
|
-
});
|
|
104
|
-
stopDefault = true;
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case 'Escape':
|
|
108
|
-
case 'PageUp':
|
|
109
|
-
case 'PageDown':
|
|
110
|
-
case 'Home':
|
|
111
|
-
cancel({
|
|
112
|
-
text,
|
|
113
|
-
forceFocusOnEditor: true,
|
|
114
|
-
addPrefixTrigger: true,
|
|
115
|
-
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
116
|
-
});
|
|
117
|
-
stopDefault = true;
|
|
118
|
-
break;
|
|
119
|
-
case 'Backspace':
|
|
120
|
-
if (raw.length === 0 || (sel === null || sel === void 0 ? void 0 : sel.anchorOffset) === 0) {
|
|
121
|
-
event.stopPropagation();
|
|
122
|
-
event.preventDefault();
|
|
123
|
-
cancel({
|
|
124
|
-
forceFocusOnEditor: true,
|
|
125
|
-
text,
|
|
126
|
-
addPrefixTrigger: false,
|
|
127
|
-
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
break;
|
|
131
|
-
case 'Enter':
|
|
132
|
-
// ED-14758 - Under the W3C specification, any keycode sent under IME would return a keycode 229
|
|
133
|
-
// 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.
|
|
134
|
-
// Some suggested the other workaround maybe listen on`keypress` instead of `keydown`
|
|
135
|
-
if (!event.isComposing && event.which !== 229 && event.keyCode !== 229) {
|
|
136
|
-
if (selectedIndex === -1) {
|
|
137
|
-
/**
|
|
138
|
-
* TODO DTR-1401: (also see ED-17200) There are two options
|
|
139
|
-
* here, either
|
|
140
|
-
* - set the index directly to 1 in WrapperTypeAhead.tsx's
|
|
141
|
-
* `insertSelectedItem` at the cost of breaking some of the a11y
|
|
142
|
-
* focus changes,
|
|
143
|
-
* - or do this jank at the cost of some small analytics noise.
|
|
144
|
-
*
|
|
145
|
-
* The focus behaviour still needs cleanup
|
|
146
|
-
*/
|
|
147
|
-
selectPreviousItem();
|
|
148
|
-
selectNextItem();
|
|
149
|
-
}
|
|
150
|
-
onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
|
|
151
|
-
}
|
|
152
|
-
break;
|
|
153
|
-
case 'Tab':
|
|
154
|
-
if (selectedIndex === -1) {
|
|
155
|
-
/**
|
|
156
|
-
* TODO DTR-1401: (also see ED-17200) There are two options
|
|
157
|
-
* here, either
|
|
158
|
-
* - set the index directly to 1 in WrapperTypeAhead.tsx's
|
|
159
|
-
* `insertSelectedItem` at the cost of breaking some of the a11y
|
|
160
|
-
* focus changes,
|
|
161
|
-
* - or do this jank at the cost of some small analytics noise.
|
|
162
|
-
*
|
|
163
|
-
*/
|
|
164
|
-
selectPreviousItem();
|
|
165
|
-
selectNextItem();
|
|
166
|
-
}
|
|
167
|
-
// TODO DTR-1401: why is this calling select item when hitting tab? fix this in DTR-1401
|
|
168
|
-
onItemSelect(SelectItemMode.TAB);
|
|
169
|
-
break;
|
|
170
|
-
case 'ArrowDown':
|
|
171
|
-
selectNextItem();
|
|
172
|
-
break;
|
|
173
|
-
case 'ArrowUp':
|
|
174
|
-
selectPreviousItem();
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
const undoRedoType = isUndoRedoShortcut(event);
|
|
178
|
-
if (onUndoRedo && undoRedoType && onUndoRedo(undoRedoType)) {
|
|
179
|
-
stopDefault = true;
|
|
180
|
-
}
|
|
181
|
-
if (isNavigationKey(event) || stopDefault) {
|
|
182
|
-
event.stopPropagation();
|
|
183
|
-
event.preventDefault();
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
}, [onUndoRedo, onItemSelect, selectNextItem, selectPreviousItem, cancel, cleanedInputContent, editorView.state]);
|
|
187
|
-
const onClick = useCallback(event => {
|
|
188
|
-
var _inputRef$current;
|
|
189
|
-
event.stopPropagation();
|
|
190
|
-
event.preventDefault();
|
|
191
|
-
onQueryFocus();
|
|
192
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
193
|
-
return false;
|
|
194
|
-
}, [onQueryFocus]);
|
|
195
|
-
useLayoutEffect(() => {
|
|
196
|
-
if (!ref.current) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
const {
|
|
200
|
-
current: element
|
|
201
|
-
} = ref;
|
|
202
|
-
const onFocusIn = event => {
|
|
203
|
-
onQueryFocus();
|
|
204
|
-
};
|
|
205
|
-
const keyDown = event => {
|
|
206
|
-
const key = keyNameNormalized(event);
|
|
207
|
-
if (['ArrowLeft', 'ArrowRight'].includes(key) && document.getSelection && document.getSelection()) {
|
|
208
|
-
var _ref$current3;
|
|
209
|
-
const q = ((_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.textContent) || '';
|
|
210
|
-
const sel = document.getSelection();
|
|
211
|
-
const isMovingRight = sel && 'ArrowRight' === key && sel.anchorOffset === q.length;
|
|
212
|
-
const isMovingLeft = sel && 'ArrowLeft' === key && (sel.anchorOffset === 0 || event.metaKey);
|
|
213
|
-
if (!isMovingRight && !isMovingLeft) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
cancel({
|
|
217
|
-
forceFocusOnEditor: true,
|
|
218
|
-
addPrefixTrigger: true,
|
|
219
|
-
text: cleanedInputContent(),
|
|
220
|
-
setSelectionAt: isMovingRight ? CloseSelectionOptions.AFTER_TEXT_INSERTED : CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
221
|
-
});
|
|
222
|
-
event.preventDefault();
|
|
223
|
-
event.stopPropagation();
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
checkKeyEvent(event);
|
|
227
|
-
};
|
|
228
|
-
const onFocusOut = event => {
|
|
229
|
-
var _window$getSelection;
|
|
230
|
-
const {
|
|
231
|
-
relatedTarget
|
|
232
|
-
} = event;
|
|
233
|
-
|
|
234
|
-
// Given the user is changing the focus
|
|
235
|
-
// When the target is inside the TypeAhead Popup
|
|
236
|
-
// Then the popup should stay open
|
|
237
|
-
if (relatedTarget instanceof HTMLElement && relatedTarget.closest && relatedTarget.closest(`.${TYPE_AHEAD_POPUP_CONTENT_CLASS}`)) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// See ED-14909: Chrome may emit focusout events where an input
|
|
242
|
-
// device was not directly responsible. (This rears in react v17+ consumers
|
|
243
|
-
// where react-managed node removal now appears to propagate focusout events to
|
|
244
|
-
// our event listener). As this path is strictly for click or other typeahead
|
|
245
|
-
// dismissals that don't involve typeahead item selection, we carve out an
|
|
246
|
-
// exception for Chrome-specific events where an input device was not the initiator.
|
|
247
|
-
if (browser.chrome && !(((_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 ? void 0 : _window$getSelection.type) === 'Range') && !('sourceCapabilities' in event && event.sourceCapabilities)) {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
cancel({
|
|
251
|
-
addPrefixTrigger: true,
|
|
252
|
-
text: cleanedInputContent(),
|
|
253
|
-
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED,
|
|
254
|
-
forceFocusOnEditor: false
|
|
255
|
-
});
|
|
256
|
-
};
|
|
257
|
-
const close = () => {
|
|
258
|
-
cancel({
|
|
259
|
-
addPrefixTrigger: false,
|
|
260
|
-
text: '',
|
|
261
|
-
forceFocusOnEditor: true,
|
|
262
|
-
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
const beforeinput = e => {
|
|
266
|
-
var _target$textContent;
|
|
267
|
-
setInFocus(false);
|
|
268
|
-
const {
|
|
269
|
-
target
|
|
270
|
-
} = e;
|
|
271
|
-
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
if (e.inputType === 'historyUndo' && ((_target$textContent = target.textContent) === null || _target$textContent === void 0 ? void 0 : _target$textContent.length) === 0) {
|
|
275
|
-
e.preventDefault();
|
|
276
|
-
e.stopPropagation();
|
|
277
|
-
close();
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (e.data != null && inputRef.current === null) {
|
|
281
|
-
setQuery('');
|
|
282
|
-
|
|
283
|
-
// We need to change the content on Safari
|
|
284
|
-
// and set the cursor at the right place
|
|
285
|
-
if (browser.safari) {
|
|
286
|
-
e.preventDefault();
|
|
287
|
-
const dataElement = document.createTextNode(e.data);
|
|
288
|
-
element.appendChild(dataElement);
|
|
289
|
-
const sel = window.getSelection();
|
|
290
|
-
const range = document.createRange();
|
|
291
|
-
range.setStart(dataElement, dataElement.length);
|
|
292
|
-
range.collapse(true);
|
|
293
|
-
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
294
|
-
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
let onInput = null;
|
|
299
|
-
if (browser.safari) {
|
|
300
|
-
// On Safari, for reasons beyond my understanding,
|
|
301
|
-
// The undo behavior is totally different from other browsers
|
|
302
|
-
// That why we need to have an specific branch only for Safari.
|
|
303
|
-
const onInput = e => {
|
|
304
|
-
var _target$textContent2;
|
|
305
|
-
const {
|
|
306
|
-
target
|
|
307
|
-
} = e;
|
|
308
|
-
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
if (e.inputType === 'historyUndo' && ((_target$textContent2 = target.textContent) === null || _target$textContent2 === void 0 ? void 0 : _target$textContent2.length) === 1) {
|
|
312
|
-
e.preventDefault();
|
|
313
|
-
e.stopPropagation();
|
|
314
|
-
close();
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
element.addEventListener('input', onInput);
|
|
319
|
-
}
|
|
320
|
-
element.addEventListener('focusout', onFocusOut);
|
|
321
|
-
element.addEventListener('focusin', onFocusIn);
|
|
322
|
-
element.addEventListener('keydown', keyDown);
|
|
323
|
-
element.addEventListener('beforeinput', beforeinput);
|
|
324
|
-
return () => {
|
|
325
|
-
element.removeEventListener('focusout', onFocusOut);
|
|
326
|
-
element.removeEventListener('focusin', onFocusIn);
|
|
327
|
-
element.removeEventListener('keydown', keyDown);
|
|
328
|
-
element.removeEventListener('beforeinput', beforeinput);
|
|
329
|
-
if (browser.safari) {
|
|
330
|
-
element.removeEventListener('input', onInput);
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent, editorView.state]);
|
|
334
|
-
useLayoutEffect(() => {
|
|
335
|
-
const hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
336
|
-
if (ref.current && forceFocus) {
|
|
337
|
-
setQuery(hasReopenQuery ? reopenQuery : null);
|
|
338
|
-
requestAnimationFrame(() => {
|
|
339
|
-
if (!(ref !== null && ref !== void 0 && ref.current)) {
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
const sel = window.getSelection();
|
|
343
|
-
if (sel && hasReopenQuery && ref.current.lastChild instanceof Text) {
|
|
344
|
-
const lastChild = ref.current.lastChild;
|
|
345
|
-
const range = document.createRange();
|
|
346
|
-
range.setStart(ref.current.lastChild, lastChild.length);
|
|
347
|
-
range.collapse(true);
|
|
348
|
-
sel.removeAllRanges();
|
|
349
|
-
sel.addRange(range);
|
|
350
|
-
}
|
|
351
|
-
ref.current.focus();
|
|
352
|
-
setInFocus(true);
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
}, [forceFocus, reopenQuery]);
|
|
356
|
-
const assistiveHintID = TYPE_AHEAD_DECORATION_ELEMENT_ID + '__assistiveHint';
|
|
357
|
-
const intl = useIntl();
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
When we migrated to emotion from styled component, we started getting this error.
|
|
361
|
-
jsx-a11y/interactive-supports-focus
|
|
362
|
-
Task added in https://product-fabric.atlassian.net/wiki/spaces/E/pages/3182068181/Potential+improvements#Moderate-changes.
|
|
363
|
-
*/
|
|
364
|
-
return jsx(Fragment, null, triggerQueryPrefix, jsx("span", {
|
|
365
|
-
css: querySpan,
|
|
366
|
-
contentEditable: true,
|
|
367
|
-
ref: ref,
|
|
368
|
-
onKeyUp: onKeyUp,
|
|
369
|
-
onClick: onClick,
|
|
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,
|
|
375
|
-
suppressContentEditableWarning: true,
|
|
376
|
-
"data-query-prefix": triggerQueryPrefix
|
|
377
|
-
}, query === null ? jsx("input", {
|
|
378
|
-
ref: inputRef,
|
|
379
|
-
type: "text"
|
|
380
|
-
}) : query), jsx("span", {
|
|
381
|
-
id: assistiveHintID,
|
|
382
|
-
style: {
|
|
383
|
-
display: 'none'
|
|
384
|
-
}
|
|
385
|
-
}, intl.formatMessage(getAriaLabel(triggerQueryPrefix, intl)), ",", intl.formatMessage(typeAheadListMessages.inputQueryAssistiveLabel)), jsx(AssistiveText, {
|
|
386
|
-
assistiveText: items.length === 0 ? intl.formatMessage(typeAheadListMessages.noSearchResultsLabel, {
|
|
387
|
-
itemsLength: items.length
|
|
388
|
-
}) : '',
|
|
389
|
-
isInFocus: items.length === 0 || isInFocus,
|
|
390
|
-
id: TYPE_AHEAD_DECORATION_ELEMENT_ID
|
|
391
|
-
}));
|
|
392
|
-
});
|
|
393
|
-
InputQuery.displayName = 'InputQuery';
|