feat: Add context menu functionality for PDF components with options to view, copy URL, and download
This commit is contained in:
@@ -3,6 +3,8 @@ import { DeesInputBase } from '../dees-input-base.js';
|
||||
import { PdfManager } from '../dees-pdf-shared/PdfManager.js';
|
||||
import { viewerStyles } from './styles.js';
|
||||
import { demo as demoFunc } from './demo.js';
|
||||
import { DeesContextmenu } from '../dees-contextmenu.js';
|
||||
import '../dees-icon.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@@ -383,4 +385,41 @@ export class DeesPdfViewer extends DeesElement {
|
||||
private printPdf() {
|
||||
window.open(this.pdfUrl, '_blank')?.print();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide context menu items for right-click functionality
|
||||
*/
|
||||
public getContextMenuItems() {
|
||||
return [
|
||||
{
|
||||
name: 'Open PDF in New Tab',
|
||||
iconName: 'lucide:ExternalLink',
|
||||
action: async () => {
|
||||
window.open(this.pdfUrl, '_blank');
|
||||
}
|
||||
},
|
||||
{ divider: true },
|
||||
{
|
||||
name: 'Copy PDF URL',
|
||||
iconName: 'lucide:Copy',
|
||||
action: async () => {
|
||||
await navigator.clipboard.writeText(this.pdfUrl);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Download PDF',
|
||||
iconName: 'lucide:Download',
|
||||
action: async () => {
|
||||
this.downloadPdf();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Print PDF',
|
||||
iconName: 'lucide:Printer',
|
||||
action: async () => {
|
||||
this.printPdf();
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user