@salesforcedevs/docs-components 0.66.4 → 0.66.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "0.66.4",
3
+ "version": "0.66.5",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "14d718be69bd8599b9ce3520a65dc8f0cb5f17de"
27
+ "gitHead": "df2dbfa015a730f63edd6520662325bac19404a2"
28
28
  }
@@ -138,6 +138,7 @@ export default class AmfReference extends LightningElement {
138
138
  protected _amfConfigMap: Map<string, AmfConfig> = new Map();
139
139
  protected _referenceSetConfig!: ReferenceSetConfig;
140
140
  protected _currentReferenceId = "";
141
+ protected _scrollInterval = 0;
141
142
 
142
143
  protected parentReferenceUrls = [];
143
144
  protected amfMap: Record<string, AmfModelRecord> = {};
@@ -165,6 +166,7 @@ export default class AmfReference extends LightningElement {
165
166
 
166
167
  constructor() {
167
168
  super();
169
+
168
170
  this._boundOnApiNavigationChanged =
169
171
  this.onApiNavigationChanged.bind(this);
170
172
  this._boundUpdateSelectedItemFromUrlQuery =
@@ -180,6 +182,9 @@ export default class AmfReference extends LightningElement {
180
182
  "popstate",
181
183
  this._boundUpdateSelectedItemFromUrlQuery
182
184
  );
185
+ this._scrollInterval = window.setInterval(() => {
186
+ this.saveScroll();
187
+ }, 1000);
183
188
  }
184
189
 
185
190
  disconnectedCallback(): void {
@@ -191,6 +196,15 @@ export default class AmfReference extends LightningElement {
191
196
  "popstate",
192
197
  this._boundUpdateSelectedItemFromUrlQuery
193
198
  );
199
+ window.clearInterval(this._scrollInterval);
200
+ }
201
+
202
+ saveScroll() {
203
+ window.history.replaceState({ scrollValue: document.body.scrollTop }, "", window.location.href);
204
+ }
205
+
206
+ restoreScroll() {
207
+ document.body.scrollTop = document.documentElement.scrollTop = window.history.state.scrollValue;
194
208
  }
195
209
 
196
210
  renderedCallback(): void {
@@ -760,8 +774,9 @@ export default class AmfReference extends LightningElement {
760
774
  if (meta) {
761
775
  // update the encoded url meta param
762
776
  const encodedMeta = this.getUrlEncoded(meta);
777
+
763
778
  window.history.pushState(
764
- {},
779
+ { },
765
780
  "",
766
781
  `${parentReferencePath}?meta=${encodedMeta}`
767
782
  );
@@ -779,7 +794,7 @@ export default class AmfReference extends LightningElement {
779
794
  // update the encoded url meta param
780
795
  const encodedMeta = this.getUrlEncoded(meta);
781
796
  window.history.replaceState(
782
- {},
797
+ window.history.state,
783
798
  "",
784
799
  `${parentReferencePath}?meta=${encodedMeta}`
785
800
  );
@@ -820,6 +835,8 @@ export default class AmfReference extends LightningElement {
820
835
  } else {
821
836
  this.loadMarkdownBasedReference();
822
837
  }
838
+
839
+ this.restoreScroll();
823
840
  }
824
841
 
825
842
  /**
@@ -827,6 +844,9 @@ export default class AmfReference extends LightningElement {
827
844
  * @param event
828
845
  */
829
846
  protected onApiNavigationChanged(): void {
847
+ this.saveScroll();
848
+ document.body.scrollTop = document.documentElement.scrollTop = 0;
849
+
830
850
  const specBasedReference = this.isSpecBasedReference(
831
851
  this._currentReferenceId
832
852
  );
@@ -866,6 +886,7 @@ export default class AmfReference extends LightningElement {
866
886
  elementId: string,
867
887
  meta: string
868
888
  ): void {
889
+
869
890
  this.selectedTopic = {
870
891
  referenceId,
871
892
  parentReferencePath,
@@ -1207,7 +1228,8 @@ export default class AmfReference extends LightningElement {
1207
1228
  window.location.href = redirectReferenceUrl;
1208
1229
  } else {
1209
1230
  // This is for CASE 1,3 and 4 mentioned above, Where we need to update the browser history
1210
- window.history.replaceState({}, "", redirectReferenceUrl);
1231
+ window.history.replaceState(window.history.state, "", redirectReferenceUrl);
1232
+
1211
1233
  }
1212
1234
  }
1213
1235
  }
@@ -1252,6 +1274,9 @@ export default class AmfReference extends LightningElement {
1252
1274
  }
1253
1275
 
1254
1276
  onNavSelect(event: CustomEvent): void {
1277
+ this.saveScroll();
1278
+ document.body.scrollTop = document.documentElement.scrollTop = 0;
1279
+
1255
1280
  const name = event.detail.name;
1256
1281
  if (name) {
1257
1282
  const urlReferenceId = this.getReferenceIdFromUrl(name);
@@ -1327,7 +1352,5 @@ export default class AmfReference extends LightningElement {
1327
1352
  parser: this.amfMap[referenceId].parser,
1328
1353
  id: amfId
1329
1354
  };
1330
-
1331
- window.scrollTo({ top: 0, behavior: "smooth" });
1332
1355
  }
1333
1356
  }
@@ -98,6 +98,7 @@ export default class ContentLayout extends LightningElement {
98
98
  private tocValue?: string = undefined;
99
99
  private observerTimerId = null;
100
100
  private didScrollToSelectedHash = false;
101
+ private _scrollInterval = 0;
101
102
 
102
103
  get showToc(): boolean {
103
104
  return this.tocOptions && this.tocOptions.length > 0;
@@ -120,6 +121,11 @@ export default class ContentLayout extends LightningElement {
120
121
  );
121
122
  this.searchSyncer.init();
122
123
  }
124
+
125
+ this._scrollInterval = window.setInterval(() => {
126
+ this.saveScroll();
127
+ }, 1000);
128
+
123
129
  }
124
130
 
125
131
  renderedCallback(): void {
@@ -132,6 +138,7 @@ export default class ContentLayout extends LightningElement {
132
138
  this.attachInteractionObserver,
133
139
  OBSERVER_ATTACH_WAIT_TIME
134
140
  );
141
+ this.restoreScroll();
135
142
  }
136
143
 
137
144
  disconnectedCallback(): void {
@@ -142,6 +149,16 @@ export default class ContentLayout extends LightningElement {
142
149
  );
143
150
  this.searchSyncer.dispose();
144
151
  this.clearRenderObserverTimer();
152
+
153
+ window.clearInterval(this._scrollInterval);
154
+ }
155
+
156
+ saveScroll() {
157
+ window.history.replaceState({ scrollValue: document.body.scrollTop }, "", window.location.href);
158
+ }
159
+
160
+ restoreScroll() {
161
+ document.body.scrollTop = document.documentElement.scrollTop = window.history.state.scrollValue;
145
162
  }
146
163
 
147
164
  clearRenderObserverTimer = () => {