Skip to content

Commit

Permalink
feat: add configuration to open exported file by system default app (#…
Browse files Browse the repository at this point in the history
…636)

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

* dev: update description

* fix: config key
  • Loading branch information
Myriad-Dreamin authored Oct 6, 2024
1 parent d6fae74 commit d4492e0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
9 changes: 7 additions & 2 deletions editors/vscode/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
19 changes: 19 additions & 0 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
21 changes: 16 additions & 5 deletions editors/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d4492e0

Please sign in to comment.