Skip to content

Commit

Permalink
styles; ad loading for menu bubble
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 2, 2023
1 parent c5ff598 commit a226c5e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions editor/src/components/editor/menu/menu-bubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@/components/editor/defs/custom-action.type'
import { newAdvice } from '@/components/editor/extensions/advice/advice';
import { ToolbarMenu } from "@/components/editor/menu/toolbar-menu";
import { BounceLoader } from "react-spinners";

export const MenuBubble = ({ editor }: {
editor: Editor
Expand Down Expand Up @@ -50,13 +51,15 @@ export const MenuBubble = ({ editor }: {

const handleToggle = () => setIsOpen(!isOpen);

return <BubbleMenu className={`bubble-menu-group w-64`} editor={editor} tippyOptions={{ duration: 100 }}>
return <BubbleMenu className={`bubble-menu-group w-64`} editor={editor} updateDelay={800}>
<div className={'bubble-menu-tier1'}>
<div className="bubble-dropdown">
<Button variant="soft" onClick={handleToggle} className={'bg-pink-500 text-white'}>
Ask AI
<CookieIcon/>
</Button>
{loading && <BounceLoader color={"#6E56CF"} size={38}/>}
{!loading && <Button variant="soft" onClick={handleToggle} className={'bg-pink-500 text-white'}>
Ask AI
<CookieIcon/>
</Button>
}
</div>
<div className="smart-menu">
<ToolbarMenu editor={editor} isBubbleMenu={true}/>
Expand All @@ -69,6 +72,7 @@ export const MenuBubble = ({ editor }: {
<Button
className="dropdown-item w-full"
onClick={async () => {
setIsOpen(false)
setLoading(true)

const text = await editor.commands?.callLlm(menu);
Expand All @@ -78,7 +82,7 @@ export const MenuBubble = ({ editor }: {
editor.commands?.setAdvice(newComment.id)
editor.commands?.setAdviceCommand(newComment)
menu.action?.(editor)
editor.commands?.focus()
editor.view?.focus()
}}
>
{menu.name} <BookmarkIcon/>
Expand All @@ -91,8 +95,10 @@ export const MenuBubble = ({ editor }: {
<Button
className="dropdown-item w-full"
onClick={(event) => {
event.preventDefault();
setIsOpen(false);
editor.chain().callLlm(menu);
editor.view?.focus()
}}
>
{menu.name}
Expand Down

0 comments on commit a226c5e

Please sign in to comment.