Commit graph

7639 commits

Author SHA1 Message Date
jenkins-bot f7a61e3f42 Merge "Allow switching in welcome dialog on mobile" 2020-02-03 23:57:18 +00:00
Bartosz Dziewoński f525f63b03 Remove hack to avoid iOS Safari menu bar area tap stealing
Explanation of what this code was for: T227628#5339392

As noted on that task, our behavior is actually unintuitive and
distracting, and iOS Safari limitations prevent us from doing it
better.

This reverts commit 600e369347.

Bug: T227628
Change-Id: Id1a5eebd06e4218e3e102165c60791999293d273
2020-01-31 21:22:23 +00:00
Máté Szabó ff4f382322 Use autogenerated parameter info for templates without TemplateData
When a template does not have user-provided TemplateData documentation,
the TemplateData API falls back to extracting possible parameters from the raw wikitext
to generate an API response with a list of potential parameters. However, it also
sets the "notemplatedata" field in the response, causing the VisualEditor to think
the response contains no useful information and ignore it. This appears to have been
an unintended side-effect of I97a1bfc9f9ead082a673a91b9d2053630a90309c.

This patch ensures that the VisualEditor will correctly consider such responses from
TemplateData by modifying ve.dm.MWTransclusionModel to check if the response contains
a parameter map. Some unit tests were added for the class to verify this behavior.

Bug: T243868
Change-Id: I72005880d9301a53224473900efe2917379e8708
2020-01-31 13:43:56 +01:00
David Lynch d85d30f9b3 Tag VE edits from the client-side
This opens up the API so that other tools can use it without being
forced to tag those edits as being from VE.

Also, document that tags is a working parameter that can be passed
through to the edit API.

Bug: T242184
Change-Id: I2c1d0f8d69bc03e5c1877c790247e165f160e966
2020-01-29 21:55:07 -08:00
Bartosz Dziewoński 4fc5d964db ArticleTargetLoader: Fix loading visual diffs when no RESTBase
When mw.libs.ve.diffLoader#fetchRevision was calling this method, we
were accidentally making no query at all if RESTBase wasn't in use.

Change-Id: Ia98343aa1ba7f4f3be0c1a8ee5864653c429fb82
2020-01-29 11:15:18 -08:00
Bartosz Dziewoński 3458d8a27e Don't offer switching to VE if it's disabled in preferences
In many places we check whether VE is available before doing things
(init.isVisualAvailable). This variable includes checks for whether
the page is wikitext, etc. Now it will also include checking whether
VE is enabled in user preferences.

In almost all places where init.isVisualAvailable is used, we were
already also checking if VE is enabled, so this doesn't affect the
behavior. But notably, we didn't do it when showing the option to
switch to VE in the welcome dialog and in the toolbar, causing T243723.

Changing init.isVisualAvailable this way makes it consistent with
init.isWikitextAvailable, which has always included a checking whether
NWE is enabled in user preferences.

Bug: T243723
Change-Id: Ie174bc3f16bceb29cb155b9223e0acef70167fd6
2020-01-28 16:26:03 -08:00
Bartosz Dziewoński 0791dd352d Fix tab initialization if NWE is enabled but VE is disabled
Bug: T178976
Change-Id: I16b7ef564e8c28c0c583c724ffb482b2c9fcbadb
2020-01-28 16:26:03 -08:00
Bartosz Dziewoński 5c8d04afdb Disallow switching in NWE welcome dialog if VE should be unavailable
When NWE is enabled but VE is supposed to be unavailable on the page
(e.g. in talk namespaces), do not show the option to switch to VE in
the welcome dialog.

This is relevant if new users use NWE, due to config like below
(we use this on WMF Office wiki):

    $wgDefaultUserOptions['visualeditor-newwikitext'] = true;

Change-Id: Iee8c3d3604a13dcd20efa713e49461ba9b885749
2020-01-28 16:26:03 -08:00
Bartosz Dziewoński 36c2cb90ab Allow switching in welcome dialog on mobile
This code works perfectly on mobile now, I believe change
4fb17205b6 fixed that.

Note that the dialog is currently never shown due to the override
in MobileArticleTarget, but I tested after removing it.

