-
Notifications
You must be signed in to change notification settings - Fork 19.7k
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
fix(tooltip): Tooltip textStyle lineHeight does not work in default #20398
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f0b9020
fix: Tooltip textStyle lineHeight does not work in default
sz-p 6dea1a4
test: Tooltip textStyle lineHeight does not work in default
sz-p c4eaf0b
fix: Tooltip textStyle lineHeight does not work in default
sz-p 234fb4b
fix: Tooltip textStyle lineHeight does not work in default
sz-p File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,17 @@ type TextStyle = string | RichTextStyle; | |
|
||
const TOOLTIP_LINE_HEIGHT_CSS = 'line-height:1'; | ||
|
||
function getTooltipLineHeight( | ||
textStyle: TooltipOption['textStyle'] | ||
) { | ||
const lineHeight = textStyle.lineHeight; | ||
if (lineHeight === undefined) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
return TOOLTIP_LINE_HEIGHT_CSS; | ||
} | ||
else { | ||
return `line-height:${encodeHTML(lineHeight + '')}px`; | ||
} | ||
} | ||
// TODO: more textStyle option | ||
function getTooltipTextStyle( | ||
textStyle: TooltipOption['textStyle'], | ||
|
@@ -272,6 +283,7 @@ function buildSection( | |
const subMarkupText = ctx.renderMode === 'richText' | ||
? subMarkupTextList.join(gaps.richText) | ||
: wrapBlockHTML( | ||
toolTipTextStyle, | ||
subMarkupTextList.join(''), | ||
noHeader ? topMarginForOuterGap : gaps.html | ||
); | ||
|
@@ -282,13 +294,15 @@ function buildSection( | |
|
||
const displayableHeader = makeValueReadable(fragment.header, 'ordinal', ctx.useUTC); | ||
const {nameStyle} = getTooltipTextStyle(toolTipTextStyle, ctx.renderMode); | ||
const tooltipLineHeight = getTooltipLineHeight(toolTipTextStyle); | ||
if (ctx.renderMode === 'richText') { | ||
return wrapInlineNameRichText(ctx, displayableHeader, nameStyle as RichTextStyle) + gaps.richText | ||
+ subMarkupText; | ||
} | ||
else { | ||
return wrapBlockHTML( | ||
`<div style="${nameStyle};${TOOLTIP_LINE_HEIGHT_CSS};">` | ||
toolTipTextStyle, | ||
`<div style="${nameStyle};${tooltipLineHeight};">` | ||
+ encodeHTML(displayableHeader) | ||
+ '</div>' | ||
+ subMarkupText, | ||
|
@@ -350,6 +364,7 @@ function buildNameValue( | |
)) | ||
) | ||
: wrapBlockHTML( | ||
toolTipTextStyle, | ||
(noMarker ? '' : markerStr) | ||
+ (noName ? '' : wrapInlineNameHTML(readableName, !noMarker, nameStyle as string)) | ||
+ (noValue ? '' : wrapInlineValueHTML( | ||
|
@@ -406,12 +421,14 @@ function getGap(gapLevel: number): { | |
} | ||
|
||
function wrapBlockHTML( | ||
textStyle: TooltipOption['textStyle'], | ||
encodedContent: string, | ||
topGap: number | ||
): string { | ||
const clearfix = '<div style="clear:both"></div>'; | ||
const marginCSS = `margin: ${topGap}px 0 0`; | ||
return `<div style="${marginCSS};${TOOLTIP_LINE_HEIGHT_CSS};">` | ||
const tooltipLineHeight = getTooltipLineHeight(textStyle); | ||
return `<div style="${marginCSS};${tooltipLineHeight};">` | ||
+ encodedContent + clearfix | ||
+ '</div>'; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use
zrUtil.retrive2
instead.