Back to Trilium

Class default<SettingsT>

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

0.102.218.0 KB
Original Source

Class default<SettingsT>

This widget allows for changing and updating depending on the active note.

Type Parameters

  • SettingsT extends AbstractButtonWidgetSettings

Hierarchy (View Summary)

Index

Constructors

constructor

Properties

_noteId_position$widgetattrschildrencomponentIdinitializednoteContext?parent?settingstooltip

Accessors

hoistedNoteIdnotenoteIdnotePathntxIdpositionsanitizedClassName

Methods

activeContextChangedactiveContextChangedEventcallMethodcanBeShownchildclasscleanupcollapsiblecontentSizedcsscssBlockdoRenderfillingfrocaReloadedEventgetClosestNtxIdgetPositiongetTitlehandleEventhandleEventInChildreniconidinitialRenderCompleteEventisActiveNoteContextisEnabledisHiddenExtisHiddenIntisNoteisNoteContextisVisiblelogRenderingErrornoteSwitchednoteSwitchedAndActivatedEventnoteSwitchedEventnoteTypeMimeChangedEventonContextMenuoptChildoptCssrefreshrefreshIconrefreshWithNoteremoverendersetNoteContextEventsetParenttitletitlePlacementtoggleExttoggleInttriggerCommandtriggerEvent

Constructors

constructor

new default<SettingsT extends AbstractButtonWidgetSettings>(): default<
SettingsT,
>

Type Parameters

  • SettingsT extends AbstractButtonWidgetSettings

Returns default<SettingsT>

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>

Protectedsettings

settings: SettingsT

Protectedtooltip

tooltip: Tooltip

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<SettingsT>

Parameters

Returns default<SettingsT>

class

class(className: string): default<SettingsT>

Parameters

  • className: string

Returns default<SettingsT>

cleanup

cleanup(): void

Returns void

collapsible

collapsible(): default<SettingsT>

Returns default<SettingsT>

contentSized

contentSized(): default<SettingsT>

Returns default<SettingsT>

css

css(name: string, value: string): default<SettingsT>

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<SettingsT>

self for chaining.

cssBlock

cssBlock(block: string): default<SettingsT>

Accepts a string of CSS to add with the widget.

Parameters

  • block: string

Returns default<SettingsT>

for chaining

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<SettingsT>

Returns default<SettingsT>

frocaReloadedEvent

frocaReloadedEvent(): Promise<void>

Returns Promise<void>

getClosestNtxId

getClosestNtxId(): undefined | null | string

Returns undefined | null | string

getPosition

getPosition(): number

Returns number

getTitle

getTitle(): null | string

Returns null | string

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>

Type Parameters

Parameters

Returns null | Promise<unknown>

icon

icon(icon: StringOrCallback): default<SettingsT>

Parameters

  • icon: StringOrCallback

Returns default<SettingsT>

id

id(id: string): default<SettingsT>

Parameters

  • id: string

Returns default<SettingsT>

initialRenderCompleteEvent

initialRenderCompleteEvent(): void

Returns void

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>

onContextMenu

onContextMenu(handler: ContextMenuHandler): default<SettingsT>

Parameters

  • handler: ContextMenuHandler

Returns default<SettingsT>

optChild

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

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<SettingsT>

self for chaining.

optCss

optCss(condition: boolean, name: string, value: string): default<SettingsT>

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<SettingsT>

self for chaining.

refresh

refresh(): Promise<void>

Returns Promise<void>

refreshIcon

refreshIcon(): void

Returns 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>

setNoteContextEvent

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

Parameters

Returns void

setParent

setParent(parent: TypedComponent<any>): default<SettingsT>

Parameters

Returns default<SettingsT>

title

title(title: StringOrCallback): default<SettingsT>

Parameters

  • title: StringOrCallback

Returns default<SettingsT>

titlePlacement

titlePlacement(placement: TitlePlacement): default<SettingsT>

Parameters

  • placement: TitlePlacement

Returns default<SettingsT>

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>

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Constructors constructor Properties _noteId_position$widgetattrschildrencomponentIdinitializednoteContextparentsettingstooltip Accessors hoistedNoteIdnotenoteIdnotePathntxIdpositionsanitizedClassName Methods activeContextChangedactiveContextChangedEventcallMethodcanBeShownchildclasscleanupcollapsiblecontentSizedcsscssBlockdoRenderfillingfrocaReloadedEventgetClosestNtxIdgetPositiongetTitlehandleEventhandleEventInChildreniconidinitialRenderCompleteEventisActiveNoteContextisEnabledisHiddenExtisHiddenIntisNoteisNoteContextisVisiblelogRenderingErrornoteSwitchednoteSwitchedAndActivatedEventnoteSwitchedEventnoteTypeMimeChangedEventonContextMenuoptChildoptCssrefreshrefreshIconrefreshWithNoteremoverendersetNoteContextEventsetParenttitletitlePlacementtoggleExttoggleInttriggerCommandtriggerEvent