1234567 |
- export class ContextMenuProvider{appendApplicableItems(event,contextMenu,target){const contentProvider=(target);async function saveAs(){if(contentProvider instanceof Workspace.UISourceCode){(contentProvider).commitWorkingCopy();}
- let content=(await contentProvider.requestContent()).content||'';if(await contentProvider.contentEncoded()){content=window.atob(content);}
- const url=contentProvider.contentURL();Workspace.fileManager.save(url,(content),true);Workspace.fileManager.close(url);}
- if(contentProvider.contentType().isDocumentOrScriptOrStyleSheet()){contextMenu.saveSection().appendItem(Common.UIString('Save as...'),saveAs);}
- const uiSourceCode=Workspace.workspace.uiSourceCodeForURL(contentProvider.contentURL());if(uiSourceCode&&Persistence.networkPersistenceManager.canSaveUISourceCodeForOverrides(uiSourceCode)){contextMenu.saveSection().appendItem(Common.UIString('Save for overrides'),()=>{uiSourceCode.commitWorkingCopy();Persistence.networkPersistenceManager.saveUISourceCodeForOverrides((uiSourceCode));Common.Revealer.reveal(uiSourceCode);});}
- const binding=uiSourceCode&&Persistence.persistence.binding(uiSourceCode);const fileURL=binding?binding.fileSystem.contentURL():contentProvider.contentURL();if(fileURL.startsWith('file://')){const path=Common.ParsedURL.urlToPlatformPath(fileURL,Host.isWin());contextMenu.revealSection().appendItem(Common.UIString('Open in containing folder'),()=>Host.InspectorFrontendHost.showItemInFolder(path));}}}
- self.Persistence=self.Persistence||{};Persistence=Persistence||{};Persistence.PersistenceActions={};Persistence.PersistenceActions.ContextMenuProvider=ContextMenuProvider;
|