@fluid-topics/ft-reader-topic-content 1.1.27 → 1.1.28

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,7 +8,7 @@ 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 { highlightHtml, highlightHtmlStyles, redux, waitFor } from "@fluid-topics/ft-wc-utils";
11
+ import { highlightHtml, highlightHtmlStyles, redux } 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";
@@ -42,9 +42,11 @@ class FtReaderTopicContent extends FtReaderTopicComponent {
42
42
  }
43
43
  updated(props) {
44
44
  super.updated(props);
45
- this.updateComplete
46
- .then(() => waitFor(() => this.topicContainer))
47
- .then(container => highlightHtml(container, this.searchInDocumentQuery));
45
+ this.updateComplete.then(() => {
46
+ if (this.topicContainer) {
47
+ highlightHtml(this.topicContainer, this.searchInDocumentQuery);
48
+ }
49
+ });
48
50
  }
49
51
  updateContent() {
50
52
  var _a;
@@ -90,7 +90,7 @@
90
90
  </section>
91
91
  `:i.html`
92
92
  <section class="topic-loading"></section>
93
- `}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.contentPreprocessor(t||'<div class="empty-topic"></div>'))).then((t=>this.content=t)).catch((t=>this.error=t)))}contentAvailableCallback(t){var e,i,s,o,n,a,r;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),this.moveSvgInShadowRoot()),(t.has("content")&&this.content||t.has("error")&&this.error)&&performance.mark("fluid_topics__reader_topic_displayed__"+(null===(r=this.tocNode)||void 0===r?void 0:r.tocId))}moveSvgInShadowRoot(){this.shadowRoot.querySelectorAll(".ft-svg-container").forEach((t=>{if(!t.shadowRoot){var e=t.innerHTML;t.innerHTML="";var i=t.attachShadow({mode:"open"}),s=document.createRange().createContextualFragment(e),o=document.importNode(s,!0);i.append(o)}}))}onStoreAvailable(){super.onStoreAvailable(),this.updateContent()}renderTopicContent(){var t,e,s,n;if(this.error)return i.html`
93
+ `}update(t){super.update(t),(t.has("map")||t.has("tocNode"))&&this.updateContent()}updated(t){super.updated(t),this.updateComplete.then((()=>{this.topicContainer&&e.highlightHtml(this.topicContainer,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.contentPreprocessor(t||'<div class="empty-topic"></div>'))).then((t=>this.content=t)).catch((t=>this.error=t)))}contentAvailableCallback(t){var e,i,s,o,n,a,r;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),this.moveSvgInShadowRoot()),(t.has("content")&&this.content||t.has("error")&&this.error)&&performance.mark("fluid_topics__reader_topic_displayed__"+(null===(r=this.tocNode)||void 0===r?void 0:r.tocId))}moveSvgInShadowRoot(){this.shadowRoot.querySelectorAll(".ft-svg-container").forEach((t=>{if(!t.shadowRoot){var e=t.innerHTML;t.innerHTML="";var i=t.attachShadow({mode:"open"}),s=document.createRange().createContextualFragment(e),o=document.importNode(s,!0);i.append(o)}}))}onStoreAvailable(){super.onStoreAvailable(),this.updateContent()}renderTopicContent(){var t,e,s,n;if(this.error)return i.html`
94
94
  <div class="topic-on-error">
95
95
  <ft-icon>WARNING</ft-icon>
96
96
  <div>