remove codemirror instead of deprecating it
This commit is contained in:
parent
6243eb0596
commit
9f4c67eb66
10 changed files with 3 additions and 24996 deletions
|
|
@ -15,13 +15,13 @@ _(Work toward next release. Currently under development.)_
|
|||
|
||||
**DEPRECATED**
|
||||
|
||||
* Deprecated `'codemirror'` interface for the `pythoncode` question type (to be
|
||||
removed in version 21)
|
||||
|
||||
**REMOVED**
|
||||
|
||||
* Stopped officially supporting Python 3.8, 3.9, and 3.10
|
||||
|
||||
* Removed `'codemirror'` interface from the `pythoncode` question type (use
|
||||
`'ace'` instead).
|
||||
|
||||
**FIXED**
|
||||
|
||||
* Updated `reporter.py` script to work with up-to-date
|
||||
|
|
|
|||
|
|
@ -42,10 +42,6 @@ def get_sandbox(context):
|
|||
_execfile(base, context)
|
||||
|
||||
|
||||
CODEMIRROR_SCRIPTS = """
|
||||
<script type="text/javascript" src="BASE/js/codemirror/codemirror.bundle.min.js"></script>
|
||||
"""
|
||||
|
||||
ACE_SCRIPTS = """
|
||||
<script type="text/javascript" src="BASE/js/ace/ace.js"></script>
|
||||
"""
|
||||
|
|
@ -54,8 +50,6 @@ ACE_SCRIPTS = """
|
|||
def extra_headers(info):
|
||||
if info["csq_interface"] == "ace":
|
||||
return ACE_SCRIPTS
|
||||
elif info["csq_interface"] == "codemirror":
|
||||
return CODEMIRROR_SCRIPTS
|
||||
else:
|
||||
return None
|
||||
|
||||
|
|
@ -616,21 +610,6 @@ def render_html_upload(last_log, **info):
|
|||
return out
|
||||
|
||||
|
||||
def render_html_codemirror(last_log, **info):
|
||||
name = info["csq_name"]
|
||||
init = last_log.get(name, None)
|
||||
if init is None:
|
||||
init = make_initial_display(info)
|
||||
else:
|
||||
init = html.escape(get_code(init, info))
|
||||
return (
|
||||
f'\n<textarea name="{name}" id="{name}">{init}</textarea>'
|
||||
'\n<script type="text/javascript">'
|
||||
f"\nvar cs_codemirror_{name} = catsoop.codemirror.editorFromTextArea(document.getElementById('{name}'), 'python');"
|
||||
"\n</script>"
|
||||
)
|
||||
|
||||
|
||||
def render_html_ace(last_log, **info):
|
||||
name = info["csq_name"]
|
||||
init = last_log.get(name, None)
|
||||
|
|
@ -685,7 +664,6 @@ def render_html_ace(last_log, **info):
|
|||
RENDERERS = {
|
||||
"ace": render_html_ace,
|
||||
"textarea": render_html_textarea,
|
||||
"codemirror": render_html_codemirror,
|
||||
"upload": render_html_upload,
|
||||
}
|
||||
|
||||
|
|
|
|||
2
catsoop/__STATIC__/js/codemirror/.gitignore
vendored
2
catsoop/__STATIC__/js/codemirror/.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
|||
node_modules
|
||||
package-lock.json
|
||||
4
catsoop/__STATIC__/js/codemirror/_build.sh
vendored
4
catsoop/__STATIC__/js/codemirror/_build.sh
vendored
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
npm install
|
||||
node_modules/.bin/rollup editor.mjs -f iife -n catsoop.codemirror -o codemirror.bundle.js -p @rollup/plugin-node-resolve
|
||||
node_modules/.bin/uglifyjs --source-map -c -o codemirror.bundle.min.js codemirror.bundle.js
|
||||
9
catsoop/__STATIC__/js/codemirror/_test.html
vendored
9
catsoop/__STATIC__/js/codemirror/_test.html
vendored
|
|
@ -1,9 +0,0 @@
|
|||
<script src="codemirror.bundle.min.js"></script>
|
||||
|
||||
<textarea id="wtf">
|
||||
hey
|
||||
</textarea>
|
||||
|
||||
<script>
|
||||
x = catsoop.codemirror.editorFromTextArea(document.getElementById("wtf"))
|
||||
</script>
|
||||
24869
catsoop/__STATIC__/js/codemirror/codemirror.bundle.js
vendored
24869
catsoop/__STATIC__/js/codemirror/codemirror.bundle.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
70
catsoop/__STATIC__/js/codemirror/editor.mjs
vendored
70
catsoop/__STATIC__/js/codemirror/editor.mjs
vendored
|
|
@ -1,70 +0,0 @@
|
|||
import {EditorView, basicSetup} from "codemirror"
|
||||
import { pythonLanguage } from "@codemirror/lang-python"
|
||||
import { cpp } from "@codemirror/lang-cpp"
|
||||
import { LanguageSupport, indentUnit, bracketMatching } from "@codemirror/language";
|
||||
import { indentMore, indentLess } from "@codemirror/commands";
|
||||
import { keymap } from "@codemirror/view";
|
||||
|
||||
function python(){
|
||||
return new LanguageSupport(pythonLanguage);
|
||||
}
|
||||
|
||||
const indentString = " ";
|
||||
|
||||
function insertSoftTab({state, dispatch}){
|
||||
if (state.selection.ranges.some(r => !r.empty)){
|
||||
return indentMore({state, dispatch})
|
||||
}
|
||||
// math from https://discuss.codemirror.net/t/get-the-current-line-and-column-number-from-the-cursor-position/4162/2
|
||||
var currentColumn = state.selection.ranges[0].head - state.doc.lineAt(state.selection.main.head).from;
|
||||
dispatch(state.update(state.replaceSelection(" ".repeat(indentString.length - (currentColumn % indentString.length))), {scrollIntoView: true, userEvent: "input"}));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//// TODO: maybe implement shift-tab?
|
||||
//function deleteSoftTab({state, dispatch}){
|
||||
// if (state.selection.ranges.some(r => !r.empty)){
|
||||
// return indentLess({state, dispatch})
|
||||
// }
|
||||
// var currentColumn = state.selection.ranges[0].head - state.doc.lineAt(state.selection.main.head).from;
|
||||
// var lookBack = currentColumn % indentString.length;
|
||||
// if (lookBack === 0){
|
||||
// lookBack = indentString.length;
|
||||
// }
|
||||
// var prevChars
|
||||
// if (!/\S/.test(prevChars)){
|
||||
// }
|
||||
//}
|
||||
|
||||
const newTabKeymap = {
|
||||
key: 'Tab',
|
||||
run: insertSoftTab,
|
||||
shift: insertSoftTab,
|
||||
};
|
||||
|
||||
const languages = {
|
||||
python: python,
|
||||
cpp: cpp,
|
||||
}
|
||||
|
||||
export function editorFromTextArea(textarea, language){
|
||||
language = typeof language === "undefined" ? "python" : language;
|
||||
var extensions = [
|
||||
basicSetup,
|
||||
languages[language](),
|
||||
indentUnit.of(indentString),
|
||||
keymap.of([newTabKeymap]),
|
||||
bracketMatching(),
|
||||
EditorView.updateListener.of(function(){
|
||||
textarea.value = view.state.doc.toString();
|
||||
}),
|
||||
];
|
||||
var view = new EditorView({doc: textarea.value, extensions})
|
||||
textarea.parentNode.insertBefore(view.dom, textarea);
|
||||
textarea.style.display = "none";
|
||||
if (textarea.form) textarea.form.addEventListener("submit", () => {
|
||||
textarea.value = view.state.doc.toString();
|
||||
});
|
||||
return view;
|
||||
}
|
||||
15
catsoop/__STATIC__/js/codemirror/package.json
vendored
15
catsoop/__STATIC__/js/codemirror/package.json
vendored
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "^6.2.4",
|
||||
"@codemirror/gutter": "^0.19.9",
|
||||
"@codemirror/highlight": "^0.19.8",
|
||||
"@codemirror/lang-cpp": "^6.0.2",
|
||||
"@codemirror/lang-python": "^6.1.3",
|
||||
"@codemirror/matchbrackets": "^0.19.4",
|
||||
"@codemirror/view": "^6.15.3",
|
||||
"@rollup/plugin-node-resolve": "^15.1.0",
|
||||
"codemirror": "^6.0.1",
|
||||
"rollup": "^3.26.3",
|
||||
"uglify-js": "^3.17.4"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue