Skip to content

Commit

Permalink
add missing settings to settings tab: (#53)
Browse files Browse the repository at this point in the history
- maxRecursiveRenderDepth
- enableJavascript
- renderNullAs
- defaultDateFormat
- defaultDateTimeFormat
  • Loading branch information
GamerGirlandCo authored Jul 6, 2024
1 parent 881a6e6 commit 0bd6db0
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DatacoreApi } from "api/api";
import { Datacore } from "index/datacore";
import { DateTime } from "luxon";
import { App, Plugin, PluginSettingTab, Setting } from "obsidian";
import { createElement, render } from "preact";
import { DEFAULT_SETTINGS, Settings } from "settings";
Expand Down Expand Up @@ -163,6 +164,54 @@ class GeneralSettingsTab extends PluginSettingTab {
});
});

new Setting(this.containerEl)
.setName("Enable Javascript")
.setDesc("Whether Javascript codeblocks will be evaluated.")
.addToggle((toggle) => {
toggle.setValue(this.plugin.settings.enableJs).onChange(async (value) => {
await this.plugin.updateSettings({ enableJs: value });
});
});

new Setting(this.containerEl)
.setName("Render Null As")
.setDesc("How to render null values in objects")
.addText(text => {
text.setValue(this.plugin.settings.renderNullAs).onChange(async (value) => {
await this.plugin.updateSettings({renderNullAs: value})
})
})


new Setting(this.containerEl)
.setName("Default Date Format")
.setDesc("The default format that dates are rendered in")
.addText(text => {
text.setValue(this.plugin.settings.defaultDateFormat).onChange(async value => {
// check if date format is valid
try {
DateTime.fromMillis(Date.now()).toFormat(value)
} catch {
return
}
await this.plugin.updateSettings({defaultDateFormat: value})
})
})

new Setting(this.containerEl)
.setName("Default Date-Time format")
.setDesc("The default format that date-times are rendered in")
.addText(text => {
text.setValue(this.plugin.settings.defaultDateTimeFormat).onChange(async value => {
try {
DateTime.fromMillis(Date.now()).toFormat(value)
} catch {
return
}
await this.plugin.updateSettings({defaultDateTimeFormat: value})
})
})

this.containerEl.createEl("h2", { text: "Performance Tuning" });

new Setting(this.containerEl)
Expand Down Expand Up @@ -204,5 +253,18 @@ class GeneralSettingsTab extends PluginSettingTab {
await this.plugin.updateSettings({ importerUtilization: limited });
});
});

new Setting(this.containerEl)
.setName("Maximum Recursive Render Depth")
.setDesc("Maximum depth that objects will be rendered to (i.e., how many levels of subproperties" +
"will be rendered by default). This avoids infinite recursion due to self-referential objects" +
"and ensures that rendering objects is acceptably performant.")
.addText(text => {
text.setValue(this.plugin.settings.maxRecursiveRenderDepth.toString()).onChange(async value => {
const parsed = parseInt(value)
if(isNaN(parsed)) return;
await this.plugin.updateSettings({maxRecursiveRenderDepth: parsed})
})
});
}
}

0 comments on commit 0bd6db0

Please sign in to comment.