Commit graph

106 commits

Author SHA1 Message Date
jenkins-bot 3dfc960576 Merge "Store DM nodes in InternalList" 2013-06-04 17:06:24 +00:00
Ed Sanders 2925966944 Store DM nodes in InternalList
Also keep items in the order they appear in the document
and grouped by group and key.

Additions and removals are triggered by the new root/unroot events.

Change-Id: Ia3e90ccfdab88f352b89992b90554e5f03ff9952
2013-06-03 22:10:07 +01:00
Inez Korczyński 394a40f27c Convert GeneratedContentNode into a mixing (instead of an abstract class).
Change-Id: I280d2a59326bd83357c7a09c3a188a70fbc75335
2013-05-29 14:54:57 -07:00
Trevor Parscal b0f464ef0e Add support for editing multi-template nodes
Objectives:

* Refactor template dialog to support loading template data for, and
  editing multiple templates and interleaved content in a template node
* Update template node model to generate multi-template wikitext

Changes:

ve.dm.MWTemplateNode.js
* Rewrite getWikitext method to work with multi-template formats

ve.dm.MWTemplateDialog.js
* Retain information about the node and template calls
* Break AJAX handler into its own method
* Attach event handlers to inputs directly so template values are
  edited directly on the fly
* Refactor page building to support multiple templates
* Add multi-template support for template data API call
* Add support for editing plain text content

Change-Id: I92ff8a9e186701a3f8da88def92a5b7dcb607897
2013-05-29 01:10:57 +01:00
Trevor Parscal 4c5c18c241 Compare objects/arrays fix
Objectives:

* Fix compareObjects so it doesn't break when given arrays
* Remove compareArrays
* Rename compareObjects to compare and update callers of both methods

Changes:

ve.js
* Loosen check for whether to recurse so both arrays and objects qualify
* Remove compareArrays
* Rename compareObjects to compare

ve.dm.MWTemplateNode.js, ve.dm.AnnotationSet.js, ve.dm.Document.js,
ve.dm.Transaction.js
* Update uses of compare(Arrays|Objects) to use compare

Change-Id: I7d4f7ceb28c0389f0157b7598e291f21393b5b85
2013-05-29 00:39:04 +01:00
Inez Korczyński 0b46b44809 Add class mw-figcaption to figcaption tag inside mwimage
This is currently required by Parsoid in order to serialize
(HTMLDOM -> wikitext) correctly.

Change-Id: I827f63420d05c62d689902c9b348d234f20a5d19
2013-05-28 23:21:59 +00:00
Inez Korczyński 476d10b1c3 Adjust coverter getDomSubtreeFromData method call inside ve.dm.MWBlockImageNode to pass correct arguments (there was an API change).
Change-Id: I1918aee714363babf5182c699fd96ef9fd4fce55
2013-05-28 16:01:16 -07:00
jenkins-bot 5add8cc4c0 Merge "Cleanup internalList method names and data stores" 2013-05-28 14:39:14 +00:00
Ed Sanders aa6eca10db Cleanup internalList method names and data stores
Rename some methods and erase the HTML data after conversion.

Change-Id: Ic7317db2c7693591fda4bea459631981a69003f3
2013-05-28 15:11:17 +01:00
Trevor Parscal 3be13a7cbc Consistent use of mw in HTML classes, and data element and annotation types
MWfooBar or MWfoobar should be mwFooBar

Change-Id: I30f0ef05960c9df218ef6f1cb161ff6ccd529bc7
2013-05-28 13:49:56 +01:00
Catrope cba55b9330 Don't do evil shadowing of mw
Having local variable called mw that shadows the global variable mw
is evil. Rename it to mwAttr.

Change-Id: I87bd3698c73608076424c10fdb0559dfdc3e3045
2013-05-26 14:34:47 +02:00
Catrope c36df77e3f Make reference editing work
The only reason it doesn't save correctly right now is because Parsoid
doesn't serialize reference edits correctly.

Change-Id: Ia0f272c07cc28ee829372eb848f23aec99eb92f0
2013-05-25 18:06:57 +02:00
jenkins-bot c6e06f3917 Merge "Merging and remapping of IVStores and InternalLists" 2013-05-25 11:37:12 +00:00
Catrope 238d68eb74 Merging and remapping of IVStores and InternalLists
Add merge() methods to IndexValueStore and InternalList, which merge
another store/list in to the current one and return a mapping
translating old indexes to new ones.

