Last active
September 16, 2020 17:16
-
-
Save m-manu/ddeb5bd7454fe42c73ee to your computer and use it in GitHub Desktop.
CKEditor in Full Screen with auto-save
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>CKEditor</title> | |
<script type="text/javascript" src="./ckeditor.js"></script> | |
<script type="text/javascript"> | |
var editor1, editor1isModified = false; | |
function initialize() { | |
CKEDITOR.replace('editor1', { | |
fullPage: true, | |
allowedContent: true, | |
extraPlugins: 'wysiwygarea' | |
}); | |
editor1 = CKEDITOR.instances['editor1']; | |
editor1.on('instanceReady', function(evt) { | |
evt.editor.setData(window.localStorage.getItem("editor1_contents")); | |
evt.editor.execCommand('maximize'); | |
}); | |
editor1.on('change', function(evt) { | |
editor1isModified = true; | |
}); | |
window.setInterval(editor1_save, 3000); | |
} | |
function editor1_save() { | |
if(editor1isModified) { | |
window.localStorage.setItem("editor1_contents", editor1.getData()); | |
editor1isModified = false; | |
} | |
} | |
</script> | |
</head> | |
<body onLoad="initialize();"> | |
<textarea cols="80" id="editor1" name="editor1" rows="10"></textarea> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment