mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Unwrap Parsoid sections
Section wrapping will be introduced in I0f4c19f7. Change-Id: I43ced131d07a20318af37e830318e30db2eb451f
This commit is contained in:
parent
38dba57e95
commit
267d60f61a
|
@ -196,6 +196,8 @@ ve.init.mw.Target.static.parseDocument = function ( documentString, mode ) {
|
|||
} else {
|
||||
// Parsoid documents are XHTML so we can use parseXhtml which fixed some IE issues.
|
||||
doc = ve.parseXhtml( documentString );
|
||||
// Strip Parsoid sections
|
||||
ve.unwrapParsoidSections( doc.body );
|
||||
}
|
||||
// Fix relative or missing base URL if needed
|
||||
this.fixBase( doc );
|
||||
|
|
|
@ -29,3 +29,18 @@ ve.decodeURIComponentIntoArticleTitle = function ( s, preserveUnderscores ) {
|
|||
}
|
||||
return s.replace( /_/g, ' ' );
|
||||
};
|
||||
|
||||
/**
|
||||
* Unwrap Parsoid sections
|
||||
*
|
||||
* @param {HTMLElement} element Parent element, e.g. document body
|
||||
*/
|
||||
ve.unwrapParsoidSections = function ( element ) {
|
||||
Array.prototype.forEach.call( element.querySelectorAll( 'section[data-mw-section-id]' ), function ( section ) {
|
||||
var parent = section.parentNode;
|
||||
while ( section.firstChild ) {
|
||||
parent.insertBefore( section.firstChild, section );
|
||||
}
|
||||
parent.removeChild( section );
|
||||
} );
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue