Commit graph

99 commits

Author SHA1 Message Date
James D. Forrester a232147b11 Switch 'disallowQuotedKeysInObjects' jscs rule on and fix up
Change-Id: I75ac4b378ef485feead9d0eff34ed7877b94b5d0
2014-08-22 13:50:48 -07:00
Ed Sanders 4af79bf3d5 Re-order methods in MWImageNode
So static methods are actally in the section marked 'Static methods',
before non-static methods, per our coding standards.

Change-Id: I17bea17a1409b02f263375c6434be872e4d239ba
2014-08-22 13:33:08 -07:00
jenkins-bot 0af7c2d634 Merge "Correct MWImage* resource regex to find literal .s rather than characters" 2014-08-21 02:07:50 +00:00
James D. Forrester 5148a0836a Rename "reference list" to "references list" internally
That's what we call them in human-speak, and it makes sense to have them align.

Bug: 49923
Change-Id: I8dcfba249fb9ea13c2b4052e98a4d253c302b1ba
2014-08-20 18:26:54 -07:00
James D. Forrester 7d3f9797c0 Correct MWImage* resource regex to find literal .s rather than characters
Change-Id: Ie5db0b4b6cdb607985b53228c4ceb26c57af9dfc
2014-08-20 18:16:13 -07:00
Bartosz Dziewoński 694c454dcd Blacklist annotating link node with more links
Previously one could select over a link node and linkify the
selection, with tremendously funny results.

Change-Id: Ic5a2132b2d18280099a6024bc4ec2b1333eca98f
2014-08-02 12:34:30 +02:00
jenkins-bot 3771aa92c1 Merge "Make the image model work without a node" 2014-07-24 00:32:54 +00:00
Moriel Schottlender 1bc7d074fe Make the image model work without a node
The image model should go by image attributes (whether it comes from
an existing node or a new one) and not a node.

Bug: 68242
Bug: 68000
Change-Id: I4cabd678157619331b3c47d3b44bc16a28fd7bd7
2014-07-23 17:27:30 -07:00
James D. Forrester c2f37a0450 test: Move mw into the global list of globals for VE-MW
Silly to have 38 MW-specific files needing to declare that they're using mw.

Change-Id: I97891ed922fe0c37d8c96425a4d23bd15098438b
2014-07-19 17:42:45 +00:00
Moriel Schottlender e94a185fda Update VE core submodule to master (ad18102)
New changes:
65042de Fix alien test data
83dccbe Add toolbar menu labels to each group for consistency
2e40ef9 Move 'language' tool from the insert to the styling menu, like in VE-MW
6fb21b2 Add toolbar action section to SA demo with keyboard shortcuts tool
f3eb000 ve.ui.Toolbar: Optimise onSurfaceViewKeyUp performance
eb4e9eb Make sure the document is focused when setting a selection
48584d3 Fixes to getRelativeOffset and getRelativeRange		
fcc427f [BREAKING CHANGE] Remove generatedContents argument from afterRender
825e4be Documentation fixes in test utils		
dbbbe0b Unit tests for showSelection		
1ba9234 Don't handle up/down on focusableNodes even if backwards
a667b87 Remove label from 'insert' menu, and instead use a large plus icon
88885b1 Localisation updates from https://translatewiki.net.		
1f3b79f Initialize data first		
18369b1 Add 'clone' and make 'getDimensionsFromValue' static in ve.dm.Scalable		
92e6b7b Switch to 'custom' when MediaSizeWidget updates		
d0cd87e Localisation updates from https://translatewiki.net.		
1ee21ff Remove lies from documentation		
164f07f Safely ignore requests to open unrecognized windows

Local changes:
Work on a cloned scalable when editing images

Make sure the image model handles a cloned copy of the node's
scalable object, which is then shared with the media size widget.

Bug: 67687
Change-Id: Ie3676b715f5bae3d83da03d667cef3a6a847e212
2014-07-16 22:38:09 +00:00
Moriel Schottlender 537e751abe MWImageModel unit tests
Change-Id: I87d1383b383e2a7cd6cb38ed51710cc36a59f63e
2014-07-15 12:47:32 +01:00
Alex Monk 51142e8b11 Replace ve.bind( fn, ... ) calls with fn.bind( ... )
Bug: 62762
Change-Id: I1a7fc7f27fa737d17f5c6b3d084ef4a35e4bebc0
2014-07-10 13:54:07 +00:00
Moriel Schottlender 01596205fb Unimplement wgSVGMaxSize
Because it doesn't work in MW.

