Skip to content

Commit 68f0a3c

Browse files
ndom91yerkeCaleb-T-OwensPavelLaptevmtsgrd
authored
fix: use our own open-rs implementation instead of relying on tauri's "shell-open" (#4748)
Co-authored-by: Yerke Tulibergenov <[email protected]> Co-authored-by: Caleb Owens <[email protected]> Co-authored-by: Pavel Laptev <[email protected]> Co-authored-by: Mattias Granlund <[email protected]> Co-authored-by: Sebastian Thiel <[email protected]> Co-authored-by: GitButler <[email protected]>
1 parent 6fdcf9f commit 68f0a3c

39 files changed

+429
-219
lines changed

Cargo.lock

Lines changed: 2 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/src/lib/barmenuActions/ProjectSettingsMenuAction.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as events from '$lib/utils/events';
77
import { createKeybind } from '$lib/utils/hotkeys';
88
import { unsubscribe } from '$lib/utils/unsubscribe';
9-
import { open } from '@tauri-apps/api/shell';
9+
import { openExternalUrl } from '$lib/utils/url';
1010
import { onMount } from 'svelte';
1111
import { goto } from '$app/navigation';
1212
@@ -29,7 +29,7 @@
2929
'menu://project/open-in-vscode/clicked',
3030
async () => {
3131
const path = `${$editor}://file${project.vscodePath}?windowId=_blank`;
32-
open(path);
32+
openExternalUrl(path);
3333
}
3434
);
3535

apps/desktop/src/lib/components/AIPromptEdit/DialogBubble.svelte

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<script lang="ts">
22
import { MessageRole } from '$lib/ai/types';
3+
import Markdown from '$lib/components/Markdown.svelte';
34
import { autoHeight } from '$lib/utils/autoHeight';
4-
import { getMarkdownRenderer } from '$lib/utils/markdown';
55
import Button from '@gitbutler/ui/Button.svelte';
66
import Icon from '@gitbutler/ui/Icon.svelte';
7-
import { marked } from 'marked';
87
import { createEventDispatcher } from 'svelte';
98
109
export let disableRemove = false;
@@ -19,7 +18,6 @@
1918
addExample: void;
2019
input: string;
2120
}>();
22-
const markedRenderer = getMarkdownRenderer();
2321
let textareaElement: HTMLTextAreaElement | undefined;
2422
2523
function focusTextareaOnMount(
@@ -73,7 +71,7 @@
7371
></textarea>
7472
{:else}
7573
<div class="markdown bubble-message scrollbar text-13 text-body">
76-
{@html marked.parse(promptMessage.content, { renderer: markedRenderer })}
74+
<Markdown content={promptMessage.content} />
7775
</div>
7876
{/if}
7977
</div>

apps/desktop/src/lib/components/BoardEmptyState.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@
5050
</div>
5151
<button
5252
class="empty-board__suggestions__link"
53-
on:click={async () =>
54-
await openExternalUrl(
55-
'https://docs.gitbutler.com/features/virtual-branches/branch-lanes'
56-
)}
53+
on:click={async () => await openExternalUrl('https://docs.gitbutler.com')}
5754
>
5855
<div class="empty-board__suggestions__link__icon">
5956
<Icon name="docs" />

apps/desktop/src/lib/components/BranchPreview.svelte

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44
import { Project } from '$lib/backend/projects';
55
import CommitCard from '$lib/commit/CommitCard.svelte';
66
import { transformAnyCommit } from '$lib/commitLines/transformers';
7+
import Markdown from '$lib/components/Markdown.svelte';
78
import FileCard from '$lib/file/FileCard.svelte';
89
import { getGitHost } from '$lib/gitHost/interface/gitHost';
910
import ScrollableContainer from '$lib/scroll/ScrollableContainer.svelte';
1011
import { SETTINGS, type Settings } from '$lib/settings/userSettings';
1112
import { RemoteBranchService } from '$lib/stores/remoteBranches';
1213
import { getContext, getContextStoreBySymbol } from '$lib/utils/context';
13-
import { getMarkdownRenderer } from '$lib/utils/markdown';
1414
import { FileIdSelection } from '$lib/vbranches/fileIdSelection';
1515
import { BranchData, type Branch } from '$lib/vbranches/types';
1616
import LineGroup from '@gitbutler/ui/commitLines/LineGroup.svelte';
1717
import { LineManagerFactory } from '@gitbutler/ui/commitLines/lineManager';
1818
import lscache from 'lscache';
19-
import { marked } from 'marked';
2019
import { onMount, setContext } from 'svelte';
2120
import { writable } from 'svelte/store';
2221
import type { PullRequest } from '$lib/gitHost/interface/types';
@@ -93,8 +92,6 @@
9392
onMount(() => {
9493
laneWidth = lscache.get(laneWidthKey);
9594
});
96-
97-
const renderer = getMarkdownRenderer();
9895
</script>
9996

10097
{#if remoteBranch || localBranch}
@@ -112,7 +109,7 @@
112109
<div class="card__header text-14 text-body text-semibold">{pr.title}</div>
113110
{#if pr.body}
114111
<div class="markdown card__content text-13 text-body">
115-
{@html marked.parse(pr.body, { renderer })}
112+
<Markdown content={pr.body} />
116113
</div>
117114
{/if}
118115
</div>

apps/desktop/src/lib/components/DecorativeSplitView.svelte

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import gbLogoSvg from '$lib/assets/gb-logo.svg?raw';
44
import { User } from '$lib/stores/user';
55
import { getContextStore } from '$lib/utils/context';
6+
import { openExternalUrl } from '$lib/utils/url';
67
import Icon from '@gitbutler/ui/Icon.svelte';
78
import { type Snippet } from 'svelte';
89
@@ -68,22 +69,20 @@
6869

6970
<div class="right-side__meta">
7071
<div class="right-side__links">
71-
<a
72+
<button
7273
class="right-side__link"
73-
target="_blank"
74-
href="https://docs.gitbutler.com/features/virtual-branches/branch-lanes"
74+
onclick={async () => await openExternalUrl('https://docs.gitbutler.com/')}
7575
>
7676
<Icon name="docs" opacity={0.6} />
7777
<span class="text-14 text-semibold">GitButler docs</span>
78-
</a>
79-
<a
78+
</button>
79+
<button
8080
class="right-side__link"
81-
target="_blank"
82-
href="https://discord.com/invite/MmFkmaJ42D"
81+
onclick={async () => await openExternalUrl('https://discord.com/invite/MmFkmaJ42D')}
8382
>
8483
<Icon name="discord" opacity={0.6} />
8584
<span class="text-14 text-semibold">Join community</span>
86-
</a>
85+
</button>
8786
</div>
8887

8988
<div class="wordmark">
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script lang="ts">
2+
import MarkdownContent from '$lib/components/MarkdownContent.svelte';
3+
import { options } from '$lib/utils/markdownRenderers';
4+
import { Lexer } from 'marked';
5+
6+
interface Props {
7+
content: string;
8+
}
9+
10+
let { content }: Props = $props();
11+
12+
const lexer = new Lexer(options);
13+
const tokens = lexer.lex(content);
14+
</script>
15+
16+
<div class="markdown-content">
17+
<MarkdownContent type="init" {tokens} />
18+
</div>
19+
20+
<style>
21+
.markdown-content {
22+
display: inline;
23+
}
24+
</style>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<script lang="ts">
2+
/* eslint svelte/valid-compile: "off" */
3+
import { renderers } from '$lib/utils/markdownRenderers';
4+
import type { Tokens, Token } from 'marked';
5+
6+
type Props =
7+
| { type: 'init'; tokens: Token[] }
8+
| Tokens.Link
9+
| Tokens.Heading
10+
| Tokens.Image
11+
| Tokens.Space
12+
| Tokens.Blockquote
13+
| Tokens.Code
14+
| Tokens.Codespan
15+
| Tokens.Text;
16+
17+
let { type, ...rest }: Props = $props();
18+
</script>
19+
20+
{#if type && renderers[type as keyof typeof renderers]}
21+
<svelte:component this={renderers[type as keyof typeof renderers] as any} {...rest}>
22+
{#if 'tokens' in rest}
23+
<svelte:self tokens={rest.tokens} />
24+
{/if}
25+
</svelte:component>
26+
{:else if 'tokens' in rest && rest.tokens}
27+
{#each rest.tokens as token}
28+
<svelte:self {...token} />
29+
{/each}
30+
{:else if 'raw' in rest}
31+
{@html rest.raw?.replaceAll('\n', '<br />') ?? ''}
32+
{/if}

0 commit comments

Comments
 (0)