Skip to content
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

Merged
merged 6 commits into from
Jan 21, 2019

Conversation

etpinard
Copy link
Contributor

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.

- 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!
@Braintelligence
Copy link

Thank you very much!

}
name = svgTextUtils.plainText(d.name || '', {
len: d.nameLength,
allowedTags: ['br', 'sub', 'sup']
Copy link
Contributor Author

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:

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?

Copy link
Contributor

@archmoj archmoj Jan 21, 2019

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Done in -> 6c7b0ed

@etpinard etpinard added this to the 1.44.0 milestone Jan 17, 2019
@antoinerg
Copy link
Contributor

Thanks @etpinard for the improvements 💪

Here's a Codepen showing the fix: https://codepen.io/anon/pen/BMaNox 👌

It's a 💃 for me!

@etpinard etpinard merged commit e6343d9 into master Jan 21, 2019
@etpinard etpinard deleted the sub-sup-in-extra-hover-label branch January 21, 2019 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] <sup> for trace.name is not respected in hoverlabel
4 participants