ContentProvider.js 1.2 KB

12345678910
  1. import{ResourceType}from'./ResourceType.js';export class ContentProvider{contentURL(){}
  2. contentType(){}
  3. contentEncoded(){}
  4. requestContent(){}
  5. searchInContent(query,caseSensitive,isRegex){}}
  6. export class SearchMatch{constructor(lineNumber,lineContent){this.lineNumber=lineNumber;this.lineContent=lineContent;}}
  7. export const performSearchInContent=function(content,query,caseSensitive,isRegex){const regex=createSearchRegex(query,caseSensitive,isRegex);const text=new TextUtils.Text(content);const result=[];for(let i=0;i<text.lineCount();++i){const lineContent=text.lineAt(i);regex.lastIndex=0;if(regex.exec(lineContent)){result.push(new SearchMatch(i,lineContent));}}
  8. return result;};export const contentAsDataURL=function(content,mimeType,contentEncoded,charset){const maxDataUrlSize=1024*1024;if(content===null||content.length>maxDataUrlSize){return null;}
  9. return'data:'+mimeType+(charset?';charset='+charset:'')+(contentEncoded?';base64':'')+','+
  10. content;};self.Common=self.Common||{};Common=Common||{};Common.ContentProvider=ContentProvider;Common.ContentProvider.SearchMatch=SearchMatch;Common.ContentProvider.performSearchInContent=performSearchInContent;Common.ContentProvider.contentAsDataURL=contentAsDataURL;Common.DeferredContent;