Commit graph

361 commits

Author SHA1 Message Date
jenkins-bot e4da8b10f3 Merge "Track more events for VisualEditorFeatureUse" 2020-06-08 22:12:17 +00:00
jenkins-bot 0179e00197 Merge "Hook up VisualEditorFeatureUse logging" 2020-06-08 22:12:13 +00:00
David Lynch c92fad4fe7 Track more events for VisualEditorFeatureUse
* Track editor mode switching between visual and source (plain)
* Track interactions with checkboxes
* Fix the tracking of firstChange when switching with content

Bug: T254291
Change-Id: I0e243e393b02952684f34dbbe1697633c0b2561a
2020-06-04 12:19:46 -05:00
jenkins-bot 94bbaa846f Merge "Depend on Linter" 2020-06-04 16:46:57 +00:00
jenkins-bot 203df3aabc Merge "Call the linter API directly if installed" 2020-06-04 16:24:36 +00:00
David Lynch 068ff29e88 Depend on Linter
Depends-On: I8b183d816748245722ca1a459203333614f58f32
Change-Id: If2252d54a39a9d12744ccdee08e334a211f41d46
2020-06-04 18:23:57 +02:00
David Lynch 5ccb0538fd Hook up VisualEditorFeatureUse logging
Bug: T252924
Depends-On: I77b2dabc39b730bc50c67029e67fedc1f173d248
Change-Id: I0189038d09ffe023b6c06be8250b412dc06d9b81
2020-06-04 09:53:20 -05:00
Ed Sanders e9f2bb80d1 Call the linter API directly if installed
If the Linter extension is not installed, just allow the page
to be edited.

Bug: T253799
Change-Id: Id3e4c9c2d48aa7ab0b270f41d33ec19184af9a48
2020-06-04 09:46:07 -05:00
Ed Sanders 70fb4a6a10 ReplyWidgetVisual: Disable template sequence
Any template that outputs wikitext spanning more than one line
will break. As we can't enforce that in VE, we should just disable
all templates for now. The can still be inserted in source mode,
and will be eventually supported when we have multi-line syntax.

Bug: T253667
Change-Id: I72a7e4c09f83bcfc2a9cc7ab33a3d5303ced851d
2020-06-03 19:28:21 +01:00
Ed Sanders 62c0080850 Fix whitespace handling in unwrapList
Update 'referenceNode' before modifying the DOM.

Bug: T254308
Change-Id: I76af898e238c1e6d3db96d3e6156e80e55c87820
2020-06-03 13:54:36 +01:00
Ed Sanders 0d14fcea6a wt->visual: Don't unwrap template lists
Bug: T253150
Change-Id: I1584d9834e29c38edf4234f2f022c1c48bfd485f
2020-06-01 22:32:23 +01:00
Ed Sanders da433037a3 Move getTranscludedFromElement to Utils
Change-Id: I8bdd757f949c013ba426150a192d71243fadf45d
2020-06-01 22:32:23 +01:00
jenkins-bot 576fe0ca36 Merge "Use current preference each time we open a new reply widget" 2020-06-01 19:10:59 +00:00
jenkins-bot 431ba1c87f Merge "Make signature prefix customisable" 2020-06-01 17:18:04 +00:00
Ed Sanders dada23e0f4 Make signature prefix customisable
Bug: T249861
Change-Id: I506a0c1b803275f5505fdf8ee29cc535814d7742
2020-06-01 18:55:04 +02:00
Ed Sanders 03a94badfe Use current preference each time we open a new reply widget
TODO: Switch already setup widgets when we re-open them.

Bug: T253888
Change-Id: I6c541f27edbfe373f62b8508381bb5182681bda4
2020-05-29 13:06:36 +01:00
Bartosz Dziewoński 79ae8a32c5 Support parsing when timestamp is wrapped in a link
Bug: T252059
Change-Id: Ib8952fb80503bad407e8d0fe725103a0fae12a6a
2020-05-27 22:47:17 +02:00
Bartosz Dziewoński 01b4a8f4f4 Support replying when timestamp is template-generated
* Move modifier#getFullyCoveredWrapper to utils
* Use that method to find the node where we start searching for
  template wrappers, rather than using endContainer

