1- "use strict" ;
1+ import parserAngular from "prettier/parser-angular" ;
2+ import parserBabylon from "prettier/parser-babylon" ;
3+ import parserFlow from "prettier/parser-flow" ;
4+ import parserGlimmer from "prettier/parser-glimmer" ;
5+ import parserGraphql from "prettier/parser-graphql" ;
6+ import parserHtml from "prettier/parser-html" ;
7+ import parserMarkdown from "prettier/parser-markdown" ;
8+ import parserPostcss from "prettier/parser-postcss" ;
9+ import parserTypescript from "prettier/parser-typescript" ;
10+ import parserYaml from "prettier/parser-yaml" ;
11+ import prettier from "prettier/standalone" ;
212
313function init ( ) {
14+ const prettierPlugins = [
15+ parserAngular ,
16+ parserBabylon ,
17+ parserFlow ,
18+ parserGlimmer ,
19+ parserGraphql ,
20+ parserHtml ,
21+ parserMarkdown ,
22+ parserPostcss ,
23+ parserTypescript ,
24+ parserYaml
25+ ] ;
26+
427 const GITHUB_URL = "https://github.com" ;
528 const GITHUB_VALID_PATHNAMES = / ^ \/ .* \/ .* \/ (?: p u l l \/ \d + (?: \/ ? | \/ f i l e s \/ ? ) $ | c o m m i t | c o m p a r e \/ .* | i s s u e s \/ \d + | i s s u e s \/ n e w ) / u;
629 const POLLING_INTERVAL = 30 ;
@@ -117,9 +140,9 @@ function init() {
117140 const textArea = findWithClass ( buttonElem , "comment-form-textarea" ) ;
118141 buttonElem . addEventListener ( "click" , event => {
119142 event . preventDefault ( ) ;
120- const formattedText = window . prettier . format ( textArea . value , {
143+ const formattedText = prettier . format ( textArea . value , {
121144 parser : "markdown" ,
122- plugins : window . prettierPlugins
145+ plugins : prettierPlugins
123146 } ) ;
124147 textArea . focus ( ) ;
125148 textArea . select ( ) ;
@@ -311,9 +334,9 @@ function init() {
311334 let formattedSnippet = snippet ;
312335
313336 try {
314- formattedSnippet = window . prettier . format ( snippet , {
337+ formattedSnippet = prettier . format ( snippet , {
315338 parser : PARSERS_LANG_MAP [ lang ] ,
316- plugins : window . prettierPlugins
339+ plugins : prettierPlugins
317340 } ) ;
318341 } catch { }
319342
@@ -339,9 +362,9 @@ function init() {
339362 }
340363
341364 try {
342- formattedText = window . prettier . format ( codeLines . join ( "\n" ) , {
365+ formattedText = prettier . format ( codeLines . join ( "\n" ) , {
343366 parser : PARSERS_LANG_MAP [ lang ] ,
344- plugins : window . prettierPlugins
367+ plugins : prettierPlugins
345368 } ) ;
346369 } catch {
347370 return ;
@@ -370,9 +393,9 @@ function init() {
370393 } ) ;
371394 }
372395
373- inputEl . value = window . prettier . format ( inputEl . value , {
396+ inputEl . value = prettier . format ( inputEl . value , {
374397 parser : "markdown" ,
375- plugins : window . prettierPlugins
398+ plugins : prettierPlugins
376399 } ) ;
377400 inputEl . focus ( ) ;
378401 } ) ;
0 commit comments