mbeditor 0.14.2 → 0.14.3

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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/app/assets/javascripts/mbeditor/application.js +5 -1
  4. data/app/assets/javascripts/mbeditor/collaboration_identity.js +4 -2
  5. data/app/assets/javascripts/mbeditor/collaboration_service.js +74 -2
  6. data/app/assets/javascripts/mbeditor/components/AiRoundTripModal.js +452 -0
  7. data/app/assets/javascripts/mbeditor/components/ChangelogView.js +1 -1
  8. data/app/assets/javascripts/mbeditor/components/CombinedFileView.js +3 -2
  9. data/app/assets/javascripts/mbeditor/components/EditorPanel.js +28 -27
  10. data/app/assets/javascripts/mbeditor/components/FileHistoryPanel.js +2 -7
  11. data/app/assets/javascripts/mbeditor/components/FileTree.js +144 -4
  12. data/app/assets/javascripts/mbeditor/components/GitPanel.js +1 -1
  13. data/app/assets/javascripts/mbeditor/components/ImportConflictModal.js +7 -68
  14. data/app/assets/javascripts/mbeditor/components/ImportDialog.js +2 -16
  15. data/app/assets/javascripts/mbeditor/components/MbeditorApp.js +340 -472
  16. data/app/assets/javascripts/mbeditor/components/ModalDialog.js +203 -0
  17. data/app/assets/javascripts/mbeditor/components/PastePlaceModal.js +1 -9
  18. data/app/assets/javascripts/mbeditor/components/Popover.js +88 -0
  19. data/app/assets/javascripts/mbeditor/components/PopupMenu.js +166 -0
  20. data/app/assets/javascripts/mbeditor/components/ProblemsPanel.js +8 -4
  21. data/app/assets/javascripts/mbeditor/components/QuickOpenDialog.js +5 -7
  22. data/app/assets/javascripts/mbeditor/components/SettingsModal.js +3 -14
  23. data/app/assets/javascripts/mbeditor/components/ShortcutHelp.js +4 -25
  24. data/app/assets/javascripts/mbeditor/components/TabBar.js +15 -32
  25. data/app/assets/javascripts/mbeditor/components/TestResultsPanel.js +2 -7
  26. data/app/assets/javascripts/mbeditor/editor_plugins.js +3 -23
  27. data/app/assets/javascripts/mbeditor/file_service.js +1 -1
  28. data/app/assets/javascripts/mbeditor/git_service.js +0 -7
  29. data/app/assets/javascripts/mbeditor/patch_select.js +156 -0
  30. data/app/assets/javascripts/mbeditor/tab_manager.js +19 -0
  31. data/app/assets/stylesheets/mbeditor/application.css +7 -110
  32. data/app/assets/stylesheets/mbeditor/editor.css +195 -192
  33. data/app/assets/stylesheets/mbeditor/glass.css +1 -1
  34. data/app/channels/mbeditor/collaboration_channel.rb +24 -5
  35. data/app/controllers/mbeditor/editors_controller.rb +75 -38
  36. data/app/controllers/mbeditor/git_controller.rb +1 -12
  37. data/app/services/mbeditor/ai_bundle_service.rb +181 -0
  38. data/app/services/mbeditor/archive_service.rb +43 -6
  39. data/app/services/mbeditor/availability_probe.rb +2 -2
  40. data/app/services/mbeditor/code_search_service.rb +1 -3
  41. data/app/services/mbeditor/collaboration_doc_store.rb +37 -1
  42. data/app/services/mbeditor/exclusion_matcher.rb +0 -4
  43. data/app/services/mbeditor/file_import_service.rb +4 -1
  44. data/app/services/mbeditor/file_operation_service.rb +3 -3
  45. data/app/services/mbeditor/git_service.rb +11 -45
  46. data/app/services/mbeditor/js_definition_service.rb +1 -0
  47. data/app/services/mbeditor/model_graph_service.rb +1 -0
  48. data/app/services/mbeditor/patch_apply_service.rb +185 -0
  49. data/app/services/mbeditor/rails_related_files_service.rb +1 -1
  50. data/app/services/mbeditor/redmine_config_error.rb +6 -0
  51. data/app/services/mbeditor/redmine_disabled_error.rb +10 -0
  52. data/app/services/mbeditor/redmine_service.rb +0 -8
  53. data/app/services/mbeditor/ruby_definition_service.rb +1 -0
  54. data/app/services/mbeditor/schema_service.rb +1 -0
  55. data/app/services/mbeditor/test_runner_service.rb +1 -1
  56. data/lib/mbeditor/rack/silence_ping_request.rb +14 -14
  57. data/lib/mbeditor/route_map.rb +5 -2
  58. data/lib/mbeditor/ruby_lsp_client.rb +7 -26
  59. data/lib/mbeditor/version.rb +1 -1
  60. data/public/monaco-editor/VERSIONS +2 -1
  61. data/public/monaco-editor/monaco.js +226 -226
  62. metadata +11 -4
  63. data/app/assets/javascripts/mbeditor/components/CommitGraph.js +0 -65
  64. data/app/services/mbeditor/git_commit_graph_service.rb +0 -62
@@ -40,7 +40,7 @@
40
40
  function close(n) {
41
41
  while (open.length > n) { var o = open.pop(); out.push(indentOf(lines[o.start_line - 1]) + 'end'); }
42
42
  }
43
- info.methods.filter(function (m, i) { return picked[i]; })
43
+ info.methods.filter(function (_m, i) { return picked[i]; })
44
44
  .sort(function (a, b) { return a.start_line - b.start_line; })
45
45
  .forEach(function (m) {
46
46
  var chain = info.owners.filter(function (o) { return contains(o, m); });
@@ -78,7 +78,7 @@
78
78
  var line = '- ' + path;
79
79
  if (info[path] && info[path].methods && Object.keys(sel).some(function (k) { return sel[k]; })) {
80
80
  body = methodSlice(e.content, info[path], sel);
81
- line += ' (methods: ' + info[path].methods.filter(function (m, i) { return sel[i]; }).map(function (m) { return m.name; }).join(', ') + ')';
81
+ line += ' (methods: ' + info[path].methods.filter(function (_m, i) { return sel[i]; }).map(function (m) { return m.name; }).join(', ') + ')';
82
82
  }
83
83
  index.push(line);
84
84
  var fence = fenceFor(body);
@@ -224,5 +224,6 @@
224
224
  );
225
225
  };
226
226
 
227
+ window.MbeditorLanguageForPath = languageFor;
227
228
  window.CombinedFileView = CombinedFileView;
228
229
  })();
@@ -5,7 +5,6 @@ var _React = React;
5
5
  var useState = _React.useState;
6
6
  var useEffect = _React.useEffect;
7
7
  var useRef = _React.useRef;
8
- var useMemo = _React.useMemo;
9
8
 
10
9
  var IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'ico', 'webp', 'bmp', 'avif'];
11
10
 
@@ -27,7 +26,6 @@ var EditorPanel = function EditorPanel(_ref) {
27
26
  var onSave = _ref.onSave;
28
27
  var onRunTestAtCursor = _ref.onRunTestAtCursor;
29
28
  var onShowHistory = _ref.onShowHistory;
30
- var treeData = _ref.treeData || [];
31
29
  var testResult = _ref.testResult;
32
30
  var testPanelFile = _ref.testPanelFile;
33
31
  var testInlineVisible = _ref.testInlineVisible;
@@ -121,7 +119,6 @@ var EditorPanel = function EditorPanel(_ref) {
121
119
  var setMethodsDropdownPos = _useState19[1];
122
120
 
123
121
  var methodsBtnRef = useRef(null);
124
- var methodsDropdownRef = useRef(null);
125
122
  // Discards a JS outline that resolves after the dropdown was closed or reopened.
126
123
  var methodsRequestRef = useRef(0);
127
124
 
@@ -1463,6 +1460,21 @@ var EditorPanel = function EditorPanel(_ref) {
1463
1460
  return function () { clearTimeout(timer); };
1464
1461
  }, [tab.gotoLine, tab.gotoCol, tab.gotoEndCol, tab.content, tab.loading]);
1465
1462
 
1463
+ // Take keyboard focus when the opener asked for it (TabManager.requestFocus):
1464
+ // once the content has loaded and the Monaco instance exists. Until then
1465
+ // the request waits: editorReady flipping re-runs this. An image tab never
1466
+ // gets an editor, so its request is dropped.
1467
+ useEffect(function () {
1468
+ if (!tab.focusOnLoad || tab.loading) return;
1469
+ var editor = monacoRef.current;
1470
+ if (!editor) {
1471
+ if (tab.isImage) TabManager.clearFocusRequest(paneId, tab.id);
1472
+ return;
1473
+ }
1474
+ editor.focus();
1475
+ TabManager.clearFocusRequest(paneId, tab.id);
1476
+ }, [tab.focusOnLoad, tab.loading, editorReady]);
1477
+
1466
1478
  // Apply RuboCop markers
1467
1479
  useEffect(function () {
1468
1480
  if (monacoRef.current && window.monaco) {
@@ -1880,7 +1892,7 @@ var EditorPanel = function EditorPanel(_ref) {
1880
1892
 
1881
1893
  var zoneIds = [];
1882
1894
  editor.changeViewZones(function(accessor) {
1883
- blocks.forEach(function(block, idx) {
1895
+ blocks.forEach(function(block) {
1884
1896
  var header = document.createElement('div');
1885
1897
  header.className = block.isUncommitted
1886
1898
  ? 'ide-blame-block-header ide-blame-block-header-uncommitted'
@@ -2152,20 +2164,6 @@ var EditorPanel = function EditorPanel(_ref) {
2152
2164
  return function () { el.removeEventListener('scroll', onScroll); };
2153
2165
  }, [tab.isPreview, isMarkdown, sourcePath]);
2154
2166
 
2155
- // Click-outside handler to close the methods dropdown
2156
- useEffect(function() {
2157
- if (!methodsOpen) return;
2158
- function handleClickOutside(e) {
2159
- var btn = methodsBtnRef.current;
2160
- var dropdown = methodsDropdownRef.current;
2161
- if (btn && !btn.contains(e.target) && (!dropdown || !dropdown.contains(e.target))) {
2162
- setMethodsOpen(false);
2163
- }
2164
- }
2165
- document.addEventListener('mousedown', handleClickOutside);
2166
- return function() { document.removeEventListener('mousedown', handleClickOutside); };
2167
- }, [methodsOpen]);
2168
-
2169
2167
  // Large-file performance tuning. Above this many lines, scroll- and edit-time
2170
2168
  // work from these features (minimap canvas repaint on every scroll,
2171
2169
  // sticky-scroll scope recompute, folding-range and bracket-pair recomputation,
@@ -2624,15 +2622,18 @@ var EditorPanel = function EditorPanel(_ref) {
2624
2622
  )
2625
2623
  ),
2626
2624
  React.createElement('div', { ref: editorRef, className: 'monaco-container', style: { flex: 1, minHeight: 0 } }),
2627
- // Portalled to body: under the glass chrome the centre column has a
2628
- // backdrop-filter, which makes it the containing block for position:fixed
2629
- // and shoves the menu ~130px off its button.
2630
- methodsOpen && methodsDropdownPos && ReactDOM.createPortal(React.createElement(
2631
- 'div',
2625
+ // A popover in the top layer, so it positions against the viewport even
2626
+ // under the glass chrome, whose centre column has a backdrop-filter that
2627
+ // otherwise becomes the containing block for position:fixed (this used to
2628
+ // need a portal to body). Outside clicks and Esc close it (onDismiss); the
2629
+ // button is its source, so clicking the button toggles instead.
2630
+ methodsOpen && methodsDropdownPos && React.createElement(
2631
+ window.Popover,
2632
2632
  {
2633
- ref: methodsDropdownRef,
2634
2633
  className: 'ide-methods-dropdown',
2635
- style: { position: 'fixed', top: methodsDropdownPos.top + 'px', right: methodsDropdownPos.right + 'px', left: 'auto', zIndex: 9900 }
2634
+ source: methodsBtnRef.current,
2635
+ style: { position: 'fixed', top: methodsDropdownPos.top + 'px', right: methodsDropdownPos.right + 'px', left: 'auto' },
2636
+ onDismiss: function () { setMethodsOpen(false); }
2636
2637
  },
2637
2638
  methodsUnavailable
2638
2639
  ? React.createElement('div', { className: 'ide-methods-dropdown-message' }, 'Outline unavailable')
@@ -2725,12 +2726,12 @@ var EditorPanel = function EditorPanel(_ref) {
2725
2726
  }
2726
2727
  return rows;
2727
2728
  })()
2728
- ), document.body),
2729
+ ),
2729
2730
  React.createElement('div', { ref: vimStatusRef, className: 'vim-statusbar', style: { display: editorPrefs.vimMode ? 'flex' : 'none', height: '22px', alignItems: 'center', padding: '0 10px', fontFamily: "'JetBrains Mono', 'Fira Code', Consolas, monospace", fontSize: '12px', background: 'var(--ide-statusbar-bg, #1e1e2e)', color: 'var(--ide-statusbar-fg, #9cdcfe)', borderTop: '1px solid var(--ide-border, #3e3e3e)', flexShrink: 0, userSelect: 'none', letterSpacing: '0.02em' } })
2730
2731
  );
2731
2732
  };
2732
2733
 
2733
- // treeData and all function props (onSave, onFormat, etc.) are intentionally
2734
+ // All function props (onSave, onFormat, etc.) are intentionally
2734
2735
  // excluded — their references change every parent render but don't affect editor output.
2735
2736
  window.EditorPanel = React.memo(EditorPanel, function(prev, next) {
2736
2737
  return prev.tab === next.tab &&
@@ -32,12 +32,8 @@ var FileHistoryPanel = function FileHistoryPanel(_ref) {
32
32
  }, [path]);
33
33
 
34
34
  return React.createElement(
35
- React.Fragment,
36
- null,
37
- React.createElement('div', { className: 'ide-modal-backdrop', onClick: onClose }),
38
- React.createElement(
39
- 'div',
40
- { className: 'ide-modal-panel' },
35
+ window.ModalDialog,
36
+ { className: 'ide-modal-panel', label: 'File history: ' + path.split('/').pop(), onDismiss: onClose },
41
37
  React.createElement(
42
38
  'div',
43
39
  { className: 'ide-file-history-header' },
@@ -106,7 +102,6 @@ var FileHistoryPanel = function FileHistoryPanel(_ref) {
106
102
  })
107
103
  )
108
104
  )
109
- )
110
105
  );
111
106
  };
112
107
 
@@ -282,13 +282,22 @@ var FileTree = function FileTree(_ref) {
282
282
 
283
283
  function onGlobalKeyDown(e) {
284
284
  if (!typeaheadEnabled) return;
285
- if (!sidebarActiveRef.current) return;
285
+ var treeFocused = !!containerRef.current && e.target === containerRef.current;
286
+ if (!sidebarActiveRef.current && !treeFocused) return;
287
+ // Space selects in the tree (handleTreeKeyDown); it only extends a
288
+ // type-to-find search that is already under way.
289
+ if (e.key === ' ' && !typeaheadBufferRef.current) return;
286
290
  if (e.ctrlKey || e.metaKey || e.altKey) return;
287
291
  // Prevent typeahead from jumping files while typing a new name in inline create/rename.
288
292
  if (pendingCreateRef.current || pendingRenameRef.current) return;
289
293
  if (e.key.length !== 1) return;
290
294
  // Still skip when an inline rename/create input is the actual focused element.
291
295
  if (e.target && e.target.tagName === 'INPUT') return;
296
+ // The sidebar flag survives opening a modal by shortcut; keystrokes in
297
+ // a dialog (e.g. Paste & Place's textarea) are never typeahead.
298
+ if (e.target && e.target.closest && e.target.closest('dialog')) return;
299
+ // Nor in an open context menu: its keys belong to the menu.
300
+ if (e.target && e.target.closest && e.target.closest('[popover]')) return;
292
301
  if (!containerRef.current) return;
293
302
 
294
303
  e.preventDefault();
@@ -419,8 +428,8 @@ var FileTree = function FileTree(_ref) {
419
428
  if (a.type !== b.type) return a.type === 'folder' ? -1 : 1;
420
429
  return a.name.localeCompare(b.name);
421
430
  });
422
- sorted.forEach(function(node) {
423
- result.push({ kind: 'node', node: node, depth: depth });
431
+ sorted.forEach(function(node, i) {
432
+ result.push({ kind: 'node', node: node, depth: depth, pos: i + 1, size: sorted.length, parentPath: parentPath });
424
433
  if (node.type === 'folder' && expandedDirs && expandedDirs[node.path] && node.children) {
425
434
  var children = flattenVisible(node.children, depth + 1, node.path);
426
435
  for (var ci = 0; ci < children.length; ci++) result.push(children[ci]);
@@ -509,6 +518,116 @@ var FileTree = function FileTree(_ref) {
509
518
  };
510
519
  }, []);
511
520
 
521
+ // The row the keyboard is on: the selection anchor, else the open file.
522
+ var cursorIndex = function cursorIndex(flat) {
523
+ var want = anchorPath || activePath;
524
+ var idx = want ? flat.findIndex(function (it) { return it.kind === 'node' && it.node.path === want; }) : -1;
525
+ return idx;
526
+ };
527
+
528
+ var setExpanded = function setExpanded(path, open) {
529
+ if (!onExpandedDirsChange) return;
530
+ onExpandedDirsChange(Object.assign({}, expandedDirs || {}, _defineProperty({}, path, open)));
531
+ };
532
+
533
+ // Keyboard model (WAI-ARIA tree pattern). Focus stays on the container;
534
+ // the current row is announced through aria-activedescendant, because the
535
+ // tree is virtualized and an off-screen row has no element to focus.
536
+ // Up/Down, Home/End move the selection
537
+ // Right open a folder, or step into an open one
538
+ // Left close an open folder, or step out to the parent
539
+ // Enter open the file (as double-click) and focus its
540
+ // editor, or toggle a folder
541
+ // Space preview the file (as click), focus stays here
542
+ // Shift+F10 / Menu the explorer context menu for the row
543
+ var handleTreeKeyDown = function handleTreeKeyDown(e) {
544
+ // Keys typed in the inline create/rename input bubble here; they are its.
545
+ if (!containerRef.current || e.target !== containerRef.current) return;
546
+ if (e.ctrlKey || e.metaKey || e.altKey) return;
547
+ var flat = flatItemsRef.current;
548
+ var nodeIdx = function (i) { return i >= 0 && i < flat.length && flat[i].kind === 'node'; };
549
+ var idx = cursorIndex(flat);
550
+ var item = idx >= 0 ? flat[idx] : null;
551
+ var node = item && item.node;
552
+ var isFolder = !!node && node.type === 'folder';
553
+ var isOpen = isFolder && !!(expandedDirs && expandedDirs[node.path]);
554
+
555
+ var moveTo = function (i) {
556
+ if (!nodeIdx(i)) return;
557
+ selectNode(flat[i].node);
558
+ scrollToItem(i);
559
+ };
560
+ var step = function (from, dir) {
561
+ for (var i = from + dir; i >= 0 && i < flat.length; i += dir) {
562
+ if (flat[i].kind === 'node') return i;
563
+ }
564
+ return -1;
565
+ };
566
+
567
+ var key = e.key;
568
+ var handled = true;
569
+ if (key === 'ContextMenu' || (key === 'F10' && e.shiftKey)) {
570
+ if (!onContextMenu) return;
571
+ if (idx < 0) idx = step(-1, 1);
572
+ if (idx < 0) return;
573
+ e.preventDefault();
574
+ scrollToItem(idx);
575
+ var rect = containerRef.current.getBoundingClientRect();
576
+ var indent = 8 + flat[idx].depth * 12;
577
+ onContextMenu({ clientX: rect.left + indent + 16, clientY: rect.top + (idx + 1) * ROW_HEIGHT, keyboard: true }, flat[idx].node);
578
+ return;
579
+ } else if (e.shiftKey) {
580
+ return;
581
+ } else if (key === 'ArrowDown') {
582
+ moveTo(idx < 0 ? step(-1, 1) : step(idx, 1));
583
+ } else if (key === 'ArrowUp') {
584
+ moveTo(idx < 0 ? step(flat.length, -1) : step(idx, -1));
585
+ } else if (key === 'Home') {
586
+ moveTo(step(-1, 1));
587
+ } else if (key === 'End') {
588
+ moveTo(step(flat.length, -1));
589
+ } else if (key === 'ArrowRight') {
590
+ if (!isFolder) { /* nothing to open */ }
591
+ else if (!isOpen) setExpanded(node.path, true);
592
+ else if (idx + 1 < flat.length && flat[idx + 1].depth > item.depth) moveTo(idx + 1);
593
+ } else if (key === 'ArrowLeft') {
594
+ if (isOpen) setExpanded(node.path, false);
595
+ else if (item && item.parentPath) {
596
+ var parentIdx = flat.findIndex(function (it) { return it.kind === 'node' && it.node.path === item.parentPath; });
597
+ moveTo(parentIdx);
598
+ }
599
+ } else if (key === 'Enter') {
600
+ if (!node) return;
601
+ if (isFolder) setExpanded(node.path, !isOpen);
602
+ else {
603
+ if (onFileDoubleClick) onFileDoubleClick(node.path, node.name);
604
+ else onSelect(node.path, node.name);
605
+ // Enter means "edit this": type into it straight away.
606
+ TabManager.requestFocus(node.path);
607
+ }
608
+ } else if (key === ' ') {
609
+ if (!node) { moveTo(step(-1, 1)); }
610
+ else if (isFolder) setExpanded(node.path, !isOpen);
611
+ else {
612
+ onSelect(node.path, node.name);
613
+ // Opening a file hands focus to its editor; a preview keeps it here.
614
+ setTimeout(function () { if (containerRef.current) containerRef.current.focus(); }, 0);
615
+ }
616
+ } else {
617
+ handled = false;
618
+ }
619
+ if (handled) {
620
+ e.preventDefault();
621
+ // Draw the cursor ring only while the keyboard is driving; a click
622
+ // clears it (onMouseDown below).
623
+ containerRef.current.classList.add('kbd-nav');
624
+ }
625
+ };
626
+
627
+ var rowId = function rowId(path) {
628
+ return 'mbt-' + path.replace(/[^A-Za-z0-9_-]/g, function (c) { return '_' + c.charCodeAt(0).toString(16); });
629
+ };
630
+
512
631
  var renderRow = function renderRow(item, idx) {
513
632
  var indentPx = 8 + item.depth * 12;
514
633
 
@@ -525,6 +644,7 @@ var FileTree = function FileTree(_ref) {
525
644
  var isExpanded = !!(expandedDirs && expandedDirs[node.path]);
526
645
  var isRenamingThisNode = !!(pendingRename && pendingRename.path === node.path);
527
646
  var isOpenFile = activePath === node.path;
647
+ var isCursor = (anchorPath || activePath) === node.path;
528
648
  var isSelected = !!(selectedPaths && selectedPaths.has(node.path));
529
649
  var isDragOver = isFolder && dragOverFolder === node.path;
530
650
  var isDragOverExternal = isFolder && externalDragOver === node.path;
@@ -547,8 +667,15 @@ var FileTree = function FileTree(_ref) {
547
667
  : React.createElement(
548
668
  'div',
549
669
  {
550
- className: classNames,
670
+ className: classNames + (isCursor ? ' is-cursor' : ''),
551
671
  style: { paddingLeft: indentPx },
672
+ id: rowId(node.path),
673
+ role: 'treeitem',
674
+ 'aria-level': item.depth + 1,
675
+ 'aria-posinset': item.pos,
676
+ 'aria-setsize': item.size,
677
+ 'aria-selected': isSelected,
678
+ 'aria-expanded': isFolder ? isExpanded : undefined,
552
679
  'data-path': node.path,
553
680
  'data-name': node.name,
554
681
  'data-type': node.type,
@@ -685,6 +812,11 @@ var FileTree = function FileTree(_ref) {
685
812
  );
686
813
  };
687
814
 
815
+ var cursorIdx = cursorIndex(flatItems);
816
+ var activeDescendant = cursorIdx >= startIdx && cursorIdx <= endIdx && flatItems[cursorIdx].kind === 'node' &&
817
+ !(pendingRename && pendingRename.path === flatItems[cursorIdx].node.path)
818
+ ? rowId(flatItems[cursorIdx].node.path) : undefined;
819
+
688
820
  var visibleRows = [];
689
821
  for (var vi = startIdx; vi <= endIdx; vi++) {
690
822
  visibleRows.push(renderRow(flatItems[vi], vi));
@@ -696,6 +828,14 @@ var FileTree = function FileTree(_ref) {
696
828
  className: 'file-tree file-tree-root',
697
829
  ref: containerRef,
698
830
  tabIndex: 0,
831
+ role: 'tree',
832
+ 'aria-label': 'Files',
833
+ 'aria-multiselectable': true,
834
+ // Only a rendered row can be referenced; moving the cursor scrolls its
835
+ // row into the rendered window first.
836
+ 'aria-activedescendant': activeDescendant,
837
+ onKeyDown: handleTreeKeyDown,
838
+ onMouseDown: function () { if (containerRef.current) containerRef.current.classList.remove('kbd-nav'); },
699
839
  // No root drag handlers here. This element is only as tall as its rows,
700
840
  // so it can't cover the empty space users actually aim at; the whole
701
841
  // scrollable panel handles the root drop instead (see the effect above).
@@ -440,7 +440,7 @@ var GitPanel = function GitPanel(_ref) {
440
440
  { className: 'git-list' },
441
441
  workingTree.length === 0
442
442
  ? React.createElement('div', { className: 'git-empty' }, 'No local changes.')
443
- : workingTree.map(function (item, idx) { return renderFileRow(item, 'HEAD', null, false); })
443
+ : workingTree.map(function (item) { return renderFileRow(item, 'HEAD', null, false); })
444
444
  )
445
445
  ),
446
446
 
@@ -7,57 +7,6 @@
7
7
  //
8
8
  // Errors from the same pass render here too, so a drop that both conflicts
9
9
  // and fails needs one dialog rather than two.
10
- // Focus containment for a modal: initial focus in, Tab cycles inside, Escape
11
- // dismisses, focus restored on unmount. Shared with ImportDialog — both are
12
- // overlays over an editor that will happily steal focus back otherwise.
13
- window.useModalFocusTrap = function useModalFocusTrap(modalRef, onDismiss) {
14
- React.useEffect(function () {
15
- var previouslyFocused = document.activeElement;
16
- var modal = modalRef.current;
17
- var focusableSelector = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
18
- var initialFocusable = modal && modal.querySelector(focusableSelector);
19
- if (initialFocusable) initialFocusable.focus();
20
- else if (modal) modal.focus();
21
-
22
- var onKey = function (e) {
23
- if (e.key === 'Escape') {
24
- e.preventDefault();
25
- e.stopPropagation();
26
- onDismiss();
27
- return;
28
- }
29
- if (e.key !== 'Tab' || !modal) return;
30
-
31
- var focusable = modal.querySelectorAll(focusableSelector);
32
- if (focusable.length === 0) {
33
- e.preventDefault();
34
- modal.focus();
35
- return;
36
- }
37
-
38
- var first = focusable[0];
39
- var last = focusable[focusable.length - 1];
40
- if (!modal.contains(document.activeElement)) {
41
- e.preventDefault();
42
- first.focus();
43
- } else if (e.shiftKey && document.activeElement === first) {
44
- e.preventDefault();
45
- last.focus();
46
- } else if (!e.shiftKey && document.activeElement === last) {
47
- e.preventDefault();
48
- first.focus();
49
- }
50
- };
51
- document.addEventListener('keydown', onKey, true);
52
- return function () {
53
- document.removeEventListener('keydown', onKey, true);
54
- if (previouslyFocused && previouslyFocused.focus && document.contains(previouslyFocused)) {
55
- previouslyFocused.focus();
56
- }
57
- };
58
- }, [onDismiss]);
59
- };
60
-
61
10
  // Compare is offered only for files that look like text and are small enough
62
11
  // to diff in a modal. file.type is '' for most source files, so this rules
63
12
  // out the known-binary families rather than requiring a text/* type.
@@ -71,7 +20,6 @@ var ImportConflictModal = function ImportConflictModal(_ref) {
71
20
  var conflicts = _ref.conflicts || [];
72
21
  var errors = _ref.errors || [];
73
22
  var onResolve = _ref.onResolve;
74
- var modalRef = React.useRef(null);
75
23
  var _cmp = React.useState(null);
76
24
  var compare = _cmp[0];
77
25
  var setCompare = _cmp[1];
@@ -89,7 +37,6 @@ var ImportConflictModal = function ImportConflictModal(_ref) {
89
37
  var dismiss = React.useCallback(function () {
90
38
  if (compare) setCompare(null); else onResolve('skip');
91
39
  }, [onResolve, compare]);
92
- window.useModalFocusTrap(modalRef, dismiss);
93
40
 
94
41
  var openCompare = function (path) {
95
42
  var file = incoming[path];
@@ -112,23 +59,16 @@ var ImportConflictModal = function ImportConflictModal(_ref) {
112
59
  );
113
60
  };
114
61
 
62
+ // A backdrop click always means skip, even from the compare view; only
63
+ // Esc steps back out of compare first (dismiss).
115
64
  return React.createElement(
116
- 'div',
65
+ window.ModalDialog,
117
66
  {
118
- className: 'schema-modal-overlay',
119
- onClick: function () { onResolve('skip'); }
67
+ className: 'schema-modal import-conflict-modal' + (compare ? ' import-conflict-wide' : ''),
68
+ label: 'Resolve import conflicts',
69
+ onDismiss: dismiss,
70
+ onBackdrop: function () { onResolve('skip'); }
120
71
  },
121
- React.createElement(
122
- 'div',
123
- {
124
- ref: modalRef,
125
- className: 'schema-modal import-conflict-modal' + (compare ? ' import-conflict-wide' : ''),
126
- role: 'dialog',
127
- 'aria-modal': 'true',
128
- 'aria-label': 'Resolve import conflicts',
129
- tabIndex: -1,
130
- onClick: function (e) { e.stopPropagation(); }
131
- },
132
72
  React.createElement(
133
73
  'div', { className: 'schema-modal-header' },
134
74
  React.createElement(
@@ -181,7 +121,6 @@ var ImportConflictModal = function ImportConflictModal(_ref) {
181
121
  button('Keep both', 'rename', 'import-conflict-btn'),
182
122
  button('Overwrite all', 'overwrite', 'import-conflict-btn import-conflict-btn-danger')
183
123
  )
184
- )
185
124
  );
186
125
  };
187
126
 
@@ -19,7 +19,6 @@ var ImportDialog = function ImportDialog(_ref) {
19
19
  var onCancel = _ref.onCancel;
20
20
  var onImport = _ref.onImport;
21
21
 
22
- var modalRef = React.useRef(null);
23
22
  var filesInputRef = React.useRef(null);
24
23
  var folderInputRef = React.useRef(null);
25
24
 
@@ -31,7 +30,6 @@ var ImportDialog = function ImportDialog(_ref) {
31
30
  var dest = _dest[0];
32
31
  var setDest = _dest[1];
33
32
 
34
- window.useModalFocusTrap(modalRef, onCancel);
35
33
 
36
34
  // webkitdirectory has no JSX/React prop, and React strips unknown lowercase
37
35
  // attributes on <input>, so it is set on the DOM node directly.
@@ -111,19 +109,8 @@ var ImportDialog = function ImportDialog(_ref) {
111
109
  var replacing = targets.filter(function (t) { return existingFiles.has(t); }).length;
112
110
 
113
111
  return React.createElement(
114
- 'div',
115
- { className: 'schema-modal-overlay', onClick: onCancel },
116
- React.createElement(
117
- 'div',
118
- {
119
- ref: modalRef,
120
- className: 'schema-modal import-dialog',
121
- role: 'dialog',
122
- 'aria-modal': 'true',
123
- 'aria-label': 'Upload files',
124
- tabIndex: -1,
125
- onClick: function (e) { e.stopPropagation(); }
126
- },
112
+ window.ModalDialog,
113
+ { className: 'schema-modal import-dialog', label: 'Upload files', onDismiss: onCancel },
127
114
  React.createElement(
128
115
  'div', { className: 'schema-modal-header' },
129
116
  React.createElement('div', { className: 'schema-modal-title' },
@@ -216,7 +203,6 @@ var ImportDialog = function ImportDialog(_ref) {
216
203
  entries.length === 0 ? 'Upload' : 'Upload ' + entries.length + ' file' + (entries.length === 1 ? '' : 's')
217
204
  )
218
205
  )
219
- )
220
206
  );
221
207
  };
222
208