Turns out the solution is to replace:
.append("xhtml:div")
.attr("id", "editor")
.attr('width', '50')
.attr('height', '50');
with:
.append("xhtml:div")
.attr("id", "editor")
.attr('style', 'width:100%;height:100%');
The reason is that Ace doesn't change size based on the size of its container - so in the previous example, the height was 0. Setting the width and height to 100% aligns it to the original size of the div.