Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
mProjectsCode committed Jun 14, 2023
2 parents a3bf18b + 2b17138 commit cae4532
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-meta-bind-plugin",
"name": "Meta Bind Plugin",
"version": "0.5.0",
"version": "0.5.1",
"minAppVersion": "0.14.0",
"description": "This plugin can create input fields inside your notes and bind them to metadata fields.",
"author": "Moritz Jung",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-meta-bind-plugin",
"version": "0.5.0",
"version": "0.5.1",
"description": "This plugin can create input fields inside your notes and bind them to metadata fields.",
"main": "main.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/renderChildren/JsViewFieldMDRC.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MetaBindPlugin from '../main';
import { ErrorLevel, MetaBindExpressionError } from '../utils/errors/MetaBindErrors';
import { ErrorLevel, MetaBindExpressionError, MetaBindJsError } from '../utils/errors/MetaBindErrors';
import { Listener, Signal } from '../utils/Signal';
import { RenderChildType } from './InputFieldMDRC';
import { JsViewFieldDeclaration } from '../parsers/ViewFieldDeclarationParser';
Expand Down Expand Up @@ -82,10 +82,10 @@ export class JsViewFieldMDRC extends AbstractViewFieldMDRC {

async evaluateExpression(): Promise<string> {
if (!this.expression) {
throw new Error("Can't evaluate expression. Expression is undefined.");
throw new MetaBindJsError(ErrorLevel.CRITICAL, "Can't evaluate expression.", 'Expression is undefined.');
}
if (!(this.plugin instanceof MetaBindPlugin)) {
throw new Error("Can't evaluate expression. JS expressions are unsupported outside of obsidian.");
if (!this.plugin.settings.enableJs) {
throw new MetaBindJsError(ErrorLevel.CRITICAL, "Can't evaluate expression.", 'JS expressions are disabled in the plugin settings.');
}

const context = this.buildContext();
Expand Down
2 changes: 2 additions & 0 deletions src/settings/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface MetaBindPluginSettings {
syncInterval: number;
maxSyncInterval: number;
minSyncInterval: number;
enableJs: boolean;

inputTemplates: string;
}
Expand All @@ -66,6 +67,7 @@ export const DEFAULT_SETTINGS: MetaBindPluginSettings = {
syncInterval: 200,
minSyncInterval: 50,
maxSyncInterval: 1000,
enableJs: false,

inputTemplates: '',
};
11 changes: 11 additions & 0 deletions src/settings/SettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ export class MetaBindSettingTab extends PluginSettingTab {
});
});

new Setting(containerEl)
.setName('Enable JS Input Fields')
.setDesc("Enable the processing of JavaScript input fields. This is potentially DANGEROUS, thus it's disabled by default. RESTART REQUIRED.")
.addToggle(cb => {
cb.setValue(this.plugin.settings.enableJs);
cb.onChange(data => {
this.plugin.settings.enableJs = data;
this.plugin.saveSettings();
});
});

new Setting(containerEl)
.setName('Disable Code Block Restrictions')
.setDesc('Disable restrictions on which input fields can be created in which code blocks. Not recommended unless you know what you are doing.')
Expand Down

0 comments on commit cae4532

Please sign in to comment.