@salesforcedevs/docs-components
Advanced tools
Comparing version 0.26.3 to 0.28.0
@@ -11,5 +11,5 @@ { | ||
"doc/header", | ||
"doc/headingAnchor", | ||
"doc/heading", | ||
"doc/phase" | ||
] | ||
} |
{ | ||
"name": "@salesforcedevs/docs-components", | ||
"version": "0.26.3", | ||
"version": "0.28.0", | ||
"description": "Docs Lightning web components for DSC", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "9c94c66a063751c3ada92ae0dbbded0b999feb98" | ||
"gitHead": "e7bf549e93170dd173ff7419b302674d0faa0b7a" | ||
} |
import { LightningElement, api } from "lwc"; | ||
import { IconSprite, IconSize, IconSymbol } from "typings/custom"; | ||
export default class HeadingAnchor extends LightningElement { | ||
@api ariaLabel: string = "copy"; | ||
@api iconSize?: IconSize = "override"; | ||
@api iconSprite?: IconSprite = "utility"; | ||
@api iconSymbol?: IconSymbol; | ||
@api title: string = ""; | ||
@api urlText: string = ""; | ||
@api hash: string | null = null; | ||
label: string = "Copy link to clipboard"; | ||
timeout: number | null = null; | ||
private async onIconClick() { | ||
await this.iconClickHandler(); | ||
private get titleToWrap() { | ||
return this.title.substring(0, this.title.lastIndexOf(" ")); | ||
} | ||
private async iconClickHandler() { | ||
private get needsSpace() { | ||
return this.titleToWrap.length > 0; | ||
} | ||
private get titleNoWrap() { | ||
return this.title.substring(this.title.lastIndexOf(" ") + 1); | ||
} | ||
private async copy() { | ||
if (this.timeout) { | ||
window.clearTimeout(this.timeout); | ||
} | ||
this.label = "Copied"; | ||
setTimeout(() => { | ||
this.timeout = window.setTimeout(() => { | ||
this.label = "Copy link to clipboard"; | ||
@@ -25,5 +33,5 @@ }, 2000); | ||
try { | ||
if (this.title && this.urlText) { | ||
if (this.title && this.hash) { | ||
const [hostUrl] = window.location.href.split("#"); | ||
const url = `${hostUrl}#${this.urlText}`; | ||
const url = `${hostUrl}#${this.hash}`; | ||
await navigator.clipboard.writeText(url); | ||
@@ -35,11 +43,2 @@ } | ||
} | ||
private async onKeyDown(e: KeyboardEvent) { | ||
switch (e.key) { | ||
case "Enter": | ||
await this.iconClickHandler(); | ||
break; | ||
default: | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
64663
34
1475
0