mediawiki-extensions-Visual.../modules/ve
Roan Kattouw cf17789985 Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.

With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );

and that takes care of metadata, internal list items, and things like
references that reference internal list items.

ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
  and the number of items in its InternalList at the time of slicing
  in the created slice. This is used for reconciliation when the
  modified slice is injected back into the parent document with
  newFromDocumentReplace().

ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
  mapping from old to new InternalList indexes so the linear model data
  being injected by newFromDocumentReplace() can have its InternalList
  indexes remapped.

ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()

ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
  newFromDocumentReplace into that
* Add empty internalList to new mini-documents

ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests

ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes

ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests

VisualEditor.hooks.php:
* Add new test file

Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-25 21:46:38 +00:00
..
ce Fix pawn on pre-annotation and keypress 2013-09-11 19:47:39 -07:00
dm Introduce newFromDocumentReplace() transaction builder 2013-09-25 21:46:38 +00:00
init Add keyboard shortcuts for formatting tools 2013-09-03 17:17:03 -07:00
test Introduce newFromDocumentReplace() transaction builder 2013-09-25 21:46:38 +00:00
ui Scroll into view support 2013-09-16 16:46:58 -07:00
ve.BranchNode.js
ve.debug.js
ve.Document.js doc: Clean up spacing that caused <pre> or broken <ul>/<ol> 2013-07-25 04:02:50 +02:00
ve.Element.js Scroll into view support 2013-09-16 16:46:58 -07:00
ve.EventEmitter.js
ve.EventSequencer.js Fix function naming conventions, comments and whitespace 2013-09-17 19:37:08 +01:00
ve.Factory.js Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00
ve.js Include element HTML in QUnit summary for diff 2013-08-02 16:10:05 +01:00
ve.LeafNode.js
ve.NamedClassFactory.js
ve.Node.js
ve.Range.js doc: Fix incorrect syntax 2013-09-06 20:29:18 +00:00
ve.Registry.js Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00
ve.track.js Add ve.track, a generic dispatch of analytic events 2013-08-03 02:51:07 +00:00