cleanup and refactor

This commit is contained in:
th committed 2026-04-09 19:39:56 +02:00
1 parent 5f9db690a4
commit 73da8fb849
10 files changed
+91 -97

No files matched your search

+2 -6
View File
@@ -1,11 +1,9 @@
// ── Editor (card create/edit) ──
import { $, api, escRe, getCsrf } from './util.js';
import { $, esc, api, escRe, getCsrf, fuzzyMatch } from './util.js';
import { state, getChildren, CARD_COLORS } from './state.js';
import { renderMd, addCodeCopyButtons, formatTodoItems } from './markdown.js';
import { pushCardEdit, snapshotCard } from './undo.js';
import { fuzzyMatch } from './util.js';
import { esc } from './util.js';
const modal = $('modal');
const body = $('editor-body');
@@ -975,7 +973,6 @@ async function uploadFile(file) {
try {
const res = await fetch('api/upload', { method: 'POST', body: form, headers: { 'X-CSRF-Token': getCsrf() } });
const text = await res.text();
console.log('Upload response:', res.status, text.substring(0, 300));
const data = JSON.parse(text);
if (data.error) throw new Error(data.error);
if (data.url) {
@@ -988,8 +985,7 @@ async function uploadFile(file) {
body.selectionStart = body.selectionEnd = idx + md.length;
}
}
} catch (err) {
console.error('Upload failed:', err);
} catch {
const idx = body.value.indexOf(placeholder);
if (idx !== -1) {
body.value = body.value.substring(0, idx) + body.value.substring(idx + placeholder.length);