mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Remove WikitextWindowAction, inherits from core
Depends-On: I2b14cc93bf3c855e157f0b26567337f74992fb96 Change-Id: I3e479c1441f548f62ff8a2f6e7b2ad450262921f
This commit is contained in:
parent
976d2e935a
commit
9b5adb8688
|
@ -1768,7 +1768,6 @@
|
|||
"modules/ve-mw/ui/ve.ui.MWWikitextDataTransferHandlerFactory.js",
|
||||
"modules/ve-mw/ui/ve.ui.MWDesktopWikitextSurface.js",
|
||||
"modules/ve-mw/ui/actions/ve.ui.MWWikitextAction.js",
|
||||
"modules/ve-mw/ui/actions/ve.ui.MWWikitextWindowAction.js",
|
||||
"modules/ve-mw/ui/inspectors/ve.ui.MWWikitextLinkAnnotationInspector.js"
|
||||
],
|
||||
"styles": [
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
/*!
|
||||
* VisualEditor UserInterface MWWikitextWindowAction class.
|
||||
*
|
||||
* @copyright 2011-2016 VisualEditor Team and others; see http://ve.mit-license.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wikitext window action.
|
||||
*
|
||||
* @class
|
||||
* @extends ve.ui.WindowAction
|
||||
* @constructor
|
||||
* @param {ve.ui.Surface} surface Surface to act on
|
||||
*/
|
||||
ve.ui.MWWikitextWindowAction = function VeUiMWWikitextWindowAction( surface ) {
|
||||
// Parent constructor
|
||||
ve.ui.MWWikitextWindowAction.super.call( this, surface );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWWikitextWindowAction, ve.ui.WindowAction );
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* Open a window.
|
||||
*
|
||||
* @method
|
||||
* @param {string} name Symbolic name of window to open
|
||||
* @param {Object} [data] Window opening data
|
||||
* @param {string} [action] Action to execute after opening, or immediately if the window is already open
|
||||
* @return {boolean} Action was executed
|
||||
*/
|
||||
ve.ui.MWWikitextWindowAction.prototype.open = function ( name, data, action ) {
|
||||
var currentInspector, inspectorWindowManager,
|
||||
originalFragment, originalDocument, coveringRange, rangeInDocument, tempDocument, tempSurfaceModel,
|
||||
windowType = this.getWindowType( name ),
|
||||
windowManager = windowType && this.getWindowManager( windowType ),
|
||||
currentWindow = windowManager.getCurrentWindow(),
|
||||
autoClosePromises = [],
|
||||
surface = this.surface,
|
||||
fragment = surface.getModel().getFragment( undefined, true ),
|
||||
dir = surface.getView().getSelection().getDirection();
|
||||
|
||||
if ( !( this.surface.getModel() instanceof ve.dm.MWWikitextSurface ) || ve.ui.windowFactory.lookup( name ).static.handlesWikitext ) {
|
||||
return ve.ui.MWWikitextWindowAction.super.prototype.open.apply( this, arguments );
|
||||
}
|
||||
|
||||
// TODO: This duplicates code in SourceSurfaceFragment#annotateContent
|
||||
originalFragment = fragment;
|
||||
originalDocument = originalFragment.getDocument();
|
||||
coveringRange = originalFragment.getSelection().getCoveringRange();
|
||||
if ( coveringRange && !coveringRange.isCollapsed() ) {
|
||||
tempDocument = surface.getModel().getDocument().shallowCloneFromRange( coveringRange );
|
||||
rangeInDocument = tempDocument.originalRange;
|
||||
} else {
|
||||
tempDocument = new ve.dm.Document(
|
||||
[
|
||||
{ type: 'paragraph', internal: { generated: 'wrapper' } }, { type: '/paragraph' },
|
||||
{ type: 'internalList' }, { type: '/internalList' }
|
||||
],
|
||||
null, null, null, null,
|
||||
originalDocument.getLang(),
|
||||
originalDocument.getDir()
|
||||
);
|
||||
rangeInDocument = new ve.Range( 1 );
|
||||
}
|
||||
tempSurfaceModel = new ve.dm.Surface( tempDocument );
|
||||
fragment = tempSurfaceModel.getLinearFragment( rangeInDocument );
|
||||
|
||||
if ( !windowManager ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data = ve.extendObject( { dir: dir }, data, { fragment: fragment } );
|
||||
if ( windowType === 'toolbar' || windowType === 'inspector' ) {
|
||||
data = ve.extendObject( data, { surface: surface } );
|
||||
// Auto-close the current window if it is different to the one we are
|
||||
// trying to open.
|
||||
// TODO: Make auto-close a window manager setting
|
||||
if ( currentWindow && currentWindow.constructor.static.name !== name ) {
|
||||
autoClosePromises.push( windowManager.closeWindow( currentWindow ) );
|
||||
}
|
||||
}
|
||||
|
||||
// If we're opening a dialog, close all inspectors first
|
||||
if ( windowType === 'dialog' ) {
|
||||
inspectorWindowManager = this.getWindowManager( 'inspector' );
|
||||
currentInspector = inspectorWindowManager.getCurrentWindow();
|
||||
if ( currentInspector ) {
|
||||
autoClosePromises.push( inspectorWindowManager.closeWindow( currentInspector ) );
|
||||
}
|
||||
}
|
||||
|
||||
$.when.apply( $, autoClosePromises ).always( function () {
|
||||
windowManager.getWindow( name ).then( function ( win ) {
|
||||
var opening = windowManager.openWindow( win, data );
|
||||
|
||||
if ( !win.constructor.static.activeSurface ) {
|
||||
surface.getView().deactivate();
|
||||
}
|
||||
|
||||
opening.then( function ( closing ) {
|
||||
// HACK: previousSelection is assumed to be in the visible surface
|
||||
win.previousSelection = null;
|
||||
closing.then( function ( closed ) {
|
||||
if ( !win.constructor.static.activeSurface ) {
|
||||
surface.getView().activate();
|
||||
}
|
||||
closed.then( function () {
|
||||
if ( tempSurfaceModel && tempSurfaceModel.hasBeenModified() ) {
|
||||
originalFragment.insertDocument( tempSurfaceModel.getDocument() );
|
||||
}
|
||||
surface.getView().emit( 'position' );
|
||||
} );
|
||||
} );
|
||||
} ).always( function () {
|
||||
if ( action ) {
|
||||
win.executeAction( action );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/* Registration */
|
||||
|
||||
ve.ui.actionFactory.register( ve.ui.MWWikitextWindowAction );
|
|
@ -29,7 +29,7 @@ ve.ui.MWWikitextLinkAnnotationInspector.static.name = 'link';
|
|||
|
||||
ve.ui.MWWikitextLinkAnnotationInspector.static.modelClasses = [];
|
||||
|
||||
ve.ui.MWWikitextLinkAnnotationInspector.static.handlesWikitext = true;
|
||||
ve.ui.MWWikitextLinkAnnotationInspector.static.handlesSource = true;
|
||||
|
||||
/* Methods */
|
||||
|
||||
|
|
Loading…
Reference in a new issue