@salesforcedevs/docs-components 1.23.0 → 1.26.0-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/package.json +2 -2
- package/src/modules/doc/contentLayout/contentLayout.css +34 -0
- package/src/modules/doc/contentLayout/contentLayout.html +20 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +6 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +15 -0
- package/src/modules/doc/xmlContent/xmlContent.html +1 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +36 -0
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +13 -0
- package/LICENSE +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0-alpha",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/lodash.orderby": "4.6.9",
|
|
26
26
|
"@types/lodash.uniqby": "4.7.9"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
|
|
29
29
|
"volta": {
|
|
30
30
|
"node": "20.19.0",
|
|
31
31
|
"yarn": "1.22.19"
|
|
@@ -1 +1,35 @@
|
|
|
1
1
|
@import "docHelpers/contentLayoutStyle";
|
|
2
|
+
|
|
3
|
+
/* New Theme Test Styles */
|
|
4
|
+
@keyframes scroll-text {
|
|
5
|
+
0% {
|
|
6
|
+
transform: translateX(100%);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
100% {
|
|
10
|
+
transform: translateX(-100%);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.new-theme-test {
|
|
15
|
+
background: linear-gradient(135deg, #d4cd00 0%, #83d400 50%, #19a700 100%);
|
|
16
|
+
color: white;
|
|
17
|
+
padding: 12px 24px;
|
|
18
|
+
margin: 0 var(--dx-g-global-header-padding-horizontal, 24px);
|
|
19
|
+
margin-top: var(--dx-g-spacing-md, 16px);
|
|
20
|
+
font-weight: 600;
|
|
21
|
+
font-size: 16px;
|
|
22
|
+
box-shadow: 0 4px 12px rgb(4 212 0 / 30%);
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
border-radius: 8px;
|
|
26
|
+
text-align: center;
|
|
27
|
+
max-width: var(--dx-g-doc-content-max-width);
|
|
28
|
+
margin-left: auto;
|
|
29
|
+
margin-right: auto;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.new-theme-banner span {
|
|
33
|
+
display: inline-block;
|
|
34
|
+
animation: scroll-text 10s linear infinite;
|
|
35
|
+
}
|
|
@@ -23,12 +23,32 @@
|
|
|
23
23
|
<div class="version-wrapper">
|
|
24
24
|
<slot name="version-banner"></slot>
|
|
25
25
|
</div>
|
|
26
|
+
<div class="new-theme-test">
|
|
27
|
+
<span>
|
|
28
|
+
✨ SFDocs is Awesome 🥰 New Theme Update inside Component!!
|
|
29
|
+
</span>
|
|
30
|
+
</div>
|
|
26
31
|
<div class="content-body-container">
|
|
27
32
|
<div class="content-body">
|
|
28
33
|
<doc-breadcrumbs
|
|
29
34
|
lwc:if={showBreadcrumbs}
|
|
30
35
|
breadcrumbs={breadcrumbs}
|
|
31
36
|
></doc-breadcrumbs>
|
|
37
|
+
<div class="read" lwc:if={showReadingTime}>
|
|
38
|
+
<svg
|
|
39
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
40
|
+
width="18"
|
|
41
|
+
height="18"
|
|
42
|
+
viewBox="0 0 52 52"
|
|
43
|
+
>
|
|
44
|
+
<g fill="#3e3e3c">
|
|
45
|
+
<path
|
|
46
|
+
d="m26 2c-13.2 0-24 10.8-24 24s10.8 24 24 24 24-10.8 24-24-10.8-24-24-24z m0 42c-9.9 0-18-8.1-18-18s8.1-18 18-18 18 8.1 18 18-8.1 18-18 18z m3.4-17.8c-0.3-0.3-0.4-0.7-0.4-1.1v-9.6c0-0.8-0.7-1.5-1.5-1.5h-3c-0.8 0-1.5 0.7-1.5 1.5v12.1c0 0.4 0.2 0.8 0.4 1.1l7.4 7.4c0.6 0.6 1.5 0.6 2.1 0l2.1-2.1c0.6-0.6 0.6-1.5 0-2.1l-5.6-5.7z"
|
|
47
|
+
></path>
|
|
48
|
+
</g>
|
|
49
|
+
</svg>
|
|
50
|
+
{readingTime} minute read
|
|
51
|
+
</div>
|
|
32
52
|
<slot onslotchange={onSlotChange}></slot>
|
|
33
53
|
<doc-sprig-survey
|
|
34
54
|
lwc:if={shouldDisplayFeedback}
|
|
@@ -45,6 +45,8 @@ export default class ContentLayout extends LightningElement {
|
|
|
45
45
|
// This is needed for now to prevent failing snapshot tests due to links in the footer
|
|
46
46
|
@api showFooter = false;
|
|
47
47
|
|
|
48
|
+
@api readingTime?: number;
|
|
49
|
+
|
|
48
50
|
@api
|
|
49
51
|
get breadcrumbs() {
|
|
50
52
|
return this._breadcrumbs;
|
|
@@ -137,6 +139,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
137
139
|
);
|
|
138
140
|
}
|
|
139
141
|
|
|
142
|
+
get showReadingTime(): boolean {
|
|
143
|
+
return this.readingTime != null && this.readingTime > 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
140
146
|
connectedCallback(): void {
|
|
141
147
|
const hasParentHighlightListener = closest(
|
|
142
148
|
"doc-xml-content",
|
|
@@ -28,6 +28,21 @@
|
|
|
28
28
|
lwc:if={showBreadcrumbs}
|
|
29
29
|
breadcrumbs={breadcrumbs}
|
|
30
30
|
></doc-breadcrumbs>
|
|
31
|
+
<div class="read" lwc:if={showReadingTime}>
|
|
32
|
+
<svg
|
|
33
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
34
|
+
width="18"
|
|
35
|
+
height="18"
|
|
36
|
+
viewBox="0 0 52 52"
|
|
37
|
+
>
|
|
38
|
+
<g fill="#3e3e3c">
|
|
39
|
+
<path
|
|
40
|
+
d="m26 2c-13.2 0-24 10.8-24 24s10.8 24 24 24 24-10.8 24-24-10.8-24-24-24z m0 42c-9.9 0-18-8.1-18-18s8.1-18 18-18 18 8.1 18 18-8.1 18-18 18z m3.4-17.8c-0.3-0.3-0.4-0.7-0.4-1.1v-9.6c0-0.8-0.7-1.5-1.5-1.5h-3c-0.8 0-1.5 0.7-1.5 1.5v12.1c0 0.4 0.2 0.8 0.4 1.1l7.4 7.4c0.6 0.6 1.5 0.6 2.1 0l2.1-2.1c0.6-0.6 0.6-1.5 0-2.1l-5.6-5.7z"
|
|
41
|
+
></path>
|
|
42
|
+
</g>
|
|
43
|
+
</svg>
|
|
44
|
+
{readingTime} minute read
|
|
45
|
+
</div>
|
|
31
46
|
<slot onslotchange={onSlotChange}></slot>
|
|
32
47
|
<doc-sprig-survey
|
|
33
48
|
lwc:if={shouldDisplayFeedback}
|
|
@@ -41,6 +41,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
41
41
|
}> {
|
|
42
42
|
@api apiDomain = "https://developer.salesforce.com";
|
|
43
43
|
@api hideFooter = false;
|
|
44
|
+
@api displayReadingTime = false;
|
|
44
45
|
|
|
45
46
|
@api
|
|
46
47
|
get allLanguages(): Array<Language> {
|
|
@@ -76,6 +77,10 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
76
77
|
return !this.hideFooter;
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
private get computedReadingTime(): number | undefined {
|
|
81
|
+
return this.displayReadingTime ? this.readingTime : undefined;
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
private searchSyncer = new SearchSyncer({
|
|
80
85
|
callbacks: {
|
|
81
86
|
onSearchChange: (nextSearchString: string): void => {
|
|
@@ -147,6 +152,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
147
152
|
|
|
148
153
|
@track private pageReference: PageReference = {};
|
|
149
154
|
@track breadcrumbs: Array<Breadcrumb> = [];
|
|
155
|
+
@track readingTime?: number;
|
|
150
156
|
|
|
151
157
|
constructor() {
|
|
152
158
|
super();
|
|
@@ -493,6 +499,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
493
499
|
}
|
|
494
500
|
|
|
495
501
|
this.docContent = data.content;
|
|
502
|
+
this.calculateReadingTime(data.content);
|
|
496
503
|
this.addMetatags();
|
|
497
504
|
this.setState({
|
|
498
505
|
isFetchingDocument: false
|
|
@@ -515,6 +522,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
515
522
|
|
|
516
523
|
if (data) {
|
|
517
524
|
this.docContent = data.content;
|
|
525
|
+
this.calculateReadingTime(data.content);
|
|
518
526
|
this.addMetatags();
|
|
519
527
|
|
|
520
528
|
if (!this.pageReference.hash) {
|
|
@@ -760,4 +768,32 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
760
768
|
private get showVersionPicker(): boolean {
|
|
761
769
|
return !this.disableVersion;
|
|
762
770
|
}
|
|
771
|
+
|
|
772
|
+
private calculateReadingTime(content: string): void {
|
|
773
|
+
if (!this.displayReadingTime) {
|
|
774
|
+
this.readingTime = undefined;
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
if (!content) {
|
|
779
|
+
this.readingTime = undefined;
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// Strip HTML tags and get text content
|
|
784
|
+
const div = document.createElement("div");
|
|
785
|
+
div.innerHTML = DOMPurify.sanitize(content);
|
|
786
|
+
const textContent = div.textContent || div.innerText || "";
|
|
787
|
+
|
|
788
|
+
// Count words (split by whitespace and filter out empty strings)
|
|
789
|
+
const wordCount = textContent
|
|
790
|
+
.trim()
|
|
791
|
+
.split(/\s+/)
|
|
792
|
+
.filter((word) => word.length > 0).length;
|
|
793
|
+
|
|
794
|
+
// Calculate reading time: (wordCount / 240) + 1, rounded
|
|
795
|
+
const readingTimeMinutes = Math.round(wordCount / 240 + 1);
|
|
796
|
+
this.readingTime =
|
|
797
|
+
readingTimeMinutes > 0 ? readingTimeMinutes : undefined;
|
|
798
|
+
}
|
|
763
799
|
}
|
|
@@ -24,6 +24,19 @@ doc-breadcrumbs {
|
|
|
24
24
|
margin-bottom: var(--dx-g-spacing-2xl);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
.read {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: var(--dx-g-spacing-xs, 8px);
|
|
31
|
+
margin-bottom: var(--dx-g-spacing-lg, 16px);
|
|
32
|
+
color: var(--dx-g-gray-30, #3e3e3c);
|
|
33
|
+
font-size: var(--dx-g-font-size-sm, 14px);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.read svg {
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
dx-sidebar,
|
|
28
41
|
dx-sidebar-old {
|
|
29
42
|
--dx-c-sidebar-vertical-padding: var(--dx-g-spacing-md);
|
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.
|