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 '<s>' and '<u>' pseudo html options for strike-through and underlining SVG text #7043

Merged
merged 6 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/7043_add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Introduce "<u>" and "<s>" pseudo html tags to underline and strike-through SVG text elements [[#7043](https://github.com/plotly/plotly.js/pull/7043)]
2 changes: 1 addition & 1 deletion src/components/annotations/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = templatedArray('annotation', {
'Sets the text associated with this annotation.',
'Plotly uses a subset of HTML tags to do things like',
'newline (<br>), bold (<b></b>), italics (<i></i>),',
'hyperlinks (<a href=\'...\'></a>). Tags <em>, <sup>, <sub>',
'hyperlinks (<a href=\'...\'></a>). Tags <em>, <sup>, <sub>, <s>, <u>',
'<span> are also supported.'
].join(' ')
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ function spikesChanged(gd, oldspikepoints) {
function plainText(s, len) {
return svgTextUtils.plainText(s || '', {
len: len,
allowedTags: ['br', 'sub', 'sup', 'b', 'i', 'em']
allowedTags: ['br', 'sub', 'sup', 'b', 'i', 'em', 's', 'u']
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/svg_text_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ var TAG_STYLES = {
// baseline below
sup: 'font-size:70%',
sub: 'font-size:70%',
s: 'text-decoration:line-through',
u: 'text-decoration:underline',
b: 'font-weight:bold',
i: 'font-style:italic',
a: 'cursor:pointer',
Expand Down
Binary file modified test/image/baselines/pie_title_middle_center_multiline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/image/mocks/pie_title_middle_center_multiline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"data": [
{
"values": [955, 405, 360, 310, 295],
"labels": ["Mandarin", "Spanish", "English", "Hindi", "Arabic"],
"labels": ["Mandarin", "Spanish", "<u>English</u>", "Hindi", "Arabic"],
"textinfo": "label+percent",
"hole": 0.4,
"title":{
Expand All @@ -14,7 +14,7 @@
],
"layout": {
"title": {
"text": "Top 5 languages by number of native speakers (2010, est.)"
"text": "Top <s>10</s> 5 languages by number of <u>native</u> speakers (<s>2009</s> 2010, est.)"
},
"height": 600,
"width": 600
Expand Down
4 changes: 2 additions & 2 deletions test/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@
"valType": "string"
},
"text": {
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub> <span> are also supported.",
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub>, <s>, <u> <span> are also supported.",
"editType": "calc+arraydraw",
"valType": "string"
},
Expand Down Expand Up @@ -6656,7 +6656,7 @@
"valType": "string"
},
"text": {
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub> <span> are also supported.",
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub>, <s>, <u> <span> are also supported.",
"editType": "calc",
"valType": "string"
},
Expand Down