Commit graph

1093 commits

Author SHA1 Message Date
jenkins-bot 00d63026a3 Merge "Halve the initial height of the reply widget on mobile" 2022-07-01 22:20:06 +00:00
jenkins-bot 4ed36bc03b Merge "Reply widget mobile: Reduce space between footer and footer-links" 2022-07-01 22:19:25 +00:00
jenkins-bot 8a0703f29d Merge "Reply widget mobile: Move reply/cancel buttons up into empty space of "advanced" bar" 2022-07-01 22:19:22 +00:00
jenkins-bot 11961a85a7 Merge "Reply widget: Simplify LESS expression" 2022-07-01 22:12:40 +00:00
Ed Sanders 9d9dc7f26a Halve the initial height of the reply widget on mobile
Vertical space is at a premium on mobile with the virtual keyboard.
The widget will auto-size when more text is entered.

Bug: T311836
Change-Id: I03ff7217f9ffe217f93a3dc95db2df018bd0d221
2022-07-01 15:05:00 +01:00
Ed Sanders 172960f887 Reply widget mobile: Reduce space between footer and footer-links
Bug: T311836
Change-Id: I6275ff67a909125398872e2f691e5b62d165d546
2022-07-01 15:05:00 +01:00
Ed Sanders 5014aa3c50 Reply widget mobile: Move reply/cancel buttons up into empty space of "advanced" bar
This reduces the overall vertical height of the tool

Bug: T311836
Change-Id: I095bff00686a54779d45efa73c3f8b74ba016702
2022-07-01 15:04:58 +01:00
Ed Sanders 1ad01e661a Reply widget: Simplify LESS expression
Change-Id: I1d00c81377cfe83167384c83d3abd3f1bcdc2497
2022-07-01 13:38:01 +01:00
Ed Sanders 98b5371a8c Have "Read as wiki page" link remove all DT content changes
As well as visual enhancements:
* Reply links
* Mobile lede section hiding

Change-Id: I14d591830620edf8bbaccb76b4bce0e87971d7c3
2022-06-30 23:02:50 +01:00
Ed Sanders 69bfc6d6a2 Hide the lede section on mobile when DiscussionTools is enabled
Bug: T311760
Change-Id: I3736b4880465359bcae9b903eecc57f1cd7674ef
2022-06-30 23:02:50 +01:00
Ed Sanders ae3be4aaf5 Always hide overflow menu when topic containers disabled
Change-Id: I05fbaa89992cfec8db50407f74061da7d1aabe2d
2022-06-30 23:02:50 +01:00
Bartosz Dziewoński b7d65bcaa7 Remove some unused or redundant styles
All of these either do nothing, or cancel out with other styles.

Change-Id: Ic2372bdc74efea288b4b906d16a6d17c86c217c4
2022-06-30 02:32:48 +02:00
Bartosz Dziewoński 6042778678 Prevent the "Subscribe" button focus outline from being cut off
We tried to align the buttons with the far edge of the page, but due
to skin styles setting `overflow: hidden` on the content, this is not
possible without causing the focus outline to be cut off.

Bug: T311662
Change-Id: Ie7c10c7564450c06231632892341c7fb232e7041
2022-06-30 02:32:48 +02:00
Bartosz Dziewoński aedb682e06 Use interface language direction for topic metadata wrapper
Bug: T305286
Bug: T311663
Change-Id: I31d9f7997c8894c344548636eea6c9a823698269
2022-06-30 02:32:48 +02:00
Bartosz Dziewoński e48f34e558 New topic hint: Avoid error about section editing when opened from diff
Bug: T311665
Change-Id: I22120a4d4dbe9ff6b9a285932ee9656bdfa0de09
2022-06-29 21:42:52 +02:00
jenkins-bot 9a531f1c68 Merge "Set height of ellipsis button to fix MenuWidget position" 2022-06-29 15:00:49 +00:00
jenkins-bot a78cacc618 Merge "Mobile topic containers: Fix right alignment of ellipsis button" 2022-06-29 14:27:32 +00:00
jenkins-bot 45e7c01b62 Merge "New topic hint: Cleanup CSS" 2022-06-29 14:23:37 +00:00
jenkins-bot c44da3739d Merge "New topic hint: Add clear:both" 2022-06-29 14:22:49 +00:00
Ed Sanders 12dae82c70 Set height of ellipsis button to fix MenuWidget position
Bug: T311558
Change-Id: I6dedf488ec19cef02949f65a5b92e38f4e4c5f85
2022-06-29 12:28:01 +01:00
Ed Sanders 26cdf6789d Mobile topic containers: Fix right alignment of ellipsis button
The icon element should be aligned with the right side
of the content area, like the expand/collapse button, and
the edit pencil in the main namespace.

Change-Id: I191a5984bafc6a478674dd5dccff0594a743ff18
2022-06-29 12:22:53 +01:00
Ed Sanders ff97a06522 New topic hint: Cleanup CSS
* Use sibling selector instead of negative margin to reduce
  space between hint and reply widget.
* Remove upstreamed right-padding for close button.

Change-Id: Ie51cd2208c2bebcbfeff08c249389085523193f0
2022-06-29 11:58:51 +01:00
Ed Sanders 90b2222341 New topic hint: Add clear:both
Bug: T311597
Change-Id: Id7e545b0c18fdd407cb096e3cc3d51415be9839c
2022-06-29 11:58:44 +01:00
Ed Sanders 56989d18a3 Fix hiding of topic container top-border when mw:tocplace present
Change-Id: I382cfeb10c7f8407b559526b0ca06e0dcddd2191
2022-06-28 15:18:13 +01:00
jenkins-bot cd86854235 Merge "Pass useskin/mobileformat when previewing/refreshing page contents" 2022-06-27 21:57:02 +00:00
Ed Sanders d00fa80ff4 Use $.html to refresh page after save
As per If549a0e647ce8.

Change-Id: I6afdc4a80615617678d2d31c2c9e5830b07a6ef0
2022-06-27 17:34:32 +01:00
Ed Sanders 639fabf647 Pass useskin/mobileformat when previewing/refreshing page contents
These are required to render content correctly on mobile.

Change-Id: I421e1f172e208c4bf9d50eee68f1b0220a78dfbe
2022-06-27 17:15:28 +01:00
Ed Sanders 7fc5a0c29d Topic containers: Design iterations
Bug: T310914
Change-Id: I9000f9902d612c58c6b3bc8b762232ca6dd9724f
2022-06-25 12:54:39 +00:00
Bartosz Dziewoński 109a50cb34 Truncate timestamps in comment IDs / names
For comments posted on or after 2022-07-12 (configurable), use a
shorter format, identical to the timestamps MediaWiki uses in URLs.

Changing the format for already existing comments would involve
difficult migrations, therefore we elect not to do it.

Bug: T304595
Change-Id: I387051a6a3a1d84cfae45c3e1516db870cc8b977
2022-06-24 00:49:58 +02:00
Ed Sanders da64c43ccc Show thread metadata in section headers
Bug: T269950
Change-Id: Ifa47ddcbccf288be0bbecd5961eab7c5122aab7b
2022-06-23 17:17:09 +01:00
Bartosz Dziewoński 1ec97b18d9 Fix race condition causing highlights to not be cleared
We cleared the highlight outside the setTimeout(), then set a new one
inside the setTimeout(). If this method was called twice quickly, two
highlights would be created, and the first one of them would become
impossible to clear.

Move the setTimeout() outside of the method to avoid this.

Bug: T311021
Change-Id: Ic8b2cf2a782a429c4ea073871efd215f4b300ed8
2022-06-20 22:51:39 +02:00
Bartosz Dziewoński d73ce24059 Tweak positioning of highlights to make them prettier
* Fix math and styling for RTL
* Make highlights for headings and framed comments cover them fully
* Align the far edges of wide comments

Bug: T309444
Change-Id: Iadbf83e02801fd9bd6336c84015994ee2819ce51
2022-06-20 19:03:50 +02:00
Bartosz Dziewoński a0750129e7 Set rootNode for items from in ThreadItemSet#newFromAnnotatedNodes
It's needed for the fix for T303396 to work correctly (in the case
where there's exactly 1 thread item on the page), and for the
highlight improvements in Iadbf83e02801fd9bd6336c84015994ee2819ce51.

Change-Id: I2b2f5535ebbf792910133622a271ac1491c74de6
2022-06-20 19:03:09 +02:00
Bartosz Dziewoński df22a66e42 topicsubscription: Reduce code duplication
Rather than making our own ThreadItem objects from scratch,
reuse those used by the rest of the code.

Change-Id: I67f5ea3ad26baffe51b66d0c75467ac00185dd0a
2022-06-20 19:02:46 +02:00
jenkins-bot 9058467403 Merge "ReplyWidgetVisual: Pass in memory-wrapped store to VE" 2022-06-17 22:26:06 +00:00
jenkins-bot 39401c4b6b Merge "ReplyWidgetVisual: Handle VE surface 'cancel' event" 2022-06-17 13:24:13 +00:00
Ed Sanders af5b9a9b46 ReplyWidgetVisual: Pass in memory-wrapped store to VE
We switched to our memory-wrapped store everywhere outside the
VE surface, but not in the VE surface itself.

Change the way we construct MemoryStorage objects so that they can
be constructed from a specific mw.SafeStorage instance.

Ensure MemoryStorage's cache is populated with initial storage object
data, and that the cache is copied over when we create derivative
objectes.

Bug: T310438
Change-Id: I652428f114dc5169195887cb8ca719ae196bb76f
2022-06-17 14:05:54 +01:00
Ed Sanders 7befd4a8fc Use new function signature for Target#initAutosave
Depends-On: I6ab00c089c9ae1a8bb05ce9405f1f1f2fd0915ca
Change-Id: I23eb131082260540d2cf5e2cad92c9514333862d
2022-06-15 23:49:49 +00:00
Bartosz Dziewoński 9eb200024e ReplyWidgetVisual: Handle VE surface 'cancel' event
Since change I29f6af4cc7c71a63a6d1bafc53d16b9abd1b60ec, VisualEditor
handles the Escape key to emit a 'cancel' event. We need to listen to
this event to allow Escape to close our editor when the surface is
focussed, in addition to the existing handling for the Escape key.

Change-Id: I8c0f2678d104a76d6a223aca9b57123b9f587ac7
2022-06-15 21:09:06 +02:00
Ed Sanders 0ad9b4c6b2 Move placeholder heading level (99) to a constant
Change the HeadingItem constructor to take a 'null' headingLevel
and store this internally with the constant. Change the JSON
serializer to convert this back to null.

Change-Id: I27508eed75d94b99c5189548919309f8da7deb75
2022-06-14 22:51:49 +01:00
Ed Sanders c2535e26dc MemoryStorage: Setup this.data before calling parent constructor
The parent constructor may trigger read/writes in the future
so this.data should always exist as early as possible.

