@fluid-topics/ft-reader-context 1.2.59 → 1.2.60
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.
|
@@ -136,6 +136,11 @@ class FtReaderContext extends FtLitElementRedux {
|
|
|
136
136
|
await this.stateManager.navigateToPage(this.page);
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
|
+
// Focus on target topic
|
|
140
|
+
if (this.tocId && !this.section) {
|
|
141
|
+
this.stateManager.store.commands.clear(/^focus-topic-/);
|
|
142
|
+
this.stateManager.store.commands.add({ type: `focus-topic-${this.tocId}` });
|
|
143
|
+
}
|
|
139
144
|
}
|
|
140
145
|
registerComponent(e) {
|
|
141
146
|
e.stopPropagation();
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<style>
|
|
11
11
|
@import "${n}"
|
|
12
12
|
</style>
|
|
13
|
-
`}get stateManager(){return this._stateManager==null&&(this._stateManager=lt.build(this.id||(""+Math.round(Math.random()*999e3)).padStart(6,"0"),this.readerServiceProvider),this._stateManager.errorHandler=e=>this.handleLoadError(e),this.addStore(this.stateManager.store,"reader")),this._stateManager}connectedCallback(){super.connectedCallback(),this.stateManager.setMapId(this.mapId),this.stateManager.awaitService().then(e=>{let t=e.fontsStylesheet();if(t&&!window.location.href.startsWith(this.baseUrl)&&!document.querySelector(`head link[href="${t}"]`)){let n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",t),document.head.append(n)}window.FluidTopicsReaderService=new bt(this.stateManager)})}update(e){super.update(e),e.has("readerServiceProvider")&&this.readerServiceProvider&&this.stateManager.initService(this.readerServiceProvider),e.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.lastNotifiedNotFoundRelative=void 0),e.has("searchInDocumentQuery")&&this.searchInDocumentQuery!=null&&this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery),["tocId","section","page","mapId","topicPivot"].some(t=>e.has(t))&&this.mapId&&this.navigateToTarget(),e.has("session")&&this.reload()}contentAvailableCallback(e){var t,n;if(super.contentAvailableCallback(e),(e.has("map")||e.has("toc"))&&this.sendLoadedEventIfLoaded(),e.has("scrollTarget")&&((t=this.scrollTarget)===null||t===void 0?void 0:t.tocId)==null){let i=e.get("scrollTarget");i?.tocId!=null&&this.scrollToTargetDebouncer.run(()=>this.stateManager.getAccurateNavigationData(i.tocId,this.currentPage,i).then(a=>this.dispatchEvent(new ht(a))))}(e.has("visibleTopics")||e.has("scrollTarget"))&&((n=this.scrollTarget)===null||n===void 0?void 0:n.tocId)==null&&Promise.all(this.visibleTopics.map(i=>this.stateManager.getAccurateNavigationData(i,this.currentPage))).then(i=>{let a=i.filter(s=>s!=null&&s.topicTitle!=="").map(s=>({tocId:s.tocId,title:s.topicTitle,page:s.page,prettyUrl:s.prettyUrl,prettyUrlDuplicated:s.prettyUrlDuplicated,breadcrumb:this.stateManager.buildBreadcrumb(s.tocId)}));this.dispatchEvent(new ft(this.map,a))})}clear(){this.stateManager.clear()}async reload(){await this.stateManager.reload()}async navigateToTarget(){await this.stateManager.loaded(),await this.navigationDebouncer.run(async()=>{this.topicPivot!=null?!await this.stateManager.navigateToRelativeTopicIfFound(this.topicPivot)&&this.lastNotifiedNotFoundRelative!==this.mapId+this.topicPivot?(this.dispatchEvent(new gt),this.lastNotifiedNotFoundRelative=this.mapId+this.topicPivot):this.lastNotifiedNotFoundRelative=void 0:this.tocId!=null?await this.stateManager.navigateToTopic(this.tocId,this.section,this.page):this.page!=null&&await this.stateManager.navigateToPage(this.page)})}registerComponent(e){e.stopPropagation();let t=e.composedPath()[0];this.register(t)}register(e){e.setReaderStateManager(this.stateManager)}handleLoadError(e){let t=e;t.status===401?this.dispatchEvent(new mt):t.status===403?this.dispatchEvent(new yt):t.status===404?this.dispatchEvent(new vt):this.dispatchEvent(new pt(e))}reloadBookmarks(){Dn.reloadBookmarks()}async reloadRating(){var e,t;await((e=this.stateManager.service)===null||e===void 0?void 0:e.reloadRating()),(t=this.stateManager.store)===null||t===void 0||t.dispatchEvent(new CustomEvent("rating-changed"))}sendLoadedEventIfLoaded(){this.mapLoadedEventDebouncer.run(()=>{this.map&&this.toc&&this.dispatchEvent(new dt(this.map,this.toc))})}};D.styles=jn;H([(0,B.redux)({store:g.name})],D.prototype,"baseUrl",void 0);H([(0,B.redux)({store:g.name})],D.prototype,"session",void 0);H([(0,ue.property)()],D.prototype,"mapId",void 0);H([(0,ue.property)()],D.prototype,"tocId",void 0);H([(0,ue.property)()],D.prototype,"section",void 0);H([(0,ue.property)()],D.prototype,"topicPivot",void 0);H([(0,ue.property)()],D.prototype,"searchInDocumentQuery",void 0);H([(0,ue.property)({type:Number,converter:{fromAttribute:Hi()}})],D.prototype,"page",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"map",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"toc",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"visibleTopics",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"currentPage",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"scrollTarget",void 0);H([(0,ue.property)({attribute:!1})],D.prototype,"readerServiceProvider",void 0);(0,Bn.customElement)("ft-reader-context")(D);})();
|
|
13
|
+
`}get stateManager(){return this._stateManager==null&&(this._stateManager=lt.build(this.id||(""+Math.round(Math.random()*999e3)).padStart(6,"0"),this.readerServiceProvider),this._stateManager.errorHandler=e=>this.handleLoadError(e),this.addStore(this.stateManager.store,"reader")),this._stateManager}connectedCallback(){super.connectedCallback(),this.stateManager.setMapId(this.mapId),this.stateManager.awaitService().then(e=>{let t=e.fontsStylesheet();if(t&&!window.location.href.startsWith(this.baseUrl)&&!document.querySelector(`head link[href="${t}"]`)){let n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",t),document.head.append(n)}window.FluidTopicsReaderService=new bt(this.stateManager)})}update(e){super.update(e),e.has("readerServiceProvider")&&this.readerServiceProvider&&this.stateManager.initService(this.readerServiceProvider),e.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.lastNotifiedNotFoundRelative=void 0),e.has("searchInDocumentQuery")&&this.searchInDocumentQuery!=null&&this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery),["tocId","section","page","mapId","topicPivot"].some(t=>e.has(t))&&this.mapId&&this.navigateToTarget(),e.has("session")&&this.reload()}contentAvailableCallback(e){var t,n;if(super.contentAvailableCallback(e),(e.has("map")||e.has("toc"))&&this.sendLoadedEventIfLoaded(),e.has("scrollTarget")&&((t=this.scrollTarget)===null||t===void 0?void 0:t.tocId)==null){let i=e.get("scrollTarget");i?.tocId!=null&&this.scrollToTargetDebouncer.run(()=>this.stateManager.getAccurateNavigationData(i.tocId,this.currentPage,i).then(a=>this.dispatchEvent(new ht(a))))}(e.has("visibleTopics")||e.has("scrollTarget"))&&((n=this.scrollTarget)===null||n===void 0?void 0:n.tocId)==null&&Promise.all(this.visibleTopics.map(i=>this.stateManager.getAccurateNavigationData(i,this.currentPage))).then(i=>{let a=i.filter(s=>s!=null&&s.topicTitle!=="").map(s=>({tocId:s.tocId,title:s.topicTitle,page:s.page,prettyUrl:s.prettyUrl,prettyUrlDuplicated:s.prettyUrlDuplicated,breadcrumb:this.stateManager.buildBreadcrumb(s.tocId)}));this.dispatchEvent(new ft(this.map,a))})}clear(){this.stateManager.clear()}async reload(){await this.stateManager.reload()}async navigateToTarget(){await this.stateManager.loaded(),await this.navigationDebouncer.run(async()=>{this.topicPivot!=null?!await this.stateManager.navigateToRelativeTopicIfFound(this.topicPivot)&&this.lastNotifiedNotFoundRelative!==this.mapId+this.topicPivot?(this.dispatchEvent(new gt),this.lastNotifiedNotFoundRelative=this.mapId+this.topicPivot):this.lastNotifiedNotFoundRelative=void 0:this.tocId!=null?await this.stateManager.navigateToTopic(this.tocId,this.section,this.page):this.page!=null&&await this.stateManager.navigateToPage(this.page)}),this.tocId&&!this.section&&(this.stateManager.store.commands.clear(/^focus-topic-/),this.stateManager.store.commands.add({type:`focus-topic-${this.tocId}`}))}registerComponent(e){e.stopPropagation();let t=e.composedPath()[0];this.register(t)}register(e){e.setReaderStateManager(this.stateManager)}handleLoadError(e){let t=e;t.status===401?this.dispatchEvent(new mt):t.status===403?this.dispatchEvent(new yt):t.status===404?this.dispatchEvent(new vt):this.dispatchEvent(new pt(e))}reloadBookmarks(){Dn.reloadBookmarks()}async reloadRating(){var e,t;await((e=this.stateManager.service)===null||e===void 0?void 0:e.reloadRating()),(t=this.stateManager.store)===null||t===void 0||t.dispatchEvent(new CustomEvent("rating-changed"))}sendLoadedEventIfLoaded(){this.mapLoadedEventDebouncer.run(()=>{this.map&&this.toc&&this.dispatchEvent(new dt(this.map,this.toc))})}};D.styles=jn;H([(0,B.redux)({store:g.name})],D.prototype,"baseUrl",void 0);H([(0,B.redux)({store:g.name})],D.prototype,"session",void 0);H([(0,ue.property)()],D.prototype,"mapId",void 0);H([(0,ue.property)()],D.prototype,"tocId",void 0);H([(0,ue.property)()],D.prototype,"section",void 0);H([(0,ue.property)()],D.prototype,"topicPivot",void 0);H([(0,ue.property)()],D.prototype,"searchInDocumentQuery",void 0);H([(0,ue.property)({type:Number,converter:{fromAttribute:Hi()}})],D.prototype,"page",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"map",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"toc",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"visibleTopics",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"currentPage",void 0);H([(0,B.redux)({store:"reader"})],D.prototype,"scrollTarget",void 0);H([(0,ue.property)({attribute:!1})],D.prototype,"readerServiceProvider",void 0);(0,Bn.customElement)("ft-reader-context")(D);})();
|
|
14
14
|
/*! Bundled license information:
|
|
15
15
|
|
|
16
16
|
@lit/reactive-element/css-tag.js:
|