Change-Id: I305a01fc78366a3d2d13662e6d71711864e0dffc
2020-01-28 16:25:53 -08:00
Ed Sanders 62145b11e6 Fix variable scope in ArticleTargetSaver
Also fix docs

Change-Id: Ida47968c995166b1dca36fc9fe28fac374010564
2020-01-24 15:32:46 -08:00
jenkins-bot 9e6a40a827 Merge "Use mw.Api#getErrorMessage instead of custom handling" 2020-01-10 14:22:14 +00:00
jenkins-bot bc2204b6c0 Merge "Add handling for mw:DisplaySpace" 2020-01-08 22:26:08 +00:00
James D. Forrester 2c77e88d2c doc: Bump copyright year for 2020
Change-Id: I30539877543dc2a57bd1428a00d10ac46d8fc294
2020-01-08 09:13:24 -08:00
Bartosz Dziewoński 8341f96217 Add handling for mw:DisplaySpace
It's supposed to be non-editable but deletable text, like mw:Entity.
We decided to handle them this way in 2015 but never implemented it
(T94509). Currently, accidentally editing text inside of
mw:DisplaySpace node causes the changes to be lost when saving.

Bug: T241906
Change-Id: I78a0cc7a75061a7eefb8b677898b5756326615d6
2020-01-08 01:40:12 +01:00
Ed Sanders edacc5bf65 MobileArticleTarget: Find DOM nodes after early return
No point running this jQuery search if we are about to return

Change-Id: I2240d4a15abbf7deb9b1f77154f299bd0d97ae18
2019-12-20 15:30:43 +00:00
James D. Forrester 1f74985894 Update VE core submodule to master (e032fa161)
New changes:
479b50059 Localisation updates from https://translatewiki.net.
c595d8ab0 Metion task related to Firefox hack
0a160fac2 Don't trust selections from the server
d796f3db5 rebaser: Update dependencies
b097dfaad ve.dm.Transaction: Don't translate offsets inside annotate-only replacements
eadee0343 FragmentWindow: Replace previousSelection with initialFragment
561e88158 Use ve.dm.example.imgSrc everywhere
d1dceab31 DesktopContext: Remove onModelSelect event
85947ac55 Pause synchronizer while staging
9a4dd169d Catch various out-of-bounds exceptions
341114afc Remove CE HTML from DM html test fixture
5d3a673e0 ve.ce.Document test: Add src to test image
182ac338e Evalutate fragment selection after staging
e032fa161 rebaser: Drop document opacity while paused

Change-Id: Id551ee2e6510610b8f2e12cf77ce3c8429700872
2019-12-20 12:15:32 +00:00
Ed Sanders a725643aa1 ArticleTargetLoader: Check apiXhr exists
Change-Id: I891d642728094af9c5a550a814d322822436a9e5
2019-12-16 09:53:57 +00:00
Bartosz Dziewoński 5f1c68945d Use mw.Api#getErrorMessage instead of custom handling
Bug: T240519
Depends-On: Ie18666b41f4aff1ab4bcf93f9df6e3000ac7b500
Change-Id: I69d9432162f195dcfe9470485b549a1b007617ff
2019-12-14 17:01:35 +00:00
Ed Sanders e6bb954edd Don't bother fetching metadata for diffs
Only HTML content is used for building diffs

Change-Id: I4f9af162792c27e7771838b6294c106bc9dc359a
2019-12-13 18:18:36 +00:00
jenkins-bot f213e370f7 Merge "Update VE core submodule to master (b1617fdca)" 2019-12-13 17:22:33 +00:00
James D. Forrester 60721584fe Update VE core submodule to master (b1617fdca)
New changes:
d4a21a7e7 Localisation updates from https://translatewiki.net.
0e99d907a Update OOUI to v0.36.0
c422b8313 Localisation updates from https://translatewiki.net.
b1617fdca Update OOUI to v0.36.1

Local changes:
* Rename onLookupMenuItemChoose → onLookupMenuChoose
  (deprecated in OOUI v0.36.0)

Change-Id: If66f3f16c0e882e99b0d768a3cf4170d24e7093e
2019-12-13 18:06:59 +01:00
jenkins-bot cee6e3e6a9 Merge "ve.ui.MWEducationPopupTool: Respect default preferences for anon users" 2019-12-13 16:23:24 +00:00
jenkins-bot bb94043f34 Merge "ve.init.mw.ArticleTargetSaver: Fix exception when handling errors" 2019-12-13 16:14:15 +00:00
jenkins-bot f3833f4906 Merge "ve.init.mw.DesktopArticleTarget: Remove dead error handling code" 2019-12-13 16:14:12 +00:00
jenkins-bot af333be75f Merge "ve.init.mw.MobileArticleTarget: Don't close overlay when showing error" 2019-12-13 16:14:09 +00:00
jenkins-bot 95a46f1666 Merge "Exactly match collapsible logic of jquery.makeCollapsible" 2019-12-13 15:42:46 +00:00
jenkins-bot 7c745c32c2 Merge "ve.init.mw.ArticleTargetLoader: Fix promises to be abortable again" 2019-12-13 15:41:01 +00:00
Ed Sanders 1d3386b8ac Wikitext links: File/Category support
Change-Id: I282141c23738ca6fa1e634da9bf02912032e12ff
2019-12-12 01:34:40 +00:00
Ed Sanders a007781e81 Support wikitext link editing
Depends-On: I3eb2d5ee0da52942db1de75ef9f8b0ae2632657e
Change-Id: I7ad61899a221a198a06e206614d907a331861dbb
2019-12-12 02:33:35 +01:00
Bartosz Dziewoński f41f499a2e ve.init.mw.ArticleTargetSaver: Fix exception when handling errors
TypeError: Cannot read property 'onCacheKeyFail' of undefined

(found when working on Ice92fafb1f546510dab28e3f8aa7d2280668965a)

Change-Id: I2a731cb273401074e65f9283c1f629dbdb272002
2019-12-11 05:55:59 +01:00
Bartosz Dziewoński a2b556ed56 ve.init.mw.DesktopArticleTarget: Remove dead error handling code
The .statusText and .status properties belong to the XMLHttpRequest
object, and are not present on the API response data object. I think
these checks were left over "just in case" when this code was ported
to use mw.Api instead of XMLHttpRequest directly.

MediaWiki API should never return just 'error' as the error code.

Change-Id: Iac6f721881b9405919d3397df6606e54f182bc59
2019-12-11 05:55:25 +01:00
Bartosz Dziewoński ef8ff1723a ve.init.mw.MobileArticleTarget: Don't close overlay when showing error
We've just displayed an error message in it, so don't close it.

I'm not sure if this code matters at all though. Usually when
there's an error during loading, code in MobileFrontend will close
the overlay and display an error message in a different way, so our
message won't be visible to the user. But maybe there's some case
I'm missing, and it's harmless. Closing the overlay was messing with
the MobileFrontend code though.

(found when working on I5146b726c5ce213992febb23f24c5937db0b9bfe)

Change-Id: Id1ea44d7bf6ef0f4fc0285e9e606dd415ed0a947
2019-12-11 05:55:25 +01:00
Bartosz Dziewoński 571bec41d1 ve.init.mw.ArticleTargetLoader: Fix promises to be abortable again
Cancelling the loading of the editor should stop the network requests.

Broken in 0498c03191. Forwarding the
'abort' function manually is the worst.

(found when working on I5146b726c5ce213992febb23f24c5937db0b9bfe)

Change-Id: Ifa7c11a433cb5ed3545fa2f3d9fae2800bcae7d7
2019-12-11 01:27:33 +01:00
jenkins-bot 90bbfb5683 Merge "ApiVisualEditorEdit: Simplify diff handling a bit more!" 2019-12-02 11:18:52 +00:00
jenkins-bot 9dbd6ce391 Merge "MWSaveDialog: Fix error handling for diffs" 2019-12-02 11:18:49 +00:00
jenkins-bot 51ed492d0b Merge "Don't reject activatingDeferred on loadFail" 2019-11-28 19:47:43 +00:00
Bartosz Dziewoński 9779336403 ApiVisualEditorEdit: Simplify diff handling a bit more!
Dealing with `result: 'nochanges'` is annoying. Just return an empty
diff to indicate no changes.

