Separate function to add code copy button
For neatness and also so it can show up separately in the profiler.
This commit is contained in:
parent
876257f4e2
commit
05a986334d
1 changed files with 14 additions and 10 deletions
|
@ -114,16 +114,7 @@ module.exports = React.createClass({
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add 'copy' buttons to pre blocks
|
this._addCodeCopyButton();
|
||||||
ReactDOM.findDOMNode(this).querySelectorAll('.mx_EventTile_body pre').forEach((p) => {
|
|
||||||
const button = document.createElement("span");
|
|
||||||
button.className = "mx_EventTile_copyButton";
|
|
||||||
button.onclick = (e) => {
|
|
||||||
const copyCode = button.parentNode.getElementsByTagName("code")[0];
|
|
||||||
this.copyToClipboard(copyCode.textContent);
|
|
||||||
};
|
|
||||||
p.appendChild(button);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -260,6 +251,19 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_addCodeCopyButton() {
|
||||||
|
// Add 'copy' buttons to pre blocks
|
||||||
|
ReactDOM.findDOMNode(this).querySelectorAll('.mx_EventTile_body pre').forEach((p) => {
|
||||||
|
const button = document.createElement("span");
|
||||||
|
button.className = "mx_EventTile_copyButton";
|
||||||
|
button.onclick = (e) => {
|
||||||
|
const copyCode = button.parentNode.getElementsByTagName("code")[0];
|
||||||
|
this.copyToClipboard(copyCode.textContent);
|
||||||
|
};
|
||||||
|
p.appendChild(button);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
onCancelClick: function(event) {
|
onCancelClick: function(event) {
|
||||||
this.setState({ widgetHidden: true });
|
this.setState({ widgetHidden: true });
|
||||||
// FIXME: persist this somewhere smarter than local storage
|
// FIXME: persist this somewhere smarter than local storage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue