Commit graph

68 commits

Author SHA1 Message Date
Ed Sanders 9fab4add17 Config: Separate useVisualEditor into enableVisual and use2017Wikitext
Currently use2017Wikitext is missing some implementations.

Change-Id: Ib5f9bcc588561a80ca11de85518e6fae64e5b104
2020-05-06 18:03:36 +01:00
Ed Sanders 56d8721fd7 Switching between VE & wikitext (plain)
Bug: T234403
Change-Id: I84a639ab8e31ec9f683a63b0ecf184f426df09dd
2020-05-06 18:03:36 +01:00
Ed Sanders a5ed469843 Create CommentController class and move most Controller methods to it
This means we have an instance for each comment, which makes keeping
track of local variables much simpler, and will make switching out
the widgets easier.

Change-Id: I7584870225b1a14146852987d6a40ad05957387c
2020-04-29 22:21:32 +02:00
jenkins-bot 922443f68f Merge "ConfirmEdit CAPTCHA support" 2020-04-29 12:04:44 +00:00
Ed Sanders 04f8e21554 Implement auto-save for ReplyWidgetPlain
Bug: T240257
Change-Id: Ica51fb51a5091b11aceb3cd5c484ef9c71b98af2
2020-04-28 20:32:20 +02:00
Bartosz Dziewoński 40c18508ec ConfirmEdit CAPTCHA support
Depends-On: I6605017fd31a4f96c529dd0beb69e9f4433cebc1
Bug: T247513
Change-Id: If9b3162969aa6ee67baff80aa84fa719bd3c3720
2020-04-21 18:55:38 +02:00
Ed Sanders 0f7eb2e36a Add "watch this page" checkbox
Bug: T245222
Depends-On: I1e0e9bb9da53a62f8a20126e579dcd6300bd2376
Change-Id: If966d2fa97648452a50a2318988a8b64d7c449cd
2020-04-20 12:40:44 +01:00
Ed Sanders ba89657994 Add a share feedback link
Bug: T249016
Change-Id: I64abeebeea332a7a4a37fd4bfd6d5f9a5defc8b5
2020-04-14 23:04:18 +00:00
Ed Sanders d40e427b5b Remove extra linebreaks from wikitext
Extra lines currently render empty list items which are invisible.
Remove these as the user probably didn't intend from them to appear
in the wikiext.

Bug: T249867
Change-Id: I75c1192a94b918783d362d38cd91a508bb169d56
2020-04-14 20:29:38 +00:00
Ed Sanders 5597787eb4 ReplyWidget: Replace .mode with #getMode
.mode was only set the end of the constructor.

Change-Id: I1a14167d1b2e524742da31f78c6cbfaf96aec667
2020-04-14 19:42:29 +00:00
Bartosz Dziewoński 807afd1ec0 Save the reply directly to the transcluded page
* When we discover the comment comes from a transcluded page, follow
  the transclusion to find the source page. We follow transclusions
  recursively, up to an arbitrary limit of 10.
* In the reply widget, display the title of the page where we will
  save the reply, to avoid users confused why their edit won't show up
  in the history. In the wikitext workflow this is done by redirecting
  the user to the edited page at the end, but it seems less surprising
  to stay on the current page.
* After saving the reply, we must purge the current page, otherwise
  the new content will not be immediately visible on it.

Bug: T247535
Change-Id: I1c6631aa65a2fce6c1c2f0dd4a8c7aa6389caf94
2020-03-24 22:29:42 +00:00
jenkins-bot 85472b7e31 Merge "ReplyWidget: Double-check that we can post before posting" 2020-03-20 19:37:48 +00:00
Bartosz Dziewoński 9d2cb7bdd0 Also update 'jsconfigvars' when previewing
This fixes a warning in the API: 'Property "modules" was set but not
"jsconfigvars" or "encodedjsconfigvars". Configuration variables are
necessary for proper module usage.'

We were already updating them when saving.

Change-Id: I3e16e3fd4b43a438c27645cca90517b6b4be7db7
2020-03-19 18:19:15 +01:00
Bartosz Dziewoński a6ce1e23a7 ReplyWidget: Double-check that we can post before posting
Bug: T246058
Change-Id: Ic87b062c2fd6d7f48933a94e140ce392003ee65a
2020-03-19 01:03:09 +01:00
Bartosz Dziewoński e9b583d1c3 parser: Improve merging multiple comments on one line
Now also works if the "follow-up" comment is wrapped in e.g. `<small>`.

Change-Id: Ic37cb6afdb42021f109a1818f5c4299d907ed094
2020-03-14 13:34:42 +00:00
Bartosz Dziewoński 04365c0188 Merge RL modules which are only loaded by 'ext.discussionTools.init'
Bug: T240474
Change-Id: I1b83aa18666be8f1ea6a3602b299f92574d42cb7
2020-03-14 14:33:23 +01:00
Bartosz Dziewoński 2a0f53fed9 Replace the closest() polyfill
If we can't use the native closest() due to lack of browser support,
then I'd rather have a simple loop that implements the functionality
we need, instead of a fallback to another native method with limited
browser support and experimental implementations.

