mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Allow markdown in issue/patch titles
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import dompurify from "dompurify";
|
||||
import { marked } from "marked";
|
||||
|
||||
import { renderer } from "@app/lib/markdown";
|
||||
import { twemoji } from "@app/lib/utils";
|
||||
|
||||
export let content: string;
|
||||
export let fontSize: "small" | "medium" = "small";
|
||||
|
||||
marked.use({ renderer });
|
||||
|
||||
const render = (content: string): string =>
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
dompurify.sanitize(marked.parseInline(content), { SANITIZE_DOM: false });
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.markdown :global(code) {
|
||||
font-family: var(--font-family-monospace);
|
||||
color: var(--color-foreground-6);
|
||||
background-color: var(--color-foreground-3);
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.125rem 0.25rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<span
|
||||
class="markdown"
|
||||
use:twemoji
|
||||
class:txt-medium={fontSize === "medium"}
|
||||
class:txt-small={fontSize === "small"}>
|
||||
{@html render(content)}
|
||||
</span>
|
||||
@@ -17,7 +17,7 @@
|
||||
export let content: string;
|
||||
export let hash: string | null = null;
|
||||
export let path: string = "/";
|
||||
export let rawPath: string;
|
||||
export let rawPath: string | undefined = undefined;
|
||||
|
||||
$: doc = matter(content);
|
||||
$: frontMatter = Object.entries(doc.data).filter(
|
||||
@@ -57,16 +57,18 @@
|
||||
|
||||
// Iterate over all images, and replace the source with a canonicalized URL
|
||||
// pointing at the projects /raw endpoint.
|
||||
for (const i of container.querySelectorAll("img")) {
|
||||
const imagePath = i.getAttribute("src");
|
||||
if (rawPath) {
|
||||
for (const i of container.querySelectorAll("img")) {
|
||||
const imagePath = i.getAttribute("src");
|
||||
|
||||
// Make sure the source isn't a URL before trying to fetch it from the repo
|
||||
if (
|
||||
imagePath &&
|
||||
!isUrl(imagePath) &&
|
||||
!imagePath.startsWith(`${base}twemoji`)
|
||||
) {
|
||||
i.setAttribute("src", `${rawPath}/${canonicalize(imagePath, path)}`);
|
||||
// Make sure the source isn't a URL before trying to fetch it from the repo
|
||||
if (
|
||||
imagePath &&
|
||||
!isUrl(imagePath) &&
|
||||
!imagePath.startsWith(`${base}twemoji`)
|
||||
) {
|
||||
i.setAttribute("src", `${rawPath}/${canonicalize(imagePath, path)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import Clipboard from "@app/components/Clipboard.svelte";
|
||||
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
|
||||
import TextInput from "@app/components/TextInput.svelte";
|
||||
|
||||
export let action: "create" | "edit" | "view" = "view";
|
||||
@@ -67,7 +68,9 @@
|
||||
<TextInput transparent variant="form" bind:value={title} />
|
||||
{:else}
|
||||
{#if title}
|
||||
<span class="txt-medium title">{title}</span>
|
||||
<div class="title">
|
||||
<InlineMarkdown fontSize="medium" content={title} />
|
||||
</div>
|
||||
{:else}
|
||||
<span class="txt-missing">No title</span>
|
||||
{/if}
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
<script lang="ts">
|
||||
import type { Commit } from "@httpd-client";
|
||||
|
||||
import { formatCommit, twemoji } from "@app/lib/utils";
|
||||
|
||||
import * as router from "@app/lib/router";
|
||||
import { formatCommit } from "@app/lib/utils";
|
||||
|
||||
import Changeset from "@app/views/projects/SourceBrowser/Changeset.svelte";
|
||||
import Clipboard from "@app/components/Clipboard.svelte";
|
||||
import CommitAuthorship from "@app/views/projects/Commit/CommitAuthorship.svelte";
|
||||
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
|
||||
|
||||
export let commit: Commit;
|
||||
|
||||
const { commit: header } = commit;
|
||||
const onBrowse = (event: { detail: string }) => {
|
||||
router.updateProjectRoute({
|
||||
view: { resource: "tree" },
|
||||
path: event.detail,
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -56,7 +49,9 @@
|
||||
<div class="commit">
|
||||
<div class="header">
|
||||
<div class="summary">
|
||||
<div class="txt-medium txt-bold" use:twemoji>{header.summary}</div>
|
||||
<div class="txt-medium txt-bold">
|
||||
<InlineMarkdown fontSize="medium" content={header.summary} />
|
||||
</div>
|
||||
<div class="layout-desktop-flex txt-monospace sha1">
|
||||
<span>{header.id}</span>
|
||||
<Clipboard small text={header.id} />
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import CommitAuthorship from "./CommitAuthorship.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let commit: CommitHeader;
|
||||
@@ -78,7 +79,7 @@
|
||||
search: undefined,
|
||||
}}>
|
||||
<div class="summary" use:twemoji>
|
||||
{commit.summary}
|
||||
<InlineMarkdown content={commit.summary} />
|
||||
</div>
|
||||
</ProjectLink>
|
||||
<CommitAuthorship header={commit} />
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import Authorship from "@app/components/Authorship.svelte";
|
||||
import Badge from "@app/components/Badge.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let issue: Issue;
|
||||
@@ -118,7 +119,9 @@
|
||||
params: { issue: issue.id },
|
||||
},
|
||||
}}>
|
||||
<span class="issue-title">{issue.title}</span>
|
||||
<span class="issue-title">
|
||||
<InlineMarkdown content={issue.title} />
|
||||
</span>
|
||||
</ProjectLink>
|
||||
<span class="tags">
|
||||
{#each issue.tags.slice(0, 4) as tag}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import Badge from "@app/components/Badge.svelte";
|
||||
import DiffStatBadge from "@app/components/DiffStatBadge.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let projectId: string;
|
||||
@@ -127,7 +128,9 @@
|
||||
params: { patch: patch.id },
|
||||
},
|
||||
}}>
|
||||
<span class="patch-title">{patch.title}</span>
|
||||
<span class="patch-title">
|
||||
<InlineMarkdown content={patch.title} />
|
||||
</span>
|
||||
</ProjectLink>
|
||||
<span class="tags">
|
||||
{#each patch.tags.slice(0, 4) as tag}
|
||||
|
||||
Reference in New Issue
Block a user