Adds a block control button with a color picker for the background color of the current block. Applies background-color as an inline style on the block element.
Select a block, open the control dropdown, and choose Background color. Pick a swatch, enter a hex value, or remove the color to reset.
<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/block-background/block-background.js"></script>
const app = Redactor('#entry', {
plugins: ['blockBackground']
});
boolean)
truetrue, shows a manual hex input in the color picker.object | string[] | null)
nullnull uses the editor-wide colors option.string)
Redactor('#entry', {
plugins: ['blockBackground'],
blockBackground: {
input: false,
colors: ['#ffffff', '#fff3bf', '#ffe066', '#ffd8a8']
}
});
en: {
blockBackground: {
"background-color": "Background color"
}
}
This plugin does not emit events.
Applies a background color to the current block and closes the dropdown.
Parameters:
color (string) — CSS color value (for example #fff3bf).app.blockBackground.set({ color: '#fff3bf' });
Clears the block background color and closes the dropdown.
app.blockBackground.remove();