2013-02-20 19:44:44 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor Initialization Target class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic Initialization target.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
2013-10-15 11:58:04 +00:00
|
|
|
* @mixins OO.EventEmitter
|
2013-02-20 19:44:44 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {jQuery} $container Conainter to render target into
|
|
|
|
*/
|
|
|
|
ve.init.Target = function VeInitTarget( $container ) {
|
2013-05-01 22:21:32 +00:00
|
|
|
// Mixin constructors
|
2013-10-15 11:58:04 +00:00
|
|
|
OO.EventEmitter.call( this );
|
2013-02-20 19:44:44 +00:00
|
|
|
|
|
|
|
// Properties
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$element = $container;
|
2013-12-19 02:06:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {ve.ui.Surface}
|
|
|
|
*/
|
|
|
|
this.surface = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {jQuery} The ve-ce-documentNode of #surface
|
|
|
|
*/
|
|
|
|
this.$document = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {ve.ui.TargetToolbar}
|
|
|
|
*/
|
|
|
|
this.toolbar = null;
|
2013-02-20 19:44:44 +00:00
|
|
|
};
|
|
|
|
|
2013-12-19 02:06:55 +00:00
|
|
|
/* Events */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fired when the #surface is ready.
|
|
|
|
*
|
|
|
|
* By default the surface document is not focussed. If the target wants
|
|
|
|
* the browsers' focus to be in the surface (ready for typing and cursoring)
|
|
|
|
* call `this.$document[0].focus();` in a handler for this event.
|
|
|
|
*
|
|
|
|
* @event surfaceReady
|
|
|
|
*/
|
|
|
|
|
2013-02-20 19:44:44 +00:00
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-15 11:58:04 +00:00
|
|
|
OO.mixinClass( ve.init.Target, OO.EventEmitter );
|
2013-05-10 00:17:51 +00:00
|
|
|
|
2013-05-14 23:45:42 +00:00
|
|
|
/* Static Properties */
|
2013-05-10 00:17:51 +00:00
|
|
|
|
2013-08-09 18:29:09 +00:00
|
|
|
ve.init.Target.static.toolbarGroups = [
|
2013-12-06 23:49:11 +00:00
|
|
|
// History
|
2013-08-27 23:28:29 +00:00
|
|
|
{ 'include': [ 'undo', 'redo' ] },
|
2013-12-06 23:49:11 +00:00
|
|
|
// Format
|
2013-08-09 18:29:09 +00:00
|
|
|
{
|
2013-08-27 23:28:29 +00:00
|
|
|
'type': 'menu',
|
|
|
|
'include': [ { 'group': 'format' } ],
|
|
|
|
'promote': [ 'paragraph' ],
|
2013-12-13 20:24:54 +00:00
|
|
|
'demote': [ 'preformatted' ]
|
2013-08-09 18:29:09 +00:00
|
|
|
},
|
2013-12-06 23:49:11 +00:00
|
|
|
// Style
|
|
|
|
{
|
|
|
|
'type': 'list',
|
|
|
|
'icon': 'text-style',
|
|
|
|
'include': [ { 'group': 'textStyle' }, 'clear' ],
|
|
|
|
'promote': [ 'bold', 'italic' ],
|
|
|
|
'demote': [ 'strikethrough', 'code', 'underline', 'clear' ]
|
|
|
|
},
|
|
|
|
// Link
|
|
|
|
{ 'include': [ 'link' ] },
|
|
|
|
// Structure
|
|
|
|
{
|
|
|
|
'type': 'bar',
|
|
|
|
'include': [ 'number', 'bullet', 'outdent', 'indent' ]
|
|
|
|
},
|
|
|
|
// Insert
|
|
|
|
{
|
|
|
|
'include': '*',
|
|
|
|
'label': 'visualeditor-toolbar-insert',
|
|
|
|
'demote': [ 'specialcharacter' ]
|
|
|
|
}
|
2013-10-18 20:09:04 +00:00
|
|
|
|
2013-05-14 23:45:42 +00:00
|
|
|
];
|
2013-05-10 00:17:51 +00:00
|
|
|
|
2013-05-14 23:45:42 +00:00
|
|
|
ve.init.Target.static.surfaceCommands = [
|
2013-08-29 23:57:41 +00:00
|
|
|
'undo',
|
|
|
|
'redo',
|
|
|
|
'bold',
|
|
|
|
'italic',
|
|
|
|
'link',
|
|
|
|
'clear',
|
2013-11-08 12:44:31 +00:00
|
|
|
'underline',
|
|
|
|
'subscript',
|
|
|
|
'superscript',
|
2013-08-29 23:57:41 +00:00
|
|
|
'indent',
|
|
|
|
'outdent',
|
|
|
|
'paragraph',
|
|
|
|
'heading1',
|
|
|
|
'heading2',
|
|
|
|
'heading3',
|
|
|
|
'heading4',
|
|
|
|
'heading5',
|
|
|
|
'heading6',
|
2013-10-07 20:45:19 +00:00
|
|
|
'preformatted',
|
|
|
|
'pasteSpecial'
|
2013-05-14 23:45:42 +00:00
|
|
|
];
|
2013-09-30 13:26:33 +00:00
|
|
|
|
|
|
|
ve.init.Target.static.pasteRules = {
|
|
|
|
'blacklist': [
|
|
|
|
// Annotations
|
|
|
|
// TODO: allow spans
|
|
|
|
'textStyle/span',
|
|
|
|
// Nodes
|
|
|
|
'alienInline', 'alienBlock'
|
2013-12-09 19:46:53 +00:00
|
|
|
]
|
2013-09-30 13:26:33 +00:00
|
|
|
};
|