@salesforcedevs/dx-components 0.19.3-alpha → 0.19.3-alpha.13
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/package.json
CHANGED
|
@@ -27,6 +27,7 @@ export const SESSION_KEY = "dx-sidebar-search-state";
|
|
|
27
27
|
|
|
28
28
|
const DEFAULT_RESULT_COUNT = 20;
|
|
29
29
|
const SEARCH_DEBOUNCE_DELAY = 780;
|
|
30
|
+
const HIGHLIGHT_DEBOUNCE_DELAY = 200;
|
|
30
31
|
|
|
31
32
|
const UserRecentSearches = new RecentSearches();
|
|
32
33
|
|
|
@@ -217,10 +218,6 @@ export default class SidebarSearch extends LightningElement {
|
|
|
217
218
|
this.onResultListChange
|
|
218
219
|
);
|
|
219
220
|
|
|
220
|
-
if (this.value) {
|
|
221
|
-
this.dispatchHighlightedTermChange();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
221
|
if (!this.preloadedState) {
|
|
225
222
|
if (this.value) {
|
|
226
223
|
this.submitSearch();
|
|
@@ -337,7 +334,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
337
334
|
this.dispatchEvent(new CustomEvent("loading", { detail: loading }));
|
|
338
335
|
}
|
|
339
336
|
|
|
340
|
-
private dispatchHighlightedTermChange() {
|
|
337
|
+
private dispatchHighlightedTermChange = debounce(() => {
|
|
341
338
|
this.dispatchEvent(
|
|
342
339
|
new CustomEvent("highlightedtermchange", {
|
|
343
340
|
detail: this.value,
|
|
@@ -345,7 +342,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
345
342
|
bubbles: true
|
|
346
343
|
})
|
|
347
344
|
);
|
|
348
|
-
}
|
|
345
|
+
}, HIGHLIGHT_DEBOUNCE_DELAY);
|
|
349
346
|
|
|
350
347
|
private updateRecentSearches = () =>
|
|
351
348
|
(this.recentSearches = UserRecentSearches.get().map((item: string) => ({
|
|
@@ -2,6 +2,10 @@ import { createSearchRegExp } from "utils/regexps";
|
|
|
2
2
|
|
|
3
3
|
const MARK_TAGS = /<\/?mark>/gi;
|
|
4
4
|
|
|
5
|
+
// mark tags not being removed from ref page
|
|
6
|
+
// mark tags dif color on ref page
|
|
7
|
+
// need to reset to first match on highlight change
|
|
8
|
+
|
|
5
9
|
export const highlightTerms = (
|
|
6
10
|
// eslint-disable-next-line no-undef
|
|
7
11
|
elements: NodeListOf<Element>,
|
|
@@ -9,6 +13,7 @@ export const highlightTerms = (
|
|
|
9
13
|
): void => {
|
|
10
14
|
searchTerm = searchTerm.trim();
|
|
11
15
|
const searchExp = createSearchRegExp(searchTerm);
|
|
16
|
+
let scrolled = false;
|
|
12
17
|
elements.forEach((element) => {
|
|
13
18
|
if (
|
|
14
19
|
element?.innerHTML.includes("<dx-") ||
|
|
@@ -17,20 +22,28 @@ export const highlightTerms = (
|
|
|
17
22
|
return;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
try {
|
|
26
|
+
let innerHtml = element.innerHTML.replace(
|
|
27
|
+
// Remove previously added mark tags
|
|
28
|
+
MARK_TAGS,
|
|
29
|
+
""
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (searchTerm) {
|
|
33
|
+
innerHtml = innerHtml.replace(searchExp, "<mark>$&</mark>");
|
|
34
|
+
}
|
|
25
35
|
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
element.innerHTML = innerHtml;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error(e, element);
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
console.log("should i scroll?");
|
|
42
|
+
const mark = element.querySelector("mark");
|
|
43
|
+
if (mark && !scrolled) {
|
|
44
|
+
scrolled = true;
|
|
45
|
+
console.log("scrolling", element);
|
|
46
|
+
element.scrollIntoView({ block: "nearest" });
|
|
47
|
+
}
|
|
31
48
|
});
|
|
32
|
-
|
|
33
|
-
if (elements.length > 0) {
|
|
34
|
-
elements[0].scrollIntoView(true);
|
|
35
|
-
}
|
|
36
49
|
};
|