Commit graph

12044 commits

Author SHA1 Message Date
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
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
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 389fd5c668 Merge "Catch errors during document initialization" 2019-10-11 16:24:02 +00: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
Ed Sanders 57d8e53111 Catch errors during document initialization
Change-Id: I5dc29666f99ac10bbf63a56153ba9a32d3568daa
Depends-On: I57fb6319bc3a9cee347c39fc75f555543991d703
2019-10-11 15:13:10 +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
Bartosz Dziewoński e472a4bbd3 Fix mw:MediaLink support
* Handle mw:MediaLinks pointing to to non-existent files, which come
  with typeof="mw:Error" (similar to image nodes).

* Fix regression from c66f8e0547, which
  caused all mw:MediaLinks to be treated as plain external links again.

* Add test cases.

Bug: T232754
Change-Id: I9ae5bcfc4e24e8c0d22ef77d6a4d03f817fc9768
2019-09-24 22:46:03 +02:00
TheSandDoctor 70e3e7cc8b VisualEditor: Replace deprecated editToken with csrfToken
The editToken key of mw.users.tokens is deprecated since MediaWiki 1.27.

Bug: T233528
Change-Id: I7297e6abb159e9bb758859454b1097292e607117
2019-09-22 10:22:01 -07:00
jenkins-bot 7f7cf6ce79 Merge "MWInternalLinkAnnotationWidget: adjust the input for relative links to subpages" 2019-09-20 11:23:40 +00:00
Bartosz Dziewoński 69147ce3bc Fix Vector wikitext surface padding overrides when using custom browser font-size
In order to get the desired padding, the `em` values were pre-multiplied
by the parent font-size, which was assumed to be `0.875em` for normal
surfaces and `(13.3333/16)em` for wikitext surfaces. (That should have
been `(13/16em)`, by the way, but that's a negligible difference.)

Unfortunately, the font-size for wikitext surfaces is actually `13px`.
Unlike `em`, `px` values are not affected by custom browser font-size,
so when one was set, the final padding was all out of whack.

Use `rem` units instead to respect the custom browser font-size,
without getting problems due to the parent element font-size.
We don't need separate rules for .ve-ui-mwWikitextSurface now.

Bug: T222217
Change-Id: Ib7ffbf09d5aa23fddb894aa3b081ec993ddcee2d
2019-09-18 22:24:47 +02:00
jenkins-bot 067ec50ff8 Merge "MWSaveDialog: add more instrumentation" 2019-09-18 15:13:10 +00:00
David Chan c4cb88aded Don't unwrap a solitary paragraph in Wikitext string transfers
This meant we were returning invalid documents with bare content outside
content branch nodes. Instead let ve.ce.Surface in VE core do the unwrapping.

Bug: T232944
Depends-On: I8799d51958b966c99307f4c70546ea326e67385c
Change-Id: I0479116b51cc3135a992fdf36b8edfb2c44916ba
2019-09-17 20:44:45 +00:00
David Lynch 001ed6a88e MWSaveDialog: add more instrumentation
Bug: T229079
Change-Id: I2e5b45a4a28b580fbca872d620df94a61fb8a24a
2019-09-16 10:48:31 -05:00
jenkins-bot 6c52d4b9da Merge "ve.init.mw.MobileArticleTarget: Really deactivate the surface" 2019-09-12 16:43:05 +00:00
jenkins-bot a7a4886a54 Merge "Add new EditAttemptStep stage: firstChange" 2019-09-12 15:19:46 +00:00
jenkins-bot b75eb54bec Merge "Add another looser selector for catching pasted references" 2019-09-10 17:14:31 +00:00
David Lynch 22461568e0 Add new EditAttemptStep stage: firstChange
Depends-On: I79e04dda6323ebb05b129bb96c0323db112bcdd0
Bug: T229079
Change-Id: Icea7eed8a56e0c5a94c6dba4b0951ecf5f594da1
2019-09-10 10:41:13 -05:00
Ed Sanders 0371915832 Add unit tests for read-mode reference filter
Bug: T150418
Change-Id: I8b39694d5c01e0902491fe3d6f3a08451c7c5297
2019-09-10 14:46:45 +00:00
Ed Sanders 90426ba496 Use MW import rules in MW tests
Bug: T150418
Depends-On: I6ad87b53446d7d9fcaf82e1d60e3f9968c4409b6
Change-Id: I5d7f24a7e36ddd3624ef120783ceec5063cf3711
2019-09-10 14:46:37 +00:00
Ed Sanders c8582df1b9 Add another looser selector for catching pasted references
Bug: T232461
Change-Id: I82eef25fbbaa4b583fac660b172541db3160c99c
2019-09-10 12:32:10 +01:00
Bartosz Dziewoński 8eef588593 ve.init.mw.MobileArticleTarget: Really deactivate the surface
The call to selectFirstContentOffset() below would re-activate the
surface and (attempt to) show the keyboard if the surface was
deactivated, but not shown as deactivated.

This might have worked correctly by accident before
I39fe44eee8eab7129340bcff796b6b9b3a59a398 in VE core.

Change-Id: I500309cc0aa8cd794175ae683a17c2614fd58cc9
2019-09-09 20:00:53 +02:00