Skip to content

Commit 8d0c41f

Browse files
authored
Merge pull request #844 from plotly/v0.35.5
V0.35.5
2 parents 92d6f67 + ea03fa8 commit 8d0c41f

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-chart-editor",
33
"description": "plotly.js chart editor react component UI",
4-
"version": "0.35.4",
4+
"version": "0.35.5",
55
"author": "Plotly, Inc.",
66
"bugs": {
77
"url": "https://github.com/plotly/react-chart-editor/issues"
@@ -15,7 +15,7 @@
1515
"fast-isnumeric": "^1.1.1",
1616
"immutability-helper": "^2.7.1",
1717
"plotly-icons": "1.2.3",
18-
"plotly.js": "1.44.3",
18+
"plotly.js": "1.44.4",
1919
"prop-types": "^15.5.10",
2020
"raf": "^3.4.0",
2121
"react-color": "^2.13.8",

src/components/containers/AnnotationAccordion.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,33 @@ import {PanelMessage} from './PanelEmpty';
44
import PropTypes from 'prop-types';
55
import React, {Component} from 'react';
66
import {connectAnnotationToLayout} from 'lib';
7+
import {templateString} from 'plotly.js/src/lib';
78

89
const AnnotationFold = connectAnnotationToLayout(PlotlyFold);
910

1011
class AnnotationAccordion extends Component {
1112
render() {
1213
const {
13-
layout: {annotations = []},
14+
layout: {annotations = [], meta = []},
1415
localize: _,
1516
} = this.context;
1617
const {canAdd, children} = this.props;
1718

1819
const content =
1920
annotations.length &&
20-
annotations.map((ann, i) => (
21-
<AnnotationFold key={i} annotationIndex={i} name={ann.text} canDelete={canAdd}>
22-
{children}
23-
</AnnotationFold>
24-
));
21+
annotations.map((ann, i) => {
22+
const textPostTemplate = templateString(ann.text, {meta});
23+
return (
24+
<AnnotationFold
25+
key={i}
26+
annotationIndex={i}
27+
name={textPostTemplate === '' ? ann.text : textPostTemplate}
28+
canDelete={canAdd}
29+
>
30+
{children}
31+
</AnnotationFold>
32+
);
33+
});
2534

2635
const addAction = {
2736
label: _('Annotation'),

src/components/fields/TextEditor.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export class UnconnectedTextEditor extends Component {
6767

6868
let fullValue = this.getAdjustedFullValue(this.props.fullValue);
6969

70-
let placeholder;
70+
let placeholder = this.props.placeholder;
71+
7172
if (multiValued || (fullValue && (!container || !nestedProperty(container, attr)))) {
7273
placeholder = fullValue;
7374
fullValue = '';
@@ -118,16 +119,27 @@ UnconnectedTextEditor.propTypes = {
118119
latexOnly: PropTypes.bool,
119120
richTextOnly: PropTypes.bool,
120121
updatePlot: PropTypes.func,
122+
placeholder: PropTypes.string,
121123
};
122124

123125
UnconnectedTextEditor.contextTypes = {
124126
localize: PropTypes.func,
127+
fullLayout: PropTypes.object,
125128
};
126129

127130
export default connectToContainer(UnconnectedTextEditor, {
128131
modifyPlotProps: (props, context, plotProps) => {
129132
if (plotProps.isVisible && plotProps.multiValued) {
130133
plotProps.isVisible = false;
131134
}
135+
136+
if (
137+
context.fullLayout &&
138+
context.fullLayout._dfltTitle &&
139+
Object.values(context.fullLayout._dfltTitle).includes(plotProps.fullValue)
140+
) {
141+
plotProps.placeholder = plotProps.fullValue;
142+
plotProps.fullValue = '';
143+
}
132144
},
133145
});

src/default_panels/StyleLayoutPanel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,11 @@ const StyleLayoutPanel = (props, {localize: _}) => (
174174
{_(
175175
'You can refer to the items in this column in any text fields of the editor like so: '
176176
)}
177-
<p style={{letterSpacing: '1px', fontStyle: 'italic'}}>
178-
{_("Ex: 'My custom title %{meta[1]}.' ")}
177+
<p>
178+
{_('Ex: ')}
179+
<span style={{letterSpacing: '1px', fontStyle: 'italic', userSelect: 'text'}}>
180+
{_('My custom title %{meta[1]}')}
181+
</span>
179182
</p>
180183
</p>
181184
</Info>

0 commit comments

Comments
 (0)