Commit graph

202 commits

Author SHA1 Message Date
Juliusz Gonera ae2f5134b2 Make MobileViewTarget scroll to desired section
Implements
https://wikimedia.mingle.thoughtworks.com/projects/mobile/cards/1626

Also, rename $el to $container so that it matches the docs.

Change-Id: I9f41ec6fb88f6f21e698553216ccf2c3231589c1
2014-02-13 00:22:53 +00:00
Juliusz Gonera a6b149decc Move restoreEditSection() to mw.Target
It can be reused in mw.ViewPageTarget and mw.MobileViewTarget.

Also, check if this.section is undefined instead of not null and update
docs. restoreEditSection() does not accept any arguments.

Change-Id: Ibbcf4cb936a89d3ae77bb61ee97b8ad00a8d8a53
2014-02-13 00:22:33 +00:00
jenkins-bot b9aa9d2f27 Merge "Include edit status in the ve.deactivationComplete event" 2014-02-12 22:02:20 +00:00
Sam Smith 5ebacd389d Include edit status in the ve.deactivationComplete event
Rather than setting the wgPostEdit configuration variable when the
user uses VisualEditor, i.e. communicating via mutable global
state, include whether or not the user edited the page in the
ve.deactivationComplete event.

Bug: 52955
Change-Id: I0f5067550921008f74221d6c92882adfe404b3a5
2014-02-12 13:59:04 -08:00
Ed Sanders c95e404a30 Give the document focus on save dialog open to resolve inspectors
Bug: 60837
Change-Id: I624a76f5d09db270e651ac004813acfba249f5f6
2014-02-12 14:14:23 +00:00
jenkins-bot c5157ac79a Merge "Fixes for 239bae7512 (mobile toolbar)" 2014-02-08 00:18:26 +00:00
jenkins-bot 814513113a Merge "Hide wikitext warning notification when the user removes the markup" 2014-02-07 22:54:56 +00:00
Roan Kattouw bb465b22a5 Fixes for 239bae7512 (mobile toolbar)
* Use correct class name for setUpToolbar() in MobileViewTarget
* Move shared setUpToolbar() code into ve.init.mw.Target
* Fix iconModuleStyles documentation, remove leading space

Change-Id: Icf5ed36fd817837c0434db8202bef8a78e6cb898
2014-02-07 14:15:17 -08:00
jrobson 684c9887cd Fix toolbar placement
The selector is too weak and results in the toolbar being placed
in positions it shouldn't be! Whoopsy!

Change-Id: I63540130e4de01f9326fe110d606985fea70b644
2014-02-07 11:09:10 -08:00
jenkins-bot c93f54e1b8 Merge "Fix crashes in onLoadError()" 2014-02-07 18:34:31 +00:00
jrobson 239bae7512 Allow better toolbar customisation for VisualEditor
The toolbar in very desktop vector skin specific
In mobile we want to have more control over the toolbar,
and its placement.
* Thus make setUpToolbar abstract
And move the function to ViewPageTarget

* Introduce ve.init.mw.Target.static.iconModuleStyles to
allow the use of different icons
* Update the mobile toolbar to only have B and I tools

Change-Id: I4c72b4b9128b3a74de8b8b5bce7664fbb315216b
2014-02-06 15:45:08 -08:00
Ed Sanders cf62801694 Move paste rules to Target
Because ViewPageTarget isn't always loaded.

Bug: 60912
Change-Id: I16bd6a329120b3dd7dcb0de3e76e69e84c18553f
2014-02-06 22:41:51 +00:00
Roan Kattouw b49adadcc7 Fix crashes in onLoadError()
The jqXHR parameter is optional, so handle the case where it's null
gracefully.

Also fix the documentation for this method, it was full of lies.

Change-Id: I6ab799846a4d4b0d10cc5fd4d8c47264b1845bdf
2014-02-06 21:17:23 +00:00
Ed Sanders 1e6daf1ee6 Implement surface paste rules for media/ref dialogs
Extend default paste rules to prevent lists/tables/references/headings
as applicable.

Also update submodule to master (76ff210).

New changes:
f1a927f Internal paste rules and type conversions

