-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
@@ -249,7 +276,7 @@ async function saveGoal() {
const name = document.getElementById('goal-name').value;
const level = document.getElementById('goal-level').value;
const category = document.getElementById('goal-category').value;
- const content = document.getElementById('goal-content').value;
+ const content = goalEditor ? goalEditor.value() : document.getElementById('goal-content').value;
if (!name) { alert('请输入目标名称'); return; }
@@ -277,6 +304,8 @@ async function saveGoal() {
}
}
+let goalEditor = null;
+
function editGoal(id) {
fetch(`${API_BASE}/${id}`)
.then(r => r.json())
@@ -285,8 +314,26 @@ function editGoal(id) {
document.getElementById('goal-name').value = g.name;
document.getElementById('goal-level').value = g.level || '入门';
document.getElementById('goal-category').value = g.category || '综合';
- document.getElementById('goal-content').value = g.content || '';
document.getElementById('goalModalTitle').textContent = '编辑目标';
+
+ // 初始化或更新 Markdown 编辑器
+ const contentEl = document.getElementById('goal-content');
+ if (window.EasyMDE) {
+ if (goalEditor) {
+ goalEditor.toTextArea();
+ goalEditor = null;
+ }
+ goalEditor = new EasyMDE({
+ element: contentEl,
+ spellChecker: false,
+ status: false,
+ toolbar: ['bold', 'italic', 'heading', '|', 'code', 'quote', 'unordered-list', '|', 'preview', 'side-by-side', 'fullscreen'],
+ initialValue: g.content || ''
+ });
+ } else {
+ contentEl.value = g.content || '';
+ }
+
new bootstrap.Modal(document.getElementById('goalModal')).show();
});
}
@@ -406,8 +453,13 @@ document.getElementById('goalModal').addEventListener('hidden.bs.modal', () => {
document.getElementById('goal-name').value = '';
document.getElementById('goal-level').value = '入门';
document.getElementById('goal-category').value = '综合';
- document.getElementById('goal-content').value = '';
document.getElementById('goalModalTitle').textContent = '新建目标';
+ // 清理 Markdown 编辑器
+ if (goalEditor) {
+ goalEditor.toTextArea();
+ goalEditor = null;
+ }
+ document.getElementById('goal-content').value = '';
});
loadGoals();
diff --git a/app/templates/problems.html b/app/templates/problems.html
index 4c7c918..b5397a2 100644
--- a/app/templates/problems.html
+++ b/app/templates/problems.html
@@ -12,6 +12,16 @@
.category-演奏能力 { background: #e8f5e9; color: #2e7d32; }
.category-其他 { background: #fff3e0; color: #e65100; }
.editor-textarea { font-family: monospace; font-size: 13px; }
+.modal-footer-with-top {
+ display: flex;
+ justify-content: flex-end;
+ gap: 0.5rem;
+ padding: 1rem;
+ border-top: 1px solid #dee2e6;
+ background: #f8f9fa;
+ position: sticky;
+ bottom: 0;
+}
{% endblock %}
@@ -121,25 +131,31 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-