/*!***********************!*\
!*** ./src/cursor.ts ***!
\***********************/
-/***/ ((__unused_webpack_module, exports) => {
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Cursor = void 0;
+const dom_1 = __webpack_require__(/*! dom */ "./src/dom.ts");
class Cursor {
constructor() {
}
const el = document.querySelector(elementId);
if (el) {
el.classList.add('cursor');
- if (!this.isVisible(elementId)) {
+ if (!(0, dom_1.isVisible)(el)) {
el.scrollIntoView(true);
}
}
isNodeExpanded() {
return this.get().classList.contains('expanded');
}
- isVisible(elementId) {
- const el = document.querySelector(elementId);
- var rect = el.getBoundingClientRect();
- return (rect.top >= 0 &&
- rect.left >= 0 &&
- rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
- rect.right <= (window.innerWidth || document.documentElement.clientWidth));
- }
}
exports.Cursor = Cursor;
+/***/ }),
+
+/***/ "./src/dom.ts":
+/*!********************!*\
+ !*** ./src/dom.ts ***!
+ \********************/
+/***/ ((__unused_webpack_module, exports) => {
+
+"use strict";
+
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.isVisible = void 0;
+function isVisible(element) {
+ const rect = element.getBoundingClientRect();
+ return (rect.top >= 0 &&
+ rect.left >= 0 &&
+ rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
+ rect.right <= (window.innerWidth || document.documentElement.clientWidth));
+}
+exports.isVisible = isVisible;
+
+
/***/ }),
/***/ "./src/help.ts":
const lyra_1 = __webpack_require__(/*! @lyrasearch/lyra */ "./node_modules/@lyrasearch/lyra/dist/cjs/index.cjs");
const lodash_1 = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
const keyboardjs_1 = __importDefault(__webpack_require__(/*! keyboardjs */ "./node_modules/keyboardjs/dist/keyboard.js"));
+const dom_1 = __webpack_require__(/*! dom */ "./src/dom.ts");
const searchModal = `
<div class="modal">
<div class="modal-content" id="search">
keyboardjs_1.default.setContext('navigation');
});
keyboardjs_1.default.bind('down', e => {
+ e.preventDefault();
document.getElementById('search-query').blur();
const el = document.querySelector('.search-result.selected');
if (el.nextElementSibling) {
el.classList.remove('selected');
el.nextElementSibling.classList.add('selected');
+ if (!(0, dom_1.isVisible)(el.nextElementSibling)) {
+ el.nextElementSibling.scrollIntoView();
+ }
}
});
- keyboardjs_1.default.bind('up', () => {
+ keyboardjs_1.default.bind('up', e => {
+ e.preventDefault();
const el = document.querySelector('.search-result.selected');
if (el.previousElementSibling) {
el.classList.remove('selected');
el.previousElementSibling.classList.add('selected');
+ if (!(0, dom_1.isVisible)(el.previousElementSibling)) {
+ el.previousElementSibling.scrollIntoView();
+ }
}
});
keyboardjs_1.default.bind('enter', e => {
+import {isVisible} from "dom";
+
export class Cursor {
constructor() {
set(elementId: string) {
this.unset();
- const el = document.querySelector(elementId);
+ const el = document.querySelector(elementId) as HTMLElement;
if(el) {
el.classList.add('cursor');
- if(!this.isVisible(elementId)) {
+ if(!isVisible(el)) {
el.scrollIntoView(true);
}
}
isNodeExpanded(): boolean {
return this.get().classList.contains('expanded');
}
-
- isVisible(elementId: string) {
- const el = document.querySelector(elementId) as HTMLElement;
- var rect = el.getBoundingClientRect();
- return (
- rect.top >= 0 &&
- rect.left >= 0 &&
- rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
- rect.right <= (window.innerWidth || document.documentElement.clientWidth)
- );
- }
}
import { map } from 'lodash';
import { OutlineNode } from 'outline';
import keyboardJS from 'keyboardjs';
+import {isVisible} from 'dom';
const searchModal = `
<div class="modal">
});
keyboardJS.bind('down', e => {
+ e.preventDefault();
document.getElementById('search-query').blur();
const el = document.querySelector('.search-result.selected');
if(el.nextElementSibling) {
el.classList.remove('selected');
el.nextElementSibling.classList.add('selected');
+ if(!isVisible(el.nextElementSibling as HTMLElement)) {
+ el.nextElementSibling.scrollIntoView();
+ }
}
});
- keyboardJS.bind('up', () => {
+ keyboardJS.bind('up', e => {
+ e.preventDefault();
const el = document.querySelector('.search-result.selected');
if(el.previousElementSibling) {
el.classList.remove('selected');
el.previousElementSibling.classList.add('selected');
+ if(!isVisible(el.previousElementSibling as HTMLElement)) {
+ el.previousElementSibling.scrollIntoView();
+ }
}
})