Skip to content

@serenity-is/corelib / HtmlReportContentEditor

Class: HtmlReportContentEditor<P>

Defined in: src/ui/editors/htmlcontenteditor.tsx:552

This is originally was intended to be a subset more compatible with reports, which was necessary as most report rendering engines had limited HTML/CSS support. We will revisit this if needed in future.

Extends

Type Parameters

P

P extends HtmlContentEditorOptions = HtmlContentEditorOptions

Constructors

Constructor

new HtmlReportContentEditor<P>(props): HtmlReportContentEditor<P>

Defined in: src/ui/editors/htmlcontenteditor.tsx:555

Parameters

props

EditorProps<P>

Returns

HtmlReportContentEditor<P>

Overrides

HtmlContentEditor.constructor

Properties

domNode

readonly domNode: HTMLTextAreaElement

Defined in: src/ui/editors/htmlcontenteditor.tsx:44

The DOM node this widget is bound to.

Inherited from

HtmlContentEditor.domNode


idPrefix

readonly idPrefix: string

Defined in: src/ui/widgets/widget.ts:96

The id prefix used for this widget's child element ids.

Inherited from

HtmlContentEditor.idPrefix


options

protected readonly options: WidgetProps<EditorProps<P>>

Defined in: src/ui/widgets/widget.ts:92

The widget's options/props.

Inherited from

HtmlContentEditor.options


uniqueName

readonly uniqueName: string

Defined in: src/ui/widgets/widget.ts:94

A unique name for this widget instance, used for event namespacing.

Inherited from

HtmlContentEditor.uniqueName


[typeInfo]

static [typeInfo]: EditorTypeInfo<"Serenity.">

Defined in: src/ui/editors/htmlcontenteditor.tsx:553

Overrides

HtmlContentEditor.[typeInfo]


CKEditorBasePath

static CKEditorBasePath: string

Defined in: src/ui/editors/htmlcontenteditor.tsx:447

Base path for CKEditor assets.

Inherited from

HtmlContentEditor.CKEditorBasePath


CKEditorVer

static CKEditorVer: string = "4.22.1"

Defined in: src/ui/editors/htmlcontenteditor.tsx:445

CKEditor version to load.

Inherited from

HtmlContentEditor.CKEditorVer


defaultDeferInit

static defaultDeferInit: boolean = false

Defined in: src/ui/widgets/widget.ts:106

Whether the classes that neither have a DeferInitAttribute (see Attributes.deferInit) nor override deferredInit, nor have a base class that says true or false, defer their initialization; false by default. An application whose widgets are written for deferred initialization turns it on in its script init, before any widget is created.

Inherited from

HtmlContentEditor.defaultDeferInit


defaultEditorProvider

static defaultEditorProvider: HtmlContentEditorProvider

Defined in: src/ui/editors/htmlcontenteditor.tsx:61

Default editor provider.

Inherited from

HtmlContentEditor.defaultEditorProvider


defaultOptions

readonly static defaultOptions: Partial<HtmlContentEditorOptions> = {}

Defined in: src/ui/editors/htmlcontenteditor.tsx:64

Default options for the editor.

Inherited from

HtmlContentEditor.defaultOptions


isComponent

readonly static isComponent: true = true

Defined in: src/ui/widgets/widget.ts:530

Inherited from

HtmlContentEditor.isComponent


tiptapModule

static tiptapModule: TiptapModule | () => TiptapModule | Promise<TiptapModule>

Defined in: src/ui/editors/htmlcontenteditor.tsx:47

The Tiptap module loader.

Inherited from

HtmlContentEditor.tiptapModule

Accessors

editorProvider

Get Signature

get editorProvider(): HtmlContentEditorProvider

Defined in: src/ui/editors/htmlcontenteditor.tsx:489

Returns the active editor provider.

Returns

HtmlContentEditorProvider

The editor provider.

Inherited from

HtmlContentEditor.editorProvider


element

Get Signature

get element(): Fluent

Defined in: src/ui/widgets/widget.ts:216

Returns a Fluent(this.domNode) object

Returns

Fluent

Inherited from

HtmlContentEditor.element


initialized

Get Signature

get protected initialized(): boolean

Defined in: src/ui/widgets/widget.ts:137

Whether the widget is initialized: always for one that initializes in its constructor, and for one that defers its initialization (see isDeferredInit), once its deferredInit is done.

Returns

boolean

Inherited from

HtmlContentEditor.initialized


props

Get Signature

get props(): WidgetProps<P>

Defined in: src/ui/widgets/widget.ts:503

Returns the widget's props/options.

Returns

WidgetProps<P>

Inherited from

HtmlContentEditor.props


readOnly

Get Signature

get readOnly(): boolean

Defined in: src/ui/editors/editorwidget.ts:42

Returns whether the editor is read-only.

Returns

boolean

True when read-only.

Set Signature

set readOnly(value): void

Defined in: src/ui/editors/editorwidget.ts:48

Sets whether the editor is read-only.

Parameters
value

boolean

Returns

void

Inherited from

HtmlContentEditor.readOnly


usesDeferredInit

Get Signature

get protected usesDeferredInit(): boolean

Defined in: src/ui/widgets/widget.ts:129

Whether this widget defers its initialization, see isDeferredInit.

Returns

boolean

Inherited from

HtmlContentEditor.usesDeferredInit


value

Get Signature

get value(): string

Defined in: src/ui/editors/htmlcontenteditor.tsx:379

Returns the current HTML value.

Returns

string

The HTML value.

Set Signature

set value(v): void

Defined in: src/ui/editors/htmlcontenteditor.tsx:405

Sets the HTML value.

Parameters
v

string

Returns

void

Inherited from

HtmlContentEditor.value

Methods

addCssClass()

protected addCssClass(): void

Defined in: src/ui/widgets/widget.ts:223

Adds the widget's CSS class to its DOM node.

Returns

void

Inherited from

HtmlContentEditor.addCssClass


addValidationRule()

Call Signature

addValidationRule(rule, uniqueName?): void

Defined in: src/ui/widgets/widget.ts:267

Adds a validation rule to the widget's DOM node.

Parameters
rule

(input) => string

The validation rule function, or a unique name when the two-argument overload is used.

uniqueName?

string

A unique name for the rule, or the rule function when the two-argument overload is used.

Returns

void

Inherited from

HtmlContentEditor.addValidationRule

Call Signature

addValidationRule(uniqueName, rule): void

Defined in: src/ui/widgets/widget.ts:268

Adds a validation rule to the widget's DOM node.

Parameters
uniqueName

string

A unique name for the rule, or the rule function when the two-argument overload is used.

rule

(input) => string

The validation rule function, or a unique name when the two-argument overload is used.

Returns

void

Inherited from

HtmlContentEditor.addValidationRule


afterRender()

protected afterRender(callback): void

Defined in: src/ui/widgets/widget.ts:359

Queues a callback to run after the widget's contents are rendered.

Parameters

callback

() => void

The callback to run after rendering.

Returns

void

Inherited from

HtmlContentEditor.afterRender


byId()

protected byId<TElement>(id): Fluent<TElement>

Defined in: src/ui/widgets/widget.ts:279

Finds a child element by its prefix-relative id.

Type Parameters

TElement

TElement extends HTMLElement = HTMLElement

Parameters

id

string

The id relative to the widget's id prefix.

Returns

Fluent<TElement>

A Fluent wrapper for the matching element.

Inherited from

HtmlContentEditor.byId


change()

change(handler): void

Defined in: src/ui/widgets/widget.ts:310

Registers a change handler on the widget's DOM node.

Parameters

handler

(e) => void

The change event handler.

Returns

void

Inherited from

HtmlContentEditor.change


changeSelect2()

changeSelect2(handler): void

Defined in: src/ui/widgets/widget.ts:319

Registers a change handler that ignores changes originating from combobox setting values.

Parameters

handler

(e) => void

The change event handler.

Returns

void

Inherited from

HtmlContentEditor.changeSelect2


configureTiptapExtension()

protected configureTiptapExtension(extension): any

Defined in: src/ui/editors/htmlcontenteditor.tsx:581

Configures a Tiptap extension.

Parameters

extension

any

The extension to configure.

Returns

any

The configured extension.

Overrides

HtmlContentEditor.configureTiptapExtension


createTiptapToolbar()

protected createTiptapToolbar(editor, hidden): HTMLElement

Defined in: src/ui/editors/htmlcontenteditor.tsx:329

Creates the Tiptap toolbar.

Parameters

