Represents a formatted text string. The underlying implementation uses a macOS Attributed String (NSAttributedString) object. Can be constructed from a plain string in RTF, HTML, or Markdown format.

Example

// create a RichString object from a html string
const item = new RichString("<b>bold</b> and <i>italic</i>.", {format: 'html'});
// create a RichString object from a markdown string
const item = new RichString("# Title\n\nBody.", {format: 'markdown'});

Constructors

Properties

Constructors

  • Create a new RichString object from a string.

    Parameters

    • source: string

      The string to convert to a RichString object.

    • Optional options: {
          format?: "html" | "rtf" | "markdown";
      }

      Options for the conversion.

      • Optional format?: "html" | "rtf" | "markdown"

        Format of the source string. Default is 'rtf'.

    Returns RichString

Properties

html: string

An HTML representation of the content.

rtf: string

An RTF representation of the content.