mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
Strip leading and trailing whitespace in text
Right now this means things like headings and list items are rendered nicer (without the whitespace), but also get their whitespace normalized when saving back. I'll submit code tomorrow that preserves this whitespace. Submitting this now because it's needed to make <br>s look reasonable Change-Id: I4b5e5ad8ee1bbe2f1eaf0fb860dd59f6e401dc3d
This commit is contained in:
parent
d6d05a40c5
commit
c0ea02c0bf
|
@ -316,9 +316,12 @@ ve.dm.Converter.prototype.getDataFromDom = function ( domElement, annotations, d
|
|||
|
||||
if ( !branchIsContent ) {
|
||||
// If it's bare content, strip leading and trailing newlines
|
||||
// FIXME these newlines should be turned into placeholders instead
|
||||
// FIXME these newlines should be preserved somehow
|
||||
text = text.replace( /^\n+/, '' ).replace( /\n+$/, '' );
|
||||
}
|
||||
// Strip leading and trailing whitespace
|
||||
// TODO store it in the element so it can be preserved
|
||||
text = text.replace( /^\s+/, '' ).replace( /\s+$/, '' );
|
||||
if ( text === '' ) {
|
||||
// Don't produce an empty text node or an empty paragraph
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue