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:
dong.nguyen committed 2026-10-22 09:55:24 +07:00
1 parent f113dfc7b5
commit 6482c993e8
24 files changed
+2523 -52

No files matched your search

+351
View File
@@ -2086,3 +2086,354 @@
.back-to-top:hover {
background: var(--accent-hover);
}
/* ── Edit mode (spec-v4 §5.5, §5.4) ─────────────────────────────────────
The Save bar and the JSON panel are chrome, not page content: they sit
fixed over the site, use the 13px chrome type step, and never participate
in the prose scale. The site underneath is untouched. ────────────────── */
.edit-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 900;
background: var(--bg-elevated);
border-top: 1px solid var(--border-strong);
padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
font-size: 13px;
line-height: 1.5;
max-height: 45vh;
overflow-y: auto;
}
.edit-bar-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
.edit-bar-title {
color: var(--accent);
}
.edit-bar-count {
color: var(--text-secondary);
}
.edit-bar-branch {
color: var(--text-secondary);
font-size: 13px;
}
.edit-bar-branch code {
color: var(--accent);
}
.edit-bar-warn {
color: var(--warning);
}
.edit-bar-actions {
margin-left: auto;
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.edit-btn {
background: transparent;
color: var(--text-primary);
border: 1px solid var(--border-strong);
border-radius: 6px;
padding: 6px 12px;
font: inherit;
font-size: 13px;
cursor: pointer;
transition: border-color var(--transition-fast), background var(--transition-fast);
}
.edit-btn:hover:not(:disabled) {
border-color: var(--accent);
color: var(--accent);
}
.edit-btn:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.edit-btn:disabled {
opacity: 0.45;
cursor: default;
}
.edit-btn-primary {
background: var(--accent-solid);
border-color: var(--accent-solid);
color: var(--text-on-accent-solid);
}
.edit-btn-primary:hover:not(:disabled) {
background: var(--accent-solid-hover);
border-color: var(--accent-solid-hover);
color: var(--text-on-accent-solid);
}
.edit-bar-diff {
margin-top: 10px;
display: grid;
gap: 10px;
}
.edit-bar-doc {
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px 10px;
}
.edit-bar-doc-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 6px;
}
.edit-bar-doc ul {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 4px;
}
.edit-bar-doc li {
display: flex;
align-items: baseline;
gap: 8px;
flex-wrap: wrap;
}
.edit-bar-path {
color: var(--accent);
font-size: 12px;
}
.edit-bar-value {
color: var(--text-secondary);
max-width: 34ch;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.edit-bar-conflicts {
margin-top: 10px;
display: grid;
gap: 6px;
color: var(--warning);
}
.edit-bar-conflict {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.edit-bar-issues,
.edit-bar-save {
margin: 10px 0 0;
padding: 0;
list-style: none;
display: grid;
gap: 3px;
}
.edit-bar-issues {
color: var(--error);
}
.edit-bar-save code {
color: var(--text-secondary);
}
.edit-bar-note {
margin-top: 8px;
color: var(--success);
}
.json-panel {
position: fixed;
top: 0;
right: 0;
bottom: 0;
z-index: 950;
width: min(620px, 100%);
background: var(--bg-elevated);
border-left: 1px solid var(--border-strong);
padding: 14px 16px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 10px;
font-size: 13px;
}
.json-panel-head {
display: flex;
align-items: center;
justify-content: space-between;
}
.json-panel-tabs {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.json-panel-tab {
background: transparent;
border: 1px solid var(--border);
border-radius: 6px;
padding: 4px 8px;
color: var(--text-secondary);
font: inherit;
font-size: 12px;
cursor: pointer;
}
.json-panel-tab.is-active {
border-color: var(--accent);
color: var(--accent);
}
.json-panel-conflict-flag {
color: var(--warning);
}
.json-panel-shape {
margin: 0;
padding: 8px 10px;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text-muted);
font-size: 12px;
white-space: pre-wrap;
}
.json-panel-tools,
.json-panel-records {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.json-panel-record {
display: inline-flex;
align-items: center;
gap: 6px;
border: 1px solid var(--border);
border-radius: 6px;
padding: 3px 8px;
color: var(--text-secondary);
}
.json-panel-readonly {
color: var(--text-muted);
}
.json-panel-section-add select {
background: var(--bg-surface);
color: var(--text-primary);
border: 1px solid var(--border-strong);
border-radius: 6px;
padding: 4px 6px;
font: inherit;
font-size: 12px;
}
.json-panel-merge {
display: grid;
gap: 6px;
border: 1px solid var(--warning);
border-radius: 8px;
padding: 8px 10px;
}
.json-panel-merge textarea {
min-height: 140px;
}
.json-panel-editor {
flex: 1;
min-height: 300px;
background: var(--bg-surface);
color: var(--text-primary);
border: 1px solid var(--border-strong);
border-radius: 8px;
padding: 10px;
font-family: ui-monospace, 'Cascadia Mono', 'Consolas', monospace;
font-size: 12.5px;
line-height: 1.5;
resize: vertical;
}
.json-panel-editor:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 1px;
}
.json-panel-issues {
margin: 0;
padding: 0;
list-style: none;
display: grid;
gap: 3px;
color: var(--error);
}
.json-panel-status {
color: var(--text-muted);
}
/* Inline editing affordances (§5.3): outline only — the element itself stays
the site's own, so the page keeps its exact rendering outside edit mode. */
.editable-text {
outline: 1px dashed transparent;
outline-offset: 2px;
border-radius: 2px;
}
.editable-text:hover {
outline-color: var(--border-strong);
}
.editable-text:focus-visible {
outline-color: var(--accent);
}
.edit-dirty {
outline-style: solid;
outline-color: var(--accent-soft);
box-shadow: inset 2px 0 0 var(--accent);
}
.edit-invalid {
outline-color: var(--error);
background: var(--accent-tint);
}
@media (max-width: 768px) {
.json-panel {
width: 100%;
}
.edit-bar-actions {
margin-left: 0;
}
}