Bug: T252058
Change-Id: I55de58102f3468fce01290bd413a7fdc96d322d6
2020-05-27 21:16:03 +02:00
Bartosz Dziewoński c7575b49f6 Work around invalid ranges in #getNativeRange
Change-Id: I46a54654acb15fb1ef7b80495cf1be8103b7688f
2020-05-27 21:16:03 +02:00
jenkins-bot 9f2ead06eb Merge "Insert replies outside of decorative comment frames" 2020-05-25 19:30:28 +00:00
jenkins-bot bb0a4c80d8 Merge "Remove empty lines in visual mode too" 2020-05-25 17:15:50 +00:00
jenkins-bot 08e6db455d Merge "Use the faster childIndexOf() approach in JS too" 2020-05-25 16:37:17 +00:00
Ed Sanders e064f43499 Remove empty lines in visual mode too
We already do this in source mode (sanitizeWikitextLinebreaks).

Bug: T253402
Change-Id: I10390b3173d22e8db735f5cd60180b1f48b94fff
2020-05-22 20:21:46 +01:00
Ed Sanders ac476eb4cf Initialize tab state to avoid flicker
Also set 'defaultMode' before calling parent constructor.

Bug: T234403
Change-Id: I08320bd539419ddf7ba22a5dc316177d751bcb8d
2020-05-22 18:25:04 +00:00
Bartosz Dziewoński 8f583a23be Use the faster childIndexOf() approach in JS too
I was wondering if the different approach to childIndexOf()
implemented in PHP in b8d7a75c34 would
be faster in JS as well, and yes, it is.

Our test suite now takes (on my machine):
* Chrome: 8337 ms → 7355 ms (average over 5 tries)
* Firefox: 5321 ms → 5044 ms (average over 5 tries)

Change-Id: I71963eeb92dcea9bfd59cbf01a7aa0b7de5d9cf1
2020-05-22 19:33:35 +02:00
Bartosz Dziewoński 420c514091 Insert replies outside of decorative comment frames
When there is a wrapper element whose range matches the range of
a comment, any replies will now be added outside of that wrapper,
instead of directly after the comment (inside the wrapper).

Bug: T250126
Change-Id: I6b42c4db019ae998e91eebd324f9cbd2aa791b4f
2020-05-22 15:01:12 +01:00
Bartosz Dziewoński fbd6338331 ReplyWidget: Avoid buttons shifting when switching to source
When the preview loads, the "Reply" / "Cancel" buttons shift downwards,
which looks ugly. Try to wait for the preview before showing the source
editor interface.

Bug: T234403
Change-Id: I70989fb9fbcac17e1a0672eda8d34bf26003bb96
2020-05-21 23:43:51 +02:00
jenkins-bot 54db24f1f5 Merge "Don't allow users to switch to a mode they are already in" 2020-05-21 18:21:42 +00:00
Ed Sanders 2d9a760d4e ReplyWidget: Use interface dir for UI
* Reset to content dir for preview.
* <textarea> gets dir from the `.sitedir-* textarea` rule.
* VE already sets the content dir in the editor.

Bug: T253255
Change-Id: I76df093490e86a730ccd5610c43c9b3fc7e07a54
2020-05-21 18:28:03 +01:00
Ed Sanders ade5f7cb6c Visual: Use createModelFromDom when setting document
Ensures that MW target sets the correct dir and lang on the document.

We should consider upstreaming this.

Bug: T253258
Change-Id: Ibc9ae7b4b105055291c941ce932f499bd6e13657
2020-05-21 18:26:59 +01:00
Ed Sanders 406aed0577 Don't allow users to switch to a mode they are already in
Change-Id: I082108c81ab871b64df76b6f9ba5cf4314ce6458
2020-05-21 18:26:08 +01:00
jenkins-bot d0dd4cf036 Merge "Add autosave support to visual mode" 2020-05-21 17:06:39 +00:00
jenkins-bot c53cecac10 Merge "Create a user preference to store visual/source mode" 2020-05-21 16:21:34 +00:00
Ed Sanders 9fbafef652 Add autosave support to visual mode
Bug: T240257
Change-Id: I87f8b68a5afee8d03c81cb283c9bee68ef9d4a5d
2020-05-20 22:16:20 +01:00
Ed Sanders 5feb69612f Create a user preference to store visual/source mode
Bug: T250523
Depends-On: I5b3b47feeeca2085fcd283d55d7e9ceafa73be70
Change-Id: I18f5d38f9d694b12e5f983be7b3b165f135a890d
2020-05-20 22:16:19 +01:00
Ed Sanders 66d3c95f23 Prefix '@' to username auto-complete output
Bug: T252460
Change-Id: I932ccddcacbe15efe9ea08d6a6d028cd84d8815c
2020-05-20 12:28:31 +01:00
Bartosz Dziewoński 515af82061 Reduce duplication between PHP parser and data gen for JS parser
Also, make the handling of TranslateNumerals and digitsRegexp the same
between PHP and JS.

Change-Id: I1d81343d0b59ab3ecd59ba1c2ad99a729d983ac4
2020-05-19 20:54:44 +02:00
jenkins-bot f5ac86528b Merge "Show real error message when an exception is thrown" 2020-05-18 23:08:34 +00:00
jenkins-bot 366aca2ccd Merge "Stop printing console warnings" 2020-05-18 22:52:30 +00:00
Bartosz Dziewoński 219339551c Stop printing console warnings
It was useful when I was debugging those parts of the code, but now
it's usually annoying.

The warnings can still sometimes be useful for understanding how the
tool parses some discussion, though. To keep that functionality, add
displaying warnings for each comment in the debug mode.

Change-Id: I2d218a8a394f179bcc0990ff988a0567c275ccf2
2020-05-18 23:37:37 +02:00
Ed Sanders 607440498e Spell check pass
Change-Id: Ia20da358297126bd52a968bd77c960f81fe82b8f
2020-05-18 21:24:14 +00:00
Bartosz Dziewoński c848d8a90e Parser tweaks
Follow-up to Ic1438d516e223db462cb227f6668e856672f538c.
Minor corrections and comment improvements in PHP parser,
and "backporting" some changes to JS parser that I like.

Change-Id: I5e54121914ec6b323e556dd133bcb71b3aefbb61
2020-05-18 19:53:26 +00:00
Ed Sanders d1e58841af Rename removeListItem to removeAddedListItem and remove in PHP
This method shouldn't be required on the server. Leave comments
relating to it in addListItem so JS & PHP can be kept in sync.

Change-Id: I849fac660faf6e750272c20776f96b9250f96b1b
2020-05-18 19:25:08 +00:00
jenkins-bot 2b7cca1380 Merge "ReplyWidget: Move all events bind to setup" 2020-05-18 19:19:47 +00:00
jenkins-bot a41eadfc51 Merge "Modifier: Pass document to createWikitext" 2020-05-18 17:54:15 +00:00
jenkins-bot 54ea65b27e Merge "Give username completion a min width of 10em" 2020-05-18 02:51:33 +00:00
jenkins-bot 55640a8a0d Merge "Show no remote users when input is empty" 2020-05-18 02:51:32 +00:00
Ed Sanders d56b512f2e ReplyWidget: Move all events bind to setup
Bug: T252439
Change-Id: I3c76e6364b63679fcbe40d256d9ba0c3eaba1578
2020-05-17 21:12:23 +01:00
Ed Sanders 5e996fdfdd Modifier: Pass document to createWikitext
Change-Id: I1793e1d690835af746a4e25a50e2e0a474811e8e
2020-05-15 22:47:54 +01:00
Ed Sanders b78fb3f4c1 Move all PHP to the MediaWiki\Extension\DiscussionTools namespace
Change-Id: I654ebb3e646a6d8d62f7bd14d48805e39f836d7e
2020-05-15 21:57:13 +02:00
Ed Sanders 340572bc05 Create a Utils class in PHP
Also move htmlTrim to utils in JS.

Change-Id: Ia5356d713c1c5d521c396cc28bcd4ecc7ee5bbbb
2020-05-15 00:25:32 +01:00
Bartosz Dziewoński 76289cdf73 tests: Fix failures due to CDATA handling in PHP
It appears PHP's DOM library always uses CDATA nodes for the contents of
<style> tags, even if there is no such markup in the source HTML.

Change-Id: Id04b27086c5e7a0b016a3a440b2b4895d6b13c93
2020-05-14 22:37:23 +00:00
Bartosz Dziewoński 33d69e26c9 tests: Fix different whitespace trimming in PHP and JS
Notably, JS trims the no-break space, while PHP doesn't. There are
some other differences that don't come up in our tests. What we really
want is to trim the ASCII whitespace as defined in the HTML spec.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
https://www.php.net/manual/en/function.trim.php
https://infra.spec.whatwg.org/#ascii-whitespace

Change-Id: I95b8fb38878716a2fa7ec84c9f2e8065ebe77c0d
2020-05-14 21:37:26 +00:00
Ed Sanders 076c6d828a Parser: Use Element instead of Node when appropriate
Change-Id: I67015989954e61810302bf8931d05419f007ffeb
2020-05-13 14:46:36 +01:00
jenkins-bot 8415b44837 Merge "Modifier: Fix missing docs and variable names" 2020-05-11 22:17:41 +00:00
Ed Sanders 07439609c4 Modifier: Fix missing docs and variable names
Change-Id: Ia5a7974f1efbe7465235fd1f1f548f53848ca960
2020-05-11 22:56:21 +02:00
Ed Sanders 6aa2fac2f8 Give username completion a min width of 10em
Change-Id: Id98643714e092f33034dcc84a97845fb2945bfb0
2020-05-11 19:44:52 +01:00
Ed Sanders 76bd22fe59 Show no remote users when input is empty
This could cause unrelated remote users to be shown
if you typed '@x<backspace>'.

Change-Id: I03c63ede4fce53c201398b6ba5256b68aa90391c
2020-05-11 19:35:48 +01:00
Bartosz Dziewoński 6237f0fe0f Show real error message when an exception is thrown
Exceptions were being treated like API errors, resulting in the
incorrect message "Invalid response from server." being shown to the
user. Instead show the error message.

Bug: T252238
Change-Id: Idbaee7d2b710812673992d30a17a9b5fe856a5a6
2020-05-11 19:04:54 +02:00
jenkins-bot dc2fe46032 Merge "parser.js: Fix some typos and variable names" 2020-05-11 15:19:36 +00:00
Ed Sanders ea0b95be05 Manually clear out session storage on teardown
We used to rely on this happening in onInputChange but
that listener is now detached.

Bug: T252176
Change-Id: I6654d68dc6107cd78172c455db9cba6cb9eabddf
2020-05-08 23:01:17 +01:00
Ed Sanders 77f1be3bd1 parser.js: Fix some typos and variable names
Change-Id: Ib80fd87893f8fad47eaeac8edabe03472b78b75c
2020-05-08 20:22:49 +01:00
jenkins-bot 4c8e92e0fb Merge "Disable VisualEditor page takeovers while a reply widget is open" 2020-05-08 14:24:26 +00:00
Ed Sanders 4f22e32304 Fix typo in parser.js 'dl' => 'dd'
Doesn't actually affect the behaviour as we are
computing indentation level.

Change-Id: I8b6824460ffbee1c0acb361c26503d3b6c439025
2020-05-08 14:24:15 +01:00
David Lynch 2f92e5d114 Disable VisualEditor page takeovers while a reply widget is open
This allows the unload handler to trigger on these links.