Bug: 59603
Change-Id: I952f98477219a55d25a2bd817344bde58a4862d4
2014-02-05 11:17:33 -08:00
Krenair 9a38ccfe12 Hide wikitext warning notification when the user removes the markup
Bug: 51701
Change-Id: I2b24b91175768334c5111bf8e550be9c34c12f69
2014-01-30 01:41:00 +00:00
Krenair ff95f88e58 Stop API error dialog popping up if you navigate away from the page while Parsoid loads
By checking response.status per this page:
http://stackoverflow.com/questions/9229005/how-to-handle-jquery-ajax-post-error-when-navigating-away-from-a-page

Bug: 51546
Change-Id: I80830b4af1f950369b73497c767cdee4806e7ce6
2014-01-29 00:22:55 +00:00
jenkins-bot 3cdc8e59b4 Merge "Tee tracked events to MediaWiki's mw.track" 2014-01-17 22:49:24 +00:00
Trevor Parscal f4156bd09f Update VE core submodule to master (e7e2833)
New changes:
* e7e2833 - Update uses of Push/IconButtonWidget to ButtonWidget
* d9d9eb5 - Update OOjs UI to v0.1.0-pre (d9bab13)
  * d9bab13 - The Great Button Refactor of 2014
* 22b93ef - Update OOjs UI build (88b2871)
  * 88b2871 - Fix png transparency on required.png
  * 670c468 - Add i18n

Also:
* Update uses of Push/IconButtonWidget to ButtonWidget as there
  is a breaking change in new OOjs UI version.
  This was separated from commit I325a4dcc316d0.

Change-Id: I82220d15221c52be03feafcfc85c2bd6c12ba462
2014-01-17 16:29:36 +01:00
Ori Livneh 753d87e618 Tee tracked events to MediaWiki's mw.track
When running in the context of MediaWiki, VisualEditor should tee its event
stream to MediaWiki's main event bus, mw.track(), so that MediaWiki event
subscribers have a unified interface for subscribing to events. Each
VisualEditor event topic is prefixed with 've.'

To test this patch, you can use this snippet:

  mw.trackSubscribe( 've', function ( topic, data ) {
    console.log( this, topic, data );
  } );

Change-Id: I6b3f10b0dd0aa7fa47c3b35e2fc554622960ce52
2014-01-16 13:34:20 -08:00
Ed Sanders a703086e61 Keyboard shortcuts MW integration
Also adds a button to the utilities menu.

Depends on I806343b42c5fc63d.

Bug: 52844
Change-Id: Ia488362f4b8c9b99b615c84a7341d97e28bdb295
2014-01-15 14:04:06 -08:00
Trevor Parscal 278bcd9a20 Added indicators to toolbars
The down arrow is no longer default, so it needs to be specified
explicitly.

Updates submodule to include indicator changes
(see I0a1faef11a1e7e6ea3e44275c85f2efafae4dc9a)

Change-Id: I32aef3ea2e66fd823aeb07dac06cfefba9954270
2014-01-13 18:32:01 -08:00
Timo Tijhof 6f90f9364e Remove unused ve-init-mw-viewPageTarget-transform-hidden
Follows-up I2d6157708bd7b.

Change-Id: I62c7d7bb179719165df92499cb66b62aa2c6785d
2014-01-13 20:18:42 +01:00
jenkins-bot 542871bcf2 Merge "Update categories HTML on page save" 2014-01-13 18:35:47 +00:00
Ed Sanders 5acabd693f Hide #contentSub properly
It is treated specially which results in it being set to opacity=0 instead
of hidden, and leaves a large space at the top of the document. Removing
special treatment of it results in it being hidden properly.

Bug: 52243
Bug: 54325
Change-Id: I2d6157708bd7b4c3a7c6474b1612862120f963b7
2014-01-13 17:05:42 +00:00
Ed Sanders c74d7f1a21 Update categories HTML on page save
Because there's an API for that.

