@salesforcedevs/docs-components 0.7.59-sppage-alpha1 → 0.7.76-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 +3 -0
- package/package.json +9 -4
- package/src/modules/doc/amfReference/amfReference.css +0 -12
- package/src/modules/doc/amfReference/amfReference.html +1 -6
- package/src/modules/doc/amfReference/amfReference.ts +10 -37
- package/src/modules/doc/amfTopic/amfTopic.ts +24 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +0 -1
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +14 -23
- package/src/modules/doc/componentPlayground/componentPlayground.css +30 -0
- package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
- package/src/modules/doc/componentPlayground/componentPlayground.ts +97 -0
- package/src/modules/doc/content/content.html +1 -0
- package/src/modules/doc/content/content.ts +7 -33
- package/src/modules/doc/contentCallout/contentCallout.css +1 -0
- package/src/modules/doc/contentLayout/contentLayout.css +27 -123
- package/src/modules/doc/contentLayout/contentLayout.html +42 -36
- package/src/modules/doc/contentLayout/contentLayout.ts +152 -204
- package/src/modules/doc/contentMedia/contentMedia.css +1 -1
- package/src/modules/doc/header/header.html +8 -3
- package/src/modules/doc/header/header.ts +49 -10
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +9 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +64 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +269 -0
- package/src/modules/doc/phase/phase.css +0 -7
- package/src/modules/doc/redocReference/redocReference.css +7 -0
- package/src/modules/doc/redocReference/redocReference.html +13 -0
- package/src/modules/doc/redocReference/redocReference.ts +427 -0
- package/src/modules/doc/specificationContent/specificationContent.css +33 -0
- package/src/modules/doc/specificationContent/specificationContent.html +94 -16
- package/src/modules/doc/specificationContent/specificationContent.ts +131 -21
- package/src/modules/doc/versionPicker/versionPicker.html +2 -0
- package/src/modules/doc/xmlContent/xmlContent.css +0 -10
- package/src/modules/doc/xmlContent/xmlContent.html +11 -8
- package/src/modules/doc/xmlContent/xmlContent.ts +76 -57
- package/src/modules/docHelpers/amfStyle/amfStyle.css +0 -2
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +160 -0
- package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
- package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
- package/src/modules/docUtils/utils/utils.ts +1 -1
package/lwc.config.json
CHANGED
|
@@ -7,17 +7,20 @@
|
|
|
7
7
|
"expose": [
|
|
8
8
|
"doc/amfReference",
|
|
9
9
|
"doc/breadcrumbs",
|
|
10
|
+
"doc/componentPlayground",
|
|
10
11
|
"doc/content",
|
|
11
12
|
"doc/contentCallout",
|
|
12
13
|
"doc/doDont",
|
|
13
14
|
"doc/contentLayout",
|
|
14
15
|
"doc/contentMedia",
|
|
15
16
|
"doc/docXmlContent",
|
|
17
|
+
"doc/lwcContentLayout",
|
|
16
18
|
"doc/header",
|
|
17
19
|
"doc/heading",
|
|
18
20
|
"doc/headingAnchor",
|
|
19
21
|
"doc/overview",
|
|
20
22
|
"doc/phase",
|
|
23
|
+
"doc/redocReference",
|
|
21
24
|
"doc/specificationContent",
|
|
22
25
|
"doc/versionPicker",
|
|
23
26
|
"doc/xmlContent",
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.76-alpha",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "
|
|
8
|
+
"node": "20.x"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@api-components/amf-helper-mixin": "4.5.
|
|
14
|
+
"@api-components/amf-helper-mixin": "4.5.29",
|
|
15
15
|
"classnames": "2.5.1",
|
|
16
|
+
"dompurify": "3.2.4",
|
|
16
17
|
"kagekiri": "1.4.2",
|
|
17
18
|
"lodash.orderby": "4.6.0",
|
|
18
19
|
"lodash.uniqby": "4.7.0",
|
|
@@ -24,5 +25,9 @@
|
|
|
24
25
|
"@types/lodash.orderby": "4.6.9",
|
|
25
26
|
"@types/lodash.uniqby": "4.7.9"
|
|
26
27
|
},
|
|
27
|
-
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
|
|
28
|
+
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
|
|
29
|
+
"volta": {
|
|
30
|
+
"node": "20.19.0",
|
|
31
|
+
"yarn": "1.22.19"
|
|
32
|
+
}
|
|
28
33
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
doc-phase {
|
|
2
|
-
--doc-c-phase-top: calc(
|
|
3
|
-
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
|
|
4
|
-
var(--dx-g-spacing-xl)
|
|
5
|
-
);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
1
|
/* We need to apply some borders when there are two doc phases */
|
|
9
2
|
doc-phase:not(:only-of-type)::part(container) {
|
|
10
3
|
border-top: 1px solid var(--dx-g-yellow-vibrant-90);
|
|
@@ -15,11 +8,6 @@ doc-phase:nth-child(2)::part(container) {
|
|
|
15
8
|
border-bottom: 1px solid var(--dx-g-yellow-vibrant-90);
|
|
16
9
|
}
|
|
17
10
|
|
|
18
|
-
/* We don't want second component to sticky as we need to handle different cases like position */
|
|
19
|
-
doc-phase:nth-child(2) {
|
|
20
|
-
position: static;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
11
|
.api-documentation {
|
|
24
12
|
margin-top: 48px;
|
|
25
13
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<doc-content-layout
|
|
3
3
|
lwc:if={isVersionFetched}
|
|
4
|
-
use-old-sidebar={useOldSidebar}
|
|
5
4
|
class="content-type content-type-reference"
|
|
6
|
-
coveo-organization-id={coveoOrganizationId}
|
|
7
|
-
coveo-public-access-token={coveoPublicAccessToken}
|
|
8
|
-
coveo-analytics-token={coveoAnalyticsToken}
|
|
9
|
-
coveo-search-hub={coveoSearchHub}
|
|
10
|
-
coveo-advanced-query-config={coveoAdvancedQueryConfig}
|
|
11
5
|
breadcrumbs={breadcrumbs}
|
|
12
6
|
sidebar-header={sidebarHeader}
|
|
13
7
|
sidebar-value={selectedSidebarValue}
|
|
@@ -20,6 +14,7 @@
|
|
|
20
14
|
languages={languages}
|
|
21
15
|
language={language}
|
|
22
16
|
show-footer={enableFooter}
|
|
17
|
+
empty-state-message={emptyStateMessage}
|
|
23
18
|
>
|
|
24
19
|
<doc-phase
|
|
25
20
|
slot="doc-phase"
|
|
@@ -3,7 +3,7 @@ import { noCase } from "no-case";
|
|
|
3
3
|
import { sentenceCase } from "sentence-case";
|
|
4
4
|
import qs from "query-string";
|
|
5
5
|
import { AmfModelParser } from "doc/amfModelParser";
|
|
6
|
-
import { normalizeBoolean
|
|
6
|
+
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
7
7
|
import type { OptionWithLink } from "typings/custom";
|
|
8
8
|
import type {
|
|
9
9
|
AmfConfig,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "./constants";
|
|
29
29
|
import { restoreScroll } from "dx/scrollManager";
|
|
30
30
|
import { DocPhaseInfo } from "typings/custom";
|
|
31
|
-
import {
|
|
31
|
+
import { oldVersionDocInfo } from "docUtils/utils";
|
|
32
32
|
|
|
33
33
|
type NavigationItem = {
|
|
34
34
|
label: string;
|
|
@@ -41,11 +41,6 @@ type NavigationItem = {
|
|
|
41
41
|
export default class AmfReference extends LightningElement {
|
|
42
42
|
@api breadcrumbs: string | null = null;
|
|
43
43
|
@api sidebarHeader!: string;
|
|
44
|
-
@api coveoOrganizationId!: string;
|
|
45
|
-
@api coveoPublicAccessToken!: string;
|
|
46
|
-
@api coveoAnalyticsToken!: string;
|
|
47
|
-
@api coveoSearchHub!: string;
|
|
48
|
-
@api useOldSidebar: boolean = false;
|
|
49
44
|
@api tocTitle?: string;
|
|
50
45
|
@api tocOptions?: string;
|
|
51
46
|
@api languages!: OptionWithLink[];
|
|
@@ -54,7 +49,6 @@ export default class AmfReference extends LightningElement {
|
|
|
54
49
|
@track navigation = [] as NavigationItem[];
|
|
55
50
|
@track versions: Array<ReferenceVersion> = [];
|
|
56
51
|
@track showVersionBanner = false;
|
|
57
|
-
@track _coveoAdvancedQueryConfig!: { [key: string]: any };
|
|
58
52
|
|
|
59
53
|
// Update this to update what component gets rendered in the content block
|
|
60
54
|
@track
|
|
@@ -160,35 +154,18 @@ export default class AmfReference extends LightningElement {
|
|
|
160
154
|
this._expandChildren = normalizeBoolean(value);
|
|
161
155
|
}
|
|
162
156
|
|
|
163
|
-
/*
|
|
164
|
-
* The get coveoAdvancedQueryConfig() method returns this._coveoAdvancedQueryConfig,
|
|
165
|
-
* but before returning it, it checks if there are multiple versions (this.versions.length > 1)
|
|
166
|
-
* and if a version is selected (this.selectedVersion). If both conditions are met,
|
|
167
|
-
* it updates the version property of this._coveoAdvancedQueryConfig with the selected version.
|
|
168
|
-
*/
|
|
169
|
-
@api
|
|
170
|
-
get coveoAdvancedQueryConfig(): { [key: string]: any } {
|
|
171
|
-
const coveoConfig = this._coveoAdvancedQueryConfig;
|
|
172
|
-
if (this.versions.length > 1 && this.selectedVersion) {
|
|
173
|
-
const currentGAVersionRef = this.versions[0];
|
|
174
|
-
if (this.selectedVersion.id !== currentGAVersionRef.id) {
|
|
175
|
-
// Currently Coveo only supports query without "v"
|
|
176
|
-
const version = this.selectedVersion.id.replace("v", "");
|
|
177
|
-
coveoConfig.version = version;
|
|
178
|
-
this._coveoAdvancedQueryConfig = coveoConfig;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return this._coveoAdvancedQueryConfig;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
set coveoAdvancedQueryConfig(config) {
|
|
185
|
-
this._coveoAdvancedQueryConfig = toJson(config);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
157
|
private get enableFooter(): boolean {
|
|
189
158
|
return !this.hideFooter;
|
|
190
159
|
}
|
|
191
160
|
|
|
161
|
+
private get emptyStateMessage(): string {
|
|
162
|
+
return JSON.stringify([
|
|
163
|
+
"Select a relevant API specification",
|
|
164
|
+
"Please consider misspellings",
|
|
165
|
+
"Try different search keywords"
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
|
|
192
169
|
// model
|
|
193
170
|
protected _amfConfigList: AmfConfig[] = [];
|
|
194
171
|
protected _amfConfigMap: Map<string, AmfConfig> = new Map();
|
|
@@ -1436,10 +1413,6 @@ export default class AmfReference extends LightningElement {
|
|
|
1436
1413
|
metaVal
|
|
1437
1414
|
);
|
|
1438
1415
|
|
|
1439
|
-
logCoveoPageView(
|
|
1440
|
-
this.coveoOrganizationId,
|
|
1441
|
-
this.coveoAnalyticsToken
|
|
1442
|
-
);
|
|
1443
1416
|
this.updateUrlWithSelected(parentReferencePath, metaVal);
|
|
1444
1417
|
this.updateTags(metadata.navTitle);
|
|
1445
1418
|
} else {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "./utils";
|
|
10
10
|
import type { TopicModel } from "./types";
|
|
11
11
|
import { Json } from "typings/custom";
|
|
12
|
+
import { buildDocLinkClickHandler } from "dxUtils/analytics";
|
|
12
13
|
|
|
13
14
|
const TABLE_SIZE_MATCH = "769px";
|
|
14
15
|
|
|
@@ -16,6 +17,15 @@ export default class AmfTopic extends LightningElement {
|
|
|
16
17
|
private _model: TopicModel | undefined;
|
|
17
18
|
private amf: Json;
|
|
18
19
|
private type: string | undefined;
|
|
20
|
+
private handleLinkClick = buildDocLinkClickHandler();
|
|
21
|
+
|
|
22
|
+
disconnectedCallback(): void {
|
|
23
|
+
// Remove link click handler
|
|
24
|
+
const container = this.template.querySelector(".topic-container");
|
|
25
|
+
if (container) {
|
|
26
|
+
container.removeEventListener("click", this.handleLinkClick);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
19
29
|
|
|
20
30
|
@api
|
|
21
31
|
get model(): TopicModel | undefined {
|
|
@@ -92,6 +102,15 @@ export default class AmfTopic extends LightningElement {
|
|
|
92
102
|
}
|
|
93
103
|
container?.appendChild(element as Node);
|
|
94
104
|
|
|
105
|
+
// Add click handler for all links in the dynamically loaded content
|
|
106
|
+
if (container) {
|
|
107
|
+
if (this.isLinkTrackingHandledByAncestor()) {
|
|
108
|
+
container.removeEventListener("click", this.handleLinkClick);
|
|
109
|
+
} else {
|
|
110
|
+
container.addEventListener("click", this.handleLinkClick);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
95
114
|
const isTabletOrDesktop = window.matchMedia(
|
|
96
115
|
`(min-width: ${TABLE_SIZE_MATCH})`
|
|
97
116
|
).matches;
|
|
@@ -108,4 +127,9 @@ export default class AmfTopic extends LightningElement {
|
|
|
108
127
|
console.error(error);
|
|
109
128
|
}
|
|
110
129
|
}
|
|
130
|
+
|
|
131
|
+
private isLinkTrackingHandledByAncestor(): boolean {
|
|
132
|
+
const host = this.template.host as HTMLElement | undefined;
|
|
133
|
+
return !!host?.closest?.("doc-content-layout");
|
|
134
|
+
}
|
|
111
135
|
}
|
|
@@ -28,8 +28,8 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
28
28
|
set breadcrumbs(value) {
|
|
29
29
|
this.normalizeAndAssignBreadcrumbs(value);
|
|
30
30
|
this.calculateBreadcrumbsConfigs();
|
|
31
|
-
if (this.
|
|
32
|
-
this.
|
|
31
|
+
if (this.isRendered) {
|
|
32
|
+
this.onWidthOrContentChange();
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -45,9 +45,9 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
45
45
|
private _breadcrumbs: Breadcrumb[] = [];
|
|
46
46
|
private _pixelPerCharacter = CONSTANTS.pixelPerCharacter;
|
|
47
47
|
private navWidth = 0;
|
|
48
|
-
private observer: ResizeObserver | null = null;
|
|
49
48
|
private breadcrumbConfigs: BreadcrumbConfig[] = [];
|
|
50
49
|
private dropdownOptionAmount? = 0;
|
|
50
|
+
private isRendered = false;
|
|
51
51
|
|
|
52
52
|
private get renderSmallVariant(): boolean {
|
|
53
53
|
return (
|
|
@@ -110,30 +110,21 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
private onWidthOrContentChange = () => {
|
|
114
|
+
this.navWidth = this.template
|
|
115
|
+
.querySelector("nav")!
|
|
116
|
+
.getBoundingClientRect().width;
|
|
117
|
+
this.updateDropdownOptionAmount();
|
|
118
|
+
};
|
|
119
|
+
|
|
113
120
|
renderedCallback(): void {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const [nav] = entries;
|
|
118
|
-
if (this.navWidth === nav.contentRect.width) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
this.navWidth = nav.contentRect.width;
|
|
122
|
-
this.updateDropdownOptionAmount();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
this.observer.observe(this.template.querySelector("nav")!);
|
|
126
|
-
} catch (error) {
|
|
127
|
-
console.error(
|
|
128
|
-
"Error occured while setting up ResizeObserver on breadcrumbs",
|
|
129
|
-
error
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
121
|
+
this.isRendered = true;
|
|
122
|
+
this.onWidthOrContentChange();
|
|
123
|
+
window.addEventListener("resize", this.onWidthOrContentChange);
|
|
133
124
|
}
|
|
134
125
|
|
|
135
126
|
disconnectedCallback(): void {
|
|
136
|
-
this.
|
|
127
|
+
window.removeEventListener("resize", this.onWidthOrContentChange);
|
|
137
128
|
}
|
|
138
129
|
|
|
139
130
|
private normalizeAndAssignBreadcrumbs(breadcrumbs?: Breadcrumb[] | string) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Designs link - https://www.figma.com/design/9SalRPlJmtRDZHq03o8dL1/One-Doc-Site-Visionary-Mocks?node-id=9968-366397&m=dev
|
|
5
|
+
* Preview padding: 24px
|
|
6
|
+
* Example Selector height: 122px
|
|
7
|
+
* Example Preview min height: 150px
|
|
8
|
+
* Tab height with border: 46px(45px height and 1px border)
|
|
9
|
+
* Codeblock height: 264px(224px for codeblock and 40px for panel)
|
|
10
|
+
* Total: 606px
|
|
11
|
+
**/
|
|
12
|
+
|
|
13
|
+
:host {
|
|
14
|
+
--playground-iframe-min-height: 500px;
|
|
15
|
+
--playground-iframe-max-height: 5000px;
|
|
16
|
+
|
|
17
|
+
margin-top: var(--dx-g-spacing-md) !important;
|
|
18
|
+
display: block !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
iframe {
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 606px;
|
|
24
|
+
min-height: var(--playground-iframe-min-height);
|
|
25
|
+
max-height: var(--playground-iframe-max-height);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.playground-container {
|
|
29
|
+
position: relative;
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="playground-container" lwc:if={playgroundAvailable}>
|
|
3
|
+
<dx-spinner
|
|
4
|
+
size="large"
|
|
5
|
+
variant="brand"
|
|
6
|
+
if:true={isLoading}
|
|
7
|
+
></dx-spinner>
|
|
8
|
+
<iframe
|
|
9
|
+
src={playgroundSrc}
|
|
10
|
+
onload={handleIframeLoad}
|
|
11
|
+
title={playgroundTitle}
|
|
12
|
+
allow="clipboard-write"
|
|
13
|
+
></iframe>
|
|
14
|
+
</div>
|
|
15
|
+
<dx-error-fallback
|
|
16
|
+
lwc:else
|
|
17
|
+
title="Code Examples Unavailable"
|
|
18
|
+
description="This component's code examples are currently unavailable. Please check again later."
|
|
19
|
+
></dx-error-fallback>
|
|
20
|
+
</template>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
|
|
3
|
+
const PLAYGROUND_HEIGHT_MESSAGE = "PLAYGROUND_HEIGHT_CHANGE";
|
|
4
|
+
const LOADER_TIMEOUT_MS = 2000;
|
|
5
|
+
|
|
6
|
+
export default class ComponentPlayground extends LightningElement {
|
|
7
|
+
@api model!: string;
|
|
8
|
+
@api namespace!: string;
|
|
9
|
+
@api component!: string;
|
|
10
|
+
@api playgroundAppUrl!: string;
|
|
11
|
+
|
|
12
|
+
isLoading = true;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Returns a formatted title for the component playground
|
|
16
|
+
* Maps 'aura' model to 'Aura' and 'lwc' model to 'Lightning'
|
|
17
|
+
* Capitalizes the first letter of the component name
|
|
18
|
+
* @returns {string} Formatted playground title
|
|
19
|
+
*/
|
|
20
|
+
get playgroundTitle() {
|
|
21
|
+
const modelName = this.model === "aura" ? "Aura" : "Lightning";
|
|
22
|
+
const componentName =
|
|
23
|
+
this.component.charAt(0).toUpperCase() + this.component.slice(1);
|
|
24
|
+
return `Example previews and code for ${modelName} ${componentName} component`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get playgroundAvailable() {
|
|
28
|
+
return (
|
|
29
|
+
this.playgroundAppUrl &&
|
|
30
|
+
this.model &&
|
|
31
|
+
this.namespace &&
|
|
32
|
+
this.component
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get playgroundSrc(): string {
|
|
37
|
+
return `${this.playgroundAppUrl}/playground/${this.model}/${
|
|
38
|
+
this.namespace
|
|
39
|
+
}/${this.component.toLowerCase()}.html`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
connectedCallback() {
|
|
43
|
+
window.addEventListener("message", this.handleIframeMessage);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
disconnectedCallback() {
|
|
47
|
+
window.removeEventListener("message", this.handleIframeMessage);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
handleIframeLoad() {
|
|
51
|
+
if (!window.ResizeObserver) {
|
|
52
|
+
// If ResizeObserver not supported, hide loader immediately (no height messages will come)
|
|
53
|
+
this.isLoading = false;
|
|
54
|
+
} else {
|
|
55
|
+
// Hide loader after 2 seconds if no height messages received
|
|
56
|
+
// This handles cases where iframe fails to load, crashes, or height reporting fails
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
this.isLoading = false;
|
|
59
|
+
}, LOADER_TIMEOUT_MS);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
handleIframeMessage = (event: MessageEvent) => {
|
|
64
|
+
// Only handle height change messages from our iframe
|
|
65
|
+
if (event.data?.type !== PLAYGROUND_HEIGHT_MESSAGE) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const iframe = this.template.querySelector(
|
|
70
|
+
"iframe"
|
|
71
|
+
) as HTMLIFrameElement;
|
|
72
|
+
if (!iframe || event.source !== iframe.contentWindow) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const height = event.data?.height;
|
|
77
|
+
if (typeof height === "number" && height > 0) {
|
|
78
|
+
const minHeight = parseInt(
|
|
79
|
+
getComputedStyle(this.template.host).getPropertyValue(
|
|
80
|
+
"--playground-iframe-min-height"
|
|
81
|
+
),
|
|
82
|
+
10
|
|
83
|
+
);
|
|
84
|
+
const maxHeight = parseInt(
|
|
85
|
+
getComputedStyle(this.template.host).getPropertyValue(
|
|
86
|
+
"--playground-iframe-max-height"
|
|
87
|
+
),
|
|
88
|
+
10
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const newHeight = Math.min(Math.max(height, minHeight), maxHeight);
|
|
92
|
+
iframe.style.height = `${newHeight}px`;
|
|
93
|
+
iframe.style.minHeight = `${newHeight}px`;
|
|
94
|
+
this.isLoading = false;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -6,7 +6,6 @@ import Button from "dx/button";
|
|
|
6
6
|
import { highlightTerms } from "dxUtils/highlight";
|
|
7
7
|
import ContentCallout from "doc/contentCallout";
|
|
8
8
|
import ContentMedia from "doc/contentMedia";
|
|
9
|
-
|
|
10
9
|
const HIGHLIGHTABLE_SELECTOR = [
|
|
11
10
|
"p",
|
|
12
11
|
".p",
|
|
@@ -43,26 +42,10 @@ export default class Content extends LightningElement {
|
|
|
43
42
|
return this.docContent;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
@api
|
|
47
|
-
set codeBlockTheme(value) {
|
|
48
|
-
this._codeBlockTheme = value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get codeBlockTheme() {
|
|
52
|
-
return this._codeBlockTheme;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
45
|
@track docContent: DocContent = "";
|
|
56
|
-
_codeBlockTheme: string = "dark";
|
|
57
46
|
_docRendered: boolean = false;
|
|
58
|
-
originalCodeBlockThemeValue: String = "";
|
|
59
47
|
|
|
60
48
|
connectedCallback() {
|
|
61
|
-
this.template.addEventListener(
|
|
62
|
-
"themechange",
|
|
63
|
-
this.updateTheme.bind(this) // eslint-disableline no-use-before-define
|
|
64
|
-
);
|
|
65
|
-
|
|
66
49
|
window.addEventListener(
|
|
67
50
|
"highlightedtermchange",
|
|
68
51
|
this.updateHighlighted
|
|
@@ -76,15 +59,6 @@ export default class Content extends LightningElement {
|
|
|
76
59
|
);
|
|
77
60
|
}
|
|
78
61
|
|
|
79
|
-
updateTheme() {
|
|
80
|
-
this._codeBlockTheme =
|
|
81
|
-
this._codeBlockTheme === "dark" ? "light" : "dark";
|
|
82
|
-
const codeBlockEls = this.template.querySelectorAll("dx-code-block");
|
|
83
|
-
codeBlockEls.forEach((codeBlockEl) => {
|
|
84
|
-
codeBlockEl.setAttribute("theme", this._codeBlockTheme);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
62
|
renderPaginationButton(anchorEl: HTMLElement) {
|
|
89
63
|
const isNext = anchorEl.textContent!.includes("Next →");
|
|
90
64
|
anchorEl.innerHTML = "";
|
|
@@ -116,11 +90,11 @@ export default class Content extends LightningElement {
|
|
|
116
90
|
const codeBlockEls = divEl.querySelectorAll(".codeSection");
|
|
117
91
|
codeBlockEls.forEach((codeBlockEl) => {
|
|
118
92
|
codeBlockEl.setAttribute("lwc:dom", "manual");
|
|
119
|
-
const classList =
|
|
93
|
+
const classList = codeBlockEl.firstElementChild?.classList;
|
|
120
94
|
let language = "";
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const className = classList[
|
|
95
|
+
if (classList) {
|
|
96
|
+
for (let i = 0; i < classList.length; i++) {
|
|
97
|
+
const className = classList[i];
|
|
124
98
|
if (className.startsWith("brush:")) {
|
|
125
99
|
language = className.split(":")[1];
|
|
126
100
|
}
|
|
@@ -133,7 +107,6 @@ export default class Content extends LightningElement {
|
|
|
133
107
|
codeBlock: codeBlockEl.innerHTML,
|
|
134
108
|
// ! Hot fix for incoming html tags from couchdb for xml blocks, fix me soon please
|
|
135
109
|
language: LANGUAGE_MAP[language] || language,
|
|
136
|
-
theme: this.codeBlockTheme,
|
|
137
110
|
header: "", // Default no title.
|
|
138
111
|
variant: this.codeBlockType,
|
|
139
112
|
isEncoded: true
|
|
@@ -158,6 +131,7 @@ export default class Content extends LightningElement {
|
|
|
158
131
|
}
|
|
159
132
|
});
|
|
160
133
|
|
|
134
|
+
// Set a flag to 1 (true) if and only if all detailEls have no content.
|
|
161
135
|
let flag = 1;
|
|
162
136
|
for (let i: number = 0; i < detailEls.length; i++) {
|
|
163
137
|
flag &= (detailEls[i].innerHTML.trim() === "") as any; // Dark Magic TM
|
|
@@ -359,7 +333,7 @@ export default class Content extends LightningElement {
|
|
|
359
333
|
);
|
|
360
334
|
|
|
361
335
|
@api
|
|
362
|
-
public navigateToHash(hash: String) {
|
|
336
|
+
public navigateToHash = (hash: String) => {
|
|
363
337
|
const splitHash = hash.split("#");
|
|
364
338
|
if (splitHash.length === 2) {
|
|
365
339
|
hash = splitHash[1];
|
|
@@ -370,7 +344,7 @@ export default class Content extends LightningElement {
|
|
|
370
344
|
} else {
|
|
371
345
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
372
346
|
}
|
|
373
|
-
}
|
|
347
|
+
};
|
|
374
348
|
|
|
375
349
|
renderedCallback() {
|
|
376
350
|
if (this._docRendered) {
|