|
@@ -1,5 +1,6 @@
|
|
|
import React, { useEffect, useRef, useState } from "react"
|
|
import React, { useEffect, useRef, useState } from "react"
|
|
|
import { getContextMenuOptions } from "../utils/mention-context"
|
|
import { getContextMenuOptions } from "../utils/mention-context"
|
|
|
|
|
+import { removeLeadingNonAlphanumeric } from "./CodeAccordian"
|
|
|
|
|
|
|
|
interface ContextMenuProps {
|
|
interface ContextMenuProps {
|
|
|
onSelect: (type: string, value: string) => void
|
|
onSelect: (type: string, value: string) => void
|
|
@@ -45,6 +46,46 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
|
|
|
}
|
|
}
|
|
|
}, [selectedIndex])
|
|
}, [selectedIndex])
|
|
|
|
|
|
|
|
|
|
+ const renderOptionContent = (option: { type: string; value: string }) => {
|
|
|
|
|
+ switch (option.value) {
|
|
|
|
|
+ case "file":
|
|
|
|
|
+ case "folder":
|
|
|
|
|
+ case "problems":
|
|
|
|
|
+ case "url":
|
|
|
|
|
+ return (
|
|
|
|
|
+ <span
|
|
|
|
|
+ style={{
|
|
|
|
|
+ whiteSpace: "nowrap",
|
|
|
|
|
+ overflow: "hidden",
|
|
|
|
|
+ textOverflow: "ellipsis",
|
|
|
|
|
+ }}>
|
|
|
|
|
+ {option.value === "file"
|
|
|
|
|
+ ? "Add File"
|
|
|
|
|
+ : option.value === "folder"
|
|
|
|
|
+ ? "Add Folder"
|
|
|
|
|
+ : option.value === "problems"
|
|
|
|
|
+ ? "Problems"
|
|
|
|
|
+ : option.value === "url"
|
|
|
|
|
+ ? "Paste URL to scrape"
|
|
|
|
|
+ : ""}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ )
|
|
|
|
|
+ default:
|
|
|
|
|
+ return (
|
|
|
|
|
+ <span
|
|
|
|
|
+ style={{
|
|
|
|
|
+ whiteSpace: "nowrap",
|
|
|
|
|
+ overflow: "hidden",
|
|
|
|
|
+ textOverflow: "ellipsis",
|
|
|
|
|
+ direction: "rtl",
|
|
|
|
|
+ textAlign: "left",
|
|
|
|
|
+ }}>
|
|
|
|
|
+ {removeLeadingNonAlphanumeric(option.value) + "\u200E"}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div
|
|
<div
|
|
|
style={{
|
|
style={{
|
|
@@ -52,6 +93,7 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
|
|
|
bottom: "calc(100% - 10px)",
|
|
bottom: "calc(100% - 10px)",
|
|
|
left: 15,
|
|
left: 15,
|
|
|
right: 15,
|
|
right: 15,
|
|
|
|
|
+ overflowX: "hidden",
|
|
|
}}
|
|
}}
|
|
|
onMouseDown={onMouseDown}>
|
|
onMouseDown={onMouseDown}>
|
|
|
<div
|
|
<div
|
|
@@ -83,29 +125,36 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
|
|
|
index === selectedIndex && option.type !== "url"
|
|
index === selectedIndex && option.type !== "url"
|
|
|
? "var(--vscode-list-activeSelectionBackground)"
|
|
? "var(--vscode-list-activeSelectionBackground)"
|
|
|
: "",
|
|
: "",
|
|
|
- // opacity: option.type === "url" ? 0.5 : 1, // Make URL option appear disabled
|
|
|
|
|
}}
|
|
}}
|
|
|
onMouseEnter={() => option.type !== "url" && setSelectedIndex(index)}>
|
|
onMouseEnter={() => option.type !== "url" && setSelectedIndex(index)}>
|
|
|
- <div style={{ display: "flex", alignItems: "center" }}>
|
|
|
|
|
- <i className={`codicon codicon-${option.icon}`} style={{ marginRight: "8px" }} />
|
|
|
|
|
- {option.value === "file"
|
|
|
|
|
- ? "Add File"
|
|
|
|
|
- : option.value === "folder"
|
|
|
|
|
- ? "Add Folder"
|
|
|
|
|
- : option.value === "problems"
|
|
|
|
|
- ? "Problems"
|
|
|
|
|
- : option.value === "url"
|
|
|
|
|
- ? "Paste URL to scrape"
|
|
|
|
|
- : option.value}
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ style={{
|
|
|
|
|
+ display: "flex",
|
|
|
|
|
+ alignItems: "center",
|
|
|
|
|
+ flex: 1,
|
|
|
|
|
+ minWidth: 0, // Allows child to shrink below content size
|
|
|
|
|
+ overflow: "hidden", // Ensures content doesn't overflow
|
|
|
|
|
+ }}>
|
|
|
|
|
+ <i
|
|
|
|
|
+ className={`codicon codicon-${option.icon}`}
|
|
|
|
|
+ style={{ marginRight: "8px", flexShrink: 0, fontSize: "14px" }}
|
|
|
|
|
+ />
|
|
|
|
|
+ {renderOptionContent(option)}
|
|
|
</div>
|
|
</div>
|
|
|
{(option.value === "file" || option.value === "folder") && (
|
|
{(option.value === "file" || option.value === "folder") && (
|
|
|
- <i className="codicon codicon-chevron-right" style={{ fontSize: "14px" }} />
|
|
|
|
|
|
|
+ <i
|
|
|
|
|
+ className="codicon codicon-chevron-right"
|
|
|
|
|
+ style={{ fontSize: "14px", flexShrink: 0, marginLeft: 8 }}
|
|
|
|
|
+ />
|
|
|
)}
|
|
)}
|
|
|
{(option.type === "problems" ||
|
|
{(option.type === "problems" ||
|
|
|
((option.type === "file" || option.type === "folder") &&
|
|
((option.type === "file" || option.type === "folder") &&
|
|
|
option.value !== "file" &&
|
|
option.value !== "file" &&
|
|
|
option.value !== "folder")) && (
|
|
option.value !== "folder")) && (
|
|
|
- <i className="codicon codicon-add" style={{ fontSize: "14px" }} />
|
|
|
|
|
|
|
+ <i
|
|
|
|
|
+ className="codicon codicon-add"
|
|
|
|
|
+ style={{ fontSize: "14px", flexShrink: 0, marginLeft: 8 }}
|
|
|
|
|
+ />
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
|
))}
|
|
))}
|