Back to Trilium

Class defaultAbstract

docs/Script API/classes/Frontend_Script_API._internal_.default-5.html

0.102.216.6 KB
Original Source

Class defaultAbstract

The base class for all the note types.

Hierarchy (View Summary)

Index

Constructors

constructor

Properties

_noteId_position$widgetattrschildrencomponentIdinitializednoteContext?parent?spacedUpdate

Accessors

hoistedNoteIdnotenoteIdnotePathntxIdpositionsanitizedClassName

Methods

activeContextChangedactiveContextChangedEventcallMethodcanBeShownchildclasscleanupcollapsiblecontentSizedcsscssBlockdataSaveddoRefreshdoRenderfillingfocusfrocaReloadedEventgetClosestNtxIdgetDatagetPositionhandleEventhandleEventInChildrenidisActiveisActiveNoteContextisEnabledisHiddenExtisHiddenIntisNoteisNoteContextisVisiblelogRenderingErrornoteSwitchednoteSwitchedAndActivatedEventnoteSwitchedEventnoteTypeMimeChangedEventoptChildoptCssreadOnlyTemporarilyDisabledEventrefreshrefreshWithNoteremoverenderscrollToEndsetNoteContextEventsetParenttoggleExttoggleInttriggerCommandtriggerEventgetType

Constructors

constructor

new default(): default

Returns default

Properties

_noteId

_noteId: string

_position

_position: number

$widget

$widget: JQuery<HTMLElement>

Protectedattrs

attrs: Record<string, string>

children

children: default[]

componentId

componentId: string

initialized

initialized: null | Promise<void>

OptionalnoteContext

noteContext?: NoteContext

Optionalparent

parent?: TypedComponent<any>

spacedUpdate

spacedUpdate: default

Accessors

hoistedNoteId

get hoistedNoteId(): undefined | string

Returns undefined | string

note

get note(): undefined | null | FNote

Returns undefined | null | FNote

noteId

get noteId(): undefined | string

Returns undefined | string

notePath

get notePath(): undefined | null | string

Returns undefined | null | string

ntxId

get ntxId(): undefined | null | string

Returns undefined | null | string

position

get position(): number

Returns number

set position(newPosition: number): void

Parameters

  • newPosition: number

Returns void

sanitizedClassName

get sanitizedClassName(): string

Returns string

Methods

activeContextChanged

activeContextChanged(): Promise<void>

Returns Promise<void>

activeContextChangedEvent

activeContextChangedEvent(
__namedParameters: { noteContext: NoteContext },
): Promise<void>

Parameters

Returns Promise<void>

callMethod

callMethod(
fun: (arg: unknown) => Promise<unknown>,
data: unknown,
): undefined | Promise<unknown>

Parameters

  • fun: (arg: unknown) => Promise<unknown>
  • data: unknown

Returns undefined | Promise<unknown>

canBeShown

canBeShown(): boolean

Returns boolean

child

child(...components: default[]): default

Parameters

Returns default

class

class(className: string): default

Parameters

  • className: string

Returns default

cleanup

cleanup(): void

Returns void

collapsible

collapsible(): default

Returns default

contentSized

contentSized(): default

Returns default

css

css(name: string, value: string): default

Sets the CSS attribute of the given name to the given value.

Parameters

  • name: string

the name of the CSS attribute to set (e.g. padding-left).

  • value: string

the value of the CSS attribute to set (e.g. 12px).

Returns default

self for chaining.

cssBlock

cssBlock(block: string): default

Accepts a string of CSS to add with the widget.

Parameters

  • block: string

Returns default

for chaining

dataSaved

dataSaved(): void

Returns void

doRefresh

doRefresh(note: FNote): void | Promise<void>

Parameters

Returns void | Promise<void>

doRender

doRender(): void

Method used for rendering the widget.

Your class should override this method. The method is expected to create a this.$widget containing jQuery object

Returns void

filling

filling(): default

Returns default

focus

focus(): void

Returns void

frocaReloadedEvent

frocaReloadedEvent(): Promise<void>

Returns Promise<void>

getClosestNtxId

getClosestNtxId(): undefined | null | string

Returns undefined | null | string

getData

getData(): void

Returns void

promise resolving note data. Note data is an object with content.

getPosition

getPosition(): number

Returns number

handleEvent

handleEvent<T extends EventNames>(
name: T,
data: EventData<T>,
): undefined | null | Promise<unknown>

Type Parameters

Parameters

Returns undefined | null | Promise<unknown>

handleEventInChildren

handleEventInChildren<T extends EventNames>(
name: T,
data: EventData<T>,
): null | Promise<unknown>

By default:

  • activeContextChanged is intercepted and converted to a setNoteContext event to avoid refresh().
  • entitiesReloaded and refreshData are passed as-is.
  • any other event is not passed to the children.

Type Parameters

Parameters

Returns null | Promise<unknown>

id

id(id: string): default

Parameters

  • id: string

Returns default

isActive

isActive(): boolean

