MWWikitextStringTransferHandler: Perform Parsoid cleanup on result

Parsoid markup delivered as a result of a paste was being handled differently.

Bug: T183173
Change-Id: Ic563d2c5cd1f663f35860892b369fb7ba34b9c55
This commit is contained in:
David Lynch 2018-01-22 12:34:06 -08:00
parent b82c7692be
commit d97b734352
2 changed files with 18 additions and 0 deletions

View file

@ -175,6 +175,21 @@ QUnit.test( 'convert', function ( assert ) {
{ type: '/internalList' }
]
},
{
msg: 'Headings, parsoid fallback ids don\'t interfere with whitespace stripping',
pasteString: '== Tudnivalók ==',
pasteType: 'text/plain',
parsoidResponse: '<h2 id="Tudnivalók"><span id="Tudnival.C3.B3k" typeof="mw:FallbackId"></span> Tudnivalók </h2>',
annotations: [],
assertDom: true,
expectedData: [
{ type: 'mwHeading', attributes: { level: 2 }, originalDomElements: $( '<h2 id="Tudnivalók"> Tudnivalók </h2>' ).toArray() },
'T', 'u', 'd', 'n', 'i', 'v', 'a', 'l', 'ó', 'k',
{ type: '/mwHeading' },
{ type: 'internalList' },
{ type: '/internalList' }
]
},
{
msg: 'Magic link (RFC)',
pasteString: 'RFC 1234',

View file

@ -128,6 +128,9 @@ ve.ui.MWWikitextStringTransferHandler.prototype.process = function () {
}
}
// Strip legacy IDs, for example in section headings
ve.stripParsoidFallbackIds( htmlDoc.body );
// Pass an empty object for the second argument (importRules) so that clipboard mode is used
// TODO: Fix that API
doc = handler.surface.getModel().getDocument().newFromHtml( htmlDoc, {} );