editor

any

The Tiptap editor.

hidden

TiptapToolbarHiddenOption

Hidden toolbar options.

Returns

HTMLElement

The toolbar element.

Inherited from

HtmlContentEditor.createTiptapToolbar


deferredInit()

protected deferredInit(): void | PromiseLike<void>

Defined in: src/ui/widgets/widget.ts:440

Does the initialization of a widget that defers it (see isDeferredInit), once, when init or initAsync is called after all its constructors are done. The base classes initialize what their constructors would, e.g. the contents, the form or the columns, and a subclass does the work its constructor would do after await super.deferredInit(), which may wait too. The part before its first await runs at once, so a widget that is made and inited has its contents.

Returns

void | PromiseLike<void>

Inherited from

HtmlContentEditor.deferredInit


destroy()

destroy(): void

Defined in: src/ui/editors/htmlcontenteditor.tsx:346

Cleans up the editor instance.

Returns

void

Inherited from

HtmlContentEditor.destroy


findById()

protected findById<TElement>(id): TElement

Defined in: src/ui/widgets/widget.ts:291

Finds a child element by its prefix-relative id.

Type Parameters

TElement

TElement extends HTMLElement = HTMLElement

Parameters

id

string

The id relative to the widget's id prefix.

Returns

TElement

The matching element, or null if not found.

Inherited from

HtmlContentEditor.findById


get_readOnly()

get_readOnly(): boolean

Defined in: src/ui/editors/htmlcontenteditor.tsx:413

Returns whether the editor is read-only.

Returns

boolean

True when read-only.

Inherited from

HtmlContentEditor.get_readOnly


get_value()

get_value(): string

Defined in: src/ui/editors/htmlcontenteditor.tsx:362

Returns the current HTML value.

Returns

string

The HTML value.

Inherited from

HtmlContentEditor.get_value


getCKEditorConfig()

protected getCKEditorConfig(): CKEditorConfig

Defined in: src/ui/editors/htmlcontenteditor.tsx:562

Returns the CKEditor configuration.

Returns

CKEditorConfig

The CKEditor config.

Overrides

HtmlContentEditor.getCKEditorConfig


getCKEditorInstance()

protected getCKEditorInstance(): any

Defined in: src/ui/editors/htmlcontenteditor.tsx:287

Returns the CKEditor instance for this editor.

Returns

any

The CKEditor instance.

Inherited from

HtmlContentEditor.getCKEditorInstance


getCKEditorLanguage()

protected getCKEditorLanguage(): string

Defined in: src/ui/editors/htmlcontenteditor.tsx:203

Returns the CKEditor language code.

Returns

string

The language code.

Inherited from

HtmlContentEditor.getCKEditorLanguage


getConfig()

protected getConfig(): CKEditorConfig

Defined in: src/ui/editors/htmlcontenteditor.tsx:225

[DEPRECATED] Override and use getCKEditorConfig()

Returns

CKEditorConfig

Inherited from

HtmlContentEditor.getConfig


getCssClass()

protected getCssClass(): string

Defined in: src/ui/widgets/widget.ts:231

Returns the CSS class(es) applied to the widget's DOM node.

Returns

string

The space-separated CSS class string.

Inherited from

HtmlContentEditor.getCssClass


getCustomAttribute()

protected getCustomAttribute<TAttr>(attrType, inherit): TAttr

Defined in: src/ui/widgets/widget.ts:351

Returns a custom attribute applied to the widget's type.

Type Parameters

TAttr

TAttr extends CustomAttribute

Parameters

attrType

(...args) => TAttr

The attribute type to look up.

inherit

boolean = true

Whether to search inherited types; defaults to true.

Returns

TAttr

The matching attribute, or null.

Inherited from

HtmlContentEditor.getCustomAttribute


getGridField()

getGridField(): Fluent

Defined in: src/ui/widgets/widget.ts:302

Returns the closest .field element containing the widget's DOM node.

Returns

Fluent

A Fluent wrapper for the grid field.

Inherited from

HtmlContentEditor.getGridField


getTiptapExtensions()

protected getTiptapExtensions(tiptap): any[]

Defined in: src/ui/editors/htmlcontenteditor.tsx:319

Returns the Tiptap extensions for this editor.

Parameters

tiptap

TiptapModule

The Tiptap module.

