@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
|
@@ -37,7 +37,7 @@ type NavigationItem = {
|
|
|
37
37
|
isExpanded: boolean;
|
|
38
38
|
children: ParsedMarkdownTopic[];
|
|
39
39
|
isChildrenLoading: boolean;
|
|
40
|
-
|
|
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
|
-
|
|
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
|
|
511
|
-
*
|
|
512
|
-
* references that have no AMF URL (i.e. those rendered
|
|
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):
|
|
515
|
+
private resolveNavRenderWith(amfConfig: AmfConfig): boolean {
|
|
515
516
|
if (amfConfig.renderWith) {
|
|
516
|
-
return amfConfig.renderWith;
|
|
517
|
+
return amfConfig.renderWith === "redoc";
|
|
517
518
|
}
|
|
518
|
-
|
|
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.
|
|
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
|
-
|
|
123
|
-
|
|
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
|
|
134
|
-
* a same-origin page
|
|
135
|
-
*
|
|
136
|
-
*
|
|
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
|
|
131
|
+
private getSameOriginReferrerHref(): string | null {
|
|
139
132
|
if (this.initialHistoryLength <= 1 || !document.referrer) {
|
|
140
|
-
return
|
|
133
|
+
return null;
|
|
141
134
|
}
|
|
142
135
|
try {
|
|
143
|
-
|
|
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
|
|
142
|
+
return null;
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
145
|
|