insomnia/app/ui/components/viewers/ResponseRaw.js
Gregory Schier bb57f360e0 Environment Tags and Such (#90)
* Sort of working nunjucks editor

* Some more tweaks

* Lots of stuff

* Gettingn pretty good

* Minor tweaks and test fixes

* Minor bug fixes and stuff

* Some fixes and perf

* Refactoring

* Good for now

* Codemirror URL

* More and more fixes and improvements

* Code single-line CSS perfect!!!

* Better nj editing

* Show preview in nj edit

* Some editor updates

* All inputs now covered

* A bunch of fixes and stuff

* Don't cache node modules because it's not needed

* More stuff

* Tweak

* Style tweaks

* Pull nunjucks mode into own file

* Move codemirror click overlay to own file

* Pull nunjucks tag stuff out

* Fixed key value editor

* raw/endraw and marks improvements

* Some tweaks
2017-02-27 13:00:13 -08:00

59 lines
1.2 KiB
JavaScript

import React, {Component, PropTypes} from 'react';
class ResponseRaw extends Component {
_update (value) {
// Use a timeout so it doesn't block the UI
window.requestAnimationFrame(() => this._setTextAreaValue(value))
}
_setTextAreaValue (value) {
// Bail if we're not mounted
if (!this._textarea) {
return;
}
this._textarea.value = value;
}
componentDidUpdate () {
this._update(this.props.value)
}
componentDidMount () {
this._update(this.props.value)
}
shouldComponentUpdate (nextProps) {
for (let key in nextProps) {
if (nextProps.hasOwnProperty(key)) {
if (nextProps[key] !== this.props[key]) {
return true;
}
}
}
return false;
}
render () {
const {fontSize} = this.props;
return (
<textarea
ref={n => this._textarea = n}
placeholder="..."
className="force-wrap scrollable wide tall selectable monospace pad no-resize"
readOnly={true}
defaultValue=""
style={{fontSize}}>
</textarea>
);
}
}
ResponseRaw.propTypes = {
value: PropTypes.string.isRequired,
fontSize: PropTypes.number
};
export default ResponseRaw;