Commit graph

2398 commits

Author SHA1 Message Date
Bartosz Dziewoński 6dc9b55b21 Move abort event tracking from the start to the end of the teardown process
Bug: T237063
Change-Id: I66869f8a84692e6fbe00373460449714cc722084
2021-07-27 22:50:52 +02:00
Bartosz Dziewoński 995644de88 Fix rare exception when editor loading is aborted
If editor loading was aborted while the surface was already being set up,
this code would cause the following exception:

    Uncaught TypeError: Cannot read property 'tools' of null

Introduced in c02c529537 (2017) because
our coding conventions at the time demanded that all `var` statements
must appear at the beginning of a function.

Bug: T287487
Change-Id: Id657d6f1e1189c17ede25362f145bb7b10f441db
2021-07-27 17:40:13 +02:00
jenkins-bot 6395ef82d9 Merge "Fix HotCat interface not working after cancelling visual editing" 2021-07-12 14:36:48 +00:00
Thiemo Kreuz fae6118071 Document and use mw.Api parameter defaults
Reasoning:
* format=json must be the default. Nothing else makes sense in
  the context of this code. This should not be a surprise.
* formatversion=2 is only a default when the custom
  getContentApi() is used, but not when mw.Api is used. One
  might argue that it's safer to always specify formatversion=2.
  However, this is not done in other places in this codebase.
  It should never be done or always.
* I find it confusing when the action=… is missing. Let's not
  rely on this default.

Change-Id: I6ca29f76bffc0849103c5bcff4aaf28fcaaa4c52
2021-07-12 09:13:59 +02:00
Bartosz Dziewoński 58b230a308 Fix HotCat interface not working after cancelling visual editing
Cloning the #catlinks node loses all native event handlers registered
on it. jQuery's `.clone( true )` method can only copy jQuery event
handlers, so it does not help. As a result, when the node is
reattached to the page after cancelling visual editing, HotCat's
interface is still visible, but not functional.

To fix this problem, keep a reference to the original node rather than
a clone.

https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
https://api.jquery.com/clone/

Change-Id: I2c0b3d1a919b67053a17dd11fd2b7dc7556267ef
2021-07-09 13:51:09 +02:00
Thiemo Kreuz c2017f74b2 Remove @param/@return docs that literally repeat the code
These don't add any knowledge but make the code harder to read
and maintain, and are an additional source of errors.

Change-Id: Ied57741a3f985e355adfddb4e75378d5c497faa9
2021-06-14 15:44:51 +02:00
jenkins-bot 1030601543 Merge "Remove docs that repeat what the code already says" 2021-06-14 13:38:30 +00:00
Ed Sanders 857014fae9 Support watchlist expiry
Bug: T251348
Change-Id: I017a54784c758c5e97fb640721bd456adc0fbab5
2021-06-08 20:14:45 +00:00
Bartosz Dziewoński 9c2c4b82c7 Make .ve-init-mw-target-surface styles not apply to nested non-target surfaces
The class .ve-init-mw-target-surface is used on the same element
as .ve-ui-surface. This element contains surface overlays
.ve-ui-overlay, which can contain other .ve-ui-surface elements
(inside inspectors), which would then erroneously have the target
surface styles applied.

Bug: T284312
Change-Id: I8d20a830dc48f6a098b0f9e9a7c7c1656de0fe56
2021-06-04 20:48:18 +00:00
Bartosz Dziewoński 32ecfe4caf Fix adding 've-init-mw-target-surface' class only to main surface
Bug: T284312
Change-Id: Ic5320f6747907542285674d386c7a59c9e857f0a
2021-06-04 20:48:08 +00:00
Thiemo Kreuz 35de3aa143 Remove docs that repeat what the code already says
Just reading the method signature gives the exact same
information in these cases. In other words, this code is
able to explain itself.

