add quick shortcut emoji feature and tests

Signed-off-by: macekj <macekj@umich.edu>
This commit is contained in:
macekj 2020-11-17 17:36:58 -05:00
parent 8eadf6b183
commit ba8d02a808
5 changed files with 107 additions and 6 deletions

View file

@ -47,7 +47,7 @@ import AutocompleteWrapperModel from "../../../editor/autocomplete";
import DocumentPosition from "../../../editor/position";
import {ICompletion} from "../../../autocomplete/Autocompleter";
const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')\\s$');
const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s|(?<=^\\+))(' + EMOTICON_REGEX.source + ')\\s$');
const IS_MAC = navigator.platform.indexOf("Mac") !== -1;
@ -524,7 +524,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
const position = model.positionForOffset(caret.offset, caret.atNodeEnd);
const range = model.startRange(position);
range.expandBackwardsWhile((index, offset, part) => {
return part.text[offset] !== " " && (
return part.text[offset] !== " " && part.text[offset] !== "+" && (
part.type === "plain" ||
part.type === "pill-candidate" ||
part.type === "command"