Update documentation system: improve structure, search, and editor

This commit is contained in:
dev
2026-11-01 14:44:05 +03:00
parent 9a509fa742
commit 773e092253
6 changed files with 40 additions and 30 deletions
+6 -3
View File
@@ -902,8 +902,11 @@ async function updateDocImageCaption(pool, user, id, caption) {
if (article.can_edit) {
const path = current.path;
const escPath = path.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const re = new RegExp('!\\[[^\\]]*\\]\\(' + escPath + '(?:\\s+"[^"]*")?\\)', 'g');
const replacement = () => newCaption ? '![' + newCaption + '](' + path + ')' : '![](' + path + ')';
const re = new RegExp('!\\[([^\\]]*)\\]\\\(' + escPath + '\\)', 'g');
function mdAlt(text) {
return String(text || '').replace(/\\/g, '\\\\').replace(/\]/g, '\\]');
}
const replacement = (m, oldAlt) => newCaption ? '![' + mdAlt(newCaption) + '](' + path + ')' : '![' + mdAlt(oldAlt) + '](' + path + ')';
const newBody = String(article.body || '').replace(re, replacement);
if (newBody !== article.body) {
await pool.query('UPDATE doc_articles SET body = $1, updated_at = now() WHERE id = $2', [newBody, current.article_id]);
@@ -916,7 +919,7 @@ async function updateDocImageCaption(pool, user, id, caption) {
async function listAllDocImages(pool, user) {
const { rows } = await pool.query(
`SELECT id, article_id, path, uploaded_by, created_at FROM doc_images ORDER BY created_at DESC`
`SELECT id, article_id, path, caption, uploaded_by, created_at FROM doc_images ORDER BY created_at DESC`
);
return rows;
}