mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
Merge pull request #145 from h-sphere/fix/canvas-rendering
fix: fixing canvas rendering
This commit is contained in:
commit
2b05291c01
2 changed files with 24 additions and 25 deletions
|
|
@ -94,13 +94,11 @@ export class CodeblockProcessor extends MarkdownRenderChild {
|
|||
|
||||
async render() {
|
||||
try {
|
||||
|
||||
const registeredTablesForContext = await this.sync.getTablesMappingForContext(this.ctx.sourcePath)
|
||||
|
||||
const res = transformQuery(this.query, registeredTablesForContext)
|
||||
const transformedQuery = res.sql
|
||||
|
||||
|
||||
if (this.flags.refresh) {
|
||||
registerObservers({
|
||||
bus: this.registrator,
|
||||
|
|
@ -110,28 +108,26 @@ export class CodeblockProcessor extends MarkdownRenderChild {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
let variables = {}
|
||||
const file = this.app.vault.getFileByPath(this.ctx.sourcePath)
|
||||
if (!file) {
|
||||
return
|
||||
if (file) {
|
||||
const fileCache = this.app.metadataCache.getFileCache(file)
|
||||
variables = {
|
||||
...fileCache?.frontmatter ?? {},
|
||||
path: file.path,
|
||||
fileName: file.name,
|
||||
basename: file.basename,
|
||||
parent: file.parent?.path,
|
||||
extension: file.extension,
|
||||
}
|
||||
}
|
||||
const fileCache = this.app.metadataCache.getFileCache(file)
|
||||
|
||||
if (this.flags.explain) {
|
||||
// Rendering explain
|
||||
const result = await this.db.explain(transformedQuery, fileCache?.frontmatter ?? {})
|
||||
const result = await this.db.explain(transformedQuery, variables)
|
||||
this.explainEl.textContent = result
|
||||
}
|
||||
|
||||
const variables = {
|
||||
...fileCache?.frontmatter ?? {},
|
||||
path: file.path,
|
||||
fileName: file.name,
|
||||
basename: file.basename,
|
||||
parent: file.parent?.path,
|
||||
extension: file.extension,
|
||||
}
|
||||
|
||||
const { data, columns } = await this.db.select(transformedQuery, variables)
|
||||
this.renderer.render({ data, columns, flags: this.flags, frontmatter: variables })
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -49,20 +49,23 @@ class GridRendererCommunicator {
|
|||
}
|
||||
|
||||
private setupLayoutObservers() {
|
||||
// Observe resize changes
|
||||
// Debounce the resize observer to prevent too frequent updates
|
||||
let resizeTimeout: NodeJS.Timeout;
|
||||
this.resizeObserver = new ResizeObserver(() => {
|
||||
if (this._gridApi) {
|
||||
this._gridApi.autoSizeAllColumns()
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(() => {
|
||||
this._gridApi.autoSizeAllColumns();
|
||||
}, 100);
|
||||
}
|
||||
})
|
||||
this.resizeObserver.observe(this.el)
|
||||
});
|
||||
this.resizeObserver.observe(this.el);
|
||||
|
||||
// Observe tab switches
|
||||
this.unregisterLeafChange = this.app.workspace.on('active-leaf-change', () => {
|
||||
if (this._gridApi) {
|
||||
this._gridApi.autoSizeAllColumns()
|
||||
this.unregisterLeafChange = this.app.workspace.on('active-leaf-change', (leaf) => {
|
||||
if (this._gridApi && leaf?.view?.getViewType() !== 'canvas') {
|
||||
this._gridApi.autoSizeAllColumns();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue