@fluid-topics/ft-reader-topic-content 1.2.34 → 1.2.36

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.
@@ -7,6 +7,10 @@ import "@fluid-topics/ft-icon";
7
7
  export declare class FtReaderTopicContent extends FtReaderTopicComponent implements FtReaderTopicContentProperties {
8
8
  static styles: import("lit").CSSResult[];
9
9
  map?: FtMap;
10
+ private translationProfileId?;
11
+ private translationDestinationLanguage?;
12
+ private translationLoading?;
13
+ private translationError?;
10
14
  scrollTarget?: FtReaderScrollTarget;
11
15
  content?: string;
12
16
  error?: Error;
@@ -24,4 +28,5 @@ export declare class FtReaderTopicContent extends FtReaderTopicComponent impleme
24
28
  protected onStoreAvailable(): void;
25
29
  renderTopicContent(): import("lit-html").TemplateResult<1>;
26
30
  private is404Error;
31
+ private getTopicLanguage;
27
32
  }
@@ -19,7 +19,7 @@ class FtReaderTopicContent extends FtReaderTopicComponent {
19
19
  this.onContentAvailable = () => null;
20
20
  }
21
21
  render() {
22
- var _a, _b;
22
+ var _a;
23
23
  if (!this.map || (!this.error && !this.content)) {
24
24
  return html `
25
25
  <section class="topic-loading"></section>
@@ -29,14 +29,14 @@ class FtReaderTopicContent extends FtReaderTopicComponent {
29
29
  <style>
30
30
  @import "${(_a = this.map) === null || _a === void 0 ? void 0 : _a.contentStyles.topicStylesheetUrl}";
31
31
  </style>
32
- <section class="topic" lang="${(_b = this.map) === null || _b === void 0 ? void 0 : _b.lang}">
32
+ <section class="topic" lang="${this.getTopicLanguage()}">
33
33
  ${this.renderTopicContent()}
34
34
  </section>
35
35
  `;
36
36
  }
37
37
  update(props) {
38
38
  super.update(props);
39
- if (props.has("map") || props.has("tocNode")) {
39
+ if (["map", "tocNode", "translationDestinationLanguage", "translationProfileId"].some(p => props.has(p))) {
40
40
  this.updateContent();
41
41
  }
42
42
  }
@@ -45,7 +45,7 @@ class FtReaderTopicContent extends FtReaderTopicComponent {
45
45
  this.error = undefined;
46
46
  this.content = undefined;
47
47
  if (this.map && this.tocNode) {
48
- (_a = this.service) === null || _a === void 0 ? void 0 : _a.getTopicContent(this.tocNode).then(content => this.contentPreprocessor(content || "<div class=\"empty-topic\"></div>")).then(content => this.content = content).catch(e => this.error = e);
48
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.fetchTopicContent(this.tocNode).then(content => this.contentPreprocessor(content || "<div class=\"empty-topic\"></div>")).then(content => this.content = content).catch(e => this.error = e);
49
49
  }
50
50
  }
51
51
  contentAvailableCallback(props) {
@@ -117,7 +117,7 @@ class FtReaderTopicContent extends FtReaderTopicComponent {
117
117
  this.updateContent();
118
118
  }
119
119
  renderTopicContent() {
120
- var _a, _b, _c, _d;
120
+ var _a, _b, _c;
121
121
  if (this.error) {
122
122
  return html `
123
123
  <div class="topic-on-error">
@@ -129,15 +129,22 @@ class FtReaderTopicContent extends FtReaderTopicComponent {
129
129
  `;
130
130
  }
131
131
  const customClasses = (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.contentStyles.customCssClasses.join(" ")) !== null && _b !== void 0 ? _b : "";
132
- return html `
133
- <div class="depth-${(_c = this.tocNode) === null || _c === void 0 ? void 0 : _c.depth} content-locale-${(_d = this.map) === null || _d === void 0 ? void 0 : _d.lang} ${customClasses}">
134
- ${this.content != null ? unsafeHTML(`${this.content}`) : nothing}
135
- </div>
136
- `;
132
+ return this.translationLoading
133
+ ? html `
134
+ <ft-skeleton></ft-skeleton>`
135
+ : html `
136
+ <div class="depth-${(_c = this.tocNode) === null || _c === void 0 ? void 0 : _c.depth} content-locale-${this.getTopicLanguage()} ${customClasses}">
137
+ ${this.content != null ? unsafeHTML(`${this.content}`) : nothing}
138
+ </div>
139
+ `;
137
140
  }
138
141
  is404Error() {
139
142
  return this.error.status === 404;
140
143
  }
144
+ getTopicLanguage() {
145
+ var _a;
146
+ return (this.translationDestinationLanguage && !this.translationError) ? this.translationDestinationLanguage.code : (_a = this.map) === null || _a === void 0 ? void 0 : _a.lang;
147
+ }
141
148
  }
142
149
  FtReaderTopicContent.styles = [
143
150
  styles,
@@ -146,6 +153,18 @@ FtReaderTopicContent.styles = [
146
153
  __decorate([
147
154
  redux()
148
155
  ], FtReaderTopicContent.prototype, "map", void 0);
156
+ __decorate([
157
+ redux({ selector: (s) => s.translation.profileId })
158
+ ], FtReaderTopicContent.prototype, "translationProfileId", void 0);
159
+ __decorate([
160
+ redux({ selector: (s) => s.translation.destinationLanguage })
161
+ ], FtReaderTopicContent.prototype, "translationDestinationLanguage", void 0);
162
+ __decorate([
163
+ redux({ selector: (s) => s.translation.isLoading })
164
+ ], FtReaderTopicContent.prototype, "translationLoading", void 0);
165
+ __decorate([
166
+ redux({ selector: (s) => s.translation.isError })
167
+ ], FtReaderTopicContent.prototype, "translationError", void 0);
149
168
  __decorate([
150
169
  redux()
151
170
  ], FtReaderTopicContent.prototype, "scrollTarget", void 0);