Bug: 48560
Change-Id: I410647d2b1aa740f606ddca64052b8d2b54671bf
2014-01-12 14:55:39 +00:00
Roan Kattouw dc882baab6 Refactor extraModules to $wgVisualEditorPreferenceModules
Instead of having a hard-coded array of preference-triggered modules
that we need to maintain in multiple places, manage this data in one
place in a configuration variable, and explicitly declare the preference
and module names rather than interpolating both of them from a name.

This allows extensions to add preference-triggered modules, and it
allows them to have preference names and module names that aren't
prefixed with 'visualeditor-enable-' and 'ext.visualEditor.' respectively.

Change-Id: I9eb14349cd39125d5c11ffb44c962cc5febb6ba0
2014-01-06 16:57:45 +08:00
James D. Forrester 0ffd654bed Bump copyright like it's 2014
Change-Id: Ic469ebda2c061dc7da0b4c1625f43a7be55da4fa
2014-01-05 20:06:50 +08:00
James D. Forrester 0fadc2bc77 Let users set __NOTOC__ & __FORCETOC__ status
This creates a new panel in the meta dialog, "Page settings", where page-
level settings will be, err, set. For now, this exposes just the
behavioural switches for the presence/absence of the Table Of Contents –
__NOTOC__ and __FORCETOC__.

As part of this change, the meta dialog is renamed to "Options" to be
less confusing, and the icon for the meta dialog is changed to the
generic one for dialogs, which was previously unused. The page settings
pane is provided first in this list, given that the categories pane
(amongst others) is now directly accessible through the toolbar menu.

Bug: 56866
Bug: 56867
Change-Id: I33ce05c19d2e19b249e1cefd26fd0e3697d0085d
2014-01-05 18:56:53 +08:00
Timo Tijhof ca40077866 Clean up Target properties
Move target.surface from mw.Target to Target
* All targets use this, let's standardise it.

Move target.$document from mw.ViewPageTarget to Target
* It was initialised with null in mw.ViewPageTarget, but the
  assignment happened in mw.Target. So it should be moved up
  at least to mw.Target.
* Since it is useful to have in sa.Target as well, moved it up
  to the abstract Target, and implemented in sa.Target and
  immediately used in the standalone demo where we were already
  duplicating the find( '.ve-ce-documentNode' ).

Add missing target.setupDone = false; in sa.Target

Add missing target.toolbar to Target
* Was used in all subclasses, but never initialised in any of
  the constructors. Let's standardise this property name as well
  (instead of initialising it in three places).

Move target#event-surfaceReady from mw.Target to Target
* sa.Target uses it as well, and considering Platform#initialize
  is already standardised in the abstract class, Target#setup
  being deferred is most likely to happen in each target as well
  so let's avoid different events being invented for the same
  thing and consistently use 'surfaceReady'.

Change-Id: Ia8bde188a4cde7e1615c2ae9c5b758eefc5d9cb7
2013-12-19 02:16:20 +00:00
Rob Moen 212e5b231b Prevent getSaveFields from returning a property named undefined
Change-Id: Id7326ee8b951ba2219d3ea6767370ece9aba3c23
2013-12-18 15:32:49 -08:00
Rob Moen 790d2c1307 Move additional module loading from mw.Target to mw.ViewPageTarget
This resolves some experimental mode dependencies on Mobile integration.

Bug: 58551
Change-Id: Id6c498ae19a5d5b1e5d1698f5e149a9b5d6f3b26
2013-12-18 07:11:36 +00:00
Timo Tijhof c6b997d0ba mw.Target: Fix document focus scroll bug
Follows-up I55ef2622c9eacc which activated code introduced in
mw.Target in commits before that one that caused a change in the
execution order.

Hiding of page content (regular wiki page content provided by
original view request) must happen before the surface document is
focussed.

We used to hide the content from mw.ViewPageTarget#setUpSurface,
which is called from #onReady, which focusses the document after
setUpSurface is done.

Most of this code was moved to mw.ViewPageTarget#onSurfaceReady
which is the listener for the surfaceReady event emitted from

If our surface document gets focus while the original wikipage
content container is still there, the view port is forced to
scroll down because our surface is the next element sibling after
the wikipage container in the DOM.

And browsers (apparently Chrome is not affected) naturally retain
scroll position even if the elements above the one you "scrolled to"
disappear.

We can't (and shouldn't) move the hidePageContent call because
that's the responsibility of the Target subclass, so instead
moved the document focus to below the hidePageContent which is
now also part of the responsibility of the Target subclass.

Also:
* Removed target.surfaceOptions reference because that property
  does not exist. We never passed a second argument here, and
  whatever this was intended for, doesn't exist.

Bug: 58089
Change-Id: I230fbd5401cbd6e3b9450c7f156650409be8ef16
2013-12-06 22:32:51 +01:00
Timo Tijhof cf7f2b141d Set up node-jscs, pass it, and configure in local Gruntfile
Let's experiment with this via our local Gruntfile. If it works
fine we can install it in Jenkins (similar to node-csslint).

Verify through $ npm install && npm test;

Fixed all outstanding violations.

Also:
* Added syntaxhighight to ignore.
* Added imetests (which contain unformatted JSON) to ignore.
* In ve.dm.ModelRegistry#matchTypeRegExps, removed redundant
  !! cast from the [+!!withFunc] statement which was hitting
  a bug in node-jscs. All callers to this local private function
  pass a literal boolean true/false so no need to cast it.
* Removed "/* key .. , value */" from ve.setProp, though this
  wasn't caught by node-jscs, found it when searching for " , ".
* Made npm.devDependencies fixed instead of using tilde-ranges.
  This too often leads to strange bugs or sudden changes. Fixed
  them at the version they were currently ranging to.

Bug: 54218
Change-Id: Ib2630806f3946874c8b01e58cf171df83a28da29
2013-12-06 10:37:27 -08:00
Roan Kattouw c8608fd7bc Remove duplicate method setUpSurface from ViewPageTarget
Was already implemented in the parent class. Moved setPasteRules() so it
would still get run, everything else had already been moved.

Change-Id: I55ef2622c9eacc8b46bd3487919165bccfc347d5
2013-12-04 22:43:47 +00:00
Ed Sanders 86922f8ca8 Change signature of getDomFromData and rename
Currently it takes 4 arguments which are all properties
of the document model, so just pass the model instead and
access the properties later. Rename to getDomFromModel.

Change-Id: I0c378a04dc08b9b90bdc3984f8fa8c4acfe0b667
2013-12-04 16:30:40 +00:00
James D. Forrester a0065cbe0b Fix naked request for save dialog's summary in save
Sometimes a save is not a save, but a switch to the wikitext editor; in this
case, the save dialog doesn't exist, so don't assume that it does.

Bug: 57947
Change-Id: Ic2df7d2066ba03564ed531e1d31351cd27441abe
2013-12-03 14:35:55 -08:00
Roan Kattouw 75449ea597 Clear cache key when deactivating target
And other state too, while we're at it.

Bug: 57905
Change-Id: Ifd2744c841f302764cf57c13f4a760cbe80fa2e0
2013-12-02 18:52:47 -08:00
Roan Kattouw 9dc891f4cb Move activating/deactivating to ViewPageTarget
That's where they belong IMO, since ViewPageTarget is the one that
has .activate() and .deactivate(), and mw.Target doesn't retain any
state (apart from some caching things).

Change-Id: Ia6cf5bac9054163d54ab492d691d8ce9d6a3bb90
2013-12-02 18:21:31 -08:00
jenkins-bot 164a262aeb Merge changes I8c8b2d49,If2124c68,I786b63ab
* changes:
  Split apart onSaveError logic for other mw targets
  mw.ViewPageTarget: Remove unused onTokenError handler covered in onSaveError
  Create base MobileView config and target refactor
2013-12-03 02:11:57 +00:00
Rob Moen db970a61fc Split apart onSaveError logic for other mw targets
Change-Id: I8c8b2d4900b511a65cff4c554cf7ef89d6d39ea9
2013-12-02 18:04:29 -08:00
Rob Moen a701e87caa mw.ViewPageTarget: Remove unused onTokenError handler covered in onSaveError
Change-Id: If2124c68aab0d313f4ddd698014d2a4296bbabb8
2013-12-03 02:02:03 +00:00
Rob Moen f1fa56165d Create base MobileView config and target refactor
Changes include:
* Target mobile for ve dependencies
* Create mobile view constructor
** Some tools like dialogs are excluded for now
* Refactor mw.target to permit code reuse
** Split out pageTarget view functionality from core init methods

