mediawiki-extensions-Visual.../modules/ve/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
..
annotations Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00
lineardata docs: Minor improvements 2013-09-05 23:56:59 +00:00
metaitems ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
nodes Add alt attribute to core image nodes 2013-09-07 12:56:17 -07:00
ve.dm.Annotation.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.AnnotationFactory.js
ve.dm.AnnotationSet.js Speed up openAndCloseAnnotations by using store indexes 2013-07-26 18:11:01 -07:00
ve.dm.BranchNode.js
ve.dm.Converter.js Fix check for preformatted when stripping whitespace 2013-09-16 16:41:45 +01:00
ve.dm.DataString.js
ve.dm.Document.js Introduce newFromDocumentReplace() transaction builder 2013-09-25 21:46:38 +00:00
ve.dm.DocumentSlice.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.DocumentSynchronizer.js doc: Clean up spacing that caused <pre> or broken <ul>/<ol> 2013-07-25 04:02:50 +02:00
ve.dm.IndexValueStore.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.InternalList.js Introduce newFromDocumentReplace() transaction builder 2013-09-25 21:46:38 +00:00
ve.dm.js
ve.dm.LeafNode.js
ve.dm.LinearData.js docs: Minor improvements 2013-09-05 23:56:59 +00:00
ve.dm.MetaItem.js Rewrite MetaList.onTransact 2013-09-11 15:29:28 -07:00
ve.dm.MetaItemFactory.js
ve.dm.MetaList.js Rewrite MetaList.onTransact 2013-09-11 15:29:28 -07:00
ve.dm.Model.js Add .static.getMatchRdfaTypes() wrapper 2013-08-07 17:39:24 +08:00
ve.dm.ModelRegistry.js Fix deprioritization of regex matches in ModelRegistry 2013-08-08 02:52:45 +00:00
ve.dm.Node.js doc: Fix incorrect syntax 2013-09-06 20:29:18 +00:00
ve.dm.NodeFactory.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.Surface.js dm.Surface: Initialize selection at (1,1) instead of (0,0) 2013-09-18 01:06:34 +00:00
ve.dm.SurfaceFragment.js Compare annotations by name only when clearing/toggling 2013-07-16 00:05:11 +01:00
ve.dm.Transaction.js Introduce newFromDocumentReplace() transaction builder 2013-09-25 21:46:38 +00:00
ve.dm.TransactionProcessor.js Fix processing of double metadata replacements 2013-09-11 15:26:12 -07:00