dsh-linked-workspace 0.8.3 → 0.10.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/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,35 @@ 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: '暂不支持把远程目录拖拽到本地,请使用右键「传输」',
2202
+ dropLocalDirUnsupported: '暂不支持把本地目录拖拽到远端,请使用右键「传输」',
2170
2203
  sheetTruncated: '仅显示前 {{rows}} 行 × {{cols}} 列',
2171
2204
  sheetMore: '工作表较多,仅显示前 20 个',
2172
2205
  noCredential: '缺少凭据',
@@ -2193,6 +2226,25 @@ function attributeViolation(name, value, tagName) {
2193
2226
  removeWorkspaceHint: '「同时移除工作区」会把该本地目录从 DSH 工作区列表移除(会话保留,显示在未分组下)。',
2194
2227
  openWorkspace: '打开工作区',
2195
2228
  workspaceMissing: '工作区未注册',
2229
+ workspaceRegister: '注册为工作区',
2230
+ workspaceRegistered: '已注册为工作区',
2231
+ conflictDropTitle: '目标已存在',
2232
+ conflictOverwrite: '覆盖',
2233
+ conflictKeepBoth: '保留两者',
2234
+ conflictCancel: '取消',
2235
+ compareLocalMissing: '本地没有对应目录,远端独有的文件无法对比',
2236
+ compareTruncatedRemote: '远端条目过多,对比只覆盖前 4000 项',
2237
+ compareTruncatedLocal: '本地条目过多,对比只覆盖前 4000 项',
2238
+ comparePush: '推送到远端',
2239
+ comparePull: '拉取到本地',
2240
+ comparePushed: '已推送 {{name}}',
2241
+ comparePulled: '已拉取 {{name}}',
2242
+ dropSameSide: '同一工作区内请使用「移动到…」;拖拽只用于本地与远端之间',
2243
+ searchModeName: '文件名',
2244
+ searchModeContent: '内容',
2245
+ searchPlaceholderContent: '在文件内容中搜索…',
2246
+ queueRetry: '重试',
2247
+ shortcutWebNote: 'Web GUI 中 Ctrl+W、Ctrl+Tab 由浏览器占用,请在 DSH 桌面端使用这些快捷键。',
2196
2248
  themeTitle: '编辑器主题',
2197
2249
  themeHint: '远程文件编辑器的配色;主题只影响本插件的远程文件视图。',
2198
2250
  themeDark: '深色',
@@ -2501,6 +2553,35 @@ function attributeViolation(name, value, tagName) {
2501
2553
  loadMore: 'Load more ({{count}} left)',
2502
2554
  loadMoreShort: 'Load more',
2503
2555
  pickerTruncated: 'Too many entries; only the first {{count}} are shown. Type a path directly.',
2556
+ filterPlaceholder: 'Filter by name…',
2557
+ filterEmpty: 'No entries match the current filter',
2558
+ searchTruncated: 'Too many results; showing the first 200. Narrow the query.',
2559
+ findPlaceholder: 'Find…',
2560
+ replacePlaceholder: 'Replace with…',
2561
+ findCounter: '{{index}} / {{total}}',
2562
+ findNoMatch: 'No match',
2563
+ findNext: 'Next match',
2564
+ findPrev: 'Previous match',
2565
+ replaceOne: 'Replace',
2566
+ replaceAll: 'Replace all',
2567
+ compareTitle: 'Local vs remote comparison',
2568
+ compareOnlyLocal: 'Local only',
2569
+ compareOnlyRemote: 'Remote only',
2570
+ compareChanged: 'Different size or time',
2571
+ compareNone: 'None',
2572
+ compareTruncated: 'Too many files; the comparison was truncated (4000 files / 12 levels).',
2573
+ compareFailed: 'Comparison failed',
2574
+ ctxCompare: 'Compare with local…',
2575
+ ctxTerminalHere: 'Open terminal here',
2576
+ ctxTransferSelected: 'Transfer selected ({{count}})',
2577
+ ctxDeleteSelected: 'Delete selected ({{count}})',
2578
+ deleteManyTitle: 'Delete multiple',
2579
+ deleteManyMessage: 'Delete the {{count}} selected items? This cannot be undone.',
2580
+ dropNeedsDesktop: 'This browser cannot read dropped file paths; drag files in the DSH desktop window',
2581
+ dropImported: 'Imported {{count}} file(s)',
2582
+ dropSkipped: '{{count}} file(s) skipped (too large or not a regular file)',
2583
+ dropDirUnsupported: 'Dropping a remote folder onto local is not supported yet; use Transfer instead',
2584
+ dropLocalDirUnsupported: 'Dropping a local folder onto remote is not supported yet; use Transfer instead',
2504
2585
  sheetTruncated: 'Showing the first {{rows}} rows × {{cols}} columns',
2505
2586
  sheetMore: 'Showing the first 20 worksheets only',
2506
2587
  noCredential: 'No credentials',
@@ -2527,6 +2608,25 @@ function attributeViolation(name, value, tagName) {
2527
2608
  removeWorkspaceHint: '“Remove workspace too” also removes the local folder from the DSH workspace list (sessions stay, shown under ungrouped).',
2528
2609
  openWorkspace: 'Open workspace',
2529
2610
  workspaceMissing: 'Workspace not registered',
2611
+ workspaceRegister: 'Register as workspace',
2612
+ workspaceRegistered: 'Registered as workspace',
2613
+ conflictDropTitle: 'Target already exists',
2614
+ conflictOverwrite: 'Overwrite',
2615
+ conflictKeepBoth: 'Keep both',
2616
+ conflictCancel: 'Cancel',
2617
+ compareLocalMissing: 'The local folder has no counterpart here; remote-only entries cannot be compared',
2618
+ compareTruncatedRemote: 'Too many remote entries; the comparison covers the first 4000',
2619
+ compareTruncatedLocal: 'Too many local entries; the comparison covers the first 4000',
2620
+ comparePush: 'Push to remote',
2621
+ comparePull: 'Pull to local',
2622
+ comparePushed: 'Pushed {{name}}',
2623
+ comparePulled: 'Pulled {{name}}',
2624
+ dropSameSide: 'Within one side, use “Move to…”; dragging is for local ↔ remote only',
2625
+ searchModeName: 'Name',
2626
+ searchModeContent: 'Content',
2627
+ searchPlaceholderContent: 'Search file contents…',
2628
+ queueRetry: 'Retry',
2629
+ shortcutWebNote: 'In the Web GUI, Ctrl+W and Ctrl+Tab are reserved by the browser; use these shortcuts in the DSH desktop app.',
2530
2630
  themeTitle: 'Editor theme',
2531
2631
  themeHint: 'Colors of the remote file editor. Themes affect this plugin’s remote file views only.',
2532
2632
  themeDark: 'Dark',
@@ -3309,6 +3409,29 @@ function attributeViolation(name, value, tagName) {
3309
3409
  '.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
3410
  '.rw-load-more:hover{text-decoration:underline}',
3311
3411
  '.rw-load-more:disabled{opacity:.6;cursor:default}',
3412
+ '.rw-filter-row{padding:4px 8px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
3413
+ '.rw-filter-row .rw-input{width:100%}',
3414
+ '.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)}',
3415
+ '.rw-find-bar .rw-input{height:26px;font-size:11.5px;min-width:120px;flex:0 1 160px}',
3416
+ '.rw-find-counter{font-size:11px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}',
3417
+ '.rw-compare-root{font-family:ui-monospace,Consolas,monospace;font-size:11px}',
3418
+ '.rw-compare-section{margin:0 0 8px}',
3419
+ '.rw-compare-title{font-size:11.5px;font-weight:600;padding:2px 0}',
3420
+ '.rw-compare-empty{font-size:11px;color:var(--dsw-alias-label-tertiary);padding-left:8px}',
3421
+ '.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}',
3422
+ '.rw-compare-row:hover{background:var(--dsw-alias-interactive-bg-hover)}',
3423
+ '.rw-compare-path{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
3424
+ '.rw-compare-size{flex:0 0 auto;color:var(--dsw-alias-label-tertiary)}',
3425
+ '.rw-compare-item{display:flex;align-items:center;gap:4px}',
3426
+ '.rw-compare-item .rw-compare-row{flex:1 1 auto;min-width:0}',
3427
+ '.rw-compare-actions{display:flex;gap:4px;flex:0 0 auto;padding-right:4px}',
3428
+ '.rw-compare-act{border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:10.5px;padding:1px 6px;border-radius:4px;cursor:pointer;white-space:nowrap}',
3429
+ '.rw-compare-act:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}',
3430
+ '.rw-search-mode{display:flex;gap:2px;flex:0 0 auto}',
3431
+ '.rw-doc-find{flex:0 0 auto}',
3432
+ '.rw-dialog-note{font-size:11px;color:var(--dsw-alias-label-tertiary);padding:2px 0}',
3433
+ '.rw-dialog-error{color:var(--dsw-alias-state-error-primary)}',
3434
+ '.rw-row.is-drop-target{outline:1px dashed var(--dsw-alias-brand-primary);outline-offset:-1px}',
3312
3435
  '.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
3436
  '.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
3437
  '.rw-doc-grid{width:100%;border-collapse:collapse;font-size:11.5px}',
@@ -3730,7 +3853,7 @@ function attributeViolation(name, value, tagName) {
3730
3853
  var locale = props.locale;
3731
3854
  var initialPath = props.initialPath || '';
3732
3855
  var root = props.root || '';
3733
- var state = useState({ loading: true, listing: null, error: '', input: initialPath, creating: false, folderName: '' });
3856
+ var state = useState({ loading: true, listing: null, error: '', input: initialPath, creating: false, folderName: '', filter: '' });
3734
3857
  var local = state[0];
3735
3858
  var setLocal = state[1];
3736
3859
 
@@ -3738,7 +3861,7 @@ function attributeViolation(name, value, tagName) {
3738
3861
  setLocal(function (previous) { return Object.assign({}, previous, { loading: true, error: '', input: path || previous.input }); });
3739
3862
  apiCall('local.browse', path ? { path: path } : {}).then(function (result) {
3740
3863
  setLocal(function (previous) {
3741
- return Object.assign({}, previous, { loading: false, listing: result, error: '', input: result.path });
3864
+ return Object.assign({}, previous, { loading: false, listing: result, error: '', input: result.path, filter: '' });
3742
3865
  });
3743
3866
  }).catch(function (error) {
3744
3867
  setLocal(function (previous) {
@@ -3779,7 +3902,11 @@ function attributeViolation(name, value, tagName) {
3779
3902
  // A folder with thousands of sub-folders must not build thousands of DOM
3780
3903
  // rows; the input box below still accepts any path.
3781
3904
  var PICKER_LIMIT = 500;
3782
- var shownEntries = entries.slice(0, PICKER_LIMIT);
3905
+ var filterText = String(local.filter || '').trim().toLowerCase();
3906
+ var matchedEntries = filterText === '' ? entries : entries.filter(function (entry) {
3907
+ return String(entry.name || '').toLowerCase().indexOf(filterText) !== -1;
3908
+ });
3909
+ var shownEntries = matchedEntries.slice(0, PICKER_LIMIT);
3783
3910
  var crumbs = useMemo(function () {
3784
3911
  if (!listing || !listing.path) return [];
3785
3912
  var path = listing.path;
@@ -3827,18 +3954,29 @@ function attributeViolation(name, value, tagName) {
3827
3954
  }, drive.name);
3828
3955
  }))
3829
3956
  : null,
3957
+ h('div', { className: 'rw-filter-row' },
3958
+ h('input', {
3959
+ className: 'rw-input', style: { height: 26, fontSize: 11.5 },
3960
+ value: local.filter,
3961
+ placeholder: t('filterPlaceholder'),
3962
+ 'aria-label': t('filterPlaceholder'),
3963
+ spellCheck: false,
3964
+ onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { filter: event.currentTarget.value }); }); },
3965
+ })),
3830
3966
  h('div', { className: 'rw-browser-list', role: 'list' },
3831
3967
  local.error
3832
3968
  ? h('div', { className: 'rw-row-msg' }, IconAlert(12), local.error)
3833
3969
  : entries.length === 0
3834
3970
  ? h('div', { className: 'rw-row-msg' }, t('emptyFolder'))
3835
- : shownEntries.map(function (entry) {
3971
+ : matchedEntries.length === 0
3972
+ ? h('div', { className: 'rw-row-msg' }, t('filterEmpty'))
3973
+ : shownEntries.map(function (entry) {
3836
3974
  return h('button', {
3837
3975
  key: entry.path, type: 'button', className: 'rw-browser-row', role: 'listitem',
3838
3976
  onClick: function () { navigate(entry.path); },
3839
3977
  }, h('span', { className: 'rw-dir-icon' }, IconFolder(13, false)), h('span', null, entry.name));
3840
3978
  }),
3841
- entries.length > PICKER_LIMIT
3979
+ matchedEntries.length > PICKER_LIMIT
3842
3980
  ? h('div', { className: 'rw-row-msg' }, t('pickerTruncated', { count: PICKER_LIMIT }))
3843
3981
  : null),
3844
3982
  h('div', { className: 'rw-browser-actions', style: { padding: '8px', gap: 8 } },
@@ -3884,7 +4022,7 @@ function attributeViolation(name, value, tagName) {
3884
4022
  var t = props.t;
3885
4023
  var locale = props.locale;
3886
4024
  var hostId = props.hostId;
3887
- var state = useState({ loading: true, listing: null, error: '', input: props.initialPath || '' });
4025
+ var state = useState({ loading: true, listing: null, error: '', input: props.initialPath || '', filter: '' });
3888
4026
  var remote = state[0];
3889
4027
  var setRemote = state[1];
3890
4028
 
@@ -3896,7 +4034,7 @@ function attributeViolation(name, value, tagName) {
3896
4034
  setRemote(function (previous) { return Object.assign({}, previous, { loading: true, error: '' }); });
3897
4035
  apiCall('hosts.browse', { hostId: hostId, path: path || undefined }).then(function (result) {
3898
4036
  setRemote(function (previous) {
3899
- return Object.assign({}, previous, { loading: false, listing: result, error: '', input: result.path });
4037
+ return Object.assign({}, previous, { loading: false, listing: result, error: '', input: result.path, filter: '' });
3900
4038
  });
3901
4039
  }).catch(function (error) {
3902
4040
  setRemote(function (previous) { return Object.assign({}, previous, { loading: false, error: messageOf(error, t, locale) }); });
@@ -3913,8 +4051,12 @@ function attributeViolation(name, value, tagName) {
3913
4051
  var listing = remote.listing;
3914
4052
  var dirs = listing ? (listing.entries || []).filter(function (entry) { return entry.type === 'dir'; }) : [];
3915
4053
  var PICKER_LIMIT = 500;
3916
- var shownDirs = dirs.slice(0, PICKER_LIMIT);
3917
- var pickerTruncated = dirs.length > PICKER_LIMIT || Boolean(listing && listing.hasMore);
4054
+ var filterText = String(remote.filter || '').trim().toLowerCase();
4055
+ var matchedDirs = filterText === '' ? dirs : dirs.filter(function (entry) {
4056
+ return String(entry.name || '').toLowerCase().indexOf(filterText) !== -1;
4057
+ });
4058
+ var shownDirs = matchedDirs.slice(0, PICKER_LIMIT);
4059
+ var pickerTruncated = matchedDirs.length > PICKER_LIMIT || Boolean(listing && listing.hasMore);
3918
4060
  var crumbs = useMemo(function () {
3919
4061
  if (!listing || !listing.path) return [];
3920
4062
  var pieces = listing.path.split('/').filter(function (piece) { return piece !== ''; });
@@ -3941,12 +4083,23 @@ function attributeViolation(name, value, tagName) {
3941
4083
  h('button', { type: 'button', className: 'rw-crumb', title: crumb.path, onClick: function () { navigate(crumb.path); } }, crumb.label));
3942
4084
  })),
3943
4085
  remote.loading ? Spinner(13) : null),
4086
+ h('div', { className: 'rw-filter-row' },
4087
+ h('input', {
4088
+ className: 'rw-input', style: { height: 26, fontSize: 11.5 },
4089
+ value: remote.filter,
4090
+ placeholder: t('filterPlaceholder'),
4091
+ 'aria-label': t('filterPlaceholder'),
4092
+ spellCheck: false,
4093
+ onChange: function (event) { setRemote(function (previous) { return Object.assign({}, previous, { filter: event.currentTarget.value }); }); },
4094
+ })),
3944
4095
  h('div', { className: 'rw-browser-list', role: 'list' },
3945
4096
  remote.error
3946
4097
  ? h('div', { className: 'rw-row-msg' }, IconAlert(12), remote.error)
3947
4098
  : dirs.length === 0
3948
4099
  ? h('div', { className: 'rw-row-msg' }, t('noEntries'))
3949
- : shownDirs.map(function (entry) {
4100
+ : matchedDirs.length === 0
4101
+ ? h('div', { className: 'rw-row-msg' }, t('filterEmpty'))
4102
+ : shownDirs.map(function (entry) {
3950
4103
  return h('button', {
3951
4104
  key: entry.path, type: 'button', className: 'rw-browser-row', role: 'listitem',
3952
4105
  onClick: function () { navigate(entry.path); },
@@ -4393,6 +4546,12 @@ function attributeViolation(name, value, tagName) {
4393
4546
  event.preventDefault();
4394
4547
  saveFile(false);
4395
4548
  }
4549
+ if (mod && (event.key === 'f' || event.key === 'F') && !event.shiftKey) {
4550
+ // Ctrl+F inside the editor opens the in-file find bar; the browser
4551
+ // find dialog cannot see textarea content anyway.
4552
+ event.preventDefault();
4553
+ openFind();
4554
+ }
4396
4555
  }
4397
4556
  window.addEventListener('keydown', onKey, true);
4398
4557
  return function () { window.removeEventListener('keydown', onKey, true); };
@@ -4407,6 +4566,132 @@ function attributeViolation(name, value, tagName) {
4407
4566
  if (gutterRef.current) gutterRef.current.scrollTop = target.scrollTop;
4408
4567
  }
4409
4568
 
4569
+ // ── in-file find / replace ──────────────────────────────────────────
4570
+ var findInputRef = useRef(null);
4571
+ var findState = useState({ open: false, query: '', replace: '', caseSensitive: false, index: 0 });
4572
+ var find = findState[0];
4573
+ var setFind = findState[1];
4574
+ var FIND_MATCH_LIMIT = 5000;
4575
+ var findResult = useMemo(function () {
4576
+ if (!find.open || find.query === '') return { list: [], truncated: false };
4577
+ var text = content;
4578
+ var needle = find.caseSensitive ? find.query : find.query.toLowerCase();
4579
+ var haystack = find.caseSensitive ? text : text.toLowerCase();
4580
+ var list = [];
4581
+ var from = 0;
4582
+ while (list.length < FIND_MATCH_LIMIT) {
4583
+ var at = haystack.indexOf(needle, from);
4584
+ if (at === -1) break;
4585
+ list.push(at);
4586
+ from = at + Math.max(needle.length, 1);
4587
+ }
4588
+ // The list is capped so a huge file cannot freeze the editor, but the
4589
+ // counter must not pretend the cap is the real number of matches.
4590
+ var truncated = list.length === FIND_MATCH_LIMIT && haystack.indexOf(needle, from) !== -1;
4591
+ return { list: list, truncated: truncated };
4592
+ }, [content, find.open, find.query, find.caseSensitive]);
4593
+ var findMatches = findResult.list;
4594
+ var findIndex = findMatches.length === 0 ? -1 : Math.min(Math.max(find.index, 0), findMatches.length - 1);
4595
+
4596
+ function focusMatch(index) {
4597
+ var target = textareaRef.current;
4598
+ var at = findMatches.length === 0 ? -1 : findMatches[Math.min(Math.max(index, 0), findMatches.length - 1)];
4599
+ if (!target || at < 0) return;
4600
+ target.focus();
4601
+ target.selectionStart = at;
4602
+ target.selectionEnd = at + find.query.length;
4603
+ // Re-focusing makes the textarea scroll the selection into view.
4604
+ target.blur();
4605
+ target.focus();
4606
+ }
4607
+
4608
+ function stepMatch(delta) {
4609
+ if (findMatches.length === 0) return;
4610
+ var next = (findIndex + delta + findMatches.length) % findMatches.length;
4611
+ setFind(function (previous) { return Object.assign({}, previous, { index: next }); });
4612
+ focusMatch(next);
4613
+ }
4614
+
4615
+ function openFind() {
4616
+ setFind(function (previous) { return Object.assign({}, previous, { open: true }); });
4617
+ requestAnimationFrame(function () {
4618
+ if (findInputRef.current) {
4619
+ findInputRef.current.focus();
4620
+ findInputRef.current.select();
4621
+ }
4622
+ });
4623
+ }
4624
+
4625
+ function closeFind() {
4626
+ setFind({ open: false, query: '', replace: '', caseSensitive: false, index: 0 });
4627
+ }
4628
+
4629
+ function replaceCurrent() {
4630
+ if (findMatches.length === 0 || !editable) return;
4631
+ var at = findMatches[findIndex];
4632
+ var next = content.slice(0, at) + find.replace + content.slice(at + find.query.length);
4633
+ setContent(next);
4634
+ setDirty(true);
4635
+ setSave({ saving: false, conflict: false, error: '', ok: false });
4636
+ setFind(function (previous) { return Object.assign({}, previous, { index: Math.min(previous.index, Math.max(findMatches.length - 1, 0)) }); });
4637
+ }
4638
+
4639
+ function replaceAll() {
4640
+ if (findMatches.length === 0 || !editable || find.query === '') return;
4641
+ var escaped = find.query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
4642
+ var pattern = new RegExp(escaped, find.caseSensitive ? 'g' : 'gi');
4643
+ var next = content.replace(pattern, function () { return find.replace; });
4644
+ setContent(next);
4645
+ setDirty(true);
4646
+ setSave({ saving: false, conflict: false, error: '', ok: false });
4647
+ setFind(function (previous) { return Object.assign({}, previous, { index: 0 }); });
4648
+ }
4649
+
4650
+ function renderFindBar() {
4651
+ if (!find.open) return null;
4652
+ var counterTotal = findResult.truncated ? String(findMatches.length) + '+' : findMatches.length;
4653
+ var counter = findMatches.length === 0 ? t('findNoMatch') : t('findCounter', { index: findIndex + 1, total: counterTotal });
4654
+ return h('div', { className: 'rw-find-bar', role: 'search' },
4655
+ h('input', {
4656
+ ref: findInputRef,
4657
+ className: 'rw-input',
4658
+ value: find.query,
4659
+ placeholder: t('findPlaceholder'),
4660
+ 'aria-label': t('findPlaceholder'),
4661
+ spellCheck: false,
4662
+ onChange: function (event) {
4663
+ var value = event.currentTarget.value;
4664
+ setFind(function (previous) { return Object.assign({}, previous, { query: value, index: 0 }); });
4665
+ },
4666
+ onKeyDown: function (event) {
4667
+ if (event.key === 'Enter') { event.preventDefault(); stepMatch(event.shiftKey ? -1 : 1); }
4668
+ if (event.key === 'Escape') { event.preventDefault(); closeFind(); }
4669
+ },
4670
+ }),
4671
+ h('span', { className: 'rw-find-counter', 'aria-live': 'polite' }, counter),
4672
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findNext'), disabled: findMatches.length === 0, onClick: function () { stepMatch(1); } }, IconChevron(12)),
4673
+ 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))),
4674
+ h('input', {
4675
+ className: 'rw-input',
4676
+ value: find.replace,
4677
+ placeholder: t('replacePlaceholder'),
4678
+ 'aria-label': t('replacePlaceholder'),
4679
+ spellCheck: false,
4680
+ disabled: !editable,
4681
+ onChange: function (event) {
4682
+ var value = event.currentTarget.value;
4683
+ setFind(function (previous) { return Object.assign({}, previous, { replace: value }); });
4684
+ },
4685
+ onKeyDown: function (event) {
4686
+ if (event.key === 'Enter') { event.preventDefault(); replaceCurrent(); }
4687
+ if (event.key === 'Escape') { event.preventDefault(); closeFind(); }
4688
+ },
4689
+ }),
4690
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: !editable || findMatches.length === 0, onClick: replaceCurrent }, t('replaceOne')),
4691
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: !editable || findMatches.length === 0, onClick: replaceAll }, t('replaceAll')),
4692
+ h('button', { type: 'button', className: 'rw-icon-btn', title: t('close'), onClick: closeFind }, IconClose(12)));
4693
+ }
4694
+
4410
4695
  var file = load.file;
4411
4696
  var lineCount = useMemo(function () {
4412
4697
  if (content.length > 200000) return null;
@@ -4569,6 +4854,7 @@ function attributeViolation(name, value, tagName) {
4569
4854
  return h('div', { className: 'rw-editor', style: containerStyle },
4570
4855
  header,
4571
4856
  banner ? h('div', { style: { padding: '8px 10px 0' } }, banner) : null,
4857
+ renderFindBar(),
4572
4858
  body,
4573
4859
  h('div', { className: 'rw-editor-status' },
4574
4860
  h('span', { className: 'rw-status-chip' }, 'UTF-8'),
@@ -4582,8 +4868,7 @@ function attributeViolation(name, value, tagName) {
4582
4868
  : file.tooLarge || file.truncated || file.binary
4583
4869
  ? h('span', { className: 'rw-status-chip rw-status-error' }, t('readOnly'))
4584
4870
  : h('span', { className: 'rw-status-chip rw-status-ok' }, theme.label ? (locale === 'zh' ? theme.label.zh : theme.label.en) : theme.id),
4585
- h('span', { className: 'rw-fill', style: { flex: '1 1 auto' } }),
4586
- h('span', { className: 'rw-status-chip' }, h('span', { className: 'rw-kbd' }, 'Ctrl'), h('span', { className: 'rw-kbd' }, 'S'))));
4871
+ h('span', { className: 'rw-fill', style: { flex: '1 1 auto' } })));
4587
4872
  }
4588
4873
 
4589
4874
  // ── linked workspace directory workbench ──────────────────────────────
@@ -4638,10 +4923,20 @@ function attributeViolation(name, value, tagName) {
4638
4923
  var cache = cacheState[0];
4639
4924
  var setCache = cacheState[1];
4640
4925
  var pending = useRef(new Set());
4926
+ var lastRefreshAt = useRef(new Map());
4641
4927
 
4642
4928
  useEffect(function () {
4643
4929
  if (!props.refreshTick) return;
4644
- Array.from(expanded).forEach(function (path) { load(path, true); });
4930
+ // A background refresh costs one full listing per expanded directory, so
4931
+ // it stays quiet while the tab is hidden and never runs more often than
4932
+ // REFRESH_MIN_INTERVAL_MS per directory.
4933
+ if (typeof document !== 'undefined' && document.hidden) return;
4934
+ var now = Date.now();
4935
+ Array.from(expanded).forEach(function (path) {
4936
+ var at = lastRefreshAt.current.get(path) || 0;
4937
+ if (now - at < REFRESH_MIN_INTERVAL_MS) return;
4938
+ load(path, true);
4939
+ });
4645
4940
  }, [props.refreshTick]);
4646
4941
 
4647
4942
  function toggle(path) {
@@ -4669,10 +4964,12 @@ function attributeViolation(name, value, tagName) {
4669
4964
  function load(path, silent) {
4670
4965
  if (pending.current.has(path)) return;
4671
4966
  pending.current.add(path);
4967
+ lastRefreshAt.current.set(path, Date.now());
4672
4968
  var previousRecord = cache.entries.get(path) || {};
4673
4969
  // A silent refresh keeps as many rows as the user already loaded:
4674
4970
  // re-reading only the first page would drop everything past it.
4675
- var keep = silent ? Math.min(Math.max(Number(previousRecord.raw) || 0, TREE_PAGE_SIZE), TREE_PAGE_MAX) : TREE_PAGE_SIZE;
4971
+ var keep = silent ? Math.max(Number(previousRecord.raw) || 0, TREE_PAGE_SIZE) : TREE_PAGE_SIZE;
4972
+ keep = Math.min(keep, TREE_PAGE_MAX);
4676
4973
  setCache(function (previous) {
4677
4974
  var entries = new Map(previous.entries);
4678
4975
  var existing = entries.get(path) || {};
@@ -4683,14 +4980,28 @@ function attributeViolation(name, value, tagName) {
4683
4980
  pending.current.delete(path);
4684
4981
  setCache(function (previous) {
4685
4982
  var next = new Map(previous.entries);
4983
+ var existing = next.get(path) || {};
4984
+ var fresh = applyEntries(result.entries || []);
4985
+ var freshPaths = new Set(fresh.map(function (entry) { return entry.path; }));
4986
+ // Keep rows beyond the refreshed page so a silent refresh cannot
4987
+ // shrink a list the user scrolled many pages into.
4988
+ var retained = silent
4989
+ ? (existing.entries || []).filter(function (entry) { return !freshPaths.has(entry.path); })
4990
+ : [];
4991
+ var pageRaw = (result.entries || []).length;
4992
+ var raw = silent ? Math.max(Number(existing.raw) || 0, pageRaw) : pageRaw;
4993
+ var total = Number(result.total) || pageRaw + retained.length;
4686
4994
  next.set(path, {
4687
4995
  loading: false,
4688
4996
  error: null,
4689
4997
  loaded: true,
4690
- entries: applyEntries(result.entries || []),
4691
- raw: (result.entries || []).length,
4692
- total: Number(result.total) || (result.entries || []).length,
4693
- hasMore: Boolean(result.hasMore),
4998
+ entries: fresh.concat(retained),
4999
+ raw: raw,
5000
+ total: total,
5001
+ // A silent refresh asks for `keep` rows; when everything is already
5002
+ // loaded the server still reports hasMore for the page it did not
5003
+ // return, so trust the row counts instead of the flag alone.
5004
+ hasMore: Boolean(result.hasMore) && raw < total,
4694
5005
  });
4695
5006
  return { entries: next };
4696
5007
  });
@@ -4747,7 +5058,23 @@ function attributeViolation(name, value, tagName) {
4747
5058
  });
4748
5059
  }
4749
5060
 
4750
- return h('div', { className: 'rw-tree', role: 'tree', 'aria-label': t('allFiles') }, h(TreeDirectory, {
5061
+ var rootRecord = cache.entries.get(rootPath);
5062
+ var rootSiblings = rootRecord && rootRecord.entries ? rootRecord.entries.map(function (item) {
5063
+ return { path: item.path, name: item.name, isDir: item.type === 'dir' };
5064
+ }) : [];
5065
+ return h('div', {
5066
+ className: 'rw-tree',
5067
+ role: 'tree',
5068
+ 'aria-label': t('allFiles'),
5069
+ onDragOver: function (event) {
5070
+ if (!props.onDropOnPath) return;
5071
+ event.preventDefault();
5072
+ try { event.dataTransfer.dropEffect = 'copy'; } catch (error) { /* ignore */ }
5073
+ },
5074
+ onDrop: function (event) {
5075
+ if (props.onDropOnPath) props.onDropOnPath(rootPath, event);
5076
+ },
5077
+ }, h(TreeDirectory, {
4751
5078
  path: rootPath,
4752
5079
  name: props.rootName || t('allFiles'),
4753
5080
  depth: 0,
@@ -4763,7 +5090,15 @@ function attributeViolation(name, value, tagName) {
4763
5090
  onPin: props.onPin,
4764
5091
  onSelectPath: props.onSelectPath,
4765
5092
  onContextMenu: props.onContextMenu,
5093
+ onDragStart: props.onDragStartRow
5094
+ ? function (event, info) { props.onDragStartRow(props.kind, event, info); }
5095
+ : null,
5096
+ onDropOnPath: props.onDropOnPath
5097
+ ? function (path, event) { props.onDropOnPath(props.kind, path, event); }
5098
+ : null,
4766
5099
  selectedPath: props.selectedPath || '',
5100
+ selectedSet: props.selectedPaths && props.selectedPaths.length > 0 ? new Set(props.selectedPaths) : null,
5101
+ siblings: rootSiblings,
4767
5102
  }));
4768
5103
  }
4769
5104
 
@@ -4914,6 +5249,7 @@ function attributeViolation(name, value, tagName) {
4914
5249
  state.error ? h(Banner, { kind: 'error' }, state.error) : null,
4915
5250
  state.loading ? h('div', { className: 'rw-hint-row' }, Spinner(12), t('loading')) : null,
4916
5251
  !state.loading && total === 0 ? h('div', { className: 'rw-hint-row' }, t('searchEmpty')) : null,
5252
+ !state.loading && state.truncated ? h('div', { className: 'rw-hint-row' }, t('searchTruncated')) : null,
4917
5253
  groups.map(function (group) {
4918
5254
  if (group.entries.length === 0) return null;
4919
5255
  return h('div', { key: group.side, className: 'rw-change-group' },
@@ -5150,6 +5486,69 @@ function attributeViolation(name, value, tagName) {
5150
5486
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, props.t('close'))));
5151
5487
  }
5152
5488
 
5489
+ function joinRelativePath(parent, relative, side) {
5490
+ var sep = side === 'remote' ? '/' : (String(parent || '').indexOf('\\') >= 0 ? '\\' : '/');
5491
+ var base = String(parent || '').replace(/[\\/]+$/, '');
5492
+ var tail = String(relative || '').split('/').filter(function (part) { return part !== ''; }).join(sep);
5493
+ if (base === '') return sep + tail;
5494
+ if (base === '/') return '/' + tail;
5495
+ return base + sep + tail;
5496
+ }
5497
+
5498
+ function CompareDialog(props) {
5499
+ var t = props.t;
5500
+ var data = props.data;
5501
+ function rowAction(side, row, kind) {
5502
+ var label = kind === 'push' ? t('comparePush') : t('comparePull');
5503
+ var title = label + ' · ' + row.path;
5504
+ return h('button', {
5505
+ key: kind,
5506
+ type: 'button',
5507
+ className: 'rw-btn rw-btn-sm rw-compare-act',
5508
+ title: title,
5509
+ onClick: function () {
5510
+ if (kind === 'push') props.onPush(row.path);
5511
+ else props.onPull(row.path);
5512
+ },
5513
+ }, label);
5514
+ }
5515
+ function section(key, title, rows, count, side, actions) {
5516
+ return h('div', { key: key, className: 'rw-compare-section' },
5517
+ h('div', { className: 'rw-compare-title' }, title + ' (' + count + ')'),
5518
+ count === 0
5519
+ ? h('div', { className: 'rw-compare-empty' }, t('compareNone'))
5520
+ : rows.map(function (row) {
5521
+ var size = row.size != null ? row.size : row.localSize;
5522
+ return h('div', { key: row.path, className: 'rw-compare-item' },
5523
+ h('button', {
5524
+ type: 'button',
5525
+ className: 'rw-compare-row',
5526
+ title: row.path,
5527
+ onClick: function () { props.onOpen(side, row.path); },
5528
+ },
5529
+ h('span', { className: 'rw-compare-path' }, row.path),
5530
+ h('span', { className: 'rw-compare-size' }, typeof size === 'number' ? formatBytes(size) : '')),
5531
+ actions && actions.length > 0 ? h('span', { className: 'rw-compare-actions' }, actions.map(function (kind) { return rowAction(side, row, kind); })) : null);
5532
+ }));
5533
+ }
5534
+ var notes = [];
5535
+ if (data.localMissing) notes.push(t('compareLocalMissing'));
5536
+ if (data.remoteTruncated) notes.push(t('compareTruncatedRemote'));
5537
+ if (data.localTruncated) notes.push(t('compareTruncatedLocal'));
5538
+ var note = notes.length > 0
5539
+ ? h('div', { className: 'rw-dialog-note' }, notes.join(' '))
5540
+ : null;
5541
+ return h(DialogShell, { title: props.title, onClose: props.onClose },
5542
+ h('div', { className: 'rw-dialog-message rw-compare-root', title: data.localPath }, data.localPath),
5543
+ note,
5544
+ section('onlyLocal', t('compareOnlyLocal'), data.onlyLocal || [], data.counts.onlyLocal, 'local', ['push']),
5545
+ section('onlyRemote', t('compareOnlyRemote'), data.onlyRemote || [], data.counts.onlyRemote, 'remote', ['pull']),
5546
+ section('changed', t('compareChanged'), data.changed || [], data.counts.changed, 'remote', ['push', 'pull']),
5547
+ data.truncated ? h('div', { className: 'rw-dialog-note' }, t('compareTruncated')) : null,
5548
+ h('div', { className: 'rw-dialog-actions' },
5549
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, t('close'))));
5550
+ }
5551
+
5153
5552
  function MoveDialog(props) {
5154
5553
  var picker = props.side === 'local'
5155
5554
  ? h(LocalPathPicker, {
@@ -5174,7 +5573,14 @@ function attributeViolation(name, value, tagName) {
5174
5573
  : props.queue.map(function (entry) {
5175
5574
  return h('div', { key: entry.id, className: 'rw-queue-row' },
5176
5575
  h('span', { className: 'rw-queue-label', title: entry.path }, entry.label),
5177
- h('span', { className: 'rw-queue-state' }, entry.message || entry.state));
5576
+ h('span', { className: 'rw-queue-state' }, entry.message || entry.state),
5577
+ entry.state === 'error' && props.onRetry
5578
+ ? h('button', {
5579
+ type: 'button',
5580
+ className: 'rw-btn rw-btn-sm',
5581
+ onClick: function () { props.onRetry(entry); },
5582
+ }, props.t('queueRetry'))
5583
+ : null);
5178
5584
  }),
5179
5585
  h('div', { className: 'rw-dialog-actions' },
5180
5586
  props.queue.some(function (entry) { return entry.state === 'done' || entry.state === 'error'; })
@@ -5197,9 +5603,11 @@ function attributeViolation(name, value, tagName) {
5197
5603
  loading: true, error: '', data: null, text: '', dirty: false, saving: false,
5198
5604
  preview: false, html: '', previewLoading: false, page: 0, sheet: 0, slide: 0,
5199
5605
  updates: {}, pptxUpdates: {}, rotations: {}, deleted: {}, pdfLoading: false, notice: '',
5606
+ findOpen: false, findQuery: '', findIndex: 0,
5200
5607
  });
5201
5608
  var state = stateRef[0];
5202
5609
  var setState = stateRef[1];
5610
+ var docTextareaRef = useRef(null);
5203
5611
 
5204
5612
  function patch(next) {
5205
5613
  setState(function (previous) { return Object.assign({}, previous, next); });
@@ -5274,13 +5682,57 @@ function attributeViolation(name, value, tagName) {
5274
5682
  if (props.visible === false) return undefined;
5275
5683
  function onKey(event) {
5276
5684
  var mod = event.ctrlKey || event.metaKey;
5277
- if (!mod || String(event.key || '').toLowerCase() !== 's') return;
5278
- event.preventDefault();
5279
- saveRef.current();
5685
+ if (!mod) return;
5686
+ var key = String(event.key || '').toLowerCase();
5687
+ if (key === 's') {
5688
+ event.preventDefault();
5689
+ saveRef.current();
5690
+ return;
5691
+ }
5692
+ // Read-only find inside the document editor (no replace).
5693
+ if (key === 'f' && kind === 'markdown' && !state.preview) {
5694
+ event.preventDefault();
5695
+ patch({ findOpen: true });
5696
+ }
5280
5697
  }
5281
5698
  window.addEventListener('keydown', onKey, true);
5282
5699
  return function () { window.removeEventListener('keydown', onKey, true); };
5283
- }, [props.visible]);
5700
+ }, [props.visible, kind, state.preview]);
5701
+
5702
+ function docMatches() {
5703
+ var query = state.findQuery;
5704
+ if (!query) return [];
5705
+ var haystack = state.text;
5706
+ var needle = query.toLowerCase();
5707
+ var lower = haystack.toLowerCase();
5708
+ var found = [];
5709
+ var from = 0;
5710
+ while (found.length < 2000) {
5711
+ var at = lower.indexOf(needle, from);
5712
+ if (at < 0) break;
5713
+ found.push(at);
5714
+ from = at + Math.max(needle.length, 1);
5715
+ }
5716
+ return found;
5717
+ }
5718
+
5719
+ function stepDocMatch(delta) {
5720
+ var matches = docMatches();
5721
+ if (matches.length === 0) return;
5722
+ var next = ((state.findIndex + delta) % matches.length + matches.length) % matches.length;
5723
+ patch({ findIndex: next });
5724
+ var area = docTextareaRef.current;
5725
+ if (!area) return;
5726
+ area.focus();
5727
+ area.setSelectionRange(matches[next], matches[next] + state.findQuery.length);
5728
+ var ratio = matches[next] / Math.max(area.value.length, 1);
5729
+ area.scrollTop = Math.max(0, ratio * area.scrollHeight - area.clientHeight / 2);
5730
+ }
5731
+
5732
+ function closeDocFind() {
5733
+ patch({ findOpen: false });
5734
+ if (docTextareaRef.current) docTextareaRef.current.focus();
5735
+ }
5284
5736
 
5285
5737
  useEffect(function () {
5286
5738
  if (!settings.autoSave || !state.dirty || state.saving) return undefined;
@@ -5391,7 +5843,32 @@ function attributeViolation(name, value, tagName) {
5391
5843
  state.previewLoading ? h('div', { className: 'rw-editor-message' }, Spinner(14), t('loading')) : null,
5392
5844
  state.html ? h('div', { className: 'rw-doc-preview', dangerouslySetInnerHTML: { __html: state.html } }) : null)
5393
5845
  : h('div', { className: 'rw-doc-body' },
5846
+ state.findOpen ? h('div', { className: 'rw-find-bar rw-doc-find' },
5847
+ h('input', {
5848
+ className: 'rw-input',
5849
+ value: state.findQuery,
5850
+ placeholder: t('findPlaceholder'),
5851
+ 'aria-label': t('findPlaceholder'),
5852
+ spellCheck: false,
5853
+ autoFocus: true,
5854
+ onChange: function (event) { patch({ findQuery: event.currentTarget.value, findIndex: 0 }); },
5855
+ onKeyDown: function (event) {
5856
+ if (event.key === 'Enter') { event.preventDefault(); stepDocMatch(event.shiftKey ? -1 : 1); }
5857
+ if (event.key === 'Escape') { event.preventDefault(); closeDocFind(); }
5858
+ },
5859
+ }),
5860
+ h('span', { className: 'rw-find-counter', 'aria-live': 'polite' },
5861
+ (function () {
5862
+ var total = docMatches().length;
5863
+ if (state.findQuery === '') return '';
5864
+ return total === 0 ? t('findNoMatch') : t('findCounter', { index: state.findIndex + 1, total: total });
5865
+ })()),
5866
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findPrev'), onClick: function () { stepDocMatch(-1); } }, h('span', { style: { display: 'inline-flex', transform: 'rotate(180deg)' } }, IconChevron(12))),
5867
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findNext'), onClick: function () { stepDocMatch(1); } }, IconChevron(12)),
5868
+ h('button', { type: 'button', className: 'rw-icon-btn', title: t('close'), onClick: closeDocFind }, IconClose(12)))
5869
+ : null,
5394
5870
  h('textarea', {
5871
+ ref: docTextareaRef,
5395
5872
  className: 'rw-doc-textarea', value: state.text, spellCheck: false,
5396
5873
  onChange: function (event) { patch({ text: event.currentTarget.value, dirty: true, html: '' }); },
5397
5874
  }));
@@ -5511,6 +5988,9 @@ function attributeViolation(name, value, tagName) {
5511
5988
  var searchQueryState = useState('');
5512
5989
  var searchQuery = searchQueryState[0];
5513
5990
  var setSearchQuery = searchQueryState[1];
5991
+ var searchModeState = useState('name');
5992
+ var searchMode = searchModeState[0];
5993
+ var setSearchMode = searchModeState[1];
5514
5994
  var searchState = useState({ loading: false, remote: [], local: [], error: null });
5515
5995
  var search = searchState[0];
5516
5996
  var setSearch = searchState[1];
@@ -5541,6 +6021,11 @@ function attributeViolation(name, value, tagName) {
5541
6021
  var selectedEntryState = useState(null);
5542
6022
  var selectedEntry = selectedEntryState[0];
5543
6023
  var setSelectedEntry = selectedEntryState[1];
6024
+ var multiState = useState([]);
6025
+ var multi = multiState[0];
6026
+ var setMulti = multiState[1];
6027
+ // Anchor for Shift+click range selection (a ref: it must not re-render).
6028
+ var selectionAnchorRef = useRef(null);
5544
6029
  var showHiddenState = useState(true);
5545
6030
  var showHidden = showHiddenState[0];
5546
6031
  var setShowHidden = showHiddenState[1];
@@ -5641,6 +6126,20 @@ function attributeViolation(name, value, tagName) {
5641
6126
  var fileDirtyState = useState({});
5642
6127
  var fileDirty = fileDirtyState[0];
5643
6128
  var setFileDirty = fileDirtyState[1];
6129
+
6130
+ // Closing the browser tab or reloading the page would silently drop
6131
+ // unsaved edits: ask for confirmation while any open file is dirty.
6132
+ useEffect(function () {
6133
+ var dirty = openFiles.some(function (file) { return Boolean(fileDirty[file.key]); });
6134
+ if (!dirty) return undefined;
6135
+ function onBeforeUnload(event) {
6136
+ event.preventDefault();
6137
+ event.returnValue = '';
6138
+ return '';
6139
+ }
6140
+ window.addEventListener('beforeunload', onBeforeUnload);
6141
+ return function () { window.removeEventListener('beforeunload', onBeforeUnload); };
6142
+ }, [openFiles, fileDirty]);
5644
6143
  var saveHandlersRef = useRef({});
5645
6144
  var directoryTabId = props.tab && props.tab.id;
5646
6145
 
@@ -5715,6 +6214,19 @@ function attributeViolation(name, value, tagName) {
5715
6214
  data.reload();
5716
6215
  }
5717
6216
 
6217
+ function openCompare(path) {
6218
+ if (!selected) return;
6219
+ setDialog({ kind: 'compare', loading: true, error: '', data: null });
6220
+ apiCall('fs.compare', Object.assign({ path: path }, scopeParams(scopeRef))).then(function (result) {
6221
+ setDialog({
6222
+ kind: 'compare', loading: false, error: '',
6223
+ data: result, root: result.path, localPath: result.localPath,
6224
+ });
6225
+ }).catch(function (error) {
6226
+ setDialog({ kind: 'compare', loading: false, error: t('compareFailed') + ':' + messageOf(error, t, locale), data: null });
6227
+ });
6228
+ }
6229
+
5718
6230
  function updateOpenMode(next) {
5719
6231
  apiCall('settings.update', { fileOpenMode: next }).then(function (result) {
5720
6232
  runtimeSettings.apply({ fileOpenMode: result && result.fileOpenMode ? result.fileOpenMode : next });
@@ -5724,9 +6236,10 @@ function attributeViolation(name, value, tagName) {
5724
6236
  });
5725
6237
  }
5726
6238
 
5727
- function openTerminal(side) {
6239
+ function openTerminal(side, atPath) {
5728
6240
  if (!selected) return;
5729
6241
  var request = { side: side };
6242
+ if (typeof atPath === 'string' && atPath !== '') request.path = atPath;
5730
6243
  if (selected.kind === 'linked') request.linkedId = selected.id;
5731
6244
  else request.workspaceId = selected.id;
5732
6245
  apiCall('terminal.open', request).then(function () {
@@ -5876,6 +6389,70 @@ function attributeViolation(name, value, tagName) {
5876
6389
  showNotice('error', t('actionFailed') + ':' + messageOf(error, t, locale));
5877
6390
  }
5878
6391
 
6392
+ // Ctrl/Cmd-click toggles an entry in the multi-selection; a plain click
6393
+ // collapses the selection to that entry (Shift extends it).
6394
+ function updateSelection(side, info) {
6395
+ if (!info || typeof info.path !== 'string') return;
6396
+ var event = info.event;
6397
+ var entry = { side: side, path: info.path, name: info.name, isDir: Boolean(info.isDir) };
6398
+ setSelectedEntry(entry);
6399
+ var toggle = Boolean(event && (event.ctrlKey || event.metaKey));
6400
+ var extend = Boolean(event && event.shiftKey);
6401
+ if (extend) {
6402
+ var anchor = selectionAnchorRef.current;
6403
+ var siblings = Array.isArray(info.siblings) ? info.siblings : [];
6404
+ if (anchor && anchor.side === side && siblings.length > 0) {
6405
+ var anchorIndex = -1;
6406
+ var targetIndex = -1;
6407
+ siblings.forEach(function (item, index) {
6408
+ if (item.path === anchor.path) anchorIndex = index;
6409
+ if (item.path === info.path) targetIndex = index;
6410
+ });
6411
+ if (anchorIndex >= 0 && targetIndex >= 0) {
6412
+ var start = Math.min(anchorIndex, targetIndex);
6413
+ var end = Math.max(anchorIndex, targetIndex);
6414
+ setMulti(siblings.slice(start, end + 1).map(function (item) {
6415
+ return { side: side, path: item.path, name: item.name, isDir: Boolean(item.isDir) };
6416
+ }));
6417
+ return;
6418
+ }
6419
+ }
6420
+ }
6421
+ setMulti(function (previous) {
6422
+ var exists = previous.some(function (item) { return item.side === side && item.path === entry.path; });
6423
+ if (extend) return exists ? previous : previous.concat([entry]);
6424
+ if (toggle) {
6425
+ return exists
6426
+ ? previous.filter(function (item) { return !(item.side === side && item.path === entry.path); })
6427
+ : previous.concat([entry]);
6428
+ }
6429
+ return [entry];
6430
+ });
6431
+ if (!extend) selectionAnchorRef.current = toggle ? selectionAnchorRef.current : { side: side, path: info.path };
6432
+ }
6433
+
6434
+ function selectedOn(side) {
6435
+ return multi.filter(function (item) { return item.side === side; });
6436
+ }
6437
+
6438
+ function selectionFor(side) {
6439
+ var list = selectedOn(side);
6440
+ if (list.length > 0) return list;
6441
+ if (selectedEntry && selectedEntry.side === side) return [selectedEntry];
6442
+ return [];
6443
+ }
6444
+
6445
+ function transferSelection() {
6446
+ var list = multi.length > 0 ? multi : (selectedEntry ? [selectedEntry] : []);
6447
+ list.forEach(function (item) { enqueueTransfer(item.side, item.path, item.name); });
6448
+ }
6449
+
6450
+ function deleteSelection() {
6451
+ var list = multi.length > 0 ? multi : (selectedEntry ? [selectedEntry] : []);
6452
+ if (list.length === 0) return;
6453
+ setDialog({ kind: 'deleteMany', entries: list });
6454
+ }
6455
+
5879
6456
  function copyPathToClipboard(text) {
5880
6457
  try {
5881
6458
  if (navigator.clipboard && navigator.clipboard.writeText) {
@@ -5985,6 +6562,136 @@ function attributeViolation(name, value, tagName) {
5985
6562
  }).catch(noticeError);
5986
6563
  }
5987
6564
 
6565
+ function confirmDeleteMany(entries) {
6566
+ var list = Array.isArray(entries) ? entries : [];
6567
+ var failures = [];
6568
+ var chain = Promise.resolve();
6569
+ list.forEach(function (entry) {
6570
+ chain = chain.then(function () {
6571
+ var method = entry.side === 'remote' ? 'fs.delete' : 'local.delete';
6572
+ var params = entry.side === 'remote'
6573
+ ? Object.assign({ path: entry.path }, scopeParams(scopeRef))
6574
+ : { path: entry.path, root: selected.localPath };
6575
+ return apiCall(method, params).then(function () {
6576
+ setMulti(function (previous) {
6577
+ return previous.filter(function (item) { return !(item.side === entry.side && item.path === entry.path); });
6578
+ });
6579
+ }).catch(function (error) { failures.push(error); });
6580
+ });
6581
+ });
6582
+ chain.then(function () {
6583
+ if (failures.length > 0) showNotice('error', messageOf(failures[0], t, locale));
6584
+ else showNotice('success', t('deleteDone'));
6585
+ refreshTree();
6586
+ });
6587
+ }
6588
+
6589
+ var DRAG_MIME = 'application/x-dsh-linked-entry';
6590
+
6591
+ function beginDragRow(side, event, info) {
6592
+ if (!event.dataTransfer || !info) return;
6593
+ try {
6594
+ event.dataTransfer.setData(DRAG_MIME, JSON.stringify({
6595
+ side: side, path: info.path, name: info.name, isDir: Boolean(info.isDir),
6596
+ }));
6597
+ event.dataTransfer.effectAllowed = 'copy';
6598
+ } catch (error) { /* drag payload unsupported */ }
6599
+ }
6600
+
6601
+ // A drop that would replace an existing file asks first: file transfer is
6602
+ // destructive and previously overwrote the target silently.
6603
+ function openConflict(error, method, params) {
6604
+ if (!error || String(error.code || '') !== 'FS_EXISTS') return false;
6605
+ setDialog({ kind: 'conflict', message: messageOf(error, t, locale), method: method, params: params });
6606
+ return true;
6607
+ }
6608
+
6609
+ function resolveConflict(choice) {
6610
+ var current = dialog;
6611
+ setDialog(null);
6612
+ if (!current || current.kind !== 'conflict' || choice === 'cancel') return;
6613
+ var params = Object.assign({}, current.params, { conflict: choice === 'overwrite' ? 'overwrite' : 'unique' });
6614
+ apiCall(current.method, params).then(function (result) {
6615
+ var skipped = Number(result && result.skipped) || 0;
6616
+ var count = current.method === 'fs.upload' ? Number(result && result.files) || 0 : 1;
6617
+ if (count > 0) showNotice('success', t('dropImported', { count: count }));
6618
+ if (skipped > 0) showNotice('warn', t('dropSkipped', { count: skipped }));
6619
+ refreshTree();
6620
+ }).catch(noticeError);
6621
+ }
6622
+
6623
+ // Drop target handling for both trees: OS files are imported into the
6624
+ // target directory, while an entry dragged from the other tree is pushed
6625
+ // across the boundary (remote→local or local→remote).
6626
+ function dropOnPath(side, targetDir, event) {
6627
+ event.preventDefault();
6628
+ event.stopPropagation();
6629
+ var transfer = event.dataTransfer;
6630
+ if (!transfer || typeof targetDir !== 'string' || targetDir === '') return;
6631
+ var files = Array.prototype.slice.call(transfer.files || []);
6632
+ var osPaths = files.map(function (file) {
6633
+ return file && typeof file.path === 'string' ? file.path : '';
6634
+ }).filter(Boolean);
6635
+ if (files.length > 0 && osPaths.length === 0) {
6636
+ showNotice('error', t('dropNeedsDesktop'));
6637
+ return;
6638
+ }
6639
+ if (osPaths.length > 0) {
6640
+ var payload = side === 'remote'
6641
+ ? Object.assign({ path: targetDir, paths: osPaths }, scopeParams(scopeRef))
6642
+ : { dir: targetDir, paths: osPaths };
6643
+ var method = side === 'remote' ? 'fs.upload' : 'local.import';
6644
+ apiCall(method, payload).then(function (result) {
6645
+ var count = side === 'remote' ? Number(result.files) || 0 : Number(result.copied) || 0;
6646
+ showNotice('success', t('dropImported', { count: count }));
6647
+ if (Number(result.skipped) > 0) showNotice('warn', t('dropSkipped', { count: result.skipped }));
6648
+ refreshTree();
6649
+ }).catch(function (error) {
6650
+ if (openConflict(error, method, payload)) return;
6651
+ noticeError(error);
6652
+ });
6653
+ return;
6654
+ }
6655
+ var raw = '';
6656
+ try { raw = transfer.getData(DRAG_MIME); } catch (error) { raw = ''; }
6657
+ if (!raw) return;
6658
+ var entry;
6659
+ try { entry = JSON.parse(raw); } catch (error) { return; }
6660
+ if (!entry || typeof entry.path !== 'string') return;
6661
+ if (entry.side === side) {
6662
+ showNotice('error', t('dropSameSide'));
6663
+ return;
6664
+ }
6665
+ if (entry.side === 'remote') {
6666
+ if (entry.isDir) {
6667
+ showNotice('error', t('dropDirUnsupported'));
6668
+ return;
6669
+ }
6670
+ var pullParams = Object.assign({ path: entry.path, targetDir: targetDir }, scopeParams(scopeRef));
6671
+ apiCall('fs.pullToLocal', pullParams).then(function () {
6672
+ showNotice('success', t('dropImported', { count: 1 }));
6673
+ refreshTree();
6674
+ }).catch(function (error) {
6675
+ if (openConflict(error, 'fs.pullToLocal', pullParams)) return;
6676
+ noticeError(error);
6677
+ });
6678
+ return;
6679
+ }
6680
+ if (entry.isDir) {
6681
+ showNotice('error', t('dropLocalDirUnsupported'));
6682
+ return;
6683
+ }
6684
+ var pushParams = Object.assign({ path: targetDir, paths: [entry.path] }, scopeParams(scopeRef));
6685
+ apiCall('fs.upload', pushParams).then(function (result) {
6686
+ if (Number(result.skipped) > 0) showNotice('warn', t('dropSkipped', { count: result.skipped }));
6687
+ else showNotice('success', t('dropImported', { count: Number(result.files) || 1 }));
6688
+ refreshTree();
6689
+ }).catch(function (error) {
6690
+ if (openConflict(error, 'fs.upload', pushParams)) return;
6691
+ noticeError(error);
6692
+ });
6693
+ }
6694
+
5988
6695
  function submitRenamed(side, oldPath, name) {
5989
6696
  var target = joinChildPath(parentPathOf(oldPath, side), name, side);
5990
6697
  if (target === oldPath) return;
@@ -6090,6 +6797,14 @@ function attributeViolation(name, value, tagName) {
6090
6797
  }
6091
6798
  var canPaste = clipboard !== null && clipboard.side === menu.side && menu.isDir;
6092
6799
  var items = [];
6800
+ var batch = multi.filter(function (item) { return item.side === menu.side; });
6801
+ if (batch.length > 1) {
6802
+ items.push({ label: t('ctxTransferSelected', { count: batch.length }), onSelect: function () {
6803
+ batch.forEach(function (item) { enqueueTransfer(item.side, item.path, item.name); });
6804
+ } });
6805
+ items.push({ label: t('ctxDeleteSelected', { count: batch.length }), onSelect: deleteSelection });
6806
+ items.push({ separator: true });
6807
+ }
6093
6808
  if (isRemote) {
6094
6809
  items.push({ label: t('ctxTransfer'), onSelect: function () { enqueueTransfer('remote', menu.path, menu.name); } });
6095
6810
  items.push({ label: t('ctxDownload'), onSelect: function () { downloadEntry(menu); } });
@@ -6133,8 +6848,12 @@ function attributeViolation(name, value, tagName) {
6133
6848
  } });
6134
6849
  if (menu.isDir) {
6135
6850
  items.push({ separator: true });
6851
+ items.push({ label: t('ctxTerminalHere'), onSelect: function () { openTerminal(menu.side, menu.path); } });
6136
6852
  items = items.concat(newEntryMenuItems(menu, t, setDialog));
6137
6853
  }
6854
+ if (menu.isDir && menu.side === 'remote' && selected && selected.kind === 'linked') {
6855
+ items.push({ label: t('ctxCompare'), onSelect: function () { openCompare(menu.path); } });
6856
+ }
6138
6857
  items.push({ separator: true });
6139
6858
  items.push({ label: t('ctxProperties'), onSelect: function () { showProperties(menu.side, menu.path); } });
6140
6859
  return items;
@@ -6142,6 +6861,45 @@ function attributeViolation(name, value, tagName) {
6142
6861
 
6143
6862
  function renderDialog() {
6144
6863
  if (!dialog) return null;
6864
+ if (dialog.kind === 'compare') {
6865
+ return dialog.loading
6866
+ ? h(DialogShell, { title: t('compareTitle'), onClose: function () { setDialog(null); } },
6867
+ h('div', { className: 'rw-dialog-message' }, Spinner(13), t('loading')))
6868
+ : dialog.error
6869
+ ? h(DialogShell, { title: t('compareTitle'), onClose: function () { setDialog(null); } },
6870
+ h('div', { className: 'rw-dialog-message rw-dialog-error' }, dialog.error),
6871
+ h('div', { className: 'rw-dialog-actions' },
6872
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { setDialog(null); } }, t('close'))))
6873
+ : h(CompareDialog, {
6874
+ t: t,
6875
+ title: t('compareTitle'),
6876
+ data: dialog.data,
6877
+ onClose: function () { setDialog(null); },
6878
+ onOpen: function (side, relative) {
6879
+ setDialog(null);
6880
+ var target = side === 'local' ? dialog.localPath : dialog.root;
6881
+ openInternalFile(side === 'local' ? 'local' : 'remote', joinRelativePath(target, relative, side === 'local' ? 'local' : 'remote'));
6882
+ },
6883
+ onPush: function (relative) {
6884
+ var source = joinRelativePath(dialog.localPath, relative, 'local');
6885
+ var remoteDir = parentPathOf(joinRelativePath(dialog.root, relative, 'remote'), 'remote');
6886
+ apiCall('fs.upload', Object.assign({ path: remoteDir, paths: [source], conflict: 'overwrite' }, scopeParams(scopeRef))).then(function () {
6887
+ showNotice('success', t('comparePushed', { name: relative.split('/').pop() }));
6888
+ setDialog(null);
6889
+ refreshTree();
6890
+ }).catch(noticeError);
6891
+ },
6892
+ onPull: function (relative) {
6893
+ var remoteFile = joinRelativePath(dialog.root, relative, 'remote');
6894
+ var localDir = parentPathOf(joinRelativePath(dialog.localPath, relative, 'local'), 'local');
6895
+ apiCall('fs.pullToLocal', Object.assign({ path: remoteFile, targetDir: localDir, conflict: 'overwrite' }, scopeParams(scopeRef))).then(function () {
6896
+ showNotice('success', t('comparePulled', { name: relative.split('/').pop() }));
6897
+ setDialog(null);
6898
+ refreshTree();
6899
+ }).catch(noticeError);
6900
+ },
6901
+ });
6902
+ }
6145
6903
  if (dialog.kind === 'props') {
6146
6904
  return h(PropertiesDialog, { t: t, title: dialog.title, rows: dialog.rows, onClose: function () { setDialog(null); } });
6147
6905
  }
@@ -6155,6 +6913,7 @@ function attributeViolation(name, value, tagName) {
6155
6913
  queueRef.current = queueRef.current.filter(function (entry) { return entry.state !== 'done' && entry.state !== 'error'; });
6156
6914
  setQueueList(queueRef.current.slice());
6157
6915
  },
6916
+ onRetry: function (entry) { enqueueTransfer(entry.side, entry.path, entry.label); },
6158
6917
  });
6159
6918
  }
6160
6919
  if (dialog.kind === 'delete') {
@@ -6167,6 +6926,24 @@ function attributeViolation(name, value, tagName) {
6167
6926
  onConfirm: function () { setDialog(null); confirmDelete(dialog); },
6168
6927
  });
6169
6928
  }
6929
+ if (dialog.kind === 'deleteMany') {
6930
+ return h(ConfirmDialog, {
6931
+ t: t,
6932
+ title: t('deleteManyTitle'),
6933
+ message: t('deleteManyMessage', { count: dialog.entries.length }),
6934
+ confirmLabel: t('deleteConfirm'),
6935
+ onClose: function () { setDialog(null); },
6936
+ onConfirm: function () { setDialog(null); confirmDeleteMany(dialog.entries); },
6937
+ });
6938
+ }
6939
+ if (dialog.kind === 'conflict') {
6940
+ return h(DialogShell, { title: t('conflictDropTitle'), onClose: function () { resolveConflict('cancel'); } },
6941
+ h('div', { className: 'rw-dialog-message' }, dialog.message),
6942
+ h('div', { className: 'rw-dialog-actions' },
6943
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { resolveConflict('cancel'); } }, t('conflictCancel')),
6944
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { resolveConflict('unique'); } }, t('conflictKeepBoth')),
6945
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-danger', onClick: function () { resolveConflict('overwrite'); } }, t('conflictOverwrite'))));
6946
+ }
6170
6947
  if (dialog.kind === 'move') {
6171
6948
  return h(MoveDialog, {
6172
6949
  t: t, locale: locale,
@@ -6238,13 +7015,14 @@ function attributeViolation(name, value, tagName) {
6238
7015
  }
6239
7016
  var alive = true;
6240
7017
  var timer = setTimeout(function () {
6241
- setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, error: null }; });
7018
+ setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, error: null }; });
6242
7019
  var scopeNow = sourceScopeOf(selected);
6243
- var jobs = [apiCall('fs.search', Object.assign({ side: 'remote', query: query, maxResults: 200 }, scopeParams(scopeNow))).catch(function (error) {
7020
+ var method = searchMode === 'content' ? 'fs.grep' : 'fs.search';
7021
+ var jobs = [apiCall(method, Object.assign({ side: 'remote', query: query, maxResults: 200 }, scopeParams(scopeNow))).catch(function (error) {
6244
7022
  return { ok: false, entries: [], error: messageOf(error, t, locale) };
6245
7023
  })];
6246
7024
  if (selected.kind === 'linked') {
6247
- jobs.push(apiCall('fs.search', Object.assign({ side: 'local', query: query, maxResults: 200 }, scopeParams(scopeNow))).catch(function (error) {
7025
+ jobs.push(apiCall(method, Object.assign({ side: 'local', query: query, maxResults: 200 }, scopeParams(scopeNow))).catch(function (error) {
6248
7026
  return { ok: false, entries: [], error: messageOf(error, t, locale) };
6249
7027
  }));
6250
7028
  } else {
@@ -6256,12 +7034,13 @@ function attributeViolation(name, value, tagName) {
6256
7034
  loading: false,
6257
7035
  remote: results[0] && results[0].entries ? results[0].entries : [],
6258
7036
  local: results[1] && results[1].entries ? results[1].entries : [],
7037
+ truncated: Boolean((results[0] && results[0].truncated) || (results[1] && results[1].truncated)),
6259
7038
  error: (results[0] && results[0].error) || (results[1] && results[1].error) || null,
6260
7039
  });
6261
7040
  });
6262
7041
  }, 320);
6263
7042
  return function () { alive = false; clearTimeout(timer); };
6264
- }, [searchOpen, searchQuery, selectedKey, version]);
7043
+ }, [searchOpen, searchQuery, selectedKey, version, searchMode]);
6265
7044
 
6266
7045
  if (!selected) {
6267
7046
  return h('div', { className: 'rw-workbench rw-workspace', ref: workbenchRef },
@@ -6305,7 +7084,10 @@ function attributeViolation(name, value, tagName) {
6305
7084
  locale: locale,
6306
7085
  showHidden: showHidden,
6307
7086
  selectedPath: selectedEntry && selectedEntry.side === 'remote' ? selectedEntry.path : '',
6308
- onSelectPath: function (info) { setSelectedEntry(Object.assign({ side: 'remote' }, info)); },
7087
+ selectedPaths: selectionFor('remote').map(function (item) { return item.path; }),
7088
+ onSelectPath: function (info) { updateSelection('remote', info); },
7089
+ onDragStartRow: beginDragRow,
7090
+ onDropOnPath: dropOnPath,
6309
7091
  onSelect: function (filePath) { openByMode('remote', filePath, { pinned: false, preview: true }); },
6310
7092
  onPin: function (filePath) { pinByMode('remote', filePath); },
6311
7093
  onContextMenu: function (info) { setSelectedEntry(Object.assign({ side: 'remote' }, info)); openContextMenu('remote', info); },
@@ -6326,7 +7108,10 @@ function attributeViolation(name, value, tagName) {
6326
7108
  locale: locale,
6327
7109
  showHidden: showHidden,
6328
7110
  selectedPath: selectedEntry && selectedEntry.side === 'local' ? selectedEntry.path : '',
6329
- onSelectPath: function (info) { setSelectedEntry(Object.assign({ side: 'local' }, info)); },
7111
+ selectedPaths: selectionFor('local').map(function (item) { return item.path; }),
7112
+ onSelectPath: function (info) { updateSelection('local', info); },
7113
+ onDragStartRow: beginDragRow,
7114
+ onDropOnPath: dropOnPath,
6330
7115
  onSelect: function (filePath) { openByMode('local', filePath, { pinned: false, preview: true }); },
6331
7116
  onPin: function (filePath) { pinByMode('local', filePath); },
6332
7117
  refreshTick: localTick,
@@ -6410,13 +7195,13 @@ function attributeViolation(name, value, tagName) {
6410
7195
  localEnabled: !remoteOnly && selected.kind === 'linked',
6411
7196
  showHidden: showHidden,
6412
7197
  onToggleHidden: function () { setShowHidden(!showHidden); },
6413
- transferEnabled: !remoteOnly && Boolean(selectedEntry),
7198
+ transferEnabled: !remoteOnly && (multi.length > 0 || Boolean(selectedEntry)),
6414
7199
  transferSelected: function () {
6415
- if (!selectedEntry) {
7200
+ if (multi.length === 0 && !selectedEntry) {
6416
7201
  showNotice('info', t('selectFirst'));
6417
7202
  return;
6418
7203
  }
6419
- enqueueTransfer(selectedEntry.side, selectedEntry.path, selectedEntry.name);
7204
+ transferSelection();
6420
7205
  },
6421
7206
  onMode: function (next) { setMode(next); },
6422
7207
  onToggleSearch: function () { setSearchOpen(!searchOpen); },
@@ -6426,9 +7211,22 @@ function attributeViolation(name, value, tagName) {
6426
7211
  searchOpen
6427
7212
  ? h('div', { className: 'rw-searchbar' },
6428
7213
  IconSearch(13),
7214
+ h('span', { className: 'rw-search-mode' },
7215
+ h('button', {
7216
+ type: 'button',
7217
+ className: 'rw-chip-btn' + (searchMode === 'name' ? ' is-on' : ''),
7218
+ title: t('searchModeName'),
7219
+ onClick: function () { setSearchMode('name'); },
7220
+ }, t('searchModeName')),
7221
+ h('button', {
7222
+ type: 'button',
7223
+ className: 'rw-chip-btn' + (searchMode === 'content' ? ' is-on' : ''),
7224
+ title: t('searchModeContent'),
7225
+ onClick: function () { setSearchMode('content'); },
7226
+ }, t('searchModeContent'))),
6429
7227
  h('input', {
6430
7228
  value: searchQuery,
6431
- placeholder: t('searchPlaceholder'),
7229
+ placeholder: searchMode === 'content' ? t('searchPlaceholderContent') : t('searchPlaceholder'),
6432
7230
  spellCheck: false,
6433
7231
  autoFocus: true,
6434
7232
  onChange: function (event) { setSearchQuery(event.currentTarget.value); },
@@ -6533,6 +7331,18 @@ function attributeViolation(name, value, tagName) {
6533
7331
  var selectedPath = props.selectedPath;
6534
7332
  var isOpen = expanded.has(path);
6535
7333
  var entry = state.entries.get(path) || { loading: false, error: null, entries: [] };
7334
+ var childSiblings = entry.entries.map(function (item) {
7335
+ return { path: item.path, name: item.name, isDir: item.type === 'dir' };
7336
+ });
7337
+ // Hovering over a collapsed folder during a drag expands it after a short
7338
+ // delay, so dropping into a nested folder does not require two passes.
7339
+ var dragOpenTimer = useRef(null);
7340
+
7341
+ useEffect(function () {
7342
+ return function () {
7343
+ if (dragOpenTimer.current) clearTimeout(dragOpenTimer.current);
7344
+ };
7345
+ }, []);
6536
7346
 
6537
7347
  useEffect(function () {
6538
7348
  if (isOpen && !entry.loading && !entry.loaded && !entry.error) props.load(path);
@@ -6569,10 +7379,14 @@ function attributeViolation(name, value, tagName) {
6569
7379
  onPin: onPin,
6570
7380
  onSelectPath: onSelectPath,
6571
7381
  onContextMenu: onContextMenu,
7382
+ onDragStart: props.onDragStart,
7383
+ onDropOnPath: props.onDropOnPath,
6572
7384
  selectedPath: selectedPath,
7385
+ selectedSet: props.selectedSet,
7386
+ siblings: childSiblings,
6573
7387
  }));
6574
7388
  } else if (child.type === 'file' || child.type === 'symlink') {
6575
- var active = selectedPath === child.path;
7389
+ var active = selectedPath === child.path || Boolean(props.selectedSet && props.selectedSet.has(child.path));
6576
7390
  children.push(h('button', {
6577
7391
  key: child.path,
6578
7392
  type: 'button',
@@ -6582,8 +7396,12 @@ function attributeViolation(name, value, tagName) {
6582
7396
  className: 'rw-row' + (active ? ' is-active' : ''),
6583
7397
  style: { paddingLeft: 6 + (depth + 1) * 12 },
6584
7398
  title: child.path,
7399
+ draggable: Boolean(props.onDragStart),
7400
+ onDragStart: function (event) {
7401
+ if (props.onDragStart) props.onDragStart(event, { path: child.path, name: child.name, isDir: false });
7402
+ },
6585
7403
  onClick: function (event) {
6586
- if (onSelectPath) onSelectPath({ path: child.path, name: child.name, isDir: false });
7404
+ if (onSelectPath) onSelectPath({ path: child.path, name: child.name, isDir: false, siblings: childSiblings, event: event });
6587
7405
  if (event.detail !== 2) onSelect(child.path);
6588
7406
  },
6589
7407
  onDoubleClick: function () { if (onPin) onPin(child.path); },
@@ -6622,17 +7440,49 @@ function attributeViolation(name, value, tagName) {
6622
7440
  role: 'treeitem',
6623
7441
  'aria-level': depth + 1,
6624
7442
  'aria-expanded': isOpen,
6625
- className: 'rw-row' + (selectedPath === path ? ' is-active' : ''),
7443
+ className: 'rw-row' + (selectedPath === path || (props.selectedSet && props.selectedSet.has(path)) ? ' is-active' : ''),
6626
7444
  style: { paddingLeft: 6 + depth * 12 },
6627
7445
  title: path,
7446
+ draggable: Boolean(props.onDragStart),
7447
+ onDragStart: function (event) {
7448
+ if (props.onDragStart) props.onDragStart(event, { path: path, name: name, isDir: true });
7449
+ },
6628
7450
  onClick: function (event) {
6629
- if (onSelectPath) onSelectPath({ path: path, name: name, isDir: true });
7451
+ if (onSelectPath) onSelectPath({ path: path, name: name, isDir: true, siblings: props.siblings || [], event: event });
6630
7452
  if (event.detail !== 2) toggle(path);
6631
7453
  },
6632
7454
  onKeyDown: function (event) {
6633
7455
  if (event.key === 'ArrowRight' && !isOpen) { event.preventDefault(); toggle(path); }
6634
7456
  else if (event.key === 'ArrowLeft' && isOpen) { event.preventDefault(); toggle(path); }
6635
7457
  },
7458
+ onDragOver: function (event) {
7459
+ if (!props.onDropOnPath) return;
7460
+ event.preventDefault();
7461
+ event.stopPropagation();
7462
+ try { event.dataTransfer.dropEffect = 'copy'; } catch (error) { /* ignore */ }
7463
+ event.currentTarget.classList.add('is-drop-target');
7464
+ if (!isOpen && !dragOpenTimer.current) {
7465
+ dragOpenTimer.current = setTimeout(function () {
7466
+ dragOpenTimer.current = null;
7467
+ toggle(path);
7468
+ }, 700);
7469
+ }
7470
+ },
7471
+ onDragLeave: function (event) {
7472
+ event.currentTarget.classList.remove('is-drop-target');
7473
+ if (dragOpenTimer.current) {
7474
+ clearTimeout(dragOpenTimer.current);
7475
+ dragOpenTimer.current = null;
7476
+ }
7477
+ },
7478
+ onDrop: function (event) {
7479
+ event.currentTarget.classList.remove('is-drop-target');
7480
+ if (dragOpenTimer.current) {
7481
+ clearTimeout(dragOpenTimer.current);
7482
+ dragOpenTimer.current = null;
7483
+ }
7484
+ if (props.onDropOnPath) props.onDropOnPath(path, event);
7485
+ },
6636
7486
  onContextMenu: function (event) {
6637
7487
  if (!onContextMenu) return;
6638
7488
  event.preventDefault();
@@ -7303,6 +8153,20 @@ function attributeViolation(name, value, tagName) {
7303
8153
  dismissSettingsOverlay();
7304
8154
  }
7305
8155
 
8156
+ function registerWorkspace() {
8157
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: 'register', message: null }); });
8158
+ apiCall('linked.update', { id: link.id, ensureWorkspace: true }).then(function () {
8159
+ setLocal(function (previous) {
8160
+ return Object.assign({}, previous, { busy: '', message: { kind: 'success', text: t('workspaceRegistered') } });
8161
+ });
8162
+ refresh();
8163
+ }).catch(function (error) {
8164
+ setLocal(function (previous) {
8165
+ return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: messageOf(error, t, locale) } });
8166
+ });
8167
+ });
8168
+ }
8169
+
7306
8170
  function pollSync(job) {
7307
8171
  if (!job) {
7308
8172
  setLocal(function (previous) { return Object.assign({}, previous, { busy: '', message: null }); });
@@ -7401,7 +8265,12 @@ function attributeViolation(name, value, tagName) {
7401
8265
  h('div', { className: 'rw-actions' },
7402
8266
  link.workspaceId
7403
8267
  ? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openWorkspace }, IconExternal(12), t('openWorkspace'))
7404
- : h('span', { className: 'rw-chip' }, t('workspaceMissing')),
8268
+ : h('button', {
8269
+ type: 'button', className: 'rw-btn rw-btn-sm',
8270
+ onClick: registerWorkspace,
8271
+ disabled: local.busy === 'register',
8272
+ title: t('workspaceMissing'),
8273
+ }, local.busy === 'register' ? Spinner(12) : IconPlus(12), t('workspaceRegister')),
7405
8274
  h('button', {
7406
8275
  type: 'button', className: 'rw-btn rw-btn-sm',
7407
8276
  onClick: sync, disabled: local.busy !== '' || !link.mirror, title: link.mirror ? t('sync') : t('mirrorHint'),
@@ -7570,6 +8439,7 @@ function attributeViolation(name, value, tagName) {
7570
8439
  h('kbd', { className: 'rw-kbd' }, item[0]),
7571
8440
  h('span', null, item[1]));
7572
8441
  })),
8442
+ h('div', { className: 'rw-group-hint', style: { marginTop: 8 } }, t('shortcutWebNote')),
7573
8443
  local.message
7574
8444
  ? h(Banner, {
7575
8445
  kind: local.message.kind === 'success' ? 'success' : 'error',