@fluid-topics/ft-reader-context 2.2.17 → 2.2.19
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/build/ft-reader-context.d.ts +7 -2
- package/build/ft-reader-context.js +52 -6
- package/build/ft-reader-context.light.js +17 -7
- package/build/ft-reader-context.min.js +34 -24
- package/build/store/FtReaderStateManager.d.ts +6 -1
- package/build/store/FtReaderStateManager.js +111 -41
- package/build/store/model.d.ts +9 -2
- package/build/store/model.js +6 -0
- package/build/store/redux.js +2 -0
- package/build/store/utils/FtOfficialReaderService.d.ts +2 -2
- package/build/store/utils/FtOfficialReaderService.js +4 -2
- package/build/store/utils/FtReaderConverter.d.ts +2 -1
- package/build/store/utils/FtReaderConverter.js +11 -8
- package/build/store/utils/FtReaderService.d.ts +9 -4
- package/build/store/utils/FtReaderService.js +40 -15
- package/package.json +5 -5
|
@@ -3,7 +3,7 @@ import { ClusteringHelper, Optional } from "@fluid-topics/ft-wc-utils";
|
|
|
3
3
|
import { FtReaderReduxStore } from "./redux";
|
|
4
4
|
import type { FtReaderService } from "./utils/FtReaderService";
|
|
5
5
|
import { FtAnalyticsEventsService } from "@fluid-topics/ft-app-context";
|
|
6
|
-
import { FtTranslationLocale, FtTranslationSettings } from "@fluid-topics/public-api";
|
|
6
|
+
import { FtMetadataFilter, FtTranslationLocale, FtTranslationSettings } from "@fluid-topics/public-api";
|
|
7
7
|
export declare class FtReaderStateManager {
|
|
8
8
|
store: FtReaderReduxStore;
|
|
9
9
|
private clusteringHelperProvider?;
|
|
@@ -20,8 +20,10 @@ export declare class FtReaderStateManager {
|
|
|
20
20
|
setMapId(mapId?: string): Promise<void>;
|
|
21
21
|
setRenderedTopics(tocIds: string[]): void;
|
|
22
22
|
setVisibleTopics(tocIds: string[]): void;
|
|
23
|
+
setFilters(filters: FtMetadataFilter[]): Promise<void>;
|
|
23
24
|
awaitService(): Promise<FtReaderService>;
|
|
24
25
|
navigateToTopic(tocId?: string, section?: string, pageNumber?: number): Promise<void>;
|
|
26
|
+
private resolvePage;
|
|
25
27
|
private resolveValidNonRootTocId;
|
|
26
28
|
navigateToPage(pageNumber: number): Promise<void>;
|
|
27
29
|
scrollDone(): void;
|
|
@@ -29,6 +31,9 @@ export declare class FtReaderStateManager {
|
|
|
29
31
|
load(): Promise<void>;
|
|
30
32
|
clear(): void;
|
|
31
33
|
reload(): Promise<void>;
|
|
34
|
+
clearFromFilter(): void;
|
|
35
|
+
reloadFromFilter(section?: string, page?: number): Promise<void>;
|
|
36
|
+
private fetchDataFromFilter;
|
|
32
37
|
private fetchData;
|
|
33
38
|
private loadConfiguration;
|
|
34
39
|
reloadConfiguration(): Promise<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FtReaderStoreEvents, } from "./model";
|
|
2
|
-
import { accessResultUrl, CanceledPromiseError, ClusteringHelper, Debouncer, waitFor, waitUntil, } from "@fluid-topics/ft-wc-utils";
|
|
1
|
+
import { FtReaderStoreEvents, FtRequestedTopicFilteredEvent, } from "./model";
|
|
2
|
+
import { accessResultUrl, CanceledPromiseError, ClusteringHelper, Debouncer, deepEqual, waitFor, waitUntil, } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { createReaderStore, } from "./redux";
|
|
4
4
|
import { FtOfficialReaderService } from "./utils/FtOfficialReaderService";
|
|
5
5
|
import { FtAnalyticsEventsService, ftAppInfoStore, } from "@fluid-topics/ft-app-context";
|
|
@@ -23,7 +23,9 @@ export class FtReaderStateManager {
|
|
|
23
23
|
}
|
|
24
24
|
async initService(serviceProvider) {
|
|
25
25
|
this.service = await serviceProvider();
|
|
26
|
-
|
|
26
|
+
const { mapId, metadataFilters } = this.store.getState();
|
|
27
|
+
this.service.mapId = mapId;
|
|
28
|
+
this.service.metadataFilters = metadataFilters;
|
|
27
29
|
return this.reload();
|
|
28
30
|
}
|
|
29
31
|
async setMapId(mapId) {
|
|
@@ -41,15 +43,20 @@ export class FtReaderStateManager {
|
|
|
41
43
|
setVisibleTopics(tocIds) {
|
|
42
44
|
this.store.actions.visibleTopics(tocIds);
|
|
43
45
|
}
|
|
46
|
+
async setFilters(filters) {
|
|
47
|
+
if (!deepEqual(filters, this.store.getState().metadataFilters)) {
|
|
48
|
+
this.store.actions.metadataFilters(filters);
|
|
49
|
+
if (this.service) {
|
|
50
|
+
this.service.metadataFilters = filters;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
44
54
|
async awaitService() {
|
|
45
55
|
return waitFor(() => this.service);
|
|
46
56
|
}
|
|
47
57
|
async navigateToTopic(tocId, section, pageNumber) {
|
|
48
58
|
await this.loaded();
|
|
49
|
-
const
|
|
50
|
-
const page = await (pageNumber != null
|
|
51
|
-
? service.getPage(pageNumber, this.getTranslationSettings())
|
|
52
|
-
: service.getPageByTocId(tocId !== null && tocId !== void 0 ? tocId : "root", this.getTranslationSettings()));
|
|
59
|
+
const page = await this.resolvePage(tocId, pageNumber);
|
|
53
60
|
this.store.actions.currentPage(page);
|
|
54
61
|
const nonRootTocId = this.resolveValidNonRootTocId(tocId, page);
|
|
55
62
|
this.store.actions.scrollTarget({ tocId: nonRootTocId, section });
|
|
@@ -62,16 +69,45 @@ export class FtReaderStateManager {
|
|
|
62
69
|
this.store.commands.add({ type: `focus-topic-${tocId}` });
|
|
63
70
|
}
|
|
64
71
|
}
|
|
72
|
+
async resolvePage(tocId, pageNumber) {
|
|
73
|
+
var _a;
|
|
74
|
+
var _b;
|
|
75
|
+
const service = await this.awaitService();
|
|
76
|
+
if (pageNumber) {
|
|
77
|
+
return service.getPage(pageNumber, this.getTranslationSettings());
|
|
78
|
+
}
|
|
79
|
+
if (!tocId) {
|
|
80
|
+
return service.getPageByTocId("root", this.getTranslationSettings());
|
|
81
|
+
}
|
|
82
|
+
const maybeFilteredTopic = this.store.getState().filteredTocNodes[tocId];
|
|
83
|
+
const nodeIsInToc = ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getTocNodeNow(tocId)) != null;
|
|
84
|
+
if (maybeFilteredTopic && maybeFilteredTopic.reason !== "ACCESS_RIGHTS_FILTER" && !nodeIsInToc) {
|
|
85
|
+
return service.getPageByTocId((_b = maybeFilteredTopic.closestParent) !== null && _b !== void 0 ? _b : "root", this.getTranslationSettings());
|
|
86
|
+
}
|
|
87
|
+
return service.getPageByTocId(tocId, this.getTranslationSettings());
|
|
88
|
+
}
|
|
65
89
|
resolveValidNonRootTocId(tocId, page) {
|
|
66
|
-
var _a
|
|
67
|
-
|
|
90
|
+
var _a;
|
|
91
|
+
var _b, _c, _d, _e;
|
|
92
|
+
const nonRootTocId = (_b = (tocId === "root" ? undefined : tocId)) !== null && _b !== void 0 ? _b : page.rootTocId;
|
|
68
93
|
if (!page.topics.includes(nonRootTocId)) {
|
|
69
94
|
if (tocId != "root" && !page.hiddenTopics.includes(nonRootTocId)) {
|
|
70
95
|
// The redirection is expected when tocId = root or when landing from an "only in toc" topic, don't send the event.
|
|
71
96
|
// Pass the requested tocId as event detail so consumers can probe access rights.
|
|
72
|
-
this.store.
|
|
97
|
+
const maybeFilteredTopic = this.store.getState().filteredTocNodes[nonRootTocId];
|
|
98
|
+
if (maybeFilteredTopic) {
|
|
99
|
+
this.store.dispatchEvent(new FtRequestedTopicFilteredEvent(maybeFilteredTopic));
|
|
100
|
+
const nodeIsInToc = ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getTocNodeNow(maybeFilteredTopic.tocId)) != null;
|
|
101
|
+
if (maybeFilteredTopic.reason === "ACCESS_RIGHTS_FILTER" || nodeIsInToc) {
|
|
102
|
+
return maybeFilteredTopic.tocId;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return (_c = maybeFilteredTopic.closestParent) !== null && _c !== void 0 ? _c : "root";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
this.store.dispatchEvent(new CustomEvent(FtReaderStoreEvents.requestedTopicNotFound));
|
|
73
109
|
}
|
|
74
|
-
return (
|
|
110
|
+
return (_e = (_d = page.topics[0]) !== null && _d !== void 0 ? _d : page.hiddenTopics[0]) !== null && _e !== void 0 ? _e : "root";
|
|
75
111
|
}
|
|
76
112
|
return nonRootTocId;
|
|
77
113
|
}
|
|
@@ -87,7 +123,7 @@ export class FtReaderStateManager {
|
|
|
87
123
|
async load() {
|
|
88
124
|
var _a;
|
|
89
125
|
if (((_a = this.service) === null || _a === void 0 ? void 0 : _a.mapId) && this.store.getState().map == null) {
|
|
90
|
-
await this.loadDebouncer.run(() => this.fetchData(
|
|
126
|
+
await this.loadDebouncer.run(() => this.fetchData());
|
|
91
127
|
}
|
|
92
128
|
}
|
|
93
129
|
clear() {
|
|
@@ -117,25 +153,55 @@ export class FtReaderStateManager {
|
|
|
117
153
|
this.clear();
|
|
118
154
|
return this.load();
|
|
119
155
|
}
|
|
120
|
-
|
|
121
|
-
|
|
156
|
+
clearFromFilter() {
|
|
157
|
+
this._loaded = false;
|
|
158
|
+
this.store.actions.toc(undefined);
|
|
159
|
+
this.store.actions.pagesToc(undefined);
|
|
160
|
+
}
|
|
161
|
+
async reloadFromFilter(section, page) {
|
|
162
|
+
var _a, _b, _c;
|
|
163
|
+
this.clearFromFilter();
|
|
164
|
+
const { scrollTarget, visibleTopics, currentPage } = this.store.getState();
|
|
165
|
+
const tocId = (_c = (_b = (_a = scrollTarget === null || scrollTarget === void 0 ? void 0 : scrollTarget.tocId) !== null && _a !== void 0 ? _a : visibleTopics === null || visibleTopics === void 0 ? void 0 : visibleTopics[0]) !== null && _b !== void 0 ? _b : currentPage === null || currentPage === void 0 ? void 0 : currentPage.rootTocId) !== null && _c !== void 0 ? _c : "root";
|
|
166
|
+
await this.fetchDataFromFilter();
|
|
167
|
+
this.navigateToTopic(tocId, section, page);
|
|
168
|
+
}
|
|
169
|
+
async fetchDataFromFilter() {
|
|
170
|
+
var _a, _b, _c, _d;
|
|
171
|
+
const translationSettings = this.getTranslationSettings();
|
|
122
172
|
try {
|
|
123
|
-
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
|
|
173
|
+
await Promise.all([
|
|
174
|
+
(_a = this.service) === null || _a === void 0 ? void 0 : _a.getToc(translationSettings).then((toc) => this.store.actions.toc(toc)),
|
|
175
|
+
(_b = this.service) === null || _b === void 0 ? void 0 : _b.getPagesToc(translationSettings).then((pagesToc) => this.store.actions.pagesToc(pagesToc)),
|
|
176
|
+
(_c = this.service) === null || _c === void 0 ? void 0 : _c.getFilteredTocNodes(translationSettings).then((filteredTocNodes) => this.store.actions.filteredTocNodes(filteredTocNodes)),
|
|
177
|
+
]);
|
|
178
|
+
this._loaded = true;
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
if (!(e instanceof CanceledPromiseError)) {
|
|
127
182
|
if (translationSettings) {
|
|
128
183
|
this.setTranslationError(true);
|
|
129
184
|
}
|
|
185
|
+
(_d = this.errorHandler) === null || _d === void 0 ? void 0 : _d.call(this, e);
|
|
130
186
|
throw e;
|
|
131
|
-
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async fetchData() {
|
|
191
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
192
|
+
const translationSettings = this.getTranslationSettings();
|
|
193
|
+
try {
|
|
194
|
+
if (translationSettings) {
|
|
195
|
+
this.setTranslationLoading(true);
|
|
196
|
+
}
|
|
132
197
|
await Promise.all([
|
|
133
198
|
this.loadConfiguration(),
|
|
134
|
-
(_a = this.service) === null || _a === void 0 ? void 0 : _a.getMap(translationSettings).then((map) => this.store.actions.map(map))
|
|
135
|
-
(_b = this.service) === null || _b === void 0 ? void 0 : _b.getToc(translationSettings).then((toc) => this.store.actions.toc(toc))
|
|
136
|
-
(_c = this.service) === null || _c === void 0 ? void 0 : _c.getPagesToc(translationSettings).then((pagesToc) => this.store.actions.pagesToc(pagesToc))
|
|
137
|
-
(_d = this.service) === null || _d === void 0 ? void 0 : _d.getPaginationConfiguration().then((conf) => this.store.actions.paginationConfiguration(conf))
|
|
138
|
-
(_e = this.service) === null || _e === void 0 ? void 0 : _e.
|
|
199
|
+
(_a = this.service) === null || _a === void 0 ? void 0 : _a.getMap(translationSettings).then((map) => this.store.actions.map(map)),
|
|
200
|
+
(_b = this.service) === null || _b === void 0 ? void 0 : _b.getToc(translationSettings).then((toc) => this.store.actions.toc(toc)),
|
|
201
|
+
(_c = this.service) === null || _c === void 0 ? void 0 : _c.getPagesToc(translationSettings).then((pagesToc) => this.store.actions.pagesToc(pagesToc)),
|
|
202
|
+
(_d = this.service) === null || _d === void 0 ? void 0 : _d.getPaginationConfiguration().then((conf) => this.store.actions.paginationConfiguration(conf)),
|
|
203
|
+
(_e = this.service) === null || _e === void 0 ? void 0 : _e.getFilteredTocNodes(translationSettings).then((filteredTocNodes) => this.store.actions.filteredTocNodes(filteredTocNodes)),
|
|
204
|
+
(_f = this.service) === null || _f === void 0 ? void 0 : _f.getTranslationError(translationSettings).then((translationError) => this.setTranslationError(translationError)),
|
|
139
205
|
]);
|
|
140
206
|
if (this.metadataForSwitchToRelatives.size > 0) {
|
|
141
207
|
this.fetchRelatives();
|
|
@@ -146,8 +212,12 @@ export class FtReaderStateManager {
|
|
|
146
212
|
}
|
|
147
213
|
}
|
|
148
214
|
catch (e) {
|
|
149
|
-
if (
|
|
150
|
-
|
|
215
|
+
if (!(e instanceof CanceledPromiseError)) {
|
|
216
|
+
if (translationSettings) {
|
|
217
|
+
this.setTranslationError(true);
|
|
218
|
+
}
|
|
219
|
+
(_g = this.errorHandler) === null || _g === void 0 ? void 0 : _g.call(this, e);
|
|
220
|
+
throw e;
|
|
151
221
|
}
|
|
152
222
|
}
|
|
153
223
|
}
|
|
@@ -177,7 +247,8 @@ export class FtReaderStateManager {
|
|
|
177
247
|
}
|
|
178
248
|
}
|
|
179
249
|
createClusteringHelper() {
|
|
180
|
-
var _a
|
|
250
|
+
var _a;
|
|
251
|
+
var _b;
|
|
181
252
|
if (this.clusteringHelperProvider) {
|
|
182
253
|
return this.clusteringHelperProvider();
|
|
183
254
|
}
|
|
@@ -214,11 +285,11 @@ export class FtReaderStateManager {
|
|
|
214
285
|
if (destinationLanguage) {
|
|
215
286
|
this.sendDocumentOnDemandTranslateEvent(destinationLanguage);
|
|
216
287
|
}
|
|
217
|
-
await this.loadDebouncer.run(() => this.fetchData(
|
|
288
|
+
await this.loadDebouncer.run(() => this.fetchData());
|
|
218
289
|
}
|
|
219
290
|
async setTranslationSourceLanguage(sourceLanguage) {
|
|
220
291
|
this.store.actions.setTranslationSourceLanguage(sourceLanguage);
|
|
221
|
-
await this.loadDebouncer.run(() => this.fetchData(
|
|
292
|
+
await this.loadDebouncer.run(() => this.fetchData());
|
|
222
293
|
}
|
|
223
294
|
async setTranslationProfileId(profileId) {
|
|
224
295
|
this.store.actions.setTranslationProfileId(profileId);
|
|
@@ -265,7 +336,8 @@ export class FtReaderStateManager {
|
|
|
265
336
|
this.metadataForSwitchToRelatives.delete(id);
|
|
266
337
|
this.updateClusteringHelper();
|
|
267
338
|
}
|
|
268
|
-
getAccurateNavigationData(tocId, currentPage, oldScrollTarget) {
|
|
339
|
+
async getAccurateNavigationData(tocId, currentPage, oldScrollTarget) {
|
|
340
|
+
await this.awaitService();
|
|
269
341
|
return this.service.getAccurateNavigationData(tocId, currentPage === null || currentPage === void 0 ? void 0 : currentPage.number, oldScrollTarget === null || oldScrollTarget === void 0 ? void 0 : oldScrollTarget.section, this.getTranslationSettings());
|
|
270
342
|
}
|
|
271
343
|
buildBreadcrumb(tocId) {
|
|
@@ -300,17 +372,18 @@ export class FtReaderStateManager {
|
|
|
300
372
|
this.store.dispatchEvent(new Event(FtReaderStoreEvents.mapAttachmentsUpdate));
|
|
301
373
|
}
|
|
302
374
|
async getRelativeDocumentUrlForLocale(uiLocale) {
|
|
303
|
-
var _a, _b
|
|
375
|
+
var _a, _b;
|
|
376
|
+
var _c;
|
|
304
377
|
if (this.store.getState().relatives == undefined) {
|
|
305
378
|
await this.fetchRelatives();
|
|
306
379
|
}
|
|
307
|
-
const maybeRelativeResultMap = ClusteringHelper.findResultWithMetadataValue((
|
|
380
|
+
const maybeRelativeResultMap = ClusteringHelper.findResultWithMetadataValue((_c = this.store.getState().relatives) !== null && _c !== void 0 ? _c : [], "ft:locale", uiLocale);
|
|
308
381
|
let targetUrl = accessResultUrl(maybeRelativeResultMap);
|
|
309
382
|
if (targetUrl) {
|
|
310
383
|
const currentTocId = this.store.getState().visibleTopics[0];
|
|
311
|
-
const metadataKey = (
|
|
384
|
+
const metadataKey = (_a = this.store.getState().configuration) === null || _a === void 0 ? void 0 : _a.relativeTopicPivotMetadata;
|
|
312
385
|
if (metadataKey && currentTocId) {
|
|
313
|
-
const maybePivot = await ((
|
|
386
|
+
const maybePivot = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getTopicMetadataValue(currentTocId, metadataKey));
|
|
314
387
|
targetUrl = addPivotQueryParam(targetUrl, maybePivot);
|
|
315
388
|
}
|
|
316
389
|
}
|
|
@@ -376,13 +449,10 @@ export class FtReaderStateManager {
|
|
|
376
449
|
appVersion: apiIntegrationAppVersion,
|
|
377
450
|
sourceLanguage: this.parseLanguageToAnalyticsFormat(map.lang),
|
|
378
451
|
destinationLanguage: this.parseLanguageToAnalyticsFormat(destinationLanguage),
|
|
379
|
-
breadcrumb: breadcrumb.map((item) => {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
title: (_a = item.untranslatedTitle) !== null && _a !== void 0 ? _a : item.title,
|
|
384
|
-
});
|
|
385
|
-
}),
|
|
452
|
+
breadcrumb: breadcrumb.map((item) => { var _a; return ({
|
|
453
|
+
tocId: item.tocId,
|
|
454
|
+
title: (_a = item.untranslatedTitle) !== null && _a !== void 0 ? _a : item.title,
|
|
455
|
+
}); }),
|
|
386
456
|
document: documentWithOriginalTitle,
|
|
387
457
|
profileId,
|
|
388
458
|
});
|
package/build/store/model.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { FtMap, FtPaginationConfiguration, FtPublicationRatingSummary, FtRatingType, FtRatingTypeKeys, FtReaderConfiguration, FtSearchResultClusterEntry, FtSession, FtTocNode, FtTopic, FtTopicRating, FtTranslationLocale } from "@fluid-topics/public-api";
|
|
1
|
+
import { FtMap, FtMetadataFilter, FtPaginationConfiguration, FtPublicationRatingSummary, FtRatingType, FtRatingTypeKeys, FtReaderConfiguration, FtSearchResultClusterEntry, FtSession, FtTocNode, FtTocNodeFiltered, FtTopic, FtTopicRating, FtTranslationLocale } from "@fluid-topics/public-api";
|
|
2
2
|
import { Optional } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
export declare enum FtReaderStoreEvents {
|
|
4
4
|
clusteringHelperCreated = "clustering-helper-created",
|
|
5
5
|
mapAttachmentsUpdate = "map-attachments-update",
|
|
6
6
|
visibleTopicChange = "visible-topic-change",
|
|
7
|
-
requestedTopicNotFound = "requested-topic-not-found"
|
|
7
|
+
requestedTopicNotFound = "requested-topic-not-found",
|
|
8
|
+
requestedTopicFiltered = "requested-topic-filtered"
|
|
9
|
+
}
|
|
10
|
+
export declare class FtRequestedTopicFilteredEvent extends CustomEvent<FtTocNodeFiltered> {
|
|
11
|
+
constructor(filteredNode: FtTocNodeFiltered);
|
|
8
12
|
}
|
|
9
13
|
export interface FtPagesTocNode {
|
|
10
14
|
depth: number;
|
|
@@ -44,6 +48,7 @@ export interface FtReaderState {
|
|
|
44
48
|
toc: Optional<Array<FtReaderTocNode>>;
|
|
45
49
|
pagesToc: Optional<Array<FtPagesTocNode>>;
|
|
46
50
|
paginationConfiguration: Optional<FtPaginationConfiguration>;
|
|
51
|
+
filteredTocNodes: Record<string, FtTocNodeFiltered>;
|
|
47
52
|
currentPage: Optional<FtReaderPage>;
|
|
48
53
|
scrollTarget: Optional<FtReaderScrollTarget>;
|
|
49
54
|
renderedTopics: string[];
|
|
@@ -63,6 +68,7 @@ export interface FtReaderState {
|
|
|
63
68
|
isError: boolean;
|
|
64
69
|
};
|
|
65
70
|
linkPreviewDialogId: Optional<string>;
|
|
71
|
+
metadataFilters: Array<FtMetadataFilter>;
|
|
66
72
|
}
|
|
67
73
|
export interface FtReaderNavigationData {
|
|
68
74
|
mapId: string;
|
|
@@ -73,6 +79,7 @@ export interface FtReaderNavigationData {
|
|
|
73
79
|
page?: number;
|
|
74
80
|
prettyUrl?: string;
|
|
75
81
|
prettyUrlDuplicated: boolean;
|
|
82
|
+
metadataFilters?: Array<FtMetadataFilter>;
|
|
76
83
|
}
|
|
77
84
|
export interface FtTopicRatingSummary {
|
|
78
85
|
rating?: FtTopicRating;
|
package/build/store/model.js
CHANGED
|
@@ -4,7 +4,13 @@ export var FtReaderStoreEvents;
|
|
|
4
4
|
FtReaderStoreEvents["mapAttachmentsUpdate"] = "map-attachments-update";
|
|
5
5
|
FtReaderStoreEvents["visibleTopicChange"] = "visible-topic-change";
|
|
6
6
|
FtReaderStoreEvents["requestedTopicNotFound"] = "requested-topic-not-found";
|
|
7
|
+
FtReaderStoreEvents["requestedTopicFiltered"] = "requested-topic-filtered";
|
|
7
8
|
})(FtReaderStoreEvents || (FtReaderStoreEvents = {}));
|
|
9
|
+
export class FtRequestedTopicFilteredEvent extends CustomEvent {
|
|
10
|
+
constructor(filteredNode) {
|
|
11
|
+
super(FtReaderStoreEvents.requestedTopicFiltered, { detail: filteredNode });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
8
14
|
export var FtReaderFeatures;
|
|
9
15
|
(function (FtReaderFeatures) {
|
|
10
16
|
FtReaderFeatures["FEEDBACK"] = "FEEDBACK";
|
package/build/store/redux.js
CHANGED
|
@@ -30,6 +30,7 @@ export const createReaderStore = (id) => FtReduxStore.get({
|
|
|
30
30
|
map: undefined,
|
|
31
31
|
toc: undefined,
|
|
32
32
|
pagesToc: undefined,
|
|
33
|
+
filteredTocNodes: {},
|
|
33
34
|
paginationConfiguration: undefined,
|
|
34
35
|
currentPage: undefined,
|
|
35
36
|
scrollTarget: undefined,
|
|
@@ -46,6 +47,7 @@ export const createReaderStore = (id) => FtReduxStore.get({
|
|
|
46
47
|
isError: false,
|
|
47
48
|
},
|
|
48
49
|
linkPreviewDialogId: undefined,
|
|
50
|
+
metadataFilters: [],
|
|
49
51
|
},
|
|
50
52
|
reducers: readerStoreStateReducers,
|
|
51
53
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FtMap, FtMapAttachment, FtPaginatedToc, FtRatingSummary, FtRatingType, FtRatingTypeKeys, FtSearchResults, FtTocNode, FtTopic, FtTranslationContent, FtTranslationSettings } from "@fluid-topics/public-api";
|
|
1
|
+
import type { FtMap, FtMapAttachment, FtMetadataFilter, FtPaginatedToc, FtRatingSummary, FtRatingType, FtRatingTypeKeys, FtSearchResults, FtTocNode, FtTopic, FtTranslationContent, FtTranslationSettings } from "@fluid-topics/public-api";
|
|
2
2
|
import { FtReaderService } from "./FtReaderService";
|
|
3
3
|
import { FtReaderFeatures } from "../model";
|
|
4
4
|
export declare class FtOfficialReaderService extends FtReaderService {
|
|
@@ -7,7 +7,7 @@ export declare class FtOfficialReaderService extends FtReaderService {
|
|
|
7
7
|
clear(): void;
|
|
8
8
|
protected fetchMap(mapId: string, translationSettings?: FtTranslationSettings): Promise<FtMap>;
|
|
9
9
|
protected fetchMapRating(mapId: string): Promise<FtRatingSummary>;
|
|
10
|
-
protected fetchPages(mapId: string, translationSettings?: FtTranslationSettings): Promise<FtPaginatedToc>;
|
|
10
|
+
protected fetchPages(mapId: string, metadataFilters?: FtMetadataFilter[], translationSettings?: FtTranslationSettings): Promise<FtPaginatedToc>;
|
|
11
11
|
protected fetchTopicHTMLContent(tocNode: FtTocNode): Promise<string>;
|
|
12
12
|
protected fetchTranslatedTopicHTMLContent(tocNode: FtTocNode, translationSettings: FtTranslationSettings): Promise<FtTranslationContent>;
|
|
13
13
|
protected fetchTopicMetadata(tocNode: FtTocNode): Promise<FtTopic>;
|
|
@@ -16,9 +16,11 @@ export class FtOfficialReaderService extends FtReaderService {
|
|
|
16
16
|
fetchMapRating(mapId) {
|
|
17
17
|
return this.api.getMapRating(mapId);
|
|
18
18
|
}
|
|
19
|
-
async fetchPages(mapId, translationSettings) {
|
|
19
|
+
async fetchPages(mapId, metadataFilters, translationSettings) {
|
|
20
20
|
await this.getMap(translationSettings);
|
|
21
|
-
return
|
|
21
|
+
return (metadataFilters === null || metadataFilters === void 0 ? void 0 : metadataFilters.length)
|
|
22
|
+
? this.api.getFilteredPages(mapId, translationSettings, metadataFilters)
|
|
23
|
+
: this.api.getPages(mapId, this.fingerprint, translationSettings);
|
|
22
24
|
}
|
|
23
25
|
fetchTopicHTMLContent(tocNode) {
|
|
24
26
|
return this.api.getTopicHTMLContent(this.mapId, tocNode.contentId, "DESIGNED_READER", this.fingerprint);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FtPaginatedToc, FtPaginationConfiguration } from "@fluid-topics/public-api";
|
|
1
|
+
import { FtPaginatedToc, FtPaginationConfiguration, FtTocNodeFiltered } from "@fluid-topics/public-api";
|
|
2
2
|
import { FtPagesTocNode, FtReaderPage, FtReaderTocNode } from "../model";
|
|
3
3
|
export type EnrichedToc = {
|
|
4
4
|
paginationConfiguration: FtPaginationConfiguration;
|
|
@@ -10,6 +10,7 @@ export type EnrichedToc = {
|
|
|
10
10
|
pages: Array<FtReaderPage>;
|
|
11
11
|
pageByTocId: Record<string, FtReaderPage>;
|
|
12
12
|
translationError: boolean;
|
|
13
|
+
filteredTocNodes: Record<string, FtTocNodeFiltered>;
|
|
13
14
|
};
|
|
14
15
|
export declare class FtReaderConverter {
|
|
15
16
|
convertPaginatedToc(mapId: string, paginatedToc: FtPaginatedToc): EnrichedToc;
|
|
@@ -19,6 +19,7 @@ class EnrichedTocBuilder {
|
|
|
19
19
|
pages: this.pages,
|
|
20
20
|
pageByTocId: this.pageByTocId,
|
|
21
21
|
translationError: this.paginatedToc.translationError,
|
|
22
|
+
filteredTocNodes: this.paginatedToc.filteredTocNodes,
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
extractPagesToc(nodes, depth, parentTocId) {
|
|
@@ -45,14 +46,15 @@ class EnrichedTocBuilder {
|
|
|
45
46
|
}
|
|
46
47
|
convertNodes(nodes, depth, parentTocId) {
|
|
47
48
|
return nodes.flatMap((node) => {
|
|
48
|
-
var _a
|
|
49
|
+
var _a;
|
|
50
|
+
var _b, _c;
|
|
49
51
|
if (node.tocId == null) {
|
|
50
52
|
return [
|
|
51
|
-
...this.convertSectionNodes((
|
|
53
|
+
...this.convertSectionNodes((_b = node.pageToc) !== null && _b !== void 0 ? _b : [], depth, node.tocId),
|
|
52
54
|
...this.convertNodes(node.children, depth, node.tocId),
|
|
53
55
|
];
|
|
54
56
|
}
|
|
55
|
-
const prettyUrl = (
|
|
57
|
+
const prettyUrl = (_a = node.prettyUrl) === null || _a === void 0 ? void 0 : _a.replace(/^\//, "");
|
|
56
58
|
const enrichedNode = {
|
|
57
59
|
tocId: node.tocId,
|
|
58
60
|
contentId: node.contentId,
|
|
@@ -94,21 +96,22 @@ class EnrichedTocBuilder {
|
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
98
|
buildPage(node, parentTocId) {
|
|
97
|
-
var _a, _b, _c
|
|
98
|
-
|
|
99
|
+
var _a, _b, _c;
|
|
100
|
+
var _d, _e, _f, _g, _h;
|
|
101
|
+
const rootTocId = (_d = node.tocId) !== null && _d !== void 0 ? _d : (_b = (_a = node.pageToc) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.tocId;
|
|
99
102
|
const page = {
|
|
100
103
|
number: this.pages.length + 1,
|
|
101
|
-
title: (
|
|
104
|
+
title: (_e = node.title) !== null && _e !== void 0 ? _e : "",
|
|
102
105
|
untranslatedTitle: node.untranslatedTitle,
|
|
103
106
|
rootTocId: rootTocId !== null && rootTocId !== void 0 ? rootTocId : "root",
|
|
104
|
-
toc: ((
|
|
107
|
+
toc: ((_f = node.pageToc) !== null && _f !== void 0 ? _f : []).map((n) => this.nodeByTocId[n.tocId]),
|
|
105
108
|
topics: [],
|
|
106
109
|
hiddenTopics: [],
|
|
107
110
|
rootDepth: rootTocId ? this.nodeByTocId[rootTocId].depth : 1,
|
|
108
111
|
breadcrumb: parentTocId ? this.buildBreadcrumb(this.nodeByTocId[parentTocId]) : [],
|
|
109
112
|
};
|
|
110
113
|
const add = (tocId, visible) => (visible ? page.topics : page.hiddenTopics).push(tocId);
|
|
111
|
-
const parentsVisibility = (_g = (
|
|
114
|
+
const parentsVisibility = (_g = (_c = node.pageConfiguration) === null || _c === void 0 ? void 0 : _c.parentsVisibility) !== null && _g !== void 0 ? _g : [];
|
|
112
115
|
page.breadcrumb.forEach((tocId, index) => {
|
|
113
116
|
add(tocId, parentsVisibility[index]);
|
|
114
117
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FluidTopicsApi, FtMap, FtMapAttachment, FtMetadata, FtPaginatedToc, FtPaginationConfiguration, FtPublicationRatingSummary, FtRatingSummary, FtRatingTypeKeys, FtReaderConfiguration, FtTocNode, FtTopic, FtTranslationContent, FtTranslationSettings } from "@fluid-topics/public-api";
|
|
1
|
+
import type { FluidTopicsApi, FtMap, FtMapAttachment, FtMetadata, FtMetadataFilter, FtPaginatedToc, FtPaginationConfiguration, FtPublicationRatingSummary, FtRatingSummary, FtRatingTypeKeys, FtReaderConfiguration, FtTocNode, FtTocNodeFiltered, FtTopic, FtTranslationContent, FtTranslationSettings } from "@fluid-topics/public-api";
|
|
2
2
|
import { FtRatingType, FtSearchResults } from "@fluid-topics/public-api";
|
|
3
3
|
import { FtPagesTocNode, FtReaderFeatureAccessData, FtReaderFeatures, FtReaderNavigationData, FtReaderPage, FtReaderTocNode, FtTopicRatingSummary } from "../model";
|
|
4
4
|
import { FtReaderConverter } from "./FtReaderConverter";
|
|
@@ -7,7 +7,7 @@ import { FtReaderBreadcrumb } from "../../models";
|
|
|
7
7
|
export declare abstract class FtReaderService extends FtServiceWithCache {
|
|
8
8
|
protected converter: FtReaderConverter;
|
|
9
9
|
protected abstract fetchMap(mapId: string, translationSettings?: FtTranslationSettings): Promise<FtMap>;
|
|
10
|
-
protected abstract fetchPages(mapId: string, translationSettings?: FtTranslationSettings): Promise<FtPaginatedToc>;
|
|
10
|
+
protected abstract fetchPages(mapId: string, metadataFilters?: FtMetadataFilter[], translationSettings?: FtTranslationSettings): Promise<FtPaginatedToc>;
|
|
11
11
|
protected abstract fetchMapRating(mapId: string): Promise<FtRatingSummary>;
|
|
12
12
|
protected abstract fetchTopicMetadata(tocNode: FtTocNode): Promise<FtTopic>;
|
|
13
13
|
protected abstract fetchTopicHTMLContent(tocNode: FtTocNode): Promise<string>;
|
|
@@ -24,9 +24,12 @@ export declare abstract class FtReaderService extends FtServiceWithCache {
|
|
|
24
24
|
protected abstract getReaderLinkPrefix(): string;
|
|
25
25
|
protected abstract isFeatureAvailable(feature: FtReaderFeatures): boolean;
|
|
26
26
|
private _mapId;
|
|
27
|
+
private _metadataFilters;
|
|
28
|
+
get metadataFilters(): FtMetadataFilter[];
|
|
29
|
+
set metadataFilters(value: FtMetadataFilter[] | undefined);
|
|
27
30
|
get mapId(): string;
|
|
28
31
|
set mapId(value: string | undefined);
|
|
29
|
-
constructor(converter: FtReaderConverter, overrideApi?: FluidTopicsApi, mapId?: string);
|
|
32
|
+
constructor(converter: FtReaderConverter, overrideApi?: FluidTopicsApi, mapId?: string, metadataFilters?: FtMetadataFilter[]);
|
|
30
33
|
private withMapId;
|
|
31
34
|
private initCache;
|
|
32
35
|
clear(): void;
|
|
@@ -41,6 +44,7 @@ export declare abstract class FtReaderService extends FtServiceWithCache {
|
|
|
41
44
|
getToc(translationSettings?: FtTranslationSettings): Promise<Array<FtReaderTocNode>>;
|
|
42
45
|
getPagesToc(translationSettings?: FtTranslationSettings): Promise<Array<FtPagesTocNode>>;
|
|
43
46
|
getTranslationError(translationSettings?: FtTranslationSettings): Promise<boolean>;
|
|
47
|
+
getFilteredTocNodes(translationSettings?: FtTranslationSettings): Promise<Record<string, FtTocNodeFiltered>>;
|
|
44
48
|
getTocNode(tocId: string, translationSettings?: FtTranslationSettings): Promise<FtReaderTocNode>;
|
|
45
49
|
getTocNodeNow(tocId: string, translationInput?: FtTranslationSettings): FtReaderTocNode | undefined;
|
|
46
50
|
getTocNodeNowByUrl(prettyUrlOrMapIdTocId: string, translationInput?: FtTranslationSettings): FtReaderTocNode | undefined;
|
|
@@ -55,7 +59,8 @@ export declare abstract class FtReaderService extends FtServiceWithCache {
|
|
|
55
59
|
getRelativesForDocument(metadataPivotKey: string, metadataPivotValues: string[]): Promise<FtSearchResults>;
|
|
56
60
|
getRelativesForTopicInMap(mapId: string, metadataPivotKey: string, metadataPivotValues: string[]): Promise<FtSearchResults>;
|
|
57
61
|
getAttachmentDownloadLink(id: string): string;
|
|
58
|
-
getLink(tocId?: string, pageNumber?: number, section?: string): string;
|
|
62
|
+
getLink(tocId?: string, pageNumber?: number, section?: string, withMetadataFilter?: boolean): string;
|
|
63
|
+
getLinkWithFilter(tocId?: string, pageNumber?: number, section?: string): string;
|
|
59
64
|
getNavigationData(tocId?: string, pageNumber?: number, section?: string, translationInput?: FtTranslationSettings): FtReaderNavigationData;
|
|
60
65
|
getAccurateNavigationData(tocId?: string, pageNumber?: number, section?: string, translationInput?: FtTranslationSettings): Promise<FtReaderNavigationData>;
|
|
61
66
|
private getRatingSummary;
|