A Pen by Alex Krolick on CodePen.
Created
September 8, 2016 17:28
-
-
Save alexkrolick/69ae54e5330a66ff8746dc8e912b5c3c to your computer and use it in GitHub Desktop.
Quill Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="editor-container"></div> | |
<form submit="#"> | |
<input type="hidden" id="myHtml"/> | |
<button type="submit">Submit</submit> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.unsavedChanges = false; | |
var quill = new Quill('#editor-container', { | |
modules: { | |
toolbar: [ | |
[{ header: [1, 2, false] }], | |
['bold', 'italic', 'underline'], | |
['image', 'code-block'] | |
] | |
}, | |
placeholder: 'Compose an epic...', | |
theme: 'snow' // or 'bubble' | |
}); | |
window.addEventListener("beforeunload", function (e) { | |
if (window.unsavedChanges) { | |
e.returnValue = 'Unsaved Changes!'; | |
return 'Unsaved Changes!'; | |
}; | |
}); | |
var syncHtml = _.debounce(function() { | |
$('myHtml').val(quill.getContents()); | |
window.unsavedChanges = false; | |
}, 500); | |
quill.on('text-change', function() { | |
window.unsavedChanges = true; | |
syncHtml(); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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.3.0/highlight.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.min.js"></script> | |
<script src="//cdn.quilljs.com/1.0.3/quill.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#editor-container { | |
height: 150px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/monokai-sublime.min.css" rel="stylesheet" /> | |
<link href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css" rel="stylesheet" /> | |
<link href="//cdn.quilljs.com/1.0.3/quill.bubble.css" rel="stylesheet" /> | |
<link href="//cdn.quilljs.com/1.0.3/quill.snow.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment