mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Modify VE constructor to have the default set of tool configuration
Configuration options are to extend base options in the constructor. Change-Id: Ic430a6489d8cf9a703e374c3f416feaf0e3d2521
This commit is contained in:
parent
e2ca8c24c7
commit
1a68c42049
|
@ -503,18 +503,8 @@ $(document).ready( function() {
|
|||
}
|
||||
};
|
||||
|
||||
/* TODO: Make the config better */
|
||||
var options = {
|
||||
toolbars: {
|
||||
'top': [ { 'name': 'history', 'items' : ['undo', 'redo'] },
|
||||
{ 'name': 'textStyle', 'items' : ['format'] },
|
||||
{ 'name': 'textStyle', 'items' : ['bold', 'italic', 'link', 'clear'] },
|
||||
{ 'name': 'list', 'items' : ['number', 'bullet', 'outdent', 'indent'] } ]
|
||||
}
|
||||
};
|
||||
|
||||
//create a new instance of VE
|
||||
var sandboxEditor = new ve.Surface('sandbox', wikidoms['Wikipedia article'], options ),
|
||||
/* Create a new instance of VE, optional third param for ve configuration options */
|
||||
var sandboxEditor = new ve.Surface('sandbox', wikidoms['Wikipedia article'] /*, options */),
|
||||
surfaceModel = sandboxEditor.getSurfaceModel(),
|
||||
documentModel = sandboxEditor.getDocumentModel(),
|
||||
editorID = sandboxEditor.getID();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* Creates an ve.Surface object.
|
||||
*
|
||||
*
|
||||
* A surface is a top-level object which contains both a surface model and a surface view.
|
||||
*
|
||||
*
|
||||
* @class
|
||||
* @constructor
|
||||
* @param {String} id Unique name of editor instance
|
||||
|
@ -14,7 +14,13 @@ ve.Surface = function( id, data, options ) {
|
|||
this.id = id;
|
||||
this.options = ve.extendObject( {
|
||||
// Default options
|
||||
}, this.options );
|
||||
toolbars: {
|
||||
'top': [{ 'name': 'history', 'items' : ['undo', 'redo'] },
|
||||
{ 'name': 'textStyle', 'items' : ['format'] },
|
||||
{ 'name': 'textStyle', 'items' : ['bold', 'italic', 'link', 'clear'] },
|
||||
{ 'name': 'list', 'items' : ['number', 'bullet', 'outdent', 'indent'] }]
|
||||
}
|
||||
}, options );
|
||||
|
||||
this.documentModel = ve.dm.DocumentNode.newFromPlainObject( data );
|
||||
this.surfaceModel = new ve.dm.Surface( this.documentModel );
|
||||
|
@ -24,7 +30,7 @@ ve.Surface = function( id, data, options ) {
|
|||
this.context = new ve.ui.Context( this.view );
|
||||
|
||||
//TODO: Configure toolbar based on this.options.
|
||||
this.toolbar = new ve.ui.Toolbar( $( '#es-toolbar'), this.view, options.toolbars.top );
|
||||
this.toolbar = new ve.ui.Toolbar( $( '#es-toolbar' ), this.view, this.options.toolbars.top );
|
||||
// Registration
|
||||
ve.instances.push( this );
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue