You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes I know it's old but I tried to upgrade to a newer version but discovered some problems, I traced back to this release.
We currently use marked-element (polymer) which uses version 0.3.9 of marked. I'm rebuilding it to use lit and to also upgrade marked. My issue is it breaks our usage. Specifically autolinking emails.
I'm doing:
override updated() {
// When masked-element was using Polymer, it was rendered synchronously,
// compared to the lit version of the element. updated() ran before the markdown
// was inserted into the slot.
this.addEventListener('marked-render-complete', () => {
// Look for @mentions and replace them with an account-label chip.
this.convertEmailsToAccountChips();
this.convertCodeToSuggestions();
});
}
private convertEmailsToAccountChips() {
for (const emailLink of this.renderRoot.querySelectorAll(
'a[href^="mailto"]'
)) {
const previous = emailLink.previousSibling;
// This Regexp matches the beginning of the MENTIONS_REGEX at the end of
// an element.
if (
previous?.nodeName === '#text' &&
previous?.textContent?.match(/(^|\s)@$/)
) {
const accountChip = document.createElement('gr-account-chip');
accountChip.account = {
email: emailLink.textContent as EmailAddress,
};
accountChip.removable = false;
// Remove the trailing @ from the previous element.
previous.textContent = previous.textContent.slice(0, -1);
emailLink.parentNode?.replaceChild(accountChip, emailLink);
}
}
}
private convertCodeToSuggestions() {
const marks = this.renderRoot.querySelectorAll('mark');
marks.forEach((userSuggestionMark, index) => {
const userSuggestion = document.createElement('gr-user-suggestion-fix');
// Temporary workaround for bug - tabs replacement
if (this.content.includes('\t')) {
userSuggestion.textContent = getUserSuggestionFromString(
this.content,
index
);
} else {
userSuggestion.textContent = userSuggestionMark.textContent ?? '';
}
userSuggestionMark.parentNode?.replaceChild(
userSuggestion,
userSuggestionMark
);
});
}
}
This is supposed to replace the linked email with gr-account-chip but because it's not linked, it can't be found.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Yes I know it's old but I tried to upgrade to a newer version but discovered some problems, I traced back to this release.
We currently use marked-element (polymer) which uses version 0.3.9 of marked. I'm rebuilding it to use lit and to also upgrade marked. My issue is it breaks our usage. Specifically autolinking emails.
I'm doing:
This is supposed to replace the linked email with gr-account-chip but because it's not linked, it can't be found.
Wondering if anyone knows what I'm doing wrong or if this is a bug? Not sure if https://github.com/markedjs/marked/pull/1385/files introduced it?
for example doing
@test.comshould link and then be found by convertEmailsToAccountChips and replaced.https://gerrit-review.googlesource.com/c/gerrit/+/480261/ is my change upgrading to 0.5 which should provide more context if any is needed.
All reactions