Initial content

content#

Type: false | string

Default: false

Initial HTML for the editor. Has priority over the host element content.

const app = Redactor('#entry', {
  content: '<p>Hello, Redactor!</p>'
});

data#

Type: false | object | array

Default: false

Initial content as JSON blocks.

const app = Redactor('#entry', {
  data: [
    { type: 'text', data: { content: '<p>Hello</p>' } },
    { type: 'heading', data: { level: 2, content: 'Title' } }
  ]
});

templateSyntax#

Type: Array<[string, string]> | false

Default: false

Protects template-engine syntax inside initial HTML (and on output). On load, matched fragments are stored safely; on getHTML() they are restored. Useful for Twig, Handlebars, Vue, and similar markup in the content.

const app = Redactor('#entry', {
  templateSyntax: [
    ['{%', '%}'],
    ['{{', '}}']
  ],
  content: '<p>Hello {% if user %}Admin{% endif %}, price: </p>'
});

Output after editing:

<p>Hello {% if user %}Admin{% endif %}, price: </p>

replaceTags#

Type: false | object

Default: false

Renames HTML tags during input cleanup. Keys are source tags, values are replacements.

const app = Redactor('#entry', {
  replaceTags: {
    b: 'strong',
    i: 'em'
  }
});