#778 - Open file or webpage

This commit is contained in:
Elio Struyf
2024-03-19 12:24:08 +01:00
parent 3a74c14ba6
commit 3842777f71
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -10,6 +10,7 @@
- [#773](https://github.com/estruyf/vscode-front-matter/issues/773): Added the ability to rename content files
- [#777](https://github.com/estruyf/vscode-front-matter/issues/777): Show an error in the metadata panel if something went wrong while parsing the front matter
- [#778](https://github.com/estruyf/vscode-front-matter/issues/778): Added the ability to open a file or webpage when custom scripts is completed
### ⚡️ Optimizations
+6 -1
View File
@@ -1,7 +1,7 @@
import { Settings } from './SettingsHelper';
import { CommandType, EnvironmentType } from './../models/PanelSettings';
import { CustomScript as ICustomScript, ScriptType } from '../models/PanelSettings';
import { window, env as vscodeEnv, ProgressLocation } from 'vscode';
import { window, env as vscodeEnv, ProgressLocation, Uri, commands } from 'vscode';
import { ArticleHelper, Logger, Telemetry } from '.';
import { Folders, WORKSPACE_PLACEHOLDER } from '../commands/Folders';
import { exec, execSync } from 'child_process';
@@ -301,6 +301,11 @@ export class CustomScript {
l10n.t(LocalizationKey.helpersCustomScriptShowOutputFrontMatterSuccess, script.title)
);
}
} else if (data.fmAction) {
if (data.fmAction === 'open' && data.fmPath) {
const uri = data.fmPath.startsWith(`http`) ? data.fmPath : Uri.file(data.fmPath);
commands.executeCommand('vscode.open', uri);
}
} else {
Logger.error(`No frontmatter found.`);
throw new Error(`No frontmatter found.`);