-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for <sub> and <sup> in "extra" hover label #3443
Conversation
- so that it can selective allow some pseudo-html tags to go through - add truncate logic where allowed pseudo-html tags don't count toward the output "length"
- the malicious <img onerror=""> tag is now gone!
Thank you very much! |
src/components/fx/hover.js
Outdated
} | ||
name = svgTextUtils.plainText(d.name || '', { | ||
len: d.nameLength, | ||
allowedTags: ['br', 'sub', 'sup'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From our list of pseudo-html tags:
plotly.js/src/lib/svg_text_utils.js
Lines 233 to 244 in cc45972
var TAG_STYLES = { | |
// would like to use baseline-shift for sub/sup but FF doesn't support it | |
// so we need to use dy along with the uber hacky shift-back-to | |
// baseline below | |
sup: 'font-size:70%', | |
sub: 'font-size:70%', | |
b: 'font-weight:bold', | |
i: 'font-style:italic', | |
a: 'cursor:pointer', | |
span: '', | |
em: 'font-style:italic;font-weight:bold' | |
}; |
I can us potentially adding <b>
, <i>
and <em>
. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In webGL
texts now we support <b>
and <i>
. So it might be nice to have them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! Done in -> 6c7b0ed
Thanks @etpinard for the improvements 💪 Here's a Codepen showing the fix: https://codepen.io/anon/pen/BMaNox 👌 It's a 💃 for me! |
fixes #3357
cc @plotly/plotly_js and @Braintelligence
Note that this PR doesn't fix the alignment problem brought in #3175 (comment) and suspected by @alexcjohnson in #3357 (comment). This issue is now in #3442.