Skip to content

Commit

Permalink
feat: Add underline (#5)
Browse files Browse the repository at this point in the history
* feat: Add underline

* fix: Fix underline bug
  • Loading branch information
code0xff authored Jul 21, 2024
1 parent 547700c commit 266451e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@tiptap/extension-link": "^2.1.16",
"@tiptap/extension-placeholder": "^2.1.16",
"@tiptap/extension-text-align": "^2.1.16",
"@tiptap/extension-underline": "^2.5.4",
"@tiptap/extension-youtube": "^2.5.4",
"@tiptap/pm": "^2.1.16",
"@tiptap/starter-kit": "^2.1.16",
Expand Down
18 changes: 17 additions & 1 deletion src/lib/editor/editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
Undo,
ScreenShare,
ScreenShareOff,
MonitorPlay
MonitorPlay,
Underline
} from 'lucide-svelte';
import {
addImage,
Expand Down Expand Up @@ -179,6 +180,14 @@
>
<Italic class="h-4 w-4" />
</Button>
<Button
on:click={() => editor.chain().focus().toggleUnderline().run()}
disabled={!editor.can().chain().focus().toggleUnderline().run()}
variant={editor.isActive('underline') ? 'default' : 'secondary'}
class="mx-0.5 h-8 px-2"
>
<Underline class="h-4 w-4" />
</Button>
<Button
on:click={() => editor.chain().focus().toggleStrike().run()}
disabled={!editor.can().chain().focus().toggleStrike().run()}
Expand Down Expand Up @@ -408,6 +417,13 @@
>
<Strikethrough class="h-4 w-4" />
</Button>
<Button
on:click={() => editor.chain().focus().toggleUnderline().run()}
variant={editor.isActive('underline') ? 'default' : 'secondary'}
class="h-8 px-2"
>
<Underline class="h-4 w-4" />
</Button>
<Button
on:click={() => editor.chain().focus().toggleCode().run()}
variant={editor.isActive('code') ? 'default' : 'secondary'}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/editor/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TextAlign from "@tiptap/extension-text-align";
import StarterKit from "@tiptap/starter-kit";
import Image from '@tiptap/extension-image';
import Youtube from "@tiptap/extension-youtube";
import Underline from "@tiptap/extension-underline";

export function getExtensions(bubbleMenu: HTMLElement) {
return [
Expand All @@ -25,6 +26,7 @@ export function getExtensions(bubbleMenu: HTMLElement) {
Placeholder,
Youtube.configure({
inline: true
})
}),
Underline
];
}
4 changes: 3 additions & 1 deletion src/lib/editor/sharing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import StarterKit from "@tiptap/starter-kit";
import Link from "@tiptap/extension-link";
import Image from '@tiptap/extension-image';
import Youtube from "@tiptap/extension-youtube";
import Underline from "@tiptap/extension-underline";

export function getExtensionsOnSharing(provider: HocuspocusProvider, bubbleMenu: HTMLElement) {
return [
Expand All @@ -32,6 +33,7 @@ export function getExtensionsOnSharing(provider: HocuspocusProvider, bubbleMenu:
Placeholder,
Youtube.configure({
inline: true
})
}),
Underline
]
}

0 comments on commit 266451e

Please sign in to comment.