Change-Id: I04d031f2b24c3b0d21fede2c19c64b54d30b5b0c
2021-06-04 14:00:21 +02:00
jenkins-bot 30bf60cb87 Merge "ArticleTarget: Always set fromEditedState when preloaded is true" 2021-05-25 20:24:29 +00:00
jenkins-bot d06554c81e Merge "Ensure correct classes are added to surfaces" 2021-05-25 19:33:17 +00:00
jenkins-bot f40bf5e3df Merge "Don't apply min-height hacks to TargetWidget surfaces" 2021-05-24 21:11:55 +00:00
Ed Sanders a71dd4f797 Ensure correct classes are added to surfaces
* Create getSurfaceClasses method.
* Pass surfaceClasses to target widgets.

This ensures that the 'content' class is passed to mobile
target widgets, and the 'mw-body-content' class is added
in a less hacky way.

Change-Id: Ibce6d1a1d0fda63cca354761f1b91f808858e95b
2021-05-23 20:04:28 +01:00
jdlrobson 2a40996cb7 Add mw-body-content to surface element
VisualEditor recreates the mw-body-content element. The element
with mw-parser-output already exists as a child. All skins now
consistently follow this pattern.

To limit the impact to the editor, we use ArticleTarget and add the class
to the surface, which corresponds to the mw-body-content element of a skin.
This avoids unrelated regressions in experiences such as DiscussionTools.

Bug: T283014
Change-Id: I4833d1ca9fda4fc0bd433760e47fe7010f00db05
2021-05-17 19:06:54 +00:00
jenkins-bot 396876fe43 Merge "Check if actionTools.notices is set before using" 2021-05-05 15:16:44 +00:00
Kosta Harlan 298cb41ed3 Check if actionTools.notices is set before using
Ib957eac2d checked to see if actionTools.notices existed before
destroying it, but assumed it always existed if editNotices was
set. This patch adds a check before attempting to show editNotices.

The error occurs because Ibc7fa48df unregisters the 'notices' tool
(along with many others) for AddLinkArticleTarget.js in
GrowthExperiments. I92a3162ef in GrowthExperiments will empty out
any notices to work around this problem.

Bug: T281960
Change-Id: Idacd365efa82ecd5c0074ead035eda0cb9444b1f
2021-05-05 08:27:55 +00:00
Ed Sanders fab7ad9d92 Make convert to wikitext on paste feature configurable (temporarily)
Bug: T280745
Change-Id: Icc716563e5536b4ef33a48ba10a72f3a39bdec35
2021-05-03 21:16:54 +00:00
Ed Sanders 1f50769cff ArticleTarget: Always set fromEditedState when preloaded is true
This means we don't need to check this.preloaded again anywhere else.

Bug: T279448
Change-Id: Ic8abdd87074d404a47ab8a82abf36e5443f3d163
2021-05-03 14:34:25 +01:00
Ed Sanders eff7d05ca2 Don't apply min-height hacks to TargetWidget surfaces
Change-Id: Ic8547f4408f667d8e3808b7d1e29737448b7cb8d
2021-04-29 16:00:36 +01:00
Gergő Tisza b902b09784 Fix ve.init.mw.MobileArticleTarget.save return value
Like its parent method, ve.init.mw.MobileArticleTarget.save
should return a promise.

Change-Id: Ic3b390e613aa71aea4e7375a1f6e421cbd4f854c
2021-04-22 14:58:59 +00:00
BrandonXLF 73adc9ac78 Strip all wikilinks for initial edit summary
The regex that removes the wikilinks to create the initial edit summary
should have the global flag since it was taken from preg_replace which
replaces globally implicitly.

Bug: T276722
Change-Id: I21e3cdfe752657ad37d9a6bd473a7e7dbb6e4cd6
2021-03-07 17:51:59 -05:00
Ed Sanders 80c530fb56 Fetch full document when diffing wikitext sections
The full document is required to diff the reference list correctly.

Bug: T260008
Change-Id: I8d714be30051c94a725cd2678c547f57fa0a0c5e
2021-02-22 13:46:08 +00:00
Adam Wight d5ba11d3b2 Track whether an event was oversampled
This is needed to reconstruct population estimates from a sample.