Depends-On: If52aa9d619eac08456874fc75c0f6e1adff01246
Bug: T244942
Change-Id: I9904e8af4a60b0f5e9a6e263cd4fd8e1e3fd1f98
2020-05-07 21:46:15 +02:00
jenkins-bot f0f457562d Merge "Handle &nbsp; and other entities in the timestamp/timezone" 2020-05-07 19:44:12 +00:00
jenkins-bot 6ee5865228 Merge "Config: Separate useVisualEditor into enableVisual and use2017Wikitext" 2020-05-06 20:27:53 +00:00
jenkins-bot 6e8899ee10 Merge "Switching between VE & wikitext (plain)" 2020-05-06 20:27:51 +00:00
jenkins-bot 6078c5b1a2 Merge "Disable IP mentioning until outstanding issues resolved" 2020-05-06 19:57:29 +00:00
jenkins-bot 2d6c8bfa94 Merge "Allow visual mode to tested with ?dtvisual=1" 2020-05-06 19:14:05 +00:00
Ed Sanders 63492f1276 Disable IP mentioning until outstanding issues resolved
Bug: T251478
Change-Id: Ied56673c08d9a9803eb58b0e373a866d21a8945f
2020-05-06 19:15:19 +01:00
Ed Sanders cb90e6edee Move IP users to bottom of suggestions
Bug: T251478
Change-Id: I55088f9724303d2c46d829a14e0dc8abd5dc38b8
2020-05-06 18:53:02 +01:00
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 d18496f025 Allow visual mode to tested with ?dtvisual=1
Bug: T251963
Change-Id: Ie86ed2097e3dc008f73d9b498627f9d025b865d5
2020-05-06 18:03:12 +01:00
Ed Sanders 44fd8ec0ef Parser: Return mw.Title from getTitleFromUrl
Change-Id: I2c3ce50c5ff7486d6c1f3a0c26cb3a9f1c252b60
2020-05-05 21:34:46 +00:00
Bartosz Dziewoński 0269626adc Handle &nbsp; and other entities in the timestamp/timezone
Bug: T251838
Change-Id: Iba8d7c71e332c63229eec4bc7c80b10627135784
2020-05-05 22:38:16 +02:00
David Lynch b7ad053105 @Username completion in VE (source or visual) mode
Bug: T232601
Depends-On: I075cac9aa195574c3d416a40bbdc5ec2d64424e2
Change-Id: Ie605e783b333be0f81099d8d953725c38eb4cee1
2020-05-05 09:44:08 -05:00
Ed Sanders 5da26e2d0b parser: Have getAuthors return a list
Change-Id: Ieda881a26f802a9e8c73822fcbcc70dd6035bbb6
2020-05-05 12:13:12 +01:00
Ed Sanders 5271b3eafd Move CommentController to separate file
Change-Id: I6dbf16801058e7e41d38a0ce5753c298d380b780
2020-04-30 17:05:04 +01:00
Ed Sanders 2aa6e5f583 Allow inspectors to position beyond the surface
Change-Id: I3cd0e433ea117b1b469e5a2111f4c7988c48abfd
2020-04-30 17:05:02 +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
Ed Sanders 75da1e0b3a ReplyWidgetVisual: Use hasContent instead of hasBeenModified for isEmpty
Change-Id: I093a4b68573809e5222db01aead3ce00ed9a87ae
2020-04-29 16:32:00 +01:00
jenkins-bot 922443f68f Merge "ConfirmEdit CAPTCHA support" 2020-04-29 12:04:44 +00:00
jenkins-bot e624e17471 Merge "Remove client-side timeout when saving pages" 2020-04-28 22:38:27 +00:00
jenkins-bot bb096d8f50 Merge "Revise error messages when replying to comments affected by templates" 2020-04-28 22:35:47 +00:00
jenkins-bot 431716577b Merge "Add 'cursor: pointer' to the reply link" 2020-04-28 22:33:34 +00:00
jenkins-bot ba3fd84243 Merge "Minimum keyboard-accessibility for the reply link" 2020-04-28 22:33:33 +00:00
jenkins-bot 5fdf6ae466 Merge "Fix inserting replies inside a <pre>" 2020-04-28 22:31:45 +00:00
Bartosz Dziewoński 021c981817 Add utils.getNativeRange() method
Change-Id: Iab6c5fa092560ee9dff808bbcc405722914febe7
2020-04-28 23:11:26 +02: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 047e8eb82c Fix inserting replies inside a <pre>
In the future, we should think about a better solution that also
handles other elements (T250126), but this is an easy fix for now.

