summaryrefslogtreecommitdiff
path: root/frontend/src/components/document/ContextMenu.tsx
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-04-28 19:12:52 +0100
committerGitHub <noreply@github.com>2026-04-28 19:12:52 +0100
commitd1fdfb140cc440664f77a24886172f9976a05a31 (patch)
tree454739f80dde60fc6c1cd97acbaef3223ac041c6 /frontend/src/components/document/ContextMenu.tsx
parent636694182fe9381479f2e9062229dda3838c5421 (diff)
downloadsoryu-d1fdfb140cc440664f77a24886172f9976a05a31.tar.gz
soryu-d1fdfb140cc440664f77a24886172f9976a05a31.zip
feat: revert broken directive PRs, re-implement Lexical document orchestrator (#98)
* feat: soryu-co/soryu - makima: Revert broken directive PRs and verify clean build * feat: soryu-co/soryu - makima: Re-implement frontend: Lexical document editor with feature flag and base components * WIP: heartbeat checkpoint * feat: soryu-co/soryu - makima: Add contract blocks, expandable log rows, and interaction controls * WIP: heartbeat checkpoint * feat: soryu-co/soryu - makima: End-to-end build verification and integration polish
Diffstat (limited to 'frontend/src/components/document/ContextMenu.tsx')
-rw-r--r--frontend/src/components/document/ContextMenu.tsx98
1 files changed, 0 insertions, 98 deletions
diff --git a/frontend/src/components/document/ContextMenu.tsx b/frontend/src/components/document/ContextMenu.tsx
deleted file mode 100644
index 5aed940..0000000
--- a/frontend/src/components/document/ContextMenu.tsx
+++ /dev/null
@@ -1,98 +0,0 @@
-import { useCallback, useEffect, useRef } from 'react';
-import './ContextMenu.css';
-
-export interface ContextMenuAction {
- label: string;
- icon: string;
- disabled?: boolean;
- onClick: () => void;
-}
-
-export interface ContextMenuProps {
- x: number;
- y: number;
- actions: ContextMenuAction[];
- dividerAfter?: number[];
- onClose: () => void;
-}
-
-export default function ContextMenu({
- x,
- y,
- actions,
- dividerAfter = [],
- onClose,
-}: ContextMenuProps) {
- const menuRef = useRef<HTMLDivElement>(null);
-
- // Adjust position so menu stays within viewport
- const adjustedPosition = useCallback(() => {
- const el = menuRef.current;
- if (!el) return { left: x, top: y };
- const rect = el.getBoundingClientRect();
- const left = x + rect.width > window.innerWidth ? x - rect.width : x;
- const top = y + rect.height > window.innerHeight ? y - rect.height : y;
- return { left: Math.max(0, left), top: Math.max(0, top) };
- }, [x, y]);
-
- // Close on click outside
- useEffect(() => {
- const handler = (e: MouseEvent) => {
- if (menuRef.current && !menuRef.current.contains(e.target as Node)) {
- onClose();
- }
- };
- // Use capture so we catch clicks before any other handler
- document.addEventListener('mousedown', handler, true);
- return () => document.removeEventListener('mousedown', handler, true);
- }, [onClose]);
-
- // Close on Escape
- useEffect(() => {
- const handler = (e: KeyboardEvent) => {
- if (e.key === 'Escape') onClose();
- };
- document.addEventListener('keydown', handler);
- return () => document.removeEventListener('keydown', handler);
- }, [onClose]);
-
- // After mount, adjust position
- useEffect(() => {
- const el = menuRef.current;
- if (!el) return;
- const pos = adjustedPosition();
- el.style.left = `${pos.left}px`;
- el.style.top = `${pos.top}px`;
- }, [adjustedPosition]);
-
- const dividerSet = new Set(dividerAfter);
-
- return (
- <div
- ref={menuRef}
- className="ctx-menu"
- style={{ left: x, top: y }}
- role="menu"
- >
- {actions.map((action, i) => (
- <div key={i}>
- <button
- className={`ctx-menu-item ${action.disabled ? 'ctx-menu-item-disabled' : ''}`}
- role="menuitem"
- disabled={action.disabled}
- onClick={() => {
- if (!action.disabled) {
- action.onClick();
- onClose();
- }
- }}
- >
- <span className="ctx-menu-icon">{action.icon}</span>
- <span className="ctx-menu-label">{action.label}</span>
- </button>
- {dividerSet.has(i) && <div className="ctx-menu-divider" />}
- </div>
- ))}
- </div>
- );
-}