Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prodrammer/e801ee0ae2bdd45ba3cf0fd61155969f to your computer and use it in GitHub Desktop.
Save prodrammer/e801ee0ae2bdd45ba3cf0fd61155969f to your computer and use it in GitHub Desktop.
QuillJS No-focus Placeholder Example
<div id="editor">
</div>
var quill = new Quill('#editor', {
modules: {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['image', 'code-block']
]
},
// the default placeholder displays
// when the editor is blank, even when
// the editor has focus.
// placeholder: 'Compose an epic...',
theme: 'snow' // or 'bubble'
});
let editorParagraph = document.querySelector('#editor > div > p')
editorParagraph.setAttribute('placeholder', 'Compose an epic...')
<script src="//cdn.quilljs.com/1.3.6/quill.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js"></script>
#editor {
height: 375px;
}
.ql-blank:not(:focus) p:before {
content: attr(placeholder);
color: #000;
}
<link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai-sublime.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" rel="stylesheet" />
<link href="//cdn.quilljs.com/1.3.6/quill.bubble.css" rel="stylesheet" />
<link href="//cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment