Update code block release.1.5.5 (#176)

This commit is contained in:
Taly 2017-03-08 17:46:50 +04:00 committed by Peter Savchenko
parent c8808e802b
commit d581856d78
2 changed files with 30 additions and 7 deletions

View file

@ -1,5 +1,7 @@
.ce-code {
display: block;
width: 100%;
min-height: 100px;
border: 1px solid #ebeef3;
border-radius: 3px;
background: #fdfdff !important;
@ -13,6 +15,9 @@
line-height: 1.5em;
color: #325179;
font-size: .8em;
resize: vertical;
outline: none;
}

View file

@ -14,17 +14,32 @@ var code = (function(code_plugin) {
*/
var make_ = function (data) {
var tag = codex.editor.draw.node('CODE', [baseClass], {});
var tag = codex.editor.draw.node('TEXTAREA', [baseClass], {});
if (data && data.text) {
tag.innerHTML = data.text;
tag.value = data.text;
}
tag.contentEditable = true;
return tag;
};
/**
* Escapes HTML chars
*
* @param {string} input
* @return {string} escaped string
*/
var escapeHTML_ = function (input) {
var div = document.createElement('DIV'),
text = document.createTextNode(input);
div.appendChild(text);
return div.innerHTML;
};
/**
* Method to render HTML block from JSON
*/
@ -38,9 +53,12 @@ var code = (function(code_plugin) {
*/
code_plugin.save = function (blockContent) {
var data = {
text : blockContent.innerHTML
};
var escaped = escapeHTML_(blockContent.value),
data = {
text : escaped
};
return data;
};