Bug: T250512
Change-Id: I1321f0da523ddb4a999b8c453b9094a267b38ae2
2020-04-27 23:23:31 +02:00
jenkins-bot f376230459 Merge "Move VE toolbar to top right" 2020-04-27 21:17:01 +00:00
Bartosz Dziewoński c07243c88f Add 'cursor: pointer' to the reply link
Bug: T250337
Change-Id: I77949f59ac4da27e7a25b5c35ca2a9df66f22872
2020-04-27 18:30:07 +00:00
Bartosz Dziewoński 7cb7722b76 Minimum keyboard-accessibility for the reply link
Using an approach similar to that in jquery.makeCollapsible.

Bug: T249915
Change-Id: Ia3dc43d23c29cd936a9445766e394f96f096da75
2020-04-27 18:30:00 +00:00
Bartosz Dziewoński 4ad9aa8449 parser: Don't crash on links to invalid titles
Bug: T251045
Change-Id: I1a7b8b9b34d38ec4e3edc12687bdf99bb0e61bd8
2020-04-27 19:59:26 +02:00
Ed Sanders cd7acc741b Move VE toolbar to top right
Change-Id: I97b322ded505df608eda73a7c6a04157e993d73b
2020-04-27 16:42:35 +01:00
Bartosz Dziewoński b1376413f0 Revise error messages when replying to comments affected by templates
Bug: T248607
Change-Id: Iea49d16bb0e5c71b36a79248f3f91f7987e65702
2020-04-26 19:50:32 +02:00
Bartosz Dziewoński 7ef3bffb1e Show error on pages with fostered content to avoid page corruption in Parsoid
When the user clicks a "Reply" link on a page that is affected by the
'fostered' lint error (indicating fostered content in the HTML
representation), display an error and refuse to edit it, as Parsoid's
transformations will damage the page content.

The error message includes a link to documentation about lint errors,
and a link to the editor that will highlight the error location.

Depends-On: I723ec766d1244d117f8d624440026fe5af0d3403
Bug: T246481
Change-Id: Ic60cb58f98d10dc9b113469e5d3bbfb2d2b0564f
2020-04-21 17:40:39 +00: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 d3c46a2967 eslint: Disable max-len
Change-Id: I7e49dc170dba62b88f1879ae670f806f6b54d4e9
2020-04-21 15:50:19 +01:00
Bartosz Dziewoński e3e36e11ac Remove client-side timeout when saving pages
Bug: T249071
Change-Id: I367c5931c05cf944bfad0f9fff69f06b32880411
2020-04-20 23:29:10 +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 f04abd02d4 Improve autosign handling of 3/5 tilde sigs and add tests
3 or 5 tilde signatures will be assumed to be erroneous and fixed
to 4 tilde signatures. This will be visible in the preview so shouldn't
come as a suprise to users.

Bug: T245628
Change-Id: I741f0761a6fb10c99cf3239ac5c6c7e1a2b872c7
2020-04-14 20:29:31 +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
David Lynch e38aad96e4 Add override config for instrumentation rates
Bug: T250086
Change-Id: I32fbf3d6562fb0a93698a24bbd8177149a19fed3
2020-04-13 12:38:40 -05:00
Bartosz Dziewoński 55b43a70d4 Fix skipping to the end of the paragraph when there is no wrapper
Bug: T249217
Change-Id: I77847901d98f56dbcbcf379c6c17f41e06a3a939
2020-04-03 18:11:59 +00:00
Bartosz Dziewoński a14293c8e7 Remove Parsoid section wrappers before finding transclusions
The section wrappers can be marked as template-affected when the
previous or next section is transcluded, causing comments to be
unnecessarily uneditable. The new test case demonstrates this.

Depends-On: I03bc455d5484a6c51f3fa2397c64936b829fe7e3
Change-Id: I895a04990d79a3475d778b4fef054ea0bb076f0b
2020-03-24 23:31:21 +01: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
Bartosz Dziewoński dab37fd7b4 parser: Make #getTranscludedFrom return page title in text form
It's more convenient for display or comparing it with other things.

Depends-On: I03bc455d5484a6c51f3fa2397c64936b829fe7e3
Change-Id: I88d7aa68977210b16860075ed52983a5e99ee0f7
2020-03-24 22:29:35 +00:00
jenkins-bot 85472b7e31 Merge "ReplyWidget: Double-check that we can post before posting" 2020-03-20 19:37:48 +00:00
jenkins-bot 5b8b801989 Merge "Use 'baserevid' instead of 'basetimestamp' for edit conflict detection" 2020-03-20 19:30:15 +00:00
Bartosz Dziewoński 7fcd880fa5 controller: Fix minor issues with error popup
The rejection handling callback was accidentally resolving the
promise, which resulted in an error like 'TypeError: Cannot read
property '$element' of undefined' when the resolution value was
used.

