This example shows how to add a custom item to the control bar dropdown next to a focused block.
<div id="entry-control-bar-buttons"></div>
const app = Redactor('#entry-control-bar-buttons', {
control: {
addDropdown: {
copyHtml: {
title: 'Copy HTML',
icon: '<svg ...>',
position: {
before: 'duplicate'
},
handler() {
const block = app.block.get();
navigator.clipboard?.writeText(block.toHTML());
app.toast.show('HTML copied to clipboard');
}
}
}
}
});