Skip to content

Commit

Permalink
fix(WISE Link): Link stops working when component is authored again (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan authored Mar 10, 2023
1 parent b7ec0b0 commit b922ccc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/assets/wise5/common/wise-link/wise-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ function createWiseLinkReplacedByElement(
componentId: string,
linkText: string
): string {
return `<${tag} wiselink="true" onclick="document.getElementById('replace-with-unique-id').dispatchEvent(new CustomEvent('wiselinkclicked', { detail: { nodeId: '${nodeId}', componentId: '${componentId}' } })); return false;">${linkText}</${tag}>`;
return `<${tag} wiselink="true" node-id="${nodeId}" component-id="${componentId}" onclick="document.getElementById('replace-with-unique-id').dispatchEvent(new CustomEvent('wiselinkclicked', { detail: { nodeId: '${nodeId}', componentId: '${componentId}' } })); return false;">${linkText}</${tag}>`;
}
5 changes: 3 additions & 2 deletions src/assets/wise5/common/wise-link/wise-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ function replaceWiseLinksHelper(html: string, regex: string): string {
const linkText = getWiseLinkLinkText(wiseLinkHTML);
let newElement = '';
const onclickString = `document.getElementById('replace-with-unique-id').dispatchEvent(new CustomEvent('wiselinkclicked', { detail: { nodeId: '${nodeId}', componentId: '${componentId}' } })); return false;`;
const params = `wiselink="true" node-id="${nodeId}" component-id="${componentId}" onclick="${onclickString}"`;
if (type === 'button') {
newElement = `<button wiselink="true" onclick="${onclickString}">${linkText}</button>`;
newElement = `<button ${params}>${linkText}</button>`;
} else {
newElement = `<a wiselink="true" onclick="${onclickString}">${linkText}</a>`;
newElement = `<a ${params}>${linkText}</a>`;
}
html = html.replace(wiseLinkHTML, newElement);
wiseLinkRegExMatchResult = wiseLinkRegEx.exec(html);
Expand Down

0 comments on commit b922ccc

Please sign in to comment.