Skip to content
Snippets Groups Projects
Commit cfdd017c authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

[placeholder addon] Allow a DOM node to be given as placeholder content

Issue #3487
parent 3d18f89f
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,9 @@
var elt = cm.state.placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
elt.className = "CodeMirror-placeholder";
elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
var placeHolder = cm.getOption("placeholder")
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
elt.appendChild(placeHolder)
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
}
......
......@@ -2762,9 +2762,10 @@ editor.setOption("extraKeys", {
<dt id="addon_placeholder"><a href="../addon/display/placeholder.js"><code>display/placeholder.js</code></a></dt>
<dd>Adds a <code>placeholder</code> option that can be used to
make text appear in the editor when it is empty and not focused.
Also gives the editor a <code>CodeMirror-empty</code> CSS class
whenever it doesn't contain any text.
make content appear in the editor when it is empty and not
focused. It can hold either a string or a DOM node. Also gives
the editor a <code>CodeMirror-empty</code> CSS class whenever it
doesn't contain any text.
See <a href="../demo/placeholder.html">the demo</a>.</dd>
<dt id="addon_fullscreen"><a href="../addon/display/fullscreen.js"><code>display/fullscreen.js</code></a></dt>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment