@fluid-topics/ft-reader-context 1.3.0 → 1.3.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/build/ft-reader-context.d.ts +2 -0
- package/build/ft-reader-context.js +14 -4
- package/build/ft-reader-context.light.js +8 -8
- package/build/ft-reader-context.min.js +25 -18
- package/build/store/FtReaderStateManager.js +13 -15
- package/build/store/utils/FtReaderService.d.ts +1 -0
- package/build/store/utils/FtReaderService.js +8 -5
- package/package.json +5 -5
|
@@ -56,7 +56,7 @@ export class FtReaderStateManager {
|
|
|
56
56
|
}
|
|
57
57
|
resolveValidNonRootTocId(tocId, page) {
|
|
58
58
|
var _a, _b, _c;
|
|
59
|
-
|
|
59
|
+
const nonRootTocId = (_a = (tocId === "root" ? undefined : tocId)) !== null && _a !== void 0 ? _a : page.rootTocId;
|
|
60
60
|
if (!page.topics.includes(nonRootTocId)) {
|
|
61
61
|
return (_c = (_b = page.topics[0]) !== null && _b !== void 0 ? _b : page.hiddenTopics[0]) !== null && _c !== void 0 ? _c : "root";
|
|
62
62
|
}
|
|
@@ -65,7 +65,7 @@ export class FtReaderStateManager {
|
|
|
65
65
|
async navigateToPage(pageNumber) {
|
|
66
66
|
await this.loaded();
|
|
67
67
|
const service = await this.awaitService();
|
|
68
|
-
|
|
68
|
+
const page = await service.getPage(pageNumber, this.getTranslationSettings());
|
|
69
69
|
this.store.actions.currentPage(page);
|
|
70
70
|
}
|
|
71
71
|
scrollDone() {
|
|
@@ -94,7 +94,7 @@ export class FtReaderStateManager {
|
|
|
94
94
|
destinationLanguage: undefined,
|
|
95
95
|
profileId: undefined,
|
|
96
96
|
isLoading: false,
|
|
97
|
-
isError: false
|
|
97
|
+
isError: false,
|
|
98
98
|
});
|
|
99
99
|
this.store.actions.mapRating(undefined);
|
|
100
100
|
(_a = this.service) === null || _a === void 0 ? void 0 : _a.clear();
|
|
@@ -122,7 +122,7 @@ export class FtReaderStateManager {
|
|
|
122
122
|
(_c = this.service) === null || _c === void 0 ? void 0 : _c.getToc(translationSettings).then(toc => this.store.actions.toc(toc)).catch(handleTranslationError),
|
|
123
123
|
(_d = this.service) === null || _d === void 0 ? void 0 : _d.getPagesToc(translationSettings).then(pagesToc => this.store.actions.pagesToc(pagesToc)).catch(handleTranslationError),
|
|
124
124
|
(_e = this.service) === null || _e === void 0 ? void 0 : _e.getPaginationConfiguration().then(conf => this.store.actions.paginationConfiguration(conf)).catch(handleTranslationError),
|
|
125
|
-
(_f = this.service) === null || _f === void 0 ? void 0 : _f.getTranslationError(translationSettings).then(translationError => this.setTranslationError(translationError))
|
|
125
|
+
(_f = this.service) === null || _f === void 0 ? void 0 : _f.getTranslationError(translationSettings).then(translationError => this.setTranslationError(translationError)),
|
|
126
126
|
]);
|
|
127
127
|
if (this.metadataForSwitchToRelatives.size > 0) {
|
|
128
128
|
this.fetchRelatives();
|
|
@@ -139,10 +139,10 @@ export class FtReaderStateManager {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
fetchRelatives() {
|
|
142
|
-
var _a, _b
|
|
142
|
+
var _a, _b;
|
|
143
143
|
const relativeMetadataValues = (_a = this.store.getState().map) === null || _a === void 0 ? void 0 : _a.metadata.filter((metadata) => { var _a; return metadata.key == ((_a = this.store.getState().configuration) === null || _a === void 0 ? void 0 : _a.relativePivotMetadata); }).flatMap((metadata) => metadata.values);
|
|
144
144
|
if (relativeMetadataValues !== undefined && relativeMetadataValues.length > 0) {
|
|
145
|
-
(_b = this.service) === null || _b === void 0 ? void 0 : _b.getRelativesForDocument(
|
|
145
|
+
(_b = this.service) === null || _b === void 0 ? void 0 : _b.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata, relativeMetadataValues).then((searchResults) => {
|
|
146
146
|
const relatives = searchResults.results.flatMap((result) => result.entries);
|
|
147
147
|
this.store.actions.relatives(relatives);
|
|
148
148
|
this.updateClusteringHelper();
|
|
@@ -163,10 +163,10 @@ export class FtReaderStateManager {
|
|
|
163
163
|
if (this.clusteringHelperProvider) {
|
|
164
164
|
return this.clusteringHelperProvider();
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
const relatives = this.store.getState().relatives;
|
|
167
167
|
if (relatives) {
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
const selectedResult = relatives.find((relative) => { var _a; return ((_a = relative.map) === null || _a === void 0 ? void 0 : _a.mapId) == this.store.getState().mapId; });
|
|
169
|
+
const metadataDescriptors = (_b = (_a = ftAppInfoStore.getState().metadataConfiguration) === null || _a === void 0 ? void 0 : _a.descriptors) !== null && _b !== void 0 ? _b : [];
|
|
170
170
|
return new ClusteringHelper(relatives, selectedResult, this.metadataForSwitchToRelatives, metadataDescriptors);
|
|
171
171
|
}
|
|
172
172
|
return undefined;
|
|
@@ -214,7 +214,7 @@ export class FtReaderStateManager {
|
|
|
214
214
|
return (state.translation.profileId && state.translation.destinationLanguage) ? {
|
|
215
215
|
profileId: state.translation.profileId,
|
|
216
216
|
destinationLanguage: state.translation.destinationLanguage.code,
|
|
217
|
-
sourceLanguage: (_a = state.map) === null || _a === void 0 ? void 0 : _a.lang
|
|
217
|
+
sourceLanguage: (_a = state.map) === null || _a === void 0 ? void 0 : _a.lang,
|
|
218
218
|
} : undefined;
|
|
219
219
|
}
|
|
220
220
|
async fetchMapRating() {
|
|
@@ -250,7 +250,7 @@ export class FtReaderStateManager {
|
|
|
250
250
|
}
|
|
251
251
|
fetchTopicContent(tocNode) {
|
|
252
252
|
var _a, _b;
|
|
253
|
-
|
|
253
|
+
const translationSettings = this.getTranslationSettings();
|
|
254
254
|
if (translationSettings) {
|
|
255
255
|
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getTranslatedTopicContent(tocNode, translationSettings).then(translationContent => {
|
|
256
256
|
if (translationContent.isTranslationError) {
|
|
@@ -264,12 +264,10 @@ export class FtReaderStateManager {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
getTocNode(tocId) {
|
|
267
|
-
|
|
268
|
-
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getTocNode(tocId, this.getTranslationSettings());
|
|
267
|
+
return this.service.getTocNode(tocId, this.getTranslationSettings());
|
|
269
268
|
}
|
|
270
269
|
getPage(targetPageNumber) {
|
|
271
|
-
|
|
272
|
-
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getPage(targetPageNumber, this.getTranslationSettings());
|
|
270
|
+
return this.service.getPage(targetPageNumber, this.getTranslationSettings());
|
|
273
271
|
}
|
|
274
272
|
onMapAttachmentsUpdate() {
|
|
275
273
|
var _a;
|
|
@@ -72,4 +72,5 @@ export declare abstract class FtReaderService extends FtServiceWithCache {
|
|
|
72
72
|
buildBreadcrumb(tocId: string, translationInput?: FtTranslationSettings): Array<FtReaderBreadcrumb>;
|
|
73
73
|
isFeatureAccessible(feature: FtReaderFeatures, { session }: FtReaderFeatureAccessData): boolean;
|
|
74
74
|
makeAbsolute(endpoint: string): string;
|
|
75
|
+
reloadConfiguration(): void;
|
|
75
76
|
}
|
|
@@ -77,7 +77,7 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
77
77
|
}
|
|
78
78
|
getTocNodeNowByUrl(prettyUrlOrMapIdTocId, translationInput) {
|
|
79
79
|
var _a, _b;
|
|
80
|
-
|
|
80
|
+
const map = this.getMapNow(translationInput);
|
|
81
81
|
if ((map === null || map === void 0 ? void 0 : map.prettyUrl) == prettyUrlOrMapIdTocId || `${map === null || map === void 0 ? void 0 : map.id}/root` === prettyUrlOrMapIdTocId) {
|
|
82
82
|
return (_a = this.getEnrichedTocNow(translationInput)) === null || _a === void 0 ? void 0 : _a.toc[0];
|
|
83
83
|
}
|
|
@@ -145,7 +145,7 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
145
145
|
page: pageNumber && page && page.number !== pageNumber ? pageNumber : undefined,
|
|
146
146
|
prettyUrl: prettyUrl != null ? prettyUrl.replace(/^r\//, "") : undefined,
|
|
147
147
|
prettyUrlDuplicated: (_b = enrichedToc === null || enrichedToc === void 0 ? void 0 : enrichedToc.duplicatedPrettyUrls.has(prettyUrl !== null && prettyUrl !== void 0 ? prettyUrl : "")) !== null && _b !== void 0 ? _b : false,
|
|
148
|
-
section: section
|
|
148
|
+
section: section,
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
async getAccurateNavigationData(tocId, pageNumber, section, translationInput) {
|
|
@@ -167,7 +167,7 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
167
167
|
var _a;
|
|
168
168
|
return rm ? {
|
|
169
169
|
type: rm.topics.type,
|
|
170
|
-
rating: (_a = rm.topics) === null || _a === void 0 ? void 0 : _a.ratings.find(t => t.tocId === tocId)
|
|
170
|
+
rating: (_a = rm.topics) === null || _a === void 0 ? void 0 : _a.ratings.find(t => t.tocId === tocId),
|
|
171
171
|
} : undefined;
|
|
172
172
|
});
|
|
173
173
|
}
|
|
@@ -202,8 +202,8 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
202
202
|
return this.api.makeAbsolute(this.api.endpoints.stylesheets.theme);
|
|
203
203
|
}
|
|
204
204
|
buildBreadcrumb(tocId, translationInput) {
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
const target = this.getTocNodeNow(tocId, translationInput);
|
|
206
|
+
const breadcrumb = [{ tocId: target.tocId, title: target.title, untranslatedTitle: target.untranslatedTitle }];
|
|
207
207
|
let parent = this.getTocNodeNow(target.parentTocId, translationInput);
|
|
208
208
|
while (parent) {
|
|
209
209
|
breadcrumb.unshift({ tocId: parent.tocId, title: parent.title, untranslatedTitle: parent.untranslatedTitle });
|
|
@@ -236,4 +236,7 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
236
236
|
makeAbsolute(endpoint) {
|
|
237
237
|
return this.api.makeAbsolute(endpoint);
|
|
238
238
|
}
|
|
239
|
+
reloadConfiguration() {
|
|
240
|
+
this.cache.registerFinal("configuration", () => this.api.getReaderConfiguration());
|
|
241
|
+
}
|
|
239
242
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reader-context",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Context block for integrated reader components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "1.3.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
22
|
+
"@fluid-topics/ft-app-context": "1.3.2",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "1.3.2",
|
|
24
24
|
"@reduxjs/toolkit": "^1.6.2",
|
|
25
25
|
"lit": "3.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@fluid-topics/public-api": "1.0.
|
|
28
|
+
"@fluid-topics/public-api": "1.0.99"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "a583b0f740d044ef603e79b142f96dc74b993f11"
|
|
31
31
|
}
|