fix: no longer capitalising renderer options

This commit is contained in:
Kacper Kula 2025-02-04 18:26:27 +00:00
parent 54981be715
commit d7ec7a33b4
7 changed files with 38 additions and 11 deletions

View file

@ -1,3 +1,6 @@
# 0.23.2 (2025-02-04)
- No longer captalising renderer options (it was breaking SQLSeal Charts integration)
# 0.23.1 (2025-02-04)
- SQLSeal now works with multiple vaults open. It registers database with unique filename to avoid conflicts.

View file

@ -1,7 +1,7 @@
{
"id": "sqlseal",
"name": "SQLSeal",
"version": "0.23.1",
"version": "0.23.2",
"minAppVersion": "0.15.0",
"description": "Use SQL in your notes to query your vault files and CSV content.",
"author": "hypersphere",

View file

@ -1,6 +1,6 @@
{
"name": "sqlseal",
"version": "0.23.1",
"version": "0.23.2",
"description": "A plugin for Obsidian that allows you to run SQL queries on your notes.",
"main": "main.js",
"scripts": {

View file

@ -56,11 +56,16 @@ export class CodeblockProcessor extends MarkdownRenderChild {
this.flags = config.flags
this.extrasEl = this.el.createDiv({ cls: 'sqlseal-extras-container' })
if (config.flags.explain) {
this.explainEl = this.extrasEl.createEl('pre', { cls: 'sqlseal-extras-explain-container' })
let rendererEl = this.el
if (this.flags.explain) {
this.extrasEl = this.el.createDiv({ cls: 'sqlseal-extras-container' })
if (config.flags.explain) {
this.explainEl = this.extrasEl.createEl('pre', { cls: 'sqlseal-extras-explain-container' })
}
rendererEl = this.el.createDiv({ cls: 'sqlseal-renderer-container' })
}
const rendererEl = this.el.createDiv({ cls: 'sqlseal-renderer-container' })
this.renderer = this.rendererRegistry.prepareRender(config.renderer.toLowerCase(), config.rendererArguments)(rendererEl)

View file

@ -75,4 +75,21 @@ describe('Parse Intermediate Content', () => {
rendererArguments: ''
})
})
it('should properly parse parameter to the function', () => {
expect(parseIntermediateContent(`
explain
no refresh
grid {
a: 5,
b: 7
}`, {})).toEqual({
flags: { explain: true, refresh: false },
renderer: 'GRID',
rendererArguments: `{
a: 5,
b: 7
}`
})
})
})

View file

@ -1,4 +1,4 @@
import { assign } from "lodash"
import { assign, trim } from "lodash"
export interface IntermediateContent {
flags: {
@ -35,18 +35,19 @@ export const parseIntermediateContent = (content: string, initialConfig: Partial
let processingFlags = true
const rendererArguments = []
for (const row of content.split('\n')) {
const trimmedRow = row.trim().toUpperCase()
const trimmedRow = row.trim()
const upperRow = trimmedRow.toUpperCase()
if (!trimmedRow) {
continue // empty row
}
if (processingFlags) {
if (!FLAGS[trimmedRow]) {
if (!FLAGS[upperRow]) {
processingFlags = false
const [renderer, ...rest ] = trimmedRow.split(' ')
config.renderer = renderer.toUpperCase()
rendererArguments.push(rest.join(' '))
} else {
const fn = FLAGS[trimmedRow]
const fn = FLAGS[upperRow]
fn(config)
}
} else {

View file

@ -41,5 +41,6 @@
"0.22.2": "0.15.0",
"0.22.3": "0.15.0",
"0.23.0": "0.15.0",
"0.23.1": "0.15.0"
"0.23.1": "0.15.0",
"0.23.2": "0.15.0"
}