Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324821

Change subject: Implement convertFromSource/convertToSource in 
WikitextSurfaceFragment
......................................................................

Implement convertFromSource/convertToSource in WikitextSurfaceFragment

Depends-On: Iaa41c49e2f8e28af28a8a64cb6915f705fa35e8c
Change-Id: I746619d442fb565cd582cb09de3126526c73c333
---
M modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.js
1 file changed, 28 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/21/324821/1

diff --git a/modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.js 
b/modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.js
index 2a2be95..1e2afe0 100644
--- a/modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.js
+++ b/modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.js
@@ -127,7 +127,7 @@
 /**
  * @inheritdoc
  */
-ve.dm.MWWikitextSurfaceFragment.prototype.convertDocument = function ( doc ) {
+ve.dm.MWWikitextSurfaceFragment.prototype.convertToSource = function ( doc ) {
        var wikitextPromise;
 
        if ( !doc.data.hasContent() ) {
@@ -147,3 +147,30 @@
 
        return wikitextPromise;
 };
+
+/**
+ * @inheritdoc
+ */
+ve.dm.MWWikitextSurfaceFragment.prototype.convertFromSource = function ( 
source ) {
+       var parsePromise = new mw.Api().post( {
+               action: 'visualeditor',
+               paction: 'parsefragment',
+               page: mw.config.get( 'wgRelevantPageName' ),
+               wikitext: source
+       } ).then( function ( response ) {
+               return ve.dm.converter.getModelFromDom(
+                       ve.createDocumentFromHtml( 
response.visualeditor.content )
+               );
+       } );
+
+       // TODO: Emit an event to trigger the progress bar
+       ve.init.target.getSurface().createProgress(
+               parsePromise, ve.msg( 
'visualeditor-generating-wikitext-progress' )
+       ).done( function ( progressBar, cancelPromise ) {
+               cancelPromise.fail( function () {
+                       parsePromise.abort();
+               } );
+       } );
+
+       return parsePromise;
+};

-- 
To view, visit https://gerrit.wikimedia.org/r/324821
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I746619d442fb565cd582cb09de3126526c73c333
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to