dsh-linked-workspace 0.8.3 → 0.9.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/CHANGELOG.md +17 -0
- package/README.en.md +17 -0
- package/README.md +17 -0
- package/docs/API.md +6 -2
- package/docs/VERIFY.md +14 -0
- package/lib/client.js +576 -28
- package/lib/index.js +254 -6
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1951,6 +1951,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
1951
1951
|
// One tree page; a folder with 20k entries must not render 20k rows.
|
|
1952
1952
|
var TREE_PAGE_SIZE = 500;
|
|
1953
1953
|
var TREE_PAGE_MAX = 5000;
|
|
1954
|
+
// Background tree refresh interval per directory. The app ticks every 4 s,
|
|
1955
|
+
// but a full remote listing on a huge folder is expensive; 15 s keeps the
|
|
1956
|
+
// tree fresh without hammering the SSH channel.
|
|
1957
|
+
var REFRESH_MIN_INTERVAL_MS = 15000;
|
|
1954
1958
|
var linkedLocalKeys = new Set();
|
|
1955
1959
|
var linkedWorkspaceKeys = new Set();
|
|
1956
1960
|
var hasRemoteDirectories = false;
|
|
@@ -2167,6 +2171,34 @@ function attributeViolation(name, value, tagName) {
|
|
|
2167
2171
|
loadMore: '加载更多(剩余 {{count}} 项)',
|
|
2168
2172
|
loadMoreShort: '加载更多',
|
|
2169
2173
|
pickerTruncated: '目录项过多,仅显示前 {{count}} 项;可直接在输入框中输入路径',
|
|
2174
|
+
filterPlaceholder: '按名称过滤…',
|
|
2175
|
+
filterEmpty: '没有匹配当前过滤条件的条目',
|
|
2176
|
+
searchTruncated: '结果过多,仅显示前 200 条;请输入更精确的关键词',
|
|
2177
|
+
findPlaceholder: '查找…',
|
|
2178
|
+
replacePlaceholder: '替换为…',
|
|
2179
|
+
findCounter: '第 {{index}} / {{total}} 个',
|
|
2180
|
+
findNoMatch: '无匹配',
|
|
2181
|
+
findNext: '下一个',
|
|
2182
|
+
findPrev: '上一个',
|
|
2183
|
+
replaceOne: '替换',
|
|
2184
|
+
replaceAll: '全部替换',
|
|
2185
|
+
compareTitle: '本地与远端对比',
|
|
2186
|
+
compareOnlyLocal: '仅本地存在',
|
|
2187
|
+
compareOnlyRemote: '仅远端存在',
|
|
2188
|
+
compareChanged: '大小或时间不同',
|
|
2189
|
+
compareNone: '无',
|
|
2190
|
+
compareTruncated: '文件过多,对比结果已截断(最多 4000 个文件 / 12 层)',
|
|
2191
|
+
compareFailed: '对比失败',
|
|
2192
|
+
ctxCompare: '与本地对比…',
|
|
2193
|
+
ctxTerminalHere: '在此打开终端',
|
|
2194
|
+
ctxTransferSelected: '传输所选的 {{count}} 项',
|
|
2195
|
+
ctxDeleteSelected: '删除所选的 {{count}} 项',
|
|
2196
|
+
deleteManyTitle: '批量删除',
|
|
2197
|
+
deleteManyMessage: '确定删除所选的 {{count}} 个项目吗?此操作不可撤销。',
|
|
2198
|
+
dropNeedsDesktop: '当前浏览器无法读取被拖入文件的路径,请在 DSH 桌面窗口中拖拽',
|
|
2199
|
+
dropImported: '已导入 {{count}} 个文件',
|
|
2200
|
+
dropSkipped: '{{count}} 个文件被跳过(过大或不是普通文件)',
|
|
2201
|
+
dropDirUnsupported: '暂不支持把远程目录拖拽到本地,请使用右键「传输」',
|
|
2170
2202
|
sheetTruncated: '仅显示前 {{rows}} 行 × {{cols}} 列',
|
|
2171
2203
|
sheetMore: '工作表较多,仅显示前 20 个',
|
|
2172
2204
|
noCredential: '缺少凭据',
|
|
@@ -2501,6 +2533,34 @@ function attributeViolation(name, value, tagName) {
|
|
|
2501
2533
|
loadMore: 'Load more ({{count}} left)',
|
|
2502
2534
|
loadMoreShort: 'Load more',
|
|
2503
2535
|
pickerTruncated: 'Too many entries; only the first {{count}} are shown. Type a path directly.',
|
|
2536
|
+
filterPlaceholder: 'Filter by name…',
|
|
2537
|
+
filterEmpty: 'No entries match the current filter',
|
|
2538
|
+
searchTruncated: 'Too many results; showing the first 200. Narrow the query.',
|
|
2539
|
+
findPlaceholder: 'Find…',
|
|
2540
|
+
replacePlaceholder: 'Replace with…',
|
|
2541
|
+
findCounter: '{{index}} / {{total}}',
|
|
2542
|
+
findNoMatch: 'No match',
|
|
2543
|
+
findNext: 'Next match',
|
|
2544
|
+
findPrev: 'Previous match',
|
|
2545
|
+
replaceOne: 'Replace',
|
|
2546
|
+
replaceAll: 'Replace all',
|
|
2547
|
+
compareTitle: 'Local vs remote comparison',
|
|
2548
|
+
compareOnlyLocal: 'Local only',
|
|
2549
|
+
compareOnlyRemote: 'Remote only',
|
|
2550
|
+
compareChanged: 'Different size or time',
|
|
2551
|
+
compareNone: 'None',
|
|
2552
|
+
compareTruncated: 'Too many files; the comparison was truncated (4000 files / 12 levels).',
|
|
2553
|
+
compareFailed: 'Comparison failed',
|
|
2554
|
+
ctxCompare: 'Compare with local…',
|
|
2555
|
+
ctxTerminalHere: 'Open terminal here',
|
|
2556
|
+
ctxTransferSelected: 'Transfer selected ({{count}})',
|
|
2557
|
+
ctxDeleteSelected: 'Delete selected ({{count}})',
|
|
2558
|
+
deleteManyTitle: 'Delete multiple',
|
|
2559
|
+
deleteManyMessage: 'Delete the {{count}} selected items? This cannot be undone.',
|
|
2560
|
+
dropNeedsDesktop: 'This browser cannot read dropped file paths; drag files in the DSH desktop window',
|
|
2561
|
+
dropImported: 'Imported {{count}} file(s)',
|
|
2562
|
+
dropSkipped: '{{count}} file(s) skipped (too large or not a regular file)',
|
|
2563
|
+
dropDirUnsupported: 'Dropping a remote folder onto local is not supported yet; use Transfer instead',
|
|
2504
2564
|
sheetTruncated: 'Showing the first {{rows}} rows × {{cols}} columns',
|
|
2505
2565
|
sheetMore: 'Showing the first 20 worksheets only',
|
|
2506
2566
|
noCredential: 'No credentials',
|
|
@@ -3309,6 +3369,22 @@ function attributeViolation(name, value, tagName) {
|
|
|
3309
3369
|
'.rw-load-more{width:100%;border:0;background:transparent;cursor:pointer;text-align:left;font:inherit;font-size:11.5px;color:var(--dsw-alias-brand-primary)}',
|
|
3310
3370
|
'.rw-load-more:hover{text-decoration:underline}',
|
|
3311
3371
|
'.rw-load-more:disabled{opacity:.6;cursor:default}',
|
|
3372
|
+
'.rw-filter-row{padding:4px 8px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
|
|
3373
|
+
'.rw-filter-row .rw-input{width:100%}',
|
|
3374
|
+
'.rw-find-bar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:6px 10px;border-bottom:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-l1)}',
|
|
3375
|
+
'.rw-find-bar .rw-input{height:26px;font-size:11.5px;min-width:120px;flex:0 1 160px}',
|
|
3376
|
+
'.rw-find-counter{font-size:11px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}',
|
|
3377
|
+
'.rw-compare-root{font-family:ui-monospace,Consolas,monospace;font-size:11px}',
|
|
3378
|
+
'.rw-compare-section{margin:0 0 8px}',
|
|
3379
|
+
'.rw-compare-title{font-size:11.5px;font-weight:600;padding:2px 0}',
|
|
3380
|
+
'.rw-compare-empty{font-size:11px;color:var(--dsw-alias-label-tertiary);padding-left:8px}',
|
|
3381
|
+
'.rw-compare-row{display:flex;width:100%;gap:8px;align-items:center;border:0;background:transparent;cursor:pointer;text-align:left;font:inherit;font-size:11px;padding:3px 6px;border-radius:4px}',
|
|
3382
|
+
'.rw-compare-row:hover{background:var(--dsw-alias-interactive-bg-hover)}',
|
|
3383
|
+
'.rw-compare-path{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3384
|
+
'.rw-compare-size{flex:0 0 auto;color:var(--dsw-alias-label-tertiary)}',
|
|
3385
|
+
'.rw-dialog-note{font-size:11px;color:var(--dsw-alias-label-tertiary);padding:2px 0}',
|
|
3386
|
+
'.rw-dialog-error{color:var(--dsw-alias-state-error-primary)}',
|
|
3387
|
+
'.rw-row.is-drop-target{outline:1px dashed var(--dsw-alias-brand-primary);outline-offset:-1px}',
|
|
3312
3388
|
'.rw-doc-tab{padding:2px 8px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;cursor:pointer;white-space:nowrap}',
|
|
3313
3389
|
'.rw-doc-tab.is-on{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary)}',
|
|
3314
3390
|
'.rw-doc-grid{width:100%;border-collapse:collapse;font-size:11.5px}',
|
|
@@ -3730,7 +3806,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3730
3806
|
var locale = props.locale;
|
|
3731
3807
|
var initialPath = props.initialPath || '';
|
|
3732
3808
|
var root = props.root || '';
|
|
3733
|
-
var state = useState({ loading: true, listing: null, error: '', input: initialPath, creating: false, folderName: '' });
|
|
3809
|
+
var state = useState({ loading: true, listing: null, error: '', input: initialPath, creating: false, folderName: '', filter: '' });
|
|
3734
3810
|
var local = state[0];
|
|
3735
3811
|
var setLocal = state[1];
|
|
3736
3812
|
|
|
@@ -3738,7 +3814,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3738
3814
|
setLocal(function (previous) { return Object.assign({}, previous, { loading: true, error: '', input: path || previous.input }); });
|
|
3739
3815
|
apiCall('local.browse', path ? { path: path } : {}).then(function (result) {
|
|
3740
3816
|
setLocal(function (previous) {
|
|
3741
|
-
return Object.assign({}, previous, { loading: false, listing: result, error: '', input: result.path });
|
|
3817
|
+
return Object.assign({}, previous, { loading: false, listing: result, error: '', input: result.path, filter: '' });
|
|
3742
3818
|
});
|
|
3743
3819
|
}).catch(function (error) {
|
|
3744
3820
|
setLocal(function (previous) {
|
|
@@ -3779,7 +3855,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
3779
3855
|
// A folder with thousands of sub-folders must not build thousands of DOM
|
|
3780
3856
|
// rows; the input box below still accepts any path.
|
|
3781
3857
|
var PICKER_LIMIT = 500;
|
|
3782
|
-
var
|
|
3858
|
+
var filterText = String(local.filter || '').trim().toLowerCase();
|
|
3859
|
+
var matchedEntries = filterText === '' ? entries : entries.filter(function (entry) {
|
|
3860
|
+
return String(entry.name || '').toLowerCase().indexOf(filterText) !== -1;
|
|
3861
|
+
});
|
|
3862
|
+
var shownEntries = matchedEntries.slice(0, PICKER_LIMIT);
|
|
3783
3863
|
var crumbs = useMemo(function () {
|
|
3784
3864
|
if (!listing || !listing.path) return [];
|
|
3785
3865
|
var path = listing.path;
|
|
@@ -3827,18 +3907,29 @@ function attributeViolation(name, value, tagName) {
|
|
|
3827
3907
|
}, drive.name);
|
|
3828
3908
|
}))
|
|
3829
3909
|
: null,
|
|
3910
|
+
h('div', { className: 'rw-filter-row' },
|
|
3911
|
+
h('input', {
|
|
3912
|
+
className: 'rw-input', style: { height: 26, fontSize: 11.5 },
|
|
3913
|
+
value: local.filter,
|
|
3914
|
+
placeholder: t('filterPlaceholder'),
|
|
3915
|
+
'aria-label': t('filterPlaceholder'),
|
|
3916
|
+
spellCheck: false,
|
|
3917
|
+
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { filter: event.currentTarget.value }); }); },
|
|
3918
|
+
})),
|
|
3830
3919
|
h('div', { className: 'rw-browser-list', role: 'list' },
|
|
3831
3920
|
local.error
|
|
3832
3921
|
? h('div', { className: 'rw-row-msg' }, IconAlert(12), local.error)
|
|
3833
3922
|
: entries.length === 0
|
|
3834
3923
|
? h('div', { className: 'rw-row-msg' }, t('emptyFolder'))
|
|
3835
|
-
:
|
|
3924
|
+
: matchedEntries.length === 0
|
|
3925
|
+
? h('div', { className: 'rw-row-msg' }, t('filterEmpty'))
|
|
3926
|
+
: shownEntries.map(function (entry) {
|
|
3836
3927
|
return h('button', {
|
|
3837
3928
|
key: entry.path, type: 'button', className: 'rw-browser-row', role: 'listitem',
|
|
3838
3929
|
onClick: function () { navigate(entry.path); },
|
|
3839
3930
|
}, h('span', { className: 'rw-dir-icon' }, IconFolder(13, false)), h('span', null, entry.name));
|
|
3840
3931
|
}),
|
|
3841
|
-
|
|
3932
|
+
matchedEntries.length > PICKER_LIMIT
|
|
3842
3933
|
? h('div', { className: 'rw-row-msg' }, t('pickerTruncated', { count: PICKER_LIMIT }))
|
|
3843
3934
|
: null),
|
|
3844
3935
|
h('div', { className: 'rw-browser-actions', style: { padding: '8px', gap: 8 } },
|
|
@@ -3884,7 +3975,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3884
3975
|
var t = props.t;
|
|
3885
3976
|
var locale = props.locale;
|
|
3886
3977
|
var hostId = props.hostId;
|
|
3887
|
-
var state = useState({ loading: true, listing: null, error: '', input: props.initialPath || '' });
|
|
3978
|
+
var state = useState({ loading: true, listing: null, error: '', input: props.initialPath || '', filter: '' });
|
|
3888
3979
|
var remote = state[0];
|
|
3889
3980
|
var setRemote = state[1];
|
|
3890
3981
|
|
|
@@ -3896,7 +3987,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3896
3987
|
setRemote(function (previous) { return Object.assign({}, previous, { loading: true, error: '' }); });
|
|
3897
3988
|
apiCall('hosts.browse', { hostId: hostId, path: path || undefined }).then(function (result) {
|
|
3898
3989
|
setRemote(function (previous) {
|
|
3899
|
-
return Object.assign({}, previous, { loading: false, listing: result, error: '', input: result.path });
|
|
3990
|
+
return Object.assign({}, previous, { loading: false, listing: result, error: '', input: result.path, filter: '' });
|
|
3900
3991
|
});
|
|
3901
3992
|
}).catch(function (error) {
|
|
3902
3993
|
setRemote(function (previous) { return Object.assign({}, previous, { loading: false, error: messageOf(error, t, locale) }); });
|
|
@@ -3913,8 +4004,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
3913
4004
|
var listing = remote.listing;
|
|
3914
4005
|
var dirs = listing ? (listing.entries || []).filter(function (entry) { return entry.type === 'dir'; }) : [];
|
|
3915
4006
|
var PICKER_LIMIT = 500;
|
|
3916
|
-
var
|
|
3917
|
-
var
|
|
4007
|
+
var filterText = String(remote.filter || '').trim().toLowerCase();
|
|
4008
|
+
var matchedDirs = filterText === '' ? dirs : dirs.filter(function (entry) {
|
|
4009
|
+
return String(entry.name || '').toLowerCase().indexOf(filterText) !== -1;
|
|
4010
|
+
});
|
|
4011
|
+
var shownDirs = matchedDirs.slice(0, PICKER_LIMIT);
|
|
4012
|
+
var pickerTruncated = matchedDirs.length > PICKER_LIMIT || Boolean(listing && listing.hasMore);
|
|
3918
4013
|
var crumbs = useMemo(function () {
|
|
3919
4014
|
if (!listing || !listing.path) return [];
|
|
3920
4015
|
var pieces = listing.path.split('/').filter(function (piece) { return piece !== ''; });
|
|
@@ -3941,12 +4036,23 @@ function attributeViolation(name, value, tagName) {
|
|
|
3941
4036
|
h('button', { type: 'button', className: 'rw-crumb', title: crumb.path, onClick: function () { navigate(crumb.path); } }, crumb.label));
|
|
3942
4037
|
})),
|
|
3943
4038
|
remote.loading ? Spinner(13) : null),
|
|
4039
|
+
h('div', { className: 'rw-filter-row' },
|
|
4040
|
+
h('input', {
|
|
4041
|
+
className: 'rw-input', style: { height: 26, fontSize: 11.5 },
|
|
4042
|
+
value: remote.filter,
|
|
4043
|
+
placeholder: t('filterPlaceholder'),
|
|
4044
|
+
'aria-label': t('filterPlaceholder'),
|
|
4045
|
+
spellCheck: false,
|
|
4046
|
+
onChange: function (event) { setRemote(function (previous) { return Object.assign({}, previous, { filter: event.currentTarget.value }); }); },
|
|
4047
|
+
})),
|
|
3944
4048
|
h('div', { className: 'rw-browser-list', role: 'list' },
|
|
3945
4049
|
remote.error
|
|
3946
4050
|
? h('div', { className: 'rw-row-msg' }, IconAlert(12), remote.error)
|
|
3947
4051
|
: dirs.length === 0
|
|
3948
4052
|
? h('div', { className: 'rw-row-msg' }, t('noEntries'))
|
|
3949
|
-
:
|
|
4053
|
+
: matchedDirs.length === 0
|
|
4054
|
+
? h('div', { className: 'rw-row-msg' }, t('filterEmpty'))
|
|
4055
|
+
: shownDirs.map(function (entry) {
|
|
3950
4056
|
return h('button', {
|
|
3951
4057
|
key: entry.path, type: 'button', className: 'rw-browser-row', role: 'listitem',
|
|
3952
4058
|
onClick: function () { navigate(entry.path); },
|
|
@@ -4393,6 +4499,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
4393
4499
|
event.preventDefault();
|
|
4394
4500
|
saveFile(false);
|
|
4395
4501
|
}
|
|
4502
|
+
if (mod && (event.key === 'f' || event.key === 'F') && !event.shiftKey) {
|
|
4503
|
+
// Ctrl+F inside the editor opens the in-file find bar; the browser
|
|
4504
|
+
// find dialog cannot see textarea content anyway.
|
|
4505
|
+
event.preventDefault();
|
|
4506
|
+
openFind();
|
|
4507
|
+
}
|
|
4396
4508
|
}
|
|
4397
4509
|
window.addEventListener('keydown', onKey, true);
|
|
4398
4510
|
return function () { window.removeEventListener('keydown', onKey, true); };
|
|
@@ -4407,6 +4519,129 @@ function attributeViolation(name, value, tagName) {
|
|
|
4407
4519
|
if (gutterRef.current) gutterRef.current.scrollTop = target.scrollTop;
|
|
4408
4520
|
}
|
|
4409
4521
|
|
|
4522
|
+
// ── in-file find / replace ──────────────────────────────────────────
|
|
4523
|
+
var findInputRef = useRef(null);
|
|
4524
|
+
var findState = useState({ open: false, query: '', replace: '', caseSensitive: false, index: 0 });
|
|
4525
|
+
var find = findState[0];
|
|
4526
|
+
var setFind = findState[1];
|
|
4527
|
+
var FIND_MATCH_LIMIT = 5000;
|
|
4528
|
+
var findResult = useMemo(function () {
|
|
4529
|
+
if (!find.open || find.query === '') return { list: [], truncated: false };
|
|
4530
|
+
var text = content;
|
|
4531
|
+
var needle = find.caseSensitive ? find.query : find.query.toLowerCase();
|
|
4532
|
+
var haystack = find.caseSensitive ? text : text.toLowerCase();
|
|
4533
|
+
var list = [];
|
|
4534
|
+
var from = 0;
|
|
4535
|
+
while (list.length < FIND_MATCH_LIMIT) {
|
|
4536
|
+
var at = haystack.indexOf(needle, from);
|
|
4537
|
+
if (at === -1) break;
|
|
4538
|
+
list.push(at);
|
|
4539
|
+
from = at + Math.max(needle.length, 1);
|
|
4540
|
+
}
|
|
4541
|
+
// The list is capped so a huge file cannot freeze the editor, but the
|
|
4542
|
+
// counter must not pretend the cap is the real number of matches.
|
|
4543
|
+
var truncated = list.length === FIND_MATCH_LIMIT && haystack.indexOf(needle, from) !== -1;
|
|
4544
|
+
return { list: list, truncated: truncated };
|
|
4545
|
+
}, [content, find.open, find.query, find.caseSensitive]);
|
|
4546
|
+
var findMatches = findResult.list;
|
|
4547
|
+
var findIndex = findMatches.length === 0 ? -1 : Math.min(Math.max(find.index, 0), findMatches.length - 1);
|
|
4548
|
+
|
|
4549
|
+
function focusMatch(index) {
|
|
4550
|
+
var target = textareaRef.current;
|
|
4551
|
+
var at = findMatches.length === 0 ? -1 : findMatches[Math.min(Math.max(index, 0), findMatches.length - 1)];
|
|
4552
|
+
if (!target || at < 0) return;
|
|
4553
|
+
target.focus();
|
|
4554
|
+
target.selectionStart = at;
|
|
4555
|
+
target.selectionEnd = at + find.query.length;
|
|
4556
|
+
// Re-focusing makes the textarea scroll the selection into view.
|
|
4557
|
+
target.blur();
|
|
4558
|
+
target.focus();
|
|
4559
|
+
}
|
|
4560
|
+
|
|
4561
|
+
function stepMatch(delta) {
|
|
4562
|
+
if (findMatches.length === 0) return;
|
|
4563
|
+
var next = (findIndex + delta + findMatches.length) % findMatches.length;
|
|
4564
|
+
setFind(function (previous) { return Object.assign({}, previous, { index: next }); });
|
|
4565
|
+
focusMatch(next);
|
|
4566
|
+
}
|
|
4567
|
+
|
|
4568
|
+
function openFind() {
|
|
4569
|
+
setFind(function (previous) { return Object.assign({}, previous, { open: true }); });
|
|
4570
|
+
requestAnimationFrame(function () {
|
|
4571
|
+
if (findInputRef.current) {
|
|
4572
|
+
findInputRef.current.focus();
|
|
4573
|
+
findInputRef.current.select();
|
|
4574
|
+
}
|
|
4575
|
+
});
|
|
4576
|
+
}
|
|
4577
|
+
|
|
4578
|
+
function closeFind() {
|
|
4579
|
+
setFind({ open: false, query: '', replace: '', caseSensitive: false, index: 0 });
|
|
4580
|
+
}
|
|
4581
|
+
|
|
4582
|
+
function replaceCurrent() {
|
|
4583
|
+
if (findMatches.length === 0 || !editable) return;
|
|
4584
|
+
var at = findMatches[findIndex];
|
|
4585
|
+
var next = content.slice(0, at) + find.replace + content.slice(at + find.query.length);
|
|
4586
|
+
setContent(next);
|
|
4587
|
+
setDirty(true);
|
|
4588
|
+
setSave({ saving: false, conflict: false, error: '', ok: false });
|
|
4589
|
+
setFind(function (previous) { return Object.assign({}, previous, { index: Math.min(previous.index, Math.max(findMatches.length - 1, 0)) }); });
|
|
4590
|
+
}
|
|
4591
|
+
|
|
4592
|
+
function replaceAll() {
|
|
4593
|
+
if (findMatches.length === 0 || !editable || find.query === '') return;
|
|
4594
|
+
var escaped = find.query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4595
|
+
var pattern = new RegExp(escaped, find.caseSensitive ? 'g' : 'gi');
|
|
4596
|
+
var next = content.replace(pattern, function () { return find.replace; });
|
|
4597
|
+
setContent(next);
|
|
4598
|
+
setDirty(true);
|
|
4599
|
+
setSave({ saving: false, conflict: false, error: '', ok: false });
|
|
4600
|
+
setFind(function (previous) { return Object.assign({}, previous, { index: 0 }); });
|
|
4601
|
+
}
|
|
4602
|
+
|
|
4603
|
+
function renderFindBar() {
|
|
4604
|
+
if (!find.open) return null;
|
|
4605
|
+
var counterTotal = findResult.truncated ? String(findMatches.length) + '+' : findMatches.length;
|
|
4606
|
+
var counter = findMatches.length === 0 ? t('findNoMatch') : t('findCounter', { index: findIndex + 1, total: counterTotal });
|
|
4607
|
+
return h('div', { className: 'rw-find-bar', role: 'search' },
|
|
4608
|
+
h('input', {
|
|
4609
|
+
ref: findInputRef,
|
|
4610
|
+
className: 'rw-input',
|
|
4611
|
+
value: find.query,
|
|
4612
|
+
placeholder: t('findPlaceholder'),
|
|
4613
|
+
'aria-label': t('findPlaceholder'),
|
|
4614
|
+
spellCheck: false,
|
|
4615
|
+
onChange: function (event) {
|
|
4616
|
+
var value = event.currentTarget.value;
|
|
4617
|
+
setFind(function (previous) { return Object.assign({}, previous, { query: value, index: 0 }); });
|
|
4618
|
+
},
|
|
4619
|
+
onKeyDown: function (event) {
|
|
4620
|
+
if (event.key === 'Enter') { event.preventDefault(); stepMatch(event.shiftKey ? -1 : 1); }
|
|
4621
|
+
if (event.key === 'Escape') { event.preventDefault(); closeFind(); }
|
|
4622
|
+
},
|
|
4623
|
+
}),
|
|
4624
|
+
h('span', { className: 'rw-find-counter' }, counter),
|
|
4625
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findNext'), disabled: findMatches.length === 0, onClick: function () { stepMatch(1); } }, IconChevron(12)),
|
|
4626
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findPrev'), disabled: findMatches.length === 0, onClick: function () { stepMatch(-1); } }, h('span', { style: { display: 'inline-flex', transform: 'rotate(180deg)' } }, IconChevron(12))),
|
|
4627
|
+
h('input', {
|
|
4628
|
+
className: 'rw-input',
|
|
4629
|
+
value: find.replace,
|
|
4630
|
+
placeholder: t('replacePlaceholder'),
|
|
4631
|
+
'aria-label': t('replacePlaceholder'),
|
|
4632
|
+
spellCheck: false,
|
|
4633
|
+
disabled: !editable,
|
|
4634
|
+
onChange: function (event) {
|
|
4635
|
+
var value = event.currentTarget.value;
|
|
4636
|
+
setFind(function (previous) { return Object.assign({}, previous, { replace: value }); });
|
|
4637
|
+
},
|
|
4638
|
+
onKeyDown: function (event) { if (event.key === 'Enter') { event.preventDefault(); replaceCurrent(); } },
|
|
4639
|
+
}),
|
|
4640
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: !editable || findMatches.length === 0, onClick: replaceCurrent }, t('replaceOne')),
|
|
4641
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: !editable || findMatches.length === 0, onClick: replaceAll }, t('replaceAll')),
|
|
4642
|
+
h('button', { type: 'button', className: 'rw-icon-btn', title: t('close'), onClick: closeFind }, IconClose(12)));
|
|
4643
|
+
}
|
|
4644
|
+
|
|
4410
4645
|
var file = load.file;
|
|
4411
4646
|
var lineCount = useMemo(function () {
|
|
4412
4647
|
if (content.length > 200000) return null;
|
|
@@ -4569,6 +4804,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4569
4804
|
return h('div', { className: 'rw-editor', style: containerStyle },
|
|
4570
4805
|
header,
|
|
4571
4806
|
banner ? h('div', { style: { padding: '8px 10px 0' } }, banner) : null,
|
|
4807
|
+
renderFindBar(),
|
|
4572
4808
|
body,
|
|
4573
4809
|
h('div', { className: 'rw-editor-status' },
|
|
4574
4810
|
h('span', { className: 'rw-status-chip' }, 'UTF-8'),
|
|
@@ -4638,10 +4874,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
4638
4874
|
var cache = cacheState[0];
|
|
4639
4875
|
var setCache = cacheState[1];
|
|
4640
4876
|
var pending = useRef(new Set());
|
|
4877
|
+
var lastRefreshAt = useRef(new Map());
|
|
4641
4878
|
|
|
4642
4879
|
useEffect(function () {
|
|
4643
4880
|
if (!props.refreshTick) return;
|
|
4644
|
-
|
|
4881
|
+
// A background refresh costs one full listing per expanded directory, so
|
|
4882
|
+
// it stays quiet while the tab is hidden and never runs more often than
|
|
4883
|
+
// REFRESH_MIN_INTERVAL_MS per directory.
|
|
4884
|
+
if (typeof document !== 'undefined' && document.hidden) return;
|
|
4885
|
+
var now = Date.now();
|
|
4886
|
+
Array.from(expanded).forEach(function (path) {
|
|
4887
|
+
var at = lastRefreshAt.current.get(path) || 0;
|
|
4888
|
+
if (now - at < REFRESH_MIN_INTERVAL_MS) return;
|
|
4889
|
+
load(path, true);
|
|
4890
|
+
});
|
|
4645
4891
|
}, [props.refreshTick]);
|
|
4646
4892
|
|
|
4647
4893
|
function toggle(path) {
|
|
@@ -4669,10 +4915,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
4669
4915
|
function load(path, silent) {
|
|
4670
4916
|
if (pending.current.has(path)) return;
|
|
4671
4917
|
pending.current.add(path);
|
|
4918
|
+
lastRefreshAt.current.set(path, Date.now());
|
|
4672
4919
|
var previousRecord = cache.entries.get(path) || {};
|
|
4673
4920
|
// A silent refresh keeps as many rows as the user already loaded:
|
|
4674
4921
|
// re-reading only the first page would drop everything past it.
|
|
4675
|
-
var keep = silent ? Math.
|
|
4922
|
+
var keep = silent ? Math.max(Number(previousRecord.raw) || 0, TREE_PAGE_SIZE) : TREE_PAGE_SIZE;
|
|
4923
|
+
keep = Math.min(keep, TREE_PAGE_MAX);
|
|
4676
4924
|
setCache(function (previous) {
|
|
4677
4925
|
var entries = new Map(previous.entries);
|
|
4678
4926
|
var existing = entries.get(path) || {};
|
|
@@ -4683,14 +4931,28 @@ function attributeViolation(name, value, tagName) {
|
|
|
4683
4931
|
pending.current.delete(path);
|
|
4684
4932
|
setCache(function (previous) {
|
|
4685
4933
|
var next = new Map(previous.entries);
|
|
4934
|
+
var existing = next.get(path) || {};
|
|
4935
|
+
var fresh = applyEntries(result.entries || []);
|
|
4936
|
+
var freshPaths = new Set(fresh.map(function (entry) { return entry.path; }));
|
|
4937
|
+
// Keep rows beyond the refreshed page so a silent refresh cannot
|
|
4938
|
+
// shrink a list the user scrolled many pages into.
|
|
4939
|
+
var retained = silent
|
|
4940
|
+
? (existing.entries || []).filter(function (entry) { return !freshPaths.has(entry.path); })
|
|
4941
|
+
: [];
|
|
4942
|
+
var pageRaw = (result.entries || []).length;
|
|
4943
|
+
var raw = silent ? Math.max(Number(existing.raw) || 0, pageRaw) : pageRaw;
|
|
4944
|
+
var total = Number(result.total) || pageRaw + retained.length;
|
|
4686
4945
|
next.set(path, {
|
|
4687
4946
|
loading: false,
|
|
4688
4947
|
error: null,
|
|
4689
4948
|
loaded: true,
|
|
4690
|
-
entries:
|
|
4691
|
-
raw:
|
|
4692
|
-
total:
|
|
4693
|
-
|
|
4949
|
+
entries: fresh.concat(retained),
|
|
4950
|
+
raw: raw,
|
|
4951
|
+
total: total,
|
|
4952
|
+
// A silent refresh asks for `keep` rows; when everything is already
|
|
4953
|
+
// loaded the server still reports hasMore for the page it did not
|
|
4954
|
+
// return, so trust the row counts instead of the flag alone.
|
|
4955
|
+
hasMore: Boolean(result.hasMore) && raw < total,
|
|
4694
4956
|
});
|
|
4695
4957
|
return { entries: next };
|
|
4696
4958
|
});
|
|
@@ -4747,7 +5009,19 @@ function attributeViolation(name, value, tagName) {
|
|
|
4747
5009
|
});
|
|
4748
5010
|
}
|
|
4749
5011
|
|
|
4750
|
-
return h('div', {
|
|
5012
|
+
return h('div', {
|
|
5013
|
+
className: 'rw-tree',
|
|
5014
|
+
role: 'tree',
|
|
5015
|
+
'aria-label': t('allFiles'),
|
|
5016
|
+
onDragOver: function (event) {
|
|
5017
|
+
if (!props.onDropOnPath) return;
|
|
5018
|
+
event.preventDefault();
|
|
5019
|
+
try { event.dataTransfer.dropEffect = 'copy'; } catch (error) { /* ignore */ }
|
|
5020
|
+
},
|
|
5021
|
+
onDrop: function (event) {
|
|
5022
|
+
if (props.onDropOnPath) props.onDropOnPath(rootPath, event);
|
|
5023
|
+
},
|
|
5024
|
+
}, h(TreeDirectory, {
|
|
4751
5025
|
path: rootPath,
|
|
4752
5026
|
name: props.rootName || t('allFiles'),
|
|
4753
5027
|
depth: 0,
|
|
@@ -4763,7 +5037,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
4763
5037
|
onPin: props.onPin,
|
|
4764
5038
|
onSelectPath: props.onSelectPath,
|
|
4765
5039
|
onContextMenu: props.onContextMenu,
|
|
5040
|
+
onDragStart: props.onDragStartRow
|
|
5041
|
+
? function (event, info) { props.onDragStartRow(props.kind, event, info); }
|
|
5042
|
+
: null,
|
|
5043
|
+
onDropOnPath: props.onDropOnPath
|
|
5044
|
+
? function (path, event) { props.onDropOnPath(props.kind, path, event); }
|
|
5045
|
+
: null,
|
|
4766
5046
|
selectedPath: props.selectedPath || '',
|
|
5047
|
+
selectedSet: props.selectedPaths && props.selectedPaths.length > 0 ? new Set(props.selectedPaths) : null,
|
|
4767
5048
|
}));
|
|
4768
5049
|
}
|
|
4769
5050
|
|
|
@@ -4914,6 +5195,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4914
5195
|
state.error ? h(Banner, { kind: 'error' }, state.error) : null,
|
|
4915
5196
|
state.loading ? h('div', { className: 'rw-hint-row' }, Spinner(12), t('loading')) : null,
|
|
4916
5197
|
!state.loading && total === 0 ? h('div', { className: 'rw-hint-row' }, t('searchEmpty')) : null,
|
|
5198
|
+
!state.loading && state.truncated ? h('div', { className: 'rw-hint-row' }, t('searchTruncated')) : null,
|
|
4917
5199
|
groups.map(function (group) {
|
|
4918
5200
|
if (group.entries.length === 0) return null;
|
|
4919
5201
|
return h('div', { key: group.side, className: 'rw-change-group' },
|
|
@@ -5150,6 +5432,37 @@ function attributeViolation(name, value, tagName) {
|
|
|
5150
5432
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, props.t('close'))));
|
|
5151
5433
|
}
|
|
5152
5434
|
|
|
5435
|
+
function CompareDialog(props) {
|
|
5436
|
+
var t = props.t;
|
|
5437
|
+
var data = props.data;
|
|
5438
|
+
function section(key, title, rows, count, side) {
|
|
5439
|
+
return h('div', { key: key, className: 'rw-compare-section' },
|
|
5440
|
+
h('div', { className: 'rw-compare-title' }, title + ' (' + count + ')'),
|
|
5441
|
+
count === 0
|
|
5442
|
+
? h('div', { className: 'rw-compare-empty' }, t('compareNone'))
|
|
5443
|
+
: rows.map(function (row) {
|
|
5444
|
+
var size = row.size != null ? row.size : row.localSize;
|
|
5445
|
+
return h('button', {
|
|
5446
|
+
key: row.path,
|
|
5447
|
+
type: 'button',
|
|
5448
|
+
className: 'rw-compare-row',
|
|
5449
|
+
title: row.path,
|
|
5450
|
+
onClick: function () { props.onOpen(side, row.path); },
|
|
5451
|
+
},
|
|
5452
|
+
h('span', { className: 'rw-compare-path' }, row.path),
|
|
5453
|
+
h('span', { className: 'rw-compare-size' }, typeof size === 'number' ? formatBytes(size) : ''));
|
|
5454
|
+
}));
|
|
5455
|
+
}
|
|
5456
|
+
return h(DialogShell, { title: props.title, onClose: props.onClose },
|
|
5457
|
+
h('div', { className: 'rw-dialog-message rw-compare-root', title: data.localPath }, data.localPath),
|
|
5458
|
+
section('onlyLocal', t('compareOnlyLocal'), data.onlyLocal || [], data.counts.onlyLocal, 'local'),
|
|
5459
|
+
section('onlyRemote', t('compareOnlyRemote'), data.onlyRemote || [], data.counts.onlyRemote, 'remote'),
|
|
5460
|
+
section('changed', t('compareChanged'), data.changed || [], data.counts.changed, 'remote'),
|
|
5461
|
+
data.truncated ? h('div', { className: 'rw-dialog-note' }, t('compareTruncated')) : null,
|
|
5462
|
+
h('div', { className: 'rw-dialog-actions' },
|
|
5463
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, t('close'))));
|
|
5464
|
+
}
|
|
5465
|
+
|
|
5153
5466
|
function MoveDialog(props) {
|
|
5154
5467
|
var picker = props.side === 'local'
|
|
5155
5468
|
? h(LocalPathPicker, {
|
|
@@ -5541,6 +5854,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
5541
5854
|
var selectedEntryState = useState(null);
|
|
5542
5855
|
var selectedEntry = selectedEntryState[0];
|
|
5543
5856
|
var setSelectedEntry = selectedEntryState[1];
|
|
5857
|
+
var multiState = useState([]);
|
|
5858
|
+
var multi = multiState[0];
|
|
5859
|
+
var setMulti = multiState[1];
|
|
5544
5860
|
var showHiddenState = useState(true);
|
|
5545
5861
|
var showHidden = showHiddenState[0];
|
|
5546
5862
|
var setShowHidden = showHiddenState[1];
|
|
@@ -5641,6 +5957,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
5641
5957
|
var fileDirtyState = useState({});
|
|
5642
5958
|
var fileDirty = fileDirtyState[0];
|
|
5643
5959
|
var setFileDirty = fileDirtyState[1];
|
|
5960
|
+
|
|
5961
|
+
// Closing the browser tab or reloading the page would silently drop
|
|
5962
|
+
// unsaved edits: ask for confirmation while any open file is dirty.
|
|
5963
|
+
useEffect(function () {
|
|
5964
|
+
var dirty = openFiles.some(function (file) { return Boolean(fileDirty[file.key]); });
|
|
5965
|
+
if (!dirty) return undefined;
|
|
5966
|
+
function onBeforeUnload(event) {
|
|
5967
|
+
event.preventDefault();
|
|
5968
|
+
event.returnValue = '';
|
|
5969
|
+
return '';
|
|
5970
|
+
}
|
|
5971
|
+
window.addEventListener('beforeunload', onBeforeUnload);
|
|
5972
|
+
return function () { window.removeEventListener('beforeunload', onBeforeUnload); };
|
|
5973
|
+
}, [openFiles, fileDirty]);
|
|
5644
5974
|
var saveHandlersRef = useRef({});
|
|
5645
5975
|
var directoryTabId = props.tab && props.tab.id;
|
|
5646
5976
|
|
|
@@ -5715,6 +6045,19 @@ function attributeViolation(name, value, tagName) {
|
|
|
5715
6045
|
data.reload();
|
|
5716
6046
|
}
|
|
5717
6047
|
|
|
6048
|
+
function openCompare(path) {
|
|
6049
|
+
if (!selected) return;
|
|
6050
|
+
setDialog({ kind: 'compare', loading: true, error: '', data: null });
|
|
6051
|
+
apiCall('fs.compare', Object.assign({ path: path }, scopeParams(scopeRef))).then(function (result) {
|
|
6052
|
+
setDialog({
|
|
6053
|
+
kind: 'compare', loading: false, error: '',
|
|
6054
|
+
data: result, root: result.path, localPath: result.localPath,
|
|
6055
|
+
});
|
|
6056
|
+
}).catch(function (error) {
|
|
6057
|
+
setDialog({ kind: 'compare', loading: false, error: t('compareFailed') + ':' + messageOf(error, t, locale), data: null });
|
|
6058
|
+
});
|
|
6059
|
+
}
|
|
6060
|
+
|
|
5718
6061
|
function updateOpenMode(next) {
|
|
5719
6062
|
apiCall('settings.update', { fileOpenMode: next }).then(function (result) {
|
|
5720
6063
|
runtimeSettings.apply({ fileOpenMode: result && result.fileOpenMode ? result.fileOpenMode : next });
|
|
@@ -5724,9 +6067,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
5724
6067
|
});
|
|
5725
6068
|
}
|
|
5726
6069
|
|
|
5727
|
-
function openTerminal(side) {
|
|
6070
|
+
function openTerminal(side, atPath) {
|
|
5728
6071
|
if (!selected) return;
|
|
5729
6072
|
var request = { side: side };
|
|
6073
|
+
if (typeof atPath === 'string' && atPath !== '') request.path = atPath;
|
|
5730
6074
|
if (selected.kind === 'linked') request.linkedId = selected.id;
|
|
5731
6075
|
else request.workspaceId = selected.id;
|
|
5732
6076
|
apiCall('terminal.open', request).then(function () {
|
|
@@ -5876,6 +6220,49 @@ function attributeViolation(name, value, tagName) {
|
|
|
5876
6220
|
showNotice('error', t('actionFailed') + ':' + messageOf(error, t, locale));
|
|
5877
6221
|
}
|
|
5878
6222
|
|
|
6223
|
+
// Ctrl/Cmd-click toggles an entry in the multi-selection; a plain click
|
|
6224
|
+
// collapses the selection to that entry (Shift extends it).
|
|
6225
|
+
function updateSelection(side, info) {
|
|
6226
|
+
if (!info || typeof info.path !== 'string') return;
|
|
6227
|
+
var event = info.event;
|
|
6228
|
+
var entry = { side: side, path: info.path, name: info.name, isDir: Boolean(info.isDir) };
|
|
6229
|
+
setSelectedEntry(entry);
|
|
6230
|
+
var toggle = Boolean(event && (event.ctrlKey || event.metaKey));
|
|
6231
|
+
var extend = Boolean(event && event.shiftKey);
|
|
6232
|
+
setMulti(function (previous) {
|
|
6233
|
+
var exists = previous.some(function (item) { return item.side === side && item.path === entry.path; });
|
|
6234
|
+
if (extend) return exists ? previous : previous.concat([entry]);
|
|
6235
|
+
if (toggle) {
|
|
6236
|
+
return exists
|
|
6237
|
+
? previous.filter(function (item) { return !(item.side === side && item.path === entry.path); })
|
|
6238
|
+
: previous.concat([entry]);
|
|
6239
|
+
}
|
|
6240
|
+
return [entry];
|
|
6241
|
+
});
|
|
6242
|
+
}
|
|
6243
|
+
|
|
6244
|
+
function selectedOn(side) {
|
|
6245
|
+
return multi.filter(function (item) { return item.side === side; });
|
|
6246
|
+
}
|
|
6247
|
+
|
|
6248
|
+
function selectionFor(side) {
|
|
6249
|
+
var list = selectedOn(side);
|
|
6250
|
+
if (list.length > 0) return list;
|
|
6251
|
+
if (selectedEntry && selectedEntry.side === side) return [selectedEntry];
|
|
6252
|
+
return [];
|
|
6253
|
+
}
|
|
6254
|
+
|
|
6255
|
+
function transferSelection() {
|
|
6256
|
+
var list = multi.length > 0 ? multi : (selectedEntry ? [selectedEntry] : []);
|
|
6257
|
+
list.forEach(function (item) { enqueueTransfer(item.side, item.path, item.name); });
|
|
6258
|
+
}
|
|
6259
|
+
|
|
6260
|
+
function deleteSelection() {
|
|
6261
|
+
var list = multi.length > 0 ? multi : (selectedEntry ? [selectedEntry] : []);
|
|
6262
|
+
if (list.length === 0) return;
|
|
6263
|
+
setDialog({ kind: 'deleteMany', entries: list });
|
|
6264
|
+
}
|
|
6265
|
+
|
|
5879
6266
|
function copyPathToClipboard(text) {
|
|
5880
6267
|
try {
|
|
5881
6268
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
@@ -5985,6 +6372,94 @@ function attributeViolation(name, value, tagName) {
|
|
|
5985
6372
|
}).catch(noticeError);
|
|
5986
6373
|
}
|
|
5987
6374
|
|
|
6375
|
+
function confirmDeleteMany(entries) {
|
|
6376
|
+
var list = Array.isArray(entries) ? entries : [];
|
|
6377
|
+
var failures = [];
|
|
6378
|
+
var chain = Promise.resolve();
|
|
6379
|
+
list.forEach(function (entry) {
|
|
6380
|
+
chain = chain.then(function () {
|
|
6381
|
+
var method = entry.side === 'remote' ? 'fs.delete' : 'local.delete';
|
|
6382
|
+
var params = entry.side === 'remote'
|
|
6383
|
+
? Object.assign({ path: entry.path }, scopeParams(scopeRef))
|
|
6384
|
+
: { path: entry.path, root: selected.localPath };
|
|
6385
|
+
return apiCall(method, params).then(function () {
|
|
6386
|
+
setMulti(function (previous) {
|
|
6387
|
+
return previous.filter(function (item) { return !(item.side === entry.side && item.path === entry.path); });
|
|
6388
|
+
});
|
|
6389
|
+
}).catch(function (error) { failures.push(error); });
|
|
6390
|
+
});
|
|
6391
|
+
});
|
|
6392
|
+
chain.then(function () {
|
|
6393
|
+
if (failures.length > 0) showNotice('error', messageOf(failures[0], t, locale));
|
|
6394
|
+
else showNotice('success', t('deleteDone'));
|
|
6395
|
+
refreshTree();
|
|
6396
|
+
});
|
|
6397
|
+
}
|
|
6398
|
+
|
|
6399
|
+
var DRAG_MIME = 'application/x-dsh-linked-entry';
|
|
6400
|
+
|
|
6401
|
+
function beginDragRow(side, event, info) {
|
|
6402
|
+
if (!event.dataTransfer || !info) return;
|
|
6403
|
+
try {
|
|
6404
|
+
event.dataTransfer.setData(DRAG_MIME, JSON.stringify({
|
|
6405
|
+
side: side, path: info.path, name: info.name, isDir: Boolean(info.isDir),
|
|
6406
|
+
}));
|
|
6407
|
+
event.dataTransfer.effectAllowed = 'copy';
|
|
6408
|
+
} catch (error) { /* drag payload unsupported */ }
|
|
6409
|
+
}
|
|
6410
|
+
|
|
6411
|
+
// Drop target handling for both trees: OS files are imported into the
|
|
6412
|
+
// target directory, while an entry dragged from the other tree is pushed
|
|
6413
|
+
// across the boundary (remote→local or local→remote).
|
|
6414
|
+
function dropOnPath(side, targetDir, event) {
|
|
6415
|
+
event.preventDefault();
|
|
6416
|
+
event.stopPropagation();
|
|
6417
|
+
var transfer = event.dataTransfer;
|
|
6418
|
+
if (!transfer || typeof targetDir !== 'string' || targetDir === '') return;
|
|
6419
|
+
var files = Array.prototype.slice.call(transfer.files || []);
|
|
6420
|
+
var osPaths = files.map(function (file) {
|
|
6421
|
+
return file && typeof file.path === 'string' ? file.path : '';
|
|
6422
|
+
}).filter(Boolean);
|
|
6423
|
+
if (files.length > 0 && osPaths.length === 0) {
|
|
6424
|
+
showNotice('error', t('dropNeedsDesktop'));
|
|
6425
|
+
return;
|
|
6426
|
+
}
|
|
6427
|
+
if (osPaths.length > 0) {
|
|
6428
|
+
var payload = side === 'remote'
|
|
6429
|
+
? Object.assign({ path: targetDir, paths: osPaths }, scopeParams(scopeRef))
|
|
6430
|
+
: { dir: targetDir, paths: osPaths };
|
|
6431
|
+
apiCall(side === 'remote' ? 'fs.upload' : 'local.import', payload).then(function (result) {
|
|
6432
|
+
var count = side === 'remote' ? Number(result.files) || 0 : Number(result.copied) || 0;
|
|
6433
|
+
showNotice('success', t('dropImported', { count: count }));
|
|
6434
|
+
if (Number(result.skipped) > 0) showNotice('warn', t('dropSkipped', { count: result.skipped }));
|
|
6435
|
+
refreshTree();
|
|
6436
|
+
}).catch(noticeError);
|
|
6437
|
+
return;
|
|
6438
|
+
}
|
|
6439
|
+
var raw = '';
|
|
6440
|
+
try { raw = transfer.getData(DRAG_MIME); } catch (error) { raw = ''; }
|
|
6441
|
+
if (!raw) return;
|
|
6442
|
+
var entry;
|
|
6443
|
+
try { entry = JSON.parse(raw); } catch (error) { return; }
|
|
6444
|
+
if (!entry || typeof entry.path !== 'string' || entry.side === side) return;
|
|
6445
|
+
if (entry.side === 'remote') {
|
|
6446
|
+
if (entry.isDir) {
|
|
6447
|
+
showNotice('error', t('dropDirUnsupported'));
|
|
6448
|
+
return;
|
|
6449
|
+
}
|
|
6450
|
+
apiCall('fs.pullToLocal', Object.assign({ path: entry.path, targetDir: targetDir }, scopeParams(scopeRef))).then(function () {
|
|
6451
|
+
showNotice('success', t('dropImported', { count: 1 }));
|
|
6452
|
+
refreshTree();
|
|
6453
|
+
}).catch(noticeError);
|
|
6454
|
+
return;
|
|
6455
|
+
}
|
|
6456
|
+
apiCall('fs.upload', Object.assign({ path: targetDir, paths: [entry.path] }, scopeParams(scopeRef))).then(function (result) {
|
|
6457
|
+
if (Number(result.skipped) > 0) showNotice('warn', t('dropSkipped', { count: result.skipped }));
|
|
6458
|
+
else showNotice('success', t('dropImported', { count: Number(result.files) || 1 }));
|
|
6459
|
+
refreshTree();
|
|
6460
|
+
}).catch(noticeError);
|
|
6461
|
+
}
|
|
6462
|
+
|
|
5988
6463
|
function submitRenamed(side, oldPath, name) {
|
|
5989
6464
|
var target = joinChildPath(parentPathOf(oldPath, side), name, side);
|
|
5990
6465
|
if (target === oldPath) return;
|
|
@@ -6090,6 +6565,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
6090
6565
|
}
|
|
6091
6566
|
var canPaste = clipboard !== null && clipboard.side === menu.side && menu.isDir;
|
|
6092
6567
|
var items = [];
|
|
6568
|
+
var batch = multi.filter(function (item) { return item.side === menu.side; });
|
|
6569
|
+
if (batch.length > 1) {
|
|
6570
|
+
items.push({ label: t('ctxTransferSelected', { count: batch.length }), onSelect: function () {
|
|
6571
|
+
batch.forEach(function (item) { enqueueTransfer(item.side, item.path, item.name); });
|
|
6572
|
+
} });
|
|
6573
|
+
items.push({ label: t('ctxDeleteSelected', { count: batch.length }), onSelect: deleteSelection });
|
|
6574
|
+
items.push({ separator: true });
|
|
6575
|
+
}
|
|
6093
6576
|
if (isRemote) {
|
|
6094
6577
|
items.push({ label: t('ctxTransfer'), onSelect: function () { enqueueTransfer('remote', menu.path, menu.name); } });
|
|
6095
6578
|
items.push({ label: t('ctxDownload'), onSelect: function () { downloadEntry(menu); } });
|
|
@@ -6133,8 +6616,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6133
6616
|
} });
|
|
6134
6617
|
if (menu.isDir) {
|
|
6135
6618
|
items.push({ separator: true });
|
|
6619
|
+
items.push({ label: t('ctxTerminalHere'), onSelect: function () { openTerminal(menu.side, menu.path); } });
|
|
6136
6620
|
items = items.concat(newEntryMenuItems(menu, t, setDialog));
|
|
6137
6621
|
}
|
|
6622
|
+
if (menu.isDir && menu.side === 'remote' && selected && selected.kind === 'linked') {
|
|
6623
|
+
items.push({ label: t('ctxCompare'), onSelect: function () { openCompare(menu.path); } });
|
|
6624
|
+
}
|
|
6138
6625
|
items.push({ separator: true });
|
|
6139
6626
|
items.push({ label: t('ctxProperties'), onSelect: function () { showProperties(menu.side, menu.path); } });
|
|
6140
6627
|
return items;
|
|
@@ -6142,6 +6629,27 @@ function attributeViolation(name, value, tagName) {
|
|
|
6142
6629
|
|
|
6143
6630
|
function renderDialog() {
|
|
6144
6631
|
if (!dialog) return null;
|
|
6632
|
+
if (dialog.kind === 'compare') {
|
|
6633
|
+
return dialog.loading
|
|
6634
|
+
? h(DialogShell, { title: t('compareTitle'), onClose: function () { setDialog(null); } },
|
|
6635
|
+
h('div', { className: 'rw-dialog-message' }, Spinner(13), t('loading')))
|
|
6636
|
+
: dialog.error
|
|
6637
|
+
? h(DialogShell, { title: t('compareTitle'), onClose: function () { setDialog(null); } },
|
|
6638
|
+
h('div', { className: 'rw-dialog-message rw-dialog-error' }, dialog.error),
|
|
6639
|
+
h('div', { className: 'rw-dialog-actions' },
|
|
6640
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { setDialog(null); } }, t('close'))))
|
|
6641
|
+
: h(CompareDialog, {
|
|
6642
|
+
t: t,
|
|
6643
|
+
title: t('compareTitle'),
|
|
6644
|
+
data: dialog.data,
|
|
6645
|
+
onClose: function () { setDialog(null); },
|
|
6646
|
+
onOpen: function (side, relative) {
|
|
6647
|
+
var root = dialog.root;
|
|
6648
|
+
var target = side === 'local' ? dialog.localPath : root;
|
|
6649
|
+
openInternalFile(side === 'local' ? 'local' : 'remote', target + (target.endsWith('/') || target.endsWith('\\') ? '' : side === 'local' ? '\\' : '/') + relative.split('/').join(side === 'local' ? '\\' : '/'));
|
|
6650
|
+
},
|
|
6651
|
+
});
|
|
6652
|
+
}
|
|
6145
6653
|
if (dialog.kind === 'props') {
|
|
6146
6654
|
return h(PropertiesDialog, { t: t, title: dialog.title, rows: dialog.rows, onClose: function () { setDialog(null); } });
|
|
6147
6655
|
}
|
|
@@ -6167,6 +6675,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
6167
6675
|
onConfirm: function () { setDialog(null); confirmDelete(dialog); },
|
|
6168
6676
|
});
|
|
6169
6677
|
}
|
|
6678
|
+
if (dialog.kind === 'deleteMany') {
|
|
6679
|
+
return h(ConfirmDialog, {
|
|
6680
|
+
t: t,
|
|
6681
|
+
title: t('deleteManyTitle'),
|
|
6682
|
+
message: t('deleteManyMessage', { count: dialog.entries.length }),
|
|
6683
|
+
confirmLabel: t('deleteConfirm'),
|
|
6684
|
+
onClose: function () { setDialog(null); },
|
|
6685
|
+
onConfirm: function () { setDialog(null); confirmDeleteMany(dialog.entries); },
|
|
6686
|
+
});
|
|
6687
|
+
}
|
|
6170
6688
|
if (dialog.kind === 'move') {
|
|
6171
6689
|
return h(MoveDialog, {
|
|
6172
6690
|
t: t, locale: locale,
|
|
@@ -6238,7 +6756,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6238
6756
|
}
|
|
6239
6757
|
var alive = true;
|
|
6240
6758
|
var timer = setTimeout(function () {
|
|
6241
|
-
setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, error: null }; });
|
|
6759
|
+
setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, error: null }; });
|
|
6242
6760
|
var scopeNow = sourceScopeOf(selected);
|
|
6243
6761
|
var jobs = [apiCall('fs.search', Object.assign({ side: 'remote', query: query, maxResults: 200 }, scopeParams(scopeNow))).catch(function (error) {
|
|
6244
6762
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
@@ -6256,6 +6774,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6256
6774
|
loading: false,
|
|
6257
6775
|
remote: results[0] && results[0].entries ? results[0].entries : [],
|
|
6258
6776
|
local: results[1] && results[1].entries ? results[1].entries : [],
|
|
6777
|
+
truncated: Boolean((results[0] && results[0].truncated) || (results[1] && results[1].truncated)),
|
|
6259
6778
|
error: (results[0] && results[0].error) || (results[1] && results[1].error) || null,
|
|
6260
6779
|
});
|
|
6261
6780
|
});
|
|
@@ -6305,7 +6824,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
6305
6824
|
locale: locale,
|
|
6306
6825
|
showHidden: showHidden,
|
|
6307
6826
|
selectedPath: selectedEntry && selectedEntry.side === 'remote' ? selectedEntry.path : '',
|
|
6308
|
-
|
|
6827
|
+
selectedPaths: selectionFor('remote').map(function (item) { return item.path; }),
|
|
6828
|
+
onSelectPath: function (info) { updateSelection('remote', info); },
|
|
6829
|
+
onDragStartRow: beginDragRow,
|
|
6830
|
+
onDropOnPath: dropOnPath,
|
|
6309
6831
|
onSelect: function (filePath) { openByMode('remote', filePath, { pinned: false, preview: true }); },
|
|
6310
6832
|
onPin: function (filePath) { pinByMode('remote', filePath); },
|
|
6311
6833
|
onContextMenu: function (info) { setSelectedEntry(Object.assign({ side: 'remote' }, info)); openContextMenu('remote', info); },
|
|
@@ -6326,7 +6848,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
6326
6848
|
locale: locale,
|
|
6327
6849
|
showHidden: showHidden,
|
|
6328
6850
|
selectedPath: selectedEntry && selectedEntry.side === 'local' ? selectedEntry.path : '',
|
|
6329
|
-
|
|
6851
|
+
selectedPaths: selectionFor('local').map(function (item) { return item.path; }),
|
|
6852
|
+
onSelectPath: function (info) { updateSelection('local', info); },
|
|
6853
|
+
onDragStartRow: beginDragRow,
|
|
6854
|
+
onDropOnPath: dropOnPath,
|
|
6330
6855
|
onSelect: function (filePath) { openByMode('local', filePath, { pinned: false, preview: true }); },
|
|
6331
6856
|
onPin: function (filePath) { pinByMode('local', filePath); },
|
|
6332
6857
|
refreshTick: localTick,
|
|
@@ -6410,13 +6935,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
6410
6935
|
localEnabled: !remoteOnly && selected.kind === 'linked',
|
|
6411
6936
|
showHidden: showHidden,
|
|
6412
6937
|
onToggleHidden: function () { setShowHidden(!showHidden); },
|
|
6413
|
-
transferEnabled: !remoteOnly && Boolean(selectedEntry),
|
|
6938
|
+
transferEnabled: !remoteOnly && (multi.length > 0 || Boolean(selectedEntry)),
|
|
6414
6939
|
transferSelected: function () {
|
|
6415
|
-
if (!selectedEntry) {
|
|
6940
|
+
if (multi.length === 0 && !selectedEntry) {
|
|
6416
6941
|
showNotice('info', t('selectFirst'));
|
|
6417
6942
|
return;
|
|
6418
6943
|
}
|
|
6419
|
-
|
|
6944
|
+
transferSelection();
|
|
6420
6945
|
},
|
|
6421
6946
|
onMode: function (next) { setMode(next); },
|
|
6422
6947
|
onToggleSearch: function () { setSearchOpen(!searchOpen); },
|
|
@@ -6569,10 +7094,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
6569
7094
|
onPin: onPin,
|
|
6570
7095
|
onSelectPath: onSelectPath,
|
|
6571
7096
|
onContextMenu: onContextMenu,
|
|
7097
|
+
onDragStart: props.onDragStart,
|
|
7098
|
+
onDropOnPath: props.onDropOnPath,
|
|
6572
7099
|
selectedPath: selectedPath,
|
|
7100
|
+
selectedSet: props.selectedSet,
|
|
6573
7101
|
}));
|
|
6574
7102
|
} else if (child.type === 'file' || child.type === 'symlink') {
|
|
6575
|
-
var active = selectedPath === child.path;
|
|
7103
|
+
var active = selectedPath === child.path || Boolean(props.selectedSet && props.selectedSet.has(child.path));
|
|
6576
7104
|
children.push(h('button', {
|
|
6577
7105
|
key: child.path,
|
|
6578
7106
|
type: 'button',
|
|
@@ -6582,8 +7110,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6582
7110
|
className: 'rw-row' + (active ? ' is-active' : ''),
|
|
6583
7111
|
style: { paddingLeft: 6 + (depth + 1) * 12 },
|
|
6584
7112
|
title: child.path,
|
|
7113
|
+
draggable: Boolean(props.onDragStart),
|
|
7114
|
+
onDragStart: function (event) {
|
|
7115
|
+
if (props.onDragStart) props.onDragStart(event, { path: child.path, name: child.name, isDir: false });
|
|
7116
|
+
},
|
|
6585
7117
|
onClick: function (event) {
|
|
6586
|
-
if (onSelectPath) onSelectPath({ path: child.path, name: child.name, isDir: false });
|
|
7118
|
+
if (onSelectPath) onSelectPath({ path: child.path, name: child.name, isDir: false, event: event });
|
|
6587
7119
|
if (event.detail !== 2) onSelect(child.path);
|
|
6588
7120
|
},
|
|
6589
7121
|
onDoubleClick: function () { if (onPin) onPin(child.path); },
|
|
@@ -6622,17 +7154,33 @@ function attributeViolation(name, value, tagName) {
|
|
|
6622
7154
|
role: 'treeitem',
|
|
6623
7155
|
'aria-level': depth + 1,
|
|
6624
7156
|
'aria-expanded': isOpen,
|
|
6625
|
-
className: 'rw-row' + (selectedPath === path ? ' is-active' : ''),
|
|
7157
|
+
className: 'rw-row' + (selectedPath === path || (props.selectedSet && props.selectedSet.has(path)) ? ' is-active' : ''),
|
|
6626
7158
|
style: { paddingLeft: 6 + depth * 12 },
|
|
6627
7159
|
title: path,
|
|
7160
|
+
draggable: Boolean(props.onDragStart),
|
|
7161
|
+
onDragStart: function (event) {
|
|
7162
|
+
if (props.onDragStart) props.onDragStart(event, { path: path, name: name, isDir: true });
|
|
7163
|
+
},
|
|
6628
7164
|
onClick: function (event) {
|
|
6629
|
-
if (onSelectPath) onSelectPath({ path: path, name: name, isDir: true });
|
|
7165
|
+
if (onSelectPath) onSelectPath({ path: path, name: name, isDir: true, event: event });
|
|
6630
7166
|
if (event.detail !== 2) toggle(path);
|
|
6631
7167
|
},
|
|
6632
7168
|
onKeyDown: function (event) {
|
|
6633
7169
|
if (event.key === 'ArrowRight' && !isOpen) { event.preventDefault(); toggle(path); }
|
|
6634
7170
|
else if (event.key === 'ArrowLeft' && isOpen) { event.preventDefault(); toggle(path); }
|
|
6635
7171
|
},
|
|
7172
|
+
onDragOver: function (event) {
|
|
7173
|
+
if (!props.onDropOnPath) return;
|
|
7174
|
+
event.preventDefault();
|
|
7175
|
+
event.stopPropagation();
|
|
7176
|
+
try { event.dataTransfer.dropEffect = 'copy'; } catch (error) { /* ignore */ }
|
|
7177
|
+
event.currentTarget.classList.add('is-drop-target');
|
|
7178
|
+
},
|
|
7179
|
+
onDragLeave: function (event) { event.currentTarget.classList.remove('is-drop-target'); },
|
|
7180
|
+
onDrop: function (event) {
|
|
7181
|
+
event.currentTarget.classList.remove('is-drop-target');
|
|
7182
|
+
if (props.onDropOnPath) props.onDropOnPath(path, event);
|
|
7183
|
+
},
|
|
6636
7184
|
onContextMenu: function (event) {
|
|
6637
7185
|
if (!onContextMenu) return;
|
|
6638
7186
|
event.preventDefault();
|