@lumel/mention 5.2.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +286 -0
  2. package/LICENSE +7 -0
  3. package/README.md +9 -0
  4. package/lib/Mention.d.ts +22 -0
  5. package/lib/MentionSuggestions/Entry/Avatar/Avatar.d.ts +9 -0
  6. package/lib/MentionSuggestions/Entry/DefaultEntryComponent.d.ts +3 -0
  7. package/lib/MentionSuggestions/Entry/Entry.d.ts +38 -0
  8. package/lib/MentionSuggestions/MentionSuggestions.d.ts +80 -0
  9. package/lib/MentionSuggestions/Popover.d.ts +10 -0
  10. package/lib/MentionSuggestions/__test__/MentionSuggestions.test.d.ts +1 -0
  11. package/lib/MentionSuggestionsPortal.d.ts +11 -0
  12. package/lib/__test__/Mention.test.d.ts +1 -0
  13. package/lib/__test__/mentionSuggestionsStrategy.test.d.ts +1 -0
  14. package/lib/defaultRegExp.d.ts +2 -0
  15. package/lib/index.cjs.js +1215 -0
  16. package/lib/index.d.ts +66 -0
  17. package/lib/index.esm.js +1198 -0
  18. package/lib/mentionStrategy.d.ts +3 -0
  19. package/lib/mentionSuggestionsStrategy.d.ts +6 -0
  20. package/lib/modifiers/addMention.d.ts +3 -0
  21. package/lib/plugin.css +8 -0
  22. package/lib/theme.d.ts +12 -0
  23. package/lib/utils/__test__/getSearchTextAt.test.d.ts +1 -0
  24. package/lib/utils/__test__/getTriggerForMention.test.d.ts +1 -0
  25. package/lib/utils/__test__/getTypeByTrigger.test.d.ts +1 -0
  26. package/lib/utils/decodeOffsetKey.d.ts +7 -0
  27. package/lib/utils/defaultSuggestionsFilter.d.ts +3 -0
  28. package/lib/utils/getSearchText.d.ts +4 -0
  29. package/lib/utils/getSearchTextAt.d.ts +9 -0
  30. package/lib/utils/getTriggerForMention.d.ts +8 -0
  31. package/lib/utils/getTypeByTrigger.d.ts +1 -0
  32. package/lib/utils/positionSuggestions.d.ts +13 -0
  33. package/lib/utils/warning.d.ts +1 -0
  34. package/package.json +60 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,286 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project adheres to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## To Be Released
