@dvrd/dvr-controls 0.0.35 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -34,6 +34,7 @@ interface Props {
|
|
|
34
34
|
interface State {
|
|
35
35
|
settings: PDFTextParams;
|
|
36
36
|
dragging: boolean;
|
|
37
|
+
focused: boolean;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export default class PdfText extends PdfElement<Props, State> {
|
|
@@ -61,6 +62,7 @@ export default class PdfText extends PdfElement<Props, State> {
|
|
|
61
62
|
persistent: PDFElementPersist.NOT_PERSISTENT,
|
|
62
63
|
}, props.defaultSettings),
|
|
63
64
|
dragging: false,
|
|
65
|
+
focused: false,
|
|
64
66
|
}
|
|
65
67
|
this.currentText = this.state.settings.text;
|
|
66
68
|
this.events = [this.event, {eventName: 'onLinkedElementMoved', handler: this.onLinkedElementMoved}]
|
|
@@ -68,14 +70,22 @@ export default class PdfText extends PdfElement<Props, State> {
|
|
|
68
70
|
|
|
69
71
|
private onBlur = (evt: React.FocusEvent<HTMLTextAreaElement>) => {
|
|
70
72
|
this.lastKnownCursor = evt.target.selectionEnd || 0;
|
|
73
|
+
this.setState({focused: false}, this.setWidth);
|
|
71
74
|
if (this.state.settings.text !== this.currentText) this.props.onSaveHistory();
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
private onFocus = (evt: React.FocusEvent) => {
|
|
75
78
|
evt.stopPropagation();
|
|
79
|
+
this.setState({focused: true}, this.setWidth);
|
|
76
80
|
this.currentText = this.state.settings.text;
|
|
77
81
|
};
|
|
78
82
|
|
|
83
|
+
getTextValue = (): string => {
|
|
84
|
+
const {settings, focused} = this.state, {values} = this.props;
|
|
85
|
+
if (focused) return settings.text;
|
|
86
|
+
return setPdfVariables(settings.text, values);
|
|
87
|
+
}
|
|
88
|
+
|
|
79
89
|
public setSetting = (key: string, value: any, callback?: VoidFunction, save: boolean = true) => {
|
|
80
90
|
this.setState({settings: Object.assign({}, this.state.settings, {[key]: value})}, () => {
|
|
81
91
|
this.setWidth();
|
|
@@ -215,7 +225,6 @@ export default class PdfText extends PdfElement<Props, State> {
|
|
|
215
225
|
render = () => {
|
|
216
226
|
const {settings, dragging} = this.state, {
|
|
217
227
|
draggable,
|
|
218
|
-
values,
|
|
219
228
|
defaultPosition,
|
|
220
229
|
onSaveHistory,
|
|
221
230
|
persistent
|
|
@@ -234,7 +243,7 @@ export default class PdfText extends PdfElement<Props, State> {
|
|
|
234
243
|
<div className='pdf-text-container'>
|
|
235
244
|
<textarea className='pdf-text-input' style={this.getTextStyle()}
|
|
236
245
|
readOnly={settings.disabled === true}
|
|
237
|
-
value={sanitizeHtml(
|
|
246
|
+
value={sanitizeHtml(this.getTextValue())} onChange={this.onChange}
|
|
238
247
|
rows={this.getRows()} onFocus={this.onFocus} onBlur={this.onBlur} onClick={this.onClick}
|
|
239
248
|
ref={(ref: HTMLTextAreaElement) => {
|
|
240
249
|
this.field = ref
|