From d97b7343525db9b2eeaf39f777cbe4d0d59d42e0 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Mon, 22 Jan 2018 12:34:06 -0800 Subject: [PATCH] MWWikitextStringTransferHandler: Perform Parsoid cleanup on result Parsoid markup delivered as a result of a paste was being handled differently. Bug: T183173 Change-Id: Ic563d2c5cd1f663f35860892b369fb7ba34b9c55 --- .../ve.ui.MWWikitextStringTransferHandler.test.js | 15 +++++++++++++++ .../ve.ui.MWWikitextStringTransferHandler.js | 3 +++ 2 files changed, 18 insertions(+) diff --git a/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js b/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js index d913356687..e9b9c8cae6 100644 --- a/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js +++ b/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js @@ -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: '

Tudnivalók

', + annotations: [], + assertDom: true, + expectedData: [ + { type: 'mwHeading', attributes: { level: 2 }, originalDomElements: $( '

Tudnivalók

' ).toArray() }, + 'T', 'u', 'd', 'n', 'i', 'v', 'a', 'l', 'ó', 'k', + { type: '/mwHeading' }, + { type: 'internalList' }, + { type: '/internalList' } + ] + }, { msg: 'Magic link (RFC)', pasteString: 'RFC 1234', diff --git a/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js b/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js index 10aedba918..dfe8b831c2 100644 --- a/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js +++ b/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js @@ -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, {} );