editor

Docs › Blocks

HTML block

Insert ready-made HTML (like a product page) with its classes and styles.

For HTML you already have: a product detail page, a banner, a hand-made layout. Unlike regular content, an HTML block keeps classes and nearly every CSS property.

Try it

Code for this demo

createEditor('#editor', {
  toolbar: 'heading | bold | htmlBlock | source | undo redo',
});

How to use

  • The htmlBlock button opens a box to paste HTML into. "Insert" puts the block at the caret.
  • In the editor an HTML block is one piece: its text cannot be edited in place, and a click selects the whole block and shows its bar.
  • The bar: Edit HTML (edit and apply in the same box, or remove), Move up, Move down, Remove.

What stays and what goes

Inside an HTML blockRegular content
classkept (up to 12 per element)dropped (only styles classes stay)
CSS propertiesnearly all kept (grid, gradients …)allow-listed ones only
section article header footer aside main centerkepttag removed, text kept
script style form input button svg …removed with contentremoved with content
Event attributes like onclickremovedremoved
javascript: URLs, CSS url() and expression()removedremoved
iframesallowed sites only (allowedIframeHosts)allowed sites only

Saved HTML

<div data-html="">
  <section class="promo" style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; …">
    …
  </section>
</div>

If your server sanitizes again, make sure its rules keep classes and styles inside div[data-html] (Security).

editor.exec('htmlBlock'); // open the HTML block dialog

Presets

htmlBlock is only in the full preset, under ⋯. It suits admin screens better than boards open to visitors.

Options

NameTypeDefaultDescription
htmlBlocktoolbar item-Insert or edit an HTML block
allowedIframeHostsstring[]-Iframes inside the block also need a built-in video site, Google Maps, or a host from this list