mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
Merge "Remove inserted leading whitespace"
This commit is contained in:
commit
cd9c38aa9a
|
@ -1672,7 +1672,6 @@ ve.dm.mwExample.domToDataCases = {
|
|||
'data': ve.dm.mwExample.mwNowiki
|
||||
},
|
||||
'mw:Nowiki unwraps when text modified': {
|
||||
'html': null,
|
||||
'data': ve.dm.mwExample.mwNowiki,
|
||||
'modify': function ( data ) {
|
||||
data[7][0] = 'z';
|
||||
|
@ -1680,7 +1679,6 @@ ve.dm.mwExample.domToDataCases = {
|
|||
'normalizedHtml': '<body><p>Foo[[Bzr]]Baz</p></body>'
|
||||
},
|
||||
'mw:Nowiki unwraps when annotations modified': {
|
||||
'html': null,
|
||||
'data': ve.dm.mwExample.mwNowiki,
|
||||
'modify': function ( data ) {
|
||||
data[7][1].push( ve.dm.example.bold );
|
||||
|
|
|
@ -1040,7 +1040,7 @@ ve.dm.Converter.prototype.getDomFromData = function ( documentData, store, inter
|
|||
* @throws Unbalanced data: looking for closing /type
|
||||
*/
|
||||
ve.dm.Converter.prototype.getDomSubtreeFromData = function ( data, container ) {
|
||||
var text, i, j, annotations, dataElement, dataElementOrSlice,
|
||||
var text, i, j, isStart, annotations, dataElement, dataElementOrSlice,
|
||||
childDomElements, pre, ours, theirs, parentDomElement, lastChild, isContentNode, sibling,
|
||||
previousSiblings, doUnwrap, textNode, type, annotatedDomElementStack, annotatedDomElements,
|
||||
dataLen = data.length,
|
||||
|
@ -1151,9 +1151,16 @@ ve.dm.Converter.prototype.getDomSubtreeFromData = function ( data, container ) {
|
|||
if ( typeof data[i] === 'string' ) {
|
||||
// Text
|
||||
text = '';
|
||||
isStart = i > 0 &&
|
||||
ve.dm.LinearData.static.isOpenElementData( data[i-1] ) &&
|
||||
ve.dm.LinearData.static.getType( data[i-1] ) !== 'preformatted';
|
||||
// Continue forward as far as the plain text goes
|
||||
while ( typeof data[i] === 'string' ) {
|
||||
text += data[i];
|
||||
// HACK: Skip over leading whitespace (bug 51462) in non-pre tags
|
||||
if ( !( isStart && data[i].match( /\s/ ) ) ) {
|
||||
text += data[i];
|
||||
isStart = false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
// i points to the first non-text thing, go back one so we don't skip this later
|
||||
|
|
|
@ -894,6 +894,25 @@ ve.dm.example.domToDataCases = {
|
|||
{ 'type': '/internalList' }
|
||||
]
|
||||
},
|
||||
'strip leading whitepsace in paragraphs': {
|
||||
'data': [
|
||||
{ 'type': 'paragraph' },
|
||||
' ', 'f', 'o', 'o',
|
||||
{ 'type': '/paragraph' },
|
||||
{ 'type': 'paragraph' },
|
||||
' ', '\t', ' ', '\t', 'b', 'a', 'r',
|
||||
{ 'type': '/paragraph' },
|
||||
{ 'type': 'heading', 'attributes': { 'level': 2 } },
|
||||
' ', ' ', 'b', 'a', 'z',
|
||||
{ 'type': '/heading' },
|
||||
{ 'type': 'preformatted' },
|
||||
' ', '\t', 'q', 'u', 'u', 'x',
|
||||
{ 'type': '/preformatted' },
|
||||
{ 'type': 'internalList' },
|
||||
{ 'type': '/internalList' }
|
||||
],
|
||||
'normalizedHtml': '<body><p>foo</p><p>bar</p><h2>baz</h2><pre> \tquux</pre></body>'
|
||||
},
|
||||
'image': {
|
||||
'html': '<body><img src="' + ve.dm.example.imgSrc + '"></body>',
|
||||
'data': [
|
||||
|
@ -1300,7 +1319,6 @@ ve.dm.example.domToDataCases = {
|
|||
]
|
||||
},
|
||||
'empty document with content added by the editor': {
|
||||
'html': null,
|
||||
'data': [
|
||||
{ 'type': 'paragraph', 'internal': { 'generated': 'empty' } },
|
||||
'F',
|
||||
|
@ -1313,7 +1331,6 @@ ve.dm.example.domToDataCases = {
|
|||
'normalizedHtml': '<body><p>Foo</p></body>'
|
||||
},
|
||||
'empty list item with content added by the editor': {
|
||||
'html': null,
|
||||
'data': [
|
||||
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
||||
{ 'type': 'listItem' },
|
||||
|
@ -2178,7 +2195,6 @@ ve.dm.example.domToDataCases = {
|
|||
]
|
||||
},
|
||||
'mismatching whitespace data is ignored': {
|
||||
'html': null,
|
||||
'data': [
|
||||
{ 'type': 'list', 'attributes': { 'style': 'bullet' }, 'internal': { 'whitespace': [ ' ', ' ', ' ', ' ' ] } },
|
||||
{ 'type': 'listItem', 'internal': { 'whitespace': [ ' ', ' ', ' ', ' ' ] } },
|
||||
|
|
|
@ -54,7 +54,7 @@ ve.test.utils.runGetDataFromDomTests = function( assert, cases ) {
|
|||
ve.dm.modelRegistry.register( ve.dm.PreformattedNode );
|
||||
|
||||
for ( msg in cases ) {
|
||||
if ( cases[msg].html !== null ) {
|
||||
if ( cases[msg].html !== undefined ) {
|
||||
n++;
|
||||
if ( cases[msg].storeItems ) {
|
||||
n += cases[msg].storeItems.length;
|
||||
|
@ -64,7 +64,7 @@ ve.test.utils.runGetDataFromDomTests = function( assert, cases ) {
|
|||
QUnit.expect( n );
|
||||
|
||||
for ( msg in cases ) {
|
||||
if ( cases[msg].html !== null ) {
|
||||
if ( cases[msg].html !== undefined ) {
|
||||
doc = new ve.dm.Document( [] );
|
||||
store = doc.getStore();
|
||||
internalList = doc.getInternalList();
|
||||
|
|
Loading…
Reference in a new issue