mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 09:09:25 +00:00
Merge "Use static parseDocument method"
This commit is contained in:
commit
4b852d899b
|
@ -21,12 +21,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
target.originalDmDoc = target.constructor.static.createModelFromDom( target.parseDocument( oldHtml ), 'visual' );
|
||||
target.originalDmDoc = target.constructor.static.createModelFromDom( target.constructor.static.parseDocument( oldHtml ), 'visual' );
|
||||
|
||||
surface.getModel().getDocument().getStore().merge( target.originalDmDoc.getStore() );
|
||||
|
||||
surface.getModel().getLinearFragment( new ve.Range( 0 ) ).insertDocument(
|
||||
target.constructor.static.createModelFromDom( target.parseDocument( newHtml ), 'visual' )
|
||||
target.constructor.static.createModelFromDom( target.constructor.static.parseDocument( newHtml ), 'visual' )
|
||||
).collapseToEnd().adjustLinearSelection( 0, 3 ).removeContent();
|
||||
|
||||
target.once( 'saveReview', function () {
|
||||
|
|
|
@ -271,7 +271,7 @@ ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
|
|||
this.etag = data.etag;
|
||||
this.fromEditedState = data.fromEditedState;
|
||||
this.switched = data.switched || 'wteswitched' in new mw.Uri( location.href ).query;
|
||||
this.doc = this.parseDocument( this.originalHtml, this.getDefaultMode() );
|
||||
this.doc = this.constructor.static.parseDocument( this.originalHtml, this.getDefaultMode() );
|
||||
|
||||
this.remoteNotices = ve.getObjectValues( data.notices );
|
||||
this.protectedClasses = data.protectedClasses;
|
||||
|
@ -1000,7 +1000,7 @@ ve.init.mw.ArticleTarget.prototype.onSaveDialogPreview = function () {
|
|||
baseDoc = target.getSurface().getModel().getDocument().getHtmlDocument();
|
||||
|
||||
if ( ve.getProp( response, 'visualeditor', 'result' ) === 'success' ) {
|
||||
doc = target.parseDocument( response.visualeditor.content, 'visual' );
|
||||
doc = target.constructor.static.parseDocument( response.visualeditor.content, 'visual' );
|
||||
body = doc.body;
|
||||
// Import body to current document, then resolve attributes against original document (parseDocument called #fixBase)
|
||||
document.adoptNode( body );
|
||||
|
@ -1079,7 +1079,7 @@ ve.init.mw.ArticleTarget.prototype.getVisualDiffGeneratorPromise = function () {
|
|||
).then( function ( response ) {
|
||||
var doc, data = response ? ( response.visualeditor || response.visualeditoredit ) : null;
|
||||
if ( data && typeof data.content === 'string' ) {
|
||||
doc = target.parseDocument( data.content, 'visual' );
|
||||
doc = target.constructor.static.parseDocument( data.content, 'visual' );
|
||||
target.originalDmDoc = target.constructor.static.createModelFromDom( doc, 'visual' );
|
||||
deferred.resolve( function () {
|
||||
return new ve.dm.VisualDiff( target.originalDmDoc, dmDoc );
|
||||
|
|
|
@ -185,26 +185,26 @@ ve.init.mw.Target.prototype.createModelFromDom = function () {
|
|||
return this.constructor.static.createModelFromDom.apply( this.constructor.static, arguments );
|
||||
};
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ve.init.mw.Target.prototype.parseDocument = function ( documentString, mode ) {
|
||||
ve.init.mw.Target.static.parseDocument = function ( documentString, mode ) {
|
||||
var doc;
|
||||
if ( mode === 'source' ) {
|
||||
// Parent method
|
||||
doc = ve.init.mw.Target.super.prototype.parseDocument.apply( this, arguments );
|
||||
doc = ve.init.mw.Target.super.static.parseDocument.apply( this, arguments );
|
||||
} else {
|
||||
// Parsoid documents are XHTML so we can use parseXhtml which fixed some IE issues.
|
||||
doc = ve.parseXhtml( documentString );
|
||||
}
|
||||
// Fix relative or missing base URL if needed
|
||||
this.constructor.static.fixBase( doc );
|
||||
this.fixBase( doc );
|
||||
|
||||
return doc;
|
||||
};
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* Handle both DOM and modules being loaded and ready.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue