mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
@@ -2,18 +2,19 @@
|
||||
import type { Blob } from "@app/project";
|
||||
import type { ProjectRoute } from "@app/router/definitions";
|
||||
|
||||
import Readme from "@app/base/projects/Readme.svelte";
|
||||
import HeaderToggleLabel from "@app/base/projects/HeaderToggleLabel.svelte";
|
||||
import ProjectLink from "@app/router/ProjectLink.svelte";
|
||||
import Readme from "@app/base/projects/Readme.svelte";
|
||||
import { isMarkdownPath, scrollIntoView, twemoji } from "@app/utils";
|
||||
import { onMount } from "svelte";
|
||||
import { updateProjectRoute } from "@app/router";
|
||||
|
||||
export let blob: Blob;
|
||||
export let line: string | null;
|
||||
export let getImage: (path: string) => Promise<Blob>;
|
||||
export let activeRoute: ProjectRoute;
|
||||
export let blob: Blob;
|
||||
export let getImage: (path: string) => Promise<Blob>;
|
||||
export let line: string | undefined = undefined;
|
||||
|
||||
$: lineNumber = line ? parseInt(line.substring(1)) : null;
|
||||
$: lineNumber = line ? parseInt(line.substring(1)) : undefined;
|
||||
|
||||
const lastCommit = blob.info.lastCommit;
|
||||
const lines = blob.binary ? 0 : (blob.content.match(/\n/g) || []).length;
|
||||
@@ -25,16 +26,23 @@
|
||||
?.values()
|
||||
.next().value;
|
||||
|
||||
$: if (line) {
|
||||
scrollIntoView(line);
|
||||
}
|
||||
// Waiting onMount, due to the line numbers still loading.
|
||||
onMount(() => {
|
||||
if (line) {
|
||||
scrollIntoView(line);
|
||||
}
|
||||
});
|
||||
const isMarkdown = isMarkdownPath(blob.path);
|
||||
// If we have a line number we should show the raw output.
|
||||
let showMarkdown = line ? false : isMarkdown;
|
||||
const toggleMarkdown = () => {
|
||||
updateProjectRoute({ hash: undefined });
|
||||
updateProjectRoute({ line: undefined });
|
||||
showMarkdown = !showMarkdown;
|
||||
};
|
||||
|
||||
$: if (line) {
|
||||
scrollIntoView(line);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -215,7 +223,7 @@
|
||||
<div class="line-numbers">
|
||||
{#each lineNumbers as lineNumber}
|
||||
<ProjectLink
|
||||
projectParams={{ hash: `L${lineNumber}` }}
|
||||
projectParams={{ line: `L${lineNumber}` }}
|
||||
id="L{lineNumber}">
|
||||
<span class="line-number" class:highlighted={lineNumber === line} />
|
||||
{lineNumber}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
export let activeRoute: ProjectRoute;
|
||||
|
||||
$: path = activeRoute.params.path || "/";
|
||||
$: line = activeRoute.params.hash || null;
|
||||
$: line = activeRoute.params.line;
|
||||
|
||||
// When the component is loaded the first time, the blob is yet to be loaded.
|
||||
let state: State = { status: Status.Loading, path };
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
router.updateProjectRoute({
|
||||
revision,
|
||||
path,
|
||||
line: activeRoute.params.line,
|
||||
hash: activeRoute.params.hash,
|
||||
route: undefined,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user