Depends-On: Ie5cf24e84a2ed041bf7c4f0b891387c45667467b
Bug: T273454
Change-Id: I3a40e74f8ccb80aa6ed7d3313a5394aa31baf572
2021-02-02 13:02:01 +01:00
jenkins-bot 54f61eb54c Merge "Update save failure logging for EditAttemptStep schema, simplify code" 2021-02-01 18:28:10 +00:00
David Lynch 284d43de93 Log the DiscussionTools a/b test bucket for relevant schemas
If someone is enrolled the DT a/b test, we want to know about their
editing here as well.

Bug: T273096
Change-Id: I235f4ccbcbfbf95c6aa0df327a9a5a7d5ddb1038
2021-01-29 20:28:11 -06:00
jenkins-bot 096f2ba8ba Merge "Implement mwPlatform#decodeEntities" 2021-01-28 20:57:40 +00:00
Ed Sanders cab608057d Implement mwPlatform#decodeEntities
Logically depends on I3c1e3aa3cee but can be merged before it.

Bug: T70429
Change-Id: I4ded7f1563b9de4cc81e05d890a24392f88de4f2
2021-01-28 19:57:58 +00:00
Ed Sanders 0edaf11ef4 SpecialCharacter: Small refactor of list building
Change-Id: I720cccbaa1d27771336a9969c4b6c776a696cde9
2021-01-28 19:14:07 +00:00
Ed Sanders 865a59d640 Compute entire old DM doc for section diffs
We need the whole DM doc to show reference diffs
correctly. We can filter down to the active section
after the conversion like we do with the editor.

Bug: T272813
Change-Id: I2081dd520ff414caadaed2efda955d600953c957
2021-01-24 23:12:26 +00:00
Ed Sanders f8c403dffb Update VE core submodule to master (a8919f78e)
New changes:
c17816c5f Diff sidebar: Make font size slightly smaller
f8439f4cc Deep-freeze linear data
a8919f78e Deep-freeze linear data added by transactions

Local changes:
Fixes for deep-frozen linear model

Bug: T119236
Change-Id: Iae4362c8dab0f2bd335e24498f3e0522b8b1d4fc
2021-01-23 19:55:14 +00:00
Ed Sanders 1ec49384dc MWSaveDialog: Use MessageWidget (inline, warning) to show save dialog warnings
This is the same style that is recommended for form warnings.

Change-Id: I163f5180c66b9eb165a610184b153bb1da99caab
2021-01-20 19:41:17 +00:00
Ed Sanders e20decc77c MWSaveDialog: Remove wrap option from showMessage
This was used when we used to pass API errors to showMessage, but
is now unused by the two remaining users (missing edit summary, and
"press ctrl+enter to submit").

Change-Id: I8a6b4db78d4e451cf3ec85fcdfd8293328aaaa3c
2021-01-16 16:22:23 +00:00
Bartosz Dziewoński df43a1ef96 Update save failure logging for EditAttemptStep schema, simplify code
* Remove custom internal events in ArticleTarget for every error type.
  The indirection was just making it harder to figure out what data
  goes where.

* Centralize the actual logging in ArticleTarget, instead of doing it
  in a dozen methods.

* Directly use the error code from the API for 'save_failure_message'.
  Previously we'd lose the original error code and generate a new one
  in the event indirection stuff, except for 'responseUnknown'.

* Update 'save_failure_type' map. Remove unused error codes, update
  the ones that changed, and sort in the order in which the types are
  listed on the schema page.

Bug: T272162
Change-Id: Ied602c456f4b0e7e9bb135e3200bec5ce65641ba
2021-01-15 20:06:20 +01:00
Gergő Tisza c88ee8cd54
Preserve vehidebetadialog URL flag when switching editor mode
Switching from visual editor to old wikitext editor results in a
page reload and loss of the mw.libs.ve.disableWelcomeDialog()
flag. Use an URL parameter to preserve the flag.

Bug: T235812
Change-Id: I3968e5b7ae536d45fd764a8b7c3ea1f6d616033f
2021-01-04 19:54:32 -08:00
Ed Sanders 069e9c68ed Reset originalDmDocPromise when setting doc
originalDmDocPromise is dervied from target.doc, so if that changes
ensure the promise is cleared.

