Skip to content

Commit

Permalink
fix help link in monaco flyout (#10008)
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll committed May 8, 2024
1 parent a04fd01 commit 4cc1d07
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions webapp/src/monacoFlyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,16 @@ export class MonacoFlyout extends data.Component<MonacoFlyoutProps, MonacoFlyout
const params = block.parameters;
const blockColor = block.attributes.color || color;
const blockDescription = this.getBlockDescription(block, params ? params.slice() : null);
const helpUrl = block.attributes.help;
const helpUrl = pxt.blocks.getHelpUrl(block as pxtc.SymbolInfo);

const openHelp = () => {
if (pxt.blocks.openHelpUrl) {
pxt.blocks.openHelpUrl(helpUrl);
}
else {
window.open(helpUrl);
}
};

const qName = this.getQName(block) || this.getSnippetName(block);
const selected = qName == this.state.selectedBlock;
Expand Down Expand Up @@ -382,9 +391,11 @@ export class MonacoFlyout extends data.Component<MonacoFlyoutProps, MonacoFlyout
<div className="description">{description}</div>
<div className="signature">
<span>{snippet ? snippet : `${qName}(${params ? params.map(p => `${p.name}`).join(", ") : ""})`}</span>
{helpUrl && <a className="blockHelp" href={`/reference/${helpUrl}`} target="_blank" rel="noopener noreferrer" role="button">
<i className="question circle outline icon" aria-label={lf("Open documentation")}></i>
</a>}
{helpUrl &&
<a className="blockHelp" role="button" onClick={openHelp}>
<i className="question circle outline icon" aria-label={lf("Open documentation")}></i>
</a>
}
</div>
{params && <div className="params">
{params.map((p, i) => {
Expand Down

0 comments on commit 4cc1d07

Please sign in to comment.