@fluid-topics/ft-reader-topic-content 1.1.3 → 1.1.4
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.
|
@@ -8,11 +8,10 @@ import { html, nothing } from "lit";
|
|
|
8
8
|
import { styles } from "./ft-reader-topic-content.css";
|
|
9
9
|
import { FtReaderTopicComponent } from "@fluid-topics/ft-reader-topic-context/build/registration";
|
|
10
10
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
11
|
-
import { redux } from "@fluid-topics/ft-wc-utils";
|
|
11
|
+
import { highlightHtml, highlightHtmlStyles, redux, waitFor } from "@fluid-topics/ft-wc-utils";
|
|
12
12
|
import { property, query, state } from "lit/decorators.js";
|
|
13
13
|
import "@fluid-topics/ft-icon";
|
|
14
14
|
import { context } from "./i18n/TopicContentMessages";
|
|
15
|
-
import { highlightHtml, highlightHtmlStyles } from "@fluid-topics/ft-wc-utils";
|
|
16
15
|
class FtReaderTopicContent extends FtReaderTopicComponent {
|
|
17
16
|
constructor() {
|
|
18
17
|
super(...arguments);
|
|
@@ -43,11 +42,9 @@ class FtReaderTopicContent extends FtReaderTopicComponent {
|
|
|
43
42
|
}
|
|
44
43
|
updated(props) {
|
|
45
44
|
super.updated(props);
|
|
46
|
-
this.updateComplete
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
45
|
+
this.updateComplete
|
|
46
|
+
.then(() => waitFor(() => this.topicContainer))
|
|
47
|
+
.then(container => highlightHtml(container, this.searchInDocumentQuery));
|
|
51
48
|
}
|
|
52
49
|
updateContent() {
|
|
53
50
|
var _a;
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
<span class="ft-i18n">
|
|
77
77
|
${this.i18n(this.context,this.key,...Array.isArray(this.args)?this.args:[])}
|
|
78
78
|
</span>
|
|
79
|
-
`:this.editorMode?"Select a context and a label key.":i.nothing}update(t){super.update(t),this.context&&this.key&&this.
|
|
79
|
+
`:this.editorMode?"Select a context and a label key.":i.nothing}update(t){var e;super.update(t),this.context&&this.key&&this.addI18nMessages(this.context,{[this.key]:null!==(e=this.defaultMessage)&&void 0!==e?e:""})}}H.elementDefinitions={},H.styles=I,Z([e.redux()],H.prototype,"editorMode",void 0),Z([s.property()],H.prototype,"context",void 0),Z([s.property()],H.prototype,"key",void 0),Z([e.jsonProperty([])],H.prototype,"args",void 0),Z([s.property()],H.prototype,"defaultMessage",void 0);class J{static build(t){return new J(t)}static fromGwt(t){return new J(t)}constructor(t){this.name=t,this.properties=new Proxy({},{get:(t,e)=>{const i=e;return t=>({context:this.name,key:i,args:"function"==typeof t?void 0:t,argsProvider:"function"==typeof t?t:void 0})}}),this.messages=new Proxy({},{get:(t,e)=>(...t)=>L.resolveMessage(this.name,e,...t)})}}e.customElement("ft-i18n")(H);const V=J.build("designedReaderTopicContent");var X=function(t,e,i,s){for(var o,n=arguments.length,a=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s,r=t.length-1;r>=0;r--)(o=t[r])&&(a=(n<3?o(a):n>3?o(e,i,a):o(e,i))||a);return n>3&&a&&Object.defineProperty(e,i,a),a};class Y extends p{constructor(){super(...arguments),this.contentPreprocessor=t=>t,this.onContentAvailable=()=>null}render(){var t,e;return this.map&&(this.error||this.content)?i.html`
|
|
80
80
|
<style>
|
|
81
81
|
@import "${null===(t=this.map)||void 0===t?void 0:t.contentStyles.topicStylesheetUrl}";
|
|
82
82
|
</style>
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
</section>
|
|
86
86
|
`:i.html`
|
|
87
87
|
<section class="topic-loading"></section>
|
|
88
|
-
`}update(t){super.update(t),(t.has("map")||t.has("tocNode"))&&this.updateContent()}updated(t){super.updated(t),this.updateComplete.then((
|
|
88
|
+
`}update(t){super.update(t),(t.has("map")||t.has("tocNode"))&&this.updateContent()}updated(t){super.updated(t),this.updateComplete.then((()=>e.waitFor((()=>this.topicContainer)))).then((t=>e.highlightHtml(t,this.searchInDocumentQuery)))}updateContent(){var t;this.error=void 0,this.content=void 0,this.map&&this.tocNode&&(null===(t=this.service)||void 0===t||t.getTopicContent(this.tocNode).then((t=>this.content=t||'<div class="empty-topic"></div>')).catch((t=>this.error=t)))}contentAvailableCallback(t){var e,i,s,o,n,a;if(super.contentAvailableCallback(t),!this.disableContextInteractions&&(null===(e=this.scrollTarget)||void 0===e?void 0:e.section)&&(null===(i=this.tocNode)||void 0===i?void 0:i.tocId)&&(null===(s=this.tocNode)||void 0===s?void 0:s.tocId)===this.scrollTarget.tocId&&this.content){(null!==(n=null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector(`[id="${this.scrollTarget.section}"], [name="${this.scrollTarget.section}"]`))&&void 0!==n?n:this).scrollIntoView({block:"start"}),null===(a=this.stateManager)||void 0===a||a.scrollDone()}this.topicContainer&&this.onContentAvailable(this.topicContainer,this.shadowRoot)}onStoreAvailable(){super.onStoreAvailable(),this.updateContent()}renderTopicContent(){var t,e,s,n;if(this.error)return i.html`
|
|
89
89
|
<div class="topic-on-error">
|
|
90
90
|
<ft-icon>WARNING</ft-icon>
|
|
91
91
|
<div>
|