Also add functions that, given such a mapping, traverse a linear
model data array and remap store/list indexes using simple logic for
annotations and node type-specific functions for node attributes.

Change-Id: I1e90755ced1a87c190947c037cf151c4d17cf8b7
2013-05-25 11:33:35 +00:00
Inez Korczyński 1d7cf569e6 Support for thumb and frame images with captions.
* VisualEditor.hooks.php
** export URL to magnify clip as a configuration variable so thumbnail image can render correctly

* ve.ce.Surface.css
** add CSS styling to make image captions look the same way in edit mode as they look in the view mode

* ve.ce.ParagraphNode.js
** add CSS class ve-ce-generated-wrapper if it is a generated wrapper

* ve.ce.MWImageCaptionNode.js
** make image caption rendering match the view mode

Change-Id: I0cd1b25e8f8355e0500aabc90e7c4cdf591545f3
2013-05-23 00:44:43 -07:00
Inez Korczyński 02d522500c Fix for check if data is balanced
Previous check wouldn't make sense, cause the last offset in the data
could be that one that makes data balanced (and j is increased always
after iteration).


Change-Id: Ie9498d0ac9e3417d09b8b3043bf3281e7dfbf9db
2013-05-22 14:19:42 -07:00
Trevor Parscal e64d900fc3 Fix image block node error
When loading an image block node in the demo, there are no classes on the figure, which caused the code to crash because it was assuming that jQuery's attr method would always return a string.

Change-Id: Ib13e7bfa3fb2bd76ac71dfef085bed209d880b4a
2013-05-15 16:24:10 -07:00
Catrope 54cd04c391 Implement ve.dm.MWTemplateNode.getWikitext()
Escapes }} and | by wrapping them in <nowiki> tags, and steps around
<nowiki> tags so as to not double-wrap things.

Change-Id: Ia50906524c1fcf55c9f390a114856bc7f20b2d3a
2013-05-15 15:16:34 -07:00
Inez Korczyński c6c7af5a62 Better support for MediaWiki block level images (thumb and frame)
Change-Id: Id6f65e4e1971e21035c89f32fa7ab0009c84695c
2013-05-14 17:14:36 -07:00
Trevor Parscal cce80e63c0 Fix for crashing on save
converter.documentData contains the full data with metadata interleaved,
but it was being sliced using offsets relevant to the element data.

Change-Id: Iddbef23212da818a2a399b4abdc223aad130eb4e
See: I6daff5c5969e5fdc871f8f346cf790b4302ae080
2013-05-14 21:34:06 +00:00
Ed Sanders 3495c6f747 Clone template dom elements being sent to converter
The dom elements in the IV store are used for rendering, so if they
are sent by reference to the converter they get re-attached, causing
all templates to disappear from the page whenever you press 'review
and save'.

Fix is to run it through ve.copyArray, which clones all the nodes.

