Move to TanStack Start from Next.js (#184)

This commit is contained in:
Aslam
2024-10-07 16:44:17 +07:00
committed by GitHub
parent 3a89a1c07f
commit 950ebc3dad
514 changed files with 20021 additions and 15508 deletions

View 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,
}
}