Skip to content
Open
58 changes: 54 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</head>

<body>
<textarea class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<textarea id="inputText" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This textarea doesn't need id, it is not used anywhere.

## CodeAssign Editor
Is a [SimpleMDE](https://simplemde.com/) Markdown editor powerd by [MarkJax](http://markjax.codeassign.com/) parser.

Expand All @@ -32,16 +32,66 @@
previewRender: markjax
});
```

And of course you can still write and use LaTeX:
$$\sum_{n=1}^{\infty} 2^{-n} = 1$$
</textarea>

<script>
function insertAfterCursor(string) {
var cursorCh = simplemde.codemirror.getCursor()["ch"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ;.

var cursorLine = simplemde.codemirror.getCursor()["line"]
var anchor = {line: cursorLine, ch: cursorCh}

simplemde.codemirror.doc.replaceRange(string, anchor)
}

var simplemde = new SimpleMDE({
previewRender: markjax,
previewRender: function(plainText, preview) {
setTimeout(function() {
markjax(plainText, preview);
}, 50);
return preview.innerHTML;
},
spellChecker: false,
indentWithTabs: false
indentWithTabs: false,
toolbar: [
"bold",
"italic",
"heading",
"|",
{
name: "latexExpr",
action: function latexExpr(editor) {
insertAfterCursor("$ $")
},
className: "fa fa-bar-chart-o",
title: "Latex Expression"
},
{
name: "latexEq",
action: function latexEq(editor) {
insertAfterCursor("$$ $$")
},
className: "fa fa-area-chart",
title: "Latex Equation"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both Latex Equation and Latex Expression are equations, only difference is the way they are shown, one is inline and other is block. So I think we should call these Inline math and Math block.

},
"|",
"quote",
"unordered-list",
"ordered-list",
"|",
"link",
"image",
"|",
"preview",
"side-by-side",
"fullscreen",
"|",
"guide"
],
"insertTexts": {
latexEq: ["", "%%"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not valid. We don't use % anywhere. https://github.com/NextStepWebs/simplemde-markdown-editor#configuration Check again what this configuration property means

}
});
SimpleMDE.toggleSideBySide(simplemde);
</script>
Expand Down