Skip to content

Commit

Permalink
Add CFG
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambushfall committed May 20, 2023
1 parent 64f83b5 commit 9f40e58
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
21 changes: 14 additions & 7 deletions editor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
const CSS_LINKS = [`https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css`];
// const CSS_LINKS = [`https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css`];

const CHEATSHEET = fetch("https://ambushfall-next13-app.vercel.app/MD_CHEATSHEET.MD").then(res => res.text())

const MD_CFG = {
async: true,
// pedantic: false,
gfm: true,
mangle: false,
headerIds: false
}

marked.use(MD_CFG);

const MD_PARSER = (rawMD) => DOMPurify.sanitize(marked.parse(rawMD));

// Elements
const editorCode = document.getElementById("editorCode");
Expand Down Expand Up @@ -59,14 +70,10 @@ async function createEditor(editorContainer) {
}
}

editorPreview.body.innerHTML = DOMPurify.sanitize(
marked.parse(editor.getValue())
);
editorPreview.body.innerHTML = MD_PARSER(editor.getValue())

editor.onDidChangeModelContent(() => {
editorPreview.body.innerHTML = DOMPurify.sanitize(
marked.parse(editor.getValue())
);
editorPreview.body.innerHTML = MD_PARSER(editor.getValue())
});

editorCopyButton.onclick = () => {
Expand Down
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,5 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.39.0-dev.20230519/min/vs/loader.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.39.0-dev.20230519/min/vs/editor/editor.main.nls.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.39.0-dev.20230519/min/vs/editor/editor.main.js"></script>
<script src="parserForLocalFile.js"></script>
<script src="editor.js"></script>
</html>
4 changes: 2 additions & 2 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ body {
.editor__code {
position: relative;
border: none;
flex-basis: 70%;
flex-basis:60%;
}

.editor__preview {
position: relative;
flex-basis: 30%;
flex-basis: 40%;
}

.editor__code > *,
Expand Down

0 comments on commit 9f40e58

Please sign in to comment.