Commit graph

341 commits

Author SHA1 Message Date
Ed Sanders 8ca9da66fd UsernameCompletionTool: Use 'userAdd' icon
Depends-On: I6de36ca2ba279dc11d18bdff3c5d138444a13361
Change-Id: Ic09e18bf284b97bb135c3e8b0129fb9bc96cf72f
2020-06-24 12:33:33 +01:00
David Lynch 02fafccd23 Fire window-open-from-tool event for username completion from toolbar
The automatic event from core didn't catch this, because it's not an action
method called "open".

Bug: T255638
Change-Id: Ifa456e850a8edb374df098e21b46bb872416ae55
2020-06-23 10:25:03 -05:00
Bartosz Dziewoński b6edd8ddef CommentController: Apply pre-save transform when switching to visual
Parsoid doesn't understand syntax expanded during pre-save transform,
e.g. [[User:Foo|]] or ~~~~, and it gets nowikied when switching back.

Change-Id: I791426d9d6c0a1399b1e95039b11e43a3e5bf79f
2020-06-22 21:01:55 +02:00
Ed Sanders 03665de09e Move VE components to dt-ve
Change-Id: I4fba23e83d9ace833b55e67d1c3ef8b8da5ed19f
2020-06-22 20:09:18 +02:00
jenkins-bot a2b31efb19 Merge "Remove unsupported argument from getWikitextFragment" 2020-06-22 17:59:57 +00:00
Ed Sanders b38e380ebf insertAndOpen: Call this.open directly now there is no precedingCharacter check
Change-Id: I82b2fdd58fe512638a8f69d4df9adc4be98e814e
2020-06-22 12:22:08 +01:00
David Lynch d7557d5ab3 Don't try to avoid username completion appearing in email addresses
Current code breaks in other languages which don't use whitespace as a
word separator. The word-separator message is (for reasons) not reliably
set to something other than " " on wikis for those languages, so we
can't use it as a trigger for just not caring.

Bug: T255153
Change-Id: I1ff929811af59fd7a7bf7e8dfc1cd121a2c4db4e
2020-06-22 12:21:32 +01:00
Ed Sanders 83968e4c00 Remove unsupported argument from getWikitextFragment
This was removed upstream due to a regression.

We don't need it right now, but may need it in the future to
support editing, so replace with a TODO.

Change-Id: Ia73657080241319df309f3b6566ac0ac36a5909d
2020-06-20 13:07:49 +01:00
jenkins-bot e4fc21ad37 Merge "Check the right page for lint errors by title" 2020-06-16 16:14:47 +00:00
jenkins-bot c678fffd49 Merge "Add user mention tool" 2020-06-15 19:46:19 +00:00
James D. Forrester d6c3df31f5 Remove various phan suppressions and fix issues
Change-Id: I73b535f284566a0a8876a3198b9784b47567fac6
2020-06-12 20:35:59 +01:00
Ed Sanders 7be0cc3209 Create ThreadItem classes
Change-Id: Id2c5324d74eccb1209ccb76768c557722c6d9400
2020-06-12 20:35:59 +01:00
jenkins-bot b6695dae58 Merge "Strip RESTBase IDs when switching to VE" 2020-06-12 18:49:20 +00:00
jenkins-bot 02d049affe Merge "Only re-focus the reply link when reply is abandoned" 2020-06-12 18:17:13 +00:00
jenkins-bot f115f3ce3d Merge "Tweak appearance of find-and-replace toolbar" 2020-06-12 18:16:48 +00:00
jenkins-bot 6eb9824e8c Merge "Add square brackets around reply link and use lower case (when possible)" 2020-06-12 18:11:20 +00:00
Ed Sanders 38d85268f0 Add user mention tool
Uses userAvatar for now while we wait on userAdd to be upstreamed.

Bug: T254366
Change-Id: Ifa512c518efa9740a138d3d42fc607f2840b4040
2020-06-11 20:53:49 +01:00
Ed Sanders f2d3a00a7b Follow-up Icb14766: Fix formatversion:2 param
Bug: T255083
Change-Id: I5636e8e21f45c50df31d05d535227cf909a45269
2020-06-11 18:27:30 +01:00
Ed Sanders 09857e13f1 Only re-focus the reply link when reply is abandoned
Bug: T252903
Change-Id: Iabac3eb2258ecd48f61e027950446f59dca68df3
2020-06-11 17:36:00 +01:00
Ed Sanders de84a27e88 Tweak appearance of find-and-replace toolbar
Change-Id: Ia61e765217ee9d4c249af0a2494ba427e29a0d54
2020-06-11 16:02:37 +01:00
Ed Sanders d6d9aec3ee Strip RESTBase IDs when switching to VE
Bug: T253584
Depends-On: If5d15dd4e7e0d3704ca8d75c0a25c529b06f17fb
Change-Id: Ia310fcc873960d0d3c1b17410e33dc4f47c5c734
2020-06-11 14:06:07 +00:00
Ed Sanders a4d767d97c CommentModifier.php: Remove unnecessary toLowerCase
We only need .toLowerCase() or strtolower() when doing
case insensitive comparisons.

Change-Id: I19caca50139a42d86ff20e1ee0224cd3deb0d092
2020-06-10 22:06:16 +01:00
jenkins-bot edba40b1b6 Merge "Always use API formatversion: 2" 2020-06-09 19:25:15 +00:00
Ed Sanders 06eab3d961 Add square brackets around reply link and use lower case (when possible)
Bug: T249578
Change-Id: I5846106b10dc82231250d04a1f9ff025cfc1ca30
2020-06-09 19:55:14 +01:00
Bartosz Dziewoński 745b65f254 Check the right page for lint errors by title
Bug: T254930
Depends-On: Ic34617e2f56d1055388ea6e8a93ff641f0342240
Change-Id: I86679ce0f641f12bd9d99e4b7baed1294103e3a2
2020-06-09 20:52:51 +02:00
Ed Sanders efd847c7df build: Update devDependencies
Change-Id: I94a455e52f2c216ccab40e360ce24fc0adc332a0
2020-06-09 19:42:05 +01:00
jenkins-bot 5907cde5e5 Merge "ReplyWidgetVisual: Disable template sequence" 2020-06-09 15:54:08 +00:00
Ed Sanders 0cfc84aa29 Always use API formatversion: 2
Change-Id: Icb14766488beab76e24d1fedcc4b6214c6b04d98
2020-06-09 00:32:11 +00:00
David Lynch 36cd435895 Tweak editor-switch mode label so it's consistent with the naming in VisualEditor
Bug: T254291
Change-Id: Iab800561f6a5e81e1e48907366e874b44924d60a
2020-06-08 17:59:05 -05:00
David Lynch 5fa7d713d8 Logging: editor_interface should be visualeditor not visual.
Also, it should switch when the editor switches.

Bug: T254291
Change-Id: I2550529f51a8417586d6f0791d958fcf4b9d4fc6
2020-06-08 17:22:35 -05:00
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