Span

Span objects represent formatted text segments within rich text fields. They contain style and formatting information for portions of text in rich text form fields. Span objects are used with the richValue property of text fields that have richText enabled.

Example

Copy
var field = this.getField("richTextField")
field.richText = true
var spans = [
    {text: "Bold text", fontWeight: 700},
    {text: " and ", fontWeight: 400},
    {text: "italic text", fontStyle: "italic"}
]
field.richValue = spans

Properties

alignment

Secure Type Access
No string R/W

The horizontal alignment of the text within the span.

Valid values:

  • "left"

  • "center"

  • "right"

Example

Copy
var span = {
    text: "Centered text",
    alignment: "center"
}

fontFamily

Secure Type Access
No string R/W

An array containing the font family name(s) for the span. The first element is the primary font family. Additional elements can specify fallback fonts.

Default value is ["sans-serif"].

Example

Copy
var span = {
    text: "Custom font text",
    fontFamily: ["Helvetica", "Arial", "sans-serif"]
}

fontStretch

Secure Type Access
No string R/W

The font stretch value for the span text.

Valid values:

  • "ultra-condensed"

  • "extra-condensed"

  • "condensed"

  • "semi-condensed"

  • "normal" (default)

  • "semi-expanded"

  • "expanded"

  • "extra-expanded"

  • "ultra-expanded"

Example

Copy
var span = {
    text: "Condensed text",
    fontStretch: "condensed"
}

fontStyle

Secure Type Access
No string R/W

The font style for the span text.

Valid values:

  • "normal" (default)

  • "italic"

Example

Copy
var span = {
    text: "Italic text",
    fontStyle: "italic"
}

fontWeight

Secure Type Access
No number R/W

The font weight for the span text. Values greater than 400 are considered bold.

Common values:

  • 400 - Normal (default)

  • 700 - Bold

Example

Copy
var span = {
    text: "Bold text",
    fontWeight: 700
}

strikethrough

Secure Type Access
No boolean R/W

When true, the text has a line through it. Default is false.

Example

Copy
var span = {
    text: "Strikethrough text",
    strikethrough: true
}

subscript

Secure Type Access
No boolean R/W

When true, the text appears as subscript. Default is false. Cannot be true if superscript is true.

Example

Copy
var span = {
    text: "2",
    subscript: true
}
// Creates H2O when combined with other spans

superscript

Secure Type Access
No boolean R/W

When true, the text appears as superscript. Default is false. Cannot be true if subscript is true.

Example

Copy
var span = {
    text: "2",
    superscript: true
}
// Creates x² when combined with other spans

text

Secure Type Access
No string R/W

The actual text content of the span.

Example

Copy
var span = {
    text: "This is the text content"
}

textColor

Secure Type Access
No object R/W

The color of the text. Value is a color array in the same format as the color object. Default is black.

Example

Copy
var span = {
    text: "Red text",
    textColor: color.red
}

// Or using RGB array
var span = {
    text: "Blue text",
    textColor: ["RGB", 0, 0, 1]
}

textSize

Secure Type Access
No number R/W

The font size of the text in points. Default is 12.

Example

Copy
var span = {
    text: "Large text",
    textSize: 18
}

underline

Secure Type Access
No boolean R/W

When true, the text is underlined. Default is false.

Example

Copy
var span = {
    text: "Underlined text",
    underline: true
}

Usage examples

Resources

Revu 21

Revu JavaScript

JavaScript

The Revu API Reference Guide documents all JavaScript capabilities available in Revu.