Fixing this reveals that we weren't removing the placeholder list
element correctly. This wasn't immediately visible because of the
.empty() call in the next resolution callback, but it would have
caused something similar to T245574.

Follow-up to 6964f0c965.

Change-Id: I3aeb9a86046c4ccaa6c39301edc7285d02b0320c
2020-03-20 19:01:03 +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 92c3f079b8 controller: Make edit summary use the wiki's content language
Bug: T246043
Change-Id: I591e1a3ed3e7c8b68f5e203a0c77d057793fc767
2020-03-14 14:17:29 +01:00
jenkins-bot f97e6303a3 Merge "controller: Show error messages immediately when loading fails" 2020-03-13 22:13:19 +00:00
Ed Sanders 1be47f0599 Support saving multi-line comments in VE
Change-Id: I3e19fac750dbb8d10b6e1bf6081453c75768e625
2020-03-13 16:12:01 +00:00
Bartosz Dziewoński 6964f0c965 controller: Show error messages immediately when loading fails
Previously you'd only learn about the issue when saving failed.
Now a modal alert dialog with the error message appears.

This means that we have to wait for the loading to finish before we
can display the ReplyWidget now... this should not be noticeable,
since we preload in #init.

Bug: T247533
Change-Id: I5468e67c449d530a0d15f69bff954d37a5b6a14c
2020-03-12 19:24:00 +01:00
Bartosz Dziewoński 4e135c7f07 Use 'baserevid' instead of 'basetimestamp' for edit conflict detection
This has two benefits:
* Allows detecting a conflict if two edits are saved in the same second
* Doesn't ignore conflicts with yourself (T246726)

Depends-On: Id7565018f66860b5c2ba688777508db1b88700ae
Bug: T246726
Change-Id: I22eaa1af5692854870d31e08b171a070a2fda0de
2020-03-12 16:31:32 +00:00
Bartosz Dziewoński 574d519f92 ReplyWidget: Fix spacing for save error messages
This was accidentally removed in c8564f6ccb.

Change-Id: Ie08ad6f8e34abedec437e418dea492cce35d74ca
2020-03-11 22:01:44 +01:00
Ed Sanders 2fcd975764 Fix padding in visual mode
Change-Id: I43229baedf73ea9273b8796792de909b7bcbd462
2020-03-11 15:03:44 +00:00
Bartosz Dziewoński 9cb497fc97 Check wgIsProbablyEditable before showing 'Reply' buttons
Bug: T240582
Change-Id: I127cd937ed2725c649dc34a8d18a29560c09fb44
2020-03-10 21:19:33 +01:00
Bartosz Dziewoński 1fff57fdff controller: Move code for transcluded comment errors
This is a problem we can detect at the loading stage, rather than at
the saving stage, so move it from #postReply to #getParsoidCommentData.

Follow-up to e3e4ef9de4.

Change-Id: I19362399f9ff2fdc487ea4900654bc61d990575f
2020-03-09 21:59:12 +01:00
jenkins-bot 2e0c299a1f Merge "Fix signatureRanges overlapping for some comments" 2020-03-09 20:31:54 +00:00
jenkins-bot 1b052248e8 Merge "Replace the closest() polyfill" 2020-03-09 20:31:33 +00:00
Bartosz Dziewoński e3e4ef9de4 parser: Detect comments transcluded from another page
When trying to reply to a comment that is inside a transclusion,
detect if it's transcluded from a subpage or simply wrapped in a
template, and show appropriate error messages.

References:
* VisualEditor ve.dm.Converter#getAboutGroup()
* VisualEditor ve.dm.ModelRegistry#matchElement()
* Parsoid Linter#findEnclosingTemplateName()

