Commit graph

1394 commits

Author SHA1 Message Date
Ed Sanders 1b5550f485 Move var declarations inline
Mostly ve-mw/ui and a few left overs.

Change-Id: Idea0c94d974e661c49af8ad4545cd8fd98179ca8
2022-03-01 17:50:24 +00:00
David Lynch 5012d2fa93 Make sure postEdit hook doesn't fire until after saveComplete is done
Follow-up to c8072f1af2

Bug: T302746
Change-Id: Iac76ac69a62b38282ae5aa6194a89ab9110b0954
2022-02-28 20:59:44 +00:00
David Lynch a6d11f5334 Don't let MobileFrontend show abandonedit after saveComplete
Follow-up to c8072f1af2

Bug: T302746
Change-Id: Id1ef6a02cde7a30eae7b36f1d10f07e9a363e974
2022-02-28 20:56:09 +00:00
jenkins-bot 839a62829d Merge "Add and fix default values in parameter documentation" 2022-02-21 13:41:51 +00:00
jenkins-bot d79527e1f2 Merge "Always scroll to top when loading VE source mode" 2022-02-21 13:23:28 +00:00
Thiemo Kreuz bc0a34b0ed Add and fix default values in parameter documentation
Same random finds while working on something else. I carefully
checked and made sure these methods are actually called without the
optional parameter.

Change-Id: Iab36fd130258322985b5d6e7f8e1f7b4ee235ba2
2022-02-21 13:19:21 +00:00
jenkins-bot aa8b08bd1a Merge "DesktopArticleTarget.init: Handle popState target reactivation properly" 2022-02-21 13:14:38 +00:00
Thiemo Kreuz 58e27f56d6 Remove not needed self = this indirections
These are only needed when we need to access a specific `this` from
within another `function () {}` context. This is not the case in the
situations here.

This is split from Ibf25d7e to make it smaller and easier to argue
about.

Change-Id: Ide1476de91fc343aa992ad92a1321d3a38b06dd0
2022-02-21 10:52:24 +01:00
Ed Sanders e4c22ec0d6 Don't suppress teardown prompt when pressing escape
Follow-up to If9e5d1fbf00f8359.

Bug: T302096
Change-Id: I60fcddee7bf0dfb3a39e92d26898da2963861c19
2022-02-18 18:15:40 +00:00
Ed Sanders c8072f1af2 Move methods from DesktopArticleTraget to ArticleTarget
To allow them to be used by MobileArticleTarget.

Change-Id: I33e8b3c2361c2dfd0fae8aa41eacf993c93c9c48
2022-02-18 17:04:04 +00:00
Ed Sanders 54cd911db0 DesktopArticleTarget.init: Handle popState target reactivation properly
This ensures the full loading sequence is shown when the
user opens VE using history navigation.

Bug: T301843
Change-Id: Ia7a641c8bd5a036f23c9da94bc539d8cf66c5021
2022-02-16 15:56:24 +00:00
Ed Sanders ca6ed21835 Always scroll to top when loading VE source mode
Change-Id: Ibfbb241f523fbdfcf6eb9fd1aeaa0e13782586aa
2022-02-16 15:17:19 +00:00
jenkins-bot b7a0a690fb Merge "Desktop: Always show loading progress in a toolbar placeholder" 2022-02-14 17:00:08 +00:00
jenkins-bot 23e9f189d6 Merge "Smooth scroll the heading to the right place while target is loading" 2022-02-14 16:59:49 +00:00
Ed Sanders 78decedd47 Desktop: Always show loading progress in a toolbar placeholder
Bug: T299907
Change-Id: I0eaeb98719bf7a43e4a87366cfcd204f35b74650
2022-02-14 16:17:48 +00:00
Bartosz Dziewoński 28c9a47164 Hide the edit notices tool earlier if there aren't any
Previously, a toolbar with the extra tool could be shown for a moment
while the editor was loading.

Bug: T301626
Change-Id: I7f5d01ef6e64ef85141a38a236fe2a1d1ada00e8
2022-02-14 15:48:55 +00:00
Bartosz Dziewoński efd1b3ab95 Fix narrow toolbar jumping during loading
When the editor is loading, and the browser window is narrow enough
that we should use the narrow toolbar, the wide toolbar would appear
for a moment. It was particularly jarring when it caused it to wrap
over two lines.

Bug: T301626
Change-Id: I551a66edab40235c4a26751eed163b5b30ef698f
2022-02-14 15:48:46 +00:00
Ed Sanders 38bdb0f87a Smooth scroll the heading to the right place while target is loading
This avoids a sudden scroll jump when the editor finally loads.

Bug: T299773
Change-Id: Ia2d56f7898d8e4c886297807954604ad5a8e8c38
2022-02-11 23:24:00 +00:00
Ed Sanders fb8815f658 Fix some behaviour when user aborts VE loading with escape
* Pass 'noPrompt' to #tryTeardown
* #loadFail gets triggered by the data promise being aborted,
  so if 'activating' has been cleared at this point, don't
  prompt about there being load error.
* Retry/cancel dialog assumed you were coming from a wikitext
  editor. Rewrite the logic to handle teardown the target if
  the user is coming from read mode.

Change-Id: If9e5d1fbf00f8359f4d06fe7fc3064cc7e349bc9
2022-02-11 00:15:35 +01:00
Bartosz Dziewoński a2390efbf4 Re-apply "Re-duplicate deduplicated TemplateStyles"
Previous attempt in 005a8d24ef,
reverted in 3c1d167b33.

The deduplicateStyles() function lacked a check for fosterable
positions, which caused T299767. This is now fixed.

Also added tests.

Bug: T287675
Bug: T299251
Change-Id: I0d22be9b66d26d09373cee63dd6ce52c1659e62d
2022-01-28 02:08:09 +01:00
jenkins-bot 1f8e56a333 Merge "Move copyright warning message parsing from RL module to API" 2022-01-26 11:07:03 +00:00
Ed Sanders 312c35077f VE-MW: Consistently use target/surface $scrollContainer to set/get scrollTop
As in Idd97d9e6d3 in ve-core.

Bug: T299841
Change-Id: I728a723cbbb1d992e0e573800298784ba385882e
2022-01-25 22:28:10 +00:00
Ed Sanders d1aaf3d451 Include heading margin when running scrollToHeading
This avoids the heading text ending up uncomfortably close
to the toolbar.

Change-Id: Iddd5fea5d75902ed093d3e9839b63a2a3c480775
2022-01-25 16:04:12 +00:00
Ed Sanders c8c9424888 Use new *SelectableContentOffset method when setting section selection
We introduced these methods in Idc0cccbe but didn't update this
logic in MW.

This prevents focus being put inside an image caption if the section
starts with a block image.

Change-Id: I4cc1a116c1dcc8e1c642359ea768b6f5265a061b
2022-01-25 16:04:12 +00:00
Bartosz Dziewoński 8080bd2f5d Move copyright warning message parsing from RL module to API
Parsing it in the RL module caused the module cache key to depend
on the parse, which is slow and makes ResourceLoader sad. The usual
approach for solving this (I206bb05d28) can't be used, because of
how EditPage generates this message.

Bonus #1:
Generate the message for the correct page title. MediaWiki allows
customizing it per-namespace or even per-title, which we haven't
supported before.

Bonus #2:
Pass the context for message localisation (depends on I5f7c77970d).
EditPage::getCopyrightWarning() was parsing messages without the
interface flag, causing some needless processing elsewhere.

Depends-On: I5f7c77970d0525c0ff394f8bd72c69dcb5d00623
Bug: T298822
Change-Id: Iaa626f0e6379a5a370f9c465cea8528bb5bde7f7
2022-01-24 22:19:04 +00:00
jenkins-bot 43b2b3de95 Merge "Revert "Re-duplicate deduplicated TemplateStyles"" 2022-01-21 21:29:41 +00:00
Bartosz Dziewoński 3c1d167b33 Revert "Re-duplicate deduplicated TemplateStyles"
This reverts commit 005a8d24ef.

Reason for revert: Causes page corruption

Bug: T287675
Bug: T299251
Bug: T299767
Change-Id: Ib6b88114f6bdcd11ada0daf8ef6ec088569c88a6
2022-01-21 21:10:27 +00:00
jenkins-bot 8d119a4356 Merge "Re-duplicate deduplicated TemplateStyles" 2022-01-16 00:24:31 +00:00
Bartosz Dziewoński 005a8d24ef Re-duplicate deduplicated TemplateStyles
Bug: T287675
Bug: T299251
Change-Id: I7711c30131cb441f84b3e2137983f0ba2a50b46f
2022-01-14 21:35:11 +00:00
Ed Sanders c0f3fc3a78 Pass visibleSection & visibleSectionOffset to target
* Find the first section below the top of the viewport
  (usually visible) and measure its offset.
* After loading the editor, ensure this heading is still
  at the same position on the page.

Bug: T296910
Change-Id: I9a05ea74ba3c19a4a91ddc1bc0afe311851c53e6
2022-01-11 20:39:27 +00:00
jenkins-bot e1b9e6a98e Merge "Watchlist API update: Call correct method" 2022-01-11 18:41:49 +00:00
Ed Sanders aea22d546e Watchlist API update: Call correct method
We changed the arguments, but not the function name.

Change-Id: Ic7b36f666ead57bc62aa6e40e148821ea267ee80
2022-01-11 18:21:12 +00:00
Ed Sanders 6c471c5b1e Introduce ArticleTarget#afterSurfaceReady
This method should be called once the surface is visible
and ready to be focused.

Change-Id: I43a1d9cabd59181d2beab8f4a29700d031903c22
2022-01-11 03:33:04 +00:00
Ed Sanders 93df71af77 ArticleTarget#scrollToHeading fixes
* Use this.getElementWindow
* Use this.surface.padding to avoid race condition
  when the toolbar hasn't fully rendered yet.

Change-Id: I055b1d9458d73e435ede6096941a3e72c9c1ce74
2022-01-11 03:32:52 +00:00
jenkins-bot b92f414e23 Merge "Use new wikipage.watchlistChange hook" 2022-01-10 22:42:17 +00:00
Ed Sanders 3800daf354 Use new wikipage.watchlistChange hook
Bug: T294254
Depends-On: I88af8585e8fc75f77ebef867d267199aeb2c6592
Change-Id: I60400124976093060b3b5478c6d7d9e6844cc217
2022-01-10 23:16:41 +01:00
mewoph 93d54c701b Check for saveDialog in ve.init.mw.DesktopArticleTarget.saveComplete
In case the save is triggered without the save dialog (for example, when a null edit is made during suggested edits task in GrowthExperiments)

Bug: T298552
Change-Id: Id49b967cfa52d33848e9c911086000fa4501fa7f
2022-01-04 13:35:21 -08:00
Ed Sanders 2098292318 Use no-jquery/no-html to warn against writing HTML strings to the DOM
This forces us to comment when we are doing this deliberately.

Change-Id: Ide1bcb64f6c6076b48e88f1f27045bd93392f8a0
2021-12-16 01:28:42 +00:00
Ed Sanders 4d13a4f4ed eslint: Enable no-jquery/no-append-html
Prevents accidentally treating plain text or user input
as HTML, which could be an XSS vulnerability.

Change-Id: Id4af48447a0907962a57340cb60aca08df9cc505
2021-12-16 02:04:11 +01:00
Ed Sanders 5c0344aeda Use new select[First|Last]SelectableContentOffset methods
* Make ve.ce.MWBlockImageNode autofocus=false, remove
  unused transition property
