From 5f7f3995f87074f54bdcb7b88b6ca75496648ec0 Mon Sep 17 00:00:00 2001 From: Timothy Cardoza Date: Tue, 17 Mar 2026 18:20:00 -0500 Subject: [PATCH] text formatting finished --- src/components/TextBubbleMenu.tsx | 51 +++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/components/TextBubbleMenu.tsx b/src/components/TextBubbleMenu.tsx index 0bc7ff6..5f62095 100644 --- a/src/components/TextBubbleMenu.tsx +++ b/src/components/TextBubbleMenu.tsx @@ -10,12 +10,15 @@ import { Heading1, Heading2, Heading3, + Heading, Eraser, ListTodo, - Grid3X3 + Grid3X3, + AlignJustify } from "lucide-solid"; import { cn } from "@/lib/utils"; import type { Editor } from "@tiptap/core"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; interface GenericAction { label: string; @@ -28,6 +31,8 @@ interface GenericAction { interface FormatGroup { name: string; actions: GenericAction[]; + collapseOnMobile?: boolean; + mobileIcon?: Component; } export const TextBubbleMenu: Component<{ editor: Editor }> = (props) => { @@ -76,6 +81,8 @@ export const TextBubbleMenu: Component<{ editor: Editor }> = (props) => { }, { name: "Headings", + collapseOnMobile: true, + mobileIcon: () => , actions: [ { label: "Heading 1", icon: () => , isActive: () => activeFormats().h1, command: () => props.editor.chain().focus().toggleHeading({ level: 1 }).run() }, { label: "Heading 2", icon: () => , isActive: () => activeFormats().h2, command: () => props.editor.chain().focus().toggleHeading({ level: 2 }).run() }, @@ -84,6 +91,8 @@ export const TextBubbleMenu: Component<{ editor: Editor }> = (props) => { }, { name: "Alignment", + collapseOnMobile: true, + mobileIcon: () => , actions: [ { label: "Align Left", icon: () => , isActive: () => activeFormats().alignLeft, command: () => props.editor.chain().focus().setTextAlign('left').run() }, { label: "Align Center", icon: () => , isActive: () => activeFormats().alignCenter, command: () => props.editor.chain().focus().setTextAlign('center').run() }, @@ -120,7 +129,7 @@ export const TextBubbleMenu: Component<{ editor: Editor }> = (props) => { {(group, groupIdx) => ( <> -
+
{(action) => (
+ + {group.collapseOnMobile && group.mobileIcon && ( +
+ + a.isActive?.()) && "bg-primary/20 text-primary" + )}> + + + + + {(action) => ( + + )} + + + +
+ )} {groupIdx() < groups.length - 1 && (
)}