@difizen/libro-search 0.1.0 → 0.1.2
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/es/abstract-search-provider.d.ts +2 -1
- package/es/abstract-search-provider.d.ts.map +1 -1
- package/es/index.less +10 -8
- package/es/libro-search-engine-text.d.ts +1 -1
- package/es/libro-search-generic-provider.d.ts +5 -4
- package/es/libro-search-generic-provider.d.ts.map +1 -1
- package/es/libro-search-generic-provider.js +11 -11
- package/es/libro-search-manager.d.ts +1 -1
- package/es/libro-search-manager.d.ts.map +1 -1
- package/es/libro-search-manager.js +3 -3
- package/es/libro-search-model.d.ts +4 -4
- package/es/libro-search-model.d.ts.map +1 -1
- package/es/libro-search-model.js +19 -9
- package/es/libro-search-protocol.d.ts +1 -13
- package/es/libro-search-protocol.d.ts.map +1 -1
- package/es/libro-search-protocol.js +0 -5
- package/es/libro-search-provider.d.ts +11 -7
- package/es/libro-search-provider.d.ts.map +1 -1
- package/es/libro-search-provider.js +70 -13
- package/es/libro-search-utils.d.ts +1 -1
- package/es/libro-search-utils.d.ts.map +1 -1
- package/es/libro-search-utils.js +11 -7
- package/es/libro-search-view.d.ts +11 -11
- package/es/libro-search-view.d.ts.map +1 -1
- package/es/libro-search-view.js +136 -79
- package/package.json +4 -3
- package/src/abstract-search-provider.ts +1 -2
- package/src/index.less +10 -8
- package/src/libro-search-engine-text.ts +1 -1
- package/src/libro-search-generic-provider.ts +6 -6
- package/src/libro-search-manager.ts +4 -3
- package/src/libro-search-model.ts +10 -11
- package/src/libro-search-protocol.ts +1 -16
- package/src/libro-search-provider.ts +88 -41
- package/src/libro-search-utils.spec.ts +2 -2
- package/src/libro-search-utils.ts +11 -9
- package/src/libro-search-view.tsx +63 -43
package/es/libro-search-view.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8;
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
6
|
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
8
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
@@ -15,13 +18,13 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
15
18
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
16
19
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
17
20
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
18
|
-
import {
|
|
21
|
+
import { ArrowDownOutlined, ArrowUpOutlined, CloseOutlined, createFromIconfontCN, EllipsisOutlined, RightOutlined } from '@ant-design/icons';
|
|
19
22
|
import { LirboContextKey } from '@difizen/libro-core';
|
|
20
|
-
import { prop, useInject } from '@difizen/mana-app';
|
|
23
|
+
import { prop, useInject, watch } from '@difizen/mana-app';
|
|
21
24
|
import { BaseView, view, ViewInstance } from '@difizen/mana-app';
|
|
22
25
|
import { inject, transient } from '@difizen/mana-app';
|
|
23
26
|
import { l10n } from '@difizen/mana-l10n';
|
|
24
|
-
import {
|
|
27
|
+
import { Button, Checkbox, Input, Tag } from 'antd';
|
|
25
28
|
import classnames from 'classnames';
|
|
26
29
|
import { forwardRef, useEffect, useRef } from 'react';
|
|
27
30
|
import { LibroSearchProviderFactory } from "./libro-search-provider.js";
|
|
@@ -45,11 +48,15 @@ export var ReplaceToggle = function ReplaceToggle() {
|
|
|
45
48
|
});
|
|
46
49
|
};
|
|
47
50
|
export var SearchIndex = function SearchIndex() {
|
|
48
|
-
var _instance$currentMatc, _instance$matchesCoun;
|
|
49
51
|
var instance = useInject(ViewInstance);
|
|
50
|
-
|
|
52
|
+
|
|
53
|
+
// TODO: trigger update when current match index changed, matchesCount dont work
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
//
|
|
56
|
+
}, [instance.currentMatchIndex]);
|
|
57
|
+
return /*#__PURE__*/_jsx("div", {
|
|
51
58
|
className: "libro-search-index",
|
|
52
|
-
children:
|
|
59
|
+
children: instance.matchesCount !== undefined ? "".concat(instance.currentMatchIndex, "/").concat(instance.matchesCount) : '无结果'
|
|
53
60
|
});
|
|
54
61
|
};
|
|
55
62
|
export var SearchContent = function SearchContent() {
|
|
@@ -87,6 +94,7 @@ export var SearchContent = function SearchContent() {
|
|
|
87
94
|
value: instance.findStr,
|
|
88
95
|
onChange: instance.handleFindChange,
|
|
89
96
|
size: "small",
|
|
97
|
+
placeholder: "\u641C\u7D22",
|
|
90
98
|
suffix: /*#__PURE__*/_jsxs("span", {
|
|
91
99
|
className: "libro-search-input-suffix",
|
|
92
100
|
children: [/*#__PURE__*/_jsx(IconFont, {
|
|
@@ -94,13 +102,15 @@ export var SearchContent = function SearchContent() {
|
|
|
94
102
|
'libro-search-input-suffix-active': instance.caseSensitive
|
|
95
103
|
}),
|
|
96
104
|
onClick: instance.toggleCaseSensitive,
|
|
97
|
-
type: "icon-Aa"
|
|
105
|
+
type: "icon-Aa",
|
|
106
|
+
title: "Match Case"
|
|
98
107
|
}), /*#__PURE__*/_jsx(IconFont, {
|
|
99
108
|
className: classnames({
|
|
100
109
|
'libro-search-input-suffix-active': instance.useRegex
|
|
101
110
|
}),
|
|
102
111
|
onClick: instance.toggleUseRegex,
|
|
103
|
-
type: "icon-zhengzeshi"
|
|
112
|
+
type: "icon-zhengzeshi",
|
|
113
|
+
title: "Use Regular Expression"
|
|
104
114
|
})]
|
|
105
115
|
})
|
|
106
116
|
})
|
|
@@ -108,10 +118,12 @@ export var SearchContent = function SearchContent() {
|
|
|
108
118
|
className: "libro-search-action",
|
|
109
119
|
children: [/*#__PURE__*/_jsx(SearchIndex, {}), /*#__PURE__*/_jsxs("div", {
|
|
110
120
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
121
|
+
title: "Previous Match",
|
|
111
122
|
onClick: instance.previous,
|
|
112
123
|
icon: /*#__PURE__*/_jsx(ArrowUpOutlined, {}),
|
|
113
124
|
size: "small"
|
|
114
125
|
}), /*#__PURE__*/_jsx(Button, {
|
|
126
|
+
title: "Next Match",
|
|
115
127
|
onClick: instance.next,
|
|
116
128
|
icon: /*#__PURE__*/_jsx(ArrowDownOutlined, {}),
|
|
117
129
|
size: "small"
|
|
@@ -133,7 +145,8 @@ export var SearchContent = function SearchContent() {
|
|
|
133
145
|
children: /*#__PURE__*/_jsx(Input, {
|
|
134
146
|
value: instance.replaceStr,
|
|
135
147
|
onChange: instance.handleReplaceChange,
|
|
136
|
-
size: "small"
|
|
148
|
+
size: "small",
|
|
149
|
+
placeholder: "\u66FF\u6362"
|
|
137
150
|
})
|
|
138
151
|
}), /*#__PURE__*/_jsx("td", {
|
|
139
152
|
className: "libro-search-action",
|
|
@@ -143,13 +156,15 @@ export var SearchContent = function SearchContent() {
|
|
|
143
156
|
icon: /*#__PURE__*/_jsx(IconFont, {
|
|
144
157
|
type: "icon-zifuchuantihuan_2"
|
|
145
158
|
}),
|
|
146
|
-
size: "small"
|
|
159
|
+
size: "small",
|
|
160
|
+
title: "Replace"
|
|
147
161
|
}), /*#__PURE__*/_jsx(Button, {
|
|
148
162
|
onClick: instance.replaceAll,
|
|
149
163
|
icon: /*#__PURE__*/_jsx(IconFont, {
|
|
150
164
|
type: "icon-tihuantupian"
|
|
151
165
|
}),
|
|
152
|
-
size: "small"
|
|
166
|
+
size: "small",
|
|
167
|
+
title: "Replace All"
|
|
153
168
|
})]
|
|
154
169
|
})
|
|
155
170
|
})]
|
|
@@ -169,7 +184,7 @@ export var SearchContent = function SearchContent() {
|
|
|
169
184
|
});
|
|
170
185
|
};
|
|
171
186
|
// TODO: 更改图标
|
|
172
|
-
export var SearchComponent = /*#__PURE__*/forwardRef(function SearchComponent(
|
|
187
|
+
export var SearchComponent = /*#__PURE__*/forwardRef(function SearchComponent(props, ref) {
|
|
173
188
|
var instance = useInject(ViewInstance);
|
|
174
189
|
return /*#__PURE__*/_jsx("div", {
|
|
175
190
|
tabIndex: 1,
|
|
@@ -185,26 +200,66 @@ export var SearchComponent = /*#__PURE__*/forwardRef(function SearchComponent(_p
|
|
|
185
200
|
children: instance.searchVisible && /*#__PURE__*/_jsx(SearchContent, {})
|
|
186
201
|
});
|
|
187
202
|
});
|
|
188
|
-
export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-view'), _dec3 =
|
|
203
|
+
export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-view'), _dec3 = inject(LirboContextKey), _dec4 = inject(LibroSearchUtils), _dec5 = inject(LibroSearchProviderFactory), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec9 = prop(), _dec10 = prop(), _dec11 = prop(), _dec12 = prop(), _dec13 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
|
|
189
204
|
_inherits(LibroSearchView, _BaseView);
|
|
190
205
|
var _super = _createSuper(LibroSearchView);
|
|
191
|
-
function LibroSearchView(
|
|
206
|
+
function LibroSearchView() {
|
|
192
207
|
var _this;
|
|
193
208
|
_classCallCheck(this, LibroSearchView);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
_initializerDefineProperty(_this, "
|
|
199
|
-
_initializerDefineProperty(_this, "
|
|
200
|
-
_initializerDefineProperty(_this, "
|
|
201
|
-
_initializerDefineProperty(_this, "
|
|
202
|
-
_initializerDefineProperty(_this, "
|
|
209
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
210
|
+
args[_key] = arguments[_key];
|
|
211
|
+
}
|
|
212
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
213
|
+
_initializerDefineProperty(_this, "contextKey", _descriptor, _assertThisInitialized(_this));
|
|
214
|
+
_initializerDefineProperty(_this, "utils", _descriptor2, _assertThisInitialized(_this));
|
|
215
|
+
_initializerDefineProperty(_this, "searchProviderFactory", _descriptor3, _assertThisInitialized(_this));
|
|
216
|
+
_initializerDefineProperty(_this, "searchProvider", _descriptor4, _assertThisInitialized(_this));
|
|
217
|
+
_initializerDefineProperty(_this, "searchVisible", _descriptor5, _assertThisInitialized(_this));
|
|
218
|
+
_initializerDefineProperty(_this, "settingVisible", _descriptor6, _assertThisInitialized(_this));
|
|
219
|
+
_initializerDefineProperty(_this, "findStr", _descriptor7, _assertThisInitialized(_this));
|
|
220
|
+
_initializerDefineProperty(_this, "lastSearch", _descriptor8, _assertThisInitialized(_this));
|
|
221
|
+
_initializerDefineProperty(_this, "replaceStr", _descriptor9, _assertThisInitialized(_this));
|
|
222
|
+
_initializerDefineProperty(_this, "caseSensitive", _descriptor10, _assertThisInitialized(_this));
|
|
223
|
+
_initializerDefineProperty(_this, "useRegex", _descriptor11, _assertThisInitialized(_this));
|
|
203
224
|
_this.view = SearchComponent;
|
|
204
|
-
_this.
|
|
205
|
-
|
|
206
|
-
|
|
225
|
+
_this.onViewMount = function () {
|
|
226
|
+
if (!_this.searchProvider && _this.libro) {
|
|
227
|
+
_this.searchProvider = _this.searchProviderFactory({
|
|
228
|
+
view: _this.libro
|
|
229
|
+
});
|
|
230
|
+
_this.toDispose.push(watch(_this.libro.model, 'active', _this.onActiveCellChanged));
|
|
231
|
+
_this.toDispose.push(_this.libro.model.onSourceChanged(function () {
|
|
232
|
+
return _this.onCellsChanged();
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
_this.onActiveCellChanged = function () {
|
|
237
|
+
if (_this.searchVisible) {
|
|
238
|
+
var _this$searchProvider;
|
|
239
|
+
(_this$searchProvider = _this.searchProvider) === null || _this$searchProvider === void 0 || _this$searchProvider.onActiveCellChanged();
|
|
240
|
+
}
|
|
207
241
|
};
|
|
242
|
+
_this.onCellsChanged = function () {
|
|
243
|
+
if (_this.searchVisible) {
|
|
244
|
+
var _this$searchProvider2;
|
|
245
|
+
(_this$searchProvider2 = _this.searchProvider) === null || _this$searchProvider2 === void 0 || _this$searchProvider2.onCellsChanged();
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
_this.onviewWillUnmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
249
|
+
var _this$searchProvider3, _this$searchProvider4;
|
|
250
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
251
|
+
while (1) switch (_context.prev = _context.next) {
|
|
252
|
+
case 0:
|
|
253
|
+
_context.next = 2;
|
|
254
|
+
return (_this$searchProvider3 = _this.searchProvider) === null || _this$searchProvider3 === void 0 ? void 0 : _this$searchProvider3.endQuery();
|
|
255
|
+
case 2:
|
|
256
|
+
(_this$searchProvider4 = _this.searchProvider) === null || _this$searchProvider4 === void 0 || _this$searchProvider4.dispose();
|
|
257
|
+
case 3:
|
|
258
|
+
case "end":
|
|
259
|
+
return _context.stop();
|
|
260
|
+
}
|
|
261
|
+
}, _callee);
|
|
262
|
+
}));
|
|
208
263
|
_this.show = function () {
|
|
209
264
|
var _this$findInputRef;
|
|
210
265
|
_this.contextKey.disableCommandMode();
|
|
@@ -213,10 +268,13 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
213
268
|
(_this$findInputRef = _this.findInputRef) === null || _this$findInputRef === void 0 || (_this$findInputRef = _this$findInputRef.current) === null || _this$findInputRef === void 0 || _this$findInputRef.focus();
|
|
214
269
|
};
|
|
215
270
|
_this.hide = function () {
|
|
216
|
-
var _this$
|
|
271
|
+
var _this$searchProvider5, _this$libro;
|
|
217
272
|
_this.searchVisible = false;
|
|
218
273
|
_this.contextKey.enableCommandMode();
|
|
219
|
-
(_this$
|
|
274
|
+
(_this$searchProvider5 = _this.searchProvider) === null || _this$searchProvider5 === void 0 || _this$searchProvider5.endQuery();
|
|
275
|
+
if (_this.searchProvider) {
|
|
276
|
+
_this.searchProvider.replaceMode = false;
|
|
277
|
+
}
|
|
220
278
|
(_this$libro = _this.libro) === null || _this$libro === void 0 || _this$libro.focus();
|
|
221
279
|
};
|
|
222
280
|
_this.onFocus = function () {
|
|
@@ -234,11 +292,11 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
234
292
|
_this.lastSearch = _this.findStr;
|
|
235
293
|
var query = _this.utils.parseQuery(_this.findStr || '', _this.caseSensitive, _this.useRegex);
|
|
236
294
|
if (query) {
|
|
237
|
-
var _this$
|
|
238
|
-
(_this$
|
|
295
|
+
var _this$searchProvider6;
|
|
296
|
+
(_this$searchProvider6 = _this.searchProvider) === null || _this$searchProvider6 === void 0 || _this$searchProvider6.startQuery(query, undefined, hightlightNext);
|
|
239
297
|
} else {
|
|
240
|
-
var _this$
|
|
241
|
-
(_this$
|
|
298
|
+
var _this$searchProvider7;
|
|
299
|
+
(_this$searchProvider7 = _this.searchProvider) === null || _this$searchProvider7 === void 0 || _this$searchProvider7.endQuery();
|
|
242
300
|
}
|
|
243
301
|
}
|
|
244
302
|
};
|
|
@@ -258,14 +316,15 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
258
316
|
};
|
|
259
317
|
_this.toggleUseRegex = function () {
|
|
260
318
|
_this.useRegex = !_this.useRegex;
|
|
319
|
+
_this.search();
|
|
261
320
|
};
|
|
262
321
|
_this.next = function () {
|
|
263
|
-
var _this$
|
|
264
|
-
(_this$
|
|
322
|
+
var _this$searchProvider8;
|
|
323
|
+
(_this$searchProvider8 = _this.searchProvider) === null || _this$searchProvider8 === void 0 || _this$searchProvider8.highlightNext();
|
|
265
324
|
};
|
|
266
325
|
_this.previous = function () {
|
|
267
|
-
var _this$
|
|
268
|
-
(_this$
|
|
326
|
+
var _this$searchProvider9;
|
|
327
|
+
(_this$searchProvider9 = _this.searchProvider) === null || _this$searchProvider9 === void 0 || _this$searchProvider9.highlightPrevious();
|
|
269
328
|
};
|
|
270
329
|
_this.searchCellOutputChange = function (e) {
|
|
271
330
|
if (_this.searchProvider) {
|
|
@@ -273,20 +332,20 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
273
332
|
}
|
|
274
333
|
};
|
|
275
334
|
_this.replace = function () {
|
|
276
|
-
var _this$
|
|
277
|
-
(_this$
|
|
335
|
+
var _this$searchProvider10;
|
|
336
|
+
(_this$searchProvider10 = _this.searchProvider) === null || _this$searchProvider10 === void 0 || _this$searchProvider10.replaceCurrentMatch(_this.replaceStr);
|
|
278
337
|
};
|
|
279
338
|
_this.replaceAll = function () {
|
|
280
|
-
var _this$
|
|
281
|
-
(_this$
|
|
339
|
+
var _this$searchProvider11;
|
|
340
|
+
(_this$searchProvider11 = _this.searchProvider) === null || _this$searchProvider11 === void 0 || _this$searchProvider11.replaceAllMatches(_this.replaceStr);
|
|
282
341
|
};
|
|
283
342
|
_this.initialQuery = function () {
|
|
284
|
-
var _this$
|
|
285
|
-
var init = (_this$
|
|
343
|
+
var _this$searchProvider12;
|
|
344
|
+
var init = (_this$searchProvider12 = _this.searchProvider) === null || _this$searchProvider12 === void 0 ? void 0 : _this$searchProvider12.getInitialQuery();
|
|
286
345
|
if (init) {
|
|
287
346
|
_this.findStr = init;
|
|
288
|
-
_this.search(false);
|
|
289
347
|
}
|
|
348
|
+
_this.search(false);
|
|
290
349
|
};
|
|
291
350
|
_this.getHeaderHeight = function () {
|
|
292
351
|
var _this$libro3;
|
|
@@ -302,11 +361,11 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
302
361
|
};
|
|
303
362
|
_this.nextMatch = function (reverse) {
|
|
304
363
|
if (reverse) {
|
|
305
|
-
var _this$
|
|
306
|
-
(_this$
|
|
364
|
+
var _this$searchProvider13;
|
|
365
|
+
(_this$searchProvider13 = _this.searchProvider) === null || _this$searchProvider13 === void 0 || _this$searchProvider13.highlightPrevious();
|
|
307
366
|
} else {
|
|
308
|
-
var _this$
|
|
309
|
-
(_this$
|
|
367
|
+
var _this$searchProvider14;
|
|
368
|
+
(_this$searchProvider14 = _this.searchProvider) === null || _this$searchProvider14 === void 0 || _this$searchProvider14.highlightNext();
|
|
310
369
|
}
|
|
311
370
|
};
|
|
312
371
|
_this.handleKeydown = function (e) {
|
|
@@ -343,30 +402,13 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
343
402
|
_this.handleReplaceChange = function (e) {
|
|
344
403
|
_this.replaceStr = e.target.value;
|
|
345
404
|
};
|
|
346
|
-
_this.contextKey = contextKey;
|
|
347
|
-
_this.utils = utils;
|
|
348
|
-
_this.searchProviderFactory = searchProviderFactory;
|
|
349
405
|
return _this;
|
|
350
406
|
}
|
|
351
|
-
LibroSearchView = inject(LibroSearchProviderFactory)(LibroSearchView, undefined, 2) || LibroSearchView;
|
|
352
|
-
LibroSearchView = inject(LibroSearchUtils)(LibroSearchView, undefined, 1) || LibroSearchView;
|
|
353
|
-
LibroSearchView = inject(LirboContextKey)(LibroSearchView, undefined, 0) || LibroSearchView;
|
|
354
407
|
_createClass(LibroSearchView, [{
|
|
355
|
-
key: "libro",
|
|
356
|
-
get: function get() {
|
|
357
|
-
return this._libro;
|
|
358
|
-
},
|
|
359
|
-
set: function set(value) {
|
|
360
|
-
this._libro = value;
|
|
361
|
-
this.searchProvider = this.searchProviderFactory({
|
|
362
|
-
view: this.libro
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
}, {
|
|
366
408
|
key: "replaceVisible",
|
|
367
409
|
get: function get() {
|
|
368
|
-
var _this$searchProvider$, _this$
|
|
369
|
-
return (_this$searchProvider$ = (_this$
|
|
410
|
+
var _this$searchProvider$, _this$searchProvider15;
|
|
411
|
+
return (_this$searchProvider$ = (_this$searchProvider15 = this.searchProvider) === null || _this$searchProvider15 === void 0 ? void 0 : _this$searchProvider15.replaceMode) !== null && _this$searchProvider$ !== void 0 ? _this$searchProvider$ : false;
|
|
370
412
|
}
|
|
371
413
|
}, {
|
|
372
414
|
key: "contentHeight",
|
|
@@ -383,8 +425,8 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
383
425
|
}, {
|
|
384
426
|
key: "currentMatchIndex",
|
|
385
427
|
get: function get() {
|
|
386
|
-
var _this$
|
|
387
|
-
var current = (_this$
|
|
428
|
+
var _this$searchProvider16;
|
|
429
|
+
var current = (_this$searchProvider16 = this.searchProvider) === null || _this$searchProvider16 === void 0 ? void 0 : _this$searchProvider16.currentMatchIndex;
|
|
388
430
|
if (current !== undefined) {
|
|
389
431
|
return current + 1;
|
|
390
432
|
}
|
|
@@ -393,59 +435,74 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
393
435
|
}, {
|
|
394
436
|
key: "matchesCount",
|
|
395
437
|
get: function get() {
|
|
396
|
-
var _this$
|
|
397
|
-
return (_this$
|
|
438
|
+
var _this$searchProvider17;
|
|
439
|
+
return (_this$searchProvider17 = this.searchProvider) === null || _this$searchProvider17 === void 0 ? void 0 : _this$searchProvider17.matchesCount;
|
|
398
440
|
}
|
|
399
441
|
}]);
|
|
400
442
|
return LibroSearchView;
|
|
401
|
-
}(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "
|
|
443
|
+
}(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "contextKey", [_dec3], {
|
|
444
|
+
configurable: true,
|
|
445
|
+
enumerable: true,
|
|
446
|
+
writable: true,
|
|
447
|
+
initializer: null
|
|
448
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "utils", [_dec4], {
|
|
449
|
+
configurable: true,
|
|
450
|
+
enumerable: true,
|
|
451
|
+
writable: true,
|
|
452
|
+
initializer: null
|
|
453
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "searchProviderFactory", [_dec5], {
|
|
454
|
+
configurable: true,
|
|
455
|
+
enumerable: true,
|
|
456
|
+
writable: true,
|
|
457
|
+
initializer: null
|
|
458
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "searchProvider", [_dec6], {
|
|
402
459
|
configurable: true,
|
|
403
460
|
enumerable: true,
|
|
404
461
|
writable: true,
|
|
405
462
|
initializer: null
|
|
406
|
-
}),
|
|
463
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "searchVisible", [_dec7], {
|
|
407
464
|
configurable: true,
|
|
408
465
|
enumerable: true,
|
|
409
466
|
writable: true,
|
|
410
467
|
initializer: function initializer() {
|
|
411
468
|
return false;
|
|
412
469
|
}
|
|
413
|
-
}),
|
|
470
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "settingVisible", [_dec8], {
|
|
414
471
|
configurable: true,
|
|
415
472
|
enumerable: true,
|
|
416
473
|
writable: true,
|
|
417
474
|
initializer: function initializer() {
|
|
418
475
|
return false;
|
|
419
476
|
}
|
|
420
|
-
}),
|
|
477
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "findStr", [_dec9], {
|
|
421
478
|
configurable: true,
|
|
422
479
|
enumerable: true,
|
|
423
480
|
writable: true,
|
|
424
481
|
initializer: function initializer() {
|
|
425
482
|
return undefined;
|
|
426
483
|
}
|
|
427
|
-
}),
|
|
484
|
+
}), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "lastSearch", [_dec10], {
|
|
428
485
|
configurable: true,
|
|
429
486
|
enumerable: true,
|
|
430
487
|
writable: true,
|
|
431
488
|
initializer: function initializer() {
|
|
432
489
|
return undefined;
|
|
433
490
|
}
|
|
434
|
-
}),
|
|
491
|
+
}), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "replaceStr", [_dec11], {
|
|
435
492
|
configurable: true,
|
|
436
493
|
enumerable: true,
|
|
437
494
|
writable: true,
|
|
438
495
|
initializer: function initializer() {
|
|
439
496
|
return '';
|
|
440
497
|
}
|
|
441
|
-
}),
|
|
498
|
+
}), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "caseSensitive", [_dec12], {
|
|
442
499
|
configurable: true,
|
|
443
500
|
enumerable: true,
|
|
444
501
|
writable: true,
|
|
445
502
|
initializer: function initializer() {
|
|
446
503
|
return false;
|
|
447
504
|
}
|
|
448
|
-
}),
|
|
505
|
+
}), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "useRegex", [_dec13], {
|
|
449
506
|
configurable: true,
|
|
450
507
|
enumerable: true,
|
|
451
508
|
writable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-search",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -36,8 +36,9 @@
|
|
|
36
36
|
"@difizen/mana-app": "latest",
|
|
37
37
|
"@difizen/mana-l10n": "latest",
|
|
38
38
|
"@ant-design/icons": "^5.1.0",
|
|
39
|
-
"@difizen/libro-common": "^0.1.
|
|
40
|
-
"@difizen/libro-core": "^0.1.
|
|
39
|
+
"@difizen/libro-common": "^0.1.2",
|
|
40
|
+
"@difizen/libro-core": "^0.1.2",
|
|
41
|
+
"@difizen/libro-code-editor": "^0.1.2",
|
|
41
42
|
"@types/lodash.debounce": "^4.0.7",
|
|
42
43
|
"classnames": "^2.3.2",
|
|
43
44
|
"lodash.debounce": "^4.0.8",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SearchMatch } from '@difizen/libro-code-editor';
|
|
1
2
|
import type { Event } from '@difizen/mana-app';
|
|
2
3
|
import type { View } from '@difizen/mana-app';
|
|
3
4
|
import { Emitter } from '@difizen/mana-app';
|
|
@@ -6,10 +7,8 @@ import { transient } from '@difizen/mana-app';
|
|
|
6
7
|
import type {
|
|
7
8
|
SearchFilter,
|
|
8
9
|
SearchFilters,
|
|
9
|
-
SearchMatch,
|
|
10
10
|
SearchProvider,
|
|
11
11
|
} from './libro-search-protocol.js';
|
|
12
|
-
|
|
13
12
|
/**
|
|
14
13
|
* Abstract class implementing the search provider interface.
|
|
15
14
|
*/
|
package/src/index.less
CHANGED
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 0;
|
|
4
4
|
right: 0;
|
|
5
|
-
box-shadow: 0 2px 2px 0 #7c68681a;
|
|
6
|
-
background-color: var(--mana-color-bg-elevated);
|
|
7
5
|
z-index: 2000;
|
|
6
|
+
background-color: var(--mana-color-bg-elevated);
|
|
7
|
+
box-shadow: 0 2px 2px 0 #7c68681a;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.libro-search-content {
|
|
11
11
|
display: flex;
|
|
12
12
|
align-items: center;
|
|
13
|
-
padding: 2px 6px;
|
|
14
13
|
min-width: 320px;
|
|
14
|
+
padding: 2px 6px;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.libro-search-row {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
18
20
|
height: 32px;
|
|
19
21
|
|
|
20
22
|
input {
|
|
@@ -22,18 +24,18 @@
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
.ant-btn {
|
|
27
|
+
margin-left: 4px;
|
|
25
28
|
border: none;
|
|
26
29
|
box-shadow: none;
|
|
27
|
-
margin-left: 4px;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
.libro-search-replace-toggle {
|
|
32
|
-
padding: 4px;
|
|
33
34
|
display: flex;
|
|
34
35
|
align-items: center;
|
|
35
36
|
height: 100%;
|
|
36
37
|
margin-right: 4px;
|
|
38
|
+
padding: 4px;
|
|
37
39
|
cursor: pointer;
|
|
38
40
|
|
|
39
41
|
&:hover {
|
|
@@ -42,8 +44,8 @@
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
.libro-search-input {
|
|
45
|
-
align-items: center;
|
|
46
47
|
flex: 1;
|
|
48
|
+
align-items: center;
|
|
47
49
|
|
|
48
50
|
.ant-input-affix-wrapper-sm {
|
|
49
51
|
margin-right: 4px;
|
|
@@ -67,12 +69,12 @@
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
.libro-search-index {
|
|
70
|
-
// width: 24px;
|
|
71
72
|
display: flex;
|
|
72
73
|
align-items: center;
|
|
73
74
|
justify-content: center;
|
|
74
|
-
|
|
75
|
+
width: 50px;
|
|
75
76
|
margin-right: 16px;
|
|
77
|
+
margin-left: 4px;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
.libro-search-action {
|
|
@@ -143,7 +143,7 @@ export class GenericSearchProvider extends AbstractSearchProvider {
|
|
|
143
143
|
*
|
|
144
144
|
* @returns A promise that resolves with a boolean indicating whether a replace occurred.
|
|
145
145
|
*/
|
|
146
|
-
async replaceCurrentMatch(
|
|
146
|
+
async replaceCurrentMatch(newText: string, loop?: boolean): Promise<boolean> {
|
|
147
147
|
return Promise.resolve(false);
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -154,7 +154,7 @@ export class GenericSearchProvider extends AbstractSearchProvider {
|
|
|
154
154
|
*
|
|
155
155
|
* @returns A promise that resolves with a boolean indicating whether a replace occurred.
|
|
156
156
|
*/
|
|
157
|
-
async replaceAllMatches(
|
|
157
|
+
async replaceAllMatches(newText: string): Promise<boolean> {
|
|
158
158
|
// This is read only, but we could loosen this in theory for input boxes...
|
|
159
159
|
return Promise.resolve(false);
|
|
160
160
|
}
|
|
@@ -166,7 +166,7 @@ export class GenericSearchProvider extends AbstractSearchProvider {
|
|
|
166
166
|
* @param query A RegExp to be use to perform the search
|
|
167
167
|
* @param filters Filter parameters to pass to provider
|
|
168
168
|
*/
|
|
169
|
-
startQuery = async (query: RegExp | null,
|
|
169
|
+
startQuery = async (query: RegExp | null, filters = {}): Promise<void> => {
|
|
170
170
|
await this.endQuery();
|
|
171
171
|
this._query = query;
|
|
172
172
|
|
|
@@ -281,8 +281,8 @@ export class GenericSearchProvider extends AbstractSearchProvider {
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
protected async _onWidgetChanged(
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
mutations: MutationRecord[],
|
|
285
|
+
observer: MutationObserver,
|
|
286
286
|
) {
|
|
287
287
|
this._currentMatchIndex = -1;
|
|
288
288
|
// This is typically cheap, but we do not control the rate of change or size of the output
|
|
@@ -290,7 +290,7 @@ export class GenericSearchProvider extends AbstractSearchProvider {
|
|
|
290
290
|
this._stateChanged.fire();
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
function elementInViewport(el: HTMLElement): boolean {
|
|
293
|
+
export function elementInViewport(el: HTMLElement): boolean {
|
|
294
294
|
const boundingClientRect = el.getBoundingClientRect();
|
|
295
295
|
return (
|
|
296
296
|
boundingClientRect.top >= 0 &&
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import type { CommandRegistry, KeybindingRegistry } from '@difizen/mana-app';
|
|
2
3
|
import {
|
|
3
4
|
LibroCommandRegister,
|
|
4
5
|
LibroExtensionSlotContribution,
|
|
@@ -8,13 +9,13 @@ import type {
|
|
|
8
9
|
LibroSlot,
|
|
9
10
|
LibroView,
|
|
10
11
|
} from '@difizen/libro-core';
|
|
11
|
-
import type { CommandRegistry, KeybindingRegistry } from '@difizen/mana-app';
|
|
12
12
|
import {
|
|
13
13
|
ViewManager,
|
|
14
14
|
CommandContribution,
|
|
15
15
|
KeybindingContribution,
|
|
16
|
+
inject,
|
|
17
|
+
singleton,
|
|
16
18
|
} from '@difizen/mana-app';
|
|
17
|
-
import { inject, singleton } from '@difizen/mana-app';
|
|
18
19
|
|
|
19
20
|
import { LibroSearchView } from './libro-search-view.js';
|
|
20
21
|
|
|
@@ -60,7 +61,7 @@ export class LibroSearchManager
|
|
|
60
61
|
commands,
|
|
61
62
|
LibroSearchToggleCommand.ShowLibroSearch,
|
|
62
63
|
{
|
|
63
|
-
execute: (
|
|
64
|
+
execute: (cell, libro, position) => {
|
|
64
65
|
if (libro) {
|
|
65
66
|
this.showSearchView(libro);
|
|
66
67
|
}
|