Rich Text
Saleor stores rich text, such as product descriptions and page content, as JSON in the Editor.js output format. The Dashboard uses Editor.js as its rich text editor, and the API accepts and returns the same JSON.
Saleor does not accept arbitrary JSON in these fields. It validates every document against the Editor.js format, sanitizes the HTML inside it, and saves only the cleaned version.
Fields that use rich text
| Object | Field |
|---|---|
Product |
description |
Category |
description, fullDescription |
Collection |
description, fullDescription |
Page |
content |
ShippingMethodType |
description |
Promotion |
description |
PromotionRule |
description |
AttributeValue |
richText |
The translations of these objects use the same format.
Most of these fields use the JSONString scalar, so you send the document as a JSON-encoded string. Promotion and PromotionRule use the JSON scalar, so you send the object itself.
Document structure
A document follows the standard Editor.js output:
{
"time": 1733140800000,
"version": "2.31.7",
"blocks": [
{
"id": "h1",
"type": "header",
"data": { "text": "Single-origin espresso", "level": 2 }
},
{
"id": "p1",
"type": "paragraph",
"data": {
"text": "Bright and <b>zesty</b>. See <a href=\"https://example.com/brew\">brewing tips</a>."
}
}
]
}
All top-level keys are optional, so {} and {"blocks": []} are valid. Each block needs a type and data. The id is optional.
Supported blocks
Saleor accepts the block types of the official Editor.js plugins that the Dashboard uses:
| Block type | data fields |
|---|---|
paragraph |
text, alignment |
header |
text, level, alignment |
list |
style (ordered, unordered, or checklist), items, meta |
quote |
text, caption, alignment |
image |
file.url, caption, withBorder, withBackground, stretched |
embed |
service, source, embed, caption, width, height |
table |
withHeadings, stretched, content (an array of rows, each an array of cells) |
Lists accept both the legacy format, where items is an array of strings, and the nested format of @editorjs/list 2.x, where each item is { "content", "items", "meta" }. The Dashboard saves lists in the legacy format so that existing storefronts keep working.
If your storefront renders rich text, handle each of these block types. Saleor does not render rich text to HTML for you.
Validation
Saleor validates rich text every time it saves it, no matter which mutation, app, or import writes the value:
- Unknown block types are rejected. A block such as
code,delimiter, orrawfails the whole document. - Unknown fields are dropped. Keys that Saleor does not expect, such as block
tunes, are removed silently instead of causing an error. - Lists have a depth limit. Nested lists can be at most 10 levels deep by default.
When validation fails, the mutation returns an error with the INVALID code and the message Invalid EditorJS input:
{
"errors": [
{
"field": "fullDescription",
"code": "INVALID",
"message": "Invalid EditorJS input"
}
]
}
For some fields, such as description or richText, field is null. The message does not say which block is invalid. To find the problem, compare your document with the supported blocks.
Sanitization
Text fields inside blocks, such as text, caption, and table cells, can contain inline HTML for formatting. Saleor cleans this HTML with nh3 before saving:
- Tags and attributes outside the allowlist are removed, for example
<script>oronclick. Formatting tags such as<b>,<i>,<s>,<a>, and<br>are kept. - Links can only use the
http,https,mailto, andtelURL schemes. Links with other schemes, such asjavascript:, lose theirhref. - Links get
rel="noopener noreferrer"added. - Links can keep
target="_blank", so they can open in a new tab.
URLs in structured fields, such as image.file.url, embed.source, and embed.embed, follow the same scheme rules. Saleor replaces a disallowed or unparseable URL with #invalid instead of returning an error. Relative URLs are not allowed, so always send absolute ones.
For example, this paragraph text:
<a href="javascript:alert(1)">x</a>
<script>
bad();
</script>
<b onclick="x()">bold</b>
is saved as:
<a rel="noopener noreferrer">x</a><b>bold</b>
The cleaned document is what the API returns, so read the value back after saving if you need to know exactly what was stored.
Configuration
If you self-host Saleor, you can allow more HTML attributes or change the rel value with these environment variables:
EDITOR_JS_ALLOWED_ATTRIBUTESEDITOR_JS_ALLOWED_ATTRIBUTE_VALUESEDITOR_JS_LINK_RELEDITOR_JS_LISTS_MAX_DEPTH
See Security for more on how Saleor cleans HTML. You cannot change the allowed URL schemes.
Plain text
Saleor converts rich text to plain text for search and other places that need it. It joins the text of all blocks and strips the HTML tags. The plain text is used for:
- Product, category, and page search.
- The
nameof a rich text attribute value, cut to 200 characters. - Rich text attributes in CSV exports.
Using rich text in the Dashboard
The Dashboard’s editor supports these block types: paragraph, header (levels 1–3), list, quote, table, image, and embed. Images are added by URL; uploading files from the editor is not supported. The inline toolbar has bold, italic, strikethrough, and links, which can open in a new tab.
You can find the editor in product, category, collection, page, shipping method, and discount forms, in rich text attributes, and in translations.