@salesforcedevs/docs-components 1.3.150 → 1.3.155-lnb-expand1
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 +2 -2
- package/src/modules/doc/amfReference/amfReference.ts +21 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +74 -41
- package/src/modules/doc/lwcReferenceLayout/lwcReferenceLayout.css +1 -0
- package/src/modules/doc/lwcReferenceLayout/lwcReferenceLayout.html +1 -0
- package/src/modules/doc/lwcReferenceLayout/lwcReferenceLayout.ts +8 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +16 -0
- package/LICENSE +0 -12
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.155-lnb-expand1",
|
|
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": "
|
|
27
|
+
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
|
|
28
28
|
}
|
|
@@ -4,6 +4,7 @@ import { sentenceCase } from "sentence-case";
|
|
|
4
4
|
import qs from "query-string";
|
|
5
5
|
import { AmfModelParser } from "./utils";
|
|
6
6
|
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
7
|
+
import { CoveoAnalyticsClient } from "coveo.analytics";
|
|
7
8
|
import type {
|
|
8
9
|
AmfConfig,
|
|
9
10
|
AmfMetadataTopic,
|
|
@@ -34,6 +35,7 @@ export default class AmfReference extends LightningElement {
|
|
|
34
35
|
@api sidebarHeader!: string;
|
|
35
36
|
@api coveoOrganizationId!: string;
|
|
36
37
|
@api coveoPublicAccessToken!: string;
|
|
38
|
+
@api coveoAnalyticsToken!: string;
|
|
37
39
|
@api coveoAdvancedQueryConfig!: string;
|
|
38
40
|
@api coveoSearchHub!: string;
|
|
39
41
|
@api useOldSidebar?: boolean = false;
|
|
@@ -215,6 +217,19 @@ export default class AmfReference extends LightningElement {
|
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
|
|
220
|
+
private logCoveoPageView() {
|
|
221
|
+
if (this.coveoOrganizationId && this.coveoAnalyticsToken) {
|
|
222
|
+
const ua = new CoveoAnalyticsClient({
|
|
223
|
+
token: this.coveoAnalyticsToken,
|
|
224
|
+
endpoint: `https://${this.coveoOrganizationId}.analytics.org.coveo.com`
|
|
225
|
+
});
|
|
226
|
+
ua.sendViewEvent({
|
|
227
|
+
contentIdKey: "@clickableuri",
|
|
228
|
+
contentIdValue: window.location.href
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
218
233
|
/**
|
|
219
234
|
* Check if the URL hash to see whether this is one we want to redirect
|
|
220
235
|
* See GUS W-10718771 for references where we want hash-based redirects
|
|
@@ -907,6 +922,8 @@ export default class AmfReference extends LightningElement {
|
|
|
907
922
|
this.handleSelectedItem();
|
|
908
923
|
|
|
909
924
|
this.updateDocPhase();
|
|
925
|
+
|
|
926
|
+
this.logCoveoPageView();
|
|
910
927
|
}
|
|
911
928
|
|
|
912
929
|
/**
|
|
@@ -1168,6 +1185,8 @@ export default class AmfReference extends LightningElement {
|
|
|
1168
1185
|
if (referenceItem) {
|
|
1169
1186
|
window.location.href = referenceItem.href;
|
|
1170
1187
|
}
|
|
1188
|
+
|
|
1189
|
+
this.logCoveoPageView();
|
|
1171
1190
|
}
|
|
1172
1191
|
|
|
1173
1192
|
/**
|
|
@@ -1260,6 +1279,8 @@ export default class AmfReference extends LightningElement {
|
|
|
1260
1279
|
}
|
|
1261
1280
|
this.updateDocPhase();
|
|
1262
1281
|
this.selectedSidebarValue = window.location.pathname;
|
|
1282
|
+
|
|
1283
|
+
this.logCoveoPageView();
|
|
1263
1284
|
}
|
|
1264
1285
|
}
|
|
1265
1286
|
|
|
@@ -35,6 +35,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
35
35
|
@api coveoSearchHub!: string;
|
|
36
36
|
@api coveoAdvancedQueryConfig!: string;
|
|
37
37
|
@api useOldSidebar?: boolean = false;
|
|
38
|
+
@api rnbByTabId?: string = "lwc-doc-tab";
|
|
38
39
|
|
|
39
40
|
@api
|
|
40
41
|
get breadcrumbs() {
|
|
@@ -118,6 +119,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
118
119
|
return window.location.pathname;
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
get showTabBasedRNB() {
|
|
123
|
+
return this.rnbByTabId ? true : false;
|
|
124
|
+
}
|
|
125
|
+
|
|
121
126
|
get showBreadcrumbs(): boolean {
|
|
122
127
|
return (
|
|
123
128
|
this.breadcrumbs != null && (this.breadcrumbs as any[]).length > 1
|
|
@@ -136,8 +141,24 @@ export default class ContentLayout extends LightningElement {
|
|
|
136
141
|
);
|
|
137
142
|
this.searchSyncer.init();
|
|
138
143
|
}
|
|
144
|
+
|
|
145
|
+
if (this.showTabBasedRNB) {
|
|
146
|
+
window.addEventListener("tabchanged", this.onTabChanged);
|
|
147
|
+
}
|
|
139
148
|
}
|
|
140
149
|
|
|
150
|
+
onTabChanged = () => {
|
|
151
|
+
this.updateRNB();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
updateRNB = () => {
|
|
155
|
+
const headingElements = this.getHeadingElements();
|
|
156
|
+
headingElements.forEach((headingElement) => {
|
|
157
|
+
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
158
|
+
});
|
|
159
|
+
this.updateTocItems(headingElements);
|
|
160
|
+
};
|
|
161
|
+
|
|
141
162
|
renderedCallback(): void {
|
|
142
163
|
/**
|
|
143
164
|
* Note: We are adding timeout because chrome is optimizing and not triggering recent renderedCallback though elements reference is changed
|
|
@@ -165,6 +186,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
165
186
|
"highlightedtermchange",
|
|
166
187
|
this.updateHighlighted
|
|
167
188
|
);
|
|
189
|
+
|
|
190
|
+
if (this.showTabBasedRNB) {
|
|
191
|
+
window.removeEventListener("tabchanged", this.onTabChanged);
|
|
192
|
+
}
|
|
168
193
|
window.removeEventListener("scroll", this.adjustNavPosition);
|
|
169
194
|
window.removeEventListener("resize", this.adjustNavPosition);
|
|
170
195
|
this.searchSyncer.dispose();
|
|
@@ -184,6 +209,29 @@ export default class ContentLayout extends LightningElement {
|
|
|
184
209
|
}
|
|
185
210
|
};
|
|
186
211
|
|
|
212
|
+
private getHeadingElements() {
|
|
213
|
+
let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
214
|
+
if (this.showTabBasedRNB) {
|
|
215
|
+
const tabPanelListItems =
|
|
216
|
+
document.querySelectorAll("dx-tab-panel-list");
|
|
217
|
+
for (const tabPanelListItem of tabPanelListItems) {
|
|
218
|
+
if (tabPanelListItem.id === this.rnbByTabId) {
|
|
219
|
+
const tabPanelItems =
|
|
220
|
+
tabPanelListItem.querySelectorAll("dx-tab-panel");
|
|
221
|
+
for (const tabPanelItem of tabPanelItems) {
|
|
222
|
+
if (tabPanelItem.active) {
|
|
223
|
+
headingElements =
|
|
224
|
+
tabPanelItem.querySelectorAll(TOC_HEADER_TAG);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return headingElements;
|
|
233
|
+
}
|
|
234
|
+
|
|
187
235
|
/*
|
|
188
236
|
This is a workaround for the global nav sticky header being decoupled from the doc header & doc phase.
|
|
189
237
|
We have to account for the global nav changing height due to animations.
|
|
@@ -243,9 +291,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
243
291
|
);
|
|
244
292
|
|
|
245
293
|
// Adjust scroll margin for doc headings when doc phase is present
|
|
246
|
-
const docHeadingEls =
|
|
247
|
-
document.querySelectorAll("doc-heading")
|
|
248
|
-
);
|
|
294
|
+
const docHeadingEls = this.getHeadingElements();
|
|
249
295
|
docHeadingEls.forEach((docHeadingEl) => {
|
|
250
296
|
docHeadingEl.style.scrollMarginTop = `${
|
|
251
297
|
globalNavHeight +
|
|
@@ -301,7 +347,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
301
347
|
);
|
|
302
348
|
|
|
303
349
|
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
304
|
-
const headingElements =
|
|
350
|
+
const headingElements = this.getHeadingElements();
|
|
305
351
|
for (const headingElement of headingElements) {
|
|
306
352
|
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
307
353
|
const id = headingElement.getAttribute("id");
|
|
@@ -317,47 +363,34 @@ export default class ContentLayout extends LightningElement {
|
|
|
317
363
|
}
|
|
318
364
|
};
|
|
319
365
|
|
|
320
|
-
onSlotChange(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
).assignedElements();
|
|
324
|
-
|
|
325
|
-
if (slotElements.length) {
|
|
326
|
-
this.contentLoaded = true;
|
|
327
|
-
const slotContentElement = slotElements[0];
|
|
328
|
-
const headingElements =
|
|
329
|
-
slotContentElement.ownerDocument?.getElementsByTagName(
|
|
330
|
-
TOC_HEADER_TAG
|
|
331
|
-
);
|
|
332
|
-
|
|
333
|
-
for (const headingElement of headingElements) {
|
|
334
|
-
// Sometimes elements hash is not being set when slot content is wrapped with div
|
|
335
|
-
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
336
|
-
}
|
|
366
|
+
onSlotChange(): void {
|
|
367
|
+
this.updateRNB();
|
|
368
|
+
}
|
|
337
369
|
|
|
338
|
-
|
|
370
|
+
// eslint-disable-next-line no-undef
|
|
371
|
+
private updateTocItems(headingElements: NodeListOf<Element>): void {
|
|
372
|
+
const tocOptions = [];
|
|
339
373
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
374
|
+
for (const headingElement of headingElements) {
|
|
375
|
+
headingElement.id = headingElement.hash;
|
|
376
|
+
|
|
377
|
+
// Update tocOptions from anchorTags only for H2, consider default as 2 as per component
|
|
378
|
+
const headingAriaLevel =
|
|
379
|
+
headingElement.attributes["aria-level"]?.nodeValue || "2";
|
|
380
|
+
const isH2 = headingAriaLevel === "2";
|
|
381
|
+
|
|
382
|
+
if (isH2) {
|
|
383
|
+
const tocItem = {
|
|
384
|
+
anchor: `#${headingElement.hash}`,
|
|
385
|
+
id: headingElement.id,
|
|
386
|
+
label: headingElement.title
|
|
387
|
+
};
|
|
388
|
+
tocOptions.push(tocItem);
|
|
389
|
+
this.tocOptionIdsSet.add(headingElement.id);
|
|
357
390
|
}
|
|
358
|
-
|
|
359
|
-
this._tocOptions = tocOptions;
|
|
360
391
|
}
|
|
392
|
+
|
|
393
|
+
this._tocOptions = tocOptions;
|
|
361
394
|
}
|
|
362
395
|
|
|
363
396
|
private disconnectObserver(): void {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "doc/contentLayout/contentLayout.css";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<template></template>
|
|
@@ -17,6 +17,7 @@ import { LightningElementWithState } from "docBaseElements/lightningElementWithS
|
|
|
17
17
|
import { oldVersionDocInfo } from "docUtils/utils";
|
|
18
18
|
import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
|
|
19
19
|
import { track as trackGTM } from "dxUtils/analytics";
|
|
20
|
+
import { CoveoAnalyticsClient } from "coveo.analytics";
|
|
20
21
|
|
|
21
22
|
// TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
|
|
22
23
|
const handleContentError = (error): void => console.log(error);
|
|
@@ -34,6 +35,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
34
35
|
@api apiDomain = "https://developer.salesforce.com";
|
|
35
36
|
@api coveoOrganizationId!: string;
|
|
36
37
|
@api coveoPublicAccessToken!: string;
|
|
38
|
+
@api coveoAnalyticsToken!: string;
|
|
37
39
|
@api coveoSearchHub!: string;
|
|
38
40
|
|
|
39
41
|
@api
|
|
@@ -434,6 +436,19 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
434
436
|
);
|
|
435
437
|
}
|
|
436
438
|
|
|
439
|
+
async logCoveoPageView() {
|
|
440
|
+
if (this.coveoOrganizationId && this.coveoAnalyticsToken) {
|
|
441
|
+
const ua = new CoveoAnalyticsClient({
|
|
442
|
+
token: this.coveoAnalyticsToken,
|
|
443
|
+
endpoint: `https://${this.coveoOrganizationId}.analytics.org.coveo.com`
|
|
444
|
+
}); // MILES TODO: replace 'fullsalesforce' with coveo organizationid
|
|
445
|
+
ua.sendViewEvent({
|
|
446
|
+
contentIdKey: "@clickableuri",
|
|
447
|
+
contentIdValue: window.location.href
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
437
452
|
async fetchDocument(): Promise<void> {
|
|
438
453
|
this.setState({
|
|
439
454
|
isFetchingDocument: true
|
|
@@ -498,6 +513,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
498
513
|
}
|
|
499
514
|
|
|
500
515
|
async fetchContent(): Promise<void> {
|
|
516
|
+
this.logCoveoPageView();
|
|
501
517
|
this.setState({
|
|
502
518
|
isFetchingContent: true
|
|
503
519
|
});
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|