Returns boolean

isActiveNoteContext

isActiveNoteContext(): boolean

Returns boolean

isEnabled

isEnabled(): undefined | null | boolean

Indicates if the widget is enabled. Widgets are enabled by default. Generally setting this to false will cause the widget not to be displayed, however it will still be available on the DOM but hidden.

If the widget is not enabled, it will not receive refreshWithNote updates.

Returns undefined | null | boolean

true when an active note exists

isHiddenExt

isHiddenExt(): boolean

Returns boolean

isHiddenInt

isHiddenInt(): boolean

Returns boolean

isNote

isNote(noteId: string): boolean

Parameters

  • noteId: string

Returns boolean

isNoteContext

isNoteContext(
ntxId: undefined | null | string | string[],
): undefined | null | boolean | ""

Parameters

  • ntxId: undefined | null | string | string[]

Returns undefined | null | boolean | ""

isVisible

isVisible(): boolean

Returns boolean

logRenderingError

logRenderingError(e: Error): void

Parameters

  • e: Error

Returns void

noteSwitched

noteSwitched(): Promise<void>

Returns Promise<void>

noteSwitchedAndActivatedEvent

noteSwitchedAndActivatedEvent(
__namedParameters: NoteSwitchedContext,
): Promise<void>

Parameters

Returns Promise<void>

noteSwitchedEvent

noteSwitchedEvent(__namedParameters: NoteSwitchedContext): Promise<void>

Parameters

Returns Promise<void>

noteTypeMimeChangedEvent

noteTypeMimeChangedEvent(__namedParameters: { noteId: string }): Promise<void>

Parameters

  • __namedParameters: { noteId: string }

Returns Promise<void>

optChild

optChild(condition: boolean, ...components: default[]): default

Conditionally adds the given components as children to this component.

Parameters

  • condition: boolean

whether to add the components.

the components to be added as children to this component provided the condition is truthy.

Returns default

self for chaining.

optCss

optCss(condition: boolean, name: string, value: string): default

Sets the CSS attribute of the given name to the given value, but only if the condition provided is truthy.

Parameters

  • condition: boolean

true in order to apply the CSS, false to ignore it.

  • name: string

the name of the CSS attribute to set (e.g. padding-left).

  • value: string

the value of the CSS attribute to set (e.g. 12px).

Returns default

self for chaining.

readOnlyTemporarilyDisabledEvent

readOnlyTemporarilyDisabledEvent(
__namedParameters: { noteContext: NoteContext },
): Promise<void>

Parameters

Returns Promise<void>

refresh

refresh(): Promise<void>

Returns Promise<void>

refreshWithNote

refreshWithNote(note: undefined | null | FNote): Promise<void>

Override this method to be able to refresh your widget with each note.

Parameters

  • note: undefined | null | FNote

Returns Promise<void>

remove

remove(): void

Returns void

render

render(): JQuery<HTMLElement>

Returns JQuery<HTMLElement>

scrollToEnd

scrollToEnd(): void

Returns void

setNoteContextEvent

setNoteContextEvent(__namedParameters: { noteContext: NoteContext }): void

Parameters

Returns void

setParent

setParent(parent: TypedComponent<any>): default

Parameters

Returns default

toggleExt

toggleExt(show: undefined | null | boolean | ""): void

Parameters

  • show: undefined | null | boolean | ""

Returns void

toggleInt

toggleInt(show: undefined | null | boolean): void

Parameters

  • show: undefined | null | boolean

Returns void

triggerCommand

triggerCommand<K extends keyof CommandMappings>(
name: K,
data?: CommandMappings[K],
): undefined | null | Promise<unknown>

Type Parameters

Parameters

Returns undefined | null | Promise<unknown>

triggerEvent

triggerEvent<T extends EventNames>(
name: T,
data: EventData<T>,
): undefined | null | Promise<unknown>

Type Parameters

Parameters

Returns undefined | null | Promise<unknown>

StaticgetType

getType(): void

Returns void

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Constructors constructor Properties _noteId_position$widgetattrschildrencomponentIdinitializednoteContextparentspacedUpdate Accessors hoistedNoteIdnotenoteIdnotePathntxIdpositionsanitizedClassName Methods activeContextChangedactiveContextChangedEventcallMethodcanBeShownchildclasscleanupcollapsiblecontentSizedcsscssBlockdataSaveddoRefreshdoRenderfillingfocusfrocaReloadedEventgetClosestNtxIdgetDatagetPositionhandleEventhandleEventInChildrenidisActiveisActiveNoteContextisEnabledisHiddenExtisHiddenIntisNoteisNoteContextisVisiblelogRenderingErrornoteSwitchednoteSwitchedAndActivatedEventnoteSwitchedEventnoteTypeMimeChangedEventoptChildoptCssreadOnlyTemporarilyDisabledEventrefreshrefreshWithNoteremoverenderscrollToEndsetNoteContextEventsetParenttoggleExttoggleInttriggerCommandtriggerEventgetType