Skip to content

Commit

Permalink
Added more settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Developer-Mike committed Mar 21, 2024
1 parent e887d1b commit cb425b3
Show file tree
Hide file tree
Showing 5 changed files with 37 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": "calctex",
"name": "Calctex",
"version": "1.3.2",
"version": "1.3.3",
"minAppVersion": "0.15.0",
"description": "Calculate LaTeX formulas inside Obsidian.",
"author": "Developer-Mike",
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

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

4 changes: 2 additions & 2 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class CalctexHintRenderer implements PluginValue {
// Create a new calculation engine
const calculationEngine = new ComputeEngine();
calculationEngine.latexOptions = {
multiply: "*",
groupSeparator: "'",
multiply: CalctexPlugin.INSTANCE.settings.multiplicationSymbol,
groupSeparator: CalctexPlugin.INSTANCE.settings.groupSeparator,
};

let formattedFormula = formula.replace("\\\\", "").replace("&", "");
Expand Down
36 changes: 33 additions & 3 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import CalctexPlugin from "./main";
import { App, PluginSettingTab, Setting } from "obsidian";

export interface CalctexPluginSettings {
calculationTriggerString: string,
completionTriggerKey: string,
calculationTriggerString: string
completionTriggerKey: string
multiplicationSymbol: string
groupSeparator: string
}

export const DEFAULT_SETTINGS: Partial<CalctexPluginSettings> = {
calculationTriggerString: "=",
completionTriggerKey: "Tab"
completionTriggerKey: "Tab",
multiplicationSymbol: "*",
groupSeparator: "'",
};

export class CalctexSettingTab extends PluginSettingTab {
Expand Down Expand Up @@ -48,5 +52,31 @@ export class CalctexSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
})
);

new Setting(containerEl)
.setName("Multiplication Symbol")
.setDesc("The symbol used for multiplication (e.g. * or \\times).")
.addText((text) =>
text
.setPlaceholder("Type a symbol here")
.setValue(this.plugin.settings.multiplicationSymbol)
.onChange(async (value) => {
this.plugin.settings.multiplicationSymbol = value;
await this.plugin.saveSettings();
})
);

new Setting(containerEl)
.setName("Group Separator")
.setDesc("The symbol used for grouping numbers (e.g. ' or \\,).")
.addText((text) =>
text
.setPlaceholder("Type a symbol here")
.setValue(this.plugin.settings.groupSeparator)
.onChange(async (value) => {
this.plugin.settings.groupSeparator = value;
await this.plugin.saveSettings();
})
);
}
}
2 changes: 1 addition & 1 deletion src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ResultWidget extends WidgetType {
super();
}

toDOM(view: EditorView): HTMLElement {
toDOM(_view: EditorView): HTMLElement {
document.removeEventListener("keydown", this.keyListener, true);

const div = document.createElement("span");
Expand Down

0 comments on commit cb425b3

Please sign in to comment.