Skip to content

Commit

Permalink
fix: make shouldShow and pluginKey option for menus, fix ueberdosis#1779
Browse files Browse the repository at this point in the history
  • Loading branch information
philippkuehn committed Aug 23, 2021
1 parent be8d8ed commit d866dff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/BubbleMenu.tsx
Original file line number Diff line number Diff line change
@@ -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,
}

Expand All @@ -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({
Expand Down
10 changes: 6 additions & 4 deletions src/FloatingMenu.tsx
Original file line number Diff line number Diff line change
@@ -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,
}

Expand All @@ -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({
Expand Down

0 comments on commit d866dff

Please sign in to comment.