We currently change <ref name="foo">Foo</ref> ... <ref name="foo">Foo</ref>
to <ref name="foo">Foo</ref> ... <ref name="foo" /> , because know
that the second ref tag isn't canonical and so we blank it.
Instead, we now preserve the contents of all ref tags that come after
the canonical one.
Change-Id: I45a51a879271890fe46c4184f1029f12d27af678
<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
Objectives:
* Split reference dialog (at least for now) an edit and an insert dialog
* Add reference search widget for selecting an existing source, or
choosing to add a new one
* Abstract reference names, don't allow editing them and generate them
when needed
* When editing groups, move the internal item and update all references
to it
* Resolve name conflicts when moving a reference to a new group by
generating a new list key
Bonus:
* Add getNodeGroups method to internal list
* Add getUniqueListKey method to internal list
* Add destroy functionality to ce.node to release events and references
Bug: 49733
Change-Id: Ib244ff6ad9b4cee1decfd9b9e1d3d4e9cdcfb78c
* Port the class preservation logic from BlockImage to InlineImage
* Add preservation for unrecognized classes
* Add the logic for collapsing spaces in the class attribute in more
places
Change-Id: I26faad7e00ab2f0a0f5d076552e56b32c692ae74
We need to normalise titles so 'user:foo_bar' == 'User:Foo bar', and
we also need to some HTML attribute removal as links from Parsoid
will have href and rel set (again, this should be fixed in by Parsoid
when the do the merging at their end).
Bug: 49985
Change-Id: I5fb5bfc69c344ca4ce4803d7b6116074648a8d7e
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
Added return boolean to ve.dm.Surface#breakpoint to indicate if
and transactions were pushed to the big stack. Use this value in
MWMetaDialog to see if we need to undo on close.
Added tests for ve.dm.Surface#breakpoint.
Bug: 49630
Change-Id: Ieb2e9e361afe057af93c4d374acc85df58bfb4c3
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
Objective:
* Allow editing reference groups and names in the reference dialog
Bonus:
* Modify attribute transaction builder to support multiple attribute
changes in a single transaction
Changes:
ve.ui.MWReferenceDialog.js
* Load ref name and group from model
* Save ref name and group, if changed, to model
ve.ui.ListAction.js, ve.ui.Transaction.test.js, ve.ce.ResizableNode.js
* Update use of newFromAttributeChange to newFromAttributeChanges
ve.dm.SurfaceFragment.test.js
* Add test for new changeAttributes method
ve.dm.InternalList.js
* Missing new line at end of file
ve.dm.Transaction.js
* Change newFromAttributeChange to accept an list of attribute changes and
produce a single transaction that applies one or more attribute changes
at once
ve.dm.SurfaceFragment.js
* Fix bug in getCoveredNodes where the wrong mode name was being used
* Add changeAttributes method, which applies attributes to all covered
nodes and allows filtering of which types of nodes the attributes are
applied to
ve.dm.MWReferenceNode.js
* Actually write key and group back to DOM
* Separate onRoot functionality into addToInternalList so it can be called
separately (similarly onUnroot/removeFromInternalList)
ve.ce.MWReferenceListNode.js
* Clone internal item CE node before appending to avoid rendering bug.
*.php
* Add links to messages and sort them
Change-Id: Ic4121e4fcfc09265d5863af6f078cdeb77926c8e
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