Change-Id: I79a795a26c4ce1381d2a0b15329f7df1d6ab77ca
2022-06-10 15:10:01 +01:00
Sam Smith e31f8e6681 logger: Also log EditAttemptStep events via Metrics Platform
The EditAttemptStep instrument is a candidate for migration to the
Metrics Platform [0]. The first step of the migration is to log events
both using the Event Platform (i.e. via mw.eventLog.submit()) and using
the Metrics Platform Client (i.e. via mw.eventLog.dispatch()).

The Metrics Platform Client can mix in additional information -
so-called context attribute [1] - based on the stream configuration. The
majority of the default values mixed into each event via the
mw.eventLog.Schema defaults mechanism are already known to the Metrics
Platform Client.

Note well that the Metrics Platform Client will not log an event without
one or more streams being configured to receive that event. Therefore,
this change is a NOP.

An example stream configuration is given in [2].

[0] https://wikitech.wikimedia.org/wiki/Metrics_Platform
[1] https://gerrit.wikimedia.org/g/mediawiki/libs/metrics-platform/+/aed6738b845/js/src/StreamConfig.d.ts#31
[2] https://phabricator.wikimedia.org/T309013#7953227

Bug: T309013
Change-Id: Ic88225111132b440657aab85c34b36a642a7e602
2022-06-08 11:31:28 +01:00
Ed Sanders 32e306f6e1 Hide icon in anon warning below tablet width
Bug: T307709
Change-Id: I800153cabc1ba14fd249c106d57162fd0cd9dbe1
2022-06-03 16:33:26 +01:00
jenkins-bot f460ce39bc Merge "Add attributes for Minerva click tracking" 2022-06-02 15:29:50 +00:00
Ed Sanders c8570b95f9 Fix CSS selector after upstream changes to CompletionWidget
Bug: T307712
Depends-On: Ie590eb6b6c38531b959eadc1fcd5ba108180fdc8
Change-Id: Id39e680cbea54d77f061936c8876ecf7ed28e8b2
2022-05-31 20:39:39 +00:00
Ed Sanders 0f0e8fca9a ThreadItem.js: Only search CommentItem's for authors
If the thread contains a sub-heading, this would add
'undefined' to the list of local authors.

Change-Id: I696c56d07f30c6de2550e5f89b8cefcb3c17a259
2022-05-31 20:16:42 +00:00
Bartosz Dziewoński 28124e7f1e Add attributes for Minerva click tracking
Bug: T295490
Change-Id: I05fa96280c8dacc801b071d22086568ee0f11d86
2022-05-27 03:55:09 +02:00
Bartosz Dziewoński d7209b13b9 CommentTarget: Clean up toolbar actions
When moving the edit mode switcher outside of the toolbar actions,
we apparently forgot that we can disable this feature entirely.

Also remove $overlay: true, which isn't needed after the changes
from T307849.

Change-Id: I005cf18853305edd162c613f60b1ac45f42c3093
2022-05-21 20:28:54 +00:00
David Lynch b6f554a945 Ready A/B test code for topic subscriptions
Topic subscription test is going to be all logged in users only, no
transitory enrollment conditions, so we can remove the anonymous user
handling and DB writes.

Bug: T302515
Bug: T304030
Change-Id: I5e57bb9b7958576f3a04373748331a86f4626fb5
2022-05-19 01:09:40 -05:00
jenkins-bot e792fa0159 Merge "CommentTargetWidget: Exclude save commands" 2022-05-19 01:14:11 +00:00
Ed Sanders 1cc94f91bc CommentTargetWidget: Exclude save commands
Bug: T308709
Change-Id: Id614c8ecbdcdab237828d998fe898dcb9517ff47
2022-05-19 00:58:40 +01:00
jenkins-bot 3141a9ed18 Merge "Ignore LRM and RLM in more places in the timestamp" 2022-05-17 19:42:05 +00:00
Bartosz Dziewoński 6a59149132 Ignore LRM and RLM in more places in the timestamp
We previously ignored them before timezone indicator (e9c401e3aa),
but they can end up in other places too, e.g. after the time.

Now we ignore them after every token. This is way overkill, but it
shouldn't hurt.

Bug: T308448
Change-Id: I20f7aaa34dba23f2a2faf1be258c1aea32ab770f
2022-05-17 02:00:22 +02:00
jenkins-bot df0e84c0d1 Merge "Remove code for handling legacy HTML with data-mw-comment-name" 2022-05-15 20:20:43 +00:00
jenkins-bot 37b28fb36b Merge "Fix reply links sometimes not working after visiting action=edit&section=new with new topic tool enabled" 2022-05-15 13:45:06 +00:00
Ed Sanders bfb3c24ecc Remove code for handling legacy HTML with data-mw-comment-name
This can be merged a few weeks after the commit that introduces
it (If28e1588742), once all the HTML caches have been purged.

Change-Id: I96d2de081a23137fe11a66c8213535219ebfb230
2022-05-14 20:23:45 +00:00
Bartosz Dziewoński 28db9b8350 Fix error message when trying to reply to transcluded comment on a protected page
If the user can't edit, tell them why, instead of trying to
advise them to use the edit button that they cannot see.

