/**
* Configuration of Dialog module for wikiEditor
*/
( function () {
var toolbarModule = require( './jquery.wikiEditor.toolbar.js' ),
InsertLinkTitleInputField = require( './insertlink/TitleInputField.js' ),
LinkTextField = require( './insertlink/LinkTextField.js' ),
LinkTypeField = require( './insertlink/LinkTypeField.js' ),
insertLinkTitleInputField = new InsertLinkTitleInputField(),
insertLinkLinkTextField = new LinkTextField(),
insertLinkLinkTypeField = new LinkTypeField(),
configData = require( './data.json' );
function triggerButtonClick( element ) {
// The dialog action should always be a DOMElement.
var dialogAction = $( element ).data( 'dialogaction' );
var $button = dialogAction ? $( dialogAction ) : $( element ).find( 'button' ).first();
// Since we're reading from data attribute, make sure we got an element before clicking.
// Note when closing a dialog this can be false leading to TypeError: $button.trigger is not a function
// (T261529)
if ( $button ) {
$button.trigger( 'click' );
}
}
module.exports = {
replaceIcons: function ( $textarea ) {
$textarea
.wikiEditor( 'addToToolbar', {
section: 'main',
group: 'insert',
tools: {
link: {
labelMsg: 'wikieditor-toolbar-tool-link',
type: 'button',
oouiIcon: 'link',
action: {
type: 'dialog',
module: 'insert-link'
}
},
file: {
labelMsg: 'wikieditor-toolbar-tool-file',
type: 'button',
oouiIcon: 'image',
action: {
type: 'dialog',
module: 'insert-file'
}
},
reference: {
labelMsg: 'wikieditor-toolbar-tool-reference',
filters: [ 'body.ns-subject' ],
type: 'button',
oouiIcon: 'reference',
action: {
type: 'encapsulate',
options: {
pre: '[',
post: ']'
}
}
}
}
} )
.wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
table: {
labelMsg: 'wikieditor-toolbar-tool-table',
type: 'button',
oouiIcon: 'table',
action: {
type: 'dialog',
module: 'insert-table'
}
}
}
} )
.wikiEditor( 'addToToolbar', {
section: 'advanced',
groups: {
search: {
tools: {
replace: {
labelMsg: 'wikieditor-toolbar-tool-replace',
type: 'button',
oouiIcon: 'articleSearch',
action: {
type: 'dialog',
module: 'search-and-replace'
}
}
}
}
}
} );
},
getDefaultConfig: function () {
return { dialogs: {
'insert-link': {
titleMsg: 'wikieditor-toolbar-tool-link-title',
id: 'wikieditor-toolbar-link-dialog',
html: $( '