@salesforcedevs/docs-components 1.30.0-fix-alpha → 1.30.1-docs-alpha
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/lwc.config.json +1 -0
- package/package.json +1 -1
- package/src/modules/doc/redocReference/redocReference.ts +49 -24
- package/src/modules/doc/unifiedContentLayout/unifiedContentLayout.css +19 -0
- package/src/modules/doc/unifiedContentLayout/unifiedContentLayout.html +28 -0
- package/src/modules/doc/unifiedContentLayout/unifiedContentLayout.ts +87 -0
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -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
|
|
40
|
+
const DEFAULT_PROJECT_TITLE = "All Reference";
|
|
41
41
|
|
|
42
42
|
export default class RedocReference extends LightningElement {
|
|
43
43
|
private _referenceConfig: ReferenceConfig = { refList: [] };
|
|
@@ -91,19 +91,60 @@ export default class RedocReference extends LightningElement {
|
|
|
91
91
|
* Project title (same value passed to `<doc-header>` as `subtitle`). Used
|
|
92
92
|
* inside the Redoc-rendered UI to label the parent project.
|
|
93
93
|
*/
|
|
94
|
-
@api
|
|
94
|
+
@api
|
|
95
|
+
get projectTitle(): string | null {
|
|
96
|
+
return this.isDocContentType
|
|
97
|
+
? this._projectTitle
|
|
98
|
+
: DEFAULT_PROJECT_TITLE;
|
|
99
|
+
}
|
|
100
|
+
set projectTitle(value: string | null) {
|
|
101
|
+
this._projectTitle = value;
|
|
102
|
+
}
|
|
103
|
+
private _projectTitle: string | null = null;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Href to navigate to when the back link is clicked AND there is no
|
|
107
|
+
* usable referrer (e.g. the user opened the page directly in a fresh
|
|
108
|
+
* tab).
|
|
109
|
+
*/
|
|
110
|
+
@api headerHref: string | null = null;
|
|
111
|
+
|
|
112
|
+
@api
|
|
113
|
+
get contentType(): string {
|
|
114
|
+
return this._contentType;
|
|
115
|
+
}
|
|
116
|
+
set contentType(value: string) {
|
|
117
|
+
this._contentType = value;
|
|
118
|
+
}
|
|
119
|
+
private _contentType: string = "";
|
|
95
120
|
|
|
96
121
|
get specTitle(): string | null {
|
|
97
122
|
return this.getSelectedReference()?.title ?? null;
|
|
98
123
|
}
|
|
99
124
|
|
|
125
|
+
get isDocContentType(): boolean {
|
|
126
|
+
return this.contentType === "docs";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get isReferenceContentType(): boolean {
|
|
130
|
+
return this.contentType === "references";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get isMultiSpecSet(): boolean {
|
|
134
|
+
const refCount = this.referenceConfig?.refList?.length ?? 0;
|
|
135
|
+
return refCount > 1;
|
|
136
|
+
}
|
|
137
|
+
|
|
100
138
|
/**
|
|
101
|
-
* Whether to show the project header
|
|
139
|
+
* Whether to show the project header. Shown for multi-spec reference
|
|
140
|
+
* sets, and for any docs-content spec topic so it always has a back
|
|
141
|
+
* link.
|
|
102
142
|
*/
|
|
103
143
|
get showRedocHeader(): boolean {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
144
|
+
return (
|
|
145
|
+
(this.isReferenceContentType && this.isMultiSpecSet) ||
|
|
146
|
+
this.isDocContentType
|
|
147
|
+
);
|
|
107
148
|
}
|
|
108
149
|
|
|
109
150
|
/**
|
|
@@ -114,11 +155,8 @@ export default class RedocReference extends LightningElement {
|
|
|
114
155
|
const referrerHref = this.getSameOriginReferrerHref();
|
|
115
156
|
if (referrerHref) {
|
|
116
157
|
window.location.href = referrerHref;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const fallbackHref = this.getReferencesRootHref();
|
|
120
|
-
if (fallbackHref) {
|
|
121
|
-
window.location.href = fallbackHref;
|
|
158
|
+
} else if (this.headerHref) {
|
|
159
|
+
window.location.href = this.headerHref;
|
|
122
160
|
}
|
|
123
161
|
};
|
|
124
162
|
|
|
@@ -143,19 +181,6 @@ export default class RedocReference extends LightningElement {
|
|
|
143
181
|
}
|
|
144
182
|
}
|
|
145
183
|
|
|
146
|
-
/**
|
|
147
|
-
* Derives the project's `.../references` root from the current URL by
|
|
148
|
-
* trimming any trailing reference id (and deeper segments). Returns null
|
|
149
|
-
* when the URL doesn't contain a `/references` segment.
|
|
150
|
-
*/
|
|
151
|
-
private getReferencesRootHref(): string | null {
|
|
152
|
-
const { pathname } = window.location;
|
|
153
|
-
const idx = pathname.lastIndexOf(REFERENCES_SEGMENT);
|
|
154
|
-
return idx === -1
|
|
155
|
-
? null
|
|
156
|
-
: pathname.slice(0, idx + REFERENCES_SEGMENT.length);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
184
|
/** When origin is provided, pass it to the footer; otherwise use dx-footer's default. */
|
|
160
185
|
get effectiveFooterOrigin(): string {
|
|
161
186
|
return (
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.content-type-docs doc-phase {
|
|
6
|
+
--doc-c-phase-top: calc(
|
|
7
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
|
|
8
|
+
var(--dx-g-spacing-xl)
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@media screen and (max-width: 768px) {
|
|
13
|
+
.content-type-docs doc-phase {
|
|
14
|
+
--doc-c-phase-top: calc(
|
|
15
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
|
|
16
|
+
40px
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<doc-content-layout
|
|
3
|
+
class="content-type content-type-markdown content-type-docs"
|
|
4
|
+
breadcrumbs={breadcrumbs}
|
|
5
|
+
share-title={shareTitle}
|
|
6
|
+
share-twitter-via={twitterVia}
|
|
7
|
+
sidebar-header={sidebarHeader}
|
|
8
|
+
sidebar-value={sidebarValue}
|
|
9
|
+
sidebar-content={sidebarContent}
|
|
10
|
+
toc-title={tocTitle}
|
|
11
|
+
toc-options={tocOptions}
|
|
12
|
+
toc-aria-level={tocAriaLevel}
|
|
13
|
+
enable-slot-change="true"
|
|
14
|
+
languages={languages}
|
|
15
|
+
language={language}
|
|
16
|
+
show-footer={enableFooter}
|
|
17
|
+
origin={origin}
|
|
18
|
+
dev-center={devCenter}
|
|
19
|
+
brand={brand}
|
|
20
|
+
>
|
|
21
|
+
<doc-phase
|
|
22
|
+
slot="doc-phase"
|
|
23
|
+
lwc:if={docPhaseInfo}
|
|
24
|
+
doc-phase-info={docPhaseInfo}
|
|
25
|
+
></doc-phase>
|
|
26
|
+
<slot></slot>
|
|
27
|
+
</doc-content-layout>
|
|
28
|
+
</template>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import { toJson } from "dxUtils/normalizers";
|
|
3
|
+
import type { OptionWithLink, TreeNode } from "typings/custom";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Per-topic type emitted by the docs content-type parser
|
|
7
|
+
* (see @salesforcedevs/sfdocs-doc-framework: `TopicTypeEnum`). Only `spec`
|
|
8
|
+
* is meaningful inside this component; everything else renders as a plain
|
|
9
|
+
* markdown-style tile.
|
|
10
|
+
*/
|
|
11
|
+
const TOPIC_TYPE_SPEC = "spec";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Translates per-topic `topicType` into the generic `showForwardArrow` flag
|
|
15
|
+
* that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc).
|
|
16
|
+
*/
|
|
17
|
+
function decorateTopicsWithForwardArrow(
|
|
18
|
+
topics: Array<TreeNode & { topicType?: string }> | undefined
|
|
19
|
+
): TreeNode[] | undefined {
|
|
20
|
+
return topics?.map((topic) => {
|
|
21
|
+
const { topicType, ...decorated } = topic;
|
|
22
|
+
if (topicType === TOPIC_TYPE_SPEC) {
|
|
23
|
+
decorated.showForwardArrow = true;
|
|
24
|
+
}
|
|
25
|
+
if (decorated.children) {
|
|
26
|
+
decorated.children = decorateTopicsWithForwardArrow(
|
|
27
|
+
decorated.children
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return decorated;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Wrapper around `doc-content-layout` for the "docs" content type emitted by
|
|
36
|
+
* the `DocsContentTypeParser`.
|
|
37
|
+
*/
|
|
38
|
+
export default class UnifiedContentLayout extends LightningElement {
|
|
39
|
+
@api breadcrumbs: string | null = null;
|
|
40
|
+
@api sidebarHeader?: string;
|
|
41
|
+
@api sidebarValue?: string;
|
|
42
|
+
@api tocTitle?: string;
|
|
43
|
+
@api tocOptions?: string;
|
|
44
|
+
@api tocAriaLevel?: string;
|
|
45
|
+
@api languages?: OptionWithLink[];
|
|
46
|
+
@api language?: string;
|
|
47
|
+
@api devCenter: any = null;
|
|
48
|
+
@api brand: any = null;
|
|
49
|
+
|
|
50
|
+
/** Optional origin URL for the footer MFE (e.g. wp-json endpoint). */
|
|
51
|
+
@api origin: string | null = null;
|
|
52
|
+
|
|
53
|
+
/** Article name from breadcrumbs, used as share title (e.g. for social share). */
|
|
54
|
+
@api shareTitle: string | null = null;
|
|
55
|
+
|
|
56
|
+
/** Optional Twitter "via" handle (e.g. SalesforceDevs) for social share. */
|
|
57
|
+
@api twitterVia: string | null = null;
|
|
58
|
+
|
|
59
|
+
@api hideFooter = false;
|
|
60
|
+
|
|
61
|
+
private _docPhaseInfo: string | null = null;
|
|
62
|
+
private _sidebarContent: unknown = null;
|
|
63
|
+
|
|
64
|
+
@api
|
|
65
|
+
get docPhaseInfo(): string | null {
|
|
66
|
+
return this._docPhaseInfo;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
set docPhaseInfo(value: string | null) {
|
|
70
|
+
this._docPhaseInfo = value || null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@api
|
|
74
|
+
get sidebarContent(): unknown {
|
|
75
|
+
return this._sidebarContent;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
set sidebarContent(value: string) {
|
|
79
|
+
this._sidebarContent = decorateTopicsWithForwardArrow(
|
|
80
|
+
toJson(value)?.topics
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private get enableFooter(): boolean {
|
|
85
|
+
return !this.hideFooter;
|
|
86
|
+
}
|
|
87
|
+
}
|