Merge branch 'feature/extension-floating-menu'
# Conflicts: # packages/react/package.json # packages/vue-2/package.json # packages/vue-3/package.json
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@tiptap/extension-bubble-menu": "^2.0.0-beta.4",
|
||||
"@tiptap/extension-floating-menu": "^2.0.0-beta.0",
|
||||
"prosemirror-view": "^1.18.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
29
packages/react/src/FloatingMenu.tsx
Normal file
29
packages/react/src/FloatingMenu.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
import { FloatingMenuPlugin, FloatingMenuPluginKey, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'
|
||||
|
||||
export type FloatingMenuProps = Omit<FloatingMenuPluginProps, 'element'> & {
|
||||
className?: string,
|
||||
}
|
||||
|
||||
export const FloatingMenu: React.FC<FloatingMenuProps> = props => {
|
||||
const element = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const { editor } = props
|
||||
|
||||
editor.registerPlugin(FloatingMenuPlugin({
|
||||
editor,
|
||||
element: element.current as HTMLElement,
|
||||
}))
|
||||
|
||||
return () => {
|
||||
editor.unregisterPlugin(FloatingMenuPluginKey)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div ref={element} className={props.className}>
|
||||
{props.children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
export * from '@tiptap/core'
|
||||
export * from './BubbleMenu'
|
||||
export { Editor } from './Editor'
|
||||
export * from './FloatingMenu'
|
||||
export * from './useEditor'
|
||||
export * from './ReactRenderer'
|
||||
export * from './ReactNodeViewRenderer'
|
||||
|
||||
Reference in New Issue
Block a user