Back to Trilium

Class FNote

docs/Script API/classes/Frontend_Script_API.FNote.html

0.102.224.8 KB
Original Source

Class FNote

Note is the main node and concept in Trilium.

Index

Constructors

constructor

Properties

attachmentsattributesblobIdchildrenchildToBranchhighlightedTokens?isProtectedmimenoteIdparentsparentToBranchsearchResultsLoaded?targetRelationstitletype

Accessors

dtoisArchived

Methods

__getInheritableAttributes__validateTypeNameaddChildaddParentexecuteScriptgetAllNotePathsgetAttachmentByIdgetAttachmentsgetAttachmentsByRolegetAttributegetAttributesgetAttributeValuegetBestNotePathgetBestNotePathStringgetBlobgetBranchesgetBranchIdsgetChildBranchesgetChildNoteIdsgetChildNotesgetColorClassgetContentgetCssClassgetFilteredChildBranchesgetIcongetJsonContentgetLabelgetLabelsgetLabelValuegetMetadatagetNoteComplementgetNotesToInheritAttributesFromgetOwnedAttributegetOwnedAttributesgetOwnedAttributeValuegetOwnedLabelgetOwnedLabelsgetOwnedLabelValuegetOwnedRelationgetOwnedRelationsgetOwnedRelationValuegetParentBranchesgetParentBranchIdsgetParentNoteIdsgetParentNotesgetPromotedDefinitionAttributesgetRelationgetRelationsgetRelationTargetgetRelationTargetsgetRelationValuegetScriptEnvgetSortedNotePathRecordsgetTargetRelationsgetTargetRelationSourceNotesgetWorkspaceIconClassgetWorkspaceTabBackgroundColorhasAncestorhasAttributehasChildrenhasLabelhasOwnedAttributehasOwnedLabelhasOwnedRelationhasRelationinvalidateAttributeCacheisContentAvailableisEligibleForConversionToAttachmentisFolderisHiddenCompletelyisHtmlisInHiddenSubtreeisJavaScriptisJsonisLabelTruthyisLaunchBarConfigisOptionsisRootisSharedsortChildrensortParentstoStringupdate

Constructors

constructor

new FNote(froca: Froca, row: FNoteRow): FNote

Parameters

Returns FNote

Properties

attachments

attachments: null | FAttachment[]

attributes

attributes: string[]

blobId

blobId: string

children

children: string[]

childToBranch

childToBranch: Record<string, string>

OptionalhighlightedTokens

highlightedTokens?: string[]

isProtected

isProtected: boolean

mime

mime: string

content-type, e.g. "application/json"

noteId

noteId: string

parents

parents: string[]

parentToBranch

parentToBranch: Record<string, string>

OptionalsearchResultsLoaded

searchResultsLoaded?: boolean

targetRelations

targetRelations: string[]

title

title: string

type

type: NoteType

Accessors

dto

get dto(): Omit<FNote, "froca">

Returns Omit<FNote, "froca">

isArchived

get isArchived(): boolean

Returns boolean

Methods

__getInheritableAttributes

__getInheritableAttributes(path: string[]): FAttribute[]

Parameters

  • path: string[]

Returns FAttribute[]

__validateTypeName

__validateTypeName(type?: string, name?: string): void

Parameters

  • Optionaltype: string
  • Optionalname: string

Returns void

addChild

addChild(childNoteId: string, branchId: string, sort?: boolean): void

Parameters

  • childNoteId: string
  • branchId: string
  • sort: boolean = true

Returns void

addParent

addParent(parentNoteId: string, branchId: string, sort?: boolean): void

Parameters

  • parentNoteId: string
  • branchId: string
  • sort: boolean = true

Returns void

executeScript

executeScript(): Promise<any>

Executes this FNote as a front-end or back-end script.

Returns Promise<any>

a promise that resolves when the script has been run. Additionally, for front-end notes, the promise will contain the value that is returned by the script.

Throws

an Error if the note has an incorrect note type or MIME for execution.

getAllNotePaths

getAllNotePaths(): string[][]

Gives all possible note paths leading to this note. Paths containing search note are ignored (could form cycles)

Returns string[][]

array of notePaths (each represented by array of noteIds constituting the particular note path)

getAttachmentById

getAttachmentById(attachmentId: string): Promise<undefined | FAttachment>

Parameters

  • attachmentId: string

Returns Promise<undefined | FAttachment>

getAttachments

getAttachments(): Promise<FAttachment[]>

Returns Promise<FAttachment[]>

getAttachmentsByRole

getAttachmentsByRole(role: string): Promise<FAttachment[]>

Parameters

  • role: string

Returns Promise<FAttachment[]>

getAttribute

getAttribute(type: AttributeType, name: string): undefined | FAttribute

Parameters

attribute type (label, relation, etc.)

  • name: string

attribute name

Returns undefined | FAttribute

attribute of the given type and name. If there are more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.

getAttributes

getAttributes(type?: AttributeType, name?: string): FAttribute[]

Parameters

attribute type to filter

  • Optionalname: string

attribute name to filter

Returns FAttribute[]

all note's attributes, including inherited ones

getAttributeValue

getAttributeValue(type: AttributeType, name: string): null | string

Parameters

attribute type (label, relation, etc.)

  • name: string

attribute name

Returns null | string

attribute value of the given type and name or null if no such attribute exists.

getBestNotePath

getBestNotePath(hoistedNoteId?: string): string[]

Returns the note path considered to be the "best"

Parameters

  • OptionalhoistedNoteId: string = "root"

Returns string[]

array of noteIds constituting the particular note path

getBestNotePathString

getBestNotePathString(hoistedNoteId?: string): string

Returns the note path considered to be the "best"

Parameters

  • OptionalhoistedNoteId: string = "root"

Returns string

serialized note path (e.g. 'root/a1h315/js725h')

getBlob

getBlob(): Promise<null | void | default>

Returns Promise<null | void | default>

getBranches

getBranches(): FBranch[]

Returns FBranch[]

Deprecated

use getParentBranches() instead

getBranchIds

getBranchIds(): string[]

Returns string[]

Deprecated

use getParentBranchIds() instead

getChildBranches

getChildBranches(): FBranch[]

Returns FBranch[]

getChildNoteIds

getChildNoteIds(): string[]

Returns string[]

getChildNotes

getChildNotes(): Promise<FNote[]>

Returns Promise<FNote[]>

getColorClass

getColorClass(): string

Returns string

getContent

getContent(): Promise<undefined | string>

Returns Promise<undefined | string>

getCssClass

getCssClass(): string

Returns string

getFilteredChildBranches

getFilteredChildBranches(): FBranch[]

Returns FBranch[]

getIcon

getIcon(): string

Returns string

getJsonContent

getJsonContent(): Promise<any>

Returns Promise<any>

getLabel

getLabel(name: string): undefined | FAttribute

Parameters

  • name: string

label name

Returns undefined | FAttribute

label if it exists, null otherwise

getLabels

getLabels(name?: string): FAttribute[]

Parameters

  • Optionalname: string

label name to filter

Returns FAttribute[]

all note's labels (attributes with type label), including inherited ones

getLabelValue

getLabelValue(name: string): null | string

Parameters

  • name: string

label name

Returns null | string

label value if label exists, null otherwise

getMetadata

getMetadata(): Promise<NoteMetaData>

Provides note's date metadata.

Returns Promise<NoteMetaData>

getNoteComplement

getNoteComplement(): Promise<null | void | default>

Returns Promise<null | void | default>

Deprecated

use getBlob() instead

getNotesToInheritAttributesFrom

getNotesToInheritAttributesFrom(): FNote[]

Returns FNote[]

getOwnedAttribute

getOwnedAttribute(type: AttributeType, name: string): undefined | FAttribute

Parameters

attribute type (label, relation, etc.)

  • name: string

attribute name

Returns undefined | FAttribute

attribute of the given type and name. If there are more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.

getOwnedAttributes

getOwnedAttributes(type?: AttributeType, name?: string): FAttribute[]

Parameters

attribute type to filter

  • Optionalname: string

attribute name to filter

Returns FAttribute[]

all note's attributes, including inherited ones

getOwnedAttributeValue