* Remove ignoreChildren from ve.dm.MWBlockImageNode
  based on new definition
* Remove tests which assert that deleting in a list next
  to a block image always de-indents. If this is desired
  behaviour it should be fixed without reference to
  ignoreChildren.

Bug: T295905
Depends-On: Idc0cccbe73d1b49d07b60c14a192a40f47d64608
Change-Id: Ib79a070f5d36dbe7742fa0760f8cdf55fe3046ed
2021-12-08 15:53:35 +00:00
Ed Sanders 86c405a2e1 Prefere ve.extendObject over $.extend
Change-Id: I37fef45701653cef08de9ec699865aa4fdf477bc
2021-11-15 21:30:19 +00:00
Ed Sanders 3801aa1bac Move var declarations inline
Change-Id: I12639c515e33b3d9e7a819581b5022ea42fd7046
2021-10-13 14:02:31 +01:00
Bartosz Dziewoński 33bbd5bcf2 Remove duplicate load error handling code
Load errors are already handled in the MobileFrontend part of the
mobile visual editor, by this code:

66c55573e5/src/mobile.init/editor.js (L375-L387)

    // Wait for the data to load before we show the editor overlay
    overlay.getLoadingPromise().then( function () {
    	...
    }, function ( error, apiResponse ) {
    	// Could not load the editor.
(1) 	overlayManager.router.back();
    	if ( error.show ) {
    		// Probably a blockMessageDrawer returned because the user is blocked.
    		document.body.appendChild( error.$el[ 0 ] );
    		error.show();
    	} else if ( apiResponse ) {
(2) 		mw.notify( editorOptions.api.getErrorMessage( apiResponse ) );
    	} else {
    		mw.notify( mw.msg( 'mobile-frontend-editor-error-loading' ) );
    	}
    } );

Compared to our code:

    ve.init.mw.MobileArticleTarget.prototype.loadFail = function ( code, errorDetails ) {
    	...
(1) 	this.overlay.onExitClick( $.Event() );
(2) 	mw.notify( this.extractErrorMessages( errorDetails ) );
    };

The lines marked with (1) and (2) do basically the same thing. And
the function parameters "error, apiResponse" and "code, errorDetails"
are actually the same objects, just with confusingly different names.

This causes the popup with error message to appears twice (although it
isn't too obvious, since the two popups appear in the same place, so
only one is visible), and also causes bogus data to be sent in event
logging (T237063).

Bug: T237063
Change-Id: I7fe7a944707fe585251ce9e16bbb78ccd123a7ed
2021-10-11 23:20:43 +02:00
Thiemo Kreuz a625669380 Add missing @fires documentation tags
Change-Id: I0c9b2aa827a6806004480b642c23f320b190b6ab
2021-09-30 15:50:33 +00:00
jenkins-bot 4478eb15d8 Merge "Update and fix all @param config and @cfg documentation" 2021-09-16 20:09:15 +00:00
Thiemo Kreuz aa556e3ef8 Update and fix all @param config and @cfg documentation
I tried to review all of them. Some of the changes I did:
* Make sure the `config` parameter is not marked as optional
  when it is not.
* Make sure default values are mentioned.
* List individual `@cfg` options when it makes sense.

Note I don't list all options a class could accept (e.g. via all
its parent classes and mixins). That's too much. Instead I checked
how a class is actually used and list only these options.

Even then I don't list everything, e.g. unspecific options
like "classes" that can be used pretty much everywhere.

Change-Id: Idf4fbe1dc3608ace277df9e385f2f140df3a2f50
2021-09-12 12:35:27 +00:00
Thiemo Kreuz e7df422495 Comment & compact targetLinksToNewWindow related syntax
Change-Id: Ifc18519d0d811c5c3fa64b1183f4eb94afd0acad
2021-09-03 14:57:29 +02:00
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