Returns

any[]

The extensions.

Inherited from

HtmlContentEditor.getTiptapExtensions


getTiptapToolbarHidden()

protected getTiptapToolbarHidden(editor): TiptapToolbarHiddenOption

Defined in: src/ui/editors/htmlcontenteditor.tsx:575

Returns the hidden Tiptap toolbar options.

Parameters

editor

any

The Tiptap editor.

Returns

TiptapToolbarHiddenOption

The hidden options.

Overrides

HtmlContentEditor.getTiptapToolbarHidden


handleCKEditorChange()

protected handleCKEditorChange(e): void

Defined in: src/ui/editors/htmlcontenteditor.tsx:177

Handles the CKEditor change event.

Parameters

e

any

The CKEditor event.

Returns

void

Inherited from

HtmlContentEditor.handleCKEditorChange


handleCKInstanceReady()

protected handleCKInstanceReady(x): void

Defined in: src/ui/editors/htmlcontenteditor.tsx:160

Handles the CKEditor instance-ready event.

Parameters

x

any

The CKEditor event.

Returns

void

Inherited from

HtmlContentEditor.handleCKInstanceReady


handleCKKey()

protected handleCKKey(e): void

Defined in: src/ui/editors/htmlcontenteditor.tsx:195

Handles the CKEditor key event.

Parameters

e

any

The CKEditor event.

Returns

void

Inherited from

HtmlContentEditor.handleCKKey


init()

init(): this

Defined in: src/ui/widgets/widget.ts:375

Initializes the widget: one that defers its initialization (see isDeferredInit) starts it, and it may end later, see initAsync; others are initialized by their constructors already.

Returns

this

This widget instance.

Inherited from

HtmlContentEditor.init


initAsync()

initAsync(): Promise<HtmlReportContentEditor<P>>

Defined in: src/ui/widgets/widget.ts:388

Initializes the widget once and waits until it is initialized: one that defers its initialization (see isDeferredInit) runs its deferredInit, the first time it is called; others are initialized by their constructors.

Returns

Promise<HtmlReportContentEditor<P>>

A promise of this widget, which is rejected when its initialization fails.

Inherited from

HtmlContentEditor.initAsync


initNow()

protected initNow(): boolean

Defined in: src/ui/widgets/widget.ts:146

Starts the initialization of a widget that defers it, if it hasn't started, and tells whether it is initialized now, e.g. as it had nothing to wait for. A method that needs the widget initialized waits for initAsync when it is not, e.g. if (!this.initNow()) return void this.initAsync().then(...).

Returns

boolean

Inherited from

HtmlContentEditor.initNow


internalRenderContents()

internalRenderContents(): void

Defined in: src/ui/widgets/widget.ts:462

Renders the widget's contents and runs any queued after-render callbacks.

Returns

void

Inherited from

HtmlContentEditor.internalRenderContents


legacyTemplateRender()

protected legacyTemplateRender(): boolean

Defined in: src/ui/widgets/widget.ts:487

Renders the widget from a legacy getTemplate string, if defined.

Returns

boolean

True if a legacy template was rendered.

Inherited from

HtmlContentEditor.legacyTemplateRender


render()

render(): any

Defined in: src/ui/widgets/widget.ts:449

Returns the main element for this widget or the document fragment. As widgets may get their elements from props unlike regular JSX widgets, this method should not be overridden. Override renderContents() instead.

Returns

any

Inherited from

HtmlContentEditor.render


renderContents()

protected renderContents(): any

Defined in: src/ui/widgets/widget.ts:477

Renders the widget's contents. Override this to provide custom content.

Returns

any

The rendered contents.

Inherited from

HtmlContentEditor.renderContents


set_readOnly()

set_readOnly(value): void

Defined in: src/ui/editors/htmlcontenteditor.tsx:421

Sets whether the editor is read-only.

Parameters

value

boolean

True to enable read-only mode.

Returns

void

Inherited from

HtmlContentEditor.set_readOnly


set_value()

set_value(value): void

Defined in: src/ui/editors/htmlcontenteditor.tsx:387

Sets the HTML value.

Parameters

value

string

The HTML value to set.

Returns

void

Inherited from

HtmlContentEditor.set_value


syncOrAsyncThen()

protected syncOrAsyncThen<T>(syncMethod, asyncMethod, then): void

