mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-26 18:28:35 +02:00
Move to TanStack Start from Next.js (#184)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import type { Editor } from "@tiptap/react"
|
||||
import { BubbleMenu } from "@tiptap/react"
|
||||
import { ImagePopoverBlock } from "../image/image-popover-block"
|
||||
import { ShouldShowProps } from "../../types"
|
||||
|
||||
const ImageBubbleMenu = ({ editor }: { editor: Editor }) => {
|
||||
const shouldShow = ({ editor, from, to }: ShouldShowProps) => {
|
||||
if (from === to) {
|
||||
return false
|
||||
}
|
||||
|
||||
const img = editor.getAttributes("image")
|
||||
|
||||
if (img.src) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
const unSetImage = () => {
|
||||
editor.commands.deleteSelection()
|
||||
}
|
||||
|
||||
return (
|
||||
<BubbleMenu
|
||||
editor={editor}
|
||||
shouldShow={shouldShow}
|
||||
tippyOptions={{
|
||||
placement: "bottom",
|
||||
offset: [0, 8],
|
||||
}}
|
||||
>
|
||||
<ImagePopoverBlock onRemove={unSetImage} />
|
||||
</BubbleMenu>
|
||||
)
|
||||
}
|
||||
|
||||
export { ImageBubbleMenu }
|
||||
Reference in New Issue
Block a user