We now have three stages:
1. Browser feature tests. Dies silently if any fail.
2. Browser blacklist. Dies silently if match found.
3. Browser whitelist. Shows warning if no match found.
Previously we were treating the remotely generated
edit notices as if they were in an object when
in fact they were in an array - the code has been
fixed to reflect that fact.
As locally generated notices will typically require
parsed messages, we've also moved the notice rendering
to after onReady is fired.
Updated jquery.client to latest master from MediaWiki core
(needed for proper detection of Iceweasel, Android and Safari)
Bug: 38128
Change-Id: Idc5f4a23a2709264d869a91d00873c4e187bc470
Prologue:
Farewell ve.Editor my good chap… Oh, hey there HTML frames - I didn't
see you there! In a world where iframes are outlaws, and symbols like
document and window are global, there were more than a few assumptions
about which document or window was being used. But fear not - for this
commit (probably) tracks them all down, leaving a trail of
iframe-compatible awesomeness in its wake. With the great ve.ui.Surface
now able to be used inside of iframes, let the reference editing
commence. But there, lurking in the darkness is a DM issue so fierce it
may take Roan and/or Ed up to 3 whole hours to sort it out.
Note to Roan and/or Ed:
Editing references seems to work fine, but when saving the page there
are "no changes" which is a reasonable indication to the contrary.
Objectives:
* Make it possible to have multiple surfaces be instantiated, get along
nicely, and be embedded inside of iframes if needed.
* Make reference content editable within a dialog
Approach:
* Move what's left of ve.Editor to ve.ui.Surface and essentially
obliterate all use of it
* Make even more stuff inherit from ve.Element (long live this.$$)
* Use the correct document or window anywhere it was being assumed to be
the top level one
* Resolve stacking order issues by removing the excessive use of z-index
and introducing global and local overlay elements for each editor
* Add a surface to the reference dialog, load up the reference contents
and save them back on apply
* Actually destroy what we create in ce and ui surfaces
* Add recursive frame offset calculation method to ve.Element
* Moved ve.ce.Surface's getSelectionRect method to the prototype
Bonus:
* Move ve.ce.DocumentNode.css contents to ve.ce.Node.css (not sure why it
was separate in the first place, but I'm likely the one to blame)
* Fix blatant lies in documentation
* Whitespace cleanup here and there
* Get rid of ve.ui.Window overlays - not used or needed
Change-Id: Iede83e7d24f7cb249b6ba3dc45d770445b862e08
If the commit message is empty we show a warning, and if the warning
is already visible we allow the user to proceed.
Bug: 47752
Change-Id: Idba707abaea8b08a94f7fa4d5bc5b1e35261a572
We need to listen to the same events as bytelimit. Specifically
we were missing keyup, which meant the counter could get stuck on
-1.
Bug: 47718
Change-Id: I3d4f3f8cd451bfb6acea19ee9baae7be60adcf15
Intercept badtoken errors, refetch the edit token from the
action=tokens API, and retry the request again. If this fails too,
show the error to the user.
Right now this just shows the good old confirm() dialog if the token
refetch fails; we should probaby give the user a clearer error message
telling them to refresh the page or something.
Bug: 42984
Change-Id: Ib43d1938ffa24bc8d1dc76a300e16e486dabd928
Add checks to make sure parts of the target are acutally
active before trying to tear them down or use them.
This fixes a couple of issues which appeared when the VE was
closed before it had a chance to finish loading.
Bug: 48520
Bug: 47813
Change-Id: Ide5def0e983bab49108b40008fc170957c7fc2a2
Objectives:
* Split ve.Surface into ve.Editor and ve.ui.Surface
* Move actions, triggers and commands to ve.ui
* Move toolbar wrapping, floating, shadow and actions functionality to configurable options of ve.ui.Toolbar
* Make ve.ce.Surface and ve.ui.Surface inherit ve.Element and use this.$$ for iframe friendliness
* Make the toolbar separately initialized so it's possible to have a surface without one, as well as control where the toolbar is
Some change notes:
VisualEditor.php
* Added standalone module for mediawiki integrated unit testing
ve.ce.Surface.js
* Remove requirement to pass in an attached container to construct object
* Inherit ve.Element and use this.$$ instead of $
* Make getSelectionRect iframe friendly
* Move most of the initialize stuff to a new initialize method to be called after the surface is attached to the DOM
ve.init.mw.ViewPageTarget.js
* Merge toolbar functions into setup/teardown methods
* Add toolbar manually (since it's not added by the surface anymore)
ve.init.sa.Target.js
* Update new init procedure for editor, surface and toolbar separately
* Move toolbar floating stuff to ve.Toolbar
Change-Id: If91a9d6e76a8be8d1b5a2566394765a37d29a8a7
Previously it was just being returned as the diff html, which
looked weird becacuse 1: it was the wrong width and 2: the
save buttons were still there.
Bug: 43754
Change-Id: I537bcae91f51a3f30ca4736c41f7a5619bbf321d
Objective:
Move toolbar floating functionality to ve.init and clean it up
As a bonus:
demo.css
* Fix CSS path to set width of inputs properly
Changes:
demos/ve/index.php
* Allow ve.init.sa.Target to construct it's own surface object
ve.ce.Surface.js
* Move object resizing and table editing disabling commands from ve.Surface
* Add method for getting the currently focused node
ve.init.mw.ViewPageTarget.js
* Remove initializing surface property (now done in parent class)
* Normalize all uses of "setup" to "setUp"
* Replace uses of getDocumentModel with getModel().getDocument()
* Add calls to set up and tear down for toolbar floating
ve.init.mw.Target.js
* Replace uses of getDocumentModel with getModel().getDocument()
ve.init.sa.Target.js
* Move example from ve.Surface
* Change constructor to accept document model
* Create ve.Surface object in constructor
* Add set up for toolbar floating
ve.ui.init.Target.js
* Initialize surface property
* Move and cleanup toolbar floating functionality from ve.Surface
ve.ui.Surface.js
* Remove example now that init.sa creates it's own surface (moved)
* Document options
* Simplify toolbar options and remove the concept of multiple toolbars
* No longer cache the options object
* Move toolbar initialization to constructor
* Change setupCommands to addCommands, making it useful after construction
* Inline selection initialization
* Move and cleanup toolbar floating functionality to ve.ce.Surface
* Reorganize a few methods
* Move toolbar floating to ve.init.Target.js
Change-Id: I393a426e35567d57c048122bf64a83c1ef45e6e8
To do this, we take the document generated by the converter and
transplant things from the original Parsoid document into it.
Change-Id: I2f5058220669526130a360cec3389c3f42b41771
If the previous commit properInnerHTML was renamed to
properInnerHtml, but its invocations weren't (a bug).
While DOM uses .innerHTML we use Html throughout the
rest of our code so we should be consistent either way.
Change-Id: If46bb256e938a097951c159b7a278667fd8e06a6
If we're in RTL mode and the skin is Vector-based, we need to reverse
the order of the tabs in the DOM, because that's a weird thing that
Vector does to render tabs in RTL.
See https://bugzilla.wikimedia.org/show_bug.cgi?id=46947 for discussion
about the Vector behavior.
Bug: 48017
Change-Id: Ie1214b08450aefed893739a2b862cb1e9b23a2ef
init.mw.Target#serialize is an odd one because it is the only
target method that has a callback parameter (instead of
emitting the event on Target and having ViewPageTarget get
the event through that).
This line from onShowChanges needed to be added to onSerialize
// Invalidate the viewer wikitext on next change
this.surface.getModel().connect( this, { 'transact': 'onSurfaceModelTransact' } );
Though onSerialize is currently bound manually from the
serialize callback, it should be refactored to be like the others.
Bug: 44446
Change-Id: I9eddebbdf9294ee3d46286bdf1b157e00252d300
We already do this in unit test so moving getDomElementSummary
and convertDomElements from ve.qunit.js to ve.js.
Apply ve.convertDomElements to report data before serialising.
Bug: 47948
Change-Id: Id807ccc6ff31d063be815ed4988cb35684adb76a
New ID is now passed from the API to the save event, to the onSave
handler. Empty diffs won't generate a newrevid.
Bug: 47420
Change-Id: I12ce27c8dc57f7aa753bcf5840635d5fea6b4e80
VE recreates the tab from scratch and deletes the old one
so as not to copy over access key settings. This fix
copies over classes from the old tab.
Bug: 47452
Change-Id: Ic2d42bb3034be25f388b587a00c3f523cfcc163c
The EventEmitter API we inherited from Node.js and then bastardized was
getting awkward and cumbersome. The number of uses of ve.bind was getting
out of control, and removing events meant caching the bound method in a
property. Many of the "features" of EventEmitter wasn't even being used,
some causing overhead, others just causing bloat. This change cleans up
how EventEmitter is used throughout the codebase.
The new event emitter API includes:
* emit - identical to the previous API, no longer throws an error if you
emit error without a handler
* once - identical to the previous API, still introduces a wrapper* on -
compatible with the previous API but has some new features
* off - identical to removeListener in the previous API
* connect - very similar to addListenerMethods but doesn't wrap callbacks
in closures anymore
* disconnect - new, basically the opposite of addListenerMethods
Another change that is made in this commit is mixing in rather than
inheriting from EventEmitter.
Finally, there are changes throughout the codebase anywhere
connect/disconnect could be used.
Change-Id: Ic3085d39172a8a719ce7f036690f673e59848d3a
Specifically by looking for "data-ve-changed",
"ChangeMarker*" and internal.changed.
Various tests, test counters and unused variables also
affected.
Bug: 45061
Change-Id: Ibd1ee68e0d650979d40574eff9cebded1a28499f
Parsoid switched from <!doctype> to <!DOCTYPE>, which exposed the fact
that our dirty regex to detect whether we're dealing with a full
document or a fragment was case-sensitive. Made it case-insensitive.
Change-Id: Ia8a38488e06ca7d7a6fb9a9699b5d9b5c5eb03f2
This is minimise the amount of data we need to serialise when
sending this over the wire.
The minimal IVStore data is added to the MW bug report, and
editedData fixed to only return the data array, not the full
LinearData object.
Documentation in AnnotationSet has finally been updated to
refelect the fact that it only stores Annotations
(was previous the generic OrderedHashSet).
getAnnotationFromOffset has been split out into a function
that just returns this indexes so that in cases where we
don't need the values we don't do an unneccesary store lookup.
Bug: 47318
Change-Id: I4819cf06d1bd0ae4f8b896052e278ca75c9551bf
This involves setting some i18n messages for the target languages based on the
translations already provided - I hope this doesn't break anything for TWN but
the need for this only just became apparent; apologies!
Longer-term we will need to come up with a better way of doing this, if we are
keeping the in-VisualEditor feedback link around.
Change-Id: Id6ed80cdcd4314e84e75fb718421767162d73ef3
This is showing a separate need for refactoring. We call
"this.serialize( ..., callback )" but if it failed callback
is never called and an event is emitter for the error.
That makes it rather disconnected from each other.
In this case we're lucky that all calls to serialize are similar
in nature and need the same kind of error callback but other
wise this would be pretty messed up. It obviously needs to be
untangled and get rid of this akward eventemitter dance.
This doesn't fix bug 47581, but it does fix the "Infinite loader
with no error" problem as a result of it by handling the error
in a more intuitive way.
Bug: 47581
Change-Id: Icdf64a792c13a326f494e051be47f2946928d142
The 'add' tabLayout path is pretty basic and up to date. The
older (now active again) tabLayout 'replace' was fairly outdated
and unmaintained.
Fixes:
* Attributes copied from the original (except for the 'id'
attribute) were not actually beinged copied over because they
don't exist on the ca-edit list item, but on the anchor link
inside that list item.
* Clean up messages from the module registry that were unused.
Keys 'accesskey-ca-edit' and 'tooltip-ca-edit' were also inexistant.
* Add message keys for tooltip and accesskey of editsource tab.
Depends on I0bde1a228983c58b in mediawiki/core.
Bug: 47396
Change-Id: If598552fac639da645a8b1273c5fc6028695fcc1
Also add detection for whether the browser is actually broken (most are,
but some, like Opera, aren't), treat <textarea> and <listing> in addition
to <pre>, and fix a bug where the function would crash if the <pre> was
empty (because .firstChild was undefined/null).
Change-Id: I541b57e9fd5c9c42d19d0a59f6e29fb43d35c9b6
Currently some issues, probably with loading nodes
after factories.
Toggled by global $wgVisualEditorEnableExperimentalCode.
Change-Id: Idab3dd68572c037289c6742d03fd327285110f67
Current set up leaves us with restoring when we're not and vice
versa. Not good. :-) (Partial fix of change 59968.)
Change-Id: Ia33a2f3318cf2e46b7469b2c773e91c5ee8fdefa
* changes:
ve.init.mw.ViewPageTarget: Put the Edit source link in the visible tab area
ve.init.mw.ViewPageTarget: Switch tabLayout from 'add' to 'replace'
Gabriel noticed whitespace diffs in the problem reports. These were
caused by browsers' .innerHTML being broken on <pre>s. We compensate
for this in the converter, but not when generating originalHtml.
However, a variable called originalHtml really shouldn't be generated,
it should just literally be the original, unprocessed HTML. This
does mean it includes the doctype, <html> and <head> which aren't
included in editedHtml (that one's just the contents of the <body>), but
that's much easier to deal with on Parsoid's end than random newline
diffs all over the place.
Change-Id: I8e66cb79887f49f84114ab6b4d0e0d24aea744b6
This was broken ever since the introduction of IndexValueStore, because
the call to getDataFromDom() wasn't updated, so it crashed with a "doc
is undefined" error. Fixing part of this by passing in a new IVStore.
The data that is transmitted over the wire still has indices with no way
to find out what the corresponding annotations are. It needs to be fully
expanded but there's no way to do this in DM quite yet.
Bug: 47319
Change-Id: I761523d22e51ac560e37ae991d01a6b84224ca40
Apparently Parsoid has always required this, and we've never sent it,
yet somehow the code in production works. This may well be the cause
of some of the selser issues we saw after the deployment attempt in
January.
Made oldid a required parameter in the API module, and default it to 0.
When we get 0, we translate that to the empty string for Parsoid's
benefit. We also need to explicitly get wgCurRevisionId in
ViewPageTarget, and that's also 0 on new pages.
Change-Id: I3a55025246014cd74e15d6d5b6c4ede7b823e5df
This makes the Edit tab point to the VisualEditor, and adds a
"Edit source" link to the p-cactions menu.
Bug: 46872
Change-Id: I559232f3d8e42df0d45311b65df8c30425b1a368
Just like ve.dm.Model is a common base class for dm.Node, dm.Annotation
and dm.MetaItem.
ce.View abstracts the this.model and this.$ behavior, including liveness,
whitelisted HTML attribute rendering and adding a back reference in
.data(). The back reference has been renamed from .data( 'node' ) to
the more generic .data( 'view' ).
At this point this means ce.Annotation is just a shell around ce.View
(except where it defaults to a span rather than a div), but that could
change in the future.
Change-Id: I0eef5b80718e0b0fcd3f8bba096b452f0bb680d0
To verify
* Save "MediaWiki:Edit" with "Edit page" (anything not "Edit")
* Set this.tabLayout = 'replace';
* Observe that the ve-edit tab is now "Edit" (msg: vector-view-edit)
instead of "Edit page" (msg: edit)
Bug: 42117
Change-Id: I2e7dd85cd14049101e2d49751d37797d77bc7c9d
Created an IndexValueStore class which can store any object and return
an integer index to its hash map.
Linear data is now stored in ve.dm.LinearData instances. Two subclasses
for element and meta data contain methods specific to those data types
(ElementLinearData and MetaLinearData).
The static methods in ve.dm.Document that inspected data at a given
offset are now instance methods of ve.dm.ElementLinearData.
AnnotationSets (which are no longer OrderedHashSets) have been moved
to /dm and also have to be instantiated with a pointer the store.
Bug: 46320
Change-Id: I249a5d48726093d1cb3e36351893f4bff85f52e2
This caused the page to stay in a dimmed state because it would
throw an exception before tearDownSurface() and showPageContent()
would be called.
Bug: 46456
Change-Id: I91ad2b110c2c523a4bb367407e3f33a953328ab4
* Document them consistently between secetions Inheritance and
Static Properties under their own (new) section Events.
* Removed any quotes or brackets around the event name in existing
@emit annotations
Search: @emit.*['"{}(){}]
* For every call to this.emit() anywhere, added @emits.
* Fixed all warnings for references to undefined events
(introduced as a result of the previous point).
Event handler parameter documented based on the emit() call
and actual handlers using the event. Usually the latter is
more elaborate.
* Extend coverage of jQuery as needed
(copied from mwcore/maintenance/jsduck/external.js
written by me, hereby implicitly and explicitly released under MIT).
Specifics
* ve.ce.Surface#onContentChange: Fixed type of range from Object to ve.Range.
* ve.ce.SurfaceObserver#poll: Fix syntax for code from {} to `backticks`.
* ve.ui.Toolbar#onContextChange: Doesn't actually emit "clearState" event.
Removed #onClearState in Tool, ButtonTool and DropdownTool.
Bug: 45872
Change-Id: Id879aa769b2c72d86a0322e75dddeb868211ce28
If the user has undone all their actions they should not be able to
save the document. By updating the 'edited' property we also solve
the issue of the onbeforeunload alert displaying if all edits
have been undone.
Bug: 42939
Change-Id: Ib3bc5b0e2f21781166a17a3fdf4f5286e6713859
This is a major refactor of user interface context, frame, dialog
and inspector classes, including adding several new classes which
generalize managing inspectors/dialogs (which are now subclasses
of window).
New classes:
* ve.ui.Window.js - base class for inspector and dialog classes
* ve.ui.WindowSet.js - manages mutually exclusive windows, used
by surface and context for dialogs and inspectors respectively
* ve.ui.DialogFactory - generates dialogs
* ve.ui.IconButtonWidget - used in inspector for buttons in the head
Refactored classes:
* ve.ui.Context - moved inspector management to window set
* ve.ui.Frame - made iframes initialize asynchronously
* ve.ui.Dialog and ve.ui.Inspector - moved initialization to async
initialize method
Other interesting bits:
ve.ui.*Icons*.css, *.svg, *.png, *.ai
* Merged icon stylesheets so all icons are available inside windows
* Renamed inspector icon to window
ve.ui.*.css
* Reorganized styles so that different windows can include only
what they need
* Moved things to where they belonged (some things were in strange places)
ve.init.Target.js, ve.init.mw.ViewPageTarget.js, ve.init.sa.Target.js
* Removed dialog management - dialogs are managed by the surface now
ve.ui.*Dialog.js
* Renamed title message static property
* Added registration
ve.ui.*Inspector.js
* Switch to accept surface object rather than context, which conforms
to the more general window class without losing any functionality
(in fact, most of the time the surface was what we actually wanted)
ve.ui.MenuWidget.js, ve.ui.MWLinkTargetInputWidget.js
* Using surface overly rather than passing an overlay around
through constructors
Change-Id: Ifd16a1003ff44c48ee7b2c66928cf9cc858b2564
Heading and Preformatted nodes have rules that should only
exist under a document node in MediaWiki.
Two new node types have been created as has a new DropdownTool which
uses these. The MW init options have been changed to use the new
DropdownTool.
Bug: 45295
Change-Id: I3f47e1ae1f5c1415bde58a75385e4bf5f4b8fffc
Changes include:
VisualEditor.i18n.php, VisualEditor.php
* i18n labels for dialogs
ve.init.mw.ViewPageTarget.js
* Initial go at onOpenDialog and onCloseDialog methods
ve.init.Target.js
* Change calls to dialog hide & show to close & open
ve.ui.MetaDialog.js, ve.ui.ContentDialog.js
* Pass surface when constructing
* Add static title message property
ve.ui.Surface.css
* Set high z-index for toolbar for shadow to overlap dialog.
ve.ui.Dialog.js
* Extends EventEmitter class.
* Changed hide/show method names to open/close.
* Create base ui elements.
ve.Surface.js
* Create instance of meta dialog.
Change-Id: I867ca0546606eeb5e2ab7f612bb5af700ab877ec
Major changes:
demos/ve/index.php
* Renamed ve-demo-content to ve-demo-editor
ve.init.mw.ViewPageTarget, ve.init.sa.Target
* Added handlers for dialog events
ve.ui.*Dialog.js
* Added skeleton classes for dialogs
ve.init.Target.js
* Create abstract class methods for Target.
ve.init.sa.Target.js
* Create Standalone target view methods.
ve.init.mw.Target.js
* Added MW specific target view methods.
* Integration action buttons are now added to the edit
view in the toolbar.
ve.Surface.js
* Simplified constructor, now requiring a target which contains the container
* Other changes include some documentation and code cleanup.
Bug: 39597
Change-Id: Iff39266bdd3052f34bda254ca407030dbbc81f26
Unfortunately the Http::get wapper provides no data if anything but
an OK status is returned, so ApiVisualEditor now uses MWHttpRequest
directly.
If a non-OK status in encountered the error code and message are
passed through to the JSON output, and rendered in the error
alert by VE.
The error code passed through is parsoidserver-http-NNN although
other suggestions are welcome.
Bug: 44354
Change-Id: I166ecf81c40f0f1c62663f2096753269d28f2916