Bug: T245694
Change-Id: If3dd1ebbf1d02ee4379c200019bfc3a8ec02325b
2020-03-09 20:28:56 +01:00
Bartosz Dziewoński b4029c3c58 Fix signatureRanges overlapping for some comments
If two signatures for a single comment were near each other,
we would sometimes treat them as one huge signature.

Change-Id: Ied4b3aa535a9ca6bebef8a004ae48b7d5a8f2f9b
2020-03-09 13:28:22 +00: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 aa91832d4e Tidy up ReplyWidgetVisual setup
Change-Id: Id575a5382a6e4cad5bdc00b66683ed0a06d749fd
2020-03-09 13:13:30 +00:00
Ed Sanders 3af3f3ed8c Wrap reply link in container so it may contain more links in future
For example 'Edit'.

Change-Id: I3d3027724cfd69a6719932bb2cb80fa711010fc4
2020-03-09 12:52:18 +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 9913a77d61 Merge "controller: apply ve.fixBase to the parsed Parsoid response" 2020-03-05 16:09:55 +00:00
jenkins-bot f7c3b701f9 Merge "Only allow opening one reply widget at once (on IE 11)" 2020-03-05 14:46:37 +00:00
jenkins-bot bba0007d44 Merge "parser: Return signature and timestamp ranges" 2020-03-05 14:46:00 +00:00
Bartosz Dziewoński 0ca851aa92 parser: Return signature and timestamp ranges
Currently not used for anything. May be used later for editing
comments (T245225) or reformatting timestamps (T240360).

Note that a comment may have multiple signatures+timestamps,
and we return them all so that you have to deal with that.

Fix some unrelated incorrect documentation comments.

Bug: T245220
Change-Id: I51b8bf4a3bb7968f35e32c7e44c95c2ab079d9ac
2020-03-05 14:28:17 +01:00
Bartosz Dziewoński 898db0d57a Only allow opening one reply widget at once (on IE 11)
We disable the other reply links using 'pointer-events: none' in CSS,
but IE 11 doesn't support that.

I tried hiding them instead and using @supports rules in CSS to apply
'pointer-events: none', but the result was worse than this.

Change-Id: Iab2bfe9c623f3d32cce9776277f33483155a0c42
2020-03-05 13:31:29 +01:00
David Lynch 0085b7c912 controller: apply ve.fixBase to the parsed Parsoid response
Also, add the missing dependency on ext.visualEditor.core.utils.parsing.

Bug: T245781
Change-Id: I26130f1afd7dd93012aea8a24943d966250c2472
2020-03-04 15:46:08 -06:00
Bartosz Dziewoński 6ab57649a7 ReplyWidget: Set line-height to match normal wikitext editor
Now it also matches the font in the reply editor used when
$wgDiscussionToolsUseVisualEditor is true.

Depends-On: Ia866af0163b538596bfbb8c96a330186b667f85f
Bug: T246846
Change-Id: I21bdbe798949c0027eea16904ec6bc125c4746d8
2020-03-04 15:45:04 +01: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
Bartosz Dziewoński 606d6b34ec Add reply links at the end of a line, even if the signature is in the middle
Previously they were added at the end of the text node containing the
timestamp, which was usually the end of the line, but not always.

And also fix the same problem for inserting the actual replies (or
reply widgets). This replaces an undocumented hack that prevented our
own reply links from triggering this bug (without it, the reply widget
would be inserted before the reply link rather than after).

While we're here, remove unintentional spacing that appeared before
some reply links, caused by trailing whitespace in text nodes.

Add tests for all of the above.

Bug: T245695
Change-Id: I354b63e2446bb996176a2e3d76abf944127f307e
2020-03-02 21:39:37 +01:00
Bartosz Dziewoński 711d5c4371 Parse Parsoid document as XHTML to avoid IE 11 bugs
This is the same as in VisualEditor. ve.parseXhtml has workarounds for
IE 11 bugs that would cause dirty diffs when saving.

Note that we must use ve.serializeXhtml to convert the document back
to a HTML string, but this is already the case (the conversion happens
in mw.libs.ve.targetSaver.saveDoc).

Change-Id: Ib6dec0002eaf33fc0d4a45331a6d38e5c5d7ab8c
2020-03-02 18:14:35 +01:00