Skip to content

Commit

Permalink
web: fix links in report issue dialog (streetwriters#7071)
Browse files Browse the repository at this point in the history
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
  • Loading branch information
01zulfi authored Dec 10, 2024
1 parent 1d78402 commit fea9c4e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
11 changes: 9 additions & 2 deletions apps/web/src/dialogs/issue-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,19 @@ export const IssueDialog = DialogManager.register(function IssueDialog(
<Link
href="https://github.com/streetwriters/notesnook/issues"
title="github.com/streetwriters/notesnook/issues"
/>{" "}
target="_blank"
>
github.com/streetwriters/notesnook/issues
</Link>
{strings.issueNotice[1]()}{" "}
<Link
href="https://discord.gg/zQBK97EE22"
title={strings.issueNotice[2]()}
/>
target="_blank"
>
{strings.issueNotice[2]()}
</Link>
/
</Text>
<Text variant="subBody" mt={1}>
{getDeviceInfo([`Pro: ${isUserPremium()}`])
Expand Down
18 changes: 17 additions & 1 deletion apps/web/src/utils/md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

import snarkdown from "snarkdown";

function addAttributes(
html: string,
tag: keyof HTMLElementTagNameMap,
attributes: Record<string, string>
) {
const temp = document.createElement("div");
temp.innerHTML = html;
const elements = temp.querySelectorAll(tag);
elements.forEach((element) => {
Object.entries(attributes).forEach(([key, value]) => {
element.setAttribute(key, value);
});
});
return temp.innerHTML;
}

export function mdToHtml(markdown: string) {
return snarkdown(markdown);
return addAttributes(snarkdown(markdown), "a", { target: "_blank" });
}

0 comments on commit fea9c4e

Please sign in to comment.