Change-Id: I192caa67ec85224500a6919efd370cf7b5c1c592
2019-11-24 09:51:54 +00:00
Bartosz Dziewoński 092d0c332b MWSaveDialog: Fix error handling for diffs
In case of HTTP errors we'd crash and show no message.

Change-Id: Ideeff4ce75e7ca82ce63bf7ede6dff03eaa1c5d7
2019-11-24 09:51:43 +00:00
Ed Sanders e1db46612c Paste plaintext if conversion fails
Change-Id: I3891888f5d1d1de0c47e7bbcb1897d23b49bfa00
Depends-On: I3e9d5e167274440a424a47c266d8af67574c70b5
2019-11-24 09:37:40 +00:00
jenkins-bot e9644ab918 Merge "Set tab-size to 4 in TempWikitextEditorWidget" 2019-11-20 17:27:03 +00:00
Ed Sanders 02d6709b1e Set tab-size to 4 in TempWikitextEditorWidget
Depends-On: Ic4a5ab803c89b3671f452579bca0da08b779bdfe
Change-Id: If6b87b9a86031b846a03d67cd8e05afd7ec0a888
2019-11-20 12:11:43 -05:00
jenkins-bot a1b6c47962 Merge "Localize some hardcoded English error messages" 2019-11-19 21:18:04 +00:00
jenkins-bot 924e579c19 Merge "ArticleTargetSaver: Fix handling for data.result !== 'success'" 2019-11-19 21:18:01 +00:00
Bartosz Dziewoński a8ab487876 Localize some hardcoded English error messages
Bug: T227325
Change-Id: I5a43b34a4492c20cab4b4ef3eceafaf669e89730
2019-11-19 15:23:58 -05:00
Bartosz Dziewoński 1dc642ee57 ArticleTargetSaver: Fix handling for data.result !== 'success'
The comment here seems to be wrong, as far as I can tell, this
case can only happen when viewing a diff with no changes
(`data.result === 'nochanges'`) or saving an edit and getting
a captcha (`data.result === 'error'`).

The handling here, added in the recent refactor
b0f4b4c94e, causes both of these
cases to behave wrong (displaying the error message, instead of
empty diff / captcha form).

Change-Id: I305e8ca9ff769c229a93d5fb3307e545a0227f2f
2019-11-19 14:23:58 -05:00
jenkins-bot 8a65008317 Merge "EditAttemptStep: Allow session ID override from query string or mw.config" 2019-11-19 14:19:44 +00:00
Roan Kattouw 0f97e1dce9 EditAttemptStep: Allow session ID override from query string or mw.config
Similar to WikiEditor, allow the editing_session_id value to be
overriden through the editingStatsId query parameter. Also allow
server-side code to override the session ID by setting
wgWMESchemaEditAttemptStepSessionId in mw.config.

Only apply the override to the first session. Once a second init event
happens, discard the overridden editing_session_id and generate a fresh
one.

Bug: T238249
Change-Id: I4ede70f310a35c95b6eb9cc34cfcf2baa77e69ee
2019-11-18 17:18:10 -08:00
jenkins-bot 35f2093c62 Merge "Move more code to ArticleTargetSaver" 2019-11-14 21:26:24 +00:00
Ed Sanders 687882f596 Don't reject activatingDeferred on loadFail
loadFail can result in a retry, in which case it isn't
approraite to reject this promise. Also many of the code
paths call 'tryTeardown' which itself will reject the promise.

Bug: T238332
Change-Id: I366662847304d8ecf79d5899b2804dded67ee999
2019-11-14 15:23:46 +00:00
Ed Sanders b0f4b4c94e Move more code to ArticleTargetSaver
* Add a postWikitext method and split out postContent
  from postHtml
* Move saveSuccess handling into postContent promise
* Connect promise directly to saveComplete instead
* Pass whole response.visualeditoredit object, instead
  of splitting into variadic arguments for saveComplete.
* [DEPRECATION] Make serialize return the postHtml promise
  and deprecate passing a callback.

Change-Id: I905737515578000b2b87214c92e8b9fe9e82f6b7
2019-11-14 14:34:22 +00:00
Bartosz Dziewoński c8fa50c3b2 Exactly match collapsible logic of jquery.makeCollapsible
Bug: T236247
Change-Id: Iaf8e8515585989fd8ca64ffd33b02399a69278b4
2019-11-13 23:26:08 +00:00
Ed Sanders 6caa4601aa Generate internal links locally
Bug: T147230
Change-Id: Ib154ffebb601dc76c708f2d8a8315cbf98ff6da1
2019-11-12 20:36:00 +00:00
jenkins-bot 84663fab0f Merge "Add missing FragmentInspector tests to MW" 2019-11-12 15:27:39 +00:00
jenkins-bot 206c440a4e Merge "tests: Have MWDummyTarget create the correct surface type" 2019-11-12 15:26:41 +00:00
Ed Sanders 545c6f1301 Add missing FragmentInspector tests to MW
Requires unregistering MWLinkAnnotationInspector

Bonus: Remove unnecessary list of unregsiters as
teardownOverrides is run on init.

Change-Id: I3e36ab7736cc8479ab53f40d2eb24c0fa15d3dc0
2019-11-12 13:52:35 +00:00
Ed Sanders 3542799ab4 tests: Have MWDummyTarget create the correct surface type
Change-Id: I3cd025d726e9db56a2391ef52852d1cb2f4305a0
2019-11-11 20:22:33 +00:00
Ed Sanders 8d818d9ff0 Update VE core submodule to master (5b9ab1cfa)
New changes:
be8235e82 Localisation updates from https://translatewiki.net.
6f43a6c8d Remove MW-specific code for setting up section editing

Local changes:
* Bring in section editing logic from VE core
  Sets attachedRoot iff there is only one SectionNode in the whole document.

Change-Id: I15b5ebf3848482ef6df6d19114d26a1b1d4a3b13
2019-11-11 18:28:14 +00:00
jenkins-bot ef4c7a856b Merge "Follow-up I83b98e41: Always sanitize when using plain text paste in NWE" 2019-11-07 19:04:11 +00:00
Ed Sanders 737e9e82f5 Follow-up I83b98e41: Always sanitize when using plain text paste in NWE
Bug: T201561
Change-Id: I0405923b2ebd1b73119d29cb6091f53b8cddc84d
2019-11-07 14:49:57 +00:00
Bartosz Dziewoński a53c02f2c4 ve.init.mw.ArticleTarget: Fix error handling in #prepareCacheKey
If the paction=serializeforcache request fails, we were erroneously
converting it to a successful result with no value, which later causes
an exception, because since 381b58585c
other code expects the result to an an object.

The bug was introduced in 2015 in 07001001be,
but until that recent change it would only cause a 'badcachekey'
error, which was handled correctly later.

Change-Id: Ie1ffc8c3e616a7d296f2186fb17eaf039971a44f
2019-11-07 01:36:41 +01:00
jenkins-bot 36bde9d1c6 Merge "Config value for X-Parsoid-Variant" 2019-11-07 00:00:40 +00:00
Ed Sanders d71522c463 Set the plain text 'pasteSpecial' flag when using plain text paste in NWE
This means the multiple lines of html (e.g. '<p>a</p><p>b</p>') are
treated as plain text and only separated by one linebreak.

Bug: T201561
Change-Id: I83b98e41bfd92d1848557b58f961abdd0db26294
2019-11-06 19:11:58 +00:00
Ed Sanders 64be4b2a4b Update VE core submodule to master (2d0f0ec1f)
New changes:
18e32c6ed Simplify paste test runner
7d71154bd Properly support middle click paste

Local changes to use simplified paste tests runner

