@happy-nut/monacori 0.1.15 → 0.1.16
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/dist/viewer.client.js +16 -0
- package/package.json +1 -1
package/dist/viewer.client.js
CHANGED
|
@@ -1008,6 +1008,15 @@ function handleTreeKey(event) {
|
|
|
1008
1008
|
return false;
|
|
1009
1009
|
}
|
|
1010
1010
|
|
|
1011
|
+
// d2h-file-side-diff is a HORIZONTAL scrollport (overflow-x:auto), so the browser swallows VERTICAL wheel
|
|
1012
|
+
// there instead of bubbling it to #diff2html-container — the diff wouldn't scroll by mouse wheel at all.
|
|
1013
|
+
// Redirect vertical wheel to the container; leave horizontal wheel (deltaX) for the side's own h-scroll.
|
|
1014
|
+
(function () {
|
|
1015
|
+
var dsc = document.getElementById('diff2html-container');
|
|
1016
|
+
if (dsc) dsc.addEventListener('wheel', function (e) {
|
|
1017
|
+
if (Math.abs(e.deltaY) >= Math.abs(e.deltaX) && e.deltaY !== 0) { dsc.scrollTop += e.deltaY; e.preventDefault(); }
|
|
1018
|
+
}, { passive: false });
|
|
1019
|
+
})();
|
|
1011
1020
|
document.addEventListener('keydown', (event) => {
|
|
1012
1021
|
if (!quickOpen?.classList.contains('hidden')) {
|
|
1013
1022
|
if (handleQuickOpenKey(event)) return;
|
|
@@ -1114,6 +1123,13 @@ document.addEventListener('keydown', (event) => {
|
|
|
1114
1123
|
}
|
|
1115
1124
|
}
|
|
1116
1125
|
|
|
1126
|
+
// PageUp/Down scroll the diff/source view. There's no focusable scroller (the diff caret is a JS cursor),
|
|
1127
|
+
// and d2h-file-side-diff's horizontal scrollport even swallows vertical wheel, so handle paging explicitly.
|
|
1128
|
+
// Only when the tree isn't focused — the tree pages itself in handleTreeKey below.
|
|
1129
|
+
if (treeFocusIndex < 0 && (event.key === 'PageDown' || event.key === 'PageUp') && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
|
1130
|
+
var psc = isDiffViewVisible() ? document.getElementById('diff2html-container') : (isSourceViewerVisible() ? document.getElementById('source-body') : null);
|
|
1131
|
+
if (psc) { event.preventDefault(); psc.scrollTop += (event.key === 'PageDown' ? 0.9 : -0.9) * psc.clientHeight; return; }
|
|
1132
|
+
}
|
|
1117
1133
|
if (treeFocusIndex >= 0 && handleTreeKey(event)) return;
|
|
1118
1134
|
if (treeFocusIndex < 0 && !event.metaKey && !event.ctrlKey && !event.altKey && isSourceViewerVisible() && handleSourceCaretKey(event)) return;
|
|
1119
1135
|
if (treeFocusIndex < 0 && !event.metaKey && !event.ctrlKey && !event.altKey && isDiffViewVisible() && handleDiffCaretKey(event)) return;
|