@kevlns/xlmerge 1.3.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +9 -4
- package/README.md +12 -6
- package/package.json +2 -2
- package/python/xlsx_merge_engine/xlsx_git_merge_bridge.py +24 -0
- package/python/xlsx_resolver/__init__.py +1 -1
- package/python/xlsx_resolver/formula_values.py +565 -0
- package/python/xlsx_resolver/merge_ui.html +345 -50
- package/python/xlsx_resolver/recalculate_workbook.ps1 +155 -0
- package/python/xlsx_resolver/xlsx_conflict.py +506 -113
- package/v-cli.plugin.json +5 -1
|
@@ -105,6 +105,15 @@ body {
|
|
|
105
105
|
align-items: center;
|
|
106
106
|
gap: 12px;
|
|
107
107
|
border-bottom: var(--border-width) solid var(--border-default);
|
|
108
|
+
flex-wrap: nowrap;
|
|
109
|
+
min-width: 0;
|
|
110
|
+
}
|
|
111
|
+
.sheet-scope {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
gap: 9px;
|
|
115
|
+
min-width: 0;
|
|
116
|
+
flex: 1 1 auto;
|
|
108
117
|
}
|
|
109
118
|
.sheet-choice { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
|
|
110
119
|
.macro-label { font-size: 11px; font-weight: 900; color: #3d3529; white-space: nowrap; }
|
|
@@ -152,6 +161,35 @@ body {
|
|
|
152
161
|
color: var(--text-muted);
|
|
153
162
|
}
|
|
154
163
|
.actions { flex: 0 0 auto; margin-left: 0; display: flex; gap: 8px; align-items: center; }
|
|
164
|
+
.sheet-actions {
|
|
165
|
+
flex: 0 0 auto;
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
gap: 7px;
|
|
169
|
+
padding: 4px 7px;
|
|
170
|
+
border: 2px solid #b8a66d;
|
|
171
|
+
background: rgba(255, 255, 255, .58);
|
|
172
|
+
}
|
|
173
|
+
.sheet-actions-label {
|
|
174
|
+
color: #6c5518;
|
|
175
|
+
font-size: 10px;
|
|
176
|
+
font-weight: 900;
|
|
177
|
+
white-space: nowrap;
|
|
178
|
+
}
|
|
179
|
+
.sheet-actions .btn { padding: 7px 11px; font-size: 12px; }
|
|
180
|
+
.global-stats {
|
|
181
|
+
flex: 0 0 auto;
|
|
182
|
+
display: inline-flex;
|
|
183
|
+
align-items: center;
|
|
184
|
+
gap: 7px;
|
|
185
|
+
padding: 5px 8px;
|
|
186
|
+
border-left: 2px solid #bfb5a0;
|
|
187
|
+
color: #332d24;
|
|
188
|
+
white-space: nowrap;
|
|
189
|
+
}
|
|
190
|
+
.global-stats-label { font-size: 11px; font-weight: 900; }
|
|
191
|
+
.global-stats-value { font-size: 16px; font-weight: 900; line-height: 1; }
|
|
192
|
+
.global-stats-divider { color: #8c806c; font-size: 16px; font-weight: 700; }
|
|
155
193
|
.btn {
|
|
156
194
|
padding: 8px 16px;
|
|
157
195
|
border: 1px solid #d8cfbd;
|
|
@@ -195,15 +233,45 @@ body {
|
|
|
195
233
|
font-weight: 600;
|
|
196
234
|
white-space: nowrap;
|
|
197
235
|
}
|
|
198
|
-
.table-
|
|
236
|
+
.table-stage {
|
|
199
237
|
flex: 1 1 auto;
|
|
200
238
|
min-width: 0;
|
|
201
239
|
min-height: 0;
|
|
240
|
+
position: relative;
|
|
241
|
+
}
|
|
242
|
+
.table-container {
|
|
243
|
+
width: 100%;
|
|
244
|
+
height: 100%;
|
|
202
245
|
overflow: auto;
|
|
203
246
|
overscroll-behavior: contain;
|
|
204
247
|
scrollbar-gutter: stable;
|
|
205
248
|
padding: 16px;
|
|
206
249
|
}
|
|
250
|
+
.confirmed-overlay {
|
|
251
|
+
position: absolute;
|
|
252
|
+
inset: 0;
|
|
253
|
+
z-index: 10;
|
|
254
|
+
display: flex;
|
|
255
|
+
align-items: center;
|
|
256
|
+
justify-content: center;
|
|
257
|
+
background: rgba(70, 70, 70, .58);
|
|
258
|
+
cursor: not-allowed;
|
|
259
|
+
}
|
|
260
|
+
.confirmed-overlay-mark {
|
|
261
|
+
width: 112px;
|
|
262
|
+
height: 112px;
|
|
263
|
+
border-radius: 50%;
|
|
264
|
+
display: flex;
|
|
265
|
+
align-items: center;
|
|
266
|
+
justify-content: center;
|
|
267
|
+
background: #2ca45d;
|
|
268
|
+
border: 6px solid #d8ffe5;
|
|
269
|
+
color: #fff;
|
|
270
|
+
font-size: 76px;
|
|
271
|
+
line-height: 1;
|
|
272
|
+
font-weight: 900;
|
|
273
|
+
box-shadow: 0 5px 0 #12552e, 0 0 28px rgba(0, 0, 0, .35);
|
|
274
|
+
}
|
|
207
275
|
table.diff-table {
|
|
208
276
|
border-collapse: collapse;
|
|
209
277
|
font-size: 13px;
|
|
@@ -272,6 +340,7 @@ tr.luban-header th:hover { background: #2d2d2d; color: #f2f2f2; }
|
|
|
272
340
|
box-shadow: 1px 1px 0 var(--shadow-edge);
|
|
273
341
|
}
|
|
274
342
|
.structure-toggle.is-delete { background: var(--tombstone); color: #fff; border-color: var(--tombstone-dark); }
|
|
343
|
+
.structure-toggle:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
|
|
275
344
|
.structure-badge { display: inline-block; padding: 2px 6px; border: 1px solid rgba(0,0,0,.28); font-size: 10px; font-weight: 800; }
|
|
276
345
|
.structure-badge.added { background: var(--incoming); color: #29401f; }
|
|
277
346
|
.structure-badge.local-existing { background: #eee8dc; color: #4b4438; border-color: #bdb4a4; }
|
|
@@ -282,7 +351,28 @@ tr.luban-header th:hover { background: #2d2d2d; color: #f2f2f2; }
|
|
|
282
351
|
.sheet-tab.sheet-added { background: var(--incoming); }
|
|
283
352
|
.sheet-tab.sheet-deleted { background: var(--tombstone); color: #fff; text-decoration: line-through; }
|
|
284
353
|
.sheet-tab.sheet-structural-conflict::before { content: '◆'; margin-right: 5px; color: #a8392f; }
|
|
354
|
+
.sheet-confirm-checkbox {
|
|
355
|
+
width: 15px;
|
|
356
|
+
height: 15px;
|
|
357
|
+
margin-right: 7px;
|
|
358
|
+
vertical-align: -2px;
|
|
359
|
+
accent-color: #278b52;
|
|
360
|
+
cursor: pointer;
|
|
361
|
+
}
|
|
362
|
+
.sheet-confirm-checkbox:focus-visible { outline: 2px solid #278b52; outline-offset: 2px; }
|
|
363
|
+
.conflict-nav { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
|
|
364
|
+
.conflict-nav .btn { padding: 6px 10px; font-size: 11px; }
|
|
365
|
+
.conflict-nav-count { min-width: 48px; text-align: center; color: #4b4438; font-size: 11px; font-weight: 800; }
|
|
285
366
|
.cell-locked { cursor: not-allowed !important; }
|
|
367
|
+
.conflict-cell-flash { animation: conflict-cell-flash .55s ease-in-out 2; position: relative; z-index: 1; }
|
|
368
|
+
@keyframes conflict-cell-flash {
|
|
369
|
+
0%, 100% { box-shadow: inset 0 0 0 2px rgba(47, 42, 34, .38); }
|
|
370
|
+
35%, 70% {
|
|
371
|
+
background-color: #b86cff !important;
|
|
372
|
+
background-image: none !important;
|
|
373
|
+
box-shadow: inset 0 0 0 999px rgba(184, 108, 255, .96), 0 0 20px 6px rgba(147, 61, 255, .88);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
286
376
|
.tooltip {
|
|
287
377
|
position: fixed;
|
|
288
378
|
display: none;
|
|
@@ -353,7 +443,9 @@ tr.luban-header th:hover { background: #2d2d2d; color: #f2f2f2; }
|
|
|
353
443
|
.toolbar { flex-wrap: wrap; }
|
|
354
444
|
.file-tabs { order: 3; flex: 1 0 100%; width: 100%; }
|
|
355
445
|
.actions { width: auto; margin-left: auto; }
|
|
356
|
-
.sheet-toolbar { align-items: flex-start; }
|
|
446
|
+
.sheet-toolbar { align-items: flex-start; flex-wrap: wrap; }
|
|
447
|
+
.sheet-scope { flex: 1 0 100%; }
|
|
448
|
+
.sheet-actions { margin-left: auto; }
|
|
357
449
|
.footer { align-items: flex-end; }
|
|
358
450
|
}
|
|
359
451
|
</style>
|
|
@@ -362,17 +454,30 @@ tr.luban-header th:hover { background: #2d2d2d; color: #f2f2f2; }
|
|
|
362
454
|
<div class="toolbar">
|
|
363
455
|
<h1>Excel 冲突解决工具</h1>
|
|
364
456
|
<div class="file-tabs" id="fileTabs"></div>
|
|
365
|
-
<div class="
|
|
366
|
-
<
|
|
367
|
-
<
|
|
368
|
-
<
|
|
369
|
-
<
|
|
370
|
-
<span class="stats"><span id="localCount">0</span> / <span id="totalCount">0</span></span>
|
|
457
|
+
<div class="global-stats" id="globalConfirmationStats" aria-label="全局冲突 Sheet 确认统计">
|
|
458
|
+
<span class="global-stats-label">冲突 Sheet 已确认</span>
|
|
459
|
+
<span class="global-stats-value" id="confirmedSheetCount">0</span>
|
|
460
|
+
<span class="global-stats-divider" aria-hidden="true">/</span>
|
|
461
|
+
<span class="global-stats-value" id="totalConflictSheetCount">0</span>
|
|
371
462
|
</div>
|
|
372
463
|
</div>
|
|
373
464
|
<div class="sheet-toolbar">
|
|
374
|
-
<
|
|
375
|
-
|
|
465
|
+
<div class="sheet-scope" aria-label="当前 Sheet 工区">
|
|
466
|
+
<span class="sheet-label">SHEET</span>
|
|
467
|
+
<div class="sheet-tabs" id="sheetTabs"></div>
|
|
468
|
+
<div class="sheet-actions" id="sheetActions" aria-label="当前 Sheet 操作">
|
|
469
|
+
<span class="sheet-actions-label">当前 Sheet 操作</span>
|
|
470
|
+
<button type="button" class="btn btn-local" id="allLocalBtn">全部本地</button>
|
|
471
|
+
<button type="button" class="btn btn-remote" id="allRemoteBtn">全部远端</button>
|
|
472
|
+
<button type="button" class="btn btn-undo" id="undoBtn">撤销</button>
|
|
473
|
+
<button type="button" class="btn btn-reset" id="resetBtn">重置</button>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
<div class="conflict-nav" id="conflictNav" aria-label="冲突定位">
|
|
477
|
+
<button type="button" class="btn" id="prevConflictBtn">上一个冲突</button>
|
|
478
|
+
<span class="conflict-nav-count" id="conflictNavCount">0 / 0</span>
|
|
479
|
+
<button type="button" class="btn" id="nextConflictBtn">下一个冲突</button>
|
|
480
|
+
</div>
|
|
376
481
|
<div class="sheet-choice" id="sheetChoice"></div>
|
|
377
482
|
</div>
|
|
378
483
|
<div class="diff-legend" id="diffLegend">
|
|
@@ -383,7 +488,9 @@ tr.luban-header th:hover { background: #2d2d2d; color: #f2f2f2; }
|
|
|
383
488
|
<span class="legend-item"><i class="legend-swatch legend-deleted"></i>已删除</span>
|
|
384
489
|
<span class="legend-item">悬停 Cell 查看 Base / 本地 / 远端</span>
|
|
385
490
|
</div>
|
|
386
|
-
<div class="table-
|
|
491
|
+
<div class="table-stage" id="tableStage">
|
|
492
|
+
<div class="table-container" id="tableContainer"></div>
|
|
493
|
+
</div>
|
|
387
494
|
<div class="tooltip" id="tooltip"></div>
|
|
388
495
|
<div class="commit-modal is-hidden" id="commitModal" role="dialog" aria-modal="true" aria-labelledby="commitModalTitle">
|
|
389
496
|
<div class="commit-modal-backdrop"></div>
|
|
@@ -422,7 +529,8 @@ function fileDecision(file) {
|
|
|
422
529
|
}
|
|
423
530
|
function sheetDecision(file, sheet) {
|
|
424
531
|
const target = fileDecision(file).sheets;
|
|
425
|
-
if (!target[sheet.name]) target[sheet.name] = {cells: {}, rows: {}, columns: {}};
|
|
532
|
+
if (!target[sheet.name]) target[sheet.name] = {cells: {}, rows: {}, columns: {}, confirmed: false};
|
|
533
|
+
if (typeof target[sheet.name].confirmed !== 'boolean') target[sheet.name].confirmed = false;
|
|
426
534
|
return target[sheet.name];
|
|
427
535
|
}
|
|
428
536
|
function cellKey(cell) { return cell.id || cell.coordinate; }
|
|
@@ -438,6 +546,7 @@ function initializeDecisions() {
|
|
|
438
546
|
if (file.macro) fileTarget.macro = file.macro.default || 'ours';
|
|
439
547
|
for (const sheet of file.diff.sheets) {
|
|
440
548
|
const target = sheetDecision(file, sheet);
|
|
549
|
+
target.confirmed = false;
|
|
441
550
|
const sheetChoice = defaultSheetChoice(sheet);
|
|
442
551
|
if (sheetChoice) target.sheet = sheetChoice;
|
|
443
552
|
if (sheet.renameStatus === 'rename_conflict') target.rename = 'ours';
|
|
@@ -481,6 +590,8 @@ function render() {
|
|
|
481
590
|
renderSheetTabs();
|
|
482
591
|
renderSheetChoice();
|
|
483
592
|
renderTable();
|
|
593
|
+
renderConflictNavigation();
|
|
594
|
+
renderActionAvailability();
|
|
484
595
|
updateStats();
|
|
485
596
|
}
|
|
486
597
|
function renderFileTabs() {
|
|
@@ -533,7 +644,20 @@ function renderSheetTabs() {
|
|
|
533
644
|
const deleted = sheet.action === 'auto_delete';
|
|
534
645
|
const structuralConflict = sheet.action.startsWith('conflict_') || sheet.renameStatus === 'rename_conflict' || (sheet.structuralConflictCount || 0) > 0;
|
|
535
646
|
tab.className = 'sheet-tab' + (index === currentSheet ? ' active' : '') + (added ? ' sheet-added' : '') + (deleted ? ' sheet-deleted' : '') + (structuralConflict ? ' sheet-structural-conflict' : '');
|
|
536
|
-
|
|
647
|
+
const target = sheetDecision(file, sheet);
|
|
648
|
+
const confirmation = document.createElement('input');
|
|
649
|
+
confirmation.type = 'checkbox';
|
|
650
|
+
confirmation.className = 'sheet-confirm-checkbox';
|
|
651
|
+
confirmation.checked = target.confirmed === true;
|
|
652
|
+
confirmation.title = '勾选表示你已人工审阅并确认本 Sheet 的所有冲突;取消勾选可继续编辑。';
|
|
653
|
+
confirmation.setAttribute('aria-label', `${sheet.name}:已确认(人工审阅完成)`);
|
|
654
|
+
confirmation.onclick = event => event.stopPropagation();
|
|
655
|
+
confirmation.onchange = event => {
|
|
656
|
+
event.stopPropagation();
|
|
657
|
+
target.confirmed = confirmation.checked;
|
|
658
|
+
render();
|
|
659
|
+
};
|
|
660
|
+
tab.append(confirmation, document.createTextNode(sheet.name));
|
|
537
661
|
const count = document.createElement('span');
|
|
538
662
|
count.className = 'tab-count';
|
|
539
663
|
count.textContent = sheetDecisionCount(file, sheet);
|
|
@@ -547,7 +671,7 @@ function renderSheetChoice() {
|
|
|
547
671
|
const file = currentFileData(); const sheet = currentSheetData();
|
|
548
672
|
const macro = file && file.macro;
|
|
549
673
|
if (macro && macro.status !== 'same') {
|
|
550
|
-
const label = document.createElement('span'); label.className = 'macro-label'; label.textContent = 'VBA/ActiveX';
|
|
674
|
+
const label = document.createElement('span'); label.className = 'macro-label'; label.textContent = '当前文件宏 · VBA/ActiveX';
|
|
551
675
|
host.append(label);
|
|
552
676
|
if (macro.status === 'conflict') {
|
|
553
677
|
const selected = fileDecision(file).macro || macro.default;
|
|
@@ -570,21 +694,22 @@ function renderSheetChoice() {
|
|
|
570
694
|
}
|
|
571
695
|
if (!sheet) return;
|
|
572
696
|
const target = sheetDecision(file, sheet);
|
|
697
|
+
const confirmed = sheetNeedsConfirmation(sheet) && target.confirmed;
|
|
573
698
|
if (sheet.renameStatus === 'rename_conflict') {
|
|
574
699
|
const local = document.createElement('button'); local.className = 'structure-toggle' + (target.rename === 'ours' ? '' : ' is-delete');
|
|
575
|
-
local.textContent = `本地名:${sheet.names.ours}`; local.onclick = () => chooseRename(file, sheet, 'ours');
|
|
700
|
+
local.textContent = `本地名:${sheet.names.ours}`; local.disabled = confirmed; local.onclick = () => chooseRename(file, sheet, 'ours');
|
|
576
701
|
const remote = document.createElement('button'); remote.className = 'structure-toggle' + (target.rename === 'theirs' ? '' : ' is-delete');
|
|
577
|
-
remote.textContent = `远端名:${sheet.names.theirs}`; remote.onclick = () => chooseRename(file, sheet, 'theirs');
|
|
702
|
+
remote.textContent = `远端名:${sheet.names.theirs}`; remote.disabled = confirmed; remote.onclick = () => chooseRename(file, sheet, 'theirs');
|
|
578
703
|
host.append(local, remote);
|
|
579
704
|
}
|
|
580
705
|
if (sheet.mergedCells && sheet.mergedCells.status === 'conflict') {
|
|
581
706
|
const label = document.createElement('span'); label.className = 'macro-label'; label.textContent = '合并表头';
|
|
582
707
|
const local = document.createElement('button');
|
|
583
708
|
local.className = 'btn btn-local macro-toggle' + (target.mergedCells === 'ours' ? ' is-selected' : '');
|
|
584
|
-
local.textContent = '本地结构'; local.onclick = () => chooseMergedCells(file, sheet, 'ours');
|
|
709
|
+
local.textContent = '本地结构'; local.disabled = confirmed; local.onclick = () => chooseMergedCells(file, sheet, 'ours');
|
|
585
710
|
const remote = document.createElement('button');
|
|
586
711
|
remote.className = 'btn btn-remote macro-toggle' + (target.mergedCells === 'theirs' ? ' is-selected' : '');
|
|
587
|
-
remote.textContent = '远端结构'; remote.onclick = () => chooseMergedCells(file, sheet, 'theirs');
|
|
712
|
+
remote.textContent = '远端结构'; remote.disabled = confirmed; remote.onclick = () => chooseMergedCells(file, sheet, 'theirs');
|
|
588
713
|
host.append(label, local, remote);
|
|
589
714
|
}
|
|
590
715
|
}
|
|
@@ -607,12 +732,15 @@ function renderTable() {
|
|
|
607
732
|
const sheet = currentSheetData();
|
|
608
733
|
const host = byId('tableContainer');
|
|
609
734
|
host.replaceChildren();
|
|
735
|
+
const oldOverlay = byId('confirmedOverlay');
|
|
736
|
+
if (oldOverlay) oldOverlay.remove();
|
|
610
737
|
if (!sheet) {
|
|
611
738
|
renderMessage(host, '无需处理', '两侧工作簿内容一致,没有需要展示的 Sheet 差异。');
|
|
612
739
|
return;
|
|
613
740
|
}
|
|
614
741
|
if (sheet.action.startsWith('conflict_')) {
|
|
615
742
|
renderSheetConflict(host, file, sheet);
|
|
743
|
+
renderConfirmedOverlay(host, file, sheet);
|
|
616
744
|
return;
|
|
617
745
|
}
|
|
618
746
|
if (sheet.action !== 'merge') {
|
|
@@ -622,9 +750,105 @@ function renderTable() {
|
|
|
622
750
|
auto_delete: '该 Sheet 的删除只发生在一侧,另一侧未修改,将自动删除。'
|
|
623
751
|
};
|
|
624
752
|
renderMessage(host, sheet.name, labels[sheet.action] || `将自动执行:${sheet.action}`);
|
|
753
|
+
renderConfirmedOverlay(host, file, sheet);
|
|
625
754
|
return;
|
|
626
755
|
}
|
|
627
756
|
renderDiffTable(host, file, sheet);
|
|
757
|
+
renderConfirmedOverlay(host, file, sheet);
|
|
758
|
+
}
|
|
759
|
+
function sheetNeedsConfirmation(sheet) {
|
|
760
|
+
return !!sheet && sheet.needsAttention !== false;
|
|
761
|
+
}
|
|
762
|
+
function renderConfirmedOverlay(host, file, sheet) {
|
|
763
|
+
if (!sheetNeedsConfirmation(sheet) || !sheetDecision(file, sheet).confirmed) return;
|
|
764
|
+
const overlay = document.createElement('div');
|
|
765
|
+
overlay.id = 'confirmedOverlay';
|
|
766
|
+
overlay.className = 'confirmed-overlay';
|
|
767
|
+
overlay.title = '本 Sheet 已确认;取消 Sheet 标签前的勾选后可继续编辑。';
|
|
768
|
+
overlay.setAttribute('aria-label', '本 Sheet 已确认,表格交互已锁定');
|
|
769
|
+
const mark = document.createElement('div');
|
|
770
|
+
mark.className = 'confirmed-overlay-mark';
|
|
771
|
+
mark.textContent = '✓';
|
|
772
|
+
overlay.append(mark);
|
|
773
|
+
byId('tableStage').append(overlay);
|
|
774
|
+
}
|
|
775
|
+
function currentSheetIsConfirmed() {
|
|
776
|
+
const file = currentFileData(); const sheet = currentSheetData();
|
|
777
|
+
return !!file && sheetNeedsConfirmation(sheet) && sheetDecision(file, sheet).confirmed;
|
|
778
|
+
}
|
|
779
|
+
function renderActionAvailability() {
|
|
780
|
+
const confirmed = currentSheetIsConfirmed();
|
|
781
|
+
byId('allLocalBtn').disabled = confirmed;
|
|
782
|
+
byId('allRemoteBtn').disabled = confirmed;
|
|
783
|
+
const file = currentFileData(); const sheet = currentSheetData();
|
|
784
|
+
const scope = file && sheet ? `当前 Sheet:${file.path} / ${sheet.name}` : '当前 Sheet';
|
|
785
|
+
const message = confirmed ? `${scope} 已确认;取消 Sheet 标签前的勾选后可继续编辑。` : `${scope} 的批量操作`;
|
|
786
|
+
byId('allLocalBtn').title = `${message}:将可处理项全部采用本地。`;
|
|
787
|
+
byId('allRemoteBtn').title = `${message}:将可处理项全部采用远端。`;
|
|
788
|
+
byId('undoBtn').title = `${scope}:撤销最近一次选择,不影响其它 Sheet 或文件级宏。`;
|
|
789
|
+
byId('resetBtn').title = `${scope}:恢复本 Sheet 的默认决策,不影响其它 Sheet 或文件级宏。`;
|
|
790
|
+
}
|
|
791
|
+
function navigableConflictCells(file, sheet) {
|
|
792
|
+
if (!sheet || !sheetNeedsConfirmation(sheet)) return [];
|
|
793
|
+
if (sheet.columns && sheet.allRows) {
|
|
794
|
+
return (sheet.cells || []).filter(cell => cell.resolution === 'conflict' && structuralCellSelectable(file, sheet, cell));
|
|
795
|
+
}
|
|
796
|
+
return (sheet.cells || []).filter(cell => cell.resolution === 'conflict');
|
|
797
|
+
}
|
|
798
|
+
function conflictCellKey(cell) { return cell && (cell.id || cell.coordinate); }
|
|
799
|
+
function renderConflictNavigation() {
|
|
800
|
+
const file = currentFileData(); const sheet = currentSheetData();
|
|
801
|
+
const cells = navigableConflictCells(file, sheet);
|
|
802
|
+
const count = byId('conflictNavCount');
|
|
803
|
+
const previous = byId('prevConflictBtn'); const next = byId('nextConflictBtn');
|
|
804
|
+
if (!count || !previous || !next) return;
|
|
805
|
+
const currentId = sheet && sheetDecision(file, sheet).lastNavigatedConflict;
|
|
806
|
+
const currentIndex = cells.findIndex(cell => conflictCellKey(cell) === currentId);
|
|
807
|
+
count.textContent = cells.length ? `${currentIndex < 0 ? 0 : currentIndex + 1} / ${cells.length}` : '0 / 0';
|
|
808
|
+
previous.disabled = cells.length === 0;
|
|
809
|
+
next.disabled = cells.length === 0;
|
|
810
|
+
previous.title = cells.length ? '定位到当前 Sheet 的上一个可处理冲突(循环)' : '当前 Sheet 没有可定位的冲突';
|
|
811
|
+
next.title = cells.length ? '定位到当前 Sheet 的下一个可处理冲突(循环)' : '当前 Sheet 没有可定位的冲突';
|
|
812
|
+
}
|
|
813
|
+
function markConflictCell(cellElement) {
|
|
814
|
+
if (!cellElement) return;
|
|
815
|
+
cellElement.classList.remove('conflict-cell-flash');
|
|
816
|
+
// Force a reflow so repeated navigation to the same cell restarts the flash.
|
|
817
|
+
void cellElement.offsetWidth;
|
|
818
|
+
cellElement.classList.add('conflict-cell-flash');
|
|
819
|
+
window.setTimeout(() => cellElement.classList.remove('conflict-cell-flash'), 1300);
|
|
820
|
+
}
|
|
821
|
+
function locateConflictCell(direction) {
|
|
822
|
+
const file = currentFileData(); const sheet = currentSheetData();
|
|
823
|
+
const cells = navigableConflictCells(file, sheet);
|
|
824
|
+
if (!cells.length) return;
|
|
825
|
+
const state = sheetDecision(file, sheet);
|
|
826
|
+
const currentId = state.lastNavigatedConflict;
|
|
827
|
+
let index = cells.findIndex(cell => conflictCellKey(cell) === currentId);
|
|
828
|
+
index = index < 0 ? (direction > 0 ? 0 : cells.length - 1) : (index + direction + cells.length) % cells.length;
|
|
829
|
+
const target = cells[index];
|
|
830
|
+
state.lastNavigatedConflict = conflictCellKey(target);
|
|
831
|
+
const rowNumber = target.row;
|
|
832
|
+
if (!(sheet.columns && sheet.allRows) && rowNumber !== undefined) {
|
|
833
|
+
const rows = [...new Set((sheet.cells || []).map(cell => cell.row))].sort((a, b) => a - b);
|
|
834
|
+
currentPage = Math.floor(Math.max(0, rows.indexOf(rowNumber)) / PAGE_SIZE);
|
|
835
|
+
} else if (sheet.columns && sheet.allRows) {
|
|
836
|
+
const rows = sheet.rows || [];
|
|
837
|
+
const rowIndex = rows.findIndex(row => row.id === target.rowId);
|
|
838
|
+
currentPage = Math.floor(Math.max(0, rowIndex) / PAGE_SIZE);
|
|
839
|
+
}
|
|
840
|
+
renderTable();
|
|
841
|
+
renderConflictNavigation();
|
|
842
|
+
requestAnimationFrame(() => {
|
|
843
|
+
const element = [...byId('tableContainer').querySelectorAll('[data-conflict-id]')]
|
|
844
|
+
.find(item => item.dataset.conflictId === conflictCellKey(target));
|
|
845
|
+
if (!element) return;
|
|
846
|
+
const container = byId('tableContainer');
|
|
847
|
+
container.scrollTop = Math.max(0, element.offsetTop - container.clientHeight / 2);
|
|
848
|
+
container.scrollLeft = Math.max(0, element.offsetLeft - container.clientWidth / 2);
|
|
849
|
+
element.scrollIntoView({block: 'nearest', inline: 'nearest'});
|
|
850
|
+
markConflictCell(element);
|
|
851
|
+
});
|
|
628
852
|
}
|
|
629
853
|
function renderMessage(host, title, message) {
|
|
630
854
|
const box = document.createElement('div');
|
|
@@ -813,7 +1037,10 @@ function renderStructuralTable(host, file, sheet) {
|
|
|
813
1037
|
} else cell.className = 'cell-no-conflict' + (structurallyLocked ? ' cell-locked' : '');
|
|
814
1038
|
if (cellData) {
|
|
815
1039
|
cell.textContent = fmtVal(structuralCellValue(target, cellData));
|
|
816
|
-
if (structuralCellSelectable(file, sheet, cellData))
|
|
1040
|
+
if (structuralCellSelectable(file, sheet, cellData)) {
|
|
1041
|
+
cell.onclick = () => cycleCell(file, sheet, cellData);
|
|
1042
|
+
if (cellData.resolution === 'conflict') cell.dataset.conflictId = cellData.id;
|
|
1043
|
+
}
|
|
817
1044
|
bindStructuralTip(cell, file, sheet, axisRow, column, cellData);
|
|
818
1045
|
}
|
|
819
1046
|
row.append(cell);
|
|
@@ -881,6 +1108,7 @@ function renderLegacyDiffTable(host, file, sheet) {
|
|
|
881
1108
|
cell.className = choice === 'ours' ? 'cell-local' : 'cell-remote';
|
|
882
1109
|
cell.textContent = fmtVal(choice === 'ours' ? changed.ours : changed.theirs);
|
|
883
1110
|
cell.onclick = () => cycleCell(file, sheet, changed);
|
|
1111
|
+
if (changed.resolution === 'conflict') cell.dataset.conflictId = changed.id || changed.coordinate;
|
|
884
1112
|
} else {
|
|
885
1113
|
cell.className = 'cell-no-conflict';
|
|
886
1114
|
cell.textContent = fmtVal(gridVal(sheet, rowNumber, col));
|
|
@@ -970,7 +1198,7 @@ function cycleCell(file, sheet, cell) {
|
|
|
970
1198
|
const target = sheetDecision(file, sheet); pushCellUndo(file, sheet, cell);
|
|
971
1199
|
const key = cellKey(cell);
|
|
972
1200
|
target.cells[key] = target.cells[key] === 'ours' ? 'theirs' : 'ours';
|
|
973
|
-
renderTable(); updateStats();
|
|
1201
|
+
renderTable(); renderConflictNavigation(); updateStats();
|
|
974
1202
|
}
|
|
975
1203
|
function chooseSheet(file, sheet, side) {
|
|
976
1204
|
const target = sheetDecision(file, sheet);
|
|
@@ -991,7 +1219,7 @@ function toggleAxis(file, sheet, kind, axis) {
|
|
|
991
1219
|
const target = sheetDecision(file, sheet); const previous = target[kind][axis.id] || axis.default;
|
|
992
1220
|
undoStack.push({kind: 'axis', fileId: file.id, sheet: sheet.name, axisKind: kind, axisId: axis.id, previous});
|
|
993
1221
|
target[kind][axis.id] = previous === 'keep' ? 'delete' : 'keep';
|
|
994
|
-
renderSheetTabs(); renderTable(); updateStats();
|
|
1222
|
+
renderSheetTabs(); renderTable(); renderConflictNavigation(); updateStats();
|
|
995
1223
|
}
|
|
996
1224
|
function chooseMacro(file, side) {
|
|
997
1225
|
const target = fileDecision(file); const previous = target.macro || file.macro.default;
|
|
@@ -1005,11 +1233,7 @@ function sideAxisChoice(axis, side) {
|
|
|
1005
1233
|
}
|
|
1006
1234
|
function bulkChoose(side) {
|
|
1007
1235
|
const file = currentFileData(); const sheet = currentSheetData(); if (!sheet) return;
|
|
1008
|
-
if (
|
|
1009
|
-
const fileTarget = fileDecision(file);
|
|
1010
|
-
undoStack.push({kind: 'macro', fileId: file.id, previous: fileTarget.macro || file.macro.default});
|
|
1011
|
-
fileTarget.macro = side;
|
|
1012
|
-
}
|
|
1236
|
+
if (currentSheetIsConfirmed()) return;
|
|
1013
1237
|
if (sheet.action.startsWith('conflict_')) { chooseSheet(file, sheet, side); return; }
|
|
1014
1238
|
const target = sheetDecision(file, sheet);
|
|
1015
1239
|
if (sheet.renameStatus === 'rename_conflict') {
|
|
@@ -1043,7 +1267,7 @@ function bulkStructuralRow(rowId) {
|
|
|
1043
1267
|
pushCellUndo(file, sheet, cell); const key = cellKey(cell);
|
|
1044
1268
|
target.cells[key] = target.cells[key] === 'ours' ? 'theirs' : 'ours';
|
|
1045
1269
|
}
|
|
1046
|
-
renderTable(); updateStats();
|
|
1270
|
+
renderTable(); renderConflictNavigation(); updateStats();
|
|
1047
1271
|
}
|
|
1048
1272
|
function bulkStructuralColumn(columnId) {
|
|
1049
1273
|
const file = currentFileData(); const sheet = currentSheetData(); const target = sheetDecision(file, sheet);
|
|
@@ -1055,7 +1279,7 @@ function bulkStructuralColumn(columnId) {
|
|
|
1055
1279
|
pushCellUndo(file, sheet, cell); const key = cellKey(cell);
|
|
1056
1280
|
target.cells[key] = target.cells[key] === 'ours' ? 'theirs' : 'ours';
|
|
1057
1281
|
}
|
|
1058
|
-
renderTable(); updateStats();
|
|
1282
|
+
renderTable(); renderConflictNavigation(); updateStats();
|
|
1059
1283
|
}
|
|
1060
1284
|
function bulkRow(row) {
|
|
1061
1285
|
const file = currentFileData(); const sheet = currentSheetData();
|
|
@@ -1063,7 +1287,7 @@ function bulkRow(row) {
|
|
|
1063
1287
|
const target = sheetDecision(file, sheet); pushCellUndo(file, sheet, cell);
|
|
1064
1288
|
const key = cellKey(cell); target.cells[key] = target.cells[key] === 'ours' ? 'theirs' : 'ours';
|
|
1065
1289
|
}
|
|
1066
|
-
renderTable(); updateStats();
|
|
1290
|
+
renderTable(); renderConflictNavigation(); updateStats();
|
|
1067
1291
|
}
|
|
1068
1292
|
function bulkCol(col) {
|
|
1069
1293
|
const file = currentFileData(); const sheet = currentSheetData();
|
|
@@ -1071,14 +1295,25 @@ function bulkCol(col) {
|
|
|
1071
1295
|
const target = sheetDecision(file, sheet); pushCellUndo(file, sheet, cell);
|
|
1072
1296
|
const key = cellKey(cell); target.cells[key] = target.cells[key] === 'ours' ? 'theirs' : 'ours';
|
|
1073
1297
|
}
|
|
1074
|
-
renderTable(); updateStats();
|
|
1298
|
+
renderTable(); renderConflictNavigation(); updateStats();
|
|
1075
1299
|
}
|
|
1076
1300
|
function undo() {
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1301
|
+
const file = currentFileData(); const sheet = currentSheetData();
|
|
1302
|
+
if (!file || !sheet) return;
|
|
1303
|
+
let actionIndex = -1;
|
|
1304
|
+
for (let index = undoStack.length - 1; index >= 0; index--) {
|
|
1305
|
+
const candidate = undoStack[index];
|
|
1306
|
+
if (candidate.fileId === file.id && candidate.sheet === sheet.name) {
|
|
1307
|
+
actionIndex = index;
|
|
1308
|
+
break;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
if (actionIndex < 0) return;
|
|
1312
|
+
const [action] = undoStack.splice(actionIndex, 1);
|
|
1313
|
+
const actionFile = model.files.find(item => item.id === action.fileId);
|
|
1314
|
+
const actionSheet = actionFile.diff.sheets.find(item => item.name === action.sheet);
|
|
1315
|
+
const target = sheetDecision(actionFile, actionSheet);
|
|
1316
|
+
target.confirmed = false;
|
|
1082
1317
|
if (action.kind === 'sheet') target.sheet = action.previous;
|
|
1083
1318
|
else if (action.kind === 'rename') target.rename = action.previous;
|
|
1084
1319
|
else if (action.kind === 'mergedCells') target.mergedCells = action.previous;
|
|
@@ -1086,22 +1321,36 @@ function undo() {
|
|
|
1086
1321
|
else target.cells[action.key] = action.previous;
|
|
1087
1322
|
render();
|
|
1088
1323
|
}
|
|
1089
|
-
function
|
|
1324
|
+
function resetSheet() {
|
|
1090
1325
|
const file = currentFileData();
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1326
|
+
const sheet = currentSheetData();
|
|
1327
|
+
if (!file || !sheet) return;
|
|
1328
|
+
const target = sheetDecision(file, sheet); const sheetChoice = defaultSheetChoice(sheet);
|
|
1329
|
+
target.confirmed = false;
|
|
1330
|
+
delete target.lastNavigatedConflict;
|
|
1331
|
+
if (sheetChoice) target.sheet = sheetChoice; else delete target.sheet;
|
|
1332
|
+
if (sheet.renameStatus === 'rename_conflict') target.rename = 'ours'; else delete target.rename;
|
|
1333
|
+
if (sheet.mergedCells && sheet.mergedCells.status === 'conflict') target.mergedCells = sheet.mergedCells.default || 'ours'; else delete target.mergedCells;
|
|
1334
|
+
target.rows = {}; target.columns = {}; target.cells = {};
|
|
1335
|
+
for (const row of sheet.allRows || sheet.rows || []) if (row.state === 'delete_modify') target.rows[row.id] = row.default;
|
|
1336
|
+
for (const column of sheet.columns || []) if (column.state === 'delete_modify') target.columns[column.id] = column.default;
|
|
1337
|
+
for (const cell of sheet.cells || []) target.cells[cellKey(cell)] = defaultCellChoice(cell);
|
|
1338
|
+
// A reset supersedes prior choices for this Sheet, while preserving other files,
|
|
1339
|
+
// other Sheets, and file-level macro choices in the shared undo history.
|
|
1340
|
+
undoStack = undoStack.filter(action => action.fileId !== file.id || action.sheet !== sheet.name);
|
|
1341
|
+
render();
|
|
1342
|
+
}
|
|
1343
|
+
function updateGlobalConfirmationStats() {
|
|
1344
|
+
let confirmed = 0; let total = 0;
|
|
1345
|
+
for (const file of model.files) for (const sheet of file.diff.sheets) {
|
|
1346
|
+
if (!sheetNeedsConfirmation(sheet)) continue;
|
|
1347
|
+
total++;
|
|
1348
|
+
if (sheetDecision(file, sheet).confirmed) confirmed++;
|
|
1101
1349
|
}
|
|
1102
|
-
|
|
1350
|
+
byId('confirmedSheetCount').textContent = String(confirmed);
|
|
1351
|
+
byId('totalConflictSheetCount').textContent = String(total);
|
|
1103
1352
|
}
|
|
1104
|
-
function
|
|
1353
|
+
function updateDecisionFooterStats() {
|
|
1105
1354
|
let total = 0; let local = 0;
|
|
1106
1355
|
for (const file of model.files) {
|
|
1107
1356
|
if (file.macro && file.macro.status === 'conflict') {
|
|
@@ -1126,10 +1375,13 @@ function updateStats() {
|
|
|
1126
1375
|
}
|
|
1127
1376
|
}
|
|
1128
1377
|
}
|
|
1129
|
-
byId('localCount').textContent = String(local); byId('totalCount').textContent = String(total);
|
|
1130
1378
|
const file = currentFileData(); const sheet = currentSheetData();
|
|
1131
1379
|
byId('footerStatus').textContent = `共 ${total} 个可决策项,${local} 项采用本地 · 当前:${file.path}${sheet ? ` / ${sheet.name}` : ''}${autoTheirsNote(' · ')}`;
|
|
1132
1380
|
}
|
|
1381
|
+
function updateStats() {
|
|
1382
|
+
updateGlobalConfirmationStats();
|
|
1383
|
+
updateDecisionFooterStats();
|
|
1384
|
+
}
|
|
1133
1385
|
|
|
1134
1386
|
function renderCommitSteps(steps) {
|
|
1135
1387
|
const host = byId('commitModalSteps'); host.replaceChildren();
|
|
@@ -1171,8 +1423,49 @@ function renderCommitMessage(text) {
|
|
|
1171
1423
|
line.textContent = text || '(无冲突 Cell,将使用默认提交信息)';
|
|
1172
1424
|
host.append(line);
|
|
1173
1425
|
}
|
|
1426
|
+
function unconfirmedSheets() {
|
|
1427
|
+
const pending = [];
|
|
1428
|
+
for (const [fileIndex, file] of model.files.entries()) {
|
|
1429
|
+
for (const [sheetIndex, sheet] of file.diff.sheets.entries()) {
|
|
1430
|
+
if (!sheetNeedsConfirmation(sheet) || sheetDecision(file, sheet).confirmed) continue;
|
|
1431
|
+
pending.push({file, sheet, fileIndex, sheetIndex, label: `${file.path}-${sheet.name}`});
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return pending;
|
|
1435
|
+
}
|
|
1436
|
+
function renderUnconfirmedSheetList(pending) {
|
|
1437
|
+
const host = byId('commitModalSteps'); host.replaceChildren();
|
|
1438
|
+
for (const item of pending) {
|
|
1439
|
+
const button = document.createElement('button');
|
|
1440
|
+
button.type = 'button';
|
|
1441
|
+
button.className = 'btn btn-cancel';
|
|
1442
|
+
button.style.display = 'block';
|
|
1443
|
+
button.style.width = '100%';
|
|
1444
|
+
button.style.marginBottom = '7px';
|
|
1445
|
+
button.style.textAlign = 'left';
|
|
1446
|
+
button.textContent = item.label;
|
|
1447
|
+
button.title = `切换到 ${item.label}`;
|
|
1448
|
+
button.onclick = () => {
|
|
1449
|
+
currentFile = item.fileIndex;
|
|
1450
|
+
currentSheet = item.sheetIndex;
|
|
1451
|
+
currentPage = 0;
|
|
1452
|
+
closeCommitModal();
|
|
1453
|
+
render();
|
|
1454
|
+
};
|
|
1455
|
+
host.append(button);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1174
1458
|
async function submitResolve() {
|
|
1175
1459
|
const button = byId('submitBtn');
|
|
1460
|
+
const pending = unconfirmedSheets();
|
|
1461
|
+
if (pending.length) {
|
|
1462
|
+
byId('footerStatus').textContent = `仍有 ${pending.length} 个 Sheet 未确认,请先完成审阅。`;
|
|
1463
|
+
showCommitModal('', '仍有未确认的 Sheet', '提交前必须人工勾选确认每个需要审阅的 Sheet。点击下方条目可直接切换过去。', [], [
|
|
1464
|
+
{label: '返回继续审阅', className: 'btn-submit', onclick: () => { closeCommitModal(); button.disabled = false; }}
|
|
1465
|
+
]);
|
|
1466
|
+
renderUnconfirmedSheetList(pending);
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1176
1469
|
button.disabled = true;
|
|
1177
1470
|
byId('footerStatus').textContent = '正在生成 commit 信息预览...';
|
|
1178
1471
|
try {
|
|
@@ -1216,9 +1509,11 @@ async function doSubmitResolve() {
|
|
|
1216
1509
|
byId('allLocalBtn').onclick = () => bulkChoose('ours');
|
|
1217
1510
|
byId('allRemoteBtn').onclick = () => bulkChoose('theirs');
|
|
1218
1511
|
byId('undoBtn').onclick = undo;
|
|
1219
|
-
byId('resetBtn').onclick =
|
|
1512
|
+
byId('resetBtn').onclick = resetSheet;
|
|
1220
1513
|
byId('cancelBtn').onclick = cancelAndExit;
|
|
1221
1514
|
byId('submitBtn').onclick = submitResolve;
|
|
1515
|
+
byId('prevConflictBtn').onclick = () => locateConflictCell(-1);
|
|
1516
|
+
byId('nextConflictBtn').onclick = () => locateConflictCell(1);
|
|
1222
1517
|
enableHorizontalWheel(byId('fileTabs'));
|
|
1223
1518
|
enableHorizontalWheel(byId('sheetTabs'));
|
|
1224
1519
|
init().catch(error => { byId('footerStatus').textContent = `加载失败: ${error.message}`; });
|