mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 18:28:02 +00:00
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:
parent
d6fae74773
commit
d4492e0436
3 changed files with 42 additions and 7 deletions
|
@ -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`
|
||||
|
|
|
@ -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.",
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue