ui: problem_files: yaml editor with schema

This commit is contained in:
undefined committed 2021-05-20 02:06:57 +08:00
1 parent 3ab02d72d8
commit d0569a6816
6 files changed
+83 -11

No files matched your search

@@ -213,7 +213,6 @@ const page = new NamedPage('problem_files', () => {
}
async function startEdit(filename, value) {
console.log(filename, value);
const { default: Editor } = await import('vj/components/editor/index');
const promise = new ActionDialog({
$body: tpl`
@@ -223,7 +222,21 @@ const page = new NamedPage('problem_files', () => {
width: `${window.innerWidth - 200}px`,
height: `${window.innerHeight - 100}px`,
}).open();
const editor = new Editor($('[name="fileContent"]'), { value, autoResize: false, autoLayout: false });
const language = {
yaml: 'yaml',
yml: 'yaml',
txt: 'plain',
in: 'plain',
out: 'plain',
ans: 'plain',
}[filename.split('.').pop()];
const editor = new Editor($('[name="fileContent"]'), {
value,
autoResize: false,
autoLayout: false,
language,
model: `hydro://problem/file/${filename}`,
});
const action = await promise;
value = editor.value();
editor.destory();