Change-Id: I1b03351a28ac82e0fdb7e94e761cf65d6548e501
2013-05-09 13:42:44 +01:00
Catrope 05828cc3f1 Preserve HTML attributes recursively
For nodes that handle their own children (as well as leaf nodes and
meta items), store the first child's attributes in html/0-0/*, the
second child's attributes in html/0-1/*, the second element's third
child's fourth child's attributes in html/1-2-3/* , etc.

This obsoletes the ad-hoc code that basically did the same thing in
MWInlineImageNode.

Change-Id: If5abd2d5d9c361b359617ff4b0f3d6ba4c9b0142
2013-05-08 11:10:07 -07:00
Catrope 85d67ce44f Do proper HTML preservation in ve.dm.MWReferenceListNode
Store the HTML as a domElements array like everywhere else, rather than
as a string. Also disable HTML attribute preservation because there's
no point doing that when we're already preserving all of the HTML.

Also fixed a misnamed attribute (<li li="foo"> --> <li id="foo">) in
the test case.

Change-Id: I36bf8bade8118e07a75eb6f3a2427a00ef4915d7
2013-05-07 21:41:29 -07:00
Ed Sanders 830de420e1 Code style fixes
* "function(" -> "function ("
* "{String}" -> "{string}"
* collapse unintentional double spaces

Change-Id: I3ce3f02d1e31d4797b44e04d28457dec363be296
2013-05-06 12:36:52 +01:00
Roan Kattouw c801099c7b Hack MWTemplate so it also does partial type matches
For extension-specific types such as mw: , we require that all
types be matched. But we want MWTemplateNode to match
anything with an mw:Object/Template type, even if it also has
other types (like mw:WikiLink/Category in our test case).

Hack this into MWTemplate by matching on /^mw:/ then using
a matchFunction to assert that mw:Object/Template is in the
typeof attribute.

Update the test case. Because it's now a template, there's a bunch
of store stuff involved. Remove the other test case for about
group forcing because it's now a duplicate of this one.

Change-Id: Iacbe952a66d610c19b46bd76b84c50488857ac29
2013-05-05 00:07:30 -07:00
Ed Sanders 7cb4a30ff3 GeneratedContentNodes store DOM elements, not HTML (like aliens)
To avoid serialisation bugs, and for consistency.

Change-Id: I02e202a2ab52c88da039349ec079bea55e000665
2013-05-02 18:22:56 +01:00
James D. Forrester b9ba3c92a3 Add support for <div>s as user-editable blocks
Bug: 47907
Change-Id: I794927a881082e0113c0ce8ee8f1d908b0960899
2013-04-30 18:43:41 -07:00
Ed Sanders cddb3f1b39 AlienNode stores original DOM elements instead of HTML
As jQuery hash problems in some cases converting HTML, it is
easier just to store the original DOM elements.

The bulk of this commit is fixing the tests as although we have an
assertion for comparing DOM elements, we don't have one for comparing
objects or arrays which may contain DOM elements.

ve.js
* copyObject & copyArray fixed to run cloneNode(true) on any item
  of type Node.
* Added callback function so an object/array can be copied with
  modifications.

ve.qunit.js
* Added deepEqualWithDomElements: Using the new copyObect/Array
  callback, we can copy the incoming object and convert any nodes
  to node summaries, then just run the normal deep equal comparison.

ve.dm.AlienNodes.js
* Instead of storing HMTL we store cloned DOM elements which we can
  send straight back to the converter without any processing.

ve.dm.example.js
* Updated tests to expect DOM elements instead of HTML.

ve.dm.Converter.test.js
* Updated tests to use deepEqualWithDomElements

Bug: 47737
Change-Id: I3df8f49b170c31da9610129d53cf8cb65dd5d5f8
2013-04-27 21:04:58 +00:00
Roan Kattouw c68765639a Add TableCaptionNode
Because we have a node for <table>, we also need one for <caption>,
otherwise we'll try to alienate it and fail.

Added the test case as a separate example document so Ed can use it
for his tests.

Removed test case asserting <caption> is alienated.

Change-Id: I3a917db58e6c0eb97899b214b07d01fc8d86b56d
2013-04-26 14:09:54 -07:00
jenkins-bot 8d4c87a388 Merge "Initial support for MWBlockImageNode - thumb images with captions :-)" 2013-04-25 23:36:08 +00:00
Inez Korczyński 4c6d296067 Initial support for MWBlockImageNode - thumb images with captions :-)
Change-Id: I4d81533ed9193ff934333f7c1ad80e03e33b236c
2013-04-25 21:49:32 +00:00
Ed Sanders bdb4a116d9 Hack to escape angle brackets in data-parsoid attribute
Parsoid is sending us some unescaped HTML in the data-parsoid
attribute. When we try to rebuild ref nodes (inline aliens)
this confuses Firefox which tries to sanitise the HTML by converting
<ref/> to <ref></span>.

As a temporary fix we can manually escape <>'s inside the
data-parsoid attribute.

Also in this commit the new MWReference nodes have been moved
to experimental as they are incomplete.

Bug: 47417
Change-Id: Ib6a0cfb880e769f28b42c9fa63ddc1abc75c399d
2013-04-25 14:55:17 +01:00
Inez Korczyński 6b7d62e4a4 Rename MWImageNode to MWInlineImageNode (get ready for adding MWBlockImageNode soon)
Change-Id: I617e2a17cb6fbd11e486c2981e361ae931ac1870
2013-04-24 16:49:07 -07:00
Christian Williams f8f82c8eaa Selecting generated content with cursor keys
Using left and right arrow key to move to and over an image will
select the entire node.

Bug: 37870
Bug: 38129
Change-Id: I70deadd2c2707149ea33e3b8ee42fb0d8508aacc
2013-04-24 13:22:41 -07:00
Ed Sanders 6ad61d4ddb Add data model support for MediaWiki references
So far just read-only.

Bug: 39599
Change-Id: I6daff5c5969e5fdc871f8f346cf790b4302ae080
2013-04-23 10:17:42 +01:00
Ed Sanders 2bd6f8576a MWTemplateNode should serialise original HTML if unchanged
To help the selective serialiser we can return the original
HTML for generated content if it is unmodified.

As the output of toDomElements now depends on changes
to the dataElement we now have a 'modify' function in
the some test cases.

We also now have 'storeItems' to assert that the index-value
store is correctly populated and for loading values back
into the store for toDomElements tests.

Also make 'mw' an attribute and remove 'about' property.

Bug: 47394
Change-Id: I2bbb5d2d6a90c4eb87fa129671112c92a9b931e7
2013-04-22 20:44:21 +00:00
Catrope 42c1aa10cd Serialize alienated context-sensitive nodes correctly
Context-sensitive nodes are HTML elements like <caption> that can only
appear in certain contexts (<table> in this case). This means that
serializing them by throwing them in a <div> and calling .innerHTML
fails, because the browser knows a <caption> can't be in a <div> and
unwraps it. jQuery's .html() function is clever though and knows to wrap
<caption> in a <table> (and has similar rules for other elements).
So use jQuery's .html() rather than manual .innerHTML stuff.

Change-Id: Id7d3eff968b3a2ba345680772f7cc32e3dcdb529
2013-04-17 18:26:54 -07:00
Ed Sanders 6dacc54954 Hybridise MWTemplateNode
* Create MWTemplateBlockNode & MWTemplateInlineNode (in ce and dm)
* Move Alien's 'isInline' code to ve.dm.Node.static.isHybridInline
* Move definition of ce.AlienBlock/InlineNode inside ce.Aline.js file
  to match dm.AlienBlock/InlineNode and MWTemplate
* Duplicate AlienBlock/Inline styles for templates
* Create test case for inline templates
* Count test cases in ve.dm.Converter.test.js automatically

Change-Id: Id9bc7f049ea974dd5e7f8b7a66080939e0948bbd
2013-04-14 02:34:18 +00:00
Ed Sanders 01eda7f36a Create MWTemplateNode
This node stores the rendered in the index-value store, hashed on
a custom hash of the dm (type + mw) which makes it unique it its
parameters.

Bug: 46571
Change-Id: I0ab4c9f7bca207121d5b42e83c821771b6139da8
2013-04-11 23:58:48 +01:00
Catrope 76b080dce1 Pass the converter object to the node handler in toDataElement()
This will allow node handlers to recursively invoke getDataFromDomRecursion()

Change-Id: I12cd4b31614a549bfbe8fbdc7d0607ece32aa98a
2013-04-11 11:12:44 -07:00
Trevor Parscal 9510440640 Image node refactor
ve.ce.ImageNode.js
* Moved in generic stuff from MWImageNode
* Added drag end handler (empty, will be used soon)

ve.ce.MWImageNode.js
* Changed to inherit ImageNode
* Moved generic stuff out

ve.dm.ImageNode.js
* Added attribute extraction/preservation for src, width and height

ve.dm.MWImageNode.js
* Changed to inherit ImageNode
* Re-using ImageNode's attribute handling to extract/preserve attributes on both the image and wrapper level

Change-Id: Ied4e1ece24e6804220eac35330790f7084df55de
2013-04-10 14:56:08 -07:00
Ed Sanders 62c06d0253 Create GeneratedContentNode which can store rendered HTML in IV store
AlienNode is now a subclass of GCNode, but doesn't use the IV store yet.

Bug: 46571
Change-Id: If0717afdf557a2aa681d1bae3a6e98299631091a
2013-04-10 19:34:19 +01:00
Catrope 316fdab450 Actually use the doc parameter in toDomElements()
It's been passed in for a while, but nothing ever used it. As we know
some browsers don't like it when we create elements in the wrong
document, and this ensures we always use the correct document for
createElement().

Change-Id: Ia3d2fabe0516956105ad2b5625ed2f76c015c26e
2013-04-09 23:48:03 +00:00
Ed Sanders 5b168bdbad Fix MWImageNode dimensions and implement toDomElements
Using element.height was returning 0 if the attribute was empty
when in fact what we mean to store is null (i.e. auto height).

This takes care of the writing of attributes in CE as jQuery
ignores an attribute-set command if the value is null.

Also in this commit I've implemented a basic toDomElements
that outputs the original HTML (code copied from AlienNode).
This stops the code from throwing an exception but will
eventually need to be rewritten to rebuild the HTML from
the attributes stored in the DM.

Bug: 56336
Change-Id: I297a1d0a07e9ebf9d0110fb1cdf266f8415f25b7
2013-03-29 12:51:43 +00:00
Inez Korczyński 21e4fdc014 Added support for displaying inline images.
Change-Id: Ieecbca8ed864585e8eaa99598d4bfdb5ac9bfec7
2013-03-28 13:05:57 -07:00
Catrope a835c03bc1 Change MetaNodes to MetaItems
Rather than meta-things being special kinds of nodes, they are now a
separate class of things (MetaItems) along with Nodes and Annotations.

* Created a generic ve.dm.MetaItem that meta items inherit from.
  There will be actual instances of this class as well in the upcoming
  meta group code.
* Renamed MetaNode to AlienMetaItem, MWMetaNode to MWMetaItem,
  'metaBlock'/'metaInline' to 'alienMeta'
* Created a MetaItemFactory, handle meta items in the ModelRegistry
* Kill ve.dm.Node.static.isMeta, now obsolete

ve.dm.Converter:
* Pass in the MetaItemFactory
* Look up data element types in the ModelRegistry rather than the
  NodeFactory, because they can be either nodes or meta items
* Document createDataElement() and make explicit that modelClass can be
  either a node or a meta item
* Handle meta items in getDataFromDom()
* In getDomFromData(), check the MetaItemFactory as well as the NodeFactory

Change-Id: I893709c6f3aa00f85c1b905b70f9f4e597bdeada
2013-03-14 23:35:50 -07:00
Ed Sanders 0ce20b6e16 Create MediaWiki specific nodes to contain MW specific rules.
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
2013-03-12 16:28:29 -07:00
Ed Sanders edcaaf9edc Use static.name once for ce and dm nodes
Add a static.name property to ce nodes and make sure both ce
and dm nodes always use the static.name property in constructors
and registration calls.

The result of this is that any given node type should now only
appear once in the code as a string.

Bug: 45701
Change-Id: Ibf31de16ab28ad58209c1443cd74f93dda278998
2013-03-07 17:19:39 -08:00
Catrope 04c72f6871 Add MWMetaNode to clean up <meta>/<link> hack in the converter
Change-Id: I4c69bff4981eef78415b43d31c3fd2ee271450ef
2013-02-22 15:21:40 -08:00
Catrope 2e36f1542b (bug 45062) Implement the new node API in the converter
This changes the node API to work with multiple elements, so we can
support about groups. Instead of passing in and returning single DOM
elements, we use arrays of DOM elements.

ve.dm.Converter:
* Pass modelRegistry into the constructor
* Remove onNodeRegister handler and its data
* Remove getDataElementFromDomElement() and
  getDataAnnotationFromDomElement(). Most logic moved into
  getDataFromDom(), some into createDataElement()
* Remove createAlien(), replaced with
  createDataElement( ve.dm.AlienNode, ... )
* Replace doAboutGrouping() (which wrapped about groups) with
  getAboutGroup() (which returns an array of the nodes in the group)
* Put in a hack so <meta>/<link> elements with an mw: property aren't
  alienated
* Remove about group wrapping behavior in favor of just outputting
  multiple nodes

ve.dm.AlienNode.js:
* For multi-element aliens, only choose inline if all elements are
  inline, not just the first one

ve.dm.example.js:
* Add html/0 stuff for meta nodes
* Fix test case to reflect new alien behavior

Change-Id: I40dcc27430f778bc00a44b91b7d824bfb2718be6
2013-02-22 15:21:40 -08:00