Change-Id: I786b63ab57518fc6af7761501259ed66592f70e3
2013-12-02 17:59:27 -08:00
jenkins-bot c06316eb64 Merge "Make veaction=edit work regardless of user preference" 2013-12-02 23:43:52 +00:00
Ed Sanders 5b9231d49d Tear down the save dialog and remove it from memory on surface teardown
Otherwise the old save dialog will still be around if the user sets up
another surface (e.g. a second edit), but won't be attached to the DOM.

Bug: 57654
Change-Id: I23c10849a212534bdd0600637d8ad4fa3ebc4fb7
2013-11-27 14:00:16 +00:00
jenkins-bot af9e6dd263 Merge "mw.ViewPageTarget: Use ve-activated class on the html element" 2013-11-26 22:52:14 +00:00
jenkins-bot c18534bcad Merge changes If814e178,Id133431e,I38d63e31,I16d575b6
* changes:
  Plain text paste with paste special
  Use rare unicode characters for paste placeholders
  Rich paste
  Add fixUpInsertion to newFromDocumentReplace
2013-11-26 21:07:46 +00:00
Rob Moen b37fbf9ba9 mw.ViewPageTarget: Use ve-activated class on the html element
This allows things outside of VisualEditor to style themselves
differently while the editor is active.

Bug: 57555
Change-Id: Ief6b5f53096dd5eeb43a72a7bb182a2c04ec97ca
2013-11-26 20:41:27 +00:00
Ed Sanders 7cec9ae04a Rich paste
Allow pasting of rich (HTML) content.

ve.ce.Surface
* Use a sliced document clone for converting to DM HTML (copy)
* Add full context to pasteTarget before copying
* Add ve-pasteProtect class to spans to prevent them being dropped
* Implement external paste by converting HTML to data and inserting
  with newFromDocumentInsertion
* Remove clipboard key placeholder after read so they aren't picked
  up by rich paste. Hash no longer includes the placeholder.
* Detect the corruption of important spans and fallback to clipboard
  data HTML if available.

ve.dm.LinearData
* Add clone method for copy

ve.dm.ElementLinearData
* Add compareUnannotated for use by context diffing.
* Add sanitize method for cleaning data according to a set of rules.

ve.dm.Transaction
* Add range parameter for inserting a range of a document only,
  e.g. stripping the paste context.

ve.dm.Document
* Implement sliced document clone creation so that DM HTML
  is generated correctly in onCopy

ve.dm.DocumentSlice
* Replaces LinearDataSlice. Now has two ranges for balanced data
  and data with a full context.

ve.init.Target.js
* Define default, loose, paste rules (just remove aliens).

ve.init.mw.ViewPageTarget
* Define strict MW paste rules:
  + no links, spans, underlines
  + no images, divs, aliens
  + strip extra HTML attribues

ve.init.sa.Target, ve.init.mw.ViewPageTarget, ve.ui.Surface
* Pass through and store paste rules.

Bug: 41193
Bug: 48170
Bug: 50128
Bug: 53828
Change-Id: I38d63e31ee3e3ee11707e3fffed5174e1d633b42
2013-11-26 18:23:12 +00:00
Rob Moen 07464e20a5 Remove the toolbar tracker
We were using it for the pop-out save dialog, but now that the save
dialog is real dialog, we don't need it any more.

Change-Id: I72697b5502d5f3fd19f2369a754a62d614af715b
2013-11-26 13:37:50 +00:00
James D. Forrester 7ba9f24121 Make veaction=edit work regardless of user preference
Move the userPrefEnabled check out of isAvailable and instead check
it in-line with isAvailable for setting up the tabs with CSS, but
not for the veaction=edit function.

Bug: 55900
Change-Id: I23984e377ff3fc797e921546492b8c73a5101235
2013-11-26 09:46:42 +00:00