Bug: T303110
Change-Id: Ibc41732a55443331e432987e630976610901c599
2022-05-13 01:56:51 +02:00
jenkins-bot 521760ecdc Merge "Redesign "new comments" warning" 2022-05-12 17:21:23 +00:00
Ed Sanders cf3e7c49d8 Redesign "new comments" warning
Bug: T300560
Change-Id: I5abf22b5a11c2639392a3d571c987ed5afaac2d6
2022-05-12 18:02:32 +01:00
Bartosz Dziewoński f534e78cde Fix reply links sometimes not working after visiting action=edit&section=new with new topic tool enabled
getPageData() had an optimization where, when it was called with
isNewTopic=true, it would skip querying 'linterrors' and
'transcludedfrom' data and return fake empty responses.

The issue is that they were cached, and then returned when it was
called with isNewTopic=false later.

Remove this optimization, as we make those queries anyway on init.

Change-Id: I1990b16f574c1aec385bd0fa46a9f39c6c2c1df2
2022-05-12 03:38:31 +02:00
Bartosz Dziewoński d7c390a6ca ReplyWidget: Fix 'returntoquery' handling for anon links
mw.util.getUrl() already encodes the values, encodeURIComponent()
isn't needed.

Also, slice off the leading '?' – while MediaWiki seems to accept it,
it looks like it is never present in any other place using this
parameter (this is fine even if there are no query parameters).

Bug: T308198
Change-Id: Iee3747ab53e3b0a5a0b43a7701205ac0c7f07e7f
2022-05-12 03:23:29 +02:00
Bartosz Dziewoński 523efb065c Make comment markers inline-block to fix comment wrapping in Safari (in headings only)
Previous attempt: I40da5272fd9c44a5a81e303349d0e8fc404e344d.
Limit the hack to only end markers and only inside headings
to avoid causing issues with page content.

Bug: T298371
Change-Id: I9dc95e17752b7f048eb3343dbeea3526359197c3
2022-05-12 02:31:22 +02:00
Ed Sanders b76cf89b9b Add missing 'undo' button on mobile
Bug: T308033
Change-Id: If3126cb213fb4a22a419b9b85fdca32b20863f03
2022-05-11 17:37:08 +01:00
Ed Sanders 95ec3e7920 Dismiss "new comment" highlights when clicking
Bug: T307807
Change-Id: I40ae5fdbadfb223b1484ebf6041d29263aafa347
2022-05-06 17:44:21 +01:00
Ed Sanders 4fb474d611 build: Update stylelint-config-wikimedia to 0.13.0
Change-Id: I164d6175f8077487e2d8dfbf0bcfbd13f1545cae
2022-05-04 23:25:06 +01:00
jenkins-bot 4f25201193 Merge "highlighter: Set the location hash for new topics on desktop as well" 2022-04-21 23:55:19 +00:00
jenkins-bot 90018a5b55 Merge "highlighter: Ensure items in .ranges and .$element are in the same order" 2022-04-21 23:55:17 +00:00
jenkins-bot d35c96db97 Merge "Mobile empty state adjustments: hide image, bigger button" 2022-04-21 21:48:07 +00:00
Bartosz Dziewoński f411f1c342 highlighter: Set the location hash for new topics on desktop as well
The old section=new wikitext editor does this, and I'd rather support
the same behavior on desktop and mobile than different ones.
Follow-up to 89a1efc9d8.

Change-Id: I5371f932680638ee159f2f713bbca44bba5675aa
2022-04-21 22:36:35 +02:00
David Lynch faff90b96b Mobile empty state adjustments: hide image, bigger button
Bug: T305261
Change-Id: I503a62fafaebfe17e1dd2181e543dcc2dbac9eb1
2022-04-21 11:48:23 -05:00
jenkins-bot 40b9b7a536 Merge "Avoid duplicating page content if there are multiple .mw-parser-output elements" 2022-04-21 01:02:06 +00:00
Bartosz Dziewoński d910663bbc highlighter: Ensure items in .ranges and .$element are in the same order
jQuery#add sorts the nodes in DOM order (and removes duplicates).
We did not sort the ranges, so they could end up in a different
order, causing #update to apply the CSS to the wrong nodes.
This was usually harmless, but it could cause incorrect rendering
when some elements are positioned or hidden.

Change-Id: Ic359db08dafa3d86a5778426a7dc2419c94feabd
2022-04-20 19:41:44 +02:00
Bartosz Dziewoński 0c6013c582 ReplyWidget: Fix text-align when content and user language have different direction
Bug: T306137
Change-Id: Ibb0accc210f3cd922ddfb4f0d95df2f98f684425
2022-04-19 22:05:09 +02:00
Bartosz Dziewoński 1ad185e097 Avoid duplicating page content if there are multiple .mw-parser-output elements
Bug: T306388
Change-Id: Iaee2999f02929d562ae9f78ef50913d515c72bb3
2022-04-19 21:46:59 +02:00
Ed Sanders 89a1efc9d8 Fix highlighting and expanding of new topics on mobile
Set the location hash to that of the new topic, then wait
for the section to expand before drawing the highlight.

Bug: T306399
Bug: T301840
Change-Id: I8bc78b49f359e10279584c16269fcb78a087eae0
2022-04-19 15:41:28 +00:00
Ed Sanders 64c76f54a3 Don't reload the page on mobile
Bug: T301839
Depends-On: I0985dd5e8db6f82df882c6f4de4ef3821a0eef13
Change-Id: Ic02de79627b813c1fa6f0e537288206bfb1dbd1c
2022-04-12 18:23:57 +01:00
jenkins-bot b0be1cbf21 Merge "Revert "Make comment markers inline-block to fix comment wrapping in Safari"" 2022-04-11 19:20:30 +00:00
Esanders 0e5ce694f3 Revert "Make comment markers inline-block to fix comment wrapping in Safari"
This reverts commit b4b6ae4e81.

