Merge "Allow a free-text string 'title' field when adding characters"

This commit is contained in:
jenkins-bot 2021-10-08 22:24:07 +00:00 committed by Gerrit Code Review
commit c3d4bfcd2e
2 changed files with 24 additions and 4 deletions

View file

@ -581,11 +581,18 @@
}
if ( character && 'action' in character && 'label' in character ) {
actions[ character.label ] = character.action;
if ( character.titleMsg !== undefined ) {
if ( character.titleMsg !== undefined || character.title !== undefined ) {
var title;
if ( character.titleMsg !== undefined ) {
// eslint-disable-next-line mediawiki/msg-doc
title = mw.msg( character.titleMsg );
} else {
title = character.title;
}
return mw.html.element(
'span',
// eslint-disable-next-line mediawiki/msg-doc
{ rel: character.label, title: mw.msg( character.titleMsg ) },
{ rel: character.label, title: title },
character.label
);
} else {

View file

@ -237,11 +237,24 @@
data = {
section: 'info',
page: 'emoticons',
characters: [ ':)', ':))', ':(', '<3', ';)' ]
characters: [
':)', ':))', ':(', '<3', ';)',
{
label: ':-s',
title: 'unsure-face',
action: {
type: 'replace',
options: {
peri: ':-s',
selectPeri: false
}
}
} ]
};
assert.strictEqual( this.$ui.find( '*[rel="info"].section *[rel="emoticons"].page *[rel=":))"]' ).length, 0, 'Before adding characters' );
this.$target.wikiEditor( 'addToToolbar', data );
assert.strictEqual( this.$ui.find( '*[rel="info"].section *[rel="emoticons"].page *[rel=":))"]' ).length, 1, 'After adding characters' );
assert.strictEqual( this.$ui.find( '*[rel="info"].section *[rel="emoticons"].page *[title="unsure-face"]' ).length, 1, 'After adding characters find the set title' );
// Remove character
data = {