import { t } from "../services/i18n.js"; import NoteContextAwareWidget from "./note_context_aware_widget.js"; import server from "../services/server.js"; import type FNote from "../entities/fnote.js"; const TPL = /*html*/`
${t("sql_table_schemas.tables")}:
`; interface SchemaResponse { name: string; columns: { name: string; type: string; }[]; } export default class SqlTableSchemasWidget extends NoteContextAwareWidget { private tableSchemasShown?: boolean; private $sqlConsoleTableSchemas!: JQuery; isEnabled() { return this.note && this.note.mime === "text/x-sqlite;schema=trilium" && super.isEnabled(); } doRender() { this.$widget = $(TPL); this.contentSized(); this.$sqlConsoleTableSchemas = this.$widget.find(".sql-table-schemas"); } async refreshWithNote(note: FNote) { if (this.tableSchemasShown) { return; } this.tableSchemasShown = true; const tableSchema = await server.get("sql/schema"); for (const table of tableSchema) { const $tableLink = $('