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

Projects
None yet
4 participants
@etpinard
Copy link
Member

etpinard commented Jan 17, 2019

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.

etpinard added some commits Jan 17, 2019

generalize svgTextUtils.plainText
- 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"
tweak XSS via hover label test
- the malicious <img onerror=""> tag is now gone!
@Braintelligence

This comment has been minimized.

Copy link

Braintelligence commented Jan 17, 2019

Thank you very much!

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

This comment has been minimized.

Copy link
@etpinard

etpinard Jan 17, 2019

Author Member

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?

This comment has been minimized.

Copy link
@archmoj

archmoj Jan 21, 2019

Collaborator

In webGL texts now we support <b> and <i>. So it might be nice to have them here.

This comment has been minimized.

Copy link
@etpinard

etpinard Jan 21, 2019

Author Member

Ok! Done in -> 6c7b0ed

@etpinard etpinard added this to the 1.44.0 milestone Jan 17, 2019

@antoinerg

This comment has been minimized.

Copy link
Collaborator

antoinerg commented Jan 21, 2019

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

8 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: publish Your tests passed on CircleCI!
Details
ci/circleci: test-image Your tests passed on CircleCI!
Details
ci/circleci: test-image2 Your tests passed on CircleCI!
Details
ci/circleci: test-jasmine Your tests passed on CircleCI!
Details
ci/circleci: test-jasmine2 Your tests passed on CircleCI!
Details
ci/circleci: test-syntax Your tests passed on CircleCI!
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details

@etpinard etpinard deleted the sub-sup-in-extra-hover-label branch Jan 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.