Bug: T157956
Depends-On: Id66bff4e41a36ed967a8cba2f6653bb26e7b4ea1
Change-Id: I0101e8bc079cd050bfbc65577a10e98213d5f00c
2019-11-06 10:31:38 -05:00
David Lynch 46e7b3ba19 Config value for X-Parsoid-Variant
Bug: T229074
Change-Id: Ib1403638b12ec5808f6b81bd114949043aa9ac2e
2019-11-05 10:56:10 -06:00
jenkins-bot 26ebdd0796 Merge "ve.init.mw.MobileArticleTarget: Improve toolbar scrolling behavior on iOS 13" 2019-11-05 14:26:27 +00:00
Ed Sanders 4c86c54e46 Replace $.when with ve.promiseAll
Add linting guards, except in preinit

Change-Id: I999641eddb0e0f5b112ec2259dbafc1e816e3437
2019-11-04 22:06:54 +08:00
Ed Sanders cc217cef29 Avoid use of $.parseHTML in model
Change-Id: Ide671e7459b14bfbb7385261221c2edd17bd1153
2019-11-04 13:23:12 +00:00
Ed Sanders 2d4234fac8 Remove jQuery from ve.dm.MWLanguageVariantNode
Change-Id: I849cb6756171aa7bba43dc390cbd390b323328d2
2019-11-02 16:28:32 +00:00
David Chan 22098d6b16 Convert $.Deferred() to ve.createDeferred(), except in preinit
Follow-up to a8e07e026dea4f54241d1dbb6b7bcdbd8c670db2 in core.

Change-Id: I09333adb4876c6e584a4a6b6a1628227c4cd2616
2019-11-02 13:06:28 +08:00
jenkins-bot b00787b572 Merge "Factor out save logic into ArticleTargetSaver" 2019-11-02 01:16:18 +00:00
Ed Sanders ffa3742ce1 build: Update linters
Change-Id: I03d1a8e63b730ad98ec07ad5f630ba82698de5be
2019-11-01 16:20:22 +00:00
Ed Sanders 381b58585c Factor out save logic into ArticleTargetSaver
Change-Id: I63fa04598e0d703fe1ba715c9c5a0abbb0d7ba5b
2019-11-01 15:45:27 +00:00
Bartosz Dziewoński 00eb79d4d7 Revert "Parse relative hrefs on image nodes like on regular links"
This reverts commit 6037fefbe0.
This reverts commit da9b6fffbd.

Bug: T237040
Change-Id: Id6ea5784512e4d4c3cb00927b859d713c3814f89
2019-10-31 22:40:42 +01:00
jenkins-bot f24c823212 Merge "Expand collapsible blocks in editor, like we do with collapsible tables" 2019-10-31 16:27:45 +00:00
Bartosz Dziewoński 95f0d5f428 ve.init.mw.MobileArticleTarget: Improve toolbar scrolling behavior on iOS 13
With this patch, the toolbar slides into place place nicely after
scrolling again, but it still occasionally flickers during the scroll.

* window.innerHeight is now smaller or something, and we have to
  twiddle the scroll position by a larger value.
* document.body.scrollTop no longer works for setting or getting the
  scroll position, so use different methods.
* requestAnimationFrame() now generates an insufficient delay to make
  scrolling happen, so use setTimeout() instead. We actually have to
  add a nonzero delay there, otherwise the toolbar sometimes doesn't
  animate like it should or flashes in random places on the screen.
  This delay is bad because the user can't start scrolling again
  during that time, but I think we can live with that.

Bug: T233470
Change-Id: I6c40ee8ce5994e12eadb085bbffd120ef160d4ee
2019-10-31 16:55:58 +01:00
Ed Sanders c83d129f6a Expand collapsible blocks in editor, like we do with collapsible tables
Bug: T236247
Change-Id: I6389d2fbb4a5a5d58bfb08f38bd4c598e20c7aaa
2019-10-31 03:18:34 +01:00
Ed Sanders 1bb72f0bb5 Replace deprecated easy-deflate.deflate with mediawiki.deflate
Change-Id: I5c77d4818074fd3dc937d7688d449952b92ee358
2019-10-30 19:13:47 +00:00
Ed Sanders 4da31e7c9e Update VE core submodule to master (3075d3f8c)
New changes:
4af3f84f7 Mark surface as "showAsDeactivated" when opening a window
79eb0e4e5 ve.ce.Surface: Guard against focusing a un-initialized surface
4124c275e [BREAKING CHANGE] ve.ui.TargetWidget: Construct a real target inside the widget

Local changes:
* Use new target widget
* Remove calls to deprecated methods
* 'surfaceReady' event was upstreamed

Bug: T236400
Change-Id: I765d657c172d96c3b2e2ae5998083e4926a31f15
2019-10-25 17:16:17 +02:00
Ed Sanders b345ae203b Fix documentation position
Change-Id: I8e1045f38e0cca3a937a5e2a07b1db820f64bee1
2019-10-24 14:31:38 +01:00
Bartosz Dziewoński 4086de5a9a ve.ui.MWEducationPopupTool: Respect default preferences for anon users
Bug: T231762
Change-Id: I05dccf79becab9487ee2a67c4970c938d52e25d7
2019-10-22 20:02:21 +02:00
jenkins-bot e4efbe2a46 Merge "ve.init.mw.MobileArticleTarget: Remove error handling hacks for MobileFrontend" 2019-10-22 15:42:32 +00:00
Bartosz Dziewoński f3dfd98e55 Don't retry when etag is undefined because the page doesn't exist
Follow-up to 5d1a67757a.

Bug: T233320
Change-Id: Ice27187862dde75c69bbdb666c0981fce94249ba
2019-10-21 19:21:59 +00:00
Bartosz Dziewoński e82f5ccf02 ve.init.mw.MobileArticleTarget: Remove error handling hacks for MobileFrontend
As of commit c65ed0e7a8ac5f32a3a6e4cb2760dae03e4fca22 in MobileFrontend,
it uses errorformat=html queries (the same as we do), so we no longer
need to massage the responses to make it happy. The same commit also
turned parseSaveError() into a no-op, so we can remove that as well.

Change-Id: I4f0109ce120ebf94e5709d47d775a8178ce216fa
2019-10-21 20:26:10 +02:00
jenkins-bot 23213a17bd Merge "eslint: Add extra restrictions to ve-mw/dm/ folder" 2019-10-18 23:12:20 +00:00
Ed Sanders 837b01b534 Use consistent tag style when constructing nodes
Change-Id: I6a2d4d7d791a74b26770ef84d15659642401b0e7
2019-10-18 23:42:54 +01:00
Ed Sanders 2846144e96 eslint: Add extra restrictions to ve-mw/dm/ folder
Same as in core, follow up to I63fa04598e.

Change-Id: I4b63ef9d07205d91d6c20db310ab350f4160c3bc
2019-10-18 23:26:26 +01:00
jenkins-bot 416323bdca Merge "Fix media embeds which don't link to the file page" 2019-10-18 10:55:58 +00:00
Bartosz Dziewoński 6037fefbe0 Fix media embeds which don't link to the file page
Follow-up to da9b6fffbd.

Bug: T235707
Change-Id: Ie5a12bf274ae6178106f81a4c84686a88307c9fb
2019-10-17 22:12:58 +02:00
Bartosz Dziewoński 5d1a67757a Detect mangled etags from RESTBase and retry via MediaWiki API
Something is causing the 'ETag' headers produced by the "public"
RESTBase (queried directly from the client) to be mangled or lost.
My theory is that some proxy or browser extension is doing that.

When we detect a bad etag when fetching the page contents, discard
the result and try querying the "private" RESTBase via the MediaWiki
API (similar to what we do on private wikis, except there we talk
directly to Parsoid instead of RESTBase). After I463a84de63, that
returns the etag as part of the payload rather than HTTP headers,
and should pass unharmed through whatever is mangling the data.

Also compare and log the two etags.

Bug: T233320
Change-Id: I2ef0ca872597566f74b650aea71bf3f15747a6d7
2019-10-16 19:53:43 +02:00
jenkins-bot b15eea1cb0 Merge "Fix Vector wikitext surface padding overrides when using custom browser font-size" 2019-10-11 15:23:17 +00:00
jenkins-bot cc1bd58e83 Merge "Parse relative hrefs on image nodes like on regular links" 2019-10-11 15:22:29 +00:00
Bartosz Dziewoński 3f0f302577 Enforce that some files must not use the ve global
Previously, the ve-mw/init/ directory contained two kinds of files:
those that were used when initializing VE, and those that may be
loaded even if VE is not going to be initialized at all. The latter
kind must not use the `ve` global variable.

