import * as fs from 'fs' ; import * as path from 'path' ; import { Uri , Webview } from 'vscode' ; import { DATA_VIEW_UI_PATH , HTML_FILE } from '../constants' ; import { HtmlUtils } from '../editor/htmlUtils' ; export function getHtml ( assets , extensionPath , webview ) { const { baseStyleUri , tabulatorStyleUri , viewControllerUri , tabulatorUri , saveIconUri } = assets ; const pathToDataViewDist = path . join ( extensionPath , DATA_VIEW_UI_PATH ) ; const pathToHtml = path . join ( pathToDataViewDist , HTML_FILE ) ; let html = fs . readFileSync ( pathToHtml ) . toString ( ) ; html = HtmlUtils . replaceCspMetaTag ( html , webview ) ; html = html . replace ( '${tabulatorStyleUri}' , tabulatorStyleUri . toString ( ) ) ; html = html . replace ( '${baseStyleUri}' , baseStyleUri . toString ( ) ) ; html = html . replace ( '${tabulatorUri}' , tabulatorUri . toString ( ) ) ; html = html . replace ( '${viewControllerUri}' , viewControllerUri . toString ( ) ) ; while ( html . match ( /\${iconSave}/ ) ) { html = html . replace ( '${iconSave}' , saveIconUri . toString ( ) ) ; } return html ; }