User:Polygnotus/Scripts/WikiEditorToolbarHelperConfigurator.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 169:
 
window.wecGenerate = function() {
// Process buttons to escape newlines for JSON storage
var processedButtons = buttons.map(function(btn) {
var processed = JSON.parse(JSON.stringify(btn)); // Deep clone
if (processed.insertBefore) {
processed.insertBefore = processed.insertBefore.replace(/\n/g, '\\n');
}
if (processed.insertAfter) {
processed.insertAfter = processed.insertAfter.replace(/\n/g, '\\n');
}
if (processed.sampleText) {
processed.sampleText = processed.sampleText.replace(/\n/g, '\\n');
}
return processed;
});
 
var config = {
defaults: {
Line 176 ⟶ 191:
autoSummary: { position: 'append', delimiter: '; ' }
},
buttons: buttonsprocessedButtons
};
$('#wec-json').val(JSON.stringify(config, null, 2));
Line 237 ⟶ 252:
var config = JSON.parse(content);
if (config.buttons) {
buttons// =Process config.buttons; to handle escaped newlines
buttons = config.buttons.map(function(btn) {
if (btn.insertBefore) {
btn.insertBefore = btn.insertBefore.replace(/\\n/g, '\n');
}
if (btn.insertAfter) {
btn.insertAfter = btn.insertAfter.replace(/\\n/g, '\n');
}
if (btn.sampleText) {
btn.sampleText = btn.sampleText.replace(/\\n/g, '\n');
}
return btn;
});
wecUpdateList();
}
} catch (e) {
//console.warn('Could Ignorenot parse errorsconfiguration:', e);
}
}
Line 272 ⟶ 299:
{{Clickable button|Wikipedia:Task Center|Volunteer at the Task Center|style=margin-left: 1.6em;}}
 
Happy editing! <!-- Template:Welcome--> [[User:Polygnotus|Polygnotus]] ([[User talk:Polygnotus|talk]]) 0607:5225, 7 June 2025 (UTC)',
autoSummary: { summary: 'Welcome new user', position: 'replace' },
namespaces: [3]
}, {
id: 'refideas-button',
label: 'Ref Ideas',
tooltip: 'Add reference ideas template',
icon: 'lightbulb',
type: 'ooui',
insertBefore: '{{refideas\n|1=\n}}',
autoSummary: { summary: 'Added {{refideas}} template' },
namespaces: [1]
}, {
id: 'wp-policy-ref',
label: 'WP Policy',
tooltip: 'Reference Wikipedia policy',
icon: 'articles',
type: 'ooui',
prompt: {
type: 'simple',
message: 'Enter policy abbreviation (e.g., NPOV, V, RS):',
defaultValue: 'NPOV'
},
insertBefore: '== [[WP:{input}]] ==\nPlease read [[WP:{input}]], thanks! [[User:Polygnotus|Polygnotus]] ([[User talk:Polygnotus|talk]]) 07:25, 7 June 2025 (UTC)',
placeholderPattern: '{input}',
autoSummary: {
summary: 'Referenced [[WP:{input}]]',
usePlaceholder: true,
placeholderPattern: '{input}'
},
namespaces: [3]
}];