mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-24 01:08:36 +02:00
chore: Enhancement + New Feature (#185)
* wip * wip page * chore: style * wip pages * wip pages * chore: toggle * chore: link * feat: topic search * chore: page section * refactor: apply tailwind class ordering * fix: handle loggedIn user for guest route * feat: folder & image schema * chore: move utils to shared * refactor: tailwind class ordering * feat: img ext for editor * refactor: remove qa * fix: tanstack start * fix: wrong import * chore: use toast * chore: schema
This commit is contained in:
48
web/shared/editor/hooks/use-text-menu-commands.ts
Normal file
48
web/shared/editor/hooks/use-text-menu-commands.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import * as React from "react"
|
||||
import { Editor } from "@tiptap/react"
|
||||
|
||||
export const useTextmenuCommands = (editor: Editor) => {
|
||||
const onBold = React.useCallback(
|
||||
() => editor.chain().focus().toggleBold().run(),
|
||||
[editor],
|
||||
)
|
||||
const onItalic = React.useCallback(
|
||||
() => editor.chain().focus().toggleItalic().run(),
|
||||
[editor],
|
||||
)
|
||||
const onStrike = React.useCallback(
|
||||
() => editor.chain().focus().toggleStrike().run(),
|
||||
[editor],
|
||||
)
|
||||
const onCode = React.useCallback(
|
||||
() => editor.chain().focus().toggleCode().run(),
|
||||
[editor],
|
||||
)
|
||||
const onCodeBlock = React.useCallback(
|
||||
() => editor.chain().focus().toggleCodeBlock().run(),
|
||||
[editor],
|
||||
)
|
||||
const onQuote = React.useCallback(
|
||||
() => editor.chain().focus().toggleBlockquote().run(),
|
||||
[editor],
|
||||
)
|
||||
const onLink = React.useCallback(
|
||||
(url: string, inNewTab?: boolean) =>
|
||||
editor
|
||||
.chain()
|
||||
.focus()
|
||||
.setLink({ href: url, target: inNewTab ? "_blank" : "" })
|
||||
.run(),
|
||||
[editor],
|
||||
)
|
||||
|
||||
return {
|
||||
onBold,
|
||||
onItalic,
|
||||
onStrike,
|
||||
onCode,
|
||||
onCodeBlock,
|
||||
onQuote,
|
||||
onLink,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user