gitorial-cli 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -59
- package/package.json +6 -4
- package/src/commands/build-gitorial.js +152 -0
- package/src/commands/build-mdbook.js +321 -0
- package/src/index.js +29 -35
- package/src/lib/fs.js +112 -0
- package/src/lib/git.js +45 -0
- package/src/lib/logger.js +22 -0
- package/src/lib/mdbook-templates.js +18 -0
- package/src/lib/monaco-assets.js +549 -0
- package/src/constants.js +0 -5
- package/src/mdbook.js +0 -468
- package/src/repack.js +0 -85
- package/src/unpack.js +0 -88
- package/src/utils.js +0 -79
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
const monacoCss = `
|
|
2
|
+
:root {
|
|
3
|
+
--content-max-width: 100% !important;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
*,
|
|
7
|
+
*::before,
|
|
8
|
+
*::after {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
html,
|
|
13
|
+
body {
|
|
14
|
+
height: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.page,
|
|
18
|
+
.content,
|
|
19
|
+
.chapter,
|
|
20
|
+
.content main {
|
|
21
|
+
height: 100%;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.page {
|
|
25
|
+
overflow-x: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.nav-chapters {
|
|
29
|
+
top: auto;
|
|
30
|
+
margin: 10px;
|
|
31
|
+
font-size: 2.5em;
|
|
32
|
+
text-align: center;
|
|
33
|
+
text-decoration: none;
|
|
34
|
+
width: 90px;
|
|
35
|
+
border-radius: 5px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.page {
|
|
39
|
+
max-width: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.content {
|
|
43
|
+
max-width: none;
|
|
44
|
+
padding: 0;
|
|
45
|
+
overflow-x: hidden;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.gitorial-step {
|
|
49
|
+
display: grid;
|
|
50
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
51
|
+
gap: 10px;
|
|
52
|
+
align-items: stretch;
|
|
53
|
+
min-height: calc(100vh - 102px);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.gitorial-step-text,
|
|
57
|
+
.gitorial-step-editor {
|
|
58
|
+
width: 100%;
|
|
59
|
+
padding: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.gitorial-step-text h1,
|
|
63
|
+
.gitorial-step-text h2,
|
|
64
|
+
.gitorial-step-text h3 {
|
|
65
|
+
margin-top: 1.4em;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.gitorial-step-text p {
|
|
69
|
+
line-height: 1.6;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.gitorial-monaco {
|
|
73
|
+
margin-top: 0;
|
|
74
|
+
border: 1px solid #d9d9d9;
|
|
75
|
+
border-radius: 0;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
background: #0f0f10;
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
height: auto;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.gitorial-monaco-toolbar {
|
|
84
|
+
display: flex;
|
|
85
|
+
gap: 12px;
|
|
86
|
+
align-items: center;
|
|
87
|
+
padding: 12px 16px;
|
|
88
|
+
background: #1b1b1d;
|
|
89
|
+
border-bottom: 1px solid #2a2a2d;
|
|
90
|
+
color: #f0f0f2;
|
|
91
|
+
font-family: "Inter", system-ui, sans-serif;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.gitorial-monaco-toolbar .label {
|
|
95
|
+
font-size: 12px;
|
|
96
|
+
opacity: 0.8;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.gitorial-monaco-toolbar .file-select {
|
|
100
|
+
background: #2b2b2f;
|
|
101
|
+
color: #f0f0f2;
|
|
102
|
+
border: 1px solid #3a3a3f;
|
|
103
|
+
border-radius: 6px;
|
|
104
|
+
padding: 6px 8px;
|
|
105
|
+
font-size: 12px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.gitorial-monaco-toolbar .toggle {
|
|
109
|
+
margin-left: auto;
|
|
110
|
+
background: #f0f0f2;
|
|
111
|
+
color: #1b1b1d;
|
|
112
|
+
border: none;
|
|
113
|
+
border-radius: 999px;
|
|
114
|
+
padding: 6px 12px;
|
|
115
|
+
font-size: 12px;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.gitorial-monaco-toolbar .toggle.secondary {
|
|
120
|
+
background: transparent;
|
|
121
|
+
color: #f0f0f2;
|
|
122
|
+
border: 1px solid #3a3a3f;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.gitorial-monaco-toolbar .diff-toggle {
|
|
126
|
+
background: transparent;
|
|
127
|
+
color: #f0f0f2;
|
|
128
|
+
border: 1px solid #3a3a3f;
|
|
129
|
+
border-radius: 999px;
|
|
130
|
+
padding: 6px 12px;
|
|
131
|
+
font-size: 12px;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.gitorial-monaco-editor {
|
|
136
|
+
height: 70vh;
|
|
137
|
+
min-height: 520px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.gitorial-monaco-footer {
|
|
141
|
+
padding: 10px 16px;
|
|
142
|
+
background: #1b1b1d;
|
|
143
|
+
border-top: 1px solid #2a2a2d;
|
|
144
|
+
font-size: 12px;
|
|
145
|
+
color: #b7b7c0;
|
|
146
|
+
font-family: "Inter", system-ui, sans-serif;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@media screen and (min-width: 1081px) {
|
|
150
|
+
.gitorial-step-text,
|
|
151
|
+
.gitorial-step-editor {
|
|
152
|
+
height: calc(100vh - 102px);
|
|
153
|
+
overflow: auto;
|
|
154
|
+
padding: 0 5px 20px 5px;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@media (max-width: 980px) {
|
|
159
|
+
.gitorial-step {
|
|
160
|
+
grid-template-columns: 1fr;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.gitorial-step-text,
|
|
164
|
+
.gitorial-step-editor {
|
|
165
|
+
height: auto;
|
|
166
|
+
overflow: visible;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.gitorial-monaco {
|
|
170
|
+
height: auto;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.gitorial-monaco-editor {
|
|
174
|
+
min-height: 480px;
|
|
175
|
+
height: 60vh;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
const monacoSetup = `
|
|
181
|
+
(function () {
|
|
182
|
+
function loadJson(url) {
|
|
183
|
+
return fetch(url).then((res) => {
|
|
184
|
+
if (!res.ok) {
|
|
185
|
+
throw new Error('Failed to load ' + url);
|
|
186
|
+
}
|
|
187
|
+
return res.json();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function detectMode(filePath) {
|
|
192
|
+
const ext = filePath.split('.').pop();
|
|
193
|
+
switch (ext) {
|
|
194
|
+
case 'rs':
|
|
195
|
+
return 'rust';
|
|
196
|
+
case 'toml':
|
|
197
|
+
return 'toml';
|
|
198
|
+
case 'js':
|
|
199
|
+
return 'javascript';
|
|
200
|
+
case 'json':
|
|
201
|
+
return 'json';
|
|
202
|
+
case 'ts':
|
|
203
|
+
return 'typescript';
|
|
204
|
+
case 'patch':
|
|
205
|
+
case 'diff':
|
|
206
|
+
return 'diff';
|
|
207
|
+
default:
|
|
208
|
+
return 'plaintext';
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function setButtonState(button, isPrimary) {
|
|
213
|
+
if (isPrimary) {
|
|
214
|
+
button.classList.remove('secondary');
|
|
215
|
+
} else {
|
|
216
|
+
button.classList.add('secondary');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function buildIframe() {
|
|
221
|
+
const iframe = document.createElement('iframe');
|
|
222
|
+
iframe.setAttribute('title', 'Gitorial Editor');
|
|
223
|
+
iframe.style.width = '100%';
|
|
224
|
+
iframe.style.height = '100%';
|
|
225
|
+
iframe.style.border = '0';
|
|
226
|
+
iframe.style.display = 'block';
|
|
227
|
+
iframe.srcdoc = \`
|
|
228
|
+
<!doctype html>
|
|
229
|
+
<html>
|
|
230
|
+
<head>
|
|
231
|
+
<meta charset="utf-8" />
|
|
232
|
+
<style>
|
|
233
|
+
html, body { margin: 0; height: 100%; background: #0f0f10; }
|
|
234
|
+
#editor { height: 100%; }
|
|
235
|
+
</style>
|
|
236
|
+
</head>
|
|
237
|
+
<body>
|
|
238
|
+
<div id="editor"></div>
|
|
239
|
+
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.47.0/min/vs/loader.js"></script>
|
|
240
|
+
<script>
|
|
241
|
+
window.require.config({ paths: { vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.47.0/min/vs' } });
|
|
242
|
+
let editor;
|
|
243
|
+
let diffEditor;
|
|
244
|
+
let currentMode = 'single';
|
|
245
|
+
function getContainer() {
|
|
246
|
+
return document.getElementById('editor');
|
|
247
|
+
}
|
|
248
|
+
function clearContainer() {
|
|
249
|
+
const container = getContainer();
|
|
250
|
+
container.innerHTML = '';
|
|
251
|
+
return container;
|
|
252
|
+
}
|
|
253
|
+
function disposeEditor() {
|
|
254
|
+
if (editor) {
|
|
255
|
+
editor.dispose();
|
|
256
|
+
editor = null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function disposeDiffEditor() {
|
|
260
|
+
if (diffEditor) {
|
|
261
|
+
diffEditor.dispose();
|
|
262
|
+
diffEditor = null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function ensureEditor(content, language) {
|
|
266
|
+
window.require(['vs/editor/editor.main'], function () {
|
|
267
|
+
if (currentMode !== 'single') {
|
|
268
|
+
disposeDiffEditor();
|
|
269
|
+
clearContainer();
|
|
270
|
+
currentMode = 'single';
|
|
271
|
+
}
|
|
272
|
+
if (!editor) {
|
|
273
|
+
editor = monaco.editor.create(getContainer(), {
|
|
274
|
+
value: content,
|
|
275
|
+
language: language,
|
|
276
|
+
theme: 'vs-dark',
|
|
277
|
+
automaticLayout: true,
|
|
278
|
+
readOnly: true,
|
|
279
|
+
});
|
|
280
|
+
} else {
|
|
281
|
+
const model = monaco.editor.createModel(content, language);
|
|
282
|
+
editor.setModel(model);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
function ensureDiffEditor(original, modified, language) {
|
|
287
|
+
window.require(['vs/editor/editor.main'], function () {
|
|
288
|
+
if (currentMode !== 'diff') {
|
|
289
|
+
disposeEditor();
|
|
290
|
+
clearContainer();
|
|
291
|
+
currentMode = 'diff';
|
|
292
|
+
}
|
|
293
|
+
if (!diffEditor) {
|
|
294
|
+
diffEditor = monaco.editor.createDiffEditor(getContainer(), {
|
|
295
|
+
theme: 'vs-dark',
|
|
296
|
+
automaticLayout: true,
|
|
297
|
+
readOnly: true,
|
|
298
|
+
renderSideBySide: true,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
const originalModel = monaco.editor.createModel(original, language);
|
|
302
|
+
const modifiedModel = monaco.editor.createModel(modified, language);
|
|
303
|
+
diffEditor.setModel({ original: originalModel, modified: modifiedModel });
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
window.addEventListener('message', function (event) {
|
|
307
|
+
const data = event.data || {};
|
|
308
|
+
if (!data.type) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (data.type === 'init' || data.type === 'set') {
|
|
312
|
+
ensureEditor(data.content || '', data.language || 'plaintext');
|
|
313
|
+
} else if (data.type === 'diff') {
|
|
314
|
+
ensureDiffEditor(data.original || '', data.modified || '', data.language || 'plaintext');
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
</script>
|
|
318
|
+
</body>
|
|
319
|
+
</html>\`;
|
|
320
|
+
return iframe;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async function initMonaco(container) {
|
|
324
|
+
const manifestUrl = container.dataset.manifest;
|
|
325
|
+
const config = await loadJson(manifestUrl);
|
|
326
|
+
|
|
327
|
+
const toolbar = container.querySelector('[data-gitorial-toolbar]');
|
|
328
|
+
const select = container.querySelector('[data-gitorial-files]');
|
|
329
|
+
const toggle = container.querySelector('[data-gitorial-toggle]');
|
|
330
|
+
const diffToggle = container.querySelector('[data-gitorial-diff]');
|
|
331
|
+
const footer = container.querySelector('[data-gitorial-footer]');
|
|
332
|
+
const editorNode = container.querySelector('[data-gitorial-editor]');
|
|
333
|
+
const iframe = buildIframe();
|
|
334
|
+
editorNode.appendChild(iframe);
|
|
335
|
+
let iframeReady = false;
|
|
336
|
+
let pendingPayload = null;
|
|
337
|
+
|
|
338
|
+
iframe.addEventListener('load', () => {
|
|
339
|
+
iframeReady = true;
|
|
340
|
+
if (pendingPayload) {
|
|
341
|
+
iframe.contentWindow.postMessage(pendingPayload, '*');
|
|
342
|
+
pendingPayload = null;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
let currentMode = 'template';
|
|
347
|
+
let previousMode = 'template';
|
|
348
|
+
let selectedLabel = null;
|
|
349
|
+
let templateFiles = config.template || [];
|
|
350
|
+
let solutionFiles = config.solution || [];
|
|
351
|
+
|
|
352
|
+
if (!solutionFiles.length) {
|
|
353
|
+
toggle.style.display = 'none';
|
|
354
|
+
footer.textContent = 'Template view only.';
|
|
355
|
+
diffToggle.style.display = 'none';
|
|
356
|
+
} else {
|
|
357
|
+
footer.textContent = 'Template view. Click View solution to compare.';
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function formatOptionLabel(file) {
|
|
361
|
+
if (!file) {
|
|
362
|
+
return '';
|
|
363
|
+
}
|
|
364
|
+
let marker = '';
|
|
365
|
+
if (file.status === 'A') {
|
|
366
|
+
marker = '[+]';
|
|
367
|
+
} else if (file.status === 'M') {
|
|
368
|
+
marker = '[~]';
|
|
369
|
+
} else if (file.status === 'D') {
|
|
370
|
+
marker = '[-]';
|
|
371
|
+
} else {
|
|
372
|
+
marker = '[ ]';
|
|
373
|
+
}
|
|
374
|
+
return marker + ' ' + file.label;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function updateFileOptions() {
|
|
378
|
+
let list = currentMode === 'template' ? templateFiles : solutionFiles;
|
|
379
|
+
if (currentMode === 'diff') {
|
|
380
|
+
const byLabel = new Map();
|
|
381
|
+
templateFiles.forEach((file) => byLabel.set(file.label, file));
|
|
382
|
+
solutionFiles.forEach((file) => {
|
|
383
|
+
if (byLabel.has(file.label)) {
|
|
384
|
+
const existing = byLabel.get(file.label);
|
|
385
|
+
byLabel.set(file.label, { ...existing, status: file.status || existing.status });
|
|
386
|
+
} else {
|
|
387
|
+
byLabel.set(file.label, file);
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
list = Array.from(byLabel.values());
|
|
391
|
+
}
|
|
392
|
+
select.innerHTML = '';
|
|
393
|
+
list.forEach((file, index) => {
|
|
394
|
+
const option = document.createElement('option');
|
|
395
|
+
option.value = file.label;
|
|
396
|
+
option.textContent = formatOptionLabel(file);
|
|
397
|
+
if (selectedLabel && selectedLabel === file.label) {
|
|
398
|
+
option.selected = true;
|
|
399
|
+
} else if (!selectedLabel && index === 0) {
|
|
400
|
+
option.selected = true;
|
|
401
|
+
}
|
|
402
|
+
select.appendChild(option);
|
|
403
|
+
});
|
|
404
|
+
if (!selectedLabel && list.length) {
|
|
405
|
+
selectedLabel = list[0].label;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function getFileContent(filePath) {
|
|
410
|
+
return fetch(filePath).then((res) => res.text());
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function findFile(list, label) {
|
|
414
|
+
return list.find((file) => file.label === label) || null;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
async function postToIframe(payload) {
|
|
418
|
+
if (iframeReady) {
|
|
419
|
+
iframe.contentWindow.postMessage(payload, '*');
|
|
420
|
+
} else {
|
|
421
|
+
pendingPayload = payload;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
async function setEditorFile(label) {
|
|
426
|
+
if (!label) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (currentMode === 'diff') {
|
|
430
|
+
const templateFile = findFile(templateFiles, label);
|
|
431
|
+
const solutionFile = findFile(solutionFiles, label);
|
|
432
|
+
const original = templateFile ? await getFileContent(templateFile.path) : '';
|
|
433
|
+
const modified = solutionFile ? await getFileContent(solutionFile.path) : '';
|
|
434
|
+
const language = detectMode((solutionFile || templateFile || { path: '' }).path);
|
|
435
|
+
await postToIframe({ type: 'diff', original, modified, language });
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const list = currentMode === 'template' ? templateFiles : solutionFiles;
|
|
440
|
+
const file = findFile(list, label);
|
|
441
|
+
if (!file) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
const content = await getFileContent(file.path);
|
|
445
|
+
const language = detectMode(file.path);
|
|
446
|
+
await postToIframe({ type: 'set', content, language });
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function currentFiles() {
|
|
450
|
+
return currentMode === 'template' ? templateFiles : solutionFiles;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
updateFileOptions();
|
|
454
|
+
if (!select.value) {
|
|
455
|
+
footer.textContent = 'No files available for this step.';
|
|
456
|
+
toggle.style.display = 'none';
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
selectedLabel = select.value;
|
|
460
|
+
await setEditorFile(selectedLabel);
|
|
461
|
+
|
|
462
|
+
select.addEventListener('change', async () => {
|
|
463
|
+
selectedLabel = select.value;
|
|
464
|
+
await setEditorFile(selectedLabel);
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
toggle.addEventListener('click', async () => {
|
|
468
|
+
if (!solutionFiles.length) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
currentMode = currentMode === 'template' ? 'solution' : 'template';
|
|
472
|
+
updateFileOptions();
|
|
473
|
+
setButtonState(toggle, currentMode === 'template');
|
|
474
|
+
toggle.textContent = currentMode === 'template' ? 'View solution' : 'Back to template';
|
|
475
|
+
toggle.disabled = currentMode === 'diff';
|
|
476
|
+
footer.textContent =
|
|
477
|
+
currentMode === 'template'
|
|
478
|
+
? 'Template view. Click View solution to compare.'
|
|
479
|
+
: 'Solution view. Click Back to template to continue.';
|
|
480
|
+
if (select.value) {
|
|
481
|
+
selectedLabel = select.value;
|
|
482
|
+
await setEditorFile(selectedLabel);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
diffToggle.addEventListener('click', async () => {
|
|
487
|
+
if (!solutionFiles.length) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
if (currentMode === 'diff') {
|
|
491
|
+
currentMode = previousMode;
|
|
492
|
+
diffToggle.textContent = 'View diff';
|
|
493
|
+
} else {
|
|
494
|
+
previousMode = currentMode;
|
|
495
|
+
currentMode = 'diff';
|
|
496
|
+
diffToggle.textContent = 'Back to code';
|
|
497
|
+
}
|
|
498
|
+
updateFileOptions();
|
|
499
|
+
toggle.disabled = currentMode === 'diff';
|
|
500
|
+
if (select.value) {
|
|
501
|
+
selectedLabel = select.value;
|
|
502
|
+
await setEditorFile(selectedLabel);
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function boot() {
|
|
508
|
+
const containers = document.querySelectorAll('[data-gitorial-monaco]');
|
|
509
|
+
if (!containers.length) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
containers.forEach((container) => {
|
|
513
|
+
initMonaco(container).catch((error) => {
|
|
514
|
+
console.error(error);
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
window.__gitorialBoot = boot;
|
|
520
|
+
})();
|
|
521
|
+
`;
|
|
522
|
+
|
|
523
|
+
const monacoEmbed = (relativeAssetBase, manifestPath) => `
|
|
524
|
+
<link rel="stylesheet" href="${relativeAssetBase}/monaco-setup.css">
|
|
525
|
+
<script src="${relativeAssetBase}/monaco-setup.js"></script>
|
|
526
|
+
|
|
527
|
+
<div class="gitorial-monaco" data-gitorial-monaco data-manifest="${manifestPath}">
|
|
528
|
+
<div class="gitorial-monaco-toolbar" data-gitorial-toolbar>
|
|
529
|
+
<span class="label">File</span>
|
|
530
|
+
<select class="file-select" data-gitorial-files></select>
|
|
531
|
+
<button class="toggle" data-gitorial-toggle>View solution</button>
|
|
532
|
+
<button class="diff-toggle" data-gitorial-diff>View diff</button>
|
|
533
|
+
</div>
|
|
534
|
+
<div class="gitorial-monaco-editor" data-gitorial-editor></div>
|
|
535
|
+
<div class="gitorial-monaco-footer" data-gitorial-footer></div>
|
|
536
|
+
</div>
|
|
537
|
+
|
|
538
|
+
<script>
|
|
539
|
+
if (window.__gitorialBoot) {
|
|
540
|
+
window.__gitorialBoot();
|
|
541
|
+
}
|
|
542
|
+
</script>
|
|
543
|
+
`;
|
|
544
|
+
|
|
545
|
+
module.exports = {
|
|
546
|
+
monacoCss,
|
|
547
|
+
monacoSetup,
|
|
548
|
+
monacoEmbed,
|
|
549
|
+
};
|