@salesforcedevs/docs-components 1.23.0 → 1.26.0-content

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.23.0",
3
+ "version": "1.26.0-content",
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": "307353d10848546abcb801cbb4bc30c323e3e929",
28
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
29
29
  "volta": {
30
30
  "node": "20.19.0",
31
31
  "yarn": "1.22.19"
@@ -29,6 +29,21 @@
29
29
  lwc:if={showBreadcrumbs}
30
30
  breadcrumbs={breadcrumbs}
31
31
  ></doc-breadcrumbs>
32
+ <div class="read" lwc:if={showReadingTime}>
33
+ <svg
34
+ xmlns="http://www.w3.org/2000/svg"
35
+ width="18"
36
+ height="18"
37
+ viewBox="0 0 52 52"
38
+ >
39
+ <g fill="#3e3e3c">
40
+ <path
41
+ 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"
42
+ ></path>
43
+ </g>
44
+ </svg>
45
+ {readingTime} minute read
46
+ </div>
32
47
  <slot onslotchange={onSlotChange}></slot>
33
48
  <doc-sprig-survey
34
49
  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}
@@ -12,6 +12,7 @@
12
12
  bail-href={sidebarFooterContent.bailHref}
13
13
  bail-label={sidebarFooterContent.bailLabel}
14
14
  show-footer={enableFooter}
15
+ reading-time={computedReadingTime}
15
16
  >
16
17
  <doc-phase
17
18
  slot="version-banner"
@@ -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);
@@ -92,6 +105,7 @@ dx-toc {
92
105
  max-width: 1000px;
93
106
  flex: 1;
94
107
  width: 0;
108
+ overflow-wrap: break-word;
95
109
  }
96
110
 
97
111
  .is-sticky {
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.