mbeditor 0.14.1 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -0
- data/app/assets/javascripts/mbeditor/application.js +5 -1
- data/app/assets/javascripts/mbeditor/collaboration_identity.js +4 -2
- data/app/assets/javascripts/mbeditor/collaboration_service.js +74 -2
- data/app/assets/javascripts/mbeditor/components/AiRoundTripModal.js +452 -0
- data/app/assets/javascripts/mbeditor/components/ChangelogView.js +1 -1
- data/app/assets/javascripts/mbeditor/components/CombinedFileView.js +44 -29
- data/app/assets/javascripts/mbeditor/components/DiffViewer.js +2 -1
- data/app/assets/javascripts/mbeditor/components/EditorPanel.js +33 -27
- data/app/assets/javascripts/mbeditor/components/FileHistoryPanel.js +2 -7
- data/app/assets/javascripts/mbeditor/components/FileTree.js +144 -4
- data/app/assets/javascripts/mbeditor/components/GitPanel.js +1 -1
- data/app/assets/javascripts/mbeditor/components/ImportConflictModal.js +7 -68
- data/app/assets/javascripts/mbeditor/components/ImportDialog.js +2 -16
- data/app/assets/javascripts/mbeditor/components/MbeditorApp.js +368 -471
- data/app/assets/javascripts/mbeditor/components/ModalDialog.js +203 -0
- data/app/assets/javascripts/mbeditor/components/PastePlaceModal.js +1 -9
- data/app/assets/javascripts/mbeditor/components/Popover.js +88 -0
- data/app/assets/javascripts/mbeditor/components/PopupMenu.js +166 -0
- data/app/assets/javascripts/mbeditor/components/ProblemsPanel.js +8 -4
- data/app/assets/javascripts/mbeditor/components/QuickOpenDialog.js +5 -7
- data/app/assets/javascripts/mbeditor/components/SettingsModal.js +3 -14
- data/app/assets/javascripts/mbeditor/components/ShortcutHelp.js +5 -26
- data/app/assets/javascripts/mbeditor/components/TabBar.js +15 -32
- data/app/assets/javascripts/mbeditor/components/TestResultsPanel.js +2 -7
- data/app/assets/javascripts/mbeditor/editor_plugins.js +3 -23
- data/app/assets/javascripts/mbeditor/file_service.js +1 -1
- data/app/assets/javascripts/mbeditor/git_service.js +0 -7
- data/app/assets/javascripts/mbeditor/patch_select.js +156 -0
- data/app/assets/javascripts/mbeditor/tab_manager.js +22 -0
- data/app/assets/stylesheets/mbeditor/application.css +7 -110
- data/app/assets/stylesheets/mbeditor/editor.css +200 -194
- data/app/assets/stylesheets/mbeditor/glass.css +1 -1
- data/app/channels/mbeditor/collaboration_channel.rb +24 -5
- data/app/controllers/mbeditor/editors_controller.rb +75 -38
- data/app/controllers/mbeditor/git_controller.rb +1 -12
- data/app/services/mbeditor/ai_bundle_service.rb +181 -0
- data/app/services/mbeditor/archive_service.rb +43 -6
- data/app/services/mbeditor/availability_probe.rb +2 -2
- data/app/services/mbeditor/code_search_service.rb +1 -3
- data/app/services/mbeditor/collaboration_doc_store.rb +37 -1
- data/app/services/mbeditor/exclusion_matcher.rb +0 -4
- data/app/services/mbeditor/file_import_service.rb +4 -1
- data/app/services/mbeditor/file_operation_service.rb +3 -3
- data/app/services/mbeditor/git_service.rb +11 -45
- data/app/services/mbeditor/js_definition_service.rb +1 -0
- data/app/services/mbeditor/model_graph_service.rb +1 -0
- data/app/services/mbeditor/patch_apply_service.rb +185 -0
- data/app/services/mbeditor/rails_related_files_service.rb +1 -1
- data/app/services/mbeditor/redmine_config_error.rb +6 -0
- data/app/services/mbeditor/redmine_disabled_error.rb +10 -0
- data/app/services/mbeditor/redmine_service.rb +0 -8
- data/app/services/mbeditor/ruby_definition_service.rb +1 -0
- data/app/services/mbeditor/schema_service.rb +1 -0
- data/app/services/mbeditor/test_runner_service.rb +1 -1
- data/lib/mbeditor/rack/silence_ping_request.rb +14 -14
- data/lib/mbeditor/route_map.rb +5 -2
- data/lib/mbeditor/ruby_lsp_client.rb +7 -26
- data/lib/mbeditor/version.rb +1 -1
- data/public/monaco-editor/VERSIONS +2 -1
- data/public/monaco-editor/monaco.js +226 -226
- metadata +11 -4
- data/app/assets/javascripts/mbeditor/components/CommitGraph.js +0 -65
- data/app/services/mbeditor/git_commit_graph_service.rb +0 -62
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// ModalDialog — the one modal shell. Renders a native <dialog> opened with
|
|
4
|
+
// showModal(), so the browser supplies what each overlay used to rebuild by
|
|
5
|
+
// hand, and rebuilt inconsistently: the page behind is inert (Tab cannot
|
|
6
|
+
// wander back into Monaco), the dialog paints in the top layer (no z-index
|
|
7
|
+
// ladder to keep ahead of), Esc is a close request, and ::backdrop replaces
|
|
8
|
+
// the full-screen overlay div.
|
|
9
|
+
//
|
|
10
|
+
// Mount = open, unmount = close. The parent owns visibility exactly as it did
|
|
11
|
+
// with the overlay divs, so React state stays the single source of truth:
|
|
12
|
+
// every native close request is cancelled and routed to onDismiss, and the
|
|
13
|
+
// parent decides whether that unmounts the dialog (ImportConflictModal uses
|
|
14
|
+
// the first Esc to leave its compare view instead). Without onDismiss, Esc
|
|
15
|
+
// does nothing — for dialogs that demand an explicit choice.
|
|
16
|
+
//
|
|
17
|
+
// className styles the panel *inside* the dialog. The <dialog> itself is an
|
|
18
|
+
// unstyled shell (.mb-dialog, editor.css) the size of that panel, so existing
|
|
19
|
+
// panel CSS carries over unchanged and "outside the dialog box" means
|
|
20
|
+
// "outside the panel" for the backdrop click.
|
|
21
|
+
//
|
|
22
|
+
// Props: className, dialogClassName (backdrop variants), label | labelledBy,
|
|
23
|
+
// onDismiss, onBackdrop (defaults to onDismiss; pass null to ignore backdrop
|
|
24
|
+
// clicks), panelProps (extra attributes for the panel), children.
|
|
25
|
+
//
|
|
26
|
+
// Initial focus: put data-autofocus on the control that should get it. React's
|
|
27
|
+
// autoFocus runs at commit, before showModal(), while the dialog is still
|
|
28
|
+
// closed and unfocusable, so it is silently lost. Without a marker,
|
|
29
|
+
// showModal()'s own focusing step picks the first focusable descendant.
|
|
30
|
+
var ModalDialog = function ModalDialog(props) {
|
|
31
|
+
var dialogRef = React.useRef(null);
|
|
32
|
+
var dismissRef = React.useRef(null);
|
|
33
|
+
dismissRef.current = props.onDismiss || null;
|
|
34
|
+
var backdropRef = React.useRef(null);
|
|
35
|
+
backdropRef.current = props.onBackdrop !== undefined ? props.onBackdrop : (props.onDismiss || null);
|
|
36
|
+
|
|
37
|
+
React.useLayoutEffect(function () {
|
|
38
|
+
var dialog = dialogRef.current;
|
|
39
|
+
if (!dialog) return undefined;
|
|
40
|
+
var previouslyFocused = document.activeElement;
|
|
41
|
+
var unmounting = false;
|
|
42
|
+
|
|
43
|
+
if (!dialog.open) dialog.showModal();
|
|
44
|
+
var marked = dialog.querySelector('[data-autofocus]');
|
|
45
|
+
if (marked && marked.focus) marked.focus();
|
|
46
|
+
|
|
47
|
+
var dismiss = function () { if (dismissRef.current) dismissRef.current(); };
|
|
48
|
+
|
|
49
|
+
var onCancel = function (e) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
dismiss();
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// A browser may refuse the cancel (Chrome stops honouring preventDefault
|
|
55
|
+
// on repeated Esc without user activation) and close the dialog itself.
|
|
56
|
+
// If the parent still has it mounted after handling the dismiss, reopen:
|
|
57
|
+
// a closed-but-mounted dialog is an invisible, unreachable modal.
|
|
58
|
+
var onClose = function () {
|
|
59
|
+
if (unmounting) return;
|
|
60
|
+
setTimeout(function () {
|
|
61
|
+
if (!unmounting && dialog.isConnected && !dialog.open) dialog.showModal();
|
|
62
|
+
}, 0);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Backdrop click. Tested by pointer position, not event.target: the
|
|
66
|
+
// <dialog> is also the target for gaps between its children. Requiring
|
|
67
|
+
// both press and release outside keeps a text-selection drag that ends on
|
|
68
|
+
// the backdrop from dismissing. (closedby="any" would do this natively,
|
|
69
|
+
// but Safari lacks it and it closes the dialog behind React's back.)
|
|
70
|
+
var outside = function (e) {
|
|
71
|
+
var r = dialog.getBoundingClientRect();
|
|
72
|
+
return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;
|
|
73
|
+
};
|
|
74
|
+
var pressedOutside = false;
|
|
75
|
+
var onPointerDown = function (e) { pressedOutside = outside(e); };
|
|
76
|
+
var onPointerUp = function (e) {
|
|
77
|
+
if (pressedOutside && outside(e) && backdropRef.current) backdropRef.current();
|
|
78
|
+
pressedOutside = false;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
dialog.addEventListener('cancel', onCancel);
|
|
82
|
+
dialog.addEventListener('close', onClose);
|
|
83
|
+
dialog.addEventListener('pointerdown', onPointerDown);
|
|
84
|
+
dialog.addEventListener('pointerup', onPointerUp);
|
|
85
|
+
return function () {
|
|
86
|
+
unmounting = true;
|
|
87
|
+
dialog.removeEventListener('cancel', onCancel);
|
|
88
|
+
dialog.removeEventListener('close', onClose);
|
|
89
|
+
dialog.removeEventListener('pointerdown', onPointerDown);
|
|
90
|
+
dialog.removeEventListener('pointerup', onPointerUp);
|
|
91
|
+
// Runs before React removes the node, so close() still gets to return
|
|
92
|
+
// focus to the opener. The fallback covers browsers that don't, and
|
|
93
|
+
// focus left on <body> because the opener has since gone.
|
|
94
|
+
if (dialog.open) dialog.close();
|
|
95
|
+
var active = document.activeElement;
|
|
96
|
+
if ((!active || active === document.body) && previouslyFocused &&
|
|
97
|
+
previouslyFocused.focus && document.contains(previouslyFocused)) {
|
|
98
|
+
previouslyFocused.focus();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}, []);
|
|
102
|
+
|
|
103
|
+
var panelProps = Object.assign({}, props.panelProps || {}, { className: props.className });
|
|
104
|
+
|
|
105
|
+
return React.createElement(
|
|
106
|
+
'dialog',
|
|
107
|
+
{
|
|
108
|
+
ref: dialogRef,
|
|
109
|
+
className: 'mb-dialog' + (props.dialogClassName ? ' ' + props.dialogClassName : ''),
|
|
110
|
+
'aria-label': props.labelledBy ? undefined : props.label,
|
|
111
|
+
'aria-labelledby': props.labelledBy
|
|
112
|
+
},
|
|
113
|
+
React.createElement('div', panelProps, props.children)
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
window.ModalDialog = ModalDialog;
|
|
118
|
+
|
|
119
|
+
// ── MbeditorDialogs: promise-returning confirm()/prompt() ─────────────────
|
|
120
|
+
// Replacements for window.confirm/window.prompt, which block the whole page
|
|
121
|
+
// (cable heartbeats and polls included), ignore the theme, and cannot put
|
|
122
|
+
// focus on the safe button of a destructive question.
|
|
123
|
+
//
|
|
124
|
+
// MbeditorDialogs.confirm({ title, message, confirmLabel, danger }) → Promise<boolean>
|
|
125
|
+
// MbeditorDialogs.prompt({ title, message, value, confirmLabel }) → Promise<string|null>
|
|
126
|
+
//
|
|
127
|
+
// A plain string is accepted as the message. Esc and the backdrop mean
|
|
128
|
+
// cancel (false / null). Each call renders into its own React root inside
|
|
129
|
+
// #mbeditor-root (so the editor's scoped CSS applies), which is what lets
|
|
130
|
+
// non-component modules such as collaboration_identity.js use it.
|
|
131
|
+
var ConfirmDialog = function ConfirmDialog(props) {
|
|
132
|
+
var h = React.createElement;
|
|
133
|
+
var _v = React.useState(props.value != null ? String(props.value) : '');
|
|
134
|
+
var value = _v[0];
|
|
135
|
+
var setValue = _v[1];
|
|
136
|
+
var isPrompt = props.kind === 'prompt';
|
|
137
|
+
var cancel = function () { props.onResult(isPrompt ? null : false); };
|
|
138
|
+
var accept = function () { props.onResult(isPrompt ? value : true); };
|
|
139
|
+
var selectedRef = React.useRef(false);
|
|
140
|
+
|
|
141
|
+
return h(window.ModalDialog,
|
|
142
|
+
{ className: 'schema-modal mb-confirm', label: props.title || props.message, onDismiss: cancel },
|
|
143
|
+
h('form', {
|
|
144
|
+
method: 'dialog',
|
|
145
|
+
onSubmit: function (e) { e.preventDefault(); accept(); }
|
|
146
|
+
},
|
|
147
|
+
props.title && h('div', { className: 'schema-modal-header' },
|
|
148
|
+
h('div', { className: 'schema-modal-title' }, props.title)),
|
|
149
|
+
h('div', { className: 'schema-modal-body' },
|
|
150
|
+
props.message && h('p', { className: 'mb-confirm-message' }, props.message),
|
|
151
|
+
isPrompt && h('input', {
|
|
152
|
+
className: 'import-dest-input', type: 'text', value: value,
|
|
153
|
+
spellCheck: false, autoComplete: 'off', 'data-autofocus': true,
|
|
154
|
+
'aria-label': props.title || props.message,
|
|
155
|
+
onChange: function (e) { setValue(e.target.value); },
|
|
156
|
+
// Select the default once, as window.prompt did, so typing replaces it.
|
|
157
|
+
onFocus: function (e) { if (!selectedRef.current) { selectedRef.current = true; e.target.select(); } }
|
|
158
|
+
})
|
|
159
|
+
),
|
|
160
|
+
h('div', { className: 'import-conflict-actions' },
|
|
161
|
+
h('button', {
|
|
162
|
+
type: 'button', className: 'import-conflict-btn', onClick: cancel,
|
|
163
|
+
// A destructive question starts on the safe answer.
|
|
164
|
+
'data-autofocus': (!isPrompt && props.danger) || undefined
|
|
165
|
+
}, props.cancelLabel || 'Cancel'),
|
|
166
|
+
h('button', {
|
|
167
|
+
type: 'submit',
|
|
168
|
+
className: 'import-conflict-btn ' + (props.danger ? 'import-conflict-btn-danger' : 'import-conflict-btn-primary'),
|
|
169
|
+
'data-autofocus': (!isPrompt && !props.danger) || undefined
|
|
170
|
+
}, props.confirmLabel || 'OK')
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
window.MbeditorDialogs = (function () {
|
|
177
|
+
function open(kind, opts) {
|
|
178
|
+
if (typeof opts === 'string') opts = { message: opts };
|
|
179
|
+
opts = opts || {};
|
|
180
|
+
return new Promise(function (resolve) {
|
|
181
|
+
var host = document.createElement('div');
|
|
182
|
+
(document.getElementById('mbeditor-root') || document.body).appendChild(host);
|
|
183
|
+
var settled = false;
|
|
184
|
+
var onResult = function (result) {
|
|
185
|
+
if (settled) return;
|
|
186
|
+
settled = true;
|
|
187
|
+
// Unmount before resolving: the dialog's close() hands focus back to
|
|
188
|
+
// the opener, and a caller that moves focus on resolve (opening a
|
|
189
|
+
// tab, say) must get the last word.
|
|
190
|
+
setTimeout(function () {
|
|
191
|
+
ReactDOM.unmountComponentAtNode(host);
|
|
192
|
+
host.remove();
|
|
193
|
+
resolve(result);
|
|
194
|
+
}, 0);
|
|
195
|
+
};
|
|
196
|
+
ReactDOM.render(React.createElement(ConfirmDialog, Object.assign({}, opts, { kind: kind, onResult: onResult })), host);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
confirm: function (opts) { return open('confirm', opts); },
|
|
201
|
+
prompt: function (opts) { return open('prompt', opts); }
|
|
202
|
+
};
|
|
203
|
+
})();
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
var PastePlaceModal = (function () {
|
|
12
12
|
var useState = React.useState;
|
|
13
|
-
var useRef = React.useRef;
|
|
14
13
|
var useMemo = React.useMemo;
|
|
15
14
|
|
|
16
15
|
var MAX_CANDIDATE_FILES = 10;
|
|
@@ -237,7 +236,6 @@ var PastePlaceModal = (function () {
|
|
|
237
236
|
}
|
|
238
237
|
|
|
239
238
|
var Modal = function PastePlaceModal(props) {
|
|
240
|
-
var modalRef = useRef(null);
|
|
241
239
|
var _c = useState('');
|
|
242
240
|
var code = _c[0]; var setCode = _c[1];
|
|
243
241
|
var _p = useState(null);
|
|
@@ -249,7 +247,6 @@ var PastePlaceModal = (function () {
|
|
|
249
247
|
var _e = useState(null);
|
|
250
248
|
var error = _e[0]; var setError = _e[1];
|
|
251
249
|
|
|
252
|
-
window.useModalFocusTrap(modalRef, props.onClose);
|
|
253
250
|
|
|
254
251
|
var byFile = useMemo(function () {
|
|
255
252
|
return plan ? buildEdits(plan.items, choices, plan.texts) : {};
|
|
@@ -282,11 +279,7 @@ var PastePlaceModal = (function () {
|
|
|
282
279
|
};
|
|
283
280
|
|
|
284
281
|
var h = React.createElement;
|
|
285
|
-
return h(
|
|
286
|
-
h('div', {
|
|
287
|
-
ref: modalRef, className: 'schema-modal paste-place-modal', role: 'dialog', 'aria-modal': 'true',
|
|
288
|
-
'aria-label': 'Paste and place', tabIndex: -1, onClick: function (e) { e.stopPropagation(); }
|
|
289
|
-
},
|
|
282
|
+
return h(window.ModalDialog, { className: 'schema-modal paste-place-modal', label: 'Paste and place', onDismiss: props.onClose },
|
|
290
283
|
h('div', { className: 'schema-modal-header' }, h('div', { className: 'schema-modal-title' }, 'Paste & Place')),
|
|
291
284
|
h('div', { className: 'schema-modal-body paste-place-body' },
|
|
292
285
|
!plan && h('textarea', {
|
|
@@ -319,7 +312,6 @@ var PastePlaceModal = (function () {
|
|
|
319
312
|
? h('button', { type: 'button', className: 'import-conflict-btn import-conflict-btn-primary', disabled: busy || files.length === 0, onClick: apply }, 'Apply to editor')
|
|
320
313
|
: h('button', { type: 'button', className: 'import-conflict-btn import-conflict-btn-primary', disabled: busy || !code.trim(), onClick: find }, busy ? 'Searching...' : 'Find placement')
|
|
321
314
|
)
|
|
322
|
-
)
|
|
323
315
|
);
|
|
324
316
|
};
|
|
325
317
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Popover — the one shell for menus, dropdowns and hovercards. Renders an
|
|
4
|
+
// element with the popover attribute and shows it on mount, so it paints in
|
|
5
|
+
// the top layer: above Monaco's widgets and every z-index, and positioned
|
|
6
|
+
// against the viewport even inside an ancestor with backdrop-filter or a
|
|
7
|
+
// transform (the glass chrome's centre column is one; it used to shove a
|
|
8
|
+
// position:fixed menu ~130px off its button).
|
|
9
|
+
//
|
|
10
|
+
// Mount = open, unmount = close, as with ModalDialog: the parent's state is
|
|
11
|
+
// the source of truth and the browser's own closes are routed to onDismiss.
|
|
12
|
+
//
|
|
13
|
+
// mode 'auto' (default) — light dismiss: an outside click or Esc closes
|
|
14
|
+
// it, and opening one auto popover closes the others. For
|
|
15
|
+
// menus. Replaces full-screen click-catcher divs and document
|
|
16
|
+
// mousedown listeners.
|
|
17
|
+
// mode 'manual' — no light dismiss; the parent closes it. For hover-driven
|
|
18
|
+
// surfaces that only need the top layer.
|
|
19
|
+
//
|
|
20
|
+
// Positioning stays with the caller (style.top/left/right, fixed to the
|
|
21
|
+
// viewport). Props: mode, className, style, onDismiss, source (the element
|
|
22
|
+
// that opened it: becomes its invoker, so clicking it does not light-dismiss
|
|
23
|
+
// and its own click handler can toggle), popoverRef (object ref to the
|
|
24
|
+
// element), and any other DOM props (onMouseEnter, role, ...), passed through.
|
|
25
|
+
var POPOVER_OWN_PROPS = { mode: 1, onDismiss: 1, source: 1, popoverRef: 1, children: 1 };
|
|
26
|
+
|
|
27
|
+
var Popover = function Popover(props) {
|
|
28
|
+
var elRef = React.useRef(null);
|
|
29
|
+
var dismissRef = React.useRef(null);
|
|
30
|
+
dismissRef.current = props.onDismiss || null;
|
|
31
|
+
var sourceRef = React.useRef(null);
|
|
32
|
+
sourceRef.current = props.source || null;
|
|
33
|
+
|
|
34
|
+
var setRef = function (el) {
|
|
35
|
+
elRef.current = el;
|
|
36
|
+
if (props.popoverRef) props.popoverRef.current = el;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
React.useLayoutEffect(function () {
|
|
40
|
+
var el = elRef.current;
|
|
41
|
+
if (!el || typeof el.showPopover !== 'function') return undefined; // no API: renders as a plain fixed element
|
|
42
|
+
var unmounting = false;
|
|
43
|
+
var lastDown = null;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
el.showPopover(sourceRef.current ? { source: sourceRef.current } : undefined);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
return undefined; // already open, or detached — nothing to manage
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Where `source` is unsupported, pressing the invoker light-dismisses the
|
|
52
|
+
// popover before the invoker's own click handler runs, and that handler
|
|
53
|
+
// would read "closed" and reopen it. Leave that close to the handler: it
|
|
54
|
+
// toggles state off, which unmounts this. The deferred check below covers
|
|
55
|
+
// a handler that does not.
|
|
56
|
+
var onPointerDown = function (e) { lastDown = { target: e.target, at: Date.now() }; };
|
|
57
|
+
var onBeforeToggle = function (e) {
|
|
58
|
+
if (unmounting || e.newState !== 'closed') return;
|
|
59
|
+
var src = sourceRef.current;
|
|
60
|
+
if (src && lastDown && Date.now() - lastDown.at < 500 && src.contains(lastDown.target)) {
|
|
61
|
+
setTimeout(function () {
|
|
62
|
+
if (!unmounting && !el.matches(':popover-open') && dismissRef.current) dismissRef.current();
|
|
63
|
+
}, 250);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (dismissRef.current) dismissRef.current();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
document.addEventListener('pointerdown', onPointerDown, true);
|
|
70
|
+
el.addEventListener('beforetoggle', onBeforeToggle);
|
|
71
|
+
return function () {
|
|
72
|
+
unmounting = true;
|
|
73
|
+
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
74
|
+
el.removeEventListener('beforetoggle', onBeforeToggle);
|
|
75
|
+
// React removes the node next; removing a showing popover hides it
|
|
76
|
+
// without firing toggle events, so nothing else is needed here.
|
|
77
|
+
};
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
var domProps = { ref: setRef, popover: props.mode || 'auto' };
|
|
81
|
+
Object.keys(props).forEach(function (k) {
|
|
82
|
+
if (!POPOVER_OWN_PROPS[k]) domProps[k] = props[k];
|
|
83
|
+
});
|
|
84
|
+
domProps.className = 'mb-popover' + (props.className ? ' ' + props.className : '');
|
|
85
|
+
return React.createElement('div', domProps, props.children);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
window.Popover = Popover;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// PopupMenu — a context menu users can drive from the keyboard. A Popover
|
|
4
|
+
// (top layer, light dismiss, Esc) holding a focusgroup of <button> items.
|
|
5
|
+
//
|
|
6
|
+
// <PopupMenu label="File actions" onDismiss={close} keyboard={openedByKey}
|
|
7
|
+
// style={{left, top}} className="context-menu">
|
|
8
|
+
// <MenuItem icon="far fa-file" label="New File" onClick={...} />
|
|
9
|
+
// <MenuSeparator />
|
|
10
|
+
// </PopupMenu>
|
|
11
|
+
//
|
|
12
|
+
// Keys: Up/Down move (wrapping), Home/End jump, Enter/Space activate (native
|
|
13
|
+
// button behaviour), Esc closes (the popover), Tab closes. Opened from the
|
|
14
|
+
// keyboard (`keyboard`), focus starts on the first item; opened by a pointer,
|
|
15
|
+
// focus goes to the menu itself without a ring, so the first ArrowDown enters
|
|
16
|
+
// it. Hovering an item focuses it, so hover and focus are one item.
|
|
17
|
+
//
|
|
18
|
+
// On close, focus returns to whatever had it when the menu opened, unless it
|
|
19
|
+
// has already moved somewhere else on purpose (a dialog, an inline rename).
|
|
20
|
+
//
|
|
21
|
+
// Roles: the browser's focusgroup="menu" infers role=menu/menuitem and does
|
|
22
|
+
// the arrow keys. Where it is missing (everything but Chromium 150+), the
|
|
23
|
+
// roles are set explicitly and the arrow keys come from onKeyDown below.
|
|
24
|
+
// Explicit roles would block the native inference, so they are never set on
|
|
25
|
+
// both paths.
|
|
26
|
+
var NATIVE_FOCUSGROUP = typeof HTMLElement !== 'undefined' && 'focusGroup' in HTMLElement.prototype;
|
|
27
|
+
|
|
28
|
+
var enabledMenuItems = function (group) {
|
|
29
|
+
return Array.prototype.filter.call(group.querySelectorAll('button'), function (b) {
|
|
30
|
+
return !b.disabled && b.getAttribute('aria-disabled') !== 'true';
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var focusQuietly = function (el, visible) {
|
|
35
|
+
try {
|
|
36
|
+
el.focus({ preventScroll: true, focusVisible: !!visible });
|
|
37
|
+
} catch (e) {
|
|
38
|
+
el.focus();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var PopupMenu = function PopupMenu(props) {
|
|
43
|
+
var groupRef = React.useRef(null);
|
|
44
|
+
var dismissRef = React.useRef(null);
|
|
45
|
+
dismissRef.current = props.onDismiss || null;
|
|
46
|
+
// Whether the last interaction was a key: decides if restored focus shows a
|
|
47
|
+
// ring. A pointer activation must not leave the opener outlined.
|
|
48
|
+
var keyedRef = React.useRef(!!props.keyboard);
|
|
49
|
+
|
|
50
|
+
var dismiss = function () { if (dismissRef.current) dismissRef.current(); };
|
|
51
|
+
|
|
52
|
+
// Runs after Popover's own layout effect (children first), so the popover
|
|
53
|
+
// is already showing and its items are focusable.
|
|
54
|
+
React.useLayoutEffect(function () {
|
|
55
|
+
var group = groupRef.current;
|
|
56
|
+
if (!group) return undefined;
|
|
57
|
+
var previous = document.activeElement;
|
|
58
|
+
|
|
59
|
+
var first = props.keyboard ? enabledMenuItems(group)[0] : null;
|
|
60
|
+
focusQuietly(first || group, !!first);
|
|
61
|
+
|
|
62
|
+
return function () {
|
|
63
|
+
// Cleanup runs before React removes the node. Only take focus back
|
|
64
|
+
// while it is still ours (inside the menu, or dropped on <body>).
|
|
65
|
+
var active = document.activeElement;
|
|
66
|
+
var ours = !active || active === document.body || group.contains(active);
|
|
67
|
+
if (ours && previous && previous !== document.body && previous.isConnected &&
|
|
68
|
+
typeof previous.focus === 'function') {
|
|
69
|
+
focusQuietly(previous, keyedRef.current);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
var onKeyDown = function (e) {
|
|
75
|
+
keyedRef.current = true;
|
|
76
|
+
var key = e.key;
|
|
77
|
+
if (key === 'Tab') {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
dismiss();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var group = groupRef.current;
|
|
83
|
+
var vertical = key === 'ArrowDown' || key === 'ArrowUp';
|
|
84
|
+
// Native focusgroup moves between items; from the menu itself (the
|
|
85
|
+
// pointer-open state) there is no item yet, so the first arrow is ours.
|
|
86
|
+
if (!(key === 'Home' || key === 'End' || (vertical && (!NATIVE_FOCUSGROUP || e.target === group)))) return;
|
|
87
|
+
var items = enabledMenuItems(group);
|
|
88
|
+
if (!items.length) return;
|
|
89
|
+
var n = items.length;
|
|
90
|
+
var cur = items.indexOf(document.activeElement);
|
|
91
|
+
var next;
|
|
92
|
+
if (key === 'Home') next = 0;
|
|
93
|
+
else if (key === 'End') next = n - 1;
|
|
94
|
+
else if (cur < 0) next = key === 'ArrowUp' ? n - 1 : 0;
|
|
95
|
+
else next = (cur + (key === 'ArrowUp' ? -1 : 1) + n) % n;
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
focusQuietly(items[next], true);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
var onPointerMove = function (e) {
|
|
102
|
+
if (e.pointerType !== 'mouse') return;
|
|
103
|
+
var item = e.target.closest && e.target.closest('button');
|
|
104
|
+
if (item && item !== document.activeElement && groupRef.current.contains(item) && !item.disabled) {
|
|
105
|
+
focusQuietly(item, false);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Focus moved out on its own (a click on something focusable, a script):
|
|
110
|
+
// the menu goes with it rather than staying open behind.
|
|
111
|
+
var onBlur = function (e) {
|
|
112
|
+
var to = e.relatedTarget;
|
|
113
|
+
if (to && groupRef.current && !groupRef.current.contains(to)) dismiss();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var popoverProps = {};
|
|
117
|
+
Object.keys(props).forEach(function (k) {
|
|
118
|
+
if (k !== 'label' && k !== 'keyboard' && k !== 'children') popoverProps[k] = props[k];
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
return React.createElement(
|
|
122
|
+
window.Popover,
|
|
123
|
+
popoverProps,
|
|
124
|
+
React.createElement(
|
|
125
|
+
'div',
|
|
126
|
+
{
|
|
127
|
+
ref: groupRef,
|
|
128
|
+
// Nested inside the popover, not on it: Chromium drops focusgroup's
|
|
129
|
+
// keyboard behaviour on the popover element itself.
|
|
130
|
+
focusgroup: 'menu nomemory',
|
|
131
|
+
role: NATIVE_FOCUSGROUP ? undefined : 'menu',
|
|
132
|
+
'aria-label': props.label,
|
|
133
|
+
tabIndex: -1,
|
|
134
|
+
className: 'context-menu-group',
|
|
135
|
+
onKeyDown: onKeyDown,
|
|
136
|
+
onPointerDown: function () { keyedRef.current = false; },
|
|
137
|
+
onPointerMove: onPointerMove,
|
|
138
|
+
onBlur: onBlur
|
|
139
|
+
},
|
|
140
|
+
props.children
|
|
141
|
+
)
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
var MenuItem = function MenuItem(props) {
|
|
146
|
+
return React.createElement(
|
|
147
|
+
'button',
|
|
148
|
+
{
|
|
149
|
+
type: 'button',
|
|
150
|
+
className: 'context-menu-item' + (props.danger ? ' context-menu-item-danger' : ''),
|
|
151
|
+
role: NATIVE_FOCUSGROUP ? undefined : 'menuitem',
|
|
152
|
+
onClick: props.onClick
|
|
153
|
+
},
|
|
154
|
+
props.icon && React.createElement('i', { className: props.icon + ' context-menu-icon', 'aria-hidden': 'true' }),
|
|
155
|
+
props.label
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// A real <hr>: a separator to assistive tech, skipped by focusgroup.
|
|
160
|
+
var MenuSeparator = function MenuSeparator() {
|
|
161
|
+
return React.createElement('hr', { className: 'context-menu-divider' });
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
window.PopupMenu = PopupMenu;
|
|
165
|
+
window.MenuItem = MenuItem;
|
|
166
|
+
window.MenuSeparator = MenuSeparator;
|
|
@@ -249,10 +249,14 @@ var ProblemsPanel = (function () {
|
|
|
249
249
|
var files = workspace.files || [];
|
|
250
250
|
// Each open is a Monaco model plus a tab; a default-config run over a
|
|
251
251
|
// real app returns hundreds, which would wedge the editor silently.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
252
|
+
var openAll = function () {
|
|
253
|
+
files.forEach(function (f) {
|
|
254
|
+
onOpenFile(f.path, (f.offenses[0] && f.offenses[0].line) || 1, 1);
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
if (files.length <= 20) { openAll(); return; }
|
|
258
|
+
window.MbeditorDialogs.confirm({ title: 'Open ' + files.length + ' files?', message: 'Each file opens in its own tab.', confirmLabel: 'Open all' })
|
|
259
|
+
.then(function (ok) { if (ok) openAll(); });
|
|
256
260
|
};
|
|
257
261
|
|
|
258
262
|
React.useEffect(function () {
|
|
@@ -223,7 +223,6 @@ var QuickOpenDialog = function QuickOpenDialog(_ref) {
|
|
|
223
223
|
// ── Keyboard ─────────────────────────────────────────────────────────────
|
|
224
224
|
|
|
225
225
|
var handleKeyDown = function handleKeyDown(e) {
|
|
226
|
-
if (e.key === 'Escape') { onClose(); return; }
|
|
227
226
|
if (query) {
|
|
228
227
|
if (e.key === 'ArrowDown') { setSelectedIndex(function (i) { return Math.min(i + 1, results.length - 1); }); return; }
|
|
229
228
|
if (e.key === 'ArrowUp') { setSelectedIndex(function (i) { return Math.max(i - 1, 0); }); return; }
|
|
@@ -354,17 +353,17 @@ var QuickOpenDialog = function QuickOpenDialog(_ref) {
|
|
|
354
353
|
|
|
355
354
|
// ── Main render ───────────────────────────────────────────────────────────
|
|
356
355
|
|
|
356
|
+
// Esc and the backdrop close it through ModalDialog; the input's own
|
|
357
|
+
// keydown handler only does list navigation.
|
|
357
358
|
return React.createElement(
|
|
358
|
-
|
|
359
|
-
{ className: 'quick-open-
|
|
360
|
-
React.createElement(
|
|
361
|
-
'div',
|
|
362
|
-
{ className: 'quick-open-box', onClick: function (e) { e.stopPropagation(); } },
|
|
359
|
+
window.ModalDialog,
|
|
360
|
+
{ className: 'quick-open-box', dialogClassName: 'mb-dialog-top', label: 'Quick open', onDismiss: onClose },
|
|
363
361
|
React.createElement(
|
|
364
362
|
'div',
|
|
365
363
|
{ className: 'quick-open-input-wrap' },
|
|
366
364
|
React.createElement('input', {
|
|
367
365
|
ref: inputRef,
|
|
366
|
+
"data-autofocus": true,
|
|
368
367
|
type: 'text',
|
|
369
368
|
className: 'quick-open-input',
|
|
370
369
|
placeholder: 'Search files by name',
|
|
@@ -439,7 +438,6 @@ var QuickOpenDialog = function QuickOpenDialog(_ref) {
|
|
|
439
438
|
)
|
|
440
439
|
)
|
|
441
440
|
)
|
|
442
|
-
)
|
|
443
441
|
);
|
|
444
442
|
};
|
|
445
443
|
|
|
@@ -220,7 +220,6 @@ var SETTINGS_SECTIONS = settingsSections(SETTINGS_ROWS);
|
|
|
220
220
|
var SettingsModal = function SettingsModal(props) {
|
|
221
221
|
var _React = React;
|
|
222
222
|
var useState = _React.useState;
|
|
223
|
-
var useEffect = _React.useEffect;
|
|
224
223
|
var useRef = _React.useRef;
|
|
225
224
|
|
|
226
225
|
var onClose = props.onClose;
|
|
@@ -238,12 +237,6 @@ var SettingsModal = function SettingsModal(props) {
|
|
|
238
237
|
|
|
239
238
|
var sectionRefs = useRef({});
|
|
240
239
|
|
|
241
|
-
useEffect(function() {
|
|
242
|
-
function onKeyDown(e) { if (e.key === 'Escape') onClose(); }
|
|
243
|
-
window.addEventListener('keydown', onKeyDown);
|
|
244
|
-
return function() { window.removeEventListener('keydown', onKeyDown); };
|
|
245
|
-
}, [onClose]);
|
|
246
|
-
|
|
247
240
|
var q = query.trim().toLowerCase();
|
|
248
241
|
var visible = sections.map(function(s) {
|
|
249
242
|
if (!q) return s;
|
|
@@ -257,11 +250,8 @@ var SettingsModal = function SettingsModal(props) {
|
|
|
257
250
|
}).filter(function(s) { return s.rows.length > 0; });
|
|
258
251
|
|
|
259
252
|
return React.createElement(
|
|
260
|
-
|
|
261
|
-
{ className: 'ide-settings-
|
|
262
|
-
React.createElement(
|
|
263
|
-
'div',
|
|
264
|
-
{ className: 'ide-settings-modal', onClick: function(e) { e.stopPropagation(); } },
|
|
253
|
+
window.ModalDialog,
|
|
254
|
+
{ className: 'ide-settings-modal', dialogClassName: 'mb-dialog-light', label: 'Settings', onDismiss: onClose },
|
|
265
255
|
React.createElement(
|
|
266
256
|
'div', { className: 'ide-settings-modal-header' },
|
|
267
257
|
React.createElement('span', { className: 'ide-settings-modal-title' }, 'Settings'),
|
|
@@ -269,7 +259,7 @@ var SettingsModal = function SettingsModal(props) {
|
|
|
269
259
|
type: 'search',
|
|
270
260
|
className: 'ide-settings-search',
|
|
271
261
|
placeholder: 'Search settings',
|
|
272
|
-
|
|
262
|
+
'data-autofocus': true,
|
|
273
263
|
value: query,
|
|
274
264
|
onChange: function(e) { setQuery(e.target.value); }
|
|
275
265
|
}),
|
|
@@ -335,7 +325,6 @@ var SettingsModal = function SettingsModal(props) {
|
|
|
335
325
|
)
|
|
336
326
|
)
|
|
337
327
|
)
|
|
338
|
-
)
|
|
339
328
|
);
|
|
340
329
|
};
|
|
341
330
|
|
|
@@ -2,23 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
// ShortcutHelp — isolated module.
|
|
4
4
|
// Renders a centred overlay listing all keyboard shortcuts and usage tips.
|
|
5
|
-
// Dismissable with the × button, clicking the backdrop, or Escape
|
|
6
|
-
// Mount/unmount is controlled entirely by the parent (showHelp
|
|
5
|
+
// Dismissable with the × button, clicking the backdrop, or Escape (all via
|
|
6
|
+
// ModalDialog). Mount/unmount is controlled entirely by the parent (showHelp).
|
|
7
7
|
|
|
8
8
|
var ShortcutHelp = function ShortcutHelp(_ref) {
|
|
9
9
|
var onClose = _ref.onClose;
|
|
10
10
|
|
|
11
|
-
var _React = React;
|
|
12
|
-
var useEffect = _React.useEffect;
|
|
13
|
-
|
|
14
|
-
useEffect(function () {
|
|
15
|
-
function onKeyDown(e) {
|
|
16
|
-
if (e.key === 'Escape') onClose();
|
|
17
|
-
}
|
|
18
|
-
window.addEventListener('keydown', onKeyDown);
|
|
19
|
-
return function () { window.removeEventListener('keydown', onKeyDown); };
|
|
20
|
-
}, [onClose]);
|
|
21
|
-
|
|
22
11
|
function Section(props) {
|
|
23
12
|
return React.createElement(
|
|
24
13
|
'div',
|
|
@@ -52,17 +41,8 @@ var ShortcutHelp = function ShortcutHelp(_ref) {
|
|
|
52
41
|
}
|
|
53
42
|
|
|
54
43
|
return React.createElement(
|
|
55
|
-
|
|
56
|
-
{ className: 'shelp-
|
|
57
|
-
React.createElement(
|
|
58
|
-
'div',
|
|
59
|
-
{
|
|
60
|
-
className: 'shelp-panel',
|
|
61
|
-
onClick: function (e) { e.stopPropagation(); },
|
|
62
|
-
role: 'dialog',
|
|
63
|
-
'aria-modal': 'true',
|
|
64
|
-
'aria-label': 'Keyboard shortcuts and help'
|
|
65
|
-
},
|
|
44
|
+
window.ModalDialog,
|
|
45
|
+
{ className: 'shelp-panel', label: 'Keyboard shortcuts and help', onDismiss: onClose },
|
|
66
46
|
React.createElement(
|
|
67
47
|
'div',
|
|
68
48
|
{ className: 'shelp-header' },
|
|
@@ -191,7 +171,7 @@ var ShortcutHelp = function ShortcutHelp(_ref) {
|
|
|
191
171
|
Tips,
|
|
192
172
|
{
|
|
193
173
|
items: [
|
|
194
|
-
'Combined View: Ctrl/Cmd-click several files or folders, right-click, "Open in Combined View" — every file on one page with Copy and Download',
|
|
174
|
+
'Combined View: Ctrl/Cmd-click several files or folders, right-click, "Open in Combined View" — every file on one page with Copy and Download. The stacked-layers icon on OPEN EDITORS does the same for all open files',
|
|
195
175
|
'Pick methods: in Combined View, tick methods under a Ruby file to send only those; "Download .md" / "Copy .md" bundles everything into one attachment',
|
|
196
176
|
'Paste & Place: right-click inside a Ruby file (or F1) → "Paste & Place Ruby Method...", paste the reply, "Find placement", check the diff, "Apply to editor" — then save; Ctrl+Z undoes',
|
|
197
177
|
'Upload compare: drop or upload a file over an existing one and click "Compare" to see the diff before choosing Skip / Keep both / Overwrite'
|
|
@@ -202,6 +182,5 @@ var ShortcutHelp = function ShortcutHelp(_ref) {
|
|
|
202
182
|
)
|
|
203
183
|
)
|
|
204
184
|
)
|
|
205
|
-
)
|
|
206
185
|
);
|
|
207
186
|
};
|