Content deleted Content added
Polygnotus (talk | contribs) No edit summary |
Polygnotus (talk | contribs) No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 132:
const cleanTitle = title.replace(/^Template:/, '');
return `{{${cleanTitle}}}`;
}▼
// Create a simple SVG with the text▼
</svg>`;▼
}
Line 157 ⟶ 139:
if (favoriteTemplates && favoriteTemplates.length > 0) {
//
$textarea.wikiEditor( 'addToToolbar', {
sections: {
Line 167 ⟶ 149:
} );
//
section: 'favorite-templates',▼
groups: {▼
favorites: {▼
label: 'My Favorites'▼
}▼
// Add
for (const template of favoriteTemplates) {
const buttonId = createButtonId(template.title);
Line 183 ⟶ 158:
const displayTitle = template.title.replace(/^Template:/, '');
'font-size': '11px',
'font-family': 'sans-serif'
function() { $(this).css('background', '#eaecf0'); },
function() { $(this).css('background', '#f8f9fa'); }
.click((function(syntax) {
return function(e) {
e.preventDefault();
// Get the textarea
const textarea = $('#wpTextbox1')[0];
if (textarea) {
// Insert the template syntax at cursor position
const start = textarea.selectionStart;
const end = textarea.selectionEnd;
const text = textarea.value;
textarea.value = text.substring(0, start) + syntax + text.substring(end);
// Move cursor to end of inserted text
textarea.selectionStart = textarea.selectionEnd = start + syntax.length;
textarea.focus();
}
};
})(templateSyntax))
▲ };
▲ }
$textarea.wikiEditor( 'addToToolbar', {
▲ section: 'favorite-templates',
▲ groups: {
}
}
} );
console.log(`Added ${favoriteTemplates.length} favorite template buttons to toolbar`);
|