Bug: 66865
Change-Id: Idad2352bee32cbf10c80a757c59e518abaa342de
2014-06-26 19:56:03 +00:00
Ed Sanders 840264e85d Remove Hiero extension code from VisualEditor extension
It doesn't belong here.

To be added in the wikihiero extension in If55af2ad.

Change-Id: Id8b026ac07cfb31e4c25f81fb67f531448454ee0
2014-06-23 09:18:42 +02:00
Ed Sanders c70d32c017 Use registered target, instead of ve.init.Target
Depends on I468d4eb4 in core.

Uses various hacks to trick the test runner into thinking
an MW target is in use, when in fact we still use SA targets.

Change-Id: If4611307d5d7aaee4af84f86ef82faf9078043b6
2014-06-17 20:41:01 +01:00
James D. Forrester 4be0218bbb Update VE core submodule to master (5f10e73)
New changes:
a53f101 Update OOjs UI to v0.1.0
1fa518b Update OOjs UI to v0.1.0-pre (15f4156bac)
257af53 Use ContextWidget instead of toolbar inside context menu
5f10e73 Follow-up Ia2076a42: Mark getDescription() as @inheritable for Annotation, Node

Local changes to adjust for the ContextWidget changes.

Change-Id: I47f68f5cf1b9583dab9bd0109fa6504481bdfc67
2014-06-09 18:35:08 -07:00
Roan Kattouw cc90e3c832 Followup bd49f97: prevent MWExtensionNodes from having children
MWBlockExtensionNodes would duplicate their children in the output DOM:
they would appear once as restored from originalDomElements, and again
because the contents then got converted to linear model data and
that got converted back to DOM as well.

Bug: 66396
Change-Id: I4513ffc1cf3eb8726ac94252fe1526fac6d8bdf3
2014-06-09 18:01:42 -07:00
Ed Sanders bd49f97553 [BREAKING CHANGE] Separate ExtensionNode in Block/Inline
Previously they were always inline.

MWExtensionNode is now a mixin and classes which inherit it should
now inherit MWBlockExtensionNode or MWInlineExtensionNode.

Change-Id: I0ddcabeb63acdf852e252c41add5233c00723f4c
2014-06-06 20:40:19 -07:00
James D. Forrester 2c00c39393 Update VE core submodule to master (2587549)
Update DM node constructors for I81c60d4a in VE core.

New changes:
2587549 [BREAKING CHANGE] Fix Node construction arguments

Change-Id: I8d4f37b631fe85a78c72407937477963ac49f87a
2014-06-06 20:28:03 -07:00
Moriel Schottlender 4355ea4f10 Followup to small SVG default size
Make sure svg drawings on block images have the default size as
the wiki default, no matter their original set size.

Also took the opportunity to clarify the synchronization method
for scalable and image type in ve.dm.MWImageNode and call it when
the image model is loaded to make sure the details are always
synchronized before edit.

Followup to I682d832e456a501836f33ed1dfc7dbd78a4edf53

Bug: 62893
Change-Id: Ic47016d171634c532092067957cc2c3d431e9746
2014-06-04 19:38:15 -04:00
Roan Kattouw 7d86729858 Decode URL encoding in resource attriute for images
In getFilename(), decode URL encoding and replace the search
for 'File:' with a more standard ./ stripping regex.

The ./ regex came from generateContents) in the CE class;
made that code use getFilename() instead.

Also apply decodeURIComponent() to the result; but protect against
exceptions because it's a useless piece of garbage.

Bug: 65611
Change-Id: I7e81a8dc26d1c636c6571d96f43a394a53490587
2014-05-28 12:21:06 -07:00
Moriel Schottlender 37b3c07b26 Image model and the media edit dialog
Creating an MWImageModel that handles all image edit operations.
If the new attributes mean a change of image types from inline
to block or vice versa, the model will handle the creation and
insertion of the new node.

Change-Id: Ibe71bc8bd74e4ba5a024ac722432ccf0b8f65e71
2014-05-19 21:11:06 -04:00
jenkins-bot 424c4e4764 Merge "Revert "Cache image scalable promises by filename"" 2014-05-14 22:56:39 +00:00
Catrope 582daaeb70 Revert "Cache image scalable promises by filename"
Caused bug 65314.

This reverts commit 97bc12a421.

Bug: 65314
Change-Id: Iaca46e5458fbc44446cc92e7241dd24d7de883d8
2014-05-14 22:54:48 +00:00
Roan Kattouw a15fa5a17c Make citation tools' compatibility check use normalized titles
Greatly enhance the functionality of ve.dm.MWTransclusionNode#isSingleTemplate
and actually use it places.

Use mw.Title to normalize titles, accounting for case differences and
spaces vs underscores. Also allow an array of template names to
be specified.

Use isSingleTemplate() in the transclusion and citation dialog tools,
which were duplicating this logic. Also document the .static.template
properties.

Without this, the citation tool will appear for a reference using
{{Cite news}}, but not for one using {{cite news}} or {{Cite_news}}.

Change-Id: I18d2bb1b22a5ab269694ad0818b1bb326ef8d1fd
2014-05-10 21:10:09 +02:00
Moriel Schottlender 97bc12a421 Cache image scalable promises by filename
Make sure that each API request per file is delivered once. If the
file appears more than once on the page, the API request for
scalable details will be sent once and cached so there aren't
multiple API requests per image.

Change-Id: I68507a8ceb31b77dbf33d1074939ce6219cf076e
2014-05-09 11:17:06 +02:00
Roan Kattouw f2422d916c Update VE core submodule to master (c150259) for scalable changes
ve.dm.Scalable is now a computational model for image scaling and
size manipulation. This commit adjusts the nodes and the edit and
insertion dialog to handle the new scalable model, and by that
use a centralized computational engine for all scaling and size
changes.

New changes:
3ec19fb8 Refactor Scalable functionality

Change-Id: I017a017924f544cc8bc9b7d8245335759ae0e890
2014-04-09 17:29:49 -07:00
Trevor Parscal 793fbb0e24 Correctly insert or update citations based on template option
When using a tool that opens a citation or citation transclusion dialog,
the dialog shouldn't use edit mode unless the template in the node and the
template the tool would insert match.

Bug: 63452
Change-Id: I34a5a2da576247f4046da45f742bccc3cec22c5a
2014-04-02 16:38:34 -07:00
Trevor Parscal be199c0bf2 Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag

Changes:

* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget

Configuration:

If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:

[
    { "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
    { "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
    { "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
    { "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]

...or...

[
    {
         "name": "any-name",
         "icon": "any-ooui-icon",
         "template": "Any template",
         "title": "Any title text"
     }
]

The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.

Depends on Ic353f91 in oojs-ui

Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-24 19:24:38 +00:00
James D. Forrester aea64bf2df Remove the math inspector code
Moved to the Math extension in I8e582ee6deadc2750

Change-Id: Iab0c56246626de1e0f6ab770e777c0a28756fa75
2014-03-19 19:27:25 -07:00
Moriel Schottlender 5f2ce173a0 Enforce width-only default size only on larger images
While the documentation is unclear, it seems that the 'thumbsize' in
$wgDefaultUserOptions is setting up width limit rather than a general
bounding box.

Things that are adapted in this fix:

* Only resize the image if the image is bigger than default and marked
  as default size.
* Only limit width, even if the image is tall.
* Add rounding to calculated height value.
* Make sure new images follow these rules as well on insertion.

Bug: 62293
Bug: 62279
Change-Id: I37525bf3480bb1da8b0538f9b38576616aabbfa6
2014-03-10 19:05:14 +00:00
Roan Kattouw c0380f16a4 Work around DOM corruption for default-sized images
This doesn't really fix the underlying issue that the
width and height are overridden to be the default size
in the DM even if that's wrong (in the case the image's
original size is smaller than the default thumbnail size),
but it fixes the DOM corruption by storing the original
width&height and restoring them if the image still has
defaultSize=true on the way out.

Bug: 62172
Change-Id: Iaee798c5bb501310e52d0ac832b2e7cd833fc438
2014-03-05 17:44:01 -08:00
Moriel Schottlender 89aecd54ba Deal with 'none'/'border' and default size in media edit
There are several conditions to defaultSize behavior of thumbnails and
frameless images and other images when it comes to default size. In the
same principle is 'border' which is not quite a type despite the fact
it 'behaves' as such in wikitext (and has a unique identifier that comes
instead of the other types.

This commit aims to organize this behavior for the user in an
understandable manner.

* Add 'basic' image type for images that have no specified type ('none')
* Handle the difference in 'default' size behavior between basic images
  and thumbnails/frameless. The thumb/frameless images have the default
  wiki size. Other images' default size is their original dimensions.
* Force wiki-configured default size for thumbnails and frameless images
  in the DM. This is done because at the moment Parsoid's output is of
  Wikipedia's default size rather than the local wiki's. The size is
  adapted if needed, directly in the DM.
* Added 'border' as a pseudo-type checkbox flag that sets css class
  'mw-image-border' is for parsoid rendering on save.
* Add 'make full size' to the size widget select and treat it as a faux
  default button for basic and frame images.

Bug: 62013
Bug: 62024
Bug: 61155
Bug: 61059
Bug: 61282
Change-Id: I6778705306f0dd6bb96afeb91383089a4ddab7ed
2014-03-05 03:53:46 +00:00
Moriel Schottlender b54575a797 Set up wiki-default image size
This commit makes several adjustments to make sure default size is being
handled correctly:

* Add wiki's default size configuration parameter to the
  VisualEditor.hooks.php file so it can be called from VE.
* Make sure new images are inserted with default size and are
  marked 'defaultSize = true' for the DM to handle.
* Force default size if 'defaultSize=true' in the DM
* Add a 'default|custom' switch to the media edit dialog for size
  inputs. When 'default' is chosen, the media size widget will be
  emptied, displaying its placeholders (default size)
* When the size widget's values are 0 it will automatically turn to
  default size values. If the value started default and the user
  typed in a size, it will automatically override default and use
  custom size.

Bug: 47804
Change-Id: Ib973ea2afa96090a4ba61b2b55ee63457f1329c1
2014-02-25 16:26:15 -05:00
Timo Tijhof 58c647e3ac Ensure we use our references to certain native or upstream methods
Checked:
 ve.cloneObject       (oo|OO).cloneObject
 ve.getObjectValues   (oo|OO).getObjectValues
 ve.getObjectKeys     Object.keys
 ve.compare           (oo|OO).compare
 ve.copy              (oo|OO).copy
 ve.isPlainObject     ($|jQuery).isPlainObject
 ve.isEmptyObject     ($|jQuery).isEmptyObject
 ve.isArray           Array.isArray
 ve.bind              ($|jQuery).proxy
 ve.indexOf           ($|jQuery).inArray
 ve.extendObject      ($|jQuery).extend

Fixed:
* ve.dm.MWBlockImageNode.js (added in Iebb2081de)
* ve.dm.MWInlineImageNode.js (aded in I62ec12a6b)
* ve.dm.MWConverter.test.js (added in I90273786a)
* ve.ui.MWMediaInsertDialog.js (added in Ia5ad9a8c0)
* ve.dm.MWTemplateSpecModel.js (added in Ic3eb66538)
* ve.init.mw.MobileViewTarget.js
* ve.init.mw.ViewPageTarget.js
* ve.init.mw.Target.js

Skipped:
* ve.init.mw.ViewPageTarget.init.js
  - Feature test (which is for the very references from ve.js
    being ensured in this commit).
  - Misc code using $.inArray (can't use ve.js yet since that
    isn't loaded yet there).

Change-Id: I73ae005d3692e871fdcaea938641558c0b98ec69
2014-02-20 22:30:29 +01:00
Roan Kattouw 2598fe8088 Use apiRequest() function in MWMediaEditDialog
Change-Id: I4fbc3f2080660b217beb502c6cf3007197627a14
2014-02-06 22:37:04 +00:00
jenkins-bot 78680bb527 Merge "Adding alternate text to media edit dialog" 2014-02-06 02:59:21 +00:00
jenkins-bot 20d6df9a65 Merge "Only generate transclusion contents for clipboard" 2014-02-05 23:02:28 +00:00
Moriel Schottlender e8205a7133 Adding alternate text to media edit dialog
Adding an option to add or edit alt text to images in the media edit
dialog.

Bug: 38129
Change-Id: I6d339781822175c40c66a4689ec6e1a873cb081d
2014-02-05 20:56:30 +00:00
Ed Sanders 61d010df2f Move image info API call to media node
As other widgets may be interested in the image info, this should
be part of the DM node, which the media edit dialog then fetches
and uses to populate the MediaSizeWidget.

Other fixes:
* Remove spinner, not really necessary as the orignal size button is
  disabled if the orignal dimensions aren't set.
* Don't wait until image info call to resolve to initialise size
  widget values. These should always be available instantly from the
  attributes.

Depends on I9530ed4257e88b in core.

Change-Id: I394f49941b621059bc08c8a8f79471b2fe16c7d8
2014-02-05 12:48:31 -08:00
Ed Sanders 13eb918087 Only generate transclusion contents for clipboard
Parsoid doesn't care about the transclusion contents and it can
cause bugs if not removed properly. Remove the about group attribute
as that was for Parsoid's benefit.

Depends on Ib29972472d in core.

Bug: 60897
Change-Id: I907b2113c257baff5c022ff0749dca9dbb1fba5f
2014-02-05 12:45:55 -08:00
Ed Sanders bdb4a8a149 Simplify toDataElement in MW
As per I54943588c5cc2 in core.

Change-Id: Ia40e7327c4ce07a79d64a6d5b1ff0d7acec55171
2014-01-27 18:43:36 -08:00
Roan Kattouw 4aeb773404 Add tagName to ve.dm.MWGalleryNode
I told James this wasn't needed, but I was wrong. It is null in
the parent class, and DOM throws on document.createElement(null).

Bug: 60307
Change-Id: Iff8fda9acf9f37e537d7d6cf6106a801d6b71338
2014-01-27 14:28:16 -08:00
Trevor Parscal 92746ef3da Implement 'change' events in templates models
This will make generating live previews possible.

Changes:
* Add change events to template model.
* Set up connect/disconnect.

Also:
* Add missing fallback for getParameterLabel (Param#label is
  optional per the TemplateData spec).
* Implement getWikitext, to be used by the UI dialog later
  to create a preview from the wikitext.
* Correctly mark ve.dm.MWTransclusionNode#escapeParameter as
  being a static method.

Change-Id: Ie306ed03babf11568e954b1813ce5324f57d7f0e
2014-01-22 19:03:17 +00:00
Ed Sanders fdb4062aec Remove unnecessary strangely written range clone
Probably left over from when the range calculation was more complex.

Change-Id: I59c989bac0d80f4a12e57cbd41bdc6587acd964a
2014-01-21 17:35:45 +00:00
jenkins-bot adf8249688 Merge "Ultra-basic gallery editing" 2014-01-15 23:27:06 +00:00
James D. Forrester 842688c51b Ultra-basic gallery editing
'Cos Erik doesn't like things he can't edit.

Change-Id: I1d9fb1215bb16b1245eddd87c977fb5bfdee4da9
2014-01-15 15:13:12 -08:00
Ed Sanders 3059fecc5f About-group extra DOM data in toDomElements
Although marked as data-ve-ignore, it isn't ignored by Parsoid,
so about group it together as well.

Bug: 59002
Change-Id: I263e316fb10f3e6f23fc1d409686cdefbd28fafa
2014-01-15 11:06:25 +00:00
Ed Sanders b2b9f217da Wrap text nodes in spans if trying to mark as data-ve-ignore
Otherwise you're going to have a bad time.

Bug: 59002
Change-Id: Ifd90087b3d36f412420b9786f3d54a5418846d03
2014-01-14 23:42:49 +00:00
James D. Forrester 0ffd654bed Bump copyright like it's 2014
Change-Id: Ic469ebda2c061dc7da0b4c1625f43a7be55da4fa
2014-01-05 20:06:50 +08:00