getOwnedAttributeValue(type: AttributeType, name: string): null | string

Parameters

attribute type (label, relation, etc.)

  • name: string

attribute name

Returns null | string

attribute value of the given type and name or null if no such attribute exists.

getOwnedLabel

getOwnedLabel(name: string): undefined | FAttribute

Parameters

  • name: string

label name

Returns undefined | FAttribute

label if it exists, null otherwise

getOwnedLabels

getOwnedLabels(name?: string): FAttribute[]

Parameters

  • Optionalname: string

label name to filter

Returns FAttribute[]

all note's labels (attributes with type label), including inherited ones

getOwnedLabelValue

getOwnedLabelValue(name: string): null | string

Parameters

  • name: string

label name

Returns null | string

label value if label exists, null otherwise

getOwnedRelation

getOwnedRelation(name: string): undefined | FAttribute

Parameters

  • name: string

relation name

Returns undefined | FAttribute

relation if it exists, null otherwise

getOwnedRelations

getOwnedRelations(name?: string): FAttribute[]

Parameters

  • Optionalname: string

relation name to filter

Returns FAttribute[]

all note's relations (attributes with type relation), including inherited ones

getOwnedRelationValue

getOwnedRelationValue(name: string): null | string

Parameters

  • name: string

relation name

Returns null | string

relation value if relation exists, null otherwise

getParentBranches

getParentBranches(): FBranch[]

Returns FBranch[]

getParentBranchIds

getParentBranchIds(): string[]

Returns string[]

getParentNoteIds

getParentNoteIds(): string[]

Returns string[]

getParentNotes

getParentNotes(): FNote[]

Returns FNote[]

getPromotedDefinitionAttributes

getPromotedDefinitionAttributes(): FAttribute[]

Returns FAttribute[]

getRelation

getRelation(name: string): undefined | FAttribute

Parameters

  • name: string

relation name

Returns undefined | FAttribute

relation if it exists, null otherwise

getRelations

getRelations(name?: string): FAttribute[]

Parameters

  • Optionalname: string

relation name to filter

Returns FAttribute[]

all note's relations (attributes with type relation), including inherited ones

getRelationTarget

getRelationTarget(name: string): Promise<null | FNote>

Parameters

  • name: string

Returns Promise<null | FNote>

target note of the relation or null (if target is empty or note was not found)

getRelationTargets

getRelationTargets(name?: string): Promise<(null | FNote)[]>

Parameters

  • Optionalname: string

relation name to filter

Returns Promise<(null | FNote)[]>

getRelationValue

getRelationValue(name: string): null | string

Parameters

  • name: string

relation name

Returns null | string

relation value if relation exists, null otherwise

getScriptEnv

getScriptEnv(): null | "frontend" | "backend"

Returns null | "frontend" | "backend"

JS script environment - either "frontend" or "backend"

getSortedNotePathRecords

getSortedNotePathRecords(hoistedNoteId?: string): NotePathRecord[]

Parameters

  • hoistedNoteId: string = "root"

Returns NotePathRecord[]

getTargetRelations

getTargetRelations(): FAttribute[]

Get relations which target this note

Returns FAttribute[]

getTargetRelationSourceNotes

getTargetRelationSourceNotes(): Promise<FNote[]>

Get relations which target this note

Returns Promise<FNote[]>

getWorkspaceIconClass

getWorkspaceIconClass(): string

Returns string

getWorkspaceTabBackgroundColor

getWorkspaceTabBackgroundColor(): string

Returns string

hasAncestor

hasAncestor(
ancestorNoteId: string,
followTemplates?: boolean,
visitedNoteIds?: null | Set<string>,
): boolean

Parameters

  • ancestorNoteId: string
  • followTemplates: boolean = false
  • visitedNoteIds: null | Set<string> = null

Returns boolean

hasAttribute

hasAttribute(type: AttributeType, name: string): boolean

Parameters

attribute type (label, relation, etc.)

  • name: string

attribute name

Returns boolean

true if note has an attribute with given type and name (including inherited)

hasChildren

hasChildren(): boolean

Returns boolean

hasLabel

hasLabel(name: string): boolean

