1
1
import { createIntegration , createComponent } from '@gitbook/runtime' ;
2
2
3
- const defaultContent = 'Starter Javascript Project' ;
3
+ import { fetchHTML } from './stackblitz' ;
4
+
5
+ const defaultContent = '//TODO: Starter Javascript Project' ;
4
6
5
7
const diagramBlock = createComponent <
6
8
{
@@ -17,6 +19,7 @@ const diagramBlock = createComponent<
17
19
} ;
18
20
} ,
19
21
async render ( element , { environment } ) {
22
+ await fetchHTML ( ) ;
20
23
const { editable } = element . context ;
21
24
const { content } = element . state ;
22
25
@@ -69,39 +72,5 @@ const diagramBlock = createComponent<
69
72
// project[template] = Can be one of: typescript, angular-cli, create-react-app, javascript
70
73
71
74
export default createIntegration ( {
72
- fetch : async ( ) => {
73
- return new Response (
74
- `<html lang='en'>
75
- <head></head>
76
- <body>
77
-
78
- <form id='mainForm' method='post' action='https://stackblitz.com/run' target='_self'>
79
- <input type='hidden' name='project[files][index.ts]' value="import { Observable } from 'rxjs/Observable';
80
- import 'rxjs/add/observable/fromEvent';
81
- import 'rxjs/add/operator/scan';
82
-
83
- var button = document.querySelector('button');
84
- Observable.fromEvent(button, 'click')
85
- .scan((count: number) => count + 1, 0)
86
- .subscribe(count => console.log(\`Clicked times\`));
87
- ">
88
- <input type='hidden' name='project[files][index.html]' value='<button>Click Me</button>
89
- '>
90
- <input type='hidden' name='project[description]' value='RxJS Example'>
91
- <input type='hidden' name='project[dependencies]' value='{"rxjs":"5.5.6"}'>
92
- <input type='hidden' name='project[template]' value='typescript'>
93
- <input type='hidden' name='project[settings]' value='{"compile":{"clearConsole":false}}'>
94
- </form>
95
- <script>document.getElementById("mainForm").submit();</script>
96
-
97
- </body></html>` ,
98
- {
99
- headers : {
100
- 'Content-Type' : 'text/html' ,
101
- 'Cache-Control' : 'public, max-age=86400' ,
102
- } ,
103
- }
104
- ) ;
105
- } ,
106
75
components : [ diagramBlock ] ,
107
76
} ) ;
0 commit comments