Back to Beekeeper Studio

Text Editor API

apps/ui-kit/docs/api/text-editor.md

5.7.210.2 KB
Original Source

Text Editor API

Note: The text editor component is being upgraded to support LSP integration. Properties marked with ⚠️ are not yet implemented.

Properties

NameTypeDescriptionDefaultStatus
valuestringThe text to display.''
readOnlyboolean | stringDisable editing. If "nocursor" is provided, focusing the editor is also disabled.false
keybindingsobjectObject containing keybindings where the key is a combination of keys and the value is a function. For example, { 'Ctrl-Enter': function submit(){}, 'Cmd-Enter': function submit(){} }.undefined
keymapstringConfigure the keymap to use. Possible values are 'default', 'vim', 'emacs' and 'sublime'.default
lineWrappingbooleanEnable line wrapping.false
focusbooleanControl or observe focus state of the editor.false
contextMenuItemsarray | functionAdd custom items to the context menu.undefined
lineNumbersbooleanShow line numbers in the editor.true
lsConfigLanguageServerConfigurationConfigure the Language Server Protocol integration. See Language Server Configuration below.undefined
replaceExtensionsExtension[] | (extensions: Extension[]) => Extension[]Replace or modify the default CodeMirror extensions used by the editor. Accepts either a full list of extensions or a function to transform the default list.undefined
vimConfigobjectConfigure vim mode.undefined⚠️
vimKeymapsarrayConfigure custom key mappings in vim. See documentation in texteditor/mixin.ts for more details.undefined⚠️
foldGutterbooleanEnable code folding in the editor.false⚠️
clipboardClipboardCustom clipboard handler for the editor used in vim. If provided, it must implement a write method to copy text to the clipboard. See MDN Clipboard API for more details.undefined⚠️
heightnumber[Deprecated] Use CSS to control the editor height instead.undefined
<!-- Not sure if autofocus should be here, see https://github.com/beekeeper-studio/beekeeper-studio/issues/3051 --> <!-- | `autoFocus` | `boolean` | Automatically focus the editor when it regains window focus after blur. | `false` | ⚠️ | -->

Language Server Configuration

NameTypeDescriptionDefault
languageIdstringThe language identifier (e.g., "javascript", "typescript", "sql").Required
rootUristringThe root URI of the workspace.Required
documentUristringThe URI of the document being edited.Required
transport{ wsUri: string } | WebSocketTransportTransport config for the language server. Can be a plain object with wsUri, or a WebSocketTransport instance from @open-rpc/client-js.Required
featuresobjectConfigure which LSP features to enable.See below
timeoutnumberTimeout for LSP requests in milliseconds.10000

Features Configuration

NameTypeDescriptionDefault
hoverEnabledbooleanEnable hover information.true
completionEnabledbooleanEnable code completion.true
diagnosticsEnabledbooleanEnable diagnostics (errors, warnings).true
signatureHelpEnabledbooleanEnable signature help for function calls.true
semanticTokensEnabledbooleanEnable semantic token highlighting.true
definitionEnabledbooleanEnable go-to-definition.true
renameEnabledbooleanEnable rename functionality.true
codeActionsEnabledbooleanEnable code actions.true
signatureActivateOnTypingbooleanShow signature help while typing.false

Methods

NameDescriptionArguments
ls()Returns the Language Server Helpers. See Language Server Helpers for more information.-

Events

NameDescriptionEvent Detail
bks-value-changeEmitted when the text is changed.{ value: string }
bks-initializedEmitted when the text editor is initialized.{ editor: TextEditor }
bks-focusEmitted when the text editor is focused.{ event: FocusEvent }
bks-blurEmitted when the text editor is blurred.{ event: FocusEvent }
bks-lsp-readyEmitted when the LSP client is ready.{ capabilities: object }