mediawiki-extensions-Visual.../modules/ve/test/dm
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
..
lineardata getAnnotationsFromRange should only ignore non-content data 2013-08-21 22:32:34 +01:00
nodes The great directory split of 2013 2013-07-02 20:51:38 -07:00
ve.dm.AnnotationSet.test.js Rename index to offset in AnnotationSet 2013-07-26 23:04:01 +00:00
ve.dm.BranchNode.test.js Kill getOffsetFromNode() with fire 2013-05-09 17:26:22 -07:00
ve.dm.Converter.test.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.Document.test.js Remove no-insertion metadata corner case from ve.dm.Transaction.pushReplace(). 2013-09-06 01:07:37 +00:00
ve.dm.DocumentSynchronizer.test.js Code style fixes 2013-05-06 12:36:52 +01:00
ve.dm.example.js Fix off-by-one error with metadata-mutating transactions. 2013-09-11 10:07:20 -07:00
ve.dm.IndexValueStore.test.js Preserve location of reference body within key 2013-06-10 02:54:26 +00:00
ve.dm.InternalList.test.js Always give references names. Ignore if used once. 2013-08-28 12:47:33 -07:00
ve.dm.LeafNode.test.js Store data in LinearData class with an index-value store for objects 2013-03-30 10:06:34 +00:00
ve.dm.LinearData.test.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.MetaList.test.js Rewrite MetaList.onTransact 2013-09-11 15:29:28 -07:00
ve.dm.Model.test.js jshint: Fix trailing comma 2013-06-05 13:00:49 +02:00
ve.dm.ModelRegistry.test.js Fix ModelRegistry bugs 2013-04-08 18:05:34 -07:00
ve.dm.Node.test.js jshint: Fix trailing comma 2013-06-05 13:00:49 +02:00
ve.dm.NodeFactory.test.js Correct name of can(Node)HaveGrandchildren functions 2013-03-13 23:25:33 +00:00
ve.dm.Surface.test.js dm.Surface: Initialize selection at (1,1) instead of (0,0) 2013-09-18 01:06:34 +00:00
ve.dm.SurfaceFragment.test.js dm.Surface: Initialize selection at (1,1) instead of (0,0) 2013-09-18 01:06:34 +00:00
ve.dm.Transaction.test.js Introduce newFromDocumentReplace() transaction builder 2013-09-25 21:46:38 +00:00
ve.dm.TransactionProcessor.test.js Merge changes I899d2b3c,I0272fe38,I7ad24e7f 2013-09-17 21:01:41 +00:00