Reference·JavaScript · @bimworks/dsleditorJavaScript

DslEditor

Class in @bimworks/dsleditor.

API catalogue · @bimworks/dsleditor · Class

TypeScript#
class DslEditor

Members#

Member Kind Description
constructor Method
element Property The element the editor added to the container.
language Property The language.
monacoEditor Property The Monaco editor (monaco.editor.IStandaloneCodeEditor), for what this package does not wrap.
addCommand Method Runs handler on a key combination of Monaco KeyMod and KeyCode names, e.g. "CtrlCmd+Enter".
dispose Method Removes the editor from the page and frees it. Call it when the host component goes away.
focus Method
format Method Formats the text with the language's formatter.
getStatus Method
getValue Method
layout Method Re-measures the container. Automatic, except after it changed size while hidden.
onChange Method Returns a function that removes the listener.
onError Method Returns a function that removes the listener.
onStatus Method Returns a function that removes the listener.
setAddress Method Another instance from now on.
setLanguage Method Switches the language, keeping the text.
setModels Method The models whose names completion proposes from now on (DslEditorOptions.models).
setReadOnly Method
setTheme Method Sets the page's theme (every editor follows).
setToken Method
setValue Method Replaces the text as one undoable edit; no-op when it is the same text.
validate Method Validates the current text now; rejects when the services cannot be reached.

constructor#

TypeScript#
constructor()

element#

TypeScript#
readonly element: HTMLDivElement

The element the editor added to the container.

language#

TypeScript#
readonly language: DslLanguage

The language.

monacoEditor#

TypeScript#
readonly monacoEditor: any

The Monaco editor (monaco.editor.IStandaloneCodeEditor), for what this package does not wrap.

addCommand#

TypeScript#
addCommand(keys: string, handler: (editor: DslEditor) => void): void

Runs handler on a key combination of Monaco KeyMod and KeyCode names, e.g. "CtrlCmd+Enter".

Parameters#

Name Type Description
keys string
handler (editor: DslEditor) => void

dispose#

TypeScript#
dispose(): void

Removes the editor from the page and frees it. Call it when the host component goes away.

focus#

TypeScript#
focus(): void

format#

TypeScript#
format(): Promise<void>

Formats the text with the language's formatter.

getStatus#

TypeScript#
getStatus(): DslEditorStatus

getValue#

TypeScript#
getValue(): string

layout#

TypeScript#
layout(): void

Re-measures the container. Automatic, except after it changed size while hidden.

onChange#

TypeScript#
onChange(listener: (value: string) => void): () => void

Returns a function that removes the listener.

Parameters#

Name Type Description
listener (value: string) => void

onError#

TypeScript#
onError(listener: (error: DslServiceError) => void): () => void

Returns a function that removes the listener.

Parameters#

Name Type Description
listener (error: DslServiceError) => void

onStatus#

TypeScript#
onStatus(listener: (status: DslEditorStatus) => void): () => void

Returns a function that removes the listener.

Parameters#

Name Type Description
listener (status: DslEditorStatus) => void

setAddress#

TypeScript#
setAddress(address: string): void

Another instance from now on.

Parameters#

Name Type Description
address string

setLanguage#

TypeScript#
setLanguage(language: DslLanguage): void

Switches the language, keeping the text.

Parameters#

Name Type Description
language DslLanguage

setModels#

TypeScript#
setModels(models: (string)[] | () => (string)[] | null | undefined | null | undefined): void

The models whose names completion proposes from now on (DslEditorOptions.models).

Parameters#

Name Type Description
models (string)[] | () => (string)[] | null | undefined | null | undefined

setReadOnly#

TypeScript#
setReadOnly(readOnly: boolean): void

Parameters#

Name Type Description
readOnly boolean

setTheme#

TypeScript#
setTheme(theme: string): void

Sets the page's theme (every editor follows).

Parameters#

Name Type Description
theme string

setToken#

TypeScript#
setToken(token: DslToken | () => DslToken | Promise<DslToken>): void

Parameters#

Name Type Description
token DslToken | () => DslToken | Promise<DslToken>

setValue#

TypeScript#
setValue(value: string): void

Replaces the text as one undoable edit; no-op when it is the same text.

Parameters#

Name Type Description
value string

validate#

TypeScript#
validate(): Promise<DslEditorStatus>

Validates the current text now; rejects when the services cannot be reached.