Bug: T305721
Bug: T298371
Change-Id: I108595da651f5a746043b553c2bcf4bdfc64c437
2022-04-11 12:32:52 +00:00
jenkins-bot e87d2117e9 Merge "Replace mediawiki.Uri with native URL (or polyfill)" 2022-04-08 08:49:35 +00:00
Bartosz Dziewoński cf255f28bf Replace mediawiki.Uri with native URL (or polyfill)
Depends-On: I7c4f9b6449a4317d68f4923fb4f198181bbfe800
Depends-On: I04464c17369ffb0dd4e7c33d2bd4db7b2d050bf4
Bug: T305010
Change-Id: I02da91010304af35f0b1f2bd4d65a84d51f29930
2022-04-08 00:35:37 +02:00
David Lynch 0fc474d66f Log saveSuccess more consistently
Cases where saveSuccess wasn't logged:
* creating a new page with the New Topic tool
* any replies on mobile
* successful replies made through transclusions which then couldn't
  purge the current page

These were all cases where we abandoned the post-save process early to
reload the page.

Bug: T305541
Change-Id: I1366a3e0a4b03ac67f926284f1aa718ae552d852
2022-04-06 11:37:29 -05:00
jenkins-bot 4da9fdc80a Merge "Make comment markers inline-block to fix comment wrapping in Safari" 2022-04-01 15:44:16 +00:00
Bartosz Dziewoński b00b7cd5b5 debughighlighter: Fix date highlighting
Follow-up to 4c29304484.

Change-Id: Id088465c3060bcceb2c2b51d784fa60b9005e867
2022-03-29 23:52:00 +02:00
Ed Sanders 48fdcf1056 Remove data-mw-comment-name attribute from subscribe links
The HeadingItem's name is now present in the DOM, so just traverse
to it and use that instead.

Change-Id: If28e1588742513d606e3d8fcfb259b85acc0a873
2022-03-28 22:30:59 +01:00
jenkins-bot 63c6aceb2c Merge "Implement getTimestampString on CommentItem" 2022-03-26 21:25:13 +00:00
Ed Sanders 215695ad2c Refactor topic subscription logic
This will make it easier to support subscription buttons with
visual enhancements enabled.

Change-Id: I3614eada32885216358143a0cacf65966381679e
2022-03-25 11:57:58 +00:00
Ed Sanders 579b8bb1d4 Implement getTimestampString on CommentItem
Change-Id: I1768e9993debe904d6a228942ad0188486d65c0b
2022-03-24 16:49:35 +00:00
Bartosz Dziewoński c7723baf72 CommentParser: Replace uses of Title with TitleValue
Another small step towards removing the reliance on global state.

Change-Id: Ifb4a5bcbef6606d02f1c7aa7385d72822cb0bad0
2022-03-18 18:24:34 +00:00
Ed Sanders b4b6ae4e81 Make comment markers inline-block to fix comment wrapping in Safari
Bug: T298371
Change-Id: I40da5272fd9c44a5a81e303349d0e8fc404e344d
2022-03-18 14:31:36 +00:00
Ed Sanders 3c66f066c2 Refactor highlights into a class, and add window resize listener
Bug: T303616
Change-Id: Id369cdfc511a7f0f5e19fff4c6424bec2f34ff55
2022-03-14 14:57:19 +00:00
Bartosz Dziewoński 01b253c5b6 Don't allow the root node to be treated like a comment frame
Also fix a bug where headings would be ignored while checking for
comment frames. See task for detailed explanation.

Bug: T303396
Change-Id: I6495826b4b050ea80680e0798ac6ab4497a7c09e
2022-03-10 17:45:08 +00:00
jenkins-bot dd24b0edcd Merge "Improve handling for comments after fake headings using wikitext ;" 2022-03-10 16:21:18 +00:00
jenkins-bot 32d9ef573a Merge "CommentParser: Avoid using a dynamic undeclared property" 2022-03-10 00:22:16 +00:00
jenkins-bot 76478dda26 Merge "Move signatureScanLimit to a constant in JS" 2022-03-10 00:22:14 +00:00
jenkins-bot dfcb2f4fc7 Merge "Fix highlighting of comments when reloading" 2022-03-09 22:44:48 +00:00
Ed Sanders 457f6eb7d1 Fix highlighting of comments when reloading
The CommentController stores a list of the new comments that
triggered the reload warning. Just highlight all the comments
in this list, as we always reload to the revision we got from
the same API call.

Bug: T303261
Change-Id: I960f3cf33e25004bad6ab6df907121a87555aaf4
2022-03-09 14:47:03 +00:00
Bartosz Dziewoński 4c29304484 CommentParser: Avoid using a dynamic undeclared property
Change-Id: Iefa8dea83bc0d31b9c6b3509189eeaa652dd9ea0
2022-03-08 23:30:11 +00:00
Bartosz Dziewoński 08c79142fb ImmutableRange: Add @property annotations for magic props
Phan can analyze them now and reports some issues with types.

* Add some assertions on types where we're sure that we're using an
  Element or non-null, but Phan can't prove it
* Fix incorrect type hints on getFullyCoveredSiblings() and
  getCoveredSiblings(), luckily it was harmless

