fix: make shouldShow and pluginKey option for menus, fix #1779

This commit is contained in:
Philipp Kühn
2021-08-23 18:44:40 +02:00
parent 1618e8ee85
commit 70a328bd3d
4 changed files with 16 additions and 12 deletions

View File

@@ -1,7 +1,9 @@
import React, { useEffect, useRef } from 'react'
import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
export type BubbleMenuProps = Omit<BubbleMenuPluginProps, 'element'> & {
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
export type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {
className?: string,
}
@@ -10,10 +12,10 @@ export const BubbleMenu: React.FC<BubbleMenuProps> = props => {
useEffect(() => {
const {
pluginKey,
pluginKey = 'bubbleMenu',
editor,
tippyOptions,
shouldShow,
tippyOptions = {},
shouldShow = null,
} = props
editor.registerPlugin(BubbleMenuPlugin({