After moving those files to ve-mw/preinit/ we can enforce this with
.eslintrc.json in that directory. This would have prevented T228684.

(Technically they merely must not use `ve.init`, and may use `ve`,
but that's harder to enforce. We should instead move the few non-init
methods out of `ve`: now, track, trackSubscribe, trackSubscribeAll).

Also, group some files under ve-mw/init/: targets/ now (only)
contains ve.init.mw.Target and its subclasses, apiresponsecache/
now contains ve.init.mw.ApiResponseCache and its subclasses.

Bug: T228684
Change-Id: I945249a27f6a0fa10a432d5c5dc57bc7e0461fd8
2019-10-10 15:15:40 +00:00
jenkins-bot def3261c49 Merge "Fix linking to pages in media dialog/media context/internal link context" 2019-10-07 15:13:02 +00:00
Bartosz Dziewoński 55aec8f977 ve.ui.MWDefinedTransclusionContextItem: Fix handling of template names
The ...target.wt property contains the wikitext used to generate
the template name. It can contain trailing newlines (T234817) and
all kinds of funny wikitext syntax. Instead, use ...target.href,
which is the title of the page that is actually transcluded. Compare
the new code to ve.dm.MWTransclusionNode.prototype.getPartsList.

Additionally, fix some confusion about namespaces (treating template
names as titles in the main namespace). The template names in the
configuration page (visualeditor-template-tools-definition.json)
now support overriding namespaces in the same way as in wikitext.

Bug: T234817
Change-Id: I7c557d28e961d0b9117fc0380c65cdd42035ae96
2019-10-07 14:56:16 +02:00
Bartosz Dziewoński 7579f6eb1f Fix linking to pages in media dialog/media context/internal link context
If you had an image thumbnail for a file 'Foo?.png' on the page,
ve.ui.MWMediaContextItem and ve.ui.MWMediaDialog did not escape
the '?' when linking to it, which resulted in incorrect links.
Similarly, if you had an internal link to the page 'Foo?',
ve.ui.MWInternalLinkContextItem did not escape it.

Additionally, the links were always generated as if the wiki was
using short URLs, even when it is not (T233628).

The approach using mw.Title is copied from ve.ui.MWGalleryDialog.

Bug: T233628
Change-Id: I10256ed6883dae0ea216de4c0719f03d7fd19ae4
2019-10-07 14:27:02 +02:00
David Lynch d03db0e4f2 ui.MWSaveDialog: checkbox tracking was getting duplicated on every setup
Bug: T232790
Change-Id: Id19aa59c71432d0179fc06b6a30014d1037074ae
2019-10-03 12:44:43 -05:00
Ed Sanders 41572f2595 build: Update eslint-config-wikimedia and fix
Change-Id: Ib9cf45a393438e2eb47fd1b0c837d2d6acb06541
2019-10-03 00:54:54 +01:00
jenkins-bot 73a92d847d Merge "ArticleTargetEvents: clean up some duplication" 2019-09-30 23:49:27 +00:00
David Lynch 651e00d529 ArticleTargetEvents: clean up some duplication
Change-Id: Ied2851f9d77d055db9fc22668b963a01ca098a95
2019-09-30 11:29:01 -05:00
Bartosz Dziewoński da9b6fffbd Parse relative hrefs on image nodes like on regular links
* In normal images, parse relative 'href' attributes instead of
  expanding them to absolute, and parse 'resource' to keep it
  identical to 'href' if they refer to the same page (including
  same percent-encoding and space/underscore). This resolves Parsoid
  generating |link= options for copy-pasted images (T193253).

* In gallery images stuff, prefix the 'resource' attribute with './',
  same as normal images do. This causes no functional changes, but it
  makes updating tests easier, and the consistency is probably good.

* Update test examples to also prefix 'resource' and relative 'href'
  attributes with './', like the real Parsoid does.

Bug: T193253
Change-Id: If2d7f080d9d693568054f8311c1e1b15ca27ea5c
2019-09-25 00:25:04 +02:00