@salesforcedevs/docs-components 1.28.5-redoc-alpha5 → 1.28.5-redoc-alpha7

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": "1.28.5-redoc-alpha5",
3
+ "version": "1.28.5-redoc-alpha7",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -37,7 +37,7 @@ type NavigationItem = {
37
37
  isExpanded: boolean;
38
38
  children: ParsedMarkdownTopic[];
39
39
  isChildrenLoading: boolean;
40
- renderWith?: string;
40
+ showForwardArrow?: boolean;
41
41
  };
42
42
 
43
43
  export default class AmfReference extends LightningElement {
@@ -499,7 +499,7 @@ export default class AmfReference extends LightningElement {
499
499
  this.isExpandChildrenEnabled(amfConfig.id),
500
500
  children: navItemChildren,
501
501
  isChildrenLoading,
502
- renderWith: this.resolveNavRenderWith(amfConfig)
502
+ showForwardArrow: this.resolveNavRenderWith(amfConfig)
503
503
  };
504
504
  this.parentReferenceUrls.push(amfConfig.href);
505
505
  }
@@ -507,21 +507,19 @@ export default class AmfReference extends LightningElement {
507
507
  }
508
508
 
509
509
  /**
510
- * Determines the `renderWith` value forwarded to the sidebar. Honors any
511
- * value set on the config; otherwise infers `"redoc"` for non-markdown
512
- * references that have no AMF URL (i.e. those rendered by Redoc).
510
+ * Determines whether the sidebar tile should render a forward arrow for
511
+ * this reference. Honors `redoc` set on the config, and also infers it
512
+ * for non-markdown references that have no AMF URL (i.e. those rendered
513
+ * by Redoc).
513
514
  */
514
- private resolveNavRenderWith(amfConfig: AmfConfig): string | undefined {
515
+ private resolveNavRenderWith(amfConfig: AmfConfig): boolean {
515
516
  if (amfConfig.renderWith) {
516
- return amfConfig.renderWith;
517
+ return amfConfig.renderWith === "redoc";
517
518
  }
518
- if (
519
+ return (
519
520
  amfConfig.referenceType !== REFERENCE_TYPES.markdown &&
520
521
  !amfConfig.amf
521
- ) {
522
- return "redoc";
523
- }
524
- return undefined;
522
+ );
525
523
  }
526
524
 
527
525
  /**
@@ -37,7 +37,7 @@ type ReferenceConfig = {
37
37
  const SCROLL_THROTTLE_DELAY = 50;
38
38
  const ELEMENT_TIMEOUT = 10000;
39
39
  const ELEMENT_CHECK_INTERVAL = 100;
40
- const REFERENCES_SEGMENT = "/references";
40
+ const REFERENCES_SEGMENT = "/references/";
41
41
 
42
42
  export default class RedocReference extends LightningElement {
43
43
  private _referenceConfig: ReferenceConfig = { refList: [] };
@@ -93,16 +93,8 @@ export default class RedocReference extends LightningElement {
93
93
  */
94
94
  @api projectTitle: string | null = "All Reference";
95
95
 
96
- private _specTitle: string | null = null;
97
-
98
- /** Title of the currently selected spec, shown beneath the project title. */
99
- @api
100
96
  get specTitle(): string | null {
101
- return this._specTitle || this.getSelectedReference()?.title || null;
102
- }
103
-
104
- set specTitle(value: string | null) {
105
- this._specTitle = value || null;
97
+ return this.getSelectedReference()?.title ?? null;
106
98
  }
107
99
 
108
100
  /**
@@ -119,8 +111,9 @@ export default class RedocReference extends LightningElement {
119
111
  */
120
112
  private onBackClick = (event: Event): void => {
121
113
  event.preventDefault();
122
- if (this.cameFromSameOriginPage()) {
123
- window.history.back();
114
+ const referrerHref = this.getSameOriginReferrerHref();
115
+ if (referrerHref) {
116
+ window.location.href = referrerHref;
124
117
  return;
125
118
  }
126
119
  const fallbackHref = this.getReferencesRootHref();
@@ -130,19 +123,23 @@ export default class RedocReference extends LightningElement {
130
123
  };
131
124
 
132
125
  /**
133
- * Returns true only when the page was reached via in-tab navigation from
134
- * a same-origin page, so `history.back()` is safe to call. Checks both
135
- * `initialHistoryLength` and `document.referrer` since neither signal is
136
- * reliable on its own.
126
+ * Returns the referrer URL when the page was reached via in-tab navigation
127
+ * from a same-origin page; otherwise `null`. Both `initialHistoryLength`
128
+ * and `document.referrer` are checked since neither signal is reliable on
129
+ * its own.
137
130
  */
138
- private cameFromSameOriginPage(): boolean {
131
+ private getSameOriginReferrerHref(): string | null {
139
132
  if (this.initialHistoryLength <= 1 || !document.referrer) {
140
- return false;
133
+ return null;
141
134
  }
142
135
  try {
143
- return new URL(document.referrer).origin === window.location.origin;
136
+ const referrerUrl = new URL(document.referrer);
137
+ if (referrerUrl.origin !== window.location.origin) {
138
+ return null;
139
+ }
140
+ return referrerUrl.href;
144
141
  } catch {
145
- return false;
142
+ return null;
146
143
  }
147
144
  }
148
145