Commit graph

124 commits

Author SHA1 Message Date
Ed Sanders 1a86cb9c61 Preserve location of reference body within key
Previously we populated the reference body into all <ref> tags
with the same key. Now we store an internal attribute marking
which element originally had the data.

If that tag is deleted the body is moved to the first <ref> tag
with that name.

Change-Id: If9f12bfb699e6ce85bb8f7d2ea9e6df528610a3d
2013-06-10 02:54:26 +00:00
jenkins-bot cd2f411a93 Merge "Support for inline images" 2013-06-07 23:13:19 +00:00
Inez Korczyński 2f15cb0067 Support for inline images
Handles typeof mw:Image and mw:Image/Frameless

Change-Id: Ie2fbd4a3e12fb6faa4ab8e6dd0aa8d1334ff6498
2013-06-07 23:09:32 +00:00
jenkins-bot 72f661dc69 Merge "ve.dm.MWBlockImageNode: Make toDomElements add more information to its output so round-tripping can work properly." 2013-06-06 21:46:21 +00:00
jenkins-bot 8c20fb278f Merge "'typeof' for templates changed in Parsoid, it is 'Transclusion' now and used to be 'Object/Template'" 2013-06-05 23:06:15 +00:00
Inez Korczyński 2f58dd3d40 'typeof' for templates changed in Parsoid, it is 'Transclusion' now and used to be 'Object/Template'
Change-Id: Ia5b826bc1a2a648a8e618642697484000b68bfc2
2013-06-05 15:31:51 -07:00
Ed Sanders 22d1908bd4 Update reference lists and inline numberings automatically.
The easy part is getting the correct numbers from the InternalList
and generating the ordered list HTML. The tricky part is connecting
up the events to make sure the renumberings/list generations are
triggered when required.

InternalList can emit an update event on document transaction, which
triggers the renumbering/relisting if any references have been
added or deleted during that transaction.

ve.ce.MWReferenceListNode also listens to changes on the
InternalListNode (i.e. changes to the contents of the references)
and always triggers a rebuild.

Change-Id: I1b48ef5240e433c3b314259aa68cde13841ea98b
2013-06-05 15:11:16 -07:00
Inez Korczyński d14b2c514d ve.dm.MWBlockImageNode: Make toDomElements add more information to its output so round-tripping can work properly.
Change-Id: Ieacf9187371a1687869bcb4bb0244f1bc251a803
2013-06-05 14:37:28 -07:00
Timo Tijhof b463c5d377 jshint: Fix trailing comma
Due to the "es5: true" jshint option we enabled, these
warnings were surpressed. I've disabled the option since
we no longer require it. It was enabled in 07c86fc to fix
a bug with jshint. This bug has now been fixed.

Change-Id: I55b7d031eb5581af5f733f050cf2ea98dacb2af6
2013-06-05 13:00:49 +02: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 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 8511f8ab3e Treat acronyms like words in camel case names
No matter what the W3C says, getDomFromHtmlString is more legible than
getDOMFromHTMLString.

Change-Id: Ic843b6671871024cce8acd82b6be435599ed168b
2013-05-28 12:51:41 +00: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 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 cc59e59647 Merge "Correctly populate internalList for example documents" 2013-05-24 22:55:36 +00:00
Catrope 8157bcc474 Correctly populate internalList for example documents
Right now the internal list is very much HTML-based, so it's not
populated at all when creating a document from data. So hack this in by
specifying what should be in the internal list as a property of the
example document's data array.

Change-Id: I51c7b7b4dcd9fd3333777c1287b7ba544887aa32
2013-05-24 17:39:45 +02: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
Catrope 9ff6737f4c Refactor HTML attribute preservation
Rather than using namespaced linmod attributes, store the preserved
HTML attributes in the .htmlAttributes property of the linear model
element, in a nested structure to allow for easier treatment of child
nodes. Also added attribute order preservation by storing attributes
as an object plus an array of keys.

