jenkins-bot has submitted this change and it was merged.
Change subject: MWTable: use new sanitization method
......................................................................
MWTable: use new sanitization method
This prevents tables from getting sanitized even on
VE to VE copy. Also by calling ClassAttributeNode sanitize
extra CSS classes are removed.
Bug: T97462
Bug: T125220
Depends-On: Ia3ce386b2a03bc227818b10423bca72c736c0656
Change-Id: Ifd91e00b40665b446bbdcdf8859d2bb641bc0e67
---
M modules/ve-mw/dm/nodes/ve.dm.MWTableNode.js
M modules/ve-mw/init/ve.init.mw.Target.js
M modules/ve-mw/tests/dm/ve.dm.mwExample.js
3 files changed, 10 insertions(+), 32 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWTableNode.js
b/modules/ve-mw/dm/nodes/ve.dm.MWTableNode.js
index 88d636f..4637808 100644
--- a/modules/ve-mw/dm/nodes/ve.dm.MWTableNode.js
+++ b/modules/ve-mw/dm/nodes/ve.dm.MWTableNode.js
@@ -44,17 +44,12 @@
ve.dm.TableCaptionNode.static.parentNodeTypes.push( 'mwTable' );
ve.dm.TableRowNode.static.childNodeTypes.push( 'mwTransclusionTableCell' );
-ve.dm.MWTableNode.static.toDataElement = function ( domElements, converter ) {
+ve.dm.MWTableNode.static.toDataElement = function ( domElements ) {
var attributes = {},
dataElement = { type: this.name },
classAttr = domElements[ 0 ].getAttribute( 'class' );
this.setClassAttributes( attributes, classAttr );
-
- // Default to wikitable when pasting
- if ( converter.isFromClipboard() ) {
- attributes.wikitable = true;
- }
if ( !ve.isEmptyObject( attributes ) ) {
dataElement.attributes = attributes;
@@ -73,6 +68,13 @@
return [ element ];
};
+ve.dm.MWTableNode.static.sanitize = function ( dataElement ) {
+ // Mixin method
+ ve.dm.ClassAttributeNode.static.sanitize.call( this, dataElement );
+
+ ve.setProp( dataElement, 'attributes', 'wikitable', true );
+};
+
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWTableNode );
diff --git a/modules/ve-mw/init/ve.init.mw.Target.js
b/modules/ve-mw/init/ve.init.mw.Target.js
index ea01957..a3624c4 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -113,7 +113,8 @@
// Nodes
'div', 'alienInline', 'alienBlock', 'comment'
],
- removeOriginalDomElements: true
+ removeOriginalDomElements: true,
+ nodeSanitization: true
},
all: null
};
diff --git a/modules/ve-mw/tests/dm/ve.dm.mwExample.js
b/modules/ve-mw/tests/dm/ve.dm.mwExample.js
index a559eae..b82283a 100644
--- a/modules/ve-mw/tests/dm/ve.dm.mwExample.js
+++ b/modules/ve-mw/tests/dm/ve.dm.mwExample.js
@@ -940,31 +940,6 @@
{ type: '/internalList' }
]
},
- 'table is created as wikitable on paste': {
- body: '<table><tr><td>Foo</td></tr></table>',
- fromClipboard: true,
- data: [
- {
- type: 'mwTable',
- attributes: {
- wikitable: true
- }
- },
- { type: 'tableSection', attributes: { style: 'body' } },
- { type: 'tableRow' },
- { type: 'tableCell', attributes: { style: 'data' } },
- { type: 'paragraph', internal: { generated: 'wrapper' }
},
- 'F', 'o', 'o',
- { type: '/paragraph' },
- { type: '/tableCell' },
- { type: '/tableRow' },
- { type: '/tableSection' },
- { type: '/mwTable' },
- { type: 'internalList' },
- { type: '/internalList' }
- ],
- normalizedBody: '<table
class="wikitable"><tr><td>Foo</td></tr></table>'
- },
'mw:Transclusion (block level)': {
body: ve.dm.mwExample.MWTransclusion.blockOpen +
ve.dm.mwExample.MWTransclusion.blockContent,
data: [
--
To view, visit https://gerrit.wikimedia.org/r/267287
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifd91e00b40665b446bbdcdf8859d2bb641bc0e67
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits