@salesforcedevs/docs-components 0.19.4-alpha.1 → 0.23.2

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/LICENSE ADDED
@@ -0,0 +1,12 @@
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "0.19.4-alpha.01",
3
+ "version": "0.23.2",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -14,5 +14,5 @@
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
- "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
17
+ "gitHead": "7fb6594b1fcd187bc3fbbd60908c0deeff7547ef"
18
18
  }
@@ -5,6 +5,23 @@ import ContentCallout from "doc/contentCallout";
5
5
  import CodeBlock from "dx/codeBlock";
6
6
  import ContentMedia from "doc/contentMedia";
7
7
  import Button from "dx/button";
8
+ import { highlightTerms } from "utils/highlight";
9
+
10
+ const HIGHLIGHTABLE_SELECTOR = [
11
+ "p",
12
+ ".p",
13
+ ".shortdesc",
14
+ "h1",
15
+ "h2",
16
+ "h3",
17
+ "h4",
18
+ "h5",
19
+ "h6",
20
+ "li",
21
+ "dl",
22
+ "th",
23
+ "td"
24
+ ].join(",");
8
25
 
9
26
  const LANGUAGE_MAP: { [key: string]: string } = {
10
27
  js: "javascript"
@@ -45,6 +62,18 @@ export default class Content extends LightningElement {
45
62
  "themechange",
46
63
  this.updateTheme.bind(this) // eslint-disableline no-use-before-define
47
64
  );
65
+
66
+ window.addEventListener(
67
+ "highlightedtermchange",
68
+ this.updateHighlighted
69
+ );
70
+ }
71
+
72
+ disconnectedCallback(): void {
73
+ window.removeEventListener(
74
+ "highlightedtermchange",
75
+ this.updateHighlighted
76
+ );
48
77
  }
49
78
 
50
79
  updateTheme() {
@@ -154,7 +183,9 @@ export default class Content extends LightningElement {
154
183
  }
155
184
  }
156
185
 
157
- if (!anchorEl.href.includes("/docs/")) {
186
+ // ! This is a hack
187
+ // Normalize urls in case it doesn't come complete.
188
+ if (anchorEl.href.startsWith("atlas.")) {
158
189
  anchorEl.href = "/docs/" + anchorEl.href;
159
190
  }
160
191
 
@@ -308,6 +339,12 @@ export default class Content extends LightningElement {
308
339
  }
309
340
  }
310
341
 
342
+ updateHighlighted = (event: any) =>
343
+ highlightTerms(
344
+ this.template.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
345
+ event.detail
346
+ );
347
+
311
348
  @api
312
349
  public navigateToHash(hash: String) {
313
350
  const splitHash = hash.split("#");
@@ -11,10 +11,6 @@ describe(TAG, () => {
11
11
  global.console = { ...global.console, error: jest.fn() };
12
12
  });
13
13
 
14
- afterEach(() => {
15
- jest.clearAllMocks();
16
- });
17
-
18
14
  afterAll(() => {
19
15
  global.console = originalConsole;
20
16
  });
@@ -83,15 +83,7 @@ const testLangEvent = () => {
83
83
  };
84
84
 
85
85
  describe(TAG, () => {
86
- afterAll(() => {
87
- jest.resetAllMocks();
88
- });
89
-
90
86
  describe("desktop", () => {
91
- afterEach(() => {
92
- jest.clearAllMocks();
93
- });
94
-
95
87
  it("renders", () => {
96
88
  const element = render();
97
89
  expect(element.headerHref).toBe("/");
@@ -57,12 +57,15 @@ header:not(.has-brand) > .header_l2 {
57
57
  }
58
58
 
59
59
  @media (max-width: 740px) {
60
- .has-nav-items .header_l2 {
61
- height: initial;
60
+ .header_l2 {
62
61
  padding: 0;
63
62
  flex-wrap: wrap;
64
63
  }
65
64
 
65
+ .has-nav-items .header_l2 {
66
+ height: initial;
67
+ }
68
+
66
69
  .header_l2_group {
67
70
  width: 100%;
68
71
  }
@@ -14,7 +14,6 @@ describe(TAG, () => {
14
14
  });
15
15
 
16
16
  afterEach(() => {
17
- jest.resetAllMocks();
18
17
  Object.defineProperty(global.navigator, "clipboard", {
19
18
  value: originalClipboard,
20
19
  configurable: true