StaticimplementationRetrieve the configured TextEditor implementation.
Static_uploadInternalUpload an image to a document's asset path.
The document's UUID.
The image file to upload.
The path to the uploaded image.
StaticactivateActivate interaction listeners for the interior content of the editor frame.
StaticcreateCreate a Rich Text Editor. The current implementation uses TinyMCE
Configuration options provided to the Editor init
Optionalengine?: 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.
StaticcreateHelper method to create an anchor element.
Optionaloptions: Partial<EnrichmentAnchorOptions> = {}Options to configure the anchor's construction.
StaticdecodeHTMLSafely decode an HTML string, removing invalid tags and converting entities back to unicode characters.
The original encoded HTML string
The decoded unicode string
StaticenrichHTMLEnrich HTML content by replacing or augmenting components of it
The original HTML content (as a string)
Optionaloptions: EnrichmentOptions = {}Additional options which configure how HTML is enriched
The enriched HTML content
StaticgetGiven 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
Optionaloptions: { label?: string; relativeTo?: any } = {}Additional options to configure link creation.
Optionallabel?: stringA custom label to use instead of the document's name.
OptionalrelativeTo?: anyA document to generate the link relative to.
StaticgetExtract 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.
StaticpreviewHTMLPreview 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
StatictruncateHTMLSanitises an HTML fragment and removes any non-paragraph-style text.
The root HTML element.
StatictruncateTruncate a fragment of text to a maximum number of characters.
The original text fragment that should be truncated to a maximum length
Optionaloptions: { maxLength?: number; splitWords?: boolean; suffix?: null | string } = {}Options which affect the behavior of text truncation
OptionalmaxLength?: numberThe maximum allowed length of the truncated string.
OptionalsplitWords?: booleanWhether to truncate by splitting on white space (if true) or breaking words.
Optionalsuffix?: null | stringA suffix string to append to denote that the text was truncated.
The truncated text string
Protected Static_applyProtectedMatch any custom registered regex patterns and apply their replacements.
The custom enricher configuration.
The existing text content.
Optionaloptions: EnrichmentOptionsOptions provided to customize text enrichment
Whether any replacements were made, requiring the text nodes to be updated.
Protected Static_createProtectedCreate a dynamic document link from a regular expression match
The regular expression match
Optionaloptions: EnrichmentOptions = {}Additional options to configure enrichment behaviour
Optionalcustom?: booleanApply custom enrichers?
Optionaldocuments?: booleanReplace dynamic document links?
Optionalembeds?: booleanReplace embedded content?
Optionallinks?: booleanReplace hyperlink content?
OptionalrelativeTo?: anyA document to resolve relative UUIDs against.
OptionalrollData?: object | FunctionThe data object providing context for inline rolls, or a function that produces it.
Optionalrolls?: booleanReplace inline dice rolls?
Optionalsecrets?: 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_createProtectedReplace a hyperlink-like string with an actual HTML <a> tag
The regular expression match
Optionaloptions: EnrichmentOptions = {}Options provided to customize text enrichment
An HTML element for the document link
Protected Static_createProtectedReplace 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
Optionaloptions: EnrichmentOptions = {}Options provided to customize text enrichment.
The replaced match. Returns null if the contained command is not a valid roll expression.
Protected Static_createProtectedCreate a TinyMCE editor instance.
Optionaloptions: object = {}Configuration options passed to the editor.
Optionalcontent: string = ""Initial HTML or text content to populate the editor with.
The TinyMCE editor instance.
Protected Static_embedProtectedEmbed content from another Document.
The regular expression match.
Optionaloptions: 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_enrichProtectedConvert text of the form @UUID[uuid]{name} to anchor elements.
The existing text content
Optionaloptions: EnrichmentOptions = {}Options provided to customize text enrichment
Optionalcustom?: booleanApply custom enrichers?
Optionaldocuments?: booleanReplace dynamic document links?
Optionalembeds?: booleanReplace embedded content?
Optionallinks?: booleanReplace hyperlink content?
OptionalrelativeTo?: anyA document to resolve relative UUIDs against.
OptionalrollData?: object | FunctionThe data object providing context for inline rolls, or a function that produces it.
Optionalrolls?: booleanReplace inline dice rolls?
Optionalsecrets?: 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_enrichProtectedHandle embedding Document content with @Embed[uuid]{label} text.
The existing text content.
Optionaloptions: EnrichmentOptions = {}Options provided to customize text enrichment.
Whether any embeds were replaced and the text nodes need to be updated.
Protected Static_enrichProtectedConvert URLs into anchor elements.
The existing text content
Optionaloptions: EnrichmentOptions = {}Options provided to customize text enrichment
Whether any hyperlinks were replaced and the text nodes need to be updated
Protected Static_enrichProtectedConvert text of the form [[roll]] to anchor elements.
The data object providing context for inline rolls.
The existing text content.
Optionaloptions: EnrichmentOptions = {}Options provided to customize text enrichment.
Whether any inline rolls were replaced and the text nodes need to be updated.
Protected Static_finalizeProtected InternalA 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_onProtectedHandle left-mouse clicks on an inline roll, dispatching the formula or displaying the tooltip
The initiating click event
Protected Static_parseProtectedParse 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.
Optionaloptions: 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_primeProtectedScan for compendium UUIDs and retrieve Documents in batches so that they are in cache when enrichment proceeds.
The text nodes to scan.
Optionaloptions: EnrichmentOptions = {}Options provided to customize text enrichment
Protected Static_replaceProtectedFacilitate 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
Optionaloptions: 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.