Commit graph

98 commits

Author SHA1 Message Date
Ed Sanders 37b81b5ba4 ArticleTarget: Always reload the page after save on non-view page
This is currently only handled in DesktopArticleTarget in teardown,
which happens after we've wasted time trying to update the page.

Also ensure we always reload on non-view pages on MobileArticleTarget
for other types of teardown (e.g. quitting the editor).

Change-Id: I7fb352fcacc8727bb113115e98af38a3940a8f9c
2022-05-13 22:53:02 +01:00
Ed Sanders ae58439c41 Upstream teardown of saveDialog from DesktopArticleTarget to ArticleTarget
Change-Id: I2e28f604d7e34fed15d9b74b6723347e3a17ce9e
2022-05-13 22:52:40 +01:00
Ed Sanders be2fc6c814 Upstream isViewPage from DesktopArticleTarget to ArticleTarget
Change-Id: Ic3839d9d70d6d4127fe2cd9bc01da799027fed3c
2022-05-13 22:47:06 +01:00
Ed Sanders b428b296e5 ArticleTarget: Ensure dataPromise rejects when switching fails
Requires switchToFallbackWikitextEditor to return a promise.

We can now pass dataPromise to the progress bar shown when
switching editors, so it hides if the switch fails.

Also fix logic for when a failed load is not retried.

Bug: T306763
Change-Id: I752ca505e7957b392202d44455b1e21b6e50fa63
2022-04-26 16:32:52 +01:00
Bartosz Dziewoński c8b0f17ce6 Store copyright message in auto-save data
Bug: T305225
Change-Id: Ie70587393715a461509dac6192d033a05c894f96
2022-04-07 23:03:37 +00:00
Ed Sanders be2a1ccf62 Respect useeditwarning user option when tearing down target
Also invert logic and rename variables to make tests in tryTeardown
and switchToWikitextSection identical.

Bug: T294463
Change-Id: Icb86a676c3f315e4a3d229f46eb383dcd7959973
2022-03-23 14:55:13 +00:00
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
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
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 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 ca6ed21835 Always scroll to top when loading VE source mode
Change-Id: Ibfbb241f523fbdfcf6eb9fd1aeaa0e13782586aa
2022-02-16 15:17:19 +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
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
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
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
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 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
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
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
Ed Sanders 857014fae9 Support watchlist expiry
Bug: T251348
Change-Id: I017a54784c758c5e97fb640721bd456adc0fbab5
2021-06-08 20:14:45 +00:00
jenkins-bot 30bf60cb87 Merge "ArticleTarget: Always set fromEditedState when preloaded is true" 2021-05-25 20:24:29 +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
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
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
jenkins-bot 54f61eb54c Merge "Update save failure logging for EditAttemptStep schema, simplify code" 2021-02-01 18:28:10 +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
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
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 27e19025a4 Fix cancelled browser-back on desktop
Bug: T263464
Change-Id: I808f7effffca5fbe9d8416d447df61dde57776c3
2020-09-21 16:23:18 +01:00
Ed Sanders 7a61992fbb Store revid as undefined when document doesn't exist (revid=0)
Bug: T262838
Change-Id: I9ac1815e281544916ea9aded8e80039245c9d871
2020-09-16 11:13:38 +00:00
jenkins-bot b55ba6f1dc Merge "Also check for revid conflict when RESTBase says page doesn't exist" 2020-07-27 21:29:50 +00:00
David Lynch c190fab8ea Always rebuild category list from Parsoid data on surfaceReady
Rebuild the category list from the data we got from the API. This makes
it work regardless of whether we came here from activating on an
existing page, switching from source mode, or loading via an edit URL.

Because Parsoid doesn't include redlink status on the <link>s it
represents the categories as, we do have to manually update those
styles.

Bug: T251398
Change-Id: Iaaef3223816269bba1371fbb07956119a120c1ca
2020-07-17 10:24:00 -05:00
Bartosz Dziewoński 36bd09c429 Also check for revid conflict when RESTBase says page doesn't exist
There used to be similar code here, but it was removed in 2015 in
85b745666f because it wasn't correct in
some cases. Restore it and instead separately check for those cases.

Bug: T257124
Change-Id: Id4a17266111d064805aa0ca865182bb2f4b019eb
2020-07-05 19:42:12 +02:00