"use client"
import type { ReactNode } from "react"
import {
AlignHorizontalSpaceAround,
Check,
Eye,
ListTree,
Maximize2,
MessageSquare,
MessageSquarePlus,
Pencil,
} from "lucide-react"
import {
MenubarCheckboxItem,
MenubarContent,
MenubarItem,
MenubarMenu,
MenubarSeparator,
MenubarSubContent,
MenubarSubTrigger,
MenubarTrigger,
} from "@/components/ui/menubar"
import {
DocsExclusiveMenuSub,
DocsExclusiveMenuSubRoot,
} from "@/components/drive/richtext/docs-exclusive-menu-sub"
import { DocsMenuShortcut } from "@/components/drive/richtext/docs-menu-shortcut"
import { DOCS_MENUBAR_CONTENT_PROPS } from "@/components/drive/richtext/docs-menubar-props"
import type {
DocsCommentsDisplay,
DocsEditorMode,
} from "@/lib/drive/docs-view-settings"
import { cn } from "@/lib/utils"
export type DocsViewMenuState = {
editorMode: DocsEditorMode
commentsDisplay: DocsCommentsDisplay
showLayout: boolean
showRuler: boolean
showEquationToolbar: boolean
showNonPrintableChars: boolean
}
export type DocsViewMenuActions = {
onEditorModeChange: (mode: DocsEditorMode) => void
onCommentsDisplayChange: (display: DocsCommentsDisplay) => void
onToggleOutlineSidebar: () => void
onToggleShowLayout: () => void
onToggleShowRuler: () => void
onToggleShowEquationToolbar: () => void
onToggleShowNonPrintableChars: () => void
onFullscreen: () => void
}
const EDITOR_MODES = [
{
id: "edit" as const,
label: "Édition",
description: "Modifier le document directement",
icon: Pencil,
},
{
id: "suggest" as const,
label: "Suggestion",
description: "Suggérer des modifications",
icon: MessageSquarePlus,
},
{
id: "view" as const,
label: "Affichage",
description: "Lire ou imprimer le document final",
icon: Eye,
},
] as const
const COMMENTS_OPTIONS = [
{ id: "hidden" as const, label: "Masquer les commentaires" },
{ id: "collapsed" as const, label: "Réduire les commentaires" },
{ id: "expanded" as const, label: "Développer les commentaires" },
{ id: "all" as const, label: "Afficher tous les commentaires" },
] as const
function MenuIcon({ children }: { children: ReactNode }) {
return {children}
}
function CheckMenuOption({
checked,
onSelect,
children,
disabled,
}: {
checked: boolean
onSelect: () => void
children: ReactNode
disabled?: boolean
}) {
return (
{checked ? : null}
{children}
)
}
function ModeMenuOption({
icon: Icon,
label,
description,
selected,
onSelect,
disabled,
}: {
icon: typeof Pencil
label: string
description: string
selected: boolean
onSelect: () => void
disabled?: boolean
}) {
return (
{label}
{description}
)
}
export function DocsViewMenu({
state,
actions,
disabled,
}: {
state: DocsViewMenuState
actions: DocsViewMenuActions
disabled?: boolean
}) {
return (
Affichage
Mode
{EDITOR_MODES.map((mode) => (
actions.onEditorModeChange(mode.id)}
/>
))}
Développer la barre latérale des onglets et sections
Ctrl+⌥A Ctrl+⌥H
Largeur du texte
Bientôt disponible
actions.onToggleShowLayout()}
>
Afficher la mise en page
actions.onToggleShowRuler()}
>
Afficher la règle
actions.onToggleShowEquationToolbar()}
>
Afficher la barre d'outils d'équation
actions.onToggleShowNonPrintableChars()}
>
Afficher les caractères non imprimables
Plein écran
)
}