apps/ui-kit/docs/api/sql-text-editor.md
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.
In addition to the properties inherited from the Text Editor, the SQL Text Editor provides:
| Name | Type | Description | Default |
|---|---|---|---|
entities | object[] | 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 |
defaultSchema | string | The default schema to use when autocompleting entity names. Schemas that match this will be prioritized in the autocompletion list. | public |
formatterDialect | string | The SQL dialect to use for formatting. See sql-formatter's language for possible options. | 'sql' |
identifierDialect | string | The SQL dialect to use for identifier quotes. See sql-query-identifier API for possible options. | 'generic' |
formatterConfig | object | Configuration object for the SQL formatter. See sql-formatter's options for possible values. Should include an id property to track the selected formatter preset. | {} |
allowPresets | boolean | When enabled, adds a submenu to the "Format Query" context menu item showing available formatter presets. | false |
presets | object[] | 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. | [] |
In addition to the events inherited from the Text Editor, the SQL Text Editor provides:
| Name | Description | Event Detail |
|---|---|---|
bks-query-selection-change | Emitted when the query selection is changed. | { selectedQuery: IdentifyResult, queries: IdentifyResult[] } |
bks-apply-preset | Emitted when a formatter preset is selected from the context menu. Used to apply the selected preset. | { id: number, ...config } |