Skip to content
Snippets Groups Projects
Commit b44b3745 authored by Alexandra's avatar Alexandra
Browse files

fix: marked module not include in bundle

parent b4708de1
No related branches found
No related tags found
No related merge requests found
import View from "./view";
import View from './view';
import * as vscode from "vscode";
import * as vscode from 'vscode';
import { marked } from 'marked';
import * as path from 'path';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const marked = require("marked");
const fs = require("fs");
import * as path from "path";
const fs = require('fs');
import { DOCS_PATH, BRIEFING_FILE_NAME } from "../core/config";
import { WebviewBase } from "./webviewBase";
import { OPEN_BRIEFING_COMMAND } from "../theia/command";
import { DOCS_PATH, BRIEFING_FILE_NAME } from '../core/config';
import { WebviewBase } from './webviewBase';
import { OPEN_BRIEFING_COMMAND } from '../theia/command';
import { userConfig } from "../extension";
import { setInterval } from "timers";
import { userConfig } from '../extension';
import { setInterval } from 'timers';
export const BRIEFING_ID = "brefingView";
export const BRIEFING_ID = 'brefingView';
export default class BriefingView extends WebviewBase {
private briefingContent: string | undefined;
......@@ -23,12 +24,12 @@ export default class BriefingView extends WebviewBase {
private loadingBriefing: boolean = false;
constructor() {
super(BRIEFING_ID, "Briefing", OPEN_BRIEFING_COMMAND);
super(BRIEFING_ID, 'Briefing', OPEN_BRIEFING_COMMAND);
}
toBase64(file: string) {
const result = fs.readFileSync(path.join(DOCS_PATH, file), {
encoding: "base64",
encoding: 'base64',
});
return result;
}
......@@ -37,8 +38,8 @@ export default class BriefingView extends WebviewBase {
const imageRegex = /\!\[(.*?)\]\(\b(image:)(.*?\))?/g
return text.replace(imageRegex, (match, title, imagePrefix, img) => {
const fileName = img.replace(")", "");
const extension = fileName.split("\.");
const fileName = img.replace(')', '');
const extension = fileName.split('.');
return `![${title}](data:image/${
extension[extension.length - 1]
......@@ -62,12 +63,12 @@ export default class BriefingView extends WebviewBase {
this.briefingContent = this.setupImages(document.getText());
} catch (e) {
console.error(e);
this.briefingContent = "Error while parsing your briefing."
this.briefingContent = 'Error while parsing your briefing.'
}
this.show();
},
(error) => {
console.error("Cannot load briefing", error);
console.error('Cannot load briefing', error);
this.errorLoadingBriefing = true;
}
);
......@@ -76,7 +77,7 @@ export default class BriefingView extends WebviewBase {
}
render() {
let output = "";
let output = '';
if (userConfig.isProfessor()) {
output += `
......@@ -94,32 +95,32 @@ export default class BriefingView extends WebviewBase {
if (this.briefingContent) {
output += `<h1>Mission Goal 🕶</h1>${marked(this.briefingContent)}`;
} else if (this.errorLoadingBriefing) {
output += "Cannot load briefing.";
output += 'Cannot load briefing.';
} else {
output += "Loading briefing..";
output += 'Loading briefing..';
}
output += "<br/>";
output += '<br/>';
if (userConfig.getUsername()) {
output += this.renderUserChallengeConfig();
} else {
output += "Loading help..";
output += 'Loading help..';
}
return output;
}
private renderUserChallengeConfig() {
let adresses = "";
let adresses = '';
let pathsLength = 0;
const paths = userConfig.getPaths();
for (const key in paths) {
if (key !== "3000") {
if (key !== '3000') {
pathsLength++;
const path = paths[key];
if (userConfig.getHost() === "localhost") {
if (userConfig.getHost() === 'localhost') {
adresses += `<li>${key} binded on <a href="http://${userConfig.getHost()}:${path}">${path}</a></li>`;
} else {
adresses += `<li>${key} binded on <a href="https://${userConfig.getHost()}/${path}/">${path}</a></li>`;
......@@ -131,6 +132,6 @@ export default class BriefingView extends WebviewBase {
return `<h3>Configuration</h3>You have the following adresses availables for your challenge : <ul>${adresses}</ul>`;
}
return "";
return '';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment