Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"enumDescriptions": [
"The directed graph layout library Dagre",
"Eclipse Layout Kernel (ELK) with the Layered algorithm",
"Terrastruct's AutoLayout Approach - available if installed"
"Terrastruct's AutoLayout Approach"
],
"description": "Layout used for preview."
},
Expand Down
2 changes: 1 addition & 1 deletion pages/previewPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
height: 100%;
}

path {
#toolbar path {
fill: var(--vscode-button-foreground);
}

Expand Down
5 changes: 3 additions & 2 deletions src/layoutPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ const talaPluginName: string =
*/
export class layoutPicker {
constructor() {
// If the plugin file exists, add the option if it hasn't been added before
if (util.isFileOnPath(talaPluginName)) {
// If d2 reports TALA (bundled or as a plugin), or the plugin file exists,
// add the option if it hasn't been added before
if (util.isLayoutAvailable("tala") || util.isFileOnPath(talaPluginName)) {
if (layouts.indexOf(layoutTala) === -1) {
layouts.push(layoutTala);
}
Expand Down
15 changes: 15 additions & 0 deletions src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ class Utility {
util.showErrorToolsNotFound("");
}
}

/**
* isLayoutAvailable - returns true if `d2 layout` reports the given
* layout engine, whether it is bundled with d2 or installed as a
* plugin on the path.
*/
isLayoutAvailable(layout: string): boolean {
const d2Path: string = ws.get("execPath", "d2");
const result = spawnSync(d2Path, ["layout"], { encoding: "utf-8" });
if (result.error || result.status !== 0) {
return false;
}

return new RegExp(`^${layout}\\b`, "m").test(result.stdout);
}
}

export class VT {
Expand Down