@fluid-topics/ft-reader-search-in-document 1.3.5 → 1.3.7
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { nothing, PropertyValues, TemplateResult } from "lit";
|
|
2
2
|
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtReaderSearchInDocumentProperties } from "./ft-reader-search-in-document.properties";
|
|
4
|
+
import { FtSearchContext } from "@fluid-topics/ft-search-context";
|
|
4
5
|
import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
|
|
5
6
|
import { FtMap, FtSearchResultClusterEntry } from "@fluid-topics/public-api";
|
|
6
7
|
declare const FtReaderSearchInDocument_base: typeof FtReaderComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
@@ -16,14 +17,15 @@ export declare class FtReaderSearchInDocument extends FtReaderSearchInDocument_b
|
|
|
16
17
|
private hideResultAbstract;
|
|
17
18
|
private hideResultsNumber;
|
|
18
19
|
private emptyResultOnClear;
|
|
19
|
-
|
|
20
|
+
searchContext?: FtSearchContext;
|
|
20
21
|
private uniqueId;
|
|
21
22
|
private get filters();
|
|
22
23
|
private renderResult;
|
|
23
24
|
onAuxClick(e: MouseEvent, result: FtSearchResultClusterEntry, rank: number): void;
|
|
24
25
|
onContextMenu(result: FtSearchResultClusterEntry, rank: number): void;
|
|
25
26
|
protected render(): typeof nothing | TemplateResult<1>;
|
|
26
|
-
protected
|
|
27
|
+
protected willUpdate(props: PropertyValues): void;
|
|
28
|
+
private initEventManager;
|
|
27
29
|
private onLinkClick;
|
|
28
30
|
importDynamicDependencies(): void;
|
|
29
31
|
}
|
|
@@ -5,13 +5,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, nothing } from "lit";
|
|
8
|
-
import { randomId, redux } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { randomId, redux, waitFor } from "@fluid-topics/ft-wc-utils";
|
|
9
9
|
import { resultStyles, styles } from "./ft-reader-search-in-document.styles";
|
|
10
10
|
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
11
11
|
import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
|
|
12
12
|
import { property, query } from "lit/decorators.js";
|
|
13
13
|
import { getResultUrl } from "@fluid-topics/ft-search-result-context/build/utils";
|
|
14
|
-
import { SearchInDocumentEvent } from "./events";
|
|
15
14
|
import { readerSearchInDocumentContext } from "./ReaderSearchInDocumentMessages";
|
|
16
15
|
import { FtCard } from "@fluid-topics/ft-card";
|
|
17
16
|
import { SearchResultClickEvent, SearchResultOpenContextMenuEvent } from "@fluid-topics/ft-search-context/build/utils";
|
|
@@ -24,7 +23,6 @@ class FtReaderSearchInDocument extends withI18n(FtReaderComponent) {
|
|
|
24
23
|
this.hideResultAbstract = false;
|
|
25
24
|
this.hideResultsNumber = false;
|
|
26
25
|
this.emptyResultOnClear = false;
|
|
27
|
-
this.userHasDoneManualAction = false;
|
|
28
26
|
this.uniqueId = randomId(6, "search-in-document-");
|
|
29
27
|
this.addI18nContext(readerSearchInDocumentContext);
|
|
30
28
|
}
|
|
@@ -35,17 +33,17 @@ class FtReaderSearchInDocument extends withI18n(FtReaderComponent) {
|
|
|
35
33
|
valueFilter: {
|
|
36
34
|
negative: false,
|
|
37
35
|
values: [this.map.id],
|
|
38
|
-
}
|
|
39
|
-
}
|
|
36
|
+
},
|
|
37
|
+
},
|
|
40
38
|
];
|
|
41
39
|
}
|
|
42
40
|
renderResult(result, rank) {
|
|
43
41
|
var _a;
|
|
44
42
|
return html `
|
|
45
43
|
<style> ${resultStyles}</style>
|
|
46
|
-
<a href="${getResultUrl(result)}" @click
|
|
47
|
-
@auxclick
|
|
48
|
-
@contextmenu
|
|
44
|
+
<a href="${getResultUrl(result)}" @click=${() => this.onLinkClick(result, rank)}
|
|
45
|
+
@auxclick=${(e) => this.onAuxClick(e, result, rank)}
|
|
46
|
+
@contextmenu=${() => this.onContextMenu(result, rank)}>
|
|
49
47
|
<ft-card clickable noheader>
|
|
50
48
|
<div class="result-container">
|
|
51
49
|
${this.hideResultTitle ? nothing : html `
|
|
@@ -75,32 +73,19 @@ class FtReaderSearchInDocument extends withI18n(FtReaderComponent) {
|
|
|
75
73
|
}
|
|
76
74
|
return html `
|
|
77
75
|
<ft-search-context id="${this.uniqueId}"
|
|
76
|
+
part="search-context"
|
|
78
77
|
contentLocale="${this.map.lang}"
|
|
79
78
|
query="${this.searchInDocumentQuery}"
|
|
80
79
|
.filters=${this.filters}
|
|
81
80
|
scope="ALL_TOPICS"
|
|
82
|
-
ignoreEmptyQuery
|
|
83
|
-
@ft-search-results-change=${(e) => {
|
|
84
|
-
var _a, _b;
|
|
85
|
-
if (this.userHasDoneManualAction) {
|
|
86
|
-
this.dispatchEvent(new SearchInDocumentEvent({
|
|
87
|
-
mapId: this.map.id,
|
|
88
|
-
mapTitle: this.map.title,
|
|
89
|
-
metadata: (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.metadata) !== null && _b !== void 0 ? _b : [],
|
|
90
|
-
query: e.detail.request.query,
|
|
91
|
-
searchResultsCount: e.detail.paging.totalResultsCount
|
|
92
|
-
}));
|
|
93
|
-
this.userHasDoneManualAction = false;
|
|
94
|
-
}
|
|
95
|
-
}}>
|
|
81
|
+
ignoreEmptyQuery>
|
|
96
82
|
<div class="ft-search-in-doc--container">
|
|
97
|
-
<ft-search-input placeholder
|
|
83
|
+
<ft-search-input placeholder="${readerSearchInDocumentContext.messages.placeholder()}"
|
|
98
84
|
?triggerSearchOnClear=${this.emptyResultOnClear}
|
|
99
|
-
@change
|
|
85
|
+
@change=${(e) => {
|
|
100
86
|
var _a;
|
|
101
|
-
this.userHasDoneManualAction = true;
|
|
102
87
|
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setSearchInDocumentQuery(e.detail);
|
|
103
|
-
}}
|
|
88
|
+
}}></ft-search-input>
|
|
104
89
|
${this.hideResultsNumber ? nothing : html `
|
|
105
90
|
<ft-search-results-number></ft-search-results-number>
|
|
106
91
|
`}
|
|
@@ -115,12 +100,21 @@ class FtReaderSearchInDocument extends withI18n(FtReaderComponent) {
|
|
|
115
100
|
</ft-search-context>
|
|
116
101
|
`;
|
|
117
102
|
}
|
|
118
|
-
|
|
119
|
-
super.
|
|
103
|
+
willUpdate(props) {
|
|
104
|
+
super.willUpdate(props);
|
|
105
|
+
if (props.has("map") && this.map) {
|
|
106
|
+
this.initEventManager();
|
|
107
|
+
}
|
|
120
108
|
if (["hideResultTitle", "hideResultBreadcrumb", "hideResultAbstract"].some(p => props.has(p)) && this.searchResults) {
|
|
121
109
|
this.searchResults.requestUpdate();
|
|
122
110
|
}
|
|
123
111
|
}
|
|
112
|
+
initEventManager() {
|
|
113
|
+
waitFor(() => { var _a; return (_a = this.searchContext) === null || _a === void 0 ? void 0 : _a.eventManager; }).then(eventManager => {
|
|
114
|
+
eventManager.setDocumentSearchFromMap(this.map);
|
|
115
|
+
eventManager.initAppInfo();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
124
118
|
onLinkClick(result, rank) {
|
|
125
119
|
this.dispatchEvent(new SearchResultClickEvent(result, rank));
|
|
126
120
|
}
|
|
@@ -137,7 +131,7 @@ class FtReaderSearchInDocument extends withI18n(FtReaderComponent) {
|
|
|
137
131
|
}
|
|
138
132
|
}
|
|
139
133
|
FtReaderSearchInDocument.elementDefinitions = {
|
|
140
|
-
"ft-card": FtCard
|
|
134
|
+
"ft-card": FtCard,
|
|
141
135
|
};
|
|
142
136
|
FtReaderSearchInDocument.styles = styles;
|
|
143
137
|
__decorate([
|
|
@@ -164,4 +158,7 @@ __decorate([
|
|
|
164
158
|
__decorate([
|
|
165
159
|
property({ type: Boolean })
|
|
166
160
|
], FtReaderSearchInDocument.prototype, "emptyResultOnClear", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
query(`[part="search-context"]`)
|
|
163
|
+
], FtReaderSearchInDocument.prototype, "searchContext", void 0);
|
|
167
164
|
export { FtReaderSearchInDocument };
|