Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add editor button to open the documentation preview #1290

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
Binary file removed assets/icon-font.woff
Binary file not shown.
13 changes: 13 additions & 0 deletions assets/icons/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Custom Icons for the Swift extension

This folder contains custom iconography used in various sections of the Swift extension for VS Code.

All icons are compiled into a single icon font using [IcoMoon](https://icomoon.io/app). The icons must be placed at the following codes within the font file:

```
\\E001 - swift-icon
\\E002 - swift-documentation
\\E003 - swift-documentation-preview
```

Any newly added icons will need to be added to the icons contribution point in the [package.json](../../package.json) for them to be usable from within the extension.
6 changes: 6 additions & 0 deletions assets/icons/dark/swift-documentation-preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/icons/dark/swift-documentation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon-font.woff
Binary file not shown.
6 changes: 6 additions & 0 deletions assets/icons/light/swift-documentation-preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/icons/light/swift-documentation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/swift-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 24 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,23 @@
"swift-icon": {
"description": "The official icon for the Swift programming language",
"default": {
"fontPath": "assets/icon-font.woff",
"fontPath": "assets/icons/icon-font.woff",
"fontCharacter": "\\E001"
}
},
"swift-documentation": {
"description": "The icon for the Swift documentation preview editor",
"default": {
"fontPath": "assets/icons/icon-font.woff",
"fontCharacter": "\\E002"
}
},
"swift-documentation-preview": {
"description": "The icon used as a button for showing the Swift documentation preview editor",
"default": {
"fontPath": "assets/icons/icon-font.woff",
"fontCharacter": "\\E003"
}
}
},
"terminal": {
Expand Down Expand Up @@ -88,7 +102,8 @@
{
"command": "swift.previewDocumentation",
"title": "Preview Documentation",
"category": "Swift"
"category": "Swift",
"icon": "$(swift-documentation-preview)"
},
{
"command": "swift.createNewProject",
Expand Down Expand Up @@ -779,6 +794,13 @@
"submenu": "swift.editor"
}
],
"editor/title": [
{
"command": "swift.previewDocumentation",
"when": "swift.supportsDocumentationLivePreview && (editorLangId == markdown || editorLangId == tutorial || editorLangId == swift)",
"group": "navigation"
}
],
"swift.editor": [
{
"command": "swift.run",
Expand Down
12 changes: 12 additions & 0 deletions src/documentation/DocumentationPreviewEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ export class DocumentationPreviewEditor implements vscode.Disposable {
],
}
);
webviewPanel.iconPath = {
light: vscode.Uri.file(
extension.asAbsolutePath(
path.join("assets", "icons", "light", "swift-documentation.svg")
)
),
dark: vscode.Uri.file(
extension.asAbsolutePath(
path.join("assets", "icons", "dark", "swift-documentation.svg")
)
),
};
const webviewBaseURI = webviewPanel.webview.asWebviewUri(
vscode.Uri.file(swiftDoccRenderPath)
);
Expand Down
Loading