2012-03-29 22:55:33 +00:00
|
|
|
/**
|
|
|
|
* Creates an ve.Surface object.
|
2012-04-19 22:14:57 +00:00
|
|
|
*
|
2012-03-29 22:55:33 +00:00
|
|
|
* A surface is a top-level object which contains both a surface model and a surface view.
|
2012-04-19 22:14:57 +00:00
|
|
|
*
|
2012-03-29 22:55:33 +00:00
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @param {String} id Unique name of editor instance
|
|
|
|
* @param {Array} data Document data
|
|
|
|
* @param {Object} options Configuration options
|
|
|
|
*/
|
|
|
|
ve.Surface = function( id, data, options ) {
|
|
|
|
// Properties
|
|
|
|
this.id = id;
|
|
|
|
this.options = ve.extendObject( {
|
|
|
|
// Default options
|
2012-04-19 22:14:57 +00:00
|
|
|
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 );
|
2012-03-29 22:55:33 +00:00
|
|
|
|
2012-04-02 22:28:26 +00:00
|
|
|
this.documentModel = ve.dm.DocumentNode.newFromPlainObject( data );
|
|
|
|
this.surfaceModel = new ve.dm.Surface( this.documentModel );
|
2012-03-29 22:55:33 +00:00
|
|
|
|
|
|
|
//TODO: Find source of breakage when view element is not #es-editor
|
2012-04-02 22:28:26 +00:00
|
|
|
this.view = new ve.ce.Surface( $( '#es-editor' ), this.surfaceModel );
|
2012-03-29 22:55:33 +00:00
|
|
|
this.context = new ve.ui.Context( this.view );
|
|
|
|
|
|
|
|
//TODO: Configure toolbar based on this.options.
|
2012-04-19 22:14:57 +00:00
|
|
|
this.toolbar = new ve.ui.Toolbar( $( '#es-toolbar' ), this.view, this.options.toolbars.top );
|
2012-03-29 22:55:33 +00:00
|
|
|
// Registration
|
|
|
|
ve.instances.push( this );
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.Surface.prototype.getSurfaceModel = function() {
|
2012-04-02 22:28:26 +00:00
|
|
|
return this.surfaceModel;
|
2012-03-29 22:55:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.Surface.prototype.getDocumentModel = function() {
|
2012-04-02 22:28:26 +00:00
|
|
|
return this.documentModel;
|
2012-03-29 22:55:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.Surface.prototype.getID = function() {
|
|
|
|
return this.id;
|
2012-04-02 22:28:26 +00:00
|
|
|
};
|