pen
pen copied to clipboard
edit buttons not appearing for popup windows
Here is the JavaScript I use to launch a Pen window on double click :
function launchEditorWindow(elem) {
var popupWindow = window.open('', 'windowName', 'height=300,width=300');
var options = {
editor: popupWindow.document.body,
class: 'pen',
list: // editor menu list
[ 'insertimage', 'blockquote', 'h2', 'h3', 'p', 'code', 'insertorderedlist', 'insertunorderedlist', 'inserthorizontalrule',
'indent', 'outdent', 'bold', 'italic', 'underline', 'createlink' ]
}}
popupWindow.document.body.innerHTML = elem.value
var editor = new Pen( options );
popupWindow.onbeforeunload = function() {
elem.value = editor.toMd(); // return a markdown string
};
}```
The problem: for a popup window created by program, most facilities of Pen do not work; the tool bar, the commands followed by space. Only the return key has an effect.
Here is a complete HTML to reproduce the problem.
<html>
<script src="http://sofish.github.io/pen/src/pen.js"></script>
<script type="text/javascript">
var popupWindow = window.open( '', 'windowName', 'height=300,width=300');
var editorDiv = popupWindow.document.createElement("div");
var body = popupWindow.document.body;
body.appendChild(editorDiv);
editorDiv.textContent = '?';
var options = { editor: editorDiv };
var editor = new Pen(options);
pen.focus();
</script>
</html>