feat: side-by-side diff view + auto-save skips backup
- Side-by-side diff: toggle button (columns-2/align-justify icon) in toolbar switches between unified and side-by-side view - Backend: diff endpoint returns left_content + right_content for side-by-side - Frontend: SequenceMatcher-based LCS diff for two-column rendering - CSS: .backup-diff-sidebyside with left/right borders, empty cell styling - Auto-save: PUT /save?backup=false skips backup creation (auto-save=no backup) - Footer text updated to reflect backup-on-manual-save behavior
This commit is contained in:
+6
-2
@@ -1346,6 +1346,7 @@ async def api_file_save(
|
||||
vault_name: str,
|
||||
path: str = Query(..., description="Relative path to file"),
|
||||
body: dict = Body(...),
|
||||
backup: bool = Query(True, description="Create a backup before saving (default true, set false for auto-save)"),
|
||||
current_user=Depends(require_auth),
|
||||
):
|
||||
"""Save (overwrite) a file's content.
|
||||
@@ -1376,8 +1377,9 @@ async def api_file_save(
|
||||
content = body.get('content', '')
|
||||
|
||||
try:
|
||||
# Backup original content before overwriting
|
||||
_backup_file(file_path, vault_name, path)
|
||||
# Backup original content before overwriting (skip on auto-save)
|
||||
if backup:
|
||||
_backup_file(file_path, vault_name, path)
|
||||
|
||||
file_path.write_text(content, encoding="utf-8")
|
||||
logger.info(f"File saved: {vault_name}/{path}")
|
||||
@@ -2119,6 +2121,8 @@ async def api_file_diff(
|
||||
"version": version,
|
||||
"compare_with": compare_with,
|
||||
"diff": "".join(diff_lines),
|
||||
"left_content": left_content,
|
||||
"right_content": right_content,
|
||||
}
|
||||
except HTTPException:
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user