Update documentation system: improve structure, search, and editor
This commit is contained in:
+6
-3
@@ -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 ? '' : '';
|
||||
const re = new RegExp('!\\[([^\\]]*)\\]\\\(' + escPath + '\\)', 'g');
|
||||
function mdAlt(text) {
|
||||
return String(text || '').replace(/\\/g, '\\\\').replace(/\]/g, '\\]');
|
||||
}
|
||||
const replacement = (m, oldAlt) => newCaption ? '' : '';
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user