Change-Id: I8cc12450378efa7434c4d66882378b715edd4a70
2022-03-08 23:29:40 +00:00
Bartosz Dziewoński eb1fe7a8fb CommentParser: Fix redundant uses of getHeadlineNodeAndOffset()
We call CommentUtils::getHeadlineNodeAndOffset() before constructing
the HeadingItem in CommentParser, so the range's startContainer
is always the headline node.

Change-Id: I2afb6ba9100e785cd91f31d82f4cea59fa8b5443
2022-03-08 23:29:34 +00:00
Bartosz Dziewoński 0e576216b2 CommentUtils: Fix confusing types in getIndentLevel()
Change-Id: I548cf4ad54e92c22da64caf53ee028a906cd3b62
2022-03-08 23:29:15 +00:00
Bartosz Dziewoński 584f6a020c Use tagName rather than nodeName when we know the node is an element
`tagName` is only defined on Element, and it returns its tag name.

`nodeName` is defined on Node, and it returns the tag name for Elements,
and a string like '#text' or '#document-fragment' for other types.

We were using both, which made it harder to reason about what types
we're dealing with.

Change-Id: I8e621e5872bdf78c84ec553cfbfcdbf0192f0589
2022-03-08 23:29:05 +00:00
jenkins-bot 1f7ff387a7 Merge "New topic: skip tabbing into the mode tabs until you've focused the body" 2022-03-08 23:18:37 +00:00
jenkins-bot 4b2f9ede8e Merge "Use MessageWidget's showClose option" 2022-03-08 22:41:39 +00:00
Ed Sanders 6869112aad Use MessageWidget's showClose option
Change-Id: I81292bd84ce6feefdb852f6a636109f68e55291d
2022-03-08 01:25:22 +00:00
Bartosz Dziewoński b2ee19b441 Remove check for CDATA nodes
Added in 76289cdf73,
should no longer be needed since we switch to Parsoid's
HTML parser in 3e6ab2c4d2.

Change-Id: Ic0b7ed8089b71f2338e604f68d547759e069f0b2
2022-03-04 22:14:41 +01:00
Ed Sanders 4f91a0b883 Highlight new comments when refreshing
Bug: T300215
Change-Id: I72655e05dccbe96f9dfa4ccca4e91b3edf133d97
2022-03-04 00:40:29 +00:00
Ed Sanders 487be9e202 Show error message as soon as we detect the parent comment has been deleted
Bug: T300504
Change-Id: I654422f7931f50503e51500508aea728adf327a1
2022-03-04 00:40:29 +00:00
Ed Sanders d619308098 Don't show auto-save notifications when dynamically updating the page
Bug: T302327
Depends-On: If94e603458a385ba6eb15c4e29144f72e3ad12ca
Change-Id: I28f965137b986d00ac7a020ca93d8dc5195f5d4f
2022-03-04 00:40:29 +00:00
Ed Sanders da49448f43 Poll for new comments in the section you are replying in
Bug: T300504
Change-Id: I3a887ab2f5260bb4893a3d680103c9d8ec767f45
2022-03-04 00:40:29 +00:00
jenkins-bot 094b77b4bb Merge "Handle reply/topic preview entirely server-side" 2022-03-02 14:13:59 +00:00
Ed Sanders 1032db4878 Move (auto) topic subscription initialisation to separate file
Bug: T302805
Change-Id: Ia901cba731233719dd1d5916eb5211a551d34091
2022-03-01 21:27:08 +00:00
Ed Sanders c70c1e76f3 Only bind page-level handlers once
Raise scope of pageThreads variable (renamed from `result`)
so we don't have to re-bind when it is updated, and use a
flag to ensure we only bind the handlers once.

Bug: T302810
Change-Id: I0a5b122b8e3f656f28f3dd4fa6aca8e7839be06b
2022-03-01 21:26:36 +00:00
Ed Sanders f5d4df12a9 Move highlightPublishedComment to highlighter.js
Bug: T302805
Change-Id: I429148b16f790e1d1f5cbbd84fc35139727b4402
2022-03-01 14:44:21 +00:00
Ed Sanders ecbe75c453 Move highlighting methods to separate file
Bug: T302805
Change-Id: Ie4a8ea3f351015ab5bb4b817ef997cf6d77428da
2022-03-01 14:29:10 +00:00
Ed Sanders b6136c9a58 Rename highlighter to debughighlighter
Change-Id: I8c3873fb345fee3687efb1632f3eae36c030f9cf
2022-03-01 14:20:18 +00:00
jenkins-bot 0dc293fc20 Merge "Warn when target comments in a link can't be found" 2022-02-28 23:24:15 +00:00
jenkins-bot e15ccb8a07 Merge "Highlight all comments since the oldest in a thread bundle" 2022-02-28 23:24:12 +00:00
Bartosz Dziewoński be74938855 Warn when target comments in a link can't be found
Links are generated to:
* Single comments, by a user or by a notification
* Potentially multiple comments (new comments since T),
  usually just by notifications.

If in either case no comments are found to highlight, warn the
user so they get some visual feedback that the notification worked
as expected, but that the comment was just deleted since.

Bug: T301602
Change-Id: I090c904481cf6f3e9f964fa43b10001e75b0bc90
2022-02-28 21:58:59 +00:00
Ed Sanders dc8b4e8d4f Highlight all comments since the oldest in a thread bundle
For topic subscriptions, further restrict this to comments
in the same thread.

