feat: add configuration to open exported file by system default app (#636)

* feat: add configuration to open exported file by system default application

* dev: update description

* fix: config key
This commit is contained in:
Myriad-Dreamin 2024-10-06 23:22:04 +08:00 committed by GitHub
parent d6fae74773
commit d4492e0436
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 7 deletions

View file

@ -106,11 +106,16 @@ Set the print width for the formatter, which is a **soft limit** of characters p
- **Type**: `number`
- **Default**: `120`
## `tinymist.showExportFileIn`
Configures way of opening exported files, e.g. inside of editor tabs or using system application.
## `tinymist.dragAndDrop`
Whether to handle drag-and-drop of resources into the editing typst document.
Whether to handle drag-and-drop of resources into the editing typst document. Note: restarting the editor is required to change this setting.
- **Type**: `boolean`
- **Type**: `string`
- **Enum**:
- `enable`
- `disable`

View file

@ -396,6 +396,25 @@
"type": "number",
"default": 120
},
"tinymist.showExportFileIn": {
"title": "(Experimental) Show Exported Files in Some Place",
"description": "Configures way of opening exported files, e.g. inside of editor tabs or using system application.",
"anyOf": [
{
"type": "string",
"description": "For all kind of files.",
"enum": [
"editorTab",
"systemDefault"
],
"default": "editorTab",
"enumDescriptions": [
"Show the exported files in editor tabs.",
"Show the exported files by system default application."
]
}
]
},
"tinymist.dragAndDrop": {
"title": "Drag and drop",
"description": "Whether to handle drag-and-drop of resources into the editing typst document. Note: restarting the editor is required to change this setting.",

View file

@ -457,11 +457,22 @@ async function commandShow(kind: "Pdf" | "Svg" | "Png", extraOpts?: any): Promis
}
}
// here we can be sure that the pdf exists
await commands.executeCommand("vscode.open", exportUri, {
viewColumn: ViewColumn.Beside,
preserveFocus: true,
} as vscode.TextDocumentShowOptions);
const conf = vscode.workspace.getConfiguration("tinymist");
const openIn: string = conf.get("showExportFileIn", "editorTab");
switch (openIn) {
default:
case "editorTab":
// here we can be sure that the pdf exists
await commands.executeCommand("vscode.open", exportUri, {
viewColumn: ViewColumn.Beside,
preserveFocus: true,
} as vscode.TextDocumentShowOptions);
break;
case "systemDefault":
await vscode.env.openExternal(exportUri);
break;
}
}
export interface PreviewResult {