mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
feat(edit): live edit mode with draft store, inline editing, JSON panel, save bar, branch targeting
?edit entry with Basic-auth probe; DraftStore copy-on-write over live branch documents (?ref GET / branch PUT, last_commit_sha optimistic concurrency, three-way rebase on 412); EditableText inline editors; JsonPanel with templates and orphan-free delete; EditBar sequential-PUT save with conflict actions and merge hint on non-master branches. scripts/smoke-draft.ts regression check.
This commit is contained in:
1 parent
f113dfc7b5
commit
6482c993e8
24 files changed
+2523
-52
No files matched your search
@@ -26,6 +26,20 @@ export type ContentStructures = {
|
||||
|
||||
const hasHtml = (value: string) => value.includes('<') || value.includes('>');
|
||||
|
||||
// Walks every string value of a text document, collecting the document paths
|
||||
// of empty strings — an empty required value is a half-finished edit, never
|
||||
// content (rule 6). Mirrors the walk in findHtmlStrings.
|
||||
function findEmptyStrings(value: unknown, docPath: string): string[] {
|
||||
if (typeof value === 'string') return value.trim() === '' ? [docPath] : [];
|
||||
if (Array.isArray(value))
|
||||
return value.flatMap((item, i) => findEmptyStrings(item, `${docPath}[${i}]`));
|
||||
if (value && typeof value === 'object')
|
||||
return Object.entries(value).flatMap(([key, item]) =>
|
||||
findEmptyStrings(item, `${docPath}.${key}`),
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
// Walks every string value of a text document, collecting its document path.
|
||||
function findHtmlStrings(value: unknown, docPath: string): string[] {
|
||||
if (typeof value === 'string') return hasHtml(value) ? [docPath] : [];
|
||||
@@ -128,6 +142,15 @@ export function collectContentIssues(
|
||||
}
|
||||
}
|
||||
|
||||
// Rule 6: no empty text values in either language document. Every string in
|
||||
// a text document is a required field; the editor rejects an empty commit
|
||||
// with exactly this rule, and CI keeps an emptied field out of master.
|
||||
for (const [lang, doc] of [['vi', vi], ['en', en]] as const) {
|
||||
for (const path of findEmptyStrings(doc, `content.${lang}.json`)) {
|
||||
issues.push({ path, message: 'empty text value' });
|
||||
}
|
||||
}
|
||||
|
||||
return issues;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user