@fluid-topics/ft-reader-context 2.1.10 → 2.1.12

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.
@@ -23,6 +23,7 @@ export interface FtReaderPage {
23
23
  title: string;
24
24
  untranslatedTitle?: string;
25
25
  rootTocId: string;
26
+ rootDepth: number;
26
27
  toc: Array<FtReaderTocNode>;
27
28
  topics: Array<string>;
28
29
  hiddenTopics: Array<string>;
@@ -90,28 +90,31 @@ class EnrichedTocBuilder {
90
90
  });
91
91
  }
92
92
  buildPage(node, parentTocId) {
93
- var _a, _b, _c, _d, _e, _f, _g, _h;
93
+ var _a, _b, _c, _d, _e, _f, _g;
94
+ const rootTocId = (_a = node.tocId) !== null && _a !== void 0 ? _a : (_b = node.pageToc) === null || _b === void 0 ? void 0 : _b[0].tocId;
94
95
  const page = {
95
96
  number: this.pages.length + 1,
96
- title: (_a = node.title) !== null && _a !== void 0 ? _a : "",
97
+ title: (_c = node.title) !== null && _c !== void 0 ? _c : "",
97
98
  untranslatedTitle: node.untranslatedTitle,
98
- rootTocId: (_d = (_b = node.tocId) !== null && _b !== void 0 ? _b : (_c = node.pageToc) === null || _c === void 0 ? void 0 : _c[0].tocId) !== null && _d !== void 0 ? _d : "root",
99
- toc: ((_e = node.pageToc) !== null && _e !== void 0 ? _e : []).map((n) => this.nodeByTocId[n.tocId]),
99
+ rootTocId: rootTocId !== null && rootTocId !== void 0 ? rootTocId : "root",
100
+ toc: ((_d = node.pageToc) !== null && _d !== void 0 ? _d : []).map((n) => this.nodeByTocId[n.tocId]),
100
101
  topics: [],
101
102
  hiddenTopics: [],
103
+ rootDepth: rootTocId ? this.nodeByTocId[rootTocId].depth : 1,
102
104
  breadcrumb: parentTocId ? this.buildBreadcrumb(this.nodeByTocId[parentTocId]) : [],
103
105
  };
104
106
  const add = (tocId, visible) => (visible ? page.topics : page.hiddenTopics).push(tocId);
105
- const parentsVisibility = (_g = (_f = node.pageConfiguration) === null || _f === void 0 ? void 0 : _f.parentsVisibility) !== null && _g !== void 0 ? _g : [];
107
+ const parentsVisibility = (_f = (_e = node.pageConfiguration) === null || _e === void 0 ? void 0 : _e.parentsVisibility) !== null && _f !== void 0 ? _f : [];
106
108
  page.breadcrumb.forEach((tocId, index) => {
107
109
  add(tocId, parentsVisibility[index]);
108
110
  });
109
111
  if (node.tocId) {
110
112
  add(node.tocId, node.pageConfiguration.isVisible);
111
113
  }
112
- page.topics.push(...this.tocIds((_h = node.pageToc) !== null && _h !== void 0 ? _h : []));
114
+ page.topics.push(...this.tocIds((_g = node.pageToc) !== null && _g !== void 0 ? _g : []));
113
115
  const overridenRootTocId = this.resolveOverridenRootTocIdByParentForcedByPagination(page.breadcrumb, parentsVisibility);
114
116
  page.rootTocId = overridenRootTocId !== null && overridenRootTocId !== void 0 ? overridenRootTocId : page.rootTocId;
117
+ page.rootDepth = overridenRootTocId ? this.nodeByTocId[overridenRootTocId].depth : page.rootDepth;
115
118
  return page;
116
119
  }
117
120
  resolveOverridenRootTocIdByParentForcedByPagination(breadcrumb, visibility) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reader-context",
3
- "version": "2.1.10",
3
+ "version": "2.1.12",
4
4
  "description": "Context block for integrated reader components",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,12 +19,12 @@
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": "2.1.10",
23
- "@fluid-topics/ft-wc-utils": "2.1.10",
22
+ "@fluid-topics/ft-app-context": "2.1.12",
23
+ "@fluid-topics/ft-wc-utils": "2.1.12",
24
24
  "lit": "3.1.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@fluid-topics/public-api": "1.0.129"
28
28
  },
29
- "gitHead": "2e92a83b868bd3944d7f807c6d232e06c63d12fa"
29
+ "gitHead": "832c31851e615afc6a08bf305eb58dd8bc68170f"
30
30
  }