Skip to content

Commit

Permalink
+ added an option to configure the java executable(references #26)
Browse files Browse the repository at this point in the history
~ setting for `Default processor for includes` actually shows the saved value now.
  • Loading branch information
joethei committed May 4, 2022
1 parent 307c39c commit 5c5ba62
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 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-plantuml",
"name": "PlantUML",
"version": "1.6.2",
"version": "1.6.3",
"minAppVersion": "0.13.0",
"description": "Render PlantUML Diagrams",
"author": "Johannes Theiner",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-plantuml",
"version": "1.6.2",
"version": "1.6.3",
"description": "PlantUML rendering for Obsidian.md",
"main": "main.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/debouncedProcessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class DebouncedProcessors implements Processor {
this.plugin = plugin;
const debounceTime = plugin.settings.debounce;
this.debounceTime = debounceTime * this.SECONDS_TO_MS_FACTOR;

}

png = async (source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) => {
Expand Down
6 changes: 3 additions & 3 deletions src/localProcessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class LocalProcessors implements Processor {
'-charset utf-8',
'-pipemap'
];
const child = exec('java ' + args.join(" "), {encoding: 'binary', cwd: path});
const child = exec(this.plugin.settings.javaPath + ' ' + args.join(" "), {encoding: 'binary', cwd: path});

let stdout = "";

Expand Down Expand Up @@ -88,9 +88,9 @@ export class LocalProcessors implements Processor {

let child: typeof ChildProcess;
if (type === OutputType.PNG) {
child = exec('java ' + args.join(" "), {encoding: 'binary', cwd: path});
child = exec(this.plugin.settings.javaPath + ' ' + args.join(" "), {encoding: 'binary', cwd: path});
} else {
child = exec('java ' + args.join(" "), {encoding: 'utf-8', cwd: path});
child = exec(this.plugin.settings.javaPath + ' ' + args.join(" "), {encoding: 'utf-8', cwd: path});
}

let stdout: any;
Expand Down
17 changes: 16 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface PlantUMLSettings {
header: string;
debounce: number;
localJar: string;
javaPath: string;
defaultProcessor: string;
}

Expand All @@ -14,6 +15,7 @@ export const DEFAULT_SETTINGS: PlantUMLSettings = {
header: '',
debounce: 3,
localJar: '',
javaPath: 'java',
defaultProcessor: "png",
}

Expand Down Expand Up @@ -53,6 +55,18 @@ export class PlantUMLSettingsTab extends PluginSettingTab {
}
)
);

new Setting(containerEl)
.setName("Java Path")
.setDesc("Path to Java executable")
.addText(text => text.setPlaceholder(DEFAULT_SETTINGS.javaPath)
.setValue(this.plugin.settings.javaPath)
.onChange(async (value) => {
this.plugin.settings.javaPath = value;
await this.plugin.saveSettings();
}
)
);
}

new Setting(containerEl)
Expand All @@ -62,6 +76,7 @@ export class PlantUMLSettingsTab extends PluginSettingTab {
dropdown
.addOption("png", "PNG")
.addOption("svg", "SVG")
.setValue(this.plugin.settings.defaultProcessor)
.onChange(async(value) => {
this.plugin.settings.defaultProcessor = value;
await this.plugin.saveSettings();
Expand All @@ -79,7 +94,7 @@ export class PlantUMLSettingsTab extends PluginSettingTab {
}
)
text.inputEl.setAttr("rows", 4);
text.inputEl.addClass("settings_area")
text.inputEl.addClass("puml-settings-area")
}
);
new Setting(containerEl).setName("Debounce")
Expand Down
6 changes: 5 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.settings_area {
.puml-settings-area {
margin-left: 5px;
margin-right: 5px;
font-size: 14px;
Expand Down Expand Up @@ -32,3 +32,7 @@
.internal-embed.file-embed[src$=".pu"] {
display: none;
}

.puml-error {
color: var(--text-error);
}
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"1.5.3": "0.13.0",
"1.6.0": "0.13.0",
"1.6.1": "0.13.0",
"1.6.2": "0.13.0"
"1.6.2": "0.13.0",
"1.6.3": "0.13.0"
}

0 comments on commit 5c5ba62

Please sign in to comment.