ve.ce.Node.js:
* Remove html/* attribute synchronization. Doesn't make sense any more
  because these things aren't in the attributes object any more. I don't
  think it ever made sense because these attributes were never supposed
  to be changed anyway.

ve.ce.View.js:
* Replace renderAttributes() with a simple wrapper around
  renderHtmlAttributeList()

ve.dm.Converter.js:
* Add buildHtmlAttributeList() and renderHtmlAttributes() for building
  and rendering HTML attribute lists

ve.dm.Model.js:
* Add getter for .htmlAttributes

ve.dm.Node.js:
* Drop .htmlAttributes on clone, and remove logic dropping html/*

ve.ui.MWCategoryWidget.js:
* Remove html/0/about hack, was already unnecessary and now doesn't
  work any more

tests/:
* UPDATE ALL THE TESTS

Change-Id: I620573afd70d36ade6b80413075b6e1f4a435abe
2013-05-17 20:57:33 -07:00
Ed Sanders 89b0dce8ec ListAction tests
Unwrap and wrap cases.

Change-Id: If4df07eae1d70347dc55b57dc117f2ff5c7385df
2013-05-13 18:59:53 +01:00
Ed Sanders 328dd8e21f Whitespace between unwrapped inline nodes assigned to paragraph
In stopWrapping we assign any left over whitespace to the paragraph
in position 3, however we weren't clearing this whitespace buffer
if an inline content node followed it.

Change-Id: I8b3ee3915044abd6bafda386430bf7f992ca4aa8
2013-05-10 16:40:11 +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
jenkins-bot 76b277485e Merge "Fix placement of whitespace when element ends in meta" 2013-05-06 20:04:04 +00: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
Roan Kattouw ef24ac5879 Force about grouping for multi-element about groups
When converting an element that starts an about group with at
least one other element in it, we now only consider models that
support about grouping. This prevents the first node from being
converted to something else and leaving the others hanging.

In practical terms, this means that elements like
<link rel="mw:WikiLink/Category" typeof="mw:Object/Template">
get alienated and pull in the rest of their about group, rather than
being converted to a category or alienMeta or whatever and
leaving the other elements to be converted normally.

Added a test case that asserts this. Really the result should be an
MWtemplate rather than an alien, but that's a separate issue.
Also removed superfluous mustMatchAll checks; we've already
filtered the array by the time we get there.

Change-Id: I522ba4c56d5bc52c7e9aab1e2535385540c1315d
2013-05-05 00:07:29 -07:00
Ed Sanders 8cfb4ee62f Fix placement of whitespace when element ends in meta
This was broken for both normal elements, where the meta item is
inside the element, and wrapper paragraphs, where the meta item
gets moved outside the wrapper.

Bug: 47712
Change-Id: I42daaf142e548e5b221ff0a52df0ad24ec6a4fd0
2013-05-03 22:45:34 +01: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 e29ed7f2b6 Remove all code related to change markers
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
2013-04-30 23:15:47 +01:00
Roan Kattouw a59f622d54 Per Timo's comment, change $.makeArray( foo ) to foo.toArray()
Change-Id: Ideee46640bc82f979578d5cc467c9c79d9806ae0
2013-04-29 18:08:04 -07:00
Ed Sanders b85c7f0628 Create meta item for defaultsort
Bug: 46465
Change-Id: I604a79c25e5b0315f7e6437da657977b0efa77db
2013-04-29 15:33:37 +01:00
Ed Sanders 6aaa54bc5f Fix new test case to use new domElements instead of html
This was missed by the merge as it doesn't cause any tests to fail (yet).

Change-Id: I6d106279d31276817ea718fdef3d8199b80693f6
2013-04-28 21:24:20 +01:00
jenkins-bot e7d335b1c7 Merge "Paragraph->heading conversion was broken when cursor next to an inline node" 2013-04-28 20:01:08 +00: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 e89e991037 Paragraph->heading conversion was broken when cursor next to an inline node
In this case, selectNodes() returns the paragraph, which is not a content
node, and so newFromContentBranchConversion() decides to do nothing at all.

This change makes newFromContentBranchConversion() more intelligent about
finding the content branch to operate on, fixing cases such as these
where selectNodes() returns the content branch itself rather than one of
its children.

Bug: 41203
Change-Id: I710fbf184ef5ef84d9c2f5bca2b115e0660f5b8f
2013-04-27 00:16:46 +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
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
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
jenkins-bot 196123e7a5 Merge "MWTemplateNode should serialise original HTML if unchanged" 2013-04-22 21:15:41 +00: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 3848c3f220 Factor the <pre> newline hack out of the converter into ve.properInnerHTML()
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
2013-04-22 20:09:52 +01:00
Ed Sanders 8b09dd7650 The resurrection
By removing the transaction listeners from surface fragments we
no longer have to make sure they are always manually destroyed.

In order to retain the functionality of having fragments update
with transactions elsewhere we keep a pointer to a place in the
new complete history stack in the surface. The complete history
stack records all transactions, even undone ones.

Whenever getRange is called we replay all transactions in the
complete history (in the correct order) since the fragment was
last updated.

Also in this commit:
* Updated Format/IndentationAction to test undo(). This increases
  coverage of surface fragment behaviour.
* .range is always accessed by .getRange now, although as an
  optimisation we can use the noCopy mode when we a sure the
  returned range will not be modified.
* Added undo test to .update (previously .onTransact)

Bug: 47343
Change-Id: I9e9818da1baa8319a3002f6d74fd1aad6732a8f5
2013-04-22 12:50:23 +01:00
Catrope 83a592f312 Fix whitespace preservation around meta items
This was broken, especially in wrappers.

Changed the wrapping algorithm so that meta items are placed outside
wrappers if possible. On the left-hand side, this is already the case:
we don't open wrappers for meta items. On the right-hand side, this is
accomplished by buffering the meta items and only inserting them when
we encounter either real text (not whitespace) or the end of the wrapper.
If we're interrupted by real text, we insert the meta items with the
unmodified whitespace. If we're interrupted by the end of the wrapper,
we insert the meta items outside of the wrapper with whitespace stripped.

Internally, this is done by stripping the whitespace into the whitespace[0]
of the meta item to its right. Then when we output the meta items, we
either decide to 'restore' the whitespace, or to 'fixup' by also setting
whitespace[3] on the element before the whitespace.

Change-Id: Ibeea2a9906c4aae9fe6d284613edd6ec853ca5e7
2013-04-18 16:06:58 -07:00
Catrope eac44c39f4 Make the AnnotationSet constructor take an array of indexes
Before, it took an array of objects and translated those to indexes
using the store. Literally every caller outside of the test suite got
an array of indexes from the linear model, translated those to objects,
then passed them into the AnnotationSet constructor which translated
them right back to indexes.

The previous behavior was kind of ridiculous on its face, but the
reason we found it is because Inez was investigating the performance
degradation when bolding a line and found that half of it was due
to the hundreds of ve.getHash() calls caused by this behavior.

Change-Id: I38df8ae9f6392849dacf477ea2f804283c964417
2013-04-18 10:56:03 -07:00
jenkins-bot 16d164ed6d Merge "Delete spurious normalizedHtml" 2013-04-18 15:32:53 +00:00