Bug: T302014
Change-Id: Ifba218871122901031a891034e709b886fc406da
2022-02-28 21:58:10 +00:00
jenkins-bot e4fa34f025 Merge "Don't insert comment markers inside replaced elements (like <video>)" 2022-02-28 17:16:11 +00:00
jenkins-bot 542da89530 Merge "Don't detect comments within references" 2022-02-28 16:47:21 +00:00
David Lynch 039372e925 New topic: skip tabbing into the mode tabs until you've focused the body
Bug: T295511
Change-Id: I23f964b5d02dc1486e1dcf71c64d337a600fdf9d
2022-02-23 11:24:58 -06:00
Ed Sanders ae554cdd66 Fix legacy hint URI on mobile
Bug: T302307
Change-Id: I7ce370bb011f0b30505c1b195bf6c96317b159e7
2022-02-22 15:31:13 +00:00
Bartosz Dziewoński 1e3ce9c88a Don't insert comment markers inside replaced elements (like <video>)
Also special-case thumbnail wrappers generated by
MediaTransformOutput::linkWrap, for compatibility with
TimedMediaHandler.

Bug: T301427
Bug: T302296
Change-Id: I7f48d8b2261507c5a33526c54109f5187d062ed3
2022-02-22 15:11:34 +00:00
Bartosz Dziewoński 8a2715bdd5 Move signatureScanLimit to a constant in JS
Change-Id: Ieb60c148fd060ab62e4a493e2d0dff6c051f945c
2022-02-21 22:42:14 +01:00
Bartosz Dziewoński 4244418e56 Don't detect comments within references
Bug: T301213
Change-Id: Ifd5198651c8ed0ce53379fb5e35938089cd54a09
2022-02-21 19:57:44 +00:00
Bartosz Dziewoński 1d43a024f9 Handle reply/topic preview entirely server-side
We were rendering the preview in a completely different way from how
we would add the real reply, and the results would be different
sometimes, particularly for multi-line comments with messed-up markup.

Render it server-side instead, in a very similar way to real replies
(generating a DOM list node and transforming it through Parsoid),
although without the whole context of the page to improve performance.

We can remove a lot of client-side code that was used solely for this.

This will allow the preview to accurately display the signatures when
we change how they are added (T278442), without us having to implement
those changes again from scratch for the preview.

Change-Id: I53341f4d4075c25b67ec3b3032bff9b8a880dcd3
2022-02-21 17:42:28 +01:00
Bartosz Dziewoński 8e44b43df0 Split off ThreadItemSet from CommentParser
Goal:
-----
Finishing the work from Iadb7757debe000025e52770ca51ebcf24ca8ee66
by changing CommentParser::parse() to return a data object, instead of
the whole parser.

Changes:
--------
ThreadItemSet.php:
ThreadItemSet.js:
* New data class to access the results of parsing a discussion. Most
  methods and properties are moved from CommentParser with no changes.

CommentParser.php:
Parser.js:
* parse() returns a new ThreadItemSet.
* Remove methods moved to ThreadItemSet.
* Placeholder headings are generated slightly differently, as we process
  things in a different order.
* Grouping threads and computing IDs/names is no longer lazy. We always
  needed IDs/names anyway.
* computeId() explicitly uses a ThreadItemSet to check the existing IDs
  when de-duplicating.

controller.js:
* Move the code for turning some nodes annotated by CommentFormatter
  into a ThreadItemSet (previously a Parser) from controller#init to
  ThreadItemSet.static.newFromAnnotatedNodes, and rewrite it to handle
  assigning parents/replies and recalculating legacy IDs more nicely.
* mw.dt.pageThreads is now a ThreadItemSet.

Change-Id: I49bfe019aa460651447fd383f73eafa9d7180a92
2022-02-21 16:22:32 +00:00
Bartosz Dziewoński 4613ae78e7 Change CommentParser into a service
Goal:
-----
To have a method like CommentParser::parse(), which just takes a node
to parse and a title and returns plain data, so that we don't need to
keep track of the config to construct a CommentParser object (the
required config like content language is provided by services) and
we don't need to keep that object around after parsing.

Changes:
--------
CommentParser.php:
* …is now a service. Constructor only takes services as arguments.
  The node and title are passed to a new parse() method.
* parse() should return plain data, but I split this part to a separate
  patch for ease of review: I49bfe019aa460651447fd383f73eafa9d7180a92.
* CommentParser still cheats and accesses global state in a few places,
  e.g. calling Title::makeTitleSafe or CommentUtils::getTitleFromUrl,
  so we can't turn its tests into true unit tests. This work is left
  for future commits.

LanguageData.php:
* …is now a service, instead of a static class.

Parser.js:
* …is not a real service, but it's changed to behave in a similar way.
  Constructor takes only the required config as argument,
  and node and title are instead passed to a new parse() method.

CommentParserTest.php:
parser.test.js:
* Can be simplified, now that we don't need a useless node and title
  to test internal methods that don't use them.

testUtils.js:
* Can be simplified, now that we don't need to override internal
  ResourceLoader stuff just to change the parser config.

Change-Id: Iadb7757debe000025e52770ca51ebcf24ca8ee66
2022-02-19 19:51:57 +01:00
Bartosz Dziewoński 99b5de8038 Split Data class into ResourceLoaderData and LanguageData
The Data class contained utilities for two unrelated purposes.
Split each half to a separate class.

Notably, this improves the signature of the getLocalData() function.

Change-Id: Icde615fb9d483fee1f352c34909b37f8ffde8081
2022-02-19 19:37:34 +01:00
Bartosz Dziewoński ae9f26a9e5 Various code quality tweaks
(suggested by PhpStorm)

composer.json:
* Document required PHP extensions

Parser.js:
* Remove incorrect param documentation
* Fix some typos in comments (missing parentheses)

CommentParser.php:
* Fix some typos in comments (missing parentheses)

ImmutableRange.php:
* Remove unused property
* Add a `throw` to indicate that code path is unreachable

SubscribedNewCommentPresentationModel.php:
* Add missing `return false`

CommentParserTest.php:
* Remove unnecessary pass-by-reference

CommentModifierTest.php:
* Remove unused variable

CommentParserTest.php:
* Don't construct Element objects directly. PHP's DOMElement allows
  it, but Parsoid/Dodo's doesn't, and we use the latter for static
  analysis. This generates all kinds of confusing warnings.

Change-Id: Ia9598ebea0e99830dd485296e94a9d96acc4b258
2022-02-19 19:36:52 +01:00
Bartosz Dziewoński f9f7aeb295 Prevent floated content from leaking out of the preview container
Change-Id: Ic4c5267cbe44fa22537a708f66e08503d0c1f816
2022-02-14 20:47:39 +01:00
Bartosz Dziewoński e414d1acaf Improve handling for comments after fake headings using wikitext ;
Bug: T265964
Change-Id: I77db68928c5426fd885a277eec52c6e164d559bb
2022-02-11 23:35:32 +00:00
Bartosz Dziewoński 4ff65cf5e2 Update references to warningbox class
Bug: T301401
Depends-On: I632e42ee9065b38dca443beae1cb01ef714cae7b
Depends-On: I7a7046bf9b9765cbb82ec3caa1530de7f05e0da4
Change-Id: Ia42cf9cd5b63cfe679bdf90bfcbf528f14f9ebcc
2022-02-09 21:36:50 +01:00
Ed Sanders f0940557ee build: Update eslint-config-wikimedia to 0.22.1
Change-Id: I18a5ceae9e8fdc6398cd27c24c1a97fe87e3c016
2022-02-09 13:50:55 +00:00
jenkins-bot 362206e572 Merge "Improve check for HTML comments after multiple line breaks" 2022-02-08 20:17:26 +00:00
jenkins-bot e8e9ba5f98 Merge "Fix some typos in comments" 2022-02-08 20:00:11 +00:00
jenkins-bot 4593a9fe91 Merge "Don't count leading/trailing whitespace against signature scan limit" 2022-02-08 20:00:08 +00:00
jenkins-bot e82a4d86f3 Merge "Don't clear target comment highlight when Ctrl-clicking" 2022-02-08 19:49:44 +00:00
Bartosz Dziewoński fa01395acc Improve check for HTML comments after multiple line breaks
In the example in T301214, there is a space character between the line
breaks.

Bug: T301214
Change-Id: Ia1a8279ba0c60f92c1a30463c2a39d9e954ae3ca
2022-02-08 01:38:56 +01:00
Ed Sanders 025130fcd2 Don't prompt to reload the page if the reply widget is open
Only show the reload prompt if the 'disappeared' error is detected
when the reply widget is loading. Don't show it if we failed
to save, as it suggests you will not lose content if you reload.

Change-Id: I106f274e180dc97b540d729e31aae575c43f29f0
2022-02-07 22:45:35 +00:00
Ed Sanders 3d0849112a ReplyWidget: Factor out #createErrorMessage
Change-Id: Ie7e34154d74c24ce8379552fdf13feba31fd401f
2022-02-07 22:44:09 +00:00
jenkins-bot 4ac8e94084 Merge "ReplyWidget: Introduce a 'refresh' teardown mode that preserves auto-save" 2022-02-07 21:45:13 +00:00
Bartosz Dziewoński 909f1383d4 Don't clear target comment highlight when Ctrl-clicking
It annoys me when Ctrl-click clears it but middle-click does not.

Change-Id: I8636140df25d44ac79cb2bc0d1aebecc62c4db5d
2022-02-07 21:29:01 +00:00
Ed Sanders 7cad692afa Move ApiDiscussionTools to ApiDiscussionToolsPageInfo
Also remove 'paction' param, and instead make 'transcludedFrom' a
property of the result object.

Change-Id: I0a289f6d71e4708afff0b52066b1ed6faf76b9ae
2022-02-07 16:50:02 +00:00
Bartosz Dziewoński 5945a4a0eb Fix some typos in comments
Change-Id: I699d9d105b8706cef0800ccc086cde687de54078
2022-02-04 20:36:28 +01:00
Bartosz Dziewoński 13ab1db6da Don't count leading/trailing whitespace against signature scan limit
It's an arbitrary limit, it seems harmless to relax it to support the
use case in the task, even if it's weird.

Bug: T300949
Change-Id: I7c895c7019726758bbae3183b9c3ecbd9eabcf38
2022-02-04 19:35:29 +00:00
Ed Sanders 0b42aea276 CommentParser: Cache variables in getUsernameFromLink
Change-Id: I625e6ded3badd75a7a658c8d000576d0d165a18b
2022-02-04 19:35:18 +00:00
Ed Sanders 8ad1df7dc8 CommentParser: Name parts of return value from findSignature
Change-Id: I3a5ad36df0afdedc0aa9a15e5d83c5426b03b790
2022-02-04 19:34:18 +00:00
Ed Sanders e2f3c2f264 ReplyWidget: Introduce a 'refresh' teardown mode that preserves auto-save
Change-Id: Ibb04f7c2813b9d3cf2bb2434a414c86eb0a7f644
2022-02-02 18:38:22 +00:00