@salesforcedevs/docs-components
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "@salesforcedevs/docs-components", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Docs Lightning web components for DSC", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -15,3 +15,3 @@ import { LightningElement, api } from "lwc"; | ||
PdfUrl | ||
} from "typings/custom"; | ||
} from "../../../../../../../typings/custom"; | ||
@@ -183,3 +183,3 @@ const API_MAIN_URL = "https://developer.salesforce.com/docs/get_document/"; | ||
this.pageReference.domain = `${window.location.protocol}//${window.location.host}`; | ||
//this.updateSelectedItem(); | ||
this.updateSelectedItem(); | ||
} | ||
@@ -259,3 +259,3 @@ | ||
} | ||
//this.updateSelectedItem(); | ||
this.updateSelectedItem(); | ||
} | ||
@@ -272,4 +272,2 @@ if ( | ||
/* | ||
TODO: use set selected item for new navigation components | ||
updateSelectedItem() { | ||
@@ -284,6 +282,5 @@ if (this.pageReference.contentDocumentId) { | ||
} | ||
this.selectedItem = item; | ||
this.selectedNavigationItem = item; | ||
} | ||
} | ||
*/ | ||
@@ -349,3 +346,2 @@ handleToolbarEvent(event: CustomEvent) { | ||
} | ||
console.log("Incorrect Doc Type"); | ||
return ""; | ||
@@ -359,3 +355,3 @@ } | ||
normalizeToc(toc) { | ||
normalizeToc(toc: DocToc) { | ||
let normalizedToc = JSON.stringify(toc).replace(/"text"/g, '"label"'); | ||
@@ -365,4 +361,4 @@ normalizedToc = normalizedToc.replace(/"id"/g, '"name"'); | ||
jsonToc.isExpanded = true; | ||
return jsonToc; | ||
return [jsonToc]; | ||
} | ||
} |
/* eslint-disable @lwc/lwc/no-inner-html */ | ||
import { LightningElement, api, track } from "lwc"; | ||
import { | ||
DocContent, | ||
PageReference | ||
} from "../../../../../../../typings/custom-new"; | ||
import { DocContent, PageReference } from "../../../../../../../typings/custom"; | ||
@@ -39,10 +36,2 @@ export default class Content extends LightningElement { | ||
constructor() { | ||
super(); | ||
this.template.addEventListener( | ||
"themechange", | ||
this.updateTheme.bind(this) // eslint-disableline no-use-before-define | ||
); | ||
} | ||
updateTheme() { | ||
@@ -96,5 +85,37 @@ this._codeBlockTheme = | ||
// Query the callouts and create a doc-content-callout component that contains the code | ||
const calloutEls = templateEl.content.querySelectorAll(".message"); | ||
calloutEls.forEach((calloutEl) => { | ||
const calloutCompEl = document.createElement("doc-content-callout"); | ||
const detailEls = calloutEl.querySelectorAll("p"); | ||
detailEls.forEach((detailEl) => { | ||
calloutCompEl.appendChild(detailEl); | ||
}); | ||
const type = calloutEl.querySelector("h4").textContent; | ||
const typeLower = type.toLowerCase(); | ||
calloutCompEl.setAttribute("title", type); | ||
calloutCompEl.setAttribute("variant", typeLower); | ||
calloutEl.innerHTML = ""; | ||
calloutEl.appendChild(calloutCompEl); | ||
}); | ||
// Modify links to work with any domain | ||
const anchorEls = templateEl.content.querySelectorAll("a"); | ||
anchorEls.forEach((anchorEl) => { | ||
if (anchorEl.textContent.includes("Next →")) { | ||
anchorEl.textContent = ""; | ||
const buttonEl = document.createElement("dx-button"); | ||
buttonEl.setAttribute("icon-symbol", "chevronright"); | ||
buttonEl.textContent = "Next"; | ||
anchorEl.appendChild(buttonEl); | ||
} | ||
if (anchorEl.textContent.includes("← Previous")) { | ||
anchorEl.textContent = ""; | ||
const buttonEl = document.createElement("dx-button"); | ||
buttonEl.setAttribute("icon-symbol", "chevronleft"); | ||
buttonEl.setAttribute("icon-position", "left"); | ||
buttonEl.setAttribute("variant", "secondary"); | ||
buttonEl.textContent = "Previous"; | ||
anchorEl.appendChild(buttonEl); | ||
} | ||
const href = anchorEl.href.split("/"); | ||
@@ -151,4 +172,5 @@ if ( | ||
const src = imgEl.src; | ||
const origin = window.location.origin; | ||
const updatedURL = src.replace( | ||
this.pageReference.domain, | ||
origin, | ||
"https://developer.salesforce.com" | ||
@@ -155,0 +177,0 @@ ); |
@@ -26,16 +26,10 @@ import { createElement } from "lwc"; | ||
describe("doc-nav", () => { | ||
it("renders the navigation", () => { | ||
const component = render(MOCK_PARAMETERS); | ||
document.body.appendChild(component); | ||
const toolbarEl = component.shadowRoot.querySelector("doc-toolbar"); | ||
expect(toolbarEl).not.toBeNull(); | ||
}); | ||
it("renders the content", () => { | ||
const component = render(MOCK_PARAMETERS); | ||
const tocEl = component.shadowRoot.querySelector("dx-tree"); | ||
const tocEl = component.shadowRoot.querySelector("dx-sidebar"); | ||
expect(tocEl).not.toBeNull(); | ||
}); | ||
/* | ||
it("fires the event", () => { | ||
@@ -45,3 +39,3 @@ const component = render(MOCK_PARAMETERS); | ||
const tocEl: HTMLElement = component.shadowRoot.querySelector( | ||
"dx-tree" | ||
"dx-sidebar" | ||
); | ||
@@ -68,2 +62,4 @@ const mockNavClick = jest.fn(); | ||
}); | ||
*/ | ||
}); |
@@ -11,3 +11,3 @@ import { LightningElement, api } from "lwc"; | ||
SelectedVersion | ||
} from "typings/custom"; | ||
} from "../../../../../../../typings/custom"; | ||
@@ -14,0 +14,0 @@ export default class Nav extends LightningElement { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
350181
6510