mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 03:08:42 +00:00
Inherit more functionality from core source mode
Change-Id: Id027681ab5f0c9f4b9ed127b583e45f0fe57ce69 Depends-On: I02f3849027a6652701c2d354d1b77ece9d1a56c1
This commit is contained in:
parent
218742d806
commit
8bca6cc777
|
@ -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();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue