Commit graph

189 commits

Author SHA1 Message Date
Michael Telatynski
287745f8c6
delint, remove unused imports and fix flow annotations
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-06-19 12:06:13 +01:00
Michael Telatynski
b79cd205a0
Support autocompleting Communities
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-06-19 11:52:48 +01:00
Michael Telatynski
9de6bf4f5a
once command has a space, strict match instead of fuzzy match
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

(cherry picked from commit a852033)
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-06-18 19:36:11 +01:00
Michael Telatynski
107802fa29
simplify arrow func
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-06-18 19:34:46 +01:00
Michael Telatynski
85ddc0651b
consolidate the two locations commands are defined, as it was a MESS
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-06-18 19:34:40 +01:00
Michael Telatynski
a50f6094cc
allow / + wait to also show all commands
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-06-16 16:44:13 +01:00
Michael Telatynski
f152ad84b8
Improve CommandProvider for Autocomplete
improve Regexp so it leaves autocomplete up whilst typing arguments
improve completion so it doesn't discard your arguments on-hover
add a way to list all commands by using `/<TAB>`

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-06-16 16:40:44 +01:00
Matthew Hodgson
4439a04689 fix lint 2018-05-20 23:43:42 +01:00
Matthew Hodgson
9aba046f21 fix MD pill serialization 2018-05-20 14:32:20 +01:00
Matthew Hodgson
c3a6a41e5d support links in RTE 2018-05-20 00:49:29 +01:00
Matthew Hodgson
c1000a7cd5 emojioneify the composer
and also fix up the selectedness CSS for pills and emoji
2018-05-14 03:02:12 +01:00
Matthew Hodgson
e06763cd59 show all slashcommands on / 2018-05-13 03:18:41 +01:00
Matthew Hodgson
c967ecc4e5 autocomplete polishing
* suppress autocomplete when navigating through history
* only search for slashcommands if in the first block of the editor
* handle suffix returns from providers correctly
* fix SelectionRange typing in the providers
* fix bugs when pressing ctrl-a, typing and then tab to complete a replacement by collapsing selection to anchor when inserting a completion in the editor
* fix https://github.com/vector-im/riot-web/issues/4762
2018-05-13 03:04:40 +01:00
Matthew Hodgson
c91dcffe82 fix cursor behaviour around pills 2018-05-13 00:40:54 +01:00
Matthew Hodgson
9c0c806af4 correctly send pills in messages 2018-05-12 20:04:58 +01:00
Luke Barnard
a3c407992b Don't autocomplete users for single "@" 2018-04-24 13:59:18 +01:00
David Baker
8342f441df
Merge pull request #1778 from matrix-org/t3chguy/devtools_autocomplete
Add /devtools to Autocomplete and run gen-i18n
2018-03-22 09:54:26 +00:00
Michael Telatynski
9df5638c8e
make linter happy - add missing trailing comma
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-03-21 11:00:07 +00:00
David Baker
7ac583bc96
Merge pull request #1800 from ma1uta/develop
Enable autocompletion for non-English languages.
2018-03-20 10:39:20 +00:00
Matthew Hodgson
b68da579f0 don't crash on missing room members 2018-03-16 01:21:52 +00:00
Anatoliy Sablin
953a520f38 Enable autocompletion for non-English languages. 2018-03-14 00:33:19 +03:00
Michael Telatynski
03676a68ac
Add /devtools to Autocomplete and run gen-i18n
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-02-28 00:57:14 +00:00
Luke Barnard
c5da1015fe Do not truncate autocompleted users in composer
so that disambiguation is possible at a glance.

Fixes https://github.com/vector-im/riot-web/issues/6024
2018-02-08 17:47:36 +00:00
Michael Telatynski
1bc9d344ae
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/nvl/rich_quoting
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

# Conflicts:
#	src/components/views/messages/TextualBody.js
2018-01-10 11:54:58 +00:00
Aidan Gauland
35780f5ae0 Remove use of deprecated React.PropTypes
Replace all uses of React.PropTypes with PropTypes and importing PropTypes from
'prop-types'.
2017-12-26 14:03:18 +13:00
Michael Telatynski
5c229b9ef8
DRY matrix.to link generation so it is all changeable in one class
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-12-12 23:33:40 +00:00
David Baker
c23a3fd7fe Add some null checks 2017-12-05 11:14:55 +00:00
Luke Barnard
dad797d4a2 Run linting --fix 2017-11-16 13:19:36 +00:00
Travis Ralston
289b0c2b6a
Merge branch 'develop' into travis/granular-settings 2017-11-07 14:55:12 -07:00
David Baker
41e7496ff1 unused var 2017-11-06 15:25:25 +00:00
Travis Ralston
893c39bfbe Merge branch 'develop' into travis/granular-settings 2017-11-03 22:00:07 -06:00
David Baker
112c74a255 Add NotifProvider to offer @room as a completion 2017-11-02 18:54:25 +00:00
David Baker
6ad4bb80dd == 2017-11-02 18:14:46 +00:00
David Baker
3b58f0ca2a Ignore removed events 2017-11-02 18:14:21 +00:00
David Baker
ee43c635d1 phrasing 2017-11-02 18:11:18 +00:00
David Baker
42589281d1 comment stub method 2017-11-02 18:10:13 +00:00
David Baker
f7201e8dee Revert unintentional changes 2017-11-02 18:08:24 +00:00
David Baker
498b117d5a copyrights 2017-11-02 18:01:28 +00:00
David Baker
4953d4de4d Give autocomplete providers the room they're in
Removes the gut-wrenching that RoomView does to jam the user list
into the user autocomplete provider.
2017-11-02 17:51:08 +00:00
Travis Ralston
ae10a11ac4 Convert synced settings to granular settings
Signed-off-by: Travis Ralston <travpc@gmail.com>
2017-10-29 01:43:52 -06:00
Luke Barnard
d3f9a3aeb5 Run eslint --fix
Fixing 1000s of lint issues. Some rules cannot be `--fix`ed but this goes some way to linting the entire codebase.
2017-10-11 17:56:17 +01:00
Stefan Parviainen
a96169e80e Fix merge conflict 2017-10-02 17:57:22 +02:00
Luke Barnard
6b9a2909df Add rule to enforce spacing in curly brackets in JSX children
This required an updated in version of eslint-plugin-react to 7.4.0.
2017-09-28 11:21:06 +01:00
Stefan Parviainen
d4929b558e Add dummy translation function to mark translatable strings
Signed-off-by: Stefan Parviainen <pafcu@iki.fi>
2017-09-22 21:43:27 +02:00
David Baker
11f6c8cf53 Fix null pointer
Check if users is null, not the room
2017-09-22 16:56:26 +01:00
David Baker
02894ee906 Experimental: Lazy load user autocomplete entries
Loading the users into the autocomplete provider is quite a large
chunk of work for a large room. Try lazy loading it the first time
a completion is done rather than up front when the room is loaded,
given that a lot of the time you switch to a room you won't say
anything.
2017-09-22 14:31:29 +01:00
Matthew Hodgson
6a53b7b149 Merge pull request #1389 from turt2live/travis/ignored_users
Add ignore user API support
2017-09-17 22:05:02 +01:00
turt2live
b2de016b35 Add option to disable Emoji suggestions
Signed-off-by: Travis Ralston <travpc@gmail.com>
2017-09-14 21:28:12 -06:00
turt2live
0363f73e28 Fix the MessagePanel test
Signed-off-by: Travis Ralston <travpc@gmail.com>
2017-09-14 20:57:28 -06:00
turt2live
3c71898237 Add /(un)ignore to autocomplete
Signed-off-by: Travis Ralston <travpc@gmail.com>
2017-09-14 20:30:40 -06:00
Luke Barnard
5b1467a4c9 Allow autocompletion when typing user IDs
Because we need to support tab completing `"@some_user"` if `@some_user` has a display name that is totally different and will therefore not match what the user typed in.

This does have the disadvantage of a display name appearing (the pill) that isn't at all what the user typed in, but the autocomplete box and the tooltip should give enough information to let the user know what's going on. (e.g. typing `@kyr*tab*` and getting `Remmy`).

This _does_ run contrary to vector-im/riot-web#4495

related to vector-im/riot-web#4794

cc @lampholder
2017-08-15 14:08:26 +01:00
Luke Barnard
610b2a3a42 For mentions, always use rawDisplayName and remove (IRC) 2017-08-09 10:40:06 +01:00
Luke Barnard
a72f38799f Disable autocompletions for users and rooms when entering a command
This only affects commands that take a room alias or user ID as an argument. (Leaving commands such as `/me` unaffected)
2017-08-08 15:58:15 +01:00
Luke Barnard
1743c047bd Use the rawDisplayName for the user provider completion
to make sure that the length of text in the decoration (See <Pill>) is equal to the length of text in the completion (underlying text range that the Entity covers).
2017-08-08 10:28:11 +01:00
Luke Barnard
72c1cf9288 When sorting completions, use matched string, not entire query
Otherwise the results vary depending on where you start autocompleting in your message. We only care about the matched string.
2017-08-02 10:09:00 +01:00
Luke Barnard
dbade448c1 Don't try to match query against roomId
We only care about aliases.
2017-08-02 09:40:00 +01:00
Luke Barnard
8053d2933a Order room completions more intuitively
by index of the query in displayedAlias and then length of displayedAlias. (So that aliases where the query appears earlier in the string appear first and if the query is in the same index for two aliases, the shorter one appears first).
2017-08-02 09:35:07 +01:00
Luke Barnard
ff95542549 Adjust emoji sorting such that exact matches/prefixes appear first
fixes https://github.com/vector-im/riot-web/issues/4704
2017-08-01 17:36:41 +01:00
Luke Barnard
6d7bff83ca Update type Completion 2017-07-20 16:49:23 +01:00
Luke Barnard
84fe51a162 Insert MD links when autocompleting in MD mode
These will appear decorated because they are inserted as entities. It was necessary to modify pills to have an explicit linkText that is derived from the `href` being pillified (and is thus no longer the inserted completion but rather the display name (or user ID) or room alias.
2017-07-20 15:09:59 +01:00
David Baker
199b771051 Merge pull request #1237 from matrix-org/luke/fix-rte-colon-parity
Implement old composer feature that inserts ': ' or ' '
2017-07-20 13:05:40 +01:00
Luke Barnard
0185119146 Merge pull request #1236 from matrix-org/luke/fix-rte-emoji-match-by-name
Match emojis by long name
2017-07-20 11:53:41 +01:00
Luke Barnard
352f70f9ce Implement old composer feature that inserts ': ' or ' '
after a user completion
2017-07-20 11:52:18 +01:00
Luke Barnard
b3df546cb9 Fix comment 2017-07-20 10:51:15 +01:00
Luke Barnard
a7feb58b63 Match emojis by long name
For example, searching for `:tong` will now match `:stuck_out_tongue` because the query `:tong` has all non-word characters removed, becoming `tong` and is then matched against the (long) names of emojis such as `smiling face with open mouth and tightly-closed eyes`.
2017-07-20 10:01:58 +01:00
Luke Barnard
3a53fabb87 Merge pull request #1228 from matrix-org/luke/feature-auto-complete-matrixto-pills
Implement composer completion user/room pill insertion
2017-07-19 17:19:47 +01:00
Richard van der Hoff
8d7ff127f1 Merge pull request #1231 from matrix-org/luke/fix-rte-duplicate-autocompletions
Use _uniq instead of _sortedUniq for return unique matched results
2017-07-19 17:05:12 +01:00
Luke Barnard
c8722292e3 Don't truncate EmojiProvider completion pills 2017-07-19 16:20:57 +01:00
Luke Barnard
b185f43d3d Use _uniq instead of _sortedUniq for return unique matched results
_sortedUniq claims to be like _uniq but optimised for sorted arrays - https://lodash.com/docs/4.17.4#sortedUniqBy. But in practice this isn't quite true, so stick with the unoptimised version.
2017-07-18 16:23:54 +01:00
Luke Barnard
897ff05d87 Implement composer completion user/room pill insertion
This modifies the composer completion such that completing a room or user will insert an IMMUTABLE matrix.to LINK Entity for the range that was replaced. Display names will not have a colon after their name anymore as it seemed strange that we would insert one after a pill.
2017-07-17 15:53:29 +01:00
Luke Barnard
dcc4db53f9 Async functions now return bluebird promises, remove redundant Promise.resolve 2017-07-13 17:51:14 +01:00
Luke Barnard
f78a49b3a9 Do reflect in the same map 2017-07-13 17:20:17 +01:00
Luke Barnard
c9f3a12693 Fix Autocompleter promises
Use bluebird instead of the now removed "q" library.

Also, make sure we timeout and then `reflect` to effectively do an `allSettled` that waits for all promises to either be resolved or rejected. Then we filter for those that are fulfilled and return the completions.
2017-07-13 16:51:14 +01:00
Richard van der Hoff
0254d2b3a2 q(...) -> Promise.resolve
```
find src test -name '*.js' | xargs perl -i -pe 's/\b[qQ]\(/Promise.resolve(/'
```
2017-07-12 18:05:08 +01:00
Richard van der Hoff
a06bd84213 replace imports of q with bluebird
update `package.json`

```
find src test -name '*.js' |
   xargs perl -i -pe 'if (/require\(.[qQ].\)/) { $_ = "import Promise from '\''bluebird'\'';\n"; }'

find src test -name '*.js' |
   xargs perl -i -pe 'if (/import [qQ]/) { $_ = "import Promise from '\''bluebird'\'';\n"; }'
```
2017-07-12 18:05:08 +01:00
David Baker
e242e5e714 Merge pull request #1205 from matrix-org/luke/feature-new-emojis
Bump the dep on emojione to 2.2.7 to add 🦈 and others
2017-07-11 14:13:13 +01:00
Luke Barnard
d146246805 Move "regional" category to after "flags"
Otherwise by default it appears first, pushing "people" further down the list

Also, remove "unicode9" category ordering, as this category does not exist as part of emojione
2017-07-11 14:06:15 +01:00
Luke Barnard
e18924c8fc Fix bug where a received message would remove completions for users
`Array.prototype.splice` will return the array of removed items, not a new array. The array operated on is actually modified in-place.

This was causing a few weird things to happen: https://github.com/vector-im/riot-web/issues/4511 and https://github.com/vector-im/riot-web/issues/4533. This should fix both of them but it is concerning that doing the tab completion is required to reproduce. Let's just see how this goes before closing the issues.

Thanks @turt2live for reproducing both bugs, giving enough information for a fix :)
2017-07-11 10:42:02 +01:00
David Baker
0112afad3c Merge pull request #1199 from matrix-org/luke/fix-rte-emoji-prefixes
Only allow completion of emoji in certain circumstances
2017-07-10 14:02:01 +01:00
Luke Barnard
62ee0f4e02 Fix accepting invites
Accepting an invite would cause a room to arrive via /sync only for it to throw an error in the auto complete code and cause the client to go wibbly (infinite spinner or preview bar).

The logs that lead to the debugging of this are https://github.com/matrix-org/riot-web-rageshakes/issues/239

Hopefully the error being throw isn't totally unrelated but looking at the sync handling for inviteRooms in sync.js, new rooms are stored and _then_ the Room event is emitted. The Room event could trigger setUserListFromRoom, which is where the bug was. So the room should have been stored regardless of this bug and the client should have been recoverable by swapping away and viewing the room again.
2017-07-07 19:43:30 +01:00
Luke Barnard
9a272d4965 Only allow completion of emoji in certain circumstances
Which are:
 - the emoji to complete is at the start of the query
 - there is a whitespace character before the emoji
 - there is an emoji before the emoji (so that several emoji can be input in-a-row)

Fixes https://github.com/vector-im/riot-web/issues/4498 (although it seems to be fixed through some other fix)
2017-07-07 19:02:51 +01:00
Luke Barnard
0a4f8ffead Alter EMOJI_REGEX to include end of string ($)
Fixes https://github.com/vector-im/riot-web/issues/4529 because the match must include the remainder of the query.
2017-07-06 18:11:46 +01:00
Luke Barnard
710ee69418 Don't try to match with an empty query string
This was causing UserProvider to give results because every string happens to start with empty string and its regex also acepts the empty string.
2017-07-04 17:32:07 +01:00
Luke Barnard
0af77e8913 Merge pull request #1177 from matrix-org/luke/fix-rte-prefix-matching
Only match users by matchgin displayname or user ID prefixes
2017-07-04 17:09:39 +01:00
Luke Barnard
2861adc830 Only truncate autocomplete pulls of Emoji, Room and UserProvider
Leaving Commands and DuckDuckGo not truncated
2017-07-04 16:50:50 +01:00
Luke Barnard
6a80875c01 Only match users by matchgin displayname or user ID prefixes
Because tab completing "k" probably shouldn't give you "luke"

Fixes https://github.com/vector-im/riot-web/issues/4495
2017-07-04 16:29:06 +01:00
Luke Barnard
e688eca823 Improve the sorting applied to the sorting of autocomplete results
QueryMatcher: sort results based on the position of the query within the matching value. The closer to the beginning of the word, the higher the result apears.

UserProvider: perf improvement (slice early) and refactor onUserSpoke
2017-07-04 13:53:06 +01:00
Michael Telatynski
fc379e2a15
fix typos post-luke-review
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-07-03 19:24:18 +01:00
Michael Telatynski
fb61a5d68b
post-merge fix
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-07-01 13:08:23 +01:00
Michael Telatynski
09f017fdd2
Merge branches 'develop' and 't3chguy/add-missing-autocomplete-commands' of github.com:matrix-org/matrix-react-sdk into t3chguy/add-missing-autocomplete-commands
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

# Conflicts:
#	src/autocomplete/CommandProvider.js
#	src/i18n/strings/en_EN.json
2017-07-01 13:07:18 +01:00
Michael Telatynski
9dba628f10
add missing commands to the Autocomplete CommandProvider
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-07-01 12:55:43 +01:00
Luke Barnard
b315ed630e Match by emoji ascii regex first before shorthand
Plaintext emojis that start with ":" will also match against the shorthand regex but the match won't include the important part of the plaintext emoji. This means some emoji like ":)" won't be matched.

To fix this, put the ascii emoji regex first so that the match will be plaintext or otherwise it will fall through to the shorthand match (if there is one).

Fixes https://github.com/vector-im/riot-web/issues/4467
2017-06-30 16:31:40 +01:00
Luke Barnard
982b009b90 Implement ascii emoji tab completion
When a fully plaintext, ascii emoji is typed like ";-)", pressing tab will suggest emojione to replace it with based off of the meta data provided by emojione.

e.g. the aliases_ascii for `😃` are [":D",":-D","=D"] so typing ":D *tab*" will insert a real 😃
2017-06-29 11:29:55 +01:00
Luke Barnard
2b8da85726 Strip the emoji meta-data for the data we need
This is done at build time by parsing emojione/emoji.json, stripping it and then writing to ./lib/stripped-emoji.json.
2017-06-28 11:36:19 +01:00
Luke Barnard
8ca3b382ed Use emojione/emoji.json because we don't want two sets of emoji meta 2017-06-28 11:19:16 +01:00
Luke Barnard
f4db765239 Fix indentation 2017-06-28 10:32:46 +01:00
Luke Barnard
9d339b96bd Order emojis by standard ordering, add alternate shortnames
Also, increase the maximum number of emoji shown to 20.
2017-06-27 20:13:48 +01:00
David Baker
3cdc7c9114 Add copyright headers 2017-06-23 18:30:16 +01:00
David Baker
c0e48c72fc Remove dep on liblevenstein
While we don't actually use it
2017-06-23 18:03:32 +01:00
Luke Barnard
89afcfd897 Linting 2017-06-23 17:35:07 +01:00