Inherit more functionality from core source mode

Change-Id: Id027681ab5f0c9f4b9ed127b583e45f0fe57ce69
Depends-On: I02f3849027a6652701c2d354d1b77ece9d1a56c1
This commit is contained in:
Ed Sanders 2016-11-30 18:41:50 +00:00 committed by Jforrester
parent 218742d806
commit 8bca6cc777
3 changed files with 7 additions and 33 deletions

View file

@ -1151,28 +1151,10 @@ ve.init.mw.ArticleTarget.prototype.getDocToSave = function () {
/**
* Create a document to save
*
* TODO: Move this code to the surface?
*
* @return {Object} Document to save
*/
ve.init.mw.ArticleTarget.prototype.createDocToSave = function () {
var i, l, text, data,
surface = this.getSurface();
if ( surface.getMode() === 'source' ) {
text = '';
data = surface.getModel().getDocument().data.data;
for ( i = 0, l = data.length; i < l; i++ ) {
if ( data[ i ].type === '/paragraph' && data[ i + 1 ].type === 'paragraph' ) {
text += '\n';
} else if ( !data[ i ].type ) {
text += data[ i ];
}
}
return text;
}
return surface.getDom();
return this.getSurface().getDom();
};
/**

View file

@ -154,24 +154,15 @@ ve.init.mw.Target.static.fixBase = function ( doc ) {
/* Methods */
/**
* Parse document string into an HTML document
*
* @param {string} documentString Document
* @param {string} mode Editing mode
* @return {HTMLDocument} HTML document
* @inheritdoc
*/
ve.init.mw.Target.prototype.parseDocument = function ( documentString, mode ) {
var doc;
if ( mode === 'source' ) {
// Parse as plain text in source mode
doc = ve.createDocumentFromHtml( '' );
documentString.split( '\n' ).forEach( function ( line ) {
var p = doc.createElement( 'p' );
p.appendChild( doc.createTextNode( line ) );
doc.body.appendChild( p );
} );
// Parent method
doc = ve.init.mw.Target.super.prototype.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

View file

@ -7,9 +7,10 @@
.ve-ui-mwDesktopWikitextSurface .ve-ce-documentNode {
font-size: 13.3333px;
/* Inherit mw-editfont setting instead of default source mode setting */
font-family: inherit;
}
.ve-ui-mwDesktopWikitextSurface .ve-ce-paragraphNode {
line-height: 20px;
margin: 0;
}