@difizen/libro-search 0.0.2-alpha.0

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/es/abstract-search-provider.d.ts +113 -0
  4. package/es/abstract-search-provider.d.ts.map +1 -0
  5. package/es/abstract-search-provider.js +126 -0
  6. package/es/index.d.ts +10 -0
  7. package/es/index.d.ts.map +1 -0
  8. package/es/index.js +9 -0
  9. package/es/index.less +107 -0
  10. package/es/libro-cell-search-provider.d.ts +10 -0
  11. package/es/libro-cell-search-provider.d.ts.map +1 -0
  12. package/es/libro-cell-search-provider.js +54 -0
  13. package/es/libro-search-engine-html.d.ts +3 -0
  14. package/es/libro-search-engine-html.d.ts.map +1 -0
  15. package/es/libro-search-engine-html.js +59 -0
  16. package/es/libro-search-engine-text.d.ts +10 -0
  17. package/es/libro-search-engine-text.d.ts.map +1 -0
  18. package/es/libro-search-engine-text.js +32 -0
  19. package/es/libro-search-generic-provider.d.ts +107 -0
  20. package/es/libro-search-generic-provider.d.ts.map +1 -0
  21. package/es/libro-search-generic-provider.js +467 -0
  22. package/es/libro-search-manager.d.ts +22 -0
  23. package/es/libro-search-manager.d.ts.map +1 -0
  24. package/es/libro-search-manager.js +102 -0
  25. package/es/libro-search-model.d.ts +111 -0
  26. package/es/libro-search-model.d.ts.map +1 -0
  27. package/es/libro-search-model.js +395 -0
  28. package/es/libro-search-protocol.d.ts +176 -0
  29. package/es/libro-search-protocol.d.ts.map +1 -0
  30. package/es/libro-search-protocol.js +36 -0
  31. package/es/libro-search-provider.d.ts +138 -0
  32. package/es/libro-search-provider.d.ts.map +1 -0
  33. package/es/libro-search-provider.js +759 -0
  34. package/es/libro-search-utils.d.ts +25 -0
  35. package/es/libro-search-utils.d.ts.map +1 -0
  36. package/es/libro-search-utils.js +85 -0
  37. package/es/libro-search-view.d.ts +59 -0
  38. package/es/libro-search-view.d.ts.map +1 -0
  39. package/es/libro-search-view.js +455 -0
  40. package/es/module.d.ts +4 -0
  41. package/es/module.d.ts.map +1 -0
  42. package/es/module.js +35 -0
  43. package/package.json +66 -0
  44. package/src/abstract-search-provider.ts +160 -0
  45. package/src/index.less +107 -0
  46. package/src/index.ts +9 -0
  47. package/src/libro-cell-search-provider.ts +39 -0
  48. package/src/libro-search-engine-html.ts +74 -0
  49. package/src/libro-search-engine-text.ts +34 -0
  50. package/src/libro-search-generic-provider.ts +303 -0
  51. package/src/libro-search-manager.ts +86 -0
  52. package/src/libro-search-model.ts +266 -0
  53. package/src/libro-search-protocol.ts +209 -0
  54. package/src/libro-search-provider.ts +507 -0
  55. package/src/libro-search-utils.spec.ts +37 -0
  56. package/src/libro-search-utils.ts +83 -0
  57. package/src/libro-search-view.tsx +404 -0
  58. package/src/module.ts +59 -0
@@ -0,0 +1,759 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
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); }); }; }
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 }); }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
13
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ 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; }
22
+ 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.'); }
23
+ import { LibroView } from '@difizen/libro-core';
24
+ import { inject, prop, transient, watch, equals } from '@difizen/mana-app';
25
+ import { Deferred, DisposableCollection } from '@difizen/mana-app';
26
+ import { l10n } from '@difizen/mana-l10n';
27
+ import { AbstractSearchProvider } from "./abstract-search-provider.js";
28
+ import { LibroCellSearchProvider } from "./libro-cell-search-provider.js";
29
+ import { SearchProviderOption } from "./libro-search-protocol.js";
30
+ export var LibroSearchProviderFactory = Symbol('LibroSearchProviderFactory');
31
+ /**
32
+ * Libro view search provider
33
+ */
34
+ export var LibroSearchProvider = (_dec = transient(), _dec2 = inject(LibroCellSearchProvider), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function (_AbstractSearchProvid) {
35
+ _inherits(LibroSearchProvider, _AbstractSearchProvid);
36
+ var _super = _createSuper(LibroSearchProvider);
37
+ /**
38
+ * @param option Provide the view to search in
39
+ */
40
+ function LibroSearchProvider(option) {
41
+ var _this;
42
+ _classCallCheck(this, LibroSearchProvider);
43
+ _this = _super.call(this, option);
44
+ _initializerDefineProperty(_this, "libroCellSearchProvider", _descriptor, _assertThisInitialized(_this));
45
+ _this.toDispose = new DisposableCollection();
46
+ _initializerDefineProperty(_this, "currentProviderIndex", _descriptor2, _assertThisInitialized(_this));
47
+ _initializerDefineProperty(_this, "searchCellOutput", _descriptor3, _assertThisInitialized(_this));
48
+ _initializerDefineProperty(_this, "onlySearchSelectedCells", _descriptor4, _assertThisInitialized(_this));
49
+ _initializerDefineProperty(_this, "replaceMode", _descriptor5, _assertThisInitialized(_this));
50
+ _this.query = undefined;
51
+ _initializerDefineProperty(_this, "searchProviders", _descriptor6, _assertThisInitialized(_this));
52
+ _initializerDefineProperty(_this, "providerMap", _descriptor7, _assertThisInitialized(_this));
53
+ _this.documentHasChanged = false;
54
+ _this.getProvider = function (cell) {
55
+ return _this.providerMap.get(cell.id);
56
+ };
57
+ /**
58
+ * Get an initial query value if applicable so that it can be entered
59
+ * into the search box as an initial query
60
+ *
61
+ * @returns Initial value used to populate the search box.
62
+ */
63
+ _this.getInitialQuery = function () {
64
+ var activeCell = _this.view.model.active;
65
+ if (activeCell) {
66
+ return _this.libroCellSearchProvider.getInitialQuery(activeCell);
67
+ }
68
+ return '';
69
+ };
70
+ /**
71
+ * Clear currently highlighted match.
72
+ */
73
+ _this.clearHighlight = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
74
+ var _this$searchProviders;
75
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
76
+ while (1) switch (_context.prev = _context.next) {
77
+ case 0:
78
+ if (!(_this.currentProviderIndex !== undefined)) {
79
+ _context.next = 4;
80
+ break;
81
+ }
82
+ _context.next = 3;
83
+ return (_this$searchProviders = _this.searchProviders[_this.currentProviderIndex]) === null || _this$searchProviders === void 0 ? void 0 : _this$searchProviders.clearHighlight();
84
+ case 3:
85
+ _this.currentProviderIndex = undefined;
86
+ case 4:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }, _callee);
91
+ }));
92
+ /**
93
+ * Highlight the next match.
94
+ *
95
+ * @param loop Whether to loop within the matches list.
96
+ *
97
+ * @returns The next match if available.
98
+ */
99
+ _this.highlightNext = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
100
+ var loop,
101
+ match,
102
+ _args2 = arguments;
103
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
104
+ while (1) switch (_context2.prev = _context2.next) {
105
+ case 0:
106
+ loop = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : true;
107
+ _context2.next = 3;
108
+ return _this.stepNext(false, loop);
109
+ case 3:
110
+ match = _context2.sent;
111
+ return _context2.abrupt("return", match !== null && match !== void 0 ? match : undefined);
112
+ case 5:
113
+ case "end":
114
+ return _context2.stop();
115
+ }
116
+ }, _callee2);
117
+ }));
118
+ /**
119
+ * Highlight the previous match.
120
+ *
121
+ * @param loop Whether to loop within the matches list.
122
+ *
123
+ * @returns The previous match if available.
124
+ */
125
+ _this.highlightPrevious = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
126
+ var loop,
127
+ match,
128
+ _args3 = arguments;
129
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
130
+ while (1) switch (_context3.prev = _context3.next) {
131
+ case 0:
132
+ loop = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : true;
133
+ _context3.next = 3;
134
+ return _this.stepNext(true, loop);
135
+ case 3:
136
+ match = _context3.sent;
137
+ return _context3.abrupt("return", match !== null && match !== void 0 ? match : undefined);
138
+ case 5:
139
+ case "end":
140
+ return _context3.stop();
141
+ }
142
+ }, _callee3);
143
+ }));
144
+ /**
145
+ * Search for a regular expression with optional filters.
146
+ *
147
+ * @param query A regular expression to test for
148
+ * @param filters Filter parameters to pass to provider
149
+ *
150
+ */
151
+ _this.startQuery = /*#__PURE__*/function () {
152
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(query, _filters) {
153
+ var _this$filters;
154
+ var highlightNext,
155
+ cells,
156
+ _args5 = arguments;
157
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
158
+ while (1) switch (_context5.prev = _context5.next) {
159
+ case 0:
160
+ highlightNext = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : true;
161
+ if (_this.view) {
162
+ _context5.next = 3;
163
+ break;
164
+ }
165
+ return _context5.abrupt("return");
166
+ case 3:
167
+ _context5.next = 5;
168
+ return _this.endQuery();
169
+ case 5:
170
+ cells = _this.view.model.cells;
171
+ _this.query = query;
172
+
173
+ // TODO: support selected cells
174
+ if ((_this$filters = _this.filters) !== null && _this$filters !== void 0 && _this$filters.onlySearchSelectedCells) {
175
+ // watch(this.view.model, 'selections', this._onSelectionChanged);
176
+ // this.view.model.selectionChanged.connect(this._onSelectionChanged, this);
177
+ }
178
+ // For each cell, create a search provider
179
+ _context5.next = 10;
180
+ return Promise.all(cells.map( /*#__PURE__*/function () {
181
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(cell) {
182
+ var _cellSearchProvider;
183
+ var cellSearchProvider;
184
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
185
+ while (1) switch (_context4.prev = _context4.next) {
186
+ case 0:
187
+ if (_this.providerMap.has(cell.id)) {
188
+ cellSearchProvider = _this.providerMap.get(cell.id);
189
+ } else {
190
+ cellSearchProvider = _this.libroCellSearchProvider.createCellSearchProvider(cell);
191
+ }
192
+ if (cellSearchProvider) {
193
+ _this.providerMap.set(cell.id, cellSearchProvider);
194
+ }
195
+ // cellSearchProvider.stateChanged(this._onSearchProviderChanged);
196
+ // await cellSearchProvider.setIsActive(
197
+ // !this._filters!.selectedCells || this.widget.content.isSelectedOrActive(cell),
198
+ // );
199
+ _context4.next = 4;
200
+ return (_cellSearchProvider = cellSearchProvider) === null || _cellSearchProvider === void 0 ? void 0 : _cellSearchProvider.startQuery(query, _this.filters);
201
+ case 4:
202
+ return _context4.abrupt("return", cellSearchProvider);
203
+ case 5:
204
+ case "end":
205
+ return _context4.stop();
206
+ }
207
+ }, _callee4);
208
+ }));
209
+ return function (_x3) {
210
+ return _ref5.apply(this, arguments);
211
+ };
212
+ }()));
213
+ case 10:
214
+ _this.searchProviders = _context5.sent;
215
+ _this.currentProviderIndex = _this.getActiveIndex();
216
+ if (!(!_this.documentHasChanged && highlightNext)) {
217
+ _context5.next = 15;
218
+ break;
219
+ }
220
+ _context5.next = 15;
221
+ return _this.highlightNext(false);
222
+ case 15:
223
+ _this.documentHasChanged = false;
224
+ return _context5.abrupt("return", Promise.resolve());
225
+ case 17:
226
+ case "end":
227
+ return _context5.stop();
228
+ }
229
+ }, _callee5);
230
+ }));
231
+ return function (_x, _x2) {
232
+ return _ref4.apply(this, arguments);
233
+ };
234
+ }();
235
+ /**
236
+ * Stop the search and clear all internal state.
237
+ */
238
+ _this.endQuery = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
239
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
240
+ while (1) switch (_context6.prev = _context6.next) {
241
+ case 0:
242
+ _context6.next = 2;
243
+ return Promise.all(_this.searchProviders.map(function (provider) {
244
+ // provider?.stateChanged(this._onSearchProviderChanged);
245
+ return provider === null || provider === void 0 ? void 0 : provider.endQuery();
246
+ }));
247
+ case 2:
248
+ _this.searchProviders.length = 0;
249
+ _this.currentProviderIndex = undefined;
250
+ case 4:
251
+ case "end":
252
+ return _context6.stop();
253
+ }
254
+ }, _callee6);
255
+ }));
256
+ /**
257
+ * Replace the currently selected match with the provided text
258
+ *
259
+ * @param newText The replacement text.
260
+ * @param loop Whether to loop within the matches list.
261
+ *
262
+ * @returns A promise that resolves with a boolean indicating whether a replace occurred.
263
+ */
264
+ _this.replaceCurrentMatch = /*#__PURE__*/function () {
265
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(newText) {
266
+ var loop,
267
+ replaceOccurred,
268
+ searchEngine,
269
+ _args7 = arguments;
270
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
271
+ while (1) switch (_context7.prev = _context7.next) {
272
+ case 0:
273
+ loop = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : true;
274
+ replaceOccurred = false; // TODO: makrdown unrendered
275
+ // const unrenderMarkdownCell = async (highlightNext = false): Promise<void> => {
276
+ // // Unrendered markdown cell
277
+ // const activeCell = this.view?.model.active;
278
+ // if (activeCell?.model.type === 'markdown' && (activeCell as MarkdownCell).rendered) {
279
+ // (activeCell as MarkdownCell).rendered = false;
280
+ // if (highlightNext) {
281
+ // await this.highlightNext(loop);
282
+ // }
283
+ // }
284
+ // };
285
+ if (!(_this.currentProviderIndex !== undefined)) {
286
+ _context7.next = 7;
287
+ break;
288
+ }
289
+ // await unrenderMarkdownCell();
290
+ searchEngine = _this.searchProviders[_this.currentProviderIndex];
291
+ _context7.next = 6;
292
+ return searchEngine === null || searchEngine === void 0 ? void 0 : searchEngine.replaceCurrentMatch(newText);
293
+ case 6:
294
+ replaceOccurred = !!_context7.sent;
295
+ case 7:
296
+ _context7.next = 9;
297
+ return _this.highlightNext(loop);
298
+ case 9:
299
+ return _context7.abrupt("return", replaceOccurred);
300
+ case 10:
301
+ case "end":
302
+ return _context7.stop();
303
+ }
304
+ }, _callee7);
305
+ }));
306
+ return function (_x4) {
307
+ return _ref7.apply(this, arguments);
308
+ };
309
+ }();
310
+ /**
311
+ * Replace all matches in the notebook with the provided text
312
+ *
313
+ * @param newText The replacement text.
314
+ *
315
+ * @returns A promise that resolves with a boolean indicating whether a replace occurred.
316
+ */
317
+ _this.replaceAllMatches = /*#__PURE__*/function () {
318
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(newText) {
319
+ var replacementOccurred;
320
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
321
+ while (1) switch (_context8.prev = _context8.next) {
322
+ case 0:
323
+ _context8.next = 2;
324
+ return Promise.all(_this.searchProviders.map(function (provider) {
325
+ return provider === null || provider === void 0 ? void 0 : provider.replaceAllMatches(newText);
326
+ }));
327
+ case 2:
328
+ replacementOccurred = _context8.sent;
329
+ return _context8.abrupt("return", replacementOccurred.includes(true));
330
+ case 4:
331
+ case "end":
332
+ return _context8.stop();
333
+ }
334
+ }, _callee8);
335
+ }));
336
+ return function (_x5) {
337
+ return _ref8.apply(this, arguments);
338
+ };
339
+ }();
340
+ _this.addCellProvider = function (index) {
341
+ var cell = _this.view.model.cells[index];
342
+ var cellSearchProvider = _this.libroCellSearchProvider.createCellSearchProvider(cell);
343
+ var current = _this.searchProviders.slice();
344
+ current.splice(index, 0, cellSearchProvider);
345
+ _this.searchProviders = current;
346
+ if (cellSearchProvider) {
347
+ cellSearchProvider.stateChanged(_this.onSearchProviderChanged);
348
+ if (_this.query) {
349
+ cellSearchProvider.startQuery(_this.query, _this.filters);
350
+ }
351
+ }
352
+ // void cellSearchProvider
353
+ // .setIsActive(
354
+ // !(this._filters?.selectedCells ?? false) || this.widget.content.isSelectedOrActive(cell),
355
+ // )
356
+ // .then(() => {
357
+ // void cellSearchProvider.startQuery(this._query, this._filters);
358
+ // });
359
+ };
360
+ _this.removeCellProvider = function (index) {
361
+ var current = _this.searchProviders.slice();
362
+ var provider = current.slice(index, 1)[0];
363
+ provider === null || provider === void 0 ? void 0 : provider.dispose();
364
+ };
365
+ _this.doCellsChanged = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
366
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
367
+ while (1) switch (_context9.prev = _context9.next) {
368
+ case 0:
369
+ if (_this.query) {
370
+ _this.startQuery(_this.query);
371
+ } else {
372
+ _this.endQuery();
373
+ }
374
+ _this.onSearchProviderChanged();
375
+ _this.cellsChangeDeferred = undefined;
376
+ case 3:
377
+ case "end":
378
+ return _context9.stop();
379
+ }
380
+ }, _callee9);
381
+ }));
382
+ _this.onCellsChanged = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
383
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
384
+ while (1) switch (_context10.prev = _context10.next) {
385
+ case 0:
386
+ if (!_this.cellsChangeDeferred) {
387
+ _this.cellsChangeDeferred = new Deferred();
388
+ _this.cellsChangeDeferred.promise.then(_this.doCellsChanged).catch(function () {
389
+ //
390
+ });
391
+ _this.cellsChangeDeferred.resolve();
392
+ }
393
+ case 1:
394
+ case "end":
395
+ return _context10.stop();
396
+ }
397
+ }, _callee10);
398
+ }));
399
+ _this.getActiveIndex = function () {
400
+ if (!_this.view.activeCell) {
401
+ return undefined;
402
+ }
403
+ var index = _this.view.model.cells.findIndex(function (cell) {
404
+ return equals(cell, _this.view.activeCell);
405
+ });
406
+ if (index < 0) {
407
+ return undefined;
408
+ }
409
+ return index;
410
+ };
411
+ _this.stepNext = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
412
+ var reverse,
413
+ loop,
414
+ activateNewMatch,
415
+ startIndex,
416
+ searchEngine,
417
+ match,
418
+ _searchEngine,
419
+ _match,
420
+ _args12 = arguments;
421
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
422
+ while (1) switch (_context12.prev = _context12.next) {
423
+ case 0:
424
+ reverse = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : false;
425
+ loop = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : false;
426
+ activateNewMatch = /*#__PURE__*/function () {
427
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
428
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
429
+ while (1) switch (_context11.prev = _context11.next) {
430
+ case 0:
431
+ case "end":
432
+ return _context11.stop();
433
+ }
434
+ }, _callee11);
435
+ }));
436
+ return function activateNewMatch() {
437
+ return _ref12.apply(this, arguments);
438
+ };
439
+ }();
440
+ if (_this.currentProviderIndex === undefined) {
441
+ _this.currentProviderIndex = _this.getActiveIndex();
442
+ }
443
+ startIndex = _this.currentProviderIndex;
444
+ case 5:
445
+ searchEngine = _this.searchProviders[_this.currentProviderIndex];
446
+ if (!reverse) {
447
+ _context12.next = 12;
448
+ break;
449
+ }
450
+ _context12.next = 9;
451
+ return searchEngine === null || searchEngine === void 0 ? void 0 : searchEngine.highlightPrevious();
452
+ case 9:
453
+ _context12.t0 = _context12.sent;
454
+ _context12.next = 15;
455
+ break;
456
+ case 12:
457
+ _context12.next = 14;
458
+ return searchEngine === null || searchEngine === void 0 ? void 0 : searchEngine.highlightNext();
459
+ case 14:
460
+ _context12.t0 = _context12.sent;
461
+ case 15:
462
+ match = _context12.t0;
463
+ if (!match) {
464
+ _context12.next = 22;
465
+ break;
466
+ }
467
+ _context12.next = 19;
468
+ return activateNewMatch();
469
+ case 19:
470
+ return _context12.abrupt("return", match);
471
+ case 22:
472
+ _this.currentProviderIndex = _this.currentProviderIndex + (reverse ? -1 : 1);
473
+ if (!loop) {
474
+ _context12.next = 27;
475
+ break;
476
+ }
477
+ if (!(_this.currentProviderIndex === startIndex)) {
478
+ _context12.next = 26;
479
+ break;
480
+ }
481
+ return _context12.abrupt("break", 28);
482
+ case 26:
483
+ _this.currentProviderIndex = (_this.currentProviderIndex + _this.searchProviders.length) % _this.searchProviders.length;
484
+ case 27:
485
+ if (0 <= _this.currentProviderIndex && _this.currentProviderIndex < _this.searchProviders.length) {
486
+ _context12.next = 5;
487
+ break;
488
+ }
489
+ case 28:
490
+ if (!loop) {
491
+ _context12.next = 44;
492
+ break;
493
+ }
494
+ // Search a last time in the first provider as it may contain more
495
+ // than one matches
496
+ _searchEngine = _this.searchProviders[_this.currentProviderIndex];
497
+ if (!reverse) {
498
+ _context12.next = 36;
499
+ break;
500
+ }
501
+ _context12.next = 33;
502
+ return _searchEngine === null || _searchEngine === void 0 ? void 0 : _searchEngine.highlightPrevious();
503
+ case 33:
504
+ _context12.t1 = _context12.sent;
505
+ _context12.next = 39;
506
+ break;
507
+ case 36:
508
+ _context12.next = 38;
509
+ return _searchEngine === null || _searchEngine === void 0 ? void 0 : _searchEngine.highlightNext();
510
+ case 38:
511
+ _context12.t1 = _context12.sent;
512
+ case 39:
513
+ _match = _context12.t1;
514
+ if (!_match) {
515
+ _context12.next = 44;
516
+ break;
517
+ }
518
+ _context12.next = 43;
519
+ return activateNewMatch();
520
+ case 43:
521
+ return _context12.abrupt("return", _match);
522
+ case 44:
523
+ _this.currentProviderIndex = undefined;
524
+ return _context12.abrupt("return", undefined);
525
+ case 46:
526
+ case "end":
527
+ return _context12.stop();
528
+ }
529
+ }, _callee12);
530
+ }));
531
+ _this.onActiveCellChanged = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
532
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
533
+ while (1) switch (_context13.prev = _context13.next) {
534
+ case 0:
535
+ _context13.next = 2;
536
+ return _this._onSelectionChanged();
537
+ case 2:
538
+ if (!(_this.getActiveIndex() !== _this.currentProviderIndex)) {
539
+ _context13.next = 5;
540
+ break;
541
+ }
542
+ _context13.next = 5;
543
+ return _this.clearHighlight();
544
+ case 5:
545
+ case "end":
546
+ return _context13.stop();
547
+ }
548
+ }, _callee13);
549
+ }));
550
+ _this.onSearchProviderChanged = function () {
551
+ // Don't highlight the next occurrence when the query
552
+ // follows a document change
553
+ _this.documentHasChanged = true;
554
+ _this._stateChanged.fire();
555
+ };
556
+ _this._onSelectionChanged = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
557
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
558
+ while (1) switch (_context14.prev = _context14.next) {
559
+ case 0:
560
+ case "end":
561
+ return _context14.stop();
562
+ }
563
+ }, _callee14);
564
+ }));
565
+ _this.view = option.view;
566
+ _this.toDispose.push(watch(_this.view.model, 'active', _this.onActiveCellChanged));
567
+ _this.toDispose.push(watch(_this.view.model, 'cells', _this.onCellsChanged));
568
+ return _this;
569
+ }
570
+ LibroSearchProvider = inject(SearchProviderOption)(LibroSearchProvider, undefined, 0) || LibroSearchProvider;
571
+ _createClass(LibroSearchProvider, [{
572
+ key: "filters",
573
+ get: function get() {
574
+ return {
575
+ searchCellOutput: this.searchCellOutput && !this.replaceMode,
576
+ onlySearchSelectedCells: this.onlySearchSelectedCells
577
+ };
578
+ }
579
+ }, {
580
+ key: "updateSearchCellOutput",
581
+ value: function updateSearchCellOutput(value) {
582
+ this.searchCellOutput = value;
583
+ this.filters.searchCellOutput = value;
584
+ }
585
+ }, {
586
+ key: "currentMatchIndex",
587
+ get:
588
+ /**
589
+ * The current index of the selected match.
590
+ */
591
+ function get() {
592
+ var agg = 0;
593
+ var found = false;
594
+ for (var idx = 0; idx < this.searchProviders.length; idx++) {
595
+ var provider = this.searchProviders[idx];
596
+ var localMatch = provider === null || provider === void 0 ? void 0 : provider.currentMatchIndex;
597
+ if (localMatch !== undefined) {
598
+ agg += localMatch;
599
+ found = true;
600
+ break;
601
+ } else {
602
+ var _provider$matchesCoun;
603
+ agg += (_provider$matchesCoun = provider === null || provider === void 0 ? void 0 : provider.matchesCount) !== null && _provider$matchesCoun !== void 0 ? _provider$matchesCoun : 0;
604
+ }
605
+ }
606
+ return found ? agg : undefined;
607
+ }
608
+
609
+ /**
610
+ * The number of matches.
611
+ */
612
+ }, {
613
+ key: "matchesCount",
614
+ get: function get() {
615
+ var _this2 = this;
616
+ var count = this.view.model.cells.reduce(function (sum, cell) {
617
+ var provider = _this2.getProvider(cell);
618
+ sum += (provider === null || provider === void 0 ? void 0 : provider.matchesCount) || 0;
619
+ return sum;
620
+ }, 0);
621
+ if (count === 0) {
622
+ return undefined;
623
+ }
624
+ return count;
625
+ }
626
+
627
+ /**
628
+ * Set to true if the widget under search is read-only, false
629
+ * if it is editable. Will be used to determine whether to show
630
+ * the replace option.
631
+ */
632
+ }, {
633
+ key: "isReadOnly",
634
+ get: function get() {
635
+ var _this$view$model$read, _this$view, _this$view$model;
636
+ return (_this$view$model$read = (_this$view = this.view) === null || _this$view === void 0 ? void 0 : (_this$view$model = _this$view.model) === null || _this$view$model === void 0 ? void 0 : _this$view$model.readOnly) !== null && _this$view$model$read !== void 0 ? _this$view$model$read : false;
637
+ }
638
+
639
+ /**
640
+ * Dispose of the resources held by the search provider.
641
+ *
642
+ * #### Notes
643
+ * If the object's `dispose` method is called more than once, all
644
+ * calls made after the first will be a no-op.
645
+ *
646
+ * #### Undefined Behavior
647
+ * It is undefined behavior to use any functionality of the object
648
+ * after it has been disposed unless otherwise explicitly noted.
649
+ */
650
+ }, {
651
+ key: "dispose",
652
+ value: function dispose() {
653
+ var _this3 = this;
654
+ if (this.isDisposed) {
655
+ return;
656
+ }
657
+ this.toDispose.dispose();
658
+ this.providerMap.clear();
659
+ _get(_getPrototypeOf(LibroSearchProvider.prototype), "dispose", this).call(this);
660
+
661
+ // const index = this.view.model.active;
662
+ this.endQuery().then(function () {
663
+ if (!_this3.view.isDisposed) {
664
+ // this.view.model.active = index;
665
+ // TODO: should active cell?
666
+ }
667
+ return;
668
+ }).catch(function (reason) {
669
+ console.error("Fail to end search query in notebook:\n".concat(reason));
670
+ });
671
+ }
672
+
673
+ /**
674
+ * Get the filters for the given provider.
675
+ *
676
+ * @returns The filters.
677
+ */
678
+ }, {
679
+ key: "getFilters",
680
+ value: function getFilters() {
681
+ return {
682
+ output: {
683
+ title: l10n.t('在 Output 中查找'),
684
+ description: l10n.t('在 Output 中查找'),
685
+ default: false,
686
+ supportReplace: false
687
+ },
688
+ selectedCells: {
689
+ title: l10n.t('仅在选中 cell 中查找'),
690
+ description: l10n.t('仅在选中 cell 中查找'),
691
+ default: false,
692
+ supportReplace: true
693
+ }
694
+ };
695
+ }
696
+ }], [{
697
+ key: "isApplicable",
698
+ value:
699
+ /**
700
+ * Report whether or not this provider has the ability to search on the given object
701
+ *
702
+ * @param domain Widget to test
703
+ * @returns Search ability
704
+ */
705
+ function isApplicable(domain) {
706
+ // check to see if the CMSearchProvider can search on the
707
+ // first cell, false indicates another editor is present
708
+ return domain instanceof LibroView;
709
+ }
710
+ }]);
711
+ return LibroSearchProvider;
712
+ }(AbstractSearchProvider), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroCellSearchProvider", [_dec2], {
713
+ configurable: true,
714
+ enumerable: true,
715
+ writable: true,
716
+ initializer: null
717
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "currentProviderIndex", [_dec3], {
718
+ configurable: true,
719
+ enumerable: true,
720
+ writable: true,
721
+ initializer: function initializer() {
722
+ return undefined;
723
+ }
724
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "searchCellOutput", [_dec4], {
725
+ configurable: true,
726
+ enumerable: true,
727
+ writable: true,
728
+ initializer: function initializer() {
729
+ return true;
730
+ }
731
+ }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "onlySearchSelectedCells", [_dec5], {
732
+ configurable: true,
733
+ enumerable: true,
734
+ writable: true,
735
+ initializer: function initializer() {
736
+ return false;
737
+ }
738
+ }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "replaceMode", [_dec6], {
739
+ configurable: true,
740
+ enumerable: true,
741
+ writable: true,
742
+ initializer: function initializer() {
743
+ return false;
744
+ }
745
+ }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "searchProviders", [_dec7], {
746
+ configurable: true,
747
+ enumerable: true,
748
+ writable: true,
749
+ initializer: function initializer() {
750
+ return [];
751
+ }
752
+ }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "providerMap", [_dec8], {
753
+ configurable: true,
754
+ enumerable: true,
755
+ writable: true,
756
+ initializer: function initializer() {
757
+ return new Map();
758
+ }
759
+ })), _class2)) || _class);