Static
implementationRetrieve the configured TextEditor implementation.
Static
_uploadInternal
Upload an image to a document's asset path.
The document's UUID.
The image file to upload.
The path to the uploaded image.
Static
activateActivate interaction listeners for the interior content of the editor frame.
Static
createCreate a Rich Text Editor. The current implementation uses TinyMCE
Configuration options provided to the Editor init
Optional
engine?: stringWhich rich text editor engine to use, "tinymce" or "prosemirror". TinyMCE is deprecated and will be removed in a later version.
Initial HTML or text content to populate the editor with
The editor instance.
Static
createHelper method to create an anchor element.
Optional
options: Partial<EnrichmentAnchorOptions> = {}Options to configure the anchor's construction.
Static
decodeHTMLSafely decode an HTML string, removing invalid tags and converting entities back to unicode characters.
The original encoded HTML string
The decoded unicode string
Static
enrichHTMLEnrich HTML content by replacing or augmenting components of it
The original HTML content (as a string)
Optional
options: EnrichmentOptions = {}Additional options which configure how HTML is enriched
The enriched HTML content
Static
getGiven a Drop event, returns a Content link if possible such as "@Actor[ABC123]", else null
The parsed object of data provided by the transfer event
Optional
options: { label?: string; relativeTo?: any } = {}Additional options to configure link creation.
Optional
label?: stringA custom label to use instead of the document's name.
Optional
relativeTo?: anyA document to generate the link relative to.
Static
getExtract JSON data from a drag/drop event.
The drag event which contains JSON data.
The extracted JSON data. The object will be empty if the DragEvent did not contain JSON-parseable data.
Static
previewHTMLPreview an HTML fragment by constructing a substring of a given length from its inner text.
The raw HTML to preview
The desired length
The previewed HTML
Static
truncateHTMLSanitises an HTML fragment and removes any non-paragraph-style text.
The root HTML element.
Static
truncateTruncate a fragment of text to a maximum number of characters.
The original text fragment that should be truncated to a maximum length
Optional
options: { maxLength?: number; splitWords?: boolean; suffix?: null | string } = {}Options which affect the behavior of text truncation
Optional
maxLength?: numberThe maximum allowed length of the truncated string.
Optional
splitWords?: booleanWhether to truncate by splitting on white space (if true) or breaking words.
Optional
suffix?: null | stringA suffix string to append to denote that the text was truncated.
The truncated text string
Protected
Static
_applyProtected
Match any custom registered regex patterns and apply their replacements.
The custom enricher configuration.
The existing text content.
Optional
options: EnrichmentOptionsOptions provided to customize text enrichment
Whether any replacements were made, requiring the text nodes to be updated.
Protected
Static
_createProtected
Create a dynamic document link from a regular expression match
The regular expression match
Optional
options: EnrichmentOptions = {}Additional options to configure enrichment behaviour
Optional
custom?: booleanApply custom enrichers?
Optional
documents?: booleanReplace dynamic document links?
Optional
embeds?: booleanReplace embedded content?
Optional
links?: booleanReplace hyperlink content?
Optional
relativeTo?: anyA document to resolve relative UUIDs against.
Optional
rollData?: object | FunctionThe data object providing context for inline rolls, or a function that produces it.
Optional
rolls?: booleanReplace inline dice rolls?
Optional
secrets?: booleanInclude unrevealed secret tags in the final HTML? If false, unrevealed secret blocks will be removed.
An HTML element for the document link.
Protected
Static
_createProtected
Replace a hyperlink-like string with an actual HTML <a> tag
The regular expression match
Optional
options: EnrichmentOptions = {}Options provided to customize text enrichment
An HTML element for the document link
Protected
Static
_createProtected
Replace an inline roll formula with a rollable <a> element or an eagerly evaluated roll result
The regular expression match array
Provided roll data for use in roll evaluation
Optional
options: EnrichmentOptions = {}Options provided to customize text enrichment.
The replaced match. Returns null if the contained command is not a valid roll expression.
Protected
Static
_createProtected
Create a TinyMCE editor instance.
Optional
options: object = {}Configuration options passed to the editor.
Optional
content: string = ""Initial HTML or text content to populate the editor with.
The TinyMCE editor instance.
Protected
Static
_embedProtected
Embed content from another Document.
The regular expression match.
Optional
options: EnrichmentOptions = {}Options provided to customize text enrichment.
A representation of the Document as HTML content, or null if the Document could not be embedded.
Protected
Static
_enrichProtected
Convert text of the form @UUID[uuid]{name} to anchor elements.
The existing text content
Optional
options: EnrichmentOptions = {}Options provided to customize text enrichment
Optional
custom?: booleanApply custom enrichers?
Optional
documents?: booleanReplace dynamic document links?
Optional
embeds?: booleanReplace embedded content?
Optional
links?: booleanReplace hyperlink content?
Optional
relativeTo?: anyA document to resolve relative UUIDs against.
Optional
rollData?: object | FunctionThe data object providing context for inline rolls, or a function that produces it.
Optional
rolls?: booleanReplace inline dice rolls?
Optional
secrets?: booleanInclude unrevealed secret tags in the final HTML? If false, unrevealed secret blocks will be removed.
Whether any content links were replaced and the text nodes need to be updated.
Protected
Static
_enrichProtected
Handle embedding Document content with @Embed[uuid]{label} text.
The existing text content.
Optional
options: EnrichmentOptions = {}Options provided to customize text enrichment.
Whether any embeds were replaced and the text nodes need to be updated.
Protected
Static
_enrichProtected
Convert URLs into anchor elements.
The existing text content
Optional
options: EnrichmentOptions = {}Options provided to customize text enrichment
Whether any hyperlinks were replaced and the text nodes need to be updated
Protected
Static
_enrichProtected
Convert text of the form [[roll]] to anchor elements.
The data object providing context for inline rolls.
The existing text content.
Optional
options: EnrichmentOptions = {}Options provided to customize text enrichment.
Whether any inline rolls were replaced and the text nodes need to be updated.
Protected
Static
_finalizeProtected
Internal
A method that can be extended by subclasses to perform final post-enrichment operations on an HTML fragment. Final changes should be made in-place, mutating the provided HTML element. Note: This API is experimental and may be removed in later versions without deprecation.
A div element containing the enriched HTML
Provided enrichment options
A promise which resolves once finalization has completed
Protected
Static
_onProtected
Handle left-mouse clicks on an inline roll, dispatching the formula or displaying the tooltip
The initiating click event
Protected
Static
_parseProtected
Parse the embed configuration to be passed to ClientDocument#toEmbed. The return value will be an object of any key=value pairs included with the configuration, as well as a separate values property that contains all the options supplied that were not in key=value format. If a uuid key is supplied it is used as the Document's UUID, otherwise the first supplied UUID is used.
The raw matched config string.
Optional
options: object = {}Options forwarded to parseUuid.
TextEditor._parseEmbedConfig('uuid=Actor.xyz caption="Example Caption" cite=false');
// Returns: { uuid: "Actor.xyz", caption: "Example Caption", cite: false, values: [] }
TextEditor._parseEmbedConfig('Actor.xyz caption="Example Caption" inline');
// Returns: { uuid: "Actor.xyz", caption: "Example Caption", values: ["inline"] }
Protected
Static
_primeProtected
Scan for compendium UUIDs and retrieve Documents in batches so that they are in cache when enrichment proceeds.
The text nodes to scan.
Optional
options: EnrichmentOptions = {}Options provided to customize text enrichment
Protected
Static
_replaceProtected
Facilitate the replacement of text node content using a matching regex rule and a provided replacement function.
The text nodes to match and replace.
The provided regular expression for matching and replacement
The replacement function
Optional
options: TextReplacementOptions = {}Options to configure text replacement behavior.
Whether a replacement was made.
A collection of helper functions and utility methods related to the rich text editor.