Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/277318
Change subject: Table import: Only import the internal list on external paste
......................................................................
Table import: Only import the internal list on external paste
Bug: T129879
Change-Id: I10c149e4b6843c03ddfc363b107281fb36b77937
---
M src/ce/ve.ce.Surface.js
M src/ui/actions/ve.ui.TableAction.js
2 files changed, 27 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/18/277318/1
diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 3f58de0..1c84a92 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -1918,6 +1918,7 @@
// Internal table-into-table paste
if ( selection instanceof ve.dm.TableSelection && slice instanceof
ve.dm.TableSlice ) {
tableAction = new ve.ui.TableAction( this.getSurface() );
+ internalListRange =
slice.getInternalList().getListNode().getOuterRange();
tableAction.importTable( slice.getTableNode() );
return;
}
@@ -2059,7 +2060,7 @@
) {
// External table-into-table paste
tableAction = new ve.ui.TableAction( this.getSurface()
);
- tableAction.importTable(
pastedDocumentModel.documentNode.children[ 0 ] );
+ tableAction.importTable(
pastedDocumentModel.documentNode.children[ 0 ], true );
return;
}
diff --git a/src/ui/actions/ve.ui.TableAction.js
b/src/ui/actions/ve.ui.TableAction.js
index 21c8b03..911aed3 100644
--- a/src/ui/actions/ve.ui.TableAction.js
+++ b/src/ui/actions/ve.ui.TableAction.js
@@ -253,10 +253,11 @@
* Import a table at the current selection, overwriting data cell by cell
*
* @param {ve.dm.TableNode} importedTableNode Table node to import
+ * @param {boolean} importInternalList Import the table document's
internalLiist
* @return {boolean} Action was executed
*/
-ve.ui.TableAction.prototype.importTable = function ( importedTableNode ) {
- var i, l, row, col, cell, importedCell, cellRange,
+ve.ui.TableAction.prototype.importTable = function ( importedTableNode,
importInternalList ) {
+ var i, l, row, col, cell, importedCell, cellRange, txs,
importedMatrix = importedTableNode.getMatrix(),
surfaceModel = this.surface.getModel(),
documentModel = surfaceModel.getDocument(),
@@ -290,20 +291,32 @@
if ( !importedCell.isPlaceholder() ) {
// Remove the existing cell contents
surfaceModel.change(
ve.dm.Transaction.newFromRemoval( documentModel, cellRange ) );
- // Perform the insertion as a separate change
so the internalList offsets are correct
- surfaceModel.change( [
- // Attribute changes are performed
separately, and removing the whole
- // cell could change the dimensions of
the table
+ // Attribute changes are performed separately,
and removing the whole
+ // cell could change the dimensions of the table
+ txs = [
ve.dm.Transaction.newFromAttributeChanges(
documentModel, cellRange.start
- 1,
ve.copy(
importedCell.node.element.attributes )
- ),
-
ve.dm.Transaction.newFromDocumentInsertion(
- documentModel, cellRange.start,
- importedTableNode.getDocument(),
- importedCell.node.getRange()
)
- ] );
+ ];
+ if ( importInternalList ) {
+ txs.push(
+
ve.dm.Transaction.newFromDocumentInsertion(
+ documentModel,
cellRange.start,
+
importedTableNode.getDocument(),
+
importedCell.node.getRange()
+ )
+ );
+ } else {
+ txs.push(
+
ve.dm.Transaction.newFromInsertion(
+ documentModel,
cellRange.start,
+
importedTableNode.getDocument().getData( importedCell.node.getRange() )
+ )
+ );
+ }
+ // Perform the insertion as a separate change
so the internalList offsets are correct
+ surfaceModel.change( txs );
} else {
// Remove the existing cell completely
surfaceModel.change(
ve.dm.Transaction.newFromRemoval( documentModel, cell.node.getOuterRange() ) );
--
To view, visit https://gerrit.wikimedia.org/r/277318
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I10c149e4b6843c03ddfc363b107281fb36b77937
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits