-
-
Notifications
You must be signed in to change notification settings - Fork 100
reimplement button-to-open-in-new-tab + custom webview #133 (monorepo) #152
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5a44265
reimplement #133 in the monorepo setup
kevinramharak 02af660
port the changes of web-preview-poc; integrate vscode-shiki-bridge
kevinramharak d8b76f6
stich everything together
kevinramharak 88685a6
Get the feature working
kevinramharak d234df9
implement webview as seperate files, implement csp with a lot of head…
kevinramharak 17b4105
finalize implementation
kevinramharak de28d44
implement the webviewviewprovider
kevinramharak 20215ab
Merge branch 'main' into feature/107-button-to-open-error-in-new-tab
kevinramharak 26473c4
Merge branch 'main' into feature/107-button-to-open-error-in-new-tab
kevinramharak 4147c36
finalize webview parts
kevinramharak 5bf4f08
remove obsolete files
kevinramharak 3fafd38
remove obsolete file
kevinramharak b6a80b9
implement proper markdown rendering
kevinramharak 918aa87
bump vscode-shiki-bridge to v0.3.0
yoavbls f462b2b
implement vscode-shiki-bridge
kevinramharak 31caba3
Few minor fixes
yoavbls 446eb30
fix copy type button
kevinramharak 56fad21
only hide new tab button in the new tab markdown preview
kevinramharak 6700a52
use whitelisted badge urls
kevinramharak 5a58f7b
avoid triggering complete rerenders of the webview
kevinramharak 1a08df3
decrease vertical padding
kevinramharak f0b4eaa
keep track of shown diagnostic per webview, to ensure the panel is re…
kevinramharak 70c7002
add missing .delete on the weakmap
kevinramharak 313b39e
add another .delete to onDidDispose to prevent leaking memory
kevinramharak 29b25c1
fix background color of the panel preview variant
kevinramharak a0b6363
bump version in lock
yoavbls f87072f
Remove icons not in use to reduce size
yoavbls File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { commands, env, window, type ExtensionContext } from "vscode"; | ||
|
|
||
| export function registerCopyError(context: ExtensionContext) { | ||
| context.subscriptions.push( | ||
| commands.registerCommand( | ||
| "prettyTsErrors.copyError", | ||
| async (errorMessage: string) => { | ||
| await env.clipboard.writeText(errorMessage); | ||
| window.showInformationMessage("Copied error message to clipboard!"); | ||
| } | ||
| ) | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { | ||
| type ExtensionContext, | ||
| commands, | ||
| Range, | ||
| TabInputText, | ||
| TabInputWebview, | ||
| Uri, | ||
| ViewColumn, | ||
| window, | ||
| } from "vscode"; | ||
| import { MarkdownWebviewProvider } from "../provider/markdownWebviewProvider"; | ||
|
|
||
| export function registerRevealSelection(context: ExtensionContext) { | ||
| context.subscriptions.push( | ||
| commands.registerCommand( | ||
| "prettyTsErrors.revealSelection", | ||
| async (uri: Uri, range: Range) => { | ||
| // ensure these are real instances | ||
| uri = Uri.from({ ...uri }); | ||
| range = new Range( | ||
| range.start.line, | ||
| range.start.character, | ||
| range.end.line, | ||
| range.end.character | ||
| ); | ||
|
|
||
| // default behaviour is to use the active view column | ||
| let viewColumn = ViewColumn.Active; | ||
|
|
||
| // detect if the active tab is our preview webview | ||
| let isFromMarkdownPreviewWebview = false; | ||
| const activeTab = window.tabGroups.activeTabGroup.activeTab; | ||
| if (activeTab && activeTab.input instanceof TabInputWebview) { | ||
| // For an unknown reason this string is prefixed with something like `mainthread-${viewType}` | ||
| // endsWith should handle a full match and the prefixed versions | ||
| if ( | ||
| activeTab.input.viewType.endsWith(MarkdownWebviewProvider.viewType) | ||
| ) { | ||
| isFromMarkdownPreviewWebview = true; | ||
| } | ||
| } | ||
|
|
||
| if (isFromMarkdownPreviewWebview) { | ||
| // find a tab group where the file is open, then use that view column for the `vscode.open` command | ||
| const tabs = window.tabGroups.all.flatMap( | ||
| (tabGroup) => tabGroup.tabs | ||
| ); | ||
| const tabWithFileOpen = tabs.find((tab) => { | ||
| if (tab.input instanceof TabInputText) { | ||
| return tab.input.uri.toString() === uri.toString(); | ||
| } | ||
| return false; | ||
| }); | ||
| if (tabWithFileOpen) { | ||
| viewColumn = tabWithFileOpen.group.viewColumn; | ||
| } else { | ||
| // If markdown preview is not open on 1, open the link in 1, else open the link in 2 | ||
| viewColumn = | ||
| activeTab!.group.viewColumn !== 1 | ||
| ? ViewColumn.One | ||
| : ViewColumn.Two; | ||
| } | ||
| } | ||
|
|
||
| return commands.executeCommand("vscode.open", uri, { | ||
| selection: range, | ||
| viewColumn, | ||
| }); | ||
| } | ||
| ) | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you want your contribution.md file to have developer setup instructions for getting debugging environment up and running. The dev setup has changed a bit since the mono repo update. But also this change might be out of scope of this pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought there was an issue for this, but I cant find it. This is indeed on the todo list after the monorepo setup. I will do this next, as it is intended to easily setup and contribute to this repo