mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
1765e39b40
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 |
||
---|---|---|
.. | ||
lineardata | ||
nodes | ||
ve.dm.AnnotationSet.test.js | ||
ve.dm.BranchNode.test.js | ||
ve.dm.Converter.test.js | ||
ve.dm.Document.test.js | ||
ve.dm.DocumentSynchronizer.test.js | ||
ve.dm.example.js | ||
ve.dm.IndexValueStore.test.js | ||
ve.dm.InternalList.test.js | ||
ve.dm.LeafNode.test.js | ||
ve.dm.LinearData.test.js | ||
ve.dm.MetaList.test.js | ||
ve.dm.Model.test.js | ||
ve.dm.ModelRegistry.test.js | ||
ve.dm.Node.test.js | ||
ve.dm.NodeFactory.test.js | ||
ve.dm.Surface.test.js | ||
ve.dm.SurfaceFragment.test.js | ||
ve.dm.Transaction.test.js | ||
ve.dm.TransactionProcessor.test.js |