Skip to content

Commit b713daa

Browse files
authored
fix(tiptap-editor): delete link from editor (#700)
1 parent 81667f5 commit b713daa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

apps/web/src/components/editor/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const Editor = memo(
6363
initialContent={initialValue}
6464
editorProps={{
6565
attributes: {
66-
class: `prose dark:prose-invert focus:outline-none max-w-full text-base-12 prose-p:my-0 prose-a:decoration-blue-9`,
66+
class: `prose dark:prose-invert focus:outline-none max-w-full text-base-12 prose-p:my-0 prose-a:decoration-blue-9 prose-a:cursor-pointer`,
6767
role: 'textbox',
6868
id: 'rich-editor'
6969
},

apps/web/src/components/editor/selectors.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
import { Button } from '../shadcn-ui/button';
2929
import { useEffect, useRef } from 'react';
3030
import { cn } from '@/src/lib/utils';
31+
import { toast } from 'sonner';
3132

3233
export const TextButtons = () => {
3334
const { editor } = useEditor();
@@ -210,6 +211,9 @@ export function getUrlFromString(str: string) {
210211
try {
211212
if (str.includes('.') && !str.includes(' ')) {
212213
return new URL(`https://${str}`).toString();
214+
} else {
215+
toast.error('Please enter a valid link');
216+
return null;
213217
}
214218
} catch (e) {
215219
return null;
@@ -279,7 +283,8 @@ export const LinkSelector = ({ open, onOpenChange }: LinkSelectorProps) => {
279283
variant="outline"
280284
type="button"
281285
className="text-red-6 hover:bg-red-1 dark:hover:bg-red-8 flex h-8 items-center rounded-sm p-1 transition-all"
282-
onClick={() => {
286+
onClick={(e) => {
287+
e.preventDefault();
283288
editor.chain().focus().unsetLink().run();
284289
onOpenChange(false);
285290
}}>

0 commit comments

Comments
 (0)