Untitled
unknown
plain_text
a year ago
935 B
9
Indexable
<TextControl
label={__('Custom Article Category Name', 'blackstone')}
help="Optional text that will override the category of this selected article."
value={customCategoryOne || ''}
onChange={(newCategory) => {
// Debug: log the original input
console.log("Original input: ", newCategory);
// Split the string into words, capitalize the first letter of each, and join them back
const formattedCategory = newCategory
.split(' ')
.map(word => {
// Debug: log each word before and after transformation
console.log("Before: ", word);
const capitalized = word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
console.log("After: ", capitalized);
return capitalized;
})
.join(' ');
// Debug: log the final formatted output
console.log("Formatted category: ", formattedCategory);
setAttributes({
customCategoryOne: formattedCategory || '',
});
}}
/>
Editor is loading...
Leave a Comment