Parameters

  • name: string

label name

Returns boolean

true if label exists (including inherited)

hasOwnedAttribute

hasOwnedAttribute(type: AttributeType, name: string): boolean

Parameters

attribute type (label, relation, etc.)

  • name: string

attribute name

Returns boolean

true if note has an attribute with given type and name (including inherited)

hasOwnedLabel

hasOwnedLabel(name: string): boolean

Parameters

  • name: string

label name

Returns boolean

true if label exists (excluding inherited)

hasOwnedRelation

hasOwnedRelation(name: string): boolean

Parameters

  • name: string

relation name

Returns boolean

true if relation exists (excluding inherited)

hasRelation

hasRelation(name: string): boolean

Parameters

  • name: string

relation name

Returns boolean

true if relation exists (including inherited)

invalidateAttributeCache

invalidateAttributeCache(): void

Returns void

Deprecated

NOOP

isContentAvailable

isContentAvailable(): boolean

Returns boolean

isEligibleForConversionToAttachment

isEligibleForConversionToAttachment(): boolean

Returns boolean

isFolder

isFolder(): boolean

Returns boolean

isHiddenCompletely

isHiddenCompletely(): boolean

Returns boolean

boolean - true if there's no non-hidden path, note is not cloned to the visible tree

isHtml

isHtml(): boolean

Returns boolean

true if this note is HTML

isInHiddenSubtree

isInHiddenSubtree(): boolean

Returns boolean

isJavaScript

isJavaScript(): boolean

Returns boolean

true if this note is JavaScript (code or file)

isJson

isJson(): boolean

Returns boolean

isLabelTruthy

isLabelTruthy(name: string): boolean

Parameters

  • name: string

label name

Returns boolean

true if label exists (including inherited) and does not have "false" value.

isLaunchBarConfig

isLaunchBarConfig(): boolean

Returns boolean

isOptions

isOptions(): boolean

Returns boolean

isRoot

isRoot(): boolean

Returns boolean

isShared

isShared(): boolean

Returns boolean

sortChildren

sortChildren(): void

Returns void

sortParents

sortParents(): void

Returns void

toString

toString(): string

Returns string

update

update(row: FNoteRow): void

Parameters

Returns void

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Constructors constructor Properties attachmentsattributesblobIdchildrenchildToBranchhighlightedTokensisProtectedmimenoteIdparentsparentToBranchsearchResultsLoadedtargetRelationstitletype Accessors dtoisArchived Methods __getInheritableAttributes__validateTypeNameaddChildaddParentexecuteScriptgetAllNotePathsgetAttachmentByIdgetAttachmentsgetAttachmentsByRolegetAttributegetAttributesgetAttributeValuegetBestNotePathgetBestNotePathStringgetBlobgetBranchesgetBranchIdsgetChildBranchesgetChildNoteIdsgetChildNotesgetColorClassgetContentgetCssClassgetFilteredChildBranchesgetIcongetJsonContentgetLabelgetLabelsgetLabelValuegetMetadatagetNoteComplementgetNotesToInheritAttributesFromgetOwnedAttributegetOwnedAttributesgetOwnedAttributeValuegetOwnedLabelgetOwnedLabelsgetOwnedLabelValuegetOwnedRelationgetOwnedRelationsgetOwnedRelationValuegetParentBranchesgetParentBranchIdsgetParentNoteIdsgetParentNotesgetPromotedDefinitionAttributesgetRelationgetRelationsgetRelationTargetgetRelationTargetsgetRelationValuegetScriptEnvgetSortedNotePathRecordsgetTargetRelationsgetTargetRelationSourceNotesgetWorkspaceIconClassgetWorkspaceTabBackgroundColorhasAncestorhasAttributehasChildrenhasLabelhasOwnedAttributehasOwnedLabelhasOwnedRelationhasRelationinvalidateAttributeCacheisContentAvailableisEligibleForConversionToAttachmentisFolderisHiddenCompletelyisHtmlisInHiddenSubtreeisJavaScriptisJsonisLabelTruthyisLaunchBarConfigisOptionsisRootisSharedsortChildrensortParentstoStringupdate