Skip to content

Commit 4f9b6b5

Browse files
committed
pr comments - get shift click working for links, remove extension comments
1 parent c4fa96e commit 4f9b6b5

File tree

4 files changed

+18
-39
lines changed

4 files changed

+18
-39
lines changed

src/components/ui/coaching-sessions/coaching-notes.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ const CoachingNotes = () => {
115115
class:
116116
"tiptap ProseMirror shadow appearance-none lg:min-h-[440px] sm:min-h-[200px] md:min-h-[350px] rounded w-full py-2 px-3 bg-inherit text-black dark:text-white text-sm mt-0 md:mt-3 leading-tight focus:outline-none focus:shadow-outline",
117117
},
118+
handleDOMEvents: {
119+
click: (view, event) => {
120+
const target = event.target as HTMLElement;
121+
122+
// Check if the clicked element is an <a> tag and Shift is pressed
123+
if (target.tagName === "A" && event.shiftKey) {
124+
event.preventDefault(); // Prevent default link behavior
125+
window
126+
.open(target.getAttribute("href") || "", "_blank")
127+
?.focus();
128+
return true; // Stop event propagation
129+
}
130+
return false; // Allow other handlers to process the event
131+
},
132+
},
118133
}}
119134
slotBefore={<Toolbar />}
120135
/>

src/components/ui/coaching-sessions/coaching-notes/extended-link-extension.tsx

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,6 @@ export const ConfiguredLink = LinkWithTitle.configure({
3636
return false;
3737
}
3838

39-
// Placeholder for future disallowed domains if we want to add any
40-
// const disallowedProtocols = ["ftp", "file", "mailto"];
41-
// const protocol = parsedUrl.protocol.replace(":", "");
42-
43-
// if (disallowedProtocols.includes(protocol)) {
44-
// return false;
45-
// }
46-
47-
// // only allow protocols specified in ctx.protocols
48-
// const allowedProtocols = ctx.protocols.map((p) =>
49-
// typeof p === "string" ? p : p.scheme
50-
// );
51-
52-
// if (!allowedProtocols.includes(protocol)) {
53-
// return false;
54-
// }
55-
56-
// Placeholder for future disallowed domains if we want to add any
57-
// const disallowedDomains = [
58-
// "example-phishing.com",
59-
// "malicious-site.net",
60-
// ];
61-
// const domain = parsedUrl.hostname;
62-
63-
// if (disallowedDomains.includes(domain)) {
64-
// return false;
65-
// }
66-
6739
// all checks have passed
6840
return true;
6941
} catch {
@@ -77,14 +49,7 @@ export const ConfiguredLink = LinkWithTitle.configure({
7749
? new URL(url)
7850
: new URL(`https://${url}`);
7951

80-
// only auto-link if the domain is not in the disallowed list
81-
const disallowedDomains = [
82-
"example-no-autolink.com",
83-
"another-no-autolink.com",
84-
];
85-
const domain = parsedUrl.hostname;
86-
87-
return !disallowedDomains.includes(domain);
52+
return !!parsedUrl;
8853
} catch {
8954
return false;
9055
}

src/components/ui/coaching-sessions/coaching-notes/extensions.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Paragraph from "@tiptap/extension-paragraph";
1111
import Strike from "@tiptap/extension-strike";
1212
import Text from "@tiptap/extension-text";
1313
import Underline from "@tiptap/extension-underline";
14-
import Link from "@tiptap/extension-link";
1514
import Collaboration from "@tiptap/extension-collaboration";
1615
import { ReactNodeViewRenderer } from "@tiptap/react";
1716
import CodeBlock from "@/components/ui/coaching-sessions/code-block";

src/components/ui/coaching-sessions/coaching-notes/toolbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ export const Toolbar = () => {
119119
icon={<Link className="h-4 w-4" />}
120120
title={
121121
editor.isActive("link")
122-
? "Update link (Ctrl + k)"
123-
: "Insert link (Ctrl + k)"
122+
? "Update Link (Ctrl + k)"
123+
: "Insert Link (Ctrl + k)"
124124
}
125125
/>
126126
</div>

0 commit comments

Comments
 (0)