import { Inject , Injectable , PLATFORM_ID } from '@angular/core' ; import { isPlatformBrowser } from '@angular/common' ; import 'prismjs' ; import 'prismjs/components/prism-markup' ; import 'prismjs/components/prism-css' ; import 'prismjs/components/prism-clike' ; import 'prismjs/components/prism-javascript' ; import 'prismjs/components/prism-php' ; import 'prismjs/components/prism-markup-templating' ; import 'prismjs/components/prism-php-extras' ; import 'prismjs/components/prism-sql' ; import 'prismjs/components/prism-json' ; import 'prismjs/plugins/line-numbers/prism-line-numbers' ; declare var Prism ; @ Injectable ( { providedIn : 'root' } ) export class PrismService { constructor ( @ Inject ( PLATFORM_ID ) private platformId ) { } highlightAll ( ) { return new Promise ( ( resolve , reject ) => { if ( isPlatformBrowser ( this . platformId ) ) { Prism . highlightAll ( ) ; resolve ( true ) ; } else { resolve ( false ) ; } } ) ; } }