TextEditor

TextEditor

A collection of helper functions and utility methods related to the rich text editor

Constructor

new TextEditor()

Source:

Methods

(static) _createInlineRoll(match, command, formula, closing) → {string}

Source:

Replace an inline roll formula with a rollable element or an eagerly evaluated roll result

Parameters:
Name Type Description
match string

The matched string

command string

An optional command

formula string

The matched formula

closing string

The closing brackets for the inline roll

Returns:

The replaced match

Type
string

(async, static) create(options, content) → {tinyMCE.Editor}

Source:

Create a Rich Text Editor. The current implementation uses TinyMCE

Parameters:
Name Type Description
options Object

Configuration options provided to the Editor init

content string

Initial HTML or text content to populate the editor with

Returns:

The editor instance.

Type
tinyMCE.Editor

(static) decodeHTML(html) → {string}

Source:

Safely decode an HTML string, removing invalid tags and converting entities back to unicode characters.

Parameters:
Name Type Description
html string

The original encoded HTML string

Returns:

The decoded unicode string

Type
string

(static) enrichHTML(content, secrets, entities, links, rolls, rollData) → {string}

Source:

Enrich HTML content by replacing or augmenting components of it

Parameters:
Name Type Description
content string

The original HTML content (as a string)

secrets boolean

Include secret tags in the final HTML? If false secret blocks will be removed.

entities boolean

Replace dynamic entity links?

links boolean

Replace hyperlink content?

rolls boolean

Replace inline dice rolls?

rollData Object

The data object providing context for inline rolls

Returns:

The enriched HTML content

Type
string

(static) previewHTML(content, length) → {string}

Source:

Preview an HTML fragment by constructing a substring of a given length from its inner text.

Parameters:
Name Type Default Description
content string

The raw HTML to preview

length number 250

The desired length

Returns:

The previewed HTML

Type
string

(static) truncateText(text, maxLengthopt, splitWordsopt, suffixopt) → {*}

Source:

Truncate a fragment of text to a maximum number of characters.

Parameters:
Name Type Attributes Description
text string

The original text fragment that should be truncated to a maximum length

maxLength number <optional>

The maximum allowed length of the truncated string.

splitWords boolean <optional>

Whether to truncate by splitting on white space (if true) or breaking words.

suffix string | null <optional>

A suffix string to append to denote that the text was truncated.

Returns:
Type
*