Jforrester has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/280840

Change subject: DSVFileTransferHandler: Let downstream over-ride the inserted 
node
......................................................................

DSVFileTransferHandler: Let downstream over-ride the inserted node

Change-Id: Ib0b67b4bf70887830405612f3fff24c076d214c0
---
M src/ui/datatransferhandlers/ve.ui.DSVFileTransferHandler.js
1 file changed, 16 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/40/280840/1

diff --git a/src/ui/datatransferhandlers/ve.ui.DSVFileTransferHandler.js 
b/src/ui/datatransferhandlers/ve.ui.DSVFileTransferHandler.js
index 2c07c07..917c90a 100644
--- a/src/ui/datatransferhandlers/ve.ui.DSVFileTransferHandler.js
+++ b/src/ui/datatransferhandlers/ve.ui.DSVFileTransferHandler.js
@@ -31,21 +31,34 @@
 
 ve.ui.DSVFileTransferHandler.static.extensions = [ 'csv', 'tsv' ];
 
+ve.ui.DSVFileTransferHandler.static.tableNodeType = 'table';
+
+ve.ui.DSVFileTransferHandler.static.tableClasses = [];
+
 /* Methods */
 
 /**
  * @inheritdoc
  */
 ve.ui.DSVFileTransferHandler.prototype.onFileLoad = function () {
-       var i, j, line,
+       var i, j, line, tableElement,
                data = [],
                input = Papa.parse( this.reader.result );
 
        if ( input.meta.aborted || ( input.data.length <= 0 ) ) {
                this.abort();
        } else {
+               tableElement = { type: this.constructor.static.tableNodeType, 
attributes: {} };
+
+               for ( i = 0; i < this.constructor.static.tableClasses.length; 
i++) {
+                       // TODO: Handle non-binary attributes via an Object.
+                       if ( typeof this.constructor.static.tableClasses[i] === 
'string' ) {
+                               tableElement.attributes[ 
this.constructor.static.tableClasses[i] ] = true;
+                       }
+               }
+
                data.push(
-                       { type: 'table' },
+                       tableElement,
                        { type: 'tableSection', attributes: { style: 'body' } }
                );
 
@@ -75,7 +88,7 @@
 
                data.push(
                        { type: '/tableSection' },
-                       { type: '/table' }
+                       { type: '/' + this.constructor.static.tableNodeType }
                );
 
                this.resolve( data );

-- 
To view, visit https://gerrit.wikimedia.org/r/280840
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0b67b4bf70887830405612f3fff24c076d214c0
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to