fix: make shouldShow and pluginKey option for menus, fix #1779
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'
|
||||
|
||||
export type FloatingMenuProps = Omit<FloatingMenuPluginProps, 'element'> & {
|
||||
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
||||
|
||||
export type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey'>, 'element'> & {
|
||||
className?: string,
|
||||
}
|
||||
|
||||
@@ -10,10 +12,10 @@ export const FloatingMenu: React.FC<FloatingMenuProps> = props => {
|
||||
|
||||
useEffect(() => {
|
||||
const {
|
||||
pluginKey,
|
||||
pluginKey = 'floatingMenu',
|
||||
editor,
|
||||
tippyOptions,
|
||||
shouldShow,
|
||||
tippyOptions = {},
|
||||
shouldShow = null,
|
||||
} = props
|
||||
|
||||
editor.registerPlugin(FloatingMenuPlugin({
|
||||
|
||||
Reference in New Issue
Block a user