feat: display element info in getAttributeOptions
This commit is contained in:
@@ -21,23 +21,26 @@ interface AttributeOption {
|
|||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getAttributeOptions = (tagName: string): AttributeOption[] => {
|
const getAttributeOptions = (tagName: string, elementInfo: ElementInfo | null): AttributeOption[] => {
|
||||||
|
if (!elementInfo) return [];
|
||||||
|
|
||||||
switch (tagName.toLowerCase()) {
|
switch (tagName.toLowerCase()) {
|
||||||
case 'a':
|
case 'a':
|
||||||
return [
|
return [
|
||||||
{ label: 'Text', value: 'innerText' },
|
{ label: `Text: ${elementInfo.innerText || 'N/A'}`, value: 'innerText' },
|
||||||
{ label: 'URL', value: 'href' }
|
{ label: `URL: ${elementInfo.url || 'N/A'}`, value: 'href' }
|
||||||
];
|
];
|
||||||
case 'img':
|
case 'img':
|
||||||
return [
|
return [
|
||||||
{ label: 'Alt Text', value: 'alt' },
|
{ label: `Alt Text: ${elementInfo.innerText || 'N/A'}`, value: 'alt' },
|
||||||
{ label: 'Source URL', value: 'src' }
|
{ label: `Source URL: ${elementInfo.imageUrl || 'N/A'}`, value: 'src' }
|
||||||
];
|
];
|
||||||
default:
|
default:
|
||||||
return [{ label: 'Text', value: 'innerText' }];
|
return [{ label: `Text: ${elementInfo.innerText || 'N/A'}`, value: 'innerText' }];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const BrowserWindow = () => {
|
export const BrowserWindow = () => {
|
||||||
const [canvasRef, setCanvasReference] = useState<React.RefObject<HTMLCanvasElement> | undefined>(undefined);
|
const [canvasRef, setCanvasReference] = useState<React.RefObject<HTMLCanvasElement> | undefined>(undefined);
|
||||||
const [screenShot, setScreenShot] = useState<string>("");
|
const [screenShot, setScreenShot] = useState<string>("");
|
||||||
|
|||||||
Reference in New Issue
Block a user