7
+
8
+ ## 5.2.1
9
+
10
+ - support react 18 in peer dependencies [#2701](https://github.com/draft-js-plugins/draft-js-plugins/issues/2701)
11
+
12
+ ## 5.2.0
13
+
14
+ - Export `Popover` component for `MentionSuggestions` prop `popoverContainer` without lose of Popper.js functionally [#2684](https://github.com/draft-js-plugins/draft-js-plugins/issues/2684)
15
+
16
+ ## 5.1.2
17
+
18
+ - Fixing `popoverContainer` type for `MentionSuggestions` [#2633](https://github.com/draft-js-plugins/draft-js-plugins/issues/2633)
19
+
20
+ ## 5.1.1
21
+
22
+ - Add Japanese symbol to default regExp
23
+ - Fixing lodash import to reduce bundle size [#2530](https://github.com/draft-js-plugins/draft-js-plugins/issues/2530)
24
+
25
+ ## 5.1.0
26
+
27
+ - Use current inline style for mention [#2414](https://github.com/draft-js-plugins/draft-js-plugins/issues/2414)
28
+
29
+ ## 5.0.0
30
+
31
+ - reset selected item on search change for mention suggestion [#2348](https://github.com/draft-js-plugins/draft-js-plugins/issues/2348)
32
+ - add `selectMention` to `EntryComponentProps` [#2363](https://github.com/draft-js-plugins/draft-js-plugins/issues/2363)
33
+
34
+ ## 4.6.1
35
+
36
+ - delay scrolling into view for selected item in mention list [#2233](https://github.com/draft-js-plugins/draft-js-plugins/issues/2233)
37
+ - add animation for `popper.js` [#2209](https://github.com/draft-js-plugins/draft-js-plugins/issues/2209)
38
+
39
+ ## 4.6.0
40
+
41
+ - sroll focused `Entry` component into view [#997](https://github.com/draft-js-plugins/draft-js-plugins/issues/997)
42
+
43
+ ## 4.5.2
44
+
45
+ - add `sideEffects` for css files [#1833](https://github.com/draft-js-plugins/draft-js-plugins/issues/1833)
46
+
47
+ ## 4.5.1
48
+
49
+ - do not render popover if there are no mentions, add `renderEmptyPopup` prop [#2049](https://github.com/draft-js-plugins/draft-js-plugins/issues/2049)
50
+ - remove the trigger from the search value [#2047](https://github.com/draft-js-plugins/draft-js-plugins/issues/2047)
51
+
52
+ ## 4.5.0
53
+
54
+ - fixing multi-character trigger [#2017](https://github.com/draft-js-plugins/draft-js-plugins/issues/2017)
55
+ - change MentionSuggestions to popper.js with option `popperOptions`, `popoverContainer` and deprecate `popoverComponent` and `positionSuggestions` [#1933](https://github.com/draft-js-plugins/draft-js-plugins/issues/1933)
56
+ - Fix @-mentions to work when the trigger character appears within the search string, for instance an email address.
57
+
58
+ ## 4.4.1
59
+
60
+ - fixing issue that line does not work [#2004](https://github.com/draft-js-plugins/draft-js-plugins/issues/2004)
61
+
62
+ ## 4.4.0
63
+
64
+ - fixing issue with build for commen js bundels [#1976](https://github.com/draft-js-plugins/draft-js-plugins/issues/1976)
65
+
66
+ ## 4.3.2
67
+
68
+ - Add store to PositionSuggestionsParams types [#1945](https://github.com/draft-js-plugins/draft-js-plugins/issues/1945)
69
+ - Fixing issue if trigger is first character and cursor if before trigger [#1957](https://github.com/draft-js-plugins/draft-js-plugins/issues/1957)
70
+
71
+ ## 4.3.1
72
+
73
+ - Fix the @ mentions to actually work. Right now they don't work in the middle of a line. If you start a line with "@" it works but if you start typing text then type "@" it doesn't work.
74
+ - Extend the support for chinese symbols [#1888](https://github.com/draft-js-plugins/draft-js-plugins/issues/1888)
75
+
76
+ ## 4.3.0
77
+
78
+ - fixing trigger range for suggestion strategy [#1772](https://github.com/draft-js-plugins/draft-js-plugins/issues/1772)
79
+ - fixing lookahead RegExp which is not supported in Safari [#1844](https://github.com/draft-js-plugins/draft-js-plugins/issues/1844)
80
+ - added support for multiple triggers
81
+
82
+ ## 4.2.0
83
+
84
+ - remove `entryComponent` from plugin config [#1736](https://github.com/draft-js-plugins/draft-js-plugins/issues/1736)
85
+
86
+ ## 4.1.0
87
+
88
+ - add "sideEffects": false for tree shaking
89
+ - Fix regex to ignore trigger in text with supportWhitespace [#1723](https://github.com/draft-js-plugins/draft-js-plugins/issues/1723)
90
+
91
+ ## 4.0.2
92
+
93
+ - Fix key bindings issue if dropdown is open but there's no suggestion [#1696](https://github.com/draft-js-plugins/draft-js-plugins/issues/1696)
94
+ - Fix popoverComponent types
95
+
96
+ ## 4.0.1
97
+
98
+ - fixing issue Failed to execute 'removeChild' on 'Node' [#1697](https://github.com/draft-js-plugins/draft-js-plugins/issues/1697)
99
+
100
+ ## 4.0.0
101
+
102
+ - Add Arabic Support
103
+ - Remove legacy lifecycle hooks
104
+ - Require react 16.3 and above version
105
+ - Migrate styles to linaria
106
+ - Hide internals in single bundle
107
+ - Add esm support
108
+ - Use lodash-es in esm bundle
109
+ - Added open and onOpenChange required props to make state controlled outside and prevent reacting on suggestions list
110
+ - onOpen and onClose callbacks are removed in favour of onOpenChange
111
+ - Made suggestions prop required (pass empty array for async suggestions)
112
+ - Remove prevState and state from positionSuggestions
113
+ - add entryComponent to mention plugin
114
+ - convert to typescript
115
+ - use the setEditorState and getEditorState functions from props.store in EmojiSuggestionsPortal
116
+
117
+ ## 3.1.5
118
+
119
+ - removed deprecated draft-js hooks (onUpArrow, onDownArrow, onEscape, onTab) usage
120
+
121
+ ## 3.1.4
122
+
123
+ - Allow draft-js v0.11
124
+ - Remove unused dependencies
125
+
126
+ ## 3.1.3
127
+
128
+ - Force update regex's `lastIndex` to avoid infinite loop
129
+ - Fixed replace issue while `mentionTrigger` is empty
130
+
131
+ ## 3.1.2
132
+
133
+ - Allow empty `mentionTrigger` with `supportWhitespace: true` #1182
134
+
135
+ ## 3.1.1
136
+
137
+ - Fix regression for special characters in mention strategy.
138
+
139
+ ## 3.1.0
140
+
141
+ - Added `supportWhitespace` option to allow more precise matching of mentions containing spaces
142
+
143
+ ## 3.0.4
144
+
145
+ - Added an `id` attribute on the listbox options so the `aria-activedescendant` value refers to the focused option.
146
+
147
+ ## 3.0.2 - 3.0.3
148
+
149
+ - bumped find-with-regex
150
+
151
+ ## 3.0.1
152
+
153
+ - Added `aria-selected="true"` for the suggestions listbox focused option.
154
+ - Update aria attributes to use booleans
155
+
156
+ ## 3.0.0
157
+
158
+ - Deprecate immutable suggestions (breaking change), use arrays from now on
159
+ - export default theme (in case we want to extend it)
160
+
161
+ ## 2.0.2
162
+
163
+ (Much thanks to "dem" aka "Michael Deryugin" - https://github.com/dem)
164
+
165
+ - fix suggestions dropdown position in case of line wrap
166
+ - Allow mention popup for styled text
167
+ - Fixed bug where a user typed not existing mention @xxx and cursor is not moved with up/down arrow key
168
+ - Updated dependencies to support react 16
169
+
170
+ ## 2.0 alpha
171
+
172
+ ### Added
173
+
174
+ - Passing through `isFocused` prop to `entryComponent`. Thanks to @thomas88
175
+ - Added support for Latin-1 Supplement and Latin Extended-A characters. Thanks to @thomas88
176
+ - Fixed incorrect opening of suggestions. Thanks to @thomas88
177
+ - Added multiple character support for mentionTrigger
178
+ - Added config option `mentionSuggestionsComponent`. If provided the passed component replaces the default `MentionSuggestions` component. The provided component must implement the same interface like `MentionSuggestions`.
179
+ - Added support popoverComponent on the `MentionSuggestions` component. Thanks to @samdroid-apps
180
+ - Introduced a new configuration option `mentionTrigger`. By default it is set to `@`. As before by default typing `@` will trigger the search for mentions. You can provide a custom character or string to change when the search is triggered. [#320](https://github.com/draft-js-plugins/draft-js-plugins/pull/320) Thanks to @yjang1031
181
+ - MentionSuggestions accepts a new prop `entryComponent`. The passed component is used as the template for each of the suggestions' entry. [#317](https://github.com/draft-js-plugins/draft-js-plugins/pull/327). Thanks to @Zhouzi
182
+ - `defaultEntryComponent` component is passed `searchValue` prop to enable more customizations when displaying the the MentionSuggestions. Thanks to @nishp1
183
+ - The config now accepts a new prop `mentionComponent`. If provided the passed component is used to render a Mention. [#271](https://github.com/draft-js-plugins/draft-js-plugins/pull/271). Thanks to @alexkuz
184
+ - Introduced the `mentionRegExp` configuration to overwrite the regular expression for initiating the dropdown. By default this supports any alphanumeric character as well as Chinese, Japanese & Korean characters.
185
+ - Added support for Chinese words. Thanks to @mzbac
186
+ - Added support for Japanese characters (hiragana & katakana).
187
+ - Added support for Korean characters (Hangul Syllables & Hangul Compatibility Jamo). Thanks to @FourwingsY
188
+ - Added support for Cyrillic characters. Thanks to @imamatory
189
+ - Added `onAddMention` prop to MentionSuggestions. The first argument of this callback will contain the mention entry.
190
+
191
+ ### Fixed
192
+
193
+ - Escape spaces before mention trigger properly
194
+ - Escape mention trigger regex properly
195
+ - Fix bug that selects candidate on hitting return key even if the dropdown was closed. Thanks to @ngs [#720](https://github.com/draft-js-plugins/draft-js-plugins/pull/720)
196
+ - Fix issue with: add two mentions in the Custom Mention Component Example editor, then press backspace key, will remove the first one. Thanks to @chenyuejie [#693](https://github.com/draft-js-plugins/draft-js-plugins/pull/693)
197
+ - Prevents inserting the selected item on Enter or Tab when there's no trigger in sight and dropdown is not rendered. Thanks to @alexfedoseev [#706](https://github.com/draft-js-plugins/draft-js-plugins/pull/706)
198
+ - Reopens mentions dropdown if new suggestions are available. Thanks to @jameskraus [#659](https://github.com/draft-js-plugins/draft-js-plugins/pull/659)
199
+ - Solved a bug with @ being placed in the beginning. Thanks to @hjyue1 [#621](https://github.com/draft-js-plugins/draft-js-plugins/pull/621)
200
+ - Fixed "Cannot read property 'getBoundingClientRect' of null" issue. Thanks to @ismyrnow [#666](https://github.com/draft-js-plugins/draft-js-plugins/pull/667)
201
+ - Mentions popover showed up when typing before a @ [#323](https://github.com/draft-js-plugins/draft-js-plugins/issues/323) Thanks to @nishp1
202
+ - Only pass element properties to the root Div of MentionSuggestions to remove the "Unknown prop warning" in React 15.2.0
203
+ - Fixed bug where a user typed @xxx (invalid mention) and hit Enter. [#416](https://github.com/draft-js-plugins/draft-js-plugins/pull/416)
204
+ - Fixed bug where press up arrow would not cycle back to the bottom of suggestions
205
+ - Fixed race condition where the SuggestionPortal would unregister and not register again when inputting Japanese, etc.
206
+ - Fixed bug where `mentionPrefix` does not appear in `editorState`. `mentionPrefix` is no longer passed to `mentionComponent`.
207
+ - Fixed bug where `onSearchChange` didn't fire when a user switched between two different mention autocompletions with the same search value. Now it will trigger `onSearchChange` in such a case.
208
+ - Fixed unrecognized `isFocused` React prop.
209
+
210
+ ## 1.1.2 - 2016-06-26
211
+
212
+ ### Fixed
213
+
214
+ - Accepts plain JavaScript Objects for mentions from now on. Until now it only accepted an `Immutable.Map`. This change would make it play nicer together with `convertFromRaw` by default. Thanks to @anderslemke [#326](https://github.com/draft-js-plugins/draft-js-plugins/pull/326)
215
+ - `positionSuggestions` now works by default with non-static parents. Thanks to @Zhouzi
216
+ [#309](https://github.com/draft-js-plugins/draft-js-plugins/pull/309)
217
+ [#206](https://github.com/draft-js-plugins/draft-js-plugins/issues/206)
218
+ [#283](https://github.com/draft-js-plugins/draft-js-plugins/issues/283)
219
+ [#289](https://github.com/draft-js-plugins/draft-js-plugins/issues/289)
220
+
221
+ ## 1.1.1 - 2016-06-05
222
+
223
+ ### Fixed
224
+
225
+ - Close mention suggestions when suggestions filtered results are empty [#291](https://github.com/draft-js-plugins/draft-js-plugins/pull/291) [#265](https://github.com/draft-js-plugins/draft-js-plugins/issues/265)
226
+
227
+ ## 1.1.0 - 2016-05-27
228
+
229
+ ### Added
230
+
231
+ - `MentionSuggestions` now accepts `onOpen`and `onClose` props. These callbacks are triggered when the popover has opened or closed.
232
+
233
+ ## 1.0.2 - 2016-05-24
234
+
235
+ ### Fixed
236
+
237
+ - Fix rendering the MentionSuggestions in IE11 by avoiding to render an Immutable List [#266](https://github.com/draft-js-plugins/draft-js-plugins/issues/266) [#270](https://github.com/draft-js-plugins/draft-js-plugins/pull/270)
238
+ - Fix React 0.14.x support by returning `<noscript />` instead of `null` [#267](https://github.com/draft-js-plugins/draft-js-plugins/pull/267)
239
+
240
+ ## 1.0.1 - 2016-04-29
241
+
242
+ ### Fixed
243
+
244
+ - Make sure there is no autocomplete on tab after deleting a mention [#234](https://github.com/draft-js-plugins/draft-js-plugins/issues/234)
245
+
246
+ ## 1.0.0 - 2016-04-20
247
+
248
+ ### Changed
249
+
250
+ - Instead of the popover inline it is now exported as `MentionSuggestions` and can be placed anywhere in the DOM. It's recommended to place it right after the Editor. This change was important to avoid selection issues trigged by `contentEditable={false}`.
251
+ - `mentions` has been renamed to `suggestions` and now has to be directly provided to the `MentionSuggestions` component as property.
252
+ - Moved to a flat configuration. Instead of plugin properties (decorators & hooks) being stored within pluginProps they now moved to the root object. See the changes here [#150](https://github.com/draft-js-plugins/draft-js-plugins/pull/150/files) as well as the initial discussion here [#143](https://github.com/draft-js-plugins/draft-js-plugins/issues/143)
253
+ - Improved the regex and now test for a whitespace in front of the `@` to make sure it doesn't match on normal text like an email [#104](https://github.com/draft-js-plugins/draft-js-plugins/issues/104)
254
+ - Moved the option `theme` from an Immutable Map to a JavaScript object. This is more likely to become a standard.
255
+ - Improved styling and added animations for the Suggestions overlay as well as the hover on a single suggestion.
256
+ - Updated the theme properties.
257
+
258
+ ### Fixed
259
+
260
+ - Fix using backspace to close the autocomplete suggestions after typing an `@` [#110](https://github.com/draft-js-plugins/draft-js-plugins/issues/110)
261
+
262
+ ### Added
263
+
264
+ - The config now takes a property `entityMutability`. A developer can choose between 'IMMUTABLE', 'SEGMENTED' & 'MUTABLE'. Read in detail about it [here](https://draftjs.org/docs/advanced-topics-entities/#mutability).
265
+ - The config now takes a property `positionSuggestions`. The function can be used to manipulate the position of the popover containing the suggestions. It receives one object as arguments containing the visible rectangle surrounding the decorated search string including the @. In addition the object contains prevProps, prevState, state & props. An object should be returned which can contain all sorts of styles. The defined properties will be applied as inline-styles.
266
+ - Introduce a new config property: `mentionPrefix`. By default it is an empty String. For Twitter or Slack like mention behaviour you can provide an `@`.
267
+
268
+ ```
269
+ const mentionPlugin = createMentionPlugin({ entityMutability: 'IMMUTABLE' });
270
+ ```
271
+
272
+ - The `MentionSuggestions` component now takes a property `onSearchChange` which will trigger whenever the search value of changes.
273
+ - The module now exports `defaultSuggestionsFilter` for convenience. As first argument it takes the search term as a String. The second argument is the Immutable list of mentions. The function returns the filter list based on substring matches.
274
+
275
+ ## 0.0.4 - 2016-03-29
276
+
277
+ ### Fixed
278
+
279
+ - Fix issue with showing two menus at the same time [#132](https://github.com/draft-js-plugins/draft-js-plugins/issues/132)
280
+ - When typing ahead to 0 results and then back the first item must be still selected. [#149](https://github.com/draft-js-plugins/draft-js-plugins/pull/149)
281
+
282
+ ## 0.0.3 - 2016-03-25
283
+
284
+ ### Released the first working version of DraftJS Mention Plugin
285
+
286
+ It's not recommended to use the version 0.0.0 - 0.0.2
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2016 Nikolaus Graf
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # DraftJS Mention Plugin
2
+
3
+ _This is a plugin for the `@draft-js-plugins/editor`._
4
+
5
+ This plugin allows you to add mentions to your editor!
6
+
7
+ Usage:
8
+
9
+ see https://www.draft-js-plugins.com/plugin/mention
@@ -0,0 +1,22 @@
1
+ import { ContentState } from 'draft-js';
2
+ import { ComponentType, ReactElement, ReactNode } from 'react';
3
+ import { MentionData } from '.';
4
+ import { MentionPluginTheme } from './theme';
5
+ export interface SubMentionComponentProps {
6
+ mention: MentionData;
7
+ children: ReactNode;
8
+ className: string;
9
+ entityKey: string;
10
+ theme: MentionPluginTheme;
11
+ decoratedText: string;
12
+ }
13
+ export interface MentionProps {
14
+ children: ReactNode;
15
+ className: string;
16
+ entityKey: string;
17
+ theme?: MentionPluginTheme;
18
+ mentionComponent?: ComponentType<SubMentionComponentProps>;
19
+ decoratedText: string;
20
+ contentState: ContentState;
21
+ }
22
+ export default function Mention(props: MentionProps): ReactElement;
@@ -0,0 +1,9 @@
1
+ import { ReactElement } from 'react';
2
+ import { MentionData } from '../../../';
3
+ import { MentionPluginTheme } from '../../../theme';
4
+ interface AvatarProps {
5
+ theme?: MentionPluginTheme;
6
+ mention: MentionData;
7
+ }
8
+ export default function Avatar({ mention, theme, }: AvatarProps): ReactElement | null;
9
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ReactElement } from 'react';
2
+ import { EntryComponentProps } from './Entry';
3
+ export default function DefaultEntryComponent(props: EntryComponentProps): ReactElement;
@@ -0,0 +1,38 @@
1
+ import { ComponentType, MouseEvent, ReactElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { MentionData } from '../../';
4
+ import { MentionPluginTheme } from '../../theme';
5
+ export interface EntryComponentProps {
6
+ className?: string;
7
+ onMouseDown(event: MouseEvent): void;
8
+ onMouseUp(event: MouseEvent): void;
9
+ onMouseEnter(event: MouseEvent): void;
10
+ role: string;
11
+ id: string;
12
+ 'aria-selected'?: boolean | 'false' | 'true';
13
+ theme?: MentionPluginTheme;
14
+ mention: MentionData;
15
+ isFocused: boolean;
16
+ searchValue?: string;
17
+ selectMention(mention: MentionData | null): void;
18
+ }
19
+ interface EntryProps {
20
+ mention: MentionData;
21
+ entryComponent: ComponentType<EntryComponentProps>;
22
+ onMentionSelect(mention: MentionData | null): void;
23
+ theme: MentionPluginTheme;
24
+ id: string;
25
+ index: number;
26
+ onMentionFocus(index: number): void;
27
+ isFocused: boolean;
28
+ searchValue?: string;
29
+ }
30
+ declare const Entry: {
31
+ ({ onMentionSelect, mention, theme, index, onMentionFocus, isFocused, id, searchValue, entryComponent, }: EntryProps): ReactElement;
32
+ propTypes: {
33
+ entryComponent: PropTypes.Validator<any>;
34
+ searchValue: PropTypes.Requireable<string>;
35
+ onMentionSelect: PropTypes.Requireable<(...args: any[]) => any>;
36
+ };
37
+ };
38
+ export default Entry;
@@ -0,0 +1,80 @@
1
+ import { AriaProps, EditorCommand } from '@draft-js-plugins/editor';
2
+ import { DraftHandleValue, EditorState, SelectionState } from 'draft-js';
3
+ import PropTypes from 'prop-types';
4
+ import { Component, ComponentType, KeyboardEvent, ReactElement, RefAttributes } from 'react';
5
+ import { MentionData, MentionPluginStore, PopperOptions } from '..';
6
+ import { MentionPluginTheme } from '../theme';
7
+ import { PositionSuggestionsFn } from '../utils/positionSuggestions';
8
+ import { EntryComponentProps } from './Entry/Entry';
9
+ import { PopoverProps } from './Popover';
10
+ export interface MentionSuggestionCallbacks {
11
+ keyBindingFn?(event: KeyboardEvent): EditorCommand | null | undefined;
12
+ handleKeyCommand: undefined;
13
+ handleReturn?(event: KeyboardEvent): DraftHandleValue;
14
+ onChange?(editorState: EditorState): EditorState;
15
+ }
16
+ export interface PopoverComponentProps {
17
+ className: string;
18
+ role: string;
19
+ id: string;
20
+ }
21
+ export interface MentionSuggestionsPubProps {
22
+ suggestions: MentionData[];
23
+ open: boolean;
24
+ onOpenChange(open: boolean): void;
25
+ onSearchChange(event: {
26
+ trigger: string;
27
+ value: string;
28
+ }): void;
29
+ onAddMention?(Mention: MentionData): void;
30
+ popoverComponent?: ReactElement<PopoverComponentProps & RefAttributes<HTMLElement>>;
31
+ entryComponent?: ComponentType<EntryComponentProps>;
32
+ popoverContainer?: ComponentType<PopoverProps>;
33
+ renderEmptyPopup?: boolean;
34
+ }
35
+ export interface MentionSuggestionsProps extends MentionSuggestionsPubProps {
36
+ callbacks: MentionSuggestionCallbacks;
37
+ store: MentionPluginStore;
38
+ positionSuggestions?: PositionSuggestionsFn;
39
+ ariaProps: AriaProps;
40
+ theme: MentionPluginTheme;
41
+ mentionPrefix: string;
42
+ mentionTriggers: string[];
43
+ entityMutability: 'SEGMENTED' | 'IMMUTABLE' | 'MUTABLE';
44
+ popperOptions?: PopperOptions;
45
+ }
46
+ export declare class MentionSuggestions extends Component<MentionSuggestionsProps> {
47
+ static propTypes: {
48
+ open: PropTypes.Validator<boolean>;
49
+ onOpenChange: PropTypes.Validator<(...args: any[]) => any>;
50
+ entityMutability: PropTypes.Requireable<string>;
51
+ entryComponent: PropTypes.Requireable<(...args: any[]) => any>;
52
+ onAddMention: PropTypes.Requireable<(...args: any[]) => any>;
53
+ suggestions: PropTypes.Validator<any[]>;
54
+ };
55
+ state: {
56
+ focusedOptionIndex: number;
57
+ };
58
+ key: string;
59
+ popover?: HTMLElement;
60
+ activeOffsetKey?: string;
61
+ lastSearchValue?: string;
62
+ lastActiveTrigger?: string;
63
+ lastSelectionIsInsideWord?: Immutable.Iterable<string, boolean>;
64
+ constructor(props: MentionSuggestionsProps);
65
+ componentDidUpdate(): void;
66
+ componentWillUnmount(): void;
67
+ onEditorStateChange: (editorState: EditorState) => EditorState;
68
+ onSearchChange: (editorState: EditorState, selection: SelectionState, activeOffsetKey: string | undefined, lastActiveOffsetKey: string | undefined, trigger: string) => void;
69
+ onDownArrow: (keyboardEvent: KeyboardEvent) => void;
70
+ onTab: (keyboardEvent: KeyboardEvent) => void;
71
+ onUpArrow: (keyboardEvent: KeyboardEvent) => void;
72
+ onEscape: (keyboardEvent: KeyboardEvent) => void;
73
+ onMentionSelect: (mention: MentionData | null) => void;
74
+ onMentionFocus: (index: number) => void;
75
+ commitSelection: () => DraftHandleValue;
76
+ openDropdown: () => void;
77
+ closeDropdown: () => void;
78
+ render(): ReactElement | null;
79
+ }
80
+ export default MentionSuggestions;
@@ -0,0 +1,10 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { MentionPluginStore, PopperOptions } from '..';
3
+ import { MentionPluginTheme } from '../theme';
4
+ export interface PopoverProps {
5
+ store: MentionPluginStore;
6
+ children: ReactNode;
7
+ popperOptions?: PopperOptions;
8
+ theme: MentionPluginTheme;
9
+ }
10
+ export default function Popover({ store, children, theme, popperOptions, }: PopoverProps): ReactElement;
@@ -0,0 +1,11 @@
1
+ import { EditorState } from 'draft-js';
2
+ import { ReactElement, ReactNode } from 'react';
3
+ import { MentionPluginStore } from '.';
4
+ export interface MentionSuggestionsPortalProps {
5
+ offsetKey: string;
6
+ store: MentionPluginStore;
7
+ getEditorState(): EditorState;
8
+ setEditorState(state: EditorState): void;
9
+ children: ReactNode;
10
+ }
11
+ export default function MentionSuggestionsPortal(props: MentionSuggestionsPortalProps): ReactElement;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;