Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Prism with Monaco #165

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions inspector/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,21 @@ table, th, td {
.no-entries {
color: grey;
}

html, body {
margin: 0;
padding: 4px;
height: 115%;
/*overflow: hidden; !* Prevent scrollbars *!*/
}

#editor {
width: 100%;
height: 85vh;
}


#editor-container {
margin: 25px;
border: 1px solid lightgray;
}
34 changes: 30 additions & 4 deletions inspector/templates/code.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% block head %}
<link rel="stylesheet" type="text/css" href="/static/prism.css">
<link rel="stylesheet" type="text/css" href="/static/style.css">
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
{% endblock %}

{% block above_body %}
Expand All @@ -18,9 +19,34 @@

{% block body %}
<a href="{{ mailto_report_link }}" class="report-anchor"> <strong>Report Malicious Package</strong> </a>
<pre id="line" class="line-numbers linkable-line-numbers language-{{ name }}">
{#<pre id="line" class="line-numbers linkable-line-numbers language-{{ name }}">#}
{# Indenting the below <code> tag will cause rendering issues! #}
<code class="language-{{ name }}">{{- code }}</code>
</pre>
<script src="/static/prism.js"></script>
{#<code class="language-{{ name }}">{{- code }}</code>#}
{#</pre>#}
<div id="editor-container">
<div id="editor"></div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.48.0/min/vs/loader.min.js"></script>
<script>

let codeLiteral = {{code|tojson}};

// Configuration for loading Monaco Editor
require.config({ paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.48.0/min/vs/' }});

// Loading the editor
require(['vs/editor/editor.main'], function () {
window.editor = monaco.editor.create(document.getElementById('editor'), {
value: codeLiteral,
language: 'python',
automaticLayout: true,
readOnly: true,
scrollBeyondLastLine: false,
fontFamily: '"JetBrains Mono", monospace'
});

});

</script>
{% endblock %}
Loading