<table>\n\n</table> round-tripped to <table>\n\n\n\n</table> because
we would store '\n\n' in both the innerPre and innerPost fields.
Fixed by not setting innerPost if the element is empty.
Change-Id: I0393bfaf9793fdebc8fff72c8760113fa69bb2bd
The converter wasn't setting .annotations on meta items created to
represent empty annotations, which meant that HTML like
<i>Foo<b></b></i> would end up as <i>Foo</i><b></b> in the linmod.
Change-Id: I13d7d9820beeee1e8c3673e08051361d6c6ac4cd
If you had <meta /><b>Annotated text</b> in a wrapper paragraph,
the converter would swap them and output the linear model equivalent
of <p wrapper><b>Annotated text</b></p><meta />.
This happened because the meta item was queued, and annotations didn't
trigger metadata queue flushes. The fix is to trigger a metadata queue
flush whenever we're about to write something that isn't itself queued.
Change-Id: I168abc0392fbec5503271d1653ee5c38518f857d
They are only run in the MW test runner, where the MW dependencies
are available. Create a ve.test namespace for storing shared
test runners.
Change-Id: I079cb18b1c73614d25a12c5d6afcf0700469e52e
This bug caused all references containing complex content (e.g. links
or templates) to be dirty-DOMed and reformatted by Parsoid.
ve.dm.MWReferenceNode.js:
* Parse the original body.html and check if it's semantically equal to
the new value. If so, don't set it.
ve.dm.Converter.js:
* .normalize() the converter output to remove empty text nodes and
merge adjacent text nodes
ve.dm.example.js:
* Update reused reference test to have body.html absent, not empty
* Add a link to one of the reference tests so this bug is triggered
** The link's attributes are ordered specifically so that toDomElements
will reorder them, at least in Chrome (may behave differently in
other browsers)
** This test fails without this fix in place
Change-Id: Idc091a14422fbb117a3d06fc6bb9497768086fc3
Broke reference insertion because it removed
newFromNodeReplacement(), which is still in use.
This reverts commit 1765e39b40
Change-Id: I043997715474ad4850329ff903eb7a8c61c8b453
HTML like <td><span>Foo<!--bar--></span></td> would lose the comment
when converting to linmod, and so we'd drop the comment when converting
back to HTML.
This happened because we were queueing up meta items to possibly move
them and their whitespace out of the wrapper paragraph even if we were
inside of an annotation and there was no way we could move things out
at all. The fix is simply to detect these case and not queue up meta
items in that case.
[12:11] marktraceur Let the comments hit the floor, let the comments hit the floor
[12:11] marktraceur (to the tune of the Drowning Pool "Let the Bodies Hit the Floor")
Bug: 50071
Change-Id: I5a844e2e0655bc1db152b3805718324ca0bb04df
This was a big gaping DOM diff that's been in there since the beginning,
but which we only found today.
Change-Id: Ie4e791b212ddd3210bc1d5c11308452bb57ae3ce
Build the new set of classes as an array (avoiding the leading space),
and only set it if it differs from what was there before. This avoids
reordering the class attribute.
Change-Id: I863ec8de2e7637f76690c4e0b7db5e153fb7e408
Prevents changing of DOM attributes on unmodified transclusions
as they can clash in the store.
Also use 'original' over 'orig' consistently.
Bug: 50079
Change-Id: Ib13bb206c49b1f5b186e40632a5c109def0f042e
Previously we were just passing a slice of the visible data, instead
of using getFullData.
Bug: 50059
Change-Id: I3bbea49132ef4a720a147ba9b170c39a0c00f711
Previously we would reserialize the JSON blob in data-mw even if we
didn't change it, which potentially reordered keys and caused a DOM
diff.
Bug: 50066
Change-Id: If0a5bcc67d3a172de0e8839cfda11efacfbf36ff
Fixes (follows-up I1b48ef5240, I6daff5c596):
* Invalid html passed to jQuery constructor.
* Use prop() instead of attr() for boolean values.
* Use append() instead of html() when appending nodes instead
of parsing html.
* Rename shadowed variable name clash 'mw' to 'mwData'.
* Fix odd construction where we parse '{}' to create an empty
object.
* Have ve.ce.MWReferenceListNode#update perform changes off-document
in a detached tree.
* Fix deep property access that can fail. mwData is set to
either JSON parse of data-mw attr or empty object.
Accessing mwData.attrs.group needs to be guarded by whether
mw.attrs is indeed set.
* Have `mw` and `about` attribtue in references list roundtrip
(especially mw which can data we aren't editing/re-creating).
* Add missing 'refGroup' property to MWReferenceListNode's
data element (similar to what MWReferenceNode already has).
Change-Id: I67e4f378ccd04e97361d8e58ae57db5353075756
Better for performance (lower level, #get calls #toArray when
called without arguments) and more semantically correct.
Change-Id: I8e615674e51fd148367fd397bd169fa203a240ad
At the moment we create an alien meta item if an annotation
wraps contents of zero length, however we also need to handle
nested empty annotations, i.e. where the contents is other
empty annotations (i.e. alien meta items).
As alien meta items simply preserve DOM elements we don't
mind what type of alien meta items they are, so this also fixes
the case of an annotation wrapping another alien meta
e.g. a comment or <meta> tag.
Bug: 48605
Change-Id: I98d88b341efcd6384ee1fda5d6d7e1e1acb107aa
This function builds a transaction that takes a document slice and
inserts it back into the document it came from, applying any changes
that were made.
This makes editing document slices simple:
slicedDoc = doc.getDocumentSlice( captionNode );
// Edit slicedDoc using a surface
tx = ve.dm.Transaction.newFromDocumentInsertion( doc, captionNode, slicedDoc );
surface.change( tx );
Specifically, newFromDocumentInsertion replaces the node's contents
with the document's contents (meaning any changes made to the node in
the meantime are lost). It also merges the stores internal lists
of the two documents and remaps indexes accordingly. This means editing
of references inside of references is supported.
This functionality is not specific to slices, and can also be used to
safely insert data from a paste buffer, with internal list data being
transplanted correctly.
ve.dm.MetaLinearData:
* Make merge( [ undefined, undefined, ... ] ) return undefined rather
than [].
ve.dm.Document:
* In getDocumentSlice, store a pointer to the original dm.Document in
the new one, and also store the length of the internal list. This
allows us to figure out which internal list items the two documents
have in common when we insert the modified slice back into the main
document.
* In getMetadataReplace, optionally take the inserted metadata as a
parameter, to allow for operations that insert both data and metadata.
Per Ed's review, rewrite this function to return null rather than {}
if no metadata needs to be replaced.
ve.dm.InternalList:
* Add method to merge two internal lists
ve.dm.Transaction:
* Remove newFromNodeReplacement and replace it with newFromDocumentInsertion.
* In pushReplace, optionally take the inserted metadata as a parameter.
Change-Id: I786ee7bad796aa54bc242993b4de3ad18ad0773e
Slightly more efficient way of seeing if the template has changed,
and results in a cleaner set of data element attributes.
Change-Id: I1507520005bfb8a88bfa6038dac5c3b15506425d
These kinds of empty nodes shouldn't occur since the converter fills
them with empty paragraphs, but selectNodes() should still behave
correctly for them.
Change-Id: Ia37f3db1c2a84b842e2311cf70642fa66af04d91
* Move them from ve.example.js to ve.dm.example.js
** Also move lookupNode() and createDomElement() there
** Delete ve.example.js because there's nothing left in it
* Make main example document implicit, but allow override
* Specify nodes as arrays and do the lookup later
* Specify range and mode separately rather than calling selectNodes()
during construction
* Construct statically rather than in a function
* Use expect( cases.length );
Change-Id: I620e949c5e612b32eaa57c5d9b60cc91f9ddbf02
Otherwise fun exceptions occur when you have a <references /> tag
with no <ref>s, for instance.
Also disregard the internalList in the data->DOM conversion, to prevent
a nasty interaction where the whitespace information on the last element
is considered invalid because it doesn't match the internalList's.
Plus test updates from hell because this touches ve.dm.example.data
Change-Id: I62881d9fc27fa081123856d1b35a6021af469271
Per the bug report, it's useless because Firefox does not preserve order
in the .attributes array (but sorts it alphabetically instead), and so we
actually get the same exact behavior regardless of whether we use ordering
cleverness or just a straight-up plain object: order is preserved in Chrome,
and alphabetized in Firefox.
Bug: 48980
Change-Id: I1463d06db4900083dd4c565292bbabef09194b43
Objectives:
* Rename just about every use of "template" to "transclusion"
* Make a proper data structure for transclusions
* Abstract away template data
* Use more template data in the user interface
* Allow adding parameters
* Allow removing templates, parameters and content
Changes:
ve.ui.Dialog.css
* Add rule to place add param controls on a single line
ve.ui.MWTemplateDialogs.js
* Move template spec loading into transclusion class
* Add remove button for parts and parameters
* Add parameter adding form
* Use template data for labels and descriptions
ve.dm.*
* Add new transclusion data structures
*.php
* Add links to new files
*.*
* Rename all things "template" to "transclusion"
Bug: 39598
Bug: 49403
Change-Id: I3bcf924a3e179cb65f19e833277a39dfd3dad8bd
We don't need to decompose and rebuild alien meta items
as they are uneditable, so just store the dom node and return that
in toDomElements.
Update test cases and several tests now need to use
assert.deepEqualWithDomElements.
Change-Id: I4d2eed267dac7855cb929a17d7aef566eaf0e287
Objective:
* Allow opening reference dialog with arbitrary selection
* Auto-insert reference when selection is not a reference node
Changes:
ve.init.mw.ViewPageTarget.js
* Added reference button to toolbar
ve.init.Target.js
* Add getToolbarSubset so we can exclude the reference button from
the toolbar in the reference dialog (nested references are not
allowed).
ve.ui.MWReferenceDialog.js
* Stop storing referenceNode (not needed)
* Only store internalItem on open if there's a focused node that's a
reference
* Use wrapper paragraph when creating a new reference
* Create new reference on dialog close if required
ve.dm.InternalList.js
* Major rewrite to support key less references.
* Add new method for creating a transaction to insert a new iternal
item. Also returns the index of the new item to be passed to the
reference node.
Change-Id: I839ae165c299248484ce93d4ab087318a95fbb94
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
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
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
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