mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
8039b1c2f8
Objective: * Allow opening reference dialog with arbitrary selection * Auto-insert reference when selection is not a reference node Changes: ve.init.mw.ViewPageTarget.js * Added reference button to toolbar ve.init.Target.js * Add getToolbarSubset so we can exclude the reference button from the toolbar in the reference dialog (nested references are not allowed). ve.ui.MWReferenceDialog.js * Stop storing referenceNode (not needed) * Only store internalItem on open if there's a focused node that's a reference * Use wrapper paragraph when creating a new reference * Create new reference on dialog close if required ve.dm.InternalList.js * Major rewrite to support key less references. * Add new method for creating a transaction to insert a new iternal item. Also returns the index of the new item to be passed to the reference node. Change-Id: I839ae165c299248484ce93d4ab087318a95fbb94
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
/*!
|
|
* 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
|
|
* @mixins ve.EventEmitter
|
|
*
|
|
* @constructor
|
|
* @param {jQuery} $container Conainter to render target into
|
|
*/
|
|
ve.init.Target = function VeInitTarget( $container ) {
|
|
// Mixin constructors
|
|
ve.EventEmitter.call( this );
|
|
|
|
// Properties
|
|
this.$ = $container;
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.mixinClass( ve.init.Target, ve.EventEmitter );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.init.Target.static.toolbarTools = [
|
|
{ 'items': ['undo', 'redo'] },
|
|
{ 'items': ['format'] },
|
|
{ 'items': ['bold', 'italic', 'link', 'clear'] },
|
|
{ 'items': ['number', 'bullet', 'outdent', 'indent'] }
|
|
];
|
|
|
|
ve.init.Target.static.surfaceCommands = [
|
|
'bold', 'italic', 'link', 'undo', 'redo', 'indent', 'outdent'
|
|
];
|
|
|
|
/* Static Methods */
|
|
|
|
/**
|
|
* Get a subset of toolbarTools excluding certain tools.
|
|
*
|
|
* @param {string[]} exclude List of tools to exclude
|
|
* @returns {Object} Toolbar tools object
|
|
*/
|
|
ve.init.Target.static.getToolbarSubset = function ( exclude ) {
|
|
var i, iLen, items, group, toolbarSubset = [];
|
|
for ( i = 0, iLen = this.toolbarTools.length; i < iLen; i++ ) {
|
|
items = ve.simpleArrayDifference( this.toolbarTools[i].items, exclude );
|
|
if ( items.length ) {
|
|
group = ve.copyObject( this.toolbarTools[i] );
|
|
group.items = items;
|
|
toolbarSubset.push( group );
|
|
}
|
|
}
|
|
return toolbarSubset;
|
|
};
|