Commit Graph

151 Commits

Author SHA1 Message Date
Luke Barnard
397201a74d Remove subjective comment 2017-07-24 09:41:46 +01:00
Luke Barnard
e315b30f6a Merge branch 'develop' into luke/fix-rte-pt-md-mentions 2017-07-21 18:06:31 +01:00
Luke Barnard
e8495f637f Strip MD mentions from the body of sent messages
Because previously we just sent the display name and MD links are not very readable.
2017-07-21 16:38:31 +01:00
Luke Barnard
7db7192701 Factor out shared logic in two code-paths for pill rendering
This isn't an entirely side-effect-free refactoring:
 - the text of the timeline pills is now either the room ID/alias or user ID/ display name of the linked resource (which means that until we do a roundtrip to get user displaynames, mentions for users not in the current room will have their user IDs shown instead of what was in the link body).
 - timeline links to rooms without avatars are now rendered as links
 - fixed issue that would throw an error whilst rendering (i.e. unusable client) a room link to a room that the client doesn't know about
2017-07-21 14:07:48 +01:00
Luke Barnard
bac22cfb7c Re-add removal of (IRC) suffix 2017-07-20 18:04:12 +01:00
Luke Barnard
08cc0c421d insert_displayname -> insert_mention 2017-07-20 18:02:54 +01:00
Luke Barnard
0600c5b049 Pretend that insert_displayname is a completion on that user
This has the advantage of us not reimplementing things and fixing the same bugs twice.
2017-07-20 16:46:53 +01:00
Luke Barnard
4bee9bd8c7 Merge branch 'develop' into luke/feature-rte-insert-pills-on-click-tl-profile 2017-07-20 15:48:38 +01:00
Luke Barnard
0419eff230 Insert pill onClick of timeline profile
When clicking someone in the timeline, insert a user pill instead of the plaintext "displayname:"
2017-07-20 15:46:36 +01:00
Luke Barnard
e893f994e1 Default to first room alias and then roomID 2017-07-20 15:17:07 +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
Luke Barnard
352f70f9ce Implement old composer feature that inserts ': ' or ' '
after a user completion
2017-07-20 11:52:18 +01:00
Luke Barnard
61d5d078dd Merge pull request #1235 from matrix-org/luke/fix-rte-inline-code-format
Mimic ctrl+j of RT mode in MD mode
2017-07-19 17:44:56 +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
Luke Barnard
29b6d70aff Merge branch 'develop' into luke/fix-rte-inline-code-format 2017-07-19 17:19:25 +01:00
Luke Barnard
28c98d93d1 Mimic ctrl+j of RT mode in MD mode
by inspecting whether multiple lines are selected or the selection is empty. If either of these are true, insert a code block surrounding the selection, otherwise insert single backticks around the selection for inline code formatting.
2017-07-19 16:13:47 +01:00
Luke Barnard
98ca937fef Interpret backspace at start of style block as block style toggle
Part of fixing https://github.com/vector-im/riot-web/issues/4580
2017-07-18 17:52:04 +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
434660166c Decorate http://matrix.to links in the composer as pills
Any links in the composer that are recognised as matrix.to links will be decorated as `<span>`s with CSS classes (one of mx_UserPill or mx_RoomPill). This implementation has the nice bonus that switching to markdown (and back) will Just Work.

This will have some CSS changes coming to better match the design.
2017-07-14 17:04:28 +01:00
Luke Barnard
219c00bbc3 Add code-block to the list of blocks where hitting return will split-block
Hitting return in a code-block will now split the block into two code blocks. (Holding shift will still insert a soft newline into the current block).

We still need to make it a bit more obvious that consecutive code-blocks
are not contiguous - https://github.com/vector-im/riot-web/issues/4535
2017-07-13 18:42:37 +01:00
Luke Barnard
d97de4d576 Implement disabled-by-default setting for auto-replacement of plaintext emojis
FTR a list of plaintexts and their unicode equivalents can be found here - https://github.com/vector-im/riot-web/issues/4554#issuecomment-314374303

Pressing space after a matching emoji will replace the plaintext emoji with the equivalent unicode emoji.
2017-07-13 17:37:43 +01:00
Luke Barnard
7fc10789fc Merge pull request #1217 from matrix-org/luke/fix-rte-html-links
Improve RTE HTML link handling
2017-07-13 13:57:58 +01:00
Luke Barnard
f1a4209d6b Fix indentation 2017-07-13 13:47:08 +01:00
Luke Barnard
5826b6f22a Instead of sending HTML for any Entity, only send HTML for Links
Otherwise emoji messages are sent as HTML, needlessly
2017-07-13 13:41:17 +01:00
Luke Barnard
be045a6dc0 Interpret whitespace after entity as the end of the entity
The easiest way to stop the user from inserting whitespace onto the end of an entity is to toggle the entity state of the whitespace that was just entered. This allows the user to continue drafting a message without editing the link content.

This is for pasted `<a>` tags that have been copied from a website. We probably also want to be storing entities for substrings of content that are determined to be URLs.
2017-07-13 13:28:51 +01:00
Luke Barnard
4b96963408 Send HTML if there are any entities present in the composer
This is so that pasted HTML links that are represented as entities are sent as HTML.
2017-07-13 13:27:49 +01:00
Luke Barnard
55e1202c09 Decorate pasted links so that they look like links
By default, draftjs will represent pasted `<a>` tags as `LINK` entities, but it doesn't do any default decoration of these links. Add a decorator to do so.

Most of this was taken from https://github.com/facebook/draft-js/blob/v0.8.1/examples/link/link.html (note the version, v0.8.1).
2017-07-13 13:26:13 +01:00
Richard van der Hoff
086304532e Merge pull request #1213 from matrix-org/rav/bluebird
Switch matrix-react-sdk to bluebird
2017-07-13 12:06:11 +01:00
Luke Barnard
04dd98e6e9 Remove references to tabComplete, which are now redundant
(since the old composer has been removed)
2017-07-13 10:16:59 +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
Luke Barnard
6ff924fc0d Remove MessageComposerInputOld 2017-07-12 18:03:13 +01:00
Luke Barnard
b104228a7b Remove redundant functions, bindings, props 2017-07-10 14:27:41 +01:00
Luke Barnard
c9df079464 Merge pull request #1176 from matrix-org/luke/feature-enable-RTE
Take RTE out of labs! 🎉
2017-07-10 13:56:00 +01:00
Luke Barnard
7a8f524f4a Remove two possible sources for the "AutoComplete stays visible bug
which is now https://github.com/vector-im/riot-web/issues/4537 <- there.

This does two things:
 - Track which query was the most recent one requesting completion and only process completions for that one. (In this case the empty string "" doesn't have any completions but we still track it so that previous calls with non-empty queries would not race and cause completions to be shown when we actuall don't want any.)
 - Make the "do we want to show the AutoComplete box?" logic a bit more sane
2017-07-07 15:30:31 +01:00
Luke Barnard
6404f7603c Merge pull request #1192 from matrix-org/t3chguy/markdown_allow_u
Allow underline through MD and in RTE (MD) using <u> which works with CM
2017-07-06 14:08:01 +01:00
Michael Telatynski
ff7ae5b995
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/markdown_allow_u 2017-07-06 13:56:20 +01:00
Michael Telatynski
fcd8321a63
Allow underline through MD and in RTE (MD) using <u> which works with CM
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-07-06 13:49:13 +01:00
Luke Barnard
bdefb35c64 Only insert HTML into the composer in RTE mode
If MD mode is enabled, paste the plaintext equivalent.
2017-07-06 11:52:02 +01:00
Luke Barnard
0bf1124f1b Merge pull request #1181 from matrix-org/luke/fix-rte-draft-persist
Implement MessageComposerStore to persist composer state when room switching
2017-07-05 18:24:27 +01:00
Luke Barnard
d78168d407 Add visual feedback for when there are no completions available
Attempts to kep parity with old composer by using the same #faa colour but uses an animation instead of a js timeout.

Fixes https://github.com/vector-im/riot-web/issues/4490
2017-07-05 18:14:22 +01:00
Luke Barnard
3d5b3ed7ad Use ContentState instead and persist over localStorage 2017-07-05 11:49:34 +01:00
Luke Barnard
084a933dbd Implement MessageComposerStore to persist composer state across room switching
This behaviour was present in the old composer but implemented using local storage. This is unecessary as we don't really care about our drafts across clients, the important thing is that our draft is kept when switching rooms.

As a bonus, ifnore vertical arrow key presses when a modifier key is pressed so that the room switching keys (alt + up/down arrow) don't also cause history browsing (or autocomplete browsing).
2017-07-05 10:24:55 +01:00
Luke Barnard
77348e6201 Remove spurious, unused code 2017-07-04 15:20:00 +01:00
Luke Barnard
664f3acc3c Only move through history if caret at start or end of line
As suggested by @dbkr (because this is what we do for the old composer), only move through history when the caret is that the beginning of the first line (block) or end of the last.

This has the nice property of being able to move the caret up to a really long message: fixes https://github.com/vector-im/riot-web/issues/4471
2017-07-04 10:12:06 +01:00
David Baker
72eed70a84 Merge pull request #1173 from matrix-org/luke/fix-rte-forgets-me
Strip out "/me" after committing to RTE history
2017-07-03 15:59:07 +01:00
Luke Barnard
775f5a0e5b Strip out "/me" after committing to RTE history
So that history can include emotes

Fixes https://github.com/vector-im/riot-web/issues/4472
2017-07-03 15:47:03 +01:00
Luke Barnard
86889b8e8c When formatting with MD enabled, move selection inside ** or equivalent
Fixes https://github.com/vector-im/riot-web/issues/3225

Also insert `\n` after code-block and blockquote to fix https://github.com/vector-im/riot-web/issues/2746
2017-07-03 15:23:24 +01:00
Luke Barnard
6bc40a112c Always store sent MD messages as MD in history
Because converting them to HTML when they got sent as HTML seems a bit pointless when they're just going to get transformed back again when retrieved from history.

Fixes regression https://github.com/vector-im/riot-web/issues/4465
2017-06-30 15:47:48 +01:00
Luke Barnard
15cfe5b8e4 Only allow history selection when on the first or last line
(of a multi-line or otherwise message in the editor)
2017-06-30 14:27:26 +01:00
Luke Barnard
e7a2c3b975 Only send HTML when using RTE when necessary
When there are no styled blocks or inline styles applied within blocks, just send text instead of HTML.

Also, don't add <br /> for the last <p> (the last block).

Fixes https://github.com/vector-im/riot-web/issues/3147
2017-06-30 11:27:00 +01:00