We call isRedirect to get the real language code instead of the site code.
Post-factum, lang attribute is added as well for each entry.
Bug: 53503
Change-Id: Ia6bf63a7cbe3c7b99ed05d0bd0fdd33190550c98
By passing in the information via a ResourceLoaderModule this
gets around any concerns with performance (version information
is read from the file system).
The version information is appended to the beta toolbar dialog.
Bug: 53050
Change-Id: I7836e1d4003416cbb7e18e3435aa87d82fd5c2e2
Also..
* removed an incorrrect comment referring to the old module
name (standalone didn't use the VisualEditorMessagesModule).
* made it use debug mode to determine whether to minify or
prettify the js code.
Change-Id: I493007649fba27e7faab0cf743eded5f68714c50
When a link was inserted, the cursor position was backwards (at the
beginning of the word rather than its end) - this commit fixes that
problem.
Also, thanks for the help Ed!
Bug: 53560
Change-Id: I04fe1ca4c9126898e7bf85cdf519794d66b4f38b
Also always use strings 'true'/'false' for the value, because
it is a string property (spellcheck, however, is a boolean)
and always use a capital second 'E' in the name.
Change-Id: Ia4e1f9edfd8f236fe81df190e6a68729d7b52243
The inspector popup should appear relative to the position of the related
calling method - either relative to the cursor (like in links and language)
or relative to the focusableNode (like in templates/transclusion).
Bug: 50905
Change-Id: I07f58d0c6561adecbec560fc24bcb6e590f2cd9f
This avoids problems when unnamed references were copy-pasted.
Knowing that key is always non-null simplifies a lot of logic
elsewhere.
Bug: 53365
Change-Id: I3a23123ae732d9583814d38dd880a0cdf691fd5d
Bug fix for browsers which don't have an event.clipboardData
property. The check is done correctly in onCopy but not onPaste.
Change-Id: I3cdf4c0358aa145dcb70c2c103d08a0002001fd4
This commit fixes two issues with insertion of annotations in blank space:
* LanguageInspector issue with inserting an language annotation inside any
whitespace (selection of space between words or collapsed selection in
blank line)
* AnnotationInspector issue with collapsed selection inside slugs. If
the marker was in a slug collapsed selection, activating
AnnotationInspector would expand the range to the closest word (on the
next paragraph). This commit makes sure the expansion for the next word
only happens if the selection is outside a slug.
Change-Id: I144eccefba16131a3d2ec6a3181adf47a15d6cc0
This listens to change events on the surface and checks to see if
there is more than just an empty paragraph node.
Bug: 53345
Change-Id: Ic8fa84d7cdcbffd154178939d0ec8c2c4f86c415
This functionality was (accidentally?) removed by I8f8a240a. It
stops us from over-zealously balancing data when we can get away
with just pasting the original selected range (e.g. it always wraps
collections of text and content nodes in another paragraph).
Bug: 53364
Change-Id: I93fa56c4e43083993c310e0050087e9d1de1e08b
modules/ve/ce/ve.ce.Surface.js
* Schedule the post-keypress async handler in a way that can be cancelled.
* Cancel it and run the handler immediately if another key event happens.
Bug: 53079
Change-Id: If139ff3230c10caa616743f71659c4606d290310
I claimed that it didn't preserve text nodes, but it does. It's just
that there's a bug where it doesn't preserve text nodes if the selector
passed to it is too simple, but 'link, meta, style' is complex enough
to avoid triggering this bug.
Change-Id: Id4a60dc87b8d4c613bc7013641b116dd7c331ac1
ce.AlienNode was mixing in GeneratedContentNode, but wasn't actually using
it properly. This commit fixes this so that AlienNode can benefit from
the <meta>/<link>/<style> stripping code in GeneratedContentNode.
Also added a getHashObject() function to dm.AlienNode to summarize the
domElements attribute because ve.getHash() chokes on it otherwise.
Change-Id: Ief3be94f9730297abe0e3c57506b81a8ff1d136d
There is no good reason why we'd render these tags, and their presence
causes Chrome to crash while cutting across them.
Bug: 50043
Change-Id: I611e3907cf20fa27dbef89ea941d0b787a44ba4f
Add a little robustness, guaranteeing that we don't end up with multiple
history tracking tasks running, leaking one, or try to clear a non-running
interval.
Change-Id: I41db2d6fefc7f45f150aa14ecefc648760ad6200
The selection property is never null; it is initialized to Range(0,0).
If it is set to null in purgeHistory(), the next call to
ve.dm.Surface.change() will crash.
Change-Id: Ia45c0ba26291e8ad09c445fdf2323710b5ab409f
domAttributeWhitelist wasn't actually being observed. Instead, we
already had the code in place to treat renderHtmlAttributes as a
boolean/whitelist/blacklist hybrid, it just wasn't used that way
yet.
This makes the interface nicer and fixes the bug where all attributes
(including data-parsoid and even things like onmouseover) were
rendered by CE.
Change-Id: I02e266c7c7dc197ed845164b7a705d786846a33b
If only a FocusableNode is selected the document doesn't have
real focus, so we must do it manually.
Bug: 53362
Change-Id: I781f59dda7f2884ff02f6688c2c8c037ac7ed1a6
* Assign cut/copy/paste events to the document so that
they are triggered when the CE doesn't have real focus
e.g. only a FocusableNode is selected
* Use clipboardData.setData when available. The key can
be stored and retrieved perfectly in text/xcustom but
this technique doesn't work in FF or IE
* Just use text content for key as this is what is written
to the clipboard, so this can be used directly without
having to get the content from the pasteTarget.
Bug: 48604
Bug: 49396
Change-Id: Ib3702f9441f6ee3fa34ec071f00994dd7e591d99
- Added missing @inheritdoc so that generated documentation is
not empty.
- Fixed type of mw.Platform#getMessage from (implied) @property
back to @method.
- Removed notes from mw methods. They are prepended instead of
appended, thus overriding the useful single-line summary
of the method with this random note. Description should either
be replaced entirely (e.g. no @inheritdoc) or inherited.
- Rephrased a few description to be consistent with the others
(e.g. "Get .." and "Add .." instead of "Gets .." or "Adds..").
Follows-up cbe35632f1.
Change-Id: Ie55bb9e18f1524b706f0e195300170e4d552bf73
The reversed image was created by Ebraminio using
convert loading.gif -flop loading2.gif
Bug: 51401
Change-Id: I264d9368cf8fd030ff34540e50e0038aa42ece16
Was previously broken as getSlice was using ve.Range#equals to
compare ranges which is direction-sensitive.
Bug: 51538
Change-Id: Ib58d1d8fd11b62388c111a5da66171d13a9db9c2
Objective:
* Use the MW link specifically, since the target/command system doesn't
understand the group/id/extension concept yet
Change-Id: I8b756fa0bb55468312bb30d45ac5b943ff7362b5
Currently ignores all non-element data, but element content (e.g.
images) can be annotated.
Added test cases and updated the test runner to only compare
store indexes for a more readable output.
Bug: 50127
Change-Id: I234586a28072811c8288aab56f6abaaa0da0c88d
Objectives:
* Make it possible to add items to toolbars without having to have all
toolbars know about the items in advance
* Make it possible to specialize an existing tool and have it be used
instead of the base implementation
Approach:
* Tools are named using a path-style category/id/ext system, making them
selectable, the latter component being used to differentiate extended
tools from their base classes, but is ignored during selection
* Toolbars have ToolGroups, which include or exclude tools by category or
category/id, and order them by promoting and demoting selections of
tools by category or category/id
Future:
* Add a way to place available but not yet placed tools in an "overflow"
group
* Add a mode to ToolGroup to make the tools a multi-column drop-down style
list with labels so tools with less obvious icons are easier to identify
- and probably use this as the overflow group
Change-Id: I7625f861435a99ce3d7a2b1ece9731aaab1776f8
Return an array of languages instead of a single language. Languages
containing hyphens return themselves along with the root code e.g.
'en-GB' => ['en-GB', 'en']
Change-Id: I840b689d0021d865f93d16d075473a2ed0a9f0d8
The old regex was lifted from PHP, which matches on UTF-8 byte sequences.
In PHP, [...\x80-\xFF]+ matches any bytes with the high bit set, which
by the particular properties of UTF-8 will match any sequence which
represents a Unicode character above U+007F.
In Javascript, regex matching is on UTF-16 Unicode code units, so we
don't have to do byte sequence matching (and cannot do so). So the
equivalent Javascript regex should use [...\u0080-\uFFFF]+, to match any
code unit above U+007F directly. (It also matches surrogate pairs, by
the particular properties of UTF-16, so any Unicode codepoint above
U+007F is matched).
Change-Id: I674b89f757b60331dd1cb23fd7ff8b18775012e9
Some browsers (e.g. Firefox) change the CE range when the dialog
is opened, so after the first surfaceModel change (to modify the
internal item) the surface's selection is modified, and the reference
is inserted in the wrong place.
Bug: 52159
Change-Id: Ia5da33b95a599ba78f308cf0554279ad44616f50
Problem: When the toolbar is created twice with the same config object,
the second time around the tools are still bound to the old surface
Reason: The tool config is overwritten such that symbolic names of tools
are replaced with instances of tools, bound to a specific surface. The
second time around, the creation fails (silently in a try-catch) and then
the already translated list of tools is used to create a new toolbar
filled with old tools still bound to the wrong surface.
Solution: Leave the config object alone, and instead build a new list of
tool instances while iterating through tool names.
Bonus: Don't fail silently. Using a try-catch to detect whether a
requested tool is supported masks other errors, and is evil. Instead,
just do a lookup and skip tools in which the lookup's result is falsey.
Change-Id: Ic43ec29173e556592bb3db9399ff83787e0a6857
toDataElement part fixed in I6d496f7. This fixes the
toDomElement part so we don't trigger a round trip warning.
Bug: 51963
Change-Id: I27a7579890d669a8b980710db1bafe066b744236
This isn't a problem when using the UI buttons as they get disabled
but the command keys can still trigger these methods.
Also fix hasPastState to include check for small stack. This fixes
an existing bug where the undo button doesn't become active until
~1s after the first change is commited (i.e. after the small stack
is committed to the big stack).
Bug: 52113
Change-Id: Idbd34953c805620881a609409290256462af80a5
This commit prepares the LanguageInputWidget to handle both annotation
and node, so it can be used as the GUI for both the LanguageInspector
and the LanguageBlockInspector that's coming up.
Cleaned up the way annotations are read into LanguageInspector and
AnnotationInspector. The attributes are kept in the Widget (without regard
to what datamodel they will serve) and are then read from the inspector.
The LinkInspector had to be adjusted slightly to accomodate a small change
in the AnnotationInspector too.
Change-Id: I17954707c00ffc4c32fbb44a6807a61760ad573c
The update event passes in a transaction object, which was interpreted
as a config object and fragmented the cache. Explicitly wrap the
update() call in an event handler to make sure the config parameter is
undefined.
Change-Id: I641c68230b92d23626fb8b12aeab6a8904a35bcc
This patch rounds off change I29740fa7a by replacing calls to EventLogging's
eventLog.logEvent with calls to VisualEditor's ve.track. ve.track publishes
events by providing an interface, ve.trackRegisterHandler, which event handlers
use to subscribe to VisualEditor events. By making it the responsibility of the
web analytics framework to register itself as a handler, VisualEditor can
remain decoupled from (and indeed ignorant of) any particular event logging
implementation. This allows VisualEditor to be integrated with many different
web analytics platforms with nothing more than a bit of glue code for mapping
ve's event semantics to those of the target platform.
The practical difference that this makes is that it frees VisualEditor from
having to know about EventLogging or from having to load EventLogging
components, which means we can remove quite a lot of gnarly code. My current
plan is to migrate the code for registering and loading the 'Edit'
schema module to Extension:CoreEvents, which is also where I'll commit the
handler for VE events. (CoreEvents exists precisely to provide an organized
place for persistent but WMF-particular instrumentation.)
Once this patch is merged and deployed, the following two configuration
variables may be removed from mediawiki-config:
- $wgVisualEditorEnableSplitTest
- $wgVisualEditorEnableEventLogging
Change-Id: Idfdf692668d2adfbe029e8f0c4ff9e96c60ff741
We were assuming images were wrapped in <a> tags. Images with
link='' are only <span> wrapped.
Bug: 51963
Change-Id: I6d496f719cfbbc7556c55f0a660cb192040f29de
Add rerender event to all image loads in MWExtensioNode.
MWHieroNode's implementation of onParseSuccess is now the same as
its parent so can be deleted.
Change-Id: Iaa4999372f1ba88a7bdf1490fc3f8640af77ceae
Create getter for extensionsName which is overriden by
MWAlienExtensionNode.
Also removed angle brackets around Alien title as the inspector
already has an angle bracket icon, and a '<' close button.
Change-Id: Ice8c5d73ed621f8e585b5f372788666f8c5aeb50
onUpdate was renamed to update. Also neither event was
actually implemented so have just removed them.
Change-Id: Iaae1661a99f97272fa42c71223fc2cb832d50c66
Previously we assumed that embedded icons mean we weren't
dealing with an inspector, but that is not always the case
(e.g. MWExtensionInspector).
Bug: 52845
Change-Id: Ifc5b054568661cb9badf6d7991f512b81e649b36
VisualEditor.i18n.php, VisualEditor.php
* Button title
* New experimental files
ve.*.MWAlienExtensionNode.js
* Very basic extension of ve.*.MWExtensionNode
ve.ui.MWAlienExtensionInspector.js
* Default to inline-block for wrapper. Should probably
get rid of styled wrappers for GeneratedContent eventually.
ve.ui.MWAlienExtensionInspector.js
* Basic extension of MWExtensionInspector. Override title to
use tag name e.g. '<easytimeline>'. Could be changed in future
to 'Extension: easytimeline' or similar.
*.png, *.svg, *Icons*.css, ve.ui.MWAlienExtensionButtonTool.js
* Angle bracket icon for button (open to suggestions)
ve.ui.MWInspector.css
* Make extension inspector text input tall by default.
Change-Id: I07f0686839192cad3cd8dfd3233ae907fe5cdf6a
Roan and I think this is way too light. The only way
I can tell it's a group is by mousing over all of
the icons back and forth really quickly :)
Increasing to 10% alpha.
Change-Id: Iab55bf64921de5247d10d611318e545efe74fe4a
GeneratedContentNode didn't track concurrent updates at all, so a
race condition was possible: if the node was updated a second time
before the first update had been rendered, the second update might
render first and then be overwritten by the other one.
To prevent this, we track the promise associated with the current
render. If a new update is launched while a previous one is still
pending we attempt to abort the old one by calling .abort() on it,
and ignore any future resolution or rejection from it.
Also allow rerenders based on non-model data by calling
.update( { config object } );
Change-Id: I8feefd9e8fb6c41d06b8b20131e3be5e37954e83
If you had an HTML element that was matched by two models, one with
a direct string match and one with a regex match, then the string
match would beat the regex match (which is correct) if they both
specified a tag name, but the regex match would win (which is wrong)
if they both didn't specify a tag name.
The fix is to only check for tagName === null if we're in tag-agnostic
mode (tag === '').
Change-Id: I9943611111e4c4ff498cdd95b7b3e72f95fb413b
Mostly as a demonstration of how easy this is with MWExtensionNode.
The icon was chosen with the following criteria:
1. Recognisable (the ankh is quite common in popular culture, right?)
2. Doesn't look idiotic to academics (I've consulted an Egyptology
PhD and they can confirm it's not the glyph for penis)
3. Renders well at <16x16
That said it does look a little like a stick man...
Bug: 43118
Change-Id: I9f9e8af501401866bfeecf0eec3690a705fbd4db
MWMath and other simple extensions all behave in a similar way, e.g.
<tagname>Foreign syntax</tagname>.
This creates a base class that should make supporting such extensions,
and editing their contents in a plain text box, very simple.
Change-Id: Icc0acb33fe32704f71dacb552d9dfa3142eaef2b
This allows abstract classes to specify RDFa types based on a static
property overridden by a child class. The default implementation is to
just use .static.matchRdfaTypes.
Change-Id: Ic71fc552a6a1626d94f998e9517af971e8198e79
Objectives:
* Use a class for toolbar groups to add more functionality later
* Rename addTools method to setup
Changes:
*.php
* Add link to new file
* Move ui element classes up for more general use
ve.init.mw.ViewPageTarget.js, ve.init.sa.Target.js, ve.ui.Context.js,
ve.ui.SurfaceWidget.js
* Update use of addTools method
ve.ui.Tool.css, ve.ui.Toolbar.css
* Move styles between sheets
ve.ui.Toolbar.js
* Rename addTools to setup
* Use ve.ui.ToolGroup objects when building tools
ve.ui.ToolGroup.js
* New class, encapsulates tools
Change-Id: Ic3a643634a80a8ac7d6f6f47f031d001c7efaee7
Objectives:
* Make drop down tools look more like buttons and less like inputs, since they aren't text input and are buttons
* Make context toolbars inside surface widgets render correctly
* Show outlines of groups on hover to hint tool relationships
* Make neighboring active tools look cleaner
Changes:
ve.ui.Tool.css
* Merge ButtonTool and DropdownTool styles as much as possible
* Add styles for DropdownTool active states
* Only round the corners of the first and last tool in a group
* Soften the borders between consecutive active tools
ve.ui.Toolbar.css
* Add border to groups on hover
ve.ui.Widget.css
* Isolate surface widget toolbar styles by using stricter selector
ve.ui.Tool.js
* Fix incorrect capitalization of class name
ve.ui.SurfaceWidget.js
* Add classes to toolbar and surface for better style targeting
Change-Id: Ib5ae8f705ef1e9c481e5bdf8c8dcef9c1eb22c4d
Objective:
* Remove ve.ui.DropdownTool's dependency on ve.ui.SurfaceToolbar so it
can be used with any ve.ui.Toolbar
Changes:
ve.ui.DropdownTool.js
* Bind onBlur to document mousedown in capture mode instead of trying to
add more and more things we are listening to which is a losing battle
* Refactor activate/deactivate mode changes
* Get rid of isEnabled check - surface should disable toolbar, the tools
shouldn't be checking if the surface is enabled after the fact (also,
this is harmless and doesn't change any actual interactions)
Change-Id: I738209d17649358c2f9812f9abac576960af867b
I trusted you guys when you told me to use DOM .focus() instead of
jQuery's .focus() and didn't test well enough :( The former doesn't
work, the latter does.
Follow-up to I7962f59b.
Bug: 47793
Change-Id: Iddfb8d7c99325b6c7a5d151948b57cfa5f0a6a62
This patch adds ve.track; it provides a means for VisualEditor code to log
various changes of state that are of potential analytic interest. This is done
without coupling VisualEditor to a particular analytics framework by providing
a method, ve.hook.registerHandler, by which event data may be routed to a
particular analytic framework for processing and dispatch.
ve.track uses a $.Callbacks-like object for tracking analytic events which can
remember an arbitrary number of past events. This is done by maintaining an
array containing the arguments of past calls and maintaining a counter for each
callback indicating its position in the queue (i.e., how many events it has
already received.) This ensures handlers are called for each event, including
events which were fired before the handler was registered. This allows the
load-order of VE and analytics components to remain unspecified.
Change-Id: I29740fa7a0ac403e484e0acee6dfcadaf6fc4566
See ApiVisualEditor.php#parsefragment.
Error code is also incorrectly about Parsoid, method
parseWikitextFragment does a FauxRequest to MediaWiki. Fixed
error.info. Keeping the same error.code for now for consistency.
Bug: 52483
Change-Id: Ic473ae4a5c1e9706140f6ec4cc8157fadd02c318
Objective:
* Make it possible to make a toolbar without a surface
Changes:
*.php
* Links to new file
ve.ui.Toolbar.js, ve.ui.SurfaceToolbar.js
* Split toolbar into generic and surface specific classes
*.js
* Update symbol names
Change-Id: Ice063a2fb67b5ce5155cdc96a0d47af49eee48cb
Follows-up ced2a8a which moved the tab layout to the server-side
and changed it to set up "source" tab and section links always
everywhere (even if VE would not be availabe in the namespace
or browser).
The JS logic (which continues to exist to take care of pages
cached before we moved it to PHP and/or to fix up pages cached
with a different configuration in the future) didn't do this yet
causing the "Edit source" tab to inconsistently appear on pages
for anonymous users viewing pages where VE is not available.
Change-Id: Ic575b3fcef17e636adaa338abc7748a4388ed9a9
This is bit of a hack, as leading whitespace could be
significant if styled with white-space:pre.
Long term VE shouldn't be editing the user's HTML, and
should just highlight potential formatting issues.
We avoid the stripping in preformatted elements as we
expect they will have that styling.
Bug: 51462
Change-Id: I654d98e17dd604cb2a192831ff3f3597f95b9962
Specifically: transclusions, formulae & references.
Captions also allowed to contain other images and reference lists
but we should probably not encourage that.
Change-Id: Ia1c99e51640a3f9ee53281a1e3ebd67dc13c8990
Because trying to work out how broken your test case is
by looking at two (potentially multi-page) serialisations
of the DOM summary is a pain in the arse. Diffing two
HTML strings may highlight the problem much more clearly.
TODO: Is it possible to defer the calculation of the HTML
infused summary object until we have determined the assertion
has failed. Otherwise we're slowing down our tests for no
reason.
Change-Id: I873bf2479ab81d15389792bd59d15580da63941a
Code speaks for itself, see also bug 52441.
Though not introduced by 14343c7bf7, that made the bug worse.
Bug: 52441
Change-Id: Ie2b80b22df03eb563de8812a47fb25152527e786