DslEditor
Class in @bimworks/dsleditor.
API catalogue · @bimworks/dsleditor · Class
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#
constructor()element#
readonly element: HTMLDivElementThe element the editor added to the container.
language#
readonly language: DslLanguageThe language.
monacoEditor#
readonly monacoEditor: anyThe Monaco editor (monaco.editor.IStandaloneCodeEditor), for what this package does not wrap.
addCommand#
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#
dispose(): voidRemoves the editor from the page and frees it. Call it when the host component goes away.
focus#
focus(): voidformat#
format(): Promise<void>Formats the text with the language's formatter.
getStatus#
getStatus(): DslEditorStatusgetValue#
getValue(): stringlayout#
layout(): voidRe-measures the container. Automatic, except after it changed size while hidden.
onChange#
onChange(listener: (value: string) => void): () => voidReturns a function that removes the listener.
Parameters#
| Name | Type | Description |
|---|---|---|
listener |
(value: string) => void |
onError#
onError(listener: (error: DslServiceError) => void): () => voidReturns a function that removes the listener.
Parameters#
| Name | Type | Description |
|---|---|---|
listener |
(error: DslServiceError) => void |
onStatus#
onStatus(listener: (status: DslEditorStatus) => void): () => voidReturns a function that removes the listener.
Parameters#
| Name | Type | Description |
|---|---|---|
listener |
(status: DslEditorStatus) => void |
setAddress#
setAddress(address: string): voidAnother instance from now on.
Parameters#
| Name | Type | Description |
|---|---|---|
address |
string |
setLanguage#
setLanguage(language: DslLanguage): voidSwitches the language, keeping the text.
Parameters#
| Name | Type | Description |
|---|---|---|
language |
DslLanguage |
setModels#
setModels(models: (string)[] | () => (string)[] | null | undefined | null | undefined): voidThe models whose names completion proposes from now on (DslEditorOptions.models).
Parameters#
| Name | Type | Description |
|---|---|---|
models |
(string)[] | () => (string)[] | null | undefined | null | undefined |
setReadOnly#
setReadOnly(readOnly: boolean): voidParameters#
| Name | Type | Description |
|---|---|---|
readOnly |
boolean |
setTheme#
setTheme(theme: string): voidSets the page's theme (every editor follows).
Parameters#
| Name | Type | Description |
|---|---|---|
theme |
string |
setToken#
Parameters#
| Name | Type | Description |
|---|---|---|
token |
DslToken | () => DslToken | Promise<DslToken> |
setValue#
setValue(value: string): voidReplaces the text as one undoable edit; no-op when it is the same text.
Parameters#
| Name | Type | Description |
|---|---|---|
value |
string |
validate#
validate(): Promise<DslEditorStatus>Validates the current text now; rejects when the services cannot be reached.