Defined in: src/ui/widgets/widget.ts:514

Runs a method synchronously or asynchronously depending on the widget's useAsync flag, then invokes a continuation.

Type Parameters

T

T

Parameters

syncMethod

() => T

The synchronous method to run.

asyncMethod

() => PromiseLike<T>

The asynchronous method to run.

then

(v) => void

The continuation invoked with the result.

Returns

void

Inherited from

HtmlContentEditor.syncOrAsyncThen


useIdPrefix()

protected useIdPrefix(): IdPrefixType

Defined in: src/ui/widgets/widget.ts:525

Returns an id prefix helper for resolving child element ids.

Returns

IdPrefixType

An IdPrefixType proxy for this widget's id prefix.

Inherited from

HtmlContentEditor.useIdPrefix


create()

static create<TWidget, P>(params): TWidget

Defined in: src/ui/widgets/widget.ts:333

Creates a widget instance from the given params, appending its element to the container and invoking the init/init callbacks.

Type Parameters

TWidget

TWidget extends Widget<P>

P

P

Parameters

params

CreateWidgetParams<TWidget, P>

The widget creation params.

Returns

TWidget

The created widget instance.

Inherited from

HtmlContentEditor.create


createDefaultElement()

static createDefaultElement(): HTMLTextAreaElement

Defined in: src/ui/editors/htmlcontenteditor.tsx:58

Creates the default DOM element for a widget.

Returns

HTMLTextAreaElement

A new div element.

Inherited from

HtmlContentEditor.createDefaultElement


getCKEditorBasePath()

static getCKEditorBasePath(): string

Defined in: src/ui/editors/htmlcontenteditor.tsx:453

Returns the base path for CKEditor assets.

Returns

string

The base path.

Inherited from

HtmlContentEditor.getCKEditorBasePath


getWidgetName()

static getWidgetName(type): string

Defined in: src/ui/widgets/widget.ts:256

Returns the widget name for a type, used for association and unique names.

Parameters

type

Function

The widget type.

Returns

string

The widget name.

Inherited from

HtmlContentEditor.getWidgetName


includeCKEditor()

static includeCKEditor(then): void

Defined in: src/ui/editors/htmlcontenteditor.tsx:470

Includes the CKEditor script and invokes the callback when loaded.

Parameters

then

() => void

Callback invoked when CKEditor is available.

Returns

void

Inherited from

HtmlContentEditor.includeCKEditor


isDeferredInit()

static isDeferredInit(type, requested?): boolean

Defined in: src/ui/widgets/widget.ts:118

Gets whether a widget of a type defers its initialization to deferredInit, which init or initAsync runs once all the constructors are done, and which may wait. It is as the DeferInitAttribute (see Attributes.deferInit) of the type or a base class says, true for a class that overrides deferredInit, else as defaultDeferInit says. It throws when the type and its base classes say conflicting things, e.g. a class has false but overrides deferredInit.

Parameters

type

Function

The widget type.

requested?

boolean

Whether the creator of the widget asks for it, see WidgetProps.deferInit, which counts only for a class whose own attribute says "optional".

Returns

boolean

Inherited from

HtmlContentEditor.isDeferredInit


registerClass()

protected static registerClass<TypeName>(typeName, intfAndAttr?): ClassTypeInfo<TypeName>

Defined in: src/ui/widgets/widget.ts:538

Registers this type as a class with the given type name.

Type Parameters

TypeName

TypeName

Parameters

typeName

StringLiteral<TypeName>

The type name to register.

intfAndAttr?

(InterfaceType | AttributeSpecifier)[]

Optional interfaces and attributes.

Returns

ClassTypeInfo<TypeName>

The class type info.

Inherited from

HtmlContentEditor.registerClass


registerEditor()

protected static registerEditor<TypeName>(typeName, intfAndAttr?): EditorTypeInfo<TypeName>

Defined in: src/ui/widgets/widget.ts:553

Registers this type as an editor with the given type name.

Type Parameters

TypeName

TypeName

Parameters

typeName

StringLiteral<TypeName>

The type name to register.

intfAndAttr?

(InterfaceType | AttributeSpecifier)[]

Optional interfaces and attributes.

Returns

EditorTypeInfo<TypeName>

The editor type info.

Inherited from

HtmlContentEditor.registerEditor