Change-Id: I0bf84aa25fc398e329b533afb28317d19716d57a
2020-03-09 13:28:14 +00:00
Ed Sanders 23966cc098 Move wikitext comment building to the controller
Change-Id: I6374ea570f093ae5286c14ed49a9be4f32f23ff5
2020-03-09 12:52:06 +00:00
jenkins-bot fa47fc9dee Merge "Move edit conflict retry code to controller" 2020-03-03 23:45:18 +00:00
jenkins-bot a8de849a4e Merge "Remove somewhat useless ReplyWidget.prototype.getParsoidCommentData" 2020-03-03 23:45:17 +00:00
jenkins-bot f1fc955dc3 Merge "Reply-to placeholder" 2020-03-03 22:59:44 +00:00
Ed Sanders 3274b0c9df Move edit conflict retry code to controller
Change-Id: Id14e93624d1828253402c04c97193fd686f67d9f
2020-03-03 13:25:14 +00:00
Ed Sanders 126266c741 Remove somewhat useless ReplyWidget.prototype.getParsoidCommentData
We always pass the same arguments to the controller method and
two of those are global config values, so just pass the comment ID
each time it is used instead.

Change-Id: Ic68c70bdadb29310e930dd10fd6c6137d01ad22f
2020-03-03 13:20:23 +00:00
Ed Sanders 7cb82b6862 Reply-to placeholder
Sets the placeholder text to "Reply to <user>".

Bug: T245227
Depends-On: I7f3a58b7093d00aace9f9c6a95a121ba4e901ad8
Change-Id: Ie51f1848c17bb892e7f64adf6f7f19fc38e56202
2020-02-29 17:29:07 +00:00
Bartosz Dziewoński 656b413b4b ReplyWidget: Disable "Reply" button if input is empty
Bug: T246058
Change-Id: Ib46f265eff3a4b4f59b5085ab33c5ebbef76003c
2020-02-29 03:58:28 +01:00
David Lynch e2bf0d25d2 Instrumentation: abort-navigate case
Bug: T244874
Change-Id: I0f8030e17d09d5b828732fc386b0b899f8c32564
2020-02-25 23:28:24 -06:00
David Lynch fb006e6373 Instrumentation
Bug: T243364
Change-Id: I8573993db0dad408f09202e548206b009c106cc9
2020-02-24 19:50:27 +01:00
jenkins-bot 37bf81bf37 Merge "When launched from an old revision, reply to latest revision" 2020-02-24 16:23:21 +00:00
jenkins-bot 4d6bdcafb1 Merge "Try to resolve edit conflicts" 2020-02-24 16:23:20 +00:00
jenkins-bot 1dfa501cc6 Merge "Rebuild Parsoid document before attempting to save" 2020-02-24 15:53:54 +00:00
Bartosz Dziewoński da11a3be73 When launched from an old revision, reply to latest revision
The "Reply" buttons were active when viewing an old revision of the
page (&oldid=1234). This was probably unintentional, and it would undo
all more recent comments if you saved yours.

However, I think it would be a useful feature. You often end up
viewing old revisions when reviewing changes to pages from your
watchlist or email notifications.

Now, when the reply widget is launched from an old revision, it will
try to find the relevant parent comment in the latest revision of the
page, and edit that revision when inserting the reply. If the parent
comment is gone, it shows a useful error message.

Bug: T235761
Change-Id: I8c5b631d3bfb62196fd219cbcd7d497408d187a7
2020-02-21 17:09:47 +00:00
Ed Sanders 1a93e420b3 Sig preview: Increase opacity
Closer matches disabled-grey which is more accessible.

Change-Id: Ieb98e88bb42fdec1f1089919cf2c0c5f72b21877
2020-02-18 15:43:06 +00:00
Bartosz Dziewoński 7ea6cdf326 Try to resolve edit conflicts
The most common case of edit conflicts on talk pages is several people
responding to the same comment at the same time.[citation needed]

We can easily resolve this case by fetching the latest revision of the
page and re-running our code to insert a reply on it.

When we can't insert a reply, that probably means the parent comment
was deleted or moved, so display an error message indicating that
instead of the generic one.

Bug: T240643
Change-Id: Ic686acc747580d46779960211a02e9830a6ae86f
2020-02-15 05:43:14 +01:00
Bartosz Dziewoński 6f404e5ce2 Rebuild Parsoid document before attempting to save
Previously, we only built the Parsoid document once (on page load) and
kept it around forever. Every time we tried to post a reply, it was
added to this document, even if it wasn't saved due to some error.
This resulted in duplicate replies when the user managed to actually
save.

Now we only keep around the HTML string and some metadata fetched from
the API, and rebuild the actual document every time before adding a
reply.

Bug: T245333
Change-Id: Ib1c344a7d613cdf67644aa243147c5e699c2c1e7
2020-02-15 05:09:34 +01:00
Ed Sanders c8564f6ccb Re-style preview
Bug: T238177
Change-Id: Iabc7cfa7595d60cbd0482340bd159002ee5a6b0e
2020-02-08 00:13:41 +00:00
Bartosz Dziewoński 6d243ed74a ReplyWidget: Handle save errors
Bug: T240519
Depends-On: Ie18666b41f4aff1ab4bcf93f9df6e3000ac7b500
Depends-On: I2a731cb273401074e65f9283c1f629dbdb272002
Change-Id: Ice92fafb1f546510dab28e3f8aa7d2280668965a
2020-01-21 22:21:57 +01:00
Ed Sanders fe48688a76 Teardown the widget as soon as possible
Bug: T241393
Change-Id: I5978133637844fcad81af426465b6f16829ee9b3
2020-01-15 16:21:59 +00:00
Ed Sanders cc5976e8db Fix <escape> handler again
Sepatate #teardown and #tryTeardown methods to make it
obvious what they do. Have <escape> call #tryTeardown
like the cancel button.

Change-Id: Ica0f3295bfee378bcd15d0b6a3ccea3c7917ad9b
2020-01-14 15:01:49 +00:00
jenkins-bot ad48d8d2f9 Merge "Option to integrate VisualEditor instead of textarea" 2020-01-09 18:08:18 +00:00
jenkins-bot 719bfee1b3 Merge "ReplyWidget: Load modules required by the content when previewing" 2020-01-08 23:28:21 +00:00
jenkins-bot 45e811a688 Merge "ReplyWidget: Pass 'title' when previewing" 2020-01-08 23:28:20 +00:00
jenkins-bot 88a467ec16 Merge "Fix re-initialization after page is updated" 2020-01-08 23:28:19 +00:00
Ed Sanders 2f1cf65233 Option to integrate VisualEditor instead of textarea
* Add config option $wgDiscussionToolsUseVisualEditor (default false).
* Add new modules ext.discussionTools.ReplyWidgetPlain and ...ReplyWidgetVisual,
  replacing ...ReplyWidget. Load only one of them depending on the config.

TODO:
* Also add the visual mode of VisualEditor, this only uses NWE now.
  There is already code to support saving from it, but no mode
  switcher tool

Co-Authored-By: Ed Sanders <esanders@wikimedia.org>
Co-Authored-By: Bartosz Dziewoński <matma.rex@gmail.com>
Change-Id: I9b6db865d51baf400fb715dc7aa68ccd8cdd4905
2020-01-07 22:15:03 +00:00
Ed Sanders c03cfde566 Fix 'escape' to teardown
Change-Id: Icc35ed83a1fa46ed592f617d0ff5dd60361c412d
2020-01-07 22:13:50 +00:00
Bartosz Dziewoński 25eb55000f Fix re-initialization after page is updated
I did this wrong in a6147ffac8, the
'dt-init-done' class was never cleared. Put it on another element.

Bug: T241861
Change-Id: I136bd9c12bcc80cff01f5d26a8a53524f0c533c6
2020-01-04 18:49:55 +01:00
Bartosz Dziewoński 0de5591889 ReplyWidget: Load modules required by the content when previewing
Unfortunately mw.Api#parse doesn't provide us with that part of the
response, so we have to manually construct the parameters.

Bug: T241193
Change-Id: Ie91d5ebc2ef483a69524b838dd3cb852e7c85cd2
2020-01-02 16:00:03 +01:00
Bartosz Dziewoński e9b1037ec6 ReplyWidget: Pass 'title' when previewing
Bug: T241221
Change-Id: Ibabc32c9e5aeec6acec3bab9ad67d6ba3c4f27e8
2019-12-27 19:30:24 +01:00
David Lynch 5eea2d42fb ReplyWidget: calling undefined clear method
Caused by 49edbb82ab.

Bug: T240729
Change-Id: I23bf7fcb7e0265f9770629590702a07a3dbed2b1
2019-12-13 16:49:10 -06:00
Ed Sanders 49edbb82ab Prompt users when pressing 'cancel' with content in the widget
And actually discard the contents when they confirm.

For now this uses the generic editor message, but that can
be tweaked later.

Bug: T240271
Change-Id: I2dfa19b2cc7ac49d7efea37ac8c9429c75934a91
2019-12-13 18:15:48 +00:00
Ed Sanders 179b29a598 Add beforeunload handlers
Bug: T240259
Change-Id: I376ea116a0fd1fdf794d9eb9e1d15f3d34babd88
2019-12-13 18:11:22 +00:00