Back to Beekeeper Studio

SQL Text Editor API

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

5.7.24.8 KB
Original Source

SQL Text Editor API

This component inherits all features from the Text Editor API, including Language Server Protocol support. Below are the SQL-specific properties and events in addition to those inherited.

Properties

In addition to the properties inherited from the Text Editor, the SQL Text Editor provides:

NameTypeDescriptionDefault
entitiesobject[]An array of entity names to autocomplete. The format is the same as the entities property of the bks-entity-list component.[]
columnsGetter(entityName: string) => (string[] | Promise<string[]>)If provided, this function will be called for autocompleting column names instead of using the entities.columns property. Expect one argument of type string representing a combination of schema name (if exists) and entity name. Accepts async or non-async function.undefined
defaultSchemastringThe default schema to use when autocompleting entity names. Schemas that match this will be prioritized in the autocompletion list.public
formatterDialectstringThe SQL dialect to use for formatting. See sql-formatter's language for possible options.'sql'
identifierDialectstringThe SQL dialect to use for identifier quotes. See sql-query-identifier API for possible options.'generic'
formatterConfigobjectConfiguration object for the SQL formatter. See sql-formatter's options for possible values. Should include an id property to track the selected formatter preset.{}
allowPresetsbooleanWhen enabled, adds a submenu to the "Format Query" context menu item showing available formatter presets.false
presetsobject[]An array of formatter preset objects. Each preset should have id, name, and config properties. Used when allowPresets is true to populate the formatter preset submenu in the context menu.[]

Events

In addition to the events inherited from the Text Editor, the SQL Text Editor provides:

NameDescriptionEvent Detail
bks-query-selection-changeEmitted when the query selection is changed.{ selectedQuery: IdentifyResult, queries: IdentifyResult[] }
bks-apply-presetEmitted when a formatter preset is selected from the context menu. Used to apply the selected preset.{ id: number, ...config }