Skip to content

Commit

Permalink
fix(plugins/plugin-client-common): Tooltips for kuiexec markdown link…
Browse files Browse the repository at this point in the history
…s have incorrect tooltip content

Fixes #6958
  • Loading branch information
starpit committed Feb 4, 2021
1 parent bc2dd7a commit 50ca156
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 11 additions & 3 deletions plugins/plugin-client-common/src/components/Content/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,16 @@ export default class Markdown extends React.PureComponent<Props> {
},

link: props => {
const isKuiCommand = props.href.startsWith('#kuiexec?command=')
const isLocal = !/^http/i.test(props.href)
const target = !isLocal ? '_blank' : undefined

const onClick = !isLocal
? (evt: React.MouseEvent) => evt.stopPropagation()
: async (evt: React.MouseEvent) => {
evt.stopPropagation()
let file = props.href
if (props.href.startsWith('#kuiexec?command=')) {
if (isKuiCommand) {
const raw = props.href.match(/#kuiexec\?command=([^&]+)(&quiet)?/)
if (raw) {
const cmdline = decodeURIComponent(raw[1])
Expand Down Expand Up @@ -177,9 +179,15 @@ export default class Markdown extends React.PureComponent<Props> {
} else if (!isLocal && this.props.noExternalLinks) {
return <span className={this.props.className}>{props.href}</span>
} else {
const tip = isKuiCommand
? `### Command Execution\n#### ${decodeURIComponent(
props.href.slice(props.href.indexOf('=') + 1)
)}\n\n\`Link will execute a command\``
: `### External Link\n#### ${props.href}\n\n\`Link will open in a separate window\``

return (
<Tooltip markdown={`### External Link\n#### ${props.href}\n\n\`Link will open in a separate window\``}>
<a className="bx--link" {...props} target={target} onClick={onClick} />
<Tooltip markdown={tip}>
<a {...props} target={target} onClick={onClick} />
</Tooltip>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ $bgcolor: var(--color-base06);
}
h3 + h4 {
padding-top: 0;

a:only-child {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}

p + p {
Expand Down

0 comments on commit 50ca156

Please sign in to comment.