From 8bca6cc77710d70ca3302ac091633681870ddb98 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 30 Nov 2016 18:41:50 +0000 Subject: [PATCH] Inherit more functionality from core source mode Change-Id: Id027681ab5f0c9f4b9ed127b583e45f0fe57ce69 Depends-On: I02f3849027a6652701c2d354d1b77ece9d1a56c1 --- .../ve-mw/init/ve.init.mw.ArticleTarget.js | 20 +------------------ modules/ve-mw/init/ve.init.mw.Target.js | 17 ++++------------ .../styles/ve.ui.MWDesktopWikitextSurface.css | 3 ++- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js index bffbe4f3b4..9e60820727 100644 --- a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js +++ b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js @@ -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(); }; /** diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 499dde8e4f..32f0bc5e49 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -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 diff --git a/modules/ve-mw/ui/styles/ve.ui.MWDesktopWikitextSurface.css b/modules/ve-mw/ui/styles/ve.ui.MWDesktopWikitextSurface.css index 732af11d75..27efdaeca3 100644 --- a/modules/ve-mw/ui/styles/ve.ui.MWDesktopWikitextSurface.css +++ b/modules/ve-mw/ui/styles/ve.ui.MWDesktopWikitextSurface.css @@ -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; }