Page tree
Skip to end of metadata
Go to start of metadata

RichTextFieldDefinition  renders a rich text editor. This is a custom Magnolia field that implements the CKEditor component.

Class: info.magnolia.ui.form.field.definition.RichTextFieldDefinition

Rich Text field properties

Simple rich text field definition.

form:
  tabs:
    - name: tabText
      label: Text
      fields:
        - name: text
          class: info.magnolia.ui.form.field.definition.RichTextFieldDefinition
          tables: true
          height: 500
          label: Text Editor

Node name

Value

 form


 tabs


 tabText


 fields


 text


 class

info.magnolia.ui.form.field.definition.RichTextFieldDefinition

 tables

true

 height

500

 label

Text Editor




You can use   common field properties  and the following properties in a rich text field definition:

Properties:

<field name>Name of field.

alignment

optional, default is false

Text alignment for paragraphs. When set to true, this option adds alignment buttons (left, center, right, justify) in the toolbar.

colors

optional

Colors displayed in the color selectors. Comma-separated a string of hexadecimal color codes without the # prefix, for example 00923E,F8C100,28166F . See CKEditor documentation for more.

configJsFile

optional

Location of a custom CKEditor configuration file, e.g. /.resources/ckeditor/config-magnolia.js. You can link to a file in the resources workspace, filesystem or classpath. See Origins and loading order for more. 

The default configuration files can be found in magnolia-ui-framework/src/main/resources/mgnl-resources/ckeditor/ 

  • config-magnolia.js (Git): Magnolia default configuration file.
  • config-default.js (Git): CKEditor configuration file.

(warning) If you use a custom configuration file Magnolia will ignore all other configured properties.

A custom configuration allows you control over the config.extraPlugins setting, but also means you need to the magnolialink and magnoliaFileBrowser plugins into your file. See the default config-magnolia.js for how to include the plugins.

fonts

optional

List of font names displayed in the Font selector in the toolbar, for example Arial/Arial,sans-serif;Times New Roman/Times New Roman,serif . Separate entries with a  semi-colon (;). It's possible to have more than one font for each entry separated by comma. A display name may be optionally defined by prefixing the entries with the name and the slash character. See

CKEditor documentation for more.

fontSizes

optional

List of fonts size displayed in the Font selector in the toolbar, for example 16/16px;24/24px;48/48px. Separate entries with a semi-colon (;). Any CSS-supported size can be used: 12px, 2.3em, 130%, larger or x-small. A display name may be optionally defined by prefixing the entries with the name and the slash character. For example, Bigger Font/14px will be displayed as Bigger Font in the list, but will be outputted as 14px. See CKEditor documentation for more.

height

optional, default is 300

The height of the editing area, including the toolbar, for example 500. This configuration option accepts an integer (to denote a value in pixels) or any CSS-defined length unit except percent (%) values. Users can expand the editing area to the full height of the container, which is typically a subapp.

images

optional, default is false

Allows images to be added from the DAM. When set to true, this option adds an image button in the toolbar. A user can define the size and alignment of the image, and some metadata.

lists

optional, default is true

Allows bulleted and numbered lists. When set to false, this option removes list buttons from the toolbar.

source

optional, default is false

Allows toggling between text and HTML editing. When set to true, this option adds a source button to the toolbar.

tables

optional, default is false

Allows tables to be added. When set to true, this option adds a tables button in the toolbar.

Link buttons

There are three link buttons:

  •  Links to external pages
  •  Links to internal pages
  •  Links to documents in the DAM

Loading order for custom configuration

(warning) Note that any configuration done in a  RichTextFieldFactory will override configuration settings from the config.js file. This is why we ignore other properties in the field definition as soon as a configJsFile is configured.

Decode text

CKEditor produces HTML such as <p> elements for paragraphs. However, text stored in JCR usually escapes HTML code. To render text which originates from a rich text field you need to decode the stored content to make sure the HTML tags are rendered properly again.

Decode the content object and then get the desired property from it:

${cmsfn.decode(content).text!""}

See  cmsfn decodeHtml.

Impact on the search index

Keep in mind that using the RTE introduces HTML into your content. The impact of this is that the HTML will be indexed along with the content.

  • No labels