Content deleted Content added
Polygnotus (talk | contribs) No edit summary |
Polygnotus (talk | contribs) No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 139:
if (favoriteTemplates && favoriteTemplates.length > 0) {
// First, add the section
$textarea.wikiEditor( 'addToToolbar', {
sections: {
'favorite-templates': {
label: 'Favorite Templates'
}
}
} );
// Create the tools object for the buttons
const templateTools = {};
Line 149 ⟶ 159:
templateTools[buttonId] = {
'border': '1px solid #a2a9b1',
'border-radius': '2px',
'background': '#f8f9fa',
'cursor': 'pointer',
'font-size': '11px',
'font-family': 'sans-serif'
})
.hover(
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: '
groups: {
'
▲ label: 'Favorite Templates',
tools: templateTools
}
|