Change-Id: I51219e06109b0ccf1a17c920131b764862be85e1
2020-12-08 17:28:28 +00:00
Thiemo Kreuz fb0e33f987 Fix incomplete return in DesktopArticleTarget.tryTeardown()
If a teardown has started, there should be a teardownPromise,
otherwise return a rejected promise.

Bug: T268358
Change-Id: Ia5cbd6b409a38f97243234ea7c87d24f71bdf3d6
2020-12-02 21:22:10 +00:00
James D. Forrester 688edf1d64 build: Use "Grade A" rules for stylelint
Change-Id: I54b16407450960fefd5522a25cb733853d2f9372
2020-12-01 08:35:03 -08:00
David Lynch efd2cc0d03 Give revision_id a fallback that'll validate
In the new-page case, wgRevisionId will be 0 so it'll try looking for
parentRevId and the cast-to-int on an undefined will get us NaN. That
fails validation, so we should give one last fallback to 0.

It's _possible_ that we could instead make this an explicit check for
using wgRevisionId if it's anything not-undefined, but I'm not certain
about whether there are cases that wouldn't cover.

Bug: T237063
Change-Id: I8a38c0f3b8f8b2b596f5d0933e1a9e7f1326d7be
2020-11-30 11:17:23 -06:00
jenkins-bot df622d3b9e Merge "Remove maxLength from new section title in NWE" 2020-11-26 00:03:45 +00:00
Bartosz Dziewoński c49f919d90 Remove maxLength from new section title in NWE
MediaWiki doesn't have such a limitation. This might have been copied
from the edit summary code, which used to be limited to 255 bytes.

Change-Id: I4afe9b1cde0663c47c0c2502b6e32116b912208b
2020-11-26 00:22:36 +01:00
Ed Sanders 6a238b784e stylelint: Remove needless disables
Change-Id: I83c778f1b08b96e6a34068f497c7a72f2887ad4c
2020-11-19 23:38:11 +00:00
James D. Forrester 726e63cca7 build: Upgrade stylelint-config-wikimedia from 0.10.1 to 0.10.3
Change-Id: Idca06a9c5f8e3b1fa7be156613380e1ed99973fd
2020-11-19 23:37:03 +00:00
jdlrobson 80415f3b0f Change selector vectorTabs => vector-menu-tabs
the former is no longer present
note: i assume the style is still needed, I have
not tested

Bug: T255718
Change-Id: I4e7851362fc0d64097aeff5ec1535f8fe7480682
2020-10-26 18:17:42 +00:00
Gergő Tisza de7c6e913b
Avoid undefined in Math.max
Math.max( undefined, x ) is NaN.

Change-Id: I60bde01d4fc6e9a52182753f79232045f48d1f8b
2020-10-14 23:51:02 -07:00
Ed Sanders f0891fc174 Update VE core submodule to master (68c5f1a3c)
New changes:
c53286843 Make NodeWindow a standalone mixin
a787fbef1 Update OOUI to v0.40.4
0d74538ee Refactor dialog logging out of ui.Command into ui.WindowAction
ea55ede8d [BREAKING CHANGE] Improve structure of special character definitions

Local changes:
Fix output of fetchSpecialCharList to match new format

Bug: T264146
Bug: T264690
Change-Id: I2a28bb9c3e54cb5f9308ab361dee99bc801b467a
2020-10-08 19:09:12 +01:00
Ed Sanders 4915cbaed4 Return language code if language name not found
A language code is better than an empty string.

The string would be used in the LanguageContext to
describe an annotation like <span lang="en-fakeVariant">.

Change-Id: Ibc18c238d6216927447ca26f336e9d973c6b93eb
2020-10-02 14:54:19 +01:00
jenkins-bot 05ec421073 Merge "Don't navigate back immediately when trying to teardown" 2020-10-02 00:22:23 +00:00
Ed Sanders 27e19025a4 Fix cancelled browser-back on desktop
Bug: T263464
Change-Id: I808f7effffca5fbe9d8416d447df61dde57776c3
2020-09-21 16:23:18 +01:00