ResourceSourceFrame.js 1.8 KB

12345678
  1. export class ResourceSourceFrame extends SourceFrame.SourceFrame{constructor(resource,autoPrettyPrint,codeMirrorOptions){super(async()=>{let content=(await resource.requestContent()).content||'';if(await resource.contentEncoded()){content=window.atob(content);}
  2. return{content,isEncoded:false};},codeMirrorOptions);this._resource=resource;this.setCanPrettyPrint(this._resource.contentType().isDocumentOrScriptOrStyleSheet(),autoPrettyPrint);}
  3. static createSearchableView(resource,highlighterType,autoPrettyPrint){return new SearchableContainer(resource,highlighterType,autoPrettyPrint);}
  4. get resource(){return this._resource;}
  5. populateTextAreaContextMenu(contextMenu,lineNumber,columnNumber){contextMenu.appendApplicableItems(this._resource);return Promise.resolve();}}
  6. export class SearchableContainer extends UI.VBox{constructor(resource,highlighterType,autoPrettyPrint){super(true);this.registerRequiredCSS('source_frame/resourceSourceFrame.css');const sourceFrame=new ResourceSourceFrame(resource,autoPrettyPrint);this._sourceFrame=sourceFrame;sourceFrame.setHighlighterType(highlighterType);const searchableView=new UI.SearchableView(sourceFrame);searchableView.element.classList.add('searchable-view');searchableView.setPlaceholder(ls`Find`);sourceFrame.show(searchableView.element);sourceFrame.setSearchableView(searchableView);searchableView.show(this.contentElement);const toolbar=new UI.Toolbar('toolbar',this.contentElement);for(const item of sourceFrame.syncToolbarItems()){toolbar.appendToolbarItem(item);}}
  7. async revealPosition(lineNumber,columnNumber){this._sourceFrame.revealPosition(lineNumber,columnNumber,true);}}
  8. self.SourceFrame=self.SourceFrame||{};SourceFrame=SourceFrame||{};SourceFrame.ResourceSourceFrame=ResourceSourceFrame;SourceFrame.ResourceSourceFrame.SearchableContainer=SearchableContainer;