Add comments & remove redundant check

This commit is contained in:
David Baker 2017-06-08 14:53:21 +01:00
parent b40636a425
commit 71eb405859
2 changed files with 11 additions and 7 deletions

View file

@ -365,6 +365,11 @@ export function bodyToHtml(content, highlights, opts) {
}
function addCodeCopyButton(safeBody) {
// Adds 'copy' buttons to pre blocks
// Note that this only manipulates the markup to add the buttons:
// we need to add the event handlers once the nodes are in the DOM
// since we can't save functions in the markup.
// This is done in TextualBody
const el = document.createElement("div");
el.innerHTML = safeBody;
const codeBlocks = Array.from(el.getElementsByTagName("pre"));

View file

@ -94,8 +94,8 @@ module.exports = React.createClass({
}
}, 10);
}
// add event handlers to the 'copy code' buttons
const buttons = ReactDOM.findDOMNode(this).getElementsByClassName("mx_EventTile_copyButton");
if (buttons.length > 0) {
for (let i = 0; i < buttons.length; i++) {
buttons[i].onclick = (e) => {
const copyCode = buttons[i].parentNode.getElementsByTagName("code")[0];
@ -103,7 +103,6 @@ module.exports